diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000000..4f29a10053aa --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,29 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.187.0/containers/python-3/.devcontainer/base.Dockerfile + +# [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6 +ARG VARIANT="3.9.0-buster" +FROM python:${VARIANT} + +# [Option] Install Node.js +ARG INSTALL_NODE="true" +ARG NODE_VERSION="lts/*" +RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi + +# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image. +# COPY requirements.txt /tmp/pip-tmp/ +# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ +# && rm -rf /tmp/pip-tmp + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 + + +RUN pip install -U https://github.com/platformio/platformio-core/archive/develop.zip +RUN platformio update +# To get the test platforms +RUN pip install PyYaml +#ENV PATH /code/buildroot/bin/:/code/buildroot/tests/:${PATH} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000000..54627d462b68 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,51 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.187.0/containers/python-3 +{ + "name": "Python 3", + "build": { + "dockerfile": "Dockerfile", + "context": "..", + "args": { + // Update 'VARIANT' to pick a Python version: 3, 3.6, 3.7, 3.8, 3.9 + "VARIANT": "3.9.0-buster", + // Options + "INSTALL_NODE": "false", + "NODE_VERSION": "lts/*" + } + }, + + // Set *default* container specific settings.json values on container create. + "settings": { + "python.pythonPath": "/usr/local/bin/python", + "python.languageServer": "Pylance", + "python.linting.enabled": true, + "python.linting.pylintEnabled": true, + "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", + "python.formatting.blackPath": "/usr/local/py-utils/bin/black", + "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", + "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", + "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", + "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", + "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", + "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", + "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance", + "platformio.platformio-ide", + "marlinfirmware.auto-build", + "editorconfig.editorconfig" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "pip3 install --user -r requirements.txt", + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + // "remoteUser": "vscode" +} 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/.github/contributing.md b/.github/contributing.md index 24b9dbdf8d0d..ef1726366a7d 100644 --- a/.github/contributing.md +++ b/.github/contributing.md @@ -34,8 +34,11 @@ This project and everyone participating in it is governed by the [Marlin Code of We have a Message Board and a Facebook group where our knowledgable user community can provide helpful advice if you have questions. -* [Marlin RepRap forum](https://reprap.org/forum/list.php?415) -* [MarlinFirmware on Facebook](https://www.facebook.com/groups/1049718498464482/) +- [Marlin Documentation](https://marlinfw.org) - Official Marlin documentation +- Facebook Group ["Marlin Firmware"](https://www.facebook.com/groups/1049718498464482/) +- RepRap.org [Marlin Forum](https://forums.reprap.org/list.php?415) +- Facebook Group ["Marlin Firmware for 3D Printers"](https://www.facebook.com/groups/3Dtechtalk/) +- [Marlin Configuration](https://www.youtube.com/results?search_query=marlin+configuration) on YouTube If chat is more your speed, you can join the MarlinFirmware Discord server: @@ -116,7 +119,7 @@ Unsure where to begin contributing to Marlin? You can start by looking through t ### Pull Requests -Pull Requests should always be targeted to working branches (e.g., `bugfix-2.0.x` and/or `bugfix-1.1.x`) and never to release branches (e.g., `2.0.x` and/or `1.1.x`). If this is your first Pull Request, please read our [Guide to Pull Requests](https://marlinfw.org/docs/development/getting_started_pull_requests.html) and Github's [Pull Request](https://help.github.com/articles/creating-a-pull-request/) documentation. +Pull Requests should always be targeted to working branches (e.g., `bugfix-2.1.x` and/or `bugfix-1.1.x`) and never to release branches (e.g., `2.0.x` and/or `1.1.x`). If this is your first Pull Request, please read our [Guide to Pull Requests](https://marlinfw.org/docs/development/getting_started_pull_requests.html) and Github's [Pull Request](https://help.github.com/articles/creating-a-pull-request/) documentation. * Fill in [the required template](pull_request_template.md). * Don't include issue numbers in the PR title. diff --git a/.gitignore b/.gitignore index 0b852d767325..a7f8a091aa4a 100755 --- a/.gitignore +++ b/.gitignore @@ -21,35 +21,18 @@ # Generated files _Version.h -bdf2u8g +bdf2u8g.exe +genpages.exe marlin_config.json mczip.h *.gen *.sublime-workspace -# # OS -# applet/ .DS_Store -# -# Misc -# -*~ -*.orig -*.rej -*.bak -*.idea -*.i -*.ii -*.swp -tags - -# -# C++ -# -# Compiled Object files +# Compiled C++ Object files *.slo *.lo *.o @@ -80,10 +63,7 @@ tags *.out *.app -# -# C -# -# Object files +# Compiled C Object files *.o *.ko *.obj @@ -143,12 +123,13 @@ vc-fileutils.settings .vscode/* !.vscode/extensions.json -#Simulation +# Simulation files imgui.ini eeprom.dat spi_flash.bin +fs.img -#cmake +# CMake CMakeLists.txt src/CMakeLists.txt CMakeListsPrivate.txt @@ -169,3 +150,16 @@ __pycache__ # IOLogger logs *_log.csv + +# Misc. +*~ +*.orig +*.rej +*.bak +*.idea +*.i +*.ii +*.swp +tags +*.logs +*.bak diff --git a/Makefile b/Makefile index ebcdf25e2d6a..2a18c0b4e829 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,16 @@ +SCRIPTS_DIR := buildroot/share/scripts +CONTAINER_RT_BIN := docker +CONTAINER_RT_OPTS := --rm -v $(PWD):/code -v platformio-cache:/root/.platformio +CONTAINER_IMAGE := marlin-dev + help: @echo "Tasks for local development:" @echo "* tests-single-ci: Run a single test from inside the CI" @echo "* tests-single-local: Run a single test locally" - @echo "* tests-single-local-docker: Run a single test locally, using docker-compose" + @echo "* tests-single-local-docker: Run a single test locally, using docker" @echo "* tests-all-local: Run all tests locally" - @echo "* tests-all-local-docker: Run all tests locally, using docker-compose" - @echo "* setup-local-docker: Setup local docker-compose" + @echo "* tests-all-local-docker: Run all tests locally, using docker" + @echo "* setup-local-docker: Build the local docker image" @echo "" @echo "Options for testing:" @echo " TEST_TARGET Set when running tests-single-*, to select the" @@ -27,26 +32,28 @@ 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 tests-single-local-docker: @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET= or use make tests-all-local-docker" ; return 1; fi - docker-compose run --rm marlin $(MAKE) tests-single-local TEST_TARGET=$(TEST_TARGET) VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD) ONLY_TEST="$(ONLY_TEST)" + @if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi + $(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) $(MAKE) tests-single-local TEST_TARGET=$(TEST_TARGET) VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD) ONLY_TEST="$(ONLY_TEST)" .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 + && for TEST_TARGET in $$($(SCRIPTS_DIR)/get_test_targets.py) ; do echo "Running tests for $$TEST_TARGET" ; run_tests . $$TEST_TARGET ; done .PHONY: tests-all-local tests-all-local-docker: - docker-compose run --rm marlin $(MAKE) tests-all-local VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD) + @if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi + $(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) $(MAKE) tests-all-local VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD) .PHONY: tests-all-local-docker setup-local-docker: - docker-compose build + $(CONTAINER_RT_BIN) build -t $(CONTAINER_IMAGE) -f docker/Dockerfile . .PHONY: setup-local-docker diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 24a2f9f6b665..642c0a107059 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -37,7 +37,7 @@ * * Advanced settings can be found in Configuration_adv.h */ -#define CONFIGURATION_H_VERSION 02010000 +#define CONFIGURATION_H_VERSION 02010201 //=========================================================================== //============================= Getting Started ============================= @@ -59,15 +59,6 @@ * https://www.thingiverse.com/thing:1278865 */ -//=========================================================================== -//========================== DELTA / SCARA / TPARA ========================== -//=========================================================================== -// -// Download configurations from the link above and customize for your machine. -// Examples are located in config/examples/delta, .../SCARA, and .../TPARA. -// -//=========================================================================== - // @section info // Author info of this build printed to the host during boot and M115 @@ -131,7 +122,7 @@ * :[-2, -1, 0, 1, 2, 3, 4, 5, 6, 7] */ //#define SERIAL_PORT_2 -1 -//#define BAUDRATE_2 250000 // Enable to override BAUDRATE +//#define BAUDRATE_2 250000 // :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] Enable to override BAUDRATE /** * Select a third serial port on the board to use for communication with the host. @@ -139,7 +130,7 @@ * :[-1, 0, 1, 2, 3, 4, 5, 6, 7] */ //#define SERIAL_PORT_3 1 -//#define BAUDRATE_3 250000 // Enable to override BAUDRATE +//#define BAUDRATE_3 250000 // :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000] Enable to override BAUDRATE // Enable the Bluetooth serial interface on AT90USB devices //#define BLUETOOTH @@ -151,6 +142,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 * @@ -159,13 +152,12 @@ * * Use TMC2208/TMC2208_STANDALONE for TMC2225 drivers and TMC2209/TMC2209_STANDALONE for TMC2226 drivers. * - * Options: A4988, A5984, DRV8825, LV8729, L6470, L6474, POWERSTEP01, - * TB6560, TB6600, TMC2100, + * Options: A4988, A5984, DRV8825, LV8729, TB6560, TB6600, TMC2100, * TMC2130, TMC2130_STANDALONE, TMC2160, TMC2160_STANDALONE, * TMC2208, TMC2208_STANDALONE, TMC2209, TMC2209_STANDALONE, * TMC26X, TMC26X_STANDALONE, TMC2660, TMC2660_STANDALONE, * TMC5130, TMC5130_STANDALONE, TMC5160, TMC5160_STANDALONE - * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'L6474', 'POWERSTEP01', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE'] + * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE'] */ #define X_DRIVER_TYPE A4988 #define Y_DRIVER_TYPE A4988 @@ -251,21 +243,6 @@ //#define SINGLENOZZLE_STANDBY_FAN #endif -/** - * Multi-Material Unit - * Set to one of these predefined models: - * - * PRUSA_MMU1 : Průša MMU1 (The "multiplexer" version) - * PRUSA_MMU2 : Průša MMU2 - * PRUSA_MMU2S : Průša MMU2S (Requires MK3S extruder with motion sensor, EXTRUDERS = 5) - * EXTENDABLE_EMU_MMU2 : MMU with configurable number of filaments (ERCF, SMuFF or similar with Průša MMU2 compatible firmware) - * EXTENDABLE_EMU_MMU2S : MMUS with configurable number of filaments (ERCF, SMuFF or similar with Průša MMU2 compatible firmware) - * - * Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails. - * See additional options in Configuration_adv.h. - */ -//#define MMU_MODEL PRUSA_MMU2 - // A dual extruder that uses a single stepper motor //#define SWITCHING_EXTRUDER #if ENABLED(SWITCHING_EXTRUDER) @@ -282,6 +259,7 @@ #define SWITCHING_NOZZLE_SERVO_NR 0 //#define SWITCHING_NOZZLE_E1_SERVO_NR 1 // If two servos are used, the index of the second #define SWITCHING_NOZZLE_SERVO_ANGLES { 0, 90 } // Angles for E0, E1 (single servo) or lowered/raised (dual servo) + #define SWITCHING_NOZZLE_SERVO_DWELL 2500 // Dwell time to wait for servo to make physical move #endif /** @@ -398,7 +376,25 @@ //#define HOTEND_OFFSET_Y { 0.0, 5.00 } // (mm) relative Y-offset for each nozzle //#define HOTEND_OFFSET_Z { 0.0, 0.00 } // (mm) relative Z-offset for each nozzle -// @section machine +// @section multi-material + +/** + * Multi-Material Unit + * Set to one of these predefined models: + * + * PRUSA_MMU1 : Průša MMU1 (The "multiplexer" version) + * PRUSA_MMU2 : Průša MMU2 + * PRUSA_MMU2S : Průša MMU2S (Requires MK3S extruder with motion sensor, EXTRUDERS = 5) + * EXTENDABLE_EMU_MMU2 : MMU with configurable number of filaments (ERCF, SMuFF or similar with Průša MMU2 compatible firmware) + * EXTENDABLE_EMU_MMU2S : MMUS with configurable number of filaments (ERCF, SMuFF or similar with Průša MMU2 compatible firmware) + * + * 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 + +// @section psu control /** * Power Supply Control @@ -501,7 +497,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 @@ -523,6 +519,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. @@ -560,22 +557,36 @@ #define DUMMY_THERMISTOR_999_VALUE 100 // Resistor values when using MAX31865 sensors (-5) on TEMP_SENSOR_0 / 1 -//#define MAX31865_SENSOR_OHMS_0 100 // (Ω) Typically 100 or 1000 (PT100 or PT1000) -//#define MAX31865_CALIBRATION_OHMS_0 430 // (Ω) Typically 430 for Adafruit PT100; 4300 for Adafruit PT1000 -//#define MAX31865_SENSOR_OHMS_1 100 -//#define MAX31865_CALIBRATION_OHMS_1 430 +#if TEMP_SENSOR_IS_MAX_TC(0) + #define MAX31865_SENSOR_OHMS_0 100 // (Ω) Typically 100 or 1000 (PT100 or PT1000) + #define MAX31865_CALIBRATION_OHMS_0 430 // (Ω) Typically 430 for Adafruit PT100; 4300 for Adafruit PT1000 +#endif +#if TEMP_SENSOR_IS_MAX_TC(1) + #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 -#define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109 -#define TEMP_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer -#define TEMP_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target +#if HAS_E_TEMP_SENSOR + #define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109 + #define TEMP_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer + #define TEMP_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target +#endif -#define TEMP_BED_RESIDENCY_TIME 10 // (seconds) Time to wait for bed to "settle" in M190 -#define TEMP_BED_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer -#define TEMP_BED_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target +#if TEMP_SENSOR_BED + #define TEMP_BED_RESIDENCY_TIME 10 // (seconds) Time to wait for bed to "settle" in M190 + #define TEMP_BED_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer + #define TEMP_BED_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target +#endif -#define TEMP_CHAMBER_RESIDENCY_TIME 10 // (seconds) Time to wait for chamber to "settle" in M191 -#define TEMP_CHAMBER_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer -#define TEMP_CHAMBER_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target +#if TEMP_SENSOR_CHAMBER + #define TEMP_CHAMBER_RESIDENCY_TIME 10 // (seconds) Time to wait for chamber to "settle" in M191 + #define TEMP_CHAMBER_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer + #define TEMP_CHAMBER_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target +#endif /** * Redundant Temperature Sensor (TEMP_SENSOR_REDUNDANT) @@ -634,6 +645,8 @@ //============================= PID Settings ================================ //=========================================================================== +// @section hotend temp + // Enable PIDTEMP for PID control or MPCTEMP for Predictive Model. // temperature control. Disable both for bang-bang heating. #define PIDTEMP // See the PID Tuning Guide at https://reprap.org/wiki/PID_Tuning @@ -644,7 +657,8 @@ #define PID_K1 0.95 // Smoothing factor within any PID loop #if ENABLED(PIDTEMP) - //#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders) + //#define PID_DEBUG // Print PID debug data to the serial port. Use 'M303 D' to toggle activation. + //#define PID_PARAMS_PER_HOTEND // Use separate PID parameters for each extruder (useful for mismatched extruders) // Set/get with G-code: M301 E[extruder number, 0-2] #if ENABLED(PID_PARAMS_PER_HOTEND) @@ -665,7 +679,8 @@ * * Use a physical model of the hotend to control temperature. When configured correctly * this gives better responsiveness and stability than PID and it also removes the need - * for PID_EXTRUSION_SCALING and PID_FAN_SCALING. Use M306 to autotune the model. + * for PID_EXTRUSION_SCALING and PID_FAN_SCALING. Use M306 T to autotune the model. + * @section mpctemp */ #if ENABLED(MPCTEMP) //#define MPC_EDIT_MENU // Add MPC editing to the "Advanced Settings" menu. (~1300 bytes of flash) @@ -718,6 +733,7 @@ * impact FET heating. This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W * heater. If your configuration is significantly different than this and you don't understand * the issues involved, don't use bed PID until someone else verifies that your hardware works. + * @section bed temp */ #define PIDTEMPBED @@ -733,7 +749,7 @@ #if ENABLED(PIDTEMPBED) //#define MIN_BED_POWER 0 - //#define PID_BED_DEBUG // Sends debug data to the serial port. + //#define PID_BED_DEBUG // Print Bed PID debug data to the serial port. // 120V 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) // from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) @@ -761,6 +777,7 @@ * impact FET heating. This also works fine on a Fotek SSR-10DA Solid State Relay into a 200W * heater. If your configuration is significantly different than this and you don't understand * the issues involved, don't use chamber PID until someone else verifies that your hardware works. + * @section chamber temp */ //#define PIDTEMPCHAMBER //#define CHAMBER_LIMIT_SWITCHING @@ -775,7 +792,7 @@ #if ENABLED(PIDTEMPCHAMBER) #define MIN_CHAMBER_POWER 0 - //#define PID_CHAMBER_DEBUG // Sends debug data to the serial port. + //#define PID_CHAMBER_DEBUG // Print Chamber PID debug data to the serial port. // Lasko "MyHeat Personal Heater" (200w) modified with a Fotek SSR-10DA to control only the heating element // and placed inside the small Creality printer enclosure tent. @@ -789,7 +806,6 @@ #endif // PIDTEMPCHAMBER #if ANY(PIDTEMP, PIDTEMPBED, PIDTEMPCHAMBER) - //#define PID_DEBUG // Sends debug data to the serial port. Use 'M303 D' to toggle activation. //#define PID_OPENLOOP // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX //#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature @@ -799,7 +815,7 @@ //#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of flash) #endif -// @section extruder +// @section safety /** * Prevent extrusion if the temperature is below EXTRUDE_MINTEMP. @@ -864,14 +880,155 @@ //#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 + +// Enable for DELTA kinematics and configure below +//#define DELTA +#if ENABLED(DELTA) + + // 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 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 + // Add three-point calibration to the MarlinUI menu. + // See http://minow.blogspot.com/index.html#4918805519571907051 + //#define DELTA_CALIBRATION_MENU + + // G33 Delta Auto-Calibration. Enable EEPROM_SETTINGS to store results. + //#define DELTA_AUTO_CALIBRATION + + #if ENABLED(DELTA_AUTO_CALIBRATION) + // Default number of probe points : n*n (1 -> 7) + #define DELTA_CALIBRATION_DEFAULT_POINTS 4 + #endif + + #if EITHER(DELTA_AUTO_CALIBRATION, DELTA_CALIBRATION_MENU) + // Step size for paper-test probing + #define PROBE_MANUALLY_STEP 0.05 // (mm) + #endif + + // Print surface diameter/2 minus unreachable space (avoid collisions with vertical towers). + #define DELTA_PRINTABLE_RADIUS 140.0 // (mm) + + // Maximum reachable area + #define DELTA_MAX_RADIUS 140.0 // (mm) + + // Center-to-center distance of the holes in the diagonal push rods. + #define DELTA_DIAGONAL_ROD 250.0 // (mm) + + // Distance between bed and nozzle Z home position + #define DELTA_HEIGHT 250.00 // (mm) Get this value from G33 auto calibrate + + #define DELTA_ENDSTOP_ADJ { 0.0, 0.0, 0.0 } // Get these values from G33 auto calibrate + + // Horizontal distance bridged by diagonal push rods when effector is centered. + #define DELTA_RADIUS 124.0 // (mm) Get this value from G33 auto calibrate + + // Trim adjustments for individual towers + // tower angle corrections for X and Y tower / rotate XYZ so Z tower angle = 0 + // measured in degrees anticlockwise looking from above the printer + #define DELTA_TOWER_ANGLE_TRIM { 0.0, 0.0, 0.0 } // Get these values from G33 auto calibrate + + // Delta radius and diagonal rod adjustments (mm) + //#define DELTA_RADIUS_TRIM_TOWER { 0.0, 0.0, 0.0 } + //#define DELTA_DIAGONAL_ROD_TRIM_TOWER { 0.0, 0.0, 0.0 } +#endif + +// @section scara + +/** + * MORGAN_SCARA was developed by QHARLEY in South Africa in 2012-2013. + * Implemented and slightly reworked by JCERNY in June, 2014. + * + * Mostly Printed SCARA is an open source design by Tyler Williams. See: + * https://www.thingiverse.com/thing:2487048 + * https://www.thingiverse.com/thing:1241491 + */ +//#define MORGAN_SCARA +//#define MP_SCARA +#if EITHER(MORGAN_SCARA, MP_SCARA) + // If movement is choppy try lowering this value + #define DEFAULT_SEGMENTS_PER_SECOND 200 + + // Length of inner and outer support arms. Measure arm lengths precisely. + #define SCARA_LINKAGE_1 150 // (mm) + #define SCARA_LINKAGE_2 150 // (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 SCARA_OFFSET_X 100 // (mm) + #define SCARA_OFFSET_Y -56 // (mm) + + #if ENABLED(MORGAN_SCARA) + + //#define DEBUG_SCARA_KINEMATICS + #define SCARA_FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly + + // Radius around the center where the arm cannot reach + #define MIDDLE_DEAD_ZONE_R 0 // (mm) + + #define THETA_HOMING_OFFSET 0 // Calculated from Calibration Guide and M360 / M114. See http://reprap.harleystudio.co.za/?page_id=1073 + #define PSI_HOMING_OFFSET 0 // Calculated from Calibration Guide and M364 / M114. See http://reprap.harleystudio.co.za/?page_id=1073 + + #elif ENABLED(MP_SCARA) + + #define SCARA_OFFSET_THETA1 12 // degrees + #define SCARA_OFFSET_THETA2 131 // degrees + + #endif + +#endif + +// @section tpara + +// Enable for TPARA kinematics and configure below +//#define AXEL_TPARA +#if ENABLED(AXEL_TPARA) + #define DEBUG_TPARA_KINEMATICS + #define DEFAULT_SEGMENTS_PER_SECOND 200 + + // Length of inner and outer support arms. Measure arm lengths precisely. + #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 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 + + // Radius around the center where the arm cannot reach + #define MIDDLE_DEAD_ZONE_R 0 // (mm) + + // Calculated from Calibration Guide and M360 / M114. See http://reprap.harleystudio.co.za/?page_id=1073 + #define THETA_HOMING_OFFSET 0 + #define PSI_HOMING_OFFSET 0 +#endif + +// @section machine + +// Articulated robot (arm). Joints are directly mapped to axes with no kinematics. +//#define ARTICULATED_ROBOT_ARM + +// For a hot wire cutter with parallel horizontal axes (X, I) where the heights of the two wire +// ends are controlled by parallel axes (Y, J). Joints are directly mapped to axes (no kinematics). +//#define FOAMCUTTER_XYUV + //=========================================================================== //============================== Endstop Settings =========================== //=========================================================================== -// @section homing +// @section endstops // Specify here all the endstop connectors that are connected to any endstop or probe. // Almost all printers will be using one per axis. Probes will use one or more of the @@ -1219,6 +1376,27 @@ #define Z_PROBE_RETRACT_X X_MAX_POS #endif +/** + * Magnetically Mounted Probe + * For probes such as Euclid, Klicky, Klackender, etc. + */ +//#define MAG_MOUNTED_PROBE +#if ENABLED(MAG_MOUNTED_PROBE) + #define PROBE_DEPLOY_FEEDRATE (133*60) // (mm/min) Probe deploy speed + #define PROBE_STOW_FEEDRATE (133*60) // (mm/min) Probe stow speed + + #define MAG_MOUNTED_DEPLOY_1 { PROBE_DEPLOY_FEEDRATE, { 245, 114, 30 } } // Move to side Dock & Attach probe + #define MAG_MOUNTED_DEPLOY_2 { PROBE_DEPLOY_FEEDRATE, { 210, 114, 30 } } // Move probe off dock + #define MAG_MOUNTED_DEPLOY_3 { PROBE_DEPLOY_FEEDRATE, { 0, 0, 0 } } // Extra move if needed + #define MAG_MOUNTED_DEPLOY_4 { PROBE_DEPLOY_FEEDRATE, { 0, 0, 0 } } // Extra move if needed + #define MAG_MOUNTED_DEPLOY_5 { PROBE_DEPLOY_FEEDRATE, { 0, 0, 0 } } // Extra move if needed + #define MAG_MOUNTED_STOW_1 { PROBE_STOW_FEEDRATE, { 245, 114, 20 } } // Move to dock + #define MAG_MOUNTED_STOW_2 { PROBE_STOW_FEEDRATE, { 245, 114, 0 } } // Place probe beside remover + #define MAG_MOUNTED_STOW_3 { PROBE_STOW_FEEDRATE, { 230, 114, 0 } } // Side move to remove probe + #define MAG_MOUNTED_STOW_4 { PROBE_STOW_FEEDRATE, { 210, 114, 20 } } // Side move to remove probe + #define MAG_MOUNTED_STOW_5 { PROBE_STOW_FEEDRATE, { 0, 0, 0 } } // Extra move if needed +#endif + // Duet Smart Effector (for delta printers) - https://bit.ly/2ul5U7J // When the pin is defined you can use M672 to set/reset the probe sensitivity. //#define DUET_SMART_EFFECTOR @@ -1234,9 +1412,37 @@ */ //#define SENSORLESS_PROBING -// -// For Z_PROBE_ALLEN_KEY see the Delta example configurations. -// +/** + * Allen key retractable z-probe as seen on many Kossel delta printers - https://reprap.org/wiki/Kossel#Automatic_bed_leveling_probe + * Deploys by touching z-axis belt. Retracts by pushing the probe down. + */ +//#define Z_PROBE_ALLEN_KEY +#if ENABLED(Z_PROBE_ALLEN_KEY) + // 2 or 3 sets of coordinates for deploying and retracting the spring loaded touch probe on G29, + // if servo actuated touch probe is not defined. Uncomment as appropriate for your printer/probe. + + #define Z_PROBE_ALLEN_KEY_DEPLOY_1 { 30.0, DELTA_PRINTABLE_RADIUS, 100.0 } + #define Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE XY_PROBE_FEEDRATE + + #define Z_PROBE_ALLEN_KEY_DEPLOY_2 { 0.0, DELTA_PRINTABLE_RADIUS, 100.0 } + #define Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE (XY_PROBE_FEEDRATE)/10 + + #define Z_PROBE_ALLEN_KEY_DEPLOY_3 { 0.0, (DELTA_PRINTABLE_RADIUS) * 0.75, 100.0 } + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE XY_PROBE_FEEDRATE + + #define Z_PROBE_ALLEN_KEY_STOW_1 { -64.0, 56.0, 23.0 } // Move the probe into position + #define Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE XY_PROBE_FEEDRATE + + #define Z_PROBE_ALLEN_KEY_STOW_2 { -64.0, 56.0, 3.0 } // Push it down + #define Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE (XY_PROBE_FEEDRATE)/10 + + #define Z_PROBE_ALLEN_KEY_STOW_3 { -64.0, 56.0, 50.0 } // Move it up to clear + #define Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE XY_PROBE_FEEDRATE + + #define Z_PROBE_ALLEN_KEY_STOW_4 { 0.0, 0.0, 50.0 } + #define Z_PROBE_ALLEN_KEY_STOW_4_FEEDRATE XY_PROBE_FEEDRATE + +#endif // Z_PROBE_ALLEN_KEY /** * Nozzle-to-Probe offsets { X, Y, Z } @@ -1432,7 +1638,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 @@ -1486,7 +1692,7 @@ //#define V_HOME_DIR -1 //#define W_HOME_DIR -1 -// @section machine +// @section geometry // The size of the printable area #define X_BED_SIZE 296 // Nozzle is at X4 when homed @@ -1690,6 +1896,15 @@ #define LEVELING_BED_TEMP 50 #endif +/** + * Bed Distance Sensor + * + * Measures the distance from bed to nozzle with accuracy of 0.01mm. + * For information about this sensor https://github.com/markniu/Bed_Distance_sensor + * Uses I2C port, so it requires I2C library markyue/Panda_SoftMasterI2C. + */ +//#define BD_SENSOR + /** * Enable detailed logging of G28, G29, M48, etc. * Turn on with the command 'M111 S32'. @@ -1703,17 +1918,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) @@ -1924,9 +2143,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) @@ -1935,8 +2153,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 @@ -1947,7 +2167,7 @@ //============================= Additional Features =========================== //============================================================================= -// @section extras +// @section eeprom /** * EEPROM @@ -1967,6 +2187,8 @@ //#define EEPROM_INIT_NOW // Init EEPROM on first boot after a new build. #endif +// @section host + // // Host Keepalive // @@ -1977,6 +2199,8 @@ #define DEFAULT_KEEPALIVE_INTERVAL 2 // Number of seconds between "busy" messages. Set with M113. #define BUSY_WHILE_HEATING // Some hosts require "busy" messages even during heating +// @section units + // // G20/G21 Inch mode support // @@ -1990,7 +2214,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 205 @@ -2004,6 +2228,8 @@ //#define PREHEAT_2_TEMP_CHAMBER 35 //#define PREHEAT_2_FAN_SPEED 0 // Value from 0 to 255 +// @section motion + /** * Nozzle Park * @@ -2102,6 +2328,8 @@ #endif +// @section host + /** * Print Job Timer * @@ -2128,6 +2356,8 @@ */ #define PRINTJOB_TIMER_AUTOSTART +// @section stats + /** * Print Counter * @@ -2142,9 +2372,11 @@ */ //#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 + /** * Password * @@ -2180,7 +2412,7 @@ //============================= LCD and SD support ============================ //============================================================================= -// @section lcd +// @section interface /** * LCD LANGUAGE @@ -2296,6 +2528,16 @@ // //#define REVERSE_SELECT_DIRECTION +// +// Encoder EMI Noise Filter +// +// This option increases encoder samples to filter out phantom encoder clicks caused by EMI noise. +// +//#define ENCODER_NOISE_FILTER +#if ENABLED(ENCODER_NOISE_FILTER) + #define ENCODER_SAMPLES 10 +#endif + // // Individual Axis Homing // @@ -2326,6 +2568,7 @@ //======================== LCD / Controller Selection ========================= //======================== (Character-based LCDs) ========================= //============================================================================= +// @section lcd // // RepRapDiscount Smart Controller. @@ -2412,7 +2655,7 @@ // // Elefu RA Board Control Panel -// http://www.elefu.com/index.php?route=product/product&product_id=53 +// https://web.archive.org/web/20140823033947/http://www.elefu.com/index.php?route=product/product&product_id=53 // //#define RA_CONTROL_PANEL @@ -2500,7 +2743,7 @@ // // ReprapWorld Graphical LCD -// https://reprapworld.com/?products_details&products_id/1218 +// https://reprapworld.com/electronics/3d-printer-modules/autonomous-printing/graphical-lcd-screen-v1-0/ // //#define REPRAPWORLD_GRAPHICAL_LCD @@ -2627,6 +2870,12 @@ // //#define SILVER_GATE_GLCD_CONTROLLER +// +// eMotion Tech LCD with SD +// https://www.reprap-france.com/produit/1234568748-ecran-graphique-128-x-64-points-2-1 +// +//#define EMOTION_TECH_LCD + //============================================================================= //============================== OLED Displays ============================== //============================================================================= @@ -2749,6 +2998,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 // @@ -2817,7 +3067,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 @@ -2884,6 +3134,10 @@ //#define TFT_COLOR_UI //#define TFT_LVGL_UI +#if ENABLED(TFT_COLOR_UI) + //#define TFT_SHARED_SPI // SPI is shared between TFT display and other devices. Disable async data transfer +#endif + #if ENABLED(TFT_LVGL_UI) //#define MKS_WIFI_MODULE // MKS WiFi module #endif @@ -2916,10 +3170,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 @@ -2954,7 +3209,7 @@ //=============================== Extra Features ============================== //============================================================================= -// @section extras +// @section fans // Set number of user-controlled fans. Disable to use all board-defined fans. // :[1,2,3,4,5,6,7,8] @@ -2978,14 +3233,18 @@ // duty cycle is attained. //#define SOFT_PWM_DITHER +// @section extras + +// Support for the BariCUDA Paste Extruder +//#define BARICUDA + +// @section lights + // Temperature status LEDs that display the hotend and bed temperature. // If all hotends, bed temperature, and target temperature are under 54C // then the BLUE led is on. Otherwise the RED led is on. (1C hysteresis) //#define TEMP_STAT_LEDS -// Support for the BariCUDA Paste Extruder -//#define BARICUDA - // Support for BlinkM/CyzRgb //#define BLINKM @@ -3006,16 +3265,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 @@ -3024,6 +3286,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 @@ -3045,6 +3311,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 @@ -3071,6 +3338,8 @@ #define PRINTER_EVENT_LEDS #endif +// @section servos + /** * Number of servos * diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index a27490ad592c..7471d4901260 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -32,7 +32,25 @@ * * Basic settings can be found in Configuration.h */ -#define CONFIGURATION_ADV_H_VERSION 02010000 +#define CONFIGURATION_ADV_H_VERSION 02010201 + +// @section develop + +/** + * Configuration Export + * + * Export the configuration as part of the build. (See signature.py) + * Output files are saved with the build (e.g., .pio/build/mega2560). + * + * See `build_all_examples --ini` as an example of config.ini archiving. + * + * 1 = marlin_config.json - Dictionary containing the configuration. + * This file is also generated for CONFIGURATION_EMBEDDING. + * 2 = config.ini - File format for PlatformIO preprocessing. + * 3 = schema.json - The entire configuration schema. (13 = pattern groups) + * 4 = schema.yml - The entire configuration schema. + */ +//#define CONFIG_EXPORT 2 // :[1:'JSON', 2:'config.ini', 3:'schema.json', 4:'schema.yml'] //=========================================================================== //============================= Thermal Settings ============================ @@ -56,87 +74,101 @@ // Custom Thermistor 1000 parameters // #if TEMP_SENSOR_0 == 1000 - #define HOTEND0_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define HOTEND0_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define HOTEND0_BETA 3950 // Beta value + #define HOTEND0_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define HOTEND0_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define HOTEND0_BETA 3950 // Beta value + #define HOTEND0_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_1 == 1000 - #define HOTEND1_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define HOTEND1_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define HOTEND1_BETA 3950 // Beta value + #define HOTEND1_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define HOTEND1_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define HOTEND1_BETA 3950 // Beta value + #define HOTEND1_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_2 == 1000 - #define HOTEND2_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define HOTEND2_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define HOTEND2_BETA 3950 // Beta value + #define HOTEND2_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define HOTEND2_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define HOTEND2_BETA 3950 // Beta value + #define HOTEND2_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_3 == 1000 - #define HOTEND3_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define HOTEND3_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define HOTEND3_BETA 3950 // Beta value + #define HOTEND3_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define HOTEND3_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define HOTEND3_BETA 3950 // Beta value + #define HOTEND3_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_4 == 1000 - #define HOTEND4_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define HOTEND4_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define HOTEND4_BETA 3950 // Beta value + #define HOTEND4_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define HOTEND4_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define HOTEND4_BETA 3950 // Beta value + #define HOTEND4_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_5 == 1000 - #define HOTEND5_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define HOTEND5_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define HOTEND5_BETA 3950 // Beta value + #define HOTEND5_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define HOTEND5_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define HOTEND5_BETA 3950 // Beta value + #define HOTEND5_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_6 == 1000 - #define HOTEND6_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define HOTEND6_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define HOTEND6_BETA 3950 // Beta value + #define HOTEND6_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define HOTEND6_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define HOTEND6_BETA 3950 // Beta value + #define HOTEND6_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_7 == 1000 - #define HOTEND7_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define HOTEND7_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define HOTEND7_BETA 3950 // Beta value + #define HOTEND7_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define HOTEND7_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define HOTEND7_BETA 3950 // Beta value + #define HOTEND7_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_BED == 1000 - #define BED_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define BED_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define BED_BETA 3950 // Beta value + #define BED_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define BED_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define BED_BETA 3950 // Beta value + #define BED_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_CHAMBER == 1000 - #define CHAMBER_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define CHAMBER_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define CHAMBER_BETA 3950 // Beta value + #define CHAMBER_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define CHAMBER_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define CHAMBER_BETA 3950 // Beta value + #define CHAMBER_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_COOLER == 1000 - #define COOLER_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define COOLER_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define COOLER_BETA 3950 // Beta value + #define COOLER_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define COOLER_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define COOLER_BETA 3950 // Beta value + #define COOLER_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_PROBE == 1000 - #define PROBE_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define PROBE_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define PROBE_BETA 3950 // Beta value + #define PROBE_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define PROBE_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define PROBE_BETA 3950 // Beta value + #define PROBE_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_BOARD == 1000 - #define BOARD_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define BOARD_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define BOARD_BETA 3950 // Beta value + #define BOARD_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define BOARD_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define BOARD_BETA 3950 // Beta value + #define BOARD_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif #if TEMP_SENSOR_REDUNDANT == 1000 - #define REDUNDANT_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor - #define REDUNDANT_RESISTANCE_25C_OHMS 100000 // Resistance at 25C - #define REDUNDANT_BETA 3950 // Beta value + #define REDUNDANT_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor + #define REDUNDANT_RESISTANCE_25C_OHMS 100000 // Resistance at 25C + #define REDUNDANT_BETA 3950 // Beta value + #define REDUNDANT_SH_C_COEFF 0 // Steinhart-Hart C coefficient #endif /** @@ -145,6 +177,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. @@ -155,6 +188,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. @@ -288,7 +322,7 @@ * and/or decrease WATCH_TEMP_INCREASE. WATCH_TEMP_INCREASE should not be set * below 2. */ - #define WATCH_TEMP_PERIOD 20 // Seconds + #define WATCH_TEMP_PERIOD 40 // Seconds #define WATCH_TEMP_INCREASE 2 // Degrees Celsius #endif @@ -437,10 +471,10 @@ * Thermistors able to support high temperature tend to have a hard time getting * good readings at room and lower temperatures. This means TEMP_SENSOR_X_RAW_LO_TEMP * will probably be caught when the heating element first turns on during the - * preheating process, which will trigger a min_temp_error as a safety measure + * preheating process, which will trigger a MINTEMP error as a safety measure * and force stop everything. * To circumvent this limitation, we allow for a preheat time (during which, - * min_temp_error won't be triggered) and add a min_temp buffer to handle + * MINTEMP error won't be triggered) and add a min_temp buffer to handle * aberrant readings. * * If you want to enable this feature for your hotend thermistor(s) @@ -448,21 +482,25 @@ */ // The number of consecutive low temperature errors that can occur -// before a min_temp_error is triggered. (Shouldn't be more than 10.) +// before a MINTEMP 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 @@ -502,6 +540,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.) @@ -518,10 +557,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 @@ -798,20 +841,20 @@ //#define Z_MULTI_ENDSTOPS // Other Z axes have their own endstops #if ENABLED(Z_MULTI_ENDSTOPS) #define Z2_USE_ENDSTOP _XMAX_ // Z2 endstop board plug. Don't forget to enable USE_*_PLUG. - #define Z2_ENDSTOP_ADJUSTMENT 0 // Z2 offset relative to Y endstop + #define Z2_ENDSTOP_ADJUSTMENT 0 // Z2 offset relative to Z endstop #endif #ifdef Z3_DRIVER_TYPE //#define INVERT_Z3_VS_Z_DIR // Z3 direction signal is the opposite of Z #if ENABLED(Z_MULTI_ENDSTOPS) #define Z3_USE_ENDSTOP _YMAX_ // Z3 endstop board plug. Don't forget to enable USE_*_PLUG. - #define Z3_ENDSTOP_ADJUSTMENT 0 // Z3 offset relative to Y endstop + #define Z3_ENDSTOP_ADJUSTMENT 0 // Z3 offset relative to Z endstop #endif #endif #ifdef Z4_DRIVER_TYPE //#define INVERT_Z4_VS_Z_DIR // Z4 direction signal is the opposite of Z #if ENABLED(Z_MULTI_ENDSTOPS) #define Z4_USE_ENDSTOP _ZMAX_ // Z4 endstop board plug. Don't forget to enable USE_*_PLUG. - #define Z4_ENDSTOP_ADJUSTMENT 0 // Z4 offset relative to Y endstop + #define Z4_ENDSTOP_ADJUSTMENT 0 // Z4 offset relative to Z endstop #endif #endif #endif @@ -840,6 +883,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 @@ -925,9 +969,12 @@ */ #define Z_STEPPER_AUTO_ALIGN #if ENABLED(Z_STEPPER_AUTO_ALIGN) - // Define probe X and Y positions for Z1, Z2 [, Z3 [, Z4]] - // If not defined, probe limits will be used. - // Override with 'M422 S X Y' + /** + * Define probe X and Y positions for Z1, Z2 [, Z3 [, Z4]] + * These positions are machine-relative and do not shift with the M206 home offset! + * If not defined, probe limits will be used. + * Override with 'M422 S X Y'. + */ #define Z_STEPPER_ALIGN_XY { { 50, 150 }, { 250, 150 } } /** @@ -1013,6 +1060,43 @@ // @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. 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: + * + * 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_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_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 } // Add a Duplicate option for well-separated conjoined nozzles @@ -1114,7 +1198,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. @@ -1288,7 +1372,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 @@ -1321,6 +1405,9 @@ #define XATC_Y_POSITION Y_CENTER // (mm) Y position to probe #define XATC_Z_OFFSETS { 0, 0, 0 } // Z offsets for X axis sample points #endif + + // Show Deploy / Stow Probe options in the Motion menu. + #define PROBE_DEPLOY_STOW_MENU #endif // Include a page of printer information in the LCD Main Menu @@ -1362,9 +1449,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 @@ -1385,37 +1469,45 @@ //#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 '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 + #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 + //#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 +#endif - #if EITHER(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI) - //#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits +// 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) //#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 @@ -1542,6 +1634,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 @@ -1553,6 +1646,9 @@ * Endstops must be activated for this option to work. */ //#define SD_ABORT_ON_ENDSTOP_HIT + #if ENABLED(SD_ABORT_ON_ENDSTOP_HIT) + //#define SD_ABORT_ON_ENDSTOP_HIT_GCODE "G28XY" // G-code to run on endstop hit (e.g., "G28XY" or "G27") + #endif //#define SD_REPRINT_LAST_SELECTED_FILE // On print completion open the LCD Menu and select the same file @@ -1587,6 +1683,8 @@ //#define USE_UHS2_USB //#define USE_UHS3_USB + #define DISABLE_DUE_SD_MMC // Disable USB Host access to USB Drive to prevent hangs on block access for DUE platform + /** * Native USB Host supported by some boards (USB OTG) */ @@ -1698,7 +1796,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 @@ -1752,14 +1850,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 // @@ -2017,11 +2109,16 @@ */ //#define LIN_ADVANCE #if ENABLED(LIN_ADVANCE) - //#define EXTRA_LIN_ADVANCE_K // Enable for second linear advance constants - #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 ALLOW_LOW_EJERK // Allow a DEFAULT_EJERK value of <10. Recommended for direct drive hotends. + #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 @@ -2479,7 +2576,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 @@ -2525,6 +2622,8 @@ #endif #endif // HAS_MULTI_EXTRUDER +// @section advanced pause + /** * Advanced Pause for Filament Change * - Adds the G-code M600 Filament Change to initiate a filament change. @@ -2583,169 +2682,33 @@ //#define FILAMENT_UNLOAD_ALL_EXTRUDERS // Allow M702 to unload all extruders above a minimum target temp (as set by M302) #endif -// @section tmc - -/** - * TMC26X Stepper Driver options - * - * The TMC26XStepper library is required for this stepper driver. - * https://github.com/trinamic/TMC26XStepper - */ -#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 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 * - * 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. + * 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 @@ -2755,17 +2718,17 @@ */ #define INTERPOLATE true - #if AXIS_IS_TMC(X) - #define X_CURRENT 650 // (mA) RMS current. Multiply by 1.414 for peak current. + #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 @@ -2775,8 +2738,8 @@ //#define X2_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Y) - #define Y_CURRENT 650 + #if AXIS_IS_TMC_CONFIG(Y) + #define Y_CURRENT 800 #define Y_CURRENT_HOME Y_CURRENT #define Y_MICROSTEPS 16 #define Y_RSENSE 0.11 @@ -2785,7 +2748,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 @@ -2795,8 +2758,8 @@ //#define Y2_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Z) - #define Z_CURRENT 580 + #if AXIS_IS_TMC_CONFIG(Z) + #define Z_CURRENT 800 #define Z_CURRENT_HOME Z_CURRENT #define Z_MICROSTEPS 16 #define Z_RSENSE 0.11 @@ -2805,7 +2768,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 @@ -2815,7 +2778,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 @@ -2825,7 +2788,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 @@ -2835,7 +2798,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 @@ -2845,7 +2808,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 @@ -2855,7 +2818,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 @@ -2865,7 +2828,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 @@ -2875,7 +2838,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 @@ -2885,7 +2848,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 @@ -2895,8 +2858,8 @@ //#define W_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E0) - #define E0_CURRENT 650 + #if AXIS_IS_TMC_CONFIG(E0) + #define E0_CURRENT 800 #define E0_MICROSTEPS 16 #define E0_RSENSE 0.11 #define E0_CHAIN_POS -1 @@ -2904,7 +2867,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 @@ -2913,7 +2876,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 @@ -2922,7 +2885,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 @@ -2931,7 +2894,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 @@ -2940,7 +2903,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 @@ -2949,7 +2912,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 @@ -2958,7 +2921,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 @@ -2967,6 +2930,8 @@ //#define E7_HOLD_MULTIPLIER 0.5 #endif + // @section tmc/spi + /** * Override default SPI pins for TMC2130, TMC2160, TMC2660, TMC5130 and TMC5160 drivers here. * The default pins can be found in your board's pins file. @@ -3004,6 +2969,8 @@ //#define TMC_SW_MISO -1 //#define TMC_SW_SCK -1 + // @section tmc/serial + /** * Four TMC2209 drivers can use the same HW/SW serial port with hardware configured addresses. * Set the address using jumpers on pins MS1 and MS2. @@ -3039,6 +3006,8 @@ //#define E6_SLAVE_ADDRESS 0 //#define E7_SLAVE_ADDRESS 0 + // @section tmc/smart + /** * Software enable * @@ -3047,20 +3016,24 @@ */ //#define SOFTWARE_DRIVER_ENABLE + // @section tmc/stealthchop + /** * TMC2130, TMC2160, TMC2208, TMC2209, TMC5130 and TMC5160 only * 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 @@ -3101,6 +3074,8 @@ //#define CHOPPER_TIMING_E6 CHOPPER_TIMING_E //#define CHOPPER_TIMING_E7 CHOPPER_TIMING_E + // @section tmc/status + /** * Monitor Trinamic drivers * for error conditions like overtemperature and short to ground. @@ -3120,6 +3095,8 @@ #define STOP_ON_ERROR #endif + // @section tmc/hybrid + /** * TMC2130, TMC2160, TMC2208, TMC2209, TMC5130 and TMC5160 only * The driver will switch to spreadCycle when stepper speed is over HYBRID_THRESHOLD. @@ -3176,6 +3153,7 @@ * homing and adds a guard period for endstop triggering. * * Comment *_STALL_SENSITIVITY to disable sensorless homing for that axis. + * @section tmc/stallguard */ //#define SENSORLESS_HOMING // StallGuard capable drivers only @@ -3199,6 +3177,8 @@ //#define IMPROVE_HOMING_RELIABILITY #endif + // @section tmc/config + /** * TMC Homing stepper phase. * @@ -3236,255 +3216,7 @@ */ #define TMC_ADV() { } -#endif // HAS_TRINAMIC_CONFIG - -// @section L64XX - -/** - * L64XX Stepper Driver options - * - * Arduino-L6470 library (0.8.0 or higher) is required. - * https://github.com/ameyer/Arduino-L6470 - * - * Requires the following to be defined in your pins_YOUR_BOARD file - * L6470_CHAIN_SCK_PIN - * L6470_CHAIN_MISO_PIN - * L6470_CHAIN_MOSI_PIN - * L6470_CHAIN_SS_PIN - * ENABLE_RESET_L64XX_CHIPS(Q) where Q is 1 to enable and 0 to reset - */ - -#if HAS_L64XX - - //#define L6470_CHITCHAT // Display additional status info - - #if AXIS_IS_L64XX(X) - #define X_MICROSTEPS 128 // Number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128) - L6474 max is 16 - #define X_OVERCURRENT 2000 // (mA) Current where the driver detects an over current - // L6470 & L6474 - VALID: 375 x (1 - 16) - 6A max - rounds down - // POWERSTEP01: VALID: 1000 x (1 - 32) - 32A max - rounds down - #define X_STALLCURRENT 1500 // (mA) Current where the driver detects a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) - // L6470 & L6474 - VALID: 31.25 * (1-128) - 4A max - rounds down - // POWERSTEP01: VALID: 200 x (1 - 32) - 6.4A max - rounds down - // L6474 - STALLCURRENT setting is used to set the nominal (TVAL) current - #define X_MAX_VOLTAGE 127 // 0-255, Maximum effective voltage seen by stepper - not used by L6474 - #define X_CHAIN_POS -1 // Position in SPI chain, 0=Not in chain, 1=Nearest MOSI - #define X_SLEW_RATE 1 // 0-3, Slew 0 is slowest, 3 is fastest - #endif - - #if AXIS_IS_L64XX(X2) - #define X2_MICROSTEPS X_MICROSTEPS - #define X2_OVERCURRENT 2000 - #define X2_STALLCURRENT 1500 - #define X2_MAX_VOLTAGE 127 - #define X2_CHAIN_POS -1 - #define X2_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Y) - #define Y_MICROSTEPS 128 - #define Y_OVERCURRENT 2000 - #define Y_STALLCURRENT 1500 - #define Y_MAX_VOLTAGE 127 - #define Y_CHAIN_POS -1 - #define Y_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Y2) - #define Y2_MICROSTEPS Y_MICROSTEPS - #define Y2_OVERCURRENT 2000 - #define Y2_STALLCURRENT 1500 - #define Y2_MAX_VOLTAGE 127 - #define Y2_CHAIN_POS -1 - #define Y2_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Z) - #define Z_MICROSTEPS 128 - #define Z_OVERCURRENT 2000 - #define Z_STALLCURRENT 1500 - #define Z_MAX_VOLTAGE 127 - #define Z_CHAIN_POS -1 - #define Z_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Z2) - #define Z2_MICROSTEPS Z_MICROSTEPS - #define Z2_OVERCURRENT 2000 - #define Z2_STALLCURRENT 1500 - #define Z2_MAX_VOLTAGE 127 - #define Z2_CHAIN_POS -1 - #define Z2_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Z3) - #define Z3_MICROSTEPS Z_MICROSTEPS - #define Z3_OVERCURRENT 2000 - #define Z3_STALLCURRENT 1500 - #define Z3_MAX_VOLTAGE 127 - #define Z3_CHAIN_POS -1 - #define Z3_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(Z4) - #define Z4_MICROSTEPS Z_MICROSTEPS - #define Z4_OVERCURRENT 2000 - #define Z4_STALLCURRENT 1500 - #define Z4_MAX_VOLTAGE 127 - #define Z4_CHAIN_POS -1 - #define Z4_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(I) - #define I_MICROSTEPS 128 - #define I_OVERCURRENT 2000 - #define I_STALLCURRENT 1500 - #define I_MAX_VOLTAGE 127 - #define I_CHAIN_POS -1 - #define I_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(J) - #define J_MICROSTEPS 128 - #define J_OVERCURRENT 2000 - #define J_STALLCURRENT 1500 - #define J_MAX_VOLTAGE 127 - #define J_CHAIN_POS -1 - #define J_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(K) - #define K_MICROSTEPS 128 - #define K_OVERCURRENT 2000 - #define K_STALLCURRENT 1500 - #define K_MAX_VOLTAGE 127 - #define K_CHAIN_POS -1 - #define K_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(U) - #define U_MICROSTEPS 128 - #define U_OVERCURRENT 2000 - #define U_STALLCURRENT 1500 - #define U_MAX_VOLTAGE 127 - #define U_CHAIN_POS -1 - #define U_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(V) - #define V_MICROSTEPS 128 - #define V_OVERCURRENT 2000 - #define V_STALLCURRENT 1500 - #define V_MAX_VOLTAGE 127 - #define V_CHAIN_POS -1 - #define V_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(W) - #define W_MICROSTEPS 128 - #define W_OVERCURRENT 2000 - #define W_STALLCURRENT 1500 - #define W_MAX_VOLTAGE 127 - #define W_CHAIN_POS -1 - #define W_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E0) - #define E0_MICROSTEPS 128 - #define E0_OVERCURRENT 2000 - #define E0_STALLCURRENT 1500 - #define E0_MAX_VOLTAGE 127 - #define E0_CHAIN_POS -1 - #define E0_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E1) - #define E1_MICROSTEPS E0_MICROSTEPS - #define E1_OVERCURRENT 2000 - #define E1_STALLCURRENT 1500 - #define E1_MAX_VOLTAGE 127 - #define E1_CHAIN_POS -1 - #define E1_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E2) - #define E2_MICROSTEPS E0_MICROSTEPS - #define E2_OVERCURRENT 2000 - #define E2_STALLCURRENT 1500 - #define E2_MAX_VOLTAGE 127 - #define E2_CHAIN_POS -1 - #define E2_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E3) - #define E3_MICROSTEPS E0_MICROSTEPS - #define E3_OVERCURRENT 2000 - #define E3_STALLCURRENT 1500 - #define E3_MAX_VOLTAGE 127 - #define E3_CHAIN_POS -1 - #define E3_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E4) - #define E4_MICROSTEPS E0_MICROSTEPS - #define E4_OVERCURRENT 2000 - #define E4_STALLCURRENT 1500 - #define E4_MAX_VOLTAGE 127 - #define E4_CHAIN_POS -1 - #define E4_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E5) - #define E5_MICROSTEPS E0_MICROSTEPS - #define E5_OVERCURRENT 2000 - #define E5_STALLCURRENT 1500 - #define E5_MAX_VOLTAGE 127 - #define E5_CHAIN_POS -1 - #define E5_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E6) - #define E6_MICROSTEPS E0_MICROSTEPS - #define E6_OVERCURRENT 2000 - #define E6_STALLCURRENT 1500 - #define E6_MAX_VOLTAGE 127 - #define E6_CHAIN_POS -1 - #define E6_SLEW_RATE 1 - #endif - - #if AXIS_IS_L64XX(E7) - #define E7_MICROSTEPS E0_MICROSTEPS - #define E7_OVERCURRENT 2000 - #define E7_STALLCURRENT 1500 - #define E7_MAX_VOLTAGE 127 - #define E7_CHAIN_POS -1 - #define E7_SLEW_RATE 1 - #endif - - /** - * Monitor L6470 drivers for error conditions like over temperature and over current. - * In the case of over temperature Marlin can decrease the drive until the error condition clears. - * Other detected conditions can be used to stop the current print. - * Relevant G-codes: - * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. - * I not present or I0 or I1 - X, Y, Z or E0 - * I2 - X2, Y2, Z2 or E1 - * I3 - Z3 or E3 - * I4 - Z4 or E4 - * I5 - E5 - * M916 - Increase drive level until get thermal warning - * M917 - Find minimum current thresholds - * M918 - Increase speed until max or error - * M122 S0/1 - Report driver parameters - */ - //#define MONITOR_L6470_DRIVER_STATUS - - #if ENABLED(MONITOR_L6470_DRIVER_STATUS) - #define KVAL_HOLD_STEP_DOWN 1 - //#define L6470_STOP_ON_ERROR - #endif - -#endif // HAS_L64XX +#endif // HAS_TRINAMIC_CONFIG || HAS_TMC26X // @section i2cbus @@ -3527,7 +3259,7 @@ #define I2C_SLAVE_ADDRESS 0 // Set a value from 8 to 127 to act as a slave #endif -// @section extras +// @section photo /** * Photo G-code @@ -3570,6 +3302,8 @@ #endif #endif +// @section cnc + /** * Spindle & Laser control * @@ -3594,6 +3328,9 @@ #if ENABLED(SPINDLE_LASER_USE_PWM) #define SPINDLE_LASER_PWM_INVERT false // Set to "true" if the speed/power goes up when you want it to go slower #define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR, ESP32, and LPC) + // ESP32: If SPINDLE_LASER_PWM_PIN is onboard then <=78125Hz. For I2S expander + // the frequency determines the PWM resolution. 2500Hz = 0-100, 977Hz = 0-255, ... + // (250000 / SPINDLE_LASER_FREQUENCY) = max value. #endif //#define AIR_EVACUATION // Cutter Vacuum / Laser Blower motor control with G-codes M10-M11 @@ -3667,8 +3404,11 @@ #endif // Define the minimum and maximum test pulse time values for a laser test fire function - #define LASER_TEST_PULSE_MIN 1 // Used with Laser Control Menu - #define LASER_TEST_PULSE_MAX 999 // Caution: Menu may not show more than 3 characters + #define LASER_TEST_PULSE_MIN 1 // (ms) Used with Laser Control Menu + #define LASER_TEST_PULSE_MAX 999 // (ms) Caution: Menu may not show more than 3 characters + + #define SPINDLE_LASER_POWERUP_DELAY 50 // (ms) Delay to allow the spindle/laser to come up to speed/power + #define SPINDLE_LASER_POWERDOWN_DELAY 50 // (ms) Delay to allow the spindle to stop /** * Laser Safety Timeout @@ -3681,79 +3421,38 @@ #define LASER_SAFETY_TIMEOUT_MS 1000 // (ms) /** - * Enable inline laser power to be handled in the planner / stepper routines. - * Inline power is specified by the I (inline) flag in an M3 command (e.g., M3 S20 I) - * or by the 'S' parameter in G0/G1/G2/G3 moves (see LASER_MOVE_POWER). + * Any M3 or G1/2/3/5 command with the 'I' parameter enables continuous inline power mode. + * + * e.g., 'M3 I' enables continuous inline power which is processed by the planner. + * Power is stored in move blocks and applied when blocks are processed by the Stepper ISR. * - * This allows the laser to keep in perfect sync with the planner and removes - * the powerup/down delay since lasers require negligible time. + * 'M4 I' sets dynamic mode which uses the current feedrate to calculate a laser power OCR value. + * + * Any move in dynamic mode will use the current feedrate to calculate the laser power. + * Feed rates are set by the F parameter of a move command e.g. G1 X0 Y10 F6000 + * Laser power would be calculated by bit shifting off 8 LSB's. In binary this is div 256. + * The calculation gives us ocr values from 0 to 255, values over F65535 will be set as 255 . + * More refined power control such as compesation for accell/decell will be addressed in future releases. + * + * M5 I clears inline mode and set power to 0, M5 sets the power output to 0 but leaves inline mode on. */ - //#define LASER_POWER_INLINE - - #if ENABLED(LASER_POWER_INLINE) - /** - * Scale the laser's power in proportion to the movement rate. - * - * - Sets the entry power proportional to the entry speed over the nominal speed. - * - Ramps the power up every N steps to approximate the speed trapezoid. - * - Due to the limited power resolution this is only approximate. - */ - #define LASER_POWER_INLINE_TRAPEZOID - - /** - * Continuously calculate the current power (nominal_power * current_rate / nominal_rate). - * Required for accurate power with non-trapezoidal acceleration (e.g., S_CURVE_ACCELERATION). - * This is a costly calculation so this option is discouraged on 8-bit AVR boards. - * - * LASER_POWER_INLINE_TRAPEZOID_CONT_PER defines how many step cycles there are between power updates. If your - * board isn't able to generate steps fast enough (and you are using LASER_POWER_INLINE_TRAPEZOID_CONT), increase this. - * Note that when this is zero it means it occurs every cycle; 1 means a delay wait one cycle then run, etc. - */ - //#define LASER_POWER_INLINE_TRAPEZOID_CONT - - /** - * Stepper iterations between power updates. Increase this value if the board - * can't keep up with the processing demands of LASER_POWER_INLINE_TRAPEZOID_CONT. - * Disable (or set to 0) to recalculate power on every stepper iteration. - */ - //#define LASER_POWER_INLINE_TRAPEZOID_CONT_PER 10 - - /** - * Include laser power in G0/G1/G2/G3/G5 commands with the 'S' parameter - */ - //#define LASER_MOVE_POWER - - #if ENABLED(LASER_MOVE_POWER) - // Turn off the laser on G0 moves with no power parameter. - // If a power parameter is provided, use that instead. - //#define LASER_MOVE_G0_OFF - - // Turn off the laser on G28 homing. - //#define LASER_MOVE_G28_OFF - #endif - - /** - * Inline flag inverted - * - * WARNING: M5 will NOT turn off the laser unless another move - * is done (so G-code files must end with 'M5 I'). - */ - //#define LASER_POWER_INLINE_INVERT - - /** - * Continuously apply inline power. ('M3 S3' == 'G1 S3' == 'M3 S3 I') - * - * The laser might do some weird things, so only enable this - * feature if you understand the implications. - */ - //#define LASER_POWER_INLINE_CONTINUOUS - - #else - #define SPINDLE_LASER_POWERUP_DELAY 50 // (ms) Delay to allow the spindle/laser to come up to speed/power - #define SPINDLE_LASER_POWERDOWN_DELAY 50 // (ms) Delay to allow the spindle to stop + /** + * Enable M3 commands for laser mode inline power planner syncing. + * This feature enables any M3 S-value to be injected into the block buffers while in + * CUTTER_MODE_CONTINUOUS. The option allows M3 laser power to be commited without waiting + * for a planner syncronization + */ + //#define LASER_POWER_SYNC - #endif + /** + * Scale the laser's power in proportion to the movement rate. + * + * - Sets the entry power proportional to the entry speed over the nominal speed. + * - Ramps the power up every N steps to approximate the speed trapezoid. + * - Due to the limited power resolution this is only approximate. + */ + //#define LASER_POWER_TRAP // // Laser I2C Ammeter (High precision INA226 low/high side module) @@ -3808,6 +3507,8 @@ #define COOLANT_FLOOD_INVERT false // Set "true" if the on/off function is reversed #endif +// @section filament width + /** * Filament Width Sensor * @@ -3841,6 +3542,8 @@ //#define FILAMENT_LCD_DISPLAY #endif +// @section power + /** * Power Monitor * Monitor voltage (V) and/or current (A), and -when possible- power (W) @@ -3864,6 +3567,8 @@ #define POWER_MONITOR_VOLTAGE_OFFSET 0 // Offset (in volts) applied to the calculated voltage #endif +// @section safety + /** * Stepper Driver Anti-SNAFU Protection * @@ -3873,6 +3578,8 @@ */ //#define DISABLE_DRIVER_SAFE_POWER_PROTECT +// @section cnc + /** * CNC Coordinate Systems * @@ -3881,6 +3588,8 @@ */ //#define CNC_COORDINATE_SYSTEMS +// @section reporting + /** * Auto-report fan speed with M123 S * Requires fans with tachometer pins @@ -3908,6 +3617,8 @@ //#define M115_GEOMETRY_REPORT #endif +// @section security + /** * Expected Printer Check * Add the M16 G-code to compare a string to the MACHINE_NAME. @@ -3915,6 +3626,8 @@ */ //#define EXPECTED_PRINTER_CHECK +// @section volumetrics + /** * Disable all Volumetric extrusion options */ @@ -3943,14 +3656,7 @@ #endif #endif -/** - * Enable this option for a leaner build of Marlin that removes all - * workspace offsets, simplifying coordinate transformations, leveling, etc. - * - * - M206 and M428 are disabled. - * - G92 will revert to its behavior from Marlin 1.0. - */ -//#define NO_WORKSPACE_OFFSETS +// @section reporting // Extra options for the M114 "Current Position" report #define M114_DETAIL // Use 'M114` for details to check planner calculations @@ -3959,6 +3665,8 @@ //#define REPORT_FAN_CHANGE // Report the new fan speed when changed by M106 (and others) +// @section gcode + /** * Spend 28 bytes of SRAM to optimize the G-code parser */ @@ -3976,6 +3684,15 @@ //#define REPETIER_GCODE_M360 // Add commands originally from Repetier FW +/** + * Enable this option for a leaner build of Marlin that removes all + * workspace offsets, simplifying coordinate transformations, leveling, etc. + * + * - M206 and M428 are disabled. + * - G92 will revert to its behavior from Marlin 1.0. + */ +//#define NO_WORKSPACE_OFFSETS + /** * CNC G-code options * Support CNC-style G-code dialects used by laser cutters, drawing machine cams, etc. @@ -3991,6 +3708,8 @@ //#define VARIABLE_G0_FEEDRATE // The G0 feedrate is set by F in G0 motion mode #endif +// @section gcode + /** * Startup commands * @@ -4015,6 +3734,8 @@ * Up to 25 may be defined, but the actual number is LCD-dependent. */ +// @section custom main menu + // Custom Menu: Main Menu //#define CUSTOM_MENU_MAIN #if ENABLED(CUSTOM_MENU_MAIN) @@ -4045,6 +3766,8 @@ //#define MAIN_MENU_ITEM_5_CONFIRM #endif +// @section custom config menu + // Custom Menu: Configuration Menu //#define CUSTOM_MENU_CONFIG #if ENABLED(CUSTOM_MENU_CONFIG) @@ -4075,6 +3798,8 @@ //#define CONFIG_MENU_ITEM_5_CONFIRM #endif +// @section custom buttons + /** * User-defined buttons to run custom G-code. * Up to 25 may be defined. @@ -4106,6 +3831,8 @@ #endif #endif +// @section host + /** * Host Action Commands * @@ -4131,6 +3858,8 @@ //#define HOST_SHUTDOWN_MENU_ITEM // Add a menu item that tells the host to shut down #endif +// @section extras + /** * Cancel Objects * @@ -4152,6 +3881,7 @@ * Alternative Supplier: https://reliabuild3d.com/ * * Reliabuild encoders have been modified to improve reliability. + * @section i2c encoders */ //#define I2C_POSITION_ENCODERS @@ -4223,6 +3953,7 @@ /** * Analog Joystick(s) + * @section joystick */ //#define JOYSTICK #if ENABLED(JOYSTICK) @@ -4244,9 +3975,10 @@ /** * 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 */ //#define MECHANICAL_GANTRY_CALIBRATION #if ENABLED(MECHANICAL_GANTRY_CALIBRATION) @@ -4264,6 +3996,7 @@ /** * Instant freeze / unfreeze functionality * Potentially useful for emergency stop that allows being resumed. + * @section interface */ //#define FREEZE_FEATURE #if ENABLED(FREEZE_FEATURE) @@ -4276,6 +4009,7 @@ * * Add support for a low-cost 8x8 LED Matrix based on the Max7219 chip as a realtime status display. * Requires 3 signal wires. Some useful debug options are included to demonstrate its usage. + * @section debug matrix */ //#define MAX7219_DEBUG #if ENABLED(MAX7219_DEBUG) @@ -4288,7 +4022,8 @@ #define MAX7219_NUMBER_UNITS 1 // Number of Max7219 units in chain. #define MAX7219_ROTATE 0 // Rotate the display clockwise (in multiples of +/- 90°) // connector at: right=0 bottom=-90 top=90 left=180 - //#define MAX7219_REVERSE_ORDER // The individual LED matrix units may be in reversed order + //#define MAX7219_REVERSE_ORDER // The order of the LED matrix units may be reversed + //#define MAX7219_REVERSE_EACH // The LEDs in each matrix unit row may be reversed //#define MAX7219_SIDE_BY_SIDE // Big chip+matrix boards can be chained side-by-side /** @@ -4296,12 +4031,15 @@ * If you add more debug displays, be careful to avoid conflicts! */ #define MAX7219_DEBUG_PRINTER_ALIVE // Blink corner LED of 8x8 matrix to show that the firmware is functioning - #define MAX7219_DEBUG_PLANNER_HEAD 3 // Show the planner queue head position on this and the next LED matrix row - #define MAX7219_DEBUG_PLANNER_TAIL 5 // Show the planner queue tail position on this and the next LED matrix row + #define MAX7219_DEBUG_PLANNER_HEAD 2 // Show the planner queue head position on this and the next LED matrix row + #define MAX7219_DEBUG_PLANNER_TAIL 4 // Show the planner queue tail position on this and the next LED matrix row #define MAX7219_DEBUG_PLANNER_QUEUE 0 // Show the current planner queue depth on this and the next LED matrix row // If you experience stuttering, reboots, etc. this option can reveal how // tweaks made to the configuration are affecting the printer in real-time. + #define MAX7219_DEBUG_PROFILE 6 // Display the fraction of CPU time spent in profiled code on this LED matrix + // row. By default idle() is profiled so this shows how "idle" the processor is. + // See class CodeProfiler. #endif /** @@ -4310,6 +4048,7 @@ * Support for Synchronized Z moves when used with NanoDLP. G0/G1 axis moves will * output a "Z_move_comp" string to enable synchronization with DLP projector exposure. * This feature allows you to use [[WaitForDoneMessage]] instead of M400 commands. + * @section nanodlp */ //#define NANODLP_Z_SYNC #if ENABLED(NANODLP_Z_SYNC) @@ -4318,6 +4057,7 @@ /** * Ethernet. Use M552 to enable and set the IP address. + * @section network */ #if HAS_ETHERNET #define MAC_ADDRESS { 0xDE, 0xAD, 0xBE, 0xEF, 0xF0, 0x0D } // A MAC address unique to your network @@ -4326,7 +4066,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) @@ -4345,6 +4085,8 @@ //#include "Configuration_Secure.h" // External file with WiFi SSID / Password #endif +// @section multi-material + /** * Průša Multi-Material Unit (MMU) * Enable in Configuration.h @@ -4450,6 +4192,7 @@ /** * Advanced Print Counter settings + * @section stats */ #if ENABLED(PRINTCOUNTER) #define SERVICE_WARNING_BUZZES 3 @@ -4479,6 +4222,9 @@ // //#define PINS_DEBUGGING +// Enable Tests that will run at startup and produce a report +//#define MARLIN_TEST_BUILD + // Enable Marlin dev mode which adds some special commands //#define MARLIN_DEV_MODE diff --git a/Marlin/Makefile b/Marlin/Makefile index 417c979f8857..ca7cacaa6acb 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -109,7 +109,7 @@ LIQUID_TWI2 ?= 0 # This defines if Wire is needed WIRE ?= 0 -# This defines if Tone is needed (i.e SPEAKER is defined in Configuration.h) +# This defines if Tone is needed (i.e., SPEAKER is defined in Configuration.h) # Disabling this (and SPEAKER) saves approximately 350 bytes of memory. TONE ?= 1 @@ -307,133 +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) - - -# 3Drag Controller -else ifeq ($(HARDWARE_MOTHERBOARD),1100) -# Velleman K8200 Controller (derived from 3Drag Controller) -else ifeq ($(HARDWARE_MOTHERBOARD),1101) -# Velleman K8400 Controller (derived from 3Drag Controller) -else ifeq ($(HARDWARE_MOTHERBOARD),1102) -# Velleman K8600 Controller (Vertex Nano) -else ifeq ($(HARDWARE_MOTHERBOARD),1103) -# Velleman K8800 Controller (Vertex Delta) -else ifeq ($(HARDWARE_MOTHERBOARD),1104) -# 2PrintBeta BAM&DICE with STK drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1105) -# 2PrintBeta BAM&DICE Due with STK drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1106) -# MKS BASE v1.0 -else ifeq ($(HARDWARE_MOTHERBOARD),1107) -# MKS v1.4 with A4982 stepper drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1108) -# MKS v1.5 with Allegro A4982 stepper drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1109) -# MKS v1.6 with Allegro A4982 stepper drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1110) -# MKS BASE 1.0 with Heroic HR4982 stepper drivers -else ifeq ($(HARDWARE_MOTHERBOARD),1111) -# MKS GEN v1.3 or 1.4 -else ifeq ($(HARDWARE_MOTHERBOARD),1112) -# MKS GEN L -else ifeq ($(HARDWARE_MOTHERBOARD),1113) -# zrib V2.0 control board (Chinese RAMPS replica) -else ifeq ($(HARDWARE_MOTHERBOARD),1114) -# BigTreeTech or BIQU KFB2.0 -else ifeq ($(HARDWARE_MOTHERBOARD),1115) -# Felix 2.0+ Electronics Board (RAMPS like) -else ifeq ($(HARDWARE_MOTHERBOARD),1116) -# Invent-A-Part RigidBoard -else ifeq ($(HARDWARE_MOTHERBOARD),1117) -# Invent-A-Part RigidBoard V2 -else ifeq ($(HARDWARE_MOTHERBOARD),1118) -# Sainsmart 2-in-1 board -else ifeq ($(HARDWARE_MOTHERBOARD),1119) -# Ultimaker -else ifeq ($(HARDWARE_MOTHERBOARD),1120) -# Ultimaker (Older electronics. Pre 1.5.4. This is rare) -else ifeq ($(HARDWARE_MOTHERBOARD),1121) - MCU ?= atmega1280 - PROG_MCU ?= m1280 - -# Azteeg X3 -else ifeq ($(HARDWARE_MOTHERBOARD),1122) -# Azteeg X3 Pro -else ifeq ($(HARDWARE_MOTHERBOARD),1123) -# Ultimainboard 2.x (Uses TEMP_SENSOR 20) -else ifeq ($(HARDWARE_MOTHERBOARD),1124) -# Rumba -else ifeq ($(HARDWARE_MOTHERBOARD),1125) -# Raise3D Rumba -else ifeq ($(HARDWARE_MOTHERBOARD),1126) -# Rapide Lite RL200 Rumba -else ifeq ($(HARDWARE_MOTHERBOARD),1127) -# Formbot T-Rex 2 Plus -else ifeq ($(HARDWARE_MOTHERBOARD),1128) -# Formbot T-Rex 3 -else ifeq ($(HARDWARE_MOTHERBOARD),1129) -# Formbot Raptor -else ifeq ($(HARDWARE_MOTHERBOARD),1130) -# Formbot Raptor 2 -else ifeq ($(HARDWARE_MOTHERBOARD),1131) -# bq ZUM Mega 3D -else ifeq ($(HARDWARE_MOTHERBOARD),1132) -# MakeBoard Mini v2.1.2 is a control board sold by MicroMake -else ifeq ($(HARDWARE_MOTHERBOARD),1133) -# TriGorilla Anycubic version 1.3 based on RAMPS EFB -else ifeq ($(HARDWARE_MOTHERBOARD),1134) -# TriGorilla Anycubic version 1.4 based on RAMPS EFB -else ifeq ($(HARDWARE_MOTHERBOARD),1135) -# TriGorilla Anycubic version 1.4 Rev 1.1 -else ifeq ($(HARDWARE_MOTHERBOARD),1136) -# Creality: Ender-4, CR-8 -else ifeq ($(HARDWARE_MOTHERBOARD),1137) -# Creality: CR10S, CR20, CR-X -else ifeq ($(HARDWARE_MOTHERBOARD),1138) -# Dagoma F5 -else ifeq ($(HARDWARE_MOTHERBOARD),1139) -# FYSETC F6 1.3 -else ifeq ($(HARDWARE_MOTHERBOARD),1140) -# FYSETC F6 1.5 -else ifeq ($(HARDWARE_MOTHERBOARD),1141) -# Duplicator i3 Plus -else ifeq ($(HARDWARE_MOTHERBOARD),1142) -# VORON -else ifeq ($(HARDWARE_MOTHERBOARD),1143) -# TRONXY V3 1.0 -else ifeq ($(HARDWARE_MOTHERBOARD),1144) -# Z-Bolt X Series -else ifeq ($(HARDWARE_MOTHERBOARD),1145) -# TT OSCAR -else ifeq ($(HARDWARE_MOTHERBOARD),1146) -# Overlord/Overlord Pro -else ifeq ($(HARDWARE_MOTHERBOARD),1147) -# ADIMLab Gantry v1 -else ifeq ($(HARDWARE_MOTHERBOARD),1148) -# ADIMLab Gantry v2 -else ifeq ($(HARDWARE_MOTHERBOARD),1149) -# BIQU Tango V1 -else ifeq ($(HARDWARE_MOTHERBOARD),1150) -# MKS GEN L V2 -else ifeq ($(HARDWARE_MOTHERBOARD),1151) -# MKS GEN L V2.1 -else ifeq ($(HARDWARE_MOTHERBOARD),1152) -# Copymaster 3D -else ifeq ($(HARDWARE_MOTHERBOARD),1153) -# Ortur 4 -else ifeq ($(HARDWARE_MOTHERBOARD),1154) -# Tenlog D3 Hero -else ifeq ($(HARDWARE_MOTHERBOARD),1155) +# Longer LKx PRO / Alfawise Uxx Pro (PRO version) +else ifeq ($(HARDWARE_MOTHERBOARD),1162) +# 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/Version.h b/Marlin/Version.h index f6e4635c8f65..8287902b687e 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -28,7 +28,7 @@ /** * Marlin release version identifier */ -//#define SHORT_BUILD_VERSION "2.1" +//#define SHORT_BUILD_VERSION "2.1.2.1" /** * Verbose version identifier which should contain a reference to the location @@ -41,7 +41,7 @@ * here we define this default string as the date where the latest release * version was tagged. */ -//#define STRING_DISTRIBUTION_DATE "2022-06-04" +//#define STRING_DISTRIBUTION_DATE "2023-05-16" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/config.ini b/Marlin/config.ini new file mode 100644 index 000000000000..0fb9fb0c9308 --- /dev/null +++ b/Marlin/config.ini @@ -0,0 +1,211 @@ +# +# Marlin Firmware +# config.ini - Options to apply before the build +# +[config:base] +ini_use_config = none + +# Load all config: sections in this file +;ini_use_config = all +# Load config file relative to Marlin/ +;ini_use_config = another.ini +# Download configurations from GitHub +;ini_use_config = example/Creality/Ender-5 Plus @ bugfix-2.1.x +# Download configurations from your server +;ini_use_config = https://me.myserver.com/path/to/configs +# Evaluate config:base and do a config dump +;ini_use_config = base +;config_export = 2 + +[config:minimal] +motherboard = BOARD_RAMPS_14_EFB +serial_port = 0 +baudrate = 250000 + +use_watchdog = on +thermal_protection_hotends = on +thermal_protection_hysteresis = 4 +thermal_protection_period = 40 + +bufsize = 4 +block_buffer_size = 16 +max_cmd_size = 96 + +extruders = 1 +temp_sensor_0 = 1 + +temp_hysteresis = 3 +heater_0_mintemp = 5 +heater_0_maxtemp = 275 +preheat_1_temp_hotend = 180 + +bang_max = 255 +pidtemp = on +pid_k1 = 0.95 +pid_max = BANG_MAX +pid_functional_range = 10 + +default_kp = 22.20 +default_ki = 1.08 +default_kd = 114.00 + +x_driver_type = A4988 +y_driver_type = A4988 +z_driver_type = A4988 +e0_driver_type = A4988 + +x_bed_size = 200 +x_min_pos = 0 +x_max_pos = X_BED_SIZE + +y_bed_size = 200 +y_min_pos = 0 +y_max_pos = Y_BED_SIZE + +z_min_pos = 0 +z_max_pos = 200 + +x_home_dir = -1 +y_home_dir = -1 +z_home_dir = -1 + +use_xmin_plug = on +use_ymin_plug = on +use_zmin_plug = on + +x_min_endstop_inverting = false +y_min_endstop_inverting = false +z_min_endstop_inverting = false + +default_axis_steps_per_unit = { 80, 80, 400, 500 } +axis_relative_modes = { false, false, false, false } +default_max_feedrate = { 300, 300, 5, 25 } +default_max_acceleration = { 3000, 3000, 100, 10000 } + +homing_feedrate_mm_m = { (50*60), (50*60), (4*60) } +homing_bump_divisor = { 2, 2, 4 } + +x_enable_on = 0 +y_enable_on = 0 +z_enable_on = 0 +e_enable_on = 0 + +invert_x_dir = false +invert_y_dir = true +invert_z_dir = false +invert_e0_dir = false + +invert_e_step_pin = false +invert_x_step_pin = false +invert_y_step_pin = false +invert_z_step_pin = false + +disable_x = false +disable_y = false +disable_z = false +disable_e = false + +proportional_font_ratio = 1.0 +default_nominal_filament_dia = 1.75 + +junction_deviation_mm = 0.013 + +default_acceleration = 3000 +default_travel_acceleration = 3000 +default_retract_acceleration = 3000 + +default_minimumfeedrate = 0.0 +default_mintravelfeedrate = 0.0 + +minimum_planner_speed = 0.05 +min_steps_per_segment = 6 +default_minsegmenttime = 20000 + +[config:basic] +bed_overshoot = 10 +busy_while_heating = on +default_ejerk = 5.0 +default_keepalive_interval = 2 +default_leveling_fade_height = 0.0 +disable_inactive_extruder = on +display_charset_hd44780 = JAPANESE +eeprom_boot_silent = on +eeprom_chitchat = on +endstoppullups = on +extrude_maxlength = 200 +extrude_mintemp = 170 +host_keepalive_feature = on +hotend_overshoot = 15 +jd_handle_small_segments = on +lcd_info_screen_style = 0 +lcd_language = en +max_bed_power = 255 +mesh_inset = 0 +min_software_endstops = on +max_software_endstops = on +min_software_endstop_x = on +min_software_endstop_y = on +min_software_endstop_z = on +max_software_endstop_x = on +max_software_endstop_y = on +max_software_endstop_z = on +preheat_1_fan_speed = 0 +preheat_1_label = "PLA" +preheat_1_temp_bed = 70 +prevent_cold_extrusion = on +prevent_lengthy_extrude = on +printjob_timer_autostart = on +probing_margin = 10 +show_bootscreen = on +soft_pwm_scale = 0 +string_config_h_author = "(none, default config)" +temp_bed_hysteresis = 3 +temp_bed_residency_time = 10 +temp_bed_window = 1 +temp_residency_time = 10 +temp_window = 1 +validate_homing_endstops = on +xy_probe_feedrate = (133*60) +z_clearance_between_probes = 5 +z_clearance_deploy_probe = 10 +z_clearance_multi_probe = 5 + +[config:advanced] +arc_support = on +auto_report_temperatures = on +autotemp = on +autotemp_oldweight = 0.98 +bed_check_interval = 5000 +default_stepper_deactive_time = 120 +default_volumetric_extruder_limit = 0.00 +disable_inactive_e = true +disable_inactive_x = true +disable_inactive_y = true +disable_inactive_z = true +e0_auto_fan_pin = -1 +encoder_100x_steps_per_sec = 80 +encoder_10x_steps_per_sec = 30 +encoder_rate_multiplier = on +extended_capabilities_report = on +extruder_auto_fan_speed = 255 +extruder_auto_fan_temperature = 50 +fanmux0_pin = -1 +fanmux1_pin = -1 +fanmux2_pin = -1 +faster_gcode_parser = on +homing_bump_mm = { 5, 5, 2 } +max_arc_segment_mm = 1.0 +min_arc_segment_mm = 0.1 +min_circle_segments = 72 +n_arc_correction = 25 +serial_overrun_protection = on +slowdown = on +slowdown_divisor = 2 +temp_sensor_bed = 0 +thermal_protection_bed_hysteresis = 2 +thermocouple_max_errors = 15 +tx_buffer_size = 0 +watch_bed_temp_increase = 2 +watch_bed_temp_period = 60 +watch_temp_increase = 2 +watch_temp_period = 20 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 diff --git a/Marlin/src/HAL/AVR/Servo.cpp b/Marlin/src/HAL/AVR/Servo.cpp index 6dc1e2fb0732..0a1ef5337ae9 100644 --- a/Marlin/src/HAL/AVR/Servo.cpp +++ b/Marlin/src/HAL/AVR/Servo.cpp @@ -67,26 +67,25 @@ static volatile int8_t Channel[_Nbr_16timers]; // counter for the s /************ static functions common to all instances ***********************/ static inline void handle_interrupts(const timer16_Sequence_t timer, volatile uint16_t* TCNTn, volatile uint16_t* OCRnA) { - if (Channel[timer] < 0) - *TCNTn = 0; // channel set to -1 indicated that refresh interval completed so reset the timer - else { - if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && SERVO(timer, Channel[timer]).Pin.isActive) - extDigitalWrite(SERVO(timer, Channel[timer]).Pin.nbr, LOW); // pulse this channel low if activated - } - - Channel[timer]++; // increment to the next channel - if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) { - *OCRnA = *TCNTn + SERVO(timer, Channel[timer]).ticks; - if (SERVO(timer, Channel[timer]).Pin.isActive) // check if activated - extDigitalWrite(SERVO(timer, Channel[timer]).Pin.nbr, HIGH); // it's an active channel so pulse it high + int8_t cho = Channel[timer]; // Handle the prior Channel[timer] first + if (cho < 0) // Channel -1 indicates the refresh interval completed... + *TCNTn = 0; // ...so reset the timer + else if (SERVO_INDEX(timer, cho) < ServoCount) // prior channel handled? + extDigitalWrite(SERVO(timer, cho).Pin.nbr, LOW); // pulse the prior channel LOW + + Channel[timer] = ++cho; // Handle the next channel (or 0) + if (cho < SERVOS_PER_TIMER && SERVO_INDEX(timer, cho) < ServoCount) { + *OCRnA = *TCNTn + SERVO(timer, cho).ticks; // set compare to current ticks plus duration + if (SERVO(timer, cho).Pin.isActive) // activated? + extDigitalWrite(SERVO(timer, cho).Pin.nbr, HIGH); // yes: pulse HIGH } else { // finished all channels so wait for the refresh period to expire before starting over - if (((unsigned)*TCNTn) + 4 < usToTicks(REFRESH_INTERVAL)) // allow a few ticks to ensure the next OCR1A not missed - *OCRnA = (unsigned int)usToTicks(REFRESH_INTERVAL); - else - *OCRnA = *TCNTn + 4; // at least REFRESH_INTERVAL has elapsed - Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel + const unsigned int cval = ((unsigned)*TCNTn) + 32 / (SERVO_TIMER_PRESCALER), // allow 32 cycles to ensure the next OCR1A not missed + ival = (unsigned int)usToTicks(REFRESH_INTERVAL); // at least REFRESH_INTERVAL has elapsed + *OCRnA = max(cval, ival); + + Channel[timer] = -1; // reset the timer counter to 0 on the next call } } @@ -123,91 +122,102 @@ static inline void handle_interrupts(const timer16_Sequence_t timer, volatile ui /****************** end of static functions ******************************/ -void initISR(timer16_Sequence_t timer) { - #ifdef _useTimer1 - if (timer == _timer1) { - TCCR1A = 0; // normal counting mode - TCCR1B = _BV(CS11); // set prescaler of 8 - TCNT1 = 0; // clear the timer count - #if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) - SBI(TIFR, OCF1A); // clear any pending interrupts; - SBI(TIMSK, OCIE1A); // enable the output compare interrupt - #else - // here if not ATmega8 or ATmega128 - SBI(TIFR1, OCF1A); // clear any pending interrupts; - SBI(TIMSK1, OCIE1A); // enable the output compare interrupt - #endif - #ifdef WIRING - timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service); - #endif - } - #endif - - #ifdef _useTimer3 - if (timer == _timer3) { - TCCR3A = 0; // normal counting mode - TCCR3B = _BV(CS31); // set prescaler of 8 - TCNT3 = 0; // clear the timer count - #ifdef __AVR_ATmega128__ - SBI(TIFR, OCF3A); // clear any pending interrupts; - SBI(ETIMSK, OCIE3A); // enable the output compare interrupt - #else - SBI(TIFR3, OCF3A); // clear any pending interrupts; - SBI(TIMSK3, OCIE3A); // enable the output compare interrupt - #endif - #ifdef WIRING - timerAttach(TIMER3OUTCOMPAREA_INT, Timer3Service); // for Wiring platform only - #endif - } - #endif - - #ifdef _useTimer4 - if (timer == _timer4) { - TCCR4A = 0; // normal counting mode - TCCR4B = _BV(CS41); // set prescaler of 8 - TCNT4 = 0; // clear the timer count - TIFR4 = _BV(OCF4A); // clear any pending interrupts; - TIMSK4 = _BV(OCIE4A); // enable the output compare interrupt - } - #endif - - #ifdef _useTimer5 - if (timer == _timer5) { - TCCR5A = 0; // normal counting mode - TCCR5B = _BV(CS51); // set prescaler of 8 - TCNT5 = 0; // clear the timer count - TIFR5 = _BV(OCF5A); // clear any pending interrupts; - TIMSK5 = _BV(OCIE5A); // enable the output compare interrupt - } - #endif -} - -void finISR(timer16_Sequence_t timer) { - // Disable use of the given timer - #ifdef WIRING - if (timer == _timer1) { - CBI( - #if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) - TIMSK1 +void initISR(const timer16_Sequence_t timer_index) { + switch (timer_index) { + default: break; + + #ifdef _useTimer1 + case _timer1: + TCCR1A = 0; // normal counting mode + TCCR1B = _BV(CS11); // set prescaler of 8 + TCNT1 = 0; // clear the timer count + #if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) + SBI(TIFR, OCF1A); // clear any pending interrupts; + SBI(TIMSK, OCIE1A); // enable the output compare interrupt #else - TIMSK + // here if not ATmega8 or ATmega128 + SBI(TIFR1, OCF1A); // clear any pending interrupts; + SBI(TIMSK1, OCIE1A); // enable the output compare interrupt #endif - , OCIE1A); // disable timer 1 output compare interrupt - timerDetach(TIMER1OUTCOMPAREA_INT); - } - else if (timer == _timer3) { - CBI( - #if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) - TIMSK3 + #ifdef WIRING + timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service); + #endif + break; + #endif + + #ifdef _useTimer3 + case _timer3: + TCCR3A = 0; // normal counting mode + TCCR3B = _BV(CS31); // set prescaler of 8 + TCNT3 = 0; // clear the timer count + #ifdef __AVR_ATmega128__ + SBI(TIFR, OCF3A); // clear any pending interrupts; + SBI(ETIMSK, OCIE3A); // enable the output compare interrupt #else - ETIMSK + SBI(TIFR3, OCF3A); // clear any pending interrupts; + SBI(TIMSK3, OCIE3A); // enable the output compare interrupt + #endif + #ifdef WIRING + timerAttach(TIMER3OUTCOMPAREA_INT, Timer3Service); // for Wiring platform only #endif - , OCIE3A); // disable the timer3 output compare A interrupt - timerDetach(TIMER3OUTCOMPAREA_INT); + break; + #endif + + #ifdef _useTimer4 + case _timer4: + TCCR4A = 0; // normal counting mode + TCCR4B = _BV(CS41); // set prescaler of 8 + TCNT4 = 0; // clear the timer count + TIFR4 = _BV(OCF4A); // clear any pending interrupts; + TIMSK4 = _BV(OCIE4A); // enable the output compare interrupt + break; + #endif + + #ifdef _useTimer5 + case _timer5: + TCCR5A = 0; // normal counting mode + TCCR5B = _BV(CS51); // set prescaler of 8 + TCNT5 = 0; // clear the timer count + TIFR5 = _BV(OCF5A); // clear any pending interrupts; + TIMSK5 = _BV(OCIE5A); // enable the output compare interrupt + break; + #endif + } +} + +void finISR(const timer16_Sequence_t timer_index) { + // Disable use of the given timer + #ifdef WIRING + switch (timer_index) { + default: break; + + case _timer1: + CBI( + #if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) + TIMSK1 + #else + TIMSK + #endif + , OCIE1A // disable timer 1 output compare interrupt + ); + timerDetach(TIMER1OUTCOMPAREA_INT); + break; + + case _timer3: + CBI( + #if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) + TIMSK3 + #else + ETIMSK + #endif + , OCIE3A // disable the timer3 output compare A interrupt + ); + timerDetach(TIMER3OUTCOMPAREA_INT); + break; } #else // !WIRING // For arduino - in future: call here to a currently undefined function to reset the timer - UNUSED(timer); + UNUSED(timer_index); #endif } diff --git a/Marlin/src/HAL/AVR/fast_pwm.cpp b/Marlin/src/HAL/AVR/fast_pwm.cpp index 0a384172c32a..0b2b8fd0b3a4 100644 --- a/Marlin/src/HAL/AVR/fast_pwm.cpp +++ b/Marlin/src/HAL/AVR/fast_pwm.cpp @@ -23,6 +23,10 @@ #include "../../inc/MarlinConfig.h" +//#define DEBUG_AVR_FAST_PWM +#define DEBUG_OUT ENABLED(DEBUG_AVR_FAST_PWM) +#include "../../core/debug_out.h" + struct Timer { volatile uint8_t* TCCRnQ[3]; // max 3 TCCR registers per timer volatile uint16_t* OCRnQ[3]; // max 3 OCR registers per timer @@ -108,12 +112,15 @@ const Timer get_pwm_timer(const pin_t pin) { } void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { + DEBUG_ECHOLNPGM("set_pwm_frequency(pin=", pin, ", freq=", f_desired, ")"); const Timer timer = get_pwm_timer(pin); if (timer.isProtected || !timer.isPWM) return; // Don't proceed if protected timer or not recognized const bool is_timer2 = timer.n == 2; const uint16_t maxtop = is_timer2 ? 0xFF : 0xFFFF; + DEBUG_ECHOLNPGM("maxtop=", maxtop); + uint16_t res = 0xFF; // resolution (TOP value) uint8_t j = CS_NONE; // prescaler index uint8_t wgm = WGM_PWM_PC_8; // waveform generation mode @@ -121,23 +128,29 @@ void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { // Calculating the prescaler and resolution to use to achieve closest frequency if (f_desired != 0) { constexpr uint16_t prescaler[] = { 1, 8, (32), 64, (128), 256, 1024 }; // (*) are Timer 2 only - uint16_t f = (F_CPU) / (2 * 1024 * maxtop) + 1; // Start with the lowest non-zero frequency achievable (1 or 31) + uint16_t f = (F_CPU) / (uint32_t(maxtop) << 11) + 1; // Start with the lowest non-zero frequency achievable (for 16MHz, 1 or 31) + DEBUG_ECHOLNPGM("f=", f); + DEBUG_ECHOLNPGM("(prescaler loop)"); LOOP_L_N(i, COUNT(prescaler)) { // Loop through all prescaler values - const uint16_t p = prescaler[i]; + const uint32_t p = prescaler[i]; // Extend to 32 bits for calculations + DEBUG_ECHOLNPGM("prescaler[", i, "]=", p); uint16_t res_fast_temp, res_pc_temp; if (is_timer2) { #if ENABLED(USE_OCR2A_AS_TOP) // No resolution calculation for TIMER2 unless enabled USE_OCR2A_AS_TOP const uint16_t rft = (F_CPU) / (p * f_desired); res_fast_temp = rft - 1; res_pc_temp = rft / 2; + DEBUG_ECHOLNPGM("(Timer2) res_fast_temp=", res_fast_temp, " res_pc_temp=", res_pc_temp); #else res_fast_temp = res_pc_temp = maxtop; + DEBUG_ECHOLNPGM("(Timer2) res_fast_temp=", maxtop, " res_pc_temp=", maxtop); #endif } else { if (p == 32 || p == 128) continue; // Skip TIMER2 specific prescalers when not TIMER2 const uint16_t rft = (F_CPU) / (p * f_desired); + DEBUG_ECHOLNPGM("(Not Timer 2) F_CPU=" STRINGIFY(F_CPU), " prescaler=", p, " f_desired=", f_desired); res_fast_temp = rft - 1; res_pc_temp = rft / 2; } @@ -146,24 +159,28 @@ 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)), + const uint16_t f_fast_temp = (F_CPU) / (p * (1 + res_fast_temp)), + f_pc_temp = (F_CPU) / ((p * res_pc_temp) << 1), + 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_temp = (F_CPU) / (2 * p * res_pc_temp), f_pc_diff = _MAX(f_pc_temp, f_desired) - _MIN(f_pc_temp, f_desired); + DEBUG_ECHOLNPGM("f_fast_temp=", f_fast_temp, " f_pc_temp=", f_pc_temp, " f_diff=", f_diff, " f_fast_diff=", f_fast_diff, " f_pc_diff=", f_pc_diff); + 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 wgm = is_timer2 ? uint8_t(TERN(USE_OCR2A_AS_TOP, WGM2_FAST_PWM_OCR2A, WGM2_FAST_PWM)) : uint8_t(WGM_FAST_PWM_ICRn); // Remember this combination f = f_fast_temp; res = res_fast_temp; j = i + 1; + DEBUG_ECHOLNPGM("(FAST) updated f=", f); } else if (f_pc_diff < f_diff) { // PHASE CORRECT values are closes to desired f // Set the Wave Generation Mode to PWM PHASE CORRECT wgm = is_timer2 ? uint8_t(TERN(USE_OCR2A_AS_TOP, WGM2_PWM_PC_OCR2A, WGM2_PWM_PC)) : uint8_t(WGM_PWM_PC_ICRn); f = f_pc_temp; res = res_pc_temp; j = i + 1; + DEBUG_ECHOLNPGM("(PHASE) updated f=", f); } - } + } // prescaler loop } _SET_WGMnQ(timer, wgm); diff --git a/Marlin/src/HAL/AVR/fastio.h b/Marlin/src/HAL/AVR/fastio.h index 51d3b311ee9d..8a5e4650f4c6 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_PIN || P == MOTOR_CURRENT_PWM_E0_PIN || P == MOTOR_CURRENT_PWM_E1_PIN || P == MOTOR_CURRENT_PWM_Z_PIN || P == MOTOR_CURRENT_PWM_XY_PIN) #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_PIN || P == MOTOR_CURRENT_PWM_E0_PIN || P == MOTOR_CURRENT_PWM_E1_PIN || P == MOTOR_CURRENT_PWM_Z_PIN) #else - #define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E) + #define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E_PIN || P == MOTOR_CURRENT_PWM_E0_PIN || P == MOTOR_CURRENT_PWM_E1_PIN) #endif #else #define PWM_CHK_MOTOR_CURRENT(P) false diff --git a/Marlin/src/HAL/AVR/fastio/fastio_1280.h b/Marlin/src/HAL/AVR/fastio/fastio_1280.h index f482f823e8b9..e6ecbabb800f 100644 --- a/Marlin/src/HAL/AVR/fastio/fastio_1280.h +++ b/Marlin/src/HAL/AVR/fastio/fastio_1280.h @@ -27,6 +27,9 @@ * Hardware Pin : 02 03 06 07 01 05 15 16 17 18 23 24 25 26 64 63 13 12 46 45 44 43 78 77 76 75 74 73 72 71 60 59 58 57 56 55 54 53 50 70 52 51 42 41 40 39 38 37 36 35 22 21 20 19 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 | 04 08 09 10 11 14 27 28 29 30 31 32 33 34 47 48 49 61 62 65 66 67 68 69 79 80 81 98 99 100 * Port : E0 E1 E4 E5 G5 E3 H3 H4 H5 H6 B4 B5 B6 B7 J1 J0 H1 H0 D3 D2 D1 D0 A0 A1 A2 A3 A4 A5 A6 A7 C7 C6 C5 C4 C3 C2 C1 C0 D7 G2 G1 G0 L7 L6 L5 L4 L3 L2 L1 L0 B3 B2 B1 B0 F0 F1 F2 F3 F4 F5 F6 F7 K0 K1 K2 K3 K4 K5 K6 K7 | E2 E6 E7 xx xx H2 H7 G3 G4 xx xx xx xx xx D4 D5 D6 xx xx J2 J3 J4 J5 J6 J7 xx xx xx xx xx * Logical Pin : 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 78 79 80 xx xx 84 85 71 70 xx xx xx xx xx 81 82 83 xx xx 72 73 75 76 77 74 xx xx xx xx xx + * + * Arduino Pin Layout video: https://youtu.be/rIqeVCX09FA + * AVR alternate pin function overview video: https://youtu.be/1yd8wuI5Plg */ #include "../fastio.h" diff --git a/Marlin/src/HAL/AVR/fastio/fastio_1281.h b/Marlin/src/HAL/AVR/fastio/fastio_1281.h index e0bc5e2995d1..812586225d17 100644 --- a/Marlin/src/HAL/AVR/fastio/fastio_1281.h +++ b/Marlin/src/HAL/AVR/fastio/fastio_1281.h @@ -26,6 +26,9 @@ * * Logical Pin: 38 39 40 41 42 43 44 45 16 10 11 12 06 07 08 09 30 31 32 33 34 35 36 37 17 18 19 20 21 22 23 24 00 01 13 05 02 03 14 15 46 47 48 49 50 51 52 53 25 26 27 28 29 04 * Port: A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 G0 G1 G2 G3 G4 G5 + * + * Arduino Pin Layout video: https://youtu.be/rIqeVCX09FA + * AVR alternate pin function overview video: https://youtu.be/1yd8wuI5Plg */ #include "../fastio.h" diff --git a/Marlin/src/HAL/AVR/fastio/fastio_168.h b/Marlin/src/HAL/AVR/fastio/fastio_168.h index 8cfdd1e8f825..4f591b37b901 100644 --- a/Marlin/src/HAL/AVR/fastio/fastio_168.h +++ b/Marlin/src/HAL/AVR/fastio/fastio_168.h @@ -26,6 +26,9 @@ * * Logical Pin: 08 09 10 11 12 13 14 15 16 17 18 19 20 21 00 01 02 03 04 05 06 07 * Port: B0 B1 B2 B3 B4 B5 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 + * + * Arduino Pin Layout video: https://youtu.be/rIqeVCX09FA + * AVR alternate pin function overview video: https://youtu.be/1yd8wuI5Plg */ #include "../fastio.h" diff --git a/Marlin/src/HAL/AVR/fastio/fastio_644.h b/Marlin/src/HAL/AVR/fastio/fastio_644.h index f4a9427e0abf..16bdc6a23da2 100644 --- a/Marlin/src/HAL/AVR/fastio/fastio_644.h +++ b/Marlin/src/HAL/AVR/fastio/fastio_644.h @@ -26,6 +26,9 @@ * * Logical Pin: 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 * Port: B0 B1 B2 B3 B4 B5 B6 B7 D0 D1 D2 D3 D4 D5 D6 D7 C0 C1 C2 C3 C4 C5 C6 C7 A7 A6 A5 A4 A3 A2 A1 A0 + * + * Arduino Pin Layout video: https://youtu.be/rIqeVCX09FA + * AVR alternate pin function overview video: https://youtu.be/1yd8wuI5Plg */ /** ATMega644 diff --git a/Marlin/src/HAL/AVR/fastio/fastio_AT90USB.h b/Marlin/src/HAL/AVR/fastio/fastio_AT90USB.h index 51d400b70565..d2a8aca6f38c 100644 --- a/Marlin/src/HAL/AVR/fastio/fastio_AT90USB.h +++ b/Marlin/src/HAL/AVR/fastio/fastio_AT90USB.h @@ -27,6 +27,9 @@ * Logical Pin: 28 29 30 31 32 33 34 35 20 21 22 23 24 25 26 27 10 11 12 13 14 15 16 17 00 01 02 03 04 05 06 07 08 09(46*47)36 37 18 19 38 39 40 41 42 43 44 45 * Port: A0 A1 A2 A3 A4 A5 A6 A7 B0 B1 B2 B3 B4 B5 B6 B7 C0 C1 C2 C3 C4 C5 C6 C7 D0 D1 D2 D3 D4 D5 D6 D7 E0 E1 E2 E3 E4 E5 E6 E7 F0 F1 F2 F3 F4 F5 F6 F7 * The logical pins 46 and 47 are not supported by Teensyduino, but are supported below as E2 and E3 + * + * Arduino Pin Layout video: https://youtu.be/rIqeVCX09FA + * AVR alternate pin function overview video: https://youtu.be/1yd8wuI5Plg */ #include "../fastio.h" diff --git a/Marlin/src/HAL/AVR/inc/Conditionals_LCD.h b/Marlin/src/HAL/AVR/inc/Conditionals_LCD.h index a611ccd7c4a9..5f1c4b16019d 100644 --- a/Marlin/src/HAL/AVR/inc/Conditionals_LCD.h +++ b/Marlin/src/HAL/AVR/inc/Conditionals_LCD.h @@ -20,7 +20,3 @@ * */ #pragma once - -#if HAS_SPI_TFT || HAS_FSMC_TFT - #error "Sorry! TFT displays are not available for HAL/AVR." -#endif diff --git a/Marlin/src/HAL/AVR/inc/SanityCheck.h b/Marlin/src/HAL/AVR/inc/SanityCheck.h index 1c1d8d441351..e66de96047a5 100644 --- a/Marlin/src/HAL/AVR/inc/SanityCheck.h +++ b/Marlin/src/HAL/AVR/inc/SanityCheck.h @@ -25,6 +25,10 @@ * Test AVR-specific configuration values for errors at compile-time. */ +#if HAS_SPI_TFT || HAS_FSMC_TFT + #error "Sorry! TFT displays are not available for HAL/AVR." +#endif + /** * Check for common serial pin conflicts */ @@ -35,16 +39,26 @@ || X_STEP_PIN == N || Y_STEP_PIN == N || Z_STEP_PIN == N \ || X_DIR_PIN == N || Y_DIR_PIN == N || Z_DIR_PIN == N \ || X_ENA_PIN == N || Y_ENA_PIN == N || Z_ENA_PIN == N \ + || BTN_EN1 == N || BTN_EN2 == 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)) - #error "Serial Port 1 pin D18 and/or D19 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 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/AVR/math.h b/Marlin/src/HAL/AVR/math.h index 7dd1018ff199..34f859fbbb03 100644 --- a/Marlin/src/HAL/AVR/math.h +++ b/Marlin/src/HAL/AVR/math.h @@ -27,13 +27,14 @@ // intRes = longIn1 * longIn2 >> 24 // uses: -// A[tmp] to store 0 -// B[tmp] to store bits 16-23 of the 48bit result. The top bit is used to round the two byte result. -// note that the lower two bytes and the upper byte of the 48bit result are not calculated. -// this can cause the result to be out by one as the lower bytes may cause carries into the upper ones. -// B A are bits 24-39 and are the returned value -// C B A is longIn1 -// D C B A is longIn2 +// r1, r0 for the result of mul. +// [tmp1] to store 0. +// [tmp2] to store bits 16-23 of the 56 bit result. The top bit of [tmp2] is used for rounding. +// Note that the lower two bytes and the upper two bytes of the 56 bit result are not calculated. +// This can cause the result to be out by one as the lower bytes may cause carries into the upper ones. +// [intRes] (A B) is bits 24-39 and is the returned value. +// [longIn1] (C B A) is a 24 bit parameter. +// [longIn2] (D C B A) is a 32 bit parameter. // FORCE_INLINE static uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2) { uint8_t tmp1; @@ -66,11 +67,9 @@ FORCE_INLINE static uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2 A("add %[tmp2], r1") A("adc %A[intRes], %[tmp1]") A("adc %B[intRes], %[tmp1]") - A("lsr %[tmp2]") - A("adc %A[intRes], %[tmp1]") - A("adc %B[intRes], %[tmp1]") A("mul %D[longIn2], %A[longIn1]") - A("add %A[intRes], r0") + A("lsl %[tmp2]") + A("adc %A[intRes], r0") A("adc %B[intRes], r1") A("mul %D[longIn2], %B[longIn1]") A("add %B[intRes], r0") @@ -85,11 +84,16 @@ FORCE_INLINE static uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2 return intRes; } -// intRes = intIn1 * intIn2 >> 16 +// intRes = intIn1 * intIn2 >> 8 // uses: -// r26 to store 0 -// r27 to store the byte 1 of the 24 bit result -FORCE_INLINE static uint16_t MultiU16X8toH16(uint8_t charIn1, uint16_t intIn2) { +// r1, r0 for the result of mul. After the second mul, r0 holds bits 0-7 of the 24 bit result and +// the top bit of r0 is used for rounding. +// [tmp] to store 0. +// [intRes] (A B) is bits 8-15 and is the returned value. +// [charIn1] is an 8 bit parameter. +// [intIn2] (B A) is a 16 bit parameter. +// +FORCE_INLINE static uint16_t MultiU8X16toH16(uint8_t charIn1, uint16_t intIn2) { uint8_t tmp; uint16_t intRes; __asm__ __volatile__ ( @@ -97,10 +101,8 @@ FORCE_INLINE static uint16_t MultiU16X8toH16(uint8_t charIn1, uint16_t intIn2) { A("mul %[charIn1], %B[intIn2]") A("movw %A[intRes], r0") A("mul %[charIn1], %A[intIn2]") - A("add %A[intRes], r1") - A("adc %B[intRes], %[tmp]") - A("lsr r0") - A("adc %A[intRes], %[tmp]") + A("lsl r0") + A("adc %A[intRes], r1") A("adc %B[intRes], %[tmp]") A("clr r1") : [intRes] "=&r" (intRes), diff --git a/Marlin/src/HAL/AVR/pinsDebug.h b/Marlin/src/HAL/AVR/pinsDebug.h index dab4e4471524..b91bde182d35 100644 --- a/Marlin/src/HAL/AVR/pinsDebug.h +++ b/Marlin/src/HAL/AVR/pinsDebug.h @@ -64,11 +64,13 @@ #define VALID_PIN(pin) (pin >= 0 && pin < NUM_DIGITAL_PINS ? 1 : 0) #if AVR_ATmega1284_FAMILY - #define DIGITAL_PIN_TO_ANALOG_PIN(P) int(analogInputToDigitalPin(0) - (P)) - #define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(7) && (P) <= analogInputToDigitalPin(0)) + #define IS_ANALOG(P) WITHIN(P, analogInputToDigitalPin(7), analogInputToDigitalPin(0)) + #define DIGITAL_PIN_TO_ANALOG_PIN(P) int(IS_ANALOG(P) ? (P) - analogInputToDigitalPin(7) : -1) #else - #define DIGITAL_PIN_TO_ANALOG_PIN(P) int((P) - analogInputToDigitalPin(0)) - #define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && ((P) <= analogInputToDigitalPin(15) || (P) <= analogInputToDigitalPin(7))) + #define _ANALOG1(P) WITHIN(P, analogInputToDigitalPin(0), analogInputToDigitalPin(7)) + #define _ANALOG2(P) WITHIN(P, analogInputToDigitalPin(8), analogInputToDigitalPin(15)) + #define IS_ANALOG(P) (_ANALOG1(P) || _ANALOG2(P)) + #define DIGITAL_PIN_TO_ANALOG_PIN(P) int(_ANALOG1(P) ? (P) - analogInputToDigitalPin(0) : _ANALOG2(P) ? (P) - analogInputToDigitalPin(8) + 8 : -1) #endif #define GET_ARRAY_PIN(p) pgm_read_byte(&pin_array[p].pin) #define MULTI_NAME_PAD 26 // space needed to be pretty if not first name assigned to a pin diff --git a/Marlin/src/HAL/AVR/timers.h b/Marlin/src/HAL/AVR/timers.h index 33c3880b6b99..d9cdfc4f0131 100644 --- a/Marlin/src/HAL/AVR/timers.h +++ b/Marlin/src/HAL/AVR/timers.h @@ -44,14 +44,14 @@ typedef uint16_t hal_timer_t; #define MF_TIMER_TEMP 0 #endif -#define TEMP_TIMER_FREQUENCY ((F_CPU) / 64.0 / 256.0) +#define TEMP_TIMER_FREQUENCY (((F_CPU) + 0x2000) / 0x4000) #define STEPPER_TIMER_RATE HAL_TIMER_RATE #define STEPPER_TIMER_PRESCALE 8 -#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // Cannot be of type double +#define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) -#define PULSE_TIMER_RATE STEPPER_TIMER_RATE // frequency of pulse timer -#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE #define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US #define ENABLE_STEPPER_DRIVER_INTERRUPT() SBI(TIMSK1, OCIE1A) 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/Servo.cpp b/Marlin/src/HAL/DUE/Servo.cpp index 72a7d649ef04..2dab88238dd6 100644 --- a/Marlin/src/HAL/DUE/Servo.cpp +++ b/Marlin/src/HAL/DUE/Servo.cpp @@ -47,7 +47,7 @@ #include "../shared/servo.h" #include "../shared/servo_private.h" -static volatile int8_t Channel[_Nbr_16timers]; // counter for the servo being pulsed for each timer (or -1 if refresh interval) +static Flags<_Nbr_16timers> DisablePending; // ISR should disable the timer at the next timer reset // ------------------------ /// Interrupt handler for the TC0 channel 1. @@ -71,82 +71,91 @@ void Servo_Handler(const timer16_Sequence_t, Tc*, const uint8_t); #endif void Servo_Handler(const timer16_Sequence_t timer, Tc *tc, const uint8_t channel) { - // clear interrupt - tc->TC_CHANNEL[channel].TC_SR; - if (Channel[timer] < 0) - tc->TC_CHANNEL[channel].TC_CCR |= TC_CCR_SWTRG; // channel set to -1 indicated that refresh interval completed so reset the timer - else if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && SERVO(timer, Channel[timer]).Pin.isActive) - extDigitalWrite(SERVO(timer, Channel[timer]).Pin.nbr, LOW); // pulse this channel low if activated - - Channel[timer]++; // increment to the next channel - if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) { - tc->TC_CHANNEL[channel].TC_RA = tc->TC_CHANNEL[channel].TC_CV + SERVO(timer,Channel[timer]).ticks; - if (SERVO(timer,Channel[timer]).Pin.isActive) // check if activated - extDigitalWrite(SERVO(timer, Channel[timer]).Pin.nbr, HIGH); // its an active channel so pulse it high + static int8_t Channel[_Nbr_16timers]; // Servo counters to pulse (or -1 for refresh interval) + int8_t cho = Channel[timer]; // Handle the prior Channel[timer] first + if (cho < 0) { // Channel -1 indicates the refresh interval completed... + tc->TC_CHANNEL[channel].TC_CCR |= TC_CCR_SWTRG; // ...so reset the timer + if (DisablePending[timer]) { + // Disabling only after the full servo period expires prevents + // pulses being too close together if immediately re-enabled. + DisablePending.clear(timer); + TC_Stop(tc, channel); + tc->TC_CHANNEL[channel].TC_SR; // clear interrupt + return; + } + } + else if (SERVO_INDEX(timer, cho) < ServoCount) // prior channel handled? + extDigitalWrite(SERVO(timer, cho).Pin.nbr, LOW); // pulse the prior channel LOW + + Channel[timer] = ++cho; // go to the next channel (or 0) + if (cho < SERVOS_PER_TIMER && SERVO_INDEX(timer, cho) < ServoCount) { + tc->TC_CHANNEL[channel].TC_RA = tc->TC_CHANNEL[channel].TC_CV + SERVO(timer, cho).ticks; + if (SERVO(timer, cho).Pin.isActive) // activated? + extDigitalWrite(SERVO(timer, cho).Pin.nbr, HIGH); // yes: pulse HIGH } else { // finished all channels so wait for the refresh period to expire before starting over - tc->TC_CHANNEL[channel].TC_RA = - tc->TC_CHANNEL[channel].TC_CV < usToTicks(REFRESH_INTERVAL) - 4 - ? (unsigned int)usToTicks(REFRESH_INTERVAL) // allow a few ticks to ensure the next OCR1A not missed - : tc->TC_CHANNEL[channel].TC_CV + 4; // at least REFRESH_INTERVAL has elapsed - Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel + const unsigned int cval = tc->TC_CHANNEL[channel].TC_CV + 128 / (SERVO_TIMER_PRESCALER), // allow 128 cycles to ensure the next CV not missed + ival = (unsigned int)usToTicks(REFRESH_INTERVAL); // at least REFRESH_INTERVAL has elapsed + tc->TC_CHANNEL[channel].TC_RA = max(cval, ival); + + Channel[timer] = -1; // reset the timer CCR on the next call } + + tc->TC_CHANNEL[channel].TC_SR; // clear interrupt } static void _initISR(Tc *tc, uint32_t channel, uint32_t id, IRQn_Type irqn) { pmc_enable_periph_clk(id); TC_Configure(tc, channel, - TC_CMR_TCCLKS_TIMER_CLOCK3 | // MCK/32 - TC_CMR_WAVE | // Waveform mode - TC_CMR_WAVSEL_UP_RC ); // Counter running up and reset when equals to RC - - /* 84MHz, MCK/32, for 1.5ms: 3937 */ - TC_SetRA(tc, channel, 2625); // 1ms - - /* Configure and enable interrupt */ + TC_CMR_WAVE // Waveform mode + | TC_CMR_WAVSEL_UP_RC // Counter running up and reset when equal to RC + | (SERVO_TIMER_PRESCALER == 2 ? TC_CMR_TCCLKS_TIMER_CLOCK1 : 0) // MCK/2 + | (SERVO_TIMER_PRESCALER == 8 ? TC_CMR_TCCLKS_TIMER_CLOCK2 : 0) // MCK/8 + | (SERVO_TIMER_PRESCALER == 32 ? TC_CMR_TCCLKS_TIMER_CLOCK3 : 0) // MCK/32 + | (SERVO_TIMER_PRESCALER == 128 ? TC_CMR_TCCLKS_TIMER_CLOCK4 : 0) // MCK/128 + ); + + // Wait 1ms before the first ISR + TC_SetRA(tc, channel, (F_CPU) / (SERVO_TIMER_PRESCALER) / 1000UL); // 1ms + + // Configure and enable interrupt NVIC_EnableIRQ(irqn); - // TC_IER_CPAS: RA Compare - tc->TC_CHANNEL[channel].TC_IER = TC_IER_CPAS; + tc->TC_CHANNEL[channel].TC_IER = TC_IER_CPAS; // TC_IER_CPAS: RA Compare // Enables the timer clock and performs a software reset to start the counting TC_Start(tc, channel); } -void initISR(const timer16_Sequence_t timer) { - #ifdef _useTimer1 - if (timer == _timer1) _initISR(TC_FOR_TIMER1, CHANNEL_FOR_TIMER1, ID_TC_FOR_TIMER1, IRQn_FOR_TIMER1); - #endif - #ifdef _useTimer2 - if (timer == _timer2) _initISR(TC_FOR_TIMER2, CHANNEL_FOR_TIMER2, ID_TC_FOR_TIMER2, IRQn_FOR_TIMER2); - #endif - #ifdef _useTimer3 - if (timer == _timer3) _initISR(TC_FOR_TIMER3, CHANNEL_FOR_TIMER3, ID_TC_FOR_TIMER3, IRQn_FOR_TIMER3); - #endif - #ifdef _useTimer4 - if (timer == _timer4) _initISR(TC_FOR_TIMER4, CHANNEL_FOR_TIMER4, ID_TC_FOR_TIMER4, IRQn_FOR_TIMER4); - #endif - #ifdef _useTimer5 - if (timer == _timer5) _initISR(TC_FOR_TIMER5, CHANNEL_FOR_TIMER5, ID_TC_FOR_TIMER5, IRQn_FOR_TIMER5); - #endif +void initISR(const timer16_Sequence_t timer_index) { + CRITICAL_SECTION_START(); + const bool disable_soon = DisablePending[timer_index]; + DisablePending.clear(timer_index); + CRITICAL_SECTION_END(); + + if (!disable_soon) switch (timer_index) { + default: break; + #ifdef _useTimer1 + case _timer1: return _initISR(TC_FOR_TIMER1, CHANNEL_FOR_TIMER1, ID_TC_FOR_TIMER1, IRQn_FOR_TIMER1); + #endif + #ifdef _useTimer2 + case _timer2: return _initISR(TC_FOR_TIMER2, CHANNEL_FOR_TIMER2, ID_TC_FOR_TIMER2, IRQn_FOR_TIMER2); + #endif + #ifdef _useTimer3 + case _timer3: return _initISR(TC_FOR_TIMER3, CHANNEL_FOR_TIMER3, ID_TC_FOR_TIMER3, IRQn_FOR_TIMER3); + #endif + #ifdef _useTimer4 + case _timer4: return _initISR(TC_FOR_TIMER4, CHANNEL_FOR_TIMER4, ID_TC_FOR_TIMER4, IRQn_FOR_TIMER4); + #endif + #ifdef _useTimer5 + case _timer5: return _initISR(TC_FOR_TIMER5, CHANNEL_FOR_TIMER5, ID_TC_FOR_TIMER5, IRQn_FOR_TIMER5); + #endif + } } -void finISR(timer16_Sequence_t) { - #ifdef _useTimer1 - TC_Stop(TC_FOR_TIMER1, CHANNEL_FOR_TIMER1); - #endif - #ifdef _useTimer2 - TC_Stop(TC_FOR_TIMER2, CHANNEL_FOR_TIMER2); - #endif - #ifdef _useTimer3 - TC_Stop(TC_FOR_TIMER3, CHANNEL_FOR_TIMER3); - #endif - #ifdef _useTimer4 - TC_Stop(TC_FOR_TIMER4, CHANNEL_FOR_TIMER4); - #endif - #ifdef _useTimer5 - TC_Stop(TC_FOR_TIMER5, CHANNEL_FOR_TIMER5); - #endif +void finISR(const timer16_Sequence_t timer_index) { + // Timer is disabled from the ISR, to ensure proper final pulse length. + DisablePending.set(timer_index); } #endif // HAS_SERVOS diff --git a/Marlin/src/HAL/DUE/ServoTimers.h b/Marlin/src/HAL/DUE/ServoTimers.h index c32c93825399..95bd404c8061 100644 --- a/Marlin/src/HAL/DUE/ServoTimers.h +++ b/Marlin/src/HAL/DUE/ServoTimers.h @@ -37,7 +37,7 @@ #define _useTimer5 #define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays -#define SERVO_TIMER_PRESCALER 32 // timer prescaler +#define SERVO_TIMER_PRESCALER 2 // timer prescaler /* TC0, chan 0 => TC0_Handler diff --git a/Marlin/src/HAL/DUE/inc/Conditionals_LCD.h b/Marlin/src/HAL/DUE/inc/Conditionals_LCD.h index 58674144470c..5f1c4b16019d 100644 --- a/Marlin/src/HAL/DUE/inc/Conditionals_LCD.h +++ b/Marlin/src/HAL/DUE/inc/Conditionals_LCD.h @@ -20,7 +20,3 @@ * */ #pragma once - -#if HAS_SPI_TFT || HAS_FSMC_TFT - #error "Sorry! TFT displays are not available for HAL/DUE." -#endif diff --git a/Marlin/src/HAL/DUE/inc/SanityCheck.h b/Marlin/src/HAL/DUE/inc/SanityCheck.h index 13484f7029d1..5f0a05baff23 100644 --- a/Marlin/src/HAL/DUE/inc/SanityCheck.h +++ b/Marlin/src/HAL/DUE/inc/SanityCheck.h @@ -25,6 +25,10 @@ * Test Arduino Due specific configuration values for errors at compile-time. */ +#if HAS_SPI_TFT || HAS_FSMC_TFT + #error "Sorry! TFT displays are not available for HAL/DUE." +#endif + /** * Check for common serial pin conflicts */ @@ -36,15 +40,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 @@ -77,7 +81,7 @@ #endif #if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY - #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on DUE." + #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported for HAL/DUE." #endif #if HAS_TMC_SW_SERIAL 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/DUE/timers.cpp b/Marlin/src/HAL/DUE/timers.cpp index a7bf7fbd6d85..e5647817b6f0 100644 --- a/Marlin/src/HAL/DUE/timers.cpp +++ b/Marlin/src/HAL/DUE/timers.cpp @@ -89,10 +89,17 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { NVIC_SetPriority(irq, timer_config[timer_num].priority); // wave mode, reset counter on match with RC, - TC_Configure(tc, channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK1); + TC_Configure(tc, channel, + TC_CMR_WAVE + | TC_CMR_WAVSEL_UP_RC + | (HAL_TIMER_PRESCALER == 2 ? TC_CMR_TCCLKS_TIMER_CLOCK1 : 0) + | (HAL_TIMER_PRESCALER == 8 ? TC_CMR_TCCLKS_TIMER_CLOCK2 : 0) + | (HAL_TIMER_PRESCALER == 32 ? TC_CMR_TCCLKS_TIMER_CLOCK3 : 0) + | (HAL_TIMER_PRESCALER == 128 ? TC_CMR_TCCLKS_TIMER_CLOCK4 : 0) + ); // Set compare value - TC_SetRC(tc, channel, VARIANT_MCK / 2 / frequency); + TC_SetRC(tc, channel, VARIANT_MCK / (HAL_TIMER_PRESCALER) / frequency); // And start timer TC_Start(tc, channel); diff --git a/Marlin/src/HAL/DUE/timers.h b/Marlin/src/HAL/DUE/timers.h index bcfd07e268c5..dc35c77e6384 100644 --- a/Marlin/src/HAL/DUE/timers.h +++ b/Marlin/src/HAL/DUE/timers.h @@ -35,7 +35,8 @@ typedef uint32_t hal_timer_t; #define HAL_TIMER_TYPE_MAX 0xFFFFFFFF -#define HAL_TIMER_RATE ((F_CPU) / 2) // frequency of timers peripherals +#define HAL_TIMER_PRESCALER 2 +#define HAL_TIMER_RATE ((F_CPU) / (HAL_TIMER_PRESCALER)) // frequency of timers peripherals #ifndef MF_TIMER_STEP #define MF_TIMER_STEP 2 // Timer Index for Stepper 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/Marlin/src/HAL/DUE/usb/compiler.h b/Marlin/src/HAL/DUE/usb/compiler.h index f89e554c4562..633197914eef 100644 --- a/Marlin/src/HAL/DUE/usb/compiler.h +++ b/Marlin/src/HAL/DUE/usb/compiler.h @@ -1059,7 +1059,7 @@ static inline void convert_64_bit_to_byte_array(uint64_t value, uint8_t *data) while (val_index < 8) { data[val_index++] = value & 0xFF; - value = value >> 8; + value >>= 8; } } 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/HAL/ESP32/HAL.cpp b/Marlin/src/HAL/ESP32/HAL.cpp index 65af39786eeb..46dd4e761b8c 100644 --- a/Marlin/src/HAL/ESP32/HAL.cpp +++ b/Marlin/src/HAL/ESP32/HAL.cpp @@ -65,6 +65,7 @@ portMUX_TYPE MarlinHAL::spinlock = portMUX_INITIALIZER_UNLOCKED; // ------------------------ uint16_t MarlinHAL::adc_result; +pwm_pin_t MarlinHAL::pwm_pin_data[MAX_EXPANDER_BITS]; // ------------------------ // Private Variables @@ -330,14 +331,37 @@ int8_t get_pwm_channel(const pin_t pin, const uint32_t freq, const uint16_t res) } void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=_BV(PWM_RESOLUTION)-1*/, const bool invert/*=false*/) { + #if ENABLED(I2S_STEPPER_STREAM) + if (pin > 127) { + const uint8_t pinlo = pin & 0x7F; + pwm_pin_t &pindata = pwm_pin_data[pinlo]; + const uint32_t duty = map(invert ? v_size - v : v, 0, v_size, 0, pindata.pwm_cycle_ticks); + if (duty == 0 || duty == pindata.pwm_cycle_ticks) { // max or min (i.e., on/off) + pindata.pwm_duty_ticks = 0; // turn off PWM for this pin + duty ? SBI32(i2s_port_data, pinlo) : CBI32(i2s_port_data, pinlo); // set pin level + } + else + pindata.pwm_duty_ticks = duty; // PWM duty count = # of 4µs ticks per full PWM cycle + + return; + } + #endif + const int8_t cid = get_pwm_channel(pin, PWM_FREQUENCY, PWM_RESOLUTION); if (cid >= 0) { - uint32_t duty = map(invert ? v_size - v : v, 0, v_size, 0, _BV(PWM_RESOLUTION)-1); + const uint32_t duty = map(invert ? v_size - v : v, 0, v_size, 0, _BV(PWM_RESOLUTION)-1); ledcWrite(cid, duty); } } int8_t MarlinHAL::set_pwm_frequency(const pin_t pin, const uint32_t f_desired) { + #if ENABLED(I2S_STEPPER_STREAM) + if (pin > 127) { + pwm_pin_data[pin & 0x7F].pwm_cycle_ticks = 1000000UL / f_desired / 4; // # of 4µs ticks per full PWM cycle + return 0; + } + #endif + const int8_t cid = channel_for_pin(pin); if (cid >= 0) { if (f_desired == ledcReadFreq(cid)) return cid; // no freq change diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h index a07303d4891f..5dc9b2cfe2e8 100644 --- a/Marlin/src/HAL/ESP32/HAL.h +++ b/Marlin/src/HAL/ESP32/HAL.h @@ -50,24 +50,25 @@ #define MYSERIAL1 flushableSerial -#if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT) - #if ENABLED(ESP3D_WIFISUPPORT) - typedef ForwardSerial1Class< decltype(Serial2Socket) > DefaultSerial1; - extern DefaultSerial1 MSerial0; - #define MYSERIAL2 MSerial0 - #else - #define MYSERIAL2 webSocketSerial - #endif +#if ENABLED(ESP3D_WIFISUPPORT) + typedef ForwardSerial1Class< decltype(Serial2Socket) > DefaultSerial1; + extern DefaultSerial1 MSerial0; + #define MYSERIAL2 MSerial0 +#elif ENABLED(WIFISUPPORT) + #define MYSERIAL2 webSocketSerial #endif -#define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock) -#define CRITICAL_SECTION_END() portEXIT_CRITICAL(&spinlock) +#define CRITICAL_SECTION_START() portENTER_CRITICAL(&hal.spinlock) +#define CRITICAL_SECTION_END() portEXIT_CRITICAL(&hal.spinlock) #define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment #define PWM_FREQUENCY 1000u // Default PWM frequency when set_pwm_duty() is called without set_pwm_frequency() #define PWM_RESOLUTION 10u // Default PWM bit resolution #define CHANNEL_MAX_NUM 15u // max PWM channel # to allocate (7 to only use low speed, 15 to use low & high) #define MAX_PWM_IOPIN 33u // hardware pwm pins < 34 +#ifndef MAX_EXPANDER_BITS + #define MAX_EXPANDER_BITS 32 // I2S expander bit width (max 32) +#endif // ------------------------ // Types @@ -76,6 +77,12 @@ typedef double isr_float_t; // FPU ops are used for single-precision, so use double for ISRs. typedef int16_t pin_t; +typedef struct pwm_pin { + uint32_t pwm_cycle_ticks = 1000000UL / (PWM_FREQUENCY) / 4; // # ticks per pwm cycle + uint32_t pwm_tick_count = 0; // current tick count + uint32_t pwm_duty_ticks = 0; // # of ticks for current duty cycle +} pwm_pin_t; + class Servo; typedef Servo hal_servo_t; @@ -197,6 +204,8 @@ class MarlinHAL { // Free SRAM static int freeMemory(); + static pwm_pin_t pwm_pin_data[MAX_EXPANDER_BITS]; + // // ADC Methods // diff --git a/Marlin/src/HAL/ESP32/i2s.cpp b/Marlin/src/HAL/ESP32/i2s.cpp index 3e77b658360b..63ceed4c9dcd 100644 --- a/Marlin/src/HAL/ESP32/i2s.cpp +++ b/Marlin/src/HAL/ESP32/i2s.cpp @@ -139,22 +139,38 @@ 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) { - i2s_push_sample(); - remaining--; - } - else { + if (!nextMainISR) { Stepper::pulse_phase_isr(); - remaining = Stepper::block_phase_isr(); + nextMainISR = Stepper::block_phase_isr(); } + #if ENABLED(LIN_ADVANCE) + else if (!nextAdvanceISR) { + Stepper::advance_isr(); + nextAdvanceISR = Stepper::la_interval; + } + #endif + else + i2s_push_sample(); + + nextMainISR--; + + #if ENABLED(LIN_ADVANCE) + if (nextAdvanceISR == Stepper::LA_ADV_NEVER) + nextAdvanceISR = Stepper::la_interval; + + if (nextAdvanceISR && nextAdvanceISR != Stepper::LA_ADV_NEVER) + nextAdvanceISR--; + #endif } } } @@ -337,6 +353,26 @@ uint8_t i2s_state(uint8_t pin) { } void i2s_push_sample() { + // Every 4µs (when space in DMA buffer) toggle each expander PWM output using + // the current duty cycle/frequency so they sync with any steps (once + // through the DMA/FIFO buffers). PWM signal inversion handled by other functions + LOOP_L_N(p, MAX_EXPANDER_BITS) { + if (hal.pwm_pin_data[p].pwm_duty_ticks > 0) { // pin has active pwm? + if (hal.pwm_pin_data[p].pwm_tick_count == 0) { + if (TEST32(i2s_port_data, p)) { // hi->lo + CBI32(i2s_port_data, p); + hal.pwm_pin_data[p].pwm_tick_count = hal.pwm_pin_data[p].pwm_cycle_ticks - hal.pwm_pin_data[p].pwm_duty_ticks; + } + else { // lo->hi + SBI32(i2s_port_data, p); + hal.pwm_pin_data[p].pwm_tick_count = hal.pwm_pin_data[p].pwm_duty_ticks; + } + } + else + hal.pwm_pin_data[p].pwm_tick_count--; + } + } + dma.current[dma.rw_pos++] = i2s_port_data; } diff --git a/Marlin/src/HAL/ESP32/inc/Conditionals_LCD.h b/Marlin/src/HAL/ESP32/inc/Conditionals_LCD.h index 4da600179d6c..5f1c4b16019d 100644 --- a/Marlin/src/HAL/ESP32/inc/Conditionals_LCD.h +++ b/Marlin/src/HAL/ESP32/inc/Conditionals_LCD.h @@ -20,7 +20,3 @@ * */ #pragma once - -#if HAS_SPI_TFT || HAS_FSMC_TFT - #error "Sorry! TFT displays are not available for HAL/ESP32." -#endif diff --git a/Marlin/src/HAL/ESP32/inc/Conditionals_adv.h b/Marlin/src/HAL/ESP32/inc/Conditionals_adv.h index 5f1c4b16019d..3ca806897a89 100644 --- a/Marlin/src/HAL/ESP32/inc/Conditionals_adv.h +++ b/Marlin/src/HAL/ESP32/inc/Conditionals_adv.h @@ -20,3 +20,10 @@ * */ #pragma once + +// +// Board-specific options need to be defined before HAL.h +// +#if MB(MKS_TINYBEE) + #define MAX_EXPANDER_BITS 24 // TinyBee has 3 x HC595 +#endif diff --git a/Marlin/src/HAL/ESP32/inc/SanityCheck.h b/Marlin/src/HAL/ESP32/inc/SanityCheck.h index 04d70ec14f0b..910918b9ea47 100644 --- a/Marlin/src/HAL/ESP32/inc/SanityCheck.h +++ b/Marlin/src/HAL/ESP32/inc/SanityCheck.h @@ -21,12 +21,19 @@ */ #pragma once +#if HAS_SPI_TFT || HAS_FSMC_TFT + #error "Sorry! TFT displays are not available for HAL/ESP32." +#endif + #if ENABLED(EMERGENCY_PARSER) #error "EMERGENCY_PARSER is not yet implemented for ESP32. Disable EMERGENCY_PARSER to continue." #endif -#if (ENABLED(SPINDLE_LASER_USE_PWM) && SPINDLE_LASER_FREQUENCY > 78125) || (ENABLED(FAST_PWM_FAN_FREQUENCY) && FAST_PWM_FAN_FREQUENCY > 78125) - #error "SPINDLE_LASER_FREQUENCY and FAST_PWM_FREQUENCY maximum value is 78125Hz for ESP32." +#if ENABLED(SPINDLE_LASER_USE_PWM) && SPINDLE_LASER_FREQUENCY > 78125 + #error "SPINDLE_LASER_FREQUENCY maximum value is 78125Hz for ESP32." +#endif +#if ENABLED(FAST_PWM_FAN) && FAST_PWM_FAN_FREQUENCY > 78125 + #error "FAST_PWM_FREQUENCY maximum value is 78125Hz for ESP32." #endif #if HAS_TMC_SW_SERIAL @@ -45,6 +52,18 @@ #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 + +#if BOTH(I2S_STEPPER_STREAM, LIN_ADVANCE) && DISABLED(EXPERIMENTAL_I2S_LA) + #error "I2S stream is currently incompatible with LIN_ADVANCE." +#endif + +#if BOTH(I2S_STEPPER_STREAM, PRINTCOUNTER) && PRINTCOUNTER_SAVE_INTERVAL > 0 && DISABLED(PRINTCOUNTER_SYNC) + #error "PRINTCOUNTER_SAVE_INTERVAL may cause issues on ESP32 with an I2S expander. Define PRINTCOUNTER_SYNC in Configuration.h for an imperfect solution." +#endif diff --git a/Marlin/src/HAL/ESP32/timers.cpp b/Marlin/src/HAL/ESP32/timers.cpp index c37ad2430cb2..a6893150b663 100644 --- a/Marlin/src/HAL/ESP32/timers.cpp +++ b/Marlin/src/HAL/ESP32/timers.cpp @@ -111,12 +111,12 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { /** * Set the upper value of the timer, when the timer reaches this upper value the * interrupt should be triggered and the counter reset - * @param timer_num timer number to set the count to - * @param count threshold at which the interrupt is triggered + * @param timer_num timer number to set the compare value to + * @param compare threshold at which the interrupt is triggered */ -void HAL_timer_set_compare(const uint8_t timer_num, hal_timer_t count) { +void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) { const tTimerConfig timer = timer_config[timer_num]; - timer_set_alarm_value(timer.group, timer.idx, count); + timer_set_alarm_value(timer.group, timer.idx, compare); } /** 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/HAL/HAL.h b/Marlin/src/HAL/HAL.h index 518657801905..f3e16cfdf12c 100644 --- a/Marlin/src/HAL/HAL.h +++ b/Marlin/src/HAL/HAL.h @@ -27,7 +27,7 @@ #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #endif -#include HAL_PATH(.,HAL.h) +#include HAL_PATH(..,HAL.h) extern MarlinHAL hal; #define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION) diff --git a/Marlin/src/HAL/LINUX/eeprom.cpp b/Marlin/src/HAL/LINUX/eeprom.cpp index 532f323c6edb..f878bba6a51b 100644 --- a/Marlin/src/HAL/LINUX/eeprom.cpp +++ b/Marlin/src/HAL/LINUX/eeprom.cpp @@ -69,12 +69,12 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui std::size_t bytes_written = 0; for (std::size_t i = 0; i < size; i++) { - buffer[pos+i] = value[i]; - bytes_written ++; + buffer[pos + i] = value[i]; + bytes_written++; } crc16(crc, value, size); - pos = pos + size; + pos += size; return (bytes_written != size); // return true for any error } @@ -82,21 +82,21 @@ bool PersistentStore::read_data(int &pos, uint8_t *value, const size_t size, uin std::size_t bytes_read = 0; if (writing) { for (std::size_t i = 0; i < size; i++) { - value[i] = buffer[pos+i]; - bytes_read ++; + value[i] = buffer[pos + i]; + bytes_read++; } crc16(crc, value, size); } else { uint8_t temp[size]; for (std::size_t i = 0; i < size; i++) { - temp[i] = buffer[pos+i]; - bytes_read ++; + temp[i] = buffer[pos + i]; + bytes_read++; } crc16(crc, temp, size); } - pos = pos + size; + pos += size; return bytes_read != size; // return true for any error } diff --git a/Marlin/src/HAL/LINUX/hardware/Heater.h b/Marlin/src/HAL/LINUX/hardware/Heater.h index b17078d0b739..6d590ce6c55e 100644 --- a/Marlin/src/HAL/LINUX/hardware/Heater.h +++ b/Marlin/src/HAL/LINUX/hardware/Heater.h @@ -26,8 +26,8 @@ struct LowpassFilter { uint64_t data_delay = 0; uint16_t update(uint16_t value) { - data_delay = data_delay - (data_delay >> 6) + value; - return (uint16_t)(data_delay >> 6); + data_delay += value - (data_delay >> 6); + return uint16_t(data_delay >> 6); } }; diff --git a/Marlin/src/HAL/LINUX/inc/Conditionals_LCD.h b/Marlin/src/HAL/LINUX/inc/Conditionals_LCD.h index 99a6fc27534a..5f1c4b16019d 100644 --- a/Marlin/src/HAL/LINUX/inc/Conditionals_LCD.h +++ b/Marlin/src/HAL/LINUX/inc/Conditionals_LCD.h @@ -20,7 +20,3 @@ * */ #pragma once - -#if HAS_SPI_TFT || HAS_FSMC_TFT - #error "Sorry! TFT displays are not available for HAL/LINUX." -#endif diff --git a/Marlin/src/HAL/LINUX/inc/SanityCheck.h b/Marlin/src/HAL/LINUX/inc/SanityCheck.h index 36d3190a3e08..861bade10ffd 100644 --- a/Marlin/src/HAL/LINUX/inc/SanityCheck.h +++ b/Marlin/src/HAL/LINUX/inc/SanityCheck.h @@ -31,13 +31,17 @@ #endif #if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY - #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on LINUX." + #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported for HAL/LINUX." +#endif + +#if HAS_SPI_TFT || HAS_FSMC_TFT + #error "Sorry! TFT displays are not available for HAL/LINUX." #endif #if HAS_TMC_SW_SERIAL - #error "TMC220x Software Serial is not supported on LINUX." + #error "TMC220x Software Serial is not supported for HAL/LINUX." #endif #if ENABLED(POSTMORTEM_DEBUGGING) - #error "POSTMORTEM_DEBUGGING is not yet supported on LINUX." + #error "POSTMORTEM_DEBUGGING is not yet supported for HAL/LINUX." #endif diff --git a/Marlin/src/HAL/LINUX/spi_pins.h b/Marlin/src/HAL/LINUX/spi_pins.h index 33136ac9dd80..9b406518738c 100644 --- a/Marlin/src/HAL/LINUX/spi_pins.h +++ b/Marlin/src/HAL/LINUX/spi_pins.h @@ -25,10 +25,10 @@ #include "../../inc/MarlinConfigPre.h" #if BOTH(HAS_MARLINUI_U8GLIB, SDSUPPORT) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_ENABLE == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN) - #define LPC_SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently - // needed due to the speed and mode required for communicating with each device being different. - // This requirement can be removed if the SPI access to these devices is updated to use - // spiBeginTransaction. + #define SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently + // needed due to the speed and mode required for communicating with each device being different. + // This requirement can be removed if the SPI access to these devices is updated to use + // spiBeginTransaction. #endif // Onboard SD diff --git a/Marlin/src/HAL/LPC1768/HAL_SPI.cpp b/Marlin/src/HAL/LPC1768/HAL_SPI.cpp index 29f9b43afef0..4d6cb55cff58 100644 --- a/Marlin/src/HAL/LPC1768/HAL_SPI.cpp +++ b/Marlin/src/HAL/LPC1768/HAL_SPI.cpp @@ -60,7 +60,7 @@ // ------------------------ // Public functions // ------------------------ -#if ENABLED(LPC_SOFTWARE_SPI) +#if ENABLED(SOFTWARE_SPI) // Software SPI @@ -161,7 +161,7 @@ // TODO: Implement this method } -#endif // LPC_SOFTWARE_SPI +#endif // SOFTWARE_SPI /** * @brief Wait until TXE (tx empty) flag is set and BSY (busy) flag unset. @@ -318,8 +318,16 @@ void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) { // Enable DMA GPDMA_ChannelCmd(0, ENABLE); + /* + * Observed behaviour on normal data transfer completion (SKR 1.3 board / LPC1768 MCU) + * GPDMA_STAT_INTTC flag is SET + * GPDMA_STAT_INTERR flag is NOT SET + * GPDMA_STAT_RAWINTTC flag is NOT SET + * GPDMA_STAT_RAWINTERR flag is SET + */ + // Wait for data transfer - while (!GPDMA_IntGetStatus(GPDMA_STAT_RAWINTTC, 0) && !GPDMA_IntGetStatus(GPDMA_STAT_RAWINTERR, 0)) { } + while (!GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0) && !GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)) {} // Clear err and int GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0); @@ -333,6 +341,43 @@ void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) { SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, DISABLE); } +void SPIClass::dmaSendAsync(void *buf, uint16_t length, bool minc) { + //TODO: LPC dma can only write 0xFFF bytes at once. + GPDMA_Channel_CFG_Type GPDMACfg; + + /* Configure GPDMA channel 0 -------------------------------------------------------------*/ + /* DMA Channel 0 */ + GPDMACfg.ChannelNum = 0; + // Source memory + GPDMACfg.SrcMemAddr = (uint32_t)buf; + // Destination memory - Not used + GPDMACfg.DstMemAddr = 0; + // Transfer size + GPDMACfg.TransferSize = length; + // Transfer width + GPDMACfg.TransferWidth = (_currentSetting->dataSize == DATA_SIZE_16BIT) ? GPDMA_WIDTH_HALFWORD : GPDMA_WIDTH_BYTE; + // Transfer type + GPDMACfg.TransferType = GPDMA_TRANSFERTYPE_M2P; + // Source connection - unused + GPDMACfg.SrcConn = 0; + // Destination connection + GPDMACfg.DstConn = (_currentSetting->spi_d == LPC_SSP0) ? GPDMA_CONN_SSP0_Tx : GPDMA_CONN_SSP1_Tx; + + GPDMACfg.DMALLI = 0; + + // Enable dma on SPI + SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, ENABLE); + + // Only increase memory if minc is true + GPDMACfg.MemoryIncrease = (minc ? GPDMA_DMACCxControl_SI : 0); + + // Setup channel with given parameter + GPDMA_Setup(&GPDMACfg); + + // Enable DMA + GPDMA_ChannelCmd(0, ENABLE); +} + uint16_t SPIClass::read() { return SSP_ReceiveData(_currentSetting->spi_d); } diff --git a/Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h b/Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h index 32ef908d633c..5f1c4b16019d 100644 --- a/Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h +++ b/Marlin/src/HAL/LPC1768/inc/Conditionals_LCD.h @@ -20,7 +20,3 @@ * */ #pragma once - -#if HAS_FSMC_TFT - #error "Sorry! FSMC TFT displays are not current available for HAL/LPC1768." -#endif diff --git a/Marlin/src/HAL/LPC1768/inc/Conditionals_post.h b/Marlin/src/HAL/LPC1768/inc/Conditionals_post.h index be574a96e4ed..a0bf4215383e 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 - #define PRINTCOUNTER_SYNC 1 +#if defined(MCU_LPC1768) && ENABLED(FLASH_EEPROM_EMULATION) && PRINTCOUNTER_SAVE_INTERVAL > 0 + #define PRINTCOUNTER_SYNC #endif diff --git a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h index 8265d58a6e8f..94923e21cf9a 100644 --- a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h +++ b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h @@ -77,6 +77,10 @@ static_assert(!(NUM_SERVOS && ENABLED(FAST_PWM_FAN)), "BLTOUCH and Servos are in #endif #endif +#if HAS_FSMC_TFT + #error "Sorry! FSMC TFT displays are not current available for HAL/LPC1768." +#endif + static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported on LPC176x."); /** diff --git a/Marlin/src/HAL/LPC1768/include/SPI.h b/Marlin/src/HAL/LPC1768/include/SPI.h index 24f4759315bd..03d34becd856 100644 --- a/Marlin/src/HAL/LPC1768/include/SPI.h +++ b/Marlin/src/HAL/LPC1768/include/SPI.h @@ -155,6 +155,7 @@ class SPIClass { void read(uint8_t *buf, uint32_t len); void dmaSend(void *buf, uint16_t length, bool minc); + void dmaSendAsync(void *buf, uint16_t length, bool minc); /** * @brief Sets the number of the SPI peripheral to be used by diff --git a/Marlin/src/HAL/LPC1768/pinsDebug.h b/Marlin/src/HAL/LPC1768/pinsDebug.h index a2f5c123a260..ae8901b0137a 100644 --- a/Marlin/src/HAL/LPC1768/pinsDebug.h +++ b/Marlin/src/HAL/LPC1768/pinsDebug.h @@ -29,8 +29,8 @@ */ #define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS -#define pwm_details(pin) pin = pin // do nothing // print PWM details -#define pwm_status(pin) false //Print a pin's PWM status. Return true if it's currently a PWM pin. +#define pwm_details(pin) NOOP // do nothing +#define pwm_status(pin) false // Print a pin's PWM status. Return true if it's currently a PWM pin. #define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P) >= 0 ? 1 : 0) #define digitalRead_mod(p) extDigitalRead(p) #define PRINT_PORT(p) diff --git a/Marlin/src/HAL/LPC1768/spi_pins.h b/Marlin/src/HAL/LPC1768/spi_pins.h index e7d774742f42..a82b21dda91f 100644 --- a/Marlin/src/HAL/LPC1768/spi_pins.h +++ b/Marlin/src/HAL/LPC1768/spi_pins.h @@ -24,10 +24,10 @@ #include "../../core/macros.h" #if BOTH(SDSUPPORT, HAS_MARLINUI_U8GLIB) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_ENABLE == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN) - #define LPC_SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently - // needed due to the speed and mode required for communicating with each device being different. - // This requirement can be removed if the SPI access to these devices is updated to use - // spiBeginTransaction. + #define SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently + // needed due to the speed and mode required for communicating with each device being different. + // This requirement can be removed if the SPI access to these devices is updated to use + // spiBeginTransaction. #endif /** onboard SD card */ diff --git a/Marlin/src/HAL/LPC1768/tft/tft_spi.cpp b/Marlin/src/HAL/LPC1768/tft/tft_spi.cpp index a9847b2d2fa0..804fc85e792f 100644 --- a/Marlin/src/HAL/LPC1768/tft/tft_spi.cpp +++ b/Marlin/src/HAL/LPC1768/tft/tft_spi.cpp @@ -26,7 +26,7 @@ #include "tft_spi.h" -SPIClass TFT_SPI::SPIx(1); +SPIClass TFT_SPI::SPIx(TFT_SPI_DEVICE); void TFT_SPI::Init() { #if PIN_EXISTS(TFT_RESET) @@ -38,40 +38,10 @@ void TFT_SPI::Init() { OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH); #endif - SET_OUTPUT(TFT_DC_PIN); - SET_OUTPUT(TFT_CS_PIN); - WRITE(TFT_DC_PIN, HIGH); - WRITE(TFT_CS_PIN, HIGH); - - /** - * STM32F1 APB2 = 72MHz, APB1 = 36MHz, max SPI speed of this MCU if 18Mhz - * STM32F1 has 3 SPI ports, SPI1 in APB2, SPI2/SPI3 in APB1 - * so the minimum prescale of SPI1 is DIV4, SPI2/SPI3 is DIV2 - */ - #if 0 - #if SPI_DEVICE == 1 - #define SPI_CLOCK_MAX SPI_CLOCK_DIV4 - #else - #define SPI_CLOCK_MAX SPI_CLOCK_DIV2 - #endif - uint8_t clock; - uint8_t spiRate = SPI_FULL_SPEED; - switch (spiRate) { - case SPI_FULL_SPEED: clock = SPI_CLOCK_MAX ; break; - case SPI_HALF_SPEED: clock = SPI_CLOCK_DIV4 ; break; - case SPI_QUARTER_SPEED: clock = SPI_CLOCK_DIV8 ; break; - case SPI_EIGHTH_SPEED: clock = SPI_CLOCK_DIV16; break; - case SPI_SPEED_5: clock = SPI_CLOCK_DIV32; break; - case SPI_SPEED_6: clock = SPI_CLOCK_DIV64; break; - default: clock = SPI_CLOCK_DIV2; // Default from the SPI library - } - #endif + OUT_WRITE(TFT_DC_PIN, HIGH); + OUT_WRITE(TFT_CS_PIN, HIGH); - #if TFT_MISO_PIN == BOARD_SPI1_MISO_PIN - SPIx.setModule(1); - #elif TFT_MISO_PIN == BOARD_SPI2_MISO_PIN - SPIx.setModule(2); - #endif + SPIx.setModule(TFT_SPI_DEVICE); SPIx.setClock(SPI_CLOCK_MAX_TFT); SPIx.setBitOrder(MSBFIRST); SPIx.setDataMode(SPI_MODE0); @@ -114,17 +84,62 @@ uint32_t TFT_SPI::ReadID(uint16_t Reg) { return data >> 7; } -bool TFT_SPI::isBusy() { return false; } +bool TFT_SPI::isBusy() { + #define __IS_DMA_CONFIGURED(__HANDLE__) ((__HANDLE__)->DMACCSrcAddr != 0) + + // DMA Channel 0 is hardcoded in dmaSendAsync() and dmaSend() + if (!__IS_DMA_CONFIGURED(LPC_GPDMACH0)) return false; + + if (GPDMA_IntGetStatus(GPDMA_STAT_INTERR, 0)) { + // You should not be here - DMA transfer error flag is set + // Abort DMA transfer and release SPI + } + else { + // Check if DMA transfer completed flag is set + if (!GPDMA_IntGetStatus(GPDMA_STAT_INTTC, 0)) return true; + // Check if SPI TX butter is empty and SPI is idle + if ((SSP_GetStatus(LPC_SSPx, SSP_STAT_TXFIFO_EMPTY) == RESET) || (SSP_GetStatus(LPC_SSPx, SSP_STAT_BUSY) == SET)) return true; + } + + Abort(); + return false; +} + +void TFT_SPI::Abort() { + // DMA Channel 0 is hardcoded in dmaSendAsync() and dmaSend() + + // Disable DMA + GPDMA_ChannelCmd(0, DISABLE); + + // Clear ERR and TC + GPDMA_ClearIntPending(GPDMA_STATCLR_INTTC, 0); + GPDMA_ClearIntPending(GPDMA_STATCLR_INTERR, 0); + + // Disable DMA on SPI + SSP_DMACmd(LPC_SSPx, SSP_DMA_TX, DISABLE); + + // Deconfigure DMA Channel 0 + LPC_GPDMACH0->DMACCControl = 0U; + LPC_GPDMACH0->DMACCConfig = 0U; + LPC_GPDMACH0->DMACCSrcAddr = 0U; + LPC_GPDMACH0->DMACCDestAddr = 0U; -void TFT_SPI::Abort() { DataTransferEnd(); } + DataTransferEnd(); +} void TFT_SPI::Transmit(uint16_t Data) { SPIx.transfer(Data); } -void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { +void TFT_SPI::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { DataTransferBegin(DATASIZE_16BIT); - WRITE(TFT_DC_PIN, HIGH); SPIx.dmaSend(Data, Count, MemoryIncrease); - DataTransferEnd(); + Abort(); +} + +void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { + DataTransferBegin(DATASIZE_16BIT); + SPIx.dmaSendAsync(Data, Count, MemoryIncrease); + + TERN_(TFT_SHARED_SPI, while (isBusy())); } #endif // HAS_SPI_TFT diff --git a/Marlin/src/HAL/LPC1768/tft/tft_spi.h b/Marlin/src/HAL/LPC1768/tft/tft_spi.h index 4753fdbae9a0..dad393981ed1 100644 --- a/Marlin/src/HAL/LPC1768/tft/tft_spi.h +++ b/Marlin/src/HAL/LPC1768/tft/tft_spi.h @@ -27,6 +27,18 @@ #include // #include +#define IS_SPI(N) (BOARD_NR_SPI >= N && (TFT_SCK_PIN == BOARD_SPI##N##_SCK_PIN) && (TFT_MOSI_PIN == BOARD_SPI##N##_MOSI_PIN) && (TFT_MISO_PIN == BOARD_SPI##N##_MISO_PIN)) +#if IS_SPI(1) + #define TFT_SPI_DEVICE 1 + #define LPC_SSPx LPC_SSP0 +#elif IS_SPI(2) + #define TFT_SPI_DEVICE 2 + #define LPC_SSPx LPC_SSP1 +#else + #error "Invalid TFT SPI configuration." +#endif +#undef IS_SPI + #ifndef LCD_READ_ID #define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341) #endif @@ -34,17 +46,19 @@ #define LCD_READ_ID4 0xD3 // Read display identification information (0xD3 on ILI9341) #endif -#define DATASIZE_8BIT SSP_DATABIT_8 -#define DATASIZE_16BIT SSP_DATABIT_16 -#define TFT_IO_DRIVER TFT_SPI +#define DATASIZE_8BIT SSP_DATABIT_8 +#define DATASIZE_16BIT SSP_DATABIT_16 +#define TFT_IO_DRIVER TFT_SPI +#define DMA_MAX_SIZE 0xFFF -#define DMA_MINC_ENABLE 1 -#define DMA_MINC_DISABLE 0 +#define DMA_MINC_ENABLE 1 +#define DMA_MINC_DISABLE 0 class TFT_SPI { private: static uint32_t ReadID(uint16_t Reg); static void Transmit(uint16_t Data); + static void Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); public: @@ -56,22 +70,20 @@ class TFT_SPI { static void Abort(); static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT); - static void DataTransferEnd() { OUT_WRITE(TFT_CS_PIN, HIGH); SPIx.end(); }; + static void DataTransferEnd() { WRITE(TFT_CS_PIN, HIGH); SSP_Cmd(LPC_SSPx, DISABLE); }; static void DataTransferAbort(); static void WriteData(uint16_t Data) { Transmit(Data); } - static void WriteReg(uint16_t Reg) { OUT_WRITE(TFT_A0_PIN, LOW); Transmit(Reg); OUT_WRITE(TFT_A0_PIN, HIGH); } + static void WriteReg(uint16_t Reg) { WRITE(TFT_DC_PIN, LOW); Transmit(Reg); WRITE(TFT_DC_PIN, HIGH); } + + static void WriteSequence_DMA(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); } + static void WriteMultiple_DMA(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } - static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); } - // static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } + static void WriteSequence(uint16_t *Data, uint16_t Count) { Transmit(DMA_MINC_ENABLE, Data, Count); } static void WriteMultiple(uint16_t Color, uint32_t Count) { - static uint16_t Data; Data = Color; - //LPC dma can only write 0xFFF bytes at once. - #define MAX_DMA_SIZE (0xFFF - 1) while (Count > 0) { - TransmitDMA(DMA_MINC_DISABLE, &Data, Count > MAX_DMA_SIZE ? MAX_DMA_SIZE : Count); - Count = Count > MAX_DMA_SIZE ? Count - MAX_DMA_SIZE : 0; + Transmit(DMA_MINC_DISABLE, &Color, Count > DMA_MAX_SIZE ? DMA_MAX_SIZE : Count); + Count = Count > DMA_MAX_SIZE ? Count - DMA_MAX_SIZE : 0; } - #undef MAX_DMA_SIZE } }; diff --git a/Marlin/src/HAL/LPC1768/tft/xpt2046.cpp b/Marlin/src/HAL/LPC1768/tft/xpt2046.cpp index 9c1e158981da..68a2176f5ed6 100644 --- a/Marlin/src/HAL/LPC1768/tft/xpt2046.cpp +++ b/Marlin/src/HAL/LPC1768/tft/xpt2046.cpp @@ -44,9 +44,11 @@ uint16_t delta(uint16_t a, uint16_t b) { return a > b ? a - b : b - a; } #endif void XPT2046::Init() { - SET_INPUT(TOUCH_MISO_PIN); - SET_OUTPUT(TOUCH_MOSI_PIN); - SET_OUTPUT(TOUCH_SCK_PIN); + #if DISABLED(TOUCH_BUTTONS_HW_SPI) + SET_INPUT(TOUCH_MISO_PIN); + SET_OUTPUT(TOUCH_MOSI_PIN); + SET_OUTPUT(TOUCH_SCK_PIN); + #endif OUT_WRITE(TOUCH_CS_PIN, HIGH); #if PIN_EXISTS(TOUCH_INT) diff --git a/Marlin/src/HAL/LPC1768/upload_extra_script.py b/Marlin/src/HAL/LPC1768/upload_extra_script.py index 7975f151f712..efd46fdd6309 100755 --- a/Marlin/src/HAL/LPC1768/upload_extra_script.py +++ b/Marlin/src/HAL/LPC1768/upload_extra_script.py @@ -9,119 +9,127 @@ import pioutil if pioutil.is_pio_build(): - target_filename = "FIRMWARE.CUR" - target_drive = "REARM" + target_filename = "FIRMWARE.CUR" + target_drive = "REARM" - import os,getpass,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: - # - # 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 + 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 = final_drive_name - if target_filename in volume_info: - if not target_file_found: - upload_disk = 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' - # - drives = os.listdir(os.path.join(os.sep, 'media', getpass.getuser())) - if target_drive in drives: # If target drive is found, use it. - target_drive_found = True - upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), target_drive) + os.sep - else: - for drive in drives: - try: - files = os.listdir(os.path.join(os.sep, 'media', getpass.getuser(), drive)) - except: - continue - else: - if target_filename in files: - upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), drive) + os.sep - 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' - # - drives = os.listdir('/Volumes') # human readable names - if target_drive in drives and not target_file_found: # set upload if not found target file yet - target_drive_found = True - upload_disk = '/Volumes/' + target_drive + '/' - for drive in drives: - try: - filenames = os.listdir('/Volumes/' + drive + '/') # will get an error if the drive is protected - except: - continue - else: - if target_filename in filenames: - if not target_file_found: - upload_disk = '/Volumes/' + drive + '/' - target_file_found = True + 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=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/HAL/NATIVE_SIM/HAL.h b/Marlin/src/HAL/NATIVE_SIM/HAL.h index 66203611447f..52e5eb4f3997 100644 --- a/Marlin/src/HAL/NATIVE_SIM/HAL.h +++ b/Marlin/src/HAL/NATIVE_SIM/HAL.h @@ -208,8 +208,8 @@ class MarlinHAL { MarlinHAL() {} // Watchdog - static void watchdog_init() IF_DISABLED(USE_WATCHDOG, {}); - static void watchdog_refresh() IF_DISABLED(USE_WATCHDOG, {}); + static void watchdog_init(); + static void watchdog_refresh(); static void init() {} // Called early in setup() static void init_board() {} // Called less early in setup() 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/HAL/NATIVE_SIM/inc/SanityCheck.h b/Marlin/src/HAL/NATIVE_SIM/inc/SanityCheck.h index 2d7bef23a36d..615e5254c95b 100644 --- a/Marlin/src/HAL/NATIVE_SIM/inc/SanityCheck.h +++ b/Marlin/src/HAL/NATIVE_SIM/inc/SanityCheck.h @@ -31,7 +31,7 @@ #endif #if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY - #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on LINUX." + #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported for HAL/LINUX." #endif #if HAS_TMC_SW_SERIAL diff --git a/Marlin/src/HAL/NATIVE_SIM/pinsDebug.h b/Marlin/src/HAL/NATIVE_SIM/pinsDebug.h index aa90eb39a330..af9a651c79ae 100644 --- a/Marlin/src/HAL/NATIVE_SIM/pinsDebug.h +++ b/Marlin/src/HAL/NATIVE_SIM/pinsDebug.h @@ -27,8 +27,8 @@ */ #define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS -#define pwm_details(pin) pin = pin // do nothing // print PWM details -#define pwm_status(pin) false //Print a pin's PWM status. Return true if it's currently a PWM pin. +#define pwm_details(pin) NOOP // do nothing +#define pwm_status(pin) false // Print a pin's PWM status. Return true if it's currently a PWM pin. #define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P) >= 0 ? 1 : 0) #define digitalRead_mod(p) digitalRead(p) #define PRINT_PORT(p) diff --git a/Marlin/src/HAL/NATIVE_SIM/spi_pins.h b/Marlin/src/HAL/NATIVE_SIM/spi_pins.h index a5138e0ccbe8..fd3378b33759 100644 --- a/Marlin/src/HAL/NATIVE_SIM/spi_pins.h +++ b/Marlin/src/HAL/NATIVE_SIM/spi_pins.h @@ -25,7 +25,7 @@ #include "../../inc/MarlinConfigPre.h" #if BOTH(HAS_MARLINUI_U8GLIB, SDSUPPORT) && (LCD_PINS_D4 == SD_SCK_PIN || LCD_PINS_ENABLE == SD_MOSI_PIN || DOGLCD_SCK == SD_SCK_PIN || DOGLCD_MOSI == SD_MOSI_PIN) - #define LPC_SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently + #define SOFTWARE_SPI // If the SD card and LCD adapter share the same SPI pins, then software SPI is currently // needed due to the speed and mode required for communicating with each device being different. // This requirement can be removed if the SPI access to these devices is updated to use // spiBeginTransaction. 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/NATIVE_SIM/u8g/LCD_I2C_routines.h b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_I2C_routines.h index 6d5f91d3ba45..ec263b6dd36b 100644 --- a/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_I2C_routines.h +++ b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_I2C_routines.h @@ -34,4 +34,3 @@ void u8g_i2c_stop(); #ifdef __cplusplus } #endif - diff --git a/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_defines.h b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_defines.h index 44ffbfeb90e5..2a50eddcd407 100644 --- a/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_defines.h +++ b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_defines.h @@ -40,5 +40,3 @@ uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void #define U8G_COM_T6963 u8g_com_null_fn #define U8G_COM_FAST_PARALLEL u8g_com_null_fn #define U8G_COM_UC_I2C u8g_com_null_fn - - diff --git a/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.cpp b/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.cpp index c384cdd75185..a3254774bfdf 100644 --- a/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.cpp +++ b/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.cpp @@ -168,4 +168,4 @@ uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void #endif #endif // IS_U8GLIB_ST7920 -#endif // TARGET_LPC1768 +#endif // __PLAT_NATIVE_SIM__ diff --git a/Marlin/src/HAL/SAMD21/HAL.cpp b/Marlin/src/HAL/SAMD21/HAL.cpp new file mode 100644 index 000000000000..14c439eeb911 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/HAL.cpp @@ -0,0 +1,212 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#ifdef __SAMD21__ + +#include "../../inc/MarlinConfig.h" + +#include + +#if USING_HW_SERIALUSB + DefaultSerial1 MSerialUSB(false, SerialUSB); +#endif +#if USING_HW_SERIAL0 + DefaultSerial2 MSerial1(false, Serial1); +#endif +#if USING_HW_SERIAL1 + DefaultSerial3 MSerial2(false, Serial2); +#endif + + + +#define WDT_CONFIG_PER_7_Val 0x9u +#define WDT_CONFIG_PER_Pos 0 +#define WDT_CONFIG_PER_7 (WDT_CONFIG_PER_7_Val << WDT_CONFIG_PER_Pos) + +#if ENABLED(USE_WATCHDOG) + + #define WDT_TIMEOUT_REG TERN(WATCHDOG_DURATION_8S, WDT_CONFIG_PER_CYC8192, WDT_CONFIG_PER_CYC4096) // 4 or 8 second timeout + + void MarlinHAL::watchdog_init() { + // Set up the generic clock (GCLK2) used to clock the watchdog timer at 1.024kHz + GCLK->GENDIV.reg = GCLK_GENDIV_DIV(4) | // Divide the 32.768kHz clock source by divisor 32, where 2^(4 + 1): 32.768kHz/32=1.024kHz + GCLK_GENDIV_ID(2); // Select Generic Clock (GCLK) 2 + while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization + + REG_GCLK_GENCTRL = GCLK_GENCTRL_DIVSEL | // Set to divide by 2^(GCLK_GENDIV_DIV(4) + 1) + GCLK_GENCTRL_IDC | // Set the duty cycle to 50/50 HIGH/LOW + GCLK_GENCTRL_GENEN | // Enable GCLK2 + GCLK_GENCTRL_SRC_OSCULP32K | // Set the clock source to the ultra low power oscillator (OSCULP32K) + GCLK_GENCTRL_ID(2); // Select GCLK2 + while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization + + // Feed GCLK2 to WDT (Watchdog Timer) + REG_GCLK_CLKCTRL = GCLK_CLKCTRL_CLKEN | // Enable GCLK2 to the WDT + GCLK_CLKCTRL_GEN_GCLK2 | // Select GCLK2 + GCLK_CLKCTRL_ID_WDT; // Feed the GCLK2 to the WDT + while (GCLK->STATUS.bit.SYNCBUSY); // Wait for synchronization + + WDT->CONFIG.bit.PER = WDT_CONFIG_PER_7; // Set the WDT reset timeout to 4 seconds + while (WDT->STATUS.bit.SYNCBUSY); // Wait for synchronization + REG_WDT_CTRL = WDT_CTRL_ENABLE; // Enable the WDT in normal mode + while (WDT->STATUS.bit.SYNCBUSY); // Wait for synchronization + } + + // Reset watchdog. MUST be called at least every 4 seconds after the + // first watchdog_init or SAMD will go into emergency procedures. + void MarlinHAL::watchdog_refresh() { + WDT->CLEAR.reg = WDT_CLEAR_CLEAR_KEY; + while (WDT->STATUS.bit.SYNCBUSY); + } + +#endif + +// ------------------------ +// Types +// ------------------------ + +// ------------------------ +// Private Variables +// ------------------------ + +// ------------------------ +// Private functions +// ------------------------ + +void MarlinHAL::dma_init() {} + +// ------------------------ +// Public functions +// ------------------------ + +// HAL initialization task +void MarlinHAL::init() { + TERN_(DMA_IS_REQUIRED, dma_init()); + #if ENABLED(SDSUPPORT) + #if HAS_SD_DETECT && SD_CONNECTION_IS(ONBOARD) + SET_INPUT_PULLUP(SD_DETECT_PIN); + #endif + OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up + #endif +} + +#pragma push_macro("WDT") +#undef WDT // Required to be able to use '.bit.WDT'. Compiler wrongly replace struct field with WDT define +uint8_t MarlinHAL::get_reset_source() { + + return 0; +} +#pragma pop_macro("WDT") + +void MarlinHAL::reboot() { NVIC_SystemReset(); } + +extern "C" { + void * _sbrk(int incr); + extern unsigned int __bss_end__; // end of bss section +} + +// Return free memory between end of heap (or end bss) and whatever is current +int freeMemory() { + int free_memory, heap_end = (int)_sbrk(0); + return (int)&free_memory - (heap_end ?: (int)&__bss_end__); +} + +// ------------------------ +// ADC +// ------------------------ + +uint16_t MarlinHAL::adc_result; + +void MarlinHAL::adc_init() { + /* thanks to https://www.eevblog.com/forum/microcontrollers/samd21g18-adc-with-resrdy-interrupts-only-reads-once-or-twice/ */ + + ADC->CTRLA.bit.ENABLE = false; + while(ADC->STATUS.bit.SYNCBUSY); + + // load chip corrections + uint32_t bias = (*((uint32_t *) ADC_FUSES_BIASCAL_ADDR) & ADC_FUSES_BIASCAL_Msk) >> ADC_FUSES_BIASCAL_Pos; + uint32_t linearity = (*((uint32_t *) ADC_FUSES_LINEARITY_0_ADDR) & ADC_FUSES_LINEARITY_0_Msk) >> ADC_FUSES_LINEARITY_0_Pos; + linearity |= ((*((uint32_t *) ADC_FUSES_LINEARITY_1_ADDR) & ADC_FUSES_LINEARITY_1_Msk) >> ADC_FUSES_LINEARITY_1_Pos) << 5; + + /* Wait for bus synchronization. */ + while (ADC->STATUS.bit.SYNCBUSY) {}; + + ADC->CALIB.reg = ADC_CALIB_BIAS_CAL(bias) | ADC_CALIB_LINEARITY_CAL(linearity); + + /* Wait for bus synchronization. */ + while (ADC->STATUS.bit.SYNCBUSY) {}; + + ADC->CTRLA.bit.SWRST = true; + while(ADC->STATUS.bit.SYNCBUSY); + + ADC->REFCTRL.reg = ADC_REFCTRL_REFSEL_INTVCC1; + ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_32| ADC_AVGCTRL_ADJRES(4);; + + + ADC->CTRLB.reg = ADC_CTRLB_PRESCALER_DIV128 | + ADC_CTRLB_RESSEL_16BIT | + ADC_CTRLB_FREERUN; + while(ADC->STATUS.bit.SYNCBUSY); + + ADC->SAMPCTRL.bit.SAMPLEN = 0x00; + while(ADC->STATUS.bit.SYNCBUSY); + + ADC->INPUTCTRL.reg = ADC_INPUTCTRL_INPUTSCAN(HAL_ADC_AIN_LEN) // scan (INPUTSCAN + NUM_EXTUDERS - 1) pins + | ADC_INPUTCTRL_GAIN_DIV2 |ADC_INPUTCTRL_MUXNEG_GND| HAL_ADC_AIN_START ; /* set to first AIN */ + + while(ADC->STATUS.bit.SYNCBUSY); + + ADC->INTENSET.reg |= ADC_INTENSET_RESRDY; // enable Result Ready ADC interrupts + while (ADC->STATUS.bit.SYNCBUSY); + + NVIC_EnableIRQ(ADC_IRQn); // enable ADC interrupts + + NVIC_SetPriority(ADC_IRQn, 3); + + ADC->CTRLA.bit.ENABLE = true; +} + +volatile uint32_t adc_results[HAL_ADC_AIN_NUM_SENSORS]; + +void ADC_Handler() { + while(ADC->STATUS.bit.SYNCBUSY == 1); + int pos = ADC->INPUTCTRL.bit.INPUTOFFSET; + + adc_results[pos] = ADC->RESULT.reg; /* Read the value. */ + ADC->INTFLAG.reg = ADC_INTENSET_RESRDY; /* Clear the data ready flag. */ +} + +void MarlinHAL::adc_start(const pin_t pin) { + /* due to the way INPUTOFFSET works, the last sensor is the first position in the array + and we want the ADC_handler interrupt to be as simple possible, so we do the calculation here. + */ + unsigned int pos = PIN_TO_INPUTCTRL(pin) - HAL_ADC_AIN_START + 1; + if (pos == HAL_ADC_AIN_NUM_SENSORS) pos = 0; + adc_result = adc_results[pos]; // 16-bit resolution + //adc_result = 0xFFFF; +} + +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/HAL.h b/Marlin/src/HAL/SAMD21/HAL.h new file mode 100644 index 000000000000..1854e523ed62 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/HAL.h @@ -0,0 +1,223 @@ +/** + * 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 + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +#define CPU_32_BIT + +#include "../shared/Marduino.h" +#include "../shared/math_32bit.h" +#include "../shared/HAL_SPI.h" +#include "fastio.h" + +// ------------------------ +// Serial ports +// ------------------------ +#include "../../core/serial_hook.h" +typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1; +extern DefaultSerial1 MSerialUSB; + +// Serial ports +typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2; +typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3; + +extern DefaultSerial2 MSerial0; +extern DefaultSerial3 MSerial1; + + +#define __MSERIAL(X) MSerial##X +#define _MSERIAL(X) __MSERIAL(X) +#define MSERIAL(X) _MSERIAL(INCREMENT(X)) + +#if WITHIN(SERIAL_PORT, 0, 1) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) +#elif SERIAL_PORT == -1 + #define MYSERIAL1 MSerialUSB +#else + #error "SERIAL_PORT must be -1 (Native USB only)." +#endif + +#ifdef SERIAL_PORT_2 + #if WITHIN(SERIAL_PORT_2, 0, 1) + #define MYSERIAL2 MSERIAL(SERIAL_PORT) + #elif SERIAL_PORT_2 == -1 + #define MYSERIAL2 MSerialUSB + #else + #error "SERIAL_PORT_2 must be -1 (Native USB only)." + #endif +#endif + +#ifdef MMU2_SERIAL_PORT + #if WITHIN(MMU2_SERIAL_PORT, 0, 1) + #define MMU2_SERIAL MSERIAL(SERIAL_PORT) + #elif MMU2_SERIAL_PORT == -1 + #define MMU2_SERIAL MSerialUSB + #else + #error "MMU2_SERIAL_PORT must be -1 (Native USB only)." + #endif +#endif + +#ifdef LCD_SERIAL_PORT + #if WITHIN(LCD_SERIAL_PORT, 0, 1) + #define LCD_SERIAL MSERIAL(SERIAL_PORT) + #elif LCD_SERIAL_PORT == -1 + #define LCD_SERIAL MSerialUSB + #else + #error "LCD_SERIAL_PORT must be -1 (Native USB only)." + #endif +#endif + +typedef int8_t pin_t; + +#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +class Servo; +typedef Servo hal_servo_t; + +// +// Interrupts +// +#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() + +#define cli() __disable_irq() // Disable interrupts +#define sei() __enable_irq() // Enable interrupts + +// +// ADC +// + +#define HAL_ADC_FILTERED 1 // Disable Marlin's oversampling. The HAL filters ADC values. +#define HAL_ADC_VREF 3.3 +#define HAL_ADC_RESOLUTION 12 +#define HAL_ADC_AIN_START ADC_INPUTCTRL_MUXPOS_PIN3 +#define HAL_ADC_AIN_NUM_SENSORS 3 +#define HAL_ADC_AIN_LEN HAL_ADC_AIN_NUM_SENSORS-1 + +// +// Pin Mapping for M42, M43, M226 +// +#define GET_PIN_MAP_PIN(index) index +#define GET_PIN_MAP_INDEX(pin) pin +#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + +// +// Tone +// +void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0); +void noTone(const pin_t _pin); + +// ------------------------ +// Class Utilities +// ------------------------ + +#pragma GCC diagnostic push +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif + +#ifdef __cplusplus + extern "C" { +#endif + +char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s); + +extern "C" int freeMemory(); + +#ifdef __cplusplus + } +#endif + +#pragma GCC diagnostic pop + +// ------------------------ +// MarlinHAL Class +// ------------------------ + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + // Watchdog + static void watchdog_init() IF_DISABLED(USE_WATCHDOG, {}); + static void watchdog_refresh() IF_DISABLED(USE_WATCHDOG, {}); + + static void init(); // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 + + // Interrupts + static bool isr_state() { return !__get_PRIMASK(); } + static void isr_on() { sei(); } + static void isr_off() { cli(); } + + static void delay_ms(const int ms) { delay(ms); } + + // Tasks, called from idle() + static void idletask() {} + + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source() {} + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static uint16_t adc_result; + + // Called by Temperature::init once at startup + static void adc_init(); + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const uint8_t ch) {} + + // Begin ADC sampling on the given pin. Called from Temperature::isr! + static void adc_start(const pin_t pin); + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value() { return adc_result; } + + /** + * Set the PWM duty cycle for the pin to the given value. + * No option to invert the duty cycle [default = false] + * No option to change the scale of the provided value to enable finer PWM duty control [default = 255] + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } + +private: + static void dma_init(); +}; diff --git a/Marlin/src/HAL/SAMD21/HAL_SPI.cpp b/Marlin/src/HAL/SAMD21/HAL_SPI.cpp new file mode 100644 index 000000000000..69c6a43af835 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/HAL_SPI.cpp @@ -0,0 +1,148 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +/** + * Hardware and software SPI implementations are included in this file. + * + * Control of the slave select pin(s) is handled by the calling routines and + * SAMD21 let hardware SPI handling to remove SS from its logic. + */ + +#ifdef __SAMD21__ + +// -------------------------------------------------------------------------- +// Includes +// -------------------------------------------------------------------------- + +#include "../../inc/MarlinConfig.h" +#include + +// -------------------------------------------------------------------------- +// Public functions +// -------------------------------------------------------------------------- + +#if EITHER(SOFTWARE_SPI, FORCE_SOFT_SPI) + + // ------------------------ + // Software SPI + // ------------------------ + #error "Software SPI not supported for SAMD21. Use Hardware SPI." + +#else // !SOFTWARE_SPI + + static SPISettings spiConfig; + + // ------------------------ + // Hardware SPI + // ------------------------ + void spiBegin() { + spiInit(SPI_HALF_SPEED); + } + + void spiInit(uint8_t spiRate) { + // Use Marlin datarates + uint32_t clock; + switch (spiRate) { + case SPI_FULL_SPEED: clock = 8000000; break; + case SPI_HALF_SPEED: clock = 4000000; break; + case SPI_QUARTER_SPEED: clock = 2000000; break; + case SPI_EIGHTH_SPEED: clock = 1000000; break; + case SPI_SIXTEENTH_SPEED: clock = 500000; break; + case SPI_SPEED_5: clock = 250000; break; + case SPI_SPEED_6: clock = 125000; break; + default: clock = 4000000; break; // Default from the SPI library + } + spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0); + SPI.begin(); + } + + /** + * @brief Receives a single byte from the SPI port. + * + * @return Byte received + * + * @details + */ + uint8_t spiRec() { + SPI.beginTransaction(spiConfig); + uint8_t returnByte = SPI.transfer(0xFF); + SPI.endTransaction(); + return returnByte; + } + + /** + * @brief Receives a number of bytes from the SPI port to a buffer + * + * @param buf Pointer to starting address of buffer to write to. + * @param nbyte Number of bytes to receive. + * @return Nothing + */ + void spiRead(uint8_t *buf, uint16_t nbyte) { + if (nbyte == 0) return; + memset(buf, 0xFF, nbyte); + + SPI.beginTransaction(spiConfig); + SPI.transfer(buf, nbyte); + SPI.endTransaction(); + + } + + /** + * @brief Sends a single byte on SPI port + * + * @param b Byte to send + * + * @details + */ + void spiSend(uint8_t b) { + SPI.beginTransaction(spiConfig); + SPI.transfer(b); + SPI.endTransaction(); + } + + /** + * @brief Write token and then write from 512 byte buffer to SPI (for SD card) + * + * @param buf Pointer with buffer start address + * @return Nothing + * + * @details Uses DMA + */ + void spiSendBlock(uint8_t token, const uint8_t *buf) { + SPI.beginTransaction(spiConfig); + SPI.transfer(token); + SPI.transfer((uint8_t*)buf, 512); + SPI.endTransaction(); + } + + void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) { + spiConfig = SPISettings(spiClock, (BitOrder)bitOrder, dataMode); + SPI.beginTransaction(spiConfig); + } +#endif // !SOFTWARE_SPI + +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/MarlinSPI.h b/Marlin/src/HAL/SAMD21/MarlinSPI.h new file mode 100644 index 000000000000..7b5392793e15 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/MarlinSPI.h @@ -0,0 +1,31 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#pragma once + +#include + +using MarlinSPI = SPIClass; diff --git a/Marlin/src/HAL/SAMD21/QSPIFlash.cpp b/Marlin/src/HAL/SAMD21/QSPIFlash.cpp new file mode 100644 index 000000000000..fa54c6207125 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/QSPIFlash.cpp @@ -0,0 +1,82 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#include "../../inc/MarlinConfig.h" + +#if ENABLED(QSPI_EEPROM) + +#include "QSPIFlash.h" + +#define INVALID_ADDR 0xFFFFFFFF +#define SECTOR_OF(a) (a & ~(SFLASH_SECTOR_SIZE - 1)) +#define OFFSET_OF(a) (a & (SFLASH_SECTOR_SIZE - 1)) + +Adafruit_SPIFlashBase * QSPIFlash::_flashBase = nullptr; +uint8_t QSPIFlash::_buf[SFLASH_SECTOR_SIZE]; +uint32_t QSPIFlash::_addr = INVALID_ADDR; + +void QSPIFlash::begin() { + if (_flashBase) return; + + _flashBase = new Adafruit_SPIFlashBase(new Adafruit_FlashTransport_QSPI()); + _flashBase->begin(nullptr); +} + +size_t QSPIFlash::size() { + return _flashBase->size(); +} + +uint8_t QSPIFlash::readByte(const uint32_t address) { + if (SECTOR_OF(address) == _addr) return _buf[OFFSET_OF(address)]; + + return _flashBase->read8(address); +} + +void QSPIFlash::writeByte(const uint32_t address, const uint8_t value) { + uint32_t const sector_addr = SECTOR_OF(address); + + // Page changes, flush old and update new cache + if (sector_addr != _addr) { + flush(); + _addr = sector_addr; + + // read a whole page from flash + _flashBase->readBuffer(sector_addr, _buf, SFLASH_SECTOR_SIZE); + } + + _buf[OFFSET_OF(address)] = value; +} + +void QSPIFlash::flush() { + if (_addr == INVALID_ADDR) return; + + _flashBase->eraseSector(_addr / SFLASH_SECTOR_SIZE); + _flashBase->writeBuffer(_addr, _buf, SFLASH_SECTOR_SIZE); + + _addr = INVALID_ADDR; +} + +#endif // QSPI_EEPROM diff --git a/Marlin/src/HAL/SAMD21/QSPIFlash.h b/Marlin/src/HAL/SAMD21/QSPIFlash.h new file mode 100644 index 000000000000..58822fe05f3e --- /dev/null +++ b/Marlin/src/HAL/SAMD21/QSPIFlash.h @@ -0,0 +1,49 @@ +/** + * @file QSPIFlash.h + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Ha Thach and Dean Miller for Adafruit Industries LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * Derived from Adafruit_SPIFlash class with no SdFat references + */ +#pragma once + +#include + +// This class extends Adafruit_SPIFlashBase by adding caching support. +// +// This class will use 4096 Bytes of RAM as a block cache. +class QSPIFlash { + public: + static void begin(); + static size_t size(); + static uint8_t readByte(const uint32_t address); + static void writeByte(const uint32_t address, const uint8_t v); + static void flush(); + + private: + static Adafruit_SPIFlashBase * _flashBase; + static uint8_t _buf[SFLASH_SECTOR_SIZE]; + static uint32_t _addr; +}; + +extern QSPIFlash qspi; diff --git a/Marlin/src/HAL/SAMD21/SAMD21.h b/Marlin/src/HAL/SAMD21/SAMD21.h new file mode 100644 index 000000000000..8e9d17fc5026 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/SAMD21.h @@ -0,0 +1,66 @@ +/** + * 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 + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +#define SYNC(sc) while (sc) { \ + asm(""); \ + } + +// Get SAMD port/pin from specified arduino pin +#define GET_SAMD_PORT(P) _GET_SAMD_PORT(PIN_TO_SAMD_PIN(P)) +#define GET_SAMD_PIN(P) _GET_SAMD_PIN(PIN_TO_SAMD_PIN(P)) + +// Get external interrupt line associated to specified arduino pin +#define PIN_TO_EILINE(P) _SAMDPORTPIN_TO_EILINE(GET_SAMD_PORT(P), GET_SAMD_PIN(P)) + +// Get adc/ain associated to specified arduino pin +#define PIN_TO_ADC(P) (ANAPIN_TO_ADCAIN(P) >> 8) + +// Private defines +#define PIN_TO_SAMD_PIN(P) DIO##P##_PIN + +#define _GET_SAMD_PORT(P) ((P) >> 5) +#define _GET_SAMD_PIN(P) ((P) & 0x1F) + +// Get external interrupt line +#define _SAMDPORTPIN_TO_EILINE(P,B) ((P == 0 && WITHIN(B, 0, 31) && B != 26 && B != 28 && B != 29) ? (B) & 0xF \ + : (P == 1 && (WITHIN(B, 0, 25) || WITHIN(B, 30, 31))) ? (B) & 0xF \ + : (P == 1 && WITHIN(B, 26, 29)) ? 12 + (B) - 26 \ + : (P == 2 && (WITHIN(B, 0, 6) || WITHIN(B, 10, 31)) && B != 29) ? (B) & 0xF \ + : (P == 2 && B == 7) ? 9 \ + : (P == 3 && WITHIN(B, 0, 1)) ? (B) \ + : (P == 3 && WITHIN(B, 8, 12)) ? 3 + (B) - 8 \ + : (P == 3 && WITHIN(B, 20, 21)) ? 10 + (B) - 20 \ + : -1) + + + +#define A2_AIN 3 +#define A3_AIN 4 +#define A4_AIN 5 +#define PIN_TO_AIN(P) A##P##_AIN +#define AIN_TO_RESULT(P) ( (P - HAL_ADC_AIN_START == HAL_ADC_AIN_NUM_SENSORS-1) ? 0 : (P - HAL_ADC_AIN_START + 1) ) diff --git a/Marlin/src/HAL/SAMD21/Servo.cpp b/Marlin/src/HAL/SAMD21/Servo.cpp new file mode 100644 index 000000000000..38b995fc9a05 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/Servo.cpp @@ -0,0 +1,220 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +/** + * This comes from Arduino library which at the moment is buggy and uncompilable + */ + +#ifdef __SAMD21__ + +#include "../../inc/MarlinConfig.h" + +#if HAS_SERVOS + +#include "../shared/servo.h" +#include "../shared/servo_private.h" +#include "SAMD21.h" + +#define __TC_GCLK_ID(t) TC##t##_GCLK_ID +#define _TC_GCLK_ID(t) __TC_GCLK_ID(t) +#define TC_GCLK_ID _TC_GCLK_ID(SERVO_TC) + +#define _TC_PRESCALER(d) TC_CTRLA_PRESCALER_DIV##d##_Val +#define TC_PRESCALER(d) _TC_PRESCALER(d) + +#define __SERVO_IRQn(t) TC##t##_IRQn +#define _SERVO_IRQn(t) __SERVO_IRQn(t) +#define SERVO_IRQn _SERVO_IRQn(SERVO_TC) + +#define HAL_SERVO_TIMER_ISR() TC_HANDLER(SERVO_TC) + +#define TIMER_TCCHANNEL(t) ((t) & 1) +#define TC_COUNTER_START_VAL 0xFFFF + + +static volatile int8_t currentServoIndex[_Nbr_16timers]; // index for the servo being pulsed for each timer (or -1 if refresh interval) + +FORCE_INLINE static uint16_t getTimerCount() { + Tcc * const tc = timer_config[SERVO_TC].pTcc; + + tc->CTRLBSET.reg = TCC_CTRLBCLR_CMD_READSYNC; + SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY); + + return tc->COUNT.bit.COUNT; +} + +// ---------------------------- +// Interrupt handler for the TC +// ---------------------------- +HAL_SERVO_TIMER_ISR() { + Tcc * const tc = timer_config[SERVO_TC].pTcc; + const timer16_Sequence_t timer = + #ifndef _useTimer1 + _timer2 + #elif !defined(_useTimer2) + _timer1 + #else + (tc->INTFLAG.reg & tc->INTENSET.reg & TC_INTFLAG_MC0) ? _timer1 : _timer2 + #endif + ; + const uint8_t tcChannel = TIMER_TCCHANNEL(timer); + + int8_t cho = currentServoIndex[timer]; // Handle the prior servo first + if (cho < 0) { // Servo -1 indicates the refresh interval completed... + #if defined(_useTimer1) && defined(_useTimer2) + if (currentServoIndex[timer ^ 1] >= 0) { + // Wait for both channels + // Clear the interrupt + tc->INTFLAG.reg = (tcChannel == 0) ? TC_INTFLAG_MC0 : TC_INTFLAG_MC1; + return; + } + #endif + tc->COUNT.reg = TC_COUNTER_START_VAL; // ...so reset the timer + SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY); + } + else if (SERVO_INDEX(timer, cho) < ServoCount) // prior channel handled? + digitalWrite(SERVO(timer, cho).Pin.nbr, LOW); // pulse the prior channel LOW + + currentServoIndex[timer] = ++cho; // go to the next channel (or 0) + if (cho < SERVOS_PER_TIMER && SERVO_INDEX(timer, cho) < ServoCount) { + if (SERVO(timer, cho).Pin.isActive) // activated? + digitalWrite(SERVO(timer, cho).Pin.nbr, HIGH); // yes: pulse HIGH + + tc->CC[tcChannel].reg = getTimerCount() - (uint16_t)SERVO(timer, cho).ticks; + } + else { + // finished all channels so wait for the refresh period to expire before starting over + currentServoIndex[timer] = -1; // reset the timer COUNT.reg on the next call + const uint16_t cval = getTimerCount() - 256 / (SERVO_TIMER_PRESCALER), // allow 256 cycles to ensure the next CV not missed + ival = (TC_COUNTER_START_VAL) - (uint16_t)usToTicks(REFRESH_INTERVAL); // at least REFRESH_INTERVAL has elapsed + tc->CC[tcChannel].reg = min(cval, ival); + } + if (tcChannel == 0) { + SYNC(tc->SYNCBUSY.bit.CC0); + tc->INTFLAG.reg = TC_INTFLAG_MC0; // Clear the interrupt + } + else { + SYNC(tc->SYNCBUSY.bit.CC1); + tc->INTFLAG.reg = TC_INTFLAG_MC1; // Clear the interrupt + } +} + +void initISR(const timer16_Sequence_t timer) { + Tcc * const tc = timer_config[SERVO_TC].pTcc; + const uint8_t tcChannel = TIMER_TCCHANNEL(timer); + + static bool initialized = false; // Servo TC has been initialized + if (!initialized) { + NVIC_DisableIRQ(SERVO_IRQn); + + // Disable the timer + tc->CTRLA.bit.ENABLE = false; + SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY); + + // Select GCLK0 as timer/counter input clock source + GCLK->CLKCTRL.reg =(GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(TCC0_GCLK_ID)); + SYNC (GCLK->STATUS.bit.SYNCBUSY); + + // Reset the timer + tc->CTRLA.bit.SWRST = true; + SYNC(tc->CTRLA.bit.SWRST); + + // Set timer counter mode to 16 bits + tc->CTRLA.reg = TC_CTRLA_MODE_COUNT16; + + // Set timer counter mode as normal PWM + tc->WAVE.bit.WAVEGEN = TCC_WAVE_WAVEGEN_NPWM_Val; + + // Set the prescaler factor + tc->CTRLA.bit.PRESCALER = TC_PRESCALER(SERVO_TIMER_PRESCALER); + + // Count down + tc->CTRLBSET.reg = TCC_CTRLBCLR_DIR; + SYNC(tc->SYNCBUSY.bit.CTRLB); + + // Reset all servo indexes + memset((void *)currentServoIndex, 0xFF, sizeof(currentServoIndex)); + + // Configure interrupt request + NVIC_ClearPendingIRQ(SERVO_IRQn); + NVIC_SetPriority(SERVO_IRQn, 5); + NVIC_EnableIRQ(SERVO_IRQn); + + initialized = true; + } + + if (!tc->CTRLA.bit.ENABLE) { + // Reset the timer counter + tc->COUNT.reg = TC_COUNTER_START_VAL; + SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY); + + // Enable the timer and start it + tc->CTRLA.bit.ENABLE = true; + SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY); + } + // First interrupt request after 1 ms + tc->CC[tcChannel].reg = getTimerCount() - (uint16_t)usToTicks(1000UL); + + if (tcChannel == 0 ) { + SYNC(tc->SYNCBUSY.bit.CC0); + + // Clear pending match interrupt + tc->INTFLAG.reg = TC_INTENSET_MC0; + // Enable the match channel interrupt request + tc->INTENSET.reg = TC_INTENSET_MC0; + } + else { + SYNC(tc->SYNCBUSY.bit.CC1); + + // Clear pending match interrupt + tc->INTFLAG.reg = TC_INTENSET_MC1; + // Enable the match channel interrupt request + tc->INTENSET.reg = TC_INTENSET_MC1; + } +} + +void finISR(const timer16_Sequence_t timer_index) { + Tcc * const tc = timer_config[SERVO_TC].pTcc; + const uint8_t tcChannel = TIMER_TCCHANNEL(timer_index); + + // Disable the match channel interrupt request + tc->INTENCLR.reg = (tcChannel == 0) ? TC_INTENCLR_MC0 : TC_INTENCLR_MC1; + + if (true + #if defined(_useTimer1) && defined(_useTimer2) + && (tc->INTENCLR.reg & (TC_INTENCLR_MC0|TC_INTENCLR_MC1)) == 0 + #endif + ) { + // Disable the timer if not used + tc->CTRLA.bit.ENABLE = false; + SYNC(tc->STATUS.reg & TC_STATUS_SYNCBUSY); + } +} + +#endif // HAS_SERVOS + +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/ServoTimers.h b/Marlin/src/HAL/SAMD21/ServoTimers.h new file mode 100644 index 000000000000..89805476831f --- /dev/null +++ b/Marlin/src/HAL/SAMD21/ServoTimers.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 + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +#define _useTimer1 +#define _useTimer2 + +#define TRIM_DURATION 5 // compensation ticks to trim adjust for digitalWrite delays +#define SERVO_TIMER_PRESCALER 64 // timer prescaler factor to 64 (avoid overflowing 16-bit clock counter, at 120MHz this is 1831 ticks per millisecond + +#define SERVO_TC 3 + +typedef enum { + #ifdef _useTimer1 + _timer1, + #endif + #ifdef _useTimer2 + _timer2, + #endif + _Nbr_16timers +} timer16_Sequence_t; diff --git a/Marlin/src/HAL/SAMD21/eeprom_flash.cpp b/Marlin/src/HAL/SAMD21/eeprom_flash.cpp new file mode 100644 index 000000000000..4a4e328d1a00 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/eeprom_flash.cpp @@ -0,0 +1,141 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#ifdef __SAMD21__ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(FLASH_EEPROM_EMULATION) + +#define TOTAL_FLASH_SIZE (MARLIN_EEPROM_SIZE+255)/256*256 + +/* reserve flash memory */ +static const uint8_t flashdata[TOTAL_FLASH_SIZE] __attribute__((__aligned__(256))) { }; \ + +#include "../shared/eeprom_api.h" + +size_t PersistentStore::capacity() { + return MARLIN_EEPROM_SIZE; + /* const uint8_t psz = NVMCTRL->SEESTAT.bit.PSZ, + sblk = NVMCTRL->SEESTAT.bit.SBLK; + + return (!psz && !sblk) ? 0 + : (psz <= 2) ? (0x200 << psz) + : (sblk == 1 || psz == 3) ? 4096 + : (sblk == 2 || psz == 4) ? 8192 + : (sblk <= 4 || psz == 5) ? 16384 + : (sblk >= 9 && psz == 7) ? 65536 + : 32768;*/ +} + +uint32_t PAGE_SIZE; +uint32_t ROW_SIZE; +bool hasWritten = false; +uint8_t * buffer; + +void _erase(const volatile void *flash_ptr) { + NVMCTRL->ADDR.reg = ((uint32_t)flash_ptr) / 2; + NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_ER; + while (!NVMCTRL->INTFLAG.bit.READY) { } + +} + +void erase(const volatile void *flash_ptr, uint32_t size) { + const uint8_t *ptr = (const uint8_t *)flash_ptr; + while (size > ROW_SIZE) { + _erase(ptr); + ptr += ROW_SIZE; + size -= ROW_SIZE; + } + _erase(ptr); +} + +bool PersistentStore::access_start() { + /* clear page buffer*/ + NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_PBC; + while (NVMCTRL->INTFLAG.bit.READY == 0) { } + + PAGE_SIZE = pow(2,3 + NVMCTRL->PARAM.bit.PSZ); + ROW_SIZE= PAGE_SIZE * 4; + /*NVMCTRL->SEECFG.reg = NVMCTRL_SEECFG_WMODE_BUFFERED; // Buffered mode and segment reallocation active + if (NVMCTRL->SEESTAT.bit.RLOCK) + NVMCTRL_CMD(NVMCTRL_CTRLB_CMD_USEE); */ // Unlock E2P data write access + // erase(&flashdata[0], TOTAL_FLASH_SIZE); + return true; +} + +bool PersistentStore::access_finish() { + if (hasWritten) { + erase(&flashdata[0], TOTAL_FLASH_SIZE); + + NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_PBC; + while (NVMCTRL->INTFLAG.bit.READY == 0) { } + + NVMCTRL->CTRLB.bit.MANW = 0; + + volatile uint32_t *dst_addr = (volatile uint32_t *) &flashdata; + + uint32_t *pointer = (uint32_t *) buffer; + for (uint32_t i = 0; i < TOTAL_FLASH_SIZE; i+=4) { + + *dst_addr = (uint32_t) *pointer; + pointer++; + dst_addr ++; + } + + // Execute "WP" Write Page + NVMCTRL->CTRLA.reg = NVMCTRL_CTRLA_CMDEX_KEY | NVMCTRL_CTRLA_CMD_WP; + while (NVMCTRL->INTFLAG.bit.READY == 0) { } + + free(buffer); + hasWritten = false; + } + return true; +} + +bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + if (!hasWritten) { + // init temp buffer + buffer = (uint8_t *) malloc(MARLIN_EEPROM_SIZE); + hasWritten=true; + } + + memcpy(buffer+pos,value,size); + pos += size; + return false; +} + +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { + volatile uint8_t *dst_addr = (volatile uint8_t *) &flashdata; + dst_addr += pos; + + memcpy(value,(const void *) dst_addr,size); + pos += size; + return false; +} + +#endif // FLASH_EEPROM_EMULATION +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/eeprom_qspi.cpp b/Marlin/src/HAL/SAMD21/eeprom_qspi.cpp new file mode 100644 index 000000000000..587dcb0b1416 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/eeprom_qspi.cpp @@ -0,0 +1,79 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#ifdef __SAMD21__ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(QSPI_EEPROM) + +#error "QSPI_EEPROM emulation Not implemented on SAMD21" + +#include "../shared/eeprom_api.h" + +#include "QSPIFlash.h" + +static bool initialized; + +size_t PersistentStore::capacity() { return qspi.size(); } + +bool PersistentStore::access_start() { + if (!initialized) { + qspi.begin(); + initialized = true; + } + return true; +} + +bool PersistentStore::access_finish() { + qspi.flush(); + return true; +} + +bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + while (size--) { + const uint8_t v = *value; + qspi.writeByte(pos, v); + crc16(crc, &v, 1); + pos++; + value++; + } + return false; +} + +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { + while (size--) { + uint8_t c = qspi.readByte(pos); + if (writing) *value = c; + crc16(crc, &c, 1); + pos++; + value++; + } + return false; +} + +#endif // QSPI_EEPROM +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/eeprom_wired.cpp b/Marlin/src/HAL/SAMD21/eeprom_wired.cpp new file mode 100644 index 000000000000..ab71e616fc7b --- /dev/null +++ b/Marlin/src/HAL/SAMD21/eeprom_wired.cpp @@ -0,0 +1,82 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#ifdef __SAMD21__ + +#include "../../inc/MarlinConfig.h" + +#if USE_WIRED_EEPROM + +#error "USE_WIRED_EEPROM emulation Not implemented on SAMD21" +/** + * PersistentStore for Arduino-style EEPROM interface + * with simple implementations supplied by Marlin. + */ + +#include "../shared/eeprom_if.h" +#include "../shared/eeprom_api.h" + +#ifndef MARLIN_EEPROM_SIZE + #error "MARLIN_EEPROM_SIZE is required for I2C / SPI EEPROM." +#endif +size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } + +bool PersistentStore::access_start() { eeprom_init(); return true; } +bool PersistentStore::access_finish() { return true; } + +bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) { + uint16_t written = 0; + while (size--) { + const uint8_t v = *value; + uint8_t * const p = (uint8_t * const)pos; + if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed! + eeprom_write_byte(p, v); + if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes + if (eeprom_read_byte(p) != v) { + SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE); + return true; + } + } + crc16(crc, &v, 1); + pos++; + value++; + } + return false; +} + +bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) { + while (size--) { + uint8_t c = eeprom_read_byte((uint8_t*)pos); + if (writing) *value = c; + crc16(crc, &c, 1); + pos++; + value++; + } + return false; +} + +#endif // USE_WIRED_EEPROM +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/endstop_interrupts.h b/Marlin/src/HAL/SAMD21/endstop_interrupts.h new file mode 100644 index 000000000000..d8711aa01870 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/endstop_interrupts.h @@ -0,0 +1,253 @@ +/** + * 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 + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +/** + * Endstop interrupts for ATMEL SAMD21 based targets. + * + * On SAMD21, all pins support external interrupt capability. + * Any pin can be used for external interrupts, but there are some restrictions. + * At most 16 different external interrupts can be used at one time. + * Further, you can’t just pick any 16 pins to use. This is because every pin on the SAMD21 + * connects to what is called an EXTINT line, and only one pin per EXTINT line can be used for external + * interrupts at a time + */ + +/** + * Endstop Interrupts + * + * Without endstop interrupts the endstop pins must be polled continually in + * the temperature-ISR via endstops.update(), most of the time finding no change. + * With this feature endstops.update() is called only when we know that at + * least one endstop has changed state, saving valuable CPU cycles. + * + * This feature only works when all used endstop pins can generate an 'external interrupt'. + * + * Test whether pins issue interrupts on your board by flashing 'pin_interrupt_test.ino'. + * (Located in Marlin/buildroot/share/pin_interrupt_test/pin_interrupt_test.ino) + */ + +#include "../../module/endstops.h" + +#define MATCH_EILINE(P1,P2) (P1 != P2 && PIN_TO_EILINE(P1) == PIN_TO_EILINE(P2)) +#define MATCH_X_MAX_EILINE(P) TERN0(HAS_X_MAX, DEFER4(MATCH_EILINE)(P, X_MAX_PIN)) +#define MATCH_X_MIN_EILINE(P) TERN0(HAS_X_MIN, DEFER4(MATCH_EILINE)(P, X_MIN_PIN)) +#define MATCH_Y_MAX_EILINE(P) TERN0(HAS_Y_MAX, DEFER4(MATCH_EILINE)(P, Y_MAX_PIN)) +#define MATCH_Y_MIN_EILINE(P) TERN0(HAS_Y_MIN, DEFER4(MATCH_EILINE)(P, Y_MIN_PIN)) +#define MATCH_Z_MAX_EILINE(P) TERN0(HAS_Z_MAX, DEFER4(MATCH_EILINE)(P, Z_MAX_PIN)) +#define MATCH_Z_MIN_EILINE(P) TERN0(HAS_Z_MIN, DEFER4(MATCH_EILINE)(P, Z_MIN_PIN)) +#define MATCH_I_MAX_EILINE(P) TERN0(HAS_I_MAX, DEFER4(MATCH_EILINE)(P, I_MAX_PIN)) +#define MATCH_I_MIN_EILINE(P) TERN0(HAS_I_MIN, DEFER4(MATCH_EILINE)(P, I_MIN_PIN)) +#define MATCH_J_MAX_EILINE(P) TERN0(HAS_J_MAX, DEFER4(MATCH_EILINE)(P, J_MAX_PIN)) +#define MATCH_J_MIN_EILINE(P) TERN0(HAS_J_MIN, DEFER4(MATCH_EILINE)(P, J_MIN_PIN)) +#define MATCH_K_MAX_EILINE(P) TERN0(HAS_K_MAX, DEFER4(MATCH_EILINE)(P, K_MAX_PIN)) +#define MATCH_K_MIN_EILINE(P) TERN0(HAS_K_MIN, DEFER4(MATCH_EILINE)(P, K_MIN_PIN)) +#define MATCH_U_MAX_EILINE(P) TERN0(HAS_U_MAX, DEFER4(MATCH_EILINE)(P, U_MAX_PIN)) +#define MATCH_U_MIN_EILINE(P) TERN0(HAS_U_MIN, DEFER4(MATCH_EILINE)(P, U_MIN_PIN)) +#define MATCH_V_MAX_EILINE(P) TERN0(HAS_V_MAX, DEFER4(MATCH_EILINE)(P, V_MAX_PIN)) +#define MATCH_V_MIN_EILINE(P) TERN0(HAS_V_MIN, DEFER4(MATCH_EILINE)(P, V_MIN_PIN)) +#define MATCH_W_MAX_EILINE(P) TERN0(HAS_W_MAX, DEFER4(MATCH_EILINE)(P, W_MAX_PIN)) +#define MATCH_W_MIN_EILINE(P) TERN0(HAS_W_MIN, DEFER4(MATCH_EILINE)(P, W_MIN_PIN)) +#define MATCH_Z2_MAX_EILINE(P) TERN0(HAS_Z2_MAX, DEFER4(MATCH_EILINE)(P, Z2_MAX_PIN)) +#define MATCH_Z2_MIN_EILINE(P) TERN0(HAS_Z2_MIN, DEFER4(MATCH_EILINE)(P, Z2_MIN_PIN)) +#define MATCH_Z3_MAX_EILINE(P) TERN0(HAS_Z3_MAX, DEFER4(MATCH_EILINE)(P, Z3_MAX_PIN)) +#define MATCH_Z3_MIN_EILINE(P) TERN0(HAS_Z3_MIN, DEFER4(MATCH_EILINE)(P, Z3_MIN_PIN)) +#define MATCH_Z4_MAX_EILINE(P) TERN0(HAS_Z4_MAX, DEFER4(MATCH_EILINE)(P, Z4_MAX_PIN)) +#define MATCH_Z4_MIN_EILINE(P) TERN0(HAS_Z4_MIN, DEFER4(MATCH_EILINE)(P, Z4_MIN_PIN)) +#define MATCH_Z_MIN_PROBE_EILINE(P) TERN0(HAS_Z_MIN_PROBE_PIN, DEFER4(MATCH_EILINE)(P, Z_MIN_PROBE_PIN)) + +#define AVAILABLE_EILINE(P) ( PIN_TO_EILINE(P) != -1 \ + && !MATCH_X_MAX_EILINE(P) && !MATCH_X_MIN_EILINE(P) \ + && !MATCH_Y_MAX_EILINE(P) && !MATCH_Y_MIN_EILINE(P) \ + && !MATCH_Z_MAX_EILINE(P) && !MATCH_Z_MIN_EILINE(P) \ + && !MATCH_I_MAX_EILINE(P) && !MATCH_I_MIN_EILINE(P) \ + && !MATCH_J_MAX_EILINE(P) && !MATCH_J_MIN_EILINE(P) \ + && !MATCH_K_MAX_EILINE(P) && !MATCH_K_MIN_EILINE(P) \ + && !MATCH_U_MAX_EILINE(P) && !MATCH_U_MIN_EILINE(P) \ + && !MATCH_V_MAX_EILINE(P) && !MATCH_V_MIN_EILINE(P) \ + && !MATCH_W_MAX_EILINE(P) && !MATCH_W_MIN_EILINE(P) \ + && !MATCH_Z2_MAX_EILINE(P) && !MATCH_Z2_MIN_EILINE(P) \ + && !MATCH_Z3_MAX_EILINE(P) && !MATCH_Z3_MIN_EILINE(P) \ + && !MATCH_Z4_MAX_EILINE(P) && !MATCH_Z4_MIN_EILINE(P) \ + && !MATCH_Z_MIN_PROBE_EILINE(P) ) + +// One ISR for all EXT-Interrupts +void endstop_ISR() { endstops.update(); } + +void setup_endstop_interrupts() { + #define _ATTACH(P) attachInterrupt(P, endstop_ISR, CHANGE) + #if HAS_X_MAX + #if !AVAILABLE_EILINE(X_MAX_PIN) + #error "X_MAX_PIN has no EXTINT line available." + #endif + _ATTACH(X_MAX_PIN); + #endif + #if HAS_X_MIN + #if !AVAILABLE_EILINE(X_MIN_PIN) + #error "X_MIN_PIN has no EXTINT line available." + #endif + _ATTACH(X_MIN_PIN); + #endif + #if HAS_Y_MAX + #if !AVAILABLE_EILINE(Y_MAX_PIN) + #error "Y_MAX_PIN has no EXTINT line available." + #endif + _ATTACH(Y_MAX_PIN); + #endif + #if HAS_Y_MIN + #if !AVAILABLE_EILINE(Y_MIN_PIN) + #error "Y_MIN_PIN has no EXTINT line available." + #endif + _ATTACH(Y_MIN_PIN); + #endif + #if HAS_Z_MAX + #if !AVAILABLE_EILINE(Z_MAX_PIN) + #error "Z_MAX_PIN has no EXTINT line available." + #endif + _ATTACH(Z_MAX_PIN); + #endif + #if HAS_Z_MIN + #if !AVAILABLE_EILINE(Z_MIN_PIN) + #error "Z_MIN_PIN has no EXTINT line available." + #endif + _ATTACH(Z_MIN_PIN); + #endif + #if HAS_Z2_MAX + #if !AVAILABLE_EILINE(Z2_MAX_PIN) + #error "Z2_MAX_PIN has no EXTINT line available." + #endif + _ATTACH(Z2_MAX_PIN); + #endif + #if HAS_Z2_MIN + #if !AVAILABLE_EILINE(Z2_MIN_PIN) + #error "Z2_MIN_PIN has no EXTINT line available." + #endif + _ATTACH(Z2_MIN_PIN); + #endif + #if HAS_Z3_MAX + #if !AVAILABLE_EILINE(Z3_MAX_PIN) + #error "Z3_MAX_PIN has no EXTINT line available." + #endif + _ATTACH(Z3_MAX_PIN); + #endif + #if HAS_Z3_MIN + #if !AVAILABLE_EILINE(Z3_MIN_PIN) + #error "Z3_MIN_PIN has no EXTINT line available." + #endif + _ATTACH(Z3_MIN_PIN); + #endif + #if HAS_Z4_MAX + #if !AVAILABLE_EILINE(Z4_MAX_PIN) + #error "Z4_MAX_PIN has no EXTINT line available." + #endif + _ATTACH(Z4_MAX_PIN); + #endif + #if HAS_Z4_MIN + #if !AVAILABLE_EILINE(Z4_MIN_PIN) + #error "Z4_MIN_PIN has no EXTINT line available." + #endif + _ATTACH(Z4_MIN_PIN); + #endif + #if HAS_Z_MIN_PROBE_PIN + #if !AVAILABLE_EILINE(Z_MIN_PROBE_PIN) + #error "Z_MIN_PROBE_PIN has no EXTINT line available." + #endif + _ATTACH(Z_MIN_PROBE_PIN); + #endif + #if HAS_I_MAX + #if !AVAILABLE_EILINE(I_MAX_PIN) + #error "I_MAX_PIN has no EXTINT line available." + #endif + attachInterrupt(I_MAX_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_I_MIN + #if !AVAILABLE_EILINE(I_MIN_PIN) + #error "I_MIN_PIN has no EXTINT line available." + #endif + attachInterrupt(I_MIN_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_J_MAX + #if !AVAILABLE_EILINE(J_MAX_PIN) + #error "J_MAX_PIN has no EXTINT line available." + #endif + attachInterrupt(J_MAX_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_J_MIN + #if !AVAILABLE_EILINE(J_MIN_PIN) + #error "J_MIN_PIN has no EXTINT line available." + #endif + attachInterrupt(J_MIN_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_K_MAX + #if !AVAILABLE_EILINE(K_MAX_PIN) + #error "K_MAX_PIN has no EXTINT line available." + #endif + attachInterrupt(K_MAX_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_K_MIN + #if !AVAILABLE_EILINE(K_MIN_PIN) + #error "K_MIN_PIN has no EXTINT line available." + #endif + attachInterrupt(K_MIN_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_U_MAX + #if !AVAILABLE_EILINE(U_MAX_PIN) + #error "U_MAX_PIN has no EXTINT line available." + #endif + attachInterrupt(U_MAX_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_U_MIN + #if !AVAILABLE_EILINE(U_MIN_PIN) + #error "U_MIN_PIN has no EXTINT line available." + #endif + attachInterrupt(U_MIN_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_V_MAX + #if !AVAILABLE_EILINE(V_MAX_PIN) + #error "V_MAX_PIN has no EXTINT line available." + #endif + attachInterrupt(V_MAX_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_V_MIN + #if !AVAILABLE_EILINE(V_MIN_PIN) + #error "V_MIN_PIN has no EXTINT line available." + #endif + attachInterrupt(V_MIN_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_W_MAX + #if !AVAILABLE_EILINE(W_MAX_PIN) + #error "W_MAX_PIN has no EXTINT line available." + #endif + attachInterrupt(W_MAX_PIN, endstop_ISR, CHANGE); + #endif + #if HAS_W_MIN + #if !AVAILABLE_EILINE(W_MIN_PIN) + #error "W_MIN_PIN has no EXTINT line available." + #endif + attachInterrupt(W_MIN_PIN, endstop_ISR, CHANGE); + #endif +} diff --git a/Marlin/src/HAL/SAMD21/fastio.h b/Marlin/src/HAL/SAMD21/fastio.h new file mode 100644 index 000000000000..df907ff7ec6c --- /dev/null +++ b/Marlin/src/HAL/SAMD21/fastio.h @@ -0,0 +1,215 @@ +/** + * 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 + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +/** + * Fast IO functions for SAMD21 + */ + +#include "SAMD21.h" + +/** + * Utility functions + */ + +#ifndef MASK + #define MASK(PIN) _BV(PIN) +#endif + +/** + * Magic I/O routines + * + * Now you can simply SET_OUTPUT(IO); WRITE(IO, HIGH); WRITE(IO, LOW); + */ + +// Read a pin +#define READ(IO) ((PORT->Group[(EPortType)GET_SAMD_PORT(IO)].IN.reg & MASK(GET_SAMD_PIN(IO))) != 0) + +// Write to a pin +#define WRITE(IO,V) do{ \ + const EPortType port = (EPortType)GET_SAMD_PORT(IO); \ + const uint32_t mask = MASK(GET_SAMD_PIN(IO)); \ + \ + if (V) PORT->Group[port].OUTSET.reg = mask; \ + else PORT->Group[port].OUTCLR.reg = mask; \ + }while(0) + +// Toggle a pin +#define TOGGLE(IO) PORT->Group[(EPortType)GET_SAMD_PORT(IO)].OUTTGL.reg = MASK(GET_SAMD_PIN(IO)); + +// Set pin as input +#define SET_INPUT(IO) do{ \ + const EPortType port = (EPortType)GET_SAMD_PORT(IO); \ + const uint32_t pin = GET_SAMD_PIN(IO); \ + \ + PORT->Group[port].PINCFG[pin].reg = (uint8_t)(PORT_PINCFG_INEN); \ + PORT->Group[port].DIRCLR.reg = MASK(pin); \ + }while(0) +// Set pin as input with pullup +#define SET_INPUT_PULLUP(IO) do{ \ + const EPortType port = (EPortType)GET_SAMD_PORT(IO); \ + const uint32_t pin = GET_SAMD_PIN(IO); \ + const uint32_t mask = MASK(pin); \ + \ + PORT->Group[port].PINCFG[pin].reg = (uint8_t)(PORT_PINCFG_INEN | PORT_PINCFG_PULLEN); \ + PORT->Group[port].DIRCLR.reg = mask; \ + PORT->Group[port].OUTSET.reg = mask; \ + }while(0) +// Set pin as input with pulldown +#define SET_INPUT_PULLDOWN(IO) do{ \ + const EPortType port = (EPortType)GET_SAMD_PORT(IO); \ + const uint32_t pin = GET_SAMD_PIN(IO); \ + const uint32_t mask = MASK(pin); \ + \ + PORT->Group[port].PINCFG[pin].reg = (uint8_t)(PORT_PINCFG_INEN | PORT_PINCFG_PULLEN); \ + PORT->Group[port].DIRCLR.reg = mask; \ + PORT->Group[port].OUTCLR.reg = mask; \ + }while(0) +// Set pin as output (push pull) +#define SET_OUTPUT(IO) do{ \ + const EPortType port = (EPortType)GET_SAMD_PORT(IO); \ + const uint32_t pin = GET_SAMD_PIN(IO); \ + \ + PORT->Group[port].DIRSET.reg = MASK(pin); \ + PORT->Group[port].PINCFG[pin].reg = 0; \ + }while(0) +// Set pin as output (open drain) +#define SET_OUTPUT_OD(IO) do{ \ + const EPortType port = (EPortType)GET_SAMD_PORT(IO); \ + const uint32_t pin = GET_SAMD_PIN(IO); \ + \ + PORT->Group[port].PINCFG[pin].reg = (uint8_t)(PORT_PINCFG_PULLEN); \ + PORT->Group[port].DIRCLR.reg = MASK(pin); \ + }while(0) +// Set pin as PWM (push pull) +#define SET_PWM SET_OUTPUT +// Set pin as PWM (open drain) +#define SET_PWM_OD SET_OUTPUT_OD + +// check if pin is an output +#define IS_OUTPUT(IO) ((PORT->Group[(EPortType)GET_SAMD_PORT(IO)].DIR.reg & MASK(GET_SAMD_PIN(IO))) \ + || (PORT->Group[(EPortType)GET_SAMD_PORT(IO)].PINCFG[GET_SAMD_PIN(IO)].reg & (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)) == PORT_PINCFG_PULLEN) +// check if pin is an input +#define IS_INPUT(IO) !IS_OUTPUT(IO) + +// Shorthand +#define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0) +#define OUT_WRITE_OD(IO,V) do{ SET_OUTPUT_OD(IO); WRITE(IO,V); }while(0) + +// digitalRead/Write wrappers +#define extDigitalRead(IO) digitalRead(IO) +#define extDigitalWrite(IO,V) digitalWrite(IO,V) + +/** + * Ports and functions + * Added as necessary or if I feel like it- not a comprehensive list! + */ + +/* + * Some of these share the same source and so can't be used in the same time + */ +#define PWM_PIN(P) (WITHIN(P, 2, 13) || WITHIN(P, 22, 23) || WITHIN(P, 44, 45) || P == 48) + +// Return fulfilled ADCx->INPUTCTRL.reg +#define PIN_TO_INPUTCTRL(P) ( (P == 0) ? ADC_INPUTCTRL_MUXPOS_PIN0 \ + : ((P) == 1) ? ADC_INPUTCTRL_MUXPOS_PIN1 \ + : ((P) == 2) ? ADC_INPUTCTRL_MUXPOS_PIN3 \ + : ((P) == 3) ? ADC_INPUTCTRL_MUXPOS_PIN4 \ + : ((P) == 4) ? ADC_INPUTCTRL_MUXPOS_PIN5 \ + : ((P) == 5) ? ADC_INPUTCTRL_MUXPOS_PIN5 \ + : ((P) == 6) ? ADC_INPUTCTRL_MUXPOS_PIN6 \ + : ((P) == 7) ? ADC_INPUTCTRL_MUXPOS_PIN7 \ + : ((P) == 8) ? ADC_INPUTCTRL_MUXPOS_PIN8 \ + : ((P) == 9) ? ADC_INPUTCTRL_MUXPOS_PIN9 \ + : ((P) == 10) ? ADC_INPUTCTRL_MUXPOS_PIN10 \ + : ((P) == 11) ? ADC_INPUTCTRL_MUXPOS_PIN11 \ + : ((P) == 12) ? ADC_INPUTCTRL_MUXPOS_PIN12 \ + : ((P) == 13) ? ADC_INPUTCTRL_MUXPOS_PIN13 \ + : ((P) == 14) ? ADC_INPUTCTRL_MUXPOS_PIN14 \ + : ADC_INPUTCTRL_MUXPOS_PIN15) + +#define digitalPinToAnalogInput(P) (WITHIN(P, 67, 74) ? (P) - 67 : WITHIN(P, 54, 61) ? 8 + (P) - 54 : WITHIN(P, 12, 13) ? 16 + (P) - 12 : P == 9 ? 18 : -1) + +/** + * pins + */ + +// PORTA +#define DIO28_PIN PIN_PA02 // A0 +#define DIO56_PIN PIN_PA03 // A13 +#define DIO31_PIN PIN_PA04 // A13 +#define DIO32_PIN PIN_PA05 // A1 +#define DIO8_PIN PIN_PA06 // A14 +#define DIO9_PIN PIN_PA07 // A15 +#define DIO4_PIN PIN_PA08 // A15 +#define DIO3_PIN PIN_PA09 // A15 +#define DIO1_PIN PIN_PA10 +#define DIO0_PIN PIN_PA11 +#define DIO18_PIN PIN_PA12 +#define DIO52_PIN PIN_PA13 +#define DIO2_PIN PIN_PA14 +#define DIO5_PIN PIN_PA15 +#define DIO11_PIN PIN_PA16 +#define DIO13_PIN PIN_PA17 +#define DIO10_PIN PIN_PA18 +#define DIO12_PIN PIN_PA19 +#define DIO6_PIN PIN_PA20 +#define DIO07_PIN PIN_PA21 +#define DIO34_PIN PIN_PA22 +#define DIO35_PIN PIN_PA23 +#define DIO42_PIN PIN_PA24 +#define DIO43_PIN PIN_PA25 + +#define DIO40_PIN PIN_PA27 + +#define DIO26_PIN PIN_PB00 +#define DIO27_PIN PIN_PB01 // A0 +#define DIO33_PIN PIN_PB02 +#define DIO39_PIN PIN_PB03 +#define DIO14_PIN PIN_PB04 +#define DIO15_PIN PIN_PB05 +#define DIO16_PIN PIN_PB06 +#define DIO17_PIN PIN_PB07 +#define DIO29_PIN PIN_PB08 +#define DIO30_PIN PIN_PB09 +#define DIO37_PIN PIN_PB10 +#define DIO38_PIN PIN_PB11 +#define DIO36_PIN PIN_PB12 +#define DIO19_PIN PIN_PB13 +#define DIO20_PIN PIN_PB14 +#define DIO21_PIN PIN_PB15 +#define DIO22_PIN PIN_PB16 +#define DIO23_PIN PIN_PB17 + +#define DIO44_PIN PIN_PB22 +#define DIO45_PIN PIN_PB23 +#define DIO24_PIN PIN_PB30 +#define DIO25_PIN PIN_PB31 + +#define DIO53_PIN PIN_PA21 +#define DIO54_PIN PIN_PA06 +#define DIO55_PIN PIN_PA07 diff --git a/Marlin/src/HAL/SAMD21/inc/Conditionals_LCD.h b/Marlin/src/HAL/SAMD21/inc/Conditionals_LCD.h new file mode 100644 index 000000000000..9d58e454327f --- /dev/null +++ b/Marlin/src/HAL/SAMD21/inc/Conditionals_LCD.h @@ -0,0 +1,23 @@ +/** + * 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 diff --git a/Marlin/src/HAL/SAMD21/inc/Conditionals_adv.h b/Marlin/src/HAL/SAMD21/inc/Conditionals_adv.h new file mode 100644 index 000000000000..d6a3c4fe0b91 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/inc/Conditionals_adv.h @@ -0,0 +1,27 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#pragma once diff --git a/Marlin/src/HAL/SAMD21/inc/Conditionals_post.h b/Marlin/src/HAL/SAMD21/inc/Conditionals_post.h new file mode 100644 index 000000000000..7315dc12a779 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/inc/Conditionals_post.h @@ -0,0 +1,33 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#pragma once + +#if USE_FALLBACK_EEPROM + #define FLASH_EEPROM_EMULATION +#elif EITHER(I2C_EEPROM, SPI_EEPROM) + #define USE_SHARED_EEPROM 1 +#endif diff --git a/Marlin/src/HAL/SAMD21/inc/SanityCheck.h b/Marlin/src/HAL/SAMD21/inc/SanityCheck.h new file mode 100644 index 000000000000..8bf052e3bb15 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/inc/SanityCheck.h @@ -0,0 +1,54 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +/** + * Test SAMD21 specific configuration values for errors at compile-time. + */ + +#if HAS_SPI_TFT || HAS_FSMC_TFT + #error "Sorry! TFT displays are not available for HAL/SAMD21." +#endif + +#if SERVO_TC == MF_TIMER_RTC + #error "Servos can't use RTC timer" +#endif + +#if ENABLED(EMERGENCY_PARSER) + #error "EMERGENCY_PARSER is not yet implemented for SAMD21. Disable EMERGENCY_PARSER to continue." +#endif + +#if ENABLED(SDIO_SUPPORT) + #error "SDIO_SUPPORT is not supported on SAMD21." +#endif + +#if ENABLED(FAST_PWM_FAN) + #error "Features requiring Hardware PWM (FAST_PWM_FAN) are not yet supported for HAL/SAMD21." +#endif + +#if ENABLED(POSTMORTEM_DEBUGGING) + #error "POSTMORTEM_DEBUGGING is not yet supported on SAMD21." +#endif diff --git a/Marlin/src/HAL/SAMD21/pinsDebug.h b/Marlin/src/HAL/SAMD21/pinsDebug.h new file mode 100644 index 000000000000..f94315cdf539 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/pinsDebug.h @@ -0,0 +1,160 @@ +/** + * 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 + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +#define NUMBER_PINS_TOTAL PINS_COUNT + +#define digitalRead_mod(p) extDigitalRead(p) +#define PRINT_PORT(p) do{ SERIAL_ECHOPGM(" Port: "); sprintf_P(buffer, PSTR("%c%02ld"), 'A' + g_APinDescription[p].ulPort, g_APinDescription[p].ulPin); SERIAL_ECHO(buffer); }while (0) +#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0) +#define PRINT_PIN(p) do{ sprintf_P(buffer, PSTR("%3d "), p); SERIAL_ECHO(buffer); }while(0) +#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 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) +#define MULTI_NAME_PAD 27 // space needed to be pretty if not first name assigned to a pin + +// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities +// uses pin index +#define M43_NEVER_TOUCH(Q) ((Q) >= 75) + +bool GET_PINMODE(int8_t pin) { // 1: output, 0: input + const EPortType samdport = g_APinDescription[pin].ulPort; + const uint32_t samdpin = g_APinDescription[pin].ulPin; + return PORT->Group[samdport].DIR.reg & MASK(samdpin) || (PORT->Group[samdport].PINCFG[samdpin].reg & (PORT_PINCFG_INEN | PORT_PINCFG_PULLEN)) == PORT_PINCFG_PULLEN; +} + +void pwm_details(int32_t pin) { + if (pwm_status(pin)) { + //uint32_t chan = g_APinDescription[pin].ulPWMChannel TODO when fast pwm is operative; + //SERIAL_ECHOPGM("PWM = ", duty); + } +} + +/** + * SAMD21 Board pin| PORT | Label + * ----------------+--------+------- + * 0 | PB25 | "RX0" + * 1 | PB24 | "TX0" + * 2 | PC18 | + * 3 | PC19 | + * 4 | PC20 | + * 5 | PC21 | + * 6 | PD20 | + * 7 | PD21 | + * 8 | PB18 | + * 9 | PB2 | + * 10 | PB22 | + * 11 | PB23 | + * 12 | PB0 | "A16" + * 13 | PB1 | LED AMBER "L" / "A17" + * 14 | PB16 | "TX3" + * 15 | PB17 | "RX3" + * 16 | PC22 | "TX2" + * 17 | PC23 | "RX2" + * 18 | PB12 | "TX1" / "A18" + * 19 | PB13 | "RX1" + * 20 | PB20 | "SDA" + * 21 | PB21 | "SCL" + * 22 | PD12 | + * 23 | PA15 | + * 24 | PC17 | + * 25 | PC16 | + * 26 | PA12 | + * 27 | PA13 | + * 28 | PA14 | + * 29 | PB19 | + * 30 | PA23 | + * 31 | PA22 | + * 32 | PA21 | + * 33 | PA20 | + * 34 | PA19 | + * 35 | PA18 | + * 36 | PA17 | + * 37 | PA16 | + * 38 | PB15 | + * 39 | PB14 | + * 40 | PC13 | + * 41 | PC12 | + * 42 | PC15 | + * 43 | PC14 | + * 44 | PC11 | + * 45 | PC10 | + * 46 | PC6 | + * 47 | PC7 | + * 48 | PC4 | + * 49 | PC5 | + * 50 | PD11 | + * 51 | PD8 | + * 52 | PD9 | + * 53 | PD10 | + * 54 | PB5 | "A8" + * 55 | PB6 | "A9" + * 56 | PB7 | "A10" + * 57 | PB8 | "A11" + * 58 | PB9 | "A12" + * 69 | PA4 | "A13" + * 60 | PA6 | "A14" + * 61 | PA7 | "A15" + * 62 | PB17 | + * 63 | PB20 | + * 64 | PD11 | + * 65 | PD8 | + * 66 | PD9 | + * 67 | PA2 | "A0" / "DAC0" + * 68 | PA5 | "A1" / "DAC1" + * 69 | PB3 | "A2" + * 70 | PC0 | "A3" + * 71 | PC1 | "A4" + * 72 | PC2 | "A5" + * 73 | PC3 | "A6" + * 74 | PB4 | "A7" + * 75 | PC31 | LED GREEN "RX" + * 76 | PC30 | LED GREEN "TX" + * 77 | PA27 | USB: Host enable + * 78 | PA24 | USB: D- + * 79 | PA25 | USB: D+ + * 80 | PB29 | SD: MISO + * 81 | PB27 | SD: SCK + * 82 | PB26 | SD: MOSI + * 83 | PB28 | SD: CS + * 84 | PA3 | AREF + * 85 | PA2 | DAC0 (Duplicate) + * 86 | PA5 | DAC1 (Duplicate) + * 87 | PB1 | LED AMBER "L" (Duplicate) + * 88 | PC24 | NeoPixel + * 89 | PB10 | QSPI: SCK + * 90 | PB11 | QSPI: CS + * 91 | PA8 | QSPI: IO0 + * 92 | PA9 | QSPI: IO1 + * 93 | PA10 | QSPI: IO2 + * 94 | PA11 | QSPI: IO3 + * 95 | PB31 | SD: DETECT + */ diff --git a/Marlin/src/HAL/SAMD21/spi_pins.h b/Marlin/src/HAL/SAMD21/spi_pins.h new file mode 100644 index 000000000000..8c25b84dc182 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/spi_pins.h @@ -0,0 +1,54 @@ +/** + * 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 + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +/** + * SAMD21 Default SPI Pins + * + * SS SCK MISO MOSI + * +-------------------------+ + * SPI | 53 52 50 51 | + * SPI1 | 83 81 80 82 | + * +-------------------------+ + * Any pin can be used for Chip Select (SD_SS_PIN) + */ +#ifndef SD_SCK_PIN + #define SD_SCK_PIN 38 +#endif +#ifndef SD_MISO_PIN + #define SD_MISO_PIN 36 +#endif +#ifndef SD_MOSI_PIN + #define SD_MOSI_PIN 37 +#endif +#ifndef SDSS + #define SDSS 18 +#endif + +#ifndef SD_SS_PIN + #define SD_SS_PIN SDSS +#endif diff --git a/Marlin/src/HAL/SAMD21/timers.cpp b/Marlin/src/HAL/SAMD21/timers.cpp new file mode 100644 index 000000000000..982eebc54951 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/timers.cpp @@ -0,0 +1,217 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#ifdef __SAMD21__ + +// -------------------------------------------------------------------------- +// Includes +// -------------------------------------------------------------------------- + +#include "../../inc/MarlinConfig.h" +#include "ServoTimers.h" // for SERVO_TC + +// -------------------------------------------------------------------------- +// Local defines +// -------------------------------------------------------------------------- + +#define NUM_HARDWARE_TIMERS 9 + +// -------------------------------------------------------------------------- +// Private Variables +// -------------------------------------------------------------------------- + +const tTimerConfig timer_config[NUM_HARDWARE_TIMERS] = { + { {.pTcc=TCC0}, TimerType::tcc, TCC0_IRQn, TC_PRIORITY(0) }, // 0 - stepper (assigned priority 2) + { {.pTcc=TCC1}, TimerType::tcc, TCC1_IRQn, TC_PRIORITY(1) }, // 1 - stepper (needed by 32 bit timers) + { {.pTcc=TCC2}, TimerType::tcc, TCC2_IRQn, 5 }, // 2 - tone (reserved by framework and fixed assigned priority 5) + { {.pTc=TC3}, TimerType::tc, TC3_IRQn, TC_PRIORITY(3) }, // 3 - servo (assigned priority 1) + { {.pTc=TC4}, TimerType::tc, TC4_IRQn, TC_PRIORITY(4) }, // 4 - software serial (no interrupts used) + { {.pTc=TC5}, TimerType::tc, TC5_IRQn, TC_PRIORITY(5) }, + { {.pTc=TC6}, TimerType::tc, TC6_IRQn, TC_PRIORITY(6) }, + { {.pTc=TC7}, TimerType::tc, TC7_IRQn, TC_PRIORITY(7) }, + { {.pRtc=RTC}, TimerType::rtc, RTC_IRQn, TC_PRIORITY(8) } // 8 - temperature (assigned priority 6) +}; + +// -------------------------------------------------------------------------- +// Private functions +// -------------------------------------------------------------------------- + +FORCE_INLINE void Disable_Irq(IRQn_Type irq) { + NVIC_DisableIRQ(irq); + + // We NEED memory barriers to ensure Interrupts are actually disabled! + // ( https://dzone.com/articles/nvic-disabling-interrupts-on-arm-cortex-m-and-the ) + __DSB(); + __ISB(); +} + +static bool tcIsSyncing(Tc * tc) { + return tc->COUNT32.STATUS.reg & TC_STATUS_SYNCBUSY; +} + +static void tcReset( Tc * tc) { + tc->COUNT32.CTRLA.reg = TC_CTRLA_SWRST; + while (tcIsSyncing(tc)) {} + while (tc->COUNT32.CTRLA.bit.SWRST) {} +} + +// -------------------------------------------------------------------------- +// Public functions +// -------------------------------------------------------------------------- + +void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { + IRQn_Type irq = timer_config[timer_num].IRQ_Id; + + // Disable interrupt, just in case it was already enabled + NVIC_DisableIRQ(irq); + NVIC_ClearPendingIRQ(irq); + + if (timer_num == MF_TIMER_RTC) { + + // https://github.com/arduino-libraries/RTCZero + Rtc * const rtc = timer_config[timer_num].pRtc; + PM->APBAMASK.reg |= PM_APBAMASK_RTC; + + GCLK->CLKCTRL.reg = (uint32_t)((GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK4 | (RTC_GCLK_ID << GCLK_CLKCTRL_ID_Pos))); + while (GCLK->STATUS.bit.SYNCBUSY) {} + + GCLK->GENCTRL.reg = (GCLK_GENCTRL_GENEN | GCLK_GENCTRL_SRC_OSCULP32K | GCLK_GENCTRL_ID(4) | GCLK_GENCTRL_DIVSEL ); + while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY) {} + + GCLK->GENDIV.reg = GCLK_GENDIV_ID(4); + GCLK->GENDIV.bit.DIV=4; + while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY) {} + + // Disable timer interrupt + rtc->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP0; + SYNC(rtc->MODE0.STATUS.bit.SYNCBUSY); + + while(rtc->MODE0.STATUS.bit.SYNCBUSY) {} + + // Stop timer, just in case, to be able to reconfigure it + rtc->MODE0.CTRL.reg = + RTC_MODE0_CTRL_MODE_COUNT32 | // Mode 0 = 32-bits counter + RTC_MODE0_CTRL_PRESCALER_DIV1024; // Divisor = 1024 + + while(rtc->MODE0.STATUS.bit.SYNCBUSY) {} + + // Mode, reset counter on match + rtc->MODE0.CTRL.reg = RTC_MODE0_CTRL_MODE_COUNT32 | RTC_MODE0_CTRL_MATCHCLR; + + // Set compare value + rtc->MODE0.COMP[0].reg = (32768 + frequency / 2) / frequency; + SYNC(rtc->MODE0.STATUS.bit.SYNCBUSY); + + // Enable interrupt on compare + rtc->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0; // reset pending interrupt + rtc->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_CMP0; // enable compare 0 interrupt + + // And start timer + rtc->MODE0.CTRL.bit.ENABLE = true; + SYNC(rtc->MODE0.STATUS.bit.SYNCBUSY); + + } + else if (timer_config[timer_num].type==TimerType::tcc) { + + Tcc * const tc = timer_config[timer_num].pTcc; + + PM->APBCMASK.reg |= PM_APBCMASK_TCC0; + GCLK->CLKCTRL.reg =(GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(TCC0_GCLK_ID)); + SYNC (GCLK->STATUS.bit.SYNCBUSY); + + tc->CTRLA.reg = TCC_CTRLA_SWRST; + SYNC (tc->SYNCBUSY.reg & TCC_SYNCBUSY_SWRST) {} + + SYNC (tc->CTRLA.bit.SWRST); + + tc->CTRLA.reg &= ~(TCC_CTRLA_ENABLE); // disable TC module + + tc->CTRLA.reg |= TCC_WAVE_WAVEGEN_MFRQ; + tc->CTRLA.reg |= TCC_CTRLA_PRESCALER_DIV2; + tc->CC[0].reg = (HAL_TIMER_RATE) / frequency; + tc->INTENSET.reg = TCC_INTFLAG_MC0; + tc->CTRLA.reg |= TCC_CTRLA_ENABLE; + tc->INTFLAG.reg = 0xFF; + SYNC ( tc->STATUS.reg & TC_STATUS_SYNCBUSY); + + } + else { + Tc * const tc = timer_config[timer_num].pTc; + + // Disable timer interrupt + tc->COUNT32.INTENCLR.reg = TC_INTENCLR_OVF; // disable overflow interrupt + + // TCn clock setup + GCLK->CLKCTRL.reg = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(GCM_TC4_TC5)) ; + SYNC (GCLK->STATUS.bit.SYNCBUSY); + + tcReset(tc); // reset TC + + // Set Timer counter 5 Mode to 16 bits, it will become a 16bit counter ('mode1' in the datasheet) + tc->COUNT32.CTRLA.reg |= TC_CTRLA_MODE_COUNT32; + // Set TC waveform generation mode to 'match frequency' + tc->COUNT32.CTRLA.reg |= TC_CTRLA_WAVEGEN_MFRQ; + //set prescaler + //the clock normally counts at the GCLK_TC frequency, but we can set it to divide that frequency to slow it down + //you can use different prescaler divisons here like TC_CTRLA_PRESCALER_DIV1 to get a different range + tc->COUNT32.CTRLA.reg |= TC_CTRLA_PRESCALER_DIV1 | TC_CTRLA_ENABLE; //it will divide GCLK_TC frequency by 1024 + //set the compare-capture register. + //The counter will count up to this value (it's a 16bit counter so we use uint16_t) + //this is how we fine-tune the frequency, make it count to a lower or higher value + //system clock should be 1MHz (8MHz/8) at Reset by default + tc->COUNT32.CC[0].reg = (uint16_t) (HAL_TIMER_RATE / frequency); + while (tcIsSyncing(tc)) {} + + // Enable the TC interrupt request + tc->COUNT32.INTENSET.bit.MC0 = 1; + while (tcIsSyncing(tc)) {} + } + + NVIC_SetPriority(irq, timer_config[timer_num].priority); + NVIC_EnableIRQ(irq); +} + +void HAL_timer_enable_interrupt(const uint8_t timer_num) { + const IRQn_Type irq = timer_config[timer_num].IRQ_Id; + NVIC_EnableIRQ(irq); +} + +void HAL_timer_disable_interrupt(const uint8_t timer_num) { + const IRQn_Type irq = timer_config[timer_num].IRQ_Id; + Disable_Irq(irq); +} + +// missing from CMSIS: Check if interrupt is enabled or not +static bool NVIC_GetEnabledIRQ(IRQn_Type IRQn) { + return TEST(NVIC->ISER[uint32_t(IRQn) >> 5], uint32_t(IRQn) & 0x1F); +} + +bool HAL_timer_interrupt_enabled(const uint8_t timer_num) { + const IRQn_Type irq = timer_config[timer_num].IRQ_Id; + return NVIC_GetEnabledIRQ(irq); +} + +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/timers.h b/Marlin/src/HAL/SAMD21/timers.h new file mode 100644 index 000000000000..303ccbdc505c --- /dev/null +++ b/Marlin/src/HAL/SAMD21/timers.h @@ -0,0 +1,160 @@ +/** + * 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 + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +#include + +// -------------------------------------------------------------------------- +// Defines +// -------------------------------------------------------------------------- + +typedef uint32_t hal_timer_t; +#define HAL_TIMER_TYPE_MAX 0xFFFFFFFF + +#define HAL_TIMER_RATE F_CPU // frequency of timers peripherals + +#define MF_TIMER_RTC 8 // This is not a TC but a RTC + +#ifndef MF_TIMER_STEP + #define MF_TIMER_STEP 4 // Timer Index for Stepper +#endif +#ifndef MF_TIMER_PULSE + #define MF_TIMER_PULSE MF_TIMER_STEP +#endif +#ifndef MF_TIMER_TEMP + #define MF_TIMER_TEMP MF_TIMER_RTC // Timer Index for Temperature +#endif + +#define TEMP_TIMER_FREQUENCY 1000 // temperature interrupt frequency + +#define STEPPER_TIMER_RATE HAL_TIMER_RATE // frequency of stepper timer (HAL_TIMER_RATE / STEPPER_TIMER_PRESCALE) +#define STEPPER_TIMER_TICKS_PER_US (STEPPER_TIMER_RATE / 1000000) // stepper timer ticks per µs +#define STEPPER_TIMER_PRESCALE (CYCLES_PER_MICROSECOND / STEPPER_TIMER_TICKS_PER_US) + +#define PULSE_TIMER_RATE STEPPER_TIMER_RATE +#define PULSE_TIMER_PRESCALE STEPPER_TIMER_PRESCALE +#define PULSE_TIMER_TICKS_PER_US STEPPER_TIMER_TICKS_PER_US + +#define ENABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_STEP) +#define DISABLE_STEPPER_DRIVER_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_STEP) +#define STEPPER_ISR_ENABLED() HAL_timer_interrupt_enabled(MF_TIMER_STEP) + +#define ENABLE_TEMPERATURE_INTERRUPT() HAL_timer_enable_interrupt(MF_TIMER_TEMP) +#define DISABLE_TEMPERATURE_INTERRUPT() HAL_timer_disable_interrupt(MF_TIMER_TEMP) + +#define TC_PRIORITY(t) ( t == SERVO_TC ? 1 \ + : (t == MF_TIMER_STEP || t == MF_TIMER_PULSE) ? 2 \ + : (t == MF_TIMER_TEMP) ? 6 : 7 ) + +#define _TC_HANDLER(t) void TC##t##_Handler() +#define TC_HANDLER(t) _TC_HANDLER(t) +#ifndef HAL_STEP_TIMER_ISR + #define HAL_STEP_TIMER_ISR() TC_HANDLER(MF_TIMER_STEP) +#endif +#if MF_TIMER_STEP != MF_TIMER_PULSE + #define HAL_PULSE_TIMER_ISR() TC_HANDLER(MF_TIMER_PULSE) +#endif +#if MF_TIMER_TEMP == MF_TIMER_RTC + #define HAL_TEMP_TIMER_ISR() void RTC_Handler() +#else + #define HAL_TEMP_TIMER_ISR() TC_HANDLER(MF_TIMER_TEMP) +#endif + +// -------------------------------------------------------------------------- +// Types +// -------------------------------------------------------------------------- +typedef enum { tcc, tc, rtc } TimerType; + +typedef struct { + union { + Tc *pTc; + Tcc *pTcc; + Rtc *pRtc; + }; + TimerType type; + IRQn_Type IRQ_Id; + uint8_t priority; +} tTimerConfig; + +// -------------------------------------------------------------------------- +// Public Variables +// -------------------------------------------------------------------------- + +extern const tTimerConfig timer_config[]; + +// -------------------------------------------------------------------------- +// Public functions +// -------------------------------------------------------------------------- + +void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency); + +FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) { + // Should never be called with timer MF_TIMER_RTC + Tc * const tc = timer_config[timer_num].pTc; + tc->COUNT32.CC[0].reg = compare; +} + +FORCE_INLINE static hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) { + // Should never be called with timer MF_TIMER_RTC + Tc * const tc = timer_config[timer_num].pTc; + return (hal_timer_t)tc->COUNT32.CC[0].reg; +} + +FORCE_INLINE static hal_timer_t HAL_timer_get_count(const uint8_t timer_num) { + // Should never be called with timer MF_TIMER_RTC + Tc * const tc = timer_config[timer_num].pTc; + tc->COUNT32.READREQ.reg = TC_READREQ_RREQ; + // Request a read synchronization + SYNC (tc->COUNT32.STATUS.bit.SYNCBUSY); + //SYNC(tc->COUNT32.STATUS.bit.SYNCBUSY ); + return tc->COUNT32.COUNT.reg; +} + +void HAL_timer_enable_interrupt(const uint8_t timer_num); +void HAL_timer_disable_interrupt(const uint8_t timer_num); +bool HAL_timer_interrupt_enabled(const uint8_t timer_num); + +FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) { + if (timer_num == MF_TIMER_RTC) { + Rtc * const rtc = timer_config[timer_num].pRtc; + // Clear interrupt flag + rtc->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0| RTC_MODE0_INTFLAG_OVF; + + } + else if (timer_config[timer_num].type == TimerType::tcc){ + Tcc * const tc = timer_config[timer_num].pTcc; + // Clear interrupt flag + tc->INTFLAG.reg = TCC_INTFLAG_OVF; + } + else { + Tc * const tc = timer_config[timer_num].pTc; + // Clear interrupt flag + tc->COUNT32.INTFLAG.bit.MC0 = 1; + } +} + +#define HAL_timer_isr_epilogue(timer_num) diff --git a/Marlin/src/HAL/SAMD21/u8g/LCD_I2C_routines.cpp b/Marlin/src/HAL/SAMD21/u8g/LCD_I2C_routines.cpp new file mode 100644 index 000000000000..41da7c10fc24 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/u8g/LCD_I2C_routines.cpp @@ -0,0 +1,32 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +// adapted from I2C/master/master.c example +// https://www-users.cs.york.ac.uk/~pcc/MCP/HAPR-Course-web/CMSIS/examples/html/master_8c_source.html + +#ifdef __SAMD21__ + +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/u8g/LCD_I2C_routines.h b/Marlin/src/HAL/SAMD21/u8g/LCD_I2C_routines.h new file mode 100644 index 000000000000..d6a3c4fe0b91 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/u8g/LCD_I2C_routines.h @@ -0,0 +1,27 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#pragma once diff --git a/Marlin/src/HAL/SAMD21/u8g/LCD_defines.h b/Marlin/src/HAL/SAMD21/u8g/LCD_defines.h new file mode 100644 index 000000000000..fa98725d2262 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/u8g/LCD_defines.h @@ -0,0 +1,41 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#pragma once + +/** + * SAMD21 LCD-specific defines + */ + +// The following are optional depending on the platform. + +// definitions of HAL specific com and device drivers. +uint8_t u8g_com_samd21_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); +uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); + +// connect U8g com generic com names to the desired driver +#define U8G_COM_HW_SPI u8g_com_samd21_st7920_hw_spi_fn // use SAMD21 specific hardware SPI routine +#define U8G_COM_ST7920_HW_SPI u8g_com_samd21_st7920_hw_spi_fn diff --git a/Marlin/src/HAL/SAMD21/u8g/LCD_pin_routines.c b/Marlin/src/HAL/SAMD21/u8g/LCD_pin_routines.c new file mode 100644 index 000000000000..f9f77825f6e0 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/u8g/LCD_pin_routines.c @@ -0,0 +1,42 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +/** + * Low level pin manipulation routines - used by all the drivers. + * + * These are based on the SAMD51 pinMode, digitalRead & digitalWrite routines. + * + * Couldn't just call exact copies because the overhead killed the LCD update speed + * With an intermediate level the softspi was running in the 10-20kHz range which + * resulted in using about about 25% of the CPU's time. + */ + +#ifdef __SAMD21__ + +#include + +#endif // __SAMD21__ diff --git a/Marlin/src/HAL/SAMD21/u8g/LCD_pin_routines.h b/Marlin/src/HAL/SAMD21/u8g/LCD_pin_routines.h new file mode 100644 index 000000000000..92626552b013 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/u8g/LCD_pin_routines.h @@ -0,0 +1,42 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ +#pragma once + +/** + * Low level pin manipulation routines - used by all the drivers. + * + * These are based on the SAMD51 pinMode, digitalRead & digitalWrite routines. + * + * Couldn't just call exact copies because the overhead killed the LCD update speed + * With an intermediate level the softspi was running in the 10-20kHz range which + * resulted in using about about 25% of the CPU's time. + */ + +void u8g_SetPinOutput(uint8_t internal_pin_number); +void u8g_SetPinInput(uint8_t internal_pin_number); +void u8g_SetPinLevel(uint8_t pin, uint8_t pin_status); +uint8_t u8g_GetPinLevel(uint8_t pin); diff --git a/Marlin/src/HAL/SAMD21/u8g/u8g_com_HAL_samd21_shared_hw_spi.cpp b/Marlin/src/HAL/SAMD21/u8g/u8g_com_HAL_samd21_shared_hw_spi.cpp new file mode 100644 index 000000000000..02dc77229676 --- /dev/null +++ b/Marlin/src/HAL/SAMD21/u8g/u8g_com_HAL_samd21_shared_hw_spi.cpp @@ -0,0 +1,154 @@ +/** + * 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 . + * + */ + +/** + * SAMD21 HAL developed by Bart Meijer (brupje) + * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) + */ + +/** + * Based on u8g_com_msp430_hw_spi.c + * + * Universal 8bit Graphics Library + * + * Copyright (c) 2012, olikraus@gmail.com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list + * of conditions and the following disclaimer. + * + * * 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. + * + * 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. + */ + +#ifdef __SAMD21__ + +#include +#include "SPI.h" + +#include "../../shared/HAL_SPI.h" + +#ifndef LCD_SPI_SPEED + #define LCD_SPI_SPEED SPI_QUARTER_SPEED +#endif + +void u8g_SetPIOutput(u8g_t *u8g, uint8_t pin_index) { + if (u8g->pin_list[pin_index]!= U8G_PIN_NONE) + pinMode(u8g->pin_list[pin_index],OUTPUT); +} + +void u8g_SetPILevel(u8g_t *u8g, uint8_t pin_index, uint8_t level) { + if (u8g->pin_list[pin_index]!= U8G_PIN_NONE) + digitalWrite(u8g->pin_list[pin_index],level); +} + +uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { + + static SPISettings lcdSPIConfig; + + switch (msg) { + case U8G_COM_MSG_STOP: + break; + + case U8G_COM_MSG_INIT: + u8g_SetPIOutput(u8g, U8G_PI_CS); + u8g_SetPIOutput(u8g, U8G_PI_A0); + u8g_SetPIOutput(u8g, U8G_PI_RESET); + + u8g_SetPILevel(u8g, U8G_PI_CS, LOW); + + spiBegin(); + lcdSPIConfig = SPISettings(900000, MSBFIRST, SPI_MODE0); + u8g->pin_list[U8G_PI_A0_STATE] = 0; + break; + + case U8G_COM_MSG_ADDRESS: // define cmd (arg_val = 0) or data mode (arg_val = 1) + u8g_SetPILevel(u8g, U8G_PI_A0, arg_val); + u8g->pin_list[U8G_PI_A0_STATE] = arg_val; + break; + + case U8G_COM_MSG_CHIP_SELECT: // arg_val == 1 means chip selected, but ST7920 is active high, so needs inverting + u8g_SetPILevel(u8g, U8G_PI_CS, arg_val ? HIGH : LOW); + break; + + case U8G_COM_MSG_RESET: + u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val); + break; + + case U8G_COM_MSG_WRITE_BYTE: + SPI.beginTransaction(lcdSPIConfig); + + if (u8g->pin_list[U8G_PI_A0_STATE] == 0) { // command + SPI.transfer(0x0f8); u8g->pin_list[U8G_PI_A0_STATE] = 2; + } + else if (u8g->pin_list[U8G_PI_A0_STATE] == 1) { // data + SPI.transfer(0x0fa); u8g->pin_list[U8G_PI_A0_STATE] = 2; + } + + SPI.transfer(arg_val & 0x0f0); + SPI.transfer(arg_val << 4); + SPI.endTransaction(); + break; + + case U8G_COM_MSG_WRITE_SEQ: + SPI.beginTransaction(lcdSPIConfig); + + if (u8g->pin_list[U8G_PI_A0_STATE] == 0 ) { // command + SPI.transfer(0x0f8); u8g->pin_list[U8G_PI_A0_STATE] = 2; + } + else if (u8g->pin_list[U8G_PI_A0_STATE] == 1) { // data + SPI.transfer(0x0fa); u8g->pin_list[U8G_PI_A0_STATE] = 2; + } + + uint8_t *ptr = (uint8_t*)arg_ptr; + while (arg_val > 0) { + SPI.transfer((*ptr) & 0x0f0); + SPI.transfer((*ptr) << 4); + ptr++; + arg_val--; + } + + SPI.endTransaction(); + break; + } + return 1; +} + +#endif // __SAMD21__ 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 04461653f94f..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 */ @@ -77,7 +82,8 @@ HAL_SERVO_TIMER_ISR() { ; const uint8_t tcChannel = TIMER_TCCHANNEL(timer); - if (currentServoIndex[timer] < 0) { + int8_t cho = currentServoIndex[timer]; // Handle the prior servo first + if (cho < 0) { // Servo -1 indicates the refresh interval completed... #if defined(_useTimer1) && defined(_useTimer2) if (currentServoIndex[timer ^ 1] >= 0) { // Wait for both channels @@ -86,41 +92,33 @@ HAL_SERVO_TIMER_ISR() { return; } #endif - tc->COUNT16.COUNT.reg = TC_COUNTER_START_VAL; + tc->COUNT16.COUNT.reg = TC_COUNTER_START_VAL; // ...so reset the timer SYNC(tc->COUNT16.SYNCBUSY.bit.COUNT); } - else if (SERVO_INDEX(timer, currentServoIndex[timer]) < ServoCount && SERVO(timer, currentServoIndex[timer]).Pin.isActive) - digitalWrite(SERVO(timer, currentServoIndex[timer]).Pin.nbr, LOW); // pulse this channel low if activated - - // Select the next servo controlled by this timer - currentServoIndex[timer]++; + else if (SERVO_INDEX(timer, cho) < ServoCount) // prior channel handled? + digitalWrite(SERVO(timer, cho).Pin.nbr, LOW); // pulse the prior channel LOW - if (SERVO_INDEX(timer, currentServoIndex[timer]) < ServoCount && currentServoIndex[timer] < SERVOS_PER_TIMER) { - if (SERVO(timer, currentServoIndex[timer]).Pin.isActive) // check if activated - digitalWrite(SERVO(timer, currentServoIndex[timer]).Pin.nbr, HIGH); // it's an active channel so pulse it high + currentServoIndex[timer] = ++cho; // go to the next channel (or 0) + if (cho < SERVOS_PER_TIMER && SERVO_INDEX(timer, cho) < ServoCount) { + if (SERVO(timer, cho).Pin.isActive) // activated? + digitalWrite(SERVO(timer, cho).Pin.nbr, HIGH); // yes: pulse HIGH - tc->COUNT16.CC[tcChannel].reg = getTimerCount() - (uint16_t)SERVO(timer, currentServoIndex[timer]).ticks; + tc->COUNT16.CC[tcChannel].reg = getTimerCount() - (uint16_t)SERVO(timer, cho).ticks; } else { // finished all channels so wait for the refresh period to expire before starting over - currentServoIndex[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel - - const uint16_t tcCounterValue = getTimerCount(); - - if ((TC_COUNTER_START_VAL - tcCounterValue) + 4UL < usToTicks(REFRESH_INTERVAL)) // allow a few ticks to ensure the next OCR1A not missed - tc->COUNT16.CC[tcChannel].reg = TC_COUNTER_START_VAL - (uint16_t)usToTicks(REFRESH_INTERVAL); - else - tc->COUNT16.CC[tcChannel].reg = (uint16_t)(tcCounterValue - 4UL); // at least REFRESH_INTERVAL has elapsed + currentServoIndex[timer] = -1; // reset the timer COUNT.reg on the next call + const uint16_t cval = getTimerCount() - 256 / (SERVO_TIMER_PRESCALER), // allow 256 cycles to ensure the next CV not missed + ival = (TC_COUNTER_START_VAL) - (uint16_t)usToTicks(REFRESH_INTERVAL); // at least REFRESH_INTERVAL has elapsed + tc->COUNT16.CC[tcChannel].reg = min(cval, ival); } if (tcChannel == 0) { SYNC(tc->COUNT16.SYNCBUSY.bit.CC0); - // Clear the interrupt - tc->COUNT16.INTFLAG.reg = TC_INTFLAG_MC0; + tc->COUNT16.INTFLAG.reg = TC_INTFLAG_MC0; // Clear the interrupt } else { SYNC(tc->COUNT16.SYNCBUSY.bit.CC1); - // Clear the interrupt - tc->COUNT16.INTFLAG.reg = TC_INTFLAG_MC1; + tc->COUNT16.INTFLAG.reg = TC_INTFLAG_MC1; // Clear the interrupt } } @@ -201,9 +199,9 @@ void initISR(const timer16_Sequence_t timer) { } } -void finISR(const timer16_Sequence_t timer) { +void finISR(const timer16_Sequence_t timer_index) { Tc * const tc = timer_config[SERVO_TC].pTc; - const uint8_t tcChannel = TIMER_TCCHANNEL(timer); + const uint8_t tcChannel = TIMER_TCCHANNEL(timer_index); // Disable the match channel interrupt request tc->COUNT16.INTENCLR.reg = (tcChannel == 0) ? TC_INTENCLR_MC0 : TC_INTENCLR_MC1; 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/Conditionals_LCD.h b/Marlin/src/HAL/SAMD51/inc/Conditionals_LCD.h index 932348c52f40..5f1c4b16019d 100644 --- a/Marlin/src/HAL/SAMD51/inc/Conditionals_LCD.h +++ b/Marlin/src/HAL/SAMD51/inc/Conditionals_LCD.h @@ -20,7 +20,3 @@ * */ #pragma once - -#if HAS_SPI_TFT || HAS_FSMC_TFT - #error "Sorry! TFT displays are not available for HAL/SAMD51." -#endif diff --git a/Marlin/src/HAL/SAMD51/inc/SanityCheck.h b/Marlin/src/HAL/SAMD51/inc/SanityCheck.h index 1b876c947dc7..f9ff090f75ae 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,11 +19,20 @@ * 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. */ +#if HAS_SPI_TFT || HAS_FSMC_TFT + #error "Sorry! TFT displays are not available for HAL/SAMD51." +#endif + #if ENABLED(FLASH_EEPROM_EMULATION) #warning "Did you activate the SmartEEPROM? See https://github.com/GMagician/SAMD51-SmartEEprom-Manager/releases" #endif @@ -49,7 +59,7 @@ #endif #if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY - #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on SAMD51." + #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported for HAL/SAMD51." #endif #if ENABLED(POSTMORTEM_DEBUGGING) diff --git a/Marlin/src/HAL/SAMD51/pinsDebug.h b/Marlin/src/HAL/SAMD51/pinsDebug.h index f0a46fd7c567..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) @@ -29,7 +34,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/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 // -------------------------------------------------------------------------- diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index 3e85aca293d2..61569c793738 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -138,7 +138,7 @@ typedef double isr_float_t; // FPU ops are used for single-precision, so use double for ISRs. -#ifdef STM32G0B1xx +#if defined(STM32G0B1xx) || defined(STM32H7xx) typedef int32_t pin_t; #else typedef int16_t pin_t; diff --git a/Marlin/src/HAL/STM32/HAL_SPI.cpp b/Marlin/src/HAL/STM32/HAL_SPI.cpp index 40d320d5e822..278d209c47cb 100644 --- a/Marlin/src/HAL/STM32/HAL_SPI.cpp +++ b/Marlin/src/HAL/STM32/HAL_SPI.cpp @@ -78,7 +78,6 @@ static SPISettings spiConfig; case SPI_SPEED_6: delaySPIFunc = &delaySPI_2000; break; // desired: 250,000 actual: ~210K default: delaySPIFunc = &delaySPI_4000; break; // desired: 125,000 actual: ~123K } - SPI.begin(); } // Begin SPI transaction, set clock, bit order, data mode 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/HAL/STM32/eeprom_sdcard.cpp b/Marlin/src/HAL/STM32/eeprom_sdcard.cpp index 473b656f9a3c..1b5c0ae5b2c0 100644 --- a/Marlin/src/HAL/STM32/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/STM32/eeprom_sdcard.cpp @@ -48,7 +48,7 @@ static char _ALIGN(4) HAL_eeprom_data[MARLIN_EEPROM_SIZE]; bool PersistentStore::access_start() { if (!card.isMounted()) return false; - SdFile file, root = card.getroot(); + MediaFile file, root = card.getroot(); if (!file.open(&root, EEPROM_FILENAME, O_RDONLY)) return true; @@ -63,7 +63,7 @@ bool PersistentStore::access_start() { bool PersistentStore::access_finish() { if (!card.isMounted()) return false; - SdFile file, root = card.getroot(); + MediaFile file, root = card.getroot(); int bytes_written = 0; if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) { bytes_written = file.write(HAL_eeprom_data, MARLIN_EEPROM_SIZE); diff --git a/Marlin/src/HAL/STM32/inc/Conditionals_post.h b/Marlin/src/HAL/STM32/inc/Conditionals_post.h index 18826e11d24a..83ce077c754d 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) && ENABLED(FLASH_EEPROM_EMULATION) && PRINTCOUNTER_SAVE_INTERVAL > 0 + #define PRINTCOUNTER_SYNC +#endif diff --git a/Marlin/src/HAL/STM32/inc/SanityCheck.h b/Marlin/src/HAL/STM32/inc/SanityCheck.h index 0f1a2acaa41c..e8ddfa172005 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 @@ -55,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/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/STM32/sdio.cpp b/Marlin/src/HAL/STM32/sdio.cpp index e958d8c3bc48..72518ef1cc87 100644 --- a/Marlin/src/HAL/STM32/sdio.cpp +++ b/Marlin/src/HAL/STM32/sdio.cpp @@ -33,227 +33,416 @@ #include #include -// use local drivers #if defined(STM32F103xE) || defined(STM32F103xG) - #include + #include + #include #elif defined(STM32F4xx) - #include + #include + #include + #include + #include #elif defined(STM32F7xx) - #include + #include + #include + #include + #include #elif defined(STM32H7xx) - #include + #define SDIO_FOR_STM32H7 + #include + #include + #include + #include #else - #error "SDIO only supported with STM32F103xE, STM32F103xG, STM32F4xx, STM32F7xx, or STM32H7xx." + #error "SDIO is only supported with STM32F103xE, STM32F103xG, STM32F4xx, STM32F7xx, and STM32H7xx." #endif +// SDIO Max Clock (naming from STM Manual, don't change) +#define SDIOCLK 48000000 + // Target Clock, configurable. Default is 18MHz, from STM32F1 #ifndef SDIO_CLOCK #define SDIO_CLOCK 18000000 // 18 MHz #endif -#define SD_TIMEOUT 1000 // ms +SD_HandleTypeDef hsd; // SDIO structure -// SDIO Max Clock (naming from STM Manual, don't change) -#define SDIOCLK 48000000 +static uint32_t clock_to_divider(uint32_t clk) { + #ifdef SDIO_FOR_STM32H7 + // SDMMC_CK frequency = sdmmc_ker_ck / [2 * CLKDIV]. + uint32_t sdmmc_clk = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_SDMMC); + return sdmmc_clk / (2U * SDIO_CLOCK) + (sdmmc_clk % (2U * SDIO_CLOCK) != 0); + #else + // limit the SDIO master clock to 8/3 of PCLK2. See STM32 Manuals + // Also limited to no more than 48Mhz (SDIOCLK). + const uint32_t pclk2 = HAL_RCC_GetPCLK2Freq(); + clk = min(clk, (uint32_t)(pclk2 * 8 / 3)); + clk = min(clk, (uint32_t)SDIOCLK); + // Round up divider, so we don't run the card over the speed supported, + // and subtract by 2, because STM32 will add 2, as written in the manual: + // SDIO_CK frequency = SDIOCLK / [CLKDIV + 2] + return pclk2 / clk + (pclk2 % clk != 0) - 2; + #endif +} -#if defined(STM32F1xx) - DMA_HandleTypeDef hdma_sdio; - extern "C" void DMA2_Channel4_5_IRQHandler(void) { - HAL_DMA_IRQHandler(&hdma_sdio); - } -#elif defined(STM32F4xx) - DMA_HandleTypeDef hdma_sdio_rx; - DMA_HandleTypeDef hdma_sdio_tx; - extern "C" void DMA2_Stream3_IRQHandler(void) { - HAL_DMA_IRQHandler(&hdma_sdio_rx); +// Start the SDIO clock +void HAL_SD_MspInit(SD_HandleTypeDef *hsd) { + UNUSED(hsd); + #ifdef SDIO_FOR_STM32H7 + pinmap_pinout(PC_12, PinMap_SD); + pinmap_pinout(PD_2, PinMap_SD); + pinmap_pinout(PC_8, PinMap_SD); + #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // Define D1-D3 only for 4-bit wide SDIO bus + pinmap_pinout(PC_9, PinMap_SD); + pinmap_pinout(PC_10, PinMap_SD); + pinmap_pinout(PC_11, PinMap_SD); + #endif + __HAL_RCC_SDMMC1_CLK_ENABLE(); + HAL_NVIC_EnableIRQ(SDMMC1_IRQn); + #else + __HAL_RCC_SDIO_CLK_ENABLE(); + #endif +} + +#ifdef SDIO_FOR_STM32H7 + + #define SD_TIMEOUT 1000 // ms + + extern "C" void SDMMC1_IRQHandler(void) { HAL_SD_IRQHandler(&hsd); } + + uint8_t waitingRxCplt = 0, waitingTxCplt = 0; + void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsdio) { waitingTxCplt = 0; } + void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsdio) { waitingRxCplt = 0; } + + void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd) { + __HAL_RCC_SDMMC1_FORCE_RESET(); delay(10); + __HAL_RCC_SDMMC1_RELEASE_RESET(); delay(10); } - extern "C" void DMA2_Stream6_IRQHandler(void) { - HAL_DMA_IRQHandler(&hdma_sdio_tx); + bool SDIO_Init() { + HAL_StatusTypeDef sd_state = HAL_OK; + if (hsd.Instance == SDMMC1) HAL_SD_DeInit(&hsd); + + // HAL SD initialization + hsd.Instance = SDMMC1; + hsd.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING; + hsd.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE; + hsd.Init.BusWide = SDMMC_BUS_WIDE_1B; + hsd.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE; + hsd.Init.ClockDiv = clock_to_divider(SDIO_CLOCK); + sd_state = HAL_SD_Init(&hsd); + + #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) + if (sd_state == HAL_OK) + sd_state = HAL_SD_ConfigWideBusOperation(&hsd, SDMMC_BUS_WIDE_4B); + #endif + + return (sd_state == HAL_OK); } -#elif defined(STM32H7xx) - #define __HAL_RCC_SDIO_FORCE_RESET __HAL_RCC_SDMMC1_FORCE_RESET - #define __HAL_RCC_SDIO_RELEASE_RESET __HAL_RCC_SDMMC1_RELEASE_RESET - #define __HAL_RCC_SDIO_CLK_ENABLE __HAL_RCC_SDMMC1_CLK_ENABLE - #define SDIO SDMMC1 - #define SDIO_IRQn SDMMC1_IRQn - #define SDIO_IRQHandler SDMMC1_IRQHandler - #define SDIO_CLOCK_EDGE_RISING SDMMC_CLOCK_EDGE_RISING - #define SDIO_CLOCK_POWER_SAVE_DISABLE SDMMC_CLOCK_POWER_SAVE_DISABLE - #define SDIO_BUS_WIDE_1B SDMMC_BUS_WIDE_1B - #define SDIO_BUS_WIDE_4B SDMMC_BUS_WIDE_4B - #define SDIO_HARDWARE_FLOW_CONTROL_DISABLE SDMMC_HARDWARE_FLOW_CONTROL_DISABLE -#endif -uint8_t waitingRxCplt = 0; -uint8_t waitingTxCplt = 0; -SD_HandleTypeDef hsd; +#else // !SDIO_FOR_STM32H7 -extern "C" void SDIO_IRQHandler(void) { - HAL_SD_IRQHandler(&hsd); -} + #define SD_TIMEOUT 500 // ms -void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsdio) { - waitingTxCplt = 0; -} + // SDIO retries, configurable. Default is 3, from STM32F1 + #ifndef SDIO_READ_RETRIES + #define SDIO_READ_RETRIES 3 + #endif -void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsdio) { - waitingRxCplt = 0; -} + // F4 supports one DMA for RX and another for TX, but Marlin will never + // do read and write at same time, so we use the same DMA for both. + DMA_HandleTypeDef hdma_sdio; -void HAL_SD_MspInit(SD_HandleTypeDef *hsd) { - pinmap_pinout(PC_12, PinMap_SD); - pinmap_pinout(PD_2, PinMap_SD); - pinmap_pinout(PC_8, PinMap_SD); - #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // define D1-D3 only if have a four bit wide SDIO bus - // D1-D3 - pinmap_pinout(PC_9, PinMap_SD); - pinmap_pinout(PC_10, PinMap_SD); - pinmap_pinout(PC_11, PinMap_SD); + #ifdef STM32F1xx + #define DMA_IRQ_HANDLER DMA2_Channel4_5_IRQHandler + #elif defined(STM32F4xx) + #define DMA_IRQ_HANDLER DMA2_Stream3_IRQHandler + #else + #error "Unknown STM32 architecture." #endif - __HAL_RCC_SDIO_CLK_ENABLE(); - HAL_NVIC_EnableIRQ(SDIO_IRQn); + extern "C" void SDIO_IRQHandler(void) { HAL_SD_IRQHandler(&hsd); } + extern "C" void DMA_IRQ_HANDLER(void) { HAL_DMA_IRQHandler(&hdma_sdio); } + + /* + SDIO_INIT_CLK_DIV is 118 + SDIO clock frequency is 48MHz / (TRANSFER_CLOCK_DIV + 2) + SDIO init clock frequency should not exceed 400kHz = 48MHz / (118 + 2) + + Default TRANSFER_CLOCK_DIV is 2 (118 / 40) + Default SDIO clock frequency is 48MHz / (2 + 2) = 12 MHz + This might be too fast for stable SDIO operations + + MKS Robin SDIO seems stable with BusWide 1bit and ClockDiv 8 (i.e., 4.8MHz SDIO clock frequency) + More testing is required as there are clearly some 4bit init problems. + */ + + void go_to_transfer_speed() { + /* Default SDIO peripheral configuration for SD card initialization */ + hsd.Init.ClockEdge = hsd.Init.ClockEdge; + hsd.Init.ClockBypass = hsd.Init.ClockBypass; + hsd.Init.ClockPowerSave = hsd.Init.ClockPowerSave; + hsd.Init.BusWide = hsd.Init.BusWide; + hsd.Init.HardwareFlowControl = hsd.Init.HardwareFlowControl; + hsd.Init.ClockDiv = clock_to_divider(SDIO_CLOCK); + + /* Initialize SDIO peripheral interface with default configuration */ + SDIO_Init(hsd.Instance, hsd.Init); + } - // DMA Config - #if defined(STM32F1xx) - __HAL_RCC_DMA2_CLK_ENABLE(); - HAL_NVIC_EnableIRQ(DMA2_Channel4_5_IRQn); - hdma_sdio.Instance = DMA2_Channel4; - hdma_sdio.Init.Direction = DMA_PERIPH_TO_MEMORY; + void SD_LowLevel_Init() { + uint32_t tempreg; + + // Enable GPIO clocks + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + + GPIO_InitTypeDef GPIO_InitStruct; + + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = 1; // GPIO_NOPULL + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; + + #if DISABLED(STM32F1xx) + GPIO_InitStruct.Alternate = GPIO_AF12_SDIO; + #endif + + GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_12; // D0 & SCK + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // define D1-D3 only if have a four bit wide SDIO bus + GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11; // D1-D3 + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + #endif + + // Configure PD.02 CMD line + GPIO_InitStruct.Pin = GPIO_PIN_2; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + // Setup DMA + #ifdef STM32F1xx + hdma_sdio.Init.Mode = DMA_NORMAL; + hdma_sdio.Instance = DMA2_Channel4; + HAL_NVIC_EnableIRQ(DMA2_Channel4_5_IRQn); + #elif defined(STM32F4xx) + hdma_sdio.Init.Mode = DMA_PFCTRL; + hdma_sdio.Instance = DMA2_Stream3; + hdma_sdio.Init.Channel = DMA_CHANNEL_4; + hdma_sdio.Init.FIFOMode = DMA_FIFOMODE_ENABLE; + hdma_sdio.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; + hdma_sdio.Init.MemBurst = DMA_MBURST_INC4; + hdma_sdio.Init.PeriphBurst = DMA_PBURST_INC4; + HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn); + #endif + HAL_NVIC_EnableIRQ(SDIO_IRQn); hdma_sdio.Init.PeriphInc = DMA_PINC_DISABLE; hdma_sdio.Init.MemInc = DMA_MINC_ENABLE; hdma_sdio.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; hdma_sdio.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - hdma_sdio.Init.Mode = DMA_NORMAL; hdma_sdio.Init.Priority = DMA_PRIORITY_LOW; - HAL_DMA_Init(&hdma_sdio); + __HAL_LINKDMA(&hsd, hdmarx, hdma_sdio); + __HAL_LINKDMA(&hsd, hdmatx, hdma_sdio); + + #ifdef STM32F1xx + __HAL_RCC_SDIO_CLK_ENABLE(); + __HAL_RCC_DMA2_CLK_ENABLE(); + #else + __HAL_RCC_SDIO_FORCE_RESET(); delay(2); + __HAL_RCC_SDIO_RELEASE_RESET(); delay(2); + __HAL_RCC_SDIO_CLK_ENABLE(); + + __HAL_RCC_DMA2_FORCE_RESET(); delay(2); + __HAL_RCC_DMA2_RELEASE_RESET(); delay(2); + __HAL_RCC_DMA2_CLK_ENABLE(); + #endif + + // Initialize the SDIO (with initial <400Khz Clock) + tempreg = 0 // Reset value + | SDIO_CLKCR_CLKEN // Clock enabled + | SDIO_INIT_CLK_DIV; // Clock Divider. Clock = 48000 / (118 + 2) = 400Khz + // Keep the rest at 0 => HW_Flow Disabled, Rising Clock Edge, Disable CLK ByPass, Bus Width = 0, Power save Disable + SDIO->CLKCR = tempreg; + + // Power up the SDIO + SDIO_PowerState_ON(SDIO); + hsd.Instance = SDIO; + } - __HAL_LINKDMA(hsd, hdmarx ,hdma_sdio); - __HAL_LINKDMA(hsd, hdmatx, hdma_sdio); - #elif defined(STM32F4xx) - __HAL_RCC_DMA2_CLK_ENABLE(); - HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn); - HAL_NVIC_EnableIRQ(DMA2_Stream6_IRQn); - hdma_sdio_rx.Instance = DMA2_Stream3; - hdma_sdio_rx.Init.Channel = DMA_CHANNEL_4; - hdma_sdio_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; - hdma_sdio_rx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_sdio_rx.Init.MemInc = DMA_MINC_ENABLE; - hdma_sdio_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - hdma_sdio_rx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - hdma_sdio_rx.Init.Mode = DMA_PFCTRL; - hdma_sdio_rx.Init.Priority = DMA_PRIORITY_LOW; - hdma_sdio_rx.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - hdma_sdio_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_sdio_rx.Init.MemBurst = DMA_MBURST_INC4; - hdma_sdio_rx.Init.PeriphBurst = DMA_PBURST_INC4; - HAL_DMA_Init(&hdma_sdio_rx); - - __HAL_LINKDMA(hsd,hdmarx,hdma_sdio_rx); - - hdma_sdio_tx.Instance = DMA2_Stream6; - hdma_sdio_tx.Init.Channel = DMA_CHANNEL_4; - hdma_sdio_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; - hdma_sdio_tx.Init.PeriphInc = DMA_PINC_DISABLE; - hdma_sdio_tx.Init.MemInc = DMA_MINC_ENABLE; - hdma_sdio_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - hdma_sdio_tx.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - hdma_sdio_tx.Init.Mode = DMA_PFCTRL; - hdma_sdio_tx.Init.Priority = DMA_PRIORITY_LOW; - hdma_sdio_tx.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - hdma_sdio_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_sdio_tx.Init.MemBurst = DMA_MBURST_INC4; - hdma_sdio_tx.Init.PeriphBurst = DMA_PBURST_INC4; - HAL_DMA_Init(&hdma_sdio_tx); - - __HAL_LINKDMA(hsd,hdmatx,hdma_sdio_tx); - #endif -} + bool SDIO_Init() { + uint8_t retryCnt = SDIO_READ_RETRIES; -void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd) { - #if !defined(STM32F1xx) - __HAL_RCC_SDIO_FORCE_RESET(); - delay(10); - __HAL_RCC_SDIO_RELEASE_RESET(); - delay(10); - #endif -} + bool status; + hsd.Instance = SDIO; + hsd.State = HAL_SD_STATE_RESET; -static uint32_t clock_to_divider(uint32_t clk) { - #if defined(STM32H7xx) - // SDMMC_CK frequency = sdmmc_ker_ck / [2 * CLKDIV]. - uint32_t sdmmc_clk = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_SDMMC); - return sdmmc_clk / (2U * SDIO_CLOCK) + (sdmmc_clk % (2U * SDIO_CLOCK) != 0); - #else - // limit the SDIO master clock to 8/3 of PCLK2. See STM32 Manuals - // Also limited to no more than 48Mhz (SDIOCLK). - const uint32_t pclk2 = HAL_RCC_GetPCLK2Freq(); - clk = min(clk, (uint32_t)(pclk2 * 8 / 3)); - clk = min(clk, (uint32_t)SDIOCLK); - // Round up divider, so we don't run the card over the speed supported, - // and subtract by 2, because STM32 will add 2, as written in the manual: - // SDIO_CK frequency = SDIOCLK / [CLKDIV + 2] - return pclk2 / clk + (pclk2 % clk != 0) - 2; - #endif -} + SD_LowLevel_Init(); -bool SDIO_Init() { - HAL_StatusTypeDef sd_state = HAL_OK; - if (hsd.Instance == SDIO) - HAL_SD_DeInit(&hsd); - - /* HAL SD initialization */ - hsd.Instance = SDIO; - hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; - hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; - hsd.Init.BusWide = SDIO_BUS_WIDE_1B; - hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE; - hsd.Init.ClockDiv = clock_to_divider(SDIO_CLOCK); - sd_state = HAL_SD_Init(&hsd); - - #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) - if (sd_state == HAL_OK) { - sd_state = HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B); + uint8_t retry_Cnt = retryCnt; + for (;;) { + hal.watchdog_refresh(); + status = (bool) HAL_SD_Init(&hsd); + if (!status) break; + if (!--retry_Cnt) return false; // return failing status if retries are exhausted } - #endif - return (sd_state == HAL_OK) ? true : false; -} + go_to_transfer_speed(); + + hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_ENABLE; + hsd.Init.ClockDiv = 8; + + #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // go to 4 bit wide mode if pins are defined + retry_Cnt = retryCnt; + for (;;) { + hal.watchdog_refresh(); + if (!HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B)) break; // some cards are only 1 bit wide so a pass here is not required + if (!--retry_Cnt) break; + } + if (!retry_Cnt) { // wide bus failed, go back to one bit wide mode + hsd.State = (HAL_SD_StateTypeDef) 0; // HAL_SD_STATE_RESET + SD_LowLevel_Init(); + retry_Cnt = retryCnt; + for (;;) { + hal.watchdog_refresh(); + status = (bool) HAL_SD_Init(&hsd); + if (!status) break; + if (!--retry_Cnt) return false; // return failing status if retries are exhausted + } + go_to_transfer_speed(); + } + #endif + + return true; + } -bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) { - uint32_t timeout = HAL_GetTick() + SD_TIMEOUT; + /** + * @brief Read or Write a block + * @details Read or Write a block with SDIO + * + * @param block The block index + * @param src The data buffer source for a write + * @param dst The data buffer destination for a read + * + * @return true on success + */ + static bool SDIO_ReadWriteBlock_DMA(uint32_t block, const uint8_t *src, uint8_t *dst) { + if (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) return false; + + hal.watchdog_refresh(); + + HAL_StatusTypeDef ret; + if (src) { + hdma_sdio.Init.Direction = DMA_MEMORY_TO_PERIPH; + HAL_DMA_Init(&hdma_sdio); + ret = HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t*)src, block, 1); + } + else { + hdma_sdio.Init.Direction = DMA_PERIPH_TO_MEMORY; + HAL_DMA_Init(&hdma_sdio); + ret = HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t*)dst, block, 1); + } + + if (ret != HAL_OK) { + HAL_DMA_Abort_IT(&hdma_sdio); + HAL_DMA_DeInit(&hdma_sdio); + return false; + } + + millis_t timeout = millis() + SD_TIMEOUT; + // Wait the transfer + while (hsd.State != HAL_SD_STATE_READY) { + if (ELAPSED(millis(), timeout)) { + HAL_DMA_Abort_IT(&hdma_sdio); + HAL_DMA_DeInit(&hdma_sdio); + return false; + } + } - while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) { - if (HAL_GetTick() >= timeout) return false; + while (__HAL_DMA_GET_FLAG(&hdma_sdio, __HAL_DMA_GET_TC_FLAG_INDEX(&hdma_sdio)) != 0 + || __HAL_DMA_GET_FLAG(&hdma_sdio, __HAL_DMA_GET_TE_FLAG_INDEX(&hdma_sdio)) != 0) { /* nada */ } + + HAL_DMA_Abort_IT(&hdma_sdio); + HAL_DMA_DeInit(&hdma_sdio); + + timeout = millis() + SD_TIMEOUT; + while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) if (ELAPSED(millis(), timeout)) return false; + + return true; } - waitingRxCplt = 1; - if (HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t *)dst, block, 1) != HAL_OK) - return false; +#endif // !SDIO_FOR_STM32H7 - timeout = HAL_GetTick() + SD_TIMEOUT; - while (waitingRxCplt) - if (HAL_GetTick() >= timeout) return false; +/** + * @brief Read a block + * @details Read a block from media with SDIO + * + * @param block The block index + * @param src The block buffer + * + * @return true on success + */ +bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) { + #ifdef SDIO_FOR_STM32H7 + + uint32_t timeout = HAL_GetTick() + SD_TIMEOUT; + + while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) + if (HAL_GetTick() >= timeout) return false; + + waitingRxCplt = 1; + if (HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t*)dst, block, 1) != HAL_OK) + return false; + + timeout = HAL_GetTick() + SD_TIMEOUT; + while (waitingRxCplt) + if (HAL_GetTick() >= timeout) return false; - return true; + return true; + + #else + + uint8_t retries = SDIO_READ_RETRIES; + while (retries--) if (SDIO_ReadWriteBlock_DMA(block, nullptr, dst)) return true; + return false; + + #endif } +/** + * @brief Write a block + * @details Write a block to media with SDIO + * + * @param block The block index + * @param src The block data + * + * @return true on success + */ bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) { - uint32_t timeout = HAL_GetTick() + SD_TIMEOUT; + #ifdef SDIO_FOR_STM32H7 - while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) - if (HAL_GetTick() >= timeout) return false; + uint32_t timeout = HAL_GetTick() + SD_TIMEOUT; - waitingTxCplt = 1; - if (HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t *)src, block, 1) != HAL_OK) - return false; + while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) + if (HAL_GetTick() >= timeout) return false; + + waitingTxCplt = 1; + if (HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t*)src, block, 1) != HAL_OK) + return false; + + timeout = HAL_GetTick() + SD_TIMEOUT; + while (waitingTxCplt) + if (HAL_GetTick() >= timeout) return false; - timeout = HAL_GetTick() + SD_TIMEOUT; - while (waitingTxCplt) - if (HAL_GetTick() >= timeout) return false; + return true; - return true; + #else + + uint8_t retries = SDIO_READ_RETRIES; + while (retries--) { + if (SDIO_ReadWriteBlock_DMA(block, src, nullptr)) return true; + delay(10); + } + return false; + + #endif } bool SDIO_IsReady() { diff --git a/Marlin/src/HAL/STM32/tft/gt911.cpp b/Marlin/src/HAL/STM32/tft/gt911.cpp index 92e14edb2057..82b7c5b10391 100644 --- a/Marlin/src/HAL/STM32/tft/gt911.cpp +++ b/Marlin/src/HAL/STM32/tft/gt911.cpp @@ -150,33 +150,37 @@ void GT911::read_reg(uint16_t reg, uint8_t reg_len, uint8_t* r_data, uint8_t r_l sw_iic.start(); sw_iic.send_byte(gt911_slave_address + 1); // Set read mode - LOOP_L_N(i, r_len) { + LOOP_L_N(i, r_len) r_data[i] = sw_iic.read_byte(1); // Read data from reg - } + sw_iic.stop(); } void GT911::Init() { OUT_WRITE(GT911_RST_PIN, LOW); OUT_WRITE(GT911_INT_PIN, LOW); - delay(20); + delay(11); + WRITE(GT911_INT_PIN, HIGH); + delayMicroseconds(110); WRITE(GT911_RST_PIN, HIGH); + delay(6); + WRITE(GT911_INT_PIN, LOW); + delay(55); SET_INPUT(GT911_INT_PIN); sw_iic.init(); - uint8_t clear_reg = 0x0000; - write_reg(0x814E, 2, &clear_reg, 2); // Reset to 0 for start + uint8_t clear_reg = 0x00; + write_reg(0x814E, 2, &clear_reg, 1); // Reset to 0 for start } bool GT911::getFirstTouchPoint(int16_t *x, int16_t *y) { read_reg(0x814E, 2, ®.REG.status, 1); - if (reg.REG.status & 0x80) { + if (reg.REG.status >= 0x80 && reg.REG.status <= 0x85) { + read_reg(0x8150, 2, reg.map + 2, 38); uint8_t clear_reg = 0x00; write_reg(0x814E, 2, &clear_reg, 1); // Reset to 0 for start - read_reg(0x8150, 2, reg.map + 2, 8 * (reg.REG.status & 0x0F)); - // First touch point *x = ((reg.REG.point[0].xh & 0x0F) << 8) | reg.REG.point[0].xl; *y = ((reg.REG.point[0].yh & 0x0F) << 8) | reg.REG.point[0].yl; diff --git a/Marlin/src/HAL/STM32/tft/gt911.h b/Marlin/src/HAL/STM32/tft/gt911.h index 752a554d98ed..260c195eca63 100644 --- a/Marlin/src/HAL/STM32/tft/gt911.h +++ b/Marlin/src/HAL/STM32/tft/gt911.h @@ -23,7 +23,7 @@ #include "../../../inc/MarlinConfig.h" -#define GT911_SLAVE_ADDRESS 0xBA +#define GT911_SLAVE_ADDRESS 0x28 #if !PIN_EXISTS(GT911_RST) #error "GT911_RST_PIN is not defined." @@ -39,42 +39,18 @@ class SW_IIC { private: uint16_t scl_pin; uint16_t sda_pin; - void write_scl(bool level) - { - WRITE(scl_pin, level); - } - void write_sda(bool level) - { - WRITE(sda_pin, level); - } - bool read_sda() - { - return READ(sda_pin); - } - void set_sda_out() - { - SET_OUTPUT(sda_pin); - } - void set_sda_in() - { - SET_INPUT_PULLUP(sda_pin); - } - static void iic_delay(uint8_t t) - { - delayMicroseconds(t); - } + void write_scl(bool level) { WRITE(scl_pin, level); } + void write_sda(bool level) { WRITE(sda_pin, level); } + bool read_sda() { return READ(sda_pin); } + void set_sda_out() { SET_OUTPUT(sda_pin); } + void set_sda_in() { SET_INPUT_PULLUP(sda_pin); } + static void iic_delay(uint8_t t) { delayMicroseconds(t); } public: SW_IIC(uint16_t sda, uint16_t scl); // setSCL/SDA have to be called before begin() - void setSCL(uint16_t scl) - { - scl_pin = scl; - }; - void setSDA(uint16_t sda) - { - sda_pin = sda; - }; + void setSCL(uint16_t scl) { scl_pin = scl; } + void setSDA(uint16_t sda) { sda_pin = sda; } void init(); // Initialize the IO port of IIC void start(); // Send IIC start signal void stop(); // Send IIC stop signal diff --git a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp index e68b3c126939..cf9e569336bc 100644 --- a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp @@ -147,21 +147,36 @@ uint32_t TFT_FSMC::ReadID(tft_data_t Reg) { } bool TFT_FSMC::isBusy() { - #if defined(STM32F1xx) - volatile bool dmaEnabled = (DMAtx.Instance->CCR & DMA_CCR_EN) != RESET; + #ifdef STM32F1xx + #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CCR & DMA_CCR_EN) + #define __IS_DMA_CONFIGURED(__HANDLE__) ((__HANDLE__)->Instance->CPAR != 0) #elif defined(STM32F4xx) - volatile bool dmaEnabled = DMAtx.Instance->CR & DMA_SxCR_EN; + #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CR & DMA_SxCR_EN) + #define __IS_DMA_CONFIGURED(__HANDLE__) ((__HANDLE__)->Instance->PAR != 0) #endif - if (dmaEnabled) { - if (__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TC_FLAG_INDEX(&DMAtx)) != 0 || __HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TE_FLAG_INDEX(&DMAtx)) != 0) - Abort(); - } - else - Abort(); - return dmaEnabled; + + if (!__IS_DMA_CONFIGURED(&DMAtx)) return false; + + // Check if DMA transfer error or transfer complete flags are set + if ((__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TE_FLAG_INDEX(&DMAtx)) == 0) && (__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TC_FLAG_INDEX(&DMAtx)) == 0)) return true; + + __DSB(); + Abort(); + return false; +} + +void TFT_FSMC::Abort() { + HAL_DMA_Abort(&DMAtx); // Abort DMA transfer if any + HAL_DMA_DeInit(&DMAtx); // Deconfigure DMA } void TFT_FSMC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { + DMAtx.Init.PeriphInc = MemoryIncrease; + HAL_DMA_Init(&DMAtx); + HAL_DMA_Start(&DMAtx, (uint32_t)Data, (uint32_t)&(LCD->RAM), Count); +} + +void TFT_FSMC::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { DMAtx.Init.PeriphInc = MemoryIncrease; HAL_DMA_Init(&DMAtx); DataTransferBegin(); diff --git a/Marlin/src/HAL/STM32/tft/tft_fsmc.h b/Marlin/src/HAL/STM32/tft/tft_fsmc.h index 2200abaa10e8..41ff8c9a83c8 100644 --- a/Marlin/src/HAL/STM32/tft/tft_fsmc.h +++ b/Marlin/src/HAL/STM32/tft/tft_fsmc.h @@ -41,6 +41,7 @@ #define DATASIZE_8BIT SPI_DATASIZE_8BIT #define DATASIZE_16BIT SPI_DATASIZE_16BIT #define TFT_IO_DRIVER TFT_FSMC +#define DMA_MAX_SIZE 0xFFFF #define TFT_DATASIZE TERN(TFT_INTERFACE_FSMC_8BIT, DATASIZE_8BIT, DATASIZE_16BIT) typedef TERN(TFT_INTERFACE_FSMC_8BIT, uint8_t, uint16_t) tft_data_t; @@ -59,13 +60,14 @@ class TFT_FSMC { static uint32_t ReadID(tft_data_t Reg); static void Transmit(tft_data_t Data) { LCD->RAM = Data; __DSB(); } + static void Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); public: static void Init(); static uint32_t GetID(); static bool isBusy(); - static void Abort() { __HAL_DMA_DISABLE(&DMAtx); } + static void Abort(); static void DataTransferBegin(uint16_t DataWidth = TFT_DATASIZE) {} static void DataTransferEnd() {}; @@ -73,13 +75,14 @@ class TFT_FSMC { static void WriteData(uint16_t Data) { Transmit(tft_data_t(Data)); } static void WriteReg(uint16_t Reg) { LCD->REG = tft_data_t(Reg); __DSB(); } - static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); } - static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); } + static void WriteSequence_DMA(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); } + static void WriteMultiple_DMA(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); } + + static void WriteSequence(uint16_t *Data, uint16_t Count) { Transmit(DMA_PINC_ENABLE, Data, Count); } static void WriteMultiple(uint16_t Color, uint32_t Count) { - static uint16_t Data; Data = Color; while (Count > 0) { - TransmitDMA(DMA_MINC_DISABLE, &Data, Count > 0xFFFF ? 0xFFFF : Count); - Count = Count > 0xFFFF ? Count - 0xFFFF : 0; + Transmit(DMA_MINC_DISABLE, &Color, Count > DMA_MAX_SIZE ? DMA_MAX_SIZE : Count); + Count = Count > DMA_MAX_SIZE ? Count - DMA_MAX_SIZE : 0; } } }; diff --git a/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp b/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp index 66cfd65995dd..2be900618f20 100644 --- a/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp @@ -356,7 +356,7 @@ void TFT_LTDC::WriteReg(uint16_t Reg) { reg = Reg; } -void TFT_LTDC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { +void TFT_LTDC::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { while (x_cur != x_min && Count) { Transmit(*Data); @@ -372,9 +372,9 @@ void TFT_LTDC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Cou if (MemoryIncrease == DMA_PINC_ENABLE) { DrawImage(x_min, y_cur, x_min + width, y_cur + height, Data); Data += width * height; - } else { - DrawRect(x_min, y_cur, x_min + width, y_cur + height, *Data); } + else + DrawRect(x_min, y_cur, x_min + width, y_cur + height, *Data); y_cur += height; } diff --git a/Marlin/src/HAL/STM32/tft/tft_ltdc.h b/Marlin/src/HAL/STM32/tft/tft_ltdc.h index 7b63d6929b31..8d83839bb3fa 100644 --- a/Marlin/src/HAL/STM32/tft/tft_ltdc.h +++ b/Marlin/src/HAL/STM32/tft/tft_ltdc.h @@ -32,6 +32,7 @@ #define DATASIZE_8BIT SPI_DATASIZE_8BIT #define DATASIZE_16BIT SPI_DATASIZE_16BIT #define TFT_IO_DRIVER TFT_LTDC +#define DMA_MAX_SIZE 0xFFFF #define TFT_DATASIZE DATASIZE_16BIT typedef uint16_t tft_data_t; @@ -49,7 +50,7 @@ class TFT_LTDC { static void DrawRect(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t color); static void DrawImage(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t *colors); static void Transmit(tft_data_t Data); - static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); + static void Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); public: static void Init(); @@ -63,13 +64,15 @@ class TFT_LTDC { static void WriteData(uint16_t Data); static void WriteReg(uint16_t Reg); - static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); } - static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); } + // Non-blocking DMA data transfer is not implemented for LTDC interface + inline static void WriteSequence_DMA(uint16_t *Data, uint16_t Count) { WriteSequence(Data, Count); } + inline static void WriteMultiple_DMA(uint16_t Color, uint16_t Count) { WriteMultiple(Color, Count); } + + static void WriteSequence(uint16_t *Data, uint16_t Count) { Transmit(DMA_PINC_ENABLE, Data, Count); } static void WriteMultiple(uint16_t Color, uint32_t Count) { - static uint16_t Data; Data = Color; while (Count > 0) { - TransmitDMA(DMA_MINC_DISABLE, &Data, Count > 0xFFFF ? 0xFFFF : Count); - Count = Count > 0xFFFF ? Count - 0xFFFF : 0; + Transmit(DMA_PINC_DISABLE, &Color, Count > DMA_MAX_SIZE ? DMA_MAX_SIZE : Count); + Count = Count > DMA_MAX_SIZE ? Count - DMA_MAX_SIZE : 0; } } }; diff --git a/Marlin/src/HAL/STM32/tft/tft_spi.cpp b/Marlin/src/HAL/STM32/tft/tft_spi.cpp index 2e18c8a64c06..5e79f156d27c 100644 --- a/Marlin/src/HAL/STM32/tft/tft_spi.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_spi.cpp @@ -160,16 +160,13 @@ uint32_t TFT_SPI::ReadID(uint16_t Reg) { for (i = 0; i < 4; i++) { #if TFT_MISO_PIN != TFT_MOSI_PIN - //if (hspi->Init.Direction == SPI_DIRECTION_2LINES) { - while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {} - SPIx.Instance->DR = 0; - //} + while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {} + SPIx.Instance->DR = 0; #endif while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_RXNE)) {} Data = (Data << 8) | SPIx.Instance->DR; } - __HAL_SPI_DISABLE(&SPIx); DataTransferEnd(); SPIx.Init.BaudRatePrescaler = BaudRatePrescaler; @@ -179,36 +176,44 @@ uint32_t TFT_SPI::ReadID(uint16_t Reg) { } bool TFT_SPI::isBusy() { - #if defined(STM32F1xx) - volatile bool dmaEnabled = (DMAtx.Instance->CCR & DMA_CCR_EN) != RESET; + #ifdef STM32F1xx + #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CCR & DMA_CCR_EN) + #define __IS_DMA_CONFIGURED(__HANDLE__) ((__HANDLE__)->Instance->CPAR != 0) #elif defined(STM32F4xx) - volatile bool dmaEnabled = DMAtx.Instance->CR & DMA_SxCR_EN; + #define __IS_DMA_ENABLED(__HANDLE__) ((__HANDLE__)->Instance->CR & DMA_SxCR_EN) + #define __IS_DMA_CONFIGURED(__HANDLE__) ((__HANDLE__)->Instance->PAR != 0) #endif - if (dmaEnabled) { - if (__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TC_FLAG_INDEX(&DMAtx)) != 0 || __HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TE_FLAG_INDEX(&DMAtx)) != 0) - Abort(); + + if (!__IS_DMA_CONFIGURED(&DMAtx)) return false; + + if (__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TE_FLAG_INDEX(&DMAtx))) { + // You should not be here - DMA transfer error flag is set + // Abort DMA transfer and release SPI } - else - Abort(); - return dmaEnabled; + else { + // Check if DMA transfer completed flag is set + if (__HAL_DMA_GET_FLAG(&DMAtx, __HAL_DMA_GET_TC_FLAG_INDEX(&DMAtx)) == 0) return true; + // Check if SPI transmit butter is empty and SPI is idle + if ((!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) || (__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY))) return true; + } + + Abort(); + return false; } void TFT_SPI::Abort() { - // Wait for any running spi - while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {} - while ( __HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY)) {} - // First, abort any running dma - HAL_DMA_Abort(&DMAtx); - // DeInit objects + HAL_DMA_Abort(&DMAtx); // Abort DMA transfer if any HAL_DMA_DeInit(&DMAtx); - HAL_SPI_DeInit(&SPIx); - // Deselect CS - DataTransferEnd(); + + CLEAR_BIT(SPIx.Instance->CR2, SPI_CR2_TXDMAEN); + + DataTransferEnd(); // Stop SPI and deselect CS } void TFT_SPI::Transmit(uint16_t Data) { - if (TFT_MISO_PIN == TFT_MOSI_PIN) + #if TFT_MISO_PIN == TFT_MOSI_PIN SPI_1LINE_TX(&SPIx); + #endif __HAL_SPI_ENABLE(&SPIx); @@ -217,14 +222,31 @@ void TFT_SPI::Transmit(uint16_t Data) { while (!__HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_TXE)) {} while ( __HAL_SPI_GET_FLAG(&SPIx, SPI_FLAG_BSY)) {} - if (TFT_MISO_PIN != TFT_MOSI_PIN) - __HAL_SPI_CLEAR_OVRFLAG(&SPIx); // Clear overrun flag in 2 Lines communication mode because received is not read + #if TFT_MISO_PIN != TFT_MOSI_PIN + __HAL_SPI_CLEAR_OVRFLAG(&SPIx); // Clear overrun flag in 2 Lines communication mode because received data is not read + #endif } void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { - // Wait last dma finish, to start another - while (isBusy()) { /* nada */ } + DMAtx.Init.MemInc = MemoryIncrease; + HAL_DMA_Init(&DMAtx); + #if TFT_MISO_PIN == TFT_MOSI_PIN + SPI_1LINE_TX(&SPIx); + #endif + + DataTransferBegin(); + + HAL_DMA_Start(&DMAtx, (uint32_t)Data, (uint32_t)&(SPIx.Instance->DR), Count); + __HAL_SPI_ENABLE(&SPIx); + + SET_BIT(SPIx.Instance->CR2, SPI_CR2_TXDMAEN); // Enable Tx DMA Request + + TERN_(TFT_SHARED_SPI, while (isBusy())); +} + + +void TFT_SPI::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { DMAtx.Init.MemInc = MemoryIncrease; HAL_DMA_Init(&DMAtx); @@ -243,7 +265,6 @@ void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Coun } #if ENABLED(USE_SPI_DMA_TC) - void TFT_SPI::TransmitDMA_IT(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { DMAtx.Init.MemInc = MemoryIncrease; @@ -262,8 +283,7 @@ void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Coun SET_BIT(SPIx.Instance->CR2, SPI_CR2_TXDMAEN); // Enable Tx DMA Request } - extern "C" void DMA2_Stream3_IRQHandler(void) { HAL_DMA_IRQHandler(&TFT_SPI::DMAtx); } - + extern "C" void DMA2_Stream3_IRQHandler(void) { TFT_SPI::DMA_IRQHandler(); } #endif #endif // HAS_SPI_TFT diff --git a/Marlin/src/HAL/STM32/tft/tft_spi.h b/Marlin/src/HAL/STM32/tft/tft_spi.h index de051e229459..6b8613e3f87f 100644 --- a/Marlin/src/HAL/STM32/tft/tft_spi.h +++ b/Marlin/src/HAL/STM32/tft/tft_spi.h @@ -39,46 +39,47 @@ #define DATASIZE_8BIT SPI_DATASIZE_8BIT #define DATASIZE_16BIT SPI_DATASIZE_16BIT #define TFT_IO_DRIVER TFT_SPI +#define DMA_MAX_SIZE 0xFFFF class TFT_SPI { private: static SPI_HandleTypeDef SPIx; - + static DMA_HandleTypeDef DMAtx; static uint32_t ReadID(uint16_t Reg); static void Transmit(uint16_t Data); + static void Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); #if ENABLED(USE_SPI_DMA_TC) static void TransmitDMA_IT(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); #endif public: - static DMA_HandleTypeDef DMAtx; - static void Init(); static uint32_t GetID(); static bool isBusy(); static void Abort(); static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT); - static void DataTransferEnd() { WRITE(TFT_CS_PIN, HIGH); }; + static void DataTransferEnd() { WRITE(TFT_CS_PIN, HIGH); __HAL_SPI_DISABLE(&SPIx); }; static void DataTransferAbort(); static void WriteData(uint16_t Data) { Transmit(Data); } static void WriteReg(uint16_t Reg) { WRITE(TFT_A0_PIN, LOW); Transmit(Reg); WRITE(TFT_A0_PIN, HIGH); } - static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); } + static void WriteSequence_DMA(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); } + static void WriteMultiple_DMA(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } #if ENABLED(USE_SPI_DMA_TC) static void WriteSequenceIT(uint16_t *Data, uint16_t Count) { TransmitDMA_IT(DMA_MINC_ENABLE, Data, Count); } + inline static void DMA_IRQHandler() { HAL_DMA_IRQHandler(&TFT_SPI::DMAtx); } #endif - static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } + static void WriteSequence(uint16_t *Data, uint16_t Count) { Transmit(DMA_MINC_ENABLE, Data, Count); } static void WriteMultiple(uint16_t Color, uint32_t Count) { - static uint16_t Data; Data = Color; while (Count > 0) { - TransmitDMA(DMA_MINC_DISABLE, &Data, Count > 0xFFFF ? 0xFFFF : Count); - Count = Count > 0xFFFF ? Count - 0xFFFF : 0; + Transmit(DMA_MINC_DISABLE, &Color, Count > DMA_MAX_SIZE ? DMA_MAX_SIZE : Count); + Count = Count > DMA_MAX_SIZE ? Count - DMA_MAX_SIZE : 0; } } }; diff --git a/Marlin/src/HAL/STM32/usb_host.cpp b/Marlin/src/HAL/STM32/usb_host.cpp index d77f0b28e964..f3784670049c 100644 --- a/Marlin/src/HAL/STM32/usb_host.cpp +++ b/Marlin/src/HAL/STM32/usb_host.cpp @@ -44,7 +44,7 @@ static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id) { break; case HOST_USER_DISCONNECTION: //SERIAL_ECHOLNPGM("APPLICATION_DISCONNECT"); - //usb.setUsbTaskState(USB_STATE_RUNNING); + usb.setUsbTaskState(USB_STATE_INIT); break; case HOST_USER_CLASS_ACTIVE: //SERIAL_ECHOLNPGM("APPLICATION_READY"); diff --git a/Marlin/src/HAL/STM32F1/SPI.cpp b/Marlin/src/HAL/STM32F1/SPI.cpp index 1ce2c7d3fd5d..a180684757ee 100644 --- a/Marlin/src/HAL/STM32F1/SPI.cpp +++ b/Marlin/src/HAL/STM32F1/SPI.cpp @@ -526,23 +526,22 @@ void SPIClass::onReceive(void(*callback)()) { _currentSetting->receiveCallback = callback; if (callback) { switch (_currentSetting->spi_d->clk_id) { - #if BOARD_NR_SPI >= 1 - case RCC_SPI1: - dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiRxDmaChannel, &SPIClass::_spi1EventCallback); - break; - #endif - #if BOARD_NR_SPI >= 2 - case RCC_SPI2: - dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiRxDmaChannel, &SPIClass::_spi2EventCallback); - break; - #endif - #if BOARD_NR_SPI >= 3 - case RCC_SPI3: - dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiRxDmaChannel, &SPIClass::_spi3EventCallback); - break; - #endif - default: - ASSERT(0); + #if BOARD_NR_SPI >= 1 + case RCC_SPI1: + dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiRxDmaChannel, &SPIClass::_spi1EventCallback); + break; + #endif + #if BOARD_NR_SPI >= 2 + case RCC_SPI2: + dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiRxDmaChannel, &SPIClass::_spi2EventCallback); + break; + #endif + #if BOARD_NR_SPI >= 3 + case RCC_SPI3: + dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiRxDmaChannel, &SPIClass::_spi3EventCallback); + break; + #endif + default: ASSERT(0); } } else { @@ -554,23 +553,22 @@ void SPIClass::onTransmit(void(*callback)()) { _currentSetting->transmitCallback = callback; if (callback) { switch (_currentSetting->spi_d->clk_id) { - #if BOARD_NR_SPI >= 1 - case RCC_SPI1: - dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, &SPIClass::_spi1EventCallback); - break; - #endif - #if BOARD_NR_SPI >= 2 - case RCC_SPI2: - dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, &SPIClass::_spi2EventCallback); - break; - #endif - #if BOARD_NR_SPI >= 3 - case RCC_SPI3: - dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, &SPIClass::_spi3EventCallback); - break; - #endif - default: - ASSERT(0); + #if BOARD_NR_SPI >= 1 + case RCC_SPI1: + dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, &SPIClass::_spi1EventCallback); + break; + #endif + #if BOARD_NR_SPI >= 2 + case RCC_SPI2: + dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, &SPIClass::_spi2EventCallback); + break; + #endif + #if BOARD_NR_SPI >= 3 + case RCC_SPI3: + dma_attach_interrupt(_currentSetting->spiDmaDev, _currentSetting->spiTxDmaChannel, &SPIClass::_spi3EventCallback); + break; + #endif + default: ASSERT(0); } } else { diff --git a/Marlin/src/HAL/STM32F1/SPI.h b/Marlin/src/HAL/STM32F1/SPI.h index 13f4d5ed6cfe..0941fa55b781 100644 --- a/Marlin/src/HAL/STM32F1/SPI.h +++ b/Marlin/src/HAL/STM32F1/SPI.h @@ -33,6 +33,15 @@ #include #include +// Number of SPI ports +#ifdef BOARD_SPI3_SCK_PIN + #define BOARD_NR_SPI 3 +#elif defined(BOARD_SPI2_SCK_PIN) + #define BOARD_NR_SPI 2 +#elif defined(BOARD_SPI1_SCK_PIN) + #define BOARD_NR_SPI 1 +#endif + // SPI_HAS_TRANSACTION means SPI has // - beginTransaction() // - endTransaction() diff --git a/Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp b/Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp index d608ccee1441..9cfa97c1ab6e 100644 --- a/Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/STM32F1/eeprom_sdcard.cpp @@ -47,7 +47,7 @@ static char _ALIGN(4) HAL_eeprom_data[MARLIN_EEPROM_SIZE]; bool PersistentStore::access_start() { if (!card.isMounted()) return false; - SdFile file, root = card.getroot(); + MediaFile file, root = card.getroot(); if (!file.open(&root, EEPROM_FILENAME, O_RDONLY)) return true; // false aborts the save @@ -62,7 +62,7 @@ bool PersistentStore::access_start() { bool PersistentStore::access_finish() { if (!card.isMounted()) return false; - SdFile file, root = card.getroot(); + MediaFile file, root = card.getroot(); int bytes_written = 0; if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) { bytes_written = file.write(HAL_eeprom_data, MARLIN_EEPROM_SIZE); diff --git a/Marlin/src/HAL/STM32F1/fast_pwm.cpp b/Marlin/src/HAL/STM32F1/fast_pwm.cpp index 297804a3ac42..c3f96f0f925f 100644 --- a/Marlin/src/HAL/STM32F1/fast_pwm.cpp +++ b/Marlin/src/HAL/STM32F1/fast_pwm.cpp @@ -39,7 +39,7 @@ inline uint8_t timer_and_index_for_pin(const pin_t pin, timer_dev **timer_ptr) { void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { const uint16_t duty = invert ? v_size - v : v; if (PWM_PIN(pin)) { - timer_dev *timer; UNUSED(timer); + timer_dev *timer; if (timer_freq[timer_and_index_for_pin(pin, &timer)] == 0) set_pwm_frequency(pin, PWM_FREQUENCY); const uint8_t channel = PIN_MAP[pin].timer_channel; @@ -55,7 +55,7 @@ void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer - timer_dev *timer; UNUSED(timer); + timer_dev *timer; timer_freq[timer_and_index_for_pin(pin, &timer)] = f_desired; // Protect used timers diff --git a/Marlin/src/HAL/STM32F1/onboard_sd.h b/Marlin/src/HAL/STM32F1/onboard_sd.h index f228d068c9db..f8846e95bcaa 100644 --- a/Marlin/src/HAL/STM32F1/onboard_sd.h +++ b/Marlin/src/HAL/STM32F1/onboard_sd.h @@ -1,11 +1,31 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 + /*----------------------------------------------------------------------- -/ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] / * Copyright (c) 2019 BigTreeTech [https://github.com/bigtreetech] -/ * Low level disk interface module include file (C)ChaN, 2015 +/ * Low level disk interface module include file (c) ChaN, 2015 /-----------------------------------------------------------------------*/ -#pragma once - #define _DISKIO_WRITE 1 /* 1: Enable disk_write function */ #define _DISKIO_IOCTL 1 /* 1: Enable disk_ioctl function */ #define _DISKIO_ISDIO 0 /* 1: Enable iSDIO control function */ diff --git a/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp b/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp index 5b52fb416fa3..512e70cf3f70 100644 --- a/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp +++ b/Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp @@ -215,22 +215,47 @@ uint32_t TFT_FSMC::GetID() { } bool TFT_FSMC::isBusy() { + #define __IS_DMA_CONFIGURED(__DMAx__, __CHx__) (dma_channel_regs(__DMAx__, __CHx__)->CPAR != 0) + + if (!__IS_DMA_CONFIGURED(FSMC_DMA_DEV, FSMC_DMA_CHANNEL)) return false; + + // Check if DMA transfer error or transfer complete flags are set + if ((dma_get_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL) & (DMA_ISR_TCIF | DMA_ISR_TEIF)) == 0) return true; + + __DSB(); + Abort(); return false; } void TFT_FSMC::Abort() { + dma_channel_reg_map *channel_regs = dma_channel_regs(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); + dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); // Abort DMA transfer if any + + // Deconfigure DMA + channel_regs->CCR = 0U; + channel_regs->CNDTR = 0U; + channel_regs->CMAR = 0U; + channel_regs->CPAR = 0U; } void TFT_FSMC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { + // TODO: HAL STM32 uses DMA2_Channel1 for FSMC on STM32F1 + dma_setup_transfer(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, Data, DMA_SIZE_16BITS, &LCD->RAM, DMA_SIZE_16BITS, DMA_MEM_2_MEM | MemoryIncrease); + dma_set_num_transfers(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, Count); + dma_clear_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); + dma_enable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); +} + +void TFT_FSMC::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { #if defined(FSMC_DMA_DEV) && defined(FSMC_DMA_CHANNEL) dma_setup_transfer(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, Data, DMA_SIZE_16BITS, &LCD->RAM, DMA_SIZE_16BITS, DMA_MEM_2_MEM | MemoryIncrease); dma_set_num_transfers(FSMC_DMA_DEV, FSMC_DMA_CHANNEL, Count); dma_clear_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); dma_enable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); - while ((dma_get_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL) & 0x0A) == 0) {}; - dma_disable(FSMC_DMA_DEV, FSMC_DMA_CHANNEL); + while ((dma_get_isr_bits(FSMC_DMA_DEV, FSMC_DMA_CHANNEL) & (DMA_CCR_TEIE | DMA_CCR_TCIE)) == 0) {} + Abort(); #endif } diff --git a/Marlin/src/HAL/STM32F1/tft/tft_fsmc.h b/Marlin/src/HAL/STM32F1/tft/tft_fsmc.h index d9ee1f4c7767..8d26f6eac0b7 100644 --- a/Marlin/src/HAL/STM32F1/tft/tft_fsmc.h +++ b/Marlin/src/HAL/STM32F1/tft/tft_fsmc.h @@ -33,6 +33,10 @@ #define DATASIZE_8BIT DMA_SIZE_8BITS #define DATASIZE_16BIT DMA_SIZE_16BITS #define TFT_IO_DRIVER TFT_FSMC +#define DMA_MAX_SIZE 0xFFFF + +#define DMA_PINC_ENABLE DMA_PINC_MODE +#define DMA_PINC_DISABLE 0 typedef struct { __IO uint16_t REG; @@ -45,6 +49,7 @@ class TFT_FSMC { static uint32_t ReadID(uint16_t Reg); static void Transmit(uint16_t Data); + static void Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); public: @@ -59,13 +64,14 @@ class TFT_FSMC { static void WriteData(uint16_t Data) { Transmit(Data); } static void WriteReg(uint16_t Reg); - static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_MODE, Data, Count); } - static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_CIRC_MODE, &Data, Count); } + static void WriteSequence_DMA(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_PINC_ENABLE, Data, Count); } + static void WriteMultiple_DMA(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_PINC_DISABLE, &Data, Count); } + + static void WriteSequence(uint16_t *Data, uint16_t Count) { Transmit(DMA_PINC_ENABLE, Data, Count); } static void WriteMultiple(uint16_t Color, uint32_t Count) { - static uint16_t Data; Data = Color; while (Count > 0) { - TransmitDMA(DMA_CIRC_MODE, &Data, Count > 0xFFFF ? 0xFFFF : Count); - Count = Count > 0xFFFF ? Count - 0xFFFF : 0; + Transmit(DMA_PINC_DISABLE, &Color, Count > DMA_MAX_SIZE ? DMA_MAX_SIZE : Count); + Count = Count > DMA_MAX_SIZE ? Count - DMA_MAX_SIZE : 0; } } }; diff --git a/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp b/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp index f447cec81107..bb495d5f58b5 100644 --- a/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp +++ b/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp @@ -26,7 +26,7 @@ #include "tft_spi.h" -SPIClass TFT_SPI::SPIx(1); +SPIClass TFT_SPI::SPIx(TFT_SPI_DEVICE); void TFT_SPI::Init() { #if PIN_EXISTS(TFT_RESET) @@ -46,7 +46,7 @@ void TFT_SPI::Init() { * STM32F1 has 3 SPI ports, SPI1 in APB2, SPI2/SPI3 in APB1 * so the minimum prescale of SPI1 is DIV4, SPI2/SPI3 is DIV2 */ - #if SPI_DEVICE == 1 + #if TFT_SPI_DEVICE == 1 #define SPI_CLOCK_MAX SPI_CLOCK_DIV4 #else #define SPI_CLOCK_MAX SPI_CLOCK_DIV2 @@ -62,7 +62,7 @@ void TFT_SPI::Init() { case SPI_SPEED_6: clock = SPI_CLOCK_DIV64; break; default: clock = SPI_CLOCK_DIV2; // Default from the SPI library } - SPIx.setModule(1); + SPIx.setModule(TFT_SPI_DEVICE); SPIx.setClockDivider(clock); SPIx.setBitOrder(MSBFIRST); SPIx.setDataMode(SPI_MODE0); @@ -71,7 +71,7 @@ void TFT_SPI::Init() { void TFT_SPI::DataTransferBegin(uint16_t DataSize) { SPIx.setDataSize(DataSize); SPIx.begin(); - OUT_WRITE(TFT_CS_PIN, LOW); + WRITE(TFT_CS_PIN, LOW); } #ifdef TFT_DEFAULT_DRIVER @@ -113,15 +113,53 @@ uint32_t TFT_SPI::ReadID(uint16_t Reg) { #endif } -bool TFT_SPI::isBusy() { return false; } +bool TFT_SPI::isBusy() { + #define __IS_DMA_CONFIGURED(__DMAx__, __CHx__) (dma_channel_regs(__DMAx__, __CHx__)->CPAR != 0) -void TFT_SPI::Abort() { DataTransferEnd(); } + if (!__IS_DMA_CONFIGURED(DMAx, DMA_CHx)) return false; + + if (dma_get_isr_bits(DMAx, DMA_CHx) & DMA_ISR_TEIF) { + // You should not be here - DMA transfer error flag is set + // Abort DMA transfer and release SPI + } + else { + // Check if DMA transfer completed flag is set + if (!(dma_get_isr_bits(DMAx, DMA_CHx) & DMA_ISR_TCIF)) return true; + // Check if SPI TX butter is empty and SPI is idle + if (!(SPIdev->regs->SR & SPI_SR_TXE) || (SPIdev->regs->SR & SPI_SR_BSY)) return true; + } + + Abort(); + return false; +} + +void TFT_SPI::Abort() { + dma_channel_reg_map *channel_regs = dma_channel_regs(DMAx, DMA_CHx); + + dma_disable(DMAx, DMA_CHx); // Abort DMA transfer if any + spi_tx_dma_disable(SPIdev); + + // Deconfigure DMA + channel_regs->CCR = 0U; + channel_regs->CNDTR = 0U; + channel_regs->CMAR = 0U; + channel_regs->CPAR = 0U; + + DataTransferEnd(); +} void TFT_SPI::Transmit(uint16_t Data) { SPIx.send(Data); } void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { DataTransferBegin(); - OUT_WRITE(TFT_DC_PIN, HIGH); + SPIx.dmaSendAsync(Data, Count, MemoryIncrease == DMA_MINC_ENABLE); + + TERN_(TFT_SHARED_SPI, while (isBusy())); +} + +void TFT_SPI::Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { + WRITE(TFT_DC_PIN, HIGH); + DataTransferBegin(); SPIx.dmaSend(Data, Count, MemoryIncrease == DMA_MINC_ENABLE); DataTransferEnd(); } diff --git a/Marlin/src/HAL/STM32F1/tft/tft_spi.h b/Marlin/src/HAL/STM32F1/tft/tft_spi.h index da9a8e0c223e..2bda8c21f724 100644 --- a/Marlin/src/HAL/STM32F1/tft/tft_spi.h +++ b/Marlin/src/HAL/STM32F1/tft/tft_spi.h @@ -25,6 +25,27 @@ #include +#define IS_SPI(N) (BOARD_NR_SPI >= N && (TFT_SCK_PIN == BOARD_SPI##N##_SCK_PIN) && (TFT_MOSI_PIN == BOARD_SPI##N##_MOSI_PIN) && (TFT_MISO_PIN == BOARD_SPI##N##_MISO_PIN)) +#if IS_SPI(1) + #define TFT_SPI_DEVICE 1 + #define SPIdev SPI1 + #define DMAx DMA1 + #define DMA_CHx DMA_CH3 +#elif IS_SPI(2) + #define TFT_SPI_DEVICE 2 + #define SPIdev SPI2 + #define DMAx DMA1 + #define DMA_CHx DMA_CH5 +#elif IS_SPI(3) + #define TFT_SPI_DEVICE 3 + #define SPIdev SPI3 + #define DMAx DMA2 + #define DMA_CHx DMA_CH2 +#else + #error "Invalid TFT SPI configuration." +#endif +#undef IS_SPI + #ifndef LCD_READ_ID #define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341) #endif @@ -32,17 +53,19 @@ #define LCD_READ_ID4 0xD3 // Read display identification information (0xD3 on ILI9341) #endif -#define DATASIZE_8BIT DATA_SIZE_8BIT -#define DATASIZE_16BIT DATA_SIZE_16BIT -#define TFT_IO_DRIVER TFT_SPI +#define DATASIZE_8BIT DATA_SIZE_8BIT +#define DATASIZE_16BIT DATA_SIZE_16BIT +#define TFT_IO_DRIVER TFT_SPI +#define DMA_MAX_SIZE 0xFFFF -#define DMA_MINC_ENABLE 1 -#define DMA_MINC_DISABLE 0 +#define DMA_MINC_ENABLE DMA_MINC_MODE +#define DMA_MINC_DISABLE 0 class TFT_SPI { private: static uint32_t ReadID(uint16_t Reg); static void Transmit(uint16_t Data); + static void Transmit(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count); public: @@ -58,15 +81,16 @@ class TFT_SPI { static void DataTransferAbort(); static void WriteData(uint16_t Data) { Transmit(Data); } - static void WriteReg(uint16_t Reg) { WRITE(TFT_A0_PIN, LOW); Transmit(Reg); WRITE(TFT_A0_PIN, HIGH); } + static void WriteReg(uint16_t Reg) { WRITE(TFT_DC_PIN, LOW); Transmit(Reg); WRITE(TFT_DC_PIN, HIGH); } + + static void WriteSequence_DMA(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); } + static void WriteMultiple_DMA(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } - static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); } - static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } + static void WriteSequence(uint16_t *Data, uint16_t Count) { Transmit(DMA_MINC_ENABLE, Data, Count); } static void WriteMultiple(uint16_t Color, uint32_t Count) { - static uint16_t Data; Data = Color; while (Count > 0) { - TransmitDMA(DMA_MINC_DISABLE, &Data, Count > 0xFFFF ? 0xFFFF : Count); - Count = Count > 0xFFFF ? Count - 0xFFFF : 0; + Transmit(DMA_MINC_DISABLE, &Color, Count > DMA_MAX_SIZE ? DMA_MAX_SIZE : Count); + Count = Count > DMA_MAX_SIZE ? Count - DMA_MAX_SIZE : 0; } } }; diff --git a/Marlin/src/HAL/TEENSY31_32/inc/Conditionals_LCD.h b/Marlin/src/HAL/TEENSY31_32/inc/Conditionals_LCD.h index 54ec16664354..5f1c4b16019d 100644 --- a/Marlin/src/HAL/TEENSY31_32/inc/Conditionals_LCD.h +++ b/Marlin/src/HAL/TEENSY31_32/inc/Conditionals_LCD.h @@ -20,7 +20,3 @@ * */ #pragma once - -#if HAS_SPI_TFT || HAS_FSMC_TFT - #error "Sorry! TFT displays are not available for HAL/TEENSY31_32." -#endif diff --git a/Marlin/src/HAL/TEENSY31_32/inc/SanityCheck.h b/Marlin/src/HAL/TEENSY31_32/inc/SanityCheck.h index dbce187673c9..c5b25f2cb51b 100644 --- a/Marlin/src/HAL/TEENSY31_32/inc/SanityCheck.h +++ b/Marlin/src/HAL/TEENSY31_32/inc/SanityCheck.h @@ -25,22 +25,26 @@ * Test TEENSY35_36 specific configuration values for errors at compile-time. */ +#if HAS_SPI_TFT || HAS_FSMC_TFT + #error "Sorry! TFT displays are not available for Teensy 3.1/3.2." +#endif + #if ENABLED(EMERGENCY_PARSER) #error "EMERGENCY_PARSER is not yet implemented for Teensy 3.1/3.2. Disable EMERGENCY_PARSER to continue." #endif #if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY - #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on Teensy 3.1/3.2." + #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported for Teensy 3.1/3.2." #endif #if HAS_TMC_SW_SERIAL - #error "TMC220x Software Serial is not supported on Teensy 3.1/3.2." + #error "TMC220x Software Serial is not supported for Teensy 3.1/3.2." #endif #if ENABLED(POSTMORTEM_DEBUGGING) - #error "POSTMORTEM_DEBUGGING is not yet supported on Teensy 3.1/3.2." + #error "POSTMORTEM_DEBUGGING is not yet supported for Teensy 3.1/3.2." #endif #if USING_PULLDOWNS - #error "PULLDOWN pin mode is not available on Teensy 3.1/3.2 boards." + #error "PULLDOWN pin mode is not available for Teensy 3.1/3.2." #endif diff --git a/Marlin/src/HAL/TEENSY35_36/inc/Conditionals_LCD.h b/Marlin/src/HAL/TEENSY35_36/inc/Conditionals_LCD.h index 632ee533acac..5f1c4b16019d 100644 --- a/Marlin/src/HAL/TEENSY35_36/inc/Conditionals_LCD.h +++ b/Marlin/src/HAL/TEENSY35_36/inc/Conditionals_LCD.h @@ -20,7 +20,3 @@ * */ #pragma once - -#if HAS_SPI_TFT || HAS_FSMC_TFT - #error "Sorry! TFT displays are not available for HAL/TEENSY35_36." -#endif diff --git a/Marlin/src/HAL/TEENSY35_36/inc/SanityCheck.h b/Marlin/src/HAL/TEENSY35_36/inc/SanityCheck.h index 330870737184..843905a8510a 100644 --- a/Marlin/src/HAL/TEENSY35_36/inc/SanityCheck.h +++ b/Marlin/src/HAL/TEENSY35_36/inc/SanityCheck.h @@ -25,22 +25,26 @@ * Test TEENSY35_36 specific configuration values for errors at compile-time. */ +#if HAS_SPI_TFT || HAS_FSMC_TFT + #error "Sorry! TFT displays are not available for Teensy 3.5/3.6." +#endif + #if ENABLED(EMERGENCY_PARSER) #error "EMERGENCY_PARSER is not yet implemented for Teensy 3.5/3.6. Disable EMERGENCY_PARSER to continue." #endif #if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY - #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on Teensy 3.5/3.6." + #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported for Teensy 3.5/3.6." #endif #if HAS_TMC_SW_SERIAL - #error "TMC220x Software Serial is not supported on Teensy 3.5/3.6." + #error "TMC220x Software Serial is not supported for Teensy 3.5/3.6." #endif #if ENABLED(POSTMORTEM_DEBUGGING) - #error "POSTMORTEM_DEBUGGING is not yet supported on Teensy 3.5/3.6." + #error "POSTMORTEM_DEBUGGING is not yet supported for Teensy 3.5/3.6." #endif #if USING_PULLDOWNS - #error "PULLDOWN pin mode is not available on Teensy 3.5/3.6 boards." + #error "PULLDOWN pin mode is not available for Teensy 3.5/3.6." #endif diff --git a/Marlin/src/HAL/TEENSY40_41/inc/Conditionals_LCD.h b/Marlin/src/HAL/TEENSY40_41/inc/Conditionals_LCD.h index 6a8540927b97..5f1c4b16019d 100644 --- a/Marlin/src/HAL/TEENSY40_41/inc/Conditionals_LCD.h +++ b/Marlin/src/HAL/TEENSY40_41/inc/Conditionals_LCD.h @@ -20,7 +20,3 @@ * */ #pragma once - -#if HAS_SPI_TFT || HAS_FSMC_TFT - #error "Sorry! TFT displays are not available for HAL/TEENSY40_41." -#endif diff --git a/Marlin/src/HAL/TEENSY40_41/inc/SanityCheck.h b/Marlin/src/HAL/TEENSY40_41/inc/SanityCheck.h index 3d2668d749bc..731658b4a31c 100644 --- a/Marlin/src/HAL/TEENSY40_41/inc/SanityCheck.h +++ b/Marlin/src/HAL/TEENSY40_41/inc/SanityCheck.h @@ -25,18 +25,22 @@ * Test TEENSY41 specific configuration values for errors at compile-time. */ +#if HAS_SPI_TFT || HAS_FSMC_TFT + #error "Sorry! TFT displays are not available for Teensy 4.0/4.1." +#endif + #if ENABLED(EMERGENCY_PARSER) #error "EMERGENCY_PARSER is not yet implemented for Teensy 4.0/4.1. Disable EMERGENCY_PARSER to continue." #endif #if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY - #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on Teensy 4.0/4.1." + #error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported for Teensy 4.0/4.1." #endif #if HAS_TMC_SW_SERIAL - #error "TMC220x Software Serial is not supported on Teensy 4.0/4.1." + #error "TMC220x Software Serial is not supported for Teensy 4.0/4.1." #endif #if ENABLED(POSTMORTEM_DEBUGGING) - #error "POSTMORTEM_DEBUGGING is not yet supported on Teensy 4.0/4.1." + #error "POSTMORTEM_DEBUGGING is not yet supported for Teensy 4.0/4.1." #endif 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/HAL/platforms.h b/Marlin/src/HAL/platforms.h index 28fe28e1094f..84ba7087b0ea 100644 --- a/Marlin/src/HAL/platforms.h +++ b/Marlin/src/HAL/platforms.h @@ -24,32 +24,34 @@ #define XSTR(V...) #V #ifdef __AVR__ - #define HAL_PATH(PATH, NAME) XSTR(PATH/AVR/NAME) + #define HAL_PATH(PATH, NAME) XSTR(PATH/HAL/AVR/NAME) #elif defined(ARDUINO_ARCH_SAM) - #define HAL_PATH(PATH, NAME) XSTR(PATH/DUE/NAME) + #define HAL_PATH(PATH, NAME) XSTR(PATH/HAL/DUE/NAME) #elif defined(__MK20DX256__) - #define HAL_PATH(PATH, NAME) XSTR(PATH/TEENSY31_32/NAME) + #define HAL_PATH(PATH, NAME) XSTR(PATH/HAL/TEENSY31_32/NAME) #elif defined(__MK64FX512__) || defined(__MK66FX1M0__) - #define HAL_PATH(PATH, NAME) XSTR(PATH/TEENSY35_36/NAME) + #define HAL_PATH(PATH, NAME) XSTR(PATH/HAL/TEENSY35_36/NAME) #elif defined(__IMXRT1062__) - #define HAL_PATH(PATH, NAME) XSTR(PATH/TEENSY40_41/NAME) + #define HAL_PATH(PATH, NAME) XSTR(PATH/HAL/TEENSY40_41/NAME) #elif defined(TARGET_LPC1768) - #define HAL_PATH(PATH, NAME) XSTR(PATH/LPC1768/NAME) + #define HAL_PATH(PATH, NAME) XSTR(PATH/HAL/LPC1768/NAME) #elif defined(__STM32F1__) || defined(TARGET_STM32F1) - #define HAL_PATH(PATH, NAME) XSTR(PATH/STM32F1/NAME) + #define HAL_PATH(PATH, NAME) XSTR(PATH/HAL/STM32F1/NAME) #elif defined(ARDUINO_ARCH_STM32) #ifndef HAL_STM32 #define HAL_STM32 #endif - #define HAL_PATH(PATH, NAME) XSTR(PATH/STM32/NAME) + #define HAL_PATH(PATH, NAME) XSTR(PATH/HAL/STM32/NAME) #elif defined(ARDUINO_ARCH_ESP32) - #define HAL_PATH(PATH, NAME) XSTR(PATH/ESP32/NAME) + #define HAL_PATH(PATH, NAME) XSTR(PATH/HAL/ESP32/NAME) #elif defined(__PLAT_LINUX__) - #define HAL_PATH(PATH, NAME) XSTR(PATH/LINUX/NAME) + #define HAL_PATH(PATH, NAME) XSTR(PATH/HAL/LINUX/NAME) #elif defined(__PLAT_NATIVE_SIM__) - #define HAL_PATH(PATH, NAME) XSTR(PATH/NATIVE_SIM/NAME) + #define HAL_PATH(PATH, NAME) XSTR(PATH/HAL/NATIVE_SIM/NAME) #elif defined(__SAMD51__) - #define HAL_PATH(PATH, NAME) XSTR(PATH/SAMD51/NAME) + #define HAL_PATH(PATH, NAME) XSTR(PATH/HAL/SAMD51/NAME) +#elif defined(__SAMD21__) + #define HAL_PATH(PATH, NAME) XSTR(PATH/HAL/SAMD21/NAME) #else #error "Unsupported Platform!" #endif diff --git a/Marlin/src/HAL/shared/HAL_spi_L6470.cpp b/Marlin/src/HAL/shared/HAL_spi_L6470.cpp deleted file mode 100644 index 5d4ce89b2748..000000000000 --- a/Marlin/src/HAL/shared/HAL_spi_L6470.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 . - * - */ - -/** - * Software L6470 SPI functions originally from Arduino Sd2Card Library - * Copyright (c) 2009 by William Greiman - */ - -#include "../../inc/MarlinConfig.h" - -#if HAS_L64XX - -#include "Delay.h" - -#include "../../core/serial.h" -#include "../../libs/L64XX/L64XX_Marlin.h" - -// Make sure GCC optimizes this file. -// Note that this line triggers a bug in GCC which is fixed by casting. -// See the note below. -#pragma GCC optimize (3) - -// run at ~4Mhz -inline uint8_t L6470_SpiTransfer_Mode_0(uint8_t b) { // using Mode 0 - for (uint8_t bits = 8; bits--;) { - WRITE(L6470_CHAIN_MOSI_PIN, b & 0x80); - b <<= 1; // little setup time - - WRITE(L6470_CHAIN_SCK_PIN, HIGH); - DELAY_NS(125); // 10 cycles @ 84mhz - - b |= (READ(L6470_CHAIN_MISO_PIN) != 0); - - WRITE(L6470_CHAIN_SCK_PIN, LOW); - DELAY_NS(125); // 10 cycles @ 84mhz - } - return b; -} - -inline uint8_t L6470_SpiTransfer_Mode_3(uint8_t b) { // using Mode 3 - for (uint8_t bits = 8; bits--;) { - WRITE(L6470_CHAIN_SCK_PIN, LOW); - WRITE(L6470_CHAIN_MOSI_PIN, b & 0x80); - - DELAY_NS(125); // 10 cycles @ 84mhz - WRITE(L6470_CHAIN_SCK_PIN, HIGH); - DELAY_NS(125); // Need more delay for fast CPUs - - b <<= 1; // little setup time - b |= (READ(L6470_CHAIN_MISO_PIN) != 0); - } - DELAY_NS(125); // 10 cycles @ 84mhz - return b; -} - -/** - * L64XX methods for SPI init and transfer - */ -void L64XX_Marlin::spi_init() { - OUT_WRITE(L6470_CHAIN_SS_PIN, HIGH); - OUT_WRITE(L6470_CHAIN_SCK_PIN, HIGH); - OUT_WRITE(L6470_CHAIN_MOSI_PIN, HIGH); - SET_INPUT(L6470_CHAIN_MISO_PIN); - - #if PIN_EXISTS(L6470_BUSY) - SET_INPUT(L6470_BUSY_PIN); - #endif - - OUT_WRITE(L6470_CHAIN_MOSI_PIN, HIGH); -} - -uint8_t L64XX_Marlin::transfer_single(uint8_t data, int16_t ss_pin) { - // First device in chain has data sent last - extDigitalWrite(ss_pin, LOW); - - hal.isr_off(); // Disable interrupts during SPI transfer (can't allow partial command to chips) - const uint8_t data_out = L6470_SpiTransfer_Mode_3(data); - hal.isr_on(); // Enable interrupts - - extDigitalWrite(ss_pin, HIGH); - return data_out; -} - -uint8_t L64XX_Marlin::transfer_chain(uint8_t data, int16_t ss_pin, uint8_t chain_position) { - uint8_t data_out = 0; - - // first device in chain has data sent last - extDigitalWrite(ss_pin, LOW); - - for (uint8_t i = L64XX::chain[0]; !L64xxManager.spi_abort && i >= 1; i--) { // Send data unless aborted - hal.isr_off(); // Disable interrupts during SPI transfer (can't allow partial command to chips) - const uint8_t temp = L6470_SpiTransfer_Mode_3(uint8_t(i == chain_position ? data : dSPIN_NOP)); - hal.isr_on(); // Enable interrupts - if (i == chain_position) data_out = temp; - } - - extDigitalWrite(ss_pin, HIGH); - return data_out; -} - -/** - * Platform-supplied L6470 buffer transfer method - */ -void L64XX_Marlin::transfer(uint8_t L6470_buf[], const uint8_t length) { - // First device in chain has its data sent last - - if (spi_active) { // Interrupted SPI transfer so need to - WRITE(L6470_CHAIN_SS_PIN, HIGH); // guarantee min high of 650ns - DELAY_US(1); - } - - WRITE(L6470_CHAIN_SS_PIN, LOW); - for (uint8_t i = length; i >= 1; i--) - L6470_SpiTransfer_Mode_3(uint8_t(L6470_buf[i])); - WRITE(L6470_CHAIN_SS_PIN, HIGH); -} - -#pragma GCC reset_options - -#endif // HAS_L64XX 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 diff --git a/Marlin/src/HAL/shared/backtrace/unwarmbytab.cpp b/Marlin/src/HAL/shared/backtrace/unwarmbytab.cpp index f1ee81ed4acb..148927a19f52 100644 --- a/Marlin/src/HAL/shared/backtrace/unwarmbytab.cpp +++ b/Marlin/src/HAL/shared/backtrace/unwarmbytab.cpp @@ -135,11 +135,11 @@ static UnwResult UnwTabExecuteInstructions(const UnwindCallbacks *cb, UnwTabStat while ((instruction = UnwTabGetNextInstruction(cb, ucb)) != -1) { if ((instruction & 0xC0) == 0x00) { // ARM_EXIDX_CMD_DATA_POP - /* vsp = vsp + (xxxxxx << 2) + 4 */ + /* vsp += (xxxxxx << 2) + 4 */ ucb->vrs[13] += ((instruction & 0x3F) << 2) + 4; } else if ((instruction & 0xC0) == 0x40) { // ARM_EXIDX_CMD_DATA_PUSH - /* vsp = vsp - (xxxxxx << 2) - 4 */ + /* vsp -= (xxxxxx << 2) - 4 */ ucb->vrs[13] -= ((instruction & 0x3F) << 2) - 4; } else if ((instruction & 0xF0) == 0x80) { diff --git a/Marlin/src/HAL/shared/eeprom_if_i2c.cpp b/Marlin/src/HAL/shared/eeprom_if_i2c.cpp index 6b559e234b4c..bba9c626a4da 100644 --- a/Marlin/src/HAL/shared/eeprom_if_i2c.cpp +++ b/Marlin/src/HAL/shared/eeprom_if_i2c.cpp @@ -33,13 +33,14 @@ #if ENABLED(SOFT_I2C_EEPROM) #include - SlowSoftWire Wire = SlowSoftWire(I2C_SDA_PIN, I2C_SCL_PIN, true); + SlowSoftWire eWire = SlowSoftWire(I2C_SDA_PIN, I2C_SCL_PIN, true); #else #include + #define eWire Wire #endif void eeprom_init() { - Wire.begin( + eWire.begin( #if PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM) uint8_t(I2C_SDA_PIN), uint8_t(I2C_SCL_PIN) #endif @@ -75,16 +76,16 @@ static uint8_t _eeprom_calc_device_address(uint8_t * const pos) { static void _eeprom_begin(uint8_t * const pos) { const unsigned eeprom_address = (unsigned)pos; - Wire.beginTransmission(_eeprom_calc_device_address(pos)); + eWire.beginTransmission(_eeprom_calc_device_address(pos)); if (!SMALL_EEPROM) - Wire.write(uint8_t((eeprom_address >> 8) & 0xFF)); // Address High, if needed - Wire.write(uint8_t(eeprom_address & 0xFF)); // Address Low + eWire.write(uint8_t((eeprom_address >> 8) & 0xFF)); // Address High, if needed + eWire.write(uint8_t(eeprom_address & 0xFF)); // Address Low } void eeprom_write_byte(uint8_t *pos, uint8_t value) { _eeprom_begin(pos); - Wire.write(value); - Wire.endTransmission(); + eWire.write(value); + eWire.endTransmission(); // wait for write cycle to complete // this could be done more efficiently with "acknowledge polling" @@ -93,9 +94,9 @@ void eeprom_write_byte(uint8_t *pos, uint8_t value) { uint8_t eeprom_read_byte(uint8_t *pos) { _eeprom_begin(pos); - Wire.endTransmission(); - Wire.requestFrom(_eeprom_calc_device_address(pos), (byte)1); - return Wire.available() ? Wire.read() : 0xFF; + eWire.endTransmission(); + eWire.requestFrom(_eeprom_calc_device_address(pos), (byte)1); + return eWire.available() ? eWire.read() : 0xFF; } #endif // USE_SHARED_EEPROM diff --git a/Marlin/src/HAL/shared/esp_wifi.cpp b/Marlin/src/HAL/shared/esp_wifi.cpp index a55f5ca39f91..8a6ac2dfa955 100644 --- a/Marlin/src/HAL/shared/esp_wifi.cpp +++ b/Marlin/src/HAL/shared/esp_wifi.cpp @@ -21,6 +21,9 @@ */ #include "../../inc/MarlinConfig.h" + +#if ENABLED(WIFISUPPORT) + #include "Delay.h" void esp_wifi_init(void) { // init ESP01 WIFI module pins @@ -41,3 +44,5 @@ void esp_wifi_init(void) { // init ESP01 WIFI module pi OUT_WRITE(ESP_WIFI_MODULE_ENABLE_PIN, HIGH); #endif } + +#endif // WIFISUPPORT diff --git a/Marlin/src/HAL/shared/servo.h b/Marlin/src/HAL/shared/servo.h index c2560a853832..15153ca53fa9 100644 --- a/Marlin/src/HAL/shared/servo.h +++ b/Marlin/src/HAL/shared/servo.h @@ -83,10 +83,10 @@ #else #include - #if defined(__AVR__) || defined(ARDUINO_ARCH_SAM) || defined(__SAMD51__) + #if defined(__AVR__) || defined(ARDUINO_ARCH_SAM) || defined(__SAMD51__) || defined(__SAMD21__) // we're good to go #else - #error "This library only supports boards with an AVR, SAM3X or SAMD51 processor." + #error "This library only supports boards with an AVR, SAM3X, SAMD21 or SAMD51 processor." #endif #define Servo_VERSION 2 // software version of this library diff --git a/Marlin/src/HAL/shared/servo_private.h b/Marlin/src/HAL/shared/servo_private.h index 021e0cb81d01..8fd5ab2d8883 100644 --- a/Marlin/src/HAL/shared/servo_private.h +++ b/Marlin/src/HAL/shared/servo_private.h @@ -49,8 +49,10 @@ #include "../DUE/ServoTimers.h" #elif defined(__SAMD51__) #include "../SAMD51/ServoTimers.h" +#elif defined(__SAMD21__) + #include "../SAMD21/ServoTimers.h" #else - #error "This library only supports boards with an AVR, SAM3X or SAMD51 processor." + #error "This library only supports boards with an AVR, SAM3X, SAMD21 or SAMD51 processor." #endif // Macros @@ -94,5 +96,5 @@ extern ServoInfo_t servo_info[MAX_SERVOS]; // Public functions -extern void initISR(const timer16_Sequence_t timer); -extern void finISR(const timer16_Sequence_t timer); +void initISR(const timer16_Sequence_t timer_index); +void finISR(const timer16_Sequence_t timer_index); diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 67950299dbd4..0ca4199fcd6d 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -34,22 +34,22 @@ #include "HAL/shared/esp_wifi.h" #include "HAL/shared/cpu_exception/exception_hook.h" +#if ENABLED(WIFISUPPORT) + #include "HAL/shared/esp_wifi.h" +#endif + #ifdef ARDUINO #include #endif #include -#include "core/utility.h" - +#include "module/endstops.h" #include "module/motion.h" #include "module/planner.h" -#include "module/endstops.h" -#include "module/temperature.h" -#include "module/settings.h" #include "module/printcounter.h" // PrintCounter or Stopwatch - +#include "module/settings.h" #include "module/stepper.h" -#include "module/stepper/indirection.h" +#include "module/temperature.h" #include "gcode/gcode.h" #include "gcode/parser.h" @@ -125,6 +125,10 @@ #include "feature/bltouch.h" #endif +#if ENABLED(BD_SENSOR) + #include "feature/bedlevel/bdl/bdl.h" +#endif + #if ENABLED(POLL_JOG) #include "feature/joystick.h" #endif @@ -228,10 +232,6 @@ #include "feature/mmu/mmu2.h" #endif -#if HAS_L64XX - #include "libs/L64XX/L64XX_Marlin.h" -#endif - #if ENABLED(PASSWORD_FEATURE) #include "feature/password/password.h" #endif @@ -252,6 +252,10 @@ #include "feature/easythreed_ui.h" #endif +#if ENABLED(MARLIN_TEST_BUILD) + #include "tests/marlin_tests.h" +#endif + PGMSTR(M112_KILL_STR, "M112 Shutdown"); MarlinState marlin_state = MF_INITIALIZING; @@ -347,7 +351,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 } @@ -434,7 +438,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { if (!has_blocks && !do_reset_timeout && gcode.stepper_inactive_timeout()) { if (!already_shutdown_steppers) { - already_shutdown_steppers = true; // L6470 SPI will consume 99% of free time without this + already_shutdown_steppers = true; // Individual axes will be disabled if configured TERN_(DISABLE_INACTIVE_X, stepper.disable_axis(X_AXIS)); @@ -488,7 +492,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 @@ -518,8 +522,8 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { if (ELAPSED(ms, next_cub_ms_##N)) { \ next_cub_ms_##N = ms + CUB_DEBOUNCE_DELAY_##N; \ CODE; \ - queue.inject(F(BUTTON##N##_GCODE)); \ - TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); \ + queue.inject(F(BUTTON##N##_GCODE)); \ + TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); \ } \ } \ }while(0) @@ -733,8 +737,6 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { TERN_(MONITOR_DRIVER_STATUS, monitor_tmc_drivers()); - TERN_(MONITOR_L6470_DRIVER_STATUS, L64xxManager.monitor_driver()); - // Limit check_axes_activity frequency to 10Hz static millis_t next_check_axes_ms = 0; if (ELAPSED(ms, next_check_axes_ms)) { @@ -775,17 +777,24 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { * - Update the Průša MMU2 * - Handle Joystick jogging */ -void idle(bool no_stepper_sleep/*=false*/) { +void idle(const bool no_stepper_sleep/*=false*/) { + #ifdef MAX7219_DEBUG_PROFILE + CodeProfiler idle_profiler; + #endif + #if ENABLED(MARLIN_DEV_MODE) static uint16_t idle_depth = 0; if (++idle_depth > 5) SERIAL_ECHOLNPGM("idle() call depth: ", idle_depth); #endif + // Bed Distance Sensor task + TERN_(BD_SENSOR, bdl.process()); + // Core Marlin activities manage_inactivity(no_stepper_sleep); // Manage Heaters (and Watchdog) - thermalManager.manage_heater(); + thermalManager.task(); // Max7219 heartbeat, animation, etc TERN_(MAX7219_DEBUG, max7219.idle_tasks()); @@ -1060,7 +1069,6 @@ inline void tmc_standby_setup() { * • TMC220x Stepper Drivers (Serial) * • PSU control * • Power-loss Recovery - * • L64XX Stepper Drivers (SPI) * • Stepper Driver Reset: DISABLE * • TMC Stepper Drivers (SPI) * • Run hal.init_board() for additional pins setup @@ -1223,10 +1231,10 @@ void setup() { SETUP_RUN(hal.init()); // Init and disable SPI thermocouples; this is still needed - #if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0)) + #if TEMP_SENSOR_IS_MAX_TC(0) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E0)) OUT_WRITE(TEMP_0_CS_PIN, HIGH); // Disable #endif - #if TEMP_SENSOR_1_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1)) + #if TEMP_SENSOR_IS_MAX_TC(1) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1)) OUT_WRITE(TEMP_1_CS_PIN, HIGH); #endif @@ -1249,10 +1257,6 @@ void setup() { SETUP_RUN(tmc_init_cs_pins()); #endif - #if HAS_L64XX - SETUP_RUN(L64xxManager.init()); // Set up SPI, init drivers - #endif - #if ENABLED(PSU_CONTROL) SETUP_LOG("PSU_CONTROL"); powerManager.init(); @@ -1268,7 +1272,9 @@ void setup() { SETUP_RUN(hal.init_board()); - SETUP_RUN(esp_wifi_init()); + #if ENABLED(WIFISUPPORT) + SETUP_RUN(esp_wifi_init()); + #endif // Report Reset Reason if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP); @@ -1639,9 +1645,15 @@ void setup() { SETUP_RUN(test_tmc_connection()); #endif + #if ENABLED(BD_SENSOR) + SETUP_RUN(bdl.init(I2C_BD_SDA_PIN, I2C_BD_SCL_PIN, I2C_BD_DELAY)); + #endif + marlin_state = MF_RUNNING; SETUP_LOG("setup() completed."); + + TERN_(MARLIN_TEST_BUILD, runStartupTests()); } /** @@ -1676,5 +1688,7 @@ void loop() { TERN_(HAS_TFT_LVGL_UI, printer_state_polling()); + TERN_(MARLIN_TEST_BUILD, runPeriodicTests()); + } while (ENABLED(__AVR__)); // Loop forever on slower (AVR) boards } diff --git a/Marlin/src/MarlinCore.h b/Marlin/src/MarlinCore.h index f80405a302ee..e9c63bb31f35 100644 --- a/Marlin/src/MarlinCore.h +++ b/Marlin/src/MarlinCore.h @@ -30,7 +30,7 @@ void stop(); // Pass true to keep steppers from timing out -void idle(bool no_stepper_sleep=false); +void idle(const bool no_stepper_sleep=false); inline void idle_no_sleep() { idle(true); } #if ENABLED(G38_PROBE_TARGET) diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index ef750056d6fc..4963945fc120 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -21,6 +21,11 @@ */ #pragma once +/** + * Whenever changes are made to this file, please update Marlin/Makefile + * and _data/boards.yml in the MarlinDocumentation repo. + */ + #include "macros.h" #define BOARD_UNKNOWN -1 @@ -110,13 +115,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 @@ -220,7 +226,7 @@ #define BOARD_5DPRINT 1707 // 5DPrint D8 Driver Board // -// LPC1768 ARM Cortex M3 +// LPC1768 ARM Cortex-M3 // #define BOARD_RAMPS_14_RE_ARM_EFB 2000 // Re-ARM with RAMPS 1.4 (Power outputs: Hotend, Fan, Bed) @@ -238,9 +244,10 @@ #define BOARD_BTT_SKR_V1_1 2012 // BigTreeTech SKR v1.1 #define BOARD_BTT_SKR_V1_3 2013 // BigTreeTech SKR v1.3 #define BOARD_BTT_SKR_V1_4 2014 // BigTreeTech SKR v1.4 +#define BOARD_EMOTRONIC 2015 // eMotion-Tech eMotronic // -// LPC1769 ARM Cortex M3 +// LPC1769 ARM Cortex-M3 // #define BOARD_MKS_SGEN 2500 // MKS-SGen @@ -257,7 +264,7 @@ #define BOARD_FLY_CDY 2511 // FLYmaker FLY CDY // -// SAM3X8E ARM Cortex M3 +// SAM3X8E ARM Cortex-M3 // #define BOARD_DUE3DOM 3000 // DUE3DOM for Arduino DUE @@ -290,170 +297,197 @@ #define BOARD_KRATOS32 3027 // K.3D Kratos32 (Arduino Due Shield) // -// SAM3X8C ARM Cortex M3 +// SAM3X8C ARM Cortex-M3 // #define BOARD_PRINTRBOARD_G2 3100 // Printrboard G2 #define BOARD_ADSK 3101 // Arduino DUE Shield Kit (ADSK) +// +// STM32 ARM Cortex-M0+ +// + +#define BOARD_BTT_EBB42_V1_1 4000 // BigTreeTech EBB42 V1.1 (STM32G0B1CB) +#define BOARD_BTT_SKR_MINI_E3_V3_0 4001 // BigTreeTech SKR Mini E3 V3.0 (STM32G0B1RE) +#define BOARD_BTT_MANTA_E3_EZ_V1_0 4002 // BigTreeTech Manta E3 EZ V1.0 (STM32G0B1RE) +#define BOARD_BTT_MANTA_M4P_V1_0 4003 // BigTreeTech Manta M4P V1.0 (STM32G0B1RE) +#define BOARD_BTT_MANTA_M5P_V1_0 4004 // BigTreeTech Manta M5P V1.0 (STM32G0B1RE) +#define BOARD_BTT_MANTA_M8P_V1_0 4005 // BigTreeTech Manta M8P V1.0 (STM32G0B1VE) +#define BOARD_BTT_MANTA_M8P_V1_1 4006 // BigTreeTech Manta M8P V1.1 (STM32G0B1VE) + // // STM32 ARM Cortex-M3 // -#define BOARD_MALYAN_M200_V2 4000 // STM32F070CB controller -#define BOARD_MALYAN_M300 4001 // STM32F070-based delta -#define BOARD_STM32F103RE 4002 // STM32F103RE Libmaple-based STM32F1 controller -#define BOARD_MALYAN_M200 4003 // STM32C8 Libmaple-based STM32F1 controller -#define BOARD_STM3R_MINI 4004 // STM32F103RE Libmaple-based STM32F1 controller -#define BOARD_GTM32_PRO_VB 4005 // STM32F103VE controller -#define BOARD_GTM32_MINI 4006 // STM32F103VE controller -#define BOARD_GTM32_MINI_A30 4007 // STM32F103VE controller -#define BOARD_GTM32_REV_B 4008 // STM32F103VE controller -#define BOARD_MORPHEUS 4009 // STM32F103C8 / STM32F103CB Libmaple-based STM32F1 controller -#define BOARD_CHITU3D 4010 // Chitu3D (STM32F103RE) -#define BOARD_MKS_ROBIN 4011 // MKS Robin (STM32F103ZE) -#define BOARD_MKS_ROBIN_MINI 4012 // MKS Robin Mini (STM32F103VE) -#define BOARD_MKS_ROBIN_NANO 4013 // MKS Robin Nano (STM32F103VE) -#define BOARD_MKS_ROBIN_NANO_V2 4014 // MKS Robin Nano V2 (STM32F103VE) -#define BOARD_MKS_ROBIN_LITE 4015 // MKS Robin Lite/Lite2 (STM32F103RC) -#define BOARD_MKS_ROBIN_LITE3 4016 // MKS Robin Lite3 (STM32F103RC) -#define BOARD_MKS_ROBIN_PRO 4017 // MKS Robin Pro (STM32F103ZE) -#define BOARD_MKS_ROBIN_E3 4018 // MKS Robin E3 (STM32F103RC) -#define BOARD_MKS_ROBIN_E3_V1_1 4019 // MKS Robin E3 V1.1 (STM32F103RC) -#define BOARD_MKS_ROBIN_E3D 4020 // MKS Robin E3D (STM32F103RC) -#define BOARD_MKS_ROBIN_E3D_V1_1 4021 // MKS Robin E3D V1.1 (STM32F103RC) -#define BOARD_MKS_ROBIN_E3P 4022 // MKS Robin E3p (STM32F103VE) -#define BOARD_BTT_SKR_MINI_V1_1 4023 // BigTreeTech SKR Mini v1.1 (STM32F103RC) -#define BOARD_BTT_SKR_MINI_E3_V1_0 4024 // BigTreeTech SKR Mini E3 (STM32F103RC) -#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 -#define BOARD_FYSETC_CHEETAH 4033 // FYSETC Cheetah -#define BOARD_FYSETC_CHEETAH_V12 4034 // FYSETC Cheetah V1.2 -#define BOARD_LONGER3D_LK 4035 // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VE -#define BOARD_CCROBOT_MEEB_3DP 4036 // ccrobot-online.com MEEB_3DP (STM32F103RC) -#define BOARD_CHITU3D_V5 4037 // Chitu3D TronXY X5SA V5 Board -#define BOARD_CHITU3D_V6 4038 // Chitu3D TronXY X5SA V6 Board -#define BOARD_CHITU3D_V9 4039 // Chitu3D TronXY X5SA V9 Board -#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_V427 4043 // Creality v4.2.7 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V4210 4044 // Creality v4.2.10 (STM32F103RC / STM32F103RE) as found in the CR-30 -#define BOARD_CREALITY_V431 4045 // Creality v4.3.1 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_A 4046 // Creality v4.3.1a (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_B 4047 // Creality v4.3.1b (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_C 4048 // Creality v4.3.1c (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_D 4049 // Creality v4.3.1d (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V452 4050 // Creality v4.5.2 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V453 4051 // Creality v4.5.3 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V24S1 4052 // Creality v2.4.S1 (STM32F103RC / STM32F103RE) v101 as found in the Ender-7 -#define BOARD_CREALITY_V24S1_301 4053 // Creality v2.4.S1_301 (STM32F103RC / STM32F103RE) v301 as found in the Ender-3 S1 -#define BOARD_CREALITY_V25S1 4054 // Creality v2.5.S1 (STM32F103RE) as found in the CR-10 Smart Pro -#define BOARD_TRIGORILLA_PRO 4055 // Trigorilla Pro (STM32F103ZE) -#define BOARD_FLY_MINI 4056 // FLYmaker FLY MINI (STM32F103RC) -#define BOARD_FLSUN_HISPEED 4057 // FLSUN HiSpeedV1 (STM32F103VE) -#define BOARD_BEAST 4058 // STM32F103RE Libmaple-based controller -#define BOARD_MINGDA_MPX_ARM_MINI 4059 // STM32F103ZE Mingda MD-16 -#define BOARD_GTM32_PRO_VD 4060 // STM32F103VE controller -#define BOARD_ZONESTAR_ZM3E2 4061 // Zonestar ZM3E2 (STM32F103RC) -#define BOARD_ZONESTAR_ZM3E4 4062 // Zonestar ZM3E4 V1 (STM32F103VC) -#define BOARD_ZONESTAR_ZM3E4V2 4063 // Zonestar ZM3E4 V2 (STM32F103VC) -#define BOARD_ERYONE_ERY32_MINI 4064 // Eryone Ery32 mini (STM32F103VE) -#define BOARD_PANDA_PI_V29 4065 // Panda Pi V2.9 - Standalone (STM32F103RC) +#define BOARD_MALYAN_M200_V2 5000 // STM32F070CB controller +#define BOARD_MALYAN_M300 5001 // STM32F070-based delta +#define BOARD_STM32F103RE 5002 // STM32F103RE Libmaple-based STM32F1 controller +#define BOARD_MALYAN_M200 5003 // STM32C8 Libmaple-based STM32F1 controller +#define BOARD_STM3R_MINI 5004 // STM32F103RE Libmaple-based STM32F1 controller +#define BOARD_GTM32_PRO_VB 5005 // STM32F103VE controller +#define BOARD_GTM32_MINI 5006 // STM32F103VE controller +#define BOARD_GTM32_MINI_A30 5007 // STM32F103VE controller +#define BOARD_GTM32_REV_B 5008 // STM32F103VE controller +#define BOARD_MORPHEUS 5009 // STM32F103C8 / STM32F103CB Libmaple-based STM32F1 controller +#define BOARD_CHITU3D 5010 // Chitu3D (STM32F103RE) +#define BOARD_MKS_ROBIN 5011 // MKS Robin (STM32F103ZE) +#define BOARD_MKS_ROBIN_MINI 5012 // MKS Robin Mini (STM32F103VE) +#define BOARD_MKS_ROBIN_NANO 5013 // MKS Robin Nano (STM32F103VE) +#define BOARD_MKS_ROBIN_NANO_V2 5014 // MKS Robin Nano V2 (STM32F103VE) +#define BOARD_MKS_ROBIN_LITE 5015 // MKS Robin Lite/Lite2 (STM32F103RC) +#define BOARD_MKS_ROBIN_LITE3 5016 // MKS Robin Lite3 (STM32F103RC) +#define BOARD_MKS_ROBIN_PRO 5017 // MKS Robin Pro (STM32F103ZE) +#define BOARD_MKS_ROBIN_E3 5018 // MKS Robin E3 (STM32F103RC) +#define BOARD_MKS_ROBIN_E3_V1_1 5019 // MKS Robin E3 V1.1 (STM32F103RC) +#define BOARD_MKS_ROBIN_E3D 5020 // MKS Robin E3D (STM32F103RC) +#define BOARD_MKS_ROBIN_E3D_V1_1 5021 // MKS Robin E3D V1.1 (STM32F103RC) +#define BOARD_MKS_ROBIN_E3P 5022 // MKS Robin E3P (STM32F103VE) +#define BOARD_BTT_SKR_MINI_V1_1 5023 // BigTreeTech SKR Mini v1.1 (STM32F103RC) +#define BOARD_BTT_SKR_MINI_E3_V1_0 5024 // BigTreeTech SKR Mini E3 (STM32F103RC) +#define BOARD_BTT_SKR_MINI_E3_V1_2 5025 // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC) +#define BOARD_BTT_SKR_MINI_E3_V2_0 5026 // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC / STM32F103RE) +#define BOARD_BTT_SKR_MINI_MZ_V1_0 5027 // BigTreeTech SKR Mini MZ V1.0 (STM32F103RC) +#define BOARD_BTT_SKR_E3_DIP 5028 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE) +#define BOARD_BTT_SKR_CR6 5029 // BigTreeTech SKR CR6 v1.0 (STM32F103RE) +#define BOARD_JGAURORA_A5S_A1 5030 // JGAurora A5S A1 (STM32F103ZE) +#define BOARD_FYSETC_AIO_II 5031 // FYSETC AIO_II (STM32F103RC) +#define BOARD_FYSETC_CHEETAH 5032 // FYSETC Cheetah (STM32F103RC) +#define BOARD_FYSETC_CHEETAH_V12 5033 // FYSETC Cheetah V1.2 (STM32F103RC) +#define BOARD_LONGER3D_LK 5034 // Longer3D LK1/2 - Alfawise U20/U20+/U30 (STM32F103VE) +#define BOARD_CCROBOT_MEEB_3DP 5035 // ccrobot-online.com MEEB_3DP (STM32F103RC) +#define BOARD_CHITU3D_V5 5036 // Chitu3D TronXY X5SA V5 Board (STM32F103ZE) +#define BOARD_CHITU3D_V6 5037 // Chitu3D TronXY X5SA V6 Board (STM32F103ZE) +#define BOARD_CHITU3D_V9 5038 // Chitu3D TronXY X5SA V9 Board (STM32F103ZE) +#define BOARD_CREALITY_V4 5039 // Creality v4.x (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V422 5040 // Creality v4.2.2 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V423 5041 // Creality v4.2.3 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V425 5042 // Creality v4.2.5 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V427 5043 // Creality v4.2.7 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V4210 5044 // Creality v4.2.10 (STM32F103RC / STM32F103RE) as found in the CR-30 +#define BOARD_CREALITY_V431 5045 // Creality v4.3.1 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_A 5046 // Creality v4.3.1a (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_B 5047 // Creality v4.3.1b (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_C 5048 // Creality v4.3.1c (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_D 5049 // Creality v4.3.1d (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V452 5050 // Creality v4.5.2 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V453 5051 // Creality v4.5.3 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V521 5052 // Creality v5.2.1 (STM32F103VE) as found in the SV04 +#define BOARD_CREALITY_V24S1 5053 // Creality v2.4.S1 (STM32F103RC / STM32F103RE) v101 as found in the Ender-7 +#define BOARD_CREALITY_V24S1_301 5054 // Creality v2.4.S1_301 (STM32F103RC / STM32F103RE) v301 as found in the Ender-3 S1 +#define BOARD_CREALITY_V25S1 5055 // Creality v2.5.S1 (STM32F103RE) as found in the CR-10 Smart Pro +#define BOARD_TRIGORILLA_PRO 5056 // Trigorilla Pro (STM32F103ZE) +#define BOARD_FLY_MINI 5057 // FLYmaker FLY MINI (STM32F103RC) +#define BOARD_FLSUN_HISPEED 5058 // FLSUN HiSpeedV1 (STM32F103VE) +#define BOARD_BEAST 5059 // STM32F103RE Libmaple-based controller +#define BOARD_MINGDA_MPX_ARM_MINI 5060 // STM32F103ZE Mingda MD-16 +#define BOARD_GTM32_PRO_VD 5061 // STM32F103VE controller +#define BOARD_ZONESTAR_ZM3E2 5062 // Zonestar ZM3E2 (STM32F103RC) +#define BOARD_ZONESTAR_ZM3E4 5063 // Zonestar ZM3E4 V1 (STM32F103VC) +#define BOARD_ZONESTAR_ZM3E4V2 5064 // Zonestar ZM3E4 V2 (STM32F103VC) +#define BOARD_ERYONE_ERY32_MINI 5065 // Eryone Ery32 mini (STM32F103VE) +#define BOARD_PANDA_PI_V29 5066 // Panda Pi V2.9 - Standalone (STM32F103RC) +#define BOARD_SOVOL_V131 5067 // Sovol V1.3.1 (GD32F103RET6) // // ARM Cortex-M4F // -#define BOARD_TEENSY31_32 4100 // Teensy3.1 and Teensy3.2 -#define BOARD_TEENSY35_36 4101 // Teensy3.5 and Teensy3.6 +#define BOARD_TEENSY31_32 5100 // Teensy3.1 and Teensy3.2 +#define BOARD_TEENSY35_36 5101 // Teensy3.5 and Teensy3.6 // // STM32 ARM Cortex-M4F // -#define BOARD_ARMED 4200 // Arm'ed STM32F4-based controller -#define BOARD_RUMBA32_V1_0 4201 // RUMBA32 STM32F446VE based controller from Aus3D -#define BOARD_RUMBA32_V1_1 4202 // RUMBA32 STM32F446VE based controller from Aus3D -#define BOARD_RUMBA32_MKS 4203 // RUMBA32 STM32F446VE based controller from Makerbase -#define BOARD_RUMBA32_BTT 4204 // RUMBA32 STM32F446VE based controller from BIGTREETECH -#define BOARD_BLACK_STM32F407VE 4205 // BLACK_STM32F407VE -#define BOARD_BLACK_STM32F407ZE 4206 // BLACK_STM32F407ZE -#define BOARD_STEVAL_3DP001V1 4207 // STEVAL-3DP001V1 3D PRINTER BOARD -#define BOARD_BTT_SKR_PRO_V1_1 4208 // BigTreeTech SKR Pro v1.1 (STM32F407ZG) -#define BOARD_BTT_SKR_PRO_V1_2 4209 // BigTreeTech SKR Pro v1.2 (STM32F407ZG) -#define BOARD_BTT_BTT002_V1_0 4210 // BigTreeTech BTT002 v1.0 (STM32F407VG) -#define BOARD_BTT_E3_RRF 4211 // BigTreeTech E3 RRF (STM32F407VG) -#define BOARD_BTT_SKR_V2_0_REV_A 4212 // BigTreeTech SKR v2.0 Rev A (STM32F407VG) -#define BOARD_BTT_SKR_V2_0_REV_B 4213 // BigTreeTech SKR v2.0 Rev B (STM32F407VG/STM32F429VG) -#define BOARD_BTT_GTR_V1_0 4214 // BigTreeTech GTR v1.0 (STM32F407IGT) -#define BOARD_BTT_OCTOPUS_V1_0 4215 // BigTreeTech Octopus v1.0 (STM32F446ZE) -#define BOARD_BTT_OCTOPUS_V1_1 4216 // BigTreeTech Octopus v1.1 (STM32F446ZE) -#define BOARD_BTT_OCTOPUS_PRO_V1_0 4217 // BigTreeTech Octopus Pro v1.0 (STM32F446ZE/STM32F429ZG) -#define BOARD_LERDGE_K 4218 // Lerdge K (STM32F407ZG) -#define BOARD_LERDGE_S 4219 // Lerdge S (STM32F407VE) -#define BOARD_LERDGE_X 4220 // Lerdge X (STM32F407VE) -#define BOARD_VAKE403D 4221 // VAkE 403D (STM32F446VE) -#define BOARD_FYSETC_S6 4222 // FYSETC S6 (STM32F446VE) -#define BOARD_FYSETC_S6_V2_0 4223 // FYSETC S6 v2.0 (STM32F446VE) -#define BOARD_FYSETC_SPIDER 4224 // FYSETC Spider (STM32F446VE) -#define BOARD_FLYF407ZG 4225 // FLYmaker FLYF407ZG (STM32F407ZG) -#define BOARD_MKS_ROBIN2 4226 // MKS_ROBIN2 (STM32F407ZE) -#define BOARD_MKS_ROBIN_PRO_V2 4227 // MKS Robin Pro V2 (STM32F407VE) -#define BOARD_MKS_ROBIN_NANO_V3 4228 // MKS Robin Nano V3 (STM32F407VG) -#define BOARD_MKS_ROBIN_NANO_V3_1 4229 // MKS Robin Nano V3.1 (STM32F407VE) -#define BOARD_MKS_MONSTER8 4230 // MKS Monster8 (STM32F407VG) -#define BOARD_ANET_ET4 4231 // ANET ET4 V1.x (STM32F407VG) -#define BOARD_ANET_ET4P 4232 // ANET ET4P V1.x (STM32F407VG) -#define BOARD_FYSETC_CHEETAH_V20 4233 // FYSETC Cheetah V2.0 -#define BOARD_TH3D_EZBOARD_V2 4234 // TH3D EZBoard v2.0 -#define BOARD_INDEX_REV03 4235 // Index PnP Controller REV03 (STM32F407VE/VG) -#define BOARD_MKS_ROBIN_NANO_V1_3_F4 4236 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VE) -#define BOARD_MKS_EAGLE 4237 // MKS Eagle (STM32F407VE) -#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 - -// -// ARM Cortex M7 -// - -#define BOARD_REMRAM_V1 5000 // RemRam v1 -#define BOARD_TEENSY41 5001 // Teensy 4.1 -#define BOARD_T41U5XBB 5002 // T41U5XBB Teensy 4.1 breakout board -#define BOARD_NUCLEO_F767ZI 5003 // ST NUCLEO-F767ZI Dev Board -#define BOARD_BTT_SKR_SE_BX 5004 // BigTreeTech SKR SE BX (STM32H743II) -#define BOARD_BTT_SKR_V3_0 5005 // BigTreeTech SKR V3.0 (STM32H743VG) -#define BOARD_BTT_SKR_V3_0_EZ 5006 // BigTreeTech SKR V3.0 EZ (STM32H743VG) +#define BOARD_ARMED 5200 // Arm'ed STM32F4-based controller +#define BOARD_RUMBA32_V1_0 5201 // RUMBA32 STM32F446VE based controller from Aus3D +#define BOARD_RUMBA32_V1_1 5202 // RUMBA32 STM32F446VE based controller from Aus3D +#define BOARD_RUMBA32_MKS 5203 // RUMBA32 STM32F446VE based controller from Makerbase +#define BOARD_RUMBA32_BTT 5204 // RUMBA32 STM32F446VE based controller from BIGTREETECH +#define BOARD_BLACK_STM32F407VE 5205 // BLACK_STM32F407VE +#define BOARD_BLACK_STM32F407ZE 5206 // BLACK_STM32F407ZE +#define BOARD_BTT_SKR_MINI_E3_V3_0_1 5207 // BigTreeTech SKR Mini E3 V3.0.1 (STM32F401RC) +#define BOARD_BTT_SKR_PRO_V1_1 5208 // BigTreeTech SKR Pro v1.1 (STM32F407ZG) +#define BOARD_BTT_SKR_PRO_V1_2 5209 // BigTreeTech SKR Pro v1.2 (STM32F407ZG) +#define BOARD_BTT_BTT002_V1_0 5210 // BigTreeTech BTT002 v1.0 (STM32F407VG) +#define BOARD_BTT_E3_RRF 5211 // BigTreeTech E3 RRF (STM32F407VG) +#define BOARD_BTT_SKR_V2_0_REV_A 5212 // BigTreeTech SKR v2.0 Rev A (STM32F407VG) +#define BOARD_BTT_SKR_V2_0_REV_B 5213 // BigTreeTech SKR v2.0 Rev B (STM32F407VG/STM32F429VG) +#define BOARD_BTT_GTR_V1_0 5214 // BigTreeTech GTR v1.0 (STM32F407IGT) +#define BOARD_BTT_OCTOPUS_V1_0 5215 // BigTreeTech Octopus v1.0 (STM32F446ZE) +#define BOARD_BTT_OCTOPUS_V1_1 5216 // BigTreeTech Octopus v1.1 (STM32F446ZE) +#define BOARD_BTT_OCTOPUS_PRO_V1_0 5217 // BigTreeTech Octopus Pro v1.0 (STM32F446ZE / STM32F429ZG) +#define BOARD_LERDGE_K 5218 // Lerdge K (STM32F407ZG) +#define BOARD_LERDGE_S 5219 // Lerdge S (STM32F407VE) +#define BOARD_LERDGE_X 5220 // Lerdge X (STM32F407VE) +#define BOARD_VAKE403D 5221 // VAkE 403D (STM32F446VE) +#define BOARD_FYSETC_S6 5222 // FYSETC S6 (STM32F446VE) +#define BOARD_FYSETC_S6_V2_0 5223 // FYSETC S6 v2.0 (STM32F446VE) +#define BOARD_FYSETC_SPIDER 5224 // FYSETC Spider (STM32F446VE) +#define BOARD_FLYF407ZG 5225 // FLYmaker FLYF407ZG (STM32F407ZG) +#define BOARD_MKS_ROBIN2 5226 // MKS Robin2 V1.0 (STM32F407ZE) +#define BOARD_MKS_ROBIN_PRO_V2 5227 // MKS Robin Pro V2 (STM32F407VE) +#define BOARD_MKS_ROBIN_NANO_V3 5228 // MKS Robin Nano V3 (STM32F407VG) +#define BOARD_MKS_ROBIN_NANO_V3_1 5229 // MKS Robin Nano V3.1 (STM32F407VE) +#define BOARD_MKS_MONSTER8_V1 5230 // MKS Monster8 V1 (STM32F407VE) +#define BOARD_MKS_MONSTER8_V2 5231 // MKS Monster8 V2 (STM32F407VE) +#define BOARD_ANET_ET4 5232 // ANET ET4 V1.x (STM32F407VG) +#define BOARD_ANET_ET4P 5233 // ANET ET4P V1.x (STM32F407VG) +#define BOARD_FYSETC_CHEETAH_V20 5234 // FYSETC Cheetah V2.0 (STM32F401RC) +#define BOARD_TH3D_EZBOARD_V2 5235 // TH3D EZBoard v2.0 (STM32F405RG) +#define BOARD_OPULO_LUMEN_REV3 5236 // Opulo Lumen PnP Controller REV3 (STM32F407VE / STM32F407VG) +#define BOARD_MKS_ROBIN_NANO_V1_3_F4 5237 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VE) +#define BOARD_MKS_EAGLE 5238 // MKS Eagle (STM32F407VE) +#define BOARD_ARTILLERY_RUBY 5239 // Artillery Ruby (STM32F401RC) +#define BOARD_FYSETC_SPIDER_V2_2 5240 // FYSETC Spider V2.2 (STM32F446VE) +#define BOARD_CREALITY_V24S1_301F4 5241 // Creality v2.4.S1_301F4 (STM32F401RC) as found in the Ender-3 S1 F4 +#define BOARD_OPULO_LUMEN_REV4 5242 // Opulo Lumen PnP Controller REV4 (STM32F407VE / STM32F407VG) +#define BOARD_FYSETC_SPIDER_KING407 5243 // FYSETC Spider King407 (STM32F407ZG) +#define BOARD_MKS_SKIPR_V1 5244 // MKS SKIPR v1.0 all-in-one board (STM32F407VE) +#define BOARD_TRONXY_V10 5245 // TRONXY V10 (STM32F446ZE) + +// +// ARM Cortex-M7 +// + +#define BOARD_REMRAM_V1 6000 // RemRam v1 +#define BOARD_TEENSY41 6001 // Teensy 4.1 +#define BOARD_T41U5XBB 6002 // T41U5XBB Teensy 4.1 breakout board +#define BOARD_NUCLEO_F767ZI 6003 // ST NUCLEO-F767ZI Dev Board +#define BOARD_BTT_SKR_SE_BX_V2 6004 // BigTreeTech SKR SE BX V2.0 (STM32H743II) +#define BOARD_BTT_SKR_SE_BX_V3 6005 // BigTreeTech SKR SE BX V3.0 (STM32H743II) +#define BOARD_BTT_SKR_V3_0 6006 // BigTreeTech SKR V3.0 (STM32H743VG) +#define BOARD_BTT_SKR_V3_0_EZ 6007 // BigTreeTech SKR V3.0 EZ (STM32H743VG) +#define BOARD_BTT_OCTOPUS_MAX_EZ_V1_0 6008 // BigTreeTech Octopus Max EZ V1.0 (STM32H723VE / STM32H723ZE) // // Espressif ESP32 WiFi // -#define BOARD_ESPRESSIF_ESP32 6000 // Generic ESP32 -#define BOARD_MRR_ESPA 6001 // MRR ESPA based on ESP32 (native pins only) -#define BOARD_MRR_ESPE 6002 // MRR ESPE based on ESP32 (with I2S stepper stream) -#define BOARD_E4D_BOX 6003 // E4d@BOX -#define BOARD_RESP32_CUSTOM 6004 // Rutilea ESP32 custom board -#define BOARD_FYSETC_E4 6005 // FYSETC E4 -#define BOARD_PANDA_ZHU 6006 // Panda_ZHU -#define BOARD_PANDA_M4 6007 // Panda_M4 -#define BOARD_MKS_TINYBEE 6008 // MKS TinyBee based on ESP32 (with I2S stepper stream) -#define BOARD_ENWI_ESPNP 6009 // enwi ESPNP based on ESP32 (with I2S stepper stream) +#define BOARD_ESPRESSIF_ESP32 7000 // Generic ESP32 +#define BOARD_MRR_ESPA 7001 // MRR ESPA based on ESP32 (native pins only) +#define BOARD_MRR_ESPE 7002 // MRR ESPE based on ESP32 (with I2S stepper stream) +#define BOARD_E4D_BOX 7003 // E4d@BOX +#define BOARD_RESP32_CUSTOM 7004 // Rutilea ESP32 custom board +#define BOARD_FYSETC_E4 7005 // FYSETC E4 +#define BOARD_PANDA_ZHU 7006 // Panda_ZHU +#define BOARD_PANDA_M4 7007 // Panda_M4 +#define BOARD_MKS_TINYBEE 7008 // MKS TinyBee based on ESP32 (with I2S stepper stream) +#define BOARD_ENWI_ESPNP 7009 // enwi ESPNP based on ESP32 (with I2S stepper stream) + +// +// SAMD51 ARM Cortex-M4 +// + +#define BOARD_AGCM4_RAMPS_144 7100 // RAMPS 1.4.4 +#define BOARD_BRICOLEMON_V1_0 7101 // Bricolemon +#define BOARD_BRICOLEMON_LITE_V1_0 7102 // Bricolemon Lite // -// SAMD51 ARM Cortex M4 +// SAMD21 ARM Cortex-M4 // -#define BOARD_AGCM4_RAMPS_144 6100 // RAMPS 1.4.4 -#define BOARD_BRICOLEMON_V1_0 6101 // Bricolemon -#define BOARD_BRICOLEMON_LITE_V1_0 6102 // Bricolemon Lite +#define BOARD_MINITRONICS20 7103 // Minitronics v2.0 // // Custom board @@ -465,7 +499,7 @@ // Simulations // -#define BOARD_LINUX_RAMPS 9999 +#define BOARD_SIMULATED 9999 #define _MB_1(B) (defined(BOARD_##B) && MOTHERBOARD==BOARD_##B) #define MB(V...) DO(MB,||,V) diff --git a/Marlin/src/core/drivers.h b/Marlin/src/core/drivers.h index 7f9da909b248..72a7d1f4b7eb 100644 --- a/Marlin/src/core/drivers.h +++ b/Marlin/src/core/drivers.h @@ -30,10 +30,6 @@ #define _A5984 0x5984 #define _DRV8825 0x8825 #define _LV8729 0x8729 -#define _L6470 0x6470 -#define _L6474 0x6474 -#define _L6480 0x6480 -#define _POWERSTEP01 0xF00D #define _TB6560 0x6560 #define _TB6600 0x6600 #define _TMC2100 0x2100 @@ -129,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) \ @@ -193,16 +191,3 @@ #if HAS_DRIVER(TMC26X) #define HAS_TMC26X 1 #endif - -// -// L64XX Stepper Drivers -// - -#if HAS_DRIVER(L6470) || HAS_DRIVER(L6474) || HAS_DRIVER(L6480) || HAS_DRIVER(POWERSTEP01) - #define HAS_L64XX 1 -#endif -#if HAS_L64XX && !HAS_DRIVER(L6474) - #define HAS_L64XX_NOT_L6474 1 -#endif - -#define AXIS_IS_L64XX(A) (AXIS_DRIVER_TYPE_##A(L6470) || AXIS_DRIVER_TYPE_##A(L6474) || AXIS_DRIVER_TYPE_##A(L6480) || AXIS_DRIVER_TYPE_##A(POWERSTEP01)) diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index 16d7b1bf663e..58d9eb5848a5 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: " @@ -191,6 +192,7 @@ #define STR_ERR_LONG_EXTRUDE_STOP " too long extrusion prevented" #define STR_ERR_HOTEND_TOO_COLD "Hotend too cold" #define STR_ERR_EEPROM_WRITE "Error writing to EEPROM!" +#define STR_ERR_EEPROM_CORRUPT "EEPROM Corrupt" #define STR_FILAMENT_CHANGE_HEAT_LCD "Press button to heat nozzle" #define STR_FILAMENT_CHANGE_INSERT_LCD "Insert filament and press button" @@ -227,10 +229,6 @@ #define STR_PID_DEBUG " PID_DEBUG " #define STR_PID_DEBUG_INPUT ": Input " #define STR_PID_DEBUG_OUTPUT " Output " -#define STR_PID_DEBUG_PTERM " pTerm " -#define STR_PID_DEBUG_ITERM " iTerm " -#define STR_PID_DEBUG_DTERM " dTerm " -#define STR_PID_DEBUG_CTERM " cTerm " #define STR_INVALID_EXTRUDER_NUM " - Invalid extruder number !" #define STR_MPC_AUTOTUNE "MPC Autotune" #define STR_MPC_AUTOTUNE_START " start for " STR_E diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index b7d1ac916eee..fce7d4eb763f 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 @@ -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 @@ -628,7 +634,9 @@ #define DEFER4(M) M EMPTY EMPTY EMPTY EMPTY()()()() // Force define expansion -#define EVAL(V...) EVAL16(V) +#define EVAL EVAL16 +#define EVAL4096(V...) EVAL2048(EVAL2048(V)) +#define EVAL2048(V...) EVAL1024(EVAL1024(V)) #define EVAL1024(V...) EVAL512(EVAL512(V)) #define EVAL512(V...) EVAL256(EVAL256(V)) #define EVAL256(V...) EVAL128(EVAL128(V)) @@ -644,8 +652,8 @@ #define IS_PROBE(V...) SECOND(V, 0) // Get the second item passed, or 0 #define PROBE() ~, 1 // Second item will be 1 if this is passed #define _NOT_0 PROBE() -#define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'. -#define _BOOL(x) NOT(NOT(x)) // NOT('0') gets '0'. Anything else gets '1'. +#define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'. +#define _BOOL(x) NOT(NOT(x)) // _BOOL('0') gets '0'. Anything else gets '1'. #define IF_ELSE(TF) _IF_ELSE(_BOOL(TF)) #define _IF_ELSE(TF) _CAT(_IF_, TF) @@ -659,7 +667,6 @@ #define HAS_ARGS(V...) _BOOL(FIRST(_END_OF_ARGUMENTS_ V)()) #define _END_OF_ARGUMENTS_() 0 - // Simple Inline IF Macros, friendly to use in other macro definitions #define IF(O, A, B) ((O) ? (A) : (B)) #define IF_0(O, A) IF(O, A, 0) @@ -707,10 +714,11 @@ ( DEFER2(__RREPEAT2)()(ADD1(_RPT_I),SUB1(_RPT_N),_RPT_OP,V) ) \ ( /* Do nothing */ ) #define __RREPEAT2() _RREPEAT2 -#define RREPEAT_S(S,N,OP) EVAL1024(_RREPEAT(S,SUB##S(N),OP)) -#define RREPEAT(N,OP) RREPEAT_S(0,N,OP) -#define RREPEAT2_S(S,N,OP,V...) EVAL1024(_RREPEAT2(S,SUB##S(N),OP,V)) -#define RREPEAT2(N,OP,V...) RREPEAT2_S(0,N,OP,V) +#define RREPEAT_S(S,N,OP) EVAL1024(_RREPEAT(S,SUB##S(N),OP)) +#define RREPEAT(N,OP) RREPEAT_S(0,N,OP) +#define RREPEAT_1(N,OP) RREPEAT_S(1,INCREMENT(N),OP) +#define RREPEAT2_S(S,N,OP,V...) EVAL1024(_RREPEAT2(S,SUB##S(N),OP,V)) +#define RREPEAT2(N,OP,V...) RREPEAT2_S(0,N,OP,V) // Call OP(A) with each item as an argument #define _MAP(_MAP_OP,A,V...) \ @@ -731,3 +739,9 @@ #define __MAPLIST() _MAPLIST #define MAPLIST(OP,V...) EVAL(_MAPLIST(OP,V)) + +// Temperature Sensor Config +#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) diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 49e792110efc..64704c1e6cb4 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -72,8 +72,8 @@ void serial_print_P(PGM_P str) { while (const char c = pgm_read_byte(str++)) SERIAL_CHAR(c); } -void serial_echo_start() { static PGMSTR(echomagic, "echo:"); serial_print_P(echomagic); } -void serial_error_start() { static PGMSTR(errormagic, "Error:"); serial_print_P(errormagic); } +void serial_echo_start() { serial_print(F("echo:")); } +void serial_error_start() { serial_print(F("Error:")); } void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); } @@ -85,11 +85,6 @@ void serial_offset(const_float_t v, const uint8_t sp/*=0*/) { SERIAL_DECIMAL(v); } -void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post/*=nullptr*/) { - if (pre) serial_print(pre); - serial_print(onoff ? on : off); - if (post) serial_print(post); -} void serialprint_onoff(const bool onoff) { serial_print(onoff ? F(STR_ON) : F(STR_OFF)); } void serialprintln_onoff(const bool onoff) { serialprint_onoff(onoff); SERIAL_EOL(); } void serialprint_truefalse(const bool tf) { serial_print(tf ? F("true") : F("false")); } diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index c19bc087833d..a741d4b1e4d0 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -327,7 +327,12 @@ inline void serial_echolnpair(FSTR_P const fstr, T v) { serial_echolnpair_P(FTOP void serial_echo_start(); void serial_error_start(); -void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post=nullptr); +inline void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post=nullptr) { + if (pre) serial_print(pre); + if (onoff && on) serial_print(on); + if (!onoff && off) serial_print(off); + if (post) serial_print(post); +} void serialprint_onoff(const bool onoff); void serialprintln_onoff(const bool onoff); void serialprint_truefalse(const bool tf); @@ -337,8 +342,8 @@ void serial_offset(const_float_t v, const uint8_t sp=0); // For v==0 draw space void print_bin(const uint16_t val); void print_pos(NUM_AXIS_ARGS(const_float_t), FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr); -inline void print_pos(const xyz_pos_t &xyz, FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr) { - print_pos(NUM_AXIS_ELEM(xyz), prefix, suffix); +inline void print_pos(const xyze_pos_t &xyze, FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr) { + print_pos(NUM_AXIS_ELEM(xyze), prefix, suffix); } #define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, F(" " STRINGIFY(VAR) "="), F(" : " SUFFIX "\n")); }while(0) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index fc3ef178b6df..f1fae85b5ca4 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) @@ -113,8 +115,8 @@ struct Flags<1> { void set(const int) { b = true; } void clear(const int) { b = false; } bool test(const int) const { return b; } - bool operator[](const int) { return b; } - bool operator[](const int) const { return b; } + bool& operator[](const int) { return b; } + bool operator[](const int) const { return b; } int size() const { return sizeof(b); } }; @@ -226,8 +228,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 @@ -307,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. @@ -347,6 +349,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 small() const { return _MIN(x, y); } + // Largest element + FI T large() const { return _MAX(x, y); } // Explicit copy and copies with conversion FI XYval copy() const { return *this; } @@ -405,18 +411,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; } @@ -424,27 +430,24 @@ struct XYval { FI XYval& operator+=(const XYval &rs) { x += rs.x; y += rs.y; return *this; } FI XYval& operator-=(const XYval &rs) { x -= rs.x; y -= rs.y; return *this; } FI XYval& operator*=(const XYval &rs) { x *= rs.x; y *= rs.y; return *this; } - FI XYval& operator+=(const XYZval &rs) { x += rs.x; y += rs.y; return *this; } - FI XYval& operator-=(const XYZval &rs) { x -= rs.x; y -= rs.y; return *this; } - FI XYval& operator*=(const XYZval &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 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 XYval &rs) { x /= rs.x; y /= rs.y; return *this; } + FI XYval& operator+=(const XYZval &rs) { NUM_AXIS_CODE(x += rs.x, y += rs.y,,,,,,, ); return *this; } + FI XYval& operator-=(const XYZval &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y,,,,,,, ); return *this; } + FI XYval& operator*=(const XYZval &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y,,,,,,, ); return *this; } + FI XYval& operator/=(const XYZval &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.y,,,,,,, ); return *this; } + FI XYval& operator+=(const XYZEval &rs) { NUM_AXIS_CODE(x += rs.x, y += rs.y,,,,,,, ); return *this; } + FI XYval& operator-=(const XYZEval &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y,,,,,,, ); return *this; } + FI XYval& operator*=(const XYZEval &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y,,,,,,, ); return *this; } + FI XYval& operator/=(const XYZEval &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.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) { 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 NUM_AXIS_GANG(x == rs.x, && y == rs.y,,,,,,, ); } + FI bool operator==(const XYZval &rs) const { return NUM_AXIS_GANG(x == rs.x, && y == rs.y,,,,,,, ); } + FI bool operator==(const XYZEval &rs) const { return NUM_AXIS_GANG(x == rs.x, && y == rs.y,,,,,,, ); } 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); } @@ -465,15 +468,9 @@ struct XYZval { FI void reset() { NUM_AXIS_GANG(x =, y =, z =, i =, j =, k =, u =, v =, w =) 0; } // Setters taking struct types and arrays - FI void set(const T px) { x = px; } - FI void set(const T px, const T py) { x = px; y = py; } - FI void set(const XYval pxy) { x = pxy.x; y = pxy.y; } - FI void set(const XYval pxy, const T pz) { NUM_AXIS_CODE(x = pxy.x, y = pxy.y, z = pz, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP); } - FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; } - #if HAS_Z_AXIS - FI void set(const T (&arr)[NUM_AXES]) { NUM_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5], u = arr[6], v = arr[7], w = arr[8]); } - FI void set(NUM_AXIS_ARGS(const T)) { NUM_AXIS_CODE(a = x, b = y, c = z, _i = i, _j = j, _k = k, _u = u, _v = v, _w = w ); } - #endif + FI void set(const XYval pxy) { NUM_AXIS_CODE(x = pxy.x, y = pxy.y,,,,,,,); } + FI void set(const XYval pxy, const T pz) { NUM_AXIS_CODE(x = pxy.x, y = pxy.y, z = pz,,,,,,); } + FI void set(const T (&arr)[NUM_AXES]) { NUM_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5], u = arr[6], v = arr[7], w = arr[8]); } #if LOGICAL_AXES > NUM_AXES FI void set(const T (&arr)[LOGICAL_AXES]) { NUM_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5], u = arr[6], v = arr[7], w = arr[8]); } FI void set(LOGICAL_AXIS_ARGS(const T)) { NUM_AXIS_CODE(a = x, b = y, c = z, _i = i, _j = j, _k = k, _u = u, _v = v, _w = w ); } @@ -481,6 +478,17 @@ struct XYZval { FI void set(const T (&arr)[DISTINCT_AXES]) { NUM_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5], u = arr[6], v = arr[7], w = arr[8]); } #endif #endif + + // Setter for all individual args + FI void set(NUM_AXIS_ARGS(const T)) { NUM_AXIS_CODE(a = x, b = y, c = z, _i = i, _j = j, _k = k, _u = u, _v = v, _w = w); } + + // Setters with fewer elements leave the rest untouched + #if HAS_Y_AXIS + FI void set(const T px) { x = px; } + #endif + #if HAS_Z_AXIS + FI void set(const T px, const T py) { x = px; y = py; } + #endif #if HAS_I_AXIS FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } #endif @@ -494,10 +502,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 @@ -506,6 +514,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 small() const { return _MIN(NUM_AXIS_LIST(x, y, z, i, j, k, u, v, w)); } + // Largest element + 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; } @@ -541,14 +553,14 @@ struct XYZval { FI XYZval& operator= (const XYZEval &rs) { set(NUM_AXIS_ELEM(rs)); return *this; } // Override other operators to get intuitive behaviors - FI XYZval operator+ (const XYval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; } - FI XYZval operator+ (const XYval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; } - FI XYZval operator- (const XYval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; } - FI XYZval operator- (const XYval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; } - FI XYZval operator* (const XYval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; } - FI XYZval operator* (const XYval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; } - FI XYZval operator/ (const XYval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; } - FI XYZval operator/ (const XYval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; } + FI XYZval operator+ (const XYval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y,,,,,,, ); return ls; } + FI XYZval operator+ (const XYval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y,,,,,,, ); return ls; } + FI XYZval operator- (const XYval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y,,,,,,, ); return ls; } + FI XYZval operator- (const XYval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y,,,,,,, ); return ls; } + FI XYZval operator* (const XYval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y,,,,,,, ); return ls; } + FI XYZval operator* (const XYval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y,,,,,,, ); return ls; } + FI XYZval operator/ (const XYval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y,,,,,,, ); return ls; } + FI XYZval operator/ (const XYval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y,,,,,,, ); return ls; } FI XYZval 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 XYZval 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 XYZval 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; } @@ -565,26 +577,26 @@ 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; } // Modifier operators - FI XYZval& operator+=(const XYval &rs) { NUM_AXIS_CODE(x += rs.x, y += rs.y, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP ); return *this; } - FI XYZval& operator-=(const XYval &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP ); return *this; } - FI XYZval& operator*=(const XYval &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP ); return *this; } - FI XYZval& operator/=(const XYval &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.y, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP ); return *this; } + FI XYZval& operator+=(const XYval &rs) { NUM_AXIS_CODE(x += rs.x, y += rs.y,,,,,,, ); return *this; } + FI XYZval& operator-=(const XYval &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y,,,,,,, ); return *this; } + FI XYZval& operator*=(const XYval &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y,,,,,,, ); return *this; } + FI XYZval& operator/=(const XYval &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.y,,,,,,, ); return *this; } FI XYZval& 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 XYZval& 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 XYZval& 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; } @@ -593,15 +605,13 @@ 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) { 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); } }; @@ -618,9 +628,31 @@ struct XYZEval { // Reset all to 0 FI void reset() { LOGICAL_AXIS_GANG(e =, x =, y =, z =, i =, j =, k =, u =, v =, w =) 0; } - // Setters for some number of linear axes, not all - FI void set(const T px) { x = px; } - FI void set(const T px, const T py) { x = px; y = py; } + // Setters taking struct types and arrays + FI void set(const XYval pxy) { x = pxy.x; OPTCODE(HAS_Y_AXIS, y = pxy.y) } + FI void set(const XYZval pxyz) { set(NUM_AXIS_ELEM(pxyz)); } + FI void set(const XYval pxy, const T pz) { set(pxy); TERN_(HAS_Z_AXIS, z = pz); } + FI void set(const T (&arr)[NUM_AXES]) { NUM_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5], u = arr[6], v = arr[7], w = arr[8]); } + #if LOGICAL_AXES > NUM_AXES + FI void set(const T (&arr)[LOGICAL_AXES]) { LOGICAL_AXIS_CODE(e = arr[LOGICAL_AXES-1], x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5], u = arr[6], v = arr[7], w = arr[8]); } + FI void set(const XYval pxy, const T pz, const T pe) { set(pxy, pz); e = pe; } + FI void set(const XYZval pxyz, const T pe) { set(pxyz); e = pe; } + FI void set(LOGICAL_AXIS_ARGS(const T)) { LOGICAL_AXIS_CODE(_e = e, a = x, b = y, c = z, _i = i, _j = j, _k = k, _u = u, _v = v, _w = w); } + #if DISTINCT_AXES > LOGICAL_AXES + FI void set(const T (&arr)[DISTINCT_AXES]) { LOGICAL_AXIS_CODE(e = arr[LOGICAL_AXES-1], x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5], u = arr[6], v = arr[7], w = arr[8]); } + #endif + #endif + + // Setter for all individual args + FI void set(NUM_AXIS_ARGS(const T)) { NUM_AXIS_CODE(a = x, b = y, c = z, _i = i, _j = j, _k = k, _u = u, _v = v, _w = w); } + + // Setters with fewer elements leave the rest untouched + #if HAS_Y_AXIS + FI void set(const T px) { x = px; } + #endif + #if HAS_Z_AXIS + FI void set(const T px, const T py) { x = px; y = py; } + #endif #if HAS_I_AXIS FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } #endif @@ -634,31 +666,22 @@ 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; } - #endif - - // Setters taking struct types and arrays - FI void set(const XYval pxy) { x = pxy.x; y = pxy.y; } - FI void set(const XYZval pxyz) { set(NUM_AXIS_ELEM(pxyz)); } - #if HAS_Z_AXIS - FI void set(NUM_AXIS_ARGS(const T)) { NUM_AXIS_CODE(a = x, b = y, c = z, _i = i, _j = j, _k = k, _u = u, _v = v, _w = w); } - #endif - FI void set(const XYval pxy, const T pz) { set(pxy); TERN_(HAS_Z_AXIS, z = pz); } - #if LOGICAL_AXES > NUM_AXES - FI void set(const XYval pxy, const T pz, const T pe) { set(pxy, pz); e = pe; } - FI void set(const XYZval pxyz, const T pe) { set(pxyz); e = pe; } - FI void set(LOGICAL_AXIS_ARGS(const T)) { LOGICAL_AXIS_CODE(_e = e, a = x, b = y, c = z, _i = i, _j = j, _k = k, _u = u, _v = v, _w = w); } + 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 - 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)); } + // Largest element + 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; } @@ -684,76 +707,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(LIST_N_1(NUM_AXES, 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) { NUM_AXIS_CODE(x += rs.x, y += rs.y,,,,,,, ); return *this; } + FI XYZEval& operator-=(const XYval &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y,,,,,,, ); return *this; } + FI XYZEval& operator*=(const XYval &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y,,,,,,, ); return *this; } + FI XYZEval& operator/=(const XYval &rs) { NUM_AXIS_CODE(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) { 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 XYZval &rs) { return !operator==(rs); } - FI bool operator!=(const XYZval &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/core/utility.cpp b/Marlin/src/core/utility.cpp index 84e4c1f69696..64f083e19718 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -29,10 +29,10 @@ void safe_delay(millis_t ms) { while (ms > 50) { ms -= 50; delay(50); - thermalManager.manage_heater(); + thermalManager.task(); } delay(ms); - thermalManager.manage_heater(); // This keeps us safe if too many small safe_delay() calls are made + thermalManager.task(); // This keeps us safe if too many small safe_delay() calls are made } // A delay to provide brittle hosts time to receive bytes @@ -51,7 +51,7 @@ void safe_delay(millis_t ms) { #include "../module/probe.h" #include "../module/motion.h" - #include "../module/stepper.h" + #include "../module/planner.h" #include "../libs/numtostr.h" #include "../feature/bedlevel/bedlevel.h" @@ -70,6 +70,7 @@ void safe_delay(millis_t ms) { TERN_(NOZZLE_AS_PROBE, "NOZZLE_AS_PROBE") TERN_(FIX_MOUNTED_PROBE, "FIX_MOUNTED_PROBE") TERN_(HAS_Z_SERVO_PROBE, TERN(BLTOUCH, "BLTOUCH", "SERVO PROBE")) + TERN_(BD_SENSOR, "BD_SENSOR") TERN_(TOUCH_MI_PROBE, "TOUCH_MI_PROBE") TERN_(Z_PROBE_SLED, "Z_PROBE_SLED") TERN_(Z_PROBE_ALLEN_KEY, "Z_PROBE_ALLEN_KEY") diff --git a/Marlin/src/core/utility.h b/Marlin/src/core/utility.h index 10c8201610ea..2731e62b6754 100644 --- a/Marlin/src/core/utility.h +++ b/Marlin/src/core/utility.h @@ -59,6 +59,11 @@ void safe_delay(millis_t ms); // Delay ensuring that temperatures are #define log_machine_info() NOOP #endif +/** + * A restorer instance remembers a variable's value before setting a + * new value, then restores the old value when it goes out of scope. + * Put operator= on your type to get extended behavior on value change. + */ template class restorer { T& ref_; diff --git a/Marlin/src/feature/babystep.cpp b/Marlin/src/feature/babystep.cpp index 54ad9588f445..2e3d6a9fd20b 100644 --- a/Marlin/src/feature/babystep.cpp +++ b/Marlin/src/feature/babystep.cpp @@ -54,6 +54,18 @@ void Babystep::add_mm(const AxisEnum axis, const_float_t mm) { add_steps(axis, mm * planner.settings.axis_steps_per_mm[axis]); } +#if ENABLED(BD_SENSOR) + void Babystep::set_mm(const AxisEnum axis, const_float_t mm) { + //if (DISABLED(BABYSTEP_WITHOUT_HOMING) && axes_should_home(_BV(axis))) return; + const int16_t distance = mm * planner.settings.axis_steps_per_mm[axis]; + accum = distance; // Count up babysteps for the UI + steps[BS_AXIS_IND(axis)] = distance; + TERN_(BABYSTEP_DISPLAY_TOTAL, axis_total[BS_TOTAL_IND(axis)] = distance); + TERN_(BABYSTEP_ALWAYS_AVAILABLE, gcode.reset_stepper_timeout()); + TERN_(INTEGRATED_BABYSTEPPING, if (has_steps()) stepper.initiateBabystepping()); + } +#endif + void Babystep::add_steps(const AxisEnum axis, const int16_t distance) { if (DISABLED(BABYSTEP_WITHOUT_HOMING) && axes_should_home(_BV(axis))) return; diff --git a/Marlin/src/feature/babystep.h b/Marlin/src/feature/babystep.h index 5693afb4fc5b..bbf0c5a26060 100644 --- a/Marlin/src/feature/babystep.h +++ b/Marlin/src/feature/babystep.h @@ -63,6 +63,10 @@ class Babystep { static void add_steps(const AxisEnum axis, const int16_t distance); static void add_mm(const AxisEnum axis, const_float_t mm); + #if ENABLED(BD_SENSOR) + static void set_mm(const AxisEnum axis, const_float_t mm); + #endif + static bool has_steps() { return steps[BS_AXIS_IND(X_AXIS)] || steps[BS_AXIS_IND(Y_AXIS)] || steps[BS_AXIS_IND(Z_AXIS)]; } diff --git a/Marlin/src/feature/bedlevel/bdl/bdl.cpp b/Marlin/src/feature/bedlevel/bdl/bdl.cpp new file mode 100644 index 000000000000..1a27011a4b8f --- /dev/null +++ b/Marlin/src/feature/bedlevel/bdl/bdl.cpp @@ -0,0 +1,196 @@ +/** + * 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(BD_SENSOR) + +#include "../../../MarlinCore.h" +#include "../../../gcode/gcode.h" +#include "../../../module/settings.h" +#include "../../../module/motion.h" +#include "../../../module/planner.h" +#include "../../../module/stepper.h" +#include "../../../module/probe.h" +#include "../../../module/temperature.h" +#include "../../../module/endstops.h" +#include "../../babystep.h" + +// I2C software Master library for segment bed heating and bed distance sensor +#include + +#include "bdl.h" +BDS_Leveling bdl; + +//#define DEBUG_OUT_BD + +// M102 S-5 Read raw Calibrate data +// M102 S-6 Start Calibrate +// M102 S4 Set the adjustable Z height value (e.g., 'M102 S4' means it will do adjusting while the Z height <= 0.4mm , disable with 'M102 S0'.) +// M102 S-1 Read sensor information + +#define MAX_BD_HEIGHT 4.0f +#define CMD_START_READ_CALIBRATE_DATA 1017 +#define CMD_END_READ_CALIBRATE_DATA 1018 +#define CMD_START_CALIBRATE 1019 +#define CMD_END_CALIBRATE 1021 +#define CMD_READ_VERSION 1016 + +I2C_SegmentBED BD_I2C_SENSOR; + +#define BD_SENSOR_I2C_ADDR 0x3C + +int8_t BDS_Leveling::config_state; +uint8_t BDS_Leveling::homing; + +void BDS_Leveling::echo_name() { SERIAL_ECHOPGM("Bed Distance Leveling"); } + +void BDS_Leveling::init(uint8_t _sda, uint8_t _scl, uint16_t delay_s) { + int ret = BD_I2C_SENSOR.i2c_init(_sda, _scl, BD_SENSOR_I2C_ADDR, delay_s); + if (ret != 1) SERIAL_ECHOLNPGM("BD_I2C_SENSOR Init Fail return code:", ret); + config_state = 0; +} + +float BDS_Leveling::read() { + const uint16_t tmp = BD_I2C_SENSOR.BD_i2c_read(); + float BD_z = NAN; + if (BD_I2C_SENSOR.BD_Check_OddEven(tmp) && (tmp & 0x3FF) < 1020) + BD_z = (tmp & 0x3FF) / 100.0f; + return BD_z; +} + +void BDS_Leveling::process() { + //if (config_state == 0) return; + static millis_t next_check_ms = 0; // starting at T=0 + static float z_pose = 0.0f; + const millis_t ms = millis(); + if (ELAPSED(ms, next_check_ms)) { // timed out (or first run) + next_check_ms = ms + (config_state < 0 ? 1000 : 100); // check at 1Hz or 10Hz + + unsigned short tmp = 0; + const float cur_z = planner.get_axis_position_mm(Z_AXIS); //current_position.z + static float old_cur_z = cur_z, + old_buf_z = current_position.z; + + tmp = BD_I2C_SENSOR.BD_i2c_read(); + if (BD_I2C_SENSOR.BD_Check_OddEven(tmp) && (tmp & 0x3FF) < 1020) { + 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 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); + //endstops.update(); + } + else + stepper.set_directions(); + + #if ENABLED(DEBUG_OUT_BD) + SERIAL_ECHOLNPGM("BD:", tmp & 0x3FF, ", Z:", cur_z, "|", current_position.z); + if (BD_I2C_SENSOR.BD_Check_OddEven(tmp) == 0) SERIAL_ECHOLNPGM("errorCRC"); + #endif + + if ((tmp & 0x3FF) > 1020) { + BD_I2C_SENSOR.BD_i2c_stop(); + safe_delay(10); + } + + // read raw calibrate data + if (config_state == -5) { + BD_I2C_SENSOR.BD_i2c_write(CMD_START_READ_CALIBRATE_DATA); + safe_delay(1000); + + for (int i = 0; i < MAX_BD_HEIGHT * 10; i++) { + tmp = BD_I2C_SENSOR.BD_i2c_read(); + SERIAL_ECHOLNPGM("Calibrate data:", i, ",", tmp & 0x3FF, ", check:", BD_I2C_SENSOR.BD_Check_OddEven(tmp)); + safe_delay(500); + } + config_state = 0; + BD_I2C_SENSOR.BD_i2c_write(CMD_END_READ_CALIBRATE_DATA); + safe_delay(500); + } + else if (config_state <= -6) { // Start Calibrate + safe_delay(100); + if (config_state == -6) { + //BD_I2C_SENSOR.BD_i2c_write(1019); // begin calibrate + //delay(1000); + gcode.stepper_inactive_time = SEC_TO_MS(60 * 5); + gcode.process_subcommands_now(F("M17 Z")); + gcode.process_subcommands_now(F("G1 Z0.0")); + z_pose = 0; + safe_delay(1000); + BD_I2C_SENSOR.BD_i2c_write(CMD_START_CALIBRATE); // Begin calibrate + SERIAL_ECHOLNPGM("Begin calibrate"); + safe_delay(2000); + config_state = -7; + } + else if (planner.get_axis_position_mm(Z_AXIS) < 10.0f) { + if (z_pose >= MAX_BD_HEIGHT) { + BD_I2C_SENSOR.BD_i2c_write(CMD_END_CALIBRATE); // End calibrate + SERIAL_ECHOLNPGM("End calibrate data"); + z_pose = 7; + config_state = 0; + safe_delay(1000); + } + else { + float tmp_k = 0; + char tmp_1[30]; + sprintf_P(tmp_1, PSTR("G1 Z%d.%d"), int(z_pose), int(int(z_pose * 10) % 10)); + gcode.process_subcommands_now(tmp_1); + + SERIAL_ECHO(tmp_1); + SERIAL_ECHOLNPGM(" ,Z:", current_position.z); + + while (tmp_k < (z_pose - 0.1f)) { + tmp_k = planner.get_axis_position_mm(Z_AXIS); + safe_delay(1); + } + safe_delay(800); + tmp = (z_pose + 0.0001f) * 10; + BD_I2C_SENSOR.BD_i2c_write(tmp); + SERIAL_ECHOLNPGM("w:", tmp, ",Zpose:", z_pose); + z_pose += 0.1001f; + //queue.enqueue_now_P(PSTR("G90")); + } + } + } + } +} + +#endif // BD_SENSOR diff --git a/Marlin/src/feature/bedlevel/bdl/bdl.h b/Marlin/src/feature/bedlevel/bdl/bdl.h new file mode 100644 index 000000000000..6307b1ab28f8 --- /dev/null +++ b/Marlin/src/feature/bedlevel/bdl/bdl.h @@ -0,0 +1,36 @@ +/** + * 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 + +class BDS_Leveling { +public: + static int8_t config_state; + static uint8_t homing; + static void echo_name(); + static void init(uint8_t _sda, uint8_t _scl, uint16_t delay_s); + static void process(); + static float read(); +}; + +extern BDS_Leveling bdl; diff --git a/Marlin/src/feature/bedlevel/bedlevel.cpp b/Marlin/src/feature/bedlevel/bedlevel.cpp index 1ca9696a3a30..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()); @@ -75,9 +76,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(); @@ -154,7 +155,7 @@ void reset_bed_level() { #endif LOOP_L_N(x, sx) { SERIAL_CHAR(' '); - const float offset = values[x * sx + y]; + const float offset = values[x * sy + y]; if (!isnan(offset)) { if (offset >= 0) SERIAL_CHAR('+'); SERIAL_ECHO_F(offset, int(precision)); diff --git a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h index 1a8e693e8180..0193b4f43e5b 100644 --- a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h +++ b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h @@ -32,8 +32,8 @@ enum MeshLevelingState : char { MeshReset // G29 S5 }; -#define MESH_X_DIST (float(MESH_MAX_X - (MESH_MIN_X)) / (GRID_MAX_CELLS_X)) -#define MESH_Y_DIST (float(MESH_MAX_Y - (MESH_MIN_Y)) / (GRID_MAX_CELLS_Y)) +#define MESH_X_DIST (float((MESH_MAX_X) - (MESH_MIN_X)) / (GRID_MAX_CELLS_X)) +#define MESH_Y_DIST (float((MESH_MAX_Y) - (MESH_MIN_Y)) / (GRID_MAX_CELLS_Y)) class mesh_bed_leveling { public: @@ -109,7 +109,7 @@ class mesh_bed_leveling { static float get_z_correction(const xy_pos_t &pos) { const xy_int8_t ind = cell_indexes(pos); const float x1 = index_to_xpos[ind.x], x2 = index_to_xpos[ind.x+1], - y1 = index_to_xpos[ind.y], y2 = index_to_xpos[ind.y+1], + y1 = index_to_ypos[ind.y], y2 = index_to_ypos[ind.y+1], z1 = calc_z0(pos.x, x1, z_values[ind.x][ind.y ], x2, z_values[ind.x+1][ind.y ]), z2 = calc_z0(pos.x, x1, z_values[ind.x][ind.y+1], x2, z_values[ind.x+1][ind.y+1]), zf = calc_z0(pos.y, y1, z1, y2, z2); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 2aa50be34d26..b7ee6aeef8a2 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -59,7 +59,7 @@ void unified_bed_leveling::report_current_mesh() { void unified_bed_leveling::report_state() { echo_name(); - SERIAL_ECHO_TERNARY(planner.leveling_active, " System v" UBL_VERSION " ", "", "in", "active\n"); + serial_ternary(planner.leveling_active, F(" System v" UBL_VERSION " "), nullptr, F("in"), F("active\n")); serial_delay(50); } @@ -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 diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index a7103d6e18c4..05a937c9853d 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -38,8 +38,8 @@ enum MeshPointType : char { INVALID, REAL, SET_IN_BITMAP, CLOSEST }; struct mesh_index_pair; -#define MESH_X_DIST (float(MESH_MAX_X - (MESH_MIN_X)) / (GRID_MAX_CELLS_X)) -#define MESH_Y_DIST (float(MESH_MAX_Y - (MESH_MIN_Y)) / (GRID_MAX_CELLS_Y)) +#define MESH_X_DIST (float((MESH_MAX_X) - (MESH_MIN_X)) / (GRID_MAX_CELLS_X)) +#define MESH_Y_DIST (float((MESH_MAX_Y) - (MESH_MIN_Y)) / (GRID_MAX_CELLS_Y)) #if ENABLED(OPTIMIZED_MESH_STORAGE) typedef int16_t mesh_store_t[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; @@ -264,9 +264,9 @@ class unified_bed_leveling { return UBL_Z_RAISE_WHEN_OFF_MESH; #endif - const uint8_t mx = _MIN(cx, (GRID_MAX_POINTS_X) - 2) + 1, my = _MIN(cy, (GRID_MAX_POINTS_Y) - 2) + 1, - x0 = get_mesh_x(cx), x1 = get_mesh_x(cx + 1); - const float z1 = calc_z0(rx0, x0, z_values[cx][cy], x1, z_values[mx][cy]), + const uint8_t mx = _MIN(cx, (GRID_MAX_POINTS_X) - 2) + 1, my = _MIN(cy, (GRID_MAX_POINTS_Y) - 2) + 1; + const float x0 = get_mesh_x(cx), x1 = get_mesh_x(cx + 1), + z1 = calc_z0(rx0, x0, z_values[cx][cy], x1, z_values[mx][cy]), z2 = calc_z0(rx0, x0, z_values[cx][my], x1, z_values[mx][my]); float z0 = calc_z0(ry0, get_mesh_y(cy), z1, get_mesh_y(cy + 1), z2); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index a02918ff297e..aa69b9467096 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -31,7 +31,6 @@ #include "../../../libs/hex_print.h" #include "../../../module/settings.h" #include "../../../lcd/marlinui.h" -#include "../../../module/stepper.h" #include "../../../module/planner.h" #include "../../../module/motion.h" #include "../../../module/probe.h" @@ -319,9 +318,7 @@ void unified_bed_leveling::G29() { TERN_(HAS_MULTI_HOTEND, if (active_extruder != 0) tool_change(0, true)); // Position bed horizontally and Z probe vertically. - #if defined(SAFE_BED_LEVELING_START_X) || defined(SAFE_BED_LEVELING_START_Y) || defined(SAFE_BED_LEVELING_START_Z) \ - || defined(SAFE_BED_LEVELING_START_I) || defined(SAFE_BED_LEVELING_START_J) || defined(SAFE_BED_LEVELING_START_K) \ - || defined(SAFE_BED_LEVELING_START_U) || defined(SAFE_BED_LEVELING_START_V) || defined(SAFE_BED_LEVELING_START_W) + #if HAS_SAFE_BED_LEVELING xyze_pos_t safe_position = current_position; #ifdef SAFE_BED_LEVELING_START_X safe_position.x = SAFE_BED_LEVELING_START_X; @@ -352,7 +349,7 @@ void unified_bed_leveling::G29() { #endif do_blocking_move_to(safe_position); - #endif + #endif // HAS_SAFE_BED_LEVELING } // Invalidate one or more nearby mesh points, possibly all. @@ -408,7 +405,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; @@ -888,8 +885,32 @@ void set_message_with_feedback(FSTR_P const fstr) { ui.capture(); save_ubl_active_state_and_disable(); // Disable bed level correction for probing - do_blocking_move_to(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y)), MANUAL_PROBE_START_Z); - //, _MIN(planner.settings.max_feedrate_mm_s[X_AXIS], planner.settings.max_feedrate_mm_s[Y_AXIS]) * 0.5f); + do_blocking_move_to( + xyz_pos_t({ + 0.5f * ((MESH_MAX_X) - (MESH_MIN_X)), + 0.5f * ((MESH_MAX_Y) - (MESH_MIN_Y)), + MANUAL_PROBE_START_Z + #ifdef SAFE_BED_LEVELING_START_I + , SAFE_BED_LEVELING_START_I + #endif + #ifdef SAFE_BED_LEVELING_START_J + , SAFE_BED_LEVELING_START_J + #endif + #ifdef SAFE_BED_LEVELING_START_K + , SAFE_BED_LEVELING_START_K + #endif + #ifdef SAFE_BED_LEVELING_START_U + , SAFE_BED_LEVELING_START_U + #endif + #ifdef SAFE_BED_LEVELING_START_V + , SAFE_BED_LEVELING_START_V + #endif + #ifdef SAFE_BED_LEVELING_START_W + , SAFE_BED_LEVELING_START_W + #endif + }) + //, _MIN(planner.settings.max_feedrate_mm_s[X_AXIS], planner.settings.max_feedrate_mm_s[Y_AXIS]) * 0.5f + ); planner.synchronize(); SERIAL_ECHOPGM("Place shim under nozzle"); @@ -1468,7 +1489,7 @@ void unified_bed_leveling::smart_fill_mesh() { float measured_z; bool abort_flag = false; - #ifdef VALIDATE_MESH_TILT + #if ENABLED(VALIDATE_MESH_TILT) float z1, z2, z3; // Needed for algorithm validation below #endif @@ -1484,9 +1505,7 @@ void unified_bed_leveling::smart_fill_mesh() { abort_flag = true; else { measured_z -= get_z_correction(points[0]); - #ifdef VALIDATE_MESH_TILT - z1 = measured_z; - #endif + TERN_(VALIDATE_MESH_TILT, z1 = measured_z); if (param.V_verbosity > 3) { serial_spaces(16); SERIAL_ECHOLNPGM("Corrected_Z=", measured_z); @@ -1499,9 +1518,7 @@ void unified_bed_leveling::smart_fill_mesh() { TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); measured_z = probe.probe_at_point(points[1], PROBE_PT_RAISE, param.V_verbosity); - #ifdef VALIDATE_MESH_TILT - z2 = measured_z; - #endif + TERN_(VALIDATE_MESH_TILT, z2 = measured_z); if (isnan(measured_z)) abort_flag = true; else { @@ -1519,9 +1536,7 @@ void unified_bed_leveling::smart_fill_mesh() { TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH))); measured_z = probe.probe_at_point(points[2], PROBE_PT_LAST_STOW, param.V_verbosity); - #ifdef VALIDATE_MESH_TILT - z3 = measured_z; - #endif + TERN_(VALIDATE_MESH_TILT, z3 = measured_z); if (isnan(measured_z)) abort_flag = true; else { @@ -1668,7 +1683,7 @@ void unified_bed_leveling::smart_fill_mesh() { * The Z error between the probed point locations and the get_z_correction() * numbers for those locations should be 0. */ - #ifdef VALIDATE_MESH_TILT + #if ENABLED(VALIDATE_MESH_TILT) auto d_from = []{ DEBUG_ECHOPGM("D from "); }; auto normed = [&](const xy_pos_t &pos, const_float_t zadd) { return normal.x * pos.x + normal.y * pos.y + zadd; diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp index e6eec0de63fd..96c30a0efd89 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp @@ -26,7 +26,6 @@ #include "../bedlevel.h" #include "../../../module/planner.h" -#include "../../../module/stepper.h" #include "../../../module/motion.h" #if ENABLED(DELTA) @@ -36,8 +35,18 @@ #include "../../../MarlinCore.h" #include +//#define DEBUG_UBL_MOTION +#define DEBUG_OUT ENABLED(DEBUG_UBL_MOTION) +#include "../../../core/debug_out.h" + #if !UBL_SEGMENTED + // TODO: The first and last parts of a move might result in very short segment(s) + // after getting split on the cell boundary, so moves like that should not + // get split. This will be most common for moves that start/end near the + // corners of cells. To fix the issue, simply check if the start/end of the line + // is very close to a cell boundary in advance and don't split the line there. + void unified_bed_leveling::line_to_destination_cartesian(const_feedRate_t scaled_fr_mm_s, const uint8_t extruder) { /** * Much of the nozzle movement will be within the same cell. So we will do as little computation @@ -176,7 +185,9 @@ dest.z += z0; planner.buffer_segment(dest, scaled_fr_mm_s, extruder); - } //else printf("FIRST MOVE PRUNED "); + } + else + DEBUG_ECHOLNPGM("[ubl] skip Y segment"); } // At the final destination? Usually not, but when on a Y Mesh Line it's completed. @@ -225,7 +236,9 @@ dest.z += z0; if (!planner.buffer_segment(dest, scaled_fr_mm_s, extruder)) break; - } //else printf("FIRST MOVE PRUNED "); + } + else + DEBUG_ECHOLNPGM("[ubl] skip Y segment"); } if (xy_pos_t(current_position) != xy_pos_t(end)) @@ -323,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 @@ -360,11 +373,12 @@ #endif NOLESS(segments, 1U); // Must have at least one segment - const float inv_segments = 1.0f / segments, // Reciprocal to save calculation - segment_xyz_mm = SQRT(cart_xy_mm_2 + sq(total.z)) * inv_segments; // Length of each segment + const float inv_segments = 1.0f / segments; // Reciprocal to save calculation + // Add hints to help optimize the move + PlannerHints hints(SQRT(cart_xy_mm_2 + sq(total.z)) * inv_segments); // Length of each segment #if ENABLED(SCARA_FEEDRATE_SCALING) - const float inv_duration = scaled_fr_mm_s / segment_xyz_mm; + hints.inv_duration = scaled_fr_mm_s / hints.millimeters; #endif xyze_float_t diff = total * inv_segments; @@ -378,13 +392,9 @@ if (!planner.leveling_active || !planner.leveling_active_at_z(destination.z)) { while (--segments) { raw += diff; - planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, segment_xyz_mm - OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) - ); + planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints); } - planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, segment_xyz_mm - OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) - ); + planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, hints); return false; // Did not set current from destination } @@ -413,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 @@ -453,7 +465,7 @@ TERN_(ENABLE_LEVELING_FADE_HEIGHT, * fade_scaling_factor); // apply fade factor to interpolated height const float oldz = raw.z; raw.z += z_cxcy; - planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, segment_xyz_mm OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) ); + planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints); raw.z = oldz; if (segments == 0) // done with last segment diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index 10d3131aedcb..1c6c1eb4aa55 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -38,15 +38,18 @@ 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" bool BLTouch::command(const BLTCommand cmd, const millis_t &ms) { - if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("BLTouch Command :", cmd); - servo[Z_PROBE_SERVO_NR].move(cmd); - safe_delay(_MAX(ms, (uint32_t)BLTOUCH_DELAY)); // BLTOUCH_DELAY is also the *minimum* delay + const BLTCommand current = servo[Z_PROBE_SERVO_NR].read(); + if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("BLTouch from ", current, " to ", cmd); + // If the new command is the same, skip it (and the delay). + // The previous write should've already delayed to detect the alarm. + if (cmd != current) { + servo[Z_PROBE_SERVO_NR].move(cmd); + safe_delay(_MAX(ms, (uint32_t)BLTOUCH_DELAY)); // BLTOUCH_DELAY is also the *minimum* delay + } return triggered(); } diff --git a/Marlin/src/feature/controllerfan.cpp b/Marlin/src/feature/controllerfan.cpp index f42bf52ae40a..6e5278ce7451 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(); } @@ -72,6 +75,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 @@ -79,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 } } diff --git a/Marlin/src/feature/dac/dac_dac084s085.cpp b/Marlin/src/feature/dac/dac_dac084s085.cpp index b88aaf802bdf..772bb68de42e 100644 --- a/Marlin/src/feature/dac/dac_dac084s085.cpp +++ b/Marlin/src/feature/dac/dac_dac084s085.cpp @@ -11,7 +11,6 @@ #include "dac_dac084s085.h" #include "../../MarlinCore.h" -#include "../../module/stepper.h" #include "../../HAL/shared/Delay.h" dac084s085::dac084s085() { } diff --git a/Marlin/src/feature/direct_stepping.cpp b/Marlin/src/feature/direct_stepping.cpp index 052e79de41e5..13cf71e07695 100644 --- a/Marlin/src/feature/direct_stepping.cpp +++ b/Marlin/src/feature/direct_stepping.cpp @@ -143,14 +143,16 @@ namespace DirectStepping { // special case for 8-bit, check if rolled back to 0 if (Cfg::DIRECTIONAL || !write_page_size) { // full 256 bytes if (write_byte_idx) return true; - } else { - if (write_byte_idx < write_page_size) return true; } - } else if (Cfg::DIRECTIONAL) { - if (write_byte_idx != Cfg::PAGE_SIZE) return true; - } else { - if (write_byte_idx < write_page_size) return true; + else if (write_byte_idx < write_page_size) + return true; + } + else if (Cfg::DIRECTIONAL) { + if (write_byte_idx != Cfg::PAGE_SIZE) + return true; } + else if (write_byte_idx < write_page_size) + return true; state = State::CHECKSUM; return true; @@ -161,11 +163,10 @@ namespace DirectStepping { return true; } case State::UNFAIL: - if (c == 0) { + if (c == 0) set_page_state(write_page_idx, PageState::FREE); - } else { + else fatal_error = true; - } state = State::MONITOR; return true; } 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/feature/fwretract.cpp b/Marlin/src/feature/fwretract.cpp index 172c97accdda..28355640d223 100644 --- a/Marlin/src/feature/fwretract.cpp +++ b/Marlin/src/feature/fwretract.cpp @@ -34,7 +34,6 @@ FWRetract fwretract; // Single instance - this calls the constructor #include "../module/motion.h" #include "../module/planner.h" -#include "../module/stepper.h" #include "../gcode/gcode.h" 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..c030ebad01fc 100644 --- a/Marlin/src/feature/host_actions.h +++ b/Marlin/src/feature/host_actions.h @@ -35,6 +35,8 @@ PROMPT_INFO }; + extern const char CONTINUE_STR[], DISMISS_STR[]; + #endif class HostUI { @@ -79,7 +81,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 +102,20 @@ 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 continue_prompt(FSTR_P const fstr) { prompt_do(PROMPT_USER_CONTINUE, fstr, FPSTR(CONTINUE_STR)); } + static void continue_prompt(const char * const cstr) { prompt_do(PROMPT_USER_CONTINUE, cstr, FPSTR(CONTINUE_STR)); } + 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); } @@ -110,5 +129,3 @@ class HostUI { }; extern HostUI hostui; - -extern const char CONTINUE_STR[], DISMISS_STR[]; diff --git a/Marlin/src/feature/joystick.cpp b/Marlin/src/feature/joystick.cpp index daa642d32e36..acab5d7437a2 100644 --- a/Marlin/src/feature/joystick.cpp +++ b/Marlin/src/feature/joystick.cpp @@ -172,8 +172,9 @@ Joystick joystick; current_position += move_dist; apply_motion_limits(current_position); const float length = sqrt(hypot2); + PlannerHints hints(length); injecting_now = true; - planner.buffer_line(current_position, length / seg_time, active_extruder, length); + planner.buffer_line(current_position, length / seg_time, active_extruder, hints); injecting_now = false; } } diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index 2a53a7c884e6..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 @@ -69,6 +57,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()); diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 8649dd014fbf..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 */ @@ -107,6 +119,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 +161,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/Marlin/src/feature/leds/neopixel.cpp b/Marlin/src/feature/leds/neopixel.cpp index 4f104234f15c..ab7ffe217796 100644 --- a/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin/src/feature/leds/neopixel.cpp @@ -108,7 +108,7 @@ void Marlin_NeoPixel::init() { set_color(adaneo1.Color TERN(LED_USER_PRESET_STARTUP, (LED_USER_PRESET_RED, LED_USER_PRESET_GREEN, LED_USER_PRESET_BLUE, LED_USER_PRESET_WHITE), - (255, 255, 255, 255)) + (0, 0, 0, 0)) ); } diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index d71aa25770fc..2048e2c2eebf 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -131,6 +131,13 @@ class Marlin_NeoPixel { // Accessors static uint16_t pixels() { return adaneo1.numPixels() * TERN1(NEOPIXEL2_INSERIES, 2); } + static uint32_t pixel_color(const uint16_t n) { + #if ENABLED(NEOPIXEL2_INSERIES) + if (n >= NEOPIXEL_PIXELS) return adaneo2.getPixelColor(n - (NEOPIXEL_PIXELS)); + #endif + return adaneo1.getPixelColor(n); + } + static uint8_t brightness() { return adaneo1.getBrightness(); } static uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w)) { @@ -174,6 +181,7 @@ extern Marlin_NeoPixel neo; // Accessors static uint16_t pixels() { return adaneo.numPixels();} + static uint32_t pixel_color(const uint16_t n) { return adaneo.getPixelColor(n); } static uint8_t brightness() { return adaneo.getBrightness(); } static uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED2, uint8_t w)) { return adaneo.Color(r, g, b OPTARG(HAS_WHITE_LED2, w)); diff --git a/Marlin/src/feature/leds/pca9632.cpp b/Marlin/src/feature/leds/pca9632.cpp index abea98800451..07c379a8154a 100644 --- a/Marlin/src/feature/leds/pca9632.cpp +++ b/Marlin/src/feature/leds/pca9632.cpp @@ -148,7 +148,7 @@ void PCA9632_set_led_color(const LEDColor &color) { #if ENABLED(PCA9632_BUZZER) - void PCA9632_buzz(const long, const uint16_t) { + void PCA9632_buzz(const long, const uint16_t=0) { uint8_t data[] = PCA9632_BUZZER_DATA; Wire.beginTransmission(I2C_ADDRESS(PCA9632_ADDRESS)); Wire.write(data, sizeof(data)); diff --git a/Marlin/src/feature/leds/pca9632.h b/Marlin/src/feature/leds/pca9632.h index fb59a8c18479..adef0200afb9 100644 --- a/Marlin/src/feature/leds/pca9632.h +++ b/Marlin/src/feature/leds/pca9632.h @@ -33,5 +33,5 @@ void PCA9632_set_led_color(const LEDColor &color); #if ENABLED(PCA9632_BUZZER) #include - void PCA9632_buzz(const long, const uint16_t); + void PCA9632_buzz(const long, const uint16_t=0); #endif diff --git a/Marlin/src/feature/max7219.cpp b/Marlin/src/feature/max7219.cpp index 474933aa1946..2fdfcba32d21 100644 --- a/Marlin/src/feature/max7219.cpp +++ b/Marlin/src/feature/max7219.cpp @@ -44,7 +44,6 @@ #include "max7219.h" #include "../module/planner.h" -#include "../module/stepper.h" #include "../MarlinCore.h" #include "../HAL/shared/Delay.h" @@ -52,6 +51,7 @@ #define HAS_SIDE_BY_SIDE 1 #endif +#define _ROT ((MAX7219_ROTATE + 360) % 360) #if _ROT == 0 || _ROT == 180 #define MAX7219_X_LEDS TERN(HAS_SIDE_BY_SIDE, 8, MAX7219_LINES) #define MAX7219_Y_LEDS TERN(HAS_SIDE_BY_SIDE, MAX7219_LINES, 8) @@ -62,6 +62,15 @@ #error "MAX7219_ROTATE must be a multiple of +/- 90°." #endif +#ifdef MAX7219_DEBUG_PROFILE + CodeProfiler::Mode CodeProfiler::mode = ACCUMULATE_AVERAGE; + uint8_t CodeProfiler::instance_count = 0; + uint32_t CodeProfiler::last_calc_time = micros(); + uint8_t CodeProfiler::time_fraction = 0; + uint32_t CodeProfiler::total_time = 0; + uint16_t CodeProfiler::call_count = 0; +#endif + Max7219 max7219; uint8_t Max7219::led_line[MAX7219_LINES]; // = { 0 }; @@ -69,7 +78,7 @@ uint8_t Max7219::suspended; // = 0; #define LINE_REG(Q) (max7219_reg_digit0 + ((Q) & 0x7)) -#if _ROT == 0 || _ROT == 270 +#if (_ROT == 0 || _ROT == 270) == DISABLED(MAX7219_REVERSE_EACH) #define _LED_BIT(Q) (7 - ((Q) & 0x7)) #else #define _LED_BIT(Q) ((Q) & 0x7) @@ -266,26 +275,27 @@ void Max7219::set(const uint8_t line, const uint8_t bits) { #endif // MAX7219_NUMERIC // Modify a single LED bit and send the changed line -void Max7219::led_set(const uint8_t x, const uint8_t y, const bool on) { +void Max7219::led_set(const uint8_t x, const uint8_t y, const bool on, uint8_t * const rcm/*=nullptr*/) { if (x >= MAX7219_X_LEDS || y >= MAX7219_Y_LEDS) return error(F("led_set"), x, y); if (BIT_7219(x, y) == on) return; XOR_7219(x, y); refresh_unit_line(LED_IND(x, y)); + if (rcm != nullptr) *rcm |= _BV(LED_IND(x, y) & 0x07); } -void Max7219::led_on(const uint8_t x, const uint8_t y) { +void Max7219::led_on(const uint8_t x, const uint8_t y, uint8_t * const rcm/*=nullptr*/) { if (x >= MAX7219_X_LEDS || y >= MAX7219_Y_LEDS) return error(F("led_on"), x, y); - led_set(x, y, true); + led_set(x, y, true, rcm); } -void Max7219::led_off(const uint8_t x, const uint8_t y) { +void Max7219::led_off(const uint8_t x, const uint8_t y, uint8_t * const rcm/*=nullptr*/) { if (x >= MAX7219_X_LEDS || y >= MAX7219_Y_LEDS) return error(F("led_off"), x, y); - led_set(x, y, false); + led_set(x, y, false, rcm); } -void Max7219::led_toggle(const uint8_t x, const uint8_t y) { +void Max7219::led_toggle(const uint8_t x, const uint8_t y, uint8_t * const rcm/*=nullptr*/) { if (x >= MAX7219_X_LEDS || y >= MAX7219_Y_LEDS) return error(F("led_toggle"), x, y); - led_set(x, y, !BIT_7219(x, y)); + led_set(x, y, !BIT_7219(x, y), rcm); } void Max7219::send_row(const uint8_t row) { @@ -448,7 +458,7 @@ void Max7219::register_setup() { pulse_load(); // Tell the chips to load the clocked out data } -#ifdef MAX7219_INIT_TEST +#if MAX7219_INIT_TEST uint8_t test_mode = 0; millis_t next_patt_ms; @@ -536,13 +546,9 @@ void Max7219::init() { register_setup(); - LOOP_LE_N(i, 7) { // Empty registers to turn all LEDs off - led_line[i] = 0x00; - send(max7219_reg_digit0 + i, 0); - pulse_load(); // Tell the chips to load the clocked out data - } + clear(); - #ifdef MAX7219_INIT_TEST + #if MAX7219_INIT_TEST start_test_pattern(); #endif } @@ -554,41 +560,55 @@ void Max7219::init() { */ // Apply changes to update a marker -void Max7219::mark16(const uint8_t pos, const uint8_t v1, const uint8_t v2) { +void Max7219::mark16(const uint8_t pos, const uint8_t v1, const uint8_t v2, uint8_t * const rcm/*=nullptr*/) { #if MAX7219_X_LEDS > 8 // At least 16 LEDs on the X-Axis. Use single line. - led_off(v1 & 0xF, pos); - led_on(v2 & 0xF, pos); + led_off(v1 & 0xF, pos, rcm); + led_on(v2 & 0xF, pos, rcm); #elif MAX7219_Y_LEDS > 8 // At least 16 LEDs on the Y-Axis. Use a single column. - led_off(pos, v1 & 0xF); - led_on(pos, v2 & 0xF); + led_off(pos, v1 & 0xF, rcm); + led_on(pos, v2 & 0xF, rcm); #else // Single 8x8 LED matrix. Use two lines to get 16 LEDs. - led_off(v1 & 0x7, pos + (v1 >= 8)); - led_on(v2 & 0x7, pos + (v2 >= 8)); + led_off(v1 & 0x7, pos + (v1 >= 8), rcm); + led_on(v2 & 0x7, pos + (v2 >= 8), rcm); #endif } // Apply changes to update a tail-to-head range -void Max7219::range16(const uint8_t y, const uint8_t ot, const uint8_t nt, const uint8_t oh, const uint8_t nh) { +void Max7219::range16(const uint8_t y, const uint8_t ot, const uint8_t nt, const uint8_t oh, + const uint8_t nh, uint8_t * const rcm/*=nullptr*/) { #if MAX7219_X_LEDS > 8 // At least 16 LEDs on the X-Axis. Use single line. if (ot != nt) for (uint8_t n = ot & 0xF; n != (nt & 0xF) && n != (nh & 0xF); n = (n + 1) & 0xF) - led_off(n & 0xF, y); + led_off(n & 0xF, y, rcm); if (oh != nh) for (uint8_t n = (oh + 1) & 0xF; n != ((nh + 1) & 0xF); n = (n + 1) & 0xF) - led_on(n & 0xF, y); + led_on(n & 0xF, y, rcm); #elif MAX7219_Y_LEDS > 8 // At least 16 LEDs on the Y-Axis. Use a single column. if (ot != nt) for (uint8_t n = ot & 0xF; n != (nt & 0xF) && n != (nh & 0xF); n = (n + 1) & 0xF) - led_off(y, n & 0xF); + led_off(y, n & 0xF, rcm); if (oh != nh) for (uint8_t n = (oh + 1) & 0xF; n != ((nh + 1) & 0xF); n = (n + 1) & 0xF) - led_on(y, n & 0xF); + led_on(y, n & 0xF, rcm); #else // Single 8x8 LED matrix. Use two lines to get 16 LEDs. if (ot != nt) for (uint8_t n = ot & 0xF; n != (nt & 0xF) && n != (nh & 0xF); n = (n + 1) & 0xF) - led_off(n & 0x7, y + (n >= 8)); + led_off(n & 0x7, y + (n >= 8), rcm); if (oh != nh) for (uint8_t n = (oh + 1) & 0xF; n != ((nh + 1) & 0xF); n = (n + 1) & 0xF) - led_on(n & 0x7, y + (n >= 8)); + led_on(n & 0x7, y + (n >= 8), rcm); #endif } // Apply changes to update a quantity -void Max7219::quantity16(const uint8_t pos, const uint8_t ov, const uint8_t nv) { +void Max7219::quantity(const uint8_t pos, const uint8_t ov, const uint8_t nv, uint8_t * const rcm/*=nullptr*/) { + for (uint8_t i = _MIN(nv, ov); i < _MAX(nv, ov); i++) + led_set( + #if MAX7219_X_LEDS >= MAX7219_Y_LEDS + i, pos // Single matrix or multiple matrices in Landscape + #else + pos, i // Multiple matrices in Portrait + #endif + , nv >= ov + , rcm + ); +} + +void Max7219::quantity16(const uint8_t pos, const uint8_t ov, const uint8_t nv, uint8_t * const rcm/*=nullptr*/) { for (uint8_t i = _MIN(nv, ov); i < _MAX(nv, ov); i++) led_set( #if MAX7219_X_LEDS > 8 // At least 16 LEDs on the X-Axis. Use single line. @@ -599,6 +619,7 @@ void Max7219::quantity16(const uint8_t pos, const uint8_t ov, const uint8_t nv) i >> 1, pos + (i & 1) #endif , nv >= ov + , rcm ); } @@ -636,16 +657,20 @@ void Max7219::idle_tasks() { register_setup(); } - #ifdef MAX7219_INIT_TEST + #if MAX7219_INIT_TEST if (test_mode) { run_test_pattern(); return; } #endif + // suspend updates and record which lines have changed for batching later + suspended++; + uint8_t row_change_mask = 0x00; + #if ENABLED(MAX7219_DEBUG_PRINTER_ALIVE) if (do_blink) { - led_toggle(MAX7219_X_LEDS - 1, MAX7219_Y_LEDS - 1); + led_toggle(MAX7219_X_LEDS - 1, MAX7219_Y_LEDS - 1, &row_change_mask); next_blink = ms + 1000; } #endif @@ -655,7 +680,7 @@ void Max7219::idle_tasks() { static int16_t last_head_cnt = 0xF, last_tail_cnt = 0xF; if (last_head_cnt != head || last_tail_cnt != tail) { - range16(MAX7219_DEBUG_PLANNER_HEAD, last_tail_cnt, tail, last_head_cnt, head); + range16(MAX7219_DEBUG_PLANNER_HEAD, last_tail_cnt, tail, last_head_cnt, head, &row_change_mask); last_head_cnt = head; last_tail_cnt = tail; } @@ -665,7 +690,7 @@ void Max7219::idle_tasks() { #ifdef MAX7219_DEBUG_PLANNER_HEAD static int16_t last_head_cnt = 0x1; if (last_head_cnt != head) { - mark16(MAX7219_DEBUG_PLANNER_HEAD, last_head_cnt, head); + mark16(MAX7219_DEBUG_PLANNER_HEAD, last_head_cnt, head, &row_change_mask); last_head_cnt = head; } #endif @@ -673,7 +698,7 @@ void Max7219::idle_tasks() { #ifdef MAX7219_DEBUG_PLANNER_TAIL static int16_t last_tail_cnt = 0x1; if (last_tail_cnt != tail) { - mark16(MAX7219_DEBUG_PLANNER_TAIL, last_tail_cnt, tail); + mark16(MAX7219_DEBUG_PLANNER_TAIL, last_tail_cnt, tail, &row_change_mask); last_tail_cnt = tail; } #endif @@ -684,11 +709,26 @@ void Max7219::idle_tasks() { static int16_t last_depth = 0; const int16_t current_depth = (head - tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1) & 0xF; if (current_depth != last_depth) { - quantity16(MAX7219_DEBUG_PLANNER_QUEUE, last_depth, current_depth); + quantity16(MAX7219_DEBUG_PLANNER_QUEUE, last_depth, current_depth, &row_change_mask); last_depth = current_depth; } #endif + #ifdef MAX7219_DEBUG_PROFILE + static uint8_t last_time_fraction = 0; + const uint8_t current_time_fraction = (uint16_t(CodeProfiler::get_time_fraction()) * MAX7219_NUMBER_UNITS + 8) / 16; + if (current_time_fraction != last_time_fraction) { + quantity(MAX7219_DEBUG_PROFILE, last_time_fraction, current_time_fraction, &row_change_mask); + last_time_fraction = current_time_fraction; + } + #endif + + // batch line updates + suspended--; + if (!suspended) + LOOP_L_N(i, 8) if (row_change_mask & _BV(i)) + refresh_line(i); + // After resume() automatically do a refresh() if (suspended == 0x80) { suspended = 0; diff --git a/Marlin/src/feature/max7219.h b/Marlin/src/feature/max7219.h index 809bda6d4b35..a6b110fdf4c9 100644 --- a/Marlin/src/feature/max7219.h +++ b/Marlin/src/feature/max7219.h @@ -47,7 +47,6 @@ #ifndef MAX7219_ROTATE #define MAX7219_ROTATE 0 #endif -#define _ROT ((MAX7219_ROTATE + 360) % 360) #ifndef MAX7219_NUMBER_UNITS #define MAX7219_NUMBER_UNITS 1 @@ -73,6 +72,67 @@ #define max7219_reg_shutdown 0x0C #define max7219_reg_displayTest 0x0F +#ifdef MAX7219_DEBUG_PROFILE + // This class sums up the amount of time for which its instances exist. + // By default there is one instantiated for the duration of the idle() + // function. But an instance can be created in any code block to measure + // the time spent from the point of instantiation until the CPU leaves + // block. Be careful about having multiple instances of CodeProfiler as + // it does not guard against double counting. In general mixing ISR and + // non-ISR use will require critical sections but note that mode setting + // is atomic so the total or average times can safely be read if you set + // mode to FREEZE first. + class CodeProfiler { + public: + enum Mode : uint8_t { ACCUMULATE_AVERAGE, ACCUMULATE_TOTAL, FREEZE }; + + private: + static Mode mode; + static uint8_t instance_count; + static uint32_t last_calc_time; + static uint32_t total_time; + static uint8_t time_fraction; + static uint16_t call_count; + + uint32_t start_time; + + public: + CodeProfiler() : start_time(micros()) { instance_count++; } + ~CodeProfiler() { + instance_count--; + if (mode == FREEZE) return; + + call_count++; + + const uint32_t now = micros(); + total_time += now - start_time; + + if (mode == ACCUMULATE_TOTAL) return; + + // update time_fraction every hundred milliseconds + if (instance_count == 0 && ELAPSED(now, last_calc_time + 100000)) { + time_fraction = total_time * 128 / (now - last_calc_time); + last_calc_time = now; + total_time = 0; + } + } + + static void set_mode(Mode _mode) { mode = _mode; } + static void reset() { + time_fraction = 0; + last_calc_time = micros(); + total_time = 0; + call_count = 0; + } + // returns fraction of total time which was measured, scaled from 0 to 128 + static uint8_t get_time_fraction() { return time_fraction; } + // returns total time in microseconds + static uint32_t get_total_time() { return total_time; } + + static uint16_t get_call_count() { return call_count; } + }; +#endif + class Max7219 { public: static uint8_t led_line[MAX7219_LINES]; @@ -110,10 +170,10 @@ class Max7219 { #endif // Set a single LED by XY coordinate - static void led_set(const uint8_t x, const uint8_t y, const bool on); - static void led_on(const uint8_t x, const uint8_t y); - static void led_off(const uint8_t x, const uint8_t y); - static void led_toggle(const uint8_t x, const uint8_t y); + static void led_set(const uint8_t x, const uint8_t y, const bool on, uint8_t * const rcm=nullptr); + static void led_on(const uint8_t x, const uint8_t y, uint8_t * const rcm=nullptr); + static void led_off(const uint8_t x, const uint8_t y, uint8_t * const rcm=nullptr); + static void led_toggle(const uint8_t x, const uint8_t y, uint8_t * const rcm=nullptr); // Set all LEDs in a single column static void set_column(const uint8_t col, const uint32_t val); @@ -147,11 +207,12 @@ class Max7219 { static void set(const uint8_t line, const uint8_t bits); static void send_row(const uint8_t row); static void send_column(const uint8_t col); - static void mark16(const uint8_t y, const uint8_t v1, const uint8_t v2); - static void range16(const uint8_t y, const uint8_t ot, const uint8_t nt, const uint8_t oh, const uint8_t nh); - static void quantity16(const uint8_t y, const uint8_t ov, const uint8_t nv); + static void mark16(const uint8_t y, const uint8_t v1, const uint8_t v2, uint8_t * const rcm=nullptr); + static void range16(const uint8_t y, const uint8_t ot, const uint8_t nt, const uint8_t oh, const uint8_t nh, uint8_t * const rcm=nullptr); + static void quantity(const uint8_t y, const uint8_t ov, const uint8_t nv, uint8_t * const rcm=nullptr); + static void quantity16(const uint8_t y, const uint8_t ov, const uint8_t nv, uint8_t * const rcm=nullptr); - #ifdef MAX7219_INIT_TEST + #if MAX7219_INIT_TEST static void test_pattern(); static void run_test_pattern(); static void start_test_pattern(); diff --git a/Marlin/src/feature/mixing.cpp b/Marlin/src/feature/mixing.cpp index b1a069e3205e..cf88b806f542 100644 --- a/Marlin/src/feature/mixing.cpp +++ b/Marlin/src/feature/mixing.cpp @@ -24,8 +24,6 @@ #if ENABLED(MIXING_EXTRUDER) -//#define MIXER_NORMALIZER_DEBUG - #include "mixing.h" Mixer mixer; diff --git a/Marlin/src/feature/mixing.h b/Marlin/src/feature/mixing.h index 85d52d69c8f3..3a14fdad5975 100644 --- a/Marlin/src/feature/mixing.h +++ b/Marlin/src/feature/mixing.h @@ -148,8 +148,7 @@ class Mixer { static void update_mix_from_vtool(const uint8_t j=selected_vtool) { float ctot = 0; MIXER_STEPPER_LOOP(i) ctot += color[j][i]; - //MIXER_STEPPER_LOOP(i) mix[i] = 100.0f * color[j][i] / ctot; - MIXER_STEPPER_LOOP(i) mix[i] = mixer_perc_t(100.0f * color[j][i] / ctot); + MIXER_STEPPER_LOOP(i) mix[i] = mixer_perc_t(100.0f * color[j][i] / ctot + 0.5f); #ifdef MIXER_NORMALIZER_DEBUG SERIAL_ECHOPGM("V-tool ", j, " [ "); diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index a4718b53d9d8..7747a8b1157c 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; } @@ -585,7 +577,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 +645,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_SEND("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 +695,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); @@ -861,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 { @@ -966,10 +979,10 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { manage_response(false, false); if (recover) { - LCD_MESSAGE(MSG_MMU2_EJECT_RECOVER); + LCD_MESSAGE(MSG_MMU2_REMOVE_AND_CLICK); mmu2_attn_buzz(); - TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("MMU2 Eject Recover"), FPSTR(CONTINUE_STR))); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("MMU2 Eject Recover"))); + TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_MMU2_EJECT_RECOVER))); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_MMU2_EJECT_RECOVER))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); mmu2_attn_buzz(true); 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 diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index ac5852f91a1a..04d206ff931d 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -35,10 +35,13 @@ #include "../gcode/gcode.h" #include "../module/motion.h" #include "../module/planner.h" -#include "../module/stepper.h" #include "../module/printcounter.h" #include "../module/temperature.h" +#if HAS_EXTRUDERS + #include "../module/stepper.h" +#endif + #if ENABLED(AUTO_BED_LEVELING_UBL) #include "bedlevel/bedlevel.h" #endif @@ -63,7 +66,7 @@ #include "../lcd/marlinui.h" -#if HAS_BUZZER +#if HAS_SOUND #include "../libs/buzzer.h" #endif @@ -98,7 +101,7 @@ fil_change_settings_t fc_settings[EXTRUDERS]; #define _PMSG(L) L##_LCD #endif -#if HAS_BUZZER +#if HAS_SOUND static void impatient_beep(const int8_t max_beep_count, const bool restart=false) { if (TERN0(HAS_MARLINUI_MENU, pause_mode == PAUSE_MODE_PAUSE_PRINT)) return; @@ -198,7 +201,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load KEEPALIVE_STATE(PAUSED_FOR_USER); wait_for_user = true; // LCD click or M108 will clear this - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("Load Filament"))); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENTLOAD))); #if ENABLED(HOST_PROMPT_SUPPORT) const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, active_extruder); @@ -208,7 +211,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load while (wait_for_user) { impatient_beep(max_beep_count); #if BOTH(FILAMENT_CHANGE_RESUME_ON_INSERT, FILAMENT_RUNOUT_SENSOR) - #if ENABLED(MULTI_FILAMENT_SENSOR) + #if MULTI_FILAMENT_SENSOR #define _CASE_INSERTED(N) case N-1: if (READ(FIL_RUNOUT##N##_PIN) != FIL_RUNOUT##N##_STATE) wait_for_user = false; break; switch (active_extruder) { REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_INSERTED) @@ -257,7 +260,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load if (show_lcd) ui.pause_show_message(PAUSE_MESSAGE_PURGE); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE))); - TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE), FPSTR(CONTINUE_STR))); + TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE))); wait_for_user = true; // A click or M108 breaks the purge_length loop for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count) unscaled_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE); @@ -407,7 +410,6 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool #endif TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_INFO, F("Pause"), FPSTR(DISMISS_STR))); - TERN_(DWIN_LCD_PROUI, DWIN_Print_Pause()); // Indicate that the printer is paused ++did_pause_print; @@ -458,6 +460,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool // If axes don't need to home then the nozzle can park if (do_park) nozzle.park(0, park_point); // Park the nozzle by doing a Minimum Z Raise followed by an XY Move + if (!do_park) LCD_MESSAGE(MSG_PARK_FAILED); #if ENABLED(DUAL_X_CARRIAGE) const int8_t saved_ext = active_extruder; @@ -469,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(); @@ -524,7 +525,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep // Wait for filament insert by user and press button KEEPALIVE_STATE(PAUSED_FOR_USER); - TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_NOZZLE_PARKED), FPSTR(CONTINUE_STR))); + TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_NOZZLE_PARKED))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_NOZZLE_PARKED))); wait_for_user = true; // LCD click or M108 will clear this while (wait_for_user) { @@ -548,9 +549,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_INFO, GET_TEXT_F(MSG_REHEATING))); - TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(GET_TEXT_F(MSG_REHEATING))); - - TERN_(DWIN_LCD_PROUI, LCD_MESSAGE(MSG_REHEATING)); + LCD_MESSAGE(MSG_REHEATING); // Re-enable the heaters if they timed out HOTEND_LOOP() thermalManager.reset_hotend_idle_timer(e); @@ -566,9 +565,12 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep HOTEND_LOOP() thermalManager.heater_idle[e].start(nozzle_timeout); - TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_REHEATDONE), FPSTR(CONTINUE_STR))); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_REHEATDONE))); - TERN_(DWIN_LCD_PROUI, LCD_MESSAGE(MSG_REHEATDONE)); + TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_REHEATDONE))); + #if ENABLED(EXTENSIBLE_UI) + ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_REHEATDONE)); + #else + LCD_MESSAGE(MSG_REHEATDONE); + #endif IF_DISABLED(PAUSE_REHEAT_FAST_RESUME, wait_for_user = true); @@ -577,9 +579,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)); } /** @@ -711,9 +711,8 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_ TERN_(HAS_FILAMENT_SENSOR, runout.reset()); - TERN(DWIN_LCD_PROUI, DWIN_Print_Resume(), ui.reset_status()); - TERN_(HAS_MARLINUI_MENU, ui.return_to_status()); - TERN_(DWIN_LCD_PROUI, HMI_ReturnScreen()); + ui.reset_status(); + ui.return_to_status(); } #endif // ADVANCED_PAUSE_FEATURE diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index c2ed169aa809..8a16628bac45 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -30,7 +30,7 @@ #include "power.h" #include "../module/planner.h" -#include "../module/stepper.h" +#include "../module/stepper/indirection.h" // for restore_stepper_drivers #include "../module/temperature.h" #include "../MarlinCore.h" @@ -46,6 +46,7 @@ Power powerManager; bool Power::psu_on; #if ENABLED(AUTO_POWER_CONTROL) + #include "../module/stepper.h" #include "../module/temperature.h" #if BOTH(USE_CONTROLLER_FAN, AUTO_POWER_CONTROLLERFAN) diff --git a/Marlin/src/feature/power_monitor.cpp b/Marlin/src/feature/power_monitor.cpp index 504f1ea48e3b..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_wchar('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_wchar('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_wchar('W'); + lcd_put_u8str(F("W")); } #endif diff --git a/Marlin/src/feature/power_monitor.h b/Marlin/src/feature/power_monitor.h index f6e0b292e30c..fa0690905333 100644 --- a/Marlin/src/feature/power_monitor.h +++ b/Marlin/src/feature/power_monitor.h @@ -32,7 +32,7 @@ struct pm_lpf_t { uint32_t filter_buf; float value; void add_sample(const uint16_t sample) { - filter_buf = filter_buf - (filter_buf >> K_VALUE) + (uint32_t(sample) << K_SCALE); + filter_buf += (uint32_t(sample) << K_SCALE) - (filter_buf >> K_VALUE); } void capture() { value = filter_buf * (SCALE * (1.0f / (1UL << (PM_K_VALUE + PM_K_SCALE)))); diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index d4450adcd853..1037f823f644 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -33,7 +33,7 @@ bool PrintJobRecovery::enabled; // Initialized by settings.load() -SdFile PrintJobRecovery::file; +MediaFile PrintJobRecovery::file; job_recovery_info_t PrintJobRecovery::info; const char PrintJobRecovery::filename[5] = "/PLR"; uint8_t PrintJobRecovery::queue_index_r; @@ -78,6 +78,14 @@ PrintJobRecovery recovery; #define POWER_LOSS_RETRACT_LEN 0 #endif +// Allow power-loss recovery to be aborted +#define PLR_CAN_ABORT +#if ENABLED(PLR_CAN_ABORT) + #define PROCESS_SUBCOMMANDS_NOW(cmd) do { if (card.flag.abort_sd_printing) return; gcode.process_subcommands_now(cmd); }while(0) +#else + #define PROCESS_SUBCOMMANDS_NOW(cmd) gcode.process_subcommands_now(cmd) +#endif + /** * Clear the recovery info */ @@ -352,12 +360,23 @@ void PrintJobRecovery::resume() { // Apply the dry-run flag if enabled if (info.flag.dryrun) marlin_debug_flags |= MARLIN_DEBUG_DRYRUN; + #if ENABLED(DEBUG_POWER_LOSS_RECOVERY) + struct OnExit { + uint8_t old_flags; + OnExit() { + old_flags = marlin_debug_flags; + marlin_debug_flags |= MARLIN_DEBUG_ECHO; + } + ~OnExit() { marlin_debug_flags = old_flags; } + } on_exit; + #endif + // Restore cold extrusion permission TERN_(PREVENT_COLD_EXTRUSION, thermalManager.allow_cold_extrude = info.flag.allow_cold_extrusion); #if HAS_LEVELING // Make sure leveling is off before any G92 and G28 - gcode.process_subcommands_now(F("M420 S0 Z0")); + PROCESS_SUBCOMMANDS_NOW(F("M420S0")); #endif #if HAS_HEATED_BED @@ -365,7 +384,7 @@ void PrintJobRecovery::resume() { if (bt) { // Restore the bed temperature sprintf_P(cmd, PSTR("M190S%i"), bt); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); } #endif @@ -376,10 +395,10 @@ void PrintJobRecovery::resume() { if (et) { #if HAS_MULTI_HOTEND sprintf_P(cmd, PSTR("T%iS"), e); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); #endif sprintf_P(cmd, PSTR("M109S%i"), et); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); } } #endif @@ -393,7 +412,7 @@ void PrintJobRecovery::resume() { // establish the current position as best we can. // - gcode.process_subcommands_now(F("G92.9E0")); // Reset E to 0 + PROCESS_SUBCOMMANDS_NOW(F("G92.9E0")); // Reset E to 0 #if Z_HOME_TO_MAX @@ -404,7 +423,7 @@ void PrintJobRecovery::resume() { "G28R0\n" // Home all axes (no raise) "G1Z%sF1200" // Move Z down to (raised) height ), dtostrf(z_now, 1, 3, str_1)); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); #elif DISABLED(BELTPRINTER) @@ -417,18 +436,18 @@ void PrintJobRecovery::resume() { #if !HOMING_Z_DOWN // Set Z to the real position sprintf_P(cmd, PSTR("G92.9Z%s"), dtostrf(z_now, 1, 3, str_1)); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); #endif // Does Z need to be raised now? It should be raised before homing XY. if (z_raised > z_now) { z_now = z_raised; sprintf_P(cmd, PSTR("G1Z%sF600"), dtostrf(z_now, 1, 3, str_1)); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); } // Home XY with no Z raise - gcode.process_subcommands_now(F("G28R0XY")); // No raise during G28 + PROCESS_SUBCOMMANDS_NOW(F("G28R0XY")); // No raise during G28 #endif @@ -436,7 +455,7 @@ void PrintJobRecovery::resume() { // Move to a safe XY position and home Z while avoiding the print. const xy_pos_t p = xy_pos_t(POWER_LOSS_ZHOME_POS) TERN_(HOMING_Z_WITH_PROBE, - probe.offset_xy); sprintf_P(cmd, PSTR("G1X%sY%sF1000\nG28HZ"), dtostrf(p.x, 1, 3, str_1), dtostrf(p.y, 1, 3, str_2)); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); #endif // Mark all axes as having been homed (no effect on current_position) @@ -447,12 +466,12 @@ void PrintJobRecovery::resume() { // Leveling may already be enabled due to the ENABLE_LEVELING_AFTER_G28 option. // TODO: Add a G28 parameter to leave leveling disabled. sprintf_P(cmd, PSTR("M420S%cZ%s"), '0' + (char)info.flag.leveling, dtostrf(info.fade, 1, 1, str_1)); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); #if !HOMING_Z_DOWN // The physical Z was adjusted at power-off so undo the M420S1 correction to Z with G92.9. sprintf_P(cmd, PSTR("G92.9Z%s"), dtostrf(z_now, 1, 1, str_1)); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); #endif #endif @@ -460,7 +479,7 @@ void PrintJobRecovery::resume() { // Z was homed down to the bed, so move up to the raised height. z_now = z_raised; sprintf_P(cmd, PSTR("G1Z%sF600"), dtostrf(z_now, 1, 3, str_1)); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); #endif // Recover volumetric extrusion state @@ -468,16 +487,16 @@ void PrintJobRecovery::resume() { #if HAS_MULTI_EXTRUDER EXTRUDER_LOOP() { sprintf_P(cmd, PSTR("M200T%iD%s"), e, dtostrf(info.filament_size[e], 1, 3, str_1)); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); } if (!info.flag.volumetric_enabled) { sprintf_P(cmd, PSTR("M200T%iD0"), info.active_extruder); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); } #else if (info.flag.volumetric_enabled) { sprintf_P(cmd, PSTR("M200D%s"), dtostrf(info.filament_size[0], 1, 3, str_1)); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); } #endif #endif @@ -489,10 +508,10 @@ void PrintJobRecovery::resume() { if (et) { #if HAS_MULTI_HOTEND sprintf_P(cmd, PSTR("T%iS"), e); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); #endif sprintf_P(cmd, PSTR("M109S%i"), et); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); } } #endif @@ -500,7 +519,7 @@ void PrintJobRecovery::resume() { // Restore the previously active tool (with no_move) #if HAS_MULTI_EXTRUDER || HAS_MULTI_HOTEND sprintf_P(cmd, PSTR("T%i S"), info.active_extruder); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); #endif // Restore print cooling fan speeds @@ -509,7 +528,7 @@ void PrintJobRecovery::resume() { const int f = info.fan_speed[i]; if (f) { sprintf_P(cmd, PSTR("M106P%iS%i"), i, f); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); } } #endif @@ -531,17 +550,17 @@ void PrintJobRecovery::resume() { // Un-retract if there was a retract at outage #if ENABLED(BACKUP_POWER_SUPPLY) && POWER_LOSS_RETRACT_LEN > 0 - gcode.process_subcommands_now(F("G1F3000E" STRINGIFY(POWER_LOSS_RETRACT_LEN))); + PROCESS_SUBCOMMANDS_NOW(F("G1F3000E" STRINGIFY(POWER_LOSS_RETRACT_LEN))); #endif // Additional purge on resume if configured #if POWER_LOSS_PURGE_LEN sprintf_P(cmd, PSTR("G1F3000E%d"), (POWER_LOSS_PURGE_LEN) + (POWER_LOSS_RETRACT_LEN)); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); #endif #if ENABLED(NOZZLE_CLEAN_FEATURE) - gcode.process_subcommands_now(F("G12")); + PROCESS_SUBCOMMANDS_NOW(F("G12")); #endif // Move back over to the saved XY @@ -549,19 +568,19 @@ void PrintJobRecovery::resume() { dtostrf(info.current_position.x, 1, 3, str_1), dtostrf(info.current_position.y, 1, 3, str_2) ); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); // Move back down to the saved Z for printing sprintf_P(cmd, PSTR("G1Z%sF600"), dtostrf(z_print, 1, 3, str_1)); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); // Restore the feedrate sprintf_P(cmd, PSTR("G1F%d"), info.feedrate); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); // Restore E position with G92.9 sprintf_P(cmd, PSTR("G92.9E%s"), dtostrf(info.current_position.e, 1, 3, str_1)); - gcode.process_subcommands_now(cmd); + PROCESS_SUBCOMMANDS_NOW(cmd); TERN_(GCODE_REPEAT_MARKERS, repeat = info.stored_repeat); TERN_(HAS_HOME_OFFSET, home_offset = info.home_offset); @@ -573,22 +592,14 @@ void PrintJobRecovery::resume() { // Relative axis modes gcode.axis_relative = info.axis_relative; - #if ENABLED(DEBUG_POWER_LOSS_RECOVERY) - const uint8_t old_flags = marlin_debug_flags; - marlin_debug_flags |= MARLIN_DEBUG_ECHO; - #endif - // Continue to apply PLR when a file is resumed! enable(true); // Resume the SD file from the last position - char *fn = info.sd_filename; - sprintf_P(cmd, M23_STR, fn); - gcode.process_subcommands_now(cmd); + sprintf_P(cmd, M23_STR, &info.sd_filename[0]); + PROCESS_SUBCOMMANDS_NOW(cmd); sprintf_P(cmd, PSTR("M24S%ldT%ld"), resume_sdpos, info.print_job_elapsed); - gcode.process_subcommands_now(cmd); - - TERN_(DEBUG_POWER_LOSS_RECOVERY, marlin_debug_flags = old_flags); + PROCESS_SUBCOMMANDS_NOW(cmd); } #if ENABLED(DEBUG_POWER_LOSS_RECOVERY) diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index 33d9dc007c0d..d241fdb74c8e 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -138,7 +138,7 @@ class PrintJobRecovery { public: static const char filename[5]; - static SdFile file; + static MediaFile file; static job_recovery_info_t info; static uint8_t queue_index_r; //!< Queue index of the active command @@ -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/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, ")"); } diff --git a/Marlin/src/feature/spindle_laser.cpp b/Marlin/src/feature/spindle_laser.cpp index 4f8f4d49dc2f..c0635c72206f 100644 --- a/Marlin/src/feature/spindle_laser.cpp +++ b/Marlin/src/feature/spindle_laser.cpp @@ -39,18 +39,26 @@ #endif SpindleLaser cutter; -uint8_t SpindleLaser::power, +bool SpindleLaser::enable_state; // Virtual enable state, controls enable pin if present and or apply power if > 0 +uint8_t SpindleLaser::power, // Actual power output 0-255 ocr or "0 = off" > 0 = "on" SpindleLaser::last_power_applied; // = 0 // Basic power state tracking + #if ENABLED(LASER_FEATURE) - cutter_test_pulse_t SpindleLaser::testPulse = 50; // Test fire Pulse time ms value. + cutter_test_pulse_t SpindleLaser::testPulse = 50; // (ms) Test fire pulse default duration + uint8_t SpindleLaser::last_block_power; // = 0 // Track power changes for dynamic inline power + feedRate_t SpindleLaser::feedrate_mm_m = 1500, + SpindleLaser::last_feedrate_mm_m; // = 0 // (mm/min) Track feedrate changes for dynamic power #endif -bool SpindleLaser::isReady; // Ready to apply power setting from the UI to OCR -cutter_power_t SpindleLaser::menuPower, // Power set via LCD menu in PWM, PERCENT, or RPM - SpindleLaser::unitPower; // LCD status power in PWM, PERCENT, or RPM -#if ENABLED(MARLIN_DEV_MODE) - cutter_frequency_t SpindleLaser::frequency; // PWM frequency setting; range: 2K - 50K -#endif +bool SpindleLaser::isReadyForUI = false; // Ready to apply power setting from the UI to OCR +CutterMode SpindleLaser::cutter_mode = CUTTER_MODE_STANDARD; // Default is standard mode + +constexpr cutter_cpower_t SpindleLaser::power_floor; +cutter_power_t SpindleLaser::menuPower = 0, // Power value via LCD menu in PWM, PERCENT, or RPM based on configured format set by CUTTER_POWER_UNIT. + SpindleLaser::unitPower = 0; // Unit power is in PWM, PERCENT, or RPM based on CUTTER_POWER_UNIT. + +cutter_frequency_t SpindleLaser::frequency; // PWM frequency setting; range: 2K - 50K + #define SPINDLE_LASER_PWM_OFF TERN(SPINDLE_LASER_PWM_INVERT, 255, 0) /** @@ -59,20 +67,20 @@ cutter_power_t SpindleLaser::menuPower, // Power s void SpindleLaser::init() { #if ENABLED(SPINDLE_SERVO) servo[SPINDLE_SERVO_NR].move(SPINDLE_SERVO_MIN); - #else + #elif PIN_EXISTS(SPINDLE_LASER_ENA) OUT_WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Init spindle to off #endif #if ENABLED(SPINDLE_CHANGE_DIR) OUT_WRITE(SPINDLE_DIR_PIN, SPINDLE_INVERT_DIR); // Init rotation to clockwise (M3) #endif + #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY + frequency = SPINDLE_LASER_FREQUENCY; + hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY); + #endif #if ENABLED(SPINDLE_LASER_USE_PWM) SET_PWM(SPINDLE_LASER_PWM_PIN); hal.set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Set to lowest speed #endif - #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY - hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY); - TERN_(MARLIN_DEV_MODE, frequency = SPINDLE_LASER_FREQUENCY); - #endif #if ENABLED(AIR_EVACUATION) OUT_WRITE(AIR_EVACUATION_PIN, !AIR_EVACUATION_ACTIVE); // Init Vacuum/Blower OFF #endif @@ -90,52 +98,62 @@ void SpindleLaser::init() { */ void SpindleLaser::_set_ocr(const uint8_t ocr) { #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY - hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), TERN(MARLIN_DEV_MODE, frequency, SPINDLE_LASER_FREQUENCY)); + hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency); #endif hal.set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); } void SpindleLaser::set_ocr(const uint8_t ocr) { - WRITE(SPINDLE_LASER_ENA_PIN, SPINDLE_LASER_ACTIVE_STATE); // Cutter ON + #if PIN_EXISTS(SPINDLE_LASER_ENA) + WRITE(SPINDLE_LASER_ENA_PIN, SPINDLE_LASER_ACTIVE_STATE); // Cutter ON + #endif _set_ocr(ocr); } void SpindleLaser::ocr_off() { - WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Cutter OFF + #if PIN_EXISTS(SPINDLE_LASER_ENA) + WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Cutter OFF + #endif _set_ocr(0); } #endif // SPINDLE_LASER_USE_PWM /** - * Apply power for laser/spindle + * Apply power for Laser or Spindle * * Apply cutter power value for PWM, Servo, and on/off pin. * - * @param opwr Power value. Range 0 to MAX. When 0 disable spindle/laser. + * @param opwr Power value. Range 0 to MAX. */ void SpindleLaser::apply_power(const uint8_t opwr) { - if (opwr == last_power_applied) return; - last_power_applied = opwr; - power = opwr; - #if ENABLED(SPINDLE_LASER_USE_PWM) - if (cutter.unitPower == 0 && CUTTER_UNIT_IS(RPM)) { - ocr_off(); - isReady = false; - } - else if (ENABLED(CUTTER_POWER_RELATIVE) || enabled()) { - set_ocr(power); - isReady = true; - } - else { - ocr_off(); - isReady = false; - } - #elif ENABLED(SPINDLE_SERVO) - servo[SPINDLE_SERVO_NR].move(power); - #else - WRITE(SPINDLE_LASER_ENA_PIN, enabled() ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE); - isReady = true; - #endif + if (enabled() || opwr == 0) { // 0 check allows us to disable where no ENA pin exists + // Test and set the last power used to improve performance + if (opwr == last_power_applied) return; + last_power_applied = opwr; + // Handle PWM driven or just simple on/off + #if ENABLED(SPINDLE_LASER_USE_PWM) + if (CUTTER_UNIT_IS(RPM) && unitPower == 0) + ocr_off(); + else if (ENABLED(CUTTER_POWER_RELATIVE) || enabled() || opwr == 0) { + set_ocr(opwr); + isReadyForUI = true; + } + else + ocr_off(); + #elif ENABLED(SPINDLE_SERVO) + servo[SPINDLE_SERVO_NR].move(opwr); + #else + WRITE(SPINDLE_LASER_ENA_PIN, enabled() ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE); + isReadyForUI = true; + #endif + } + else { + #if PIN_EXISTS(SPINDLE_LASER_ENA) + WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); + #endif + isReadyForUI = false; // Only used for UI display updates. + TERN_(SPINDLE_LASER_USE_PWM, ocr_off()); + } } #if ENABLED(SPINDLE_CHANGE_DIR) diff --git a/Marlin/src/feature/spindle_laser.h b/Marlin/src/feature/spindle_laser.h index 808fa634e162..8908ae6df524 100644 --- a/Marlin/src/feature/spindle_laser.h +++ b/Marlin/src/feature/spindle_laser.h @@ -30,89 +30,100 @@ #include "spindle_laser_types.h" -#if HAS_BEEPER - #include "../libs/buzzer.h" -#endif +#include "../libs/buzzer.h" -#if ENABLED(LASER_POWER_INLINE) - #include "../module/planner.h" -#endif +// Inline laser power +#include "../module/planner.h" #define PCT_TO_PWM(X) ((X) * 255 / 100) #define PCT_TO_SERVO(X) ((X) * 180 / 100) + +// Laser/Cutter operation mode +enum CutterMode : int8_t { + CUTTER_MODE_ERROR = -1, + CUTTER_MODE_STANDARD, // M3 power is applied directly and waits for planner moves to sync. + CUTTER_MODE_CONTINUOUS, // M3 or G1/2/3 move power is controlled within planner blocks, set with 'M3 I', cleared with 'M5 I'. + CUTTER_MODE_DYNAMIC // M4 laser power is proportional to the feed rate, set with 'M4 I', cleared with 'M5 I'. +}; + class SpindleLaser { public: - static const inline uint8_t pct_to_ocr(const_float_t pct) { return uint8_t(PCT_TO_PWM(pct)); } + static CutterMode cutter_mode; - // cpower = configured values (e.g., SPEED_POWER_MAX) + static constexpr uint8_t pct_to_ocr(const_float_t pct) { return uint8_t(PCT_TO_PWM(pct)); } + // cpower = configured values (e.g., SPEED_POWER_MAX) // Convert configured power range to a percentage - static const inline uint8_t cpwr_to_pct(const cutter_cpower_t cpwr) { - constexpr cutter_cpower_t power_floor = TERN(CUTTER_POWER_RELATIVE, SPEED_POWER_MIN, 0), - power_range = SPEED_POWER_MAX - power_floor; - return cpwr ? round(100.0f * (cpwr - power_floor) / power_range) : 0; + static constexpr cutter_cpower_t power_floor = TERN(CUTTER_POWER_RELATIVE, SPEED_POWER_MIN, 0); + static constexpr uint8_t cpwr_to_pct(const cutter_cpower_t cpwr) { + return cpwr ? round(100.0f * (cpwr - power_floor) / (SPEED_POWER_MAX - power_floor)) : 0; } - // Convert a cpower (e.g., SPEED_POWER_STARTUP) to unit power (upwr, upower), - // which can be PWM, Percent, Servo angle, or RPM (rel/abs). - static const inline cutter_power_t cpwr_to_upwr(const cutter_cpower_t cpwr) { // STARTUP power to Unit power - const cutter_power_t upwr = ( + // Convert config defines from RPM to %, angle or PWM when in Spindle mode + // and convert from PERCENT to PWM when in Laser mode + static constexpr cutter_power_t cpwr_to_upwr(const cutter_cpower_t cpwr) { // STARTUP power to Unit power + return ( #if ENABLED(SPINDLE_FEATURE) - // Spindle configured values are in RPM + // Spindle configured define values are in RPM #if CUTTER_UNIT_IS(RPM) - cpwr // to RPM - #elif CUTTER_UNIT_IS(PERCENT) // to PCT - cpwr_to_pct(cpwr) - #elif CUTTER_UNIT_IS(SERVO) // to SERVO angle - PCT_TO_SERVO(cpwr_to_pct(cpwr)) - #else // to PWM - PCT_TO_PWM(cpwr_to_pct(cpwr)) + cpwr // to same + #elif CUTTER_UNIT_IS(PERCENT) + cpwr_to_pct(cpwr) // to Percent + #elif CUTTER_UNIT_IS(SERVO) + PCT_TO_SERVO(cpwr_to_pct(cpwr)) // to SERVO angle + #else + PCT_TO_PWM(cpwr_to_pct(cpwr)) // to PWM #endif #else - // Laser configured values are in PCT + // Laser configured define values are in Percent #if CUTTER_UNIT_IS(PWM255) - PCT_TO_PWM(cpwr) + PCT_TO_PWM(cpwr) // to PWM #else - cpwr // to RPM/PCT + cpwr // to same #endif #endif ); - return upwr; } - static const cutter_power_t mpower_min() { return cpwr_to_upwr(SPEED_POWER_MIN); } - static const cutter_power_t mpower_max() { return cpwr_to_upwr(SPEED_POWER_MAX); } + static constexpr cutter_power_t mpower_min() { return cpwr_to_upwr(SPEED_POWER_MIN); } + static constexpr cutter_power_t mpower_max() { return cpwr_to_upwr(SPEED_POWER_MAX); } #if ENABLED(LASER_FEATURE) - static cutter_test_pulse_t testPulse; // Test fire Pulse ms value + static cutter_test_pulse_t testPulse; // (ms) Test fire pulse duration + static uint8_t last_block_power; // Track power changes for dynamic power + + static feedRate_t feedrate_mm_m, last_feedrate_mm_m; // (mm/min) Track feedrate changes for dynamic power + static bool laser_feedrate_changed() { + const bool changed = last_feedrate_mm_m != feedrate_mm_m; + if (changed) last_feedrate_mm_m = feedrate_mm_m; + return changed; + } #endif - static bool isReady; // Ready to apply power setting from the UI to OCR + static bool isReadyForUI; // Ready to apply power setting from the UI to OCR + static bool enable_state; static uint8_t power, last_power_applied; // Basic power state tracking - #if ENABLED(MARLIN_DEV_MODE) - static cutter_frequency_t frequency; // Set PWM frequency; range: 2K-50K - #endif + static cutter_frequency_t frequency; // Set PWM frequency; range: 2K-50K static cutter_power_t menuPower, // Power as set via LCD menu in PWM, Percentage or RPM unitPower; // Power as displayed status in PWM, Percentage or RPM static void init(); - #if ENABLED(MARLIN_DEV_MODE) + #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY static void refresh_frequency() { hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency); } #endif // Modifying this function should update everywhere static bool enabled(const cutter_power_t opwr) { return opwr > 0; } - static bool enabled() { return enabled(power); } + static bool enabled() { return enable_state; } static void apply_power(const uint8_t inpow); FORCE_INLINE static void refresh() { apply_power(power); } - FORCE_INLINE static void set_power(const uint8_t upwr) { power = upwr; refresh(); } #if ENABLED(SPINDLE_LASER_USE_PWM) @@ -123,7 +134,6 @@ class SpindleLaser { public: static void set_ocr(const uint8_t ocr); - static void ocr_set_power(const uint8_t ocr) { power = ocr; set_ocr(ocr); } static void ocr_off(); /** @@ -141,78 +151,74 @@ class SpindleLaser { ); } - /** - * Correct power to configured range - */ - static cutter_power_t power_to_range(const cutter_power_t pwr) { - return power_to_range(pwr, _CUTTER_POWER(CUTTER_POWER_UNIT)); - } - - static cutter_power_t power_to_range(const cutter_power_t pwr, const uint8_t pwrUnit) { - static constexpr float - min_pct = TERN(CUTTER_POWER_RELATIVE, 0, TERN(SPINDLE_FEATURE, round(100.0f * (SPEED_POWER_MIN) / (SPEED_POWER_MAX)), SPEED_POWER_MIN)), - max_pct = TERN(SPINDLE_FEATURE, 100, SPEED_POWER_MAX); - if (pwr <= 0) return 0; - cutter_power_t upwr; - switch (pwrUnit) { - case _CUTTER_POWER_PWM255: - upwr = cutter_power_t( - (pwr < pct_to_ocr(min_pct)) ? pct_to_ocr(min_pct) // Use minimum if set below - : (pwr > pct_to_ocr(max_pct)) ? pct_to_ocr(max_pct) // Use maximum if set above - : pwr - ); - break; - case _CUTTER_POWER_PERCENT: - upwr = cutter_power_t( - (pwr < min_pct) ? min_pct // Use minimum if set below - : (pwr > max_pct) ? max_pct // Use maximum if set above - : pwr // PCT - ); - break; - case _CUTTER_POWER_RPM: - upwr = cutter_power_t( - (pwr < SPEED_POWER_MIN) ? SPEED_POWER_MIN // Use minimum if set below - : (pwr > SPEED_POWER_MAX) ? SPEED_POWER_MAX // Use maximum if set above - : pwr // Calculate OCR value - ); - break; - default: break; - } - return upwr; - } - #endif // SPINDLE_LASER_USE_PWM /** - * Enable/Disable spindle/laser - * @param enable true = enable; false = disable + * Correct power to configured range */ - static void set_enabled(const bool enable) { - uint8_t value = 0; - if (enable) { - #if ENABLED(SPINDLE_LASER_USE_PWM) - if (power) - value = power; - else if (unitPower) - value = upower_to_ocr(cpwr_to_upwr(SPEED_POWER_STARTUP)); - #else - value = 255; - #endif + static cutter_power_t power_to_range(const cutter_power_t pwr, const uint8_t pwrUnit=_CUTTER_POWER(CUTTER_POWER_UNIT)) { + static constexpr float + min_pct = TERN(CUTTER_POWER_RELATIVE, 0, TERN(SPINDLE_FEATURE, round(100.0f * (SPEED_POWER_MIN) / (SPEED_POWER_MAX)), SPEED_POWER_MIN)), + max_pct = TERN(SPINDLE_FEATURE, 100, SPEED_POWER_MAX); + if (pwr <= 0) return 0; + cutter_power_t upwr; + switch (pwrUnit) { + case _CUTTER_POWER_PWM255: { // PWM + const uint8_t pmin = pct_to_ocr(min_pct), pmax = pct_to_ocr(max_pct); + upwr = cutter_power_t(constrain(pwr, pmin, pmax)); + } break; + case _CUTTER_POWER_PERCENT: // Percent + upwr = cutter_power_t(constrain(pwr, min_pct, max_pct)); + break; + case _CUTTER_POWER_RPM: // Calculate OCR value + upwr = cutter_power_t(constrain(pwr, SPEED_POWER_MIN, SPEED_POWER_MAX)); + break; + default: break; } - set_power(value); + return upwr; } - static void disable() { isReady = false; set_enabled(false); } - /** - * Wait for spindle to spin up or spin down + * Enable Laser or Spindle output. + * It's important to prevent changing the power output value during inline cutter operation. + * Inline power is adjusted in the planner to support LASER_TRAP_POWER and CUTTER_MODE_DYNAMIC mode. + * + * This method accepts one of the following control states: + * + * - For CUTTER_MODE_STANDARD the cutter power is either full on/off or ocr-based and it will apply + * SPEED_POWER_STARTUP if no value is assigned. * - * @param on true = state to on; false = state to off. + * - For CUTTER_MODE_CONTINUOUS inline and power remains where last set and the cutter output enable flag is set. + * + * - CUTTER_MODE_DYNAMIC is also inline-based and it just sets the enable output flag. + * + * - For CUTTER_MODE_ERROR set the output enable_state flag directly and set power to 0 for any mode. + * This mode allows a global power shutdown action to occur. */ - static void power_delay(const bool on) { - #if DISABLED(LASER_POWER_INLINE) - safe_delay(on ? SPINDLE_LASER_POWERUP_DELAY : SPINDLE_LASER_POWERDOWN_DELAY); + static void set_enabled(bool enable) { + switch (cutter_mode) { + case CUTTER_MODE_STANDARD: + apply_power(enable ? TERN(SPINDLE_LASER_USE_PWM, (power ?: (unitPower ? upower_to_ocr(cpwr_to_upwr(SPEED_POWER_STARTUP)) : 0)), 255) : 0); + break; + case CUTTER_MODE_CONTINUOUS: + case CUTTER_MODE_DYNAMIC: + TERN_(LASER_FEATURE, set_inline_enabled(enable)); + break; + case CUTTER_MODE_ERROR: // Error mode, no enable and kill power. + enable = false; + apply_power(0); + } + #if PIN_EXISTS(SPINDLE_LASER_ENA) + WRITE(SPINDLE_LASER_ENA_PIN, enable ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE); #endif + enable_state = enable; + } + + static void disable() { isReadyForUI = false; set_enabled(false); } + + // Wait for spindle/laser to startup or shutdown + static void power_delay(const bool on) { + safe_delay(on ? SPINDLE_LASER_POWERUP_DELAY : SPINDLE_LASER_POWERDOWN_DELAY); } #if ENABLED(SPINDLE_CHANGE_DIR) @@ -224,122 +230,98 @@ class SpindleLaser { #endif #if ENABLED(AIR_EVACUATION) - static void air_evac_enable(); // Turn On Cutter Vacuum or Laser Blower motor - static void air_evac_disable(); // Turn Off Cutter Vacuum or Laser Blower motor - static void air_evac_toggle(); // Toggle Cutter Vacuum or Laser Blower motor - static bool air_evac_state() { // Get current state + static void air_evac_enable(); // Turn On Cutter Vacuum or Laser Blower motor + static void air_evac_disable(); // Turn Off Cutter Vacuum or Laser Blower motor + static void air_evac_toggle(); // Toggle Cutter Vacuum or Laser Blower motor + static bool air_evac_state() { // Get current state return (READ(AIR_EVACUATION_PIN) == AIR_EVACUATION_ACTIVE); } #endif #if ENABLED(AIR_ASSIST) - static void air_assist_enable(); // Turn on air assist - static void air_assist_disable(); // Turn off air assist - static void air_assist_toggle(); // Toggle air assist - static bool air_assist_state() { // Get current state + static void air_assist_enable(); // Turn on air assist + static void air_assist_disable(); // Turn off air assist + static void air_assist_toggle(); // Toggle air assist + static bool air_assist_state() { // Get current state return (READ(AIR_ASSIST_PIN) == AIR_ASSIST_ACTIVE); } #endif #if HAS_MARLINUI_MENU - static void enable_with_dir(const bool reverse) { - isReady = true; - const uint8_t ocr = TERN(SPINDLE_LASER_USE_PWM, upower_to_ocr(menuPower), 255); - if (menuPower) - power = ocr; - else - menuPower = cpwr_to_upwr(SPEED_POWER_STARTUP); - unitPower = menuPower; - set_reverse(reverse); - set_enabled(true); - } - FORCE_INLINE static void enable_forward() { enable_with_dir(false); } - FORCE_INLINE static void enable_reverse() { enable_with_dir(true); } - FORCE_INLINE static void enable_same_dir() { enable_with_dir(is_reverse()); } + + #if ENABLED(SPINDLE_FEATURE) + static void enable_with_dir(const bool reverse) { + isReadyForUI = true; + const uint8_t ocr = TERN(SPINDLE_LASER_USE_PWM, upower_to_ocr(menuPower), 255); + if (menuPower) + power = ocr; + else + menuPower = cpwr_to_upwr(SPEED_POWER_STARTUP); + unitPower = menuPower; + set_reverse(reverse); + set_enabled(true); + } + FORCE_INLINE static void enable_forward() { enable_with_dir(false); } + FORCE_INLINE static void enable_reverse() { enable_with_dir(true); } + FORCE_INLINE static void enable_same_dir() { enable_with_dir(is_reverse()); } + #endif // SPINDLE_FEATURE #if ENABLED(SPINDLE_LASER_USE_PWM) static void update_from_mpower() { - if (isReady) power = upower_to_ocr(menuPower); + if (isReadyForUI) power = upower_to_ocr(menuPower); unitPower = menuPower; } #endif #if ENABLED(LASER_FEATURE) + // Toggle the laser on/off with menuPower. Apply SPEED_POWER_STARTUP if it was 0 on entry. + static void menu_set_enabled(const bool state) { + set_enabled(state); + if (state) { + if (!menuPower) menuPower = cpwr_to_upwr(SPEED_POWER_STARTUP); + power = TERN(SPINDLE_LASER_USE_PWM, upower_to_ocr(menuPower), 255); + apply_power(power); + } else + apply_power(0); + } + /** * Test fire the laser using the testPulse ms duration * Also fires with any PWM power that was previous set * If not set defaults to 80% power */ static void test_fire_pulse() { - TERN_(HAS_BEEPER, buzzer.tone(30, 3000)); - enable_forward(); // Turn Laser on (Spindle speak but same funct) - delay(testPulse); // Delay for time set by user in pulse ms menu screen. - disable(); // Turn laser off + BUZZ(30, 3000); + cutter_mode = CUTTER_MODE_STANDARD; // Menu needs standard mode. + menu_set_enabled(true); // Laser On + delay(testPulse); // Delay for time set by user in pulse ms menu screen. + menu_set_enabled(false); // Laser Off } - #endif + #endif // LASER_FEATURE #endif // HAS_MARLINUI_MENU - #if ENABLED(LASER_POWER_INLINE) - /** - * Inline power adds extra fields to the planner block - * to handle laser power and scale to movement speed. - */ + #if ENABLED(LASER_FEATURE) - // Force disengage planner power control - static void inline_disable() { - isReady = false; - unitPower = 0; - planner.laser_inline.status.isPlanned = false; - planner.laser_inline.status.isEnabled = false; - planner.laser_inline.power = 0; + // Dynamic mode rate calculation + static uint8_t calc_dynamic_power() { + if (feedrate_mm_m > 65535) return 255; // Too fast, go always on + uint16_t rate = uint16_t(feedrate_mm_m); // 16 bits from the G-code parser float input + rate >>= 8; // Take the G-code input e.g. F40000 and shift off the lower bits to get an OCR value from 1-255 + return uint8_t(rate); } // Inline modes of all other functions; all enable planner inline power control - static void set_inline_enabled(const bool enable) { - if (enable) - inline_power(255); - else { - isReady = false; - unitPower = menuPower = 0; - planner.laser_inline.status.isPlanned = false; - TERN(SPINDLE_LASER_USE_PWM, inline_ocr_power, inline_power)(0); - } - } + static void set_inline_enabled(const bool enable) { planner.laser_inline.status.isEnabled = enable; } // Set the power for subsequent movement blocks - static void inline_power(const cutter_power_t upwr) { - unitPower = menuPower = upwr; - #if ENABLED(SPINDLE_LASER_USE_PWM) - #if ENABLED(SPEED_POWER_RELATIVE) && !CUTTER_UNIT_IS(RPM) // relative mode does not turn laser off at 0, except for RPM - planner.laser_inline.status.isEnabled = true; - planner.laser_inline.power = upower_to_ocr(upwr); - isReady = true; - #else - inline_ocr_power(upower_to_ocr(upwr)); - #endif - #else - planner.laser_inline.status.isEnabled = enabled(upwr); - planner.laser_inline.power = upwr; - isReady = enabled(upwr); - #endif + static void inline_power(const cutter_power_t cpwr) { + TERN(SPINDLE_LASER_USE_PWM, power = planner.laser_inline.power = cpwr, planner.laser_inline.power = cpwr > 0 ? 255 : 0); } - static void inline_direction(const bool) { /* never */ } - - #if ENABLED(SPINDLE_LASER_USE_PWM) - static void inline_ocr_power(const uint8_t ocrpwr) { - isReady = ocrpwr > 0; - planner.laser_inline.status.isEnabled = ocrpwr > 0; - planner.laser_inline.power = ocrpwr; - } - #endif - #endif // LASER_POWER_INLINE + #endif // LASER_FEATURE - static void kill() { - TERN_(LASER_POWER_INLINE, inline_disable()); - disable(); - } + static void kill() { disable(); } }; extern SpindleLaser cutter; diff --git a/Marlin/src/feature/spindle_laser_types.h b/Marlin/src/feature/spindle_laser_types.h index d249a20e7531..2f36a68a1a32 100644 --- a/Marlin/src/feature/spindle_laser_types.h +++ b/Marlin/src/feature/spindle_laser_types.h @@ -74,12 +74,10 @@ typedef IF<(SPEED_POWER_MAX > 255), uint16_t, uint8_t>::type cutter_cpower_t; #endif #endif +typedef uint16_t cutter_frequency_t; + #if ENABLED(LASER_FEATURE) typedef uint16_t cutter_test_pulse_t; #define CUTTER_MENU_PULSE_TYPE uint16_3 -#endif - -#if ENABLED(MARLIN_DEV_MODE) - typedef uint16_t cutter_frequency_t; #define CUTTER_MENU_FREQUENCY_TYPE uint16_5 #endif diff --git a/Marlin/src/feature/stepper_driver_safety.cpp b/Marlin/src/feature/stepper_driver_safety.cpp index b8762da9b0c0..d3fc1614861e 100644 --- a/Marlin/src/feature/stepper_driver_safety.cpp +++ b/Marlin/src/feature/stepper_driver_safety.cpp @@ -43,7 +43,7 @@ void stepper_driver_backward_check() { SET_INPUT(AXIS##_ENABLE_PIN); \ OUT_WRITE(AXIS##_STEP_PIN, false); \ delay(20); \ - if (READ(AXIS##_ENABLE_PIN) == false) { \ + if (READ(AXIS##_ENABLE_PIN) == LOW) { \ SBI(axis_plug_backward, BIT); \ stepper_driver_backward_error(F(STRINGIFY(AXIS))); \ } \ diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index cb970c7ebc87..2e5a5c55850b 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -33,17 +33,12 @@ #include "../gcode/gcode.h" #if ENABLED(TMC_DEBUG) - #include "../module/planner.h" #include "../libs/hex_print.h" #if ENABLED(MONITOR_DRIVER_STATUS) static uint16_t report_tmc_status_interval; // = 0 #endif #endif -#if HAS_MARLINUI_MENU - #include "../module/stepper.h" -#endif - /** * Check for over temperature or short to ground error flags. * Report and log warning of overtemperature condition. @@ -606,8 +601,8 @@ case TMC_STEALTHCHOP: serialprint_truefalse(st.en_pwm_mode()); break; case TMC_GLOBAL_SCALER: { - uint16_t value = st.GLOBAL_SCALER(); - SERIAL_ECHO(value ? value : 256); + const uint16_t value = st.GLOBAL_SCALER(); + SERIAL_ECHO(value ?: 256); SERIAL_ECHOPGM("/256"); } break; diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index 21fa08fc107a..fe20423b8d8b 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -107,7 +107,6 @@ #include "../../MarlinCore.h" #include "../../module/planner.h" -#include "../../module/stepper.h" #include "../../module/motion.h" #include "../../module/tool_change.h" #include "../../module/temperature.h" @@ -163,8 +162,8 @@ float g26_random_deviation = 0.0; */ bool user_canceled() { if (!ui.button_pressed()) return false; // Return if the button isn't pressed - ui.set_status(GET_TEXT_F(MSG_G26_CANCELED), 99); - TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); + LCD_MESSAGE_MAX(MSG_G26_CANCELED); + ui.quick_feedback(); ui.wait_for_release(); return true; } @@ -306,7 +305,7 @@ typedef struct { LIMIT(e.x, X_MIN_POS + 1, X_MAX_POS - 1); #endif - if (position_is_reachable(s.x, s.y) && position_is_reachable(e.x, e.y)) + if (position_is_reachable(s) && position_is_reachable(e)) print_line_from_here_to_there(s, e); } } @@ -322,11 +321,9 @@ typedef struct { #if HAS_HEATED_BED if (bed_temp > 25) { - #if HAS_WIRED_LCD - ui.set_status(GET_TEXT_F(MSG_G26_HEATING_BED), 99); - ui.quick_feedback(); - TERN_(HAS_MARLINUI_MENU, ui.capture()); - #endif + LCD_MESSAGE_MAX(MSG_G26_HEATING_BED); + ui.quick_feedback(); + TERN_(HAS_MARLINUI_MENU, ui.capture()); thermalManager.setTargetBed(bed_temp); // Wait for the temperature to stabilize @@ -341,20 +338,16 @@ typedef struct { #endif // HAS_HEATED_BED // Start heating the active nozzle - #if HAS_WIRED_LCD - ui.set_status(GET_TEXT_F(MSG_G26_HEATING_NOZZLE), 99); - ui.quick_feedback(); - #endif + LCD_MESSAGE_MAX(MSG_G26_HEATING_NOZZLE); + ui.quick_feedback(); thermalManager.setTargetHotend(hotend_temp, active_extruder); // Wait for the temperature to stabilize if (!thermalManager.wait_for_hotend(active_extruder, true OPTARG(G26_CLICK_CAN_CANCEL, true))) return G26_ERR; - #if HAS_WIRED_LCD - ui.reset_status(); - ui.quick_feedback(); - #endif + ui.reset_status(); + ui.completion_feedback(); return G26_OK; } @@ -372,7 +365,7 @@ typedef struct { if (prime_flag == -1) { // The user wants to control how much filament gets purged ui.capture(); - ui.set_status(GET_TEXT_F(MSG_G26_MANUAL_PRIME), 99); + LCD_MESSAGE_MAX(MSG_G26_MANUAL_PRIME); ui.chirp(); destination = current_position; @@ -399,17 +392,15 @@ typedef struct { ui.wait_for_release(); - ui.set_status(GET_TEXT_F(MSG_G26_PRIME_DONE), 99); + LCD_MESSAGE_MAX(MSG_G26_PRIME_DONE); ui.quick_feedback(); ui.release(); } else #endif { - #if HAS_WIRED_LCD - ui.set_status(GET_TEXT_F(MSG_G26_FIXED_LENGTH), 99); - ui.quick_feedback(); - #endif + LCD_MESSAGE_MAX(MSG_G26_FIXED_LENGTH); + ui.quick_feedback(); destination = current_position; destination.e += prime_length; prepare_internal_move_to_destination(fr_slow_e); @@ -854,7 +845,7 @@ void GcodeSuite::G26() { } while (--g26_repeats && location.valid()); LEAVE: - ui.set_status(GET_TEXT_F(MSG_G26_LEAVING), -1); + LCD_MESSAGE_MIN(MSG_G26_LEAVING); TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location, ExtUI::G26_FINISH)); g26.retract_filament(destination); diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index a2c53b5ab253..79f92f7482a2 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -32,7 +32,6 @@ #include "../../../feature/bedlevel/bedlevel.h" #include "../../../module/motion.h" #include "../../../module/planner.h" -#include "../../../module/stepper.h" #include "../../../module/probe.h" #include "../../queue.h" @@ -410,7 +409,7 @@ G29_TYPE GcodeSuite::G29() { if (!probe.good_bounds(abl.probe_position_lf, abl.probe_position_rb)) { if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPGM("G29 L", abl.probe_position_lf.x, " R", abl.probe_position_rb.x, - " F", abl.probe_position_lf.y, " B", abl.probe_position_rb.y); + " F", abl.probe_position_lf.y, " B", abl.probe_position_rb.y); } SERIAL_ECHOLNPGM("? (L,R,F,B) out of bounds."); G29_RETURN(false, false); @@ -418,7 +417,7 @@ G29_TYPE GcodeSuite::G29() { // Probe at the points of a lattice grid abl.gridSpacing.set((abl.probe_position_rb.x - abl.probe_position_lf.x) / (abl.grid_points.x - 1), - (abl.probe_position_rb.y - abl.probe_position_lf.y) / (abl.grid_points.y - 1)); + (abl.probe_position_rb.y - abl.probe_position_lf.y) / (abl.grid_points.y - 1)); #endif // ABL_USES_GRID @@ -454,9 +453,7 @@ G29_TYPE GcodeSuite::G29() { } // Position bed horizontally and Z probe vertically. - #if defined(SAFE_BED_LEVELING_START_X) || defined(SAFE_BED_LEVELING_START_Y) || defined(SAFE_BED_LEVELING_START_Z) \ - || defined(SAFE_BED_LEVELING_START_I) || defined(SAFE_BED_LEVELING_START_J) || defined(SAFE_BED_LEVELING_START_K) \ - || defined(SAFE_BED_LEVELING_START_U) || defined(SAFE_BED_LEVELING_START_V) || defined(SAFE_BED_LEVELING_START_W) + #if HAS_SAFE_BED_LEVELING xyze_pos_t safe_position = current_position; #ifdef SAFE_BED_LEVELING_START_X safe_position.x = SAFE_BED_LEVELING_START_X; @@ -487,7 +484,7 @@ G29_TYPE GcodeSuite::G29() { #endif do_blocking_move_to(safe_position); - #endif + #endif // HAS_SAFE_BED_LEVELING // Disable auto bed leveling during G29. // Be formal so G29 can be done successively without G28. diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index b9440f78b2e9..e3e96a7960c2 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -36,7 +36,7 @@ #include "../../../libs/buzzer.h" #include "../../../lcd/marlinui.h" #include "../../../module/motion.h" -#include "../../../module/stepper.h" +#include "../../../module/planner.h" #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extui/ui_api.h" @@ -108,9 +108,7 @@ void GcodeSuite::G29() { TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart()); // Position bed horizontally and Z probe vertically. - #if defined(SAFE_BED_LEVELING_START_X) || defined(SAFE_BED_LEVELING_START_Y) || defined(SAFE_BED_LEVELING_START_Z) \ - || defined(SAFE_BED_LEVELING_START_I) || defined(SAFE_BED_LEVELING_START_J) || defined(SAFE_BED_LEVELING_START_K) \ - || defined(SAFE_BED_LEVELING_START_U) || defined(SAFE_BED_LEVELING_START_V) || defined(SAFE_BED_LEVELING_START_W) + #if HAS_SAFE_BED_LEVELING xyze_pos_t safe_position = current_position; #ifdef SAFE_BED_LEVELING_START_X safe_position.x = SAFE_BED_LEVELING_START_X; @@ -141,7 +139,7 @@ void GcodeSuite::G29() { #endif do_blocking_move_to(safe_position); - #endif + #endif // HAS_SAFE_BED_LEVELING return; } diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 27551fb10911..a9f378adfc90 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -24,8 +24,9 @@ #include "../gcode.h" -#include "../../module/stepper.h" #include "../../module/endstops.h" +#include "../../module/planner.h" +#include "../../module/stepper.h" // for various #if HAS_MULTI_HOTEND #include "../../module/tool_change.h" @@ -35,6 +36,10 @@ #include "../../feature/bedlevel/bedlevel.h" #endif +#if ENABLED(BD_SENSOR) + #include "../../feature/bedlevel/bdl/bdl.h" +#endif + #if ENABLED(SENSORLESS_HOMING) #include "../../feature/tmc_util.h" #endif @@ -55,11 +60,7 @@ #include "../../lcd/e3v2/proui/dwin.h" #endif -#if HAS_L64XX // set L6470 absolute position registers to counts - #include "../../libs/L64XX/L64XX_Marlin.h" -#endif - -#if ENABLED(LASER_MOVE_G28_OFF) +#if ENABLED(LASER_FEATURE) #include "../../feature/spindle_laser.h" #endif @@ -169,7 +170,7 @@ motion_state.jerk_state = planner.max_jerk; planner.max_jerk.set(0, 0 OPTARG(DELTA, 0)); #endif - planner.reset_acceleration_rates(); + planner.refresh_acceleration_rates(); return motion_state; } @@ -178,7 +179,7 @@ planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = motion_state.acceleration.y; TERN_(DELTA, planner.settings.max_acceleration_mm_per_s2[Z_AXIS] = motion_state.acceleration.z); TERN_(HAS_CLASSIC_JERK, planner.max_jerk = motion_state.jerk_state); - planner.reset_acceleration_rates(); + planner.refresh_acceleration_rates(); } #endif // IMPROVE_HOMING_RELIABILITY @@ -205,7 +206,14 @@ void GcodeSuite::G28() { DEBUG_SECTION(log_G28, "G28", DEBUGGING(LEVELING)); if (DEBUGGING(LEVELING)) log_machine_info(); - TERN_(LASER_MOVE_G28_OFF, cutter.set_inline_enabled(false)); // turn off laser + TERN_(BD_SENSOR, bdl.config_state = 0); + + /** + * Set the laser power to false to stop the planner from processing the current power setting. + */ + #if ENABLED(LASER_FEATURE) + planner.laser_inline.status.isPowered = false; + #endif #if ENABLED(DUAL_X_CARRIAGE) bool IDEX_saved_duplication_state = extruder_duplication_enabled; @@ -395,26 +403,44 @@ void GcodeSuite::G28() { UNUSED(needZ); UNUSED(homeZZ); #else constexpr bool doZ = false; + #if !HAS_Y_AXIS + constexpr bool doY = false; + #endif #endif + // Z may home first, e.g., when homing away from the bed TERN_(HOME_Z_FIRST, if (doZ) homeaxis(Z_AXIS)); + // 'R' to specify a specific raise. 'R0' indicates no raise, e.g., for recovery.resume + // When 'R0' is used, there should already be adequate clearance, e.g., from homing Z to max. const bool seenR = parser.seenval('R'); - const float z_homing_height = seenR ? parser.value_linear_units() : Z_HOMING_HEIGHT; - if (z_homing_height && (seenR || NUM_AXIS_GANG(doX, || doY, || TERN0(Z_SAFE_HOMING, doZ), || doI, || doJ, || doK, || doU, || doV, || doW))) { + // Use raise given by 'R' or Z_HOMING_HEIGHT (above the probe trigger point) + float z_homing_height = seenR ? parser.value_linear_units() : Z_HOMING_HEIGHT; + + // Check for any lateral motion that might require clearance + const bool may_skate = seenR || NUM_AXIS_GANG(doX, || doY, || TERN0(Z_SAFE_HOMING, doZ), || doI, || doJ, || doK, || doU, || doV, || doW); + + if (seenR && z_homing_height == 0) { + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("R0 = No Z raise"); + } + else if (z_homing_height && may_skate) { // Raise Z before homing any other axes and z is not already high enough (never lower z) - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Raise Z (before homing) by ", z_homing_height); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Raise Z before homing:"); do_z_clearance(z_homing_height); - TERN_(BLTOUCH, bltouch.init()); } + // Init BLTouch ahead of any lateral motion, even if not homing with the probe + TERN_(BLTOUCH, if (may_skate) bltouch.init()); + // Diagonal move first if both are homing TERN_(QUICK_HOME, if (doX && doY) quick_home_xy()); - // Home Y (before X) - if (ENABLED(HOME_Y_BEFORE_X) && (doY || TERN0(CODEPENDENT_XY_HOMING, doX))) - homeaxis(Y_AXIS); + #if HAS_Y_AXIS + // Home Y (before X) + if (ENABLED(HOME_Y_BEFORE_X) && (doY || TERN0(CODEPENDENT_XY_HOMING, doX))) + homeaxis(Y_AXIS); + #endif // Home X if (doX || (doY && ENABLED(CODEPENDENT_XY_HOMING) && DISABLED(HOME_Y_BEFORE_X))) { @@ -447,9 +473,11 @@ void GcodeSuite::G28() { if (doI) homeaxis(I_AXIS); #endif - // Home Y (after X) - if (DISABLED(HOME_Y_BEFORE_X) && doY) - homeaxis(Y_AXIS); + #if HAS_Y_AXIS + // Home Y (after X) + if (DISABLED(HOME_Y_BEFORE_X) && doY) + homeaxis(Y_AXIS); + #endif #if BOTH(FOAMCUTTER_XYUV, HAS_J_AXIS) // Home J (after Y) @@ -596,20 +624,4 @@ void GcodeSuite::G28() { TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(old_grblstate)); - #if HAS_L64XX - // Set L6470 absolute position registers to counts - // constexpr *might* move this to PROGMEM. - // If not, this will need a PROGMEM directive and an accessor. - #define _EN_ITEM(N) , E_AXIS - static constexpr AxisEnum L64XX_axis_xref[MAX_L64XX] = { - NUM_AXIS_LIST(X_AXIS, Y_AXIS, Z_AXIS, I_AXIS, J_AXIS, K_AXIS, U_AXIS, V_AXIS, W_AXIS), - X_AXIS, Y_AXIS, Z_AXIS, Z_AXIS, Z_AXIS - REPEAT(E_STEPPERS, _EN_ITEM) - }; - #undef _EN_ITEM - for (uint8_t j = 1; j <= L64XX::chain[0]; j++) { - const uint8_t cv = L64XX::chain[j]; - L64xxManager.set_param((L64XX_axis_t)cv, L6470_ABS_POS, stepper.position(L64XX_axis_xref[cv])); - } - #endif } diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index ffe53b63fbef..d9dc3e6a525c 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -27,7 +27,7 @@ #include "../gcode.h" #include "../../module/delta.h" #include "../../module/motion.h" -#include "../../module/stepper.h" +#include "../../module/planner.h" #include "../../module/endstops.h" #include "../../lcd/marlinui.h" @@ -464,8 +464,8 @@ void GcodeSuite::G33() { SERIAL_ECHOLNPGM("G33 Auto Calibrate"); // Report settings - PGM_P const checkingac = PSTR("Checking... AC"); - SERIAL_ECHOPGM_P(checkingac); + FSTR_P const checkingac = F("Checking... AC"); + SERIAL_ECHOF(checkingac); SERIAL_ECHOPGM(" at radius:", dcr); if (verbose_level == 0) SERIAL_ECHOPGM(" (DRY-RUN)"); SERIAL_EOL(); diff --git a/Marlin/src/gcode/calibrate/G34.cpp b/Marlin/src/gcode/calibrate/G34.cpp index 6fdebb69b0f0..7ae1e7765caa 100644 --- a/Marlin/src/gcode/calibrate/G34.cpp +++ b/Marlin/src/gcode/calibrate/G34.cpp @@ -26,9 +26,12 @@ #include "../gcode.h" #include "../../module/motion.h" -#include "../../module/stepper.h" #include "../../module/endstops.h" +#if ANY(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_PWM, HAS_TRINAMIC_CONFIG) + #include "../../module/stepper.h" +#endif + #if HAS_LEVELING #include "../../feature/bedlevel/bedlevel.h" #endif @@ -55,7 +58,7 @@ void GcodeSuite::G34() { // Move XY to safe position if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Parking XY"); const xy_pos_t safe_pos = GANTRY_CALIBRATION_SAFE_POSITION; - do_blocking_move_to(safe_pos, MMM_TO_MMS(GANTRY_CALIBRATION_XY_PARK_FEEDRATE)); + do_blocking_move_to_xy(safe_pos, MMM_TO_MMS(GANTRY_CALIBRATION_XY_PARK_FEEDRATE)); #endif const float move_distance = parser.intval('Z', GANTRY_CALIBRATION_EXTRA_HEIGHT), diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index d68207885d39..8cf652cd8411 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -224,13 +224,15 @@ void GcodeSuite::G34() { // Safe clearance even on an incline if ((iteration == 0 || i > 0) && z_probe > current_position.z) do_blocking_move_to_z(z_probe); + xy_pos_t &ppos = z_stepper_align.xy[iprobe]; + if (DEBUGGING(LEVELING)) - DEBUG_ECHOLNPGM_P(PSTR("Probing X"), z_stepper_align.xy[iprobe].x, SP_Y_STR, z_stepper_align.xy[iprobe].y); + DEBUG_ECHOLNPGM_P(PSTR("Probing X"), ppos.x, SP_Y_STR, ppos.y); // Probe a Z height for each stepper. // Probing sanity check is disabled, as it would trigger even in normal cases because // current_position.z has been manually altered in the "dirty trick" above. - const float z_probed_height = probe.probe_at_point(z_stepper_align.xy[iprobe], raise_after, 0, true, false); + const float z_probed_height = probe.probe_at_point(DIFF_TERN(HAS_HOME_OFFSET, ppos, xy_pos_t(home_offset)), raise_after, 0, true, false); if (isnan(z_probed_height)) { SERIAL_ECHOLNPGM("Probing failed"); LCD_MESSAGE(MSG_LCD_PROBING_FAILED); diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 8b6ea0bf1fae..6d4117b6b806 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -84,7 +84,7 @@ void GcodeSuite::M48() { }; if (!probe.can_reach(test_position)) { - ui.set_status(GET_TEXT_F(MSG_M48_OUT_OF_BOUNDS), 99); + LCD_MESSAGE_MAX(MSG_M48_OUT_OF_BOUNDS); SERIAL_ECHOLNPGM("? (X,Y) out of bounds."); return; } @@ -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(); diff --git a/Marlin/src/gcode/calibrate/M665.cpp b/Marlin/src/gcode/calibrate/M665.cpp index aa21471b6027..a8e02831e2a8 100644 --- a/Marlin/src/gcode/calibrate/M665.cpp +++ b/Marlin/src/gcode/calibrate/M665.cpp @@ -86,13 +86,13 @@ * * Parameters: * - * S[segments-per-second] - Segments-per-second + * S[segments] - Segments-per-second * * Without NO_WORKSPACE_OFFSETS: * - * P[theta-psi-offset] - Theta-Psi offset, added to the shoulder (A/X) angle - * T[theta-offset] - Theta offset, added to the elbow (B/Y) angle - * Z[z-offset] - Z offset, added to Z + * P[theta-psi-offset] - Theta-Psi offset, added to the shoulder (A/X) angle + * T[theta-offset] - Theta offset, added to the elbow (B/Y) angle + * Z[z-offset] - Z offset, added to Z * * A, P, and X are all aliases for the shoulder angle * B, T, and Y are all aliases for the elbow angle @@ -152,18 +152,33 @@ * * Parameters: * - * S[segments-per-second] - Segments-per-second + * S[segments] - Segments-per-second + * L[left] - Work area minimum X + * R[right] - Work area maximum X + * T[top] - Work area maximum Y + * B[bottom] - Work area minimum Y + * H[length] - Maximum belt length */ void GcodeSuite::M665() { - if (parser.seenval('S')) - segments_per_second = parser.value_float(); - else - M665_report(); + if (!parser.seen_any()) return M665_report(); + if (parser.seenval('S')) segments_per_second = parser.value_float(); + if (parser.seenval('L')) draw_area_min.x = parser.value_linear_units(); + if (parser.seenval('R')) draw_area_max.x = parser.value_linear_units(); + 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(); } void GcodeSuite::M665_report(const bool forReplay/*=true*/) { - report_heading_etc(forReplay, F(STR_POLARGRAPH_SETTINGS " (" STR_S_SEG_PER_SEC ")")); - SERIAL_ECHOLNPGM(" M665 S", segments_per_second); + report_heading_etc(forReplay, F(STR_POLARGRAPH_SETTINGS)); + SERIAL_ECHOLNPGM_P( + PSTR(" M665 S"), LINEAR_UNIT(segments_per_second), + PSTR(" L"), LINEAR_UNIT(draw_area_min.x), + PSTR(" R"), LINEAR_UNIT(draw_area_max.x), + SP_T_STR, LINEAR_UNIT(draw_area_max.y), + SP_B_STR, LINEAR_UNIT(draw_area_min.y), + PSTR(" H"), LINEAR_UNIT(polargraph_max_belt_len) + ); } #endif diff --git a/Marlin/src/gcode/config/M200-M205.cpp b/Marlin/src/gcode/config/M200-M205.cpp index 87c1f2ce305e..cda3177d93eb 100644 --- a/Marlin/src/gcode/config/M200-M205.cpp +++ b/Marlin/src/gcode/config/M200-M205.cpp @@ -221,9 +221,9 @@ void GcodeSuite::M203_report(const bool forReplay/*=true*/) { /** * M204: Set Accelerations in units/sec^2 (M204 P1200 R3000 T3000) * - * P = Printing moves - * R = Retract only (no X, Y, Z) moves - * T = Travel (non printing) moves + * P Printing moves + * R Retract only (no X, Y, Z) moves + * T Travel (non printing) moves */ void GcodeSuite::M204() { if (!parser.seen("PRST")) @@ -247,24 +247,37 @@ void GcodeSuite::M204_report(const bool forReplay/*=true*/) { ); } +#if AXIS_COLLISION('B') + #define M205_MIN_SEG_TIME_PARAM 'D' + #define M205_MIN_SEG_TIME_STR "D" + #warning "Use 'M205 D' for Minimum Segment Time." +#else + #define M205_MIN_SEG_TIME_PARAM 'B' + #define M205_MIN_SEG_TIME_STR "B" +#endif + /** * M205: Set Advanced Settings * - * B = Min Segment Time (µs) - * S = Min Feed Rate (units/s) - * T = Min Travel Feed Rate (units/s) - * X = Max X Jerk (units/sec^2) - * Y = Max Y Jerk (units/sec^2) - * Z = Max Z Jerk (units/sec^2) - * E = Max E Jerk (units/sec^2) - * J = Junction Deviation (mm) (If not using CLASSIC_JERK) + * B<µs> : Min Segment Time + * S : Min Feed Rate + * T : Min Travel Feed Rate + * + * With CLASSIC_JERK: + * X : Max X Jerk + * Y : Max Y Jerk + * Z : Max Z Jerk + * ... : etc + * E : Max E Jerk + * + * Without CLASSIC_JERK: + * J(mm) : Junction Deviation */ void GcodeSuite::M205() { - if (!parser.seen("BST" TERN_(HAS_JUNCTION_DEVIATION, "J") TERN_(HAS_CLASSIC_JERK, "XYZE"))) - return M205_report(); + if (!parser.seen_any()) return M205_report(); //planner.synchronize(); - if (parser.seenval('B')) planner.settings.min_segment_time_us = parser.value_ulong(); + if (parser.seenval(M205_MIN_SEG_TIME_PARAM)) planner.settings.min_segment_time_us = parser.value_ulong(); if (parser.seenval('S')) planner.settings.min_feedrate_mm_s = parser.value_linear_units(); if (parser.seenval('T')) planner.settings.min_travel_feedrate_mm_s = parser.value_linear_units(); #if HAS_JUNCTION_DEVIATION @@ -304,7 +317,7 @@ void GcodeSuite::M205() { void GcodeSuite::M205_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F( - "Advanced (B S T" + "Advanced (" M205_MIN_SEG_TIME_STR " S T" TERN_(HAS_JUNCTION_DEVIATION, " J") #if HAS_CLASSIC_JERK NUM_AXIS_GANG( @@ -317,7 +330,7 @@ void GcodeSuite::M205_report(const bool forReplay/*=true*/) { ")" )); SERIAL_ECHOLNPGM_P( - PSTR(" M205 B"), LINEAR_UNIT(planner.settings.min_segment_time_us) + PSTR(" M205 " M205_MIN_SEG_TIME_STR), LINEAR_UNIT(planner.settings.min_segment_time_us) , PSTR(" S"), LINEAR_UNIT(planner.settings.min_feedrate_mm_s) , SP_T_STR, LINEAR_UNIT(planner.settings.min_travel_feedrate_mm_s) #if HAS_JUNCTION_DEVIATION 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/gcode/config/M220.cpp b/Marlin/src/gcode/config/M220.cpp index c9070df803b8..6797df25d562 100644 --- a/Marlin/src/gcode/config/M220.cpp +++ b/Marlin/src/gcode/config/M220.cpp @@ -36,16 +36,15 @@ * R : Flag to restore the last-saved factor */ void GcodeSuite::M220() { + if (!parser.seen_any()) { + SERIAL_ECHOLNPGM("FR:", feedrate_percentage, "%"); + return; + } static int16_t backup_feedrate_percentage = 100; - if (parser.seen('B')) backup_feedrate_percentage = feedrate_percentage; - if (parser.seen('R')) feedrate_percentage = backup_feedrate_percentage; - + const int16_t now_feedrate_perc = feedrate_percentage; + if (parser.seen_test('R')) feedrate_percentage = backup_feedrate_percentage; + if (parser.seen_test('B')) backup_feedrate_percentage = now_feedrate_perc; if (parser.seenval('S')) feedrate_percentage = parser.value_int(); - if (!parser.seen_any()) { - SERIAL_ECHOPGM("FR:", feedrate_percentage); - SERIAL_CHAR('%'); - SERIAL_EOL(); - } } 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/M302.cpp b/Marlin/src/gcode/config/M302.cpp index 9f4d569d7b2e..12408c898755 100644 --- a/Marlin/src/gcode/config/M302.cpp +++ b/Marlin/src/gcode/config/M302.cpp @@ -28,7 +28,7 @@ #include "../../module/temperature.h" #if ENABLED(DWIN_LCD_PROUI) - #include "../../lcd/e3v2/proui/dwin_defines.h" + #include "../../lcd/e3v2/proui/dwin.h" #endif /** 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/gcode/config/M43.cpp b/Marlin/src/gcode/config/M43.cpp index 688b94c9bf39..460e25dde272 100644 --- a/Marlin/src/gcode/config/M43.cpp +++ b/Marlin/src/gcode/config/M43.cpp @@ -313,24 +313,34 @@ 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('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'); // 'W' Watch until click, M108, or reset if (parser.boolval('W')) { - SERIAL_ECHOLNPGM("Watching pins"); #ifdef ARDUINO_ARCH_SAM NOLESS(first_pin, 2); // Don't hijack the UART pins #endif - uint8_t pin_state[last_pin - first_pin + 1]; + + const uint8_t pin_count = last_pin - first_pin + 1; + uint8_t pin_state[pin_count]; + bool can_watch = false; LOOP_S_LE_N(i, first_pin, last_pin) { pin_t pin = GET_PIN_MAP_PIN_M43(i); if (!VALID_PIN(pin)) continue; if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue; + can_watch = true; pinMode(pin, INPUT_PULLUP); delay(1); /* @@ -341,16 +351,36 @@ void GcodeSuite::M43() { pin_state[i - first_pin] = extDigitalRead(pin); } + const bool multipin = (pin_count > 1); + + if (!can_watch) { + SERIAL_ECHOPGM("Specified pin"); + SERIAL_ECHOPGM_P(multipin ? PSTR("s are") : PSTR(" is")); + SERIAL_ECHOLNPGM(" protected. Use 'I' to override."); + return; + } + + // "Watching pin(s) # - #" + SERIAL_ECHOPGM("Watching pin"); + if (multipin) SERIAL_CHAR('s'); + SERIAL_CHAR(' '); SERIAL_ECHO(first_pin); + if (multipin) SERIAL_ECHOPGM(" - ", last_pin); + SERIAL_EOL(); + #if HAS_RESUME_CONTINUE KEEPALIVE_STATE(PAUSED_FOR_USER); wait_for_user = true; - TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("M43 Wait Called"), FPSTR(CONTINUE_STR))); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("M43 Wait Called"))); + TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(F("M43 Waiting..."))); + #if ENABLED(EXTENSIBLE_UI) + ExtUI::onUserConfirmRequired(F("M43 Waiting...")); + #else + LCD_MESSAGE(MSG_USERWAIT); + #endif #endif for (;;) { LOOP_S_LE_N(i, first_pin, last_pin) { - pin_t pin = GET_PIN_MAP_PIN_M43(i); + const pin_t pin = GET_PIN_MAP_PIN_M43(i); if (!VALID_PIN(pin)) continue; if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue; const byte val = @@ -361,7 +391,7 @@ void GcodeSuite::M43() { //*/ extDigitalRead(pin); if (val != pin_state[i - first_pin]) { - report_pin_state_extended(pin, ignore_protection, false); + report_pin_state_extended(pin, ignore_protection, true); pin_state[i - first_pin] = val; } } @@ -373,11 +403,13 @@ void GcodeSuite::M43() { safe_delay(200); } + + TERN_(HAS_RESUME_CONTINUE, ui.reset_status()); } else { // Report current state of selected pin(s) LOOP_S_LE_N(i, first_pin, last_pin) { - pin_t pin = GET_PIN_MAP_PIN_M43(i); + const pin_t pin = GET_PIN_MAP_PIN_M43(i); if (VALID_PIN(pin)) report_pin_state_extended(pin, ignore_protection, true); } } diff --git a/Marlin/src/gcode/config/M540.cpp b/Marlin/src/gcode/config/M540.cpp index 54d52f3a31e2..e751248dd641 100644 --- a/Marlin/src/gcode/config/M540.cpp +++ b/Marlin/src/gcode/config/M540.cpp @@ -25,7 +25,7 @@ #if ENABLED(SD_ABORT_ON_ENDSTOP_HIT) #include "../gcode.h" -#include "../../module/stepper.h" +#include "../../module/planner.h" /** * M540: Set whether SD card print should abort on endstop hit (M540 S<0|1>) diff --git a/Marlin/src/gcode/control/M17_M18_M84.cpp b/Marlin/src/gcode/control/M17_M18_M84.cpp index c2c8a702a1b6..4ff48568faea 100644 --- a/Marlin/src/gcode/control/M17_M18_M84.cpp +++ b/Marlin/src/gcode/control/M17_M18_M84.cpp @@ -24,6 +24,7 @@ #include "../../MarlinCore.h" // for stepper_inactive_time, disable_e_steppers #include "../../lcd/marlinui.h" #include "../../module/motion.h" // for e_axis_mask +#include "../../module/planner.h" #include "../../module/stepper.h" #if ENABLED(AUTO_BED_LEVELING_UBL) diff --git a/Marlin/src/gcode/control/M226.cpp b/Marlin/src/gcode/control/M226.cpp index 63f022e82bd8..4eb3db4bc31f 100644 --- a/Marlin/src/gcode/control/M226.cpp +++ b/Marlin/src/gcode/control/M226.cpp @@ -26,7 +26,7 @@ #include "../gcode.h" #include "../../MarlinCore.h" // for pin_is_protected and idle() -#include "../../module/stepper.h" +#include "../../module/planner.h" void protected_pin_err(); diff --git a/Marlin/src/gcode/control/M3-M5.cpp b/Marlin/src/gcode/control/M3-M5.cpp index 817ed4fcb4d9..5d5d44e8bfe8 100644 --- a/Marlin/src/gcode/control/M3-M5.cpp +++ b/Marlin/src/gcode/control/M3-M5.cpp @@ -26,22 +26,32 @@ #include "../gcode.h" #include "../../feature/spindle_laser.h" -#include "../../module/stepper.h" +#include "../../module/planner.h" /** * Laser: * M3 - Laser ON/Power (Ramped power) - * M4 - Laser ON/Power (Continuous power) + * M4 - Laser ON/Power (Ramped power) + * M5 - Set power output to 0 (leaving inline mode unchanged). + * + * M3I - Enable continuous inline power to be processed by the planner, with power + * calculated and set in the planner blocks, processed inline during stepping. + * Within inline mode M3 S-Values will set the power for the next moves e.g. G1 X10 Y10 powers on with the last S-Value. + * M3I must be set before using planner-synced M3 inline S-Values (LASER_POWER_SYNC). + * + * M4I - Set dynamic mode which calculates laser power OCR based on the current feedrate. + * + * M5I - Clear inline mode and set power to 0. * * Spindle: * M3 - Spindle ON (Clockwise) * M4 - Spindle ON (Counter-clockwise) + * M5 - Spindle OFF * * Parameters: - * S - Set power. S0 will turn the spindle/laser off, except in relative mode. - * O - Set power and OCR (oscillator count register) + * S - Set power. S0 will turn the spindle/laser off. * - * If no PWM pin is defined then M3/M4 just turns it on. + * If no PWM pin is defined then M3/M4 just turns it on or off. * * At least 12.8kHz (50Hz * 256) is needed for Spindle PWM. * Hardware PWM is required on AVR. ISRs are too slow. @@ -70,77 +80,77 @@ void GcodeSuite::M3_M4(const bool is_M4) { reset_stepper_timeout(); // Reset timeout to allow subsequent G-code to power the laser (imm.) #endif - #if EITHER(SPINDLE_LASER_USE_PWM, SPINDLE_SERVO) - auto get_s_power = [] { - if (parser.seenval('S')) { - const float spwr = parser.value_float(); - #if ENABLED(SPINDLE_SERVO) - cutter.unitPower = spwr; - #else - cutter.unitPower = TERN(SPINDLE_LASER_USE_PWM, - cutter.power_to_range(cutter_power_t(round(spwr))), - spwr > 0 ? 255 : 0); - #endif - } - else - cutter.unitPower = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP); - return cutter.unitPower; - }; - #endif + if (cutter.cutter_mode == CUTTER_MODE_STANDARD) + planner.synchronize(); // Wait for previous movement commands (G0/G1/G2/G3) to complete before changing power - #if ENABLED(LASER_POWER_INLINE) - if (parser.seen('I') == DISABLED(LASER_POWER_INLINE_INVERT)) { - // Laser power in inline mode - cutter.inline_direction(is_M4); // Should always be unused - #if ENABLED(SPINDLE_LASER_USE_PWM) - if (parser.seenval('O')) { - cutter.unitPower = cutter.power_to_range(parser.value_byte(), 0); - cutter.inline_ocr_power(cutter.unitPower); // The OCR is a value from 0 to 255 (uint8_t) - } - else - cutter.inline_power(cutter.upower_to_ocr(get_s_power())); - #else - cutter.set_inline_enabled(true); - #endif - return; + #if ENABLED(LASER_FEATURE) + if (parser.seen_test('I')) { + cutter.cutter_mode = is_M4 ? CUTTER_MODE_DYNAMIC : CUTTER_MODE_CONTINUOUS; + cutter.inline_power(0); + cutter.set_enabled(true); } - // Non-inline, standard case - cutter.inline_disable(); // Prevent future blocks re-setting the power #endif - planner.synchronize(); // Wait for previous movement commands (G0/G0/G2/G3) to complete before changing power - cutter.set_reverse(is_M4); - - #if ENABLED(SPINDLE_LASER_USE_PWM) - if (parser.seenval('O')) { - cutter.unitPower = cutter.power_to_range(parser.value_byte(), 0); - cutter.ocr_set_power(cutter.unitPower); // The OCR is a value from 0 to 255 (uint8_t) + auto get_s_power = [] { + float u; + if (parser.seenval('S')) { + const float v = parser.value_float(); + u = TERN(LASER_POWER_TRAP, v, cutter.power_to_range(v)); } - else - cutter.set_power(cutter.upower_to_ocr(get_s_power())); - #elif ENABLED(SPINDLE_SERVO) - cutter.set_power(get_s_power()); - #else + else if (cutter.cutter_mode == CUTTER_MODE_STANDARD) + u = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP); + + cutter.menuPower = cutter.unitPower = u; + + // PWM not implied, power converted to OCR from unit definition and on/off if not PWM. + cutter.power = TERN(SPINDLE_LASER_USE_PWM, cutter.upower_to_ocr(u), u > 0 ? 255 : 0); + return u; + }; + + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS || cutter.cutter_mode == CUTTER_MODE_DYNAMIC) { // Laser power in inline mode + #if ENABLED(LASER_FEATURE) + planner.laser_inline.status.isPowered = true; // M3 or M4 is powered either way + get_s_power(); // Update cutter.power if seen + #if ENABLED(LASER_POWER_SYNC) + // With power sync we only set power so it does not effect queued inline power sets + planner.buffer_sync_block(BLOCK_BIT_LASER_PWR); // Send the flag, queueing inline power + #else + planner.synchronize(); + cutter.inline_power(cutter.power); + #endif + #endif + } + else { cutter.set_enabled(true); - #endif - cutter.menuPower = cutter.unitPower; + get_s_power(); + cutter.apply_power( + #if ENABLED(SPINDLE_SERVO) + cutter.unitPower + #elif ENABLED(SPINDLE_LASER_USE_PWM) + cutter.upower_to_ocr(cutter.unitPower) + #else + cutter.unitPower > 0 ? 255 : 0 + #endif + ); + TERN_(SPINDLE_CHANGE_DIR, cutter.set_reverse(is_M4)); + } } /** * M5 - Cutter OFF (when moves are complete) */ void GcodeSuite::M5() { - #if ENABLED(LASER_POWER_INLINE) - if (parser.seen('I') == DISABLED(LASER_POWER_INLINE_INVERT)) { - cutter.set_inline_enabled(false); // Laser power in inline mode - return; - } - // Non-inline, standard case - cutter.inline_disable(); // Prevent future blocks re-setting the power - #endif planner.synchronize(); - cutter.set_enabled(false); - cutter.menuPower = cutter.unitPower; + cutter.power = 0; + cutter.apply_power(0); // M5 just kills power, leaving inline mode unchanged + if (cutter.cutter_mode != CUTTER_MODE_STANDARD) { + if (parser.seen_test('I')) { + TERN_(LASER_FEATURE, cutter.inline_power(cutter.power)); + cutter.set_enabled(false); // Needs to happen while we are in inline mode to clear inline power. + cutter.cutter_mode = CUTTER_MODE_STANDARD; // Switch from inline to standard mode. + } + } + cutter.set_enabled(false); // Disable enable output setting } #endif // HAS_CUTTER diff --git a/Marlin/src/gcode/control/M350_M351.cpp b/Marlin/src/gcode/control/M350_M351.cpp index ac6b5a329b70..425abad5291d 100644 --- a/Marlin/src/gcode/control/M350_M351.cpp +++ b/Marlin/src/gcode/control/M350_M351.cpp @@ -29,9 +29,6 @@ #if NUM_AXES == XYZ && EXTRUDERS >= 1 #define HAS_M350_B_PARAM 1 // "5th axis" (after E0) for an original XYZEB setup. - #if AXIS_COLLISION('B') - #error "M350 parameter 'B' collision with axis name." - #endif #endif /** diff --git a/Marlin/src/gcode/control/M400.cpp b/Marlin/src/gcode/control/M400.cpp index 9a5ad4e9df80..6058fb894e97 100644 --- a/Marlin/src/gcode/control/M400.cpp +++ b/Marlin/src/gcode/control/M400.cpp @@ -21,7 +21,7 @@ */ #include "../gcode.h" -#include "../../module/stepper.h" +#include "../../module/planner.h" /** * M400: Finish all moves diff --git a/Marlin/src/gcode/control/M605.cpp b/Marlin/src/gcode/control/M605.cpp index 06d92c844811..a52c706fa6b5 100644 --- a/Marlin/src/gcode/control/M605.cpp +++ b/Marlin/src/gcode/control/M605.cpp @@ -28,7 +28,6 @@ #include "../gcode.h" #include "../../module/motion.h" -#include "../../module/stepper.h" #include "../../module/tool_change.h" #include "../../module/planner.h" @@ -170,7 +169,7 @@ if (parser.seen("EPS")) { planner.synchronize(); if (parser.seenval('P')) duplication_e_mask = parser.value_int(); // Set the mask directly - else if (parser.seenval('E')) duplication_e_mask = pow(2, parser.value_int() + 1) - 1; // Set the mask by E index + else if (parser.seenval('E')) duplication_e_mask = _BV(parser.value_int() + 1) - 1; // Set the mask by E index ena = (2 == parser.intval('S', extruder_duplication_enabled ? 2 : 0)); set_duplication_enabled(ena && (duplication_e_mask >= 3)); } 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/eeprom/M500-M504.cpp b/Marlin/src/gcode/eeprom/M500-M504.cpp index 412d0033558f..c3962117e51f 100644 --- a/Marlin/src/gcode/eeprom/M500-M504.cpp +++ b/Marlin/src/gcode/eeprom/M500-M504.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfig.h" #if ENABLED(CONFIGURATION_EMBEDDING) - #include "../../sd/SdBaseFile.h" + #include "../../sd/cardreader.h" #include "../../mczip.h" #endif @@ -66,11 +66,19 @@ void GcodeSuite::M502() { #if ENABLED(CONFIGURATION_EMBEDDING) if (parser.seen_test('C')) { - SdBaseFile file; - const uint16_t size = sizeof(mc_zip); + MediaFile file; // Need to create the config size on the SD card - if (file.open("mc.zip", O_WRITE|O_CREAT) && file.write(pgm_read_ptr(mc_zip), size) != -1 && file.close()) - SERIAL_ECHO_MSG("Configuration saved as 'mc.zip'"); + MediaFile root = card.getroot(); + if (file.open(&root, "mc.zip", O_WRITE|O_CREAT)) { + bool success = true; + for (uint16_t i = 0; success && i < sizeof(mc_zip); ++i) { + const uint8_t c = pgm_read_byte(&mc_zip[i]); + success = (file.write(c) == 1); + } + success = file.close() && success; + + if (success) SERIAL_ECHO_MSG("Configuration saved as 'mc.zip'"); + } } #endif } diff --git a/Marlin/src/gcode/feature/L6470/M122.cpp b/Marlin/src/gcode/feature/L6470/M122.cpp deleted file mode 100644 index 4a5629b04920..000000000000 --- a/Marlin/src/gcode/feature/L6470/M122.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 HAS_L64XX - -#include "../../gcode.h" -#include "../../../libs/L64XX/L64XX_Marlin.h" -#include "../../../module/stepper/indirection.h" - -void echo_yes_no(const bool yes); - -inline void L6470_say_status(const L64XX_axis_t axis) { - if (L64xxManager.spi_abort) return; - const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; - L64xxManager.get_status(axis); - L64xxManager.say_axis(axis); - #if ENABLED(L6470_CHITCHAT) - char temp_buf[20]; - sprintf_P(temp_buf, PSTR(" status: %4x "), sh.STATUS_AXIS_RAW); - SERIAL_ECHO(temp_buf); - print_bin(sh.STATUS_AXIS_RAW); - switch (sh.STATUS_AXIS_LAYOUT) { - case L6470_STATUS_LAYOUT: SERIAL_ECHOPGM(" L6470"); break; - case L6474_STATUS_LAYOUT: SERIAL_ECHOPGM(" L6474"); break; - case L6480_STATUS_LAYOUT: SERIAL_ECHOPGM(" L6480/powerSTEP01"); break; - } - #endif - SERIAL_ECHOPGM("\n...OUTPUT: "); - SERIAL_ECHOF(sh.STATUS_AXIS & STATUS_HIZ ? F("OFF") : F("ON ")); - SERIAL_ECHOPGM(" BUSY: "); echo_yes_no((sh.STATUS_AXIS & STATUS_BUSY) == 0); - SERIAL_ECHOPGM(" DIR: "); - SERIAL_ECHOF((((sh.STATUS_AXIS & STATUS_DIR) >> 4) ^ L64xxManager.index_to_dir[axis]) ? F("FORWARD") : F("REVERSE")); - if (sh.STATUS_AXIS_LAYOUT == L6480_STATUS_LAYOUT) { - SERIAL_ECHOPGM(" Last Command: "); - if (sh.STATUS_AXIS & sh.STATUS_AXIS_WRONG_CMD) SERIAL_ECHOPGM("VALID"); - else SERIAL_ECHOPGM("ERROR"); - SERIAL_ECHOPGM("\n...THERMAL: "); - switch ((sh.STATUS_AXIS & (sh.STATUS_AXIS_TH_SD | sh.STATUS_AXIS_TH_WRN)) >> 11) { - case 0: SERIAL_ECHOPGM("DEVICE SHUTDOWN"); break; - case 1: SERIAL_ECHOPGM("BRIDGE SHUTDOWN"); break; - case 2: SERIAL_ECHOPGM("WARNING "); break; - case 3: SERIAL_ECHOPGM("OK "); break; - } - } - else { - SERIAL_ECHOPGM(" Last Command: "); - if (!(sh.STATUS_AXIS & sh.STATUS_AXIS_WRONG_CMD)) SERIAL_ECHOPGM("IN"); - SERIAL_ECHOPGM("VALID "); - SERIAL_ECHOF(sh.STATUS_AXIS & sh.STATUS_AXIS_NOTPERF_CMD ? F("COMPLETED ") : F("Not PERFORMED")); - SERIAL_ECHOPGM("\n...THERMAL: ", !(sh.STATUS_AXIS & sh.STATUS_AXIS_TH_SD) ? "SHUTDOWN " : !(sh.STATUS_AXIS & sh.STATUS_AXIS_TH_WRN) ? "WARNING " : "OK "); - } - SERIAL_ECHOPGM(" OVERCURRENT:"); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_OCD) == 0); - if (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT) { - SERIAL_ECHOPGM(" STALL:"); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_STEP_LOSS_A) == 0 || (sh.STATUS_AXIS & sh.STATUS_AXIS_STEP_LOSS_B) == 0); - SERIAL_ECHOPGM(" STEP-CLOCK MODE:"); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_SCK_MOD) != 0); - } - else { - SERIAL_ECHOPGM(" STALL: NA " - " STEP-CLOCK MODE: NA" - " UNDER VOLTAGE LOCKOUT: "); echo_yes_no((sh.STATUS_AXIS & sh.STATUS_AXIS_UVLO) == 0); - } - SERIAL_EOL(); -} - -/** - * M122: Debug L6470 drivers - */ -void GcodeSuite::M122() { - L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status - L64xxManager.spi_active = true; // Tell set_directions() a series of SPI transfers is underway - - //if (parser.seen('S')) - // tmc_set_report_interval(parser.value_bool()); - //else - - #if AXIS_IS_L64XX(X) - L6470_say_status(X); - #endif - #if AXIS_IS_L64XX(X2) - L6470_say_status(X2); - #endif - #if AXIS_IS_L64XX(Y) - L6470_say_status(Y); - #endif - #if AXIS_IS_L64XX(Y2) - L6470_say_status(Y2); - #endif - #if AXIS_IS_L64XX(Z) - L6470_say_status(Z); - #endif - #if AXIS_IS_L64XX(Z2) - L6470_say_status(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - L6470_say_status(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - L6470_say_status(Z4); - #endif - #if AXIS_IS_L64XX(E0) - L6470_say_status(E0); - #endif - #if AXIS_IS_L64XX(E1) - L6470_say_status(E1); - #endif - #if AXIS_IS_L64XX(E2) - L6470_say_status(E2); - #endif - #if AXIS_IS_L64XX(E3) - L6470_say_status(E3); - #endif - #if AXIS_IS_L64XX(E4) - L6470_say_status(E4); - #endif - #if AXIS_IS_L64XX(E5) - L6470_say_status(E5); - #endif - #if AXIS_IS_L64XX(E6) - L6470_say_status(E6); - #endif - #if AXIS_IS_L64XX(E7) - L6470_say_status(E7); - #endif - - L64xxManager.spi_active = false; // done with all SPI transfers - clear handshake flags - L64xxManager.spi_abort = false; - L64xxManager.pause_monitor(false); -} - -#endif // HAS_L64XX diff --git a/Marlin/src/gcode/feature/L6470/M906.cpp b/Marlin/src/gcode/feature/L6470/M906.cpp deleted file mode 100644 index 26c637df279c..000000000000 --- a/Marlin/src/gcode/feature/L6470/M906.cpp +++ /dev/null @@ -1,417 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 HAS_L64XX - -#if AXIS_COLLISION('I') - #error "M906 parameter 'I' collision with axis name." -#endif - -#include "../../gcode.h" -#include "../../../libs/L64XX/L64XX_Marlin.h" -#include "../../../module/stepper/indirection.h" -#include "../../../module/planner.h" - -#define DEBUG_OUT ENABLED(L6470_CHITCHAT) -#include "../../../core/debug_out.h" - -/** - * MACRO to fetch information on the items associated with current limiting - * and maximum voltage output. - * - * L6470 can be setup to shutdown if either current threshold is exceeded. - * - * L6470 output current can not be set directly. It is set indirectly by - * setting the maximum effective output voltage. - * - * Effective output voltage is set by PWM duty cycle. - * - * Maximum effective output voltage is affected by MANY variables. The main ones are: - * KVAL_HOLD - * KVAL_RUN - * KVAL_ACC - * KVAL_DEC - * Vs compensation (if enabled) - */ -void L64XX_report_current(L64XX &motor, const L64XX_axis_t axis) { - - if (L64xxManager.spi_abort) return; // don't do anything if set_directions() has occurred - - const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; - const uint16_t status = L64xxManager.get_status(axis); //also populates shadow structure - const uint8_t OverCurrent_Threshold = uint8_t(motor.GetParam(L6470_OCD_TH)); - - auto say_axis_status = [](const L64XX_axis_t axis, const uint16_t status) { - L64xxManager.say_axis(axis); - #if ENABLED(L6470_CHITCHAT) - char tmp[10]; - sprintf_P(tmp, PSTR("%4x "), status); - DEBUG_ECHOPGM(" status: ", tmp); - print_bin(status); - #else - UNUSED(status); - #endif - SERIAL_EOL(); - }; - - char temp_buf[10]; - - switch (sh.STATUS_AXIS_LAYOUT) { - case L6470_STATUS_LAYOUT: // L6470 - case L6480_STATUS_LAYOUT: { // L6480 & powerstep01 - const uint16_t Stall_Threshold = (uint8_t)motor.GetParam(L6470_STALL_TH), - motor_status = (status & (STATUS_MOT_STATUS)) >> 5, - L6470_ADC_out = motor.GetParam(L6470_ADC_OUT), - L6470_ADC_out_limited = constrain(L6470_ADC_out, 8, 24); - const float comp_coef = 1600.0f / L6470_ADC_out_limited; - const uint16_t MicroSteps = _BV(motor.GetParam(L6470_STEP_MODE) & 0x07); - - say_axis_status(axis, sh.STATUS_AXIS_RAW); - - SERIAL_ECHOPGM("...OverCurrent Threshold: "); - sprintf_P(temp_buf, PSTR("%2d ("), OverCurrent_Threshold); - SERIAL_ECHO(temp_buf); - SERIAL_ECHO((OverCurrent_Threshold + 1) * motor.OCD_CURRENT_CONSTANT_INV); - SERIAL_ECHOPGM(" mA)"); - SERIAL_ECHOPGM(" Stall Threshold: "); - sprintf_P(temp_buf, PSTR("%2d ("), Stall_Threshold); - SERIAL_ECHO(temp_buf); - SERIAL_ECHO((Stall_Threshold + 1) * motor.STALL_CURRENT_CONSTANT_INV); - SERIAL_ECHOPGM(" mA)"); - SERIAL_ECHOPGM(" Motor Status: "); - switch (motor_status) { - case 0: SERIAL_ECHOPGM("stopped"); break; - case 1: SERIAL_ECHOPGM("accelerating"); break; - case 2: SERIAL_ECHOPGM("decelerating"); break; - case 3: SERIAL_ECHOPGM("at constant speed"); break; - } - SERIAL_EOL(); - - SERIAL_ECHOPGM("...MicroSteps: ", MicroSteps, - " ADC_OUT: ", L6470_ADC_out); - SERIAL_ECHOPGM(" Vs_compensation: "); - SERIAL_ECHOF((motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_EN_VSCOMP) ? F("ENABLED ") : F("DISABLED")); - SERIAL_ECHOLNPGM(" Compensation coefficient: ~", comp_coef * 0.01f); - - SERIAL_ECHOPGM("...KVAL_HOLD: ", motor.GetParam(L6470_KVAL_HOLD), - " KVAL_RUN : ", motor.GetParam(L6470_KVAL_RUN), - " KVAL_ACC: ", motor.GetParam(L6470_KVAL_ACC), - " KVAL_DEC: ", motor.GetParam(L6470_KVAL_DEC), - " V motor max = "); - switch (motor_status) { - case 0: SERIAL_ECHO(motor.GetParam(L6470_KVAL_HOLD) * 100 / 256); SERIAL_ECHOPGM("% (KVAL_HOLD)"); break; - case 1: SERIAL_ECHO(motor.GetParam(L6470_KVAL_RUN) * 100 / 256); SERIAL_ECHOPGM("% (KVAL_RUN)"); break; - case 2: SERIAL_ECHO(motor.GetParam(L6470_KVAL_ACC) * 100 / 256); SERIAL_ECHOPGM("% (KVAL_ACC)"); break; - case 3: SERIAL_ECHO(motor.GetParam(L6470_KVAL_DEC) * 100 / 256); SERIAL_ECHOPGM("% (KVAL_HOLD)"); break; - } - SERIAL_EOL(); - - #if ENABLED(L6470_CHITCHAT) - DEBUG_ECHOPGM("...SLEW RATE: "); - switch (sh.STATUS_AXIS_LAYOUT) { - case L6470_STATUS_LAYOUT: { - switch ((motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_POW_SR) >> CONFIG_POW_SR_BIT) { - case 0: { DEBUG_ECHOLNPGM("320V/uS") ; break; } - case 1: { DEBUG_ECHOLNPGM("75V/uS") ; break; } - case 2: { DEBUG_ECHOLNPGM("110V/uS") ; break; } - case 3: { DEBUG_ECHOLNPGM("260V/uS") ; break; } - } - break; - } - case L6480_STATUS_LAYOUT: { - switch (motor.GetParam(L6470_GATECFG1) & CONFIG1_SR ) { - case CONFIG1_SR_220V_us: { DEBUG_ECHOLNPGM("220V/uS") ; break; } - case CONFIG1_SR_400V_us: { DEBUG_ECHOLNPGM("400V/uS") ; break; } - case CONFIG1_SR_520V_us: { DEBUG_ECHOLNPGM("520V/uS") ; break; } - case CONFIG1_SR_980V_us: { DEBUG_ECHOLNPGM("980V/uS") ; break; } - default: { DEBUG_ECHOLNPGM("unknown") ; break; } - } - } - } - #endif - SERIAL_EOL(); - break; - } - - case L6474_STATUS_LAYOUT: { // L6474 - const uint16_t L6470_ADC_out = motor.GetParam(L6470_ADC_OUT) & 0x1F, - L6474_TVAL_val = motor.GetParam(L6474_TVAL) & 0x7F; - - say_axis_status(axis, sh.STATUS_AXIS_RAW); - - SERIAL_ECHOPGM("...OverCurrent Threshold: "); - sprintf_P(temp_buf, PSTR("%2d ("), OverCurrent_Threshold); - SERIAL_ECHO(temp_buf); - SERIAL_ECHO((OverCurrent_Threshold + 1) * motor.OCD_CURRENT_CONSTANT_INV); - SERIAL_ECHOPGM(" mA)"); - SERIAL_ECHOPGM(" TVAL: "); - sprintf_P(temp_buf, PSTR("%2d ("), L6474_TVAL_val); - SERIAL_ECHO(temp_buf); - SERIAL_ECHO((L6474_TVAL_val + 1) * motor.STALL_CURRENT_CONSTANT_INV); - SERIAL_ECHOLNPGM(" mA) Motor Status: NA"); - - const uint16_t MicroSteps = _BV(motor.GetParam(L6470_STEP_MODE) & 0x07); //NOMORE(MicroSteps, 16); - SERIAL_ECHOPGM("...MicroSteps: ", MicroSteps, - " ADC_OUT: ", L6470_ADC_out); - - SERIAL_ECHOLNPGM(" Vs_compensation: NA\n"); - SERIAL_ECHOLNPGM("...KVAL_HOLD: NA" - " KVAL_RUN : NA" - " KVAL_ACC: NA" - " KVAL_DEC: NA" - " V motor max = NA"); - - #if ENABLED(L6470_CHITCHAT) - DEBUG_ECHOPGM("...SLEW RATE: "); - switch ((motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_POW_SR) >> CONFIG_POW_SR_BIT) { - case 0: DEBUG_ECHOLNPGM("320V/uS") ; break; - case 1: DEBUG_ECHOLNPGM("75V/uS") ; break; - case 2: DEBUG_ECHOLNPGM("110V/uS") ; break; - case 3: DEBUG_ECHOLNPGM("260V/uS") ; break; - default: DEBUG_ECHOLNPGM("slew rate: ", (motor.GetParam(sh.L6470_AXIS_CONFIG) & CONFIG_POW_SR) >> CONFIG_POW_SR_BIT); break; - } - #endif - SERIAL_EOL(); - SERIAL_EOL(); - break; - } - } -} - -/** - * M906: report or set KVAL_HOLD which sets the maximum effective voltage provided by the - * PWMs to the steppers - * - * On L6474 this sets the TVAL register (same address). - * - * I - select which driver(s) to change on multi-driver axis - * (default) all drivers on the axis - * 0 - monitor only the first XYZ... driver - * 1 - monitor only X2, Y2, Z2 - * 2 - monitor only Z3 - * 3 - monitor only Z4 - * Xxxx, Yxxx, Zxxx, Axxx, Bxxx, Cxxx, Uxxx, Vxxx, Wxxx, Exxx - axis to change (optional) - * L6474 - current in mA (4A max) - * All others - 0-255 - * - * Sets KVAL_HOLD which affects the current being driven through the stepper. - * - * L6470 is used in the STEP-CLOCK mode. KVAL_HOLD is the only KVAL_xxx - * that affects the effective voltage seen by the stepper. - */ -void GcodeSuite::M906() { - - L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status - - #define L6470_SET_KVAL_HOLD(Q) (AXIS_IS_L64XX(Q) ? stepper##Q.setTVALCurrent(value) : stepper##Q.SetParam(L6470_KVAL_HOLD, uint8_t(value))) - - DEBUG_ECHOLNPGM("M906"); - - uint8_t report_current = true; - - #if AXIS_IS_L64XX(X2) || AXIS_IS_L64XX(Y2) || AXIS_IS_L64XX(Z2) || AXIS_IS_L64XX(Z3) || AXIS_IS_L64XX(Z4) - const int8_t index = parser.byteval('I', -1); - #else - constexpr int8_t index = -1; - #endif - - LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(AXIS_CHAR(i))) { - - report_current = false; - - if (planner.has_blocks_queued() || planner.cleaning_buffer_counter) { - SERIAL_ECHOLNPGM("Test aborted. Can't set KVAL_HOLD while steppers are moving."); - return; - } - - switch (i) { - #if AXIS_IS_L64XX(X) || AXIS_IS_L64XX(X2) - case X_AXIS: - #if AXIS_IS_L64XX(X) - if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(X); - #endif - #if AXIS_IS_L64XX(X2) - if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(X2); - #endif - break; - #endif - - #if AXIS_IS_L64XX(Y) || AXIS_IS_L64XX(Y2) - case Y_AXIS: - #if AXIS_IS_L64XX(Y) - if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(Y); - #endif - #if AXIS_IS_L64XX(Y2) - if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(Y2); - #endif - break; - #endif - - #if AXIS_IS_L64XX(Z) || AXIS_IS_L64XX(Z2) || AXIS_IS_L64XX(Z3) || AXIS_IS_L64XX(Z4) - case Z_AXIS: - #if AXIS_IS_L64XX(Z) - if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(Z); - #endif - #if AXIS_IS_L64XX(Z2) - if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - if (index < 0 || index == 2) L6470_SET_KVAL_HOLD(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - if (index < 0 || index == 3) L6470_SET_KVAL_HOLD(Z4); - #endif - break; - #endif - - #if AXIS_IS_L64XX(I) - case I_AXIS: L6470_SET_KVAL_HOLD(I); break; - #endif - #if AXIS_IS_L64XX(J) - case J_AXIS: L6470_SET_KVAL_HOLD(J); break; - #endif - #if AXIS_IS_L64XX(K) - case K_AXIS: L6470_SET_KVAL_HOLD(K); break; - #endif - #if AXIS_IS_L64XX(U) - case U_AXIS: L6470_SET_KVAL_HOLD(U); break; - #endif - #if AXIS_IS_L64XX(V) - case V_AXIS: L6470_SET_KVAL_HOLD(V); break; - #endif - #if AXIS_IS_L64XX(W) - case W_AXIS: L6470_SET_KVAL_HOLD(W); break; - #endif - - #if AXIS_IS_L64XX(E0) || AXIS_IS_L64XX(E1) || AXIS_IS_L64XX(E2) || AXIS_IS_L64XX(E3) || AXIS_IS_L64XX(E4) || AXIS_IS_L64XX(E5) || AXIS_IS_L64XX(E6) || AXIS_IS_L64XX(E7) - case E_AXIS: { - const int8_t eindex = get_target_e_stepper_from_command(-2); - #if AXIS_IS_L64XX(E0) - if (eindex < 0 || eindex == 0) L6470_SET_KVAL_HOLD(E0); - #endif - #if AXIS_IS_L64XX(E1) - if (eindex < 0 || eindex == 1) L6470_SET_KVAL_HOLD(E1); - #endif - #if AXIS_IS_L64XX(E2) - if (eindex < 0 || eindex == 2) L6470_SET_KVAL_HOLD(E2); - #endif - #if AXIS_IS_L64XX(E3) - if (eindex < 0 || eindex == 3) L6470_SET_KVAL_HOLD(E3); - #endif - #if AXIS_IS_L64XX(E4) - if (eindex < 0 || eindex == 4) L6470_SET_KVAL_HOLD(E4); - #endif - #if AXIS_IS_L64XX(E5) - if (eindex < 0 || eindex == 5) L6470_SET_KVAL_HOLD(E5); - #endif - #if AXIS_IS_L64XX(E6) - if (eindex < 0 || eindex == 6) L6470_SET_KVAL_HOLD(E6); - #endif - #if AXIS_IS_L64XX(E7) - if (eindex < 0 || eindex == 7) L6470_SET_KVAL_HOLD(E7); - #endif - } break; - #endif - } - } - - if (report_current) { - #define L64XX_REPORT_CURRENT(Q) L64XX_report_current(stepper##Q, Q) - - L64xxManager.spi_active = true; // Tell set_directions() a series of SPI transfers is underway - - #if AXIS_IS_L64XX(X) - L64XX_REPORT_CURRENT(X); - #endif - #if AXIS_IS_L64XX(X2) - L64XX_REPORT_CURRENT(X2); - #endif - #if AXIS_IS_L64XX(Y) - L64XX_REPORT_CURRENT(Y); - #endif - #if AXIS_IS_L64XX(Y2) - L64XX_REPORT_CURRENT(Y2); - #endif - #if AXIS_IS_L64XX(Z) - L64XX_REPORT_CURRENT(Z); - #endif - #if AXIS_IS_L64XX(Z2) - L64XX_REPORT_CURRENT(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - L64XX_REPORT_CURRENT(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - L64XX_REPORT_CURRENT(Z4); - #endif - #if AXIS_IS_L64XX(I) - L64XX_REPORT_CURRENT(I); - #endif - #if AXIS_IS_L64XX(J) - L64XX_REPORT_CURRENT(J); - #endif - #if AXIS_IS_L64XX(K) - L64XX_REPORT_CURRENT(K); - #endif - #if AXIS_IS_L64XX(U) - L64XX_REPORT_CURRENT(U); - #endif - #if AXIS_IS_L64XX(V) - L64XX_REPORT_CURRENT(V); - #endif - #if AXIS_IS_L64XX(W) - L64XX_REPORT_CURRENT(W); - #endif - #if AXIS_IS_L64XX(E0) - L64XX_REPORT_CURRENT(E0); - #endif - #if AXIS_IS_L64XX(E1) - L64XX_REPORT_CURRENT(E1); - #endif - #if AXIS_IS_L64XX(E2) - L64XX_REPORT_CURRENT(E2); - #endif - #if AXIS_IS_L64XX(E3) - L64XX_REPORT_CURRENT(E3); - #endif - #if AXIS_IS_L64XX(E4) - L64XX_REPORT_CURRENT(E4); - #endif - #if AXIS_IS_L64XX(E5) - L64XX_REPORT_CURRENT(E5); - #endif - #if AXIS_IS_L64XX(E6) - L64XX_REPORT_CURRENT(E6); - #endif - #if AXIS_IS_L64XX(E7) - L64XX_REPORT_CURRENT(E7); - #endif - - L64xxManager.spi_active = false; // done with all SPI transfers - clear handshake flags - L64xxManager.spi_abort = false; - L64xxManager.pause_monitor(false); - } -} - -#endif // HAS_L64XX diff --git a/Marlin/src/gcode/feature/L6470/M916-M918.cpp b/Marlin/src/gcode/feature/L6470/M916-M918.cpp deleted file mode 100644 index 9e1f1b98da34..000000000000 --- a/Marlin/src/gcode/feature/L6470/M916-M918.cpp +++ /dev/null @@ -1,650 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 . - * - */ - -// -// NOTE: All tests assume each axis uses matching driver chips. -// - -#include "../../../inc/MarlinConfig.h" - -#if HAS_L64XX - -#include "../../gcode.h" -#include "../../../module/stepper/indirection.h" -#include "../../../module/planner.h" -#include "../../../libs/L64XX/L64XX_Marlin.h" - -#define DEBUG_OUT ENABLED(L6470_CHITCHAT) -#include "../../../core/debug_out.h" - -/** - * M916: increase KVAL_HOLD until get thermal warning - * NOTE - on L6474 it is TVAL that is used - * - * J - select which driver(s) to monitor on multi-driver axis - * 0 - (default) monitor all drivers on the axis or E0 - * 1 - monitor only X, Y, Z, E1 - * 2 - monitor only X2, Y2, Z2, E2 - * 3 - monitor only Z3, E3 - * 4 - monitor only Z4, E4 - * - * Xxxx, Yxxx, Zxxx, Exxx - axis to be monitored with displacement - * xxx (1-255) is distance moved on either side of current position - * - * F - feedrate - * optional - will use default max feedrate from configuration.h if not specified - * - * T - current (mA) setting for TVAL (0 - 4A in 31.25mA increments, rounds down) - L6474 only - * optional - will report current value from driver if not specified - * - * K - value for KVAL_HOLD (0 - 255) (ignored for L6474) - * optional - will report current value from driver if not specified - * - * D - time (in seconds) to run each setting of KVAL_HOLD/TVAL - * optional - defaults to zero (runs each setting once) - */ - -/** - * This routine is also useful for determining the approximate KVAL_HOLD - * where the stepper stops losing steps. The sound will get noticeably quieter - * as it stops losing steps. - */ - -void GcodeSuite::M916() { - - DEBUG_ECHOLNPGM("M916"); - - L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status - - // Variables used by L64xxManager.get_user_input function - some may not be used - char axis_mon[3][3] = { {" "}, {" "}, {" "} }; // list of Axes to be monitored - L64XX_axis_t axis_index[3]; - uint16_t axis_status[3]; - uint8_t driver_count = 1; - float position_max; - float position_min; - float final_feedrate; - uint8_t kval_hold; - uint8_t OCD_TH_val = 0; - uint8_t STALL_TH_val = 0; - uint16_t over_current_threshold; - constexpr uint8_t over_current_flag = false; // M916 doesn't play with the overcurrent thresholds - - #define DRIVER_TYPE_L6474(Q) AXIS_DRIVER_TYPE_##Q(L6474) - - uint8_t j; // general purpose counter - - if (L64xxManager.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, OCD_TH_val, STALL_TH_val, over_current_threshold)) - return; // quit if invalid user input - - DEBUG_ECHOLNPGM("feedrate = ", final_feedrate); - - planner.synchronize(); // wait for all current movement commands to complete - - const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; - for (j = 0; j < driver_count; j++) - L64xxManager.get_status(axis_index[j]); // clear out any pre-existing error flags - - char temp_axis_string[] = " "; - temp_axis_string[0] = axis_mon[0][0]; // need to have a string for use within sprintf format section - char gcode_string[80]; - uint16_t status_composite = 0; - - uint16_t M91x_counter = kval_hold; - uint16_t M91x_counter_max; - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { - M91x_counter_max = 128; // TVAL is 7 bits - LIMIT(M91x_counter, 0U, 127U); - } - else - M91x_counter_max = 256; // KVAL_HOLD is 8 bits - - uint8_t M91x_delay_s = parser.byteval('D'); // get delay in seconds - millis_t M91x_delay_ms = SEC_TO_MS(M91x_delay_s * 60); - millis_t M91x_delay_end; - - DEBUG_ECHOLNPGM(".\n."); - - do { - - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) - DEBUG_ECHOLNPGM("TVAL current (mA) = ", (M91x_counter + 1) * sh.AXIS_STALL_CURRENT_CONSTANT_INV); // report TVAL current for this run - else - DEBUG_ECHOLNPGM("kval_hold = ", M91x_counter); // report KVAL_HOLD for this run - - for (j = 0; j < driver_count; j++) - L64xxManager.set_param(axis_index[j], L6470_KVAL_HOLD, M91x_counter); //set KVAL_HOLD or TVAL (same register address) - - M91x_delay_end = millis() + M91x_delay_ms; - do { - // turn the motor(s) both directions - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(final_feedrate)); - process_subcommands_now(gcode_string); - - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(final_feedrate)); - process_subcommands_now(gcode_string); - - // get the status after the motors have stopped - planner.synchronize(); - - status_composite = 0; // clear out the old bits - - for (j = 0; j < driver_count; j++) { - axis_status[j] = (~L64xxManager.get_status(axis_index[j])) & sh.L6470_ERROR_MASK; // bits of interest are all active low - status_composite |= axis_status[j] ; - } - - if (status_composite) break; - } while (millis() < M91x_delay_end); - - if (status_composite) break; - - M91x_counter++; - - } while (!(status_composite & (sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD)) && (M91x_counter < M91x_counter_max)); - - DEBUG_ECHOLNPGM("."); - - #if ENABLED(L6470_CHITCHAT) - if (status_composite) { - L64xxManager.error_status_decode(status_composite, axis_index[0], - sh.STATUS_AXIS_TH_SD, sh.STATUS_AXIS_TH_WRN, - sh.STATUS_AXIS_STEP_LOSS_A, sh.STATUS_AXIS_STEP_LOSS_B, - sh.STATUS_AXIS_OCD, sh.STATUS_AXIS_LAYOUT); - DEBUG_ECHOLNPGM("."); - } - #endif - - if ((status_composite & (sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD))) - DEBUG_ECHOLNPGM(".\n.\nTest completed normally - Thermal warning/shutdown has occurred"); - else if (status_composite) - DEBUG_ECHOLNPGM(".\n.\nTest completed abnormally - non-thermal error has occurred"); - else - DEBUG_ECHOLNPGM(".\n.\nTest completed normally - Unable to get to thermal warning/shutdown"); - - L64xxManager.pause_monitor(false); -} - -/** - * M917: Find minimum current thresholds - * - * Decrease OCD current until overcurrent error - * Increase OCD until overcurrent error goes away - * Decrease stall threshold until stall (not done on L6474) - * Increase stall until stall error goes away (not done on L6474) - * - * J - select which driver(s) to monitor on multi-driver axis - * 0 - (default) monitor all drivers on the axis or E0 - * 1 - monitor only X, Y, Z, E1 - * 2 - monitor only X2, Y2, Z2, E2 - * Xxxx, Yxxx, Zxxx, Exxx - axis to be monitored with displacement - * xxx (1-255) is distance moved on either side of current position - * - * F - feedrate - * optional - will use default max feedrate from Configuration.h if not specified - * - * I - starting over-current threshold - * optional - will report current value from driver if not specified - * if there are multiple drivers on the axis then all will be set the same - * - * T - current (mA) setting for TVAL (0 - 4A in 31.25mA increments, rounds down) - L6474 only - * optional - will report current value from driver if not specified - * - * K - value for KVAL_HOLD (0 - 255) (ignored for L6474) - * optional - will report current value from driver if not specified - */ -void GcodeSuite::M917() { - - DEBUG_ECHOLNPGM("M917"); - - L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status - - char axis_mon[3][3] = { {" "}, {" "}, {" "} }; // list of Axes to be monitored - L64XX_axis_t axis_index[3]; - uint16_t axis_status[3]; - uint8_t driver_count = 1; - float position_max; - float position_min; - float final_feedrate; - uint8_t kval_hold; - uint8_t OCD_TH_val = 0; - uint8_t STALL_TH_val = 0; - uint16_t over_current_threshold; - constexpr uint8_t over_current_flag = true; - - uint8_t j; // general purpose counter - - if (L64xxManager.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, OCD_TH_val, STALL_TH_val, over_current_threshold)) - return; // quit if invalid user input - - DEBUG_ECHOLNPGM("feedrate = ", final_feedrate); - - planner.synchronize(); // wait for all current movement commands to complete - - const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; - for (j = 0; j < driver_count; j++) - L64xxManager.get_status(axis_index[j]); // clear error flags - char temp_axis_string[] = " "; - temp_axis_string[0] = axis_mon[0][0]; // need a sprintf format string - char gcode_string[80]; - uint16_t status_composite = 0; - uint8_t test_phase = 0; // 0 - decreasing OCD - exit when OCD warning occurs (ignore STALL) - // 1 - increasing OCD - exit when OCD warning stops (ignore STALL) - // 2 - OCD finalized - decreasing STALL - exit when STALL warning happens - // 3 - OCD finalized - increasing STALL - exit when STALL warning stop - // 4 - all testing completed - DEBUG_ECHOPGM(".\n.\n.\nover_current threshold : ", (OCD_TH_val + 1) * 375); // first status display - DEBUG_ECHOPGM(" (OCD_TH: : ", OCD_TH_val); - if (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT) { - DEBUG_ECHOPGM(") Stall threshold: ", (STALL_TH_val + 1) * 31.25); - DEBUG_ECHOPGM(" (STALL_TH: ", STALL_TH_val); - } - DEBUG_ECHOLNPGM(")"); - - do { - - if (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT) DEBUG_ECHOPGM("STALL threshold : ", (STALL_TH_val + 1) * 31.25); - DEBUG_ECHOLNPGM(" OCD threshold : ", (OCD_TH_val + 1) * 375); - - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(final_feedrate)); - process_subcommands_now(gcode_string); - - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(final_feedrate)); - process_subcommands_now(gcode_string); - - planner.synchronize(); - - status_composite = 0; // clear out the old bits - - for (j = 0; j < driver_count; j++) { - axis_status[j] = (~L64xxManager.get_status(axis_index[j])) & sh.L6470_ERROR_MASK; // bits of interest are all active low - status_composite |= axis_status[j]; - } - - if (status_composite && (status_composite & sh.STATUS_AXIS_UVLO)) { - DEBUG_ECHOLNPGM("Test aborted (Undervoltage lockout active)"); - #if ENABLED(L6470_CHITCHAT) - for (j = 0; j < driver_count; j++) { - if (j) DEBUG_ECHOPGM("..."); - L64xxManager.error_status_decode(axis_status[j], axis_index[j], - sh.STATUS_AXIS_TH_SD, sh.STATUS_AXIS_TH_WRN, - sh.STATUS_AXIS_STEP_LOSS_A, sh.STATUS_AXIS_STEP_LOSS_B, - sh.STATUS_AXIS_OCD, sh.STATUS_AXIS_LAYOUT); - } - #endif - return; - } - - if (status_composite & (sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD)) { - DEBUG_ECHOLNPGM("thermal problem - waiting for chip(s) to cool down "); - uint16_t status_composite_temp = 0; - uint8_t k = 0; - do { - k++; - if (!(k % 4)) { - kval_hold *= 0.95; - DEBUG_EOL(); - DEBUG_ECHOLNPGM("Lowering KVAL_HOLD by about 5% to ", kval_hold); - for (j = 0; j < driver_count; j++) - L64xxManager.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold); - } - DEBUG_ECHOLNPGM("."); - reset_stepper_timeout(); // keep steppers powered - safe_delay(5000); - status_composite_temp = 0; - for (j = 0; j < driver_count; j++) { - axis_status[j] = (~L64xxManager.get_status(axis_index[j])) & sh.L6470_ERROR_MASK; // bits of interest are all active low - status_composite_temp |= axis_status[j]; - } - } - while (status_composite_temp & (sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD)); - DEBUG_EOL(); - } - if (status_composite & (sh.STATUS_AXIS_STEP_LOSS_A | sh.STATUS_AXIS_STEP_LOSS_B | sh.STATUS_AXIS_OCD)) { - switch (test_phase) { - - case 0: { - if (status_composite & sh.STATUS_AXIS_OCD) { - // phase 0 with OCD warning - time to go to next phase - if (OCD_TH_val >= sh.AXIS_OCD_TH_MAX) { - OCD_TH_val = sh.AXIS_OCD_TH_MAX; // limit to max - test_phase = 2; // at highest value so skip phase 1 - //DEBUG_ECHOLNPGM("LOGIC E0A OCD at highest - skip to 2"); - DEBUG_ECHOLNPGM("OCD at highest - OCD finalized"); - } - else { - OCD_TH_val++; // normal exit to next phase - test_phase = 1; // setup for first pass of phase 1 - //DEBUG_ECHOLNPGM("LOGIC E0B - inc OCD & go to 1"); - DEBUG_ECHOLNPGM("inc OCD"); - } - } - else { // phase 0 without OCD warning - keep on decrementing if can - if (OCD_TH_val) { - OCD_TH_val--; // try lower value - //DEBUG_ECHOLNPGM("LOGIC E0C - dec OCD"); - DEBUG_ECHOLNPGM("dec OCD"); - } - else { - test_phase = 2; // at lowest value without warning so skip phase 1 - //DEBUG_ECHOLNPGM("LOGIC E0D - OCD at latest - go to 2"); - DEBUG_ECHOLNPGM("OCD finalized"); - } - } - } break; - - case 1: { - if (status_composite & sh.STATUS_AXIS_OCD) { - // phase 1 with OCD warning - increment if can - if (OCD_TH_val >= sh.AXIS_OCD_TH_MAX) { - OCD_TH_val = sh.AXIS_OCD_TH_MAX; // limit to max - test_phase = 2; // at highest value so go to next phase - //DEBUG_ECHOLNPGM("LOGIC E1A - OCD at max - go to 2"); - DEBUG_ECHOLNPGM("OCD finalized"); - } - else { - OCD_TH_val++; // try a higher value - //DEBUG_ECHOLNPGM("LOGIC E1B - inc OCD"); - DEBUG_ECHOLNPGM("inc OCD"); - } - } - else { // phase 1 without OCD warning - normal exit to phase 2 - test_phase = 2; - //DEBUG_ECHOLNPGM("LOGIC E1C - no OCD warning - go to 1"); - DEBUG_ECHOLNPGM("OCD finalized"); - } - } break; - - case 2: { - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // skip all STALL_TH steps if L6474 - test_phase = 4; - break; - } - if (status_composite & (sh.STATUS_AXIS_STEP_LOSS_A | sh.STATUS_AXIS_STEP_LOSS_B)) { - // phase 2 with stall warning - time to go to next phase - if (STALL_TH_val >= 127) { - STALL_TH_val = 127; // limit to max - //DEBUG_ECHOLNPGM("LOGIC E2A - STALL warning, STALL at max, quit"); - DEBUG_ECHOLNPGM("finished - STALL at maximum value but still have stall warning"); - test_phase = 4; - } - else { - test_phase = 3; // normal exit to next phase (found failing value of STALL) - STALL_TH_val++; // setup for first pass of phase 3 - //DEBUG_ECHOLNPGM("LOGIC E2B - INC - STALL warning, inc Stall, go to 3"); - DEBUG_ECHOLNPGM("inc Stall"); - } - } - else { // phase 2 without stall warning - decrement if can - if (STALL_TH_val) { - STALL_TH_val--; // try a lower value - //DEBUG_ECHOLNPGM("LOGIC E2C - no STALL, dec STALL"); - DEBUG_ECHOLNPGM("dec STALL"); - } - else { - DEBUG_ECHOLNPGM("finished - STALL at lowest value but still do NOT have stall warning"); - test_phase = 4; - //DEBUG_ECHOLNPGM("LOGIC E2D - no STALL, at lowest so quit"); - } - } - } break; - - case 3: { - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // skip all STALL_TH steps if L6474 - test_phase = 4; - break; - } - if (status_composite & (sh.STATUS_AXIS_STEP_LOSS_A | sh.STATUS_AXIS_STEP_LOSS_B)) { - // phase 3 with stall warning - increment if can - if (STALL_TH_val >= 127) { - STALL_TH_val = 127; // limit to max - DEBUG_ECHOLNPGM("finished - STALL at maximum value but still have stall warning"); - test_phase = 4; - //DEBUG_ECHOLNPGM("LOGIC E3A - STALL, at max so quit"); - } - else { - STALL_TH_val++; // still looking for passing value - //DEBUG_ECHOLNPGM("LOGIC E3B - STALL, inc stall"); - DEBUG_ECHOLNPGM("inc stall"); - } - } - else { //phase 3 without stall warning but have OCD warning - DEBUG_ECHOLNPGM("Hardware problem - OCD warning without STALL warning"); - test_phase = 4; - //DEBUG_ECHOLNPGM("LOGIC E3C - not STALLED, hardware problem (quit)"); - } - } break; - - } - - } - else { - switch (test_phase) { - case 0: { // phase 0 without OCD warning - keep on decrementing if can - if (OCD_TH_val) { - OCD_TH_val--; // try lower value - //DEBUG_ECHOLNPGM("LOGIC N0A - DEC OCD"); - DEBUG_ECHOLNPGM("DEC OCD"); - } - else { - test_phase = 2; // at lowest value without warning so skip phase 1 - //DEBUG_ECHOLNPGM("LOGIC N0B - OCD at lowest (go to phase 2)"); - DEBUG_ECHOLNPGM("OCD finalized"); - } - } break; - - case 1: //DEBUG_ECHOLNPGM("LOGIC N1 (go directly to 2)"); // phase 1 without OCD warning - drop directly to phase 2 - DEBUG_ECHOLNPGM("OCD finalized"); - - case 2: { // phase 2 without stall warning - keep on decrementing if can - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // skip all STALL_TH steps if L6474 - test_phase = 4; - break; - } - if (STALL_TH_val) { - STALL_TH_val--; // try a lower value (stay in phase 2) - //DEBUG_ECHOLNPGM("LOGIC N2B - dec STALL"); - DEBUG_ECHOLNPGM("dec STALL"); - } - else { - DEBUG_ECHOLNPGM("finished - STALL at lowest value but still no stall warning"); - test_phase = 4; - //DEBUG_ECHOLNPGM("LOGIC N2C - STALL at lowest (quit)"); - } - } break; - - case 3: { - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // skip all STALL_TH steps if L6474 - test_phase = 4; - break; - } - test_phase = 4; - //DEBUG_ECHOLNPGM("LOGIC N3 - finished!"); - DEBUG_ECHOLNPGM("finished!"); - } break; // phase 3 without any warnings - desired exit - } // - } // end of status checks - - if (test_phase != 4) { - for (j = 0; j < driver_count; j++) { // update threshold(s) - L64xxManager.set_param(axis_index[j], L6470_OCD_TH, OCD_TH_val); - if (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT) L64xxManager.set_param(axis_index[j], L6470_STALL_TH, STALL_TH_val); - if (L64xxManager.get_param(axis_index[j], L6470_OCD_TH) != OCD_TH_val) DEBUG_ECHOLNPGM("OCD mismatch"); - if ((L64xxManager.get_param(axis_index[j], L6470_STALL_TH) != STALL_TH_val) && (sh.STATUS_AXIS_LAYOUT != L6474_STATUS_LAYOUT)) DEBUG_ECHOLNPGM("STALL mismatch"); - } - } - - } while (test_phase != 4); - - DEBUG_ECHOLNPGM("."); - if (status_composite) { - #if ENABLED(L6470_CHITCHAT) - for (j = 0; j < driver_count; j++) { - if (j) DEBUG_ECHOPGM("..."); - L64xxManager.error_status_decode(axis_status[j], axis_index[j], - sh.STATUS_AXIS_TH_SD, sh.STATUS_AXIS_TH_WRN, - sh.STATUS_AXIS_STEP_LOSS_A, sh.STATUS_AXIS_STEP_LOSS_B, - sh.STATUS_AXIS_OCD, sh.STATUS_AXIS_LAYOUT); - } - DEBUG_ECHOLNPGM("."); - #endif - DEBUG_ECHOLNPGM("Completed with errors"); - } - else - DEBUG_ECHOLNPGM("Completed with no errors"); - DEBUG_ECHOLNPGM("."); - - L64xxManager.pause_monitor(false); -} - -/** - * M918: increase speed until error or max feedrate achieved (as shown in configuration.h)) - * - * J - select which driver(s) to monitor on multi-driver axis - * 0 - (default) monitor all drivers on the axis or E0 - * 1 - monitor only X, Y, Z, E1 - * 2 - monitor only X2, Y2, Z2, E2 - * Xxxx, Yxxx, Zxxx, Exxx - axis to be monitored with displacement - * xxx (1-255) is distance moved on either side of current position - * - * I - over current threshold - * optional - will report current value from driver if not specified - * - * T - current (mA) setting for TVAL (0 - 4A in 31.25mA increments, rounds down) - L6474 only - * optional - will report current value from driver if not specified - * - * K - value for KVAL_HOLD (0 - 255) (ignored for L6474) - * optional - will report current value from driver if not specified - * - * M - value for microsteps (1 - 128) (optional) - * optional - will report current value from driver if not specified - */ -void GcodeSuite::M918() { - - DEBUG_ECHOLNPGM("M918"); - - L64xxManager.pause_monitor(true); // Keep monitor_driver() from stealing status - - char axis_mon[3][3] = { {" "}, {" "}, {" "} }; // list of Axes to be monitored - L64XX_axis_t axis_index[3]; - uint16_t axis_status[3]; - uint8_t driver_count = 1; - float position_max, position_min; - float final_feedrate; - uint8_t kval_hold; - uint8_t OCD_TH_val = 0; - uint8_t STALL_TH_val = 0; - uint16_t over_current_threshold; - constexpr uint8_t over_current_flag = true; - - const L64XX_Marlin::L64XX_shadow_t &sh = L64xxManager.shadow; - - uint8_t j; // general purpose counter - - if (L64xxManager.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, OCD_TH_val, STALL_TH_val, over_current_threshold)) - return; // quit if invalid user input - - L64xxManager.get_status(axis_index[0]); // populate shadow array - - uint8_t m_steps = parser.byteval('M'); - - if (m_steps != 0) { - LIMIT(m_steps, 1, sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT ? 16 : 128); // L6474 - - uint8_t stepVal; - for (stepVal = 0; stepVal < 8; stepVal++) { // convert to L64xx register value - if (m_steps == 1) break; - m_steps >>= 1; - } - - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) - stepVal |= 0x98; // NO SYNC - else - stepVal |= (!SYNC_EN) | SYNC_SEL_1 | stepVal; - - for (j = 0; j < driver_count; j++) { - L64xxManager.set_param(axis_index[j], dSPIN_HARD_HIZ, 0); // can't write STEP register if stepper being powered - // results in an extra NOOP being sent (data 00) - L64xxManager.set_param(axis_index[j], L6470_STEP_MODE, stepVal); // set microsteps - } - } - m_steps = L64xxManager.get_param(axis_index[0], L6470_STEP_MODE) & 0x07; // get microsteps - - DEBUG_ECHOLNPGM("Microsteps = ", _BV(m_steps)); - DEBUG_ECHOLNPGM("target (maximum) feedrate = ", final_feedrate); - - const float feedrate_inc = final_feedrate / 10, // Start at 1/10 of max & go up by 1/10 per step - fr_limit = final_feedrate * 0.99f; // Rounding-safe comparison value - float current_feedrate = 0; - - planner.synchronize(); // Wait for moves to complete - - for (j = 0; j < driver_count; j++) - L64xxManager.get_status(axis_index[j]); // Clear error flags - - char temp_axis_string[2] = " "; - temp_axis_string[0] = axis_mon[0][0]; // Need a sprintf format string - //temp_axis_string[1] = '\n'; - - char gcode_string[80]; - uint16_t status_composite = 0; - DEBUG_ECHOLNPGM(".\n.\n."); // Make feedrate outputs easier to read - - do { - current_feedrate += feedrate_inc; - DEBUG_ECHOLNPGM("...feedrate = ", current_feedrate); - - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_min), uint16_t(current_feedrate)); - process_subcommands_now(gcode_string); - - sprintf_P(gcode_string, PSTR("G0 %s%03d F%03d"), temp_axis_string, uint16_t(position_max), uint16_t(current_feedrate)); - process_subcommands_now(gcode_string); - - planner.synchronize(); - - for (j = 0; j < driver_count; j++) { - axis_status[j] = (~L64xxManager.get_status(axis_index[j])) & 0x0800; // Bits of interest are all active LOW - status_composite |= axis_status[j]; - } - if (status_composite) break; // Break on any error - } while (current_feedrate < fr_limit); - - DEBUG_ECHOPGM("Completed with "); - if (status_composite) { - DEBUG_ECHOLNPGM("errors"); - #if ENABLED(L6470_CHITCHAT) - for (j = 0; j < driver_count; j++) { - if (j) DEBUG_ECHOPGM("..."); - L64xxManager.error_status_decode(axis_status[j], axis_index[j], - sh.STATUS_AXIS_TH_SD, sh.STATUS_AXIS_TH_WRN, - sh.STATUS_AXIS_STEP_LOSS_A, sh.STATUS_AXIS_STEP_LOSS_B, - sh.STATUS_AXIS_OCD, sh.STATUS_AXIS_LAYOUT); - } - #endif - } - else - DEBUG_ECHOLNPGM("no errors"); - - L64xxManager.pause_monitor(false); -} - -#endif // HAS_L64XX diff --git a/Marlin/src/gcode/feature/advance/M900.cpp b/Marlin/src/gcode/feature/advance/M900.cpp index 8b59e88fb114..8c0da41801cc 100644 --- a/Marlin/src/gcode/feature/advance/M900.cpp +++ b/Marlin/src/gcode/feature/advance/M900.cpp @@ -26,10 +26,9 @@ #include "../../gcode.h" #include "../../../module/planner.h" -#include "../../../module/stepper.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 @@ -37,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() { @@ -51,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) { @@ -59,12 +59,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) @@ -112,9 +112,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() { @@ -128,7 +128,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"); @@ -146,7 +146,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/gcode/feature/camera/M240.cpp b/Marlin/src/gcode/feature/camera/M240.cpp index 19051ffd423e..cf2e47ef6d2f 100644 --- a/Marlin/src/gcode/feature/camera/M240.cpp +++ b/Marlin/src/gcode/feature/camera/M240.cpp @@ -128,11 +128,13 @@ void GcodeSuite::M240() { if (homing_needed_error()) return; - const xyz_pos_t old_pos = { + const xyz_pos_t old_pos = NUM_AXIS_ARRAY( current_position.x + parser.linearval('A'), current_position.y + parser.linearval('B'), - current_position.z - }; + current_position.z, + current_position.i, current_position.j, current_position.k, + current_position.u, current_position.v, current_position.w + ); #ifdef PHOTO_RETRACT_MM const float rval = parser.linearval('R', _PHOTO_RETRACT_MM); @@ -140,7 +142,7 @@ void GcodeSuite::M240() { e_move_m240(-rval, sval); #endif - feedRate_t fr_mm_s = MMM_TO_MMS(parser.linearval('F')); + feedRate_t fr_mm_s = parser.feedrateval('F'); if (fr_mm_s) NOLESS(fr_mm_s, 10.0f); constexpr xyz_pos_t photo_position = PHOTO_POSITION; 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..a4b3cd3fee97 --- /dev/null +++ b/Marlin/src/gcode/feature/input_shaping/M593.cpp @@ -0,0 +1,85 @@ +/** + * 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 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 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 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) + ); + #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 Set the given parameters only for the X axis. + * Y Set the given parameters only for the Y axis. + */ +void GcodeSuite::M593() { + if (!parser.seen_any()) return M593_report(); + + 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(); + 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(); + constexpr float min_freq = float(uint32_t(STEPPER_TIMER_RATE) / 2) / shaping_time_t(-2); + if (freq == 0.0f || freq > min_freq) { + if (for_X) stepper.set_shaping_frequency(X_AXIS, freq); + if (for_Y) stepper.set_shaping_frequency(Y_AXIS, freq); + } + else + SERIAL_ECHOLNPGM("?Frequency (F) must be greater than ", min_freq, " or 0 to disable"); + } +} + +#endif diff --git a/Marlin/src/gcode/feature/leds/M150.cpp b/Marlin/src/gcode/feature/leds/M150.cpp index 95e7367b6e23..43062c3f752a 100644 --- a/Marlin/src/gcode/feature/leds/M150.cpp +++ b/Marlin/src/gcode/feature/leds/M150.cpp @@ -31,11 +31,13 @@ * M150: Set Status LED Color - Use R-U-B-W for R-G-B-W * and Brightness - Use P (for NEOPIXEL only) * - * Always sets all 3 or 4 components. If a component is left out, set to 0. - * If brightness is left out, no value changed + * Always sets all 3 or 4 components unless the K flag is specified. + * If a component is left out, set to 0. + * If brightness is left out, no value changed. * * With NEOPIXEL_LED: * I Set the NeoPixel index to affect. Default: All + * K Keep all unspecified values unchanged instead of setting to 0. * * With NEOPIXEL2_SEPARATE: * S The NeoPixel strip to set. Default: All. @@ -51,16 +53,24 @@ * M150 P ; Set LED full brightness * M150 I1 R ; Set NEOPIXEL index 1 to red * M150 S1 I1 R ; Set SEPARATE index 1 to red + * M150 K R127 ; Set LED red to 50% without changing blue or green */ void GcodeSuite::M150() { + int32_t old_color = 0; + #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; break; - case 1: neo2.neoindex = index; brightness = neo2.brightness(); break; + case 0: neo.neoindex = index; old_color = parser.seen('K') ? neo.pixel_color(index >= 0 ? index : 0) : 0; break; + case 1: neo2.neoindex = index; brightness = neo2.brightness(); old_color = parser.seen('K') ? neo2.pixel_color(index >= 0 ? index : 0) : 0; break; } #else const uint8_t brightness = neo.brightness(); @@ -69,10 +79,10 @@ void GcodeSuite::M150() { #endif const LEDColor color = LEDColor( - parser.seen('R') ? (parser.has_value() ? parser.value_byte() : 255) : 0, - parser.seen('U') ? (parser.has_value() ? parser.value_byte() : 255) : 0, - parser.seen('B') ? (parser.has_value() ? parser.value_byte() : 255) : 0 - OPTARG(HAS_WHITE_LED, parser.seen('W') ? (parser.has_value() ? parser.value_byte() : 255) : 0) + parser.seen('R') ? (parser.has_value() ? parser.value_byte() : 255) : (old_color >> 16) & 0xFF, + parser.seen('U') ? (parser.has_value() ? parser.value_byte() : 255) : (old_color >> 8) & 0xFF, + parser.seen('B') ? (parser.has_value() ? parser.value_byte() : 255) : old_color & 0xFF + OPTARG(HAS_WHITE_LED, parser.seen('W') ? (parser.has_value() ? parser.value_byte() : 255) : (old_color >> 24) & 0xFF) OPTARG(NEOPIXEL_LED, parser.seen('P') ? (parser.has_value() ? parser.value_byte() : 255) : brightness) ); diff --git a/Marlin/src/gcode/feature/pause/G61.cpp b/Marlin/src/gcode/feature/pause/G61.cpp index b85487af45c2..889709c04531 100644 --- a/Marlin/src/gcode/feature/pause/G61.cpp +++ b/Marlin/src/gcode/feature/pause/G61.cpp @@ -35,11 +35,24 @@ /** * G61: Return to saved position * - * F - Feedrate (optional) for the move back. - * S - Slot # (0-based) to restore from (default 0). - * X Y Z E - Axes to restore. At least one is required. + * F - Feedrate (optional) for the move back. + * S - Slot # (0-based) to restore from (default 0). + * X - Restore X axis, applying the given offset (default 0) + * Y - Restore Y axis, applying the given offset (default 0) + * Z - Restore Z axis, applying the given offset (default 0) * - * If XYZE are not given, default restore uses the smart blocking move. + * If there is an Extruder: + * E - Restore E axis, applying the given offset (default 0) + * + * With extra axes using default names: + * A - Restore 4th axis, applying the given offset (default 0) + * B - Restore 5th axis, applying the given offset (default 0) + * C - Restore 6th axis, applying the given offset (default 0) + * U - Restore 7th axis, applying the given offset (default 0) + * V - Restore 8th axis, applying the given offset (default 0) + * W - Restore 9th axis, applying the given offset (default 0) + * + * If no axes are specified then all axes are restored. */ void GcodeSuite::G61() { @@ -71,7 +84,7 @@ void GcodeSuite::G61() { if (parser.seen(STR_AXES_MAIN)) { DEBUG_ECHOPGM(STR_RESTORING_POS " S", slot); LOOP_NUM_AXES(i) { - destination[i] = parser.seenval(AXIS_CHAR(i)) + destination[i] = parser.seen(AXIS_CHAR(i)) ? stored_position[slot][i] + parser.value_axis_units((AxisEnum)i) : current_position[i]; DEBUG_CHAR(' ', AXIS_CHAR(i)); diff --git a/Marlin/src/gcode/feature/pause/M125.cpp b/Marlin/src/gcode/feature/pause/M125.cpp index ae450cc5e945..9b18eda4fbae 100644 --- a/Marlin/src/gcode/feature/pause/M125.cpp +++ b/Marlin/src/gcode/feature/pause/M125.cpp @@ -71,12 +71,12 @@ void GcodeSuite::M125() { if (parser.seenval('X')) park_point.x = RAW_X_POSITION(parser.linearval('X')), if (parser.seenval('Y')) park_point.y = RAW_Y_POSITION(parser.linearval('Y')), NOOP, - if (parser.seenval(AXIS4_NAME)) park_point.i = RAW_X_POSITION(parser.linearval(AXIS4_NAME)), - if (parser.seenval(AXIS5_NAME)) park_point.j = RAW_X_POSITION(parser.linearval(AXIS5_NAME)), - if (parser.seenval(AXIS6_NAME)) park_point.k = RAW_X_POSITION(parser.linearval(AXIS6_NAME)), - if (parser.seenval(AXIS7_NAME)) park_point.u = RAW_X_POSITION(parser.linearval(AXIS7_NAME)), - if (parser.seenval(AXIS8_NAME)) park_point.v = RAW_X_POSITION(parser.linearval(AXIS8_NAME)), - if (parser.seenval(AXIS9_NAME)) park_point.w = RAW_X_POSITION(parser.linearval(AXIS9_NAME)) + if (parser.seenval(AXIS4_NAME)) park_point.i = RAW_I_POSITION(parser.linearval(AXIS4_NAME)), + if (parser.seenval(AXIS5_NAME)) park_point.j = RAW_J_POSITION(parser.linearval(AXIS5_NAME)), + if (parser.seenval(AXIS6_NAME)) park_point.k = RAW_K_POSITION(parser.linearval(AXIS6_NAME)), + if (parser.seenval(AXIS7_NAME)) park_point.u = RAW_U_POSITION(parser.linearval(AXIS7_NAME)), + if (parser.seenval(AXIS8_NAME)) park_point.v = RAW_V_POSITION(parser.linearval(AXIS8_NAME)), + if (parser.seenval(AXIS9_NAME)) park_point.w = RAW_W_POSITION(parser.linearval(AXIS9_NAME)) ); // Lift Z axis diff --git a/Marlin/src/gcode/feature/trinamic/M122.cpp b/Marlin/src/gcode/feature/trinamic/M122.cpp index 29416324064f..61786d51ada1 100644 --- a/Marlin/src/gcode/feature/trinamic/M122.cpp +++ b/Marlin/src/gcode/feature/trinamic/M122.cpp @@ -26,7 +26,7 @@ #include "../../gcode.h" #include "../../../feature/tmc_util.h" -#include "../../../module/stepper/indirection.h" +#include "../../../module/stepper/indirection.h" // for restore_stepper_drivers /** * M122: Debug TMC drivers @@ -47,7 +47,7 @@ void GcodeSuite::M122() { if (sflag && !sval) tmc_set_report_interval(0); else if (parser.seenval('P')) - tmc_set_report_interval(_MAX(250, parser.value_ushort())); + tmc_set_report_interval(_MAX(uint16_t(250), parser.value_ushort())); else if (sval) tmc_set_report_interval(MONITOR_DRIVER_STATUS_INTERVAL_MS); #endif diff --git a/Marlin/src/gcode/feature/trinamic/M569.cpp b/Marlin/src/gcode/feature/trinamic/M569.cpp index 44675a850eb5..e0aa182bf285 100644 --- a/Marlin/src/gcode/feature/trinamic/M569.cpp +++ b/Marlin/src/gcode/feature/trinamic/M569.cpp @@ -53,6 +53,8 @@ static void set_stealth_status(const bool enable, const int8_t eindex) { constexpr int8_t index = -1; #endif + UNUSED(index); + LOOP_LOGICAL_AXES(i) if (parser.seen(AXIS_CHAR(i))) { switch (i) { case X_AXIS: @@ -197,8 +199,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/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/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 5425fc701fcd..bb859d802641 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -53,7 +53,7 @@ GcodeSuite gcode; #include "../feature/cancel_object.h" #endif -#if ENABLED(LASER_MOVE_POWER) +#if ENABLED(LASER_FEATURE) #include "../feature/spindle_laser.h" #endif @@ -210,8 +210,11 @@ void GcodeSuite::get_destination_from_command() { recovery.save(); #endif - if (parser.floatval('F') > 0) + if (parser.floatval('F') > 0) { feedrate_mm_s = parser.value_feedrate(); + // Update the cutter feed rate for use by M4 I set inline moves. + TERN_(LASER_FEATURE, cutter.feedrate_mm_m = MMS_TO_MMM(feedrate_mm_s)); + } #if BOTH(PRINTCOUNTER, HAS_EXTRUDERS) if (!DEBUGGING(DRYRUN) && !skip_move) @@ -223,15 +226,29 @@ void GcodeSuite::get_destination_from_command() { M165(); #endif - #if ENABLED(LASER_MOVE_POWER) - // Set the laser power in the planner to configure this move - if (parser.seen('S')) { - const float spwr = parser.value_float(); - cutter.inline_power(TERN(SPINDLE_LASER_USE_PWM, cutter.power_to_range(cutter_power_t(round(spwr))), spwr > 0 ? 255 : 0)); + #if ENABLED(LASER_FEATURE) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS || cutter.cutter_mode == CUTTER_MODE_DYNAMIC) { + // Set the cutter power in the planner to configure this move + cutter.last_feedrate_mm_m = 0; + if (WITHIN(parser.codenum, 1, TERN(ARC_SUPPORT, 3, 1)) || TERN0(BEZIER_CURVE_SUPPORT, parser.codenum == 5)) { + planner.laser_inline.status.isPowered = true; + if (parser.seen('I')) cutter.set_enabled(true); // This is set for backward LightBurn compatibility. + if (parser.seenval('S')) { + const float v = parser.value_float(), + u = TERN(LASER_POWER_TRAP, v, cutter.power_to_range(v)); + cutter.menuPower = cutter.unitPower = u; + cutter.inline_power(TERN(SPINDLE_LASER_USE_PWM, cutter.upower_to_ocr(u), u > 0 ? 255 : 0)); + } + } + else if (parser.codenum == 0) { + // For dynamic mode we need to flag isPowered off, dynamic power is calculated in the stepper based on feedrate. + if (cutter.cutter_mode == CUTTER_MODE_DYNAMIC) planner.laser_inline.status.isPowered = false; + cutter.inline_power(0); // This is planner-based so only set power and do not disable inline control flags. + } } - else if (ENABLED(LASER_MOVE_G0_OFF) && parser.codenum == 0) // G0 - cutter.set_inline_enabled(false); - #endif + else if (parser.codenum == 0) + cutter.apply_power(0); + #endif // LASER_FEATURE } /** @@ -544,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 @@ -560,6 +577,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 100: M100(); break; // M100: Free Memory Report #endif + #if ENABLED(BD_SENSOR) + case 102: M102(); break; // M102: Configure Bed Distance Sensor + #endif + #if HAS_EXTRUDERS case 104: M104(); break; // M104: Set hot end temperature case 109: M109(); break; // M109: Wait for hotend temperature to reach target @@ -579,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:) @@ -748,7 +771,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 290: M290(); break; // M290: Babystepping #endif - #if HAS_BUZZER + #if HAS_SOUND case 300: M300(); break; // M300: Play beep tone #endif @@ -772,6 +795,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 @@ -848,6 +875,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 421: M421(); break; // M421: Set a Mesh Bed Leveling Z coordinate #endif + #if ENABLED(X_AXIS_TWIST_COMPENSATION) + case 423: M423(); break; // M423: Reset, modify, or report X-Twist Compensation data + #endif + #if ENABLED(BACKLASH_GCODE) case 425: M425(); break; // M425: Tune backlash compensation #endif @@ -902,6 +933,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 575: M575(); break; // M575: Set serial baudrate #endif + #if HAS_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 @@ -912,7 +947,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { #endif #if IS_KINEMATIC - case 665: M665(); break; // M665: Set Delta/SCARA parameters + case 665: M665(); break; // M665: Set Kinematics parameters #endif #if ENABLED(DELTA) || HAS_EXTRA_ENDSTOPS @@ -984,14 +1019,6 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 919: M919(); break; // M919: Set stepper Chopper Times #endif - #if HAS_L64XX - case 122: M122(); break; // M122: Report status - case 906: M906(); break; // M906: Set or get motor drive level - case 916: M916(); break; // M916: L6470 tuning: Increase drive level until thermal warning - case 917: M917(); break; // M917: L6470 tuning: Find minimum current thresholds - case 918: M918(); break; // M918: L6470 tuning: Increase speed until max or error - #endif - #if HAS_MICROSTEPS case 350: M350(); break; // M350: Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers. case 351: M351(); break; // M351: Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low. @@ -1030,7 +1057,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 1efcb1cf9345..5d56e53dd5e0 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. @@ -132,6 +132,8 @@ * * M100 - Watch Free Memory (for debugging) (Requires M100_FREE_MEMORY_WATCHER) * + * M102 - Configure Bed Distance Sensor. (Requires BD_SENSOR) + * * M104 - Set extruder target temp. * M105 - Report current temperatures. * M106 - Set print fan speed. @@ -155,7 +157,7 @@ * M120 - Enable endstops detection. * M121 - Disable endstops detection. * - * M122 - Debug stepper (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660 or L6470) + * M122 - Debug stepper (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) * M123 - Report fan tachometers. (Requires En_FAN_TACHO_PIN) Optionally set auto-report interval. (Requires AUTO_REPORT_FANS) * M125 - Save current position and move to filament change position. (Requires PARK_HEAD_ON_PAUSE) * @@ -257,11 +259,13 @@ * 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_[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) * M665 - Set delta configurations: "M665 H L R S B X Y Z (Requires DELTA) * Set SCARA configurations: "M665 S P T Z (Requires MORGAN_SCARA or MP_SCARA) + * Set Polargraph draw area and belt length: "M665 S L R T B H" * M666 - Set/get offsets for delta (Requires DELTA) or dual endstops. (Requires [XYZ]_DUAL_ENDSTOPS) * M672 - Set/Reset Duet Smart Effector's sensitivity. (Requires DUET_SMART_EFFECTOR and SMART_EFFECTOR_MOD_PIN) * M701 - Load filament (Requires FILAMENT_LOAD_UNLOAD_GCODES) @@ -286,7 +290,7 @@ * M871 - Print/reset/clear first layer temperature offset values. (Requires PTC_PROBE, PTC_BED, or PTC_HOTEND) * M876 - Handle Prompt Response. (Requires HOST_PROMPT_SUPPORT and not EMERGENCY_PARSER) * M900 - Get or Set Linear Advance K-factor. (Requires LIN_ADVANCE) - * M906 - Set or get motor current in milliamps using axis codes XYZE, etc. Report values if no axis codes given. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660 or L6470) + * M906 - Set or get motor current in milliamps using axis codes XYZE, etc. Report values if no axis codes given. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) * M907 - Set digital trimpot motor current using axis codes. (Requires a board with digital trimpots) * M908 - Control digital trimpot directly. (Requires HAS_MOTOR_CURRENT_DAC or DIGIPOTSS_PIN) * M909 - Print digipot/DAC current value. (Requires HAS_MOTOR_CURRENT_DAC) @@ -295,9 +299,6 @@ * M912 - Clear stepper driver overtemperature pre-warn condition flag. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) * M913 - Set HYBRID_THRESHOLD speed. (Requires HYBRID_THRESHOLD) * M914 - Set StallGuard sensitivity. (Requires SENSORLESS_HOMING or SENSORLESS_PROBING) - * M916 - L6470 tuning: Increase KVAL_HOLD until thermal warning. (Requires at least one _DRIVER_TYPE L6470) - * M917 - L6470 tuning: Find minimum current thresholds. (Requires at least one _DRIVER_TYPE L6470) - * M918 - L6470 tuning: Increase speed until max or error. (Requires at least one _DRIVER_TYPE L6470) * M919 - Get or Set motor Chopper Times (time_off, hysteresis_end, hysteresis_start) using axis codes XYZE, etc. If no parameters are given, report. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660) * M951 - Set Magnetic Parking Extruder parameters. (Requires MAGNETIC_PARKING_EXTRUDER) * M3426 - Read MCP3426 ADC over I2C. (Requires HAS_MCP3426_ADC) @@ -677,7 +678,7 @@ class GcodeSuite { static void M48(); #endif - #if ENABLED(LCD_SET_PROGRESS_MANUALLY) + #if ENABLED(SET_PROGRESS_MANUALLY) static void M73(); #endif @@ -707,6 +708,11 @@ class GcodeSuite { static void M100(); #endif + #if ENABLED(BD_SENSOR) + static void M102(); + static void M102_report(const bool forReplay=true); + #endif + #if HAS_EXTRUDERS static void M104_M109(const bool isM109); FORCE_INLINE static void M104() { M104_M109(false); } @@ -886,7 +892,7 @@ class GcodeSuite { static void M250_report(const bool forReplay=true); #endif - #if HAS_DISPLAY_SLEEP + #if HAS_GCODE_M255 static void M255(); static void M255_report(const bool forReplay=true); #endif @@ -916,7 +922,7 @@ class GcodeSuite { static void M290(); #endif - #if HAS_BUZZER + #if HAS_SOUND static void M300(); #endif @@ -1075,6 +1081,11 @@ class GcodeSuite { static void M575(); #endif + #if HAS_SHAPING + static void M593(); + static void M593_report(const bool forReplay=true); + #endif + #if ENABLED(ADVANCED_PAUSE_FEATURE) static void M600(); static void M603(); @@ -1163,14 +1174,6 @@ class GcodeSuite { static void M919(); #endif - #if HAS_L64XX - static void M122(); - static void M906(); - static void M916(); - static void M917(); - static void M918(); - #endif - #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM || HAS_MOTOR_CURRENT_I2C || HAS_MOTOR_CURRENT_DAC static void M907(); #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM @@ -1197,7 +1200,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/gcode/gcode_d.cpp b/Marlin/src/gcode/gcode_d.cpp index 2ebe38bbcf19..be431eed0d78 100644 --- a/Marlin/src/gcode/gcode_d.cpp +++ b/Marlin/src/gcode/gcode_d.cpp @@ -156,20 +156,21 @@ void GcodeSuite::D(const int16_t dcode) { } break; case 5: { // D5 Read / Write onboard Flash - #define FLASH_SIZE 1024 + // This will overwrite program and data, so don't use it. + #define ONBOARD_FLASH_SIZE 1024 // 0x400 uint8_t *pointer = parser.hex_adr_val('A'); uint16_t len = parser.ushortval('C', 1); uintptr_t addr = (uintptr_t)pointer; - NOMORE(addr, size_t(FLASH_SIZE - 1)); - NOMORE(len, FLASH_SIZE - addr); + NOMORE(addr, size_t(ONBOARD_FLASH_SIZE - 1)); + NOMORE(len, ONBOARD_FLASH_SIZE - addr); if (parser.seenval('X')) { // TODO: Write the hex bytes after the X //while (len--) {} } else { //while (len--) { - //// TODO: Read bytes from EEPROM - // print_hex_byte(eeprom_read_byte(adr++)); + //// TODO: Read bytes from FLASH + // print_hex_byte(flash_read_byte(adr++)); //} SERIAL_EOL(); } diff --git a/Marlin/src/gcode/geometry/G53-G59.cpp b/Marlin/src/gcode/geometry/G53-G59.cpp index 092c141228fb..c51c29f4233f 100644 --- a/Marlin/src/gcode/geometry/G53-G59.cpp +++ b/Marlin/src/gcode/geometry/G53-G59.cpp @@ -25,8 +25,6 @@ #if ENABLED(CNC_COORDINATE_SYSTEMS) -#include "../../module/stepper.h" - //#define DEBUG_M53 /** diff --git a/Marlin/src/gcode/geometry/G92.cpp b/Marlin/src/gcode/geometry/G92.cpp index 58ed26a15aa8..b36f21d3c08f 100644 --- a/Marlin/src/gcode/geometry/G92.cpp +++ b/Marlin/src/gcode/geometry/G92.cpp @@ -22,7 +22,6 @@ #include "../gcode.h" #include "../../module/motion.h" -#include "../../module/stepper.h" #if ENABLED(I2C_POSITION_ENCODERS) #include "../../feature/encoder_i2c.h" diff --git a/Marlin/src/gcode/host/M114.cpp b/Marlin/src/gcode/host/M114.cpp index 8ea300b5e053..60359eeecfae 100644 --- a/Marlin/src/gcode/host/M114.cpp +++ b/Marlin/src/gcode/host/M114.cpp @@ -28,12 +28,6 @@ #if ENABLED(M114_DETAIL) - #if HAS_L64XX - #include "../../libs/L64XX/L64XX_Marlin.h" - #define DEBUG_OUT ENABLED(L6470_CHITCHAT) - #include "../../core/debug_out.h" - #endif - void report_all_axis_pos(const xyze_pos_t &pos, const uint8_t n=LOGICAL_AXES, const uint8_t precision=3) { char str[12]; LOOP_L_N(a, n) { @@ -84,89 +78,6 @@ planner.synchronize(); - #if HAS_L64XX - char temp_buf[80]; - int32_t temp; - //#define ABS_POS_SIGN_MASK 0b1111 1111 1110 0000 0000 0000 0000 0000 - #define ABS_POS_SIGN_MASK 0b11111111111000000000000000000000 - #define REPORT_ABSOLUTE_POS(Q) do{ \ - L64xxManager.say_axis(Q, false); \ - temp = L6470_GETPARAM(L6470_ABS_POS,Q); \ - if (temp & ABS_POS_SIGN_MASK) temp |= ABS_POS_SIGN_MASK; \ - sprintf_P(temp_buf, PSTR(":%8ld "), temp); \ - DEBUG_ECHO(temp_buf); \ - }while(0) - - DEBUG_ECHOPGM("\nL6470:"); - #if AXIS_IS_L64XX(X) - REPORT_ABSOLUTE_POS(X); - #endif - #if AXIS_IS_L64XX(X2) - REPORT_ABSOLUTE_POS(X2); - #endif - #if AXIS_IS_L64XX(Y) - REPORT_ABSOLUTE_POS(Y); - #endif - #if AXIS_IS_L64XX(Y2) - REPORT_ABSOLUTE_POS(Y2); - #endif - #if AXIS_IS_L64XX(Z) - REPORT_ABSOLUTE_POS(Z); - #endif - #if AXIS_IS_L64XX(Z2) - REPORT_ABSOLUTE_POS(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - REPORT_ABSOLUTE_POS(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - REPORT_ABSOLUTE_POS(Z4); - #endif - #if AXIS_IS_L64XX(I) - REPORT_ABSOLUTE_POS(I); - #endif - #if AXIS_IS_L64XX(J) - REPORT_ABSOLUTE_POS(J); - #endif - #if AXIS_IS_L64XX(K) - REPORT_ABSOLUTE_POS(K); - #endif - #if AXIS_IS_L64XX(U) - REPORT_ABSOLUTE_POS(U); - #endif - #if AXIS_IS_L64XX(V) - REPORT_ABSOLUTE_POS(V); - #endif - #if AXIS_IS_L64XX(W) - REPORT_ABSOLUTE_POS(W); - #endif - #if AXIS_IS_L64XX(E0) - REPORT_ABSOLUTE_POS(E0); - #endif - #if AXIS_IS_L64XX(E1) - REPORT_ABSOLUTE_POS(E1); - #endif - #if AXIS_IS_L64XX(E2) - REPORT_ABSOLUTE_POS(E2); - #endif - #if AXIS_IS_L64XX(E3) - REPORT_ABSOLUTE_POS(E3); - #endif - #if AXIS_IS_L64XX(E4) - REPORT_ABSOLUTE_POS(E4); - #endif - #if AXIS_IS_L64XX(E5) - REPORT_ABSOLUTE_POS(E5); - #endif - #if AXIS_IS_L64XX(E6) - REPORT_ABSOLUTE_POS(E6); - #endif - #if AXIS_IS_L64XX(E7) - REPORT_ABSOLUTE_POS(E7); - #endif - SERIAL_EOL(); - #endif // HAS_L64XX - SERIAL_ECHOPGM("Stepper:"); LOOP_LOGICAL_AXES(i) { SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_LBL[i]), stepper.position((AxisEnum)i)); diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index d38bd6612d9c..8ffe0d570051 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 @@ -121,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)); @@ -130,6 +151,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)); @@ -194,26 +222,49 @@ 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 = NUM_AXIS_ARRAY(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 = NUM_AXIS_ARRAY(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 = NUM_AXIS_ARRAY(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, "}" - "}," + "min:{" + LIST_N(DOUBLE(NUM_AXES), + "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 + ), + "},max:{" + LIST_N(DOUBLE(NUM_AXES), + "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 + ), + "}" // max + "}," // full "work:{" - "min:{x:", wmin.x, ",y:", wmin.y, ",z:", wmin.z, "}," - "max:{x:", wmax.x, ",y:", wmax.y, ",z:", wmax.z, "}", - "}" - "}" + "min:{" + LIST_N(DOUBLE(NUM_AXES), + "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 + ), + "},max:{" + LIST_N(DOUBLE(NUM_AXES), + "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 + ), + "}" // max + "}" // work + "}" // area ); #endif diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index af03fcb0b1a1..120a36a57828 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.continue_prompt(parser.string_arg); + else + hostui.continue_prompt(parser.codenum ? F("M1 Stop") : F("M0 Stop")); + #endif TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(ms)); diff --git a/Marlin/src/gcode/lcd/M145.cpp b/Marlin/src/gcode/lcd/M145.cpp index 8dbe2fb07e55..942d20afd2f8 100644 --- a/Marlin/src/gcode/lcd/M145.cpp +++ b/Marlin/src/gcode/lcd/M145.cpp @@ -47,7 +47,7 @@ void GcodeSuite::M145() { preheat_t &mat = ui.material_preset[material]; #if HAS_HOTEND if (parser.seenval('H')) - mat.hotend_temp = constrain(parser.value_int(), EXTRUDE_MINTEMP, thermalManager.hotend_max_target(0)); + mat.hotend_temp = constrain(parser.value_int(), thermalManager.extrude_min_temp, thermalManager.hotend_max_target(0)); #endif #if HAS_HEATED_BED if (parser.seenval('B')) diff --git a/Marlin/src/gcode/lcd/M255.cpp b/Marlin/src/gcode/lcd/M255.cpp index cfdf27b8a1fc..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 int s = parser.value_int() * 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/gcode/lcd/M300.cpp b/Marlin/src/gcode/lcd/M300.cpp index 5250774955fb..76d4b96b2428 100644 --- a/Marlin/src/gcode/lcd/M300.cpp +++ b/Marlin/src/gcode/lcd/M300.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfig.h" -#if HAS_BUZZER +#if HAS_SOUND #include "../gcode.h" @@ -42,4 +42,4 @@ void GcodeSuite::M300() { BUZZ(duration, frequency); } -#endif // HAS_BUZZER +#endif // HAS_SOUND diff --git a/Marlin/src/gcode/lcd/M73.cpp b/Marlin/src/gcode/lcd/M73.cpp index a86eee4d9967..02d44ca00be8 100644 --- a/Marlin/src/gcode/lcd/M73.cpp +++ b/Marlin/src/gcode/lcd/M73.cpp @@ -22,11 +22,12 @@ #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" @@ -36,7 +37,15 @@ * 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 + * + * M73 Progress: ---%; 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 +55,40 @@ 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) + 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) + SERIAL_ECHOPGM(" Time left: ", ui.remaining_time / 60, "m;"); + #endif + #if ENABLED(SET_INTERACTION_TIME) + SERIAL_ECHOPGM(" Change: ", ui.interaction_time / 60, "m;"); + #endif + SERIAL_EOL(); + } #endif } -#endif // LCD_SET_PROGRESS_MANUALLY +#endif // SET_PROGRESS_MANUALLY diff --git a/Marlin/src/gcode/motion/G0_G1.cpp b/Marlin/src/gcode/motion/G0_G1.cpp index 933bf3d5d9ef..cee2f050807e 100644 --- a/Marlin/src/gcode/motion/G0_G1.cpp +++ b/Marlin/src/gcode/motion/G0_G1.cpp @@ -32,7 +32,7 @@ #include "../../sd/cardreader.h" #if ENABLED(NANODLP_Z_SYNC) - #include "../../module/stepper.h" + #include "../../module/planner.h" #endif extern xyze_pos_t destination; diff --git a/Marlin/src/gcode/motion/G2_G3.cpp b/Marlin/src/gcode/motion/G2_G3.cpp index dd1c1d14708f..14ff7ed67c38 100644 --- a/Marlin/src/gcode/motion/G2_G3.cpp +++ b/Marlin/src/gcode/motion/G2_G3.cpp @@ -197,8 +197,8 @@ void plan_arc( // Feedrate for the move, scaled by the feedrate multiplier const feedRate_t scaled_fr_mm_s = MMS_SCALED(feedrate_mm_s); - // Get the nominal segment length based on settings - const float nominal_segment_mm = ( + // Get the ideal segment length for the move based on settings + const float ideal_segment_mm = ( #if ARC_SEGMENTS_PER_SEC // Length based on segments per second and feedrate constrain(scaled_fr_mm_s * RECIPROCAL(ARC_SEGMENTS_PER_SEC), MIN_ARC_SEGMENT_MM, MAX_ARC_SEGMENT_MM) #else @@ -206,19 +206,21 @@ void plan_arc( #endif ); - // Number of whole segments based on the nominal segment length - const float nominal_segments = _MAX(FLOOR(flat_mm / nominal_segment_mm), min_segments); + // Number of whole segments based on the ideal segment length + const float nominal_segments = _MAX(FLOOR(flat_mm / ideal_segment_mm), min_segments), + nominal_segment_mm = flat_mm / nominal_segments; - // A new segment length based on the required minimum - const float segment_mm = constrain(flat_mm / nominal_segments, MIN_ARC_SEGMENT_MM, MAX_ARC_SEGMENT_MM); + // The number of whole segments in the arc, with best attempt to honor MIN_ARC_SEGMENT_MM and MAX_ARC_SEGMENT_MM + const uint16_t segments = nominal_segment_mm > (MAX_ARC_SEGMENT_MM) ? CEIL(flat_mm / (MAX_ARC_SEGMENT_MM)) : + nominal_segment_mm < (MIN_ARC_SEGMENT_MM) ? _MAX(1, FLOOR(flat_mm / (MIN_ARC_SEGMENT_MM))) : + nominal_segments; + const float segment_mm = flat_mm / segments; - // The number of whole segments in the arc, ignoring the remainder - uint16_t segments = FLOOR(flat_mm / segment_mm); - - // Are the segments now too few to reach the destination? - const float segmented_length = segment_mm * segments; - const bool tooshort = segmented_length < flat_mm - 0.0001f; - const float proportion = tooshort ? segmented_length / flat_mm : 1.0f; + // Add hints to help optimize the move + PlannerHints hints; + #if ENABLED(SCARA_FEEDRATE_SCALING) + hints.inv_duration = (scaled_fr_mm_s / flat_mm) * segments; + #endif /** * Vector rotation by transformation matrix: r is the original vector, r_T is the rotated vector, @@ -246,108 +248,123 @@ void plan_arc( * a correction, the planner should have caught up to the lag caused by the initial plan_arc overhead. * This is important when there are successive arc motions. */ - // Vector rotation matrix values - xyze_pos_t raw; - const float theta_per_segment = proportion * angular_travel / segments, - sq_theta_per_segment = sq(theta_per_segment), - sin_T = theta_per_segment - sq_theta_per_segment * theta_per_segment / 6, - cos_T = 1 - 0.5f * sq_theta_per_segment; // Small angle approximation - - #if DISABLED(AUTO_BED_LEVELING_UBL) - ARC_LIJKUVW_CODE( - const float per_segment_L = proportion * travel_L / segments, - const float per_segment_I = proportion * travel_I / segments, - const float per_segment_J = proportion * travel_J / segments, - const float per_segment_K = proportion * travel_K / segments, - const float per_segment_U = proportion * travel_U / segments, - const float per_segment_V = proportion * travel_V / segments, - const float per_segment_W = proportion * travel_W / segments - ); - #endif - - CODE_ITEM_E(const float extruder_per_segment = proportion * travel_E / segments); - // For shortened segments, run all but the remainder in the loop - if (tooshort) segments++; - - // Initialize all linear axes and E - ARC_LIJKUVWE_CODE( - raw[axis_l] = current_position[axis_l], - raw.i = current_position.i, - raw.j = current_position.j, - raw.k = current_position.k, - raw.u = current_position.u, - raw.v = current_position.v, - raw.w = current_position.w, - raw.e = current_position.e - ); - - #if ENABLED(SCARA_FEEDRATE_SCALING) - const float inv_duration = scaled_fr_mm_s / segment_mm; - #endif + xyze_pos_t raw; - millis_t next_idle_ms = millis() + 200UL; + // do not calculate rotation parameters for trivial single-segment arcs + if (segments > 1) { + // Vector rotation matrix values + const float theta_per_segment = angular_travel / segments, + sq_theta_per_segment = sq(theta_per_segment), + sin_T = theta_per_segment - sq_theta_per_segment * theta_per_segment / 6, + cos_T = 1 - 0.5f * sq_theta_per_segment; // Small angle approximation + + #if DISABLED(AUTO_BED_LEVELING_UBL) + ARC_LIJKUVW_CODE( + const float per_segment_L = travel_L / segments, + const float per_segment_I = travel_I / segments, + const float per_segment_J = travel_J / segments, + const float per_segment_K = travel_K / segments, + const float per_segment_U = travel_U / segments, + const float per_segment_V = travel_V / segments, + const float per_segment_W = travel_W / segments + ); + #endif - #if N_ARC_CORRECTION > 1 - int8_t arc_recalc_count = N_ARC_CORRECTION; - #endif + CODE_ITEM_E(const float extruder_per_segment = travel_E / segments); - for (uint16_t i = 1; i < segments; i++) { // Iterate (segments-1) times + // Initialize all linear axes and E + ARC_LIJKUVWE_CODE( + raw[axis_l] = current_position[axis_l], + raw.i = current_position.i, + raw.j = current_position.j, + raw.k = current_position.k, + raw.u = current_position.u, + raw.v = current_position.v, + raw.w = current_position.w, + raw.e = current_position.e + ); - thermalManager.manage_heater(); - const millis_t ms = millis(); - if (ELAPSED(ms, next_idle_ms)) { - next_idle_ms = ms + 200UL; - idle(); - } + millis_t next_idle_ms = millis() + 200UL; #if N_ARC_CORRECTION > 1 - if (--arc_recalc_count) { - // Apply vector rotation matrix to previous rvec.a / 1 - const float r_new_Y = rvec.a * sin_T + rvec.b * cos_T; - rvec.a = rvec.a * cos_T - rvec.b * sin_T; - rvec.b = r_new_Y; - } - else + int8_t arc_recalc_count = N_ARC_CORRECTION; #endif - { + + // An arc can always complete within limits from a speed which... + // a) is <= any configured maximum speed, + // b) does not require centripetal force greater than any configured maximum acceleration, + // c) is <= nominal speed, + // d) allows the print head to stop in the remining length of the curve within all configured maximum accelerations. + // The last has to be calculated every time through the loop. + const float limiting_accel = _MIN(planner.settings.max_acceleration_mm_per_s2[axis_p], planner.settings.max_acceleration_mm_per_s2[axis_q]), + limiting_speed = _MIN(planner.settings.max_feedrate_mm_s[axis_p], planner.settings.max_feedrate_mm_s[axis_q]), + limiting_speed_sqr = _MIN(sq(limiting_speed), limiting_accel * radius, sq(scaled_fr_mm_s)); + float arc_mm_remaining = flat_mm; + + for (uint16_t i = 1; i < segments; i++) { // Iterate (segments-1) times + + thermalManager.task(); + const millis_t ms = millis(); + if (ELAPSED(ms, next_idle_ms)) { + next_idle_ms = ms + 200UL; + idle(); + } + #if N_ARC_CORRECTION > 1 - arc_recalc_count = N_ARC_CORRECTION; + if (--arc_recalc_count) { + // Apply vector rotation matrix to previous rvec.a / 1 + const float r_new_Y = rvec.a * sin_T + rvec.b * cos_T; + rvec.a = rvec.a * cos_T - rvec.b * sin_T; + rvec.b = r_new_Y; + } + else #endif + { + #if N_ARC_CORRECTION > 1 + arc_recalc_count = N_ARC_CORRECTION; + #endif + + // Arc correction to radius vector. Computed only every N_ARC_CORRECTION increments. + // Compute exact location by applying transformation matrix from initial radius vector(=-offset). + // To reduce stuttering, the sin and cos could be computed at different times. + // For now, compute both at the same time. + const float Ti = i * theta_per_segment, cos_Ti = cos(Ti), sin_Ti = sin(Ti); + rvec.a = -offset[0] * cos_Ti + offset[1] * sin_Ti; + rvec.b = -offset[0] * sin_Ti - offset[1] * cos_Ti; + } - // Arc correction to radius vector. Computed only every N_ARC_CORRECTION increments. - // Compute exact location by applying transformation matrix from initial radius vector(=-offset). - // To reduce stuttering, the sin and cos could be computed at different times. - // For now, compute both at the same time. - const float cos_Ti = cos(i * theta_per_segment), sin_Ti = sin(i * theta_per_segment); - rvec.a = -offset[0] * cos_Ti + offset[1] * sin_Ti; - rvec.b = -offset[0] * sin_Ti - offset[1] * cos_Ti; - } + // Update raw location + raw[axis_p] = center_P + rvec.a; + raw[axis_q] = center_Q + rvec.b; + ARC_LIJKUVWE_CODE( + #if ENABLED(AUTO_BED_LEVELING_UBL) + raw[axis_l] = start_L, + raw.i = start_I, raw.j = start_J, raw.k = start_K, + raw.u = start_U, raw.v = start_V, raw.w = start_V + #else + raw[axis_l] += per_segment_L, + raw.i += per_segment_I, raw.j += per_segment_J, raw.k += per_segment_K, + raw.u += per_segment_U, raw.v += per_segment_V, raw.w += per_segment_W + #endif + , raw.e += extruder_per_segment + ); - // Update raw location - raw[axis_p] = center_P + rvec.a; - raw[axis_q] = center_Q + rvec.b; - ARC_LIJKUVWE_CODE( - #if ENABLED(AUTO_BED_LEVELING_UBL) - raw[axis_l] = start_L, - raw.i = start_I, raw.j = start_J, raw.k = start_K, - raw.u = start_U, raw.v = start_V, raw.w = start_V - #else - raw[axis_l] += per_segment_L, - raw.i += per_segment_I, raw.j += per_segment_J, raw.k += per_segment_K, - raw.u += per_segment_U, raw.v += per_segment_V, raw.w += per_segment_W + apply_motion_limits(raw); + + #if HAS_LEVELING && !PLANNER_LEVELING + planner.apply_leveling(raw); #endif - , raw.e += extruder_per_segment - ); - apply_motion_limits(raw); + // calculate safe speed for stopping by the end of the arc + arc_mm_remaining -= segment_mm; + hints.safe_exit_speed_sqr = _MIN(limiting_speed_sqr, 2 * limiting_accel * arc_mm_remaining); - #if HAS_LEVELING && !PLANNER_LEVELING - planner.apply_leveling(raw); - #endif + if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints)) + break; - if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0 OPTARG(SCARA_FEEDRATE_SCALING, inv_duration))) - break; + hints.curve_radius = radius; + } } // Ensure last segment arrives at target location. @@ -366,7 +383,9 @@ void plan_arc( planner.apply_leveling(raw); #endif - planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, 0 OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)); + hints.curve_radius = 0; + hints.safe_exit_speed_sqr = 0.0f; + planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints); #if ENABLED(AUTO_BED_LEVELING_UBL) ARC_LIJKUVW_CODE( diff --git a/Marlin/src/gcode/motion/G4.cpp b/Marlin/src/gcode/motion/G4.cpp index df3f5b010e97..ebaa6aabc062 100644 --- a/Marlin/src/gcode/motion/G4.cpp +++ b/Marlin/src/gcode/motion/G4.cpp @@ -21,7 +21,7 @@ */ #include "../gcode.h" -#include "../../module/stepper.h" +#include "../../module/planner.h" #include "../../lcd/marlinui.h" /** diff --git a/Marlin/src/gcode/motion/G6.cpp b/Marlin/src/gcode/motion/G6.cpp index a57a293e06f8..fb6281707b45 100644 --- a/Marlin/src/gcode/motion/G6.cpp +++ b/Marlin/src/gcode/motion/G6.cpp @@ -50,7 +50,7 @@ void GcodeSuite::G6() { // No speed is set, can't schedule the move if (!planner.last_page_step_rate) return; - const page_idx_t page_idx = (page_idx_t) parser.value_ulong(); + const page_idx_t page_idx = (page_idx_t)parser.value_ulong(); uint16_t num_steps = DirectStepping::Config::TOTAL_STEPS; if (parser.seen('S')) num_steps = parser.value_ushort(); 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 diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index a16853bdf894..42a081960d08 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -28,13 +28,14 @@ #include "../../module/motion.h" #include "../../module/probe.h" #include "../../feature/bedlevel/bedlevel.h" +#include "../../lcd/marlinui.h" #if HAS_PTC #include "../../feature/probe_temp_comp.h" #endif -#if ENABLED(DWIN_LCD_PROUI) - #include "../../lcd/marlinui.h" +#if HAS_MULTI_HOTEND + #include "../../module/tool_change.h" #endif /** @@ -49,48 +50,57 @@ */ void GcodeSuite::G30() { - 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) }; - - 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 - return; + #if HAS_MULTI_HOTEND + const uint8_t old_tool_index = active_extruder; + tool_change(0); + #endif + + // 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)) { + // Disable leveling so the planner won't mess with us + TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); + + remember_feedrate_scaling_off(); + + TERN_(DWIN_CREALITY_LCD_JYERSUI, process_subcommands_now(F("G28O"))); + + const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; + + TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool())); + 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.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"), + dtostrf(pos.x, 1, 1, str_1), + dtostrf(pos.y, 1, 1, str_2), + dtostrf(measured_z, 1, 2, str_3) + ); + ui.set_status(msg); + #endif + } + + restore_feedrate_and_scaling(); + + if (raise_after == PROBE_PT_STOW) + probe.move_z_after_probing(); + + report_current_position(); } - - // Disable leveling so the planner won't mess with us - TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); - - remember_feedrate_scaling_off(); - - TERN_(DWIN_LCD_PROUI, process_subcommands_now(F("G28O"))); - - const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; - - TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool())); - 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); - #if ENABLED(DWIN_LCD_PROUI) - char msg[31], str_1[6], str_2[6], str_3[6]; - sprintf_P(msg, PSTR("X:%s, Y:%s, Z:%s"), - dtostrf(pos.x, 1, 1, str_1), - dtostrf(pos.y, 1, 1, str_2), - dtostrf(measured_z, 1, 2, str_3) - ); - ui.set_status(msg); - #endif + else { + SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT)); + LCD_MESSAGE(MSG_ZPROBE_OUT); } - restore_feedrate_and_scaling(); - - if (raise_after == PROBE_PT_STOW) - probe.move_z_after_probing(); - - report_current_position(); + // Restore the active tool + TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index)); } #endif // HAS_BED_PROBE diff --git a/Marlin/src/gcode/probe/G38.cpp b/Marlin/src/gcode/probe/G38.cpp index ed24ce3258d9..5b138fdaf6dd 100644 --- a/Marlin/src/gcode/probe/G38.cpp +++ b/Marlin/src/gcode/probe/G38.cpp @@ -28,7 +28,7 @@ #include "../../module/endstops.h" #include "../../module/motion.h" -#include "../../module/stepper.h" +#include "../../module/planner.h" #include "../../module/probe.h" inline void G38_single_probe(const uint8_t move_value) { @@ -110,13 +110,7 @@ void GcodeSuite::G38(const int8_t subcode) { remember_feedrate_scaling_off(); - const bool error_on_fail = - #if ENABLED(G38_PROBE_AWAY) - !TEST(subcode, 0) - #else - (subcode == 2) - #endif - ; + const bool error_on_fail = TERN(G38_PROBE_AWAY, !TEST(subcode, 0), subcode == 2); // If any axis has enough movement, do the move LOOP_NUM_AXES(i) diff --git a/Marlin/src/gcode/probe/M102.cpp b/Marlin/src/gcode/probe/M102.cpp new file mode 100644 index 000000000000..b70c9aed1836 --- /dev/null +++ b/Marlin/src/gcode/probe/M102.cpp @@ -0,0 +1,57 @@ +/** + * 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 . + * + */ + +/** + * M102.cpp - Configure Bed Distance Sensor + */ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(BD_SENSOR) + +#include "../gcode.h" +#include "../../feature/bedlevel/bdl/bdl.h" + +/** + * M102: Configure the Bed Distance Sensor + * + * M102 S<10ths> : Set adjustable Z height in 10ths of a mm (e.g., 'M102 S4' enables adjusting for Z <= 0.4mm.) + * M102 S0 : Disable adjustable Z height. + * + * Negative S values are commands: + * M102 S-1 : Read sensor information + * M102 S-5 : Read raw Calibration data + * M102 S-6 : Start Calibration + */ +void GcodeSuite::M102() { + if (parser.seenval('S')) + bdl.config_state = parser.value_int(); + else + M102_report(); +} + +void GcodeSuite::M102_report(const bool forReplay/*=true*/) { + report_heading(forReplay, F("Bed Distance Sensor")); + SERIAL_ECHOLNPGM(" M102 S", bdl.config_state); +} + +#endif // BD_SENSOR diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 454a009b8598..c951fc633364 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -384,7 +384,7 @@ inline bool process_line_done(uint8_t &sis, char (&buff)[MAX_CMD_SIZE], int &ind buff[ind] = '\0'; // Of course, I'm a Terminator. const bool is_empty = (ind == 0); // An empty line? if (is_empty) - thermalManager.manage_heater(); // Keep sensors satisfied + thermalManager.task(); // Keep sensors satisfied else ind = 0; // Start a new line return is_empty; // Inform the caller @@ -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; } diff --git a/Marlin/src/gcode/sd/M1001.cpp b/Marlin/src/gcode/sd/M1001.cpp index 197177882c31..1d1d1a4b7f80 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 { @@ -97,7 +97,7 @@ void GcodeSuite::M1001() { if (long_print) { printerEventLEDs.onPrintCompleted(); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_PRINT_DONE))); - TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, GET_TEXT_F(MSG_PRINT_DONE), FPSTR(CONTINUE_STR))); + TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_PRINT_DONE))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(SEC_TO_MS(TERN(HAS_MARLINUI_MENU, PE_LEDS_COMPLETED_TIME, 30)))); printerEventLEDs.onResumeAfterWait(); } @@ -109,7 +109,6 @@ void GcodeSuite::M1001() { #endif TERN_(EXTENSIBLE_UI, ExtUI::onPrintDone()); - TERN_(DWIN_LCD_PROUI, DWIN_Print_Finished()); // Re-select the last printed file in the UI TERN_(SD_REPRINT_LAST_SELECTED_FILE, ui.reselect_last_file()); 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/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/gcode/sd/M524.cpp b/Marlin/src/gcode/sd/M524.cpp index 001a1e184263..f2b9274223c2 100644 --- a/Marlin/src/gcode/sd/M524.cpp +++ b/Marlin/src/gcode/sd/M524.cpp @@ -28,7 +28,7 @@ #include "../../sd/cardreader.h" #if ENABLED(DWIN_LCD_PROUI) - #include "../../lcd/e3v2/proui/dwin.h" + #include "../../lcd/marlinui.h" #endif /** @@ -38,7 +38,7 @@ void GcodeSuite::M524() { #if ENABLED(DWIN_LCD_PROUI) - HMI_flag.abort_flag = true; // The LCD will handle it + ui.abort_print(); #else diff --git a/Marlin/src/gcode/stats/M75-M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp index 0ed1e6693013..2ff04797eb28 100644 --- a/Marlin/src/gcode/stats/M75-M78.cpp +++ b/Marlin/src/gcode/stats/M75-M78.cpp @@ -39,7 +39,6 @@ void GcodeSuite::M75() { startOrResumeJob(); #if ENABLED(DWIN_LCD_PROUI) - DWIN_Print_Started(false); if (!IS_SD_PRINTING()) DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); #endif } @@ -48,9 +47,8 @@ void GcodeSuite::M75() { * M76: Pause print timer */ void GcodeSuite::M76() { - print_job_timer.pause(); + TERN(DWIN_LCD_PROUI, ui.pause_print(), print_job_timer.pause()); TERN_(HOST_PAUSE_M76, hostui.pause()); - TERN_(DWIN_LCD_PROUI, DWIN_Print_Pause()); } /** @@ -58,7 +56,6 @@ void GcodeSuite::M76() { */ void GcodeSuite::M77() { print_job_timer.stop(); - TERN_(DWIN_LCD_PROUI, DWIN_Print_Finished()); } #if ENABLED(PRINTCOUNTER) diff --git a/Marlin/src/gcode/temp/M106_M107.cpp b/Marlin/src/gcode/temp/M106_M107.cpp index 98e87c415de9..ae517c977b29 100644 --- a/Marlin/src/gcode/temp/M106_M107.cpp +++ b/Marlin/src/gcode/temp/M106_M107.cpp @@ -90,7 +90,7 @@ void GcodeSuite::M106() { // Set speed, with constraint thermalManager.set_fan_speed(pfan, speed); - TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_FLAG_SYNC_FANS)); + TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_BIT_SYNC_FANS)); if (TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())) // pfan == 0 when duplicating thermalManager.set_fan_speed(1 - pfan, speed); @@ -111,7 +111,7 @@ void GcodeSuite::M107() { if (TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())) // pfan == 0 when duplicating thermalManager.set_fan_speed(1 - pfan, 0); - TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_FLAG_SYNC_FANS)); + TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_BIT_SYNC_FANS)); } #endif // HAS_FAN diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index ce362984a6ca..820b1556d611 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -48,7 +48,7 @@ void GcodeSuite::M303() { - #if ANY(PID_DEBUG, PID_BED_DEBUG, PID_CHAMBER_DEBUG) + #if HAS_PID_DEBUG if (parser.seen_test('D')) { thermalManager.pid_debug_flag ^= true; SERIAL_ECHO_START(); @@ -61,15 +61,9 @@ void GcodeSuite::M303() { const heater_id_t hid = (heater_id_t)parser.intval('E'); celsius_t default_temp; switch (hid) { - #if ENABLED(PIDTEMP) - case 0 ... HOTENDS - 1: default_temp = PREHEAT_1_TEMP_HOTEND; break; - #endif - #if ENABLED(PIDTEMPBED) - case H_BED: default_temp = PREHEAT_1_TEMP_BED; break; - #endif - #if ENABLED(PIDTEMPCHAMBER) - case H_CHAMBER: default_temp = PREHEAT_1_TEMP_CHAMBER; break; - #endif + OPTCODE(PIDTEMP, case 0 ... HOTENDS - 1: default_temp = PREHEAT_1_TEMP_HOTEND; break) + OPTCODE(PIDTEMPBED, case H_BED: default_temp = PREHEAT_1_TEMP_BED; break) + OPTCODE(PIDTEMPCHAMBER, case H_CHAMBER: default_temp = PREHEAT_1_TEMP_CHAMBER; break) default: SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID); @@ -84,9 +78,15 @@ void GcodeSuite::M303() { const celsius_t temp = seenS ? parser.value_celsius() : default_temp; const bool u = parser.boolval('U'); - #if ENABLED(DWIN_LCD_PROUI) + #if ENABLED(DWIN_LCD_PROUI) && EITHER(PIDTEMP, PIDTEMPBED) if (seenC) HMI_data.PidCycles = c; - if (seenS) { if (hid == H_BED) HMI_data.BedPidT = temp; else HMI_data.HotendPidT = temp; } + if (seenS) { + switch (hid) { + OPTCODE(PIDTEMP, case 0 ... HOTENDS - 1: HMI_data.HotendPidT = temp; break) + OPTCODE(PIDTEMPBED, case H_BED: HMI_data.BedPidT = temp; break) + default: break; + } + } #endif #if DISABLED(BUSY_WHILE_HEATING) 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); diff --git a/Marlin/src/gcode/units/M149.cpp b/Marlin/src/gcode/units/M149.cpp index 3f1ea3654ec4..a04247cbcb17 100644 --- a/Marlin/src/gcode/units/M149.cpp +++ b/Marlin/src/gcode/units/M149.cpp @@ -30,9 +30,9 @@ * M149: Set temperature units */ void GcodeSuite::M149() { - if (parser.seenval('C')) parser.set_input_temp_units(TEMPUNIT_C); - else if (parser.seenval('K')) parser.set_input_temp_units(TEMPUNIT_K); - else if (parser.seenval('F')) parser.set_input_temp_units(TEMPUNIT_F); + if (parser.seen('C')) parser.set_input_temp_units(TEMPUNIT_C); + else if (parser.seen('K')) parser.set_input_temp_units(TEMPUNIT_K); + else if (parser.seen('F')) parser.set_input_temp_units(TEMPUNIT_F); else M149_report(); } diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 559a21bc59a8..eee877be80fd 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -99,7 +99,7 @@ #define IS_ULTIPANEL 1 #define STD_ENCODER_PULSES_PER_STEP 2 -#elif ANY(miniVIKI, VIKI2, WYH_L12864, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864) +#elif ANY(miniVIKI, VIKI2, WYH_L12864, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864, EMOTION_TECH_LCD) #define DOGLCD #define IS_DOGM_12864 1 @@ -116,6 +116,9 @@ #define IS_U8GLIB_LM6059_AF 1 #elif ENABLED(AZSMZ_12864) #define IS_U8GLIB_ST7565_64128N 1 + #elif ENABLED(EMOTION_TECH_LCD) + #define IS_U8GLIB_ST7565_64128N 1 + #define ST7565_VOLTAGE_DIVIDER_VALUE 0x07 #endif #elif ENABLED(OLED_PANEL_TINYBOY2) @@ -134,6 +137,7 @@ #define DOGLCD #define IS_U8GLIB_ST7920 1 #define IS_ULTIPANEL 1 + #define ENCODER_PULSES_PER_STEP 2 #elif ENABLED(MKS_12864OLED) @@ -370,6 +374,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 @@ -461,7 +466,7 @@ #define HAS_DGUS_LCD_CLASSIC 1 #endif -#if ANY(HAS_DGUS_LCD_CLASSIC, DGUS_LCD_UI_RELOADED) +#if EITHER(HAS_DGUS_LCD_CLASSIC, DGUS_LCD_UI_RELOADED) #define HAS_DGUS_LCD 1 #endif @@ -513,7 +518,7 @@ #define HAS_LCDPRINT 1 #endif -#if ANY(HAS_DISPLAY, HAS_DWIN_E3V2) +#if HAS_DISPLAY || HAS_DWIN_E3V2 #define HAS_STATUS_MESSAGE 1 #endif @@ -525,10 +530,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 @@ -588,12 +589,26 @@ #else #undef EXTRUDERS #define EXTRUDERS 0 + #undef TEMP_SENSOR_0 + #undef TEMP_SENSOR_1 + #undef TEMP_SENSOR_2 + #undef TEMP_SENSOR_3 + #undef TEMP_SENSOR_4 + #undef TEMP_SENSOR_5 + #undef TEMP_SENSOR_6 + #undef TEMP_SENSOR_7 #undef SINGLENOZZLE #undef SWITCHING_EXTRUDER #undef SWITCHING_NOZZLE #undef MIXING_EXTRUDER #undef HOTEND_IDLE_TIMEOUT #undef DISABLE_E + #undef THERMAL_PROTECTION_HOTENDS + #undef PREVENT_COLD_EXTRUSION + #undef PREVENT_LENGTHY_EXTRUDE + #undef FILAMENT_RUNOUT_SENSOR + #undef FILAMENT_RUNOUT_DISTANCE_MM + #undef DISABLE_INACTIVE_EXTRUDER #endif #define E_OPTARG(N) OPTARG(HAS_MULTI_EXTRUDER, N) @@ -665,13 +680,46 @@ #define E_MANUAL EXTRUDERS #endif +#if E_STEPPERS <= 7 + #undef INVERT_E7_DIR + #undef E7_DRIVER_TYPE + #if E_STEPPERS <= 6 + #undef INVERT_E6_DIR + #undef E6_DRIVER_TYPE + #if E_STEPPERS <= 5 + #undef INVERT_E5_DIR + #undef E5_DRIVER_TYPE + #if E_STEPPERS <= 4 + #undef INVERT_E4_DIR + #undef E4_DRIVER_TYPE + #if E_STEPPERS <= 3 + #undef INVERT_E3_DIR + #undef E3_DRIVER_TYPE + #if E_STEPPERS <= 2 + #undef INVERT_E2_DIR + #undef E2_DRIVER_TYPE + #if E_STEPPERS <= 1 + #undef INVERT_E1_DIR + #undef E1_DRIVER_TYPE + #if E_STEPPERS == 0 + #undef INVERT_E0_DIR + #undef E0_DRIVER_TYPE + #endif + #endif + #endif + #endif + #endif + #endif + #endif +#endif + /** * Number of Linear Axes (e.g., XYZIJKUVW) * All the logical axes except for the tool (E) axis */ -#ifdef LINEAR_AXES - #undef LINEAR_AXES - #define LINEAR_AXES_WARNING 1 +#ifdef NUM_AXES + #undef NUM_AXES + #define NUM_AXES_WARNING 1 #endif #ifdef W_DRIVER_TYPE @@ -693,6 +741,7 @@ #else #define NUM_AXES 1 #endif +#define HAS_X_AXIS 1 #if NUM_AXES >= XY #define HAS_Y_AXIS 1 #if NUM_AXES >= XYZ @@ -727,31 +776,6 @@ #endif #endif -#if E_STEPPERS <= 0 - #undef E0_DRIVER_TYPE -#endif -#if E_STEPPERS <= 1 - #undef E1_DRIVER_TYPE -#endif -#if E_STEPPERS <= 2 - #undef E2_DRIVER_TYPE -#endif -#if E_STEPPERS <= 3 - #undef E3_DRIVER_TYPE -#endif -#if E_STEPPERS <= 4 - #undef E4_DRIVER_TYPE -#endif -#if E_STEPPERS <= 5 - #undef E5_DRIVER_TYPE -#endif -#if E_STEPPERS <= 6 - #undef E6_DRIVER_TYPE -#endif -#if E_STEPPERS <= 7 - #undef E7_DRIVER_TYPE -#endif - #if !HAS_Y_AXIS #undef ENDSTOPPULLUP_YMIN #undef ENDSTOPPULLUP_YMAX @@ -765,6 +789,8 @@ #undef Y_MIN_POS #undef Y_MAX_POS #undef MANUAL_Y_HOME_POS + #undef MIN_SOFTWARE_ENDSTOP_Y + #undef MAX_SOFTWARE_ENDSTOP_Y #endif #if !HAS_Z_AXIS @@ -782,6 +808,8 @@ #undef Z_MIN_POS #undef Z_MAX_POS #undef MANUAL_Z_HOME_POS + #undef MIN_SOFTWARE_ENDSTOP_Z + #undef MAX_SOFTWARE_ENDSTOP_Z #endif #if !HAS_I_AXIS @@ -796,6 +824,8 @@ #undef I_MIN_POS #undef I_MAX_POS #undef MANUAL_I_HOME_POS + #undef MIN_SOFTWARE_ENDSTOP_I + #undef MAX_SOFTWARE_ENDSTOP_I #endif #if !HAS_J_AXIS @@ -810,6 +840,8 @@ #undef J_MIN_POS #undef J_MAX_POS #undef MANUAL_J_HOME_POS + #undef MIN_SOFTWARE_ENDSTOP_J + #undef MAX_SOFTWARE_ENDSTOP_J #endif #if !HAS_K_AXIS @@ -824,6 +856,8 @@ #undef K_MIN_POS #undef K_MAX_POS #undef MANUAL_K_HOME_POS + #undef MIN_SOFTWARE_ENDSTOP_K + #undef MAX_SOFTWARE_ENDSTOP_K #endif #if !HAS_U_AXIS @@ -838,6 +872,8 @@ #undef U_MIN_POS #undef U_MAX_POS #undef MANUAL_U_HOME_POS + #undef MIN_SOFTWARE_ENDSTOP_U + #undef MAX_SOFTWARE_ENDSTOP_U #endif #if !HAS_V_AXIS @@ -852,6 +888,8 @@ #undef V_MIN_POS #undef V_MAX_POS #undef MANUAL_V_HOME_POS + #undef MIN_SOFTWARE_ENDSTOP_V + #undef MAX_SOFTWARE_ENDSTOP_V #endif #if !HAS_W_AXIS @@ -866,6 +904,8 @@ #undef W_MIN_POS #undef W_MAX_POS #undef MANUAL_W_HOME_POS + #undef MIN_SOFTWARE_ENDSTOP_W + #undef MAX_SOFTWARE_ENDSTOP_W #endif #ifdef X2_DRIVER_TYPE @@ -879,7 +919,7 @@ /** * Number of Primary Linear Axes (e.g., XYZ) - * X, XY, or XYZ axes. Excluding duplicate axes (X2, Y2. Z2. Z3, Z4) + * X, XY, or XYZ axes. Excluding duplicate axes (X2, Y2, Z2, Z3, Z4) */ #if NUM_AXES >= 3 #define PRIMARY_LINEAR_AXES 3 @@ -941,7 +981,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. @@ -971,8 +1011,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) @@ -1016,20 +1059,6 @@ #ifndef Z_PROBE_SERVO_NR #define Z_PROBE_SERVO_NR 0 #endif - #ifdef DEACTIVATE_SERVOS_AFTER_MOVE - #error "BLTOUCH requires DEACTIVATE_SERVOS_AFTER_MOVE to be to disabled. Please update your Configuration.h file." - #endif - - // Always disable probe pin inverting for BLTouch - #if Z_MIN_PROBE_ENDSTOP_INVERTING - #error "BLTOUCH requires Z_MIN_PROBE_ENDSTOP_INVERTING set to false. Please update your Configuration.h file." - #endif - - #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) - #if Z_MIN_ENDSTOP_INVERTING - #error "BLTOUCH requires Z_MIN_ENDSTOP_INVERTING set to false. Please update your Configuration.h file." - #endif - #endif #endif /** @@ -1046,9 +1075,12 @@ #endif /** - * Set a flag for any type of bed probe, including the paper-test + * Set flags for any form of bed probe */ -#if ANY(HAS_Z_SERVO_PROBE, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, SOLENOID_PROBE, SENSORLESS_PROBING, RACK_AND_PINION_PROBE, MAGLEV4) +#if ANY(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, HAS_Z_SERVO_PROBE, SOLENOID_PROBE, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING, MAGLEV4, MAG_MOUNTED_PROBE) + #define HAS_STOWABLE_PROBE 1 +#endif +#if ANY(HAS_STOWABLE_PROBE, FIX_MOUNTED_PROBE, BD_SENSOR, NOZZLE_AS_PROBE) #define HAS_BED_PROBE 1 #endif @@ -1152,45 +1184,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 +#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 Z_HOME_DIR > 0 - #define Z_HOME_TO_MAX 1 -#elif Z_HOME_DIR < 0 - #define Z_HOME_TO_MIN 1 +#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 I_HOME_DIR > 0 - #define I_HOME_TO_MAX 1 -#elif I_HOME_DIR < 0 - #define I_HOME_TO_MIN 1 +#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 J_HOME_DIR > 0 - #define J_HOME_TO_MAX 1 -#elif J_HOME_DIR < 0 - #define J_HOME_TO_MIN 1 +#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 K_HOME_DIR > 0 - #define K_HOME_TO_MAX 1 -#elif K_HOME_DIR < 0 - #define K_HOME_TO_MIN 1 +#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 U_HOME_DIR > 0 - #define U_HOME_TO_MAX 1 -#elif U_HOME_DIR < 0 - #define U_HOME_TO_MIN 1 +#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 V_HOME_DIR > 0 - #define V_HOME_TO_MAX 1 -#elif V_HOME_DIR < 0 - #define V_HOME_TO_MIN 1 +#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 W_HOME_DIR > 0 - #define W_HOME_TO_MAX 1 -#elif W_HOME_DIR < 0 - #define W_HOME_TO_MIN 1 +#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 /** @@ -1206,13 +1254,13 @@ #if NONE(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, HAS_DELTA_SENSORLESS_PROBING) #define USES_Z_MIN_PROBE_PIN 1 #endif - #if Z_HOME_TO_MIN && TERN1(USES_Z_MIN_PROBE_PIN, ENABLED(USE_PROBE_FOR_Z_HOMING)) + #if Z_HOME_TO_MIN && (DISABLED(USES_Z_MIN_PROBE_PIN) || ENABLED(USE_PROBE_FOR_Z_HOMING)) #define HOMING_Z_WITH_PROBE 1 #endif #ifndef Z_PROBE_LOW_POINT #define Z_PROBE_LOW_POINT -5 #endif - #if ENABLED(Z_PROBE_ALLEN_KEY) + #if EITHER(Z_PROBE_ALLEN_KEY, MAG_MOUNTED_PROBE) #define PROBE_TRIGGERED_WHEN_STOWED_TEST 1 // Extra test for Allen Key Probe #endif #if MULTIPLE_PROBING > 1 @@ -1226,6 +1274,7 @@ // Clear probe pin settings when no probe is selected #undef Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN #undef USE_PROBE_FOR_Z_HOMING + #undef Z_MIN_PROBE_REPEATABILITY_TEST #endif #if ENABLED(BELTPRINTER) && !defined(HOME_Y_BEFORE_X) @@ -1392,6 +1441,10 @@ #define EXTRUDE_MINTEMP 170 #endif +#if ANY(PID_DEBUG, PID_BED_DEBUG, PID_CHAMBER_DEBUG) + #define HAS_PID_DEBUG 1 +#endif + /** * TFT Displays * @@ -1427,7 +1480,7 @@ #define TFT_DEFAULT_ORIENTATION 0 #define TFT_RES_480x272 #define TFT_INTERFACE_FSMC -#elif ANY(MKS_ROBIN_TFT_V1_1R, LONGER_LK_TFT28) // ILI9328 or R61505 +#elif EITHER(MKS_ROBIN_TFT_V1_1R, LONGER_LK_TFT28) // ILI9328 or R61505 #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y) #define TFT_RES_320x240 #define TFT_INTERFACE_FSMC @@ -1440,7 +1493,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) @@ -1463,7 +1516,13 @@ #elif ENABLED(TFT_RES_1024x600) #define TFT_WIDTH 1024 #define TFT_HEIGHT 600 - #define GRAPHICAL_TFT_UPSCALE 4 + #if ENABLED(TOUCH_SCREEN) + #define GRAPHICAL_TFT_UPSCALE 6 + #define TFT_PIXEL_OFFSET_X 120 + #else + #define GRAPHICAL_TFT_UPSCALE 8 + #define TFT_PIXEL_OFFSET_X 0 + #endif #endif // FSMC/SPI TFT Panels using standard HAL/tft/tft_(fsmc|spi|ltdc).h @@ -1512,6 +1571,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 @@ -1522,7 +1583,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) @@ -1533,7 +1594,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) @@ -1567,7 +1628,9 @@ #endif #endif -#if X_HOME_DIR || (HAS_Y_AXIS && Y_HOME_DIR) || (HAS_Z_AXIS && Z_HOME_DIR) || (HAS_I_AXIS && I_HOME_DIR) || (HAS_J_AXIS && J_HOME_DIR) || (HAS_K_AXIS && K_HOME_DIR) +#if X_HOME_DIR || (HAS_Y_AXIS && Y_HOME_DIR) || (HAS_Z_AXIS && Z_HOME_DIR) \ + || (HAS_I_AXIS && I_HOME_DIR) || (HAS_J_AXIS && J_HOME_DIR) || (HAS_K_AXIS && K_HOME_DIR) \ + || (HAS_U_AXIS && U_HOME_DIR) || (HAS_V_AXIS && V_HOME_DIR) || (HAS_W_AXIS && W_HOME_DIR) #define HAS_ENDSTOPS 1 #define COORDINATE_OKAY(N,L,H) WITHIN(N,L,H) #else diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 130e68f61ee9..faf882389179 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -79,31 +79,54 @@ #define SERVO_DELAY { 50 } #endif +#if !HAS_BED_PROBE + #undef BABYSTEP_ZPROBE_OFFSET +#endif +#if !HAS_STOWABLE_PROBE + #undef PROBE_DEPLOY_STOW_MENU +#endif + +// Some options are disallowed without required axes +#if !HAS_Y_AXIS + #undef SAFE_BED_LEVELING_START_Y + #undef ARC_SUPPORT + #undef INPUT_SHAPING_Y + #undef SHAPING_FREQ_Y + #undef SHAPING_BUFFER_Y +#endif +#if !HAS_Z_AXIS + #undef SAFE_BED_LEVELING_START_Z +#endif +#if !HAS_I_AXIS + #undef SAFE_BED_LEVELING_START_I +#endif +#if !HAS_J_AXIS + #undef SAFE_BED_LEVELING_START_J +#endif +#if !HAS_K_AXIS + #undef SAFE_BED_LEVELING_START_K +#endif +#if !HAS_U_AXIS + #undef SAFE_BED_LEVELING_START_U +#endif +#if !HAS_V_AXIS + #undef SAFE_BED_LEVELING_START_V +#endif +#if !HAS_W_AXIS + #undef SAFE_BED_LEVELING_START_W +#endif + +// Disallowed with no extruders #if !HAS_EXTRUDERS #define NO_VOLUMETRICS - #undef TEMP_SENSOR_0 - #undef TEMP_SENSOR_1 - #undef TEMP_SENSOR_2 - #undef TEMP_SENSOR_3 - #undef TEMP_SENSOR_4 - #undef TEMP_SENSOR_5 - #undef TEMP_SENSOR_6 - #undef TEMP_SENSOR_7 #undef FWRETRACT #undef PIDTEMP #undef AUTOTEMP #undef PID_EXTRUSION_SCALING #undef LIN_ADVANCE - #undef FILAMENT_RUNOUT_SENSOR #undef ADVANCED_PAUSE_FEATURE - #undef FILAMENT_RUNOUT_DISTANCE_MM - #undef FILAMENT_LOAD_UNLOAD_GCODES - #undef DISABLE_INACTIVE_EXTRUDER #undef FILAMENT_LOAD_UNLOAD_GCODES #undef EXTRUDER_RUNOUT_PREVENT - #undef PREVENT_COLD_EXTRUSION - #undef PREVENT_LENGTHY_EXTRUDE - #undef THERMAL_PROTECTION_HOTENDS #undef THERMAL_PROTECTION_PERIOD #undef WATCH_TEMP_PERIOD #undef SHOW_TEMP_ADC_VALUES @@ -112,6 +135,31 @@ #undef STEALTHCHOP_E #endif +#if HOTENDS <= 7 + #undef E7_AUTO_FAN_PIN + #if HOTENDS <= 6 + #undef E6_AUTO_FAN_PIN + #if HOTENDS <= 5 + #undef E5_AUTO_FAN_PIN + #if HOTENDS <= 4 + #undef E4_AUTO_FAN_PIN + #if HOTENDS <= 3 + #undef E3_AUTO_FAN_PIN + #if HOTENDS <= 2 + #undef E2_AUTO_FAN_PIN + #if HOTENDS <= 1 + #undef E1_AUTO_FAN_PIN + #if HOTENDS == 0 + #undef E0_AUTO_FAN_PIN + #endif + #endif + #endif + #endif + #endif + #endif + #endif +#endif + /** * Temperature Sensors; define what sensor(s) we have. */ @@ -132,9 +180,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) ) @@ -150,8 +199,7 @@ #define REDUNDANT_TEMP_MATCH(...) 0 #endif -#if TEMP_SENSOR_0 == -5 || TEMP_SENSOR_0 == -3 || TEMP_SENSOR_0 == -2 - #define TEMP_SENSOR_0_IS_MAX_TC 1 +#if TEMP_SENSOR_IS_MAX_TC(0) #if TEMP_SENSOR_0 == -5 #define TEMP_SENSOR_0_IS_MAX31865 1 #define TEMP_SENSOR_0_MAX_TC_TMIN 0 @@ -175,20 +223,18 @@ #define TEMP_SENSOR_0_IS_AD8495 1 #elif TEMP_SENSOR_0 == -1 #define TEMP_SENSOR_0_IS_AD595 1 +#elif TEMP_SENSOR_0 == 1000 + #define TEMP_SENSOR_0_IS_CUSTOM 1 +#elif TEMP_SENSOR_0 == 998 || TEMP_SENSOR_0 == 999 + #define TEMP_SENSOR_0_IS_DUMMY 1 #elif TEMP_SENSOR_0 > 0 #define TEMP_SENSOR_0_IS_THERMISTOR 1 - #if TEMP_SENSOR_0 == 1000 - #define TEMP_SENSOR_0_IS_CUSTOM 1 - #elif TEMP_SENSOR_0 == 998 || TEMP_SENSOR_0 == 999 - #define TEMP_SENSOR_0_IS_DUMMY 1 - #endif #else #undef HEATER_0_MINTEMP #undef HEATER_0_MAXTEMP #endif -#if TEMP_SENSOR_1 == -5 || TEMP_SENSOR_1 == -3 || TEMP_SENSOR_1 == -2 - #define TEMP_SENSOR_1_IS_MAX_TC 1 +#if TEMP_SENSOR_IS_MAX_TC(1) #if TEMP_SENSOR_1 == -5 #define TEMP_SENSOR_1_IS_MAX31865 1 #define TEMP_SENSOR_1_MAX_TC_TMIN 0 @@ -222,40 +268,137 @@ #define TEMP_SENSOR_1_IS_AD8495 1 #elif TEMP_SENSOR_1 == -1 #define TEMP_SENSOR_1_IS_AD595 1 +#elif TEMP_SENSOR_1 == 1000 + #define TEMP_SENSOR_1_IS_CUSTOM 1 +#elif TEMP_SENSOR_1 == 998 || TEMP_SENSOR_1 == 999 + #define TEMP_SENSOR_1_IS_DUMMY 1 #elif TEMP_SENSOR_1 > 0 #define TEMP_SENSOR_1_IS_THERMISTOR 1 - #if TEMP_SENSOR_1 == 1000 - #define TEMP_SENSOR_1_IS_CUSTOM 1 - #elif TEMP_SENSOR_1 == 998 || TEMP_SENSOR_1 == 999 - #define TEMP_SENSOR_1_IS_DUMMY 1 - #endif #else #undef HEATER_1_MINTEMP #undef HEATER_1_MAXTEMP #endif -#if TEMP_SENSOR_REDUNDANT == -5 || TEMP_SENSOR_REDUNDANT == -3 || TEMP_SENSOR_REDUNDANT == -2 - #define TEMP_SENSOR_REDUNDANT_IS_MAX_TC 1 +#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 == 1000 + #define TEMP_SENSOR_2_IS_CUSTOM 1 +#elif TEMP_SENSOR_2 == 998 || TEMP_SENSOR_2 == 999 + #define TEMP_SENSOR_2_IS_DUMMY 1 +#elif TEMP_SENSOR_2 > 0 + #define TEMP_SENSOR_2_IS_THERMISTOR 1 +#else + #undef HEATER_2_MINTEMP + #undef HEATER_2_MAXTEMP +#endif + +#if TEMP_SENSOR_3 == 1000 + #define TEMP_SENSOR_3_IS_CUSTOM 1 +#elif TEMP_SENSOR_3 == 998 || TEMP_SENSOR_3 == 999 + #define TEMP_SENSOR_3_IS_DUMMY 1 +#elif TEMP_SENSOR_3 > 0 + #define TEMP_SENSOR_3_IS_THERMISTOR 1 +#elif !TEMP_SENSOR_3 + #undef HEATER_3_MINTEMP + #undef HEATER_3_MAXTEMP +#endif + +#if TEMP_SENSOR_4 == 1000 + #define TEMP_SENSOR_4_IS_CUSTOM 1 +#elif TEMP_SENSOR_4 == 998 || TEMP_SENSOR_4 == 999 + #define TEMP_SENSOR_4_IS_DUMMY 1 +#elif TEMP_SENSOR_4 > 0 + #define TEMP_SENSOR_4_IS_THERMISTOR 1 +#elif !TEMP_SENSOR_4 + #undef HEATER_4_MINTEMP + #undef HEATER_4_MAXTEMP +#endif + +#if TEMP_SENSOR_5 == 1000 + #define TEMP_SENSOR_5_IS_CUSTOM 1 +#elif TEMP_SENSOR_5 == 998 || TEMP_SENSOR_5 == 999 + #define TEMP_SENSOR_5_IS_DUMMY 1 +#elif TEMP_SENSOR_5 > 0 + #define TEMP_SENSOR_5_IS_THERMISTOR 1 +#elif !TEMP_SENSOR_5 + #undef HEATER_5_MINTEMP + #undef HEATER_5_MAXTEMP +#endif +#if TEMP_SENSOR_6 == 1000 + #define TEMP_SENSOR_6_IS_CUSTOM 1 +#elif TEMP_SENSOR_6 == 998 || TEMP_SENSOR_6 == 999 + #define TEMP_SENSOR_6_IS_DUMMY 1 +#elif TEMP_SENSOR_6 > 0 + #define TEMP_SENSOR_6_IS_THERMISTOR 1 +#elif !TEMP_SENSOR_6 + #undef HEATER_6_MINTEMP + #undef HEATER_6_MAXTEMP +#endif + +#if TEMP_SENSOR_7 == 1000 + #define TEMP_SENSOR_7_IS_CUSTOM 1 +#elif TEMP_SENSOR_7 == 998 || TEMP_SENSOR_7 == 999 + #define TEMP_SENSOR_7_IS_DUMMY 1 +#elif TEMP_SENSOR_7 > 0 + #define TEMP_SENSOR_7_IS_THERMISTOR 1 +#elif !TEMP_SENSOR_7 + #undef HEATER_7_MINTEMP + #undef HEATER_7_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 @@ -276,15 +419,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_0_IS_MAX_TC && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_0) || (TEMP_SENSOR_1_IS_MAX_TC && 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 @@ -300,39 +449,19 @@ #endif #endif -#if TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC || TEMP_SENSOR_REDUNDANT_IS_MAX_TC +#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 @@ -556,16 +685,6 @@ #endif #endif -// Probe Temperature Compensation -#if !TEMP_SENSOR_PROBE - #undef PTC_PROBE -#endif -#if !TEMP_SENSOR_BED - #undef PTC_BED -#endif -#if !HAS_EXTRUDERS - #undef PTC_HOTEND -#endif #if ANY(PTC_PROBE, PTC_BED, PTC_HOTEND) #define HAS_PTC 1 #endif @@ -583,10 +702,20 @@ #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 + #if STATUS_MESSAGE_TIMEOUT_SEC > 0 #define HAS_STATUS_MESSAGE_TIMEOUT 1 #endif @@ -628,10 +757,10 @@ #if ALL(HAS_RESUME_CONTINUE, PRINTER_EVENT_LEDS, SDSUPPORT) #define HAS_LEDS_OFF_FLAG 1 #endif -#ifdef DISPLAY_SLEEP_MINUTES +#if 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 @@ -936,8 +1065,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 @@ -947,6 +1076,7 @@ #undef CNC_WORKSPACE_PLANES #if NUM_AXES < 2 #undef STEALTHCHOP_Y + #undef QUICK_HOME #endif #endif #endif @@ -956,6 +1086,12 @@ #endif #endif +#if defined(SAFE_BED_LEVELING_START_X) || defined(SAFE_BED_LEVELING_START_Y) || defined(SAFE_BED_LEVELING_START_Z) \ + || defined(SAFE_BED_LEVELING_START_I) || defined(SAFE_BED_LEVELING_START_J) || defined(SAFE_BED_LEVELING_START_K) \ + || defined(SAFE_BED_LEVELING_START_U) || defined(SAFE_BED_LEVELING_START_V) || defined(SAFE_BED_LEVELING_START_W) + #define HAS_SAFE_BED_LEVELING 1 +#endif + // // SD Card connection methods // Defined here so pins and sanity checks can use them @@ -984,7 +1120,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 @@ -1018,13 +1154,13 @@ * LCD_SERIAL_PORT must be defined ahead of HAL.h */ #ifndef LCD_SERIAL_PORT - #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI - #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 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, BTT_OCTOPUS_V1_1) #define LCD_SERIAL_PORT 1 - #elif MB(CREALITY_V24S1_301, CREALITY_V24S1_301F4, CREALITY_V423) - #define LCD_SERIAL_PORT 2 // Creality Ender3S1 board + #elif MB(CREALITY_V24S1_301, CREALITY_V24S1_301F4, CREALITY_V423, MKS_ROBIN) + #define LCD_SERIAL_PORT 2 // Creality Ender3S1, MKS Robin #else - #define LCD_SERIAL_PORT 3 // Creality 4.x board + #define LCD_SERIAL_PORT 3 // Other boards #endif #endif #ifdef LCD_SERIAL_PORT @@ -1048,3 +1184,19 @@ #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 + +// Input shaping +#if EITHER(INPUT_SHAPING_X, INPUT_SHAPING_Y) + #define HAS_SHAPING 1 +#endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 9edcd6f1aa9a..3adfddd4620e 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -48,7 +48,7 @@ // Set additional flags to let HALs choose in their Conditionals_post.h #if ANY(FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION, SDCARD_EEPROM_EMULATION, QSPI_EEPROM) #define USE_EMULATED_EEPROM 1 - #elif ANY(I2C_EEPROM, SPI_EEPROM) + #elif EITHER(I2C_EEPROM, SPI_EEPROM) #define USE_WIRED_EEPROM 1 #elif ENABLED(IIC_BL24CXX_EEPROM) // nothing @@ -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 @@ -190,22 +190,22 @@ #define XY_CENTER { X_CENTER, Y_CENTER } #endif #if HAS_I_AXIS - #define I_CENTER TERN(BED_CENTER_AT_0_0, 0, _I_HALF_BED) + #define I_CENTER _I_HALF_BED #endif #if HAS_J_AXIS - #define J_CENTER TERN(BED_CENTER_AT_0_0, 0, _J_HALF_BED) + #define J_CENTER _J_HALF_BED #endif #if HAS_K_AXIS - #define K_CENTER TERN(BED_CENTER_AT_0_0, 0, _K_HALF_BED) + #define K_CENTER _K_HALF_BED #endif #if HAS_U_AXIS - #define U_CENTER TERN(BED_CENTER_AT_0_0, 0, _U_HALF_BED) + #define U_CENTER _U_HALF_BED #endif #if HAS_V_AXIS - #define V_CENTER TERN(BED_CENTER_AT_0_0, 0, _V_HALF_BED) + #define V_CENTER _V_HALF_BED #endif #if HAS_W_AXIS - #define W_CENTER TERN(BED_CENTER_AT_0_0, 0, _W_HALF_BED) + #define W_CENTER _W_HALF_BED #endif // Get the linear boundaries of the bed @@ -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 /** @@ -339,21 +341,21 @@ #ifdef MANUAL_U_HOME_POS #define U_HOME_POS MANUAL_U_HOME_POS #else - #define U_HOME_POS (U_HOME_DIR < 0 ? U_MIN_POS : U_MAX_POS) + #define U_HOME_POS TERN(U_HOME_TO_MIN, U_MIN_POS, U_MAX_POS) #endif #endif #if HAS_V_AXIS #ifdef MANUAL_V_HOME_POS #define V_HOME_POS MANUAL_V_HOME_POS #else - #define V_HOME_POS (V_HOME_DIR < 0 ? V_MIN_POS : V_MAX_POS) + #define V_HOME_POS TERN(V_HOME_TO_MIN, V_MIN_POS, V_MAX_POS) #endif #endif #if HAS_W_AXIS #ifdef MANUAL_W_HOME_POS #define W_HOME_POS MANUAL_W_HOME_POS #else - #define W_HOME_POS (W_HOME_DIR < 0 ? W_MIN_POS : W_MAX_POS) + #define W_HOME_POS TERN(W_HOME_TO_MIN, W_MIN_POS, W_MAX_POS) #endif #endif @@ -471,6 +473,8 @@ #elif ENABLED(ZONESTAR_12864OLED) #define _LCD_CONTRAST_MIN 64 #define _LCD_CONTRAST_INIT 128 +#elif ENABLED(EMOTION_TECH_LCD) + #define _LCD_CONTRAST_INIT 140 #elif IS_TFTGLCD_PANEL #define _LCD_CONTRAST_INIT 250 #endif @@ -507,7 +511,7 @@ */ #if ENABLED(SDSUPPORT) - #if HAS_SD_HOST_DRIVE && SD_CONNECTION_IS(ONBOARD) + #if HAS_SD_HOST_DRIVE && SD_CONNECTION_IS(ONBOARD) && DISABLED(KEEP_SD_DETECT) // // The external SD card is not used. Hardware SPI is used to access the card. // When sharing the SD card with a PC we want the menu options to @@ -679,7 +683,7 @@ #if HAS_MAX_TC // Translate old _SS, _CS, _SCK, _DO, _DI, _MISO, and _MOSI PIN defines. - #if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1)) + #if TEMP_SENSOR_IS_MAX_TC(0) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1)) #if !PIN_EXISTS(TEMP_0_CS) // SS, CS #if PIN_EXISTS(MAX6675_SS) @@ -721,19 +725,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 @@ -746,9 +750,9 @@ #endif #endif - #endif // TEMP_SENSOR_0_IS_MAX_TC + #endif // TEMP_SENSOR_IS_MAX_TC(0) - #if TEMP_SENSOR_1_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1)) + #if TEMP_SENSOR_IS_MAX_TC(1) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1)) #if !PIN_EXISTS(TEMP_1_CS) // SS2, CS2 #if PIN_EXISTS(MAX6675_SS2) @@ -815,7 +819,76 @@ #endif #endif - #endif // TEMP_SENSOR_1_IS_MAX_TC + #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 @@ -855,56 +928,14 @@ #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 + #if !PIN_EXISTS(X2_MAX) + #undef X2_MAX_PIN + #if PIN_EXISTS(X2_STOP) + #define X2_MAX_PIN X2_STOP_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_ @@ -919,56 +950,20 @@ #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 + #if !PIN_EXISTS(X2_MIN) + #undef X2_MIN_PIN + #if PIN_EXISTS(X2_STOP) + #define X2_MIN_PIN X2_STOP_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 @@ -990,56 +985,14 @@ #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 + #if !PIN_EXISTS(Y2_MAX) + #undef Y2_MAX_PIN + #if PIN_EXISTS(Y2_STOP) + #define Y2_MAX_PIN Y2_STOP_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_ @@ -1054,56 +1007,20 @@ #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 + #if !PIN_EXISTS(Y2_MIN) + #undef Y2_MIN_PIN + #if PIN_EXISTS(Y2_STOP) + #define Y2_MIN_PIN Y2_STOP_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 @@ -1126,56 +1043,14 @@ #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 + #if !PIN_EXISTS(Z2_MAX) + #undef Z2_MAX_PIN + #if PIN_EXISTS(Z2_STOP) + #define Z2_MAX_PIN Z2_STOP_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_ @@ -1190,56 +1065,20 @@ #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 + #if !PIN_EXISTS(Z2_MIN) + #undef Z2_MIN_PIN + #if PIN_EXISTS(Z2_STOP) + #define Z2_MIN_PIN Z2_STOP_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 @@ -1257,56 +1096,14 @@ #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 + #if !PIN_EXISTS(Z3_MAX) + #undef Z3_MAX_PIN + #if PIN_EXISTS(Z3_STOP) + #define Z3_MAX_PIN Z3_STOP_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_ @@ -1321,56 +1118,20 @@ #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 + #if !PIN_EXISTS(Z3_MIN) + #undef Z3_MIN_PIN + #if PIN_EXISTS(Z3_STOP) + #define Z3_MIN_PIN Z3_STOP_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 @@ -1389,56 +1150,14 @@ #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 + #if !PIN_EXISTS(Z4_MAX) + #undef Z4_MAX_PIN + #if PIN_EXISTS(Z4_STOP) + #define Z4_MAX_PIN Z4_STOP_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_ @@ -1453,56 +1172,20 @@ #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 + #if !PIN_EXISTS(Z4_MIN) + #undef Z4_MIN_PIN + #if PIN_EXISTS(Z4_STOP) + #define Z4_MIN_PIN Z4_STOP_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 @@ -1581,6 +1264,24 @@ #if ENABLED(USE_ZMAX_PLUG) #define ENDSTOPPULLDOWN_ZMAX #endif + #if ENABLED(USE_IMAX_PLUG) + #define ENDSTOPPULLDOWN_IMAX + #endif + #if ENABLED(USE_JMAX_PLUG) + #define ENDSTOPPULLDOWN_JMAX + #endif + #if ENABLED(USE_KMAX_PLUG) + #define ENDSTOPPULLDOWN_KMAX + #endif + #if ENABLED(USE_UMAX_PLUG) + #define ENDSTOPPULLDOWN_UMAX + #endif + #if ENABLED(USE_VMAX_PLUG) + #define ENDSTOPPULLDOWN_VMAX + #endif + #if ENABLED(USE_WMAX_PLUG) + #define ENDSTOPPULLDOWN_WMAX + #endif #if ENABLED(USE_XMIN_PLUG) #define ENDSTOPPULLDOWN_XMIN #endif @@ -1590,6 +1291,24 @@ #if ENABLED(USE_ZMIN_PLUG) #define ENDSTOPPULLDOWN_ZMIN #endif + #if ENABLED(USE_IMIN_PLUG) + #define ENDSTOPPULLDOWN_IMIN + #endif + #if ENABLED(USE_JMIN_PLUG) + #define ENDSTOPPULLDOWN_JMIN + #endif + #if ENABLED(USE_KMIN_PLUG) + #define ENDSTOPPULLDOWN_KMIN + #endif + #if ENABLED(USE_UMIN_PLUG) + #define ENDSTOPPULLDOWN_UMIN + #endif + #if ENABLED(USE_VMIN_PLUG) + #define ENDSTOPPULLDOWN_VMIN + #endif + #if ENABLED(USE_WMIN_PLUG) + #define ENDSTOPPULLDOWN_WMIN + #endif #endif /** @@ -1610,7 +1329,7 @@ #define HAS_X_MS_PINS 1 #endif -#if PIN_EXISTS(X2_ENABLE) || AXIS_IS_L64XX(X2) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X2)) +#if PIN_EXISTS(X2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X2)) #define HAS_X2_ENABLE 1 #endif #if PIN_EXISTS(X2_DIR) @@ -1631,7 +1350,7 @@ #endif #if HAS_Y_AXIS - #if PIN_EXISTS(Y_ENABLE) || AXIS_IS_L64XX(Y) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y)) + #if PIN_EXISTS(Y_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y)) #define HAS_Y_ENABLE 1 #endif #if PIN_EXISTS(Y_DIR) @@ -1644,7 +1363,7 @@ #define HAS_Y_MS_PINS 1 #endif - #if PIN_EXISTS(Y2_ENABLE) || AXIS_IS_L64XX(Y2) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y2)) + #if PIN_EXISTS(Y2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y2)) #define HAS_Y2_ENABLE 1 #endif #if PIN_EXISTS(Y2_DIR) @@ -1664,7 +1383,7 @@ #endif #if HAS_Z_AXIS - #if PIN_EXISTS(Z_ENABLE) || AXIS_IS_L64XX(Z) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z)) + #if PIN_EXISTS(Z_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z)) #define HAS_Z_ENABLE 1 #endif #if PIN_EXISTS(Z_DIR) @@ -1684,7 +1403,7 @@ #endif #if NUM_Z_STEPPERS >= 2 - #if PIN_EXISTS(Z2_ENABLE) || AXIS_IS_L64XX(Z2) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2)) + #if PIN_EXISTS(Z2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2)) #define HAS_Z2_ENABLE 1 #endif #if PIN_EXISTS(Z2_DIR) @@ -1699,7 +1418,7 @@ #endif #if NUM_Z_STEPPERS >= 3 - #if PIN_EXISTS(Z3_ENABLE) || AXIS_IS_L64XX(Z3) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z3)) + #if PIN_EXISTS(Z3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z3)) #define HAS_Z3_ENABLE 1 #endif #if PIN_EXISTS(Z3_DIR) @@ -1714,7 +1433,7 @@ #endif #if NUM_Z_STEPPERS >= 4 - #if PIN_EXISTS(Z4_ENABLE) || AXIS_IS_L64XX(Z4) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z4)) + #if PIN_EXISTS(Z4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z4)) #define HAS_Z4_ENABLE 1 #endif #if PIN_EXISTS(Z4_DIR) @@ -1729,7 +1448,7 @@ #endif #if HAS_I_AXIS - #if PIN_EXISTS(I_ENABLE) || AXIS_IS_L64XX(I) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(I)) + #if PIN_EXISTS(I_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(I)) #define HAS_I_ENABLE 1 #endif #if PIN_EXISTS(I_DIR) @@ -1749,7 +1468,7 @@ #endif #if HAS_J_AXIS - #if PIN_EXISTS(J_ENABLE) || AXIS_IS_L64XX(J) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(J)) + #if PIN_EXISTS(J_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(J)) #define HAS_J_ENABLE 1 #endif #if PIN_EXISTS(J_DIR) @@ -1769,7 +1488,7 @@ #endif #if HAS_K_AXIS - #if PIN_EXISTS(K_ENABLE) || AXIS_IS_L64XX(K) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(K)) + #if PIN_EXISTS(K_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(K)) #define HAS_K_ENABLE 1 #endif #if PIN_EXISTS(K_DIR) @@ -1789,7 +1508,7 @@ #endif #if HAS_U_AXIS - #if PIN_EXISTS(U_ENABLE) || AXIS_IS_L64XX(U) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(U)) + #if PIN_EXISTS(U_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(U)) #define HAS_U_ENABLE 1 #endif #if PIN_EXISTS(U_DIR) @@ -1809,7 +1528,7 @@ #endif #if HAS_V_AXIS - #if PIN_EXISTS(V_ENABLE) || AXIS_IS_L64XX(V) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(V)) + #if PIN_EXISTS(V_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(V)) #define HAS_V_ENABLE 1 #endif #if PIN_EXISTS(V_DIR) @@ -1829,7 +1548,7 @@ #endif #if HAS_W_AXIS - #if PIN_EXISTS(W_ENABLE) || AXIS_IS_L64XX(W) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(W)) + #if PIN_EXISTS(W_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(W)) #define HAS_W_ENABLE 1 #endif #if PIN_EXISTS(W_DIR) @@ -1851,7 +1570,7 @@ // Extruder steppers and solenoids #if HAS_EXTRUDERS - #if PIN_EXISTS(E0_ENABLE) || AXIS_IS_L64XX(E0) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0)) + #if PIN_EXISTS(E0_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0)) #define HAS_E0_ENABLE 1 #endif #if PIN_EXISTS(E0_DIR) @@ -1865,7 +1584,7 @@ #endif #if E_STEPPERS > 1 || ENABLED(E_DUAL_STEPPER_DRIVERS) - #if PIN_EXISTS(E1_ENABLE) || AXIS_IS_L64XX(E1) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1)) + #if PIN_EXISTS(E1_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1)) #define HAS_E1_ENABLE 1 #endif #if PIN_EXISTS(E1_DIR) @@ -1880,7 +1599,7 @@ #endif #if E_STEPPERS > 2 - #if PIN_EXISTS(E2_ENABLE) || AXIS_IS_L64XX(E2) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2)) + #if PIN_EXISTS(E2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2)) #define HAS_E2_ENABLE 1 #endif #if PIN_EXISTS(E2_DIR) @@ -1895,7 +1614,7 @@ #endif #if E_STEPPERS > 3 - #if PIN_EXISTS(E3_ENABLE) || AXIS_IS_L64XX(E3) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3)) + #if PIN_EXISTS(E3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3)) #define HAS_E3_ENABLE 1 #endif #if PIN_EXISTS(E3_DIR) @@ -1910,7 +1629,7 @@ #endif #if E_STEPPERS > 4 - #if PIN_EXISTS(E4_ENABLE) || AXIS_IS_L64XX(E4) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4)) + #if PIN_EXISTS(E4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4)) #define HAS_E4_ENABLE 1 #endif #if PIN_EXISTS(E4_DIR) @@ -1925,7 +1644,7 @@ #endif #if E_STEPPERS > 5 - #if PIN_EXISTS(E5_ENABLE) || AXIS_IS_L64XX(E5) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5)) + #if PIN_EXISTS(E5_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5)) #define HAS_E5_ENABLE 1 #endif #if PIN_EXISTS(E5_DIR) @@ -1940,7 +1659,7 @@ #endif #if E_STEPPERS > 6 - #if PIN_EXISTS(E6_ENABLE) || AXIS_IS_L64XX(E6) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E6)) + #if PIN_EXISTS(E6_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E6)) #define HAS_E6_ENABLE 1 #endif #if PIN_EXISTS(E6_DIR) @@ -1955,7 +1674,7 @@ #endif #if E_STEPPERS > 7 - #if PIN_EXISTS(E7_ENABLE) || AXIS_IS_L64XX(E7) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E7)) + #if PIN_EXISTS(E7_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E7)) #define HAS_E7_ENABLE 1 #endif #if PIN_EXISTS(E7_DIR) @@ -2444,15 +2163,15 @@ // // Flag the indexed hardware serial ports in use -#define CONF_SERIAL_IS(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)) -#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) \ @@ -2479,7 +2198,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) @@ -2541,6 +2260,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 // @@ -2553,7 +2287,7 @@ #define IS_Z3_ENDSTOP(A,M) (ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPERS >= 3 && Z3_USE_ENDSTOP == _##A##M##_) #define IS_Z4_ENDSTOP(A,M) (ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPERS >= 4 && Z4_USE_ENDSTOP == _##A##M##_) -#define _HAS_STOP(A,M) (PIN_EXISTS(A##_##M) && !IS_PROBE_PIN(A,M) && !IS_X2_ENDSTOP(A,M) && !IS_Y2_ENDSTOP(A,M) && !IS_Z2_ENDSTOP(A,M) && !IS_Z3_ENDSTOP(A,M) && !IS_Z4_ENDSTOP(A,M)) +#define _HAS_STOP(A,M) (HAS_##A##_AXIS && PIN_EXISTS(A##_##M) && !IS_PROBE_PIN(A,M) && !IS_X2_ENDSTOP(A,M) && !IS_Y2_ENDSTOP(A,M) && !IS_Z2_ENDSTOP(A,M) && !IS_Z3_ENDSTOP(A,M) && !IS_Z4_ENDSTOP(A,M)) #if _HAS_STOP(X,MIN) #define HAS_X_MIN 1 #endif @@ -2654,7 +2388,7 @@ // // ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface) // -#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && NONE(TEMP_SENSOR_##P##_IS_MAX_TC, 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 @@ -2698,7 +2432,7 @@ #define HAS_TEMP_ADC_REDUNDANT 1 #endif -#define HAS_TEMP(N) ANY(HAS_TEMP_ADC_##N, TEMP_SENSOR_##N##_IS_MAX_TC, TEMP_SENSOR_##N##_IS_DUMMY) +#define HAS_TEMP(N) (TEMP_SENSOR_IS_MAX_TC(N) || EITHER(HAS_TEMP_ADC_##N, TEMP_SENSOR_##N##_IS_DUMMY)) #if HAS_HOTEND && HAS_TEMP(0) #define HAS_TEMP_HOTEND 1 #endif @@ -2774,6 +2508,7 @@ #define BED_MAX_TARGET (BED_MAXTEMP - (BED_OVERSHOOT)) #else #undef PIDTEMPBED + #undef PREHEAT_BEFORE_LEVELING #endif #if HAS_TEMP_COOLER && PIN_EXISTS(COOLER) @@ -2868,10 +2603,21 @@ #if ANY(HAS_AUTO_FAN_0, HAS_AUTO_FAN_1, HAS_AUTO_FAN_2, HAS_AUTO_FAN_3, HAS_AUTO_FAN_4, HAS_AUTO_FAN_5, HAS_AUTO_FAN_6, HAS_AUTO_FAN_7, HAS_AUTO_CHAMBER_FAN, HAS_AUTO_COOLER_FAN) #define HAS_AUTO_FAN 1 -#endif -#define _FANOVERLAP(A,B) (A##_AUTO_FAN_PIN == E##B##_AUTO_FAN_PIN) -#if HAS_AUTO_FAN && (_FANOVERLAP(CHAMBER,0) || _FANOVERLAP(CHAMBER,1) || _FANOVERLAP(CHAMBER,2) || _FANOVERLAP(CHAMBER,3) || _FANOVERLAP(CHAMBER,4) || _FANOVERLAP(CHAMBER,5) || _FANOVERLAP(CHAMBER,6) || _FANOVERLAP(CHAMBER,7)) - #define AUTO_CHAMBER_IS_E 1 + #define _FANOVERLAP(I,T) (T##_AUTO_FAN_PIN == E##I##_AUTO_FAN_PIN) + #if HAS_AUTO_CHAMBER_FAN + #define _CHFANOVERLAP(I) || _FANOVERLAP(I,CHAMBER) + #if (0 REPEAT(8, _CHFANOVERLAP)) + #define AUTO_CHAMBER_IS_E 1 + #endif + #undef _CHFANOVERLAP + #endif + #if HAS_AUTO_COOLER_FAN + #define _COFANOVERLAP(I) || _FANOVERLAP(I,COOLER) + #if (0 REPEAT(8, _COFANOVERLAP)) + #define AUTO_COOLER_IS_E 1 + #endif + #undef _COFANOVERLAP + #endif #endif // Fans check @@ -2916,6 +2662,9 @@ #if !HAS_AUTO_CHAMBER_FAN || AUTO_CHAMBER_IS_E #undef AUTO_POWER_CHAMBER_FAN #endif +#if !HAS_AUTO_COOLER_FAN || AUTO_COOLER_IS_E + #undef AUTO_POWER_COOLER_FAN +#endif // Print Cooling fans (limit) #ifdef NUM_M106_FANS @@ -3122,73 +2871,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 */ @@ -3304,7 +2986,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 @@ -3562,8 +3252,11 @@ #if PIN_EXISTS(BEEPER) #define HAS_BEEPER 1 #endif -#if ANY(HAS_BEEPER, LCD_USE_I2C_BUZZER, PCA9632_BUZZER) - #define HAS_BUZZER 1 +#if ANY(IS_TFTGLCD_PANEL, PCA9632_BUZZER, LCD_USE_I2C_BUZZER) + #define USE_MARLINUI_BUZZER 1 +#endif +#if EITHER(HAS_BEEPER, USE_MARLINUI_BUZZER) + #define HAS_SOUND 1 #endif #if ENABLED(LCD_USE_I2C_BUZZER) @@ -3573,7 +3266,7 @@ #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 #endif -#elif HAS_BUZZER +#elif HAS_SOUND #ifndef LCD_FEEDBACK_FREQUENCY_HZ #define LCD_FEEDBACK_FREQUENCY_HZ 5000 #endif @@ -3582,12 +3275,13 @@ #endif #endif -#if HAS_BUZZER +#if HAS_SOUND #if LCD_FEEDBACK_FREQUENCY_DURATION_MS && LCD_FEEDBACK_FREQUENCY_HZ #define HAS_CHIRP 1 #endif #else #undef SOUND_MENU_ITEM // No buzzer menu item without a buzzer + #undef SOUND_ON_DEFAULT #endif /** @@ -3658,13 +3352,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/inc/MarlinConfig.h b/Marlin/src/inc/MarlinConfig.h index 8fdb4b9baeae..c8584be1c727 100644 --- a/Marlin/src/inc/MarlinConfig.h +++ b/Marlin/src/inc/MarlinConfig.h @@ -34,20 +34,20 @@ #include "../pins/pins.h" #ifndef __MARLIN_DEPS__ - #include HAL_PATH(../HAL, timers.h) - #include HAL_PATH(../HAL, spi_pins.h) + #include HAL_PATH(.., timers.h) + #include HAL_PATH(.., spi_pins.h) #endif #include "Conditionals_post.h" #ifndef __MARLIN_DEPS__ - #include HAL_PATH(../HAL, inc/Conditionals_post.h) + #include HAL_PATH(.., inc/Conditionals_post.h) #include "../core/types.h" // Ahead of sanity-checks #include "SanityCheck.h" - #include HAL_PATH(../HAL, inc/SanityCheck.h) + #include HAL_PATH(.., inc/SanityCheck.h) // Include all core headers #include "../core/language.h" diff --git a/Marlin/src/inc/MarlinConfigPre.h b/Marlin/src/inc/MarlinConfigPre.h index c090b7e37bc4..c2191ab1b74f 100644 --- a/Marlin/src/inc/MarlinConfigPre.h +++ b/Marlin/src/inc/MarlinConfigPre.h @@ -49,7 +49,7 @@ #include "Conditionals_LCD.h" #ifndef __MARLIN_DEPS__ - #include HAL_PATH(../HAL, inc/Conditionals_LCD.h) + #include HAL_PATH(.., inc/Conditionals_LCD.h) #endif #include "../core/drivers.h" @@ -58,5 +58,5 @@ #include "Conditionals_adv.h" #ifndef __MARLIN_DEPS__ - #include HAL_PATH(../HAL, inc/Conditionals_adv.h) + #include HAL_PATH(.., inc/Conditionals_adv.h) #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 816b5d83576b..ca47353fa3b8 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -88,7 +88,7 @@ * Warnings for old configurations */ #ifndef MOTHERBOARD - #error "MOTHERBOARD is required." + #error "MOTHERBOARD is required. You must '#define MOTHERBOARD BOARD_MYNAME' (not just '#define BOARD_MYNAME')." #elif !defined(X_BED_SIZE) || !defined(Y_BED_SIZE) #error "X_BED_SIZE and Y_BED_SIZE are now required!" #elif WATCH_TEMP_PERIOD > 500 @@ -350,7 +350,7 @@ #elif defined(HAVE_TMC2208) #error "HAVE_TMC2208 is now [AXIS]_DRIVER_TYPE TMC2208." #elif defined(HAVE_L6470DRIVER) - #error "HAVE_L6470DRIVER is now [AXIS]_DRIVER_TYPE L6470." + #error "HAVE_L6470DRIVER is obsolete. L64xx stepper drivers are no longer supported in Marlin." #elif defined(X_IS_TMC) || defined(X2_IS_TMC) || defined(Y_IS_TMC) || defined(Y2_IS_TMC) || defined(Z_IS_TMC) || defined(Z2_IS_TMC) || defined(Z3_IS_TMC) \ || defined(E0_IS_TMC) || defined(E1_IS_TMC) || defined(E2_IS_TMC) || defined(E3_IS_TMC) || defined(E4_IS_TMC) || defined(E5_IS_TMC) || defined(E6_IS_TMC) || defined(E7_IS_TMC) #error "[AXIS]_IS_TMC is now [AXIS]_DRIVER_TYPE TMC26X." @@ -363,9 +363,6 @@ #elif defined(X_IS_TMC2208) || defined(X2_IS_TMC2208) || defined(Y_IS_TMC2208) || defined(Y2_IS_TMC2208) || defined(Z_IS_TMC2208) || defined(Z2_IS_TMC2208) || defined(Z3_IS_TMC2208) \ || defined(E0_IS_TMC2208) || defined(E1_IS_TMC2208) || defined(E2_IS_TMC2208) || defined(E3_IS_TMC2208) || defined(E4_IS_TMC2208) || defined(E5_IS_TMC2208) || defined(E6_IS_TMC2208) || defined(E7_IS_TMC2208) #error "[AXIS]_IS_TMC2208 is now [AXIS]_DRIVER_TYPE TMC2208." -#elif defined(X_IS_L6470) || defined(X2_IS_L6470) || defined(Y_IS_L6470) || defined(Y2_IS_L6470) || defined(Z_IS_L6470) || defined(Z2_IS_L6470) || defined(Z3_IS_L6470) \ - || defined(E0_IS_L6470) || defined(E1_IS_L6470) || defined(E2_IS_L6470) || defined(E3_IS_L6470) || defined(E4_IS_L6470) || defined(E5_IS_L6470) || defined(E6_IS_L6470) || defined(E7_IS_L6470) - #error "[AXIS]_IS_L6470 is now [AXIS]_DRIVER_TYPE L6470." #elif defined(AUTOMATIC_CURRENT_CONTROL) #error "AUTOMATIC_CURRENT_CONTROL is now MONITOR_DRIVER_STATUS." #elif defined(FILAMENT_CHANGE_LOAD_LENGTH) @@ -419,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." @@ -447,6 +444,16 @@ #error "SPINDLE_LASER_ACTIVE_HIGH is now SPINDLE_LASER_ACTIVE_STATE." #elif defined(SPINDLE_LASER_ENABLE_INVERT) #error "SPINDLE_LASER_ENABLE_INVERT is now SPINDLE_LASER_ACTIVE_STATE." +#elif defined(LASER_POWER_INLINE) + #error "LASER_POWER_INLINE is not required, inline mode is enabled with 'M3 I' and disabled with 'M5 I'." +#elif defined(LASER_POWER_INLINE_TRAPEZOID) + #error "LASER_POWER_INLINE_TRAPEZOID is now LASER_POWER_TRAP." +#elif defined(LASER_POWER_INLINE_TRAPEZOID_CONT) + #error "LASER_POWER_INLINE_TRAPEZOID_CONT is replaced with LASER_POWER_TRAP." +#elif defined(LASER_POWER_INLINE_TRAPEZOID_PER) + #error "LASER_POWER_INLINE_TRAPEZOID_CONT_PER replaced with LASER_POWER_TRAP." +#elif defined(LASER_POWER_INLINE_CONTINUOUS) + #error "LASER_POWER_INLINE_CONTINUOUS is not required, inline mode is enabled with 'M3 I' and disabled with 'M5 I'." #elif defined(CUTTER_POWER_DISPLAY) #error "CUTTER_POWER_DISPLAY is now CUTTER_POWER_UNIT." #elif defined(CHAMBER_HEATER_PIN) @@ -580,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) @@ -595,6 +602,8 @@ #error "ARC_SUPPORT no longer uses ARC_SEGMENTS_PER_R." #elif ENABLED(ARC_SUPPORT) && (!defined(MIN_ARC_SEGMENT_MM) || !defined(MAX_ARC_SEGMENT_MM)) #error "ARC_SUPPORT now requires MIN_ARC_SEGMENT_MM and MAX_ARC_SEGMENT_MM." +#elif defined(LASER_POWER_INLINE) + #error "LASER_POWER_INLINE is obsolete." #elif defined(SPINDLE_LASER_PWM) #error "SPINDLE_LASER_PWM (true) is now set with SPINDLE_LASER_USE_PWM (enabled)." #elif ANY(IS_RAMPS_EEB, IS_RAMPS_EEF, IS_RAMPS_EFB, IS_RAMPS_EFF, IS_RAMPS_SF) @@ -619,6 +628,8 @@ #error "Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS is now just Z_STEPPER_ALIGN_STEPPER_XY." #elif defined(DWIN_CREALITY_LCD_ENHANCED) #error "DWIN_CREALITY_LCD_ENHANCED is now DWIN_LCD_PROUI." +#elif defined(LINEAR_AXES) + #error "LINEAR_AXES is now NUM_AXES (to account for rotational axes)." #elif defined(X_DUAL_STEPPER_DRIVERS) #error "X_DUAL_STEPPER_DRIVERS is no longer needed and should be removed." #elif defined(Y_DUAL_STEPPER_DRIVERS) @@ -631,11 +642,58 @@ #error "LEVEL_CORNERS_* settings have been renamed BED_TRAMMING_*." #elif defined(LEVEL_CENTER_TOO) #error "LEVEL_CENTER_TOO is now BED_TRAMMING_INCLUDE_CENTER." -#endif - +#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)." +#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." +#elif defined(LIN_ADVANCE_K) + #error "LIN_ADVANCE_K is now ADVANCE_K." +#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 +#define _L6470 0x6470 +#define _L6474 0x6474 +#define _L6480 0x6480 +#define _POWERSTEP01 0xF00D +#if HAS_DRIVER(L6470) + #error "L6470 stepper drivers are no longer supported in Marlin." +#elif HAS_DRIVER(L6474) + #error "L6474 stepper drivers are no longer supported in Marlin." +#elif HAS_DRIVER(L6480) + #error "L6480 stepper drivers are no longer supported in Marlin." +#elif HAS_DRIVER(POWERSTEP01) + #error "POWERSTEP01 stepper drivers are no longer supported in Marlin." +#endif +#undef _L6470 +#undef _L6474 +#undef _L6480 +#undef _POWERSTEP01 + +// Check AXIS_RELATIVE_MODES 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 */ @@ -652,34 +710,46 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L #endif #endif - #ifdef PTC_PROBE_START - constexpr auto _ptc_sample_start = PTC_PROBE_START; - constexpr decltype(_ptc_sample_start) _test_ptc_sample_start = 12.3f; - static_assert(_test_ptc_sample_start != 12.3f, "PTC_PROBE_START must be a whole number."); - #endif - #ifdef PTC_PROBE_RES - constexpr auto _ptc_sample_res = PTC_PROBE_RES; - constexpr decltype(_ptc_sample_res) _test_ptc_sample_res = 12.3f; - static_assert(_test_ptc_sample_res != 12.3f, "PTC_PROBE_RES must be a whole number."); - #endif - #ifdef PTC_BED_START - constexpr auto _btc_sample_start = PTC_BED_START; - constexpr decltype(_btc_sample_start) _test_btc_sample_start = 12.3f; - static_assert(_test_btc_sample_start != 12.3f, "PTC_BED_START must be a whole number."); - #endif - #ifdef PTC_BED_RES - constexpr auto _btc_sample_res = PTC_BED_RES; - constexpr decltype(_btc_sample_res) _test_btc_sample_res = 12.3f; - static_assert(_test_btc_sample_res != 12.3f, "PTC_BED_RES must be a whole number."); + #if ENABLED(PTC_PROBE) + #if !TEMP_SENSOR_PROBE + #error "PTC_PROBE requires a probe with a thermistor." + #endif + #ifdef PTC_PROBE_START + constexpr auto _ptc_sample_start = PTC_PROBE_START; + constexpr decltype(_ptc_sample_start) _test_ptc_sample_start = 12.3f; + static_assert(_test_ptc_sample_start != 12.3f, "PTC_PROBE_START must be a whole number."); + #endif + #ifdef PTC_PROBE_RES + constexpr auto _ptc_sample_res = PTC_PROBE_RES; + constexpr decltype(_ptc_sample_res) _test_ptc_sample_res = 12.3f; + static_assert(_test_ptc_sample_res != 12.3f, "PTC_PROBE_RES must be a whole number."); + #endif + #if ENABLED(PTC_BED) && defined(PTC_PROBE_TEMP) + constexpr auto _btc_probe_temp = PTC_PROBE_TEMP; + constexpr decltype(_btc_probe_temp) _test_btc_probe_temp = 12.3f; + static_assert(_test_btc_probe_temp != 12.3f, "PTC_PROBE_TEMP must be a whole number."); + #endif #endif - #ifdef PTC_PROBE_TEMP - constexpr auto _btc_probe_temp = PTC_PROBE_TEMP; - constexpr decltype(_btc_probe_temp) _test_btc_probe_temp = 12.3f; - static_assert(_test_btc_probe_temp != 12.3f, "PTC_PROBE_TEMP must be a whole number."); + + #if ENABLED(PTC_BED) + #if !TEMP_SENSOR_BED + #error "PTC_BED requires a bed with a thermistor." + #endif + #ifdef PTC_BED_START + constexpr auto _btc_sample_start = PTC_BED_START; + constexpr decltype(_btc_sample_start) _test_btc_sample_start = 12.3f; + static_assert(_test_btc_sample_start != 12.3f, "PTC_BED_START must be a whole number."); + #endif + #ifdef PTC_BED_RES + constexpr auto _btc_sample_res = PTC_BED_RES; + constexpr decltype(_btc_sample_res) _test_btc_sample_res = 12.3f; + static_assert(_test_btc_sample_res != 12.3f, "PTC_BED_RES must be a whole number."); + #endif #endif + #if ENABLED(PTC_HOTEND) #if EXTRUDERS != 1 - #error "PTC_HOTEND only works with a single extruder." + #error "PTC_HOTEND requires a single extruder." #endif #ifdef PTC_HOTEND_START constexpr auto _etc_sample_start = PTC_HOTEND_START; @@ -746,15 +816,13 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L /** * Multiple Stepper Drivers Per Axis */ -#define GOOD_AXIS_PINS(A) (HAS_##A##_ENABLE && HAS_##A##_STEP && HAS_##A##_DIR) -#if HAS_X2_STEPPER && !GOOD_AXIS_PINS(X) +#define GOOD_AXIS_PINS(A) PINS_EXIST(A##_ENABLE, A##_STEP, A##_DIR) +#if HAS_X2_STEPPER && !GOOD_AXIS_PINS(X2) #error "If X2_DRIVER_TYPE is defined, then X2 ENABLE/STEP/DIR pins are also needed." #endif - -#if HAS_DUAL_Y_STEPPERS && !GOOD_AXIS_PINS(Y) +#if HAS_DUAL_Y_STEPPERS && !GOOD_AXIS_PINS(Y2) #error "If Y2_DRIVER_TYPE is defined, then Y2 ENABLE/STEP/DIR pins are also needed." #endif - #if HAS_Z_AXIS #if NUM_Z_STEPPERS >= 2 && !GOOD_AXIS_PINS(Z2) #error "If Z2_DRIVER_TYPE is defined, then Z2 ENABLE/STEP/DIR pins are also needed." @@ -769,12 +837,14 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L * Validate that the bed size fits */ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS) are too narrow to contain X_BED_SIZE."); -static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS) are too narrow to contain Y_BED_SIZE."); +#if HAS_Y_AXIS + static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS) are too narrow to contain Y_BED_SIZE."); +#endif /** * 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) @@ -782,7 +852,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) @@ -847,8 +917,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 @@ -858,18 +928,24 @@ 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) #error "SD_REPRINT_LAST_SELECTED_FILE currently requires a Marlin-native LCD menu." #endif +#if ANY(HAS_MARLINUI_MENU, TOUCH_UI_FTDI_EVE, EXTENSIBLE_UI, DWIN_LCD_PROUI) && !defined(MANUAL_FEEDRATE) + #error "MANUAL_FEEDRATE is required for ProUI, MarlinUI, ExtUI, or FTDI EVE Touch UI." +#endif + /** * Custom Boot and Status screens */ @@ -904,12 +980,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "SDSORT_LIMIT must be 256 or smaller." #elif SDSORT_LIMIT < 10 #error "SDSORT_LIMIT should be greater than 9 to be useful." - #elif DISABLED(SDSORT_USES_RAM) - #if ENABLED(SDSORT_DYNAMIC_RAM) - #error "SDSORT_DYNAMIC_RAM requires SDSORT_USES_RAM (which reads the directory into RAM)." - #elif ENABLED(SDSORT_CACHE_NAMES) - #error "SDSORT_CACHE_NAMES requires SDSORT_USES_RAM (which reads the directory into RAM)." - #endif + #elif ENABLED(SDSORT_DYNAMIC_RAM) && DISABLED(SDSORT_USES_RAM) + #error "SDSORT_DYNAMIC_RAM requires SDSORT_USES_RAM (which reads the directory into RAM)." + #elif ENABLED(SDSORT_CACHE_NAMES) && DISABLED(SDSORT_USES_RAM) + #error "SDSORT_CACHE_NAMES requires SDSORT_USES_RAM (which reads the directory into RAM)." + #elif ENABLED(SDSORT_DYNAMIC_RAM) && DISABLED(SDSORT_CACHE_NAMES) + #error "SDSORT_DYNAMIC_RAM requires SDSORT_CACHE_NAMES." #endif #if ENABLED(SDSORT_CACHE_NAMES) && DISABLED(SDSORT_DYNAMIC_RAM) @@ -1277,10 +1353,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) @@ -1447,6 +1528,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 */ @@ -1466,18 +1552,18 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif /** - * Features that require a min/max/specific NUM_AXES + * Features that require a min/max/specific steppers / axes to be enabled. */ #if HAS_LEVELING && !HAS_Z_AXIS #error "Leveling in Marlin requires three or more axes, with Z as the vertical axis." #elif ENABLED(CNC_WORKSPACE_PLANES) && !HAS_Z_AXIS - #error "CNC_WORKSPACE_PLANES currently requires NUM_AXES >= 3" + #error "CNC_WORKSPACE_PLANES currently requires a Z axis" #elif ENABLED(DIRECT_STEPPING) && NUM_AXES > XYZ - #error "DIRECT_STEPPING currently requires NUM_AXES 3" -#elif ENABLED(FOAMCUTTER_XYUV) && NUM_AXES < 5 - #error "FOAMCUTTER_XYUV requires NUM_AXES >= 5." + #error "DIRECT_STEPPING does not currently support more than 3 axes (i.e., XYZ)." +#elif ENABLED(FOAMCUTTER_XYUV) && !(HAS_I_AXIS && HAS_J_AXIS) + #error "FOAMCUTTER_XYUV requires I and J steppers to be enabled." #elif ENABLED(LINEAR_ADVANCE) && HAS_I_AXIS - #error "LINEAR_ADVANCE currently requires NUM_AXES <= 3." + #error "LINEAR_ADVANCE does not currently support the inclusion of an I axis." #endif /** @@ -1485,11 +1571,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS */ #if HAS_I_AXIS #if !defined(I_MIN_POS) || !defined(I_MAX_POS) - #error "I_MIN_POS and I_MAX_POS are required with NUM_AXES >= 4." + #error "I_MIN_POS and I_MAX_POS are required for the I axis." #elif !defined(I_HOME_DIR) - #error "I_HOME_DIR is required with NUM_AXES >= 4." + #error "I_HOME_DIR is required for the I axis." #elif HAS_I_ENABLE && !defined(I_ENABLE_ON) - #error "I_ENABLE_ON is required for your I driver with NUM_AXES >= 4." + #error "I_ENABLE_ON is required for the I stepper." + #elif !defined(INVERT_I_DIR) + #error "INVERT_I_DIR is required for the I stepper." #endif #endif #if HAS_J_AXIS @@ -1498,11 +1586,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #elif ENABLED(AXIS5_ROTATES) && DISABLED(AXIS4_ROTATES) #error "AXIS5_ROTATES requires AXIS4_ROTATES." #elif !defined(J_MIN_POS) || !defined(J_MAX_POS) - #error "J_MIN_POS and J_MAX_POS are required with NUM_AXES >= 5." + #error "J_MIN_POS and J_MAX_POS are required for the J axis." #elif !defined(J_HOME_DIR) - #error "J_HOME_DIR is required with NUM_AXES >= 5." + #error "J_HOME_DIR is required for the J axis." #elif HAS_J_ENABLE && !defined(J_ENABLE_ON) - #error "J_ENABLE_ON is required for your J driver with NUM_AXES >= 5." + #error "J_ENABLE_ON is required for the J stepper." + #elif !defined(INVERT_J_DIR) + #error "INVERT_J_DIR is required for the J stepper." #endif #endif #if HAS_K_AXIS @@ -1511,11 +1601,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #elif ENABLED(AXIS6_ROTATES) && DISABLED(AXIS5_ROTATES) #error "AXIS6_ROTATES requires AXIS5_ROTATES." #elif !defined(K_MIN_POS) || !defined(K_MAX_POS) - #error "K_MIN_POS and K_MAX_POS are required with NUM_AXES >= 6." + #error "K_MIN_POS and K_MAX_POS are required for the K axis." #elif !defined(K_HOME_DIR) - #error "K_HOME_DIR is required with NUM_AXES >= 6." + #error "K_HOME_DIR is required for the K axis." #elif HAS_K_ENABLE && !defined(K_ENABLE_ON) - #error "K_ENABLE_ON is required for your K driver with NUM_AXES >= 6." + #error "K_ENABLE_ON is required for the K stepper." + #elif !defined(INVERT_K_DIR) + #error "INVERT_K_DIR is required for the K stepper." #endif #endif #if HAS_U_AXIS @@ -1524,11 +1616,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #elif ENABLED(AXIS7_ROTATES) && DISABLED(AXIS6_ROTATES) #error "AXIS7_ROTATES requires AXIS6_ROTATES." #elif !defined(U_MIN_POS) || !defined(U_MAX_POS) - #error "U_MIN_POS and U_MAX_POS are required with NUM_AXES >= 7." + #error "U_MIN_POS and U_MAX_POS are required for the U axis." #elif !defined(U_HOME_DIR) - #error "U_HOME_DIR is required with NUM_AXES >= 7." + #error "U_HOME_DIR is required for the U axis." #elif HAS_U_ENABLE && !defined(U_ENABLE_ON) - #error "U_ENABLE_ON is required for your U driver with NUM_AXES >= 7." + #error "U_ENABLE_ON is required for the U stepper." + #elif !defined(INVERT_U_DIR) + #error "INVERT_U_DIR is required for the U stepper." #endif #endif #if HAS_V_AXIS @@ -1537,11 +1631,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #elif ENABLED(AXIS8_ROTATES) && DISABLED(AXIS7_ROTATES) #error "AXIS8_ROTATES requires AXIS7_ROTATES." #elif !defined(V_MIN_POS) || !defined(V_MAX_POS) - #error "V_MIN_POS and V_MAX_POS are required with NUM_AXES >= 8." + #error "V_MIN_POS and V_MAX_POS are required for the V axis." #elif !defined(V_HOME_DIR) - #error "V_HOME_DIR is required with NUM_AXES >= 8." + #error "V_HOME_DIR is required for the V axis." #elif HAS_V_ENABLE && !defined(V_ENABLE_ON) - #error "V_ENABLE_ON is required for your V driver with NUM_AXES >= 8." + #error "V_ENABLE_ON is required for the V stepper." + #elif !defined(INVERT_V_DIR) + #error "INVERT_V_DIR is required for the V stepper." #endif #endif #if HAS_W_AXIS @@ -1550,11 +1646,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #elif ENABLED(AXIS9_ROTATES) && DISABLED(AXIS8_ROTATES) #error "AXIS9_ROTATES requires AXIS8_ROTATES." #elif !defined(W_MIN_POS) || !defined(W_MAX_POS) - #error "W_MIN_POS and W_MAX_POS are required with NUM_AXES >= 9." + #error "W_MIN_POS and W_MAX_POS are required for the W axis." #elif !defined(W_HOME_DIR) - #error "W_HOME_DIR is required with NUM_AXES >= 9." + #error "W_HOME_DIR is required for the W axis." #elif HAS_W_ENABLE && !defined(W_ENABLE_ON) - #error "W_ENABLE_ON is required for your W driver with NUM_AXES >= 9." + #error "W_ENABLE_ON is required for the W stepper." + #elif !defined(INVERT_W_DIR) + #error "INVERT_W_DIR is required for the W stepper." #endif #endif @@ -1565,16 +1663,16 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Allow only one kinematic type to be defined */ -#if MANY(DELTA, MORGAN_SCARA, MP_SCARA, AXEL_TPARA, COREXY, COREXZ, COREYZ, COREYX, COREZX, COREZY, MARKFORGED_XY, MARKFORGED_YX, FOAMCUTTER_XYUV) - #error "Please enable only one of DELTA, MORGAN_SCARA, MP_SCARA, AXEL_TPARA, COREXY, COREXZ, COREYZ, COREYX, COREZX, COREZY, MARKFORGED_XY, MARKFORGED_YX, or FOAMCUTTER_XYUV." +#if MANY(DELTA, MORGAN_SCARA, MP_SCARA, AXEL_TPARA, COREXY, COREXZ, COREYZ, COREYX, COREZX, COREZY, MARKFORGED_XY, MARKFORGED_YX, ARTICULATED_ROBOT_ARM, FOAMCUTTER_XYUV) + #error "Please enable only one of DELTA, MORGAN_SCARA, MP_SCARA, AXEL_TPARA, COREXY, COREXZ, COREYZ, COREYX, COREZX, COREZY, MARKFORGED_XY, MARKFORGED_YX, ARTICULATED_ROBOT_ARM, or FOAMCUTTER_XYUV." #endif /** * 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) @@ -1613,8 +1711,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS */ #if 1 < 0 \ + (DISABLED(BLTOUCH) && HAS_Z_SERVO_PROBE) \ - + COUNT_ENABLED(PROBE_MANUALLY, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING, MAGLEV4) - #error "Please enable only one probe option: PROBE_MANUALLY, SENSORLESS_PROBING, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, MAGLEV4, or Z Servo." + + COUNT_ENABLED(PROBE_MANUALLY, BLTOUCH, BD_SENSOR, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING, MAGLEV4, MAG_MOUNTED_PROBE) + #error "Please enable only one probe option: PROBE_MANUALLY, SENSORLESS_PROBING, BLTOUCH, BD_SENSOR, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, MAGLEV4, MAG_MOUNTED_PROBE or Z Servo." #endif #if HAS_BED_PROBE @@ -1693,7 +1791,29 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if BLTOUCH_DELAY < 200 #error "BLTOUCH_DELAY less than 200 is unsafe and is not supported." #endif - #endif + + #ifdef DEACTIVATE_SERVOS_AFTER_MOVE + #error "BLTOUCH requires DEACTIVATE_SERVOS_AFTER_MOVE to be to disabled. Please update your Configuration.h file." + #endif + + #if ENABLED(INVERTED_PROBE_STATE) + #if !Z_MIN_PROBE_ENDSTOP_INVERTING + #error "BLTOUCH requires Z_MIN_PROBE_ENDSTOP_INVERTING set to true." + #endif + #elif Z_MIN_PROBE_ENDSTOP_INVERTING + #error "BLTOUCH requires Z_MIN_PROBE_ENDSTOP_INVERTING set to false." + #endif + #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) + #if ENABLED(INVERTED_PROBE_STATE) + #if !Z_MIN_ENDSTOP_INVERTING + #error "BLTOUCH requires Z_MIN_ENDSTOP_INVERTING set to true." + #endif + #elif Z_MIN_ENDSTOP_INVERTING + #error "BLTOUCH requires Z_MIN_ENDSTOP_INVERTING set to false." + #endif + #endif + + #endif // BLTOUCH #if ENABLED(RACK_AND_PINION_PROBE) && !(defined(Z_PROBE_DEPLOY_X) && defined(Z_PROBE_RETRACT_X)) #error "RACK_AND_PINION_PROBE requires Z_PROBE_DEPLOY_X and Z_PROBE_RETRACT_X." @@ -1711,13 +1831,34 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TOUCH_MI_PROBE requires Z_AFTER_PROBING to be disabled." #elif Z_HOMING_HEIGHT < 10 #error "TOUCH_MI_PROBE requires Z_HOMING_HEIGHT >= 10." - #elif Z_MIN_PROBE_ENDSTOP_INVERTING - #error "TOUCH_MI_PROBE requires Z_MIN_PROBE_ENDSTOP_INVERTING to be set to false." #elif DISABLED(BABYSTEP_ZPROBE_OFFSET) #error "TOUCH_MI_PROBE requires BABYSTEPPING with BABYSTEP_ZPROBE_OFFSET." #elif !HAS_RESUME_CONTINUE #error "TOUCH_MI_PROBE currently requires an LCD controller or EMERGENCY_PARSER." #endif + #if ENABLED(INVERTED_PROBE_STATE) + #if !Z_MIN_PROBE_ENDSTOP_INVERTING + #error "TOUCH_MI_PROBE requires Z_MIN_PROBE_ENDSTOP_INVERTING set to true." + #endif + #elif Z_MIN_PROBE_ENDSTOP_INVERTING + #error "TOUCH_MI_PROBE requires Z_MIN_PROBE_ENDSTOP_INVERTING set to false." + #endif + #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) + #if ENABLED(INVERTED_PROBE_STATE) + #if !Z_MIN_ENDSTOP_INVERTING + #error "TOUCH_MI_PROBE requires Z_MIN_ENDSTOP_INVERTING set to true." + #endif + #elif Z_MIN_ENDSTOP_INVERTING + #error "TOUCH_MI_PROBE requires Z_MIN_ENDSTOP_INVERTING set to false." + #endif + #endif + #endif // TOUCH_MI_PROBE + + /** + * Mag mounted probe requirements + */ + #if BOTH(MAG_MOUNTED_PROBE, USE_PROBE_FOR_Z_HOMING) && DISABLED(Z_SAFE_HOMING) + #error "MAG_MOUNTED_PROBE requires Z_SAFE_HOMING if it's being used to home Z." #endif /** @@ -1726,7 +1867,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if ENABLED(MAGLEV4) #if !PIN_EXISTS(MAGLEV_TRIGGER) #error "MAGLEV4 requires MAGLEV_TRIGGER_PIN to be defined." - #elif DISABLED(Z_SAFE_HOMING) + #elif ENABLED(HOMING_Z_WITH_PROBE) && DISABLED(Z_SAFE_HOMING) #error "MAGLEV4 requires Z_SAFE_HOMING." #elif MAGLEV_TRIGGER_DELAY != 15 #error "MAGLEV_TRIGGER_DELAY should not be changed. Comment out this line to continue." @@ -1738,9 +1879,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS */ #if ENABLED(SENSORLESS_PROBING) #if ENABLED(DELTA) && !(X_SENSORLESS && Y_SENSORLESS && Z_SENSORLESS) - #error "SENSORLESS_PROBING requires TMC2130/2160/2209/5130/5160 drivers on X, Y, and Z." + #error "SENSORLESS_PROBING requires TMC2130/2160/2209/5130/5160 drivers on X, Y, and Z and {X|Y|Z}_STALL_SENSITIVITY." #elif !Z_SENSORLESS - #error "SENSORLESS_PROBING requires a TMC2130/2160/2209/5130/5160 driver on Z." + #error "SENSORLESS_PROBING requires a TMC2130/2160/2209/5130/5160 driver on Z and Z_STALL_SENSITIVITY." #endif #elif ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) #if DISABLED(USE_ZMIN_PLUG) @@ -1781,15 +1922,17 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Make sure Z raise values are set */ #ifndef Z_CLEARANCE_DEPLOY_PROBE - #error "You must define Z_CLEARANCE_DEPLOY_PROBE in your configuration." - #elif !defined(Z_CLEARANCE_BETWEEN_PROBES) - #error "You must define Z_CLEARANCE_BETWEEN_PROBES in your configuration." - #elif Z_CLEARANCE_DEPLOY_PROBE < 0 - #error "Probes need Z_CLEARANCE_DEPLOY_PROBE >= 0." - #elif Z_CLEARANCE_BETWEEN_PROBES < 0 - #error "Probes need Z_CLEARANCE_BETWEEN_PROBES >= 0." - #elif Z_AFTER_PROBING < 0 - #error "Probes need Z_AFTER_PROBING >= 0." + #error "Z_CLEARANCE_DEPLOY_PROBE is required for bed probes." + #else + static_assert(Z_CLEARANCE_DEPLOY_PROBE >= 0, "Probes require Z_CLEARANCE_DEPLOY_PROBE >= 0."); + #endif + #ifndef Z_CLEARANCE_BETWEEN_PROBES + #error "Z_CLEARANCE_BETWEEN_PROBES is required for bed probes." + #else + static_assert(Z_CLEARANCE_BETWEEN_PROBES >= 0, "Probes require Z_CLEARANCE_BETWEEN_PROBES >= 0."); + #endif + #ifdef Z_AFTER_PROBING + static_assert(Z_AFTER_PROBING >= 0, "Probes require Z_AFTER_PROBING >= 0."); #endif #if MULTIPLE_PROBING > 0 || EXTRA_PROBING > 0 @@ -1986,6 +2129,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)."); @@ -2018,6 +2167,27 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS static_assert(WITHIN(Z_SAFE_HOMING_Y_POINT, Y_MIN_POS, Y_MAX_POS), "Z_SAFE_HOMING_Y_POINT can't be reached by the nozzle."); #endif +// Check Safe Bed Leveling settings +#if HAS_SAFE_BED_LEVELING + #if defined(SAFE_BED_LEVELING_START_Y) && !defined(SAFE_BED_LEVELING_START_X) + #error "If SAFE_BED_LEVELING_START_Y is defined, SAFE_BED_LEVELING_START_X must also be defined." + #elif defined(SAFE_BED_LEVELING_START_Z) && !defined(SAFE_BED_LEVELING_START_Y) + #error "If SAFE_BED_LEVELING_START_Z is defined, SAFE_BED_LEVELING_START_Y must also be defined." + #elif defined(SAFE_BED_LEVELING_START_I) && !defined(SAFE_BED_LEVELING_START_Z) + #error "If SAFE_BED_LEVELING_START_I is defined, SAFE_BED_LEVELING_START_Z must also be defined." + #elif defined(SAFE_BED_LEVELING_START_J) && !defined(SAFE_BED_LEVELING_START_I) + #error "If SAFE_BED_LEVELING_START_J is defined, SAFE_BED_LEVELING_START_I must also be defined." + #elif defined(SAFE_BED_LEVELING_START_K) && !defined(SAFE_BED_LEVELING_START_J) + #error "If SAFE_BED_LEVELING_START_K is defined, SAFE_BED_LEVELING_START_J must also be defined." + #elif defined(SAFE_BED_LEVELING_START_U) && !defined(SAFE_BED_LEVELING_START_K) + #error "If SAFE_BED_LEVELING_START_U is defined, SAFE_BED_LEVELING_START_K must also be defined." + #elif defined(SAFE_BED_LEVELING_START_V) && !defined(SAFE_BED_LEVELING_START_U) + #error "If SAFE_BED_LEVELING_START_V is defined, SAFE_BED_LEVELING_START_U must also be defined." + #elif defined(SAFE_BED_LEVELING_START_W) && !defined(SAFE_BED_LEVELING_START_V) + #error "If SAFE_BED_LEVELING_START_W is defined, SAFE_BED_LEVELING_START_V must also be defined." + #endif +#endif + /** * Make sure DISABLE_[XYZ] compatible with selected homing options */ @@ -2116,13 +2286,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS */ #if HAS_AUTO_FAN #if HAS_FAN0 - #if E0_AUTO_FAN_PIN == FAN_PIN + #if PIN_EXISTS(E0_AUTO_FAN) && E0_AUTO_FAN_PIN == FAN_PIN #error "You cannot set E0_AUTO_FAN_PIN equal to FAN_PIN." - #elif E1_AUTO_FAN_PIN == FAN_PIN + #elif PIN_EXISTS(E1_AUTO_FAN) && E1_AUTO_FAN_PIN == FAN_PIN #error "You cannot set E1_AUTO_FAN_PIN equal to FAN_PIN." - #elif E2_AUTO_FAN_PIN == FAN_PIN + #elif PIN_EXISTS(E2_AUTO_FAN) && E2_AUTO_FAN_PIN == FAN_PIN #error "You cannot set E2_AUTO_FAN_PIN equal to FAN_PIN." - #elif E3_AUTO_FAN_PIN == FAN_PIN + #elif PIN_EXISTS(E3_AUTO_FAN) && E3_AUTO_FAN_PIN == FAN_PIN #error "You cannot set E3_AUTO_FAN_PIN equal to FAN_PIN." #endif #endif @@ -2139,14 +2309,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 @@ -2200,6 +2378,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 < 15000 + #error "Thermistor 66 requires MILLISECONDS_PREHEAT_TIME ≥ 15000, but 30000 or higher is recommended." + #endif + #undef _BAD_MINTEMP +#endif + /** * Required MAX31865 settings */ @@ -2217,12 +2426,19 @@ 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 */ #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." @@ -2274,9 +2490,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TEMP_SENSOR_REDUNDANT_TARGET can't be COOLER without TEMP_COOLER_PIN defined." #endif - #if TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0) && !PIN_EXISTS(TEMP_0_CS) + #if TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E0) && !PIN_EXISTS(TEMP_0_CS) #error "TEMP_SENSOR_REDUNDANT MAX Thermocouple with TEMP_SENSOR_REDUNDANT_SOURCE E0 requires TEMP_0_CS_PIN." - #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1) && !PIN_EXISTS(TEMP_1_CS) + #elif TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1) && !PIN_EXISTS(TEMP_1_CS) #error "TEMP_SENSOR_REDUNDANT MAX Thermocouple with TEMP_SENSOR_REDUNDANT_SOURCE E1 requires TEMP_1_CS_PIN." #endif #endif @@ -2289,7 +2505,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TEMP_0_PIN or TEMP_0_CS_PIN not defined for this board." #elif HAS_EXTRUDERS && !HAS_HEATER_0 #error "HEATER_0_PIN not defined for this board." -#elif TEMP_SENSOR_0_IS_MAX_TC && !PIN_EXISTS(TEMP_0_CS) +#elif TEMP_SENSOR_IS_MAX_TC(0) && !PIN_EXISTS(TEMP_0_CS) #error "TEMP_SENSOR_0 MAX thermocouple requires TEMP_0_CS_PIN." #elif HAS_HOTEND && !HAS_TEMP_HOTEND && !TEMP_SENSOR_0_IS_DUMMY #error "TEMP_0_PIN (required for TEMP_SENSOR_0) not defined for this board." @@ -2298,7 +2514,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #if HAS_MULTI_HOTEND - #if TEMP_SENSOR_1_IS_MAX_TC && !PIN_EXISTS(TEMP_1_CS) + #if TEMP_SENSOR_IS_MAX_TC(1) && !PIN_EXISTS(TEMP_1_CS) #error "TEMP_SENSOR_1 MAX thermocouple requires TEMP_1_CS_PIN." #elif TEMP_SENSOR_1 == 0 #error "TEMP_SENSOR_1 is required with 2 or more HOTENDS." @@ -2310,8 +2526,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TEMP_SENSOR_2 is required with 3 or more HOTENDS." #elif !HAS_HEATER_2 #error "HEATER_2_PIN not defined for this board." - #elif !PIN_EXISTS(TEMP_2) && !TEMP_SENSOR_2_IS_DUMMY - #error "TEMP_2_PIN not defined for this board." + #elif !ANY_PIN(TEMP_2, TEMP_2_CS) && !TEMP_SENSOR_2_IS_DUMMY + #error "TEMP_2_PIN or TEMP_2_CS_PIN not defined for this board." #endif #if HOTENDS > 3 #if TEMP_SENSOR_3 == 0 @@ -2523,7 +2739,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) ) ) @@ -2538,22 +2754,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 @@ -2567,29 +2783,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 @@ -2732,24 +2948,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Auto Fan check for PWM pins */ #if HAS_AUTO_FAN && EXTRUDER_AUTO_FAN_SPEED != 255 - #define AF_ERR_SUFF "_AUTO_FAN_PIN is not a PWM pin. Set EXTRUDER_AUTO_FAN_SPEED to 255." - #if HAS_AUTO_FAN_0 - static_assert(_TEST_PWM(E0_AUTO_FAN_PIN), "E0" AF_ERR_SUFF); - #elif HAS_AUTO_FAN_1 - static_assert(_TEST_PWM(E1_AUTO_FAN_PIN), "E1" AF_ERR_SUFF); - #elif HAS_AUTO_FAN_2 - static_assert(_TEST_PWM(E2_AUTO_FAN_PIN), "E2" AF_ERR_SUFF); - #elif HAS_AUTO_FAN_3 - static_assert(_TEST_PWM(E3_AUTO_FAN_PIN), "E3" AF_ERR_SUFF); - #elif HAS_AUTO_FAN_4 - static_assert(_TEST_PWM(E4_AUTO_FAN_PIN), "E4" AF_ERR_SUFF); - #elif HAS_AUTO_FAN_5 - static_assert(_TEST_PWM(E5_AUTO_FAN_PIN), "E5" AF_ERR_SUFF); - #elif HAS_AUTO_FAN_6 - static_assert(_TEST_PWM(E6_AUTO_FAN_PIN), "E6" AF_ERR_SUFF); - #elif HAS_AUTO_FAN_7 - static_assert(_TEST_PWM(E7_AUTO_FAN_PIN), "E7" AF_ERR_SUFF); - #endif + #define AF_ASSERT(N) OPTCODE(HAS_AUTO_FAN_##N, static_assert(_TEST_PWM(E##N##_AUTO_FAN_PIN), "E" STRINGIFY(N) "_AUTO_FAN_PIN is not a PWM pin. Set EXTRUDER_AUTO_FAN_SPEED to 255.")) + REPEAT(8, AF_ASSERT) + #undef AF_ASSERT #endif /** @@ -2921,8 +3122,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif -#if defined(GRAPHICAL_TFT_UPSCALE) && !WITHIN(GRAPHICAL_TFT_UPSCALE, 2, 4) - #error "GRAPHICAL_TFT_UPSCALE must be 2, 3, or 4." +#if defined(GRAPHICAL_TFT_UPSCALE) && !WITHIN(GRAPHICAL_TFT_UPSCALE, 2, 8) + #error "GRAPHICAL_TFT_UPSCALE must be between 2 and 8." #endif #if BOTH(CHIRON_TFT_STANDARD, CHIRON_TFT_NEW) @@ -2930,7 +3131,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" @@ -2948,7 +3149,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif /** - * Ender 3 V2 controller has some limitations + * Ender-3 V2 controller has some limitations */ #if ENABLED(DWIN_CREALITY_LCD) #if DISABLED(SDSUPPORT) @@ -2976,11 +3177,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 @@ -2988,7 +3189,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_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." @@ -3447,8 +3648,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 @@ -3500,7 +3701,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * TMC SPI Chaining */ -#define IN_CHAIN(A) ((A##_CHAIN_POS > 0) && !HAS_L64XX) +#define IN_CHAIN(A) A##_CHAIN_POS > 0 #if IN_CHAIN(X ) || IN_CHAIN(Y ) || IN_CHAIN(Z ) || IN_CHAIN(X2) || IN_CHAIN(Y2) || IN_CHAIN(Z2) || IN_CHAIN(Z3) || IN_CHAIN(Z4) \ || IN_CHAIN(E0) || IN_CHAIN(E1) || IN_CHAIN(E2) || IN_CHAIN(E3) || IN_CHAIN(E4) || IN_CHAIN(E5) || IN_CHAIN(E6) || IN_CHAIN(E7) #define BAD_CHAIN(A) (IN_CHAIN(A) && !PIN_EXISTS(A##_CS)) @@ -3565,13 +3766,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #undef IN_CHAIN -/** - * L64XX requirement - */ -#if HAS_L64XX && NUM_AXES > 3 - #error "L64XX requires NUM_AXES <= 3. Homing with L64XX is not yet implemented for NUM_AXES > 3." -#endif - /** * Digipot requirement */ @@ -3661,6 +3855,10 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "LED_CONTROL_MENU requires an LCD controller that implements the menu." #endif +#if ENABLED(CUSTOM_MENU_MAIN) && NONE(HAS_MARLINUI_MENU, TOUCH_UI_FTDI_EVE, TFT_LVGL_UI) + #error "CUSTOM_MENU_MAIN requires an LCD controller that implements the menu." +#endif + #if ENABLED(CASE_LIGHT_USE_NEOPIXEL) && DISABLED(NEOPIXEL_LED) #error "CASE_LIGHT_USE_NEOPIXEL requires NEOPIXEL_LED." #endif @@ -3839,45 +4037,34 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "CUTTER_POWER_UNIT must be PWM255, PERCENT, RPM, or SERVO." #endif - #if ENABLED(LASER_POWER_INLINE) + #if ENABLED(LASER_FEATURE) #if ENABLED(SPINDLE_CHANGE_DIR) - #error "SPINDLE_CHANGE_DIR and LASER_POWER_INLINE are incompatible." - #elif ENABLED(LASER_MOVE_G0_OFF) && DISABLED(LASER_MOVE_POWER) - #error "LASER_MOVE_G0_OFF requires LASER_MOVE_POWER." + #error "SPINDLE_CHANGE_DIR and LASER_FEATURE are incompatible." + #elif ENABLED(LASER_MOVE_G0_OFF) + #error "LASER_MOVE_G0_OFF is no longer required, G0 and G28 cannot apply power." + #elif ENABLED(LASER_MOVE_G28_OFF) + #error "LASER_MOVE_G0_OFF is no longer required, G0 and G28 cannot apply power." + #elif ENABLED(LASER_MOVE_POWER) + #error "LASER_MOVE_POWER is no longer applicable." #endif - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) + #if ENABLED(LASER_POWER_TRAP) #if DISABLED(SPINDLE_LASER_USE_PWM) - #error "LASER_POWER_INLINE_TRAPEZOID requires SPINDLE_LASER_USE_PWM to function." - #elif ENABLED(S_CURVE_ACCELERATION) - //#ifndef LASER_POWER_INLINE_S_CURVE_ACCELERATION_WARN - // #define LASER_POWER_INLINE_S_CURVE_ACCELERATION_WARN - // #warning "Combining LASER_POWER_INLINE_TRAPEZOID with S_CURVE_ACCELERATION may result in unintended behavior." - //#endif + #error "LASER_POWER_TRAP requires SPINDLE_LASER_USE_PWM to function." #endif #endif - #if ENABLED(LASER_POWER_INLINE_INVERT) - //#ifndef LASER_POWER_INLINE_INVERT_WARN - // #define LASER_POWER_INLINE_INVERT_WARN - // #warning "Enabling LASER_POWER_INLINE_INVERT means that `M5` won't kill the laser immediately; use `M5 I` instead." - //#endif - #endif #else #if SPINDLE_LASER_POWERUP_DELAY < 1 #error "SPINDLE_LASER_POWERUP_DELAY must be greater than 0." #elif SPINDLE_LASER_POWERDOWN_DELAY < 1 #error "SPINDLE_LASER_POWERDOWN_DELAY must be greater than 0." - #elif ENABLED(LASER_MOVE_POWER) - #error "LASER_MOVE_POWER requires LASER_POWER_INLINE." - #elif ANY(LASER_POWER_INLINE_TRAPEZOID, LASER_POWER_INLINE_INVERT, LASER_MOVE_G0_OFF, LASER_MOVE_POWER) - #error "Enabled an inline laser feature without inline laser power being enabled." #endif #endif #define _PIN_CONFLICT(P) (PIN_EXISTS(P) && P##_PIN == SPINDLE_LASER_PWM_PIN) #if BOTH(SPINDLE_FEATURE, LASER_FEATURE) #error "Enable only one of SPINDLE_FEATURE or LASER_FEATURE." - #elif !PIN_EXISTS(SPINDLE_LASER_ENA) && DISABLED(SPINDLE_SERVO) - #error "(SPINDLE|LASER)_FEATURE requires SPINDLE_LASER_ENA_PIN or SPINDLE_SERVO to control the power." + #elif NONE(SPINDLE_SERVO, SPINDLE_LASER_USE_PWM) && !PIN_EXISTS(SPINDLE_LASER_ENA) + #error "(SPINDLE|LASER)_FEATURE requires SPINDLE_LASER_ENA_PIN, SPINDLE_LASER_USE_PWM, or SPINDLE_SERVO to control the power." #elif ENABLED(SPINDLE_CHANGE_DIR) && !PIN_EXISTS(SPINDLE_DIR) #error "SPINDLE_DIR_PIN is required for SPINDLE_CHANGE_DIR." #elif ENABLED(SPINDLE_LASER_USE_PWM) @@ -3887,7 +4074,7 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "SPINDLE_LASER_PWM_PIN not assigned to a PWM pin." #elif !defined(SPINDLE_LASER_PWM_INVERT) #error "SPINDLE_LASER_PWM_INVERT is required for (SPINDLE|LASER)_FEATURE." - #elif !(defined(SPEED_POWER_INTERCEPT) && defined(SPEED_POWER_MIN) && defined(SPEED_POWER_MAX) && defined(SPEED_POWER_STARTUP)) + #elif !(defined(SPEED_POWER_MIN) && defined(SPEED_POWER_MAX) && defined(SPEED_POWER_STARTUP)) #error "SPINDLE_LASER_USE_PWM equation constant(s) missing." #elif _PIN_CONFLICT(X_MIN) #error "SPINDLE_LASER_USE_PWM pin conflicts with X_MIN_PIN." @@ -3953,10 +4140,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 @@ -3977,16 +4160,20 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); /** * Touch Screen Calibration */ -#if !MB(LINUX_RAMPS) && ENABLED(TFT_TOUCH_DEVICE_XPT2046) && DISABLED(TOUCH_SCREEN_CALIBRATION) \ +#if !MB(SIMULATED) && ENABLED(TFT_TOUCH_DEVICE_XPT2046) && DISABLED(TOUCH_SCREEN_CALIBRATION) \ && !(defined(TOUCH_CALIBRATION_X) && defined(TOUCH_CALIBRATION_Y) && defined(TOUCH_OFFSET_X) && defined(TOUCH_OFFSET_Y)) #error "TOUCH_CALIBRATION_[XY] and TOUCH_OFFSET_[XY] are required for resistive touch screens with TOUCH_SCREEN_CALIBRATION disabled." #endif /** - * Sanity check for WIFI + * Sanity check WiFi options */ -#if EITHER(ESP3D_WIFISUPPORT, WIFISUPPORT) && DISABLED(ARDUINO_ARCH_ESP32) - #error "ESP3D_WIFISUPPORT or WIFISUPPORT requires an ESP32 MOTHERBOARD." +#if ENABLED(ESP3D_WIFISUPPORT) && DISABLED(ARDUINO_ARCH_ESP32) + #error "ESP3D_WIFISUPPORT requires an ESP32 MOTHERBOARD." +#elif ENABLED(WEBSUPPORT) && NONE(ARDUINO_ARCH_ESP32, WIFISUPPORT) + #error "WEBSUPPORT requires WIFISUPPORT and an ESP32 MOTHERBOARD." +#elif BOTH(ESP3D_WIFISUPPORT, WIFISUPPORT) + #error "Enable only one of ESP3D_WIFISUPPORT or WIFISUPPORT." #endif /** @@ -4137,11 +4324,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." @@ -4153,3 +4335,61 @@ 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 + +/** + * Input Shaping requirements + */ +#if HAS_SHAPING + #if ENABLED(DELTA) + #error "Input Shaping is not compatible with DELTA kinematics." + #elif ENABLED(SCARA) + #error "Input Shaping is not compatible with SCARA kinematics." + #elif ENABLED(TPARA) + #error "Input Shaping is not compatible with TPARA kinematics." + #elif ENABLED(POLAR) + #error "Input Shaping is not compatible with POLAR kinematics." + #elif ENABLED(POLARGRAPH) + #error "Input Shaping is not compatible with POLARGRAPH kinematics." + #elif ENABLED(DIRECT_STEPPING) + #error "Input Shaping is not compatible with DIRECT_STEPPING." + #elif BOTH(INPUT_SHAPING_X, CORE_IS_XZ) + #error "INPUT_SHAPING_X is not supported with COREXZ." + #elif BOTH(INPUT_SHAPING_Y, CORE_IS_YZ) + #error "INPUT_SHAPING_Y is not supported with COREYZ." + #elif ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) + #if !BOTH(INPUT_SHAPING_X, INPUT_SHAPING_Y) + #error "INPUT_SHAPING_X and INPUT_SHAPING_Y must both be enabled for COREXY, COREYX, or MARKFORGED_*." + #else + static_assert(SHAPING_FREQ_X == SHAPING_FREQ_Y, "SHAPING_FREQ_X and SHAPING_FREQ_Y must be the same for COREXY / COREYX / MARKFORGED_*."); + static_assert(SHAPING_ZETA_X == SHAPING_ZETA_Y, "SHAPING_ZETA_X and SHAPING_ZETA_Y must be the same for COREXY / COREYX / MARKFORGED_*."); + #endif + #endif + + #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 + #ifdef __AVR__ + #if ENABLED(INPUT_SHAPING_X) + #if F_CPU > 16000000 + 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) == 0 || (SHAPING_FREQ_X) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_X is below the minimum (16) for AVR 16MHz."); + #endif + #endif + #if ENABLED(INPUT_SHAPING_Y) + #if F_CPU > 16000000 + 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) == 0 || (SHAPING_FREQ_Y) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_Y is below the minimum (16) for AVR 16MHz."); + #endif + #endif + #endif +#endif + +// Misc. Cleanup +#undef _TEST_PWM +#undef _NUM_AXES_STR +#undef _LOGICAL_AXES_STR diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 4070a801a5d4..f2aa547135d8 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -25,7 +25,7 @@ * Release version. Leave the Marlin version or apply a custom scheme. */ #ifndef SHORT_BUILD_VERSION - #define SHORT_BUILD_VERSION "2.1" + #define SHORT_BUILD_VERSION "2.1.2.1" #endif /** @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2022-06-04" + #define STRING_DISTRIBUTION_DATE "2023-05-16" #endif /** @@ -52,7 +52,7 @@ * to alert users to major changes. */ -#define MARLIN_HEX_VERSION 02010000 +#define MARLIN_HEX_VERSION 02010201 #ifndef REQUIRED_CONFIGURATION_H_VERSION #define REQUIRED_CONFIGURATION_H_VERSION MARLIN_HEX_VERSION #endif diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index e48788b7b4e2..9b3d69860736 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -35,8 +35,12 @@ #warning "WARNING! Disable MARLIN_DEV_MODE for the final build!" #endif -#if LINEAR_AXES_WARNING - #warning "Note: LINEAR_AXES is now based on the *_DRIVER_TYPE settings so you can remove LINEAR_AXES from Configuration.h." +#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 // Safety Features @@ -707,12 +711,11 @@ #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) && DISABLED(NO_CREALITY_422_DRIVER_WARNING) + #warning "Creality 4.2.2 boards come with a variety of stepper drivers. Check the board label (typically on SD Card module) and set the correct *_DRIVER_TYPE! (C=HR4988, E=A4988, A=TMC2208, B=TMC2209, H=TMC2225, H8=HR4988). (Define NO_CREALITY_422_DRIVER_WARNING to suppress this warning.)" #endif -#if PRINTCOUNTER_SYNC +#if ENABLED(PRINTCOUNTER_SYNC) #warning "To prevent step loss, motion will pause for PRINTCOUNTER auto-save." #endif @@ -773,3 +776,24 @@ #if MB(BTT_BTT002_V1_0, EINSY_RAMBO) && DISABLED(NO_MK3_FAN_PINS_WARNING) #warning "Define MK3_FAN_PINS to swap hotend and part cooling fan pins. (Define NO_MK3_FAN_PINS_WARNING to suppress this warning.)" #endif + +/** + * GD32 is not exactly like STM32 + */ +#if MB(SOVOL_V131) + #warning "GD32 based controllers may not be fully compatible with Maple Generic STM32F103RE. Please report any issues." +#endif + +/** + * BD Sensor should always include BABYSTEPPING + */ +#if ENABLED(BD_SENSOR) && DISABLED(BABYSTEPPING) + #warning "BABYSTEPPING is recommended with BD_SENSOR." +#endif + +/** + * Input Shaping + */ +#if HAS_SHAPING && ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) + #warning "Input Shaping for CORE / MARKFORGED kinematic axes is still experimental." +#endif diff --git a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp index 1e82fe403d9f..48f5f97133db 100644 --- a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp +++ b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp @@ -50,15 +50,15 @@ extern LCD_CLASS lcd; int lcd_glyph_height() { return 1; } typedef struct _hd44780_charmap_t { - wchar_t uchar; // the unicode char + lchar_t uchar; // the unicode char uint8_t idx; // the glyph of the char in the ROM uint8_t idx2; // the char used to be combined with the idx to simulate a single char } 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 = { @@ -992,7 +992,7 @@ void lcd_put_int(const int i) { lcd.print(i); } // return < 0 on error // return the advanced cols -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length) { // find the HD44780 internal ROM first int ret; @@ -1051,10 +1051,10 @@ static int lcd_put_u8str_max_cb(const char * utf8_str, read_byte_cb_t cb_read_by pixel_len_t ret = 0; const uint8_t *p = (uint8_t *)utf8_str; while (ret < max_length) { - wchar_t ch = 0; - p = get_utf8_value_cb(p, cb_read_byte, &ch); - if (!ch) break; - ret += lcd_put_wchar_max(ch, max_length - ret); + lchar_t wc; + p = get_utf8_value_cb(p, cb_read_byte, wc); + if (!wc) break; + ret += lcd_put_lchar_max(wc, max_length - ret); } return (int)ret; } diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index da4db8b2d419..8817ad74ad50 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 // @@ -120,10 +124,11 @@ static void createChar_P(const char c, const byte * const ptr) { #endif #if ENABLED(LCD_USE_I2C_BUZZER) - void MarlinUI::buzz(const long duration, const uint16_t freq) { - if (!sound_on) return; - lcd.buzz(duration, freq); + + void MarlinUI::buzz(const long duration, const uint16_t freq/*=0*/) { + if (sound_on) lcd.buzz(duration, freq); } + #endif void MarlinUI::set_custom_characters(const HD44780CharSet screen_charset/*=CHARSET_INFO*/) { @@ -405,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_wchar(' '); + lcd_put_u8str(F(" ")); } // Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line @@ -413,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_wchar(' '); + for (; slen < len; ++slen) lcd_put_u8str(F(" ")); safe_delay(time); } else { @@ -425,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_wchar(' '); + for (uint8_t ix = slen - i; ix < len; ++ix) lcd_put_u8str(F(" ")); // Delay safe_delay(dly); @@ -439,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_wchar(indent, 0, '\x00'); lcd_put_u8str(F( "------" )); lcd_put_wchar('\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_wchar(indent, 2, '\x02'); lcd_put_u8str(F( "------" )); lcd_put_wchar('\x03'); + lcd_put_lchar(indent, 2, '\x02'); lcd_put_u8str(F( "------" )); lcd_put_u8str(F("\x03")); } void MarlinUI::show_bootscreen() { @@ -510,18 +515,26 @@ void MarlinUI::draw_kill_screen() { // Homed and known, display constantly. // FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) { - lcd_put_wchar('X' + uint8_t(axis)); + lcd_put_lchar('X' + uint8_t(axis)); if (blink) lcd_put_u8str(value); else if (axis_should_home(axis)) - while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?'); + 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(" ")); else 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); @@ -531,78 +544,77 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr const celsius_t t1 = thermalManager.wholeDegHotend(heater_id), t2 = thermalManager.degTargetHotend(heater_id); #endif - if (prefix >= 0) lcd_put_wchar(prefix); + if (prefix >= 0) lcd_put_lchar(prefix); lcd_put_u8str(t1 < 0 ? "err" : i16tostr3rj(t1)); - lcd_put_wchar('/'); + 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_wchar(' '); - if (t2 >= 10) lcd_put_wchar(' '); - if (t2 >= 100) lcd_put_wchar(' '); - } + 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_wchar(LCD_STR_DEGREE[0]); - lcd_put_wchar(' '); - if (t2 < 10) lcd_put_wchar(' '); + lcd_put_lchar(LCD_STR_DEGREE[0]); + 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_wchar(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_wchar('/'); + 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_wchar(' '); - if (t2 >= 10) lcd_put_wchar(' '); - if (t2 >= 100) lcd_put_wchar(' '); - } - else - #endif - lcd_put_u8str(i16tostr3left(t2)); + lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegCooler())); + lcd_put_u8str(F("/")); - if (prefix >= 0) { - lcd_put_wchar(LCD_STR_DEGREE[0]); - lcd_put_wchar(' '); - if (t2 < 10) lcd_put_wchar(' '); + #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_wchar('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_wchar('A'); + lcd_put_u8str(F("A")); } } #endif @@ -611,19 +623,35 @@ 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 +#if HAS_CUTTER - 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_wchar('%'); + 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 +#endif // HAS_CUTTER #if ENABLED(LCD_PROGRESS_BAR) @@ -667,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_wchar('%'); + lcd_put_u8str(F("%")); return; } @@ -686,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_wchar(' '); ++slen; } + while (slen < LCD_WIDTH) { lcd_put_u8str(F(" ")); ++slen; } } else { // String is larger than the available space in screen. @@ -700,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_wchar(' '); // 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_wchar(' '); + lcd_put_u8str(F(" ")); if (--chars) { // Draw a third space if there's room - lcd_put_wchar(' '); + lcd_put_u8str(F(" ")); if (--chars) lcd_put_u8str_max(status_message, chars); // Print a second copy of the message } @@ -725,13 +753,62 @@ 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_wchar(' '); - ++slen; - } + for (; slen < LCD_WIDTH; ++slen) lcd_put_u8str(F(" ")); #endif } +#if HAS_PRINT_PROGRESS + #define TPOFFSET (LCD_WIDTH - 1) + static uint8_t timepos = TPOFFSET - 6; + static char buffer[8]; + 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_u8str(F("%")); + } + } + #endif + #if ENABLED(SHOW_REMAINING_TIME) + void MarlinUI::drawRemain() { + 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); + } + } + #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); + 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); + } + } + #endif + #if ENABLED(SHOW_ELAPSED_TIME) + void MarlinUI::drawElapsed() { + 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_u8str(buffer); + } + } + #endif +#endif // HAS_PRINT_PROGRESS + /** * LCD_INFO_SCREEN_STYLE 0 : Classic Status Screen * @@ -764,35 +841,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_wchar(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_wchar(timepos, 2, LCD_STR_CLOCK[0]); - } - lcd_put_u8str(buffer); - return timepos; -} - void MarlinUI::draw_status_screen() { const bool blink = get_blink(); @@ -820,6 +868,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 @@ -840,6 +897,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)); @@ -855,8 +921,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 @@ -912,7 +978,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_wchar(' '); + lcd_put_u8str(F(" ")); _draw_axis_value(Y_AXIS, ftostr4sign(lpos.y), blink); } @@ -926,7 +992,7 @@ void MarlinUI::draw_status_screen() { _draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink); #if HAS_LEVELING && !HAS_HEATED_BED - lcd_put_wchar(planner.leveling_active || blink ? '_' : ' '); + lcd_put_lchar(planner.leveling_active || blink ? '_' : ' '); #endif #endif // LCD_HEIGHT > 2 @@ -935,22 +1001,21 @@ void MarlinUI::draw_status_screen() { #if LCD_HEIGHT > 3 - lcd_put_wchar(0, 2, LCD_STR_FEEDRATE[0]); + lcd_put_lchar(0, 2, LCD_STR_FEEDRATE[0]); lcd_put_u8str(i16tostr3rj(feedrate_percentage)); - lcd_put_wchar('%'); - - const uint8_t timepos = draw_elapsed_or_remaining_time(LCD_WIDTH - 1, blink); + lcd_put_u8str(F("%")); #if LCD_WIDTH >= 20 - lcd_moveto(timepos - 7, 2); + #if HAS_PRINT_PROGRESS - _draw_print_progress(); + 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 ) { @@ -969,9 +1034,9 @@ void MarlinUI::draw_status_screen() { per = planner.flow_percentage[0]; #endif } - lcd_put_wchar(c); + lcd_put_lchar(c); lcd_put_u8str(i16tostr3rj(per)); - lcd_put_wchar('%'); + lcd_put_u8str(F("%")); #endif #endif @@ -993,7 +1058,7 @@ void MarlinUI::draw_status_screen() { _draw_axis_value(Z_AXIS, ftostr52sp(LOGICAL_Z_POSITION(current_position.z)), blink); #if HAS_LEVELING && (HAS_MULTI_HOTEND || !HAS_HEATED_BED) - lcd_put_wchar(LCD_WIDTH - 1, 0, planner.leveling_active || blink ? '_' : ' '); + lcd_put_lchar(LCD_WIDTH - 1, 0, planner.leveling_active || blink ? '_' : ' '); #endif // ========== Line 2 ========== @@ -1008,14 +1073,14 @@ void MarlinUI::draw_status_screen() { _draw_bed_status(blink); #endif - lcd_put_wchar(LCD_WIDTH - 9, 1, LCD_STR_FEEDRATE[0]); + lcd_put_lchar(LCD_WIDTH - 9, 1, LCD_STR_FEEDRATE[0]); lcd_put_u8str(i16tostr3rj(feedrate_percentage)); - lcd_put_wchar('%'); + lcd_put_u8str(F("%")); // ========== Line 3 ========== // - // SD Percent, Hotend 2, or Bed + // Progress percent, Hotend 2, or Bed // lcd_moveto(0, 2); #if HOTENDS > 2 @@ -1024,24 +1089,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 ======== @@ -1075,29 +1133,29 @@ 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_wchar(' '); 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_wchar(' '); + 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_wchar(0, row, sel ? pre_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_wchar(' '); - lcd_put_wchar(post_char); + for (; n; --n) lcd_put_u8str(F(" ")); + lcd_put_lchar(post_char); } // Draw a menu item with a (potentially) editable value void MenuEditItemBase::draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char * const inStr, const bool pgm) { const uint8_t vlen = inStr ? (pgm ? utf8_strlen_P(inStr) : utf8_strlen(inStr)) : 0; - lcd_put_wchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' '); + 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_wchar(':'); - for (; n; --n) lcd_put_wchar(' '); + lcd_put_u8str(F(":")); + for (; n; --n) lcd_put_u8str(F(" ")); if (pgm) lcd_put_u8str_P(inStr); else lcd_put_u8str(inStr); } } @@ -1107,10 +1165,10 @@ 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_wchar(':'); 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_wchar(LCD_WIDTH - len, valrow, ' '); // Right-justified, padded, leading space + lcd_put_lchar(LCD_WIDTH - len, valrow, ' '); // Right-justified, padded, leading space lcd_put_u8str(value); } } @@ -1120,22 +1178,22 @@ void MarlinUI::draw_status_screen() { ui.draw_select_screen_prompt(pref, string, suff); if (no) { SETCURSOR(0, LCD_HEIGHT - 1); - lcd_put_wchar(yesno ? ' ' : '['); lcd_put_u8str(no); lcd_put_wchar(yesno ? ' ' : ']'); + lcd_put_lchar(yesno ? ' ' : '['); lcd_put_u8str(no); lcd_put_lchar(yesno ? ' ' : ']'); } if (yes) { SETCURSOR_RJ(utf8_strlen(yes) + 2, LCD_HEIGHT - 1); - lcd_put_wchar(yesno ? '[' : ' '); lcd_put_u8str(yes); lcd_put_wchar(yesno ? ']' : ' '); + lcd_put_lchar(yesno ? '[' : ' '); lcd_put_u8str(yes); lcd_put_lchar(yesno ? ']' : ' '); } } #if ENABLED(SDSUPPORT) void MenuItem_sdbase::draw(const bool sel, const uint8_t row, FSTR_P const, CardReader &theCard, const bool isDir) { - lcd_put_wchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' '); + 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_wchar(' '); - lcd_put_wchar(isDir ? LCD_STR_FOLDER[0] : ' '); + for (; n; --n) lcd_put_u8str(F(" ")); + lcd_put_lchar(isDir ? LCD_STR_FOLDER[0] : ' '); } #endif @@ -1253,7 +1311,7 @@ void MarlinUI::draw_status_screen() { void prep_and_put_map_char(custom_char &chrdata, const coordinate &ul, const coordinate &lr, const coordinate &brc, const uint8_t cl, const char c, const lcd_uint_t x, const lcd_uint_t y) { add_edges_to_custom_char(chrdata, ul, lr, brc, cl); lcd.createChar(c, (uint8_t*)&chrdata); - lcd_put_wchar(x, y, c); + lcd_put_lchar(x, y, c); } void MarlinUI::ubl_plot(const uint8_t x_plot, const uint8_t y_plot) { @@ -1270,7 +1328,7 @@ void MarlinUI::draw_status_screen() { #define _LCD_W_POS 8 #define _PLOT_X 0 #define _MAP_X 1 - #define _LABEL(X,Y,C) lcd_put_wchar(X, Y, C) + #define _LABEL(X,Y,C) lcd_put_lchar(X, Y, C) #define _XLABEL(X,Y) _LABEL('X',X,Y) #define _YLABEL(X,Y) _LABEL('Y',X,Y) #define _ZLABEL(X,Y) _LABEL('Z',X,Y) @@ -1333,13 +1391,13 @@ void MarlinUI::draw_status_screen() { n_cols = right_edge / (HD44780_CHAR_WIDTH) + 1; for (i = 0; i < n_cols; i++) { - lcd_put_wchar(i, 0, CHAR_LINE_TOP); // Box Top line - lcd_put_wchar(i, n_rows - 1, CHAR_LINE_BOT); // Box Bottom line + lcd_put_lchar(i, 0, CHAR_LINE_TOP); // Box Top line + lcd_put_lchar(i, n_rows - 1, CHAR_LINE_BOT); // Box Bottom line } for (j = 0; j < n_rows; j++) { - lcd_put_wchar(0, j, CHAR_EDGE_L); // Box Left edge - lcd_put_wchar(n_cols - 1, j, CHAR_EDGE_R); // Box Right edge + lcd_put_lchar(0, j, CHAR_EDGE_L); // Box Left edge + lcd_put_lchar(n_cols - 1, j, CHAR_EDGE_R); // Box Right edge } /** @@ -1349,8 +1407,8 @@ void MarlinUI::draw_status_screen() { k = pixels_per_y_mesh_pnt * (GRID_MAX_POINTS_Y) + 2; l = (HD44780_CHAR_HEIGHT) * n_rows; if (l > k && l - k >= (HD44780_CHAR_HEIGHT) / 2) { - lcd_put_wchar(0, n_rows - 1, ' '); // Box Left edge - lcd_put_wchar(n_cols - 1, n_rows - 1, ' '); // Box Right edge + lcd_put_lchar(0, n_rows - 1, ' '); // Box Left edge + lcd_put_lchar(n_cols - 1, n_rows - 1, ' '); // Box Right edge } clear_custom_char(&new_char); @@ -1464,11 +1522,11 @@ void MarlinUI::draw_status_screen() { /** * Print plot position */ - lcd_put_wchar(_LCD_W_POS, 0, '('); + lcd_put_lchar(_LCD_W_POS, 0, '('); lcd_put_u8str(ui8tostr3rj(x_plot)); - lcd_put_wchar(','); + lcd_put_u8str(F(",")); lcd_put_u8str(ui8tostr3rj(y_plot)); - lcd_put_wchar(')'); + lcd_put_u8str(F(")")); #if LCD_HEIGHT <= 3 // 16x2 or 20x2 display diff --git a/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp index 7b15b786055c..e681ff0a9170 100644 --- a/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp @@ -48,7 +48,7 @@ int lcd_glyph_height() { return 1; } typedef struct _TFTGLCD_charmap_t { - wchar_t uchar; // the unicode char + lchar_t uchar; // the unicode char uint8_t idx; // the glyph of the char in the ROM uint8_t idx2; // the char used to be combined with the idx to simulate a single char } TFTGLCD_charmap_t; @@ -991,7 +991,7 @@ void lcd_put_int(const int i) { // return < 0 on error // return the advanced cols -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length) { // find the HD44780 internal ROM first int ret; @@ -1049,10 +1049,10 @@ static int lcd_put_u8str_max_cb(const char * utf8_str, read_byte_cb_t cb_read_by pixel_len_t ret = 0; const uint8_t *p = (uint8_t *)utf8_str; while (ret < max_length) { - wchar_t ch = 0; - p = get_utf8_value_cb(p, cb_read_byte, &ch); - if (!ch) break; - ret += lcd_put_wchar_max(ch, max_length - ret); + lchar_t wc; + p = get_utf8_value_cb(p, cb_read_byte, wc); + if (!wc) break; + ret += lcd_put_lchar_max(wc, max_length - ret); } return (int)ret; } diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index 46564bb1e6e2..f87d76cef78c 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -299,7 +299,7 @@ uint8_t MarlinUI::read_slow_buttons() { } // Duration in ms, freq in Hz -void MarlinUI::buzz(const long duration, const uint16_t freq) { +void MarlinUI::buzz(const long duration, const uint16_t freq/*=0*/) { if (!PanelDetected) return; if (!sound_on) return; #if ENABLED(TFTGLCD_PANEL_SPI) @@ -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_wchar(' '); - if (t2 >= 10) lcd_put_wchar(' '); - if (t2 >= 100) lcd_put_wchar(' '); - } + 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_wchar(' '); - if (t2 < 10) lcd_put_wchar(' '); + 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_wchar('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_wchar(' '); 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_wchar('K'); + lcd_put_u8str(F("K")); #elif CUTTER_UNIT_IS(PERCENT) - lcd_moveto(17, 6); lcd_put_wchar('%'); + 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)); @@ -599,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(LCD_SET_PROGRESS_MANUALLY) - 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) @@ -799,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/buttons.h b/Marlin/src/lcd/buttons.h index 2580a71d1b82..58471239bbfb 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)) @@ -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 @@ -190,20 +183,20 @@ #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_DOWN _BUTTON_PRESSED(DOWN) #else - #define _BUTTON_PRESSED_DWN false + #define _BUTTON_PRESSED_DOWN false #endif -#if BUTTON_EXISTS(LFT) - #define _BUTTON_PRESSED_LFT _BUTTON_PRESSED(LFT) +#if BUTTON_EXISTS(LEFT) + #define _BUTTON_PRESSED_LEFT _BUTTON_PRESSED(LEFT) #else - #define _BUTTON_PRESSED_LFT false + #define _BUTTON_PRESSED_LEFT false #endif -#if BUTTON_EXISTS(RT) - #define _BUTTON_PRESSED_RT _BUTTON_PRESSED(RT) +#if BUTTON_EXISTS(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) diff --git a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h index e5c6524a9ec4..cfba12acff1b 100644 --- a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h +++ b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h @@ -41,6 +41,13 @@ #define U8G_COM_HAL_HW_SPI_FN u8g_com_samd51_hw_spi_fn #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_samd51_st7920_hw_spi_fn + + #elif defined(__SAMD21__) + + uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); + + #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_samd21_st7920_hw_spi_fn + #elif defined(__STM32F1__) uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); @@ -124,7 +131,7 @@ #ifndef U8G_COM_SSD_I2C_HAL #define U8G_COM_SSD_I2C_HAL u8g_com_null_fn #endif -#if HAS_FSMC_GRAPHICAL_TFT || HAS_SPI_GRAPHICAL_TFT +#if HAS_FSMC_GRAPHICAL_TFT || HAS_SPI_GRAPHICAL_TFT || HAS_LTDC_GRAPHICAL_TFT uint8_t u8g_com_hal_tft_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); #define U8G_COM_HAL_TFT_FN u8g_com_hal_tft_fn #else diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_hu.h b/Marlin/src/lcd/dogm/fontdata/langdata_hu.h index 450662a8c9d1..c0175be874ee 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_hu.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_hu.h @@ -7,10 +7,4 @@ #include "langdata.h" -const u8g_fntpgm_uint8_t fontpage_2_241_241[31] U8G_FONT_SECTION("fontpage_2_241_241") = { - 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xF1,0xF1,0x00,0x08,0x00,0x00, - 0x00,0x05,0x08,0x08,0x06,0x00,0x00,0x48,0x90,0x00,0x88,0x88,0x88,0x88,0x70}; - -static const uxg_fontinfo_t g_fontinfo_hu[] PROGMEM = { - FONTDATA_ITEM(2, 241, 241, fontpage_2_241_241), // 'ű' -- 'ű' -}; +static const uxg_fontinfo_t g_fontinfo_hu[] PROGMEM = {}; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_pl.h b/Marlin/src/lcd/dogm/fontdata/langdata_pl.h index e89a6c159a4e..e9365a69c23c 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_pl.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_pl.h @@ -27,6 +27,9 @@ const u8g_fntpgm_uint8_t fontpage_2_218_219[47] U8G_FONT_SECTION("fontpage_2_218 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xDA,0xDB,0x00,0x0A,0x00,0x00, 0x00,0x05,0x0A,0x0A,0x06,0x00,0x00,0x10,0x20,0x00,0x70,0x88,0x80,0x70,0x08,0x88, 0x70,0x05,0x08,0x08,0x06,0x00,0x00,0x10,0x20,0x00,0x78,0x80,0x70,0x08,0xF0}; +const u8g_fntpgm_uint8_t fontpage_2_250_250[31] U8G_FONT_SECTION("fontpage_2_250_250") = { + 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xFA,0xFA,0x00,0x08,0x00,0x00, + 0x00,0x05,0x08,0x08,0x06,0x00,0x00,0x10,0x20,0x00,0xF8,0x10,0x20,0x40,0xF8}; const u8g_fntpgm_uint8_t fontpage_2_252_252[30] U8G_FONT_SECTION("fontpage_2_252_252") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xFC,0xFC,0x00,0x07,0x00,0x00, 0x00,0x05,0x07,0x07,0x06,0x00,0x00,0x20,0x00,0xF8,0x10,0x20,0x40,0xF8}; @@ -37,5 +40,6 @@ static const uxg_fontinfo_t g_fontinfo_pl[] PROGMEM = { FONTDATA_ITEM(2, 153, 153, fontpage_2_153_153), // 'ę' -- 'ę' FONTDATA_ITEM(2, 193, 196, fontpage_2_193_196), // 'Ł' -- 'ń' FONTDATA_ITEM(2, 218, 219, fontpage_2_218_219), // 'Ś' -- 'ś' + FONTDATA_ITEM(2, 250, 250, fontpage_2_250_250), // 'ź' -- 'ź' FONTDATA_ITEM(2, 252, 252, fontpage_2_252_252), // 'ż' -- 'ż' }; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_sv.h b/Marlin/src/lcd/dogm/fontdata/langdata_sv.h new file mode 100644 index 000000000000..cf6328766e32 --- /dev/null +++ b/Marlin/src/lcd/dogm/fontdata/langdata_sv.h @@ -0,0 +1,10 @@ +/** + * Generated automatically by buildroot/share/fonts/uxggenpages.sh + * Contents will be REPLACED by future processing! + * Use genallfont.sh to generate font data for updated languages. + */ +#pragma once + +#include "langdata.h" + +static const uxg_fontinfo_t g_fontinfo_sv[] PROGMEM = {}; diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_zh_CN.h b/Marlin/src/lcd/dogm/fontdata/langdata_zh_CN.h index 664fa5f4bfe9..60316a147987 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_zh_CN.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_zh_CN.h @@ -7,9 +7,6 @@ #include "langdata.h" -const u8g_fntpgm_uint8_t fontpage_64_157_157[26] U8G_FONT_SECTION("fontpage_64_157_157") = { - 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x9D,0x9D,0x00,0x07,0x00,0x00, - 0x00,0x05,0x03,0x03,0x06,0x00,0x04,0xD8,0x48,0x90}; const u8g_fntpgm_uint8_t fontpage_69_191_191[28] U8G_FONT_SECTION("fontpage_69_191_191") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xBF,0xBF,0x00,0x05,0x00,0x00, 0x00,0x05,0x05,0x05,0x06,0x00,0x00,0x08,0x18,0x28,0x48,0xF8}; @@ -382,10 +379,6 @@ const u8g_fntpgm_uint8_t fontpage_172_232_232[45] U8G_FONT_SECTION("fontpage_172 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xE8,0xE8,0x00,0x0A,0xFF,0x00, 0x00,0x0B,0x0B,0x16,0x0C,0x00,0xFF,0x7B,0xC0,0x4A,0x40,0x4A,0x40,0x7B,0xC0,0x04, 0x80,0xFF,0xE0,0x11,0x00,0xFB,0xE0,0x4A,0x40,0x4A,0x40,0x7B,0xC0}; -const u8g_fntpgm_uint8_t fontpage_172_244_244[45] U8G_FONT_SECTION("fontpage_172_244_244") = { - 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xF4,0xF4,0x00,0x0A,0xFF,0x00, - 0x00,0x0B,0x0B,0x16,0x0C,0x00,0xFF,0x01,0x00,0xEF,0xE0,0xA5,0x40,0xAF,0xE0,0xA4, - 0x40,0xA7,0xC0,0xE4,0x40,0x07,0xC0,0x04,0x40,0x07,0xC0,0x0C,0x60}; const u8g_fntpgm_uint8_t fontpage_173_222_222[45] U8G_FONT_SECTION("fontpage_173_222_222") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xDE,0xDE,0x00,0x0A,0xFF,0x00, 0x00,0x0A,0x0B,0x16,0x0C,0x01,0xFF,0xFF,0xC0,0x80,0x40,0x80,0x40,0x9E,0x40,0x92, @@ -744,10 +737,6 @@ const u8g_fntpgm_uint8_t fontpage_202_244_244[45] U8G_FONT_SECTION("fontpage_202 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xF4,0xF4,0x00,0x0A,0xFF,0x00, 0x00,0x0B,0x0B,0x16,0x0C,0x00,0xFF,0x11,0x00,0xFF,0xE0,0x55,0x40,0x7C,0x80,0x39, 0x40,0x56,0x20,0x7F,0xC0,0x04,0x00,0x27,0x80,0x24,0x00,0xFF,0xE0}; -const u8g_fntpgm_uint8_t fontpage_203_135_135[45] U8G_FONT_SECTION("fontpage_203_135_135") = { - 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x87,0x87,0x00,0x0A,0xFF,0x00, - 0x00,0x0B,0x0B,0x16,0x0C,0x00,0xFF,0x08,0x00,0x04,0x00,0xFF,0xE0,0x11,0x00,0x11, - 0x00,0x11,0x00,0x0A,0x00,0x0A,0x00,0x04,0x00,0x1B,0x00,0xE0,0xE0}; const u8g_fntpgm_uint8_t fontpage_203_153_153[45] U8G_FONT_SECTION("fontpage_203_153_153") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x99,0x99,0x00,0x0A,0xFF,0x00, 0x00,0x0B,0x0B,0x16,0x0C,0x00,0xFF,0x20,0x80,0xAC,0x80,0x72,0x80,0x20,0x80,0xFC, @@ -1050,10 +1039,6 @@ const u8g_fntpgm_uint8_t fontpage_246_201_201[45] U8G_FONT_SECTION("fontpage_246 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xC9,0xC9,0x00,0x0A,0xFF,0x00, 0x00,0x0B,0x0B,0x16,0x0C,0x00,0xFF,0x42,0x00,0x7B,0xE0,0x94,0x80,0x7F,0xC0,0x04, 0x00,0xFF,0xE0,0x01,0x00,0x7F,0xC0,0x11,0x00,0x09,0x00,0x03,0x00}; -const u8g_fntpgm_uint8_t fontpage_247_128_128[45] U8G_FONT_SECTION("fontpage_247_128_128") = { - 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x00,0x0A,0xFF,0x00, - 0x00,0x0B,0x0B,0x16,0x0C,0x00,0xFF,0x42,0x00,0x7B,0xE0,0x94,0x80,0x27,0xC0,0x50, - 0x40,0x4F,0x40,0x49,0x40,0x4F,0x40,0x49,0x40,0x4F,0x40,0x40,0xC0}; const u8g_fntpgm_uint8_t fontpage_247_177_177[45] U8G_FONT_SECTION("fontpage_247_177_177") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xB1,0xB1,0x00,0x0A,0xFF,0x00, 0x00,0x0B,0x0B,0x16,0x0C,0x00,0xFF,0x21,0x00,0x3D,0xE0,0x4A,0x80,0x94,0x40,0x7F, @@ -1465,7 +1450,6 @@ const u8g_fntpgm_uint8_t fontpage_510_154_154[30] U8G_FONT_SECTION("fontpage_510 0x00,0x02,0x07,0x07,0x0C,0x06,0x01,0xC0,0xC0,0x00,0x00,0x00,0xC0,0xC0}; static const uxg_fontinfo_t g_fontinfo_zh_CN[] PROGMEM = { - FONTDATA_ITEM(64, 157, 157, fontpage_64_157_157), // '”' -- '”' FONTDATA_ITEM(69, 191, 191, fontpage_69_191_191), // '⊿' -- '⊿' FONTDATA_ITEM(156, 128, 128, fontpage_156_128_128), // '一' -- '一' FONTDATA_ITEM(156, 137, 139, fontpage_156_137_139), // '三' -- '下' @@ -1553,7 +1537,6 @@ static const uxg_fontinfo_t g_fontinfo_zh_CN[] PROGMEM = { FONTDATA_ITEM(171, 183, 183, fontpage_171_183_183), // '喷' -- '喷' FONTDATA_ITEM(172, 180, 180, fontpage_172_180_180), // '嘴' -- '嘴' FONTDATA_ITEM(172, 232, 232, fontpage_172_232_232), // '器' -- '器' - FONTDATA_ITEM(172, 244, 244, fontpage_172_244_244), // '噴' -- '噴' FONTDATA_ITEM(173, 222, 222, fontpage_173_222_222), // '回' -- '回' FONTDATA_ITEM(173, 224, 224, fontpage_173_224_224), // '因' -- '因' FONTDATA_ITEM(173, 250, 250, fontpage_173_250_250), // '固' -- '固' @@ -1642,7 +1625,6 @@ static const uxg_fontinfo_t g_fontinfo_zh_CN[] PROGMEM = { FONTDATA_ITEM(202, 240, 240, fontpage_202_240_240), // '数' -- '数' FONTDATA_ITEM(202, 242, 242, fontpage_202_242_242), // '敲' -- '敲' FONTDATA_ITEM(202, 244, 244, fontpage_202_244_244), // '整' -- '整' - FONTDATA_ITEM(203, 135, 135, fontpage_203_135_135), // '文' -- '文' FONTDATA_ITEM(203, 153, 153, fontpage_203_153_153), // '料' -- '料' FONTDATA_ITEM(203, 156, 156, fontpage_203_156_156), // '斜' -- '斜' FONTDATA_ITEM(203, 173, 173, fontpage_203_173_173), // '断' -- '断' @@ -1718,7 +1700,6 @@ static const uxg_fontinfo_t g_fontinfo_zh_CN[] PROGMEM = { FONTDATA_ITEM(245, 239, 239, fontpage_245_239_239), // '端' -- '端' FONTDATA_ITEM(246, 172, 172, fontpage_246_172_172), // '第' -- '第' FONTDATA_ITEM(246, 201, 201, fontpage_246_201_201), // '等' -- '等' - FONTDATA_ITEM(247, 128, 128, fontpage_247_128_128), // '简' -- '简' FONTDATA_ITEM(247, 177, 177, fontpage_247_177_177), // '箱' -- '箱' FONTDATA_ITEM(248, 251, 251, fontpage_248_251_251), // '类' -- '类' FONTDATA_ITEM(250, 162, 162, fontpage_250_162_162), // '索' -- '索' diff --git a/Marlin/src/lcd/dogm/fontdata/langdata_zh_TW.h b/Marlin/src/lcd/dogm/fontdata/langdata_zh_TW.h index 093629cd16fa..c132a0de706b 100644 --- a/Marlin/src/lcd/dogm/fontdata/langdata_zh_TW.h +++ b/Marlin/src/lcd/dogm/fontdata/langdata_zh_TW.h @@ -343,12 +343,10 @@ const u8g_fntpgm_uint8_t fontpage_178_167_167[45] U8G_FONT_SECTION("fontpage_178 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xA7,0xA7,0x00,0x0A,0xFF,0x00, 0x00,0x0B,0x0B,0x16,0x0C,0x00,0xFF,0x04,0x00,0x04,0x00,0x04,0x00,0xFF,0xE0,0x04, 0x00,0x04,0x00,0x0A,0x00,0x0A,0x00,0x11,0x00,0x20,0x80,0xC0,0x60}; -const u8g_fntpgm_uint8_t fontpage_178_169_170[73] U8G_FONT_SECTION("fontpage_178_169_170") = { - 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xA9,0xAA,0x00,0x0A,0xFF,0x00, +const u8g_fntpgm_uint8_t fontpage_178_169_169[45] U8G_FONT_SECTION("fontpage_178_169_169") = { + 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xA9,0xA9,0x00,0x0A,0xFF,0x00, 0x00,0x0B,0x0B,0x16,0x0C,0x00,0xFF,0x7F,0xC0,0x04,0x00,0x04,0x00,0x04,0x00,0xFF, - 0xE0,0x04,0x00,0x0A,0x00,0x0A,0x00,0x11,0x00,0x20,0x80,0xC0,0x60,0x0B,0x0B,0x16, - 0x0C,0x00,0xFF,0x04,0x00,0x04,0x00,0x04,0x00,0xFF,0xE0,0x04,0x00,0x0A,0x00,0x0A, - 0x00,0x11,0x00,0x19,0x00,0x24,0x80,0xC4,0x60}; + 0xE0,0x04,0x00,0x0A,0x00,0x0A,0x00,0x11,0x00,0x20,0x80,0xC0,0x60}; const u8g_fntpgm_uint8_t fontpage_178_177_177[45] U8G_FONT_SECTION("fontpage_178_177_177") = { 0x00,0x0C,0x0F,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0xB1,0xB1,0x00,0x0A,0xFF,0x00, 0x00,0x0B,0x0B,0x16,0x0C,0x00,0xFF,0x24,0x00,0x24,0x00,0x3F,0xC0,0x44,0x00,0x04, @@ -1302,7 +1300,7 @@ static const uxg_fontinfo_t g_fontinfo_zh_TW[] PROGMEM = { FONTDATA_ITEM(178, 154, 154, fontpage_178_154_154), // '多' -- '多' FONTDATA_ITEM(178, 160, 160, fontpage_178_160_160), // '夠' -- '夠' FONTDATA_ITEM(178, 167, 167, fontpage_178_167_167), // '大' -- '大' - FONTDATA_ITEM(178, 169, 170, fontpage_178_169_170), // '天' -- '太' + FONTDATA_ITEM(178, 169, 169, fontpage_178_169_169), // '天' -- '天' FONTDATA_ITEM(178, 177, 177, fontpage_178_177_177), // '失' -- '失' FONTDATA_ITEM(179, 203, 203, fontpage_179_203_203), // '始' -- '始' FONTDATA_ITEM(181, 146, 146, fontpage_181_146_146), // '媒' -- '媒' diff --git a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp index f5c13798f234..74a49b095021 100644 --- a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp +++ b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp @@ -28,13 +28,13 @@ void lcd_put_int(const int i) { u8g.print(i); } // return < 0 on error // return the advanced pixels -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length) { if (c < 256) { u8g.print((char)c); 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 3c661a44294a..1a86058b943c 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 @@ -371,11 +370,11 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop if (!PAGE_CONTAINS(y1 + 1, y2 + 2)) return; - lcd_put_wchar(LCD_PIXEL_WIDTH - 11 * (MENU_FONT_WIDTH), y2, 'E'); - lcd_put_wchar((char)('1' + extruder)); - lcd_put_wchar(' '); + lcd_put_lchar(LCD_PIXEL_WIDTH - 11 * (MENU_FONT_WIDTH), y2, 'E'); + lcd_put_lchar((char)('1' + extruder)); + lcd_put_u8str(F(" ")); lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegHotend(extruder))); - lcd_put_wchar('/'); + lcd_put_u8str(F("/")); if (get_blink() || !thermalManager.heater_idle[extruder].timed_out) lcd_put_u8str(i16tostr3rj(thermalManager.degTargetHotend(extruder))); @@ -421,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_wchar(' '); + 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_wchar(' '); + while (n > MENU_FONT_WIDTH) n -= lcd_put_u8str(F(" ")); } } @@ -434,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_wchar(' '); - lcd_put_wchar(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2, post_char); - lcd_put_wchar(' '); + 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_u8str(F(" ")); } } @@ -449,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_wchar(':'); - while (n > MENU_FONT_WIDTH) n -= lcd_put_wchar(' '); + 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); } @@ -494,14 +493,14 @@ 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_wchar(':'); + lcd_put_u8str(F(":")); if (extra_row) { // Assume that value is numeric (with no descender) baseline += EDIT_FONT_ASCENT + 2; onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline); } if (onpage) { - lcd_put_wchar(((lcd_chr_fit - 1) - (vallen * prop + 1)) * one_chr_width, baseline, ' '); // Right-justified, padded, add a leading space + lcd_put_lchar(((lcd_chr_fit - 1) - (vallen * prop + 1)) * one_chr_width, baseline, ' '); // Right-justified, padded, add a leading space lcd_put_u8str(value); } } @@ -533,10 +532,10 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop void MenuItem_sdbase::draw(const bool sel, const uint8_t row, FSTR_P const, CardReader &theCard, const bool isDir) { if (mark_as_selected(row, sel)) { const uint8_t maxlen = LCD_WIDTH - isDir; - if (isDir) lcd_put_wchar(LCD_STR_FOLDER[0]); + 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_wchar(' '); + while (n > MENU_FONT_WIDTH) n -= lcd_put_u8str(F(" ")); } } @@ -611,11 +610,11 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop // Print plot position if (PAGE_CONTAINS(LCD_PIXEL_HEIGHT - (INFO_FONT_HEIGHT - 1), LCD_PIXEL_HEIGHT)) { - lcd_put_wchar(5, LCD_PIXEL_HEIGHT, '('); + lcd_put_lchar(5, LCD_PIXEL_HEIGHT, '('); u8g.print(x_plot); - lcd_put_wchar(','); + lcd_put_u8str(F(",")); u8g.print(y_plot); - lcd_put_wchar(')'); + 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/marlinui_DOGM.h b/Marlin/src/lcd/dogm/marlinui_DOGM.h index 050f147d625c..f70621574c33 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.h +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.h @@ -36,10 +36,16 @@ // RepRapWorld Graphical LCD - #define U8G_CLASS U8GLIB_ST7920_128X64_4X + #if DISABLED(SDSUPPORT) && (LCD_PINS_D4 == SD_SCK_PIN) && (LCD_PINS_ENABLE == SD_MOSI_PIN) + #define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL + #define U8G_PARAM LCD_PINS_RS + #elif ENABLED(SDSUPPORT) && __SAMD21__ + + #define U8G_CLASS U8GLIB_ST7920_128X64_4X #define U8G_PARAM LCD_PINS_RS #else + #define U8G_CLASS U8GLIB_ST7920_128X64_4X #define U8G_PARAM LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS #endif diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 010a1397f620..cba58f5c02f9 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" @@ -200,7 +198,7 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co const char *str = i16tostr3rj(temp); const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1; lcd_put_u8str(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty, &str[3-len]); - lcd_put_wchar(LCD_STR_DEGREE[0]); + lcd_put_lchar(LCD_STR_DEGREE[0]); } } @@ -432,19 +430,62 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const const bool is_inch = parser.using_inch_units(); const AxisEnum a = TERN(LCD_SHOW_E_TOTAL, axis == E_AXIS ? X_AXIS : axis, axis); const uint8_t offs = a * (is_inch ? XYZ_SPACING_IN : XYZ_SPACING); - lcd_put_wchar((is_inch ? X_LABEL_POS_IN : X_LABEL_POS) + offs, XYZ_BASELINE, AXIS_CHAR(axis)); + lcd_put_lchar((is_inch ? X_LABEL_POS_IN : X_LABEL_POS) + offs, XYZ_BASELINE, AXIS_CHAR(axis)); lcd_moveto((is_inch ? X_VALUE_POS_IN : X_VALUE_POS) + offs, XYZ_BASELINE); if (blink) lcd_put_u8str(value); else if (axis_should_home(axis)) - while (const char c = *value++) lcd_put_wchar(c <= '.' ? c : '?'); + 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); } +// Prepare strings for progress display +#if HAS_PRINT_PROGRESS + static MarlinUI::progress_t progress = 0; + static char bufferc[13]; + + static void prepare_time_string(const duration_t &time, char prefix) { + char str[13]; + 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) + void MarlinUI::drawPercent() { + 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) + void MarlinUI::drawRemain() { + if (printJobOngoing() && get_remaining_time() != 0) + prepare_time_string(get_remaining_time(), 'R'); } + #endif + #if ENABLED(SHOW_INTERACTION_TIME) + void MarlinUI::drawInter() { + if (printingIsActive() && interaction_time) + prepare_time_string(interaction_time, 'C'); } + #endif + #if ENABLED(SHOW_ELAPSED_TIME) + void MarlinUI::drawElapsed() { + if (printJobOngoing()) + prepare_time_string(print_job_timer.duration(), 'E'); } + #endif +#endif // HAS_PRINT_PROGRESS + /** * Draw the Status Screen for a 128x64 DOGM (U8glib) display. * @@ -453,38 +494,22 @@ 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]; #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()); + static u8g_uint_t progress_bar_solid_width = 0; + // At the first page, generate new display values if (first_page) { #if ANIM_HBCC @@ -502,7 +527,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) @@ -512,7 +539,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) @@ -520,64 +547,19 @@ 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 elapsed = print_job_timer.duration(); - const uint8_t p = progress & 0xFF, ev = elapsed.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_SD_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 - #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)); - } - } - #endif } #endif } - const bool blink = get_blink(); - // Status Menu Font set_font(FONT_STATUSMENU); @@ -634,6 +616,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,18 +648,17 @@ 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 #if DO_DRAW_CUTTER - if (cutter.isReady && PAGE_CONTAINS(STATUS_CUTTER_TEXT_Y - INFO_FONT_ASCENT, STATUS_CUTTER_TEXT_Y - 1)) { + if (cutter.isReadyForUI && PAGE_CONTAINS(STATUS_CUTTER_TEXT_Y - INFO_FONT_ASCENT, STATUS_CUTTER_TEXT_Y - 1)) { #if CUTTER_UNIT_IS(PERCENT) 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_wchar('K'); + lcd_put_u8str(F("K")); #else lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower)); #endif @@ -734,7 +717,7 @@ void MarlinUI::draw_status_screen() { } #endif lcd_put_u8str(STATUS_FAN_TEXT_X, STATUS_FAN_TEXT_Y, i16tostr3rj(thermalManager.pwmToPercent(spd))); - lcd_put_wchar(c); + lcd_put_lchar(c); } } #endif @@ -757,74 +740,20 @@ 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_wchar('%'); - } - } - 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_wchar('%'); - } - #endif - - // - // Elapsed Time - // - - #if ENABLED(SHOW_REMAINING_TIME) - if (blink && estimation_string[0]) { - lcd_put_wchar(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 + // Progress strings + if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)){ + ui.rotate_progress(); + lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, bufferc); } - - #endif // HAS_PRINT_PROGRESS + #endif // // XYZ Coordinates @@ -892,12 +821,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 @@ -912,11 +843,11 @@ void MarlinUI::draw_status_screen() { if (PAGE_CONTAINS(EXTRAS_2_BASELINE - INFO_FONT_ASCENT, EXTRAS_2_BASELINE - 1)) { set_font(FONT_MENU); - lcd_put_wchar(3, EXTRAS_2_BASELINE, LCD_STR_FEEDRATE[0]); + lcd_put_lchar(3, EXTRAS_2_BASELINE, LCD_STR_FEEDRATE[0]); set_font(FONT_STATUSMENU); lcd_put_u8str(12, EXTRAS_2_BASELINE, i16tostr3rj(feedrate_percentage)); - lcd_put_wchar('%'); + lcd_put_u8str(F("%")); // // Filament sensor display if SD is disabled @@ -924,10 +855,10 @@ 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_wchar('%'); + lcd_put_u8str(F("%")); set_font(FONT_MENU); - lcd_put_wchar(47, EXTRAS_2_BASELINE, LCD_STR_FILAM_DIA[0]); // lcd_put_u8str(F(LCD_STR_FILAM_DIA)); - lcd_put_wchar(93, EXTRAS_2_BASELINE, LCD_STR_FILAM_MUL[0]); + 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]); #endif } @@ -941,12 +872,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_wchar(':'); + lcd_put_u8str(F(":")); lcd_put_u8str(wstring); lcd_put_u8str(F(" " LCD_STR_FILAM_MUL)); - lcd_put_wchar(':'); + lcd_put_u8str(F(":")); lcd_put_u8str(mstring); - lcd_put_wchar('%'); + lcd_put_u8str(F("%")); return; } #endif @@ -979,7 +910,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_wchar(' '); ++slen; } + while (slen < lcd_width) { lcd_put_u8str(F(" ")); ++slen; } } else { // String is longer than the available space @@ -997,14 +928,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_wchar(' '); // 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_wchar(' '); + lcd_put_u8str(F(" ")); if (--chars) { // Draw a third space if there's room - lcd_put_wchar(' '); + 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_wchar(' '); + lcd_put_u8str(F(" ")); } } } @@ -1019,7 +950,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_wchar(' '); + for (; slen < lcd_width; ++slen) lcd_put_u8str(F(" ")); #endif // !STATUS_MESSAGE_SCROLLING diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp index 492a79a31108..bb5294ea3d43 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 } } } @@ -681,14 +629,14 @@ void ST7920_Lite_Status_Screen::draw_position(const xyze_pos_t &pos, const bool #endif } else { - write_byte(alt_label ? alt_label : 'X'); + write_byte(alt_label ?: 'X'); write_str(dtostrf(pos.x, -4, 0, str), 4); - write_byte(alt_label ? alt_label : 'Y'); + write_byte(alt_label ?: 'Y'); write_str(dtostrf(pos.y, -4, 0, str), 4); } - write_byte(alt_label ? alt_label : 'Z'); + write_byte(alt_label ?: 'Z'); write_str(dtostrf(pos.z, -5, 1, str), 5); } @@ -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/dogm/u8g_dev_st7565_64128n_HAL.cpp b/Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp index bfd44d08dfbb..63e7b2e2b8b5 100644 --- a/Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp @@ -74,7 +74,6 @@ #define ST7565_ON(N) ((N) ? 0xAF : 0xAE) #define ST7565_OUT_MODE(N) ((N) ? 0xC8 : 0xC0) #define ST7565_POWER_CONTROL(N) (0x28 | (N)) -#define ST7565_V0_RATIO(N) (0x10 | ((N) & 0x7)) #define ST7565_V5_RATIO(N) (0x20 | ((N) & 0x7)) #define ST7565_CONTRAST(N) (0x81), (N) @@ -106,11 +105,14 @@ static const uint8_t u8g_dev_st7565_64128n_HAL_init_seq[] PROGMEM = { ST7565_POWER_CONTROL(0x7), // power control: turn on voltage follower U8G_ESC_DLY(50), // delay 50 ms - ST7565_V0_RATIO(0), // Set V0 voltage resistor ratio. Setting for controlling brightness of Displaytech 64128N + #ifdef ST7565_VOLTAGE_DIVIDER_VALUE + // Set V5 voltage resistor ratio. Affects brightness of Displaytech 64128N + ST7565_V5_RATIO(ST7565_VOLTAGE_DIVIDER_VALUE), + #endif ST7565_INVERTED(0), // display normal, bit val 0: LCD pixel off. - ST7565_CONTRAST(0x1E), // Contrast value. Setting for controlling brightness of Displaytech 64128N + ST7565_CONTRAST(0x1E), // Contrast value for Displaytech 64128N ST7565_ON(1), // display on diff --git a/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp b/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp index f1bf9d032ec8..efc010ca8960 100644 --- a/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp @@ -501,26 +501,26 @@ U8G_PB_DEV(u8g_dev_tft_320x240_upscale_from_128x64, WIDTH, HEIGHT, PAGE_HEIGHT, void MarlinUI::touch_calibration_screen() { uint16_t x, y; - calibrationState calibration_stage = touch_calibration.get_calibration_state(); + calibrationState stage = touch_calibration.get_calibration_state(); - if (calibration_stage == CALIBRATION_NONE) { + if (stage == CALIBRATION_NONE) { // start and clear screen defer_status_screen(true); - calibration_stage = touch_calibration.calibration_start(); + stage = touch_calibration.calibration_start(); tftio.set_window(0, 0, (TFT_WIDTH) - 1, (TFT_HEIGHT) - 1); tftio.WriteMultiple(TFT_MARLINBG_COLOR, uint32_t(TFT_WIDTH) * (TFT_HEIGHT)); } else { // clear last cross - x = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].x; - y = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].y; + x = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].x; + y = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].y; drawCross(x, y, TFT_MARLINBG_COLOR); } FSTR_P str = nullptr; - if (calibration_stage < CALIBRATION_SUCCESS) { + if (stage < CALIBRATION_SUCCESS) { // handle current state - switch (calibration_stage) { + switch (stage) { case CALIBRATION_TOP_LEFT: str = GET_TEXT_F(MSG_TOP_LEFT); break; case CALIBRATION_BOTTOM_LEFT: str = GET_TEXT_F(MSG_BOTTOM_LEFT); break; case CALIBRATION_TOP_RIGHT: str = GET_TEXT_F(MSG_TOP_RIGHT); break; @@ -528,13 +528,13 @@ U8G_PB_DEV(u8g_dev_tft_320x240_upscale_from_128x64, WIDTH, HEIGHT, PAGE_HEIGHT, default: break; } - x = touch_calibration.calibration_points[calibration_stage].x; - y = touch_calibration.calibration_points[calibration_stage].y; + x = touch_calibration.calibration_points[stage].x; + y = touch_calibration.calibration_points[stage].y; drawCross(x, y, TFT_MARLINUI_COLOR); } else { // end calibration - str = calibration_stage == CALIBRATION_SUCCESS ? GET_TEXT_F(MSG_CALIBRATION_COMPLETED) : GET_TEXT_F(MSG_CALIBRATION_FAILED); + str = stage == CALIBRATION_SUCCESS ? GET_TEXT_F(MSG_CALIBRATION_COMPLETED) : GET_TEXT_F(MSG_CALIBRATION_FAILED); defer_status_screen(false); touch_calibration.calibration_end(); TERN_(HAS_TOUCH_BUTTONS, redrawTouchButtons = true); @@ -548,7 +548,7 @@ U8G_PB_DEV(u8g_dev_tft_320x240_upscale_from_128x64, WIDTH, HEIGHT, PAGE_HEIGHT, } while (u8g.nextPage()); drawing_screen = false; safe_delay(250); - if (calibration_stage == CALIBRATION_SUCCESS) { + if (stage == CALIBRATION_SUCCESS) { safe_delay(500); ui.goto_previous_screen(); } diff --git a/Marlin/src/lcd/dogm/u8g_fontutf8.cpp b/Marlin/src/lcd/dogm/u8g_fontutf8.cpp index 8ba0e7d50a8b..e9d15350963a 100644 --- a/Marlin/src/lcd/dogm/u8g_fontutf8.cpp +++ b/Marlin/src/lcd/dogm/u8g_fontutf8.cpp @@ -60,11 +60,11 @@ static int fontgroup_init(font_group_t * root, const uxg_fontinfo_t * fntinfo, i return 0; } -static const font_t* fontgroup_find(font_group_t * root, wchar_t val) { - uxg_fontinfo_t vcmp = {(uint16_t)(val / 128), (uint8_t)(val % 128 + 128), (uint8_t)(val % 128 + 128), 0, 0}; - size_t idx = 0; +static const font_t* fontgroup_find(font_group_t * root, const lchar_t &val) { + if (val <= 0xFF) return nullptr; - if (val < 256) return nullptr; + uxg_fontinfo_t vcmp = { uint16_t(val >> 7), uint8_t((val & 0x7F) + 0x80), uint8_t((val & 0x7F) + 0x80), 0, 0 }; + size_t idx = 0; if (pf_bsearch_r((void*)root->m_fntifo, root->m_fntinfo_num, pf_bsearch_cb_comp_fntifo_pgm, (void*)&vcmp, &idx) < 0) return nullptr; @@ -73,7 +73,7 @@ static const font_t* fontgroup_find(font_group_t * root, wchar_t val) { return vcmp.fntdata; } -static void fontgroup_drawwchar(font_group_t *group, const font_t *fnt_default, wchar_t val, void * userdata, fontgroup_cb_draw_t cb_draw_ram) { +static void fontgroup_drawwchar(font_group_t *group, const font_t *fnt_default, const lchar_t &val, void * userdata, fontgroup_cb_draw_t cb_draw_ram) { uint8_t buf[2] = {0, 0}; const font_t * fntpqm = (font_t*)fontgroup_find(group, val); if (!fntpqm) { @@ -106,10 +106,10 @@ static void fontgroup_drawwchar(font_group_t *group, const font_t *fnt_default, static void fontgroup_drawstring(font_group_t *group, const font_t *fnt_default, const char *utf8_msg, read_byte_cb_t cb_read_byte, void * userdata, fontgroup_cb_draw_t cb_draw_ram) { const uint8_t *p = (uint8_t*)utf8_msg; for (;;) { - wchar_t val = 0; - p = get_utf8_value_cb(p, cb_read_byte, &val); - if (!val) break; - fontgroup_drawwchar(group, fnt_default, val, userdata, cb_draw_ram); + lchar_t wc; + p = get_utf8_value_cb(p, cb_read_byte, wc); + if (!wc) break; + fontgroup_drawwchar(group, fnt_default, wc, userdata, cb_draw_ram); } } @@ -149,19 +149,19 @@ static int fontgroup_cb_draw_u8g(void *userdata, const font_t *fnt_current, cons } /** - * @brief Draw a wchar_t at the specified position + * @brief Draw a lchar_t at the specified position * * @param pu8g : U8G pointer * @param x : position x axis * @param y : position y axis - * @param ch : the wchar_t + * @param wc : the lchar_t * @param max_width : the pixel width of the string allowed * * @return number of pixels advanced * * Draw a UTF-8 string at the specified position */ -unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, wchar_t ch, 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); @@ -176,7 +176,7 @@ unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, wchar_t data.adv = 0; data.max_width = max_width; data.fnt_prev = nullptr; - fontgroup_drawwchar(group, fnt_default, ch, (void*)&data, fontgroup_cb_draw_u8g); + fontgroup_drawwchar(group, fnt_default, wc, (void*)&data, fontgroup_cb_draw_u8g); u8g_SetFont(pu8g, (const u8g_fntpgm_uint8_t*)fnt_default); return data.adv; diff --git a/Marlin/src/lcd/dogm/u8g_fontutf8.h b/Marlin/src/lcd/dogm/u8g_fontutf8.h index 5933f027cc79..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, wchar_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/README.md b/Marlin/src/lcd/e3v2/README.md index 10b05455fdaf..09055d03a492 100644 --- a/Marlin/src/lcd/e3v2/README.md +++ b/Marlin/src/lcd/e3v2/README.md @@ -1,6 +1,6 @@ -# DWIN for Creality Ender 3 v2 +# DWIN for Creality Ender-3 v2 -Marlin's Ender 3 v2 support requires the `DWIN_SET` included with the Ender 3 V2 [example configuration](https://github.com/MarlinFirmware/Configurations/tree/bugfix-2.0.x/config/examples/Creality/Ender-3%20V2). +Marlin's Ender-3 v2 support requires the `DWIN_SET` included with the Ender-3 V2 [example configuration](https://github.com/MarlinFirmware/Configurations/tree/bugfix-2.1.x/config/examples/Creality/Ender-3%20V2). ## Easy Install diff --git a/Marlin/src/lcd/e3v2/common/dwin_api.cpp b/Marlin/src/lcd/e3v2/common/dwin_api.cpp index 3f699465a9c8..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 DISABLED(DWIN_LCD_PROUI) + #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; @@ -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/common/dwin_font.h b/Marlin/src/lcd/e3v2/common/dwin_font.h index 5a4b1a61cf24..10bb104d27bc 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_font.h +++ b/Marlin/src/lcd/e3v2/common/dwin_font.h @@ -21,6 +21,8 @@ */ #pragma once +typedef uint8_t fontid_t; + /** * 3-.0:The font size, 0x00-0x09, corresponds to the font size below: * 0x00=6*12 0x01=8*16 0x02=10*20 0x03=12*24 0x04=14*28 diff --git a/Marlin/src/lcd/e3v2/common/encoder.cpp b/Marlin/src/lcd/e3v2/common/encoder.cpp index 9922b70b29df..5081e27690f2 100644 --- a/Marlin/src/lcd/e3v2/common/encoder.cpp +++ b/Marlin/src/lcd/e3v2/common/encoder.cpp @@ -36,7 +36,7 @@ #include "../../marlinui.h" #include "../../../HAL/shared/Delay.h" -#if HAS_BUZZER +#if HAS_SOUND #include "../../../libs/buzzer.h" #endif @@ -50,9 +50,7 @@ ENCODER_Rate EncoderRate; // TODO: Replace with ui.quick_feedback void Encoder_tick() { - #if PIN_EXISTS(BEEPER) - if (ui.sound_on) buzzer.click(10); - #endif + TERN_(HAS_BEEPER, if (ui.sound_on) buzzer.click(10)); } // Encoder initialization @@ -66,7 +64,7 @@ void Encoder_Configuration() { #if BUTTON_EXISTS(ENC) SET_INPUT_PULLUP(BTN_ENC); #endif - #if PIN_EXISTS(BEEPER) + #if HAS_BEEPER SET_OUTPUT(BEEPER_PIN); // TODO: Use buzzer.h which already inits this #endif } @@ -98,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/e3v2/creality/dwin.cpp b/Marlin/src/lcd/e3v2/creality/dwin.cpp index 3ca7627db086..8eda8ca4477c 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin.cpp @@ -2243,7 +2243,7 @@ void HMI_SelectFile() { card.openAndPrintFile(card.filename); #if HAS_FAN - // All fans on for Ender 3 v2 ? + // All fans on for Ender-3 v2 ? // The slicer should manage this for us. //for (uint8_t i = 0; i < FAN_COUNT; i++) // thermalManager.fan_speed[i] = 255; @@ -2625,15 +2625,13 @@ void Draw_HomeOff_Menu() { #include "../../../libs/buzzer.h" void HMI_AudioFeedback(const bool success=true) { - #if HAS_BUZZER - if (success) { - buzzer.tone(100, 659); - buzzer.tone(10, 0); - buzzer.tone(100, 698); - } - else - buzzer.tone(40, 440); - #endif + if (success) { + BUZZ(100, 659); + BUZZ(10, 0); + BUZZ(100, 698); + } + else + BUZZ(40, 440); } // Prepare @@ -3397,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/README.md b/Marlin/src/lcd/e3v2/jyersui/README.md index 10b05455fdaf..09055d03a492 100644 --- a/Marlin/src/lcd/e3v2/jyersui/README.md +++ b/Marlin/src/lcd/e3v2/jyersui/README.md @@ -1,6 +1,6 @@ -# DWIN for Creality Ender 3 v2 +# DWIN for Creality Ender-3 v2 -Marlin's Ender 3 v2 support requires the `DWIN_SET` included with the Ender 3 V2 [example configuration](https://github.com/MarlinFirmware/Configurations/tree/bugfix-2.0.x/config/examples/Creality/Ender-3%20V2). +Marlin's Ender-3 v2 support requires the `DWIN_SET` included with the Ender-3 V2 [example configuration](https://github.com/MarlinFirmware/Configurations/tree/bugfix-2.1.x/config/examples/Creality/Ender-3%20V2). ## Easy Install diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 19155fd5e55d..34985a54cbbf 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -80,6 +80,13 @@ #include "../../../feature/powerloss.h" #endif +#if HAS_TRINAMIC_CONFIG + #include "../../../module/stepper/trinamic.h" + + #define TMC_MIN_CURRENT 400 + #define TMC_MAX_CURRENT 1500 +#endif + #define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) #define DWIN_FONT_MENU font8x16 @@ -204,6 +211,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 { @@ -283,7 +339,7 @@ CrealityDWINClass CrealityDWIN; #endif - void manual_move(bool zmove=false) { + void manual_mesh_move(const bool zmove=false) { if (zmove) { planner.synchronize(); current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES; @@ -322,7 +378,7 @@ CrealityDWINClass CrealityDWIN; return min; } - void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7) { + void Draw_Bed_Mesh(const int16_t selected=-1, const uint8_t gridline_width=1, const uint16_t padding_x=8, const uint16_t padding_y_top=40 + 53 - 7) { drawing_mesh = true; const uint16_t total_width_px = DWIN_WIDTH - padding_x - padding_x, cell_width_px = total_width_px / (GRID_MAX_POINTS_X), @@ -415,15 +471,15 @@ constexpr const char * const CrealityDWINClass::preheat_modes[3]; // 3=Title bar and Menu area (default) // 2=Menu area // 1=Title bar -void CrealityDWINClass::Clear_Screen(uint8_t e/*=3*/) { +void CrealityDWINClass::Clear_Screen(const uint8_t e/*=3*/) { if (e == 1 || e == 3 || e == 4) DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.menu_top_bg, Color_Bg_Blue, false), 0, 0, DWIN_WIDTH, TITLE_HEIGHT); // Clear Title Bar if (e == 2 || e == 3) DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, STATUS_Y); // Clear Menu Area if (e == 4) DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, 31, DWIN_WIDTH, DWIN_HEIGHT); // Clear Popup Area } -void CrealityDWINClass::Draw_Float(float value, uint8_t row, bool selected/*=false*/, uint8_t minunit/*=10*/) { +void CrealityDWINClass::Draw_Float(const_float_t value, const uint8_t row, const bool selected/*=false*/, const uint8_t minunit/*=10*/) { const uint8_t digits = (uint8_t)floor(log10(abs(value))) + log10(minunit) + (minunit > 1); - const uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black; + const uint16_t bColor = selected ? Select_Color : Color_Bg_Black; const uint16_t xpos = 240 - (digits * 8); DWIN_Draw_Rectangle(1, Color_Bg_Black, 194, MBASE(row), 234 - (digits * 8), MBASE(row) + 16); if (isnan(value)) @@ -434,44 +490,44 @@ void CrealityDWINClass::Draw_Float(float value, uint8_t row, bool selected/*=fal } } -void CrealityDWINClass::Draw_Option(uint8_t value, const char * const * options, uint8_t row, bool selected/*=false*/, bool color/*=false*/) { - uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black, - tColor = (color) ? GetColor(value, Color_White, false) : Color_White; +void CrealityDWINClass::Draw_Option(const uint8_t value, const char * const * options, const uint8_t row, const bool selected/*=false*/, const bool color/*=false*/) { + const uint16_t bColor = selected ? Select_Color : Color_Bg_Black, + tColor = color ? GetColor(value, Color_White, false) : Color_White; DWIN_Draw_Rectangle(1, bColor, 202, MBASE(row) + 14, 258, MBASE(row) - 2); DWIN_Draw_String(false, DWIN_FONT_MENU, tColor, bColor, 202, MBASE(row) - 1, options[value]); } -uint16_t CrealityDWINClass::GetColor(uint8_t color, uint16_t original, bool light/*=false*/) { +uint16_t CrealityDWINClass::GetColor(const uint8_t color, const uint16_t original, const bool light/*=false*/) { switch (color) { case Default: return original; break; case White: - return (light) ? Color_Light_White : Color_White; + return light ? Color_Light_White : Color_White; break; case Green: - return (light) ? Color_Light_Green : Color_Green; + return light ? Color_Light_Green : Color_Green; break; case Cyan: - return (light) ? Color_Light_Cyan : Color_Cyan; + return light ? Color_Light_Cyan : Color_Cyan; break; case Blue: - return (light) ? Color_Light_Blue : Color_Blue; + return light ? Color_Light_Blue : Color_Blue; break; case Magenta: - return (light) ? Color_Light_Magenta : Color_Magenta; + return light ? Color_Light_Magenta : Color_Magenta; break; case Red: - return (light) ? Color_Light_Red : Color_Red; + return light ? Color_Light_Red : Color_Red; break; case Orange: - return (light) ? Color_Light_Orange : Color_Orange; + return light ? Color_Light_Orange : Color_Orange; break; case Yellow: - return (light) ? Color_Light_Yellow : Color_Yellow; + return light ? Color_Light_Yellow : Color_Yellow; break; case Brown: - return (light) ? Color_Light_Brown : Color_Brown; + return light ? Color_Light_Brown : Color_Brown; break; case Black: return Color_Black; @@ -480,7 +536,7 @@ uint16_t CrealityDWINClass::GetColor(uint8_t color, uint16_t original, bool ligh return Color_White; } -void CrealityDWINClass::Draw_Title(const char * ctitle) { +void CrealityDWINClass::Draw_Title(const char * const ctitle) { DWIN_Draw_String(false, DWIN_FONT_HEAD, GetColor(eeprom_settings.menu_top_txt, Color_White, false), Color_Bg_Blue, (DWIN_WIDTH - strlen(ctitle) * STAT_CHR_W) / 2, 5, ctitle); } void CrealityDWINClass::Draw_Title(FSTR_P const ftitle) { @@ -493,7 +549,7 @@ void _Decorate_Menu_Item(uint8_t row, uint8_t icon, bool more) { DWIN_Draw_Line(CrealityDWIN.GetColor(CrealityDWIN.eeprom_settings.menu_split_line, Line_Color, true), 16, MBASE(row) + 33, 256, MBASE(row) + 33); // Draw Menu Line } -void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, const char * label1, const char * label2, bool more/*=false*/, bool centered/*=false*/) { +void CrealityDWINClass::Draw_Menu_Item(const uint8_t row, const uint8_t icon/*=0*/, const char * const label1, const char * const label2, const bool more/*=false*/, const bool centered/*=false*/) { const uint8_t label_offset_y = (label1 || label2) ? MENU_CHR_H * 3 / 5 : 0, label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label1 ? strlen(label1) : 0) * MENU_CHR_W) / 2), label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label2 ? strlen(label2) : 0) * MENU_CHR_W) / 2); @@ -502,7 +558,7 @@ void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, const ch _Decorate_Menu_Item(row, icon, more); } -void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, FSTR_P const flabel1, FSTR_P const flabel2, bool more/*=false*/, bool centered/*=false*/) { +void CrealityDWINClass::Draw_Menu_Item(const uint8_t row, const uint8_t icon/*=0*/, FSTR_P const flabel1, FSTR_P const flabel2, const bool more/*=false*/, const bool centered/*=false*/) { const uint8_t label_offset_y = (flabel1 || flabel2) ? MENU_CHR_H * 3 / 5 : 0, label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (flabel1 ? strlen_P(FTOP(flabel1)) : 0) * MENU_CHR_W) / 2), label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (flabel2 ? strlen_P(FTOP(flabel2)) : 0) * MENU_CHR_W) / 2); @@ -511,7 +567,7 @@ void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, FSTR_P c _Decorate_Menu_Item(row, icon, more); } -void CrealityDWINClass::Draw_Checkbox(uint8_t row, bool value) { +void CrealityDWINClass::Draw_Checkbox(const uint8_t row, const bool value) { #if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS) // Draw appropriate checkbox icon DWIN_ICON_Show(ICON, (value ? ICON_Checkbox_T : ICON_Checkbox_F), 226, MBASE(row) - 3); #else // Draw a basic checkbox using rectangles and lines @@ -528,7 +584,7 @@ void CrealityDWINClass::Draw_Checkbox(uint8_t row, bool value) { #endif } -void CrealityDWINClass::Draw_Menu(uint8_t menu, uint8_t select/*=0*/, uint8_t scroll/*=0*/) { +void CrealityDWINClass::Draw_Menu(const uint8_t menu, const uint8_t select/*=0*/, const uint8_t scroll/*=0*/) { if (active_menu != menu) { last_menu = active_menu; if (process == Menu) last_selection = selection; @@ -545,12 +601,12 @@ void CrealityDWINClass::Draw_Menu(uint8_t menu, uint8_t select/*=0*/, uint8_t sc DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); } -void CrealityDWINClass::Redraw_Menu(bool lastprocess/*=true*/, bool lastselection/*=false*/, bool lastmenu/*=false*/) { - switch ((lastprocess) ? last_process : process) { +void CrealityDWINClass::Redraw_Menu(const bool lastproc/*=true*/, const bool lastsel/*=false*/, const bool lastmenu/*=false*/) { + switch (lastproc ? last_process : process) { case Menu: - Draw_Menu((lastmenu) ? last_menu : active_menu, (lastselection) ? last_selection : selection, (lastmenu) ? 0 : scrollpos); + Draw_Menu(lastmenu ? last_menu : active_menu, lastsel ? last_selection : selection, lastmenu ? 0 : scrollpos); break; - case Main: Draw_Main_Menu((lastselection) ? last_selection : selection); break; + case Main: Draw_Main_Menu(lastsel ? last_selection : selection); break; case Print: Draw_Print_Screen(); break; case File: Draw_SD_List(); break; default: break; @@ -616,7 +672,7 @@ void CrealityDWINClass::Main_Menu_Icons() { #endif } -void CrealityDWINClass::Draw_Main_Menu(uint8_t select/*=0*/) { +void CrealityDWINClass::Draw_Main_Menu(const uint8_t select/*=0*/) { process = Main; active_menu = MainMenu; selection = select; @@ -684,36 +740,18 @@ 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); } 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); @@ -728,7 +766,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(); @@ -766,7 +804,7 @@ void CrealityDWINClass::Draw_Print_confirm() { DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 85, 281, 188, 322); } -void CrealityDWINClass::Draw_SD_Item(uint8_t item, uint8_t row) { +void CrealityDWINClass::Draw_SD_Item(const uint8_t item, const uint8_t row) { if (item == 0) Draw_Menu_Item(0, ICON_Back, card.flag.workDirIsRoot ? F("Back") : F("..")); else { @@ -787,7 +825,7 @@ void CrealityDWINClass::Draw_SD_Item(uint8_t item, uint8_t row) { } } -void CrealityDWINClass::Draw_SD_List(bool removed/*=false*/) { +void CrealityDWINClass::Draw_SD_List(const bool removed/*=false*/) { Clear_Screen(); Draw_Title("Select File"); selection = 0; @@ -805,7 +843,7 @@ void CrealityDWINClass::Draw_SD_List(bool removed/*=false*/) { DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(0) - 18, 14, MBASE(0) + 33); } -void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) { +void CrealityDWINClass::Draw_Status_Area(const bool icons/*=false*/) { if (icons) DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, STATUS_Y, DWIN_WIDTH, DWIN_HEIGHT - 1); @@ -928,7 +966,7 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) { if ((update_z = axis_should_home(Z_AXIS) && ui.get_blink())) DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 205, 459, F(" -?- ")); else - DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 2, 205, 459, (current_position.z>=0) ? current_position.z : 0); + DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 2, 205, 459, current_position.z >= 0 ? current_position.z : 0); } DWIN_UpdateLCD(); } @@ -964,72 +1002,45 @@ void MarlinUI::kill_screen(FSTR_P const error, FSTR_P const) { } void CrealityDWINClass::Popup_Select() { - const uint16_t c1 = (selection == 0) ? GetColor(eeprom_settings.highlight_box, Color_White) : Color_Bg_Window, - c2 = (selection == 0) ? Color_Bg_Window : GetColor(eeprom_settings.highlight_box, Color_White); + const uint16_t c1 = selection ? Color_Bg_Window : GetColor(eeprom_settings.highlight_box, Color_White), + c2 = selection ? GetColor(eeprom_settings.highlight_box, Color_White) : Color_Bg_Window; DWIN_Draw_Rectangle(0, c1, 25, 279, 126, 318); DWIN_Draw_Rectangle(0, c1, 24, 278, 127, 319); DWIN_Draw_Rectangle(0, c2, 145, 279, 246, 318); DWIN_Draw_Rectangle(0, c2, 144, 278, 247, 319); } -void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) { +void CrealityDWINClass::Update_Status_Bar(const 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); - } - } } } /* Menu Item Config */ -void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/*=true*/) { +void CrealityDWINClass::Menu_Item_Handler(const uint8_t menu, const uint8_t item, bool draw/*=true*/) { const uint8_t row = item - scrollpos; #if HAS_LEVELING static bool level_state; @@ -1189,7 +1200,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(ADVANCED_PAUSE_FEATURE) case PREPARE_CHANGEFIL: if (draw) { - Draw_Menu_Item(row, ICON_ResumeEEPROM, F("Change Filament") + Draw_Menu_Item(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE) #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) , nullptr, true #endif @@ -1202,7 +1213,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -1345,7 +1356,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Popup_Handler(ETemp); } else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); Redraw_Menu(); @@ -1727,12 +1738,12 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case CHANGEFIL_LOAD: if (draw) - Draw_Menu_Item(row, ICON_WriteEEPROM, F("Load Filament")); + Draw_Menu_Item(row, ICON_WriteEEPROM, GET_TEXT_F(MSG_FILAMENTLOAD)); else { if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -1745,13 +1756,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case CHANGEFIL_UNLOAD: if (draw) - Draw_Menu_Item(row, ICON_ReadEEPROM, F("Unload Filament")); + Draw_Menu_Item(row, ICON_ReadEEPROM, GET_TEXT_F(MSG_FILAMENTUNLOAD)); else { if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) { Popup_Handler(ETemp); } else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -1764,12 +1775,12 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case CHANGEFIL_CHANGE: if (draw) - Draw_Menu_Item(row, ICON_ResumeEEPROM, F("Change Filament")); + Draw_Menu_Item(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE)); else { if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -2136,7 +2147,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); @@ -2144,7 +2155,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); @@ -2152,7 +2163,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); @@ -2203,7 +2214,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); @@ -2212,7 +2223,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); @@ -2220,7 +2231,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); @@ -2291,7 +2302,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Float(planner.flow_percentage[0], row, false, 1); } else - Modify_Value(planner.flow_percentage[0], MIN_FLOW_RATE, MAX_FLOW_RATE, 1); + Modify_Value(planner.flow_percentage[0], MIN_FLOW_RATE, MAX_FLOW_RATE, 1, []{ planner.refresh_e_factor(0); }); break; #endif } @@ -2461,35 +2472,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 } @@ -2716,7 +2727,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define ADVANCED_BACK 0 #define ADVANCED_BEEPER (ADVANCED_BACK + ENABLED(SOUND_MENU_ITEM)) #define ADVANCED_PROBE (ADVANCED_BEEPER + ENABLED(HAS_BED_PROBE)) - #define ADVANCED_CORNER (ADVANCED_PROBE + 1) + #define ADVANCED_TMC (ADVANCED_PROBE + ENABLED(HAS_TRINAMIC_CONFIG)) + #define ADVANCED_CORNER (ADVANCED_TMC + 1) #define ADVANCED_LA (ADVANCED_CORNER + ENABLED(LIN_ADVANCE)) #define ADVANCED_LOAD (ADVANCED_LA + ENABLED(ADVANCED_PAUSE_FEATURE)) #define ADVANCED_UNLOAD (ADVANCED_LOAD + ENABLED(ADVANCED_PAUSE_FEATURE)) @@ -2756,6 +2768,15 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; #endif + #if HAS_TRINAMIC_CONFIG + case ADVANCED_TMC: + if (draw) + Draw_Menu_Item(row, ICON_Motion, F("TMC Drivers"), nullptr, true); + else + Draw_Menu(TMCMenu); + break; + #endif + case ADVANCED_CORNER: if (draw) { Draw_Menu_Item(row, ICON_MaxAccelerated, F("Bed Screw Inset")); @@ -2768,7 +2789,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 @@ -2901,7 +2922,93 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; } break; - #endif + #endif // HAS_PROBE_MENU + + #if HAS_TRINAMIC_CONFIG + case TMCMenu: + + #define TMC_BACK 0 + #define TMC_STEPPER_CURRENT_X (TMC_BACK + AXIS_IS_TMC(X)) + #define TMC_STEPPER_CURRENT_Y (TMC_STEPPER_CURRENT_X + AXIS_IS_TMC(Y)) + #define TMC_STEPPER_CURRENT_Z (TMC_STEPPER_CURRENT_Y + AXIS_IS_TMC(Z)) + #define TMC_STEPPER_CURRENT_E (TMC_STEPPER_CURRENT_Z + AXIS_IS_TMC(E0)) + #define TMC_TOTAL TMC_STEPPER_CURRENT_E + + switch (item) { + + case TMC_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, F("Back")); + else + Draw_Menu(Advanced, ADVANCED_TMC); + break; + + #if AXIS_IS_TMC(X) + case TMC_STEPPER_CURRENT_X: + + static float stepper_current_x; + + if (draw) { + Draw_Menu_Item(row, ICON_StepX, F("Stepper X current")); + stepper_current_x = stepperX.getMilliamps(); + Draw_Float(stepper_current_x, row, false, 1); + } + else { + Modify_Value(stepper_current_x, TMC_MIN_CURRENT, TMC_MAX_CURRENT, 1, []{ stepperX.rms_current(stepper_current_x); }); + } + break; + #endif + + #if AXIS_IS_TMC(Y) + case TMC_STEPPER_CURRENT_Y: + + static float stepper_current_y; + + if (draw) { + Draw_Menu_Item(row, ICON_StepY, F("Stepper Y current")); + stepper_current_y = stepperY.getMilliamps(); + Draw_Float(stepper_current_y, row, false, 1); + } + else { + Modify_Value(stepper_current_y, TMC_MIN_CURRENT, TMC_MAX_CURRENT, 1, []{ stepperY.rms_current(stepper_current_y); }); + } + break; + #endif + + #if AXIS_IS_TMC(Z) + case TMC_STEPPER_CURRENT_Z: + + static float stepper_current_z; + + if (draw) { + Draw_Menu_Item(row, ICON_StepZ, F("Stepper Z current")); + stepper_current_z = stepperZ.getMilliamps(); + Draw_Float(stepper_current_z, row, false, 1); + } + else { + Modify_Value(stepper_current_z, TMC_MIN_CURRENT, TMC_MAX_CURRENT, 1, []{ stepperZ.rms_current(stepper_current_z); }); + } + break; + #endif + + #if AXIS_IS_TMC(E0) + case TMC_STEPPER_CURRENT_E: + + static float stepper_current_e; + + if (draw) { + Draw_Menu_Item(row, ICON_StepE, F("Stepper E current")); + stepper_current_e = stepperE0.getMilliamps(); + Draw_Float(stepper_current_e, row, false, 1); + } + else { + Modify_Value(stepper_current_e, TMC_MIN_CURRENT, TMC_MAX_CURRENT, 1, []{ stepperE0.rms_current(stepper_current_e); }); + } + break; + #endif + }; + break; + #endif // HAS_TRINAMIC_CONFIG case InfoMain: case Info: @@ -3035,7 +3142,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ mesh_conf.goto_mesh_value = true; mesh_conf.mesh_x = mesh_conf.mesh_y = 0; Popup_Handler(MoveWait); - mesh_conf.manual_move(); + mesh_conf.manual_mesh_move(); Draw_Menu(UBLMesh); #endif #elif HAS_BED_PROBE @@ -3091,7 +3198,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ TERN_(HAS_HEATED_BED, thermalManager.wait_for_bed_heating()); #endif Popup_Handler(MoveWait); - mesh_conf.manual_move(); + mesh_conf.manual_mesh_move(); Draw_Menu(LevelManual); } break; @@ -3328,7 +3435,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ mesh_conf.mesh_x++; else mesh_conf.mesh_x--; - mesh_conf.manual_move(); + mesh_conf.manual_mesh_move(); } } break; @@ -3375,7 +3482,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ else { mesh_conf.goto_mesh_value = !mesh_conf.goto_mesh_value; current_position.z = 0; - mesh_conf.manual_move(true); + mesh_conf.manual_mesh_move(true); Draw_Checkbox(row, mesh_conf.goto_mesh_value); } break; @@ -3428,7 +3535,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ mesh_conf.mesh_x++; else mesh_conf.mesh_x--; - mesh_conf.manual_move(); + mesh_conf.manual_mesh_move(); } else { gcode.process_subcommands_now(F("G29 S")); @@ -3449,7 +3556,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ mesh_conf.mesh_x--; else mesh_conf.mesh_x++; - mesh_conf.manual_move(); + mesh_conf.manual_mesh_move(); } } break; @@ -3633,7 +3740,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Float(planner.flow_percentage[0], row, false, 1); } else - Modify_Value(planner.flow_percentage[0], MIN_FLOW_RATE, MAX_FLOW_RATE, 1); + Modify_Value(planner.flow_percentage[0], MIN_FLOW_RATE, MAX_FLOW_RATE, 1, []{ planner.refresh_e_factor(0); }); break; case TUNE_HOTEND: if (draw) { @@ -3699,7 +3806,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) case TUNE_CHANGEFIL: if (draw) - Draw_Menu_Item(row, ICON_ResumeEEPROM, F("Change Filament")); + Draw_Menu_Item(row, ICON_ResumeEEPROM, GET_TEXT_F(MSG_FILAMENTCHANGE)); else Popup_Handler(ConfFilChange); break; @@ -3755,7 +3862,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu_Item(row, ICON_Back, F("Cancel")); else { thermalManager.setTargetHotend(0, 0); - thermalManager.set_fan_speed(0, 0); + TERN_(HAS_FAN, thermalManager.set_fan_speed(0, 0)); Redraw_Menu(false, true, true); } break; @@ -3825,32 +3932,32 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } } -FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) { +FSTR_P CrealityDWINClass::Get_Menu_Title(const uint8_t menu) { switch (menu) { - case MainMenu: return F("Main Menu"); - case Prepare: return F("Prepare"); + case MainMenu: return GET_TEXT_F(MSG_MAIN_MENU); + case Prepare: return GET_TEXT_F(MSG_PREPARE); case HomeMenu: return F("Homing Menu"); - case Move: return F("Move"); - case ManualLevel: return F("Manual Leveling"); + case Move: return GET_TEXT_F(MSG_MOVE_AXIS); + case ManualLevel: return GET_TEXT_F(MSG_BED_TRAMMING_MANUAL); #if HAS_ZOFFSET_ITEM - case ZOffset: return F("Z Offset"); + case ZOffset: return GET_TEXT_F(MSG_ZPROBE_ZOFFSET); #endif #if HAS_PREHEAT case Preheat: return F("Preheat"); #endif #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - case ChangeFilament: return F("Change Filament"); + case ChangeFilament: return GET_TEXT_F(MSG_FILAMENTCHANGE); #endif #if HAS_CUSTOM_MENU case MenuCustom: #ifdef CUSTOM_MENU_CONFIG_TITLE return F(CUSTOM_MENU_CONFIG_TITLE); #else - return F("Custom Commands"); + return GET_TEXT_F(MSG_CUSTOM_COMMANDS); #endif #endif - case Control: return F("Control"); - case TempMenu: return F("Temperature"); + case Control: return GET_TEXT_F(MSG_CONTROL); + case TempMenu: return GET_TEXT_F(MSG_TEMPERATURE); #if HAS_HOTEND || HAS_HEATED_BED case PID: return F("PID Menu"); #endif @@ -3871,11 +3978,14 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) { #if HAS_CLASSIC_JERK case MaxJerk: return F("Max Jerk"); #endif - case Steps: return F("Steps/mm"); + case Steps: return GET_TEXT_F(MSG_STEPS_PER_MM); case Visual: return F("Visual Settings"); - case Advanced: return F("Advanced Settings"); + case Advanced: return GET_TEXT_F(MSG_ADVANCED_SETTINGS); #if HAS_BED_PROBE - case ProbeMenu: return F("Probe Menu"); + case ProbeMenu: return F("Bed Probe"); + #endif + #if HAS_TRINAMIC_CONFIG + case TMCMenu: return GET_TEXT_F(MSG_TMC_DRIVERS); #endif case ColorSettings: return F("UI Color Settings"); case Info: return F("Info"); @@ -3891,15 +4001,15 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) { case UBLMesh: return F("UBL Bed Leveling"); #endif #if ENABLED(PROBE_MANUALLY) - case ManualMesh: return F("Mesh Bed Leveling"); + case ManualMesh: return GET_TEXT_F(MSG_MANUAL_LEVELING); #endif - case Tune: return F("Tune"); - case PreheatHotend: return F("Preheat Hotend"); + case Tune: return GET_TEXT_F(MSG_TUNE); + case PreheatHotend: return GET_TEXT_F(MSG_PREHEAT_HOTEND); } return F(""); } -uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) { +uint8_t CrealityDWINClass::Get_Menu_Size(const uint8_t menu) { switch (menu) { case Prepare: return PREPARE_TOTAL; case HomeMenu: return HOME_TOTAL; @@ -3945,6 +4055,9 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) { #if HAS_BED_PROBE case ProbeMenu: return PROBE_TOTAL; #endif + #if HAS_TRINAMIC_CONFIG + case TMCMenu: return TMC_TOTAL; + #endif case Info: return INFO_TOTAL; case InfoMain: return INFO_TOTAL; #if ENABLED(AUTO_BED_LEVELING_UBL) && !HAS_BED_PROBE @@ -3973,7 +4086,7 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) { /* Popup Config */ -void CrealityDWINClass::Popup_Handler(PopupID popupid, bool option/*=false*/) { +void CrealityDWINClass::Popup_Handler(const PopupID popupid, const bool option/*=false*/) { popup = last_popup = popupid; switch (popupid) { case Pause: Draw_Popup(F("Pause Print"), F(""), F(""), Popup); break; @@ -4109,17 +4222,14 @@ void CrealityDWINClass::Value_Control() { planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); planner.synchronize(); break; - case UBLMesh: mesh_conf.manual_move(true); break; - case LevelManual: mesh_conf.manual_move(selection == LEVELING_M_OFFSET); break; + case UBLMesh: mesh_conf.manual_mesh_move(true); break; + case LevelManual: mesh_conf.manual_mesh_move(selection == LEVELING_M_OFFSET); break; #endif } - if (valuepointer == &planner.flow_percentage[0]) - planner.refresh_e_factor(0); if (funcpointer) funcpointer(); return; } - NOLESS(tempvalue, (valuemin * valueunit)); - NOMORE(tempvalue, (valuemax * valueunit)); + LIMIT(tempvalue, valuemin * valueunit, valuemax * valueunit); Draw_Float(tempvalue / valueunit, selection - scrollpos, true, valueunit); DWIN_UpdateLCD(); if (active_menu == Move && livemove) { @@ -4161,42 +4271,31 @@ void CrealityDWINClass::Option_Control() { DWIN_UpdateLCD(); return; } - NOLESS(tempvalue, valuemin); - NOMORE(tempvalue, valuemax); + LIMIT(tempvalue, valuemin, valuemax); Draw_Option(tempvalue, static_cast(valuepointer), selection - scrollpos, true); DWIN_UpdateLCD(); } 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 +4307,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 +4320,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--; @@ -4375,7 +4474,7 @@ void CrealityDWINClass::Popup_Control() { case ETemp: if (selection == 0) { thermalManager.setTargetHotend(EXTRUDE_MINTEMP, 0); - thermalManager.set_fan_speed(0, MAX_FAN_SPEED); + TERN_(HAS_FAN, thermalManager.set_fan_speed(0, MAX_FAN_SPEED)); Draw_Menu(PreheatHotend); } else @@ -4404,7 +4503,7 @@ void CrealityDWINClass::Popup_Control() { if (thermalManager.temp_hotend[0].target < thermalManager.extrude_min_temp) Popup_Handler(ETemp); else { - if (thermalManager.temp_hotend[0].celsius < thermalManager.temp_hotend[0].target - 2) { + if (thermalManager.temp_hotend[0].is_below_target(2)) { Popup_Handler(Heating); thermalManager.wait_for_hotend(0); } @@ -4424,7 +4523,7 @@ void CrealityDWINClass::Popup_Control() { else { pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; if (printing) Popup_Handler(Resuming); - else Redraw_Menu(true, true, (active_menu==PreheatHotend)); + else Redraw_Menu(true, true, active_menu == PreheatHotend); } break; #endif // ADVANCED_PAUSE_FEATURE @@ -4483,7 +4582,7 @@ void CrealityDWINClass::Confirm_Control() { /* In-Menu Value Modification */ -void CrealityDWINClass::Setup_Value(float value, float min, float max, float unit, uint8_t type) { +void CrealityDWINClass::Setup_Value(const_float_t value, const_float_t min, const_float_t max, const_float_t unit, const uint8_t type) { if (TERN0(HAS_HOTEND, valuepointer == &thermalManager.temp_hotend[0].pid.Ki) || TERN0(HAS_HEATED_BED, valuepointer == &thermalManager.temp_bed.pid.Ki)) tempvalue = unscalePID_i(value) * unit; else if (TERN0(HAS_HOTEND, valuepointer == &thermalManager.temp_hotend[0].pid.Kd) || TERN0(HAS_HEATED_BED, valuepointer == &thermalManager.temp_bed.pid.Kd)) @@ -4499,38 +4598,38 @@ void CrealityDWINClass::Setup_Value(float value, float min, float max, float uni Draw_Float(tempvalue / unit, selection - scrollpos, true, valueunit); } -void CrealityDWINClass::Modify_Value(float &value, float min, float max, float unit, void (*f)()/*=nullptr*/) { +void CrealityDWINClass::Modify_Value(float &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()/*=nullptr*/) { valuepointer = &value; funcpointer = f; Setup_Value((float)value, min, max, unit, 0); } -void CrealityDWINClass::Modify_Value(uint8_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) { +void CrealityDWINClass::Modify_Value(uint8_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()/*=nullptr*/) { valuepointer = &value; funcpointer = f; Setup_Value((float)value, min, max, unit, 1); } -void CrealityDWINClass::Modify_Value(uint16_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) { +void CrealityDWINClass::Modify_Value(uint16_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()/*=nullptr*/) { valuepointer = &value; funcpointer = f; Setup_Value((float)value, min, max, unit, 2); } -void CrealityDWINClass::Modify_Value(int16_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) { +void CrealityDWINClass::Modify_Value(int16_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()/*=nullptr*/) { valuepointer = &value; funcpointer = f; Setup_Value((float)value, min, max, unit, 3); } -void CrealityDWINClass::Modify_Value(uint32_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) { +void CrealityDWINClass::Modify_Value(uint32_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()/*=nullptr*/) { valuepointer = &value; funcpointer = f; Setup_Value((float)value, min, max, unit, 4); } -void CrealityDWINClass::Modify_Value(int8_t &value, float min, float max, float unit, void (*f)()/*=nullptr*/) { +void CrealityDWINClass::Modify_Value(int8_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()/*=nullptr*/) { valuepointer = &value; funcpointer = f; Setup_Value((float)value, min, max, unit, 5); } -void CrealityDWINClass::Modify_Option(uint8_t value, const char * const * options, uint8_t max) { +void CrealityDWINClass::Modify_Option(const uint8_t value, const char * const * options, const uint8_t max) { tempvalue = value; valuepointer = const_cast(options); valuemin = 0; @@ -4554,7 +4653,7 @@ void CrealityDWINClass::Update_Status(const char * const text) { } } -void CrealityDWINClass::Start_Print(bool sd) { +void CrealityDWINClass::Start_Print(const bool sd) { sdprint = sd; if (!printing) { printing = true; @@ -4562,7 +4661,7 @@ void CrealityDWINClass::Start_Print(bool sd) { if (sd) { #if ENABLED(POWER_LOSS_RECOVERY) if (recovery.valid()) { - SdFile *diveDir = nullptr; + MediaFile *diveDir = nullptr; const char * const fname = card.diveToFile(true, diveDir, recovery.info.sd_filename); card.selectFileByName(fname); } @@ -4571,8 +4670,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(); } } @@ -4581,8 +4680,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(); } @@ -4625,7 +4724,7 @@ void CrealityDWINClass::State_Update() { Popup_Handler(FilChange); else if (pause_menu_response == PAUSE_RESPONSE_RESUME_PRINT) { if (printing) Popup_Handler(Resuming); - else Redraw_Menu(true, true, (active_menu==PreheatHotend)); + else Redraw_Menu(true, true, active_menu == PreheatHotend); } } #endif @@ -4659,7 +4758,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()); } } @@ -4771,13 +4870,13 @@ void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) { Update_Status(success ? "Success" : "Failed"); } -void CrealityDWINClass::Save_Settings(char *buff) { +void CrealityDWINClass::Save_Settings(char * const buff) { TERN_(AUTO_BED_LEVELING_UBL, eeprom_settings.tilt_grid_size = mesh_conf.tilt_grid - 1); eeprom_settings.corner_pos = corner_pos * 10; memcpy(buff, &eeprom_settings, _MIN(sizeof(eeprom_settings), eeprom_data_size)); } -void CrealityDWINClass::Load_Settings(const char *buff) { +void CrealityDWINClass::Load_Settings(const char * const buff) { memcpy(&eeprom_settings, buff, _MIN(sizeof(eeprom_settings), eeprom_data_size)); TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1); if (eeprom_settings.corner_pos == 0) eeprom_settings.corner_pos = 325; diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.h b/Marlin/src/lcd/e3v2/jyersui/dwin.h index 8985647cd131..71db445aa869 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.h +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.h @@ -75,6 +75,9 @@ enum menuID : uint8_t { ColorSettings, Advanced, ProbeMenu, + #if HAS_TRINAMIC_CONFIG + TMCMenu, + #endif Info, Leveling, LevelManual, @@ -169,17 +172,17 @@ class CrealityDWINClass { static constexpr const char * const color_names[11] = { "Default", "White", "Green", "Cyan", "Blue", "Magenta", "Red", "Orange", "Yellow", "Brown", "Black" }; static constexpr const char * const preheat_modes[3] = { "Both", "Hotend", "Bed" }; - static void Clear_Screen(uint8_t e=3); - static void Draw_Float(float value, uint8_t row, bool selected=false, uint8_t minunit=10); - static void Draw_Option(uint8_t value, const char * const * options, uint8_t row, bool selected=false, bool color=false); - static uint16_t GetColor(uint8_t color, uint16_t original, bool light=false); - static void Draw_Checkbox(uint8_t row, bool value); - static void Draw_Title(const char * title); + static void Clear_Screen(const uint8_t e=3); + static void Draw_Float(const_float_t value, const uint8_t row, const bool selected=false, const uint8_t minunit=10); + static void Draw_Option(const uint8_t value, const char * const * options, const uint8_t row, const bool selected=false, const bool color=false); + static uint16_t GetColor(const uint8_t color, const uint16_t original, const bool light=false); + static void Draw_Checkbox(const uint8_t row, const bool value); + static void Draw_Title(const char * const title); static void Draw_Title(FSTR_P const title); - static void Draw_Menu_Item(uint8_t row, uint8_t icon=0, const char * const label1=nullptr, const char * const label2=nullptr, bool more=false, bool centered=false); - static void Draw_Menu_Item(uint8_t row, uint8_t icon=0, FSTR_P const flabel1=nullptr, FSTR_P const flabel2=nullptr, bool more=false, bool centered=false); - static void Draw_Menu(uint8_t menu, uint8_t select=0, uint8_t scroll=0); - static void Redraw_Menu(bool lastprocess=true, bool lastselection=false, bool lastmenu=false); + static void Draw_Menu_Item(const uint8_t row, uint8_t icon=0, const char * const label1=nullptr, const char * const label2=nullptr, const bool more=false, const bool centered=false); + static void Draw_Menu_Item(const uint8_t row, uint8_t icon=0, FSTR_P const flabel1=nullptr, FSTR_P const flabel2=nullptr, const bool more=false, const bool centered=false); + static void Draw_Menu(const uint8_t menu, const uint8_t select=0, const uint8_t scroll=0); + static void Redraw_Menu(const bool lastproc=true, const bool lastsel=false, const bool lastmenu=false); static void Redraw_Screen(); static void Main_Menu_Icons(); @@ -188,29 +191,28 @@ 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(); static void Draw_Print_confirm(); - static void Draw_SD_Item(uint8_t item, uint8_t row); - static void Draw_SD_List(bool removed=false); - static void Draw_Status_Area(bool icons=false); + static void Draw_SD_Item(const uint8_t item, const uint8_t row); + static void Draw_SD_List(const bool removed=false); + static void Draw_Status_Area(const bool icons=false); static void Draw_Popup(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, uint8_t mode, uint8_t icon=0); static void Popup_Select(); - static void Update_Status_Bar(bool refresh=false); + static void Update_Status_Bar(const bool refresh=false); - #if ENABLED(AUTO_BED_LEVELING_UBL) - static void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7); + #if HAS_MESH static void Set_Mesh_Viewer_Status(); #endif - static FSTR_P Get_Menu_Title(uint8_t menu); - static uint8_t Get_Menu_Size(uint8_t menu); - static void Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw=true); + static FSTR_P Get_Menu_Title(const uint8_t menu); + static uint8_t Get_Menu_Size(const uint8_t menu); + static void Menu_Item_Handler(const uint8_t menu, const uint8_t item, bool draw=true); - static void Popup_Handler(PopupID popupid, bool option = false); - static void Confirm_Handler(PopupID popupid); + static void Popup_Handler(const PopupID popupid, bool option=false); + static void Confirm_Handler(const PopupID popupid); static void Main_Menu_Control(); static void Menu_Control(); @@ -221,24 +223,24 @@ class CrealityDWINClass { static void Popup_Control(); static void Confirm_Control(); - static void Setup_Value(float value, float min, float max, float unit, uint8_t type); - static void Modify_Value(float &value, float min, float max, float unit, void (*f)()=nullptr); - static void Modify_Value(uint8_t &value, float min, float max, float unit, void (*f)()=nullptr); - static void Modify_Value(uint16_t &value, float min, float max, float unit, void (*f)()=nullptr); - static void Modify_Value(int16_t &value, float min, float max, float unit, void (*f)()=nullptr); - static void Modify_Value(uint32_t &value, float min, float max, float unit, void (*f)()=nullptr); - static void Modify_Value(int8_t &value, float min, float max, float unit, void (*f)()=nullptr); - static void Modify_Option(uint8_t value, const char * const * options, uint8_t max); + static void Setup_Value(const_float_t value, const_float_t min, const_float_t max, const_float_t unit, const uint8_t type); + static void Modify_Value(float &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()=nullptr); + static void Modify_Value(uint8_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()=nullptr); + static void Modify_Value(uint16_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()=nullptr); + static void Modify_Value(int16_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()=nullptr); + static void Modify_Value(uint32_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()=nullptr); + static void Modify_Value(int8_t &value, const_float_t min, const_float_t max, const_float_t unit, void (*f)()=nullptr); + static void Modify_Option(const uint8_t value, const char * const * options, const uint8_t max); static void Update_Status(const char * const text); - static void Start_Print(bool sd); + static void Start_Print(const bool sd); static void Stop_Print(); static void Update(); static void State_Update(); static void Screen_Update(); static void AudioFeedback(const bool success=true); - static void Save_Settings(char *buff); - static void Load_Settings(const char *buff); + static void Save_Settings(char * const buff); + static void Load_Settings(const char * const buff); static void Reset_Settings(); }; diff --git a/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp b/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp index 30e86270c726..38a8eafe2366 100644 --- a/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp @@ -50,12 +50,12 @@ uint8_t read_byte(const uint8_t *byte) { return *byte; } * @ displays an axis name such as XYZUVW, or E for an extruder */ void DWIN_String::add(const char *tpl, const int8_t index, const char *cstr/*=nullptr*/, FSTR_P const fstr/*=nullptr*/) { - wchar_t wchar; + lchar_t wc; while (*tpl) { - tpl = get_utf8_value_cb(tpl, read_byte, &wchar); - if (wchar > 255) wchar |= 0x0080; - const uint8_t ch = uint8_t(wchar & 0x00FF); + tpl = get_utf8_value_cb(tpl, read_byte, wc); + if (wc > 255) wc |= 0x0080; + const uint8_t ch = uint8_t(wc & 0x00FF); if (ch == '=' || ch == '~' || ch == '*') { if (index >= 0) { @@ -80,32 +80,32 @@ void DWIN_String::add(const char *tpl, const int8_t index, const char *cstr/*=nu } void DWIN_String::add(const char *cstr, uint8_t max_len/*=MAX_STRING_LENGTH*/) { - wchar_t wchar; + lchar_t wc; while (*cstr && max_len) { - cstr = get_utf8_value_cb(cstr, read_byte, &wchar); + cstr = get_utf8_value_cb(cstr, read_byte, wc); /* - if (wchar > 255) wchar |= 0x0080; - uint8_t ch = uint8_t(wchar & 0x00FF); + if (wc > 255) wc |= 0x0080; + const uint8_t ch = uint8_t(wc & 0x00FF); add_character(ch); */ - add(wchar); + add(wc); max_len--; } eol(); } -void DWIN_String::add(const wchar_t character) { +void DWIN_String::add(const lchar_t &wc) { int ret; size_t idx = 0; dwin_charmap_t pinval; dwin_charmap_t *copy_address = nullptr; - pinval.uchar = character; + pinval.uchar = wc; pinval.idx = -1; // For 8-bit ASCII just print the single character char str[] = { '?', 0 }; - if (character < 255) { - str[0] = (char)character; + if (wc < 255) { + str[0] = (char)wc; } else { copy_address = nullptr; diff --git a/Marlin/src/lcd/e3v2/marlinui/dwin_string.h b/Marlin/src/lcd/e3v2/marlinui/dwin_string.h index c29777ae7b12..686b1aa2b17a 100644 --- a/Marlin/src/lcd/e3v2/marlinui/dwin_string.h +++ b/Marlin/src/lcd/e3v2/marlinui/dwin_string.h @@ -29,7 +29,7 @@ #include typedef struct _dwin_charmap_t { - wchar_t uchar; // the unicode char + lchar_t uchar; // the unicode char uint8_t idx; // the glyph of the char in the ROM uint8_t idx2; // the char used to be combined with the idx to simulate a single char } dwin_charmap_t; @@ -69,10 +69,10 @@ class DWIN_String { /** * @brief Append a UTF-8 character * - * @param character The UTF-8 character + * @param wc The UTF-8 character */ - static void add(wchar_t character); - static void set(wchar_t character) { set(); add(character); } + static void add(const lchar_t &wc); + static void set(const lchar_t &wc) { set(); add(wc); } /** * @brief Append / Set C-string diff --git a/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp b/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp index 278f17fac994..e603882e0cfd 100644 --- a/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp @@ -63,7 +63,7 @@ int lcd_put_dwin_string() { // return < 0 on error // return the advanced cols -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length) { dwin_string.set(c); dwin_string.truncate(max_length); // Draw the char(s) at the cursor and advance the cursor @@ -87,10 +87,10 @@ static int lcd_put_u8str_max_cb(const char * utf8_str, read_byte_cb_t cb_read_by const uint8_t *p = (uint8_t *)utf8_str; dwin_string.set(); while (dwin_string.length < max_length) { - wchar_t ch = 0; - p = get_utf8_value_cb(p, cb_read_byte, &ch); - if (!ch) break; - dwin_string.add(ch); + lchar_t wc; + p = get_utf8_value_cb(p, cb_read_byte, wc); + if (!wc) break; + dwin_string.add(wc); } DWIN_Draw_String(dwin_font.solid, dwin_font.index, dwin_font.fg, dwin_font.bg, cursor.x, cursor.y, dwin_string.string()); lcd_advance_cursor(dwin_string.length); diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp index ce1758f1da64..e822371c0df1 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp @@ -195,7 +195,7 @@ void MarlinUI::draw_status_message(const bool blink) { } const bool hash_changed = hash != old_hash; old_hash = hash; - return hash_changed || !ui.did_first_redraw; + return hash_changed || !did_first_redraw; }; #if ENABLED(STATUS_MESSAGE_SCROLLING) @@ -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_wchar(' '); ++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_wchar('.'); // 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_wchar('.'); + 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_wchar(' '); ++slen; } + while (slen < max_status_chars) { lcd_put_u8str(F(" ")); ++slen; } } #endif @@ -410,8 +410,7 @@ void MarlinUI::draw_status_message(const bool blink) { const dwin_coord_t by = (row * MENU_LINE_HEIGHT) + MENU_FONT_HEIGHT + EXTRA_ROW_HEIGHT / 2; DWIN_Draw_String(true, font16x32, Color_Yellow, Color_Bg_Black, (LCD_PIXEL_WIDTH - vallen * 16) / 2, by, S(dwin_string.string())); - extern screenFunc_t _manual_move_func_ptr; - if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) { + if (ui.can_show_slider()) { const dwin_coord_t slider_length = LCD_PIXEL_WIDTH - TERN(DWIN_MARLINUI_LANDSCAPE, 120, 20), slider_height = 16, @@ -566,7 +565,7 @@ void MarlinUI::draw_status_message(const bool blink) { #endif // AUTO_BED_LEVELING_UBL - #if ANY(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY) + #if EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY) void MarlinUI::zoffset_overlay(const int8_t dir) { const int rot_up = TERN(OVERLAY_GFX_REVERSE, ICON_RotateCCW, ICON_RotateCW), diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp index 8024085ef734..5ec94b853f10 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp @@ -61,77 +61,60 @@ #define STATUS_CHR_WIDTH 14 #define STATUS_CHR_HEIGHT 28 +bool old_is_printing; + // // Before homing, blink '123' <-> '???'. // Homed but unknown... '123' <-> ' '. // Homed and known, display constantly. // -FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink, const uint16_t x, const uint16_t y) { - - #if ENABLED(DWIN_MARLINUI_PORTRAIT) - - uint8_t vallen = utf8_strlen(value); - if (!ui.did_first_redraw) { - dwin_string.set('X' + axis); - DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x + (vallen * 14 - 14) / 2, y + 2, S(dwin_string.string())); - } - - dwin_string.set(); - if (blink) - dwin_string.add(value); - else if (!TEST(axes_homed, axis)) - while (const char c = *value++) dwin_string.add(c <= '.' ? c : '?'); - else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !TEST(axes_trusted, axis)) - dwin_string.add(TERN1(DWIN_MARLINUI_PORTRAIT, axis == Z_AXIS) ? PSTR(" ") : PSTR(" ")); - else - dwin_string.add(value); - - // For E_TOTAL there may be some characters to cover up - if (BOTH(DWIN_MARLINUI_PORTRAIT, LCD_SHOW_E_TOTAL) && axis == X_AXIS) - dwin_string.add(F(" ")); - - DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + 32, S(dwin_string.string())); - - #else // !DWIN_MARLINUI_PORTRAIT - - if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) { - dwin_string.set('X' + axis); - DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x, y, S(dwin_string.string())); - } - - dwin_string.set(); - if (blink) - dwin_string.add(value); - else { - if (!TEST(axes_homed, axis)) - while (const char c = *value++) dwin_string.add(c <= '.' ? c : '?'); - else { - #if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) - if (!TEST(axes_trusted, axis)) - dwin_string.add(TERN1(DWIN_MARLINUI_PORTRAIT, axis == Z_AXIS) ? PSTR(" ") : PSTR(" ")); - else - #endif - dwin_string.add(value); - } - } - - // For E_TOTAL there may be some characters to cover up - if (ENABLED(LCD_SHOW_E_TOTAL) && (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) && axis == X_AXIS) - dwin_string.add(F(" ")); - - DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x + 32, y + 4, S(dwin_string.string())); +void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink, const uint16_t x, const uint16_t y) { + const bool x_redraw = !ui.did_first_redraw || old_is_printing != print_job_timer.isRunning(); + if (x_redraw) { + dwin_string.set('X' + axis); + DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, + #if ENABLED(DWIN_MARLINUI_PORTRAIT) + x + (utf8_strlen(value) * 14 - 14) / 2, y + 2 + #else + x, y + #endif + , S(dwin_string.string()) + ); + } - #endif // !DWIN_MARLINUI_PORTRAIT + dwin_string.set(); + if (blink) + dwin_string.add(value); + else if (!TEST(axes_homed, axis)) + while (const char c = *value++) dwin_string.add(c <= '.' ? c : '?'); + else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !TEST(axes_trusted, axis)) + dwin_string.add(TERN1(DWIN_MARLINUI_PORTRAIT, axis == Z_AXIS) ? PSTR(" ") : PSTR(" ")); + else + dwin_string.add(value); + + // For E_TOTAL there may be some characters to cover up + if (TERN0(LCD_SHOW_E_TOTAL, x_redraw && axis == X_AXIS)) + dwin_string.add(F(" ")); + + DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, + #if ENABLED(DWIN_MARLINUI_PORTRAIT) + x, y + 32 + #else + x + 32, y + 4 + #endif + , S(dwin_string.string()) + ); } #if ENABLED(LCD_SHOW_E_TOTAL) - FORCE_INLINE void _draw_e_value(const_float_t value, const uint16_t x, const uint16_t y) { + void _draw_e_value(const_float_t value, const uint16_t x, const uint16_t y) { const uint8_t scale = value >= 100000.0f ? 10 : 1; // show cm after 99,999mm + const bool e_redraw = !ui.did_first_redraw || old_is_printing != print_job_timer.isRunning(); #if ENABLED(DWIN_MARLINUI_PORTRAIT) - if (!ui.did_first_redraw) { + if (e_redraw) { // Extra spaces to erase previous value dwin_string.set(F("E ")); DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x + (4 * 14 / 2) - 7, y + 2, S(dwin_string.string())); @@ -145,7 +128,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #else // !DWIN_MARLINUI_PORTRAIT - if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) { + if (e_redraw) { dwin_string.set(F("E ")); DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x, y, S(dwin_string.string())); } @@ -160,26 +143,27 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #endif // LCD_SHOW_E_TOTAL -// -// Fan Icon and Percentage -// -FORCE_INLINE void _draw_fan_status(const uint16_t x, const uint16_t y) { - const uint16_t fanx = (4 * STATUS_CHR_WIDTH - STATUS_FAN_WIDTH) / 2; - const uint8_t fan_pct = thermalManager.scaledFanSpeedPercent(0); - const bool fan_on = !!fan_pct; - if (fan_on) { - DWIN_ICON_Animation(0, fan_on, ICON, ICON_Fan0, ICON_Fan3, x + fanx, y, 25); - dwin_string.set(i8tostr3rj(fan_pct)); - dwin_string.add('%'); - DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + STATUS_FAN_HEIGHT, S(dwin_string.string())); - } - else { - DWIN_ICON_AnimationControl(0x0000); // disable all icon animations (this is the only one) - DWIN_ICON_Show(ICON, ICON_Fan0, x + fanx, y); - dwin_string.set(F(" ")); - DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + STATUS_FAN_HEIGHT, S(dwin_string.string())); +#if HAS_FAN + // + // Fan Icon and Percentage + // + FORCE_INLINE void _draw_fan_status(const uint16_t x, const uint16_t y) { + const uint16_t fanx = (4 * STATUS_CHR_WIDTH - STATUS_FAN_WIDTH) / 2; + const bool fan_on = !!thermalManager.scaledFanSpeed(0); + if (fan_on) { + DWIN_ICON_Animation(0, fan_on, ICON, ICON_Fan0, ICON_Fan3, x + fanx, y, 25); + dwin_string.set(i8tostr3rj(thermalManager.scaledFanSpeedPercent(0))); + dwin_string.add('%'); + DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + STATUS_FAN_HEIGHT, S(dwin_string.string())); + } + else { + DWIN_ICON_AnimationControl(0x0000); // disable all icon animations (this is the only one) + DWIN_ICON_Show(ICON, ICON_Fan0, x + fanx, y); + dwin_string.set(F(" ")); + DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + STATUS_FAN_HEIGHT, S(dwin_string.string())); + } } -} +#endif /** * Draw a single heater icon with current and target temperature, at the given XY @@ -207,72 +191,56 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x #endif #endif - #if HAS_HOTEND && HAS_HEATED_BED - float tc, tt; - bool c_draw, t_draw, i_draw, ta; - const bool isBed = heater < 0; - if (isBed) { + celsius_float_t tc = 0, tt = 0; + bool isBed = (DISABLED(HAS_HOTEND) && ENABLED(HAS_HEATED_BED)) || (BOTH(HAS_HOTEND, HAS_HEATED_BED) && heater < 0), + ta = false, c_draw, t_draw, i_draw; + c_draw = t_draw = i_draw = !ui.did_first_redraw; + if (isBed) { + #if HAS_HEATED_BED tc = thermalManager.degBed(); tt = thermalManager.degTargetBed(); ta = thermalManager.isHeatingBed(); - c_draw = tc != old_bed_temp; - t_draw = tt != old_bed_target; - i_draw = ta != old_bed_on; + c_draw |= tc != old_bed_temp; + t_draw |= tt != old_bed_target; + i_draw |= ta != old_bed_on; old_bed_temp = tc; old_bed_target = tt; old_bed_on = ta; - } - else { + #if HAS_LEVELING + i_draw |= planner.leveling_active != old_leveling_on; + old_leveling_on = planner.leveling_active; + #endif + #endif + } + else { + #if HAS_HOTEND tc = thermalManager.degHotend(heater); tt = thermalManager.degTargetHotend(heater); ta = thermalManager.isHeatingHotend(heater); - c_draw = tc != old_temp[heater]; - t_draw = tt != old_target[heater]; - i_draw = ta != old_on[heater]; + c_draw |= tc != old_temp[heater]; + t_draw |= tt != old_target[heater]; + i_draw |= ta != old_on[heater]; old_temp[heater] = tc; old_target[heater] = tt; old_on[heater] = ta; - } - #elif HAS_HOTEND - constexpr bool isBed = false; - const float tc = thermalManager.degHotend(heater), tt = thermalManager.degTargetHotend(heater); - const uint8_t ta = thermalManager.isHeatingHotend(heater); - bool c_draw = tc != old_temp[heater], t_draw = tt != old_target[heater], i_draw = ta != old_on[heater]; - old_temp[heater] = tc; old_target[heater] = tt; old_on[heater] = ta; - #elif HAS_HEATED_BED - constexpr bool isBed = true; - const float tc = thermalManager.degBed(), tt = thermalManager.degTargetBed(); - const uint8_t ta = thermalManager.isHeatingBed(); - bool c_draw = tc != old_bed_temp, t_draw = tt != old_bed_target, i_draw = ta != old_bed_on; - old_bed_temp = tc; old_bed_target = tt; old_bed_on = ta; - #else - bool c_draw = false, t_draw = false, i_draw = false; - constexpr float tc = 0, tt = 0; - constexpr uint8_t ta = 0; - #endif - - #if HAS_HEATED_BED && HAS_LEVELING - if (isBed) { - i_draw |= (planner.leveling_active != old_leveling_on); - old_leveling_on = planner.leveling_active; - } - #endif + #endif + } // Draw target temperature, if needed - if (!ui.did_first_redraw || t_draw) { + if (t_draw) { dwin_string.set(i16tostr3rj(tt + 0.5)); dwin_string.add(LCD_STR_DEGREE); DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y, S(dwin_string.string())); } // Draw heater icon with on / off / leveled states - if (!ui.did_first_redraw || i_draw) { + if (i_draw) { const uint8_t ico = isBed ? (TERN0(HAS_LEVELING, planner.leveling_active) ? ICON_BedLevelOff : ICON_BedOff) : ICON_HotendOff; DWIN_ICON_Show(ICON, ico + ta, x, y + STATUS_CHR_HEIGHT + 2); } // Draw current temperature, if needed - if (!ui.did_first_redraw || c_draw) { + if (c_draw) { dwin_string.set(i16tostr3rj(tc + 0.5)); dwin_string.add(LCD_STR_DEGREE); DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + 70, S(dwin_string.string())); @@ -294,7 +262,7 @@ FORCE_INLINE void _draw_feedrate_status(const char *value, uint16_t x, uint16_t } /** - * Draw the MarlinUI Status Screen for Ender 3 V2 + * Draw the MarlinUI Status Screen for Ender-3 V2 */ void MarlinUI::draw_status_screen() { const bool blink = get_blink(); @@ -315,7 +283,7 @@ void MarlinUI::draw_status_screen() { // Draw a frame around the x/y/z values DWIN_Draw_Rectangle(0, Select_Color, #if ENABLED(DWIN_MARLINUI_PORTRAIT) - 0, 193, LCD_PIXEL_WIDTH, 260 + 0, 193, LCD_PIXEL_WIDTH - 1, 260 #else 0, 115, LCD_PIXEL_WIDTH - 1, 152 #endif @@ -334,7 +302,6 @@ void MarlinUI::draw_status_screen() { #if HAS_HEATED_BED _draw_heater_status(H_BED, hx, STATUS_HEATERS_Y); #endif - #if HAS_FAN _draw_fan_status(LCD_PIXEL_WIDTH - STATUS_CHR_WIDTH * 5, STATUS_FAN_Y); #endif @@ -366,6 +333,8 @@ void MarlinUI::draw_status_screen() { ); } + // TODO! + // // Elapsed time // @@ -374,11 +343,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'; } @@ -412,7 +381,7 @@ void MarlinUI::draw_status_screen() { } DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 378, 170, S(dwin_string.string())); } - else if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) { + else if (!ui.did_first_redraw || old_is_printing != print_job_timer.isRunning()) { dwin_string.set(F(" ")); DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(dwin_string.string())); } @@ -447,13 +416,13 @@ 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( 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 @@ -468,7 +437,7 @@ void MarlinUI::draw_status_screen() { draw_status_message(blink); ui.did_first_redraw = true; - ui.old_is_printing = print_job_timer.isRunning(); + old_is_printing = print_job_timer.isRunning(); } #endif // IS_DWIN_MARLINUI diff --git a/Marlin/src/lcd/e3v2/proui/base64.hpp b/Marlin/src/lcd/e3v2/proui/base64.hpp index d82d0b27e8ac..a51cca7c52ec 100644 --- a/Marlin/src/lcd/e3v2/proui/base64.hpp +++ b/Marlin/src/lcd/e3v2/proui/base64.hpp @@ -5,7 +5,7 @@ * Author: Densaugeo * Maintainer: Densaugeo * Version: 1.2.1.1 - * Changed unsigned int to uint16_t for use in the professional Ender 3V2/S1 firmware + * Changed unsigned int to uint16_t for use in the professional Ender-3V2/S1 firmware * Url: https://www.arduino.cc/reference/en/libraries/base64/ */ diff --git a/Marlin/src/lcd/e3v2/proui/ubl_tools.cpp b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp similarity index 72% rename from Marlin/src/lcd/e3v2/proui/ubl_tools.cpp rename to Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp index 87909d2dd2a2..47b104c5ba47 100644 --- a/Marlin/src/lcd/e3v2/proui/ubl_tools.cpp +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp @@ -21,24 +21,35 @@ */ /** - * UBL Tools and Mesh Viewer for Pro UI - * Version: 1.0.0 - * Date: 2022/04/13 + * Bed Level Tools for Pro UI + * Extended by: Miguel A. Risco-Castillo (MRISCOC) + * Version: 2.1.0 + * Date: 2022/08/27 + * + * Based on the original work of: Henri-J-Norden + * https://github.com/Jyers/Marlin/pull/126 + * + * 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 . * - * Original Author: Henri-J-Norden - * Original Source: https://github.com/Jyers/Marlin/pull/126 */ #include "../../../inc/MarlinConfigPre.h" -#if BOTH(DWIN_LCD_PROUI, AUTO_BED_LEVELING_UBL) +#if BOTH(DWIN_LCD_PROUI, HAS_LEVELING) -#include "ubl_tools.h" #include "../../marlinui.h" #include "../../../core/types.h" -#include "dwin.h" -#include "dwinui.h" -#include "dwin_popup.h" #include "../../../feature/bedlevel/bedlevel.h" #include "../../../module/probe.h" #include "../../../gcode/gcode.h" @@ -47,27 +58,34 @@ #include "../../../libs/least_squares_fit.h" #include "../../../libs/vector_3.h" -UBLMeshToolsClass ubl_tools; +#include "dwin.h" +#include "dwinui.h" +#include "dwin_popup.h" +#include "bedlevel_tools.h" + +BedLevelToolsClass bedLevelTools; #if ENABLED(USE_UBL_VIEWER) - bool UBLMeshToolsClass::viewer_asymmetric_range = false; - bool UBLMeshToolsClass::viewer_print_value = false; + bool BedLevelToolsClass::viewer_asymmetric_range = false; + bool BedLevelToolsClass::viewer_print_value = false; #endif -bool UBLMeshToolsClass::goto_mesh_value = false; -uint8_t UBLMeshToolsClass::tilt_grid = 1; +bool BedLevelToolsClass::goto_mesh_value = false; +uint8_t BedLevelToolsClass::mesh_x = 0; +uint8_t BedLevelToolsClass::mesh_y = 0; +uint8_t BedLevelToolsClass::tilt_grid = 1; bool drawing_mesh = false; char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16]; #if ENABLED(AUTO_BED_LEVELING_UBL) - void UBLMeshToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y, bool undefined/*=false*/) { + void BedLevelToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y, bool undefined/*=false*/) { sprintf_P(cmd, PSTR("M421 I%i J%i Z%s %s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1), undefined ? "N" : ""); gcode.process_subcommands_now(cmd); planner.synchronize(); } - bool UBLMeshToolsClass::create_plane_from_mesh() { + bool BedLevelToolsClass::create_plane_from_mesh() { struct linear_fit_data lsf_results; incremental_LSF_reset(&lsf_results); GRID_LOOP(x, y) { @@ -119,7 +137,7 @@ char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16]; #else - void UBLMeshToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y) { + void BedLevelToolsClass::manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y) { sprintf_P(cmd, PSTR("G29 I%i J%i Z%s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1)); gcode.process_subcommands_now(cmd); planner.synchronize(); @@ -127,7 +145,8 @@ char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16]; #endif -void UBLMeshToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove/*=false*/) { +void BedLevelToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove/*=false*/) { + gcode.process_subcommands_now(F("G28O")); if (zmove) { planner.synchronize(); current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES; @@ -149,8 +168,32 @@ void UBLMeshToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y, } } -float UBLMeshToolsClass::get_max_value() { - float max = __FLT_MIN__; +// Move / Probe methods. As examples, not yet used. +void BedLevelToolsClass::MoveToXYZ() { + bedLevelTools.goto_mesh_value = true; + bedLevelTools.manual_move(bedLevelTools.mesh_x, bedLevelTools.mesh_y, false); +} +void BedLevelToolsClass::MoveToXY() { + bedLevelTools.goto_mesh_value = false; + bedLevelTools.manual_move(bedLevelTools.mesh_x, bedLevelTools.mesh_y, false); +} +void BedLevelToolsClass::MoveToZ() { + bedLevelTools.goto_mesh_value = true; + bedLevelTools.manual_move(bedLevelTools.mesh_x, bedLevelTools.mesh_y, true); +} +void BedLevelToolsClass::ProbeXY() { + const uint16_t Clear = Z_CLEARANCE_DEPLOY_PROBE; + sprintf_P(cmd, PSTR("G28O\nG0Z%i\nG30X%sY%s"), + Clear, + dtostrf(bedlevel.get_mesh_x(bedLevelTools.mesh_x), 1, 2, str_1), + dtostrf(bedlevel.get_mesh_y(bedLevelTools.mesh_y), 1, 2, str_2) + ); + gcode.process_subcommands_now(cmd); +} + +// Accessors +float BedLevelToolsClass::get_max_value() { + float max = __FLT_MAX__ * -1; GRID_LOOP(x, y) { if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] > max) max = bedlevel.z_values[x][y]; @@ -158,7 +201,7 @@ float UBLMeshToolsClass::get_max_value() { return max; } -float UBLMeshToolsClass::get_min_value() { +float BedLevelToolsClass::get_min_value() { float min = __FLT_MAX__; GRID_LOOP(x, y) { if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] < min) @@ -167,19 +210,18 @@ float UBLMeshToolsClass::get_min_value() { return min; } -bool UBLMeshToolsClass::validate() { - float min = __FLT_MAX__, max = __FLT_MIN__; - +// Return 'true' if mesh is good and within LCD limits +bool BedLevelToolsClass::meshvalidate() { GRID_LOOP(x, y) { - if (isnan(bedlevel.z_values[x][y])) return false; - if (bedlevel.z_values[x][y] < min) min = bedlevel.z_values[x][y]; - if (bedlevel.z_values[x][y] > max) max = bedlevel.z_values[x][y]; + const float v = bedlevel.z_values[x][y]; + if (isnan(v) || !WITHIN(v, UBL_Z_OFFSET_MIN, UBL_Z_OFFSET_MAX)) return false; } - return max <= UBL_Z_OFFSET_MAX && min >= UBL_Z_OFFSET_MIN; + return true; } #if ENABLED(USE_UBL_VIEWER) - void UBLMeshToolsClass::Draw_Bed_Mesh(int16_t selected /*= -1*/, uint8_t gridline_width /*= 1*/, uint16_t padding_x /*= 8*/, uint16_t padding_y_top /*= 40 + 53 - 7*/) { + + void BedLevelToolsClass::Draw_Bed_Mesh(int16_t selected /*= -1*/, uint8_t gridline_width /*= 1*/, uint16_t padding_x /*= 8*/, uint16_t padding_y_top /*= 40 + 53 - 7*/) { drawing_mesh = true; const uint16_t total_width_px = DWIN_WIDTH - padding_x - padding_x; const uint16_t cell_width_px = total_width_px / (GRID_MAX_POINTS_X); @@ -237,7 +279,7 @@ bool UBLMeshToolsClass::validate() { } } - void UBLMeshToolsClass::Set_Mesh_Viewer_Status() { // TODO: draw gradient with values as a legend instead + void BedLevelToolsClass::Set_Mesh_Viewer_Status() { // TODO: draw gradient with values as a legend instead float v_max = abs(get_max_value()), v_min = abs(get_min_value()), range = _MAX(v_min, v_max); if (v_min > 3e+10F) v_min = 0.0000001; if (v_max > 3e+10F) v_max = 0.0000001; @@ -255,6 +297,7 @@ bool UBLMeshToolsClass::validate() { ui.set_status(msg); drawing_mesh = false; } -#endif -#endif // DWIN_LCD_PROUI && AUTO_BED_LEVELING_UBL +#endif // USE_UBL_VIEWER + +#endif // DWIN_LCD_PROUI && HAS_LEVELING diff --git a/Marlin/src/lcd/e3v2/proui/ubl_tools.h b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h similarity index 55% rename from Marlin/src/lcd/e3v2/proui/ubl_tools.h rename to Marlin/src/lcd/e3v2/proui/bedlevel_tools.h index 563794a46385..6e642f030c18 100644 --- a/Marlin/src/lcd/e3v2/proui/ubl_tools.h +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h @@ -1,10 +1,33 @@ +/* + * 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 . + * + */ + /** - * UBL Tools and Mesh Viewer for Pro UI - * Version: 1.0.0 - * Date: 2022/04/13 + * Bed Level Tools for Pro UI + * Extended by: Miguel A. Risco-Castillo (MRISCOC) + * Version: 2.1.0 + * Date: 2022/08/27 * - * Original Author: Henri-J-Norden (https://github.com/Henri-J-Norden) - * Original Source: https://github.com/Jyers/Marlin/pull/135 + * Based on the original work of: Henri-J-Norden + * https://github.com/Jyers/Marlin/pull/126 * * 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 @@ -29,13 +52,15 @@ #define UBL_Z_OFFSET_MIN -3.0 #define UBL_Z_OFFSET_MAX 3.0 -class UBLMeshToolsClass { +class BedLevelToolsClass { public: #if ENABLED(USE_UBL_VIEWER) static bool viewer_asymmetric_range; static bool viewer_print_value; #endif static bool goto_mesh_value; + static uint8_t mesh_x; + static uint8_t mesh_y; static uint8_t tilt_grid; #if ENABLED(AUTO_BED_LEVELING_UBL) @@ -45,15 +70,17 @@ class UBLMeshToolsClass { static void manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y); #endif static void manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove=false); + static void MoveToXYZ(); + static void MoveToXY(); + static void MoveToZ(); + static void ProbeXY(); static float get_max_value(); static float get_min_value(); - static bool validate(); + static bool meshvalidate(); #if ENABLED(USE_UBL_VIEWER) static void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7); static void Set_Mesh_Viewer_Status(); #endif }; -extern UBLMeshToolsClass ubl_tools; - -void Goto_MeshViewer(); +extern BedLevelToolsClass bedLevelTools; diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 07b134471b58..4a332f973e20 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -23,8 +23,8 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.17.2 - * Date: 2022/04/08 + * Version: 3.21.2 + * Date: 2022/12/02 */ #include "../../../inc/MarlinConfig.h" @@ -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." @@ -62,10 +62,6 @@ #warning "MESH_EDIT_MENU is recommended with ProUI." #endif -#include "dwin.h" -#include "menus.h" -#include "dwin_popup.h" - #include "../../fontutils.h" #include "../../marlinui.h" @@ -78,6 +74,7 @@ #include "../../../module/temperature.h" #include "../../../module/printcounter.h" #include "../../../module/motion.h" +#include "../../../module/stepper.h" #include "../../../module/planner.h" #include "../../../gcode/gcode.h" @@ -99,78 +96,73 @@ #define HAS_ONESTEP_LEVELING 1 #endif -#if HAS_MESH || HAS_ONESTEP_LEVELING +#if HAS_MESH || (HAS_LEVELING && HAS_ZOFFSET_ITEM) #include "../../../feature/bedlevel/bedlevel.h" + #include "bedlevel_tools.h" #endif #if HAS_BED_PROBE #include "../../../module/probe.h" #endif -#ifdef BLTOUCH_HS_MODE +#if ENABLED(BLTOUCH) #include "../../../feature/bltouch.h" #endif -#if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET) - #define HAS_ZOFFSET_ITEM 1 - #if ENABLED(BABYSTEPPING) - #include "../../../feature/babystep.h" - #if !HAS_BED_PROBE - #define JUST_BABYSTEP 1 - #endif - #endif +#if ENABLED(BABYSTEPPING) + #include "../../../feature/babystep.h" #endif #if ENABLED(POWER_LOSS_RECOVERY) #include "../../../feature/powerloss.h" #endif -#if HAS_ESDIAG - #include "endstop_diag.h" +#if ENABLED(PRINTCOUNTER) + #include "printstats.h" #endif -#if HAS_PIDPLOT - #include "plot.h" +#if ENABLED(CASE_LIGHT_MENU) + #include "../../../feature/caselight.h" #endif -#if HAS_GCODE_PREVIEW - #include "gcode_preview.h" +#if ENABLED(LED_CONTROL_MENU) + #include "../../../feature/leds/leds.h" #endif -#if HAS_MESH - #include "meshviewer.h" +#include "dwin.h" +#include "dwinui.h" +#include "menus.h" +#include "dwin_popup.h" + +#if HAS_GCODE_PREVIEW + #include "gcode_preview.h" #endif -#if ENABLED(AUTO_BED_LEVELING_UBL) - #include "ubl_tools.h" +#if HAS_ESDIAG + #include "endstop_diag.h" #endif -#if ENABLED(PRINTCOUNTER) - #include "printstats.h" +#if HAS_PIDPLOT + #include "plot.h" #endif -#if ENABLED(CASE_LIGHT_MENU) - #include "../../../feature/caselight.h" +#if HAS_MESH + #include "meshviewer.h" #endif -#if ENABLED(LED_CONTROL_MENU) - #include "../../../feature/leds/leds.h" +#if HAS_LOCKSCREEN + #include "lockscreen.h" #endif -#include -#include -#include +#define DEBUG_OUT ENABLED(DEBUG_DWIN) +#include "../../../core/debug_out.h" #ifndef MACHINE_SIZE #define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) #endif -#include "lockscreen.h" - #define PAUSE_HEAT -#define MENU_CHAR_LIMIT 24 - // Print speed limit #define MIN_PRINT_SPEED 10 #define MAX_PRINT_SPEED 999 @@ -191,18 +183,16 @@ // Editable temperature limits #define MIN_ETEMP 0 -#define MAX_ETEMP (HEATER_0_MAXTEMP - (HOTEND_OVERSHOOT)) +#define MAX_ETEMP (thermalManager.hotend_maxtemp[0] - (HOTEND_OVERSHOOT)) #define MIN_BEDTEMP 0 #define MAX_BEDTEMP BED_MAX_TARGET -#define FEEDRATE_E (60) - #define DWIN_VAR_UPDATE_INTERVAL 1024 -#define DWIN_SCROLL_UPDATE_INTERVAL SEC_TO_MS(2) +#define DWIN_UPDATE_INTERVAL 1024 #define DWIN_REMAIN_TIME_UPDATE_INTERVAL SEC_TO_MS(20) -#if HAS_MESH - #define BABY_Z_VAR TERN(HAS_BED_PROBE, probe.offset.z, HMI_data.ManualZOffset) +#if HAS_MESH && HAS_BED_PROBE + #define BABY_Z_VAR probe.offset.z #else float z_offset = 0; #define BABY_Z_VAR z_offset @@ -213,10 +203,6 @@ HMI_value_t HMI_value; HMI_flag_t HMI_flag{0}; HMI_data_t HMI_data; -millis_t dwin_heat_time = 0; - -uint8_t checkkey = 255, last_checkkey = MainMenu; - enum SelectItem : uint8_t { PAGE_PRINT = 0, PAGE_PREPARE, @@ -238,11 +224,7 @@ typedef struct { bool dec() { if (now) now--; return changed(); } bool inc(uint8_t v) { if (now < (v - 1)) now++; else now = (v - 1); return changed(); } } select_t; - -select_t select_page{0}, select_file{0}, select_print{0}; -uint8_t index_file = MROWS; - -bool hash_changed = true; // Flag to know if message status was changed +select_t select_page{0}, select_print{0}; constexpr float max_feedrate_edit_values[] = #ifdef MAX_FEEDRATE_EDIT_VALUES @@ -251,6 +233,7 @@ constexpr float max_feedrate_edit_values[] = { 1000, 1000, 10, 50 } #endif ; + constexpr float max_acceleration_edit_values[] = #ifdef MAX_ACCEL_EDIT_VALUES MAX_ACCEL_EDIT_VALUES @@ -258,6 +241,7 @@ constexpr float max_acceleration_edit_values[] = { 1000, 1000, 200, 2000 } #endif ; + #if HAS_CLASSIC_JERK constexpr float max_jerk_edit_values[] = #ifdef MAX_JERK_EDIT_VALUES @@ -268,17 +252,21 @@ constexpr float max_acceleration_edit_values[] = ; #endif -static uint8_t _percent_done = 0; -static uint32_t _remain_time = 0; - -// Additional Aux Host Support -static bool sdprint = false; - #if HAS_HOTEND float last_E = 0; + #define E_MIN_POS (last_E - (EXTRUDE_MAXLENGTH)) + #define E_MAX_POS (last_E + (EXTRUDE_MAXLENGTH)) #endif +bool hash_changed = true; // Flag to know if message status was changed +uint8_t _percent_done = 0; +uint32_t _remain_time = 0; +bool blink = false; +millis_t dwin_heat_time = 0; +uint8_t checkkey = 255, last_checkkey = MainMenu; + // New menu system pointers +MenuClass *FileMenu = nullptr; MenuClass *PrepareMenu = nullptr; MenuClass *TrammingMenu = nullptr; MenuClass *MoveMenu = nullptr; @@ -305,10 +293,16 @@ MenuClass *FilamentMenu = nullptr; MenuClass *TemperatureMenu = nullptr; MenuClass *MaxSpeedMenu = nullptr; MenuClass *MaxAccelMenu = nullptr; -MenuClass *MaxJerkMenu = nullptr; +#if HAS_CLASSIC_JERK + MenuClass *MaxJerkMenu = nullptr; +#endif MenuClass *StepsMenu = nullptr; -MenuClass *HotendPIDMenu = nullptr; -MenuClass *BedPIDMenu = nullptr; +#if ENABLED(PIDTEMP) + MenuClass *HotendPIDMenu = nullptr; +#endif +#if ENABLED(PIDTEMPBED) + MenuClass *BedPIDMenu = nullptr; +#endif #if ENABLED(CASELIGHT_USES_BRIGHTNESS) MenuClass *CaseLightMenu = nullptr; #endif @@ -338,6 +332,10 @@ MenuItemClass *FanSpeedItem = nullptr; MenuItemClass *MMeshMoveZItem = nullptr; MenuItemClass *EditZValueItem = nullptr; +bool Printing() { return printingIsActive() || printingIsPaused(); } +bool SD_Printing() { return Printing() && IS_SD_FILE_OPEN(); } +bool Host_Printing() { return Printing() && !IS_SD_FILE_OPEN(); } + #define DWIN_LANGUAGE_EEPROM_ADDRESS 0x01 // Between 0x01 and 0x63 (EEPROM_OFFSET-1) // BL24CXX::check() uses 0x00 @@ -369,7 +367,7 @@ void HMI_ToggleLanguage() { typedef struct { uint16_t x, y[2], w, h; } text_info_t; void ICON_Button(const bool selected, const int iconid, const frame_rect_t &ico, const text_info_t (&txt), FSTR_P caption) { - DWIN_ICON_Show(true, false, false, ICON, iconid + selected, ico.x, ico.y); + DWINUI::Draw_IconWB(iconid + selected, ico.x, ico.y); if (selected) DWINUI::Draw_Box(0, HMI_data.Highlight_Color, ico); if (HMI_IsChinese()) { DWIN_Frame_AreaCopy(1, txt.x, txt.y[selected], txt.x + txt.w - 1, txt.y[selected] + txt.h - 1, ico.x + (ico.w - txt.w) / 2, (ico.y + ico.h - 25) - txt.h/2); @@ -453,47 +451,9 @@ void ICON_Stop() { ICON_Button(select_print.now == PRINT_STOP, ICON_Stop_0, ico, txt, GET_TEXT_F(MSG_BUTTON_STOP)); } -//----------------------------------------------------------------------------- -// Drawing routines -//----------------------------------------------------------------------------- - -void Move_Highlight(const int8_t from, const int8_t newline) { - Erase_Menu_Cursor(newline - from); - Draw_Menu_Cursor(newline); -} - -void Add_Menu_Line() { - Move_Highlight(1, MROWS); - DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(MROWS + 1), 240); -} - -void Scroll_Menu(const uint8_t dir) { - DWIN_Frame_AreaMove(1, dir, MLINE, HMI_data.Background_Color, 0, 31, DWIN_WIDTH, 349); - switch (dir) { - case DWIN_SCROLL_DOWN: Move_Highlight(-1, 0); break; - case DWIN_SCROLL_UP: Add_Menu_Line(); break; - } -} - -inline uint16_t nr_sd_menu_items() { - return card.get_num_Files() + !card.flag.workDirIsRoot; -} - -void Erase_Menu_Text(const uint8_t line) { - DWIN_Draw_Rectangle(1, HMI_data.Background_Color, LBLX, MBASE(line) - 14, 271, MBASE(line) + 28); -} - -// Draw "Back" line at the top -void Draw_Back_First(const bool is_sel=true) { - Draw_Menu_Line(0, ICON_Back); - if (HMI_IsChinese()) - DWIN_Frame_AreaCopy(1, 129, 72, 156, 84, LBLX, MBASE(0)); - else - DWINUI::Draw_String(LBLX, MBASE(0), GET_TEXT_F(MSG_BACK)); - if (is_sel) Draw_Menu_Cursor(0); -} - +// //PopUps +// void Popup_window_PauseOrStop() { if (HMI_IsChinese()) { DWINUI::ClearMainArea(); @@ -547,20 +507,19 @@ void Popup_window_PauseOrStop() { DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); } } - else DWIN_Show_Popup(toohigh ? ICON_TempTooHigh : ICON_TempTooLow, F("Nozzle or Bed temperature"), toohigh ? F("is too high") : F("is too low"), BTN_Continue); + else + DWIN_Show_Popup(toohigh ? ICON_TempTooHigh : ICON_TempTooLow, F("Nozzle or Bed temperature"), toohigh ? F("is too high") : F("is too low"), BTN_Continue); } #endif +// // Draw status line +// void DWIN_DrawStatusLine(const char *text) { DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); if (text) DWINUI::Draw_CenteredString(HMI_data.StatusTxt_Color, STATUS_Y + 2, text); } - -void DWIN_DrawStatusLine(FSTR_P fstr) { - DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); - if (fstr) DWINUI::Draw_CenteredString(HMI_data.StatusTxt_Color, STATUS_Y + 2, fstr); -} +void DWIN_DrawStatusLine(FSTR_P fstr) { DWIN_DrawStatusLine(FTOP(fstr)); } // Clear & reset status line void DWIN_ResetStatusLine() { @@ -569,12 +528,16 @@ void DWIN_ResetStatusLine() { } // Djb2 hash algorithm -void DWIN_CheckStatusMessage() { - static uint32_t old_hash = 0; - char * str = &ui.status_message[0]; +uint32_t GetHash(char * str) { uint32_t hash = 5381; char c; while ((c = *str++)) hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ + return hash; +} + +void DWIN_CheckStatusMessage() { + static uint32_t old_hash = 0; + uint32_t hash = GetHash(&ui.status_message[0]); hash_changed = hash != old_hash; old_hash = hash; }; @@ -587,10 +550,10 @@ void DWIN_DrawStatusMessage() { // If the string fits the status line do not scroll it if (slen <= LCD_WIDTH) { - if (hash_changed) { - DWIN_DrawStatusLine(ui.status_message); - hash_changed = false; - } + if (hash_changed) { + DWIN_DrawStatusLine(ui.status_message); + hash_changed = false; + } } else { // String is larger than the available line space @@ -607,7 +570,7 @@ void DWIN_DrawStatusMessage() { if (rlen < LCD_WIDTH) { DWINUI::Draw_Char(HMI_data.StatusTxt_Color, '.'); // Always at 1+ spaces left, draw a dot uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters - if (--chars) { // Draw a second dot if there's space + if (--chars) { // Draw a second dot if there's space DWINUI::Draw_Char(HMI_data.StatusTxt_Color, '.'); if (--chars) DWINUI::Draw_String(HMI_data.StatusTxt_Color, ui.status_message, chars); // Print a second copy of the message @@ -639,7 +602,7 @@ void Draw_Print_Labels() { } void Draw_Print_ProgressBar() { - DWIN_ICON_Show(true, false, false, ICON, ICON_Bar, 15, 93); + DWINUI::Draw_IconWB(ICON_Bar, 15, 93); DWIN_Draw_Rectangle(1, HMI_data.Barfill_Color, 16 + _percent_done * 240 / 100, 93, 256, 113); DWINUI::Draw_Int(HMI_data.PercentTxt_Color, HMI_data.Background_Color, 3, 117, 133, _percent_done); DWINUI::Draw_String(HMI_data.PercentTxt_Color, 142, 133, F("%")); @@ -682,7 +645,7 @@ void Draw_PrintProcess() { else Title.ShowCaption(GET_TEXT_F(MSG_PRINTING)); DWINUI::ClearMainArea(); - DWIN_Print_Header(sdprint ? card.longest_filename() : nullptr); + DWIN_Print_Header(SD_Printing() ? card.longest_filename() : nullptr); Draw_Print_Labels(); DWINUI::Draw_Icon(ICON_PrintTime, 15, 173); DWINUI::Draw_Icon(ICON_RemainTime, 150, 171); @@ -713,11 +676,18 @@ void Draw_PrintDone() { Title.ShowCaption(GET_TEXT_F(MSG_PRINT_DONE)); DWINUI::ClearMainArea(); DWIN_Print_Header(nullptr); - if (sdprint && TERN0(HAS_GCODE_PREVIEW, Preview_Valid())) { - DWIN_ICON_Show(0, 0, 1, 21, 100, 0x00); - DWINUI::Draw_Button(BTN_Continue, 86, 300); - } - else { + + #if HAS_GCODE_PREVIEW + const bool isvalid = Preview_Valid(); + if (isvalid) { + DWIN_ICON_Show(0, 0, 1, 21, 100, 0x00); + DWINUI::Draw_Button(BTN_Continue, 86, 300); + } + #else + constexpr bool isvalid = false; + #endif + + if (!isvalid) { Draw_Print_ProgressBar(); Draw_Print_Labels(); DWINUI::Draw_Icon(ICON_PrintTime, 15, 173); @@ -744,7 +714,6 @@ void Draw_Main_Menu() { else Title.ShowCaption(MACHINE_NAME); DWINUI::Draw_Icon(ICON_LOGO, 71, 52); // CREALITY logo - DWIN_ResetStatusLine(); ICON_Print(); ICON_Prepare(); ICON_Control(); @@ -759,13 +728,15 @@ void Goto_Main_Menu() { } // Draw X, Y, Z and blink if in an un-homed or un-trusted state -void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, const bool blink, const bool force) { +void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, const bool force) { const bool draw_qmark = axis_should_home(axis), draw_empty = NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !draw_qmark && !axis_is_trusted(axis); // Check for a position change static xyz_pos_t oldpos = { -1, -1, -1 }; - const float p = current_position[axis]; + + const float p = TERN(SHOW_REAL_POS, stepper.position(axis) / planner.settings.axis_steps_per_mm[axis], current_position[axis]); + const bool changed = oldpos[axis] != p; if (changed) oldpos[axis] = p; @@ -779,18 +750,38 @@ void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, } } +void _draw_ZOffsetIcon() { + #if HAS_LEVELING + #if NO_BLINK_LEV_IND + static bool _leveling_active = false; + if (_leveling_active != planner.leveling_active) { + _leveling_active = planner.leveling_active; + DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 186, 415, 205, 436); + DWINUI::Draw_Icon(_leveling_active ? ICON_SetZOffset : ICON_Zoffset, 187, 416); + } + #else + if (planner.leveling_active) { + DWIN_Draw_Rectangle(1, blink ? HMI_data.SplitLine_Color : HMI_data.Background_Color, 186, 415, 205, 436); + DWINUI::Draw_Icon(ICON_SetZOffset, 186, 416); + } + static bool _leveling_active = false; + if (_leveling_active != planner.leveling_active) { + _leveling_active = planner.leveling_active; + if (!_leveling_active) { + DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 186, 415, 205, 436); + DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); + } + } + #endif + #else + DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); + #endif +} + void _draw_xyz_position(const bool force) { - //SERIAL_ECHOPGM("Draw XYZ:"); - static bool _blink = false; - const bool blink = !!(millis() & 0x400UL); - if (force || blink != _blink) { - _blink = blink; - //SERIAL_ECHOPGM(" (blink)"); - _update_axis_value(X_AXIS, 27, 459, blink, true); - _update_axis_value(Y_AXIS, 112, 459, blink, true); - _update_axis_value(Z_AXIS, 197, 459, blink, true); - } - //SERIAL_EOL(); + _update_axis_value(X_AXIS, 27, 459, force); + _update_axis_value(Y_AXIS, 112, 459, force); + _update_axis_value(Z_AXIS, 197, 459, force); } void update_variable() { @@ -818,17 +809,11 @@ void update_variable() { if (_new_fanspeed) _fanspeed = thermalManager.fan_speed[0]; #endif - if (checkkey == Menu && (CurrentMenu == TuneMenu || CurrentMenu == TemperatureMenu)) { + if (IsMenu(TuneMenu) || IsMenu(TemperatureMenu)) { // Tune page temperature update - #if HAS_HOTEND - if (_new_hotend_target) HotendTargetItem->redraw(); - #endif - #if HAS_HEATED_BED - if (_new_bed_target) BedTargetItem->redraw(); - #endif - #if HAS_FAN - if (_new_fanspeed) FanSpeedItem->redraw(); - #endif + TERN_(HAS_HOTEND, if (_new_hotend_target) HotendTargetItem->redraw()); + TERN_(HAS_HEATED_BED, if (_new_bed_target) BedTargetItem->redraw()); + TERN_(HAS_FAN, if (_new_fanspeed) FanSpeedItem->redraw()); } // Bottom temperature update @@ -872,34 +857,23 @@ void update_variable() { DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 204, 417, _offset); } - #if HAS_MESH - static bool _leveling_active = false; - if (_leveling_active != planner.leveling_active) { - _leveling_active = planner.leveling_active; - DWIN_Draw_Box(1, HMI_data.Background_Color, 186, 416, 20, 20); - if (_leveling_active) - DWINUI::Draw_Icon(ICON_SetZOffset, 186, 416); - else - DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); - } - #else - DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); - #endif - + _draw_ZOffsetIcon(); _draw_xyz_position(false); } /** - * Read and cache the working directory. - * - * TODO: New code can follow the pattern of menu_media.cpp - * and rely on Marlin caching for performance. No need to - * cache files here. + * Memory card and file management */ -#ifndef strcasecmp_P - #define strcasecmp_P(a, b) strcasecmp((a), (b)) -#endif +bool DWIN_lcd_sd_status = false; + +void SetMediaAutoMount() { + Toggle_Chkb_Line(HMI_data.MediaAutoMount); +} + +inline uint16_t nr_sd_menu_items() { + return _MIN(card.get_num_Files() + !card.flag.workDirIsRoot, MENU_MAX_ITEMS); +} void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) { size_t pos = strlen(src); // index of ending nul @@ -925,117 +899,120 @@ void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) while (pos--) dst[pos] = src[pos]; } -void HMI_SDCardInit() { card.cdroot(); } - -#if ENABLED(SCROLL_LONG_FILENAMES) - - char shift_name[LONG_FILENAME_LENGTH + 1]; - int8_t shift_amt; // = 0 - millis_t shift_ms; // = 0 - - // Init the shift name based on the highlighted item - void Init_Shift_Name() { - const bool is_subdir = !card.flag.workDirIsRoot; - const int8_t filenum = select_file.now - 1 - is_subdir; // Skip "Back" and ".." - const uint16_t fileCnt = card.get_num_Files(); - if (WITHIN(filenum, 0, fileCnt - 1)) { - card.getfilename_sorted(SD_ORDER(filenum, fileCnt)); - char * const name = card.longest_filename(); - make_name_without_ext(shift_name, name, 100); - } - } - - void Init_SDItem_Shift() { - shift_amt = 0; - shift_ms = select_file.now > 0 && strlen(shift_name) > MENU_CHAR_LIMIT ? millis() + 750UL : 0; - } +void Redraw_SD_List() { + InvalidateMenu(); + Draw_Print_File_Menu(); +} -#endif +void SDCard_Up() { + card.cdup(); + DWIN_lcd_sd_status = false; // On next DWIN_Update +} -/** - * Display an SD item, adding a CDUP for subfolders. - */ -void Draw_SDItem(const uint16_t item, int16_t row=-1) { - if (row < 0) row = item + 1 + MROWS - index_file; - const bool is_subdir = !card.flag.workDirIsRoot; - if (is_subdir && item == 0) - return Draw_Menu_Line(row, ICON_Folder, ".."); +void SDCard_Folder(char * const dirname) { + card.cd(dirname); + DWIN_lcd_sd_status = false; // On next DWIN_Update +} - card.getfilename_sorted(SD_ORDER(item - is_subdir, card.get_num_Files())); - char * const name = card.longest_filename(); +void onClickSDItem() { + const uint16_t hasUpDir = !card.flag.workDirIsRoot; + if (hasUpDir && CurrentMenu->selected == 1) return SDCard_Up(); + else { + const uint16_t filenum = CurrentMenu->selected - 1 - hasUpDir; + card.getfilename_sorted(SD_ORDER(filenum, card.get_num_Files())); - #if ENABLED(SCROLL_LONG_FILENAMES) - // Init the current selected name - // This is used during scroll drawing - if (item == select_file.now - 1) { - make_name_without_ext(shift_name, name, 100); - Init_SDItem_Shift(); - } - #endif + // Enter that folder! + if (card.flag.filenameIsDir) return SDCard_Folder(card.filename); - // Draw the file/folder with name aligned left - char str[strlen(name) + 1]; - make_name_without_ext(str, name); - const uint8_t icon = card.flag.filenameIsDir ? ICON_Folder : card.fileIsBinary() ? ICON_Binary : ICON_File; - Draw_Menu_Line(row, icon, str); + if (card.fileIsBinary()) + return DWIN_Popup_Confirm(ICON_Error, F("Please check filenames"), F("Only G-code can be printed")); + else + return Goto_ConfirmToPrint(); + } } #if ENABLED(SCROLL_LONG_FILENAMES) + char shift_name[LONG_FILENAME_LENGTH + 1] = ""; void Draw_SDItem_Shifted(uint8_t &shift) { - // Limit to the number of chars past the cutoff - const size_t len = strlen(shift_name); - NOMORE(shift, _MAX(len - MENU_CHAR_LIMIT, 0U)); - // Shorten to the available space - const size_t lastchar = _MIN((signed)len, shift + MENU_CHAR_LIMIT); - + const size_t lastchar = shift + MENU_CHAR_LIMIT; const char c = shift_name[lastchar]; shift_name[lastchar] = '\0'; - const uint8_t row = select_file.now + MROWS - index_file; // skip "Back" and scroll + const uint8_t row = FileMenu->line(); Erase_Menu_Text(row); Draw_Menu_Line(row, 0, &shift_name[shift]); shift_name[lastchar] = c; } + void FileMenuIdle(bool reset=false) { + static bool hasUpDir = false; + static uint8_t last_itemselected = 0; + static int8_t shift_amt = 0, shift_len = 0; + if (reset) { + last_itemselected = 0; + hasUpDir = !card.flag.workDirIsRoot; // is a SubDir + return; + } + const uint8_t selected = FileMenu->selected; + if (last_itemselected != selected) { + if (last_itemselected >= 1 + hasUpDir) FileMenu->Items()[last_itemselected]->redraw(true); + last_itemselected = selected; + if (selected >= 1 + hasUpDir) { + const int8_t filenum = selected - 1 - hasUpDir; // Skip "Back" and ".." + card.getfilename_sorted(SD_ORDER(filenum, card.get_num_Files())); + make_name_without_ext(shift_name, card.longest_filename(), LONG_FILENAME_LENGTH); + shift_len = strlen(shift_name); + shift_amt = 0; + } + } + else if ((selected >= 1 + hasUpDir) && (shift_len > MENU_CHAR_LIMIT)) { + uint8_t shift_new = _MIN(shift_amt + 1, shift_len - MENU_CHAR_LIMIT); // Try to shift by... + Draw_SDItem_Shifted(shift_new); // Draw the item + if (shift_new == shift_amt) // Scroll reached the end + shift_new = -1; // Reset + shift_amt = shift_new; // Set new scroll + } + } +#else + char shift_name[FILENAME_LENGTH + 1] = ""; #endif -// Redraw the first set of SD Files -void Redraw_SD_List() { - select_file.reset(); - index_file = MROWS; - - DWINUI::ClearMainArea(); // Leave title bar unchanged - - Draw_Back_First(); +void onDrawFileName(MenuItemClass* menuitem, int8_t line) { + const bool is_subdir = !card.flag.workDirIsRoot; + if (is_subdir && menuitem->pos == 1) { + Draw_Menu_Line(line, ICON_Folder, ".."); + } + else { + uint8_t icon; + card.getfilename_sorted(SD_ORDER(menuitem->pos - is_subdir - 1, card.get_num_Files())); + make_name_without_ext(shift_name, card.longest_filename()); + icon = card.flag.filenameIsDir ? ICON_Folder : card.fileIsBinary() ? ICON_Binary : ICON_File; + Draw_Menu_Line(line, icon, shift_name); + } +} +void Draw_Print_File_Menu() { + checkkey = Menu; if (card.isMounted()) { - // As many files as will fit - LOOP_L_N(i, _MIN(nr_sd_menu_items(), MROWS)) - Draw_SDItem(i, i + 1); - - TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift()); + if (SET_MENU(FileMenu, MSG_MEDIA_MENU, nr_sd_menu_items() + 1)) { + BACK_ITEM(Goto_Main_Menu); + LOOP_L_N(i, nr_sd_menu_items()) { + MenuItemAdd(onDrawFileName, onClickSDItem); + } + } + UpdateMenu(FileMenu); + TERN_(DASH_REDRAW, DWIN_RedrawDash()); } else { + if (SET_MENU(FileMenu, MSG_MEDIA_MENU, 1)) BACK_ITEM(Goto_Main_Menu); + UpdateMenu(FileMenu); DWIN_Draw_Rectangle(1, HMI_data.AlertBg_Color, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4)); DWINUI::Draw_CenteredString(font12x24, HMI_data.AlertTxt_Color, MBASE(3), GET_TEXT_F(MSG_MEDIA_NOT_INSERTED)); } -} - -bool DWIN_lcd_sd_status = false; - -void SDCard_Up() { - card.cdup(); - Redraw_SD_List(); - DWIN_lcd_sd_status = false; // On next DWIN_Update -} - -void SDCard_Folder(char * const dirname) { - card.cd(dirname); - Redraw_SD_List(); - DWIN_lcd_sd_status = false; // On next DWIN_Update + TERN_(SCROLL_LONG_FILENAMES, FileMenuIdle(true)); } // @@ -1045,29 +1022,16 @@ void HMI_SDCardUpdate() { if (HMI_flag.home_flag) return; if (DWIN_lcd_sd_status != card.isMounted()) { DWIN_lcd_sd_status = card.isMounted(); - //SERIAL_ECHOLNPGM("HMI_SDCardUpdate: ", DWIN_lcd_sd_status); - if (DWIN_lcd_sd_status) { // Media inserted - if (checkkey == SelectFile) - Redraw_SD_List(); - } - else { // Media removed - // clean file icon - if (checkkey == SelectFile) { - Redraw_SD_List(); - } - else if (sdprint && card.isPrinting() && printingIsActive()) { - wait_for_heatup = wait_for_user = false; - HMI_flag.abort_flag = true; // Abort print - } - } + if (IsMenu(FileMenu)) Redraw_SD_List(); + if (!DWIN_lcd_sd_status && SD_Printing()) ui.abort_print(); // Media removed while printing DWIN_UpdateLCD(); } } -// -// The Dashboard is always on-screen, except during -// full-screen modal dialogs. -// +/** + * Dash board and indicators + */ + void DWIN_Draw_Dashboard() { DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, STATUS_Y + 21, DWIN_WIDTH, DWIN_HEIGHT - 1); @@ -1099,7 +1063,7 @@ void DWIN_Draw_Dashboard() { DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 195 + 2 * STAT_CHR_W, 384, thermalManager.fan_speed[0]); #endif - #if BOTH(BABYSTEPPING, HAS_BED_PROBE) + #if HAS_ZOFFSET_ITEM DWINUI::Draw_Icon(planner.leveling_active ? ICON_SetZOffset : ICON_Zoffset, 187, 416); #endif @@ -1116,11 +1080,11 @@ void DWIN_Draw_Dashboard() { void Draw_Info_Menu() { DWINUI::ClearMainArea(); - Draw_Back_First(); if (HMI_IsChinese()) Title.FrameCopy(30, 17, 28, 13); // "Info" else Title.ShowCaption(GET_TEXT_F(MSG_INFO_SCREEN)); + Draw_Menu_Line(0, ICON_Back, GET_TEXT_F(MSG_BACK), false, true); if (HMI_IsChinese()) { DWIN_Frame_AreaCopy(1, 197, 149, 252, 161, 108, 102); // "Size" @@ -1143,15 +1107,6 @@ void Draw_Info_Menu() { } } -void Draw_Print_File_Menu() { - if (HMI_IsChinese()) - Title.FrameCopy(0, 31, 56, 14); // "Print file" - else - Title.ShowCaption(GET_TEXT_F(MSG_MEDIA_MENU)); - Redraw_SD_List(); - TERN_(DASH_REDRAW, DWIN_RedrawDash()); -} - // Main Process void HMI_MainMenu() { EncoderState encoder_diffState = get_encoder_state(); @@ -1180,9 +1135,10 @@ void HMI_MainMenu() { else if (encoder_diffState == ENCODER_DIFF_ENTER) { switch (select_page.now) { case PAGE_PRINT: - checkkey = SelectFile; - card.mount(); - safe_delay(300); + if (HMI_data.MediaAutoMount) { + card.mount(); + safe_delay(800); + }; Draw_Print_File_Menu(); break; case PAGE_PREPARE: Draw_Prepare_Menu(); break; @@ -1193,125 +1149,11 @@ void HMI_MainMenu() { DWIN_UpdateLCD(); } -// Select (and Print) File -void HMI_SelectFile() { - EncoderState encoder_diffState = get_encoder_state(); - - const uint16_t hasUpDir = !card.flag.workDirIsRoot; - - if (encoder_diffState == ENCODER_DIFF_NO) { - #if ENABLED(SCROLL_LONG_FILENAMES) - if (shift_ms && select_file.now >= 1 + hasUpDir) { - // Scroll selected filename every second - const millis_t ms = millis(); - if (ELAPSED(ms, shift_ms)) { - const bool was_reset = shift_amt < 0; - shift_ms = ms + 375UL + was_reset * 250UL; // ms per character - uint8_t shift_new = shift_amt + 1; // Try to shift by... - Draw_SDItem_Shifted(shift_new); // Draw the item - if (!was_reset && shift_new == 0) // Was it limited to 0? - shift_ms = 0; // No scrolling needed - else if (shift_new == shift_amt) // Scroll reached the end - shift_new = -1; // Reset - shift_amt = shift_new; // Set new scroll - } - } - #endif - return; - } - - // First pause is long. Easy. - // On reset, long pause must be after 0. - - const uint16_t fullCnt = nr_sd_menu_items(); - - if (encoder_diffState == ENCODER_DIFF_CW && fullCnt) { - if (select_file.inc(1 + fullCnt)) { - const uint8_t itemnum = select_file.now - 1; // -1 for "Back" - if (TERN0(SCROLL_LONG_FILENAMES, shift_ms)) { // If line was shifted - Erase_Menu_Text(itemnum + MROWS - index_file); // Erase and - Draw_SDItem(itemnum - 1); // redraw - } - if (select_file.now > MROWS && select_file.now > index_file) { // Cursor past the bottom - index_file = select_file.now; // New bottom line - Scroll_Menu(DWIN_SCROLL_UP); - Draw_SDItem(itemnum, MROWS); // Draw and init the shift name - } - else { - Move_Highlight(1, select_file.now + MROWS - index_file); // Just move highlight - TERN_(SCROLL_LONG_FILENAMES, Init_Shift_Name()); // ...and init the shift name - } - TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift()); - } - } - else if (encoder_diffState == ENCODER_DIFF_CCW && fullCnt) { - if (select_file.dec()) { - const uint8_t itemnum = select_file.now - 1; // -1 for "Back" - if (TERN0(SCROLL_LONG_FILENAMES, shift_ms)) { // If line was shifted - Erase_Menu_Text(select_file.now + 1 + MROWS - index_file); // Erase and - Draw_SDItem(itemnum + 1); // redraw - } - if (select_file.now < index_file - MROWS) { // Cursor past the top - index_file--; // New bottom line - Scroll_Menu(DWIN_SCROLL_DOWN); - if (index_file == MROWS) { - Draw_Back_First(); - TERN_(SCROLL_LONG_FILENAMES, shift_ms = 0); - } - else { - Draw_SDItem(itemnum, 0); // Draw the item (and init shift name) - } - } - else { - Move_Highlight(-1, select_file.now + MROWS - index_file); // Just move highlight - TERN_(SCROLL_LONG_FILENAMES, Init_Shift_Name()); // ...and init the shift name - } - TERN_(SCROLL_LONG_FILENAMES, Init_SDItem_Shift()); // Reset left. Init timer. - } - } - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - if (select_file.now == 0) { // Back - select_page.set(PAGE_PRINT); - return Goto_Main_Menu(); - } - else if (hasUpDir && select_file.now == 1) { // CD-Up - SDCard_Up(); - goto HMI_SelectFileExit; - } - else { - const uint16_t filenum = select_file.now - 1 - hasUpDir; - card.getfilename_sorted(SD_ORDER(filenum, card.get_num_Files())); - - // Enter that folder! - if (card.flag.filenameIsDir) { - SDCard_Folder(card.filename); - goto HMI_SelectFileExit; - } - - // Reset highlight for next entry - select_print.reset(); - select_file.reset(); - - // Start choice and print SD file - HMI_flag.heat_flag = true; - HMI_flag.print_finish = false; - - if (card.fileIsBinary()) - return DWIN_Popup_Confirm(ICON_Error, F("Please check filenames"), F("Only G-code can be printed")); - else - return Goto_ConfirmToPrint(); - } - } - - HMI_SelectFileExit: - DWIN_UpdateLCD(); -} - // Pause or Stop popup void onClick_PauseOrStop() { switch (select_print.now) { - case PRINT_PAUSE_RESUME: if (HMI_flag.select_flag) HMI_flag.pause_flag = true; break; // confirm pause - case PRINT_STOP: if (HMI_flag.select_flag) HMI_flag.abort_flag = true; break; // stop confirmed then abort print + case PRINT_PAUSE_RESUME: if (HMI_flag.select_flag) ui.pause_print(); break; // confirm pause + case PRINT_STOP: if (HMI_flag.select_flag) ui.abort_print(); break; // stop confirmed then abort print default: break; } return Goto_PrintProcess(); @@ -1363,20 +1205,21 @@ void HMI_Printing() { void Draw_Main_Area() { switch (checkkey) { case MainMenu: Draw_Main_Menu(); break; - case SelectFile: Draw_Print_File_Menu(); break; case PrintProcess: Draw_PrintProcess(); break; case PrintDone: Draw_PrintDone(); break; #if HAS_ESDIAG case ESDiagProcess: Draw_EndStopDiag(); break; #endif case Popup: popupDraw(); break; - case Locked: lockScreen.draw(); break; + #if HAS_LOCKSCREEN + case Locked: lockScreen.draw(); break; + #endif case Menu: case SetInt: case SetPInt: case SetIntNoDraw: case SetFloat: - case SetPFloat: ReDrawMenu(); break; + case SetPFloat: ReDrawMenu(true); break; default: break; } } @@ -1388,27 +1231,35 @@ void HMI_ReturnScreen() { } void HMI_WaitForUser() { - get_encoder_state(); + EncoderState encoder_diffState = get_encoder_state(); + if (encoder_diffState != ENCODER_DIFF_NO && !ui.backlight) { + if (checkkey == WaitResponse) HMI_ReturnScreen(); + return ui.refresh_brightness(); + } if (!wait_for_user) { switch (checkkey) { case PrintDone: select_page.reset(); Goto_Main_Menu(); break; - TERN_(HAS_ONESTEP_LEVELING, case Leveling:) - default: HMI_ReturnScreen(); break; + #if HAS_BED_PROBE + case Leveling: + #endif + default: + HMI_ReturnScreen(); + break; } } } void HMI_Init() { - DWINUI::Draw_Box(1, Color_Black, {5, 220, DWIN_WIDTH-5, DWINUI::fontHeight()}); + DWINUI::Draw_Box(1, Color_Black, { 5, 220, DWIN_WIDTH - 5, DWINUI::fontHeight() }); DWINUI::Draw_CenteredString(Color_White, 220, F("Professional Firmware ")); - for (uint16_t t = 0; t <= 100; t += 2) { + for (uint16_t t = 15; t <= 257; t += 10) { DWINUI::Draw_Icon(ICON_Bar, 15, 260); - DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 15 + t * 242 / 100, 260, 257, 280); + DWIN_Draw_Rectangle(1, HMI_data.Background_Color, t, 260, 257, 280); DWIN_UpdateLCD(); - delay(20); + delay(50); } HMI_SetLanguage(); } @@ -1419,12 +1270,13 @@ void EachMomentUpdate() { if (ELAPSED(ms, next_var_update_ms)) { next_var_update_ms = ms + DWIN_VAR_UPDATE_INTERVAL; + blink = !blink; update_variable(); #if HAS_ESDIAG if (checkkey == ESDiagProcess) ESDiag.Update(); #endif #if HAS_PIDPLOT - if (checkkey == PidProcess) Plot.Update((HMI_value.pidresult == PID_EXTR_START) ? thermalManager.wholeDegHotend(0) : thermalManager.wholeDegBed()); + if (checkkey == PidProcess) Plot.Update((HMI_value.pidresult == PIDTEMP_START) ? thermalManager.wholeDegHotend(0) : thermalManager.wholeDegBed()); #endif } @@ -1437,73 +1289,73 @@ void EachMomentUpdate() { if (ELAPSED(ms, next_status_update_ms)) { next_status_update_ms = ms + 500; DWIN_DrawStatusMessage(); + #if ENABLED(SCROLL_LONG_FILENAMES) + if (IsMenu(FileMenu)) FileMenuIdle(); + #endif } - if (PENDING(ms, next_rts_update_ms)) return; - next_rts_update_ms = ms + DWIN_SCROLL_UPDATE_INTERVAL; - - if (checkkey == PrintProcess) { // print process + if (!PENDING(ms, next_rts_update_ms)) { + next_rts_update_ms = ms + DWIN_UPDATE_INTERVAL; - // Print pause - if (HMI_flag.pause_flag && !HMI_flag.home_flag) { - HMI_flag.pause_flag = false; - if (!HMI_flag.pause_action) { - HMI_flag.pause_action = true; - return ui.pause_print(); - } + if ((Printing() != HMI_flag.printing_flag) && !HMI_flag.home_flag) { + HMI_flag.printing_flag = Printing(); + DEBUG_ECHOLNPGM("printing_flag: ", HMI_flag.printing_flag); + if (HMI_flag.printing_flag) + DWIN_Print_Started(); + else if (HMI_flag.abort_flag) + DWIN_Print_Aborted(); + else + DWIN_Print_Finished(); } - // if print done - if (HMI_flag.print_finish && !HMI_flag.home_flag) { - HMI_flag.print_finish = false; - return DWIN_Print_Finished(); + if ((printingIsPaused() != HMI_flag.pause_flag) && !HMI_flag.home_flag) { + HMI_flag.pause_flag = printingIsPaused(); + DEBUG_ECHOLNPGM("pause_flag: ", HMI_flag.pause_flag); + if (HMI_flag.pause_flag) + DWIN_Print_Pause(); + else if (HMI_flag.abort_flag) + DWIN_Print_Aborted(); + else + DWIN_Print_Resume(); } - // if print was aborted - if (HMI_flag.abort_flag && !HMI_flag.home_flag) { // Print Stop - HMI_flag.abort_flag = false; - if (!HMI_flag.abort_action) { - HMI_flag.abort_action = true; - ui.abort_print(); - return Goto_PrintDone(); - } - } + if (checkkey == PrintProcess) { // print process - duration_t elapsed = print_job_timer.duration(); // print timer + duration_t elapsed = print_job_timer.duration(); // print timer - if (sdprint && card.isPrinting() && !HMI_flag.percent_flag) { - uint8_t percentDone = card.percentDone(); - if (_percent_done != percentDone) { // print percent - _percent_done = percentDone; - Draw_Print_ProgressBar(); + if (card.isPrinting() && !HMI_flag.percent_flag) { + uint8_t percentDone = card.percentDone(); + if (_percent_done != percentDone) { // print percent + _percent_done = percentDone; + Draw_Print_ProgressBar(); } - // Estimate remaining time every 20 seconds - static millis_t next_remain_time_update = 0; - if (_percent_done > 1 && ELAPSED(ms, next_remain_time_update) && !HMI_flag.heat_flag && !HMI_flag.remain_flag) { - _remain_time = (elapsed.value - dwin_heat_time) / (_percent_done * 0.01f) - (elapsed.value - dwin_heat_time); - next_remain_time_update += DWIN_REMAIN_TIME_UPDATE_INTERVAL; - Draw_Print_ProgressRemain(); + // Estimate remaining time every 20 seconds + static millis_t next_remain_time_update = 0; + if (_percent_done > 1 && ELAPSED(ms, next_remain_time_update) && !HMI_flag.heat_flag && !HMI_flag.remain_flag) { + _remain_time = (elapsed.value - dwin_heat_time) / (_percent_done * 0.01f) - (elapsed.value - dwin_heat_time); + next_remain_time_update += DWIN_REMAIN_TIME_UPDATE_INTERVAL; + Draw_Print_ProgressRemain(); + } } - } - - // Print time so far - static uint16_t last_Printtime = 0; - const uint16_t min = (elapsed.value % 3600) / 60; - if (last_Printtime != min) { // 1 minute update - last_Printtime = min; - Draw_Print_ProgressElapsed(); - } - } + // Print time so far + static uint16_t last_Printtime = 0; + const uint16_t min = (elapsed.value % 3600) / 60; + if (last_Printtime != min) { // 1 minute update + last_Printtime = min; + Draw_Print_ProgressElapsed(); + } - #if ENABLED(POWER_LOSS_RECOVERY) - else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off - return Goto_PowerLossRecovery(); } - #endif // POWER_LOSS_RECOVERY + #if ENABLED(POWER_LOSS_RECOVERY) + else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off + return Goto_PowerLossRecovery(); + } + #endif // POWER_LOSS_RECOVERY - DWIN_UpdateLCD(); + DWIN_UpdateLCD(); + } } #if ENABLED(POWER_LOSS_RECOVERY) @@ -1523,7 +1375,7 @@ void EachMomentUpdate() { DWINUI::Draw_Button(BTN_Cancel, 26, 280); DWINUI::Draw_Button(BTN_Continue, 146, 280); } - SdFile *dir = nullptr; + MediaFile *dir = nullptr; const char * const filename = card.diveToFile(true, dir, recovery.info.sd_filename); card.selectFileByName(filename); DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 207, card.longest_filename()); @@ -1540,8 +1392,6 @@ void EachMomentUpdate() { else { select_print.set(PRINT_SETUP); queue.inject(F("M1000")); - sdprint = true; - return Goto_PrintProcess(); } } @@ -1558,16 +1408,17 @@ void DWIN_HandleScreen() { switch (checkkey) { case MainMenu: HMI_MainMenu(); break; case Menu: HMI_Menu(); break; - case SetInt: HMI_SetInt(); break; + case SetInt: HMI_SetDraw(); break; + case SetFloat: HMI_SetDraw(); break; case SetPInt: HMI_SetPInt(); break; - case SetIntNoDraw: HMI_SetIntNoDraw(); break; - case SetFloat: HMI_SetFloat(); break; case SetPFloat: HMI_SetPFloat(); break; - case SelectFile: HMI_SelectFile(); break; + case SetIntNoDraw: HMI_SetNoDraw(); break; case PrintProcess: HMI_Printing(); break; case Popup: HMI_Popup(); break; case Leveling: break; - case Locked: HMI_LockScreen(); break; + #if HAS_LOCKSCREEN + case Locked: HMI_LockScreen(); break; + #endif case PrintDone: TERN_(HAS_ESDIAG, case ESDiagProcess:) case WaitResponse: HMI_WaitForUser(); break; @@ -1609,15 +1460,11 @@ void DWIN_HomingStart() { void DWIN_HomingDone() { HMI_flag.home_flag = false; - #if ENABLED(MESH_BED_LEVELING) && EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) - planner.synchronize(); - babystep.add_mm(Z_AXIS, HMI_data.ManualZOffset); - #endif - if (HMI_flag.abort_action) DWIN_Print_Aborted(); else HMI_ReturnScreen(); + HMI_ReturnScreen(); } void DWIN_LevelingStart() { - #if HAS_ONESTEP_LEVELING + #if HAS_BED_PROBE HMI_SaveProcessID(Leveling); Title.ShowCaption(GET_TEXT_F(MSG_BED_LEVELING)); DWIN_Show_Popup(ICON_AutoLeveling, GET_TEXT_F(MSG_BED_LEVELING), GET_TEXT_F(MSG_PLEASE_WAIT)); @@ -1643,10 +1490,10 @@ void DWIN_LevelingDone() { } #if HAS_MESH - void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { + void DWIN_MeshUpdate(const int8_t cpos, const int8_t tpos, const_float_t zval) { char msg[33] = ""; char str_1[6] = ""; - sprintf_P(msg, PSTR(S_FMT " %i/%i Z=%s"), GET_TEXT(MSG_PROBING_POINT), xpos, ypos, dtostrf(zval, 1, 2, str_1)); + sprintf_P(msg, PSTR(S_FMT " %i/%i Z=%s"), GET_TEXT(MSG_PROBING_POINT), cpos, tpos, dtostrf(zval, 1, 2, str_1)); ui.set_status(msg); } #endif @@ -1661,96 +1508,102 @@ void DWIN_LevelingDone() { DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 100, GET_TEXT_F(MSG_PID_AUTOTUNE)); DWINUI::Draw_String(HMI_data.PopupTxt_Color, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("PID target: Celsius")); switch (HMI_value.pidresult) { - case PID_EXTR_START: - DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for Nozzle is running.")); - Plot.Draw(gfrm, thermalManager.hotend_maxtemp[0], HMI_data.HotendPidT); - DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, HMI_data.HotendPidT); - break; - case PID_BED_START: - DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for BED is running.")); - Plot.Draw(gfrm, BED_MAXTEMP, HMI_data.BedPidT); - DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, HMI_data.BedPidT); - break; - default: - break; + #if ENABLED(PIDTEMP) + case PIDTEMP_START: + DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for Nozzle is running.")); + Plot.Draw(gfrm, thermalManager.hotend_maxtemp[0], HMI_data.HotendPidT); + DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, HMI_data.HotendPidT); + break; + #endif + #if ENABLED(PIDTEMPBED) + case PIDTEMPBED_START: + DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for BED is running.")); + Plot.Draw(gfrm, BED_MAXTEMP, HMI_data.BedPidT); + DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, HMI_data.BedPidT); + break; + #endif + default: break; } } #endif -void DWIN_PidTuning(pidresult_t result) { - HMI_value.pidresult = result; - switch (result) { - case PID_BED_START: - HMI_SaveProcessID(PidProcess); - #if HAS_PIDPLOT - DWIN_Draw_PIDPopup(); - #else - DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for BED is running.")); +#if EITHER(PIDTEMP, PIDTEMPBED) + + void DWIN_PidTuning(pidresult_t result) { + HMI_value.pidresult = result; + switch (result) { + #if ENABLED(PIDTEMP) + case PIDTEMP_START: + HMI_SaveProcessID(PidProcess); + #if HAS_PIDPLOT + DWIN_Draw_PIDPopup(); + #else + DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for Nozzle is running.")); + #endif + break; + case PID_BAD_EXTRUDER_NUM: + checkkey = last_checkkey; + DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_PID_AUTOTUNE_FAILED), GET_TEXT_F(MSG_BAD_EXTRUDER_NUM)); + break; #endif - break; - case PID_EXTR_START: - HMI_SaveProcessID(PidProcess); - #if HAS_PIDPLOT - DWIN_Draw_PIDPopup(); - #else - DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for Nozzle is running.")); + #if ENABLED(PIDTEMPBED) + case PIDTEMPBED_START: + HMI_SaveProcessID(PidProcess); + #if HAS_PIDPLOT + DWIN_Draw_PIDPopup(); + #else + DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for BED is running.")); + #endif + break; #endif - break; - case PID_BAD_EXTRUDER_NUM: - checkkey = last_checkkey; - DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_PID_AUTOTUNE_FAILED), GET_TEXT_F(MSG_BAD_EXTRUDER_NUM)); - break; - case PID_TUNING_TIMEOUT: - checkkey = last_checkkey; - DWIN_Popup_Confirm(ICON_TempTooHigh, GET_TEXT_F(MSG_ERROR), GET_TEXT_F(MSG_PID_TIMEOUT)); - break; - case PID_TEMP_TOO_HIGH: - checkkey = last_checkkey; - DWIN_Popup_Confirm(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE_FAILED), GET_TEXT_F(MSG_TEMP_TOO_HIGH)); - break; - case PID_DONE: - checkkey = last_checkkey; - DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_PID_AUTOTUNE), GET_TEXT_F(MSG_BUTTON_DONE)); - break; - default: - checkkey = last_checkkey; - break; + case PID_TUNING_TIMEOUT: + checkkey = last_checkkey; + DWIN_Popup_Confirm(ICON_TempTooHigh, GET_TEXT_F(MSG_ERROR), GET_TEXT_F(MSG_PID_TIMEOUT)); + break; + case PID_TEMP_TOO_HIGH: + checkkey = last_checkkey; + DWIN_Popup_Confirm(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE_FAILED), GET_TEXT_F(MSG_TEMP_TOO_HIGH)); + break; + case PID_DONE: + checkkey = last_checkkey; + DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_PID_AUTOTUNE), GET_TEXT_F(MSG_BUTTON_DONE)); + break; + default: checkkey = last_checkkey; break; + } } -} + +#endif // PIDTEMP || PIDTEMPBED // Started a Print Job -void DWIN_Print_Started(const bool sd) { - sdprint = IS_SD_PRINTING() || sd; +void DWIN_Print_Started() { + DEBUG_ECHOLNPGM("DWIN_Print_Started: ", SD_Printing()); + TERN_(HAS_GCODE_PREVIEW, if (Host_Printing()) Preview_Invalidate()); _percent_done = 0; _remain_time = 0; HMI_flag.percent_flag = false; HMI_flag.remain_flag = false; HMI_flag.pause_flag = false; - HMI_flag.pause_action = false; HMI_flag.abort_flag = false; - HMI_flag.abort_action = false; - HMI_flag.print_finish = false; + select_print.reset(); Goto_PrintProcess(); } // Pause a print job void DWIN_Print_Pause() { + DEBUG_ECHOLNPGM("DWIN_Print_Pause"); ICON_ResumeOrPause(); } // Resume print job void DWIN_Print_Resume() { - HMI_flag.pause_action = false; + DEBUG_ECHOLNPGM("DWIN_Print_Resume"); ICON_ResumeOrPause(); - if (printJobOngoing()) { - LCD_MESSAGE(MSG_RESUME_PRINT); - Goto_PrintProcess(); - } + LCD_MESSAGE(MSG_RESUME_PRINT); } // Ended print job void DWIN_Print_Finished() { - if (HMI_flag.abort_flag || checkkey == PrintDone) return; + DEBUG_ECHOLNPGM("DWIN_Print_Finished"); TERN_(POWER_LOSS_RECOVERY, if (card.isPrinting()) recovery.cancel()); HMI_flag.pause_flag = false; wait_for_heatup = false; @@ -1761,15 +1614,11 @@ void DWIN_Print_Finished() { // Print was aborted void DWIN_Print_Aborted() { - TERN_(DEBUG_DWIN, SERIAL_ECHOLNPGM("DWIN_Print_Aborted")); - HMI_flag.abort_action = false; - wait_for_heatup = false; - planner.finish_and_disable(); - thermalManager.cooldown(); - Goto_PrintDone(); + DEBUG_ECHOLNPGM("DWIN_Print_Aborted"); + DWIN_Print_Finished(); } -// Progress Bar update +// Progress and remaining time update void DWIN_M73() { if (parser.seenval('P')) { _percent_done = parser.value_byte(); @@ -1793,16 +1642,16 @@ void DWIN_M73() { void DWIN_SetColorDefaults() { HMI_data.Background_Color = Def_Background_Color; - HMI_data.Cursor_color = Def_Cursor_color; - HMI_data.TitleBg_color = Def_TitleBg_color; - HMI_data.TitleTxt_color = Def_TitleTxt_color; + HMI_data.Cursor_Color = Def_Cursor_Color; + HMI_data.TitleBg_Color = Def_TitleBg_Color; + HMI_data.TitleTxt_Color = Def_TitleTxt_Color; HMI_data.Text_Color = Def_Text_Color; HMI_data.Selected_Color = Def_Selected_Color; HMI_data.SplitLine_Color = Def_SplitLine_Color; HMI_data.Highlight_Color = Def_Highlight_Color; HMI_data.StatusBg_Color = Def_StatusBg_Color; HMI_data.StatusTxt_Color = Def_StatusTxt_Color; - HMI_data.PopupBg_color = Def_PopupBg_color; + HMI_data.PopupBg_Color = Def_PopupBg_Color; HMI_data.PopupTxt_Color = Def_PopupTxt_Color; HMI_data.AlertBg_Color = Def_AlertBg_Color; HMI_data.AlertTxt_Color = Def_AlertTxt_Color; @@ -1813,74 +1662,78 @@ void DWIN_SetColorDefaults() { } void DWIN_SetDataDefaults() { + DEBUG_ECHOLNPGM("DWIN_SetDataDefaults"); DWIN_SetColorDefaults(); DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); - TERN_(HAS_HOTEND, HMI_data.HotendPidT = PREHEAT_1_TEMP_HOTEND); - TERN_(HAS_HEATED_BED, HMI_data.BedPidT = PREHEAT_1_TEMP_BED); - TERN_(HAS_HOTEND, HMI_data.PidCycles = 5); + TERN_(PIDTEMP, HMI_data.HotendPidT = DEF_HOTENDPIDT); + TERN_(PIDTEMPBED, HMI_data.BedPidT = DEF_BEDPIDT); + TERN_(HAS_PID_HEATING, HMI_data.PidCycles = DEF_PIDCYCLES); #if ENABLED(PREVENT_COLD_EXTRUSION) HMI_data.ExtMinT = EXTRUDE_MINTEMP; ApplyExtMinT(); #endif - #if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) - HMI_data.BedLevT = LEVELING_BED_TEMP; - #endif + TERN_(PREHEAT_BEFORE_LEVELING, HMI_data.BedLevT = LEVELING_BED_TEMP); TERN_(BAUD_RATE_GCODE, SetBaud250K()); + HMI_data.FullManualTramming = false; + HMI_data.MediaAutoMount = ENABLED(HAS_SD_EXTENDER); + #if BOTH(INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) + HMI_data.z_after_homing = DEF_Z_AFTER_HOMING; + #endif #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) - leds.set_default(); + TERN_(LED_COLOR_PRESETS, leds.set_default()); ApplyLEDColor(); #endif } void DWIN_CopySettingsTo(char * const buff) { + DEBUG_ECHOLNPGM("DWIN_CopySettingsTo"); + DEBUG_ECHOLNPGM("HMI_data: ", sizeof(HMI_data_t)); memcpy(buff, &HMI_data, eeprom_data_size); } void DWIN_CopySettingsFrom(const char * const buff) { + DEBUG_ECHOLNPGM("DWIN_CopySettingsFrom"); memcpy(&HMI_data, buff, sizeof(HMI_data_t)); if (HMI_data.Text_Color == HMI_data.Background_Color) DWIN_SetColorDefaults(); DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); TERN_(PREVENT_COLD_EXTRUSION, ApplyExtMinT()); feedrate_percentage = 100; TERN_(BAUD_RATE_GCODE, HMI_SetBaudRate()); - #if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) - // Apply Case light brightness - caselight.brightness = HMI_data.CaseLight_Brightness; - caselight.update_brightness(); - #endif #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) leds.set_color( - (HMI_data.LED_Color >> 16) & 0xFF, - (HMI_data.LED_Color >> 8) & 0xFF, - (HMI_data.LED_Color >> 0) & 0xFF - OPTARG(HAS_WHITE_LED, (HMI_data.LED_Color >> 24) & 0xFF) + HMI_data.Led_Color.r, + HMI_data.Led_Color.g, + HMI_data.Led_Color.b + OPTARG(HAS_WHITE_LED, HMI_data.Led_Color.w) ); leds.update(); #endif - } // Initialize or re-initialize the LCD void MarlinUI::init_lcd() { - TERN_(DEBUG_DWIN, SERIAL_ECHOLNPGM("DWIN_Startup")); - DWINUI::init(); + DEBUG_ECHOLNPGM("MarlinUI::init_lcd"); + delay(750); // wait to wakeup screen + const bool hs = DWIN_Handshake(); UNUSED(hs); + DEBUG_ECHOPGM("DWIN_Handshake "); + DEBUG_ECHOLNF(hs ? F("ok.") : F("error.")); + DWIN_Frame_SetDir(1); DWIN_JPG_CacheTo1(Language_English); Encoder_Configuration(); } void DWIN_InitScreen() { + DEBUG_ECHOLNPGM("DWIN_InitScreen"); + DWIN_SetColorDefaults(); HMI_Init(); // draws boot screen - onCursorDraw = Draw_Menu_Cursor; - onCursorErase = Erase_Menu_Cursor; + DWINUI::init(); + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); DWINUI::onTitleDraw = Draw_Title; - onMenuDraw = Draw_Menu; + InitMenu(); checkkey = 255; - CurrentMenu = nullptr; - PreviousMenu = nullptr; - index_file = MROWS; hash_changed = true; last_E = 0; - DWIN_DrawStatusLine(FSTR_P(nullptr)); + DWIN_DrawStatusLine(); DWIN_Draw_Dashboard(); Goto_Main_Menu(); } @@ -1932,12 +1785,12 @@ void DWIN_RedrawScreen() { //if (mode == PAUSE_MODE_SAME) return; pause_mode = mode; switch (message) { - case PAUSE_MESSAGE_PARKING: DWIN_Popup_Pause(GET_TEXT_F(MSG_PAUSE_PRINT_PARKING)); break; // M125 - case PAUSE_MESSAGE_CHANGING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INIT)); break; // pause_print (M125, M600) + case PAUSE_MESSAGE_PARKING: DWIN_Popup_Pause(GET_TEXT_F(MSG_PAUSE_PRINT_PARKING)); break; // M125 + case PAUSE_MESSAGE_CHANGING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INIT)); break; // pause_print (M125, M600) case PAUSE_MESSAGE_WAITING: DWIN_Popup_Pause(GET_TEXT_F(MSG_ADVANCED_PAUSE_WAITING), BTN_Continue); break; - case PAUSE_MESSAGE_INSERT: DWIN_Popup_Continue(ICON_BLTouch, GET_TEXT_F(MSG_ADVANCED_PAUSE), GET_TEXT_F(MSG_FILAMENT_CHANGE_INSERT)); break; + case PAUSE_MESSAGE_INSERT: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INSERT), BTN_Continue); break; case PAUSE_MESSAGE_LOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_LOAD)); break; - case PAUSE_MESSAGE_UNLOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); break; // Unload of pause and Unload of M702 + case PAUSE_MESSAGE_UNLOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); break; // Unload of pause and Unload of M702 case PAUSE_MESSAGE_PURGE: #if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE) DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_CONT_PURGE)); @@ -1949,7 +1802,7 @@ void DWIN_RedrawScreen() { case PAUSE_MESSAGE_RESUME: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_RESUME)); break; case PAUSE_MESSAGE_HEAT: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_HEAT), BTN_Continue); break; case PAUSE_MESSAGE_HEATING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_HEATING)); break; - case PAUSE_MESSAGE_STATUS: HMI_ReturnScreen(); break; // Exit from Pause, Load and Unload + case PAUSE_MESSAGE_STATUS: HMI_ReturnScreen(); break; // Exit from Pause, Load and Unload default: break; } } @@ -1962,13 +1815,13 @@ void DWIN_RedrawScreen() { } void onClick_FilamentPurge() { - if (HMI_flag.select_flag) - pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; // "Purge More" button - else { - HMI_SaveProcessID(NothingToDo); - pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; // "Continue" button - } + if (HMI_flag.select_flag) + pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; // "Purge More" button + else { + HMI_SaveProcessID(NothingToDo); + pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; // "Continue" button } + } void Goto_FilamentPurge() { pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; @@ -1978,6 +1831,7 @@ void DWIN_RedrawScreen() { #endif // ADVANCED_PAUSE_FEATURE #if HAS_MESH + void DWIN_MeshViewer() { if (!leveling_is_valid()) DWIN_Popup_Continue(ICON_BLTouch, GET_TEXT_F(MSG_MESH_VIEWER), GET_TEXT_F(MSG_NO_VALID_MESH)); @@ -1986,55 +1840,60 @@ void DWIN_RedrawScreen() { MeshViewer.Draw(); } } + #endif // HAS_MESH -void DWIN_LockScreen() { - if (checkkey != Locked) { - lockScreen.rprocess = checkkey; - checkkey = Locked; - lockScreen.init(); +#if HAS_LOCKSCREEN + + void DWIN_LockScreen() { + if (checkkey != Locked) { + lockScreen.rprocess = checkkey; + checkkey = Locked; + lockScreen.init(); + } } -} -void DWIN_UnLockScreen() { - if (checkkey == Locked) { - checkkey = lockScreen.rprocess; - Draw_Main_Area(); + void DWIN_UnLockScreen() { + if (checkkey == Locked) { + checkkey = lockScreen.rprocess; + Draw_Main_Area(); + } } -} -void HMI_LockScreen() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - lockScreen.onEncoder(encoder_diffState); - if (lockScreen.isUnlocked()) DWIN_UnLockScreen(); -} + void HMI_LockScreen() { + EncoderState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_NO) return; + lockScreen.onEncoder(encoder_diffState); + if (lockScreen.isUnlocked()) DWIN_UnLockScreen(); + } +#endif // HAS_LOCKSCREEN #if HAS_GCODE_PREVIEW void onClick_ConfirmToPrint() { + Preview_Reset(); + DWIN_ResetStatusLine(); if (HMI_flag.select_flag) { // Confirm - card.openAndPrintFile(card.filename); - return DWIN_Print_Started(true); - } - else { // Cancel - DWIN_ResetStatusLine(); - checkkey = SelectFile; - return Draw_Print_File_Menu(); + HMI_flag.heat_flag = true; + Goto_Main_Menu(); + return card.openAndPrintFile(card.filename); } + else + HMI_ReturnScreen(); } - void Goto_ConfirmToPrint() { - Goto_Popup(Preview_DrawFromSD, onClick_ConfirmToPrint); - } +#endif -#else - void Goto_ConfirmToPrint() { +void Goto_ConfirmToPrint() { + #if HAS_GCODE_PREVIEW + Goto_Popup(Preview_DrawFromSD, onClick_ConfirmToPrint); + #else + // Print SD file + HMI_flag.heat_flag = true; card.openAndPrintFile(card.filename); - DWIN_Print_Started(true); - } -#endif + #endif +} #if HAS_ESDIAG void Draw_EndStopDiag() { @@ -2050,6 +1909,7 @@ void HMI_LockScreen() { // Tool functions #if ENABLED(EEPROM_SETTINGS) + void WriteEeprom() { DWIN_DrawStatusLine(GET_TEXT_F(MSG_STORE_EEPROM)); DWIN_UpdateLCD(); @@ -2069,8 +1929,9 @@ void HMI_LockScreen() { } #if HAS_MESH - void SaveMesh() { TERN(AUTO_BED_LEVELING_UBL, UBLSaveMesh(), WriteEeprom()); } + void SaveMesh() { TERN(AUTO_BED_LEVELING_UBL, UBLMeshSave(), WriteEeprom()); } #endif + #endif // Reset Printer @@ -2088,13 +1949,6 @@ void Goto_Info_Menu() { HMI_SaveProcessID(WaitResponse); } -void Goto_Move_Menu() { - #if HAS_HOTEND - gcode.process_subcommands_now(F("G92E0")); // reset extruder position - #endif - Draw_Move_Menu(); -} - void DisableMotors() { queue.inject(F("M84")); } void AutoLev() { // Always reacquire the Z "home" position @@ -2102,15 +1956,24 @@ void AutoLev() { // Always reacquire the Z "home" position } void AutoHome() { queue.inject_P(G28_STR); } -void HomeX() { queue.inject(F("G28X")); } -void HomeY() { queue.inject(F("G28Y")); } -void HomeZ() { queue.inject(F("G28Z")); } -void SetHome() { +#if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) + void HomeX() { queue.inject(F("G28X")); } + void HomeY() { queue.inject(F("G28Y")); } + void HomeZ() { queue.inject(F("G28Z")); } + #if BOTH(INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) + void ApplyZAfterHoming() { HMI_data.z_after_homing = MenuData.Value; }; + void SetZAfterHoming() { SetIntOnClick(0, 20, HMI_data.z_after_homing, ApplyZAfterHoming); } + #endif +#endif + +#if HAS_HOME_OFFSET // Apply workspace offset, making the current position 0,0,0 - queue.inject(F("G92X0Y0Z0")); - DONE_BUZZ(true); -} + void SetHome() { + queue.inject(F("G92X0Y0Z0")); + DONE_BUZZ(true); + } +#endif #if HAS_ZOFFSET_ITEM @@ -2119,46 +1982,45 @@ void SetHome() { #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) const_float_t step_zoffset = round((MenuData.Value / 100.0f) * planner.settings.axis_steps_per_mm[Z_AXIS]) - babystep.accum; if (BABYSTEP_ALLOWED()) babystep.add_steps(Z_AXIS, step_zoffset); + //DEBUG_ECHOLNF(F("BB Steps: "), step_zoffset); #endif } - - #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) - void SetZOffset() { + void SetZOffset() { + #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) babystep.accum = round(planner.settings.axis_steps_per_mm[Z_AXIS] * BABY_Z_VAR); - SetPFloatOnClick(Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX, 2, ApplyZOffset, LiveZOffset); - } - #endif + #endif + SetPFloatOnClick(Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX, 2, ApplyZOffset, LiveZOffset); + } void SetMoveZto0() { #if ENABLED(Z_SAFE_HOMING) char cmd[54], str_1[5], str_2[5]; - sprintf_P(cmd, PSTR("G28XYO\nG28Z\nG0X%sY%sF5000\nM420S0\nG0Z0F300\nM400"), + sprintf_P(cmd, PSTR("G28XYO\nG28Z\nG0X%sY%sF5000\nG0Z0F300\nM400"), dtostrf(Z_SAFE_HOMING_X_POINT, 1, 1, str_1), dtostrf(Z_SAFE_HOMING_Y_POINT, 1, 1, str_2) ); gcode.process_subcommands_now(cmd); #else - gcode.process_subcommands_now(F("G28O\nM420S0\nG0Z0F300\nM400")); + TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); + gcode.process_subcommands_now(F("G28Z\nG0Z0F300\nM400")); #endif ui.reset_status(); DONE_BUZZ(true); } - void HomeZandDisable() { - SetMoveZto0(); - DisableMotors(); - } + #if !HAS_BED_PROBE + void HomeZandDisable() { + SetMoveZto0(); + DisableMotors(); + } + #endif #endif // HAS_ZOFFSET_ITEM #if HAS_PREHEAT - void DoPreheat0() { ui.preheat_all(0); } - #if PREHEAT_COUNT >= 2 - void DoPreheat1() { ui.preheat_all(1); } - #if PREHEAT_COUNT >= 3 - void DoPreheat2() { ui.preheat_all(2); } - #endif - #endif + #define _DoPreheat(N) void DoPreheat##N() { ui.preheat_all(N-1); }\ + void DoPreheatHotend##N() { ui.preheat_hotend(N-1); } + REPEAT_1(PREHEAT_COUNT, _DoPreheat) #endif void DoCoolDown() { thermalManager.cooldown(); } @@ -2169,64 +2031,62 @@ void SetLanguage() { Draw_Prepare_Menu(); } +bool EnableLiveMove = false; +void SetLiveMove() { Toggle_Chkb_Line(EnableLiveMove); } void LiveMove() { + planner.synchronize(); + if (!EnableLiveMove) return; *MenuData.P_Float = MenuData.Value / MINUNITMULT; - if (!planner.is_full()) { - planner.synchronize(); - planner.buffer_line(current_position, homing_feedrate(HMI_value.axis)); - } + if (!planner.is_full()) planner.buffer_line(current_position, manual_feedrate_mm_s[HMI_value.axis]); } -void ApplyMoveE() { - last_E = MenuData.Value / MINUNITMULT; - if (!planner.is_full()) { - planner.synchronize(); - planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E)); - } +void ApplyMove() { + planner.synchronize(); + if (EnableLiveMove) return; + if (HMI_value.axis == E_AXIS) last_E = MenuData.Value / MINUNITMULT; + if (!planner.is_full()) planner.buffer_line(current_position, manual_feedrate_mm_s[HMI_value.axis]); } -void SetMoveX() { HMI_value.axis = X_AXIS; SetPFloatOnClick(X_MIN_POS, X_MAX_POS, UNITFDIGITS, planner.synchronize, LiveMove); } -void SetMoveY() { HMI_value.axis = Y_AXIS; SetPFloatOnClick(Y_MIN_POS, Y_MAX_POS, UNITFDIGITS, planner.synchronize, LiveMove); } -void SetMoveZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick(Z_MIN_POS, Z_MAX_POS, UNITFDIGITS, planner.synchronize, LiveMove); } + +void SetMoveX() { HMI_value.axis = X_AXIS; SetPFloatOnClick(X_MIN_POS, X_MAX_POS, UNITFDIGITS, ApplyMove, LiveMove); } +void SetMoveY() { HMI_value.axis = Y_AXIS; SetPFloatOnClick(Y_MIN_POS, Y_MAX_POS, UNITFDIGITS, ApplyMove, LiveMove); } +void SetMoveZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick(Z_MIN_POS, Z_MAX_POS, UNITFDIGITS, ApplyMove, LiveMove); } #if HAS_HOTEND void SetMoveE() { - #if ENABLED(PREVENT_COLD_EXTRUSION) - if (thermalManager.tooColdToExtrude(0)) - return DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_HOTEND_TOO_COLD), GET_TEXT_F(MSG_PLEASE_PREHEAT)); - #endif - SetPFloatOnClick(last_E - (EXTRUDE_MAXLENGTH), last_E + (EXTRUDE_MAXLENGTH), UNITFDIGITS, ApplyMoveE); + if (thermalManager.tooColdToExtrude(0)) return DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_HOTEND_TOO_COLD), GET_TEXT_F(MSG_PLEASE_PREHEAT)); + HMI_value.axis = E_AXIS; SetPFloatOnClick(E_MIN_POS, E_MAX_POS, UNITFDIGITS, ApplyMove, LiveMove); } #endif -void SetPID(celsius_t t, heater_id_t h) { - char cmd[53] = ""; - char str_1[5] = "", str_2[5] = ""; - sprintf_P(cmd, PSTR("G28OXY\nG0Z5F300\nG0X%sY%sF5000\nM84\nM400"), - dtostrf(X_CENTER, 1, 1, str_1), - dtostrf(Y_CENTER, 1, 1, str_2) - ); - gcode.process_subcommands_now(cmd); - thermalManager.PID_autotune(t, h, HMI_data.PidCycles, true); -} -#if HAS_HOTEND - void HotendPID() { SetPID(HMI_data.HotendPidT, H_E0); } -#endif -#if HAS_HEATED_BED - void BedPID() { SetPID(HMI_data.BedPidT, H_BED); } +#if EITHER(PIDTEMP, PIDTEMPBED) + void SetPID(celsius_t t, heater_id_t h) { + char cmd[53] = ""; + char str_1[5] = "", str_2[5] = ""; + sprintf_P(cmd, PSTR("G28OXY\nG0Z5F300\nG0X%sY%sF5000\nM84\nM400"), + dtostrf(X_CENTER, 1, 1, str_1), + dtostrf(Y_CENTER, 1, 1, str_2) + ); + gcode.process_subcommands_now(cmd); + thermalManager.PID_autotune(t, h, HMI_data.PidCycles, true); + } + #if ENABLED(PIDTEMP) + void HotendPID() { SetPID(HMI_data.HotendPidT, H_E0); } + #endif + #if ENABLED(PIDTEMPBED) + void BedPID() { SetPID(HMI_data.BedPidT, H_BED); } + #endif #endif #if ENABLED(POWER_LOSS_RECOVERY) void SetPwrLossr() { - recovery.enable(!recovery.enabled); - Draw_Chkb_Line(CurrentMenu->line(), recovery.enabled); - DWIN_UpdateLCD(); + Toggle_Chkb_Line(recovery.enabled); + recovery.changed(); } #endif #if ENABLED(BAUD_RATE_GCODE) - void HMI_SetBaudRate() { - if (HMI_data.Baud115K) SetBaud115K(); else SetBaud250K(); - } + void HMI_SetBaudRate() { HMI_data.Baud115K ? SetBaud115K() : SetBaud250K(); } void SetBaudRate() { + HMI_data.Baud115K ^= true; HMI_SetBaudRate(); Draw_Chkb_Line(CurrentMenu->line(), HMI_data.Baud115K); DWIN_UpdateLCD(); @@ -2244,10 +2104,8 @@ void SetPID(celsius_t t, heater_id_t h) { #if ENABLED(CASE_LIGHT_MENU) void SetCaseLight() { - caselight.on = !caselight.on; + Toggle_Chkb_Line(caselight.on); caselight.update_enabled(); - Draw_Chkb_Line(CurrentMenu->line(), caselight.on); - DWIN_UpdateLCD(); } #if ENABLED(CASELIGHT_USES_BRIGHTNESS) void LiveCaseLightBrightness() { caselight.brightness = MenuData.Value; caselight.update_brightness(); } @@ -2259,12 +2117,13 @@ void SetPID(celsius_t t, heater_id_t h) { #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) void SetLedStatus() { leds.toggle(); - Draw_Chkb_Line(CurrentMenu->line(), leds.lights_on); - DWIN_UpdateLCD(); + Show_Chkb_Line(leds.lights_on); } #endif #if HAS_COLOR_LEDS - void ApplyLEDColor() { HMI_data.LED_Color = TERN0(HAS_WHITE_LED, (leds.color.w << 24)) | (leds.color.r << 16) | (leds.color.g << 8) | leds.color.b; } + void ApplyLEDColor() { + HMI_data.Led_Color = LEDColor( {leds.color.r, leds.color.g, leds.color.b OPTARG(HAS_WHITE_LED, HMI_data.Led_Color.w) } ); + } void LiveLEDColor(uint8_t *color) { *color = MenuData.Value; leds.update(); } void LiveLEDColorR() { LiveLEDColor(&leds.color.r); } void LiveLEDColorG() { LiveLEDColor(&leds.color.g); } @@ -2281,9 +2140,7 @@ void SetPID(celsius_t t, heater_id_t h) { #if ENABLED(SOUND_MENU_ITEM) void SetEnableSound() { - ui.sound_on = !ui.sound_on; - Draw_Chkb_Line(CurrentMenu->line(), ui.sound_on); - DWIN_UpdateLCD(); + Toggle_Chkb_Line(ui.sound_on); } #endif @@ -2305,11 +2162,9 @@ void SetPID(celsius_t t, heater_id_t h) { void ProbeStow() { probe.stow(); } void ProbeDeploy() { probe.deploy(); } - #ifdef BLTOUCH_HS_MODE + #if ENABLED(BLTOUCH_HS_MODE) void SetHSMode() { - bltouch.high_speed_mode = !bltouch.high_speed_mode; - Draw_Chkb_Line(CurrentMenu->line(), bltouch.high_speed_mode); - DWIN_UpdateLCD(); + Toggle_Chkb_Line(bltouch.high_speed_mode); } #endif @@ -2318,9 +2173,7 @@ void SetPID(celsius_t t, heater_id_t h) { #if HAS_FILAMENT_SENSOR void SetRunoutEnable() { runout.reset(); - runout.enabled = !runout.enabled; - Draw_Chkb_Line(CurrentMenu->line(), runout.enabled); - DWIN_UpdateLCD(); + Toggle_Chkb_Line(runout.enabled); } #if HAS_FILAMENT_RUNOUT_DISTANCE void ApplyRunoutDistance() { runout.set_runout_distance(MenuData.Value / MINUNITMULT); } @@ -2338,7 +2191,7 @@ void SetPID(celsius_t t, heater_id_t h) { void SetExtMinT() { SetPIntOnClick(MIN_ETEMP, MAX_ETEMP, ApplyExtMinT); } #endif -void RestoreDefaultsColors() { +void RestoreDefaultColors() { DWIN_SetColorDefaults(); DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); DWIN_RedrawScreen(); @@ -2358,7 +2211,7 @@ void LiveRGBColor() { DWIN_Draw_Rectangle(1, color, 20, 315, DWIN_WIDTH - 20, 335); } void SetRGBColor() { - const uint8_t color = CurrentMenu->SelectedItem()->icon; + const uint8_t color = static_cast(CurrentMenu->SelectedItem())->icon; SetIntOnClick(0, (color == 1) ? 63 : 31, HMI_value.Color[color], nullptr, LiveRGBColor); } @@ -2395,10 +2248,12 @@ void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); } queue.inject(F("M600 B2")); } - void ParkHead() { - LCD_MESSAGE(MSG_FILAMENT_PARK_ENABLED); - queue.inject(F("G28O\nG27")); - } + #if ENABLED(NOZZLE_PARK_FEATURE) + void ParkHead() { + LCD_MESSAGE(MSG_FILAMENT_PARK_ENABLED); + queue.inject(F("G28O\nG27")); + } + #endif #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) void UnloadFilament() { @@ -2414,8 +2269,7 @@ void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); } #endif // ADVANCED_PAUSE_FEATURE -void ApplyFlow() { planner.refresh_e_factor(0); } -void SetFlow() { SetPIntOnClick(MIN_PRINT_FLOW, MAX_PRINT_FLOW, ApplyFlow); } +void SetFlow() { SetPIntOnClick(MIN_PRINT_FLOW, MAX_PRINT_FLOW, []{ planner.refresh_e_factor(0); }); } // Bed Tramming @@ -2518,14 +2372,14 @@ void TramBR() { Tram(2); } void TramBL() { Tram(3); } void TramC () { Tram(4); } -#if HAS_BED_PROBE +#if HAS_BED_PROBE && HAS_MESH void Trammingwizard() { - bed_mesh_t zval = {0}; if (HMI_data.FullManualTramming) { LCD_MESSAGE_F("Disable manual tramming"); return; } + bed_mesh_t zval = {0}; zval[0][0] = Tram(0); checkkey = NothingToDo; MeshViewer.DrawMesh(zval, 2, 2); @@ -2546,9 +2400,9 @@ void TramC () { Tram(4); } MeshViewer.DrawMesh(zval, 2, 2); ui.reset_status(); - if (ABS(MeshViewer.max - MeshViewer.min) < 0.05) { - DWINUI::Draw_CenteredString(140,F("Corners leveled")); - DWINUI::Draw_CenteredString(160,F("Tolerance achieved!")); + if (ABS(MeshViewer.max - MeshViewer.min) < 0.05f) { + DWINUI::Draw_CenteredString(140, F("Corners leveled")); + DWINUI::Draw_CenteredString(160, F("Tolerance achieved!")); } else { uint8_t p = 0; @@ -2581,12 +2435,10 @@ void TramC () { Tram(4); } } void SetManualTramming() { - HMI_data.FullManualTramming = !HMI_data.FullManualTramming; - Draw_Chkb_Line(CurrentMenu->line(), HMI_data.FullManualTramming); - DWIN_UpdateLCD(); + Toggle_Chkb_Line(HMI_data.FullManualTramming); } -#endif // HAS_BED_PROBE +#endif // HAS_BED_PROBE && HAS_MESH #if ENABLED(MESH_BED_LEVELING) @@ -2603,7 +2455,7 @@ void TramC () { Tram(4); } *MenuData.P_Float = MenuData.Value / POW(10, 2); if (!planner.is_full()) { planner.synchronize(); - planner.buffer_line(current_position, homing_feedrate(Z_AXIS)); + planner.buffer_line(current_position, manual_feedrate_mm_s[Z_AXIS]); } } void SetMMeshMoveZ() { SetPFloatOnClick(-1, 1, 2, planner.synchronize, LiveMeshMoveZ); } @@ -2650,11 +2502,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 @@ -2663,22 +2515,24 @@ 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() { *MenuData.P_Float = scalePID_i(MenuData.Value / POW(10, 2)); - thermalManager.updatePID(); + TERN_(PIDTEMP, thermalManager.updatePID()); } void ApplyPIDd() { *MenuData.P_Float = scalePID_d(MenuData.Value / POW(10, 2)); - thermalManager.updatePID(); + TERN_(PIDTEMP, thermalManager.updatePID()); } void SetKi() { MenuData.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; @@ -2840,13 +2694,11 @@ void onDrawGetColorItem(MenuItemClass* menuitem, int8_t line) { DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); } -#if HAS_FILAMENT_SENSOR - void onDrawRunoutEnable(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, runout.enabled); } +#if EITHER(PIDTEMP, PIDTEMPBED) + void onDrawPIDi(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_i(*(float*)static_cast(menuitem)->value)); } + void onDrawPIDd(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_d(*(float*)static_cast(menuitem)->value)); } #endif -void onDrawPIDi(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_i(*(float*)static_cast(menuitem)->value)); } -void onDrawPIDd(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 2, unscalePID_d(*(float*)static_cast(menuitem)->value)); } - void onDrawSpeedItem(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) menuitem->SetFrame(1, 116, 164, 171, 176); onDrawPIntMenu(menuitem, line); @@ -2904,16 +2756,6 @@ void onDrawSteps(MenuItemClass* menuitem, int8_t line) { onDrawPIntMenu(menuitem, line); } #endif - void onDrawPLAPreheatSubMenu(MenuItemClass* menuitem, int8_t line) { - if (HMI_IsChinese()) menuitem->SetFrame(1, 100, 89, 178, 101); - onDrawSubMenu(menuitem,line); - } - #if PREHEAT_COUNT >= 2 - void onDrawABSPreheatSubMenu(MenuItemClass* menuitem, int8_t line) { - if (HMI_IsChinese()) menuitem->SetFrame(1, 180, 89, 260, 100); - onDrawSubMenu(menuitem,line); - } - #endif #endif // HAS_PREHEAT void onDrawSpeed(MenuItemClass* menuitem, int8_t line) { @@ -3044,6 +2886,7 @@ void onDrawMaxAccelZ(MenuItemClass* menuitem, int8_t line) { } #if HAS_HOTEND + void onDrawMaxJerkE(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); @@ -3053,6 +2896,7 @@ void onDrawMaxAccelZ(MenuItemClass* menuitem, int8_t line) { } onDrawPFloatMenu(menuitem, line); } + #endif #endif // HAS_CLASSIC_JERK @@ -3082,6 +2926,7 @@ void onDrawStepsZ(MenuItemClass* menuitem, int8_t line) { } #if HAS_HOTEND + void onDrawStepsE(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 153, 148, 194, 161); @@ -3089,6 +2934,7 @@ void onDrawStepsZ(MenuItemClass* menuitem, int8_t line) { } onDrawPFloatMenu(menuitem, line); } + #endif #if HAS_ONESTEP_LEVELING @@ -3097,159 +2943,145 @@ void onDrawStepsZ(MenuItemClass* menuitem, int8_t line) { // Menu Creation and Drawing functions ====================================================== -void SetMenuTitle(frame_rect_t cn, const __FlashStringHelper* fstr) { - if (HMI_IsChinese() && (cn.w != 0)) - CurrentMenu->MenuTitle.SetFrame(cn.x, cn.y, cn.w, cn.h); +frame_rect_t selrect(frame_rect_t) { + if (HMI_IsChinese()) + return {133, 1, 28, 13}; else - CurrentMenu->MenuTitle.SetCaption(fstr); + return{0}; } void Draw_Prepare_Menu() { checkkey = Menu; - if (!PrepareMenu) PrepareMenu = new MenuClass(); - if (CurrentMenu != PrepareMenu) { - CurrentMenu = PrepareMenu; - SetMenuTitle({133, 1, 28, 13}, GET_TEXT_F(MSG_PREPARE)); - MenuItemsPrepare(13); + if (SET_MENU_R(PrepareMenu, selrect({133, 1, 28, 13}), MSG_PREPARE, 10 + PREHEAT_COUNT)) { BACK_ITEM(Goto_Main_Menu); #if ENABLED(ADVANCED_PAUSE_FEATURE) - MENU_ITEM_F(ICON_FilMan, MSG_FILAMENT_MAN, onDrawSubMenu, Draw_FilamentMan_Menu); + MENU_ITEM(ICON_FilMan, MSG_FILAMENT_MAN, onDrawSubMenu, Draw_FilamentMan_Menu); #endif - MENU_ITEM_F(ICON_Axis, MSG_MOVE_AXIS, onDrawMoveSubMenu, Goto_Move_Menu); - MENU_ITEM_F(ICON_Tram, MSG_BED_TRAMMING, onDrawSubMenu, Draw_Tramming_Menu); - MENU_ITEM_F(ICON_CloseMotor, MSG_DISABLE_STEPPERS, onDrawDisableMotors, DisableMotors); + MENU_ITEM(ICON_Axis, MSG_MOVE_AXIS, onDrawMoveSubMenu, Draw_Move_Menu); + MENU_ITEM(ICON_Tram, MSG_BED_TRAMMING, onDrawSubMenu, Draw_Tramming_Menu); + MENU_ITEM(ICON_CloseMotor, MSG_DISABLE_STEPPERS, onDrawDisableMotors, DisableMotors); #if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) - MENU_ITEM_F(ICON_Homing, MSG_HOMING, onDrawSubMenu, Draw_Homing_Menu); + MENU_ITEM(ICON_Homing, MSG_HOMING, onDrawSubMenu, Draw_Homing_Menu); #else - MENU_ITEM_F(ICON_Homing, MSG_AUTO_HOME, onDrawAutoHome, AutoHome); + MENU_ITEM(ICON_Homing, MSG_AUTO_HOME, onDrawAutoHome, AutoHome); #endif #if ENABLED(MESH_BED_LEVELING) - MENU_ITEM_F(ICON_ManualMesh, MSG_MANUAL_MESH, onDrawSubMenu, Draw_ManualMesh_Menu); - #endif - #if HAS_ONESTEP_LEVELING - MENU_ITEM_F(ICON_Level, MSG_AUTO_MESH, onDrawMenuItem, AutoLev); + MENU_ITEM(ICON_ManualMesh, MSG_MANUAL_MESH, onDrawSubMenu, Draw_ManualMesh_Menu); + #elif HAS_BED_PROBE + MENU_ITEM(ICON_Level, MSG_AUTO_MESH, onDrawMenuItem, AutoLev); #endif #if HAS_ZOFFSET_ITEM - #if ENABLED(BABYSTEP_ZPROBE_OFFSET) - MENU_ITEM_F(ICON_SetZOffset, MSG_PROBE_WIZARD, onDrawSubMenu, Draw_ZOffsetWiz_Menu); - #elif JUST_BABYSTEP - EDIT_ITEM_F(ICON_Zoffset, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); - #else - MENU_ITEM_F(ICON_SetHome, MSG_SET_HOME_OFFSETS, onDrawHomeOffset, SetHome); + #if HAS_BED_PROBE + MENU_ITEM(ICON_SetZOffset, MSG_PROBE_WIZARD, onDrawSubMenu, Draw_ZOffsetWiz_Menu); + #elif ENABLED(BABYSTEPPING) + EDIT_ITEM(ICON_Zoffset, MSG_HOME_OFFSET_Z, onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); + #elif HAS_HOME_OFFSET + MENU_ITEM(ICON_SetHome, MSG_SET_HOME_OFFSETS, onDrawHomeOffset, SetHome); #endif #endif #if HAS_PREHEAT - MENU_ITEM_F(ICON_PLAPreheat, MSG_PREHEAT_1, onDrawPreheat1, DoPreheat0); - #if PREHEAT_COUNT > 1 - MENU_ITEM(ICON_ABSPreheat, F("Preheat " PREHEAT_2_LABEL), onDrawPreheat2, DoPreheat1); - #if PREHEAT_COUNT > 2 - MENU_ITEM(ICON_CustomPreheat, F("Preheat " PREHEAT_3_LABEL), onDrawMenuItem, DoPreheat2); - #endif - #endif + #define _ITEM_PREHEAT(N) MENU_ITEM(ICON_Preheat##N, MSG_PREHEAT_##N, onDrawMenuItem, DoPreheat##N); + REPEAT_1(PREHEAT_COUNT, _ITEM_PREHEAT) #endif - MENU_ITEM_F(ICON_Cool, MSG_COOLDOWN, onDrawCooldown, DoCoolDown); - MENU_ITEM_F(ICON_Language, MSG_UI_LANGUAGE, onDrawLanguage, SetLanguage); + MENU_ITEM(ICON_Cool, MSG_COOLDOWN, onDrawCooldown, DoCoolDown); + MENU_ITEM(ICON_Language, MSG_UI_LANGUAGE, onDrawLanguage, SetLanguage); } ui.reset_status(true); - CurrentMenu->draw(); + UpdateMenu(PrepareMenu); } void Draw_Tramming_Menu() { checkkey = Menu; - if (SetMenu(TrammingMenu, GET_TEXT_F(MSG_BED_TRAMMING), 8)) { + if (SET_MENU(TrammingMenu, MSG_BED_TRAMMING, 8)) { BACK_ITEM(Draw_Prepare_Menu); - #if HAS_BED_PROBE - MENU_ITEM_F(ICON_ProbeSet, MSG_TRAMMING_WIZARD, onDrawMenuItem, Trammingwizard); - EDIT_ITEM_F(ICON_ProbeSet, MSG_BED_TRAMMING_MANUAL, onDrawChkbMenu, SetManualTramming, &HMI_data.FullManualTramming); - #else - MENU_ITEM(ICON_MoveZ0, F("Home Z and disable"), onDrawMenuItem, HomeZandDisable); + #if HAS_BED_PROBE && HAS_MESH + MENU_ITEM(ICON_ProbeSet, MSG_TRAMMING_WIZARD, onDrawMenuItem, Trammingwizard); + EDIT_ITEM(ICON_ProbeSet, MSG_BED_TRAMMING_MANUAL, onDrawChkbMenu, SetManualTramming, &HMI_data.FullManualTramming); + #elif !HAS_BED_PROBE && HAS_ZOFFSET_ITEM + MENU_ITEM_F(ICON_MoveZ0, "Home Z and disable", onDrawMenuItem, HomeZandDisable); #endif - MENU_ITEM_F(ICON_Axis, MSG_LEVBED_FL, onDrawMenuItem, TramFL); - MENU_ITEM_F(ICON_Axis, MSG_LEVBED_FR, onDrawMenuItem, TramFR); - MENU_ITEM_F(ICON_Axis, MSG_LEVBED_BR, onDrawMenuItem, TramBR); - MENU_ITEM_F(ICON_Axis, MSG_LEVBED_BL, onDrawMenuItem, TramBL); - MENU_ITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_C ), onDrawMenuItem, TramC ); + MENU_ITEM(ICON_Axis, MSG_LEVBED_FL, onDrawMenuItem, TramFL); + MENU_ITEM(ICON_Axis, MSG_LEVBED_FR, onDrawMenuItem, TramFR); + MENU_ITEM(ICON_Axis, MSG_LEVBED_BR, onDrawMenuItem, TramBR); + MENU_ITEM(ICON_Axis, MSG_LEVBED_BL, onDrawMenuItem, TramBL); + MENU_ITEM(ICON_Axis, MSG_LEVBED_C, onDrawMenuItem, TramC ); } UpdateMenu(TrammingMenu); } void Draw_Control_Menu() { checkkey = Menu; - if (!ControlMenu) ControlMenu = new MenuClass(); - if (CurrentMenu != ControlMenu) { - CurrentMenu = ControlMenu; - SetMenuTitle({103, 1, 28, 14}, GET_TEXT_F(MSG_CONTROL)); - MenuItemsPrepare(10); + if (SET_MENU_R(ControlMenu, selrect({103, 1, 28, 14}), MSG_CONTROL, 10)) { BACK_ITEM(Goto_Main_Menu); - MENU_ITEM_F(ICON_Temperature, MSG_TEMPERATURE, onDrawTempSubMenu, Draw_Temperature_Menu); - MENU_ITEM_F(ICON_Motion, MSG_MOTION, onDrawMotionSubMenu, Draw_Motion_Menu); + MENU_ITEM(ICON_Temperature, MSG_TEMPERATURE, onDrawTempSubMenu, Draw_Temperature_Menu); + MENU_ITEM(ICON_Motion, MSG_MOTION, onDrawMotionSubMenu, Draw_Motion_Menu); #if ENABLED(EEPROM_SETTINGS) - MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawWriteEeprom, WriteEeprom); - MENU_ITEM_F(ICON_ReadEEPROM, MSG_LOAD_EEPROM, onDrawReadEeprom, ReadEeprom); - MENU_ITEM_F(ICON_ResumeEEPROM, MSG_RESTORE_DEFAULTS, onDrawResetEeprom, ResetEeprom); + MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawWriteEeprom, WriteEeprom); + MENU_ITEM(ICON_ReadEEPROM, MSG_LOAD_EEPROM, onDrawReadEeprom, ReadEeprom); + MENU_ITEM(ICON_ResumeEEPROM, MSG_RESTORE_DEFAULTS, onDrawResetEeprom, ResetEeprom); #endif - MENU_ITEM_F(ICON_Reboot, MSG_RESET_PRINTER, onDrawMenuItem, RebootPrinter); + MENU_ITEM(ICON_Reboot, MSG_RESET_PRINTER, onDrawMenuItem, RebootPrinter); #if ENABLED(CASE_LIGHT_MENU) #if ENABLED(CASELIGHT_USES_BRIGHTNESS) - MENU_ITEM_F(ICON_CaseLight, MSG_CASE_LIGHT, onDrawSubMenu, Draw_CaseLight_Menu); + MENU_ITEM(ICON_CaseLight, MSG_CASE_LIGHT, onDrawSubMenu, Draw_CaseLight_Menu); #else - MENU_ITEM_F(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); + MENU_ITEM(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); #endif #endif #if ENABLED(LED_CONTROL_MENU) - MENU_ITEM_F(ICON_LedControl, MSG_LED_CONTROL, onDrawSubMenu, Draw_LedControl_Menu); + MENU_ITEM(ICON_LedControl, MSG_LED_CONTROL, onDrawSubMenu, Draw_LedControl_Menu); #endif - MENU_ITEM_F(ICON_Info, MSG_INFO_SCREEN, onDrawInfoSubMenu, Goto_Info_Menu); + MENU_ITEM(ICON_Info, MSG_INFO_SCREEN, onDrawInfoSubMenu, Goto_Info_Menu); } ui.reset_status(true); - CurrentMenu->draw(); + UpdateMenu(ControlMenu); } void Draw_AdvancedSettings_Menu() { checkkey = Menu; - if (SetMenu(AdvancedSettings, GET_TEXT_F(MSG_ADVANCED_SETTINGS), 20)) { + if (SET_MENU(AdvancedSettings, MSG_ADVANCED_SETTINGS, 18)) { BACK_ITEM(Goto_Main_Menu); #if ENABLED(EEPROM_SETTINGS) - MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); - #endif - #if HAS_BED_PROBE - MENU_ITEM_F(ICON_ProbeSet, MSG_ZPROBE_SETTINGS, onDrawSubMenu, Draw_ProbeSet_Menu); + MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); #endif #if HAS_MESH - MENU_ITEM_F(ICON_ProbeSet, MSG_MESH_LEVELING, onDrawSubMenu, Draw_MeshSet_Menu); + MENU_ITEM(ICON_ProbeSet, MSG_MESH_LEVELING, onDrawSubMenu, Draw_MeshSet_Menu); #endif - #if HAS_HOME_OFFSET - MENU_ITEM_F(ICON_HomeOffset, MSG_SET_HOME_OFFSETS, onDrawSubMenu, Draw_HomeOffset_Menu); + #if HAS_BED_PROBE + MENU_ITEM(ICON_ProbeSet, MSG_ZPROBE_SETTINGS, onDrawSubMenu, Draw_ProbeSet_Menu); #endif - #if HAS_HOTEND - MENU_ITEM(ICON_PIDNozzle, F(STR_HOTEND_PID " Settings"), onDrawSubMenu, Draw_HotendPID_Menu); + MENU_ITEM(ICON_FilSet, MSG_FILAMENT_SET, onDrawSubMenu, Draw_FilSet_Menu); + #if ENABLED(PIDTEMP) + MENU_ITEM_F(ICON_PIDNozzle, STR_HOTEND_PID " Settings", onDrawSubMenu, Draw_HotendPID_Menu); #endif - #if HAS_HEATED_BED - MENU_ITEM(ICON_PIDbed, F(STR_BED_PID " Settings"), onDrawSubMenu, Draw_BedPID_Menu); + #if ENABLED(PIDTEMPBED) + MENU_ITEM_F(ICON_PIDBed, STR_BED_PID " Settings", onDrawSubMenu, Draw_BedPID_Menu); #endif - MENU_ITEM_F(ICON_FilSet, MSG_FILAMENT_SET, onDrawSubMenu, Draw_FilSet_Menu); - #if ENABLED(POWER_LOSS_RECOVERY) - EDIT_ITEM_F(ICON_Pwrlossr, MSG_OUTAGE_RECOVERY, onDrawChkbMenu, SetPwrLossr, &recovery.enabled); + #if HAS_ESDIAG + MENU_ITEM_F(ICON_ESDiag, "End-stops diag.", onDrawSubMenu, Draw_EndStopDiag); #endif - #if ENABLED(BAUD_RATE_GCODE) - EDIT_ITEM(ICON_SetBaudRate, F("115K baud"), onDrawChkbMenu, SetBaudRate, &HMI_data.Baud115K); + #if ENABLED(PRINTCOUNTER) + MENU_ITEM(ICON_PrintStats, MSG_INFO_STATS_MENU, onDrawSubMenu, Goto_PrintStats); + MENU_ITEM(ICON_PrintStatsReset, MSG_INFO_PRINT_COUNT_RESET, onDrawSubMenu, PrintStatsReset); #endif - #if HAS_LCD_BRIGHTNESS - EDIT_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); - MENU_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight); + #if HAS_LOCKSCREEN + MENU_ITEM(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); #endif - MENU_ITEM_F(ICON_Scolor, MSG_COLORS_SELECT, onDrawSubMenu, Draw_SelectColors_Menu); #if ENABLED(SOUND_MENU_ITEM) - EDIT_ITEM_F(ICON_Sound, MSG_SOUND_ENABLE, onDrawChkbMenu, SetEnableSound, &ui.sound_on); + EDIT_ITEM(ICON_Sound, MSG_SOUND_ENABLE, onDrawChkbMenu, SetEnableSound, &ui.sound_on); #endif - #if HAS_ESDIAG - MENU_ITEM(ICON_ESDiag, F("End-stops diag."), onDrawSubMenu, Draw_EndStopDiag); + #if ENABLED(POWER_LOSS_RECOVERY) + EDIT_ITEM(ICON_Pwrlossr, MSG_OUTAGE_RECOVERY, onDrawChkbMenu, SetPwrLossr, &recovery.enabled); #endif - #if ENABLED(PRINTCOUNTER) - MENU_ITEM_F(ICON_PrintStats, MSG_INFO_STATS_MENU, onDrawSubMenu, Goto_PrintStats); - MENU_ITEM_F(ICON_PrintStatsReset, MSG_INFO_PRINT_COUNT_RESET, onDrawSubMenu, PrintStats.Reset); + EDIT_ITEM(ICON_File, MSG_MEDIA_UPDATE, onDrawChkbMenu, SetMediaAutoMount, &HMI_data.MediaAutoMount); + #if ENABLED(BAUD_RATE_GCODE) + EDIT_ITEM_F(ICON_SetBaudRate, "115K baud", onDrawChkbMenu, SetBaudRate, &HMI_data.Baud115K); + #endif + #if HAS_LCD_BRIGHTNESS + EDIT_ITEM(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); + MENU_ITEM(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight); #endif - MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); + MENU_ITEM(ICON_Scolor, MSG_COLORS_SELECT, onDrawSubMenu, Draw_SelectColors_Menu); } ui.reset_status(true); UpdateMenu(AdvancedSettings); @@ -3257,50 +3089,54 @@ void Draw_AdvancedSettings_Menu() { void Draw_Move_Menu() { checkkey = Menu; - if (!MoveMenu) MoveMenu = new MenuClass(); - if (CurrentMenu != MoveMenu) { - CurrentMenu = MoveMenu; - SetMenuTitle({192, 1, 42, 14}, GET_TEXT_F(MSG_MOVE_AXIS)); - MenuItemsPrepare(5); + if (SET_MENU_R(MoveMenu, selrect({192, 1, 42, 14}), MSG_MOVE_AXIS, 6)) { BACK_ITEM(Draw_Prepare_Menu); - EDIT_ITEM_F(ICON_MoveX, MSG_MOVE_X, onDrawMoveX, SetMoveX, ¤t_position.x); - EDIT_ITEM_F(ICON_MoveY, MSG_MOVE_Y, onDrawMoveY, SetMoveY, ¤t_position.y); - EDIT_ITEM_F(ICON_MoveZ, MSG_MOVE_Z, onDrawMoveZ, SetMoveZ, ¤t_position.z); + EDIT_ITEM(ICON_Axis, MSG_LIVE_MOVE, onDrawChkbMenu, SetLiveMove, &EnableLiveMove); + EDIT_ITEM(ICON_MoveX, MSG_MOVE_X, onDrawMoveX, SetMoveX, ¤t_position.x); + EDIT_ITEM(ICON_MoveY, MSG_MOVE_Y, onDrawMoveY, SetMoveY, ¤t_position.y); + EDIT_ITEM(ICON_MoveZ, MSG_MOVE_Z, onDrawMoveZ, SetMoveZ, ¤t_position.z); #if HAS_HOTEND - EDIT_ITEM_F(ICON_Extruder, MSG_MOVE_E, onDrawMoveE, SetMoveE, ¤t_position.e); + gcode.process_subcommands_now(F("G92E0")); // reset extruder position + EDIT_ITEM(ICON_Extruder, MSG_MOVE_E, onDrawMoveE, SetMoveE, ¤t_position.e); #endif } - CurrentMenu->draw(); + UpdateMenu(MoveMenu); if (!all_axes_trusted()) LCD_MESSAGE_F("WARNING: Current position unknown. Home axes."); } #if HAS_HOME_OFFSET + void Draw_HomeOffset_Menu() { checkkey = Menu; - if (SetMenu(HomeOffMenu, GET_TEXT_F(MSG_SET_HOME_OFFSETS), 4)) { - BACK_ITEM(Draw_AdvancedSettings_Menu); - EDIT_ITEM_F(ICON_HomeOffsetX, MSG_HOME_OFFSET_X, onDrawPFloatMenu, SetHomeOffsetX, &home_offset.x); - EDIT_ITEM_F(ICON_HomeOffsetY, MSG_HOME_OFFSET_Y, onDrawPFloatMenu, SetHomeOffsetY, &home_offset.y); - EDIT_ITEM_F(ICON_HomeOffsetZ, MSG_HOME_OFFSET_Z, onDrawPFloatMenu, SetHomeOffsetZ, &home_offset.z); + if (SET_MENU(HomeOffMenu, MSG_SET_HOME_OFFSETS, 4)) { + BACK_ITEM(Draw_PhySet_Menu); + EDIT_ITEM(ICON_HomeOffsetX, MSG_HOME_OFFSET_X, onDrawPFloatMenu, SetHomeOffsetX, &home_offset.x); + EDIT_ITEM(ICON_HomeOffsetY, MSG_HOME_OFFSET_Y, onDrawPFloatMenu, SetHomeOffsetY, &home_offset.y); + EDIT_ITEM(ICON_HomeOffsetZ, MSG_HOME_OFFSET_Z, onDrawPFloatMenu, SetHomeOffsetZ, &home_offset.z); } UpdateMenu(HomeOffMenu); } + #endif #if HAS_BED_PROBE + void Draw_ProbeSet_Menu() { checkkey = Menu; - if (SetMenu(ProbeSetMenu, GET_TEXT_F(MSG_ZPROBE_SETTINGS), 8)) { + if (SET_MENU(ProbeSetMenu, MSG_ZPROBE_SETTINGS, 9)) { BACK_ITEM(Draw_AdvancedSettings_Menu); - EDIT_ITEM_F(ICON_ProbeOffsetX, MSG_ZPROBE_XOFFSET, onDrawPFloatMenu, SetProbeOffsetX, &probe.offset.x); - EDIT_ITEM_F(ICON_ProbeOffsetY, MSG_ZPROBE_YOFFSET, onDrawPFloatMenu, SetProbeOffsetY, &probe.offset.y); - EDIT_ITEM_F(ICON_ProbeOffsetZ, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z); - #ifdef BLTOUCH_HS_MODE - EDIT_ITEM_F(ICON_HSMode, MSG_ENABLE_HS_MODE, onDrawChkbMenu, SetHSMode, &bltouch.high_speed_mode); + EDIT_ITEM(ICON_ProbeOffsetX, MSG_ZPROBE_XOFFSET, onDrawPFloatMenu, SetProbeOffsetX, &probe.offset.x); + EDIT_ITEM(ICON_ProbeOffsetY, MSG_ZPROBE_YOFFSET, onDrawPFloatMenu, SetProbeOffsetY, &probe.offset.y); + EDIT_ITEM(ICON_ProbeOffsetZ, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z); + #if ENABLED(BLTOUCH) + MENU_ITEM(ICON_ProbeStow, MSG_MANUAL_STOW, onDrawMenuItem, ProbeStow); + MENU_ITEM(ICON_ProbeDeploy, MSG_MANUAL_DEPLOY, onDrawMenuItem, ProbeDeploy); + MENU_ITEM(ICON_BltouchReset, MSG_BLTOUCH_RESET, onDrawMenuItem, bltouch._reset); + #if ENABLED(BLTOUCH_HS_MODE) + EDIT_ITEM(ICON_HSMode, MSG_ENABLE_HS_MODE, onDrawChkbMenu, SetHSMode, &bltouch.high_speed_mode); + #endif #endif - MENU_ITEM_F(ICON_ProbeTest, MSG_M48_TEST, onDrawMenuItem, ProbeTest); - MENU_ITEM_F(ICON_ProbeStow, MSG_MANUAL_STOW, onDrawMenuItem, ProbeStow); - MENU_ITEM_F(ICON_ProbeDeploy, MSG_MANUAL_DEPLOY, onDrawMenuItem, ProbeDeploy); + MENU_ITEM(ICON_ProbeTest, MSG_M48_TEST, onDrawMenuItem, ProbeTest); } UpdateMenu(ProbeSetMenu); } @@ -3309,23 +3145,23 @@ void Draw_Move_Menu() { void Draw_FilSet_Menu() { checkkey = Menu; - if (SetMenu(FilSetMenu, GET_TEXT_F(MSG_FILAMENT_SET), 9)) { + if (SET_MENU(FilSetMenu, MSG_FILAMENT_SET, 9)) { BACK_ITEM(Draw_AdvancedSettings_Menu); #if HAS_FILAMENT_SENSOR - EDIT_ITEM_F(ICON_Runout, MSG_RUNOUT_ENABLE, onDrawChkbMenu, SetRunoutEnable, &runout.enabled); + EDIT_ITEM(ICON_Runout, MSG_RUNOUT_ENABLE, onDrawChkbMenu, SetRunoutEnable, &runout.enabled); #endif #if HAS_FILAMENT_RUNOUT_DISTANCE - EDIT_ITEM_F(ICON_Runout, MSG_RUNOUT_DISTANCE_MM, onDrawPFloatMenu, SetRunoutDistance, &runout.runout_distance()); + EDIT_ITEM(ICON_Runout, MSG_RUNOUT_DISTANCE_MM, onDrawPFloatMenu, SetRunoutDistance, &runout.runout_distance()); #endif #if ENABLED(PREVENT_COLD_EXTRUSION) - EDIT_ITEM_F(ICON_ExtrudeMinT, MSG_EXTRUDER_MIN_TEMP, onDrawPIntMenu, SetExtMinT, &HMI_data.ExtMinT); + EDIT_ITEM(ICON_ExtrudeMinT, MSG_EXTRUDER_MIN_TEMP, onDrawPIntMenu, SetExtMinT, &HMI_data.ExtMinT); #endif #if ENABLED(ADVANCED_PAUSE_FEATURE) - EDIT_ITEM_F(ICON_FilLoad, MSG_FILAMENT_LOAD, onDrawPFloatMenu, SetFilLoad, &fc_settings[0].load_length); - EDIT_ITEM_F(ICON_FilUnload, MSG_FILAMENT_UNLOAD, onDrawPFloatMenu, SetFilUnload, &fc_settings[0].unload_length); + EDIT_ITEM(ICON_FilLoad, MSG_FILAMENT_LOAD, onDrawPFloatMenu, SetFilLoad, &fc_settings[0].load_length); + EDIT_ITEM(ICON_FilUnload, MSG_FILAMENT_UNLOAD, onDrawPFloatMenu, SetFilUnload, &fc_settings[0].unload_length); #endif #if ENABLED(FWRETRACT) - MENU_ITEM_F(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); + MENU_ITEM(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); #endif } UpdateMenu(FilSetMenu); @@ -3333,401 +3169,393 @@ void Draw_FilSet_Menu() { void Draw_SelectColors_Menu() { checkkey = Menu; - if (SetMenu(SelectColorMenu, GET_TEXT_F(MSG_COLORS_SELECT), 20)) { + if (SET_MENU(SelectColorMenu, MSG_COLORS_SELECT, 20)) { BACK_ITEM(Draw_AdvancedSettings_Menu); - MENU_ITEM_F(ICON_StockConfiguration, MSG_RESTORE_DEFAULTS, onDrawMenuItem, RestoreDefaultsColors); - EDIT_ITEM(0, F("Screen Background"), onDrawSelColorItem, SelColor, &HMI_data.Background_Color); - EDIT_ITEM(0, F("Cursor"), onDrawSelColorItem, SelColor, &HMI_data.Cursor_color); - EDIT_ITEM(0, F("Title Background"), onDrawSelColorItem, SelColor, &HMI_data.TitleBg_color); - EDIT_ITEM(0, F("Title Text"), onDrawSelColorItem, SelColor, &HMI_data.TitleTxt_color); - EDIT_ITEM(0, F("Text"), onDrawSelColorItem, SelColor, &HMI_data.Text_Color); - EDIT_ITEM(0, F("Selected"), onDrawSelColorItem, SelColor, &HMI_data.Selected_Color); - EDIT_ITEM(0, F("Split Line"), onDrawSelColorItem, SelColor, &HMI_data.SplitLine_Color); - EDIT_ITEM(0, F("Highlight"), onDrawSelColorItem, SelColor, &HMI_data.Highlight_Color); - EDIT_ITEM(0, F("Status Background"), onDrawSelColorItem, SelColor, &HMI_data.StatusBg_Color); - EDIT_ITEM(0, F("Status Text"), onDrawSelColorItem, SelColor, &HMI_data.StatusTxt_Color); - EDIT_ITEM(0, F("Popup Background"), onDrawSelColorItem, SelColor, &HMI_data.PopupBg_color); - EDIT_ITEM(0, F("Popup Text"), onDrawSelColorItem, SelColor, &HMI_data.PopupTxt_Color); - EDIT_ITEM(0, F("Alert Background"), onDrawSelColorItem, SelColor, &HMI_data.AlertBg_Color); - EDIT_ITEM(0, F("Alert Text"), onDrawSelColorItem, SelColor, &HMI_data.AlertTxt_Color); - EDIT_ITEM(0, F("Percent Text"), onDrawSelColorItem, SelColor, &HMI_data.PercentTxt_Color); - EDIT_ITEM(0, F("Bar Fill"), onDrawSelColorItem, SelColor, &HMI_data.Barfill_Color); - EDIT_ITEM(0, F("Indicator value"), onDrawSelColorItem, SelColor, &HMI_data.Indicator_Color); - EDIT_ITEM(0, F("Coordinate value"), onDrawSelColorItem, SelColor, &HMI_data.Coordinate_Color); + MENU_ITEM(ICON_StockConfiguration, MSG_RESTORE_DEFAULTS, onDrawMenuItem, RestoreDefaultColors); + EDIT_ITEM_F(0, "Screen Background", onDrawSelColorItem, SelColor, &HMI_data.Background_Color); + EDIT_ITEM_F(0, "Cursor", onDrawSelColorItem, SelColor, &HMI_data.Cursor_Color); + EDIT_ITEM_F(0, "Title Background", onDrawSelColorItem, SelColor, &HMI_data.TitleBg_Color); + EDIT_ITEM_F(0, "Title Text", onDrawSelColorItem, SelColor, &HMI_data.TitleTxt_Color); + EDIT_ITEM_F(0, "Text", onDrawSelColorItem, SelColor, &HMI_data.Text_Color); + EDIT_ITEM_F(0, "Selected", onDrawSelColorItem, SelColor, &HMI_data.Selected_Color); + EDIT_ITEM_F(0, "Split Line", onDrawSelColorItem, SelColor, &HMI_data.SplitLine_Color); + EDIT_ITEM_F(0, "Highlight", onDrawSelColorItem, SelColor, &HMI_data.Highlight_Color); + EDIT_ITEM_F(0, "Status Background", onDrawSelColorItem, SelColor, &HMI_data.StatusBg_Color); + EDIT_ITEM_F(0, "Status Text", onDrawSelColorItem, SelColor, &HMI_data.StatusTxt_Color); + EDIT_ITEM_F(0, "Popup Background", onDrawSelColorItem, SelColor, &HMI_data.PopupBg_Color); + EDIT_ITEM_F(0, "Popup Text", onDrawSelColorItem, SelColor, &HMI_data.PopupTxt_Color); + EDIT_ITEM_F(0, "Alert Background", onDrawSelColorItem, SelColor, &HMI_data.AlertBg_Color); + EDIT_ITEM_F(0, "Alert Text", onDrawSelColorItem, SelColor, &HMI_data.AlertTxt_Color); + EDIT_ITEM_F(0, "Percent Text", onDrawSelColorItem, SelColor, &HMI_data.PercentTxt_Color); + EDIT_ITEM_F(0, "Bar Fill", onDrawSelColorItem, SelColor, &HMI_data.Barfill_Color); + EDIT_ITEM_F(0, "Indicator value", onDrawSelColorItem, SelColor, &HMI_data.Indicator_Color); + EDIT_ITEM_F(0, "Coordinate value", onDrawSelColorItem, SelColor, &HMI_data.Coordinate_Color); } UpdateMenu(SelectColorMenu); } void Draw_GetColor_Menu() { checkkey = Menu; - if (SetMenu(GetColorMenu, GET_TEXT_F(MSG_COLORS_GET), 5)) { + if (SET_MENU(GetColorMenu, MSG_COLORS_GET, 5)) { BACK_ITEM(DWIN_ApplyColor); - MENU_ITEM_F(ICON_Cancel, MSG_BUTTON_CANCEL, onDrawMenuItem, Draw_SelectColors_Menu); - MENU_ITEM_F(0, MSG_COLORS_RED, onDrawGetColorItem, SetRGBColor); - MENU_ITEM_F(1, MSG_COLORS_GREEN, onDrawGetColorItem, SetRGBColor); - MENU_ITEM_F(2, MSG_COLORS_BLUE, onDrawGetColorItem, SetRGBColor); + MENU_ITEM(ICON_Cancel, MSG_BUTTON_CANCEL, onDrawMenuItem, Draw_SelectColors_Menu); + MENU_ITEM(0, MSG_COLORS_RED, onDrawGetColorItem, SetRGBColor); + MENU_ITEM(1, MSG_COLORS_GREEN, onDrawGetColorItem, SetRGBColor); + MENU_ITEM(2, MSG_COLORS_BLUE, onDrawGetColorItem, SetRGBColor); } UpdateMenu(GetColorMenu); DWIN_Draw_Rectangle(1, *MenuData.P_Int, 20, 315, DWIN_WIDTH - 20, 335); } #if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) - void Draw_CaseLight_Menu() { - checkkey = Menu; - if (SetMenu(CaseLightMenu, GET_TEXT_F(MSG_CASE_LIGHT), 3)) { - BACK_ITEM(Draw_Control_Menu); - EDIT_ITEM_F(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); - EDIT_ITEM_F(ICON_Brightness, MSG_CASE_LIGHT_BRIGHTNESS, onDrawPInt8Menu, SetCaseLightBrightness, &caselight.brightness); - } - UpdateMenu(CaseLightMenu); + + void Draw_CaseLight_Menu() { + checkkey = Menu; + if (SET_MENU(CaseLightMenu, MSG_CASE_LIGHT, 3)) { + BACK_ITEM(Draw_Control_Menu); + EDIT_ITEM(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); + EDIT_ITEM(ICON_Brightness, MSG_CASE_LIGHT_BRIGHTNESS, onDrawPInt8Menu, SetCaseLightBrightness, &caselight.brightness); } + UpdateMenu(CaseLightMenu); + } + #endif #if ENABLED(LED_CONTROL_MENU) - void Draw_LedControl_Menu() { - checkkey = Menu; - if (SetMenu(LedControlMenu, GET_TEXT_F(MSG_LED_CONTROL), 6)) { - BACK_ITEM(Draw_Control_Menu); - #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) - EDIT_ITEM_F(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); - #endif - #if HAS_COLOR_LEDS - EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_RED, onDrawPInt8Menu, SetLEDColorR, &leds.color.r); - EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_GREEN, onDrawPInt8Menu, SetLEDColorG, &leds.color.g); - EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_BLUE, onDrawPInt8Menu, SetLEDColorB, &leds.color.b); + + void Draw_LedControl_Menu() { + checkkey = Menu; + if (SET_MENU(LedControlMenu, MSG_LED_CONTROL, 10)) { + BACK_ITEM(Draw_Control_Menu); + #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) + EDIT_ITEM(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); + #endif + #if HAS_COLOR_LEDS + #if ENABLED(LED_COLOR_PRESETS) + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_WHITE, onDrawMenuItem, leds.set_white); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_RED, onDrawMenuItem, leds.set_red); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_ORANGE, onDrawMenuItem, leds.set_orange); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_YELLOW, onDrawMenuItem, leds.set_yellow); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_GREEN, onDrawMenuItem, leds.set_green); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_BLUE, onDrawMenuItem, leds.set_blue); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_INDIGO, onDrawMenuItem, leds.set_indigo); + MENU_ITEM(ICON_LedControl, MSG_SET_LEDS_VIOLET, onDrawMenuItem, leds.set_violet); + #else + EDIT_ITEM(ICON_LedControl, MSG_COLORS_RED, onDrawPInt8Menu, SetLEDColorR, &leds.color.r); + EDIT_ITEM(ICON_LedControl, MSG_COLORS_GREEN, onDrawPInt8Menu, SetLEDColorG, &leds.color.g); + EDIT_ITEM(ICON_LedControl, MSG_COLORS_BLUE, onDrawPInt8Menu, SetLEDColorB, &leds.color.b); #if ENABLED(HAS_WHITE_LED) - EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_WHITE, onDrawPInt8Menu, SetLedColorW, &leds.color.w); + EDIT_ITEM(ICON_LedControl, MSG_COLORS_WHITE, onDrawPInt8Menu, SetLEDColorW, &leds.color.w); #endif #endif - } - UpdateMenu(LedControlMenu); + #endif } -#endif + UpdateMenu(LedControlMenu); + } + +#endif // LED_CONTROL_MENU void Draw_Tune_Menu() { checkkey = Menu; - if (!TuneMenu) TuneMenu = new MenuClass(); - if (CurrentMenu != TuneMenu) { - CurrentMenu = TuneMenu; - SetMenuTitle({73, 2, 28, 12}, GET_TEXT_F(MSG_TUNE)); // TODO: Chinese, English "Tune" JPG - MenuItemsPrepare(16); + if (SET_MENU_R(TuneMenu, selrect({73, 2, 28, 12}), MSG_TUNE, 14)) { BACK_ITEM(Goto_PrintProcess); - EDIT_ITEM_F(ICON_Speed, MSG_SPEED, onDrawSpeedItem, SetSpeed, &feedrate_percentage); + EDIT_ITEM(ICON_Speed, MSG_SPEED, onDrawSpeedItem, SetSpeed, &feedrate_percentage); #if HAS_HOTEND - HotendTargetItem = EDIT_ITEM_F(ICON_HotendTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); + HotendTargetItem = EDIT_ITEM(ICON_HotendTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); #endif #if HAS_HEATED_BED - BedTargetItem = EDIT_ITEM_F(ICON_BedTemp, MSG_UBL_SET_TEMP_BED, onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); + BedTargetItem = EDIT_ITEM(ICON_BedTemp, MSG_UBL_SET_TEMP_BED, onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); #endif #if HAS_FAN - FanSpeedItem = EDIT_ITEM_F(ICON_FanSpeed, MSG_FAN_SPEED, onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); + FanSpeedItem = EDIT_ITEM(ICON_FanSpeed, MSG_FAN_SPEED, onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); #endif - #if HAS_ZOFFSET_ITEM && EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) - EDIT_ITEM_F(ICON_Zoffset, MSG_ZPROBE_ZOFFSET, onDrawZOffset, SetZOffset, &BABY_Z_VAR); + #if ALL(HAS_ZOFFSET_ITEM, HAS_BED_PROBE, BABYSTEPPING) + EDIT_ITEM(ICON_Zoffset, MSG_ZPROBE_ZOFFSET, onDrawZOffset, SetZOffset, &BABY_Z_VAR); + #elif ALL(HAS_ZOFFSET_ITEM, MESH_BED_LEVELING, BABYSTEPPING) + EDIT_ITEM(ICON_Zoffset, MSG_HOME_OFFSET_Z, onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); #endif - EDIT_ITEM_F(ICON_Flow, MSG_FLOW, onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); + EDIT_ITEM(ICON_Flow, MSG_FLOW, onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); #if ENABLED(ADVANCED_PAUSE_FEATURE) - MENU_ITEM_F(ICON_FilMan, MSG_FILAMENTCHANGE, onDrawMenuItem, ChangeFilament); + MENU_ITEM(ICON_FilMan, MSG_FILAMENTCHANGE, onDrawMenuItem, ChangeFilament); + #endif + #if HAS_FILAMENT_SENSOR + EDIT_ITEM(ICON_Runout, MSG_RUNOUT_ENABLE, onDrawChkbMenu, SetRunoutEnable, &runout.enabled); #endif #if ENABLED(FWRETRACT) - MENU_ITEM_F(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); + MENU_ITEM(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); + #endif + #if HAS_LOCKSCREEN + MENU_ITEM(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); #endif - MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); #if HAS_LCD_BRIGHTNESS - EDIT_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); - MENU_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight); + EDIT_ITEM(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); + MENU_ITEM(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight); #endif #if ENABLED(CASE_LIGHT_MENU) - EDIT_ITEM_F(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); + EDIT_ITEM(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, SetCaseLight, &caselight.on); #elif ENABLED(LED_CONTROL_MENU) && DISABLED(CASE_LIGHT_USE_NEOPIXEL) - EDIT_ITEM_F(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); + EDIT_ITEM(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); #endif } - CurrentMenu->draw(); + UpdateMenu(TuneMenu); } void Draw_Motion_Menu() { checkkey = Menu; - if (!MotionMenu) MotionMenu = new MenuClass(); - if (CurrentMenu != MotionMenu) { - CurrentMenu = MotionMenu; - SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_MOTION)); // TODO: Chinese, English "Motion" JPG - MenuItemsPrepare(6); + if (SET_MENU_R(MotionMenu, selrect({1, 16, 28, 13}), MSG_MOTION, 6)) { BACK_ITEM(Draw_Control_Menu); - MENU_ITEM_F(ICON_MaxSpeed, MSG_SPEED, onDrawSpeed, Draw_MaxSpeed_Menu); - MENU_ITEM_F(ICON_MaxAccelerated, MSG_ACCELERATION, onDrawAcc, Draw_MaxAccel_Menu); + MENU_ITEM(ICON_MaxSpeed, MSG_SPEED, onDrawSpeed, Draw_MaxSpeed_Menu); + MENU_ITEM(ICON_MaxAccelerated, MSG_ACCELERATION, onDrawAcc, Draw_MaxAccel_Menu); #if HAS_CLASSIC_JERK - MENU_ITEM_F(ICON_MaxJerk, MSG_JERK, onDrawJerk, Draw_MaxJerk_Menu); + MENU_ITEM(ICON_MaxJerk, MSG_JERK, onDrawJerk, Draw_MaxJerk_Menu); #endif - MENU_ITEM_F(ICON_Step, MSG_STEPS_PER_MM, onDrawSteps, Draw_Steps_Menu); - EDIT_ITEM_F(ICON_Flow, MSG_FLOW, onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); + MENU_ITEM(ICON_Step, MSG_STEPS_PER_MM, onDrawSteps, Draw_Steps_Menu); + EDIT_ITEM(ICON_Flow, MSG_FLOW, onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); } - CurrentMenu->draw(); + UpdateMenu(MotionMenu); } #if ENABLED(ADVANCED_PAUSE_FEATURE) + void Draw_FilamentMan_Menu() { checkkey = Menu; - if (SetMenu(FilamentMenu, GET_TEXT_F(MSG_FILAMENT_MAN), 5)) { + if (SET_MENU(FilamentMenu, MSG_FILAMENT_MAN, 5)) { BACK_ITEM(Draw_Prepare_Menu); - MENU_ITEM_F(ICON_Park, MSG_FILAMENT_PARK_ENABLED, onDrawMenuItem, ParkHead); - MENU_ITEM_F(ICON_FilMan, MSG_FILAMENTCHANGE, onDrawMenuItem, ChangeFilament); + #if ENABLED(NOZZLE_PARK_FEATURE) + MENU_ITEM(ICON_Park, MSG_FILAMENT_PARK_ENABLED, onDrawMenuItem, ParkHead); + #endif + MENU_ITEM(ICON_FilMan, MSG_FILAMENTCHANGE, onDrawMenuItem, ChangeFilament); #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - MENU_ITEM_F(ICON_FilUnload, MSG_FILAMENTUNLOAD, onDrawMenuItem, UnloadFilament); - MENU_ITEM_F(ICON_FilLoad, MSG_FILAMENTLOAD, onDrawMenuItem, LoadFilament); + MENU_ITEM(ICON_FilUnload, MSG_FILAMENTUNLOAD, onDrawMenuItem, UnloadFilament); + MENU_ITEM(ICON_FilLoad, MSG_FILAMENTLOAD, onDrawMenuItem, LoadFilament); #endif } UpdateMenu(FilamentMenu); } + #endif #if ENABLED(MESH_BED_LEVELING) + void Draw_ManualMesh_Menu() { checkkey = Menu; - if (SetMenu(ManualMesh, GET_TEXT_F(MSG_UBL_MANUAL_MESH), 6)) { + if (SET_MENU(ManualMesh, MSG_UBL_MANUAL_MESH, 6)) { BACK_ITEM(Draw_Prepare_Menu); - MENU_ITEM_F(ICON_ManualMesh, MSG_LEVEL_BED, onDrawMenuItem, ManualMeshStart); - MMeshMoveZItem = EDIT_ITEM_F(ICON_Zoffset, MSG_MOVE_Z, onDrawMMeshMoveZ, SetMMeshMoveZ, ¤t_position.z); - MENU_ITEM_F(ICON_Axis, MSG_UBL_CONTINUE_MESH, onDrawMenuItem, ManualMeshContinue); - MENU_ITEM_F(ICON_MeshViewer, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer); - MENU_ITEM_F(ICON_MeshSave, MSG_UBL_SAVE_MESH, onDrawMenuItem, ManualMeshSave); + MENU_ITEM(ICON_ManualMesh, MSG_LEVEL_BED, onDrawMenuItem, ManualMeshStart); + MMeshMoveZItem = EDIT_ITEM(ICON_Zoffset, MSG_MOVE_Z, onDrawMMeshMoveZ, SetMMeshMoveZ, ¤t_position.z); + MENU_ITEM(ICON_Axis, MSG_UBL_CONTINUE_MESH, onDrawMenuItem, ManualMeshContinue); + MENU_ITEM(ICON_MeshViewer, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer); + MENU_ITEM(ICON_MeshSave, MSG_UBL_SAVE_MESH, onDrawMenuItem, ManualMeshSave); } UpdateMenu(ManualMesh); } -#endif + +#endif // MESH_BED_LEVELING #if HAS_PREHEAT - void Draw_Preheat_Menu(frame_rect_t cn, const __FlashStringHelper* fstr) { + void Draw_Preheat_Menu(bool NotCurrent) { checkkey = Menu; - if (CurrentMenu != PreheatMenu) { - CurrentMenu = PreheatMenu; - SetMenuTitle(cn, fstr); - MenuItemsPrepare(5); + if (NotCurrent) { BACK_ITEM(Draw_Temperature_Menu); #if HAS_HOTEND - EDIT_ITEM_F(ICON_SetEndTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawSetPreheatHotend, SetPreheatEndTemp, &ui.material_preset[HMI_value.Select].hotend_temp); + EDIT_ITEM(ICON_SetEndTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawSetPreheatHotend, SetPreheatEndTemp, &ui.material_preset[HMI_value.Select].hotend_temp); #endif #if HAS_HEATED_BED - EDIT_ITEM_F(ICON_SetBedTemp, MSG_UBL_SET_TEMP_BED, onDrawSetPreheatBed, SetPreheatBedTemp, &ui.material_preset[HMI_value.Select].bed_temp); + EDIT_ITEM(ICON_SetBedTemp, MSG_UBL_SET_TEMP_BED, onDrawSetPreheatBed, SetPreheatBedTemp, &ui.material_preset[HMI_value.Select].bed_temp); #endif #if HAS_FAN - EDIT_ITEM_F(ICON_FanSpeed, MSG_FAN_SPEED, onDrawSetPreheatFan, SetPreheatFanSpeed, &ui.material_preset[HMI_value.Select].fan_speed); + EDIT_ITEM(ICON_FanSpeed, MSG_FAN_SPEED, onDrawSetPreheatFan, SetPreheatFanSpeed, &ui.material_preset[HMI_value.Select].fan_speed); #endif #if ENABLED(EEPROM_SETTINGS) - MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawWriteEeprom, WriteEeprom); + MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawWriteEeprom, WriteEeprom); #endif } - CurrentMenu->draw(); + UpdateMenu(PreheatMenu); } - void Draw_Preheat1_Menu() { - HMI_value.Select = 0; - if (!PreheatMenu) PreheatMenu = new MenuClass(); - Draw_Preheat_Menu({59, 16, 81, 14}, F(PREHEAT_1_LABEL " Preheat Settings")); // TODO: English "PLA Settings" JPG - } - - #if PREHEAT_COUNT >= 2 - void Draw_Preheat2_Menu() { - HMI_value.Select = 1; - if (!PreheatMenu) PreheatMenu = new MenuClass(); - Draw_Preheat_Menu({142, 16, 82, 14}, F(PREHEAT_2_LABEL " Preheat Settings")); // TODO: English "ABS Settings" JPG - } - #endif - - #if PREHEAT_COUNT >= 3 - void Draw_Preheat3_Menu() { - HMI_value.Select = 2; - if (!PreheatMenu) PreheatMenu = new MenuClass(); - Draw_Preheat_Menu({225, 16, 82, 14}, F(PREHEAT_3_LABEL " Preheat Settings")); // TODO: English "... Settings" JPG + #define _Preheat_Menu(N) \ + void Draw_Preheat## N ##_Menu() { \ + HMI_value.Select = N-1; \ + Draw_Preheat_Menu(SET_MENU(PreheatMenu, MSG_PREHEAT_## N ##_SETTINGS, 5)); \ } - #endif + REPEAT_1(PREHEAT_COUNT, _Preheat_Menu) #endif // HAS_PREHEAT void Draw_Temperature_Menu() { checkkey = Menu; - if (!TemperatureMenu) TemperatureMenu = new MenuClass(); - if (CurrentMenu != TemperatureMenu) { - CurrentMenu = TemperatureMenu; - SetMenuTitle({236, 2, 28, 12}, GET_TEXT_F(MSG_TEMPERATURE)); - MenuItemsPrepare(7); + if (SET_MENU_R(TemperatureMenu, selrect({236, 2, 28, 12}), MSG_TEMPERATURE, 4 + PREHEAT_COUNT)) { BACK_ITEM(Draw_Control_Menu); #if HAS_HOTEND - HotendTargetItem = EDIT_ITEM_F(ICON_SetEndTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); + HotendTargetItem = EDIT_ITEM(ICON_SetEndTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); #endif #if HAS_HEATED_BED - BedTargetItem = EDIT_ITEM_F(ICON_SetBedTemp, MSG_UBL_SET_TEMP_BED, onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); + BedTargetItem = EDIT_ITEM(ICON_SetBedTemp, MSG_UBL_SET_TEMP_BED, onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); #endif #if HAS_FAN - FanSpeedItem = EDIT_ITEM_F(ICON_FanSpeed, MSG_FAN_SPEED, onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); + FanSpeedItem = EDIT_ITEM(ICON_FanSpeed, MSG_FAN_SPEED, onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); #endif #if HAS_PREHEAT - MENU_ITEM_F(ICON_SetPLAPreheat, MSG_PREHEAT_1_SETTINGS, onDrawPLAPreheatSubMenu, Draw_Preheat1_Menu); - #if PREHEAT_COUNT >= 2 - MENU_ITEM_F(ICON_SetABSPreheat, MSG_PREHEAT_2_SETTINGS, onDrawABSPreheatSubMenu, Draw_Preheat2_Menu); - #if PREHEAT_COUNT >= 3 - MENU_ITEM_F(ICON_SetCustomPreheat, MSG_PREHEAT_3_SETTINGS, onDrawSubMenu, Draw_Preheat3_Menu); - #endif - #endif + #define _ITEM_SETPREHEAT(N) MENU_ITEM(ICON_SetPreheat##N, MSG_PREHEAT_## N ##_SETTINGS, onDrawSubMenu, Draw_Preheat## N ##_Menu); + REPEAT_1(PREHEAT_COUNT, _ITEM_SETPREHEAT) #endif } - CurrentMenu->draw(); + UpdateMenu(TemperatureMenu); } void Draw_MaxSpeed_Menu() { checkkey = Menu; - if (!MaxSpeedMenu) MaxSpeedMenu = new MenuClass(); - if (CurrentMenu != MaxSpeedMenu) { - CurrentMenu = MaxSpeedMenu; - SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_MAX_SPEED)); - MenuItemsPrepare(5); + if (SET_MENU_R(MaxSpeedMenu, selrect({1, 16, 28, 13}), MSG_MAX_SPEED, 5)) { BACK_ITEM(Draw_Motion_Menu); - EDIT_ITEM_F(ICON_MaxSpeedX, MSG_VMAX_A, onDrawMaxSpeedX, SetMaxSpeedX, &planner.settings.max_feedrate_mm_s[X_AXIS]); - EDIT_ITEM_F(ICON_MaxSpeedY, MSG_VMAX_B, onDrawMaxSpeedY, SetMaxSpeedY, &planner.settings.max_feedrate_mm_s[Y_AXIS]); - EDIT_ITEM_F(ICON_MaxSpeedZ, MSG_VMAX_C, onDrawMaxSpeedZ, SetMaxSpeedZ, &planner.settings.max_feedrate_mm_s[Z_AXIS]); + EDIT_ITEM(ICON_MaxSpeedX, MSG_VMAX_A, onDrawMaxSpeedX, SetMaxSpeedX, &planner.settings.max_feedrate_mm_s[X_AXIS]); + EDIT_ITEM(ICON_MaxSpeedY, MSG_VMAX_B, onDrawMaxSpeedY, SetMaxSpeedY, &planner.settings.max_feedrate_mm_s[Y_AXIS]); + EDIT_ITEM(ICON_MaxSpeedZ, MSG_VMAX_C, onDrawMaxSpeedZ, SetMaxSpeedZ, &planner.settings.max_feedrate_mm_s[Z_AXIS]); #if HAS_HOTEND - EDIT_ITEM_F(ICON_MaxSpeedE, MSG_VMAX_E, onDrawMaxSpeedE, SetMaxSpeedE, &planner.settings.max_feedrate_mm_s[E_AXIS]); + EDIT_ITEM(ICON_MaxSpeedE, MSG_VMAX_E, onDrawMaxSpeedE, SetMaxSpeedE, &planner.settings.max_feedrate_mm_s[E_AXIS]); #endif } - CurrentMenu->draw(); + UpdateMenu(MaxSpeedMenu); } void Draw_MaxAccel_Menu() { checkkey = Menu; - if (!MaxAccelMenu) MaxAccelMenu = new MenuClass(); - if (CurrentMenu != MaxAccelMenu) { - CurrentMenu = MaxAccelMenu; - SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_ACCELERATION)); - MenuItemsPrepare(5); + if (SET_MENU_R(MaxAccelMenu, selrect({1, 16, 28, 13}), MSG_AMAX_EN, 5)) { BACK_ITEM(Draw_Motion_Menu); - EDIT_ITEM_F(ICON_MaxAccX, MSG_AMAX_A, onDrawMaxAccelX, SetMaxAccelX, &planner.settings.max_acceleration_mm_per_s2[X_AXIS]); - EDIT_ITEM_F(ICON_MaxAccY, MSG_AMAX_B, onDrawMaxAccelY, SetMaxAccelY, &planner.settings.max_acceleration_mm_per_s2[Y_AXIS]); - EDIT_ITEM_F(ICON_MaxAccZ, MSG_AMAX_C, onDrawMaxAccelZ, SetMaxAccelZ, &planner.settings.max_acceleration_mm_per_s2[Z_AXIS]); + EDIT_ITEM(ICON_MaxAccX, MSG_AMAX_A, onDrawMaxAccelX, SetMaxAccelX, &planner.settings.max_acceleration_mm_per_s2[X_AXIS]); + EDIT_ITEM(ICON_MaxAccY, MSG_AMAX_B, onDrawMaxAccelY, SetMaxAccelY, &planner.settings.max_acceleration_mm_per_s2[Y_AXIS]); + EDIT_ITEM(ICON_MaxAccZ, MSG_AMAX_C, onDrawMaxAccelZ, SetMaxAccelZ, &planner.settings.max_acceleration_mm_per_s2[Z_AXIS]); #if HAS_HOTEND - EDIT_ITEM_F(ICON_MaxAccE, MSG_AMAX_E, onDrawMaxAccelE, SetMaxAccelE, &planner.settings.max_acceleration_mm_per_s2[E_AXIS]); + EDIT_ITEM(ICON_MaxAccE, MSG_AMAX_E, onDrawMaxAccelE, SetMaxAccelE, &planner.settings.max_acceleration_mm_per_s2[E_AXIS]); #endif } - CurrentMenu->draw(); + UpdateMenu(MaxAccelMenu); } #if HAS_CLASSIC_JERK + void Draw_MaxJerk_Menu() { checkkey = Menu; - if (!MaxJerkMenu) MaxJerkMenu = new MenuClass(); - if (CurrentMenu != MaxJerkMenu) { - CurrentMenu = MaxJerkMenu; - SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_JERK)); - MenuItemsPrepare(5); + if (SET_MENU_R(MaxJerkMenu, selrect({1, 16, 28, 13}), MSG_JERK, 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(ICON_MaxSpeedJerkX, MSG_VA_JERK, onDrawMaxJerkX, SetMaxJerkX, &planner.max_jerk.x); + EDIT_ITEM(ICON_MaxSpeedJerkY, MSG_VB_JERK, onDrawMaxJerkY, SetMaxJerkY, &planner.max_jerk.y); + EDIT_ITEM(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(ICON_MaxSpeedJerkE, MSG_VE_JERK, onDrawMaxJerkE, SetMaxJerkE, &planner.max_jerk.e); #endif } - CurrentMenu->draw(); + UpdateMenu(MaxJerkMenu); } -#endif + +#endif // HAS_CLASSIC_JERK void Draw_Steps_Menu() { checkkey = Menu; - if (!StepsMenu) StepsMenu = new MenuClass(); - if (CurrentMenu != StepsMenu) { - CurrentMenu = StepsMenu; - SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_STEPS_PER_MM)); - MenuItemsPrepare(5); + if (SET_MENU_R(StepsMenu, selrect({1, 16, 28, 13}), MSG_STEPS_PER_MM, 5)) { BACK_ITEM(Draw_Motion_Menu); - EDIT_ITEM_F(ICON_StepX, MSG_A_STEPS, onDrawStepsX, SetStepsX, &planner.settings.axis_steps_per_mm[X_AXIS]); - EDIT_ITEM_F(ICON_StepY, MSG_B_STEPS, onDrawStepsY, SetStepsY, &planner.settings.axis_steps_per_mm[Y_AXIS]); - EDIT_ITEM_F(ICON_StepZ, MSG_C_STEPS, onDrawStepsZ, SetStepsZ, &planner.settings.axis_steps_per_mm[Z_AXIS]); + EDIT_ITEM(ICON_StepX, MSG_A_STEPS, onDrawStepsX, SetStepsX, &planner.settings.axis_steps_per_mm[X_AXIS]); + EDIT_ITEM(ICON_StepY, MSG_B_STEPS, onDrawStepsY, SetStepsY, &planner.settings.axis_steps_per_mm[Y_AXIS]); + EDIT_ITEM(ICON_StepZ, MSG_C_STEPS, onDrawStepsZ, SetStepsZ, &planner.settings.axis_steps_per_mm[Z_AXIS]); #if HAS_HOTEND - EDIT_ITEM_F(ICON_StepE, MSG_E_STEPS, onDrawStepsE, SetStepsE, &planner.settings.axis_steps_per_mm[E_AXIS]); + EDIT_ITEM(ICON_StepE, MSG_E_STEPS, onDrawStepsE, SetStepsE, &planner.settings.axis_steps_per_mm[E_AXIS]); #endif } - CurrentMenu->draw(); + UpdateMenu(StepsMenu); } -#if HAS_HOTEND +#if ENABLED(PIDTEMP) + void Draw_HotendPID_Menu() { checkkey = Menu; - if (SetMenu(HotendPIDMenu, F(STR_HOTEND_PID " Settings"),8)) { + if (SET_MENU_F(HotendPIDMenu, 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); - EDIT_ITEM(ICON_PIDValue, F("Set" STR_KI), onDrawPIDi, SetKi, &thermalManager.temp_hotend[0].pid.Ki); - EDIT_ITEM(ICON_PIDValue, F("Set" STR_KD), onDrawPIDd, SetKd, &thermalManager.temp_hotend[0].pid.Kd); - EDIT_ITEM_F(ICON_Temperature, MSG_TEMPERATURE, onDrawPIntMenu, SetHotendPidT, &HMI_data.HotendPidT); - EDIT_ITEM_F(ICON_PIDcycles, MSG_PID_CYCLE, onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); + MENU_ITEM_F(ICON_PIDNozzle, STR_HOTEND_PID, onDrawMenuItem, HotendPID); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KP, onDrawPFloat2Menu, SetKp, &thermalManager.temp_hotend[0].pid.Kp); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KI, onDrawPIDi, SetKi, &thermalManager.temp_hotend[0].pid.Ki); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KD, onDrawPIDd, SetKd, &thermalManager.temp_hotend[0].pid.Kd); + EDIT_ITEM(ICON_Temperature, MSG_TEMPERATURE, onDrawPIntMenu, SetHotendPidT, &HMI_data.HotendPidT); + EDIT_ITEM(ICON_PIDCycles, MSG_PID_CYCLE, onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); #if ENABLED(EEPROM_SETTINGS) - MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); + MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); #endif } UpdateMenu(HotendPIDMenu); } + #endif -#if HAS_HEATED_BED +#if ENABLED(PIDTEMPBED) + void Draw_BedPID_Menu() { checkkey = Menu; - if (SetMenu(BedPIDMenu, F(STR_BED_PID " Settings"),8)) { + if (SET_MENU_F(BedPIDMenu, 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); - EDIT_ITEM(ICON_PIDValue, F("Set" STR_KI), onDrawPIDi, SetKi, &thermalManager.temp_bed.pid.Ki); - EDIT_ITEM(ICON_PIDValue, F("Set" STR_KD), onDrawPIDd, SetKd, &thermalManager.temp_bed.pid.Kd); - EDIT_ITEM_F(ICON_Temperature, MSG_TEMPERATURE, onDrawPIntMenu, SetBedPidT, &HMI_data.BedPidT); - EDIT_ITEM_F(ICON_PIDcycles, MSG_PID_CYCLE, onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); + MENU_ITEM_F(ICON_PIDBed, STR_BED_PID, onDrawMenuItem,BedPID); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KP, onDrawPFloat2Menu, SetKp, &thermalManager.temp_bed.pid.Kp); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KI, onDrawPIDi, SetKi, &thermalManager.temp_bed.pid.Ki); + EDIT_ITEM_F(ICON_PIDValue, "Set" STR_KD, onDrawPIDd, SetKd, &thermalManager.temp_bed.pid.Kd); + EDIT_ITEM(ICON_Temperature, MSG_TEMPERATURE, onDrawPIntMenu, SetBedPidT, &HMI_data.BedPidT); + EDIT_ITEM(ICON_PIDCycles, MSG_PID_CYCLE, onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); #if ENABLED(EEPROM_SETTINGS) - MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); + MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); #endif } UpdateMenu(BedPIDMenu); } -#endif -#if ENABLED(BABYSTEP_ZPROBE_OFFSET) +#endif // PIDTEMPBED + +#if HAS_BED_PROBE + void Draw_ZOffsetWiz_Menu() { checkkey = Menu; - if (SetMenu(ZOffsetWizMenu, GET_TEXT_F(MSG_PROBE_WIZARD), 4)) { + if (SET_MENU(ZOffsetWizMenu, MSG_PROBE_WIZARD, 4)) { BACK_ITEM(Draw_Prepare_Menu); - MENU_ITEM_F(ICON_Homing, MSG_AUTO_HOME, onDrawMenuItem, AutoHome); - MENU_ITEM(ICON_MoveZ0, F("Move Z to Home"), onDrawMenuItem, SetMoveZto0); - EDIT_ITEM_F(ICON_Zoffset, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); + MENU_ITEM(ICON_Homing, MSG_AUTO_HOME, onDrawMenuItem, AutoHome); + MENU_ITEM_F(ICON_MoveZ0, "Move Z to Home", onDrawMenuItem, SetMoveZto0); + EDIT_ITEM(ICON_Zoffset, MSG_ZPROBE_ZOFFSET, onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); } UpdateMenu(ZOffsetWizMenu); if (!axis_is_trusted(Z_AXIS)) LCD_MESSAGE_F("WARNING: Z position unknown, move Z to home"); } + #endif #if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) + void Draw_Homing_Menu() { checkkey = Menu; - if (SetMenu(HomingMenu, GET_TEXT_F(MSG_HOMING), 5)) { + if (SET_MENU(HomingMenu, MSG_HOMING, 6)) { BACK_ITEM(Draw_Prepare_Menu); - MENU_ITEM_F(ICON_Homing, MSG_AUTO_HOME, onDrawMenuItem, AutoHome); - MENU_ITEM_F(ICON_HomeX, MSG_AUTO_HOME_X, onDrawMenuItem, HomeX); - MENU_ITEM_F(ICON_HomeY, MSG_AUTO_HOME_Y, onDrawMenuItem, HomeY); - MENU_ITEM_F(ICON_HomeZ, MSG_AUTO_HOME_Z, onDrawMenuItem, HomeZ); + MENU_ITEM(ICON_Homing, MSG_AUTO_HOME, onDrawMenuItem, AutoHome); + MENU_ITEM(ICON_HomeX, MSG_AUTO_HOME_X, onDrawMenuItem, HomeX); + MENU_ITEM(ICON_HomeY, MSG_AUTO_HOME_Y, onDrawMenuItem, HomeY); + MENU_ITEM(ICON_HomeZ, MSG_AUTO_HOME_Z, onDrawMenuItem, HomeZ); + #if ENABLED(MESH_BED_LEVELING) + EDIT_ITEM(ICON_ZAfterHome, MSG_Z_AFTER_HOME, onDrawPInt8Menu, SetZAfterHoming, &HMI_data.z_after_homing); + #endif } UpdateMenu(HomingMenu); } + #endif #if ENABLED(FWRETRACT) + void Draw_FWRetract_Menu() { checkkey = Menu; - if (SetMenu(FWRetractMenu, GET_TEXT_F(MSG_FWRETRACT), 6)) { + if (SET_MENU(FWRetractMenu, MSG_FWRETRACT, 6)) { BACK_ITEM(Return_FWRetract_Menu); - EDIT_ITEM_F(ICON_FWRetLength, MSG_CONTROL_RETRACT, onDrawPFloatMenu, SetRetractLength, &fwretract.settings.retract_length); - EDIT_ITEM_F(ICON_FWRetSpeed, MSG_SINGLENOZZLE_RETRACT_SPEED, onDrawPFloatMenu, SetRetractSpeed, &fwretract.settings.retract_feedrate_mm_s); - EDIT_ITEM_F(ICON_FWRetZRaise, MSG_CONTROL_RETRACT_ZHOP, onDrawPFloat2Menu, SetZRaise, &fwretract.settings.retract_zraise); - EDIT_ITEM_F(ICON_FWRecSpeed, MSG_SINGLENOZZLE_UNRETRACT_SPEED, onDrawPFloatMenu, SetRecoverSpeed, &fwretract.settings.retract_recover_feedrate_mm_s); - EDIT_ITEM_F(ICON_FWRecExtra, MSG_CONTROL_RETRACT_RECOVER, onDrawPFloatMenu, SetAddRecover, &fwretract.settings.retract_recover_extra); + EDIT_ITEM(ICON_FWRetLength, MSG_CONTROL_RETRACT, onDrawPFloatMenu, SetRetractLength, &fwretract.settings.retract_length); + EDIT_ITEM(ICON_FWRetSpeed, MSG_SINGLENOZZLE_RETRACT_SPEED, onDrawPFloatMenu, SetRetractSpeed, &fwretract.settings.retract_feedrate_mm_s); + EDIT_ITEM(ICON_FWRetZRaise, MSG_CONTROL_RETRACT_ZHOP, onDrawPFloat2Menu, SetZRaise, &fwretract.settings.retract_zraise); + EDIT_ITEM(ICON_FWRecSpeed, MSG_SINGLENOZZLE_UNRETRACT_SPEED, onDrawPFloatMenu, SetRecoverSpeed, &fwretract.settings.retract_recover_feedrate_mm_s); + EDIT_ITEM(ICON_FWRecExtra, MSG_CONTROL_RETRACT_RECOVER, onDrawPFloatMenu, SetAddRecover, &fwretract.settings.retract_recover_extra); } UpdateMenu(FWRetractMenu); } + #endif //============================================================================= @@ -3745,41 +3573,41 @@ void Draw_Steps_Menu() { DWIN_UpdateLCD(); } - #if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) + #if ENABLED(PREHEAT_BEFORE_LEVELING) void SetBedLevT() { SetPIntOnClick(MIN_BEDTEMP, MAX_BEDTEMP); } #endif #if ENABLED(MESH_EDIT_MENU) - uint8_t mesh_x = 0, mesh_y = 0; #define Z_OFFSET_MIN -3 #define Z_OFFSET_MAX 3 - void LiveEditMesh() { ((MenuItemPtrClass*)EditZValueItem)->value = &bedlevel.z_values[HMI_value.Select ? mesh_x : MenuData.Value][HMI_value.Select ? MenuData.Value : mesh_y]; EditZValueItem->redraw(); } - void ApplyEditMeshX() { mesh_x = MenuData.Value; } - void SetEditMeshX() { HMI_value.Select = 0; SetIntOnClick(0, GRID_MAX_POINTS_X - 1, mesh_x, ApplyEditMeshX, LiveEditMesh); } - void ApplyEditMeshY() { mesh_y = MenuData.Value; } - void SetEditMeshY() { HMI_value.Select = 1; SetIntOnClick(0, GRID_MAX_POINTS_Y - 1, mesh_y, ApplyEditMeshY, LiveEditMesh); } + void LiveEditMesh() { ((MenuItemPtrClass*)EditZValueItem)->value = &bedlevel.z_values[HMI_value.Select ? bedLevelTools.mesh_x : MenuData.Value][HMI_value.Select ? MenuData.Value : bedLevelTools.mesh_y]; EditZValueItem->redraw(); } + void ApplyEditMeshX() { bedLevelTools.mesh_x = MenuData.Value; } + void SetEditMeshX() { HMI_value.Select = 0; SetIntOnClick(0, GRID_MAX_POINTS_X - 1, bedLevelTools.mesh_x, ApplyEditMeshX, LiveEditMesh); } + void ApplyEditMeshY() { bedLevelTools.mesh_y = MenuData.Value; } + void SetEditMeshY() { HMI_value.Select = 1; SetIntOnClick(0, GRID_MAX_POINTS_Y - 1, bedLevelTools.mesh_y, ApplyEditMeshY, LiveEditMesh); } void SetEditZValue() { SetPFloatOnClick(Z_OFFSET_MIN, Z_OFFSET_MAX, 3); } #endif -#endif + +#endif // HAS_MESH #if ENABLED(AUTO_BED_LEVELING_UBL) void ApplyUBLSlot() { bedlevel.storage_slot = MenuData.Value; } void SetUBLSlot() { SetIntOnClick(0, settings.calc_num_meshes() - 1, bedlevel.storage_slot, ApplyUBLSlot); } void onDrawUBLSlot(MenuItemClass* menuitem, int8_t line) { - if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0; + NOLESS(bedlevel.storage_slot, 0); onDrawIntMenu(menuitem, line, bedlevel.storage_slot); } - void ApplyUBLTiltGrid() { ubl_tools.tilt_grid = MenuData.Value; } - void SetUBLTiltGrid() { SetIntOnClick(1, 3, ubl_tools.tilt_grid, ApplyUBLTiltGrid); } + void ApplyUBLTiltGrid() { bedLevelTools.tilt_grid = MenuData.Value; } + void SetUBLTiltGrid() { SetIntOnClick(1, 3, bedLevelTools.tilt_grid, ApplyUBLTiltGrid); } - void UBLTiltMesh() { - if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0; + void UBLMeshTilt() { + NOLESS(bedlevel.storage_slot, 0); char buf[15]; - if (ubl_tools.tilt_grid > 1) { - sprintf_P(buf, PSTR("G28O\nG29 J%i"), ubl_tools.tilt_grid); + if (bedLevelTools.tilt_grid > 1) { + sprintf_P(buf, PSTR("G28O\nG29 J%i"), bedLevelTools.tilt_grid); gcode.process_subcommands_now(buf); } else @@ -3788,76 +3616,65 @@ void Draw_Steps_Menu() { } void UBLSmartFillMesh() { - bedlevel.smart_fill_mesh(); + LOOP_L_N(x, GRID_MAX_POINTS_Y) bedlevel.smart_fill_mesh(); LCD_MESSAGE(MSG_UBL_MESH_FILLED); } - bool UBLValidMesh() { - const bool valid = ubl_tools.validate(); - if (!valid) bedlevel.invalidate(); - return valid; - } - - void UBLSaveMesh() { - if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0; + void UBLMeshSave() { + NOLESS(bedlevel.storage_slot, 0); settings.store_mesh(bedlevel.storage_slot); ui.status_printf(0, GET_TEXT_F(MSG_MESH_SAVED), bedlevel.storage_slot); DONE_BUZZ(true); } - void UBLLoadMesh() { - if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0; + void UBLMeshLoad() { + NOLESS(bedlevel.storage_slot, 0); settings.load_mesh(bedlevel.storage_slot); - if (UBLValidMesh()) { - ui.status_printf(0, GET_TEXT_F(MSG_MESH_LOADED), bedlevel.storage_slot); - DONE_BUZZ(true); - } - else { - LCD_MESSAGE_F("Invalid Mesh Loaded"); - DONE_BUZZ(false); - } } #endif // AUTO_BED_LEVELING_UBL #if HAS_MESH + void Draw_MeshSet_Menu() { checkkey = Menu; - if (SetMenu(MeshMenu, GET_TEXT_F(MSG_MESH_LEVELING), 15)) { + if (SET_MENU(MeshMenu, MSG_MESH_LEVELING, 13)) { BACK_ITEM(Draw_AdvancedSettings_Menu); - #if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) - EDIT_ITEM_F(ICON_Temperature, MSG_UBL_SET_TEMP_BED, onDrawPIntMenu, SetBedLevT, &HMI_data.BedLevT); + #if ENABLED(PREHEAT_BEFORE_LEVELING) + EDIT_ITEM(ICON_Temperature, MSG_UBL_SET_TEMP_BED, onDrawPIntMenu, SetBedLevT, &HMI_data.BedLevT); #endif - EDIT_ITEM_F(ICON_SetZOffset, MSG_Z_FADE_HEIGHT, onDrawPFloatMenu, SetMeshFadeHeight, &planner.z_fade_height); - EDIT_ITEM_F(ICON_UBLActive, MSG_ACTIVATE_MESH, onDrawChkbMenu, SetMeshActive, &planner.leveling_active); + EDIT_ITEM(ICON_SetZOffset, MSG_Z_FADE_HEIGHT, onDrawPFloatMenu, SetMeshFadeHeight, &planner.z_fade_height); + EDIT_ITEM(ICON_UBLActive, MSG_ACTIVATE_MESH, onDrawChkbMenu, SetMeshActive, &planner.leveling_active); #if HAS_BED_PROBE - MENU_ITEM_F(ICON_Level, MSG_AUTO_MESH, onDrawMenuItem, AutoLev); + MENU_ITEM(ICON_Level, MSG_AUTO_MESH, onDrawMenuItem, AutoLev); #endif #if ENABLED(AUTO_BED_LEVELING_UBL) - EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_STORAGE_SLOT, onDrawUBLSlot, SetUBLSlot, &bedlevel.storage_slot); - MENU_ITEM_F(ICON_UBLActive, MSG_UBL_SAVE_MESH, onDrawMenuItem, UBLSaveMesh); - MENU_ITEM_F(ICON_UBLActive, MSG_UBL_LOAD_MESH, onDrawMenuItem, UBLLoadMesh); - EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_TILTING_GRID, onDrawPInt8Menu, SetUBLTiltGrid, &ubl_tools.tilt_grid); - MENU_ITEM_F(ICON_UBLActive, MSG_UBL_TILT_MESH, onDrawMenuItem, UBLTiltMesh); - MENU_ITEM_F(ICON_UBLActive, MSG_UBL_SMART_FILLIN, onDrawMenuItem, UBLSmartFillMesh); + EDIT_ITEM(ICON_UBLSlot, MSG_UBL_STORAGE_SLOT, onDrawUBLSlot, SetUBLSlot, &bedlevel.storage_slot); + MENU_ITEM(ICON_UBLMeshSave, MSG_UBL_SAVE_MESH, onDrawMenuItem, UBLMeshSave); + MENU_ITEM(ICON_UBLMeshLoad, MSG_UBL_LOAD_MESH, onDrawMenuItem, UBLMeshLoad); + EDIT_ITEM(ICON_UBLTiltGrid, MSG_UBL_TILTING_GRID, onDrawPInt8Menu, SetUBLTiltGrid, &bedLevelTools.tilt_grid); + MENU_ITEM(ICON_UBLTiltGrid, MSG_UBL_TILT_MESH, onDrawMenuItem, UBLMeshTilt); + MENU_ITEM(ICON_UBLSmartFill, MSG_UBL_SMART_FILLIN, onDrawMenuItem, UBLSmartFillMesh); #endif #if ENABLED(MESH_EDIT_MENU) - MENU_ITEM_F(ICON_UBLActive, MSG_EDIT_MESH, onDrawSubMenu, Draw_EditMesh_Menu); + MENU_ITEM(ICON_MeshEdit, MSG_EDIT_MESH, onDrawSubMenu, Draw_EditMesh_Menu); #endif - MENU_ITEM_F(ICON_MeshViewer, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer); + MENU_ITEM(ICON_MeshViewer, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer); } UpdateMenu(MeshMenu); } #if ENABLED(MESH_EDIT_MENU) void Draw_EditMesh_Menu() { + if (!leveling_is_valid()) { LCD_MESSAGE(MSG_UBL_MESH_INVALID); return; } + set_bed_leveling_enabled(false); checkkey = Menu; - if (SetMenu(EditMeshMenu, GET_TEXT_F(MSG_EDIT_MESH), 4)) { - mesh_x = mesh_y = 0; + if (SET_MENU(EditMeshMenu, MSG_EDIT_MESH, 4)) { + bedLevelTools.mesh_x = bedLevelTools.mesh_y = 0; BACK_ITEM(Draw_MeshSet_Menu); - EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_X, onDrawPInt8Menu, SetEditMeshX, &mesh_x); - EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_Y, onDrawPInt8Menu, SetEditMeshY, &mesh_y); - EditZValueItem = EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_EDIT_Z, onDrawPFloat3Menu, SetEditZValue, &bedlevel.z_values[mesh_x][mesh_y]); + EDIT_ITEM(ICON_MeshEditX, MSG_MESH_X, onDrawPInt8Menu, SetEditMeshX, &bedLevelTools.mesh_x); + EDIT_ITEM(ICON_MeshEditY, MSG_MESH_Y, onDrawPInt8Menu, SetEditMeshY, &bedLevelTools.mesh_y); + EditZValueItem = EDIT_ITEM(ICON_MeshEditZ, MSG_MESH_EDIT_Z, onDrawPFloat2Menu, SetEditZValue, &bedlevel.z_values[bedLevelTools.mesh_x][bedLevelTools.mesh_y]); } UpdateMenu(EditMeshMenu); } diff --git a/Marlin/src/lcd/e3v2/proui/dwin.h b/Marlin/src/lcd/e3v2/proui/dwin.h index 4f992b3a7895..a742d859605e 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.h +++ b/Marlin/src/lcd/e3v2/proui/dwin.h @@ -24,16 +24,32 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.17.2 - * Date: 2022/04/08 + * Version: 3.21.2 + * Date: 2022/12/02 */ +#include "../../../inc/MarlinConfig.h" + #include "dwin_defines.h" #include "dwinui.h" #include "../common/encoder.h" #include "../../../libs/BL24CXX.h" -#include "../../../inc/MarlinConfig.h" +#if EITHER(BABYSTEPPING, HAS_BED_PROBE) + #define HAS_ZOFFSET_ITEM 1 + #if !HAS_BED_PROBE + #define JUST_BABYSTEP 1 + #endif +#endif + +namespace GET_LANG(LCD_LANGUAGE) { + #define _MSG_PREHEAT(N) \ + LSTR MSG_PREHEAT_##N = _UxGT("Preheat ") PREHEAT_## N ##_LABEL; \ + LSTR MSG_PREHEAT_## N ##_SETTINGS = _UxGT("Preheat ") PREHEAT_## N ##_LABEL _UxGT(" Conf"); + #if PREHEAT_COUNT > 3 + REPEAT_S(4, PREHEAT_COUNT, _MSG_PREHEAT) + #endif +} enum processID : uint8_t { // Process ID @@ -44,7 +60,6 @@ enum processID : uint8_t { SetIntNoDraw, SetFloat, SetPFloat, - SelectFile, PrintProcess, Popup, Leveling, @@ -59,33 +74,87 @@ enum processID : uint8_t { }; enum pidresult_t : uint8_t { + PIDTEMP_START = 0, + PIDTEMPBED_START, PID_BAD_EXTRUDER_NUM, PID_TEMP_TOO_HIGH, PID_TUNING_TIMEOUT, - PID_EXTR_START, - PID_BED_START, - PID_DONE + PID_DONE, }; #define DWIN_CHINESE 123 #define DWIN_ENGLISH 0 +typedef struct { + // Color settings + uint16_t Background_Color; + uint16_t Cursor_Color; + uint16_t TitleBg_Color; + uint16_t TitleTxt_Color; + uint16_t Text_Color; + uint16_t Selected_Color; + uint16_t SplitLine_Color; + uint16_t Highlight_Color; + uint16_t StatusBg_Color; + uint16_t StatusTxt_Color; + uint16_t PopupBg_Color; + uint16_t PopupTxt_Color; + uint16_t AlertBg_Color; + uint16_t AlertTxt_Color; + uint16_t PercentTxt_Color; + uint16_t Barfill_Color; + uint16_t Indicator_Color; + uint16_t Coordinate_Color; + + // Temperatures + #if ENABLED(PIDTEMP) + int16_t HotendPidT = DEF_HOTENDPIDT; + #endif + #if ENABLED(PIDTEMPBED) + int16_t BedPidT = DEF_BEDPIDT; + #endif + #if (HAS_HOTEND || HAS_HEATED_BED) && HAS_PID_HEATING + int16_t PidCycles = DEF_PIDCYCLES; + #endif + #if ENABLED(PREVENT_COLD_EXTRUSION) + int16_t ExtMinT = EXTRUDE_MINTEMP; + #endif + #if ENABLED(PREHEAT_BEFORE_LEVELING) + int16_t BedLevT = LEVELING_BED_TEMP; + #endif + #if ENABLED(BAUD_RATE_GCODE) + bool Baud115K = false; + #endif + + bool FullManualTramming = false; + bool MediaAutoMount = ENABLED(HAS_SD_EXTENDER); + #if BOTH(INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) + uint8_t z_after_homing = DEF_Z_AFTER_HOMING; + #endif + #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) + LEDColor Led_Color = Def_Leds_Color; + #endif +} HMI_data_t; + +extern HMI_data_t HMI_data; +static constexpr size_t eeprom_data_size = sizeof(HMI_data_t); + typedef struct { int8_t Color[3]; // Color components - pidresult_t pidresult = PID_DONE; + #if HAS_PID_HEATING + tempcontrol_t pidresult = PID_DONE; + #endif uint8_t Select = 0; // Auxiliary selector variable AxisEnum axis = X_AXIS; // Axis Select } HMI_value_t; typedef struct { uint8_t language; + bool printing_flag:1; // sd or host printing + bool abort_flag:1; // sd or host was aborted + bool pause_flag:1; // printing is paused bool percent_flag:1; // percent was override by M73 bool remain_flag:1; // remain was override by M73 - bool pause_flag:1; // printing is paused - bool pause_action:1; // flag a pause action - bool abort_flag:1; // printing is aborting - bool abort_action:1; // flag a aborting action - bool print_finish:1; // print was finished bool select_flag:1; // Popup button selected bool home_flag:1; // homing in course bool heat_flag:1; // 0: heating done 1: during heating @@ -105,6 +174,7 @@ extern millis_t dwin_heat_time; #endif // Tool Functions +uint32_t GetHash(char * str); #if ENABLED(EEPROM_SETTINGS) void WriteEeprom(); void ReadEeprom(); @@ -118,15 +188,14 @@ void DisableMotors(); void AutoLev(); void AutoHome(); #if HAS_PREHEAT - void DoPreheat0(); - void DoPreheat1(); - void DoPreheat2(); + #define _DOPREHEAT(N) void DoPreheat##N(); + REPEAT_1(PREHEAT_COUNT, _DOPREHEAT) #endif void DoCoolDown(); -#if HAS_HOTEND +#if ENABLED(PIDTEMP) void HotendPID(); #endif -#if HAS_HEATED_BED +#if ENABLED(PIDTEMPBED) void BedPID(); #endif #if ENABLED(BAUD_RATE_GCODE) @@ -146,10 +215,15 @@ void ParkHead(); void ApplyLEDColor(); #endif #if ENABLED(AUTO_BED_LEVELING_UBL) - void UBLTiltMesh(); - bool UBLValidMesh(); - void UBLSaveMesh(); - void UBLLoadMesh(); + void UBLMeshTilt(); + void UBLMeshSave(); + void UBLMeshLoad(); +#endif +#if ENABLED(HOST_SHUTDOWN_MENU_ITEM) && defined(SHUTDOWN_ACTION) + void HostShutDown(); +#endif +#if !HAS_BED_PROBE + void HomeZandDisable(); #endif // Other @@ -160,8 +234,7 @@ void Goto_PowerLossRecovery(); void Goto_ConfirmToPrint(); void DWIN_Draw_Dashboard(const bool with_update); // Status Area void Draw_Main_Area(); // Redraw main area -void DWIN_DrawStatusLine(const char *text); // Draw simple status text -void DWIN_DrawStatusLine(FSTR_P fstr); +void DWIN_DrawStatusLine(const char *text = ""); // Draw simple status text void DWIN_RedrawDash(); // Redraw Dash and Status line void DWIN_RedrawScreen(); // Redraw all screen elements void HMI_MainMenu(); // Main process screen @@ -170,7 +243,6 @@ void HMI_Printing(); // Print page void HMI_ReturnScreen(); // Return to previous screen before popups void HMI_WaitForUser(); void HMI_SaveProcessID(const uint8_t id); -void HMI_SDCardInit(); void HMI_SDCardUpdate(); void EachMomentUpdate(); void update_variable(); @@ -180,12 +252,11 @@ void DWIN_CheckStatusMessage(); void DWIN_HomingStart(); void DWIN_HomingDone(); #if HAS_MESH - void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval); + void DWIN_MeshUpdate(const int8_t cpos, const int8_t tpos, const_float_t zval); #endif void DWIN_LevelingStart(); void DWIN_LevelingDone(); -void DWIN_PidTuning(pidresult_t result); -void DWIN_Print_Started(const bool sd=false); +void DWIN_Print_Started(); void DWIN_Print_Pause(); void DWIN_Print_Resume(); void DWIN_Print_Finished(); @@ -210,9 +281,11 @@ void DWIN_RebootScreen(); #endif // Utility and extensions -void DWIN_LockScreen(); -void DWIN_UnLockScreen(); -void HMI_LockScreen(); +#if HAS_LOCKSCREEN + void DWIN_LockScreen(); + void DWIN_UnLockScreen(); + void HMI_LockScreen(); +#endif #if HAS_MESH void DWIN_MeshViewer(); #endif @@ -227,6 +300,7 @@ void HMI_LockScreen(); #endif // Menu drawing functions +void Draw_Print_File_Menu(); void Draw_Control_Menu(); void Draw_AdvancedSettings_Menu(); void Draw_Prepare_Menu(); @@ -259,12 +333,6 @@ void Draw_Motion_Menu(); #if ENABLED(MESH_BED_LEVELING) void Draw_ManualMesh_Menu(); #endif -#if HAS_HOTEND - void Draw_Preheat1_Menu(); - void Draw_Preheat2_Menu(); - void Draw_Preheat3_Menu(); - void Draw_HotendPID_Menu(); -#endif void Draw_Temperature_Menu(); void Draw_MaxSpeed_Menu(); void Draw_MaxAccel_Menu(); @@ -272,9 +340,6 @@ void Draw_MaxAccel_Menu(); void Draw_MaxJerk_Menu(); #endif void Draw_Steps_Menu(); -#if HAS_HEATED_BED - void Draw_BedPID_Menu(); -#endif #if EITHER(HAS_BED_PROBE, BABYSTEPPING) void Draw_ZOffsetWiz_Menu(); #endif @@ -290,3 +355,15 @@ void Draw_Steps_Menu(); void Draw_EditMesh_Menu(); #endif #endif + +// PID +#if HAS_PID_HEATING + void DWIN_PidTuning(tempcontrol_t result); + #if ENABLED(PIDTEMP) + void Draw_HotendPID_Menu(); + #endif + #if ENABLED(PIDTEMPBED) + void Draw_BedPID_Menu(); + #endif +#endif +#endif diff --git a/Marlin/src/lcd/e3v2/proui/dwin_defines.h b/Marlin/src/lcd/e3v2/proui/dwin_defines.h index 1517acd238d0..de3f40e2814b 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_defines.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_defines.h @@ -19,44 +19,45 @@ * along with this program. If not, see . * */ -#pragma once - /** * DWIN general defines and data structs for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.11.2 - * Date: 2022/02/28 + * Version: 3.12.2 + * Date: 2022/08/08 */ +#pragma once + //#define DEBUG_DWIN 1 //#define NEED_HEX_PRINT 1 -#include "../../../inc/MarlinConfigPre.h" -#include - -#define HAS_ESDIAG 1 -#define HAS_PIDPLOT 1 -#define HAS_GCODE_PREVIEW 1 #if defined(__STM32F1__) || defined(STM32F1) #define DASH_REDRAW 1 #endif -#include "../common/dwin_color.h" -#if ENABLED(LED_CONTROL_MENU) - #include "../../../feature/leds/leds.h" +#if DISABLED(PROBE_MANUALLY) && ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_UBL) + #define HAS_ONESTEP_LEVELING 1 +#endif + +#if !HAS_BED_PROBE && ENABLED(BABYSTEPPING) + #define JUST_BABYSTEP 1 +#endif + +#if ANY(BABYSTEPPING, HAS_BED_PROBE, HAS_WORKSPACE_OFFSET) + #define HAS_ZOFFSET_ITEM 1 #endif #define Def_Background_Color RGB( 1, 12, 8) -#define Def_Cursor_color RGB(20, 49, 31) -#define Def_TitleBg_color RGB( 0, 23, 16) -#define Def_TitleTxt_color Color_White +#define Def_Cursor_Color RGB(20, 49, 31) +#define Def_TitleBg_Color RGB( 0, 23, 16) +#define Def_TitleTxt_Color Color_White #define Def_Text_Color Color_White #define Def_Selected_Color Select_Color #define Def_SplitLine_Color RGB( 0, 23, 16) #define Def_Highlight_Color Color_White #define Def_StatusBg_Color RGB( 0, 23, 16) #define Def_StatusTxt_Color Color_Yellow -#define Def_PopupBg_color Color_Bg_Window +#define Def_PopupBg_Color Color_Bg_Window #define Def_PopupTxt_Color Popup_Text_Color #define Def_AlertBg_Color Color_Bg_Red #define Def_AlertTxt_Color Color_Yellow @@ -65,64 +66,18 @@ #define Def_Indicator_Color Color_White #define Def_Coordinate_Color Color_White #define Def_Button_Color RGB( 0, 23, 16) - -#define HAS_ESDIAG 1 - #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) - #define Def_Leds_Color 0xFFFFFFFF + #define Def_Leds_Color LEDColorWhite() #endif #if ENABLED(CASELIGHT_USES_BRIGHTNESS) #define Def_CaseLight_Brightness 255 #endif +#ifdef Z_AFTER_HOMING + #define DEF_Z_AFTER_HOMING Z_AFTER_HOMING +#else + #define DEF_Z_AFTER_HOMING 0 +#endif +#define DEF_HOTENDPIDT TERN(PREHEAT_1_TEMP_BED, PREHEAT_1_TEMP_HOTEND, 195) +#define DEF_BEDPIDT TERN(PREHEAT_1_TEMP_BED, PREHEAT_1_TEMP_HOTEND, 60) +#define DEF_PIDCYCLES 5 -typedef struct { - // Color settings - uint16_t Background_Color = Def_Background_Color; - uint16_t Cursor_color = Def_Cursor_color; - uint16_t TitleBg_color = Def_TitleBg_color; - uint16_t TitleTxt_color = Def_TitleTxt_color; - uint16_t Text_Color = Def_Text_Color; - uint16_t Selected_Color = Def_Selected_Color; - uint16_t SplitLine_Color = Def_SplitLine_Color; - uint16_t Highlight_Color = Def_Highlight_Color; - uint16_t StatusBg_Color = Def_StatusBg_Color; - uint16_t StatusTxt_Color = Def_StatusTxt_Color; - uint16_t PopupBg_color = Def_PopupBg_color; - uint16_t PopupTxt_Color = Def_PopupTxt_Color; - uint16_t AlertBg_Color = Def_AlertBg_Color; - uint16_t AlertTxt_Color = Def_AlertTxt_Color; - uint16_t PercentTxt_Color = Def_PercentTxt_Color; - uint16_t Barfill_Color = Def_Barfill_Color; - uint16_t Indicator_Color = Def_Indicator_Color; - uint16_t Coordinate_Color = Def_Coordinate_Color; - // Temperatures - #if HAS_HOTEND && defined(PREHEAT_1_TEMP_HOTEND) - int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND; - #endif - #if HAS_HEATED_BED && defined(PREHEAT_1_TEMP_BED) - int16_t BedPidT = PREHEAT_1_TEMP_BED; - #endif - #if HAS_HOTEND || HAS_HEATED_BED - int16_t PidCycles = 10; - #endif - #if ENABLED(PREVENT_COLD_EXTRUSION) - int16_t ExtMinT = EXTRUDE_MINTEMP; - #endif - #if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) - int16_t BedLevT = LEVELING_BED_TEMP; - #endif - #if ENABLED(BAUD_RATE_GCODE) - bool Baud115K = false; - #endif - bool FullManualTramming = false; - // Led - #if ENABLED(MESH_BED_LEVELING) - float ManualZOffset = 0; - #endif - #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) - uint32_t LED_Color = Def_Leds_Color; - #endif -} HMI_data_t; - -static constexpr size_t eeprom_data_size = sizeof(HMI_data_t); -extern HMI_data_t HMI_data; diff --git a/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp index 59b6c0d328ae..552075f9dcb9 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp @@ -46,8 +46,8 @@ uint16_t HighlightYPos = 280; void Draw_Select_Highlight(const bool sel, const uint16_t ypos) { HighlightYPos = ypos; HMI_flag.select_flag = sel; - const uint16_t c1 = sel ? HMI_data.Highlight_Color : HMI_data.PopupBg_color, - c2 = sel ? HMI_data.PopupBg_color : HMI_data.Highlight_Color; + const uint16_t c1 = sel ? HMI_data.Highlight_Color : HMI_data.PopupBg_Color, + c2 = sel ? HMI_data.PopupBg_Color : HMI_data.Highlight_Color; DWIN_Draw_Rectangle(0, c1, 25, ypos - 1, 126, ypos + 38); DWIN_Draw_Rectangle(0, c1, 24, ypos - 2, 127, ypos + 39); DWIN_Draw_Rectangle(0, c2, 145, ypos - 1, 246, ypos + 38); diff --git a/Marlin/src/lcd/e3v2/proui/dwin_popup.h b/Marlin/src/lcd/e3v2/proui/dwin_popup.h index b4503ea7866b..f24aac582e6c 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_popup.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.h @@ -44,7 +44,7 @@ void Goto_Popup(const popupDrawFunc_t fnDraw, const popupClickFunc_t fnClick=nul void HMI_Popup(); inline void Draw_Popup_Bkgd() { - DWIN_Draw_Rectangle(1, HMI_data.PopupBg_color, 14, 60, 258, 330); + DWIN_Draw_Rectangle(1, HMI_data.PopupBg_Color, 14, 60, 258, 330); DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, 14, 60, 258, 330); } diff --git a/Marlin/src/lcd/e3v2/proui/dwinui.cpp b/Marlin/src/lcd/e3v2/proui/dwinui.cpp index ecb4754a0f35..afb18f24dbc9 100644 --- a/Marlin/src/lcd/e3v2/proui/dwinui.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwinui.cpp @@ -23,56 +23,43 @@ /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.17.1 - * Date: 2022/04/12 + * Version: 3.20.1 + * Date: 2022/10/25 */ -#include "../../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfig.h" #if ENABLED(DWIN_LCD_PROUI) -#include "../../../inc/MarlinConfig.h" +#include "dwin_defines.h" #include "dwin_lcd.h" #include "dwinui.h" -#include "dwin_defines.h" - -//#define DEBUG_OUT 1 -#include "../../../core/debug_out.h" xy_int_t DWINUI::cursor = { 0 }; uint16_t DWINUI::pencolor = Color_White; uint16_t DWINUI::textcolor = Def_Text_Color; uint16_t DWINUI::backcolor = Def_Background_Color; uint16_t DWINUI::buttoncolor = Def_Button_Color; -uint8_t DWINUI::font = font8x16; +uint8_t DWINUI::fontid = font8x16; FSTR_P const DWINUI::Author = F(STRING_CONFIG_H_AUTHOR); void (*DWINUI::onTitleDraw)(TitleClass* title) = nullptr; void DWINUI::init() { - delay(750); // Delay for wait to wakeup screen - const bool hs = DWIN_Handshake(); UNUSED(hs); - #if ENABLED(DEBUG_DWIN) - SERIAL_ECHOPGM("DWIN_Handshake "); - SERIAL_ECHOLNF(hs ? F("ok.") : F("error.")); - #endif - DWIN_Frame_SetDir(1); cursor.reset(); pencolor = Color_White; textcolor = Def_Text_Color; backcolor = Def_Background_Color; buttoncolor = Def_Button_Color; - font = font8x16; + fontid = font8x16; } // Set text/number font -void DWINUI::setFont(uint8_t cfont) { - font = cfont; -} +void DWINUI::setFont(fontid_t fid) { fontid = fid; } // Get font character width -uint8_t DWINUI::fontWidth(uint8_t cfont) { - switch (cfont) { +uint8_t DWINUI::fontWidth(fontid_t fid) { + switch (fid) { case font6x12 : return 6; case font8x16 : return 8; case font10x20: return 10; @@ -88,8 +75,8 @@ uint8_t DWINUI::fontWidth(uint8_t cfont) { } // Get font character height -uint8_t DWINUI::fontHeight(uint8_t cfont) { - switch (cfont) { +uint8_t DWINUI::fontHeight(fontid_t fid) { + switch (fid) { case font6x12 : return 12; case font8x16 : return 16; case font10x20: return 20; @@ -105,14 +92,10 @@ uint8_t DWINUI::fontHeight(uint8_t cfont) { } // Get screen x coordinates from text column -uint16_t DWINUI::ColToX(uint8_t col) { - return col * fontWidth(font); -} +uint16_t DWINUI::ColToX(uint8_t col) { return col * fontWidth(fontid); } // Get screen y coordinates from text row -uint16_t DWINUI::RowToY(uint8_t row) { - return row * fontHeight(font); -} +uint16_t DWINUI::RowToY(uint8_t row) { return row * fontHeight(fontid); } // Set text/number color void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor) { @@ -152,9 +135,9 @@ void DWINUI::MoveBy(xy_int_t point) { } // Draw a Centered string using arbitrary x1 and x2 margins -void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string) { - const uint16_t x = _MAX(0U, x2 + x1 - strlen_P(string) * fontWidth(size)) / 2 - 1; - DWIN_Draw_String(bShow, size, color, bColor, x, y, string); +void DWINUI::Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string) { + const uint16_t x = _MAX(0U, x2 + x1 - strlen_P(string) * fontWidth(fid)) / 2 - 1; + DWIN_Draw_String(bShow, fid, color, bColor, x, y, string); } // Draw a char @@ -164,13 +147,13 @@ void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint1 // c: ASCII code of char void DWINUI::Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c) { const char string[2] = { c, 0}; - DWIN_Draw_String(false, font, color, backcolor, x, y, string, 1); + DWIN_Draw_String(false, fontid, color, backcolor, x, y, string, 1); } // Draw a char at cursor position and increment cursor void DWINUI::Draw_Char(uint16_t color, const char c) { Draw_Char(color, cursor.x, cursor.y, c); - MoveBy(fontWidth(font), 0); + MoveBy(fontWidth(fontid), 0); } // Draw a string at cursor position @@ -178,49 +161,62 @@ void DWINUI::Draw_Char(uint16_t color, const char c) { // *string: The string // rlimit: For draw less chars than string length use rlimit void DWINUI::Draw_String(const char * const string, uint16_t rlimit) { - DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, rlimit); - MoveBy(strlen(string) * fontWidth(font), 0); + DWIN_Draw_String(false, fontid, textcolor, backcolor, cursor.x, cursor.y, string, rlimit); + MoveBy(strlen(string) * fontWidth(fontid), 0); } void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rlimit) { - DWIN_Draw_String(false, font, color, backcolor, cursor.x, cursor.y, string, rlimit); - MoveBy(strlen(string) * fontWidth(font), 0); + DWIN_Draw_String(false, fontid, color, backcolor, cursor.x, cursor.y, string, rlimit); + MoveBy(strlen(string) * fontWidth(fontid), 0); } // Draw a numeric integer value // bShow: true=display background color; false=don't display background color // signedMode: 1=signed; 0=unsigned -// size: Font size +// fid: Font ID // color: Character color // bColor: Background color // iNum: Number of digits // x/y: Upper-left coordinate // value: Integer value -void DWINUI::Draw_Int(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value) { +void DWINUI::Draw_Int(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value) { char nstr[10]; sprintf_P(nstr, PSTR("%*li"), (signedMode ? iNum + 1 : iNum), value); - DWIN_Draw_String(bShow, size, color, bColor, x, y, nstr); + DWIN_Draw_String(bShow, fid, color, bColor, x, y, nstr); } // Draw a numeric float value // bShow: true=display background color; false=don't display background color // signedMode: 1=signed; 0=unsigned -// size: Font size +// fid: Font ID // color: Character color // bColor: Background color // iNum: Number of digits // fNum: Number of decimal digits // x/y: Upper-left coordinate // value: float value -void DWINUI::Draw_Float(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { +void DWINUI::Draw_Float(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { char nstr[10]; - DWIN_Draw_String(bShow, size, color, bColor, x, y, dtostrf(value, iNum + (signedMode ? 2:1) + fNum, fNum, nstr)); + DWIN_Draw_String(bShow, fid, color, bColor, x, y, dtostrf(value, iNum + (signedMode ? 2:1) + fNum, fNum, nstr)); +} + +// ------------------------- Icons -------------------------------// + +// Draw an Icon and select library automatically +// BG: The icon background display: false=Background filtering is not displayed, true=Background display +// libID: Icon library ID +// picID: Icon ID +// x/y: Upper-left point +void DWINUI::ICON_Show(bool BG, uint8_t icon, uint16_t x, uint16_t y) { + const uint8_t libID = ICON TERN_(HAS_CUSTOMICONS, + (icon / 100)); + const uint8_t picID = icon TERN_(HAS_CUSTOMICONS, % 100); + DWIN_ICON_Show(BG, false, !BG, libID, picID, x, y); } // ------------------------- Buttons ------------------------------// void DWINUI::Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption) { DWIN_Draw_Rectangle(1, bcolor, x1, y1, x2, y2); - Draw_CenteredString(0, font, color, bcolor, x1, x2, (y2 + y1 - fontHeight())/2, caption); + Draw_CenteredString(0, fontid, color, bcolor, x1, x2, (y2 + y1 - fontHeight())/2, caption); } void DWINUI::Draw_Button(uint8_t id, uint16_t x, uint16_t y) { @@ -326,8 +322,8 @@ uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) { // x/y: Upper-left point // mode : 0 : unchecked, 1 : checked void DWINUI::Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked=false) { - DWIN_Draw_String(true, font8x16, color, bcolor, x + 4, y, checked ? F("x") : F(" ")); DWIN_Draw_Rectangle(0, color, x + 2, y + 2, x + 17, y + 17); + DWIN_Draw_Rectangle(1, checked ? color : bcolor, x + 6, y + 6, x + 13, y + 13); } // Clear Menu by filling the menu area with background color diff --git a/Marlin/src/lcd/e3v2/proui/dwinui.h b/Marlin/src/lcd/e3v2/proui/dwinui.h index f8ff0917694d..55345a789985 100644 --- a/Marlin/src/lcd/e3v2/proui/dwinui.h +++ b/Marlin/src/lcd/e3v2/proui/dwinui.h @@ -19,19 +19,22 @@ * along with this program. If not, see . * */ -#pragma once /** * DWIN Enhanced implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 3.17.1 - * Date: 2022/04/12 + * Version: 3.18.1 + * Date: 2022/07/05 */ -#include "dwin_lcd.h" +#pragma once + +#include "../../../inc/MarlinConfigPre.h" + #include "../common/dwin_set.h" #include "../common/dwin_font.h" #include "../common/dwin_color.h" +#include "dwin_lcd.h" // Extra Icons #define ICON_AdvSet ICON_Language @@ -39,6 +42,7 @@ #define ICON_BedSizeY ICON_PrintSize #define ICON_BedTramming ICON_SetHome #define ICON_Binary ICON_Contact +#define ICON_BltouchReset ICON_StockConfiguration #define ICON_Brightness ICON_Motion #define ICON_Cancel ICON_StockConfiguration #define ICON_CustomPreheat ICON_SetEndTemp @@ -73,6 +77,10 @@ #define ICON_MaxPosX ICON_MoveX #define ICON_MaxPosY ICON_MoveY #define ICON_MaxPosZ ICON_MoveZ +#define ICON_MeshEdit ICON_Homing +#define ICON_MeshEditX ICON_MoveX +#define ICON_MeshEditY ICON_MoveY +#define ICON_MeshEditZ ICON_MoveZ #define ICON_MeshNext ICON_Axis #define ICON_MeshPoints ICON_SetEndTemp #define ICON_MeshSave ICON_WriteEEPROM @@ -84,11 +92,22 @@ #define ICON_ParkPosY ICON_StepY #define ICON_ParkPosZ ICON_StepZ #define ICON_PhySet ICON_PrintSize -#define ICON_PIDbed ICON_SetBedTemp -#define ICON_PIDcycles ICON_ResumeEEPROM +#define ICON_PIDNozzle ICON_SetEndTemp +#define ICON_PIDBed ICON_SetBedTemp +#define ICON_PIDCycles ICON_ResumeEEPROM #define ICON_PIDValue ICON_Contact #define ICON_PrintStats ICON_PrintTime #define ICON_PrintStatsReset ICON_RemainTime +#define ICON_Preheat1 ICON_PLAPreheat +#define ICON_Preheat2 ICON_ABSPreheat +#define ICON_Preheat3 ICON_CustomPreheat +#define ICON_Preheat4 ICON_CustomPreheat +#define ICON_Preheat5 ICON_CustomPreheat +#define ICON_Preheat6 ICON_CustomPreheat +#define ICON_Preheat7 ICON_CustomPreheat +#define ICON_Preheat8 ICON_CustomPreheat +#define ICON_Preheat9 ICON_CustomPreheat +#define ICON_Preheat10 ICON_CustomPreheat #define ICON_ProbeDeploy ICON_SetEndTemp #define ICON_ProbeMargin ICON_PrintSize #define ICON_ProbeOffsetX ICON_StepX @@ -104,9 +123,26 @@ #define ICON_Scolor ICON_MaxSpeed #define ICON_SetBaudRate ICON_Setspeed #define ICON_SetCustomPreheat ICON_SetEndTemp +#define ICON_SetPreheat1 ICON_SetPLAPreheat +#define ICON_SetPreheat2 ICON_SetABSPreheat +#define ICON_SetPreheat3 ICON_SetCustomPreheat +#define ICON_SetPreheat4 ICON_SetCustomPreheat +#define ICON_SetPreheat5 ICON_SetCustomPreheat +#define ICON_SetPreheat6 ICON_SetCustomPreheat +#define ICON_SetPreheat7 ICON_SetCustomPreheat +#define ICON_SetPreheat8 ICON_SetCustomPreheat +#define ICON_SetPreheat9 ICON_SetCustomPreheat +#define ICON_SetPreheat10 ICON_SetCustomPreheat #define ICON_Sound ICON_Cool #define ICON_TBSetup ICON_Contact #define ICON_UBLActive ICON_HotendTemp +#define ICON_UBLActive ICON_HotendTemp +#define ICON_UBLSlot ICON_ResumeEEPROM +#define ICON_UBLMeshSave ICON_WriteEEPROM +#define ICON_UBLMeshLoad ICON_ReadEEPROM +#define ICON_UBLTiltGrid ICON_PrintSize +#define ICON_UBLSmartFill ICON_StockConfiguration +#define ICON_ZAfterHome ICON_SetEndTemp #define ICON_CaseLight ICON_Motion #define ICON_LedControl ICON_Motion @@ -145,7 +181,7 @@ #define DWIN_FONT_HEAD font10x20 #define DWIN_FONT_ALERT font10x20 #define STATUS_Y 354 -#define LCD_WIDTH (DWIN_WIDTH / 8) // only if the default font is font8x16 +#define LCD_WIDTH (DWIN_WIDTH / 8) // only if the default fontid is font8x16 // Minimum unit (0.1) : multiple (10) #define UNITFDIGITS 1 @@ -156,7 +192,7 @@ constexpr uint8_t TITLE_HEIGHT = 30, // Title bar heig TROWS = (STATUS_Y - TITLE_HEIGHT) / MLINE, // Total rows MROWS = TROWS - 1, // Other-than-Back ICOX = 26, // Menu item icon X position - LBLX = 60, // Menu item label X position + LBLX = 55, // Menu item label X position VALX = 210, // Menu item value X position MENU_CHR_W = 8, MENU_CHR_H = 16, // Menu font 8x16 STAT_CHR_W = 10; @@ -196,7 +232,7 @@ namespace DWINUI { extern uint16_t textcolor; extern uint16_t backcolor; extern uint16_t buttoncolor; - extern uint8_t font; + extern fontid_t fontid; extern FSTR_P const Author; extern void (*onTitleDraw)(TitleClass* title); @@ -205,15 +241,15 @@ namespace DWINUI { void init(); // Set text/number font - void setFont(uint8_t cfont); + void setFont(fontid_t cfont); // Get font character width - uint8_t fontWidth(uint8_t cfont); - inline uint8_t fontWidth() { return fontWidth(font); }; + uint8_t fontWidth(fontid_t cfont); + inline uint8_t fontWidth() { return fontWidth(fontid); }; // Get font character height - uint8_t fontHeight(uint8_t cfont); - inline uint8_t fontHeight() { return fontHeight(font); }; + uint8_t fontHeight(fontid_t cfont); + inline uint8_t fontHeight() { return fontHeight(fontid); }; // Get screen x coordinates from text column uint16_t ColToX(uint8_t col); @@ -261,125 +297,132 @@ namespace DWINUI { return t; } + // Draw an Icon and select library automatically + // BG: The icon background display: false=Background filtering is not displayed, true=Background display + // libID: Icon library ID + // picID: Icon ID + // x/y: Upper-left point + void ICON_Show(bool BG, uint8_t icon, uint16_t x, uint16_t y); + // Draw an Icon with transparent background from the library ICON // icon: Icon ID // x/y: Upper-left point inline void Draw_Icon(uint8_t icon, uint16_t x, uint16_t y) { - DWIN_ICON_Show(ICON, icon, x, y); + ICON_Show(false, icon, x, y); } // Draw an Icon from the library ICON with its background // icon: Icon ID // x/y: Upper-left point inline void Draw_IconWB(uint8_t icon, uint16_t x, uint16_t y) { - DWIN_ICON_Show(true, false, false, ICON, icon, x, y); + ICON_Show(true, icon, x, y); } // Draw a numeric integer value // bShow: true=display background color; false=don't display background color // signedMode: 1=signed; 0=unsigned - // size: Font size + // fid: Font ID // color: Character color // bColor: Background color // iNum: Number of digits // x/y: Upper-left coordinate // value: Integer value - void Draw_Int(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value); + void Draw_Int(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, int32_t value); // Draw a positive integer - inline void Draw_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(bShow, 0, size, color, bColor, iNum, x, y, value); + inline void Draw_Int(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(bShow, 0, fid, color, bColor, iNum, x, y, value); } inline void Draw_Int(uint8_t iNum, long value) { - Draw_Int(false, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); - MoveBy(iNum * fontWidth(font), 0); + Draw_Int(false, 0, fontid, textcolor, backcolor, iNum, cursor.x, cursor.y, value); + MoveBy(iNum * fontWidth(fontid), 0); } inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(false, 0, font, textcolor, backcolor, iNum, x, y, value); + Draw_Int(false, 0, fontid, textcolor, backcolor, iNum, x, y, value); } inline void Draw_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(false, 0, font, color, backcolor, iNum, x, y, value); + Draw_Int(false, 0, fontid, color, backcolor, iNum, x, y, value); } inline void Draw_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(true, 0, font, color, bColor, iNum, x, y, value); + Draw_Int(true, 0, fontid, color, bColor, iNum, x, y, value); } - inline void Draw_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(true, 0, size, color, bColor, iNum, x, y, value); + inline void Draw_Int(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(true, 0, fid, color, bColor, iNum, x, y, value); } // Draw a signed integer - inline void Draw_Signed_Int(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(bShow, 1, size, color, bColor, iNum, x, y, value); + inline void Draw_Signed_Int(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(bShow, 1, fid, color, bColor, iNum, x, y, value); } inline void Draw_Signed_Int(uint8_t iNum, long value) { - Draw_Int(false, 1, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); - MoveBy(iNum * fontWidth(font), 0); + Draw_Int(false, 1, fontid, textcolor, backcolor, iNum, cursor.x, cursor.y, value); + MoveBy(iNum * fontWidth(fontid), 0); } inline void Draw_Signed_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(false, 1, font, textcolor, backcolor, iNum, x, y, value); + Draw_Int(false, 1, fontid, textcolor, backcolor, iNum, x, y, value); } inline void Draw_Signed_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(false, 1, font, color, backcolor, iNum, x, y, value); + Draw_Int(false, 1, fontid, color, backcolor, iNum, x, y, value); } inline void Draw_Signed_Int(uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(true, 1, font, color, bColor, iNum, x, y, value); + Draw_Int(true, 1, fontid, color, bColor, iNum, x, y, value); } - inline void Draw_Signed_Int(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { - Draw_Int(true, 1, size, color, bColor, iNum, x, y, value); + inline void Draw_Signed_Int(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, long value) { + Draw_Int(true, 1, fid, color, bColor, iNum, x, y, value); } // Draw a numeric float value // bShow: true=display background color; false=don't display background color // signedMode: 1=signed; 0=unsigned - // size: Font size + // fid: Font ID // color: Character color // bColor: Background color // iNum: Number of digits // fNum: Number of decimal digits // x/y: Upper-left coordinate // value: float value - void Draw_Float(uint8_t bShow, bool signedMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value); + void Draw_Float(uint8_t bShow, bool signedMode, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value); // Draw a positive floating point number - inline void Draw_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(bShow, 0, size, color, bColor, iNum, fNum, x, y, value); + inline void Draw_Float(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(bShow, 0, fid, color, bColor, iNum, fNum, x, y, value); } inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) { - Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); - MoveBy((iNum + fNum + 1) * fontWidth(font), 0); + Draw_Float(false, 0, fontid, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); + MoveBy((iNum + fNum + 1) * fontWidth(fontid), 0); } inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, x, y, value); + Draw_Float(false, 0, fontid, textcolor, backcolor, iNum, fNum, x, y, value); } - inline void Draw_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(false, 0, size, textcolor, backcolor, iNum, fNum, x, y, value); + inline void Draw_Float(fontid_t fid, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(false, 0, fid, textcolor, backcolor, iNum, fNum, x, y, value); } inline void Draw_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(true, 0, font, color, bColor, iNum, fNum, x, y, value); + Draw_Float(true, 0, fontid, color, bColor, iNum, fNum, x, y, value); } - inline void Draw_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(true, 0, size, color, bColor, iNum, fNum, x, y, value); + inline void Draw_Float(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(true, 0, fid, color, bColor, iNum, fNum, x, y, value); } // Draw a signed floating point number - inline void Draw_Signed_Float(uint8_t bShow, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(bShow, 1, size, color, bColor, iNum, fNum, x, y, value); + inline void Draw_Signed_Float(uint8_t bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(bShow, 1, fid, color, bColor, iNum, fNum, x, y, value); } inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) { - Draw_Float(false, 1, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); - MoveBy((iNum + fNum + 1) * fontWidth(font), 0); + Draw_Float(false, 1, fontid, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); + MoveBy((iNum + fNum + 1) * fontWidth(fontid), 0); } inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(false, 1, font, textcolor, backcolor, iNum, fNum, x, y, value); + Draw_Float(false, 1, fontid, textcolor, backcolor, iNum, fNum, x, y, value); } - inline void Draw_Signed_Float(uint8_t size, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(false, 1, size, textcolor, backcolor, iNum, fNum, x, y, value); + inline void Draw_Signed_Float(fontid_t fid, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(false, 1, fid, textcolor, backcolor, iNum, fNum, x, y, value); } inline void Draw_Signed_Float(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(true, 1, font, color, bColor, iNum, fNum, x, y, value); + Draw_Float(true, 1, fontid, color, bColor, iNum, fNum, x, y, value); } - inline void Draw_Signed_Float(uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Float(true, 1, size, color, bColor, iNum, fNum, x, y, value); + inline void Draw_Signed_Float(fontid_t fid, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { + Draw_Float(true, 1, fid, color, bColor, iNum, fNum, x, y, value); } // Draw a char @@ -407,70 +450,70 @@ namespace DWINUI { } // Draw a string - // size: Font size + // fid: Font ID // color: Character color // bColor: Background color // x/y: Upper-left coordinate of the string // *string: The string inline void Draw_String(uint16_t x, uint16_t y, const char * const string) { - DWIN_Draw_String(false, font, textcolor, backcolor, x, y, string); + DWIN_Draw_String(false, fontid, textcolor, backcolor, x, y, string); } inline void Draw_String(uint16_t x, uint16_t y, FSTR_P title) { - DWIN_Draw_String(false, font, textcolor, backcolor, x, y, FTOP(title)); + DWIN_Draw_String(false, fontid, textcolor, backcolor, x, y, FTOP(title)); } inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, const char * const string) { - DWIN_Draw_String(false, font, color, backcolor, x, y, string); + DWIN_Draw_String(false, fontid, color, backcolor, x, y, string); } inline void Draw_String(uint16_t color, uint16_t x, uint16_t y, FSTR_P title) { - DWIN_Draw_String(false, font, color, backcolor, x, y, title); + DWIN_Draw_String(false, fontid, color, backcolor, x, y, title); } inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) { - DWIN_Draw_String(true, font, color, bgcolor, x, y, string); + DWIN_Draw_String(true, fontid, color, bgcolor, x, y, string); } inline void Draw_String(uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) { - DWIN_Draw_String(true, font, color, bgcolor, x, y, title); + DWIN_Draw_String(true, fontid, color, bgcolor, x, y, title); } - inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) { - DWIN_Draw_String(true, size, color, bgcolor, x, y, string); + inline void Draw_String(fontid_t fid, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, const char * const string) { + DWIN_Draw_String(true, fid, color, bgcolor, x, y, string); } - inline void Draw_String(uint8_t size, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) { - DWIN_Draw_String(true, size, color, bgcolor, x, y, title); + inline void Draw_String(fontid_t fid, uint16_t color, uint16_t bgcolor, uint16_t x, uint16_t y, FSTR_P title) { + DWIN_Draw_String(true, fid, color, bgcolor, x, y, title); } // Draw a centered string using DWIN_WIDTH // bShow: true=display background color; false=don't display background color - // size: Font size + // fid: Font ID // color: Character color // bColor: Background color // y: Upper coordinate of the string // *string: The string - void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string); - inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) { - Draw_CenteredString(bShow, size, color, bColor, 0, DWIN_WIDTH, y, string); + void Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t x1, uint16_t x2, uint16_t y, const char * const string); + inline void Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) { + Draw_CenteredString(bShow, fid, color, bColor, 0, DWIN_WIDTH, y, string); } - inline void Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) { - Draw_CenteredString(bShow, size, color, bColor, y, FTOP(string)); + inline void Draw_CenteredString(bool bShow, fontid_t fid, uint16_t color, uint16_t bColor, uint16_t y, FSTR_P string) { + Draw_CenteredString(bShow, fid, color, bColor, y, FTOP(string)); } inline void Draw_CenteredString(uint16_t color, uint16_t bcolor, uint16_t y, const char * const string) { - Draw_CenteredString(true, font, color, bcolor, y, string); + Draw_CenteredString(true, fontid, color, bcolor, y, string); } - inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, const char * const string) { - Draw_CenteredString(false, size, color, backcolor, y, string); + inline void Draw_CenteredString(fontid_t fid, uint16_t color, uint16_t y, const char * const string) { + Draw_CenteredString(false, fid, color, backcolor, y, string); } - inline void Draw_CenteredString(uint8_t size, uint16_t color, uint16_t y, FSTR_P title) { - Draw_CenteredString(false, size, color, backcolor, y, title); + inline void Draw_CenteredString(fontid_t fid, uint16_t color, uint16_t y, FSTR_P title) { + Draw_CenteredString(false, fid, color, backcolor, y, title); } inline void Draw_CenteredString(uint16_t color, uint16_t y, const char * const string) { - Draw_CenteredString(false, font, color, backcolor, y, string); + Draw_CenteredString(false, fontid, color, backcolor, y, string); } inline void Draw_CenteredString(uint16_t color, uint16_t y, FSTR_P title) { - Draw_CenteredString(false, font, color, backcolor, y, title); + Draw_CenteredString(false, fontid, color, backcolor, y, title); } inline void Draw_CenteredString(uint16_t y, const char * const string) { - Draw_CenteredString(false, font, textcolor, backcolor, y, string); + Draw_CenteredString(false, fontid, textcolor, backcolor, y, string); } inline void Draw_CenteredString(uint16_t y, FSTR_P title) { - Draw_CenteredString(false, font, textcolor, backcolor, y, title); + Draw_CenteredString(false, fontid, textcolor, backcolor, y, title); } // Draw a box diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp index 19d726037ce9..0945d6977814 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp @@ -23,17 +23,13 @@ /** * DWIN Endstops diagnostic page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.2.2 - * Date: 2022/02/24 + * Version: 1.3.3 + * Date: 2022/10/07 */ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_LCD_PROUI) - -#include "dwin_defines.h" - -#if HAS_ESDIAG +#if BOTH(DWIN_LCD_PROUI, HAS_ESDIAG) #include "endstop_diag.h" @@ -64,7 +60,7 @@ void draw_es_label(FSTR_P const flabel=nullptr) { void draw_es_state(const bool is_hit) { const uint8_t LM = 130; DWINUI::cursor.x = LM; - DWIN_Draw_Rectangle(1, HMI_data.PopupBg_color, LM, DWINUI::cursor.y, LM + 100, DWINUI::cursor.y + 20); + DWIN_Draw_Rectangle(1, HMI_data.PopupBg_Color, LM, DWINUI::cursor.y, LM + 100, DWINUI::cursor.y + 20); is_hit ? DWINUI::Draw_String(RGB(31,31,16), F(STR_ENDSTOP_HIT)) : DWINUI::Draw_String(RGB(16,63,16), F(STR_ENDSTOP_OPEN)); DWINUI::MoveBy(0, 25); } @@ -109,5 +105,4 @@ void ESDiagClass::Update() { DWIN_UpdateLCD(); } -#endif // HAS_ESDIAG -#endif // DWIN_LCD_PROUI +#endif // DWIN_LCD_PROUI && HAS_ESDIAG diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.h b/Marlin/src/lcd/e3v2/proui/endstop_diag.h index 316a1e1ed3d9..33f1d10d2da5 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.h +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.h @@ -24,8 +24,8 @@ /** * DWIN End Stops diagnostic page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.2.3 - * Date: 2022/02/24 + * Version: 1.3.2 + * Date: 2022/10/07 */ class ESDiagClass { diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp index adb23a96646b..6411b669bbc8 100644 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp @@ -23,8 +23,8 @@ /** * DWIN g-code thumbnail preview * Author: Miguel A. Risco-Castillo - * version: 2.1 - * Date: 2021/06/19 + * version: 3.1.2 + * Date: 2022/09/03 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -43,11 +43,8 @@ */ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_LCD_PROUI) -#include "dwin_defines.h" - -#if HAS_GCODE_PREVIEW +#if BOTH(DWIN_LCD_PROUI, HAS_GCODE_PREVIEW) #include "../../../core/types.h" #include "../../marlinui.h" @@ -246,6 +243,10 @@ void Preview_DrawFromSD() { } } +void Preview_Invalidate() { + fileprop.thumbstart = 0; +} + bool Preview_Valid() { return !!fileprop.thumbstart; } @@ -254,5 +255,4 @@ void Preview_Reset() { fileprop.thumbsize = 0; } -#endif // HAS_GCODE_PREVIEW -#endif // DWIN_LCD_PROUI +#endif // HAS_GCODE_PREVIEW && DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview.h b/Marlin/src/lcd/e3v2/proui/gcode_preview.h index 4417084a242d..c1949c5abc12 100644 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview.h +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.h @@ -1,8 +1,8 @@ /** * DWIN g-code thumbnail preview * Author: Miguel A. Risco-Castillo - * version: 2.1 - * Date: 2021/06/19 + * version: 3.1.2 + * Date: 2022/09/03 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -23,5 +23,6 @@ #pragma once void Preview_DrawFromSD(); +void Preview_Invalidate(); bool Preview_Valid(); void Preview_Reset(); diff --git a/Marlin/src/lcd/e3v2/proui/lockscreen.cpp b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp index 44b595096a88..85f35582b268 100644 --- a/Marlin/src/lcd/e3v2/proui/lockscreen.cpp +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp @@ -23,16 +23,15 @@ /** * Lock screen implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 2.2.0 - * Date: 2022/04/11 + * Version: 2.3.2 + * Date: 2022/11/20 */ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_LCD_PROUI) +#if BOTH(DWIN_LCD_PROUI, HAS_LOCKSCREEN) -#include "../../../core/types.h" -#include "dwin_lcd.h" +#include "dwin_defines.h" #include "dwinui.h" #include "dwin.h" #include "lockscreen.h" @@ -73,4 +72,4 @@ void LockScreenClass::onEncoder(EncoderState encoder_diffState) { DWIN_UpdateLCD(); } -#endif // DWIN_LCD_PROUI +#endif // DWIN_LCD_PROUI && HAS_LOCKSCREEN diff --git a/Marlin/src/lcd/e3v2/proui/lockscreen.h b/Marlin/src/lcd/e3v2/proui/lockscreen.h index 83d5530be3e4..cb75f2c7c0db 100644 --- a/Marlin/src/lcd/e3v2/proui/lockscreen.h +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.h @@ -24,8 +24,8 @@ /** * Lock screen implementation for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 2.2.0 - * Date: 2022/04/11 + * Version: 2.3.2 + * Date: 2022/11/20 */ #include "../common/encoder.h" diff --git a/Marlin/src/lcd/e3v2/proui/menus.cpp b/Marlin/src/lcd/e3v2/proui/menus.cpp index 6438545cb251..540f9e1f417b 100644 --- a/Marlin/src/lcd/e3v2/proui/menus.cpp +++ b/Marlin/src/lcd/e3v2/proui/menus.cpp @@ -23,8 +23,8 @@ /** * Menu functions for ProUI * Author: Miguel A. Risco-Castillo - * Version: 1.4.1 - * Date: 2022/04/14 + * Version: 1.9.1 + * Date: 2022/12/02 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -53,22 +53,23 @@ int8_t MenuItemTotal = 0; int8_t MenuItemCount = 0; -MenuItemClass** MenuItems = nullptr; +CustomMenuItemClass** MenuItems = nullptr; MenuClass *CurrentMenu = nullptr; MenuClass *PreviousMenu = nullptr; -void (*onMenuDraw)(MenuClass* menu) = nullptr; -void (*onCursorErase)(const int8_t line) = nullptr; -void (*onCursorDraw)(const int8_t line) = nullptr; MenuData_t MenuData; // Menuitem Drawing functions ================================================= void Draw_Title(TitleClass* title) { - DWIN_Draw_Rectangle(1, HMI_data.TitleBg_color, 0, 0, DWIN_WIDTH - 1, TITLE_HEIGHT - 1); + DWIN_Draw_Rectangle(1, HMI_data.TitleBg_Color, 0, 0, DWIN_WIDTH - 1, TITLE_HEIGHT - 1); if (title->frameid) DWIN_Frame_AreaCopy(title->frameid, title->frame.left, title->frame.top, title->frame.right, title->frame.bottom, 14, (TITLE_HEIGHT - (title->frame.bottom - title->frame.top)) / 2 - 1); else - DWIN_Draw_String(false, DWIN_FONT_HEAD, HMI_data.TitleTxt_color, HMI_data.TitleBg_color, 14, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, title->caption); + #if ENABLED(TITLE_CENTERED) + DWINUI::Draw_CenteredString(false, DWIN_FONT_HEAD, HMI_data.TitleTxt_Color, HMI_data.TitleBg_Color, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, title->caption); + #else + DWIN_Draw_String(false, DWIN_FONT_HEAD, HMI_data.TitleTxt_Color, HMI_data.TitleBg_Color, 14, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, title->caption); + #endif } void Draw_Menu(MenuClass* menu) { @@ -78,7 +79,7 @@ void Draw_Menu(MenuClass* menu) { void Draw_Menu_Cursor(const int8_t line) { const uint16_t ypos = MYPOS(line); - DWINUI::Draw_Box(1, HMI_data.Cursor_color, {0, ypos, 15, MLINE - 1}); + DWINUI::Draw_Box(1, HMI_data.Cursor_Color, {0, ypos, 15, MLINE - 1}); } void Erase_Menu_Cursor(const int8_t line) { @@ -86,17 +87,39 @@ void Erase_Menu_Cursor(const int8_t line) { DWINUI::Draw_Box(1, HMI_data.Background_Color, {0, ypos, 15, MLINE - 1}); } -void Draw_Menu_Line(const uint8_t line, const uint8_t icon /*=0*/, const char * const label /*=nullptr*/, bool more /*=false*/) { +void Erase_Menu_Text(const int8_t line) { + if (line < 0 || line >= TROWS) return; + const uint16_t ypos = MYPOS(line) + 1; + DWINUI::Draw_Box(1, HMI_data.Background_Color, {LBLX, ypos, DWIN_WIDTH - LBLX, MLINE - 2}); +} + +void Draw_Menu_Line(const uint8_t line, const uint8_t icon /*=0*/, const char * const label /*=nullptr*/, bool more /*=false*/, bool selected /*=false*/) { if (icon) DWINUI::Draw_Icon(icon, ICOX, MBASE(line) - 3); if (label) DWINUI::Draw_String(LBLX, MBASE(line) - 1, (char*)label); if (more) DWINUI::Draw_Icon(ICON_More, VALX + 16, MBASE(line) - 3); + if (selected) Draw_Menu_Cursor(line); DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); } +void Draw_Menu_Line(const uint8_t line, const uint8_t icon /*=0*/, FSTR_P label /*=nullptr*/, bool more /*=false*/, bool selected /*=false*/) { + Draw_Menu_Line(line, icon, FTOP(label), more, selected); +} + void Draw_Chkb_Line(const uint8_t line, const bool checked) { DWINUI::Draw_Checkbox(HMI_data.Text_Color, HMI_data.Background_Color, VALX + 3 * DWINUI::fontWidth(), MBASE(line) - 1, checked); } +void Show_Chkb_Line(const bool checked) { + const uint8_t line = CurrentMenu->line(); + DWINUI::Draw_Checkbox(HMI_data.Text_Color, HMI_data.Background_Color, VALX + 3 * DWINUI::fontWidth(), MBASE(line) - 1, checked); + DWIN_UpdateLCD(); +} + +void Toggle_Chkb_Line(bool &checked) { + checked = !checked; + Show_Chkb_Line(checked); +} + void Draw_Menu_IntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const int32_t value /*=0*/) { DWINUI::Draw_Signed_Int(HMI_data.Text_Color, bcolor, iNum , VALX, MBASE(line) - 1, value); } @@ -140,22 +163,11 @@ void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const flo DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(line), value); } -void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line) { +void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp) { const float value = *(float*)static_cast(menuitem)->value; - const int8_t dp = UNITFDIGITS; onDrawFloatMenu(menuitem, line, dp, value); } -void onDrawPFloat2Menu(MenuItemClass* menuitem, int8_t line) { - const float value = *(float*)static_cast(menuitem)->value; - onDrawFloatMenu(menuitem, line, 2, value); -} - -void onDrawPFloat3Menu(MenuItemClass* menuitem, int8_t line) { - const float value = *(float*)static_cast(menuitem)->value; - onDrawFloatMenu(menuitem, line, 3, value); -} - void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line, bool checked) { onDrawMenuItem(menuitem, line); Draw_Chkb_Line(line, checked); @@ -166,6 +178,19 @@ void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, val); } +void DrawItemEdit(const bool selected) { + const uint16_t bcolor = selected ? HMI_data.Selected_Color : HMI_data.Background_Color; + const uint8_t iNum = 4 - ((MenuData.dp > 0) ? (MenuData.dp - 1) : 0); + switch (checkkey) { + case SetIntNoDraw: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; + case SetInt: + case SetPInt: DWINUI::Draw_Signed_Int(HMI_data.Text_Color, bcolor, iNum , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); break; + case SetFloat: + case SetPFloat: DWINUI::Draw_Signed_Float(HMI_data.Text_Color, bcolor, iNum, MenuData.dp, VALX - 2 * DWINUI::fontWidth(), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, MenuData.dp)); break; + default: break; + } +} + //----------------------------------------------------------------------------- // On click functions //----------------------------------------------------------------------------- @@ -198,7 +223,7 @@ void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, // Apply: update function when the encoder is pressed void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { SetOnClick(process, lo, hi, 0, val, Apply, LiveUpdate); - Draw_Menu_IntValue(HMI_data.Selected_Color, CurrentMenu->line(), 4, MenuData.Value); + DrawItemEdit(true); } // Generic onclick event for float values @@ -211,7 +236,7 @@ void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { const int32_t value = round(val * POW(10, dp)); SetOnClick(process, lo * POW(10, dp), hi * POW(10, dp), dp, value, Apply, LiveUpdate); - DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), val); + DrawItemEdit(true); } // Generic onclick event for integer values @@ -260,8 +285,8 @@ void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)( // Generic menu control using the encoder void HMI_Menu() { EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; if (CurrentMenu) { + if (encoder_diffState == ENCODER_DIFF_NO) return; if (encoder_diffState == ENCODER_DIFF_ENTER) CurrentMenu->onClick(); else @@ -269,65 +294,46 @@ void HMI_Menu() { } } -// Get an integer value using the encoder without draw anything -// lo: low limit -// hi: high limit +// Get a value using the encoder +// draw : draw the value // Return value: // 0 : no change // 1 : live change // 2 : apply change -int8_t HMI_GetIntNoDraw(const int32_t lo, const int32_t hi) { +int8_t HMI_Get(bool draw) { + const int32_t lo = MenuData.MinValue; + const int32_t hi = MenuData.MaxValue; const int32_t cval = MenuData.Value; - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, MenuData.Value)) { - EncoderRate.enabled = false; - checkkey = Menu; - return 2; - } - LIMIT(MenuData.Value, lo, hi); - } - return int8_t(cval != MenuData.Value); -} - -// Get an integer value using the encoder -// lo: low limit -// hi: high limit -// Return value: -// 0 : no change -// 1 : live change -// 2 : apply change -int8_t HMI_GetInt(const int32_t lo, const int32_t hi) { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); + EncoderState encoder_diffState = get_encoder_state(); if (encoder_diffState != ENCODER_DIFF_NO) { if (Apply_Encoder(encoder_diffState, MenuData.Value)) { EncoderRate.enabled = false; - DWINUI::Draw_Signed_Int(HMI_data.Text_Color, HMI_data.Background_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); + if (draw) DrawItemEdit(false); checkkey = Menu; return 2; } LIMIT(MenuData.Value, lo, hi); - DWINUI::Draw_Signed_Int(HMI_data.Text_Color, HMI_data.Selected_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, MenuData.Value); - return 1; } - return 0; + const bool change = cval != MenuData.Value; + if (change) DrawItemEdit(true); + return int8_t(change); } -// Set an integer using the encoder -void HMI_SetInt() { - int8_t val = HMI_GetInt(MenuData.MinValue, MenuData.MaxValue); +// Set and draw a value using the encoder +void HMI_SetDraw() { + int8_t val = HMI_Get(true); switch (val) { - case 0: return; break; + case 0: return; case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; case 2: if (MenuData.Apply) MenuData.Apply(); break; } } -// Set an integer without drawing -void HMI_SetIntNoDraw() { - int8_t val = HMI_GetIntNoDraw(MenuData.MinValue, MenuData.MaxValue); +// Set an value without drawing +void HMI_SetNoDraw() { + int8_t val = HMI_Get(false); switch (val) { - case 0: return; break; + case 0: return; case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; case 2: if (MenuData.Apply) MenuData.Apply(); break; } @@ -335,7 +341,7 @@ void HMI_SetIntNoDraw() { // Set an integer pointer variable using the encoder void HMI_SetPInt() { - int8_t val = HMI_GetInt(MenuData.MinValue, MenuData.MaxValue); + int8_t val = HMI_Get(true); switch (val) { case 0: return; case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; @@ -343,43 +349,9 @@ void HMI_SetPInt() { } } -// Get a scaled float value using the encoder -// dp: decimal places -// lo: scaled low limit -// hi: scaled high limit -// Return value: -// 0 : no change -// 1 : live change -// 2 : apply change -int8_t HMI_GetFloat(uint8_t dp, int32_t lo, int32_t hi) { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, MenuData.Value)) { - EncoderRate.enabled = false; - DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, dp)); - checkkey = Menu; - return 2; - } - LIMIT(MenuData.Value, lo, hi); - DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), MenuData.Value / POW(10, dp)); - return 1; - } - return 0; -} - -// Set a scaled float using the encoder -void HMI_SetFloat() { - const int8_t val = HMI_GetFloat(MenuData.dp, MenuData.MinValue, MenuData.MaxValue); - switch (val) { - case 0: return; - case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; - case 2: if (MenuData.Apply) MenuData.Apply(); break; - } -} - // Set a scaled float pointer variable using the encoder void HMI_SetPFloat() { - const int8_t val = HMI_GetFloat(MenuData.dp, MenuData.MinValue, MenuData.MaxValue); + const int8_t val = HMI_Get(true); switch (val) { case 0: return; case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; @@ -387,7 +359,7 @@ void HMI_SetPFloat() { } } -// Menu Classes =============================================================== +// Menu Class =============================================================== MenuClass::MenuClass() { selected = 0; @@ -396,10 +368,10 @@ MenuClass::MenuClass() { void MenuClass::draw() { MenuTitle.draw(); - if (onMenuDraw != nullptr) onMenuDraw(this); + Draw_Menu(this); for (int8_t i = 0; i < MenuItemCount; i++) MenuItems[i]->draw(i - topline); - if (onCursorDraw != nullptr) onCursorDraw(line()); + Draw_Menu_Cursor(line()); DWIN_UpdateLCD(); } @@ -408,7 +380,7 @@ void MenuClass::onScroll(bool dir) { if (dir) sel++; else sel--; LIMIT(sel, 0, MenuItemCount - 1); if (sel != selected) { - if (onCursorErase != nullptr) onCursorErase(line()); + Erase_Menu_Cursor(line()); DWIN_UpdateLCD(); if ((sel - topline) == TROWS) { DWIN_Frame_AreaMove(1, DWIN_SCROLL_UP, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1); @@ -421,7 +393,7 @@ void MenuClass::onScroll(bool dir) { MenuItems[sel]->draw(0); } selected = sel; - if (onCursorDraw != nullptr) onCursorDraw(line()); + Draw_Menu_Cursor(line()); DWIN_UpdateLCD(); } } @@ -430,11 +402,11 @@ void MenuClass::onClick() { if (MenuItems[selected]->onClick != nullptr) (*MenuItems[selected]->onClick)(); } -MenuItemClass *MenuClass::SelectedItem() { +CustomMenuItemClass *MenuClass::SelectedItem() { return MenuItems[selected]; } -MenuItemClass** MenuClass::Items() { +CustomMenuItemClass** MenuClass::Items() { return MenuItems; } @@ -444,40 +416,47 @@ int8_t MenuClass::count() { /* MenuItem Class ===========================================================*/ -MenuItemClass::MenuItemClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)()) { - icon = cicon; +void CustomMenuItemClass::draw(int8_t line) { + if (line < 0 || line >= TROWS) return; + if (onDraw != nullptr) (*onDraw)(static_cast(this), line); +}; + +void CustomMenuItemClass::redraw(bool erase /*=false*/) { + const int8_t line = CurrentMenu->line(this->pos); + if (erase) Erase_Menu_Text(line); + draw(line); +} + +CustomMenuItemClass::CustomMenuItemClass(OnDrawItem ondraw, OnClickItem onclick) { onClick = onclick; - onDraw = ondraw; - const uint8_t len = _MIN(sizeof(caption) - 1, strlen(text)); - memcpy(&caption[0], text, len); - caption[len] = '\0'; + onDraw = ondraw; } -MenuItemClass::MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)()) { +MenuItemClass::MenuItemClass(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick) : CustomMenuItemClass(ondraw, onclick) { + icon = cicon; + SetCaption(text); +} + +MenuItemClass::MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw, OnClickItem onclick) : CustomMenuItemClass(ondraw, onclick) { icon = cicon; - onClick = onclick; - onDraw = ondraw; caption[0] = '\0'; frameid = id; frame = { x1, y1, x2, y2 }; } +void MenuItemClass::SetCaption(const char * const text) { + const uint8_t len = _MIN(sizeof(caption) - 1, strlen(text)); + memcpy(&caption[0], text, len); + caption[len] = '\0'; +} + void MenuItemClass::SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { caption[0] = '\0'; frameid = id; frame = { x1, y1, x2, y2 }; } -void MenuItemClass::draw(int8_t line) { - if (line < 0 || line >= TROWS) return; - if (onDraw != nullptr) (*onDraw)(this, line); -}; - -void MenuItemClass::redraw() { - draw(CurrentMenu->line(this->pos)); -} - -MenuItemPtrClass::MenuItemPtrClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) : MenuItemClass(cicon, text, ondraw, onclick) { +MenuItemPtrClass::MenuItemPtrClass(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val) : MenuItemClass(cicon, text, ondraw, onclick) { value = val; }; @@ -494,40 +473,58 @@ void MenuItemsClear() { void MenuItemsPrepare(int8_t totalitems) { MenuItemsClear(); - MenuItemTotal = totalitems; - MenuItems = new MenuItemClass*[totalitems]; + MenuItemTotal = _MIN(totalitems, MENU_MAX_ITEMS); + MenuItems = new CustomMenuItemClass*[totalitems]; } -MenuItemClass* MenuItemsAdd(MenuItemClass* menuitem) { +bool IsMenu(MenuClass* _menu) { + return ((checkkey == Menu) && !!CurrentMenu && (CurrentMenu == _menu)); +} + +template +T* MenuItemAdd(T* menuitem) { MenuItems[MenuItemCount] = menuitem; menuitem->pos = MenuItemCount++; return menuitem; } -MenuItemClass* MenuItemsAdd(uint8_t cicon, const char * const text/*=nullptr*/, void (*ondraw)(MenuItemClass* menuitem, int8_t line)/*=nullptr*/, void (*onclick)()/*=nullptr*/) { +CustomMenuItemClass* MenuItemAdd(OnDrawItem ondraw/*=nullptr*/, OnClickItem onclick/*=nullptr*/) { + if (MenuItemCount < MenuItemTotal) { + CustomMenuItemClass* menuitem = new CustomMenuItemClass(ondraw, onclick); + return MenuItemAdd(menuitem); + } + else return nullptr; +} + +MenuItemClass* MenuItemAdd(uint8_t cicon, const char * const text/*=nullptr*/, OnDrawItem ondraw/*=nullptr*/, OnClickItem onclick/*=nullptr*/) { if (MenuItemCount < MenuItemTotal) { MenuItemClass* menuitem = new MenuItemClass(cicon, text, ondraw, onclick); - return MenuItemsAdd(menuitem); + return MenuItemAdd(menuitem); } else return nullptr; } -MenuItemClass* MenuItemsAdd(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line)/*=nullptr*/, void (*onclick)()/*=nullptr*/) { +MenuItemClass* MenuItemAdd(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw/*=nullptr*/, OnClickItem onclick/*=nullptr*/) { if (MenuItemCount < MenuItemTotal) { MenuItemClass* menuitem = new MenuItemClass(cicon, id, x1, y1, x2, y2, ondraw, onclick); - return MenuItemsAdd(menuitem); + return MenuItemAdd(menuitem); } else return nullptr; } -MenuItemClass* MenuItemsAdd(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) { +MenuItemClass* EditItemAdd(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val) { if (MenuItemCount < MenuItemTotal) { MenuItemClass* menuitem = new MenuItemPtrClass(cicon, text, ondraw, onclick, val); - return MenuItemsAdd(menuitem); + return MenuItemAdd(menuitem); } else return nullptr; } +void InitMenu() { + PreviousMenu = nullptr; + InvalidateMenu(); +} + bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems) { if (!menu) menu = new MenuClass(); const bool NotCurrent = (CurrentMenu != menu); @@ -538,6 +535,27 @@ bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems) { return NotCurrent; } +bool SetMenu(MenuClass* &menu, frame_rect_t cn, FSTR_P title, int8_t totalitems) { + if (!menu) menu = new MenuClass(); + const bool NotCurrent = (CurrentMenu != menu); + if (NotCurrent) { + if (cn.w != 0) + menu->MenuTitle.SetFrame(cn.x, cn.y, cn.w, cn.h); + else + menu->MenuTitle.SetCaption(title); + MenuItemsPrepare(totalitems); + } + return NotCurrent; +} + +void InvalidateMenu() { + if (CurrentMenu) { + CurrentMenu->topline = 0; + CurrentMenu->selected = 0; + CurrentMenu = nullptr; + } +} + void UpdateMenu(MenuClass* &menu) { if (!menu) return; if (CurrentMenu != menu) { @@ -547,6 +565,9 @@ void UpdateMenu(MenuClass* &menu) { menu->draw(); } -void ReDrawMenu() { if (CurrentMenu && checkkey==Menu) CurrentMenu->draw(); } +void ReDrawMenu(bool force /*= false*/) { + if (CurrentMenu && (force || checkkey==Menu)) CurrentMenu->draw(); + if (force) DrawItemEdit(true); +} #endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/menus.h b/Marlin/src/lcd/e3v2/proui/menus.h index d4514d173237..33712f8959ef 100644 --- a/Marlin/src/lcd/e3v2/proui/menus.h +++ b/Marlin/src/lcd/e3v2/proui/menus.h @@ -23,8 +23,8 @@ /** * Menu functions for ProUI * Author: Miguel A. Risco-Castillo - * Version: 1.4.1 - * Date: 2022/04/14 + * Version: 1.9.1 + * Date: 2022/12/02 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -44,6 +44,9 @@ #include "dwinui.h" +#define MENU_CHAR_LIMIT 24 +#define MENU_MAX_ITEMS TERN(SDSORT_LIMIT, SDSORT_LIMIT, 64) + typedef struct { int32_t MaxValue = 0; // Auxiliar max integer/scaled float value int32_t MinValue = 0; // Auxiliar min integer/scaled float value @@ -56,46 +59,60 @@ typedef struct { } MenuData_t; extern MenuData_t MenuData; -extern void (*onCursorErase)(const int8_t line); -extern void (*onCursorDraw)(const int8_t line); // Auxiliary Macros =========================================================== // Create and add a MenuItem object to the menu array -#define BACK_ITEM(H) MenuItemsAdd(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, H) -#define MENU_ITEM(V...) MenuItemsAdd(V) -#define EDIT_ITEM(V...) MenuItemsAdd(V) -#define MENU_ITEM_F(I,L,V...) MenuItemsAdd(I, GET_TEXT_F(L), V) -#define EDIT_ITEM_F(I,L,V...) MenuItemsAdd(I, GET_TEXT_F(L), V) +#define SET_MENU(I,L,V) SetMenu(I, GET_TEXT_F(L), V) +#define SET_MENU_F(I,L,V) SetMenu(I, F(L), V) +#define SET_MENU_R(I,R,L,V) SetMenu(I, R, GET_TEXT_F(L), V) + +#define BACK_ITEM(H) MenuItemAdd(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, H) +#define MENU_ITEM(I,L,V...) MenuItemAdd(I, GET_TEXT_F(L), V) +#define EDIT_ITEM(I,L,V...) EditItemAdd(I, GET_TEXT_F(L), V) +#define MENU_ITEM_F(I,L,V...) MenuItemAdd(I, F(L), V) +#define EDIT_ITEM_F(I,L,V...) EditItemAdd(I, F(L), V) // Menu Classes =============================================================== -class MenuItemClass { -protected: +class CustomMenuItemClass; +class MenuItemClass; + +typedef void (*OnDrawCustomItem)(CustomMenuItemClass* menuitem, int8_t line); +typedef void (*OnDrawItem)(MenuItemClass* menuitem, int8_t line); +typedef void (*OnClickItem)(); + +class CustomMenuItemClass { public: int8_t pos = 0; + OnDrawItem onDraw = nullptr; + void (*onClick)() = nullptr; + CustomMenuItemClass() {}; + CustomMenuItemClass(OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); + virtual ~CustomMenuItemClass(){}; + virtual void draw(int8_t line); + void redraw(bool erase=false); +}; + +class MenuItemClass: public CustomMenuItemClass { +public: uint8_t icon = 0; - char caption[32] = ""; + char caption[MENU_CHAR_LIMIT] = ""; uint8_t frameid = 0; rect_t frame = {0}; - void (*onDraw)(MenuItemClass* menuitem, int8_t line) = nullptr; - void (*onClick)() = nullptr; - MenuItemClass() {}; - MenuItemClass(uint8_t cicon, const char * const text=nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr); - // MenuItemClass(uint8_t cicon, FSTR_P text = nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr) : MenuItemClass(cicon, FTOP(text), ondraw, onclick){} - MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr); + using CustomMenuItemClass::CustomMenuItemClass; + MenuItemClass(uint8_t cicon, const char * const text=nullptr, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); + MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); void SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); - virtual ~MenuItemClass(){}; - virtual void draw(int8_t line); - void redraw(); + void SetCaption(const char * const text = nullptr); }; class MenuItemPtrClass: public MenuItemClass { public: void *value = nullptr; using MenuItemClass::MenuItemClass; - MenuItemPtrClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val); - MenuItemPtrClass(uint8_t cicon, FSTR_P text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) : MenuItemPtrClass(cicon, FTOP(text), ondraw, onclick, val){} + MenuItemPtrClass(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val); + MenuItemPtrClass(uint8_t cicon, FSTR_P text, OnDrawItem ondraw, OnClickItem onclick, void* val) : MenuItemPtrClass(cicon, FTOP(text), ondraw, onclick, val){} }; class MenuClass { @@ -111,12 +128,11 @@ class MenuClass { virtual void draw(); virtual void onScroll(bool dir); void onClick(); - MenuItemClass* SelectedItem(); - static MenuItemClass** Items(); + CustomMenuItemClass* SelectedItem(); + static CustomMenuItemClass** Items(); }; extern MenuClass *CurrentMenu; extern MenuClass *PreviousMenu; -extern void (*onMenuDraw)(MenuClass* menu); // Menuitem Drawing functions ================================================= @@ -124,8 +140,12 @@ void Draw_Title(TitleClass* title); void Draw_Menu(MenuClass* menu); void Draw_Menu_Cursor(const int8_t line); void Erase_Menu_Cursor(const int8_t line); -void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr, bool more=false); +void Erase_Menu_Text(const int8_t line); +void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr, bool more=false, bool selected=false); +void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, FSTR_P label=nullptr, bool more=false, bool selected=false); void Draw_Chkb_Line(const uint8_t line, const bool checked); +void Show_Chkb_Line(const bool checked); +void Toggle_Chkb_Line(bool &checked); void Draw_Menu_IntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const int32_t value=0); void onDrawMenuItem(MenuItemClass* menuitem, int8_t line); void onDrawSubMenu(MenuItemClass* menuitem, int8_t line); @@ -134,9 +154,11 @@ void onDrawPIntMenu(MenuItemClass* menuitem, int8_t line); void onDrawPInt8Menu(MenuItemClass* menuitem, int8_t line); void onDrawPInt32Menu(MenuItemClass* menuitem, int8_t line); void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value); -void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line); -void onDrawPFloat2Menu(MenuItemClass* menuitem, int8_t line); -void onDrawPFloat3Menu(MenuItemClass* menuitem, int8_t line); +void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp); +inline void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, UNITFDIGITS); }; +inline void onDrawPFloat2Menu(MenuItemClass* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, 2); }; +inline void onDrawPFloat3Menu(MenuItemClass* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, 3); }; +inline void onDrawPFloat4Menu(MenuItemClass* menuitem, int8_t line) { onDrawPFloatMenu(menuitem, line, 4); }; void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line, bool checked); void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line); @@ -153,22 +175,28 @@ void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)( // HMI user control functions ================================================= void HMI_Menu(); -void HMI_SetInt(); +void HMI_SetDraw(); +void HMI_SetNoDraw(); void HMI_SetPInt(); -void HMI_SetIntNoDraw(); -void HMI_SetFloat(); void HMI_SetPFloat(); // Menu auxiliary functions =================================================== +// Initialize menu +void InitMenu(); + // Create a new menu bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems); +bool SetMenu(MenuClass* &menu, frame_rect_t cn, FSTR_P title, int8_t totalitems); + +// Invalidate CurrentMenu to prepare for full menu drawing +void InvalidateMenu(); //Update the Menu and Draw if it is valid void UpdateMenu(MenuClass* &menu); //Redraw the current Menu if it is valid -void ReDrawMenu(); +void ReDrawMenu(bool force = false); // Clear MenuItems array and free MenuItems elements void MenuItemsClear(); @@ -176,13 +204,17 @@ void MenuItemsClear(); // Prepare MenuItems array void MenuItemsPrepare(int8_t totalitems); +// Is the current menu = menu? +bool IsMenu(MenuClass* menu); + // Add elements to the MenuItems array -MenuItemClass* MenuItemsAdd(uint8_t cicon, const char * const text=nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr); -inline MenuItemClass* MenuItemsAdd(uint8_t cicon, FSTR_P text = nullptr, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr) { - return MenuItemsAdd(cicon, FTOP(text), ondraw, onclick); +CustomMenuItemClass* MenuItemAdd(OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); +MenuItemClass* MenuItemAdd(uint8_t cicon, const char * const text=nullptr, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); +inline MenuItemClass* MenuItemAdd(uint8_t cicon, FSTR_P text = nullptr, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr) { + return MenuItemAdd(cicon, FTOP(text), ondraw, onclick); } -MenuItemClass* MenuItemsAdd(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr); -MenuItemClass* MenuItemsAdd(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val); -inline MenuItemClass* MenuItemsAdd(uint8_t cicon, FSTR_P text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) { - return MenuItemsAdd(cicon, FTOP(text), ondraw, onclick, val); +MenuItemClass* MenuItemAdd(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, OnDrawItem ondraw=nullptr, OnClickItem onclick=nullptr); +MenuItemClass* EditItemAdd(uint8_t cicon, const char * const text, OnDrawItem ondraw, OnClickItem onclick, void* val); +inline MenuItemClass* EditItemAdd(uint8_t cicon, FSTR_P text, OnDrawItem ondraw, OnClickItem onclick, void* val) { + return EditItemAdd(cicon, FTOP(text), ondraw, onclick, val); } diff --git a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp index c2d01a07eb76..18cdffd00d62 100644 --- a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp @@ -31,8 +31,6 @@ #if BOTH(DWIN_LCD_PROUI, HAS_MESH) -#include "meshviewer.h" - #include "../../../core/types.h" #include "../../marlinui.h" #include "dwin_lcd.h" @@ -40,9 +38,10 @@ #include "dwin.h" #include "dwin_popup.h" #include "../../../feature/bedlevel/bedlevel.h" +#include "meshviewer.h" #if ENABLED(AUTO_BED_LEVELING_UBL) - #include "ubl_tools.h" + #include "bedlevel_tools.h" #endif MeshViewerClass MeshViewer; @@ -112,10 +111,10 @@ void MeshViewerClass::DrawMesh(bed_mesh_t zval, const uint8_t sizex, const uint8 void MeshViewerClass::Draw(bool withsave /*= false*/) { Title.ShowCaption(GET_TEXT_F(MSG_MESH_VIEWER)); - #if ENABLED(USE_UBL_VIEWER) + #if USE_UBL_VIEWER DWINUI::ClearMainArea(); - ubl_tools.viewer_print_value = true; - ubl_tools.Draw_Bed_Mesh(-1, 1, 8, 10 + TITLE_HEIGHT); + bedLevelTools.viewer_print_value = true; + bedLevelTools.Draw_Bed_Mesh(-1, 1, 8, 10 + TITLE_HEIGHT); #else DrawMesh(bedlevel.z_values, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y); #endif @@ -127,8 +126,8 @@ void MeshViewerClass::Draw(bool withsave /*= false*/) { else DWINUI::Draw_Button(BTN_Continue, 86, 305); - #if ENABLED(USE_UBL_VIEWER) - ubl_tools.Set_Mesh_Viewer_Status(); + #if USE_UBL_VIEWER + bedLevelTools.Set_Mesh_Viewer_Status(); #else char str_1[6], str_2[6] = ""; ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"), diff --git a/Marlin/src/lcd/e3v2/proui/meshviewer.h b/Marlin/src/lcd/e3v2/proui/meshviewer.h index 1e78ff2657b8..3aafe16984aa 100644 --- a/Marlin/src/lcd/e3v2/proui/meshviewer.h +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.h @@ -21,9 +21,6 @@ */ #pragma once -#include "../../../core/types.h" -#include "../../../feature/bedlevel/bedlevel.h" - /** * Mesh Viewer for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) diff --git a/Marlin/src/lcd/e3v2/proui/plot.cpp b/Marlin/src/lcd/e3v2/proui/plot.cpp index ebc685fa2453..75917320a45f 100644 --- a/Marlin/src/lcd/e3v2/proui/plot.cpp +++ b/Marlin/src/lcd/e3v2/proui/plot.cpp @@ -23,8 +23,8 @@ /** * DWIN Single var plot * Author: Miguel A. Risco-Castillo - * Version: 2.0 - * Date: 2022/01/31 + * Version: 2.1.2 + * Date: 2022/11/20 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -44,15 +44,13 @@ #include "../../../inc/MarlinConfigPre.h" -#ifdef DWIN_LCD_PROUI +#if BOTH(DWIN_LCD_PROUI, HAS_PIDPLOT) #include "plot.h" - #include "../../../core/types.h" #include "../../marlinui.h" #include "dwin_lcd.h" #include "dwinui.h" -#include "dwin_popup.h" #include "dwin.h" #define Plot_Bg_Color RGB( 1, 12, 8) @@ -71,7 +69,7 @@ void PlotClass::Draw(const frame_rect_t frame, const float max, const float ref) y2 = frame.y + frame.h - 1; r = round((y2) - ref * scale); DWINUI::Draw_Box(1, Plot_Bg_Color, frame); - for (uint8_t i = 1; i < 4; i++) if (i*50 < frame.w) DWIN_Draw_VLine(Line_Color, i*50 + frame.x, frame.y, frame.h); + for (uint8_t i = 1; i < 4; i++) if (i * 50 < frame.w) DWIN_Draw_VLine(Line_Color, i * 50 + frame.x, frame.y, frame.h); DWINUI::Draw_Box(0, Color_White, DWINUI::ExtendFrame(frame, 1)); DWIN_Draw_HLine(Color_Red, frame.x, r, frame.w); } @@ -91,4 +89,4 @@ void PlotClass::Update(const float value) { grphpoints++; } -#endif // DWIN_LCD_PROUI +#endif // DWIN_LCD_PROUI && HAS_PIDPLOT diff --git a/Marlin/src/lcd/e3v2/proui/plot.h b/Marlin/src/lcd/e3v2/proui/plot.h index 8522c530bd3f..ea15255fe53a 100644 --- a/Marlin/src/lcd/e3v2/proui/plot.h +++ b/Marlin/src/lcd/e3v2/proui/plot.h @@ -23,8 +23,8 @@ /** * DWIN Single var plot * Author: Miguel A. Risco-Castillo - * Version: 1.0 - * Date: 2022/01/30 + * Version: 2.1.2 + * Date: 2022/11/20 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as diff --git a/Marlin/src/lcd/e3v2/proui/printstats.cpp b/Marlin/src/lcd/e3v2/proui/printstats.cpp index 5a7b6c9c4170..638cd3420809 100644 --- a/Marlin/src/lcd/e3v2/proui/printstats.cpp +++ b/Marlin/src/lcd/e3v2/proui/printstats.cpp @@ -23,8 +23,8 @@ /** * Print Stats page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.3.0 - * Date: 2022/02/24 + * Version: 1.4.2 + * Date: 2022/12/03 */ #include "../../../inc/MarlinConfigPre.h" @@ -79,4 +79,12 @@ void Goto_PrintStats() { HMI_SaveProcessID(WaitResponse); } +// Print Stats Reset popup +void Popup_ResetStats() { DWIN_Popup_ConfirmCancel(ICON_Info_0, GET_TEXT_F(MSG_RESET_STATS)); } +void OnClick_ResetStats() { + if (HMI_flag.select_flag) PrintStatsClass::Reset(); + HMI_ReturnScreen(); +} +void PrintStatsReset() { Goto_Popup(Popup_ResetStats, OnClick_ResetStats); } + #endif // DWIN_LCD_PROUI && PRINTCOUNTER diff --git a/Marlin/src/lcd/e3v2/proui/printstats.h b/Marlin/src/lcd/e3v2/proui/printstats.h index 705c923da41b..4a383068864b 100644 --- a/Marlin/src/lcd/e3v2/proui/printstats.h +++ b/Marlin/src/lcd/e3v2/proui/printstats.h @@ -24,8 +24,8 @@ /** * Print Stats page for PRO UI * Author: Miguel A. Risco-Castillo (MRISCOC) - * Version: 1.3.0 - * Date: 2022/02/24 + * Version: 1.4.2 + * Date: 2022/12/03 */ class PrintStatsClass { @@ -37,3 +37,4 @@ class PrintStatsClass { extern PrintStatsClass PrintStats; void Goto_PrintStats(); +void PrintStatsReset(); 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("/.."); 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 88326466c092..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; @@ -606,9 +601,11 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr break; #endif - case VP_BED_CONTROL: - preheat_temp = PREHEAT_1_TEMP_BED; - break; + #if HAS_HEATED_BED + case VP_BED_CONTROL: + preheat_temp = PREHEAT_1_TEMP_BED; + break; + #endif } *(int16_t*)var.memadr = *(int16_t*)var.memadr > 0 ? 0 : preheat_temp; @@ -619,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) { @@ -642,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/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/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp index 18ac433b719a..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) { @@ -258,7 +255,7 @@ void DGUSScreenHandlerMKS::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { ) filelist.refresh(); } - void DGUSScreenHandler::SDPrintingFinished() { + void DGUSScreenHandlerMKS::SDPrintingFinished() { if (DGUSAutoTurnOff) { queue.exhaust(); gcode.process_subcommands_now(F("M81")); @@ -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,35 +393,35 @@ 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); mks_language_index = MKS_SimpleChinese; - dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_Choose); - dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_NoChoose); + dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE1, (uint8_t)MKS_Language_Choose); + dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE2, (uint8_t)MKS_Language_NoChoose); settings.save(); break; case MKS_English: DGUS_LanguageDisplay(MKS_English); mks_language_index = MKS_English; - dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_NoChoose); - dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_Choose); + dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE1, (uint8_t)MKS_Language_NoChoose); + dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE2, (uint8_t)MKS_Language_Choose); settings.save(); break; default: break; @@ -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,10 +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"); - char babystep_buf[30]; - 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) @@ -1142,7 +1138,7 @@ void DGUSScreenHandlerMKS::HandleAccChange(DGUS_VP_Variable &var, void *val_ptr) else queue.inject(F("M290 Z-0.01")); - z_offset_add = z_offset_add - ZOffset_distance; + z_offset_add -= ZOffset_distance; break; case 1: @@ -1157,37 +1153,29 @@ void DGUSScreenHandlerMKS::HandleAccChange(DGUS_VP_Variable &var, void *val_ptr) else queue.inject(F("M290 Z-0.01")); - z_offset_add = z_offset_add + ZOffset_distance; + 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 } @@ -1206,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: @@ -1292,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; @@ -1446,12 +1434,12 @@ bool DGUSScreenHandlerMKS::loop() { void DGUSScreenHandlerMKS::LanguagePInit() { switch (mks_language_index) { case MKS_SimpleChinese: - dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_Choose); - dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_NoChoose); + dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE1, (uint8_t)MKS_Language_Choose); + dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE2, (uint8_t)MKS_Language_NoChoose); break; case MKS_English: - dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_NoChoose); - dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_Choose); + dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE1, (uint8_t)MKS_Language_NoChoose); + dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE2, (uint8_t)MKS_Language_Choose); break; default: break; diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h b/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h index fa5bf3039696..c4e3645f28c9 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.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/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) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h index eb76bb9b2b2c..9a20c2a038d7 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/media_file_reader.h @@ -32,7 +32,7 @@ class MediaFileReader { private: #if ENABLED(SDSUPPORT) - SdFile root, file; + MediaFile root, file; #endif public: diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.cpp index e3b95c4cd490..656c1f04d2ea 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.cpp @@ -52,7 +52,6 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) { .enabled(ENABLED(HAS_MULTI_HOTEND)) .tag(6) .button(BTN_POS(1,5), BTN_SIZE(1,1), GET_TEXT_F(MSG_OFFSETS_MENU)) - .tag(7) .button(BTN_POS(2,1), BTN_SIZE(1,1), GET_TEXT_F(MSG_STEPS_PER_MM)) .tag(8) .button(BTN_POS(2,2), BTN_SIZE(1,1), GET_TEXT_F(MSG_MAX_SPEED)) .tag(9) .button(BTN_POS(2,3), BTN_SIZE(1,1), GET_TEXT_F(MSG_ACCELERATION)) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/advanced_settings_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/advanced_settings_menu.cpp index 00cdf76331d6..f607dc102dc1 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/advanced_settings_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/advanced_settings_menu.cpp @@ -58,8 +58,8 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) { .enabled(ENABLED(HAS_TRINAMIC_CONFIG)) .tag(3) .button(TMC_CURRENT_POS, GET_TEXT_F(MSG_TMC_CURRENT)) .enabled(ENABLED(LIN_ADVANCE)) - .tag(4) .button(LIN_ADVANCE_POS, GET_TEXT_F(MSG_LINEAR_ADVANCE)) - .tag(5) .button(VELOCITY_POS, GET_TEXT_F(MSG_MAX_SPEED)) + .tag(4) .button(LIN_ADVANCE_POS, GET_TEXT_F(MSG_LINEAR_ADVANCE)) + .tag(5) .button(VELOCITY_POS, GET_TEXT_F(MSG_MAX_SPEED_NO_UNITS)) .tag(6) .button(ACCELERATION_POS, GET_TEXT_F(MSG_ACCELERATION)) .tag(7) .button(JERK_POS, GET_TEXT_F(TERN(HAS_JUNCTION_DEVIATION, MSG_JUNCTION_DEVIATION, MSG_JERK))) .tag(8) .button(ENDSTOPS_POS, GET_TEXT_F(MSG_LCD_ENDSTOPS)) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/cocoa_press_ui.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/cocoa_press_ui.h index 6a022289252d..5704371131c6 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/cocoa_press_ui.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/cocoa_press_ui.h @@ -1,4 +1,3 @@ - /**************************************************************************** * 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 * @@ -28,33 +27,26 @@ constexpr float x_max = 480.000000; constexpr float y_min = 0.000000; constexpr float y_max = 272.000000; -const PROGMEM uint16_t syringe_outline[] = {0xED96, 0x14F0, 0xE65D, 0x10E9, 0xDED2, 0x0F9C, 0xD74B, 0x110E, 0xD01B, 0x1543, 0xCE80, 0x1836, 0xCE0A, 0x1C3A, 0xCE0F, 0x27AD, 0xCF0A, 0x2BD3, 0xD127, 0x2E5B, 0xD2A1, 0x2FF0, 0xD2A2, 0x9FC9, 0xD407, 0xA97A, 0xD7B9, 0xB10C, 0xD7BF, 0xBB58, 0xD978, 0xC2BE, 0xDD55, 0xC6EB, 0xDD58, 0xD159, 0xDE3B, 0xD3A8, 0xDFCF, 0xD3AF, 0xE0B8, 0xD04C, 0xE0B8, 0xC6EB, 0xE4A7, 0xC299, 0xE652, 0xBAF6, 0xE652, 0xB10C, 0xEA2E, 0xA8EA, 0xEB6C, 0x9E86, 0xEB6C, 0x2F58, 0xEF3C, 0x2B4E, 0xF003, 0x2583, 0xEFFD, 0x1AC2, 0xED96, 0x14F0, 0xED96, 0x14F0}; -const PROGMEM uint16_t syringe_fluid[] = {0xDE73, 0x2512, 0xDA0C, 0x261D, 0xD5B8, 0x29A0, 0xD4AE, 0x2D87, 0xD4AE, 0x9F60, 0xD585, 0xA63B, 0xDE44, 0xA9DE, 0xE32A, 0xA942, 0xE7E3, 0xA6A5, 0xE930, 0xA342, 0xE95D, 0x9C1D, 0xE95B, 0x31B8, 0xE955, 0x2B63, 0xE867, 0x2A67, 0xE790, 0x28DE, 0xE342, 0x25CB, 0xDE73, 0x2512}; -const PROGMEM uint16_t syringe[] = {0xED91, 0x1502, 0xE658, 0x10FB, 0xDECE, 0x0FAE, 0xD746, 0x1120, 0xD016, 0x1555, 0xCE7B, 0x1848, 0xCE05, 0x1C4D, 0xCE0A, 0x27BF, 0xCF05, 0x2BE5, 0xD122, 0x2E6E, 0xD29C, 0x3002, 0xD29D, 0x9FDB, 0xD402, 0xA98C, 0xD7B4, 0xB11F, 0xD7BA, 0xBB6A, 0xD973, 0xC2D1, 0xDD50, 0xC6FD, 0xDD53, 0xD16C, 0xDE36, 0xD3BA, 0xDFCA, 0xD3C2, 0xE0B3, 0xD05E, 0xE0B3, 0xC6FD, 0xE4A2, 0xC2AB, 0xE64D, 0xBB09, 0xE64D, 0xB11F, 0xEA29, 0xA8FC, 0xEB67, 0x9E98, 0xEB67, 0x2F6B, 0xEF37, 0x2B60, 0xEFFE, 0x2595, 0xEFF8, 0x1AD5, 0xED91, 0x1502, 0xED91, 0x1502, 0xFFFF, 0xD1CF, 0x1A7E, 0xD84F, 0x16DB, 0xDF19, 0x15A9, 0xE5E0, 0x16EA, 0xEC5B, 0x1AA4, 0xEC9D, 0x1D34, 0xEC9D, 0x20CC, 0xE5F1, 0x1D41, 0xDF02, 0x1C12, 0xD812, 0x1D41, 0xD166, 0x20CC, 0xD16C, 0x1B45, 0xD1CF, 0x1A7E, 0xFFFF, 0xE3BD, 0xACFD, 0xDE8E, 0xAF4F, 0xD988, 0xAC0F, 0xD7CC, 0xA8CD, 0xDD1C, 0xAAA9, 0xE287, 0xAA5B, 0xE655, 0xA8BE, 0xE3BD, 0xACFD, 0xFFFF, 0xE802, 0x2DC5, 0xE809, 0x343C, 0xE808, 0x9FC8, 0xE7E3, 0xA296, 0xE70D, 0xA4B1, 0xE2C9, 0xA70E, 0xDE4E, 0xA790, 0xD6A1, 0xA457, 0xD5FF, 0x9F2B, 0xD5FF, 0x2DFD, 0xD6B2, 0x2B72, 0xDA78, 0x2861, 0xDE9D, 0x276F, 0xE300, 0x2824, 0xE70D, 0x2B13, 0xE7FF, 0x2DB6, 0xE800, 0x2DC5, 0xE802, 0x2DC5, 0xFFFF, 0xE2ED, 0xBA8B, 0xE1CC, 0xBF52, 0xDF1C, 0xC165, 0xDC64, 0xBF99, 0xDB1B, 0xBAFF, 0xDB19, 0xB433, 0xDF04, 0xB552, 0xE2EF, 0xB438, 0xE2ED, 0xBA8B, 0xFFFF, 0xEC09, 0x2893, 0xE925, 0x2A08, 0xE57D, 0x261D, 0xE149, 0x246F, 0xDBDE, 0x24A0, 0xD6BC, 0x2795, 0xD484, 0x2A46, 0xD1C0, 0x2853, 0xD166, 0x251E, 0xD80D, 0x2151, 0xDF02, 0x200C, 0xE5F6, 0x2151, 0xEC9D, 0x251E, 0xEC09, 0x2893}; -const PROGMEM uint16_t park_btn[] = {0x0AAA, 0x0E1E, 0x57FF, 0x0E1E, 0x57FF, 0x33C3, 0x0AAA, 0x33C3, 0x0AAA, 0x0E1E}; -const PROGMEM uint16_t pause_btn[] = {0x47FF, 0xCA58, 0x7FFF, 0xCA58, 0x7FFF, 0xEFFE, 0x47FF, 0xEFFE, 0x47FF, 0xCA58}; -const PROGMEM uint16_t load_chocolate_btn[] = {0x0AAA, 0x3D2C, 0x57FF, 0x3D2C, 0x57FF, 0x62D2, 0x0AAA, 0x62D2, 0x0AAA, 0x3D2C}; -const PROGMEM uint16_t preheat_chocolate_btn[] = {0x0AAA, 0x6C3B, 0x57FF, 0x6C3B, 0x57FF, 0x91E0, 0x0AAA, 0x91E0, 0x0AAA, 0x6C3B}; -const PROGMEM uint16_t menu_btn[] = {0x0AAA, 0x9B4A, 0x57FF, 0x9B4A, 0x57FF, 0xC0EF, 0x0AAA, 0xC0EF, 0x0AAA, 0x9B4A}; -const PROGMEM uint16_t print_btn[] = {0x0AAA, 0xCA58, 0x42AA, 0xCA58, 0x42AA, 0xEFFE, 0x0AAA, 0xEFFE, 0x0AAA, 0xCA58}; -const PROGMEM uint16_t stop_btn[] = {0x8554, 0xCA58, 0xBD53, 0xCA58, 0xBD53, 0xEFFE, 0x8554, 0xEFFE, 0x8554, 0xCA58}; -const PROGMEM uint16_t print_time_hms[] = {0x62A9, 0xA968, 0x8FFE, 0xA968, 0x8FFE, 0xC0EF, 0x62A9, 0xC0EF, 0x62A9, 0xA968}; -const PROGMEM uint16_t print_time_percent[] = {0x8FFE, 0xA968, 0xBD53, 0xA968, 0xBD53, 0xC0EF, 0x8FFE, 0xC0EF, 0x8FFE, 0xA968}; -const PROGMEM uint16_t print_time_label[] = {0x62A9, 0x91E0, 0xBD53, 0x91E0, 0xBD53, 0xA986, 0x62A9, 0xA986, 0x62A9, 0x91E0}; -const PROGMEM uint16_t h3_temp[] = {0x62A9, 0x75A4, 0x8FFE, 0x75A4, 0x8FFE, 0x8D2C, 0x62A9, 0x8D2C, 0x62A9, 0x75A4}; -const PROGMEM uint16_t h3_label[] = {0x62A9, 0x5E1D, 0x8FFE, 0x5E1D, 0x8FFE, 0x75A4, 0x62A9, 0x75A4, 0x62A9, 0x5E1D}; -const PROGMEM uint16_t chocolate_label[] = {0x62A9, 0x12D2, 0xBD53, 0x12D2, 0xBD53, 0x2A5A, 0x62A9, 0x2A5A, 0x62A9, 0x12D2}; -const PROGMEM uint16_t h0_label[] = {0x62A9, 0x2A5A, 0x8FFE, 0x2A5A, 0x8FFE, 0x41E1, 0x62A9, 0x41E1, 0x62A9, 0x2A5A}; -const PROGMEM uint16_t h0_temp[] = {0x62A9, 0x41E1, 0x8FFE, 0x41E1, 0x8FFE, 0x5968, 0x62A9, 0x5968, 0x62A9, 0x41E1}; -const PROGMEM uint16_t h1_label[] = {0x8FFE, 0x2A5A, 0xBD53, 0x2A5A, 0xBD53, 0x41E1, 0x8FFE, 0x41E1, 0x8FFE, 0x2A5A}; -const PROGMEM uint16_t h1_temp[] = {0x8FFE, 0x41E1, 0xBD53, 0x41E1, 0xBD53, 0x5968, 0x8FFE, 0x5968, 0x8FFE, 0x41E1}; -const PROGMEM uint16_t h2_label[] = {0x8FFE, 0x5E1D, 0xBD53, 0x5E1D, 0xBD53, 0x75A4, 0x8FFE, 0x75A4, 0x8FFE, 0x5E1D}; -const PROGMEM uint16_t h2_temp[] = {0x8FFE, 0x75A4, 0xBD53, 0x75A4, 0xBD53, 0x8D2C, 0x8FFE, 0x8D2C, 0x8FFE, 0x75A4}; -const PROGMEM uint16_t extrude_btn[] = {0xC859, 0xDD2B, 0xF5AE, 0xDD2B, 0xF5AE, 0xEFFE, 0xC859, 0xEFFE, 0xC859, 0xDD2B}; -const PROGMEM uint16_t load_screen_extrude[] = {0x25FB, 0x89AE, 0x2F58, 0x89AE, 0x2F58, 0xAAF6, 0x3406, 0xAAF6, 0x2AAA, 0xBB9A, 0x214D, 0xAAF6, 0x25FB, 0xAAF6, 0x25FB, 0x89AE}; -const PROGMEM uint16_t load_screen_retract[] = {0x25FC, 0x790A, 0x2F58, 0x790A, 0x2F58, 0x57C2, 0x3406, 0x57C2, 0x2AAA, 0x471D, 0x214D, 0x57C2, 0x25FC, 0x57C2, 0x25FC, 0x790A}; -const PROGMEM uint16_t load_screen_back_btn[] = {0x1555, 0xCA58, 0xC553, 0xCA58, 0xC553, 0xEFFE, 0x1555, 0xEFFE, 0x1555, 0xCA58}; -const PROGMEM uint16_t load_screen_unload_btn[] = {0x4AAA, 0x8EBD, 0xC553, 0x8EBD, 0xC553, 0xB463, 0x4AAA, 0xB463, 0x4AAA, 0x8EBD}; -const PROGMEM uint16_t load_screen_load_btn[] = {0x4AAA, 0x5322, 0xC553, 0x5322, 0xC553, 0x78C7, 0x4AAA, 0x78C7, 0x4AAA, 0x5322}; -const PROGMEM uint16_t load_sreen_title[] = {0x4AAA, 0x1787, 0xC553, 0x1787, 0xC553, 0x3D2C, 0x4AAA, 0x3D2C, 0x4AAA, 0x1787}; -const PROGMEM uint16_t load_screen_increment[] = {0x1555, 0x2E1D, 0x3FFF, 0x2E1D, 0x3FFF, 0x3D2C, 0x1555, 0x3D2C, 0x1555, 0x2E1D}; +const PROGMEM uint16_t menu_btn[] = {0x0AAA, 0x0E1E, 0x6D54, 0x0E1E, 0x6D54, 0x2F0E, 0x0AAA, 0x2F0E, 0x0AAA, 0x0E1E}; +const PROGMEM uint16_t print_btn[] = {0x47FF, 0xCF0D, 0x7FFF, 0xCF0D, 0x7FFF, 0xEFFE, 0x47FF, 0xEFFE, 0x47FF, 0xCF0D}; +const PROGMEM uint16_t load_chocolate_btn[] = {0x0AAA, 0x3878, 0x6D54, 0x3878, 0x6D54, 0x5968, 0x0AAA, 0x5968, 0x0AAA, 0x3878}; +const PROGMEM uint16_t extrude_btn[] = {0x0AAA, 0x5E1D, 0x6D54, 0x5E1D, 0x6D54, 0x7F0E, 0x0AAA, 0x7F0E, 0x0AAA, 0x5E1D}; +const PROGMEM uint16_t preheat_chocolate_btn[] = {0x0AAA, 0x83C2, 0x6D54, 0x83C2, 0x6D54, 0xA4B3, 0x0AAA, 0xA4B3, 0x0AAA, 0x83C2}; +const PROGMEM uint16_t media_btn[] = {0x0AAA, 0xCF0D, 0x42AA, 0xCF0D, 0x42AA, 0xEFFE, 0x0AAA, 0xEFFE, 0x0AAA, 0xCF0D}; +const PROGMEM uint16_t pause_btn[] = {0x8554, 0xCF0D, 0xBD53, 0xCF0D, 0xBD53, 0xEFFE, 0x8554, 0xEFFE, 0x8554, 0xCF0D}; +const PROGMEM uint16_t print_time_hms[] = {0xC59E, 0xAEA0, 0xF510, 0xAEA0, 0xF510, 0xC52D, 0xC59E, 0xC52D, 0xC59E, 0xAEA0}; +const PROGMEM uint16_t file_name[] = {0x0B0E, 0xAECD, 0xBCEF, 0xAECD, 0xBCEF, 0xC4AB, 0x0B0E, 0xC4AB, 0x0B0E, 0xAECD}; +const PROGMEM uint16_t chocolate_label[] = {0x75C1, 0x1369, 0xF4FE, 0x1369, 0xF4FE, 0x2AB1, 0x75C1, 0x2AB1, 0x75C1, 0x1369}; +const PROGMEM uint16_t h0_label[] = {0x8304, 0x4BEB, 0xB271, 0x4BEB, 0xB271, 0x63B0, 0x8304, 0x63B0, 0x8304, 0x4BEB}; +const PROGMEM uint16_t h0_temp[] = {0x8304, 0x7190, 0xB271, 0x7190, 0xB271, 0x8955, 0x8304, 0x8955, 0x8304, 0x7190}; +const PROGMEM uint16_t h1_label[] = {0xBB04, 0x4BEB, 0xEA71, 0x4BEB, 0xEA71, 0x63B0, 0xBB04, 0x63B0, 0xBB04, 0x4BEB}; +const PROGMEM uint16_t h1_temp[] = {0xBB04, 0x7190, 0xEA71, 0x7190, 0xEA71, 0x8956, 0xBB04, 0x8956, 0xBB04, 0x7190}; +const PROGMEM uint16_t stop_btn[] = {0xC2A9, 0xCF0D, 0xF553, 0xCF0D, 0xF553, 0xEFFE, 0xC2A9, 0xEFFE, 0xC2A9, 0xCF0D}; +const PROGMEM uint16_t load_screen_extrude[] = {0x382C, 0x8B02, 0x4188, 0x8B02, 0x4188, 0xAC4A, 0x4637, 0xAC4A, 0x3CDA, 0xBCEE, 0x337D, 0xAC4A, 0x382C, 0xAC4A, 0x382C, 0x8B02}; +const PROGMEM uint16_t load_screen_retract[] = {0x382C, 0x7A5D, 0x4188, 0x7A5D, 0x4188, 0x5915, 0x4637, 0x5915, 0x3CDA, 0x4871, 0x337E, 0x5915, 0x382C, 0x5915, 0x382C, 0x7A5D}; +const PROGMEM uint16_t load_screen_back_btn[] = {0x1555, 0xCA58, 0xEAA8, 0xCA58, 0xEAA8, 0xEFFE, 0x1555, 0xEFFE, 0x1555, 0xCA58}; +const PROGMEM uint16_t load_screen_unload_btn[] = {0x67FF, 0x70F0, 0xEAA8, 0x70F0, 0xEAA8, 0x9695, 0x67FF, 0x9695, 0x67FF, 0x70F0}; +const PROGMEM uint16_t load_screen_start_stop_btn[] = {0x67FF, 0x9B4A, 0xEAA8, 0x9B4A, 0xEAA8, 0xC0EF, 0x67FF, 0xC0EF, 0x67FF, 0x9B4A}; +const PROGMEM uint16_t load_screen_load_btn[] = {0x67FF, 0x4696, 0xEAA8, 0x4696, 0xEAA8, 0x6C3B, 0x67FF, 0x6C3B, 0x67FF, 0x4696}; +const PROGMEM uint16_t load_screen_continuous[] = {0x67FF, 0x1787, 0xEAA8, 0x1787, 0xEAA8, 0x3D2C, 0x67FF, 0x3D2C, 0x67FF, 0x1787}; +const PROGMEM uint16_t load_screen_increment[] = {0x1555, 0x1787, 0x62A9, 0x1787, 0x62A9, 0x3D2C, 0x1555, 0x3D2C, 0x1555, 0x1787}; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/confirm_start_print_dialog_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/confirm_start_print_dialog_box.cpp new file mode 100644 index 000000000000..ca98e7c9b6d4 --- /dev/null +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/confirm_start_print_dialog_box.cpp @@ -0,0 +1,55 @@ +/************************************** + * confirm_start_print_dialog_box.cpp * + **************************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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. * + * * + * To view a copy of the GNU General Public License, go to the following * + * location: . * + ****************************************************************************/ + +#include "../config.h" +#include "../screens.h" + +#ifdef COCOA_CONFIRM_START_PRINT + +using namespace FTDI; +using namespace Theme; +using namespace ExtUI; + +void ConfirmStartPrintDialogBox::onRedraw(draw_mode_t) { + FileList files; + const char *filename = files.filename(); + char buffer[strlen_P(GET_TEXT(MSG_START_PRINT_CONFIRMATION)) + strlen(filename) + 1]; + sprintf_P(buffer, GET_TEXT(MSG_START_PRINT_CONFIRMATION), filename); + drawMessage((const char *)buffer); + drawYesNoButtons(); +} + +bool ConfirmStartPrintDialogBox::onTouchEnd(uint8_t tag) { + switch (tag) { + case 1: { + FileList files; + printFile(files.shortFilename()); + StatusScreen::setStatusMessage(GET_TEXT_F(MSG_PRINT_STARTING)); + GOTO_SCREEN(StatusScreen); + return true; + } + case 2: GOTO_PREVIOUS(); return true; + default: return false; + } +} + +#endif // COCOA_CONFIRM_START_PRINT diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/confirm_start_print_dialog_box.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/confirm_start_print_dialog_box.h new file mode 100644 index 000000000000..38cb5c2774bf --- /dev/null +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/confirm_start_print_dialog_box.h @@ -0,0 +1,32 @@ +/************************************ + * confirm_start_print_dialog_box.h * + ************************************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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. * + * * + * To view a copy of the GNU General Public License, go to the following * + * location: . * + ****************************************************************************/ + +#pragma once + +#define COCOA_CONFIRM_START_PRINT +#define COCOA_CONFIRM_START_PRINT_CLASS ConfirmStartPrintDialogBox + +class ConfirmStartPrintDialogBox : public DialogBoxBaseClass, public UncachedScreen { + public: + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t); +}; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/files_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/files_screen.cpp new file mode 100644 index 000000000000..581c3374288b --- /dev/null +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/files_screen.cpp @@ -0,0 +1,289 @@ +/******************** + * files_screen.cpp * + ********************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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. * + * * + * To view a copy of the GNU General Public License, go to the following * + * location: . * + ****************************************************************************/ + +#include "../config.h" +#include "../screens.h" +#include "../screen_data.h" + +#ifdef COCOA_FILES_SCREEN + +#if ENABLED(TOUCH_UI_PORTRAIT) + #define GRID_COLS 6 + #define GRID_ROWS 15 + #define FILES_PER_PAGE 11 + #define PREV_DIR LEFT + #define NEXT_DIR RIGHT + + #define PREV_POS BTN_POS(1,1), BTN_SIZE(1,2) + #define HEAD_POS BTN_POS(2,1), BTN_SIZE(4,2) + #define NEXT_POS BTN_POS(6,1), BTN_SIZE(1,2) + #define LIST_POS BTN_POS(1,3), BTN_SIZE(6,FILES_PER_PAGE) + #define BTN1_POS BTN_POS(1,14), BTN_SIZE(3,2) + #define BTN2_POS BTN_POS(4,14), BTN_SIZE(3,2) +#else + #define GRID_COLS 12 + #define GRID_ROWS 8 + #define FILES_PER_PAGE 6 + #define PREV_DIR UP + #define NEXT_DIR DOWN + + #define PREV_POS BTN_POS(12,2), BTN_SIZE(1,3) + #define HEAD_POS BTN_POS( 1,1), BTN_SIZE(12,1) + #define NEXT_POS BTN_POS(12,5), BTN_SIZE(1,4) + #define LIST_POS BTN_POS( 1,2), BTN_SIZE(11,FILES_PER_PAGE) + #define BTN1_POS BTN_POS( 1,8), BTN_SIZE(6,1) + #define BTN2_POS BTN_POS( 7,8), BTN_SIZE(5,1) +#endif + +using namespace FTDI; +using namespace ExtUI; +using namespace Theme; + +constexpr static FilesScreenData &mydata = screen_data.FilesScreen; + +void FilesScreen::onEntry() { + mydata.cur_page = 0; + mydata.selected_tag = 0xFF; + #if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810) + CLCD::mem_write_32(CLCD::REG::MACRO_0,DL::NOP); + #endif + gotoPage(0); + BaseScreen::onEntry(); +} + +const char *FilesScreen::getSelectedFilename(bool shortName) { + FileList files; + files.seek(getSelectedFileIndex(), true); + return shortName ? files.shortFilename() : files.filename(); +} + +void FilesScreen::drawSelectedFile() { + if(mydata.selected_tag == 0xFF) return; + FileList files; + files.seek(getSelectedFileIndex(), true); + mydata.flags.is_dir = files.isDir(); + drawFileButton( + files.filename(), + mydata.selected_tag, + mydata.flags.is_dir, + true + ); +} + +uint16_t FilesScreen::getSelectedFileIndex() { + return getFileForTag(mydata.selected_tag); +} + +uint16_t FilesScreen::getFileForTag(uint8_t tag) { + return mydata.cur_page * FILES_PER_PAGE + tag - 2; +} + +void FilesScreen::drawFileButton(int x, int y, int w, int h, const char *filename, uint8_t tag, bool is_dir, bool is_highlighted) { + #define SUB_COLS 6 + #define SUB_ROWS FILES_PER_PAGE + + const int bx = SUB_X(1); + const int by = SUB_Y(getLineForTag(tag)+1); + const int bw = SUB_W(6); + const int bh = SUB_H(1); + + CommandProcessor cmd; + cmd.tag(tag); + cmd.cmd(COLOR_RGB(is_highlighted ? fg_action : bg_color)); + cmd.font(font_medium).rectangle(bx, by, bw, bh); + cmd.cmd(COLOR_RGB(is_highlighted ? normal_btn.rgb : bg_text_enabled)); + #if ENABLED(SCROLL_LONG_FILENAMES) + if (is_highlighted) { + cmd.cmd(SAVE_CONTEXT()); + cmd.cmd(SCISSOR_XY(x,y)); + cmd.cmd(SCISSOR_SIZE(w,h)); + cmd.cmd(MACRO(0)); + cmd.text(bx, by, bw, bh, filename, OPT_CENTERY | OPT_NOFIT); + } else + #endif + draw_text_with_ellipsis(cmd, bx,by, bw - (is_dir ? 20 : 0), bh, filename, OPT_CENTERY, font_medium); + if (is_dir && !is_highlighted) cmd.text(bx, by, bw, bh, F("> "), OPT_CENTERY | OPT_RIGHTX); + #if ENABLED(SCROLL_LONG_FILENAMES) + if (is_highlighted) cmd.cmd(RESTORE_CONTEXT()); + #endif +} + +void FilesScreen::drawFileList() { + FileList files; + mydata.num_page = max(1,ceil(float(files.count()) / FILES_PER_PAGE)); + mydata.cur_page = min(mydata.cur_page, mydata.num_page-1); + mydata.flags.is_root = files.isAtRootDir(); + mydata.flags.is_empty = true; + + uint16_t fileIndex = mydata.cur_page * FILES_PER_PAGE; + for (uint8_t i = 0; i < FILES_PER_PAGE; i++, fileIndex++) { + if (files.seek(fileIndex)) { + drawFileButton(files.filename(), getTagForLine(i), files.isDir(), false); + mydata.flags.is_empty = false; + } else + break; + } +} + +void FilesScreen::drawHeader() { + char str[16]; + sprintf_P(str, PSTR("Page %d of %d"), mydata.cur_page + 1, mydata.num_page); + + CommandProcessor cmd; + cmd.colors(normal_btn) + .font(font_small) + .tag(0).button(HEAD_POS, str, OPT_CENTER | OPT_FLAT); +} + +void FilesScreen::drawArrows() { + const bool prev_enabled = mydata.cur_page > 0; + const bool next_enabled = mydata.cur_page < (mydata.num_page - 1); + + CommandProcessor cmd; + cmd.colors(normal_btn); + cmd.tag(242).enabled(prev_enabled).button(PREV_POS, F("")); if (prev_enabled) drawArrow(PREV_POS, PREV_DIR); + cmd.tag(243).enabled(next_enabled).button(NEXT_POS, F("")); if (next_enabled) drawArrow(NEXT_POS, NEXT_DIR); +} + +void FilesScreen::drawFooter() { + const bool has_selection = mydata.selected_tag != 0xFF; + + CommandProcessor cmd; + cmd.colors(normal_btn) + .font(font_medium) + .colors(normal_btn) + .enabled(!mydata.flags.is_root) + .tag(245).button(BTN2_POS, F("Up Dir")) + .colors(action_btn); + + if (mydata.flags.is_empty) + cmd.tag(240).button(BTN1_POS, GET_TEXT_F(MSG_BUTTON_DONE)); + else if (has_selection && mydata.flags.is_dir) + cmd.tag(244).button(BTN1_POS, GET_TEXT_F(MSG_BUTTON_OPEN)); + else + cmd.tag(241).enabled(has_selection).button(BTN1_POS, F("Select")); +} + +void FilesScreen::drawFileButton(const char *filename, uint8_t tag, bool is_dir, bool is_highlighted) { + #undef MARGIN_L + #undef MARGIN_R + #define MARGIN_L 0 + #define MARGIN_R 0 + drawFileButton(LIST_POS, filename, tag, is_dir, is_highlighted); +} + +void FilesScreen::onRedraw(draw_mode_t what) { + if (what & FOREGROUND) { + drawHeader(); + drawArrows(); + drawSelectedFile(); + drawFooter(); + } +} + +void FilesScreen::gotoPage(uint8_t page) { + mydata.selected_tag = 0xFF; + mydata.cur_page = page; + CommandProcessor cmd; + cmd.cmd(CMD_DLSTART) + .cmd(CLEAR_COLOR_RGB(bg_color)) + .cmd(CLEAR(true,true,true)) + .colors(normal_btn); + drawFileList(); + storeBackground(); +} + +bool FilesScreen::onTouchEnd(uint8_t tag) { + switch (tag) { + case 240: // Done button, always select first file + { + FileList files; + files.seek(0); + GOTO_PREVIOUS(); + } + return true; + case 241: // Select highlighted file + GOTO_PREVIOUS(); + return true; + case 242: // Previous page + if (mydata.cur_page > 0) { + gotoPage(mydata.cur_page-1); + } + break; + case 243: // Next page + if (mydata.cur_page < (mydata.num_page-1)) { + gotoPage(mydata.cur_page+1); + } + break; + case 244: // Select directory + { + FileList files; + files.changeDir(getSelectedShortFilename()); + gotoPage(0); + } + break; + case 245: // Up directory + { + FileList files; + files.upDir(); + gotoPage(0); + } + break; + default: // File selected + if (tag < 240) { + mydata.selected_tag = tag; + #if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810) + mydata.scroll_pos = 0; + mydata.scroll_max = 0; + if (FTDI::ftdi_chip >= 810) { + const char *filename = getSelectedFilename(); + if (filename[0]) { + CommandProcessor cmd; + constexpr int dim[4] = {LIST_POS}; + const uint16_t text_width = cmd.font(font_medium).text_width(filename); + if (text_width > dim[2]) + mydata.scroll_max = text_width - dim[2] + MARGIN_L + MARGIN_R + 10; + } + } + #endif + } + break; + } + return true; +} + +void FilesScreen::onIdle() { + #if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810) + if (FTDI::ftdi_chip >= 810) { + CLCD::mem_write_32(CLCD::REG::MACRO_0, + VERTEX_TRANSLATE_X(-int32_t(mydata.scroll_pos))); + if (mydata.scroll_pos < mydata.scroll_max * 16) + mydata.scroll_pos++; + } + #endif +} + +void FilesScreen::onMediaRemoved() { + if (AT_SCREEN(FilesScreen)) GOTO_SCREEN(StatusScreen); +} + +#endif // COCOA_FILES_SCREEN diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/files_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/files_screen.h new file mode 100644 index 000000000000..99ea52ff817b --- /dev/null +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/files_screen.h @@ -0,0 +1,68 @@ +/****************** + * files_screen.h * + ******************/ + +/**************************************************************************** + * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * + * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. * + * * + * 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. * + * * + * To view a copy of the GNU General Public License, go to the following * + * location: . * + ****************************************************************************/ + +#pragma once + +#define COCOA_FILES_SCREEN +#define COCOA_FILES_SCREEN_CLASS FilesScreen + +struct FilesScreenData { + struct { + uint8_t is_dir : 1; + uint8_t is_root : 1; + uint8_t is_empty : 1; + } flags; + uint8_t selected_tag; + uint8_t num_page; + uint8_t cur_page; + #if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810) + uint16_t scroll_pos; + uint16_t scroll_max; + #endif +}; + +class FilesScreen : public BaseScreen, public CachedScreen { + private: + static uint8_t getTagForLine(uint8_t line) {return line + 2;} + static uint8_t getLineForTag(uint8_t tag) {return tag - 2;} + static uint16_t getFileForTag(uint8_t tag); + static uint16_t getSelectedFileIndex(); + + inline static const char *getSelectedShortFilename() {return getSelectedFilename(true);} + static const char *getSelectedFilename(bool shortName = false); + + static void drawFileButton(int x, int y, int w, int h, const char *filename, uint8_t tag, bool is_dir, bool is_highlighted); + static void drawFileButton(const char *filename, uint8_t tag, bool is_dir, bool is_highlighted); + static void drawFileList(); + static void drawHeader(); + static void drawArrows(); + static void drawFooter(); + static void drawSelectedFile(); + + static void gotoPage(uint8_t); + public: + static void onEntry(); + static void onRedraw(draw_mode_t); + static bool onTouchEnd(uint8_t tag); + static void onIdle(); + static void onMediaRemoved(); +}; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.cpp index 5e61bdb12f18..be18c0348388 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.cpp @@ -57,7 +57,9 @@ void LevelingMenu::onRedraw(draw_mode_t what) { cmd.font(font_large) .cmd(COLOR_RGB(bg_text_enabled)) .text(BED_MESH_TITLE_POS, GET_TEXT_F(MSG_BED_LEVELING)) + #if ENABLED(BLTOUCH) .text(BLTOUCH_TITLE_POS, GET_TEXT_F(MSG_BLTOUCH)) + #endif .font(font_medium).colors(normal_btn) .tag(2).button(PROBE_BED_POS, GET_TEXT_F(MSG_PROBE_BED)) .enabled(ENABLED(HAS_MESH)) @@ -66,8 +68,10 @@ void LevelingMenu::onRedraw(draw_mode_t what) { .tag(4).button(EDIT_MESH_POS, GET_TEXT_F(MSG_EDIT_MESH)) #undef GRID_COLS #define GRID_COLS 2 + #if ENABLED(BLTOUCH) .tag(5).button(BLTOUCH_RESET_POS, GET_TEXT_F(MSG_BLTOUCH_RESET)) .tag(6).button(BLTOUCH_TEST_POS, GET_TEXT_F(MSG_BLTOUCH_SELFTEST)) + #endif #undef GRID_COLS #define GRID_COLS 3 .colors(action_btn) @@ -81,8 +85,10 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) { case 2: BedMeshViewScreen::doProbe(); break; case 3: BedMeshViewScreen::show(); break; case 4: BedMeshEditScreen::show(); break; + #if ENABLED(BLTOUCH) case 5: injectCommands(F("M280 P0 S60")); break; case 6: SpinnerDialogBox::enqueueAndWait(F("M280 P0 S90\nG4 P100\nM280 P0 S120")); break; + #endif default: return false; } return true; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/load_chocolate.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/load_chocolate.cpp index d40b3be35460..95ddf7d387f7 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/load_chocolate.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/load_chocolate.cpp @@ -39,42 +39,6 @@ using namespace Theme; constexpr static LoadChocolateScreenData &mydata = screen_data.LoadChocolateScreen; -void LoadChocolateScreen::draw_syringe(draw_mode_t what) { - #if ENABLED(COCOA_PRESS_CHOCOLATE_LEVEL_SENSOR) - const float fill_level = get_chocolate_fill_level(); - #else - constexpr float fill_level = 1.0f; - #endif - - CommandProcessor cmd; - PolyUI ui(cmd, what); - - if (what & BACKGROUND) { - // Paint the shadow for the syringe - ui.color(shadow_rgb); - ui.shadow(POLY(syringe_outline), shadow_depth); - } - - if (what & FOREGROUND) { - int16_t x, y, h, v; - - // Paint the syringe icon - ui.color(syringe_rgb); - ui.fill(POLY(syringe_outline)); - - ui.color(fluid_rgb); - ui.bounds(POLY(syringe_fluid), x, y, h, v); - cmd.cmd(SAVE_CONTEXT()); - cmd.cmd(SCISSOR_XY(x,y + v * (1.0 - fill_level))); - cmd.cmd(SCISSOR_SIZE(h, v * fill_level)); - ui.fill(POLY(syringe_fluid), false); - cmd.cmd(RESTORE_CONTEXT()); - - ui.color(stroke_rgb); - ui.fill(POLY(syringe)); - } -} - void LoadChocolateScreen::draw_buttons(draw_mode_t what) { int16_t x, y, h, v; @@ -84,10 +48,18 @@ void LoadChocolateScreen::draw_buttons(draw_mode_t what) { cmd.font(font_medium).colors(normal_btn); ui.bounds(POLY(load_screen_unload_btn), x, y, h, v); - cmd.tag(2).button(x, y, h, v, GET_TEXT_F(MSG_FULL_UNLOAD)); + cmd.tag(2).colors(mydata.repeat_tag == 5 ? action_btn : normal_btn).button(x, y, h, v, GET_TEXT_F(MSG_UNLOAD)); ui.bounds(POLY(load_screen_load_btn), x, y, h, v); - cmd.tag(3).button(x, y, h, v, GET_TEXT_F(MSG_FULL_LOAD)); + cmd.tag(3).colors(mydata.repeat_tag == 6 ? action_btn : normal_btn).button(x, y, h, v, GET_TEXT_F(MSG_LOAD)); + + ui.bounds(POLY(load_screen_start_stop_btn), x, y, h, v); + if(mydata.repeat_tag == 0) { + cmd.colors(normal_btn).enabled(false); + } else { + cmd.colors(mydata.repeating ? action_btn : normal_btn).enabled(true); + } + cmd.tag(4).button(x, y, h, v, GET_TEXT_F(MSG_START_STOP)); ui.bounds(POLY(load_screen_back_btn), x, y, h, v); cmd.tag(1).colors(action_btn).button(x, y, h, v, GET_TEXT_F(MSG_BUTTON_DONE)); @@ -102,8 +74,8 @@ void LoadChocolateScreen::draw_text(draw_mode_t what) { cmd.font(font_medium).cmd(COLOR_RGB(bg_text_enabled)); - ui.bounds(POLY(load_sreen_title), x, y, h, v); - cmd.tag(2).text(x, y, h, v, GET_TEXT_F(MSG_LOAD_UNLOAD)); + ui.bounds(POLY(load_screen_continuous), x, y, h, v); + cmd.tag(2).text(x, y, h, v, GET_TEXT_F(MSG_CONTINUOUS)); ui.bounds(POLY(load_screen_increment), x, y, h, v); cmd.tag(3).text(x, y, h, v, GET_TEXT_F(MSG_INCREMENT)); @@ -120,11 +92,12 @@ void LoadChocolateScreen::draw_arrows(draw_mode_t what) { constexpr uint8_t style = PolyUI::REGULAR; - ui.button(4, POLY(load_screen_extrude), style); - ui.button(5, POLY(load_screen_retract), style); + ui.button(5, POLY(load_screen_extrude), style); + ui.button(6, POLY(load_screen_retract), style); } void LoadChocolateScreen::onEntry() { + mydata.repeating = false; mydata.repeat_tag = 0; } @@ -136,14 +109,15 @@ void LoadChocolateScreen::onRedraw(draw_mode_t what) { .tag(0); } - draw_syringe(what); draw_arrows(what); draw_buttons(what); draw_text(what); } -bool LoadChocolateScreen::onTouchStart(uint8_t) { - mydata.repeat_tag = 0; +bool LoadChocolateScreen::onTouchStart(uint8_t tag) { + if(tag != 4) { + mydata.repeating = false; + } return true; } @@ -151,10 +125,13 @@ bool LoadChocolateScreen::onTouchEnd(uint8_t tag) { using namespace ExtUI; switch (tag) { case 2: - mydata.repeat_tag = (mydata.repeat_tag == 2) ? 0 : 2; + mydata.repeat_tag = 5; break; case 3: - mydata.repeat_tag = (mydata.repeat_tag == 3) ? 0 : 3; + mydata.repeat_tag = 6; + break; + case 4: + mydata.repeating = !mydata.repeating; break; case 1: GOTO_PREVIOUS(); break; } @@ -176,26 +153,10 @@ bool LoadChocolateScreen::onTouchHeld(uint8_t tag) { #define UI_INCREMENT_AXIS(axis) UI_INCREMENT(AxisPosition_mm, axis); #define UI_DECREMENT_AXIS(axis) UI_DECREMENT(AxisPosition_mm, axis); switch (tag) { - case 2: { - if (get_chocolate_fill_level() < 0.1) { - mydata.repeat_tag = 0; - return false; - } - UI_INCREMENT_AXIS(E0); - break; - } - case 3: { - if (get_chocolate_fill_level() > 0.75) { - mydata.repeat_tag = 0; - return false; - } - UI_DECREMENT_AXIS(E0); - break; - } - case 4: + case 5: UI_INCREMENT_AXIS(E0); break; - case 5: + case 6: UI_DECREMENT_AXIS(E0); break; default: return false; @@ -207,7 +168,7 @@ bool LoadChocolateScreen::onTouchHeld(uint8_t tag) { void LoadChocolateScreen::onIdle() { reset_menu_timeout(); - if (mydata.repeat_tag) onTouchHeld(mydata.repeat_tag); + if (mydata.repeating) onTouchHeld(mydata.repeat_tag); if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) { if (!EventLoop::is_touch_held()) onRefresh(); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/load_chocolate.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/load_chocolate.h index 4a582f0212f8..426669775d66 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/load_chocolate.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/load_chocolate.h @@ -28,11 +28,11 @@ struct LoadChocolateScreenData { uint8_t repeat_tag; + bool repeating; }; class LoadChocolateScreen : public BaseScreen, public CachedScreen { private: - static void draw_syringe(draw_mode_t what); static void draw_arrows(draw_mode_t what); static void draw_buttons(draw_mode_t what); static void draw_text(draw_mode_t what); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_menu.cpp index b01aa81dd441..2fabb81ee4db 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/preheat_menu.cpp @@ -32,7 +32,7 @@ using namespace Theme; #define GRID_ROWS 5 void PreheatMenu::onRedraw(draw_mode_t what) { - const int16_t w = TERN0(COCOA_PRESS_EXTRA_HEATER, has_extra_heater() ? BTN_W(1) : BTN_W(2)); + const int16_t w = TERN0(COCOA_PRESS_EXTRA_HEATER, has_extra_heater()) ? BTN_W(1) : BTN_W(2); const int16_t h = BTN_H(1); if (what & BACKGROUND) { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/screens.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/screens.h index 8481e446c425..5276f64f4429 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/screens.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/screens.h @@ -90,7 +90,6 @@ enum { #include "../generic/spinner_dialog_box.h" #include "../generic/restore_failsafe_dialog_box.h" #include "../generic/save_settings_dialog_box.h" -#include "../generic/confirm_start_print_dialog_box.h" #include "../generic/confirm_abort_print_dialog_box.h" #include "../generic/confirm_user_request_alert_box.h" #include "../generic/touch_calibration_screen.h" @@ -114,7 +113,6 @@ enum { #include "../generic/bed_mesh_edit_screen.h" #include "../generic/case_light_screen.h" #include "../generic/linear_advance_screen.h" -#include "../generic/files_screen.h" #include "../generic/move_axis_screen.h" #include "../generic/flow_percent_screen.h" #if HAS_JUNCTION_DEVIATION @@ -132,3 +130,5 @@ enum { #include "leveling_menu.h" #include "move_xyz_screen.h" #include "move_e_screen.h" +#include "files_screen.h" +#include "confirm_start_print_dialog_box.h" diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp index 00b2d6a0943e..eddf36723977 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp @@ -29,6 +29,8 @@ #include "cocoa_press_ui.h" #define POLY(A) PolyUI::poly_reader_t(A, sizeof(A)/sizeof(A[0])) +#define ICON_POS(x,y,w,h) x, y, h, h +#define TEXT_POS(x,y,w,h) x + h, y, w - h, h const uint8_t shadow_depth = 5; @@ -38,8 +40,28 @@ using namespace ExtUI; float StatusScreen::increment; +void StatusScreen::_format_time(char *outstr, uint32_t time) { + const uint8_t hrs = time / 3600, + min = (time / 60) % 60, + sec = time % 60; + if (hrs) + sprintf_P(outstr, PSTR("%02d:%02d"), hrs, min); + else + sprintf_P(outstr, PSTR("%02d:%02ds"), min, sec); +} + void StatusScreen::loadBitmaps() { + // Load the bitmaps for the status screen + using namespace Theme; constexpr uint32_t base = ftdi_memory_map::RAM_G; + CLCD::mem_write_xbm(base + Light_Bulb_Info.RAMG_offset, Light_Bulb, sizeof(Light_Bulb)); + CLCD::mem_write_xbm(base + Chamber_Icon_Info.RAMG_offset, Chamber_Icon, sizeof(Chamber_Icon)); + CLCD::mem_write_xbm(base + Clock_Icon_Info.RAMG_offset, Clock_Icon, sizeof(Clock_Icon)); + CLCD::mem_write_xbm(base + File_Icon_Info.RAMG_offset, File_Icon, sizeof(File_Icon)); + CLCD::mem_write_xbm(base + TD_Icon_Info.RAMG_offset, TD_Icon, sizeof(TD_Icon)); + CLCD::mem_write_xbm(base + Extruder_Icon_Info.RAMG_offset, Extruder_Icon, sizeof(Extruder_Icon)); + CLCD::mem_write_xbm(base + Bed_Heat_Icon_Info.RAMG_offset, Bed_Heat_Icon, sizeof(Bed_Heat_Icon)); + CLCD::mem_write_xbm(base + Fan_Icon_Info.RAMG_offset, Fan_Icon, sizeof(Fan_Icon)); // Load fonts for internationalization #if ENABLED(TOUCH_UI_USE_UTF8) @@ -47,33 +69,50 @@ void StatusScreen::loadBitmaps() { #endif } -void StatusScreen::draw_progress(draw_mode_t what) { +void StatusScreen::draw_time(draw_mode_t what) { CommandProcessor cmd; PolyUI ui(cmd, what); - int16_t x, y, h, v; - - cmd.cmd(COLOR_RGB(accent_color_1)); - cmd.font(font_medium); + int16_t x, y, w, h; + ui.bounds(POLY(print_time_hms), x, y, w, h); if (what & BACKGROUND) { - ui.bounds(POLY(print_time_label), x, y, h, v); - cmd.text(x, y, h, v, GET_TEXT_F(MSG_ELAPSED_PRINT)); + cmd.cmd(COLOR_RGB(bg_text_enabled)) + .cmd (BITMAP_SOURCE(Clock_Icon_Info)) + .cmd (BITMAP_LAYOUT(Clock_Icon_Info)) + .cmd (BITMAP_SIZE (Clock_Icon_Info)) + .icon(ICON_POS(x, y, w, h), Clock_Icon_Info, icon_scale) + .cmd(COLOR_RGB(bg_text_enabled)); } if (what & FOREGROUND) { const uint32_t elapsed = getProgress_seconds_elapsed(); - const uint8_t hrs = elapsed/3600; - const uint8_t min = (elapsed/60)%60; + char elapsed_str[10]; + _format_time(elapsed_str, elapsed); + + cmd.font(font_medium) + .cmd(COLOR_RGB(bg_text_enabled)) + .text(TEXT_POS(x, y, w, h), elapsed_str); + } +} + + +void StatusScreen::draw_progress(draw_mode_t what) { + CommandProcessor cmd; + PolyUI ui(cmd, what); - char str[10]; - sprintf_P(str, PSTR(" %02d : %02d"), hrs, min); - ui.bounds(POLY(print_time_hms), x, y, h, v); - cmd.text(x, y, h, v, str); + int16_t x, y, w, h; - sprintf_P(str, PSTR("%-3d%%"), getProgress_percent() ); - ui.bounds(POLY(print_time_percent), x, y, h, v); - cmd.text(x, y, h, v, str); + cmd.cmd(COLOR_RGB(accent_color_1)); + cmd.font(font_medium); + + if (what & FOREGROUND) { + // Draw progress bar + ui.bounds(POLY(file_name), x, y, w, h); + const uint16_t bar_width = w * getProgress_percent() / 100; + cmd.tag(8) + .cmd(COLOR_RGB(accent_color_5)) + .rectangle(x, y, bar_width, h); } } @@ -81,30 +120,38 @@ void StatusScreen::draw_temperature(draw_mode_t what) { CommandProcessor cmd; PolyUI ui(cmd, what); - int16_t x, y, h, v; + int16_t x, y, w, h; if (what & BACKGROUND) { cmd.cmd(COLOR_RGB(fluid_rgb)); cmd.font(font_medium).tag(10); - ui.bounds(POLY(chocolate_label), x, y, h, v); - cmd.text(x, y, h, v, GET_TEXT_F(MSG_CHOCOLATE)); + /*ui.bounds(POLY(temp_lbl), x, y, w, h); + cmd.text(x, y, w, h, F("Temp")); - ui.bounds(POLY(h0_label), x, y, h, v); - cmd.text(x, y, h, v, GET_TEXT_F(MSG_NOZZLE)); + ui.bounds(POLY(set_lbl), x, y, w, h); + cmd.text(x, y, w, h, F("Set"));*/ - ui.bounds(POLY(h1_label), x, y, h, v); - cmd.text(x, y, h, v, GET_TEXT_F(MSG_BODY)); + ui.bounds(POLY(chocolate_label), x, y, w, h); + cmd.text(x, y, w, h, F("Cocoa Press")); + + ui.bounds(POLY(h0_label), x, y, w, h); + cmd.text(x, y, w, h, GET_TEXT_F(MSG_NOZZLE)); + + ui.bounds(POLY(h1_label), x, y, w, h); + cmd.text(x, y, w, h, GET_TEXT_F(MSG_BODY)); #if ENABLED(COCOA_PRESS_EXTRA_HEATER) if (has_extra_heater()) { - ui.bounds(POLY(h2_label), x, y, h, v); - cmd.text(x, y, h, v, GET_TEXT_F(MSG_EXTERNAL)); + ui.bounds(POLY(h2_label), x, y, w, h); + cmd.text(x, y, w, h, GET_TEXT_F(MSG_EXTERNAL)); } #endif - ui.bounds(POLY(h3_label), x, y, h, v); - cmd.text(x, y, h, v, GET_TEXT_F(MSG_CHAMBER)); + #if ENABLED(COCOA_PRESS_CHAMBER_COOLER) + ui.bounds(POLY(h3_label), x, y, w, h); + cmd.text(x, y, w, h, GET_TEXT_F(MSG_CHAMBER)); + #endif #if ENABLED(TOUCH_UI_USE_UTF8) load_utf8_bitmaps(cmd); // Restore font bitmap handles @@ -117,68 +164,60 @@ void StatusScreen::draw_temperature(draw_mode_t what) { cmd.font(font_large).tag(10); + // Show the actual temperatures + format_temp(str, getActualTemp_celsius(E0)); - ui.bounds(POLY(h0_temp), x, y, h, v); - cmd.text(x, y, h, v, str); + ui.bounds(POLY(h0_temp), x, y, w, h); + cmd.text(x, y, w, h, str); format_temp(str, getActualTemp_celsius(E1)); - ui.bounds(POLY(h1_temp), x, y, h, v); - cmd.text(x, y, h, v, str); + ui.bounds(POLY(h1_temp), x, y, w, h); + cmd.text(x, y, w, h, str); #if ENABLED(COCOA_PRESS_EXTRA_HEATER) if (has_extra_heater()) { format_temp(str, getActualTemp_celsius(E2)); - ui.bounds(POLY(h2_temp), x, y, h, v); - cmd.text(x, y, h, v, str); + ui.bounds(POLY(h2_temp), x, y, w, h); + cmd.text(x, y, w, h, str); } #endif - format_temp(str, getActualTemp_celsius(CHAMBER)); - ui.bounds(POLY(h3_temp), x, y, h, v); - cmd.text(x, y, h, v, str); - } -} + #if ENABLED(COCOA_PRESS_CHAMBER_COOLER) + format_temp(str, getActualTemp_celsius(CHAMBER)); + ui.bounds(POLY(h3_temp), x, y, w, h); + cmd.text(x, y, w, h, str); + #endif -void StatusScreen::draw_syringe(draw_mode_t what) { - #if ENABLED(COCOA_PRESS_CHOCOLATE_LEVEL_SENSOR) - const float fill_level = get_chocolate_fill_level(); - #else - constexpr float fill_level = 1.0f; - #endif + /*// Show the set temperatures + format_temp(str, getTargetTemp_celsius(E0)); + ui.bounds(POLY(h0_set), x, y, w, h); + cmd.text(x, y, w, h, str); - CommandProcessor cmd; - PolyUI ui(cmd, what); + format_temp(str, getTargetTemp_celsius(E1)); + ui.bounds(POLY(h1_set), x, y, w, h); + cmd.text(x, y, w, h, str); - if (what & BACKGROUND) { - // Paint the shadow for the syringe - ui.color(shadow_rgb); - ui.shadow(POLY(syringe_outline), shadow_depth); - } + #if ENABLED(COCOA_PRESS_EXTRA_HEATER) + if (has_extra_heater()) { + format_temp(str, getTargetTemp_celsius(E2)); + ui.bounds(POLY(h2_set), x, y, w, h); + cmd.text(x, y, w, h, str); + } + #endif - if (what & FOREGROUND) { - int16_t x, y, h, v; - - // Paint the syringe icon - ui.color(syringe_rgb); - ui.fill(POLY(syringe_outline)); - - ui.color(fluid_rgb); - ui.bounds(POLY(syringe_fluid), x, y, h, v); - cmd.cmd(SAVE_CONTEXT()); - cmd.cmd(SCISSOR_XY(x,y + v * (1.0 - fill_level))); - cmd.cmd(SCISSOR_SIZE(h, v * fill_level)); - ui.fill(POLY(syringe_fluid), false); - cmd.cmd(RESTORE_CONTEXT()); - - ui.color(stroke_rgb); - ui.fill(POLY(syringe)); + #if ENABLED(COCOA_PRESS_CHAMBER_COOLER) + format_temp(str, getTargetTemp_celsius(CHAMBER)); + ui.bounds(POLY(h3_set), x, y, w, h); + cmd.text(x, y, w, h, str); + #endif*/ } } void StatusScreen::draw_buttons(draw_mode_t what) { - int16_t x, y, h, v; + int16_t x, y, w, h; - const bool can_print = isMediaInserted() && !isPrintingFromMedia(); + const bool can_print = !isPrinting() && isMediaInserted() && isFileSelected(); + const bool can_select = !isPrinting() && isMediaInserted(); const bool sdOrHostPrinting = ExtUI::isPrinting(); const bool sdOrHostPaused = ExtUI::isPrintingPaused(); @@ -187,29 +226,68 @@ void StatusScreen::draw_buttons(draw_mode_t what) { cmd.font(font_medium).colors(normal_btn); - ui.bounds(POLY(park_btn), x, y, h, v); - cmd.tag(1).button(x, y, h, v, GET_TEXT_F(MSG_FILAMENT_PARK_ENABLED)); + ui.bounds(POLY(load_chocolate_btn), x, y, w, h); + cmd.tag(1).button(x, y, w, h, GET_TEXT_F(MSG_LOAD_UNLOAD)); + + ui.bounds(POLY(extrude_btn), x, y, w, h); + cmd.tag(2).button(x, y, w, h, GET_TEXT_F(MSG_EXTRUDE)); + + ui.bounds(POLY(preheat_chocolate_btn), x, y, w, h); + cmd.tag(3).button(x, y, w, h, GET_TEXT_F(MSG_PREHEAT_CHOCOLATE)); + + ui.bounds(POLY(menu_btn), x, y, w, h); + cmd.tag(4).button(x, y, w, h, GET_TEXT_F(MSG_BUTTON_MENU)); + + ui.bounds(POLY(media_btn), x, y, w, h); + cmd.tag(5).enabled(can_select).button(x, y, w, h, GET_TEXT_F(MSG_BUTTON_MEDIA)); + + ui.bounds(POLY(print_btn), x, y, w, h); + cmd.tag(6).colors(action_btn).enabled(can_print).button(x, y, w, h, GET_TEXT_F(MSG_BUTTON_PRINT)); - ui.bounds(POLY(load_chocolate_btn), x, y, h, v); - cmd.tag(2).button(x, y, h, v, GET_TEXT_F(MSG_LOAD_UNLOAD)); + ui.bounds(POLY(pause_btn), x, y, w, h); + cmd.tag(sdOrHostPaused ? 8 : 7).enabled(sdOrHostPrinting).button(x, y, w, h, sdOrHostPaused ? GET_TEXT_F(MSG_BUTTON_RESUME) : GET_TEXT_F(MSG_BUTTON_PAUSE)); - ui.bounds(POLY(preheat_chocolate_btn), x, y, h, v); - cmd.tag(3).button(x, y, h, v, GET_TEXT_F(MSG_PREHEAT_CHOCOLATE)); + ui.bounds(POLY(stop_btn), x, y, w, h); + cmd.tag(9).enabled(sdOrHostPrinting).button(x, y, w, h, GET_TEXT_F(MSG_BUTTON_STOP)); +} - ui.bounds(POLY(menu_btn), x, y, h, v); - cmd.tag(4).button(x, y, h, v, GET_TEXT_F(MSG_BUTTON_MENU)); +void StatusScreen::draw_file(draw_mode_t what) { + int16_t x, y, w, h; - ui.bounds(POLY(pause_btn), x, y, h, v); - cmd.tag(sdOrHostPaused ? 6 : 5).enabled(sdOrHostPrinting).button(x, y, h, v, sdOrHostPaused ? GET_TEXT_F(MSG_BUTTON_RESUME) : GET_TEXT_F(MSG_BUTTON_PAUSE)); + CommandProcessor cmd; + PolyUI ui(cmd, what); - ui.bounds(POLY(stop_btn), x, y, h, v); - cmd.tag(7).enabled(sdOrHostPrinting).button(x, y, h, v, GET_TEXT_F(MSG_BUTTON_STOP)); + ui.bounds(POLY(file_name), x, y, w, h); - ui.bounds(POLY(extrude_btn), x, y, h, v); - cmd.tag(8).button(x, y, h, v, GET_TEXT_F(MSG_EXTRUDE)); + if (what & BACKGROUND) { + cmd.tag(5) + .cmd(COLOR_RGB(bg_text_enabled)) + .cmd (BITMAP_SOURCE(File_Icon_Info)) + .cmd (BITMAP_LAYOUT(File_Icon_Info)) + .cmd (BITMAP_SIZE (File_Icon_Info)) + .icon(ICON_POS(x, y, w, h), File_Icon_Info, icon_scale); + } - ui.bounds(POLY(print_btn), x, y, h, v); - cmd.tag(9).colors(action_btn).enabled(can_print).button(x, y, h, v, GET_TEXT_F(MSG_BUTTON_PRINT)); + if (what & FOREGROUND) { + cmd.cmd(COLOR_RGB(bg_text_enabled)); + + if(!isMediaInserted()) + draw_text_with_ellipsis(cmd, TEXT_POS(x, y, w, h), F("No media present"), OPT_CENTERY, font_small); + else if(isFileSelected()) { + FileList list; + draw_text_with_ellipsis(cmd, TEXT_POS(x, y, w, h), list.filename(), OPT_CENTERY, font_small); + } else + draw_text_with_ellipsis(cmd, TEXT_POS(x, y, w, h), F("No file selected"), OPT_CENTERY, font_small); + } +} + +bool StatusScreen::isFileSelected() { + if(!isMediaInserted()) return false; + FileList list; + if(list.isDir()) return false; + const char *filename = list.filename(); + if(filename[0] == '\0') return false; + return true; } void StatusScreen::onRedraw(draw_mode_t what) { @@ -220,8 +298,9 @@ void StatusScreen::onRedraw(draw_mode_t what) { .tag(0); } + draw_file(what); + draw_time(what); draw_progress(what); - draw_syringe(what); draw_temperature(what); draw_buttons(what); } @@ -233,11 +312,12 @@ bool StatusScreen::onTouchStart(uint8_t) { bool StatusScreen::onTouchEnd(uint8_t tag) { switch (tag) { - case 1: SpinnerDialogBox::enqueueAndWait(F("G28 O\nG27")); break; - case 2: GOTO_SCREEN(LoadChocolateScreen); break; + case 1: GOTO_SCREEN(LoadChocolateScreen); break; case 3: GOTO_SCREEN(PreheatMenu); break; case 4: GOTO_SCREEN(MainMenu); break; - case 5: + case 5: GOTO_SCREEN(FilesScreen); break; + case 6: GOTO_SCREEN(ConfirmStartPrintDialogBox); break; + case 7: sound.play(twinkle, PLAY_ASYNCHRONOUS); if (ExtUI::isPrintingFromMedia()) ExtUI::pausePrint(); @@ -246,7 +326,7 @@ bool StatusScreen::onTouchEnd(uint8_t tag) { #endif GOTO_SCREEN(StatusScreen); break; - case 6: + case 8: sound.play(twinkle, PLAY_ASYNCHRONOUS); if (ExtUI::isPrintingFromMedia()) ExtUI::resumePrint(); @@ -255,12 +335,12 @@ bool StatusScreen::onTouchEnd(uint8_t tag) { #endif GOTO_SCREEN(StatusScreen); break; - case 7: + case 9: GOTO_SCREEN(ConfirmAbortPrintDialogBox); current_screen.forget(); PUSH_SCREEN(StatusScreen); break; - case 9: GOTO_SCREEN(FilesScreen); break; + case 10: GOTO_SCREEN(TemperatureScreen); break; default: return false; } @@ -271,7 +351,7 @@ bool StatusScreen::onTouchEnd(uint8_t tag) { } bool StatusScreen::onTouchHeld(uint8_t tag) { - if (tag == 8 && !ExtUI::isMoving()) { + if (tag == 2 && !ExtUI::isMoving()) { LoadChocolateScreen::setManualFeedrateAndIncrement(1, increment); UI_INCREMENT(AxisPosition_mm, E0); current_screen.onRefresh(); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.h index 08fb6f26d4c5..05f99e953d6c 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.h @@ -28,17 +28,19 @@ class StatusScreen : public BaseScreen, public CachedScreen { private: + static void _format_time(char *outstr, uint32_t time); + static float increment; static bool jog_xy; static bool fine_motion; + static void draw_time(draw_mode_t what); static void draw_progress(draw_mode_t what); static void draw_temperature(draw_mode_t what); - static void draw_syringe(draw_mode_t what); - static void draw_arrows(draw_mode_t what); - static void draw_overlay_icons(draw_mode_t what); - static void draw_fine_motion(draw_mode_t what); static void draw_buttons(draw_mode_t what); + static void draw_file(draw_mode_t what); + + static bool isFileSelected(); public: static void loadBitmaps(); static void unlockMotors(); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp index a796c8edcf5f..662753a1547c 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/commands.cpp @@ -1208,7 +1208,7 @@ void CLCD::default_display_orientation() { + ENABLED(TOUCH_UI_INVERTED) * 1 ); cmd.execute(); - #elif ANY(TOUCH_UI_PORTRAIT, TOUCH_UI_MIRRORED) + #elif EITHER(TOUCH_UI_PORTRAIT, TOUCH_UI_MIRRORED) #error "PORTRAIT or MIRRORED orientation not supported on the FT800." #elif ENABLED(TOUCH_UI_INVERTED) mem_write_32(REG::ROTATE, 1); 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/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h index da911c772daa..6b2dc9eb4498 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h @@ -240,8 +240,8 @@ #define IS_PROBE(V...) SECOND(V, 0) // Get the second item passed, or 0 #define PROBE() ~, 1 // Second item will be 1 if this is passed #define _NOT_0 PROBE() - #define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'. - #define _BOOL(x) NOT(NOT(x)) // NOT('0') gets '0'. Anything else gets '1'. + #define NOT(x) IS_PROBE(_CAT(_NOT_, x)) // NOT('0') gets '1'. Anything else gets '0'. + #define _BOOL(x) NOT(NOT(x)) // _BOOL('0') gets '0'. Anything else gets '1'. #define _DO_1(W,C,A) (_##W##_1(A)) #define _DO_2(W,C,A,B) (_##W##_1(A) C _##W##_1(B)) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h index 648ed5330a98..fd3e8f921c74 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/command_processor.h @@ -125,7 +125,7 @@ class CommandProcessor : public CLCD::CommandFifo { } inline CommandProcessor& set_button_style_callback(const btn_style_func_t *func) { - _btn_style_callback = func ? func : default_button_style_func; + _btn_style_callback = func ?: default_button_style_func; return *this; } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.cpp index 47bf79e46743..3d53f2d99baf 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_player.cpp @@ -41,7 +41,7 @@ namespace FTDI { #endif // Play the note - CLCD::mem_write_16(REG::SOUND, (note == REST) ? 0 : (((note ? note : NOTE_C4) << 8) | effect)); + CLCD::mem_write_16(REG::SOUND, (note == REST) ? 0 : (((note ?: NOTE_C4) << 8) | effect)); CLCD::mem_write_8(REG::PLAY, 1); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/svg2cpp.py b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/svg2cpp.py index cfc262545356..f6e4a3e39abe 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/svg2cpp.py +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/svg2cpp.py @@ -112,10 +112,10 @@ def from_svg_view_box(self, svg): if s: m = re.search('viewBox="([0-9-.]+) ([0-9-.]+) ([0-9-.]+) ([0-9-.]+)"', svg) if m: - self.x_min = float(m.group(1)) - self.y_min = float(m.group(2)) - self.x_max = float(m.group(3)) - self.y_max = float(m.group(4)) + self.x_min = float(m[1]) + self.y_min = float(m[2]) + self.x_max = float(m[3]) + self.y_max = float(m[4]) return True return False @@ -205,18 +205,18 @@ def process_svg_path_data(self, id, d): pass # Just eat the spaces elif self.eat_token('([LMHVZlmhvz])'): - cmd = self.m.group(1) + cmd = self.m[1] # The following commands take no arguments if cmd == "Z" or cmd == "z": self.process_svg_path_data_cmd(id, cmd, 0, 0) elif self.eat_token('([CScsQqTtAa])'): - print("Unsupported path data command:", self.m.group(1), "in path", id, "\n", file=sys.stderr) + print("Unsupported path data command:", self.m[1], "in path", id, "\n", file=sys.stderr) quit() elif self.eat_token('([ ,]*[-0-9e.]+)+'): # Process list of coordinates following command - coords = re.split('[ ,]+', self.m.group(0)) + coords = re.split('[ ,]+', self.m[0]) # The following commands take two arguments if cmd == "L" or cmd == "l": while coords: @@ -245,7 +245,7 @@ def process_svg_paths(self, svg): id = "" m = re.search(' id="(.*)"', path) if m: - id = m.group(1) + id = m[1] m = re.search(' transform="(.*)"', path) if m: @@ -254,7 +254,7 @@ def process_svg_paths(self, svg): m = re.search(' d="(.*)"', path) if m: - self.process_svg_path_data(id, m.group(1)) + self.process_svg_path_data(id, m[1]) self.op.path_finished(id) self.reset() 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/extui/ftdi_eve_touch_ui/generic/change_filament_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/change_filament_screen.cpp index fa0748c17b37..17ec975692ea 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/change_filament_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/change_filament_screen.cpp @@ -171,9 +171,9 @@ void ChangeFilamentScreen::onRedraw(draw_mode_t what) { const bool t_ok = getActualTemp_celsius(e) > getSoftenTemp() - 10; - if (mydata.t_tag && !t_ok) { + if (mydata.t_tag && !t_ok) cmd.text(HEATING_LBL_POS, GET_TEXT_F(MSG_HEATING)); - } else if (getActualTemp_celsius(e) > 100) { + else if (getActualTemp_celsius(e) > 100) { cmd.cmd(COLOR_RGB(0xFF0000)) .text(CAUTION_LBL_POS, GET_TEXT_F(MSG_CAUTION)) .colors(normal_btn) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/dialog_box_base_class.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/dialog_box_base_class.cpp index a006d30942d9..ea177bfdc1d5 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/dialog_box_base_class.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/dialog_box_base_class.cpp @@ -39,7 +39,7 @@ void DialogBoxBaseClass::drawMessage(T message, const int16_t font) { .cmd(CLEAR(true,true,true)) .cmd(COLOR_RGB(bg_text_enabled)) .tag(0); - draw_text_box(cmd, BTN_POS(1,1), BTN_SIZE(2,6), message, OPT_CENTER, font ? font : font_large); + draw_text_box(cmd, BTN_POS(1,1), BTN_SIZE(2,6), message, OPT_CENTER, font ?: font_large); cmd.colors(normal_btn); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp index 00768dbaf7de..290c20f43e59 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp @@ -111,16 +111,17 @@ void FilesScreen::drawFileButton(int x, int y, int w, int h, const char *filenam cmd.cmd(COLOR_RGB(is_highlighted ? fg_action : bg_color)); cmd.font(font_medium).rectangle(bx, by, bw, bh); cmd.cmd(COLOR_RGB(is_highlighted ? normal_btn.rgb : bg_text_enabled)); - #if ENABLED(SCROLL_LONG_FILENAMES) - if (is_highlighted) { + if (TERN0(SCROLL_LONG_FILENAMES, is_highlighted)) { + #if ENABLED(SCROLL_LONG_FILENAMES) cmd.cmd(SAVE_CONTEXT()); cmd.cmd(SCISSOR_XY(x,y)); cmd.cmd(SCISSOR_SIZE(w,h)); cmd.cmd(MACRO(0)); cmd.text(bx, by, bw, bh, filename, OPT_CENTERY | OPT_NOFIT); - } else - #endif - draw_text_with_ellipsis(cmd, bx,by, bw - (is_dir ? 20 : 0), bh, filename, OPT_CENTERY, font_medium); + #endif + } + else + draw_text_with_ellipsis(cmd, bx,by, bw - (is_dir ? 20 : 0), bh, filename, OPT_CENTERY, font_medium); if (is_dir && !is_highlighted) cmd.text(bx, by, bw, bh, F("> "), OPT_CENTERY | OPT_RIGHTX); #if ENABLED(SCROLL_LONG_FILENAMES) if (is_highlighted) cmd.cmd(RESTORE_CONTEXT()); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/language_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/language_menu.cpp index 499f741540ab..5d797f44df31 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/language_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/language_menu.cpp @@ -56,7 +56,7 @@ void LanguageMenu::onRedraw(draw_mode_t) { bool LanguageMenu::onTouchEnd(uint8_t tag) { if (tag > 0 && tag <= NUM_LANGUAGES) { - lang = tag - 1; + ftdi_language = tag - 1; GOTO_SCREEN(StatusScreen); return true; } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_velocity_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_velocity_screen.cpp index e7fc23ab4870..666a7542cccb 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_velocity_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_velocity_screen.cpp @@ -34,7 +34,7 @@ void MaxVelocityScreen::onRedraw(draw_mode_t what) { widgets_t w(what); w.precision(0); w.units(GET_TEXT_F(MSG_UNITS_MM_S)); - w.heading( GET_TEXT_F(MSG_MAX_SPEED)); + w.heading( GET_TEXT_F(MSG_MAX_SPEED_NO_UNITS)); w.color(x_axis) .adjuster( 2, GET_TEXT_F(MSG_VMAX_X), getAxisMaxFeedrate_mm_s(X) ); w.color(y_axis) .adjuster( 4, GET_TEXT_F(MSG_VMAX_Y), getAxisMaxFeedrate_mm_s(Y) ); w.color(z_axis) .adjuster( 6, GET_TEXT_F(MSG_VMAX_Z), getAxisMaxFeedrate_mm_s(Z) ); 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..c3927c21a7dd 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 @@ -61,9 +61,9 @@ void MoveAxisScreen::onRedraw(draw_mode_t what) { w.adjuster( 10, GET_TEXT_F(MSG_AXIS_E2), mydata.e_rel[1], canMove(E1)); #if EXTRUDERS > 2 w.adjuster( 12, GET_TEXT_F(MSG_AXIS_E3), mydata.e_rel[2], canMove(E2)); - #endif - #if EXTRUDERS > 3 - w.adjuster( 14, GET_TEXT_F(MSG_AXIS_E4), mydata.e_rel[3], canMove(E3)); + #if EXTRUDERS > 3 + w.adjuster( 14, GET_TEXT_F(MSG_AXIS_E4), mydata.e_rel[3], canMove(E3)); + #endif #endif #endif #if Z_HOME_TO_MIN @@ -79,41 +79,45 @@ bool BaseMoveAxisScreen::onTouchHeld(uint8_t tag) { switch (tag) { case 2: UI_DECREMENT_AXIS(X); break; case 3: UI_INCREMENT_AXIS(X); break; - case 4: UI_DECREMENT_AXIS(Y); break; - case 5: UI_INCREMENT_AXIS(Y); break; - case 6: UI_DECREMENT_AXIS(Z); break; - case 7: UI_INCREMENT_AXIS(Z); break; - // For extruders, also update relative distances. - case 8: UI_DECREMENT_AXIS(E0); mydata.e_rel[0] -= increment; break; - case 9: UI_INCREMENT_AXIS(E0); mydata.e_rel[0] += increment; break; - #if HAS_MULTI_EXTRUDER - case 10: UI_DECREMENT_AXIS(E1); mydata.e_rel[1] -= increment; break; - case 11: UI_INCREMENT_AXIS(E1); mydata.e_rel[1] += increment; break; - #endif - #if EXTRUDERS > 2 - case 12: UI_DECREMENT_AXIS(E2); mydata.e_rel[2] -= increment; break; - case 13: UI_INCREMENT_AXIS(E2); mydata.e_rel[2] += increment; break; + #if HAS_EXTRUDERS + // For extruders, also update relative distances. + case 8: UI_DECREMENT_AXIS(E0); mydata.e_rel[0] -= increment; break; + case 9: UI_INCREMENT_AXIS(E0); mydata.e_rel[0] += increment; break; + #if HAS_MULTI_EXTRUDER + case 10: UI_DECREMENT_AXIS(E1); mydata.e_rel[1] -= increment; break; + case 11: UI_INCREMENT_AXIS(E1); mydata.e_rel[1] += increment; break; + #if EXTRUDERS > 2 + case 12: UI_DECREMENT_AXIS(E2); mydata.e_rel[2] -= increment; break; + case 13: UI_INCREMENT_AXIS(E2); mydata.e_rel[2] += increment; break; + #if EXTRUDERS > 3 + case 14: UI_DECREMENT_AXIS(E3); mydata.e_rel[3] -= increment; break; + case 15: UI_INCREMENT_AXIS(E3); mydata.e_rel[3] += increment; break; + #endif + #endif + #endif #endif - #if EXTRUDERS > 3 - case 14: UI_DECREMENT_AXIS(E3); mydata.e_rel[3] -= increment; break; - case 15: UI_INCREMENT_AXIS(E3); mydata.e_rel[3] += increment; break; + #if HAS_Y_AXIS + case 4: UI_DECREMENT_AXIS(Y); break; + case 5: UI_INCREMENT_AXIS(Y); break; + case 20: SpinnerDialogBox::enqueueAndWait(F("G28X")); break; + case 21: SpinnerDialogBox::enqueueAndWait(F("G28Y")); break; + #if HAS_Z_AXIS + case 6: UI_DECREMENT_AXIS(Z); break; + case 7: UI_INCREMENT_AXIS(Z); break; + case 22: SpinnerDialogBox::enqueueAndWait(F("G28Z")); break; + case 24: raiseZtoTop(); break; + #endif #endif - case 20: SpinnerDialogBox::enqueueAndWait(F("G28X")); break; - case 21: SpinnerDialogBox::enqueueAndWait(F("G28Y")); break; - case 22: SpinnerDialogBox::enqueueAndWait(F("G28Z")); break; case 23: SpinnerDialogBox::enqueueAndWait(F("G28")); break; - case 24: raiseZtoTop(); break; default: return false; } - #undef UI_DECREMENT_AXIS - #undef UI_INCREMENT_AXIS return true; } void BaseMoveAxisScreen::raiseZtoTop() { - constexpr xyze_feedrate_t homing_feedrate = HOMING_FEEDRATE_MM_M; - setAxisPosition_mm(Z_MAX_POS - 5, Z, homing_feedrate[Z_AXIS]); + constexpr xyz_feedrate_t homing_feedrate = HOMING_FEEDRATE_MM_M; + setAxisPosition_mm(Z_MAX_POS - 5, Z, homing_feedrate.z); } float BaseMoveAxisScreen::getManualFeedrate(uint8_t axis, float increment_mm) { @@ -128,9 +132,11 @@ void BaseMoveAxisScreen::setManualFeedrate(ExtUI::axis_t axis, float increment_m ExtUI::setFeedrate_mm_s(getManualFeedrate(X_AXIS + (axis - ExtUI::X), increment_mm)); } -void BaseMoveAxisScreen::setManualFeedrate(ExtUI::extruder_t, float increment_mm) { - ExtUI::setFeedrate_mm_s(getManualFeedrate(E_AXIS, increment_mm)); -} +#if HAS_EXTRUDERS + void BaseMoveAxisScreen::setManualFeedrate(ExtUI::extruder_t, float increment_mm) { + ExtUI::setFeedrate_mm_s(getManualFeedrate(E_AXIS, increment_mm)); + } +#endif void MoveAxisScreen::onIdle() { if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language.cpp index bf684e43f917..9ff738e45c19 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language.cpp @@ -23,5 +23,5 @@ #include "../../../../MarlinCore.h" #if ENABLED(TOUCH_UI_FTDI_EVE) #include "language.h" - uint8_t lang = 0; + uint8_t ftdi_language = 0; #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h index 5dbde8a5c359..05e625842ad9 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language_en.h @@ -146,6 +146,7 @@ namespace Language_en { LSTR MSG_PROBE_BED = u8"Probe Mesh"; LSTR MSG_PRINT_TEST = u8"Print Test (PLA)"; LSTR MSG_MOVE_Z_TO_TOP = u8"Raise Z to Top"; + LSTR MSG_MAX_SPEED_NO_UNITS = u8"Max Speed"; #if ENABLED(TOUCH_UI_LULZBOT_BIO) LSTR MSG_MOVE_TO_HOME = u8"Move to Home"; @@ -163,8 +164,9 @@ namespace Language_en { LSTR MSG_CHOCOLATE = u8"Chocolate"; LSTR MSG_UNLOAD_CARTRIDGE = u8"Unload Cartridge"; LSTR MSG_LOAD_UNLOAD = u8"Load/Unload"; - LSTR MSG_FULL_LOAD = u8"Full Load"; - LSTR MSG_FULL_UNLOAD = u8"Full Unload"; + LSTR MSG_START_STOP = u8"Start/Stop"; + LSTR MSG_LOAD = u8"Load"; + LSTR MSG_UNLOAD = u8"Unload"; LSTR MSG_PREHEAT_CHOCOLATE = u8"Preheat Chocolate"; LSTR MSG_PREHEAT_FINISHED = u8"Preheat finished"; LSTR MSG_PREHEAT = u8"Preheat"; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screen_data.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screen_data.h index 5d715572fa27..48a0c1a96440 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screen_data.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screen_data.h @@ -64,6 +64,7 @@ union screen_data_t { DECL_DATA_IF_INCLUDED(FTDI_ALERT_DIALOG_BOX) DECL_DATA_IF_INCLUDED(COCOA_PREHEAT_SCREEN) DECL_DATA_IF_INCLUDED(COCOA_LOAD_CHOCOLATE_SCREEN) + DECL_DATA_IF_INCLUDED(COCOA_FILES_SCREEN) }; extern screen_data_t screen_data; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.cpp index ec627e313b13..ed210369c4f2 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.cpp @@ -116,6 +116,8 @@ SCREEN_TABLE { DECL_SCREEN_IF_INCLUDED(COCOA_LEVELING_MENU) DECL_SCREEN_IF_INCLUDED(COCOA_MOVE_XYZ_SCREEN) DECL_SCREEN_IF_INCLUDED(COCOA_MOVE_E_SCREEN) + DECL_SCREEN_IF_INCLUDED(COCOA_CONFIRM_START_PRINT) + DECL_SCREEN_IF_INCLUDED(COCOA_FILES_SCREEN) }; SCREEN_TABLE_POST diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h index 995379fcdab7..70c2be4ec23f 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h @@ -37,14 +37,14 @@ namespace Theme { #else // Use linear accent colors - #if ANY(TOUCH_UI_ROYAL_THEME, TOUCH_UI_FROZEN_THEME) - // Dark blue accent colors - constexpr int accent_hue = 216; - constexpr float accent_sat = 0.7; + #if EITHER(TOUCH_UI_ROYAL_THEME, TOUCH_UI_FROZEN_THEME) + // Dark blue accent colors + constexpr int accent_hue = 216; + constexpr float accent_sat = 0.7; #else - // Green accent colors - constexpr int accent_hue = 68; - constexpr float accent_sat = 0.68; + // Green accent colors + constexpr int accent_hue = 68; + constexpr float accent_sat = 0.68; #endif // Shades of accent color @@ -88,7 +88,7 @@ namespace Theme { constexpr uint32_t bed_mesh_lines_rgb = 0xFFFFFF; constexpr uint32_t bed_mesh_shadow_rgb = 0x444444; - #elif ANY(TOUCH_UI_COCOA_THEME, TOUCH_UI_FROZEN_THEME) + #elif EITHER(TOUCH_UI_COCOA_THEME, TOUCH_UI_FROZEN_THEME) constexpr uint32_t theme_darkest = accent_color_1; constexpr uint32_t theme_dark = accent_color_4; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/marlin_bootscreen_landscape.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/marlin_bootscreen_landscape.h index 1231d31dc387..4e706a645a06 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/marlin_bootscreen_landscape.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/marlin_bootscreen_landscape.h @@ -1,4 +1,3 @@ - /**************************************************************************** * 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/lcd/extui/ftdi_eve_touch_ui/theme/marlin_bootscreen_portrait.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/marlin_bootscreen_portrait.h index c6065af7f7ca..ce0423921323 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/marlin_bootscreen_portrait.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/marlin_bootscreen_portrait.h @@ -1,4 +1,3 @@ - /**************************************************************************** * 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/lcd/extui/mks_ui/SPIFlashStorage.cpp b/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp index 6f2351bba68c..43149dc60c58 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; @@ -148,7 +148,7 @@ uint32_t SPIFlashStorage::m_startAddress; #endif // HAS_SPI_FLASH_COMPRESSION -void SPIFlashStorage::beginWrite(uint32_t startAddress) { +void SPIFlashStorage::beginWrite(const uint32_t startAddress) { m_pageDataUsed = 0; m_currentPage = 0; m_startAddress = startAddress; @@ -171,7 +171,7 @@ void SPIFlashStorage::endWrite() { #endif } -void SPIFlashStorage::savePage(uint8_t *buffer) { +void SPIFlashStorage::savePage(uint8_t * const buffer) { W25QXX.SPI_FLASH_BufferWrite(buffer, m_startAddress + (SPI_FLASH_PageSize * m_currentPage), SPI_FLASH_PageSize); // Test env // char fname[256]; @@ -181,7 +181,7 @@ void SPIFlashStorage::savePage(uint8_t *buffer) { // fclose(fp); } -void SPIFlashStorage::loadPage(uint8_t *buffer) { +void SPIFlashStorage::loadPage(uint8_t * const buffer) { W25QXX.SPI_FLASH_BufferRead(buffer, m_startAddress + (SPI_FLASH_PageSize * m_currentPage), SPI_FLASH_PageSize); // Test env // char fname[256]; @@ -260,7 +260,7 @@ void SPIFlashStorage::readPage() { #endif } -uint16_t SPIFlashStorage::inData(uint8_t *data, uint16_t size) { +uint16_t SPIFlashStorage::inData(const uint8_t * const data, uint16_t size) { // Don't write more than we can NOMORE(size, pageDataFree()); memcpy(m_pageData + m_pageDataUsed, data, size); @@ -268,12 +268,12 @@ uint16_t SPIFlashStorage::inData(uint8_t *data, uint16_t size) { return size; } -void SPIFlashStorage::writeData(uint8_t *data, uint16_t size) { +void SPIFlashStorage::writeData(const uint8_t *data, uint16_t size) { // Flush a page if needed if (pageDataFree() == 0) flushPage(); while (size > 0) { - uint16_t written = inData(data, size); + const uint16_t written = inData(data, size); size -= written; // Need to write more? Flush page and continue! if (size > 0) { @@ -283,7 +283,7 @@ void SPIFlashStorage::writeData(uint8_t *data, uint16_t size) { } } -void SPIFlashStorage::beginRead(uint32_t startAddress) { +void SPIFlashStorage::beginRead(const uint32_t startAddress) { m_startAddress = startAddress; m_currentPage = 0; // Nothing in memory now @@ -293,7 +293,7 @@ void SPIFlashStorage::beginRead(uint32_t startAddress) { #endif } -uint16_t SPIFlashStorage::outData(uint8_t *data, uint16_t size) { +uint16_t SPIFlashStorage::outData(uint8_t * const data, uint16_t size) { // Don't read more than we have NOMORE(size, pageDataFree()); memcpy(data, m_pageData + m_pageDataUsed, size); @@ -306,7 +306,7 @@ void SPIFlashStorage::readData(uint8_t *data, uint16_t size) { if (pageDataFree() == 0) readPage(); while (size > 0) { - uint16_t read = outData(data, size); + const uint16_t read = outData(data, size); size -= read; // Need to write more? Flush page and continue! if (size > 0) { diff --git a/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h b/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h index 72394286ac58..bd7109b7acbd 100644 --- a/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h +++ b/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h @@ -75,23 +75,23 @@ class SPIFlashStorage { public: // Write operation - static void beginWrite(uint32_t startAddress); + static void beginWrite(const uint32_t startAddress); static void endWrite(); - static void writeData(uint8_t *data, uint16_t size); + static void writeData(const uint8_t *data, uint16_t size); // Read operation - static void beginRead(uint32_t startAddress); + static void beginRead(const uint32_t startAddress); static void readData(uint8_t *data, uint16_t size); static uint32_t getCurrentPage() { return m_currentPage; } private: static void flushPage(); - static void savePage(uint8_t *buffer); - static void loadPage(uint8_t *buffer); + static void savePage(uint8_t * const buffer); + static void loadPage(uint8_t * const buffer); static void readPage(); - static uint16_t inData(uint8_t *data, uint16_t size); - static uint16_t outData(uint8_t *data, uint16_t size); + static uint16_t inData(const uint8_t * const data, uint16_t size); + static uint16_t outData(uint8_t * const data, uint16_t size); static uint8_t m_pageData[SPI_FLASH_PageSize]; static uint32_t m_currentPage; 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/lcd/extui/mks_ui/draw_dialog.cpp b/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp index a69c54bcff63..a214e7d1e0e7 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp @@ -90,7 +90,7 @@ static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) { char *cur_name; cur_name = strrchr(list_file.file_name[sel_id], '/'); - SdFile file, *curDir; + MediaFile file, *curDir; card.abortFilePrintNow(); const char * const fname = card.diveToFile(false, curDir, cur_name); if (!fname) return; 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; 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/mks_ui/draw_touch_calibration.cpp b/Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.cpp index e0c663e282e3..a9a25db11822 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.cpp @@ -55,22 +55,22 @@ static void drawCross(uint16_t x, uint16_t y, uint16_t color) { void lv_update_touch_calibration_screen() { uint16_t x, y; - calibrationState calibration_stage = touch_calibration.get_calibration_state(); - if (calibration_stage == CALIBRATION_NONE) { + calibrationState stage = touch_calibration.get_calibration_state(); + if (stage == CALIBRATION_NONE) { // start and clear screen - calibration_stage = touch_calibration.calibration_start(); + stage = touch_calibration.calibration_start(); } else { // clear last cross - x = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].x; - y = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].y; + x = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].x; + y = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].y; drawCross(x, y, LV_COLOR_BACKGROUND.full); } const char *str = nullptr; - if (calibration_stage < CALIBRATION_SUCCESS) { + if (stage < CALIBRATION_SUCCESS) { // handle current state - switch (calibration_stage) { + switch (stage) { case CALIBRATION_TOP_LEFT: str = GET_TEXT(MSG_TOP_LEFT); break; case CALIBRATION_BOTTOM_LEFT: str = GET_TEXT(MSG_BOTTOM_LEFT); break; case CALIBRATION_TOP_RIGHT: str = GET_TEXT(MSG_TOP_RIGHT); break; @@ -78,13 +78,13 @@ void lv_update_touch_calibration_screen() { default: break; } - x = touch_calibration.calibration_points[calibration_stage].x; - y = touch_calibration.calibration_points[calibration_stage].y; + x = touch_calibration.calibration_points[stage].x; + y = touch_calibration.calibration_points[stage].y; drawCross(x, y, LV_COLOR_WHITE.full); } else { // end calibration - str = calibration_stage == CALIBRATION_SUCCESS ? GET_TEXT(MSG_CALIBRATION_COMPLETED) : GET_TEXT(MSG_CALIBRATION_FAILED); + str = stage == CALIBRATION_SUCCESS ? GET_TEXT(MSG_CALIBRATION_COMPLETED) : GET_TEXT(MSG_CALIBRATION_FAILED); touch_calibration.calibration_end(); 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_TC_RETURN); } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp index 6a8333fd66df..b510e3c0c6f3 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp @@ -647,8 +647,8 @@ char *creat_title_text() { char *cur_name = strrchr(list_file.file_name[sel_id], '/'); - SdFile file; - SdFile *curDir; + MediaFile file; + MediaFile *curDir; const char * const fname = card.diveToFile(false, curDir, cur_name); if (!fname) return; if (file.open(curDir, fname, O_READ)) { diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.h b/Marlin/src/lcd/extui/mks_ui/draw_ui.h index 798e662220ef..9bc583d3ad32 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.h @@ -236,9 +236,9 @@ typedef struct UI_Config_Struct { eStepMax = 10; // Extruder speed (mm/s) uint8_t extruSpeed; - static constexpr uint8_t eSpeedH = 1, + static constexpr uint8_t eSpeedH = 20, eSpeedN = 10, - eSpeedL = 20; + eSpeedL = 1; uint8_t print_state; uint8_t stepPrintSpeed; uint8_t waitEndMoves; diff --git a/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp b/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp index 00bb9833fc72..0c6315d43870 100644 --- a/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp +++ b/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp @@ -727,7 +727,7 @@ void disp_assets_update_progress(FSTR_P const fmsg) { uint8_t mks_test_flag = 0; const char *MKSTestPath = "MKS_TEST"; void mks_test_get() { - SdFile dir, root = card.getroot(); + MediaFile dir, root = card.getroot(); if (dir.open(&root, MKSTestPath, O_RDONLY)) mks_test_flag = 0x1E; } diff --git a/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp b/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp index c618127980bb..d642d81f6baa 100644 --- a/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp +++ b/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp @@ -403,8 +403,8 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) { #define ASSET_TYPE_TITLE_LOGO 2 #define ASSET_TYPE_G_PREVIEW 3 #define ASSET_TYPE_FONT 4 - static void loadAsset(SdFile &dir, dir_t& entry, FSTR_P const fn, int8_t assetType) { - SdFile file; + static void loadAsset(MediaFile &dir, dir_t& entry, FSTR_P const fn, int8_t assetType) { + MediaFile file; char dosFilename[FILENAME_LENGTH]; createFilename(dosFilename, entry); if (!file.open(&dir, dosFilename, O_READ)) { @@ -488,7 +488,7 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) { void UpdateAssets() { if (!card.isMounted()) return; - SdFile dir, root = card.getroot(); + MediaFile dir, root = card.getroot(); if (dir.open(&root, assetsPath, O_RDONLY)) { disp_assets_update(); 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..9a8996330365 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp +++ b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp @@ -38,7 +38,7 @@ #include "../../../MarlinCore.h" #include "../../../inc/MarlinConfig.h" -#include HAL_PATH(../../../HAL, tft/xpt2046.h) +#include HAL_PATH(../../.., tft/xpt2046.h) #include "../../marlinui.h" XPT2046 touch; @@ -137,7 +137,10 @@ void tft_lvgl_init() { uint16_t usb_flash_loop = 1000; #if ENABLED(MULTI_VOLUME) && !HAS_SD_HOST_DRIVE SET_INPUT_PULLUP(SD_DETECT_PIN); - card.changeMedia(IS_SD_INSERTED() ? &card.media_driver_sdcard : &card.media_driver_usbFlash); + if (IS_SD_INSERTED()) + card.changeMedia(&card.media_driver_sdcard); + else + card.changeMedia(&card.media_driver_usbFlash); #endif do { card.media_driver_usbFlash.idle(); @@ -482,18 +485,19 @@ 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 } #if 1 // HAS_ENCODER_ACTION + void lv_update_encoder() { static uint32_t encoder_time1; uint32_t tmpTime, diffTime = 0; @@ -554,7 +558,7 @@ void lv_encoder_pin_init() { #endif // HAS_ENCODER_WHEEL - } // next_button_update_ms + } // encoder_time1 } #endif // HAS_ENCODER_ACTION diff --git a/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp index 6607e7531f0e..0e55b3448ba1 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp @@ -53,42 +53,45 @@ void WifiSerial::init(PinName _rx, PinName _tx) { WifiSerial::WifiSerial(void *peripheral) { // If PIN_SERIALy_RX is not defined assume half-duplex _serial.pin_rx = NC; + if (false) { + // for else if / else below... + } // If Serial is defined in variant set // the Rx/Tx pins for com port if defined #if defined(Serial) && defined(PIN_SERIAL_TX) - if ((void *)this == (void *)&Serial) { + else if ((void *)this == (void *)&Serial) { #ifdef PIN_SERIAL_RX setRx(PIN_SERIAL_RX); #endif setTx(PIN_SERIAL_TX); - } else + } #endif #if defined(PIN_SERIAL1_TX) && defined(USART1_BASE) - if (peripheral == USART1) { + else if (peripheral == USART1) { #ifdef PIN_SERIAL1_RX setRx(PIN_SERIAL1_RX); #endif setTx(PIN_SERIAL1_TX); - } else + } #endif #if defined(PIN_SERIAL2_TX) && defined(USART2_BASE) - if (peripheral == USART2) { + else if (peripheral == USART2) { #ifdef PIN_SERIAL2_RX setRx(PIN_SERIAL2_RX); #endif setTx(PIN_SERIAL2_TX); - } else + } #endif #if defined(PIN_SERIAL3_TX) && defined(USART3_BASE) - if (peripheral == USART3) { + else if (peripheral == USART3) { #ifdef PIN_SERIAL3_RX setRx(PIN_SERIAL3_RX); #endif setTx(PIN_SERIAL3_TX); - } else + } #endif #ifdef PIN_SERIAL4_TX - if (false + else if (false #ifdef USART4_BASE || peripheral == USART4 #elif defined(UART4_BASE) @@ -99,10 +102,10 @@ WifiSerial::WifiSerial(void *peripheral) { setRx(PIN_SERIAL4_RX); #endif setTx(PIN_SERIAL4_TX); - } else + } #endif #ifdef PIN_SERIAL5_TX - if (false + else if (false #ifdef USART5_BASE || peripheral == USART5 #elif defined(UART5_BASE) @@ -113,18 +116,18 @@ WifiSerial::WifiSerial(void *peripheral) { setRx(PIN_SERIAL5_RX); #endif setTx(PIN_SERIAL5_TX); - } else + } #endif #if defined(PIN_SERIAL6_TX) && defined(USART6_BASE) - if (peripheral == USART6) { + else if (peripheral == USART6) { #ifdef PIN_SERIAL6_RX setRx(PIN_SERIAL6_RX); #endif setTx(PIN_SERIAL6_TX); - } else + } #endif #ifdef PIN_SERIAL7_TX - if (false + else if (false #ifdef USART7_BASE || peripheral == USART7 #elif defined(UART7_BASE) @@ -135,10 +138,10 @@ WifiSerial::WifiSerial(void *peripheral) { setRx(PIN_SERIAL7_RX); #endif setTx(PIN_SERIAL7_TX); - } else + } #endif #ifdef PIN_SERIAL8_TX - if (false + else if (false #ifdef USART8_BASE || peripheral == USART8 #elif defined(UART8_BASE) @@ -149,18 +152,18 @@ WifiSerial::WifiSerial(void *peripheral) { setRx(PIN_SERIAL8_RX); #endif setTx(PIN_SERIAL8_TX); - } else + } #endif #if defined(PIN_SERIAL9_TX) && defined(UART9_BASE) - if (peripheral == UART9) { + else if (peripheral == UART9) { #ifdef PIN_SERIAL9_RX setRx(PIN_SERIAL9_RX); #endif setTx(PIN_SERIAL9_TX); - } else + } #endif #ifdef PIN_SERIAL10_TX - if (false + else if (false #ifdef USART10_BASE || peripheral == USART10 #elif defined(UART10_BASE) @@ -171,18 +174,18 @@ WifiSerial::WifiSerial(void *peripheral) { setRx(PIN_SERIAL10_RX); #endif setTx(PIN_SERIAL10_TX); - } else + } #endif #if defined(PIN_SERIALLP1_TX) && defined(LPUART1_BASE) - if (peripheral == LPUART1) { + else if (peripheral == LPUART1) { #ifdef PIN_SERIALLP1_RX setRx(PIN_SERIALLP1_RX); #endif setTx(PIN_SERIALLP1_TX); - } else + } #endif // else get the pins of the first peripheral occurrence in PinMap - { + else { _serial.pin_rx = pinmap_pin(peripheral, PinMap_UART_RX); _serial.pin_tx = pinmap_pin(peripheral, PinMap_UART_TX); } diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp index 73a76323fd2b..a8d30b442a9b 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp @@ -736,7 +736,7 @@ int32_t lastFragment = 0; char saveFilePath[50]; -static SdFile upload_file, *upload_curDir; +static MediaFile upload_file, *upload_curDir; static filepos_t pos; int write_to_file(char *buf, int len) { @@ -974,8 +974,8 @@ static void wifi_gcode_exec(uint8_t *cmd_line) { if (!gcode_preview_over) { char *cur_name = strrchr(list_file.file_name[sel_id], '/'); - SdFile file; - SdFile *curDir; + MediaFile file; + MediaFile *curDir; card.abortFilePrintNow(); const char * const fname = card.diveToFile(false, curDir, cur_name); if (!fname) return; @@ -1595,7 +1595,7 @@ static void file_fragment_msg_handle(uint8_t * msg, uint16_t msgLen) { } } upload_file.close(); - SdFile file, *curDir; + MediaFile file, *curDir; const char * const fname = card.diveToFile(false, curDir, saveFilePath); if (file.open(curDir, fname, O_RDWR)) { gCfgItems.curFilesize = file.fileSize(); @@ -1638,7 +1638,7 @@ void esp_data_parser(char *cmdRxBuf, int len) { esp_msg_index += cpyLen; - leftLen = leftLen - cpyLen; + leftLen -= cpyLen; tail_pos = charAtArray(esp_msg_buf, esp_msg_index, ESP_PROTOC_TAIL); if (tail_pos == -1) { @@ -1969,7 +1969,7 @@ void mks_wifi_firmware_update() { if (wifi_upload(0) >= 0) { card.removeFile((char *)ESP_FIRMWARE_FILE_RENAME); - SdFile file, *curDir; + MediaFile file, *curDir; const char * const fname = card.diveToFile(false, curDir, ESP_FIRMWARE_FILE); if (file.open(curDir, fname, O_READ)) { file.rename(curDir, (char *)ESP_FIRMWARE_FILE_RENAME); diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp b/Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp index c07cc47a3689..18a311303ccf 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp @@ -86,7 +86,7 @@ static const uint32_t defaultTimeout = 500; static const uint32_t eraseTimeout = 15000; static const uint32_t blockWriteTimeout = 200; static const uint32_t blockWriteInterval = 15; // 15ms is long enough, 10ms is mostly too short -static SdFile update_file, *update_curDir; +static MediaFile update_file, *update_curDir; // Messages corresponding to result codes, should make sense when followed by " error" const char *resultMessages[] = { 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 68b0a81fe514..576fc56b7863 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -169,7 +169,7 @@ namespace ExtUI { } void yield() { - if (!flags.printer_killed) thermalManager.manage_heater(); + if (!flags.printer_killed) thermalManager.task(); } void enableHeater(const extruder_t extruder) { @@ -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 @@ -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 @@ -843,11 +843,13 @@ namespace ExtUI { #endif // BABYSTEPPING float getZOffset_mm() { - return (0.0f + return ( #if HAS_BED_PROBE - + probe.offset.z + probe.offset.z #elif ENABLED(BABYSTEP_DISPLAY_TOTAL) - + planner.mm_per_step[Z_AXIS] * babystep.axis_total[BS_AXIS_IND(Z_AXIS)] + planner.mm_per_step[Z_AXIS] * babystep.axis_total[BS_AXIS_IND(Z_AXIS)] + #else + 0.0f #endif ); } @@ -976,32 +978,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) { @@ -1076,7 +1072,7 @@ namespace ExtUI { void coolDown() { thermalManager.cooldown(); } bool awaitingUserConfirm() { - return TERN0(HAS_RESUME_CONTINUE, wait_for_user) || getHostKeepaliveIsPaused(); + return TERN0(HAS_RESUME_CONTINUE, wait_for_user) || TERN0(HOST_KEEPALIVE_FEATURE, getHostKeepaliveIsPaused()); } void setUserConfirmed() { TERN_(HAS_RESUME_CONTINUE, wait_for_user = false); } diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 84555187677a..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(); @@ -324,18 +327,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/fontutils.cpp b/Marlin/src/lcd/fontutils.cpp index a97e63ac4d3a..46329fd4be62 100644 --- a/Marlin/src/lcd/fontutils.cpp +++ b/Marlin/src/lcd/fontutils.cpp @@ -31,8 +31,6 @@ #include "../inc/MarlinConfig.h" -#define MAX_UTF8_CHAR_SIZE 4 - #if HAS_WIRED_LCD #include "marlinui.h" #include "../MarlinCore.h" @@ -99,7 +97,7 @@ static inline bool utf8_is_start_byte_of_char(const uint8_t b) { /* This function gets the character at the pstart position, interpreting UTF8 multibyte sequences and returns the pointer to the next character */ -const uint8_t* get_utf8_value_cb(const uint8_t *pstart, read_byte_cb_t cb_read_byte, wchar_t *pval) { +const uint8_t* get_utf8_value_cb(const uint8_t *pstart, read_byte_cb_t cb_read_byte, lchar_t &pval) { uint32_t val = 0; const uint8_t *p = pstart; @@ -158,7 +156,7 @@ const uint8_t* get_utf8_value_cb(const uint8_t *pstart, read_byte_cb_t cb_read_b else for (; 0xFC < (0xFE & valcur); ) { p++; valcur = cb_read_byte(p); } - if (pval) *pval = val; + pval = val; return p; } diff --git a/Marlin/src/lcd/fontutils.h b/Marlin/src/lcd/fontutils.h index e01962d7ad80..69edf1a0c839 100644 --- a/Marlin/src/lcd/fontutils.h +++ b/Marlin/src/lcd/fontutils.h @@ -31,36 +31,41 @@ #pragma once #include -#include // wchar_t #include // uint32_t #include "../HAL/shared/Marduino.h" #include "../core/macros.h" +#define MAX_UTF8_CHAR_SIZE 4 + +// Use a longer character type (if needed) because wchar_t is only 16 bits wide +#ifdef MAX_UTF8_CHAR_SIZE + #if MAX_UTF8_CHAR_SIZE > 2 + typedef uint32_t lchar_t; + #else + typedef wchar_t lchar_t; + #endif +#else + #define wchar_t uint32_t +#endif + // read a byte from ROM or RAM typedef uint8_t (*read_byte_cb_t)(const uint8_t * str); uint8_t read_byte_ram(const uint8_t *str); uint8_t read_byte_rom(const uint8_t *str); -// there's overflow of the wchar_t due to the 2-byte size in Arduino -// sizeof(wchar_t)=2; sizeof(size_t)=2; sizeof(uint32_t)=4; -// sizeof(int)=2; sizeof(long)=4; sizeof(unsigned)=2; -//#undef wchar_t -#define wchar_t uint32_t -//typedef uint32_t wchar_t; - typedef uint16_t pixel_len_t; #define PIXEL_LEN_NOLIMIT ((pixel_len_t)(-1)) /* Perform binary search */ -typedef int (* pf_bsearch_cb_comp_t)(void *userdata, size_t idx, void * data_pin); /*"data_list[idx] - *data_pin"*/ +typedef int (* pf_bsearch_cb_comp_t)(void *userdata, size_t idx, void * data_pin); int pf_bsearch_r(void *userdata, size_t num_data, pf_bsearch_cb_comp_t cb_comp, void *data_pinpoint, size_t *ret_idx); /* Get the character, decoding multibyte UTF8 characters and returning a pointer to the start of the next UTF8 character */ -const uint8_t* get_utf8_value_cb(const uint8_t *pstart, read_byte_cb_t cb_read_byte, wchar_t *pval); +const uint8_t* get_utf8_value_cb(const uint8_t *pstart, read_byte_cb_t cb_read_byte, lchar_t &pval); -inline const char* get_utf8_value_cb(const char *pstart, read_byte_cb_t cb_read_byte, wchar_t *pval) { +inline const char* get_utf8_value_cb(const char *pstart, read_byte_cb_t cb_read_byte, lchar_t &pval) { return (const char *)get_utf8_value_cb((const uint8_t *)pstart, cb_read_byte, pval); } diff --git a/Marlin/src/lcd/language/language_an.h b/Marlin/src/lcd/language/language_an.h index 98f3d4ed97e1..1d4801278ce2 100644 --- a/Marlin/src/lcd/language/language_an.h +++ b/Marlin/src/lcd/language/language_an.h @@ -83,12 +83,14 @@ namespace Language_an { LSTR MSG_MOVE_X = _UxGT("Mover X"); LSTR MSG_MOVE_Y = _UxGT("Mover Y"); LSTR MSG_MOVE_Z = _UxGT("Mover Z"); + LSTR MSG_MOVE_N = _UxGT("Mover @"); LSTR MSG_MOVE_E = _UxGT("Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Extrusor *"); LSTR MSG_MOVE_N_MM = _UxGT("Mover $mm"); 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"); @@ -101,7 +103,6 @@ namespace Language_an { LSTR MSG_FLOW_N = _UxGT("Fluxo ~"); LSTR MSG_CONTROL = _UxGT("Control"); LSTR MSG_AUTOTEMP = _UxGT("Temperatura Auto."); - LSTR MSG_SELECT = _UxGT("Trigar"); LSTR MSG_SELECT_E = _UxGT("Trigar *"); LSTR MSG_ACC = _UxGT("Aceleracion"); LSTR MSG_VTRAV_MIN = _UxGT("Vel. viache min"); diff --git a/Marlin/src/lcd/language/language_bg.h b/Marlin/src/lcd/language/language_bg.h index 2596d62564e6..312ada7b10cd 100644 --- a/Marlin/src/lcd/language/language_bg.h +++ b/Marlin/src/lcd/language/language_bg.h @@ -72,12 +72,14 @@ namespace Language_bg { LSTR MSG_MOVE_X = _UxGT("Движение по X"); LSTR MSG_MOVE_Y = _UxGT("Движение по Y"); LSTR MSG_MOVE_Z = _UxGT("Движение по Z"); + LSTR MSG_MOVE_N = _UxGT("Движение по @"); LSTR MSG_MOVE_E = _UxGT("Екструдер"); LSTR MSG_MOVE_EN = _UxGT("Екструдер *"); LSTR MSG_MOVE_N_MM = _UxGT("Премести с $mm"); 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 fd46bcc28fc0..13b5d70837ad 100644 --- a/Marlin/src/lcd/language/language_ca.h +++ b/Marlin/src/lcd/language/language_ca.h @@ -83,12 +83,14 @@ namespace Language_ca { LSTR MSG_MOVE_X = _UxGT("Mou X"); LSTR MSG_MOVE_Y = _UxGT("Mou Y"); LSTR MSG_MOVE_Z = _UxGT("Mou Z"); + LSTR MSG_MOVE_N = _UxGT("Mou @"); LSTR MSG_MOVE_E = _UxGT("Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Extrusor *"); LSTR MSG_MOVE_N_MM = _UxGT("Mou $mm"); 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"); @@ -149,7 +151,7 @@ namespace Language_ca { LSTR MSG_CHANGE_MEDIA = _UxGT("Canvia SD"); LSTR MSG_ZPROBE_OUT = _UxGT("Sonda Z fora"); LSTR MSG_BLTOUCH_RESET = _UxGT("Reinicia BLTouch"); - LSTR MSG_HOME_FIRST = _UxGT("Home %s%s%s primer"); + LSTR MSG_HOME_FIRST = _UxGT("Home %s primer"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Decalatge Z"); LSTR MSG_BABYSTEP_X = _UxGT("Micropas X"); LSTR MSG_BABYSTEP_Y = _UxGT("Micropas Y"); diff --git a/Marlin/src/lcd/language/language_cz.h b/Marlin/src/lcd/language/language_cz.h index d78b43f9a9e0..bb930eb7846c 100644 --- a/Marlin/src/lcd/language/language_cz.h +++ b/Marlin/src/lcd/language/language_cz.h @@ -232,6 +232,7 @@ namespace Language_cz { LSTR MSG_MOVE_X = _UxGT("Posunout X"); LSTR MSG_MOVE_Y = _UxGT("Posunout Y"); LSTR MSG_MOVE_Z = _UxGT("Posunout Z"); + LSTR MSG_MOVE_N = _UxGT("Posunout @"); LSTR MSG_MOVE_E = _UxGT("Extrudér"); LSTR MSG_MOVE_EN = _UxGT("Extrudér *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hotend je studený"); @@ -239,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."); @@ -262,7 +264,6 @@ namespace Language_cz { LSTR MSG_LCD_OFF = _UxGT("Vyp"); LSTR MSG_PID_AUTOTUNE = _UxGT("PID automatika"); LSTR MSG_PID_AUTOTUNE_E = _UxGT("PID automatika *"); - LSTR MSG_SELECT = _UxGT("Vybrat"); LSTR MSG_SELECT_E = _UxGT("Vybrat *"); LSTR MSG_ACC = _UxGT("Zrychl"); LSTR MSG_JERK = _UxGT("Jerk"); @@ -394,7 +395,7 @@ namespace Language_cz { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("vysunout TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Vysunout Z-sondu"); LSTR MSG_MANUAL_STOW = _UxGT("Zasunout Z-sondu"); - LSTR MSG_HOME_FIRST = _UxGT("Domů %s%s%s první"); + LSTR MSG_HOME_FIRST = _UxGT("Domů %s první"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Z ofset"); LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); @@ -432,8 +433,6 @@ namespace Language_cz { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Kalibrovat Střed"); LSTR MSG_DELTA_SETTINGS = _UxGT("Delta nastavení"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Autokalibrace"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Nast.výšku delty"); - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Nast. Z-ofset"); LSTR MSG_DELTA_DIAG_ROD = _UxGT("Diag rameno"); LSTR MSG_DELTA_HEIGHT = _UxGT("Výška"); LSTR MSG_DELTA_RADIUS = _UxGT("Poloměr"); diff --git a/Marlin/src/lcd/language/language_da.h b/Marlin/src/lcd/language/language_da.h index 05474744d0ac..56c53b84fd51 100644 --- a/Marlin/src/lcd/language/language_da.h +++ b/Marlin/src/lcd/language/language_da.h @@ -74,10 +74,14 @@ namespace Language_da { LSTR MSG_MOVE_X = _UxGT("Flyt X"); LSTR MSG_MOVE_Y = _UxGT("Flyt Y"); LSTR MSG_MOVE_Z = _UxGT("Flyt Z"); + LSTR MSG_MOVE_N = _UxGT("Flyt @"); + LSTR MSG_MOVE_E = _UxGT("Flyt E"); + LSTR MSG_MOVE_EN = _UxGT("Flyt *"); LSTR MSG_MOVE_N_MM = _UxGT("Flyt $mm"); 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"); @@ -94,7 +98,6 @@ namespace Language_da { LSTR MSG_AUTOTEMP = _UxGT("Autotemp"); LSTR MSG_LCD_ON = _UxGT("Til"); LSTR MSG_LCD_OFF = _UxGT("Fra"); - LSTR MSG_SELECT = _UxGT("Vælg"); LSTR MSG_SELECT_E = _UxGT("Vælg *"); LSTR MSG_A_RETRACT = _UxGT("A-retract"); LSTR MSG_A_TRAVEL = _UxGT("A-rejse"); @@ -135,7 +138,7 @@ namespace Language_da { LSTR MSG_CHANGE_MEDIA = _UxGT("Skift SD kort"); LSTR MSG_ZPROBE_OUT = _UxGT("Probe udenfor plade"); LSTR MSG_BLTOUCH_SELFTEST = _UxGT("BLTouch Selv-Test"); - LSTR MSG_HOME_FIRST = _UxGT("Home %s%s%s først"); + LSTR MSG_HOME_FIRST = _UxGT("Home %s først"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Opvarmning fejlet"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("Fejl: reserve temp"); LSTR MSG_THERMAL_RUNAWAY = _UxGT("Temp løber løbsk"); diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index 2b22319361aa..09b979b5f78b 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -37,7 +37,10 @@ namespace Language_de { LSTR WELCOME_MSG = MACHINE_NAME _UxGT(" bereit"); LSTR MSG_YES = _UxGT("JA"); LSTR MSG_NO = _UxGT("NEIN"); + LSTR MSG_HIGH = _UxGT("HOCH"); + LSTR MSG_LOW = _UxGT("RUNTER"); LSTR MSG_BACK = _UxGT("Zurück"); + LSTR MSG_ERROR = _UxGT("Fehler"); LSTR MSG_MEDIA_ABORTING = _UxGT("Abbruch..."); LSTR MSG_MEDIA_INSERTED = _UxGT("Medium erkannt"); LSTR MSG_MEDIA_REMOVED = _UxGT("Medium entfernt"); @@ -51,6 +54,8 @@ namespace Language_de { LSTR MSG_LCD_SOFT_ENDSTOPS = _UxGT("Software-Endstopp"); LSTR MSG_MAIN = _UxGT("Hauptmenü"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Erw. Einstellungen"); + LSTR MSG_TOOLBAR_SETUP = _UxGT("Toolbar Einstellung"); + LSTR MSG_OPTION_DISABLED = _UxGT("Option Deaktiviert"); LSTR MSG_CONFIGURATION = _UxGT("Konfiguration"); LSTR MSG_RUN_AUTO_FILES = _UxGT("Autostart"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Motoren deaktivieren"); // M84 :: Max length 19 characters @@ -64,6 +69,7 @@ namespace Language_de { LSTR MSG_AUTO_HOME_Z = _UxGT("Home Z"); LSTR MSG_FILAMENT_SET = _UxGT("Fila. Einstellungen"); LSTR MSG_FILAMENT_MAN = _UxGT("Filament Management"); + LSTR MSG_MANUAL_LEVELING = _UxGT("Manuell Nivellierung"); LSTR MSG_LEVBED_FL = _UxGT("Vorne Links"); LSTR MSG_LEVBED_FR = _UxGT("Vorne Rechts"); LSTR MSG_LEVBED_C = _UxGT("Mitte"); @@ -96,7 +102,14 @@ namespace Language_de { LSTR MSG_PREHEAT_1_ALL = PREHEAT_1_LABEL _UxGT(" Alles Vorwärmen"); LSTR MSG_PREHEAT_1_BEDONLY = PREHEAT_1_LABEL _UxGT(" Bett Vorwärmen"); LSTR MSG_PREHEAT_1_SETTINGS = PREHEAT_1_LABEL _UxGT(" Einstellungen"); - + #ifdef PREHEAT_2_LABEL + LSTR MSG_PREHEAT_2 = PREHEAT_2_LABEL _UxGT(" Vorwärmen"); + LSTR MSG_PREHEAT_2_SETTINGS = PREHEAT_2_LABEL _UxGT(" Vorwärmen Konf"); + #endif + #ifdef PREHEAT_3_LABEL + LSTR MSG_PREHEAT_3 = PREHEAT_3_LABEL _UxGT(" Vorwärmen"); + LSTR MSG_PREHEAT_3_SETTINGS = PREHEAT_3_LABEL _UxGT(" Vorwärmen Konf"); + #endif LSTR MSG_PREHEAT_M = _UxGT("$ Vorwärmen"); LSTR MSG_PREHEAT_M_H = _UxGT("$ Vorwärmen") " ~"; LSTR MSG_PREHEAT_M_END = _UxGT("$ Extr. Vorwärmen"); @@ -143,10 +156,19 @@ namespace Language_de { LSTR MSG_MESH_VIEW = _UxGT("Netz ansehen"); LSTR MSG_EDITING_STOPPED = _UxGT("Netzbearb. angeh."); LSTR MSG_NO_VALID_MESH = _UxGT("Kein gültiges Netz"); + LSTR MSG_ACTIVATE_MESH = _UxGT("Nivellierung aktiv."); LSTR MSG_PROBING_POINT = _UxGT("Messpunkt"); LSTR MSG_MESH_X = _UxGT("Index X"); LSTR MSG_MESH_Y = _UxGT("Index Y"); + LSTR MSG_MESH_INSET = _UxGT("Mesh-Einsatz"); + LSTR MSG_MESH_MIN_X = _UxGT("Mesh X Minimum"); + LSTR MSG_MESH_MAX_X = _UxGT("Mesh X Maximum"); + LSTR MSG_MESH_MIN_Y = _UxGT("Mesh Y Minimum"); + LSTR MSG_MESH_MAX_Y = _UxGT("Mesh Y Maximum"); + LSTR MSG_MESH_AMAX = _UxGT("Bereich maximieren"); + LSTR MSG_MESH_CENTER = _UxGT("Center Area"); LSTR MSG_MESH_EDIT_Z = _UxGT("Z-Wert"); + LSTR MSG_MESH_CANCEL = _UxGT("Mesh abgebrochen"); LSTR MSG_CUSTOM_COMMANDS = _UxGT("Benutzer-Menü"); LSTR MSG_M48_TEST = _UxGT("M48 Sondentest"); LSTR MSG_M48_POINT = _UxGT("M48 Punkt"); @@ -165,6 +187,9 @@ namespace Language_de { LSTR MSG_UBL_TOOLS = _UxGT("UBL-Werkzeuge"); LSTR MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling"); LSTR MSG_LCD_TILTING_MESH = _UxGT("Berührungspunkt"); + LSTR MSG_UBL_TILT_MESH = _UxGT("Tilt Mesh"); + LSTR MSG_UBL_TILTING_GRID = _UxGT("Tilting Grid Size"); + LSTR MSG_UBL_MESH_TILTED = _UxGT("Mesh Tilted"); LSTR MSG_UBL_MANUAL_MESH = _UxGT("Netz manuell erst."); LSTR MSG_UBL_MESH_WIZARD = _UxGT("UBL Netz Assistent"); LSTR MSG_UBL_BC_INSERT = _UxGT("Unterlegen & messen"); @@ -183,14 +208,12 @@ namespace Language_de { LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("Bearbeitung beendet"); LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Eigenes Netz erst."); LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("Netz erstellen"); - #if HAS_PREHEAT - LSTR MSG_UBL_BUILD_MESH_M = _UxGT("$ Netz erstellen"); - LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("$ Netz validieren"); - #endif + LSTR MSG_UBL_BUILD_MESH_M = _UxGT("$ Netz erstellen"); LSTR MSG_UBL_BUILD_COLD_MESH = _UxGT("Netz erstellen kalt"); LSTR MSG_UBL_MESH_HEIGHT_ADJUST = _UxGT("Netzhöhe einst."); LSTR MSG_UBL_MESH_HEIGHT_AMOUNT = _UxGT("Höhe"); LSTR MSG_UBL_VALIDATE_MESH_MENU = _UxGT("Netz validieren"); + LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("$ Netz validieren"); LSTR MSG_UBL_VALIDATE_CUSTOM_MESH = _UxGT("Eig. Netz validieren"); LSTR MSG_G26_HEATING_BED = _UxGT("G26 heizt Bett"); LSTR MSG_G26_HEATING_NOZZLE = _UxGT("G26 Düse aufheizen"); @@ -215,6 +238,8 @@ namespace Language_de { LSTR MSG_UBL_MANUAL_FILLIN = _UxGT("Manuelles Füllen"); LSTR MSG_UBL_SMART_FILLIN = _UxGT("Cleveres Füllen"); LSTR MSG_UBL_FILLIN_MESH = _UxGT("Netz Füllen"); + LSTR MSG_UBL_MESH_FILLED = _UxGT("Fehlende Punkte erg."); + LSTR MSG_UBL_MESH_INVALID = _UxGT("Ungültiges Netz"); LSTR MSG_UBL_INVALIDATE_ALL = _UxGT("Alles annullieren"); LSTR MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Nächstlieg. ann."); LSTR MSG_UBL_FINE_TUNE_ALL = _UxGT("Feineinst. Alles"); @@ -223,6 +248,7 @@ namespace Language_de { LSTR MSG_UBL_STORAGE_SLOT = _UxGT("Speicherort"); LSTR MSG_UBL_LOAD_MESH = _UxGT("Bettnetz laden"); LSTR MSG_UBL_SAVE_MESH = _UxGT("Bettnetz speichern"); + LSTR MSG_UBL_INVALID_SLOT = _UxGT("Wähle einen Mesh-Slot"); LSTR MSG_MESH_LOADED = _UxGT("Netz %i geladen"); LSTR MSG_MESH_SAVED = _UxGT("Netz %i gespeichert"); LSTR MSG_UBL_NO_STORAGE = _UxGT("Kein Speicher"); @@ -231,12 +257,12 @@ namespace Language_de { LSTR MSG_UBL_Z_OFFSET = _UxGT("Z-Versatz: "); LSTR MSG_UBL_Z_OFFSET_STOPPED = _UxGT("Z-Versatz angehalten"); LSTR MSG_UBL_STEP_BY_STEP_MENU = _UxGT("Schrittweises UBL"); - LSTR MSG_UBL_1_BUILD_COLD_MESH = _UxGT("1.Netz erstellen kalt"); - LSTR MSG_UBL_2_SMART_FILLIN = _UxGT("2.Cleveres Füllen"); + LSTR MSG_UBL_1_BUILD_COLD_MESH = _UxGT("1.Netz kalt erstellen"); + LSTR MSG_UBL_2_SMART_FILLIN = _UxGT("2.Intelligent Füllen"); LSTR MSG_UBL_3_VALIDATE_MESH_MENU = _UxGT("3.Netz validieren"); - LSTR MSG_UBL_4_FINE_TUNE_ALL = _UxGT("4.Feineinst. Alles"); + LSTR MSG_UBL_4_FINE_TUNE_ALL = _UxGT("4.Alles Feineinst."); LSTR MSG_UBL_5_VALIDATE_MESH_MENU = _UxGT("5.Netz validieren"); - LSTR MSG_UBL_6_FINE_TUNE_ALL = _UxGT("6.Feineinst. Alles"); + LSTR MSG_UBL_6_FINE_TUNE_ALL = _UxGT("6.Alles Feineinst."); LSTR MSG_UBL_7_SAVE_MESH = _UxGT("7.Bettnetz speichern"); LSTR MSG_LED_CONTROL = _UxGT("Licht-Steuerung"); @@ -275,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"); @@ -315,7 +342,11 @@ namespace Language_de { LSTR MSG_PID_AUTOTUNE_E = _UxGT("PID Autotune *"); LSTR MSG_PID_CYCLE = _UxGT("PID Zyklus"); LSTR MSG_PID_AUTOTUNE_DONE = _UxGT("PID Tuning fertig"); - LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Autotune fehlge.! Falscher Extruder"); + LSTR MSG_PID_AUTOTUNE_FAILED = _UxGT("PID Autotune fehlge.!"); + LSTR MSG_BAD_EXTRUDER_NUM = _UxGT("ungültiger Extruder."); + LSTR MSG_TEMP_TOO_HIGH = _UxGT("Temperatur zu hoch."); + LSTR MSG_TIMEOUT = _UxGT("Timeout."); + LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Autotune fehlge.! Ungültiger Extruder"); LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Autotune fehlge.! Temperatur zu hoch."); LSTR MSG_PID_TIMEOUT = _UxGT("Autotune fehlge.! Timeout."); LSTR MSG_MPC_MEASURING_AMBIENT = _UxGT("teste Wärmeverlust"); @@ -326,7 +357,6 @@ namespace Language_de { LSTR MSG_SENSOR_RESPONSIVENESS_E = _UxGT("Sensor res *"); LSTR MSG_MPC_AMBIENT_XFER_COEFF_E = _UxGT("Ambient h *"); LSTR MSG_MPC_AMBIENT_XFER_COEFF_FAN_E = _UxGT("Amb. h fan *"); - LSTR MSG_SELECT = _UxGT("Auswählen"); LSTR MSG_SELECT_E = _UxGT("Auswählen *"); LSTR MSG_ACC = _UxGT("Beschleunigung"); LSTR MSG_JERK = _UxGT("Jerk"); @@ -334,14 +364,14 @@ namespace Language_de { LSTR MSG_VB_JERK = _UxGT("Max ") STR_B _UxGT(" Jerk"); LSTR MSG_VC_JERK = _UxGT("Max ") STR_C _UxGT(" Jerk"); LSTR MSG_VN_JERK = _UxGT("Max @ Jerk"); - LSTR MSG_VE_JERK = _UxGT("Max E Jerk"); + LSTR MSG_VE_JERK = _UxGT("Max ") STR_E _UxGT(" Jerk"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Junction Dev"); LSTR MSG_MAX_SPEED = _UxGT("Max Geschw. (mm/s)"); LSTR MSG_VMAX_A = _UxGT("V max ") STR_A; LSTR MSG_VMAX_B = _UxGT("V max ") STR_B; LSTR MSG_VMAX_C = _UxGT("V max ") STR_C; LSTR MSG_VMAX_N = _UxGT("V max @"); - LSTR MSG_VMAX_E = _UxGT("V max E"); + LSTR MSG_VMAX_E = _UxGT("V max ") STR_E; LSTR MSG_VMAX_EN = _UxGT("V max *"); LSTR MSG_VMIN = _UxGT("V min "); LSTR MSG_VTRAV_MIN = _UxGT("V min Leerfahrt"); @@ -350,7 +380,7 @@ namespace Language_de { LSTR MSG_AMAX_B = _UxGT("A max ") STR_B; LSTR MSG_AMAX_C = _UxGT("A max ") STR_C; LSTR MSG_AMAX_N = _UxGT("A max @"); - LSTR MSG_AMAX_E = _UxGT("A max E"); + LSTR MSG_AMAX_E = _UxGT("A max ") STR_E; LSTR MSG_AMAX_EN = _UxGT("A max *"); LSTR MSG_A_RETRACT = _UxGT("A Einzug"); LSTR MSG_A_TRAVEL = _UxGT("A Leerfahrt"); @@ -377,20 +407,24 @@ 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"); LSTR MSG_LOAD_EEPROM = _UxGT("Konfig. laden"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Standardwerte laden"); LSTR MSG_INIT_EEPROM = _UxGT("Werkseinstellungen"); LSTR MSG_ERR_EEPROM_CRC = _UxGT("EEPROM CRC Fehler"); - LSTR MSG_ERR_EEPROM_INDEX = _UxGT("EEPROM Index Fehler"); + LSTR MSG_ERR_EEPROM_SIZE = _UxGT("EEPROM Größe Fehler"); LSTR MSG_ERR_EEPROM_VERSION = _UxGT("EEPROM Version Fehler"); LSTR MSG_SETTINGS_STORED = _UxGT("Einstell. gespei."); LSTR MSG_MEDIA_UPDATE = _UxGT("FW Update vom Medium"); LSTR MSG_RESET_PRINTER = _UxGT("Drucker neustarten"); LSTR MSG_REFRESH = LCD_STR_REFRESH _UxGT("Aktualisieren"); LSTR MSG_INFO_SCREEN = _UxGT("Info"); + LSTR MSG_INFO_MACHINENAME = _UxGT("Machine Name"); + LSTR MSG_INFO_SIZE = _UxGT("Größe"); + LSTR MSG_INFO_FWVERSION = _UxGT("Firmware Version"); + LSTR MSG_INFO_BUILD = _UxGT("Build Datum"); LSTR MSG_PREPARE = _UxGT("Vorbereitung"); LSTR MSG_TUNE = _UxGT("Justierung"); LSTR MSG_POWER_MONITOR = _UxGT("Power Monitor"); @@ -417,6 +451,7 @@ namespace Language_de { LSTR MSG_BUTTON_RESUME = _UxGT("Fortsetzen"); LSTR MSG_BUTTON_ADVANCED = _UxGT("Erweitert"); LSTR MSG_BUTTON_SAVE = _UxGT("Speichern"); + LSTR MSG_BUTTON_PURGE = _UxGT("Reinigen"); LSTR MSG_PAUSING = _UxGT("Pause..."); LSTR MSG_PAUSE_PRINT = _UxGT("SD-Druck pausieren"); LSTR MSG_ADVANCED_PAUSE = _UxGT("Erweiterte Pause"); @@ -439,9 +474,12 @@ namespace Language_de { LSTR MSG_REMAINING_TIME = _UxGT("Verbleiben"); LSTR MSG_PRINT_ABORTED = _UxGT("Druck abgebrochen"); LSTR MSG_PRINT_DONE = _UxGT("Druck fertig"); + LSTR MSG_PRINTER_KILLED = _UxGT("Drucker killed!"); + LSTR MSG_TURN_OFF = _UxGT("Drucker ausschalten"); LSTR MSG_NO_MOVE = _UxGT("Motoren angeschaltet"); LSTR MSG_KILLED = _UxGT("ABGEBROCHEN"); LSTR MSG_STOPPED = _UxGT("ANGEHALTEN"); + LSTR MSG_FWRETRACT = _UxGT("Firmware Retract"); LSTR MSG_CONTROL_RETRACT = _UxGT("Einzug mm"); LSTR MSG_CONTROL_RETRACT_SWAP = _UxGT("Wechs. Einzug mm"); LSTR MSG_CONTROL_RETRACTF = _UxGT("V Einzug"); @@ -501,12 +539,15 @@ namespace Language_de { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("TouchMI ausfahren"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Z-Sonde ausfahren"); LSTR MSG_MANUAL_STOW = _UxGT("Z-Sonde einfahren"); - LSTR MSG_HOME_FIRST = _UxGT("Vorher %s%s%s homen"); + LSTR MSG_HOME_FIRST = _UxGT("Vorher %s homen"); LSTR MSG_ZPROBE_SETTINGS = _UxGT("Sondeneinstellungen"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Sondenversatz"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Sondenversatz X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Sondenversatz Y"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Sondenversatz Z"); + LSTR MSG_ZPROBE_MARGIN = _UxGT("Sondenrand"); + LSTR MSG_Z_FEED_RATE = _UxGT("Z-Vorschub"); + LSTR MSG_ENABLE_HS_MODE = _UxGT("HS-Modus aktivieren"); LSTR MSG_MOVE_NOZZLE_TO_BED = _UxGT("Bewege Düse zum Bett"); LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); @@ -544,8 +585,6 @@ namespace Language_de { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Kalibriere Mitte"); LSTR MSG_DELTA_SETTINGS = _UxGT("Delta Einst. anzeig."); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Autom. Kalibrierung"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Delta Höhe setzen"); - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Sondenversatz Z"); LSTR MSG_DELTA_DIAG_ROD = _UxGT("Diag Rod"); LSTR MSG_DELTA_HEIGHT = _UxGT("Höhe"); LSTR MSG_DELTA_RADIUS = _UxGT("Radius"); @@ -572,33 +611,37 @@ namespace Language_de { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Helligkeit"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Falscher Drucker"); + LSTR MSG_COLORS_GET = _UxGT("Farbe"); + LSTR MSG_COLORS_SELECT = _UxGT("Farben auswählen"); + LSTR MSG_COLORS_APPLIED = _UxGT("Farben verwenden"); + LSTR MSG_COLORS_RED = _UxGT("Rot"); + LSTR MSG_COLORS_GREEN = _UxGT("Grün"); + LSTR MSG_COLORS_BLUE = _UxGT("Blau"); + LSTR MSG_COLORS_WHITE = _UxGT("Weiß"); + LSTR MSG_UI_LANGUAGE = _UxGT("UI Sprache"); + LSTR MSG_SOUND_ENABLE = _UxGT("Ton aktivieren"); + LSTR MSG_LOCKSCREEN = _UxGT("Bildschirm sperren"); + LSTR MSG_LOCKSCREEN_LOCKED = _UxGT("Drucker ist gesperrt,"); + LSTR MSG_LOCKSCREEN_UNLOCK = _UxGT("Scrollen zum Entsper."); + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("Kein Medium eingelegt."); - LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Bitte auf Neustart warten. "); - LSTR MSG_PLEASE_PREHEAT = _UxGT("Bitte das Hot-End vorheizen."); + LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Bitte auf Neustart warten."); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Bitte das Hotend vorheizen."); LSTR MSG_INFO_PRINT_COUNT_RESET = _UxGT("Druckzähler zurücksetzen"); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Gesamte Drucke"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Komplette Drucke"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Gesamte Druckzeit"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Längste Druckzeit"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Gesamt Extrudiert"); - LSTR MSG_COLORS_GET = _UxGT("Farbe"); - LSTR MSG_COLORS_SELECT = _UxGT("Farben auswählen"); - LSTR MSG_COLORS_APPLIED = _UxGT("Farben verwenden"); - LSTR MSG_COLORS_RED = _UxGT("Rot"); - LSTR MSG_COLORS_GREEN = _UxGT("Grün"); - LSTR MSG_COLORS_BLUE = _UxGT("Blau"); - LSTR MSG_COLORS_WHITE = _UxGT("Weiß"); - LSTR MSG_UI_LANGUAGE = _UxGT("UI Sprache"); - LSTR MSG_SOUND_ENABLE = _UxGT("Ton aktivieren"); - LSTR MSG_LOCKSCREEN = _UxGT("Bildschirm sperren"); #else + LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Auf Neustart warten"); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Bitte vorheizen"); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Drucke"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Komplette"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Gesamte"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Längste"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Extrud."); - LSTR MSG_PLEASE_PREHEAT = _UxGT("Bitte vorheizen"); #endif LSTR MSG_INFO_MIN_TEMP = _UxGT("Min Temp"); @@ -615,10 +658,14 @@ namespace Language_de { LSTR MSG_FILAMENT_CHANGE_OPTION_HEADER = _UxGT("FORTS. OPTIONEN:"); LSTR MSG_FILAMENT_CHANGE_OPTION_PURGE = _UxGT("Mehr entladen"); LSTR MSG_FILAMENT_CHANGE_OPTION_RESUME = _UxGT("Druck weiter"); + LSTR MSG_FILAMENT_CHANGE_PURGE_CONTINUE = _UxGT("Löschen o. fortfah.?"); LSTR MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Düse: "); LSTR MSG_RUNOUT_SENSOR = _UxGT("Runout-Sensor"); LSTR MSG_RUNOUT_DISTANCE_MM = _UxGT("Runout-Weg mm"); LSTR MSG_RUNOUT_ENABLE = _UxGT("Runout aktivieren"); + LSTR MSG_RUNOUT_ACTIVE = _UxGT("Runout aktiv"); + LSTR MSG_INVERT_EXTRUDER = _UxGT("Invert Extruder"); + LSTR MSG_EXTRUDER_MIN_TEMP = _UxGT("Extruder Min Temp."); LSTR MSG_FANCHECK = _UxGT("Lüftergeschw. prüfen"); LSTR MSG_KILL_HOMING_FAILED = _UxGT("Homing gescheitert"); LSTR MSG_LCD_PROBING_FAILED = _UxGT("Probing gescheitert"); @@ -662,6 +709,7 @@ namespace Language_de { LSTR MSG_VTOOLS_RESET = _UxGT("V-Tools ist resetet"); LSTR MSG_START_Z = _UxGT("Z Start:"); LSTR MSG_END_Z = _UxGT("Z Ende:"); + LSTR MSG_GAMES = _UxGT("Spiele"); LSTR MSG_BRICKOUT = _UxGT("Brickout"); LSTR MSG_INVADERS = _UxGT("Invaders"); @@ -685,6 +733,7 @@ namespace Language_de { // // Die Filament-Change-Bildschirme können bis zu 3 Zeilen auf einem 4-Zeilen-Display anzeigen // ...oder 2 Zeilen auf einem 3-Zeilen-Display. + #if LCD_HEIGHT >= 4 LSTR MSG_ADVANCED_PAUSE_WAITING = _UxGT(MSG_2_LINE("Knopf drücken um", "Druck fortzusetzen")); LSTR MSG_PAUSE_PRINT_PARKING = _UxGT(MSG_2_LINE("Druck ist", "pausiert...")); @@ -722,10 +771,11 @@ namespace Language_de { LSTR MSG_BACKLASH = _UxGT("Spiel"); LSTR MSG_BACKLASH_CORRECTION = _UxGT("Korrektur"); LSTR MSG_BACKLASH_SMOOTHING = _UxGT("Glätten"); + LSTR MSG_LEVEL_X_AXIS = _UxGT("X Achse leveln"); LSTR MSG_AUTO_CALIBRATE = _UxGT("Auto. Kalibiren"); #if ENABLED(TOUCH_UI_FTDI_EVE) - LSTR MSG_HEATER_TIMEOUT = _UxGT("Idle Timeout, Temperatur fällt. Drücke Okay, um erneut aufzuheizen und fortzufahren."); + LSTR MSG_HEATER_TIMEOUT = _UxGT("Idle Timeout, Temperatur gefallen. Drücke Okay, um erneut aufzuheizen und fortzufahren."); #else LSTR MSG_HEATER_TIMEOUT = _UxGT("Heizungs Timeout"); #endif diff --git a/Marlin/src/lcd/language/language_el.h b/Marlin/src/lcd/language/language_el.h index 47d6a5b2da35..57af804147c5 100644 --- a/Marlin/src/lcd/language/language_el.h +++ b/Marlin/src/lcd/language/language_el.h @@ -92,12 +92,14 @@ namespace Language_el { LSTR MSG_MOVE_X = _UxGT("Μετακίνηση X"); LSTR MSG_MOVE_Y = _UxGT("Μετακίνηση Y"); LSTR MSG_MOVE_Z = _UxGT("Μετακίνηση Z"); + 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 μμ"); + 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 bd2e7d595d9a..08f647f705bb 100644 --- a/Marlin/src/lcd/language/language_el_gr.h +++ b/Marlin/src/lcd/language/language_el_gr.h @@ -81,12 +81,14 @@ namespace Language_el_gr { LSTR MSG_MOVE_X = _UxGT("Μετακίνηση X"); LSTR MSG_MOVE_Y = _UxGT("Μετακίνηση Y"); LSTR MSG_MOVE_Z = _UxGT("Μετακίνηση Z"); + 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 μμ"); + 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 81f30b61d8ef..8dab8fcdaec4 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -82,6 +82,7 @@ namespace Language_en { LSTR MSG_AUTO_HOME_X = _UxGT("Home X"); LSTR MSG_AUTO_HOME_Y = _UxGT("Home Y"); LSTR MSG_AUTO_HOME_Z = _UxGT("Home Z"); + LSTR MSG_Z_AFTER_HOME = _UxGT("Z After Homing"); LSTR MSG_FILAMENT_SET = _UxGT("Filament Settings"); LSTR MSG_FILAMENT_MAN = _UxGT("Filament Management"); LSTR MSG_MANUAL_LEVELING = _UxGT("Manual Leveling"); @@ -133,6 +134,7 @@ namespace Language_en { LSTR MSG_PREHEAT_M_BEDONLY = _UxGT("Preheat $ Bed"); LSTR MSG_PREHEAT_M_SETTINGS = _UxGT("Preheat $ Conf"); #endif + LSTR MSG_PREHEAT_HOTEND = _UxGT("Preheat Hotend"); LSTR MSG_PREHEAT_CUSTOM = _UxGT("Preheat Custom"); LSTR MSG_COOLDOWN = _UxGT("Cooldown"); @@ -254,6 +256,7 @@ namespace Language_en { LSTR MSG_UBL_SMART_FILLIN = _UxGT("Smart Fill-in"); LSTR MSG_UBL_FILLIN_MESH = _UxGT("Fill-in Mesh"); LSTR MSG_UBL_MESH_FILLED = _UxGT("Missing Points Filled"); + LSTR MSG_UBL_MESH_INVALID = _UxGT("Invalid Mesh"); LSTR MSG_UBL_INVALIDATE_ALL = _UxGT("Invalidate All"); LSTR MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Invalidate Closest"); LSTR MSG_UBL_FINE_TUNE_ALL = _UxGT("Fine Tune All"); @@ -265,6 +268,7 @@ namespace Language_en { LSTR MSG_UBL_INVALID_SLOT = _UxGT("First Select a Mesh Slot"); LSTR MSG_MESH_LOADED = _UxGT("Mesh %i Loaded"); LSTR MSG_MESH_SAVED = _UxGT("Mesh %i Saved"); + LSTR MSG_MESH_ACTIVE = _UxGT("Mesh %i active"); LSTR MSG_UBL_NO_STORAGE = _UxGT("No Storage"); LSTR MSG_UBL_SAVE_ERROR = _UxGT("Err: UBL Save"); LSTR MSG_UBL_RESTORE_ERROR = _UxGT("Err: UBL Restore"); @@ -309,17 +313,20 @@ namespace Language_en { LSTR MSG_MOVE_Z = _UxGT("Move Z"); LSTR MSG_MOVE_N = _UxGT("Move @"); LSTR MSG_MOVE_E = _UxGT("Move Extruder"); - LSTR MSG_MOVE_EN = _UxGT("Move E*"); + LSTR MSG_MOVE_EN = _UxGT("Move *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hotend too cold"); LSTR MSG_MOVE_N_MM = _UxGT("Move $mm"); 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_LIVE_MOVE = _UxGT("Live Move"); LSTR MSG_SPEED = _UxGT("Speed"); LSTR MSG_BED_Z = _UxGT("Bed Z"); LSTR MSG_NOZZLE = _UxGT("Nozzle"); @@ -331,6 +338,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 ~"); @@ -370,7 +378,6 @@ namespace Language_en { LSTR MSG_SENSOR_RESPONSIVENESS_E = _UxGT("Sensor res *"); LSTR MSG_MPC_AMBIENT_XFER_COEFF_E = _UxGT("Ambient h *"); LSTR MSG_MPC_AMBIENT_XFER_COEFF_FAN_E = _UxGT("Amb. h fan *"); - LSTR MSG_SELECT = _UxGT("Select"); LSTR MSG_SELECT_E = _UxGT("Select *"); LSTR MSG_ACC = _UxGT("Accel"); LSTR MSG_JERK = _UxGT("Jerk"); @@ -398,6 +405,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_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"); @@ -417,20 +429,26 @@ 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"); 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"); LSTR MSG_LOAD_EEPROM = _UxGT("Load Settings"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Restore Defaults"); LSTR MSG_INIT_EEPROM = _UxGT("Initialize EEPROM"); - LSTR MSG_ERR_EEPROM_CRC = _UxGT("EEPROM CRC Error"); - LSTR MSG_ERR_EEPROM_INDEX = _UxGT("EEPROM Index Error"); - LSTR MSG_ERR_EEPROM_VERSION = _UxGT("EEPROM Version Error"); + LSTR MSG_ERR_EEPROM_CRC = _UxGT("Err: EEPROM CRC"); + LSTR MSG_ERR_EEPROM_SIZE = _UxGT("Err: EEPROM Size"); + LSTR MSG_ERR_EEPROM_VERSION = _UxGT("Err: EEPROM Version"); + LSTR MSG_ERR_EEPROM_CORRUPT = _UxGT("Err: EEPROM Corrupt"); LSTR MSG_SETTINGS_STORED = _UxGT("Settings Stored"); LSTR MSG_MEDIA_UPDATE = MEDIA_TYPE_EN _UxGT(" Update"); LSTR MSG_RESET_PRINTER = _UxGT("Reset Printer"); @@ -471,15 +489,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 +520,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. "); @@ -510,8 +539,10 @@ 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_PARK_FAILED = _UxGT("Head cannot be parked"); LSTR MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Recover Speed"); LSTR MSG_SINGLENOZZLE_FAN_SPEED = _UxGT("Fan Speed"); LSTR MSG_SINGLENOZZLE_FAN_TIME = _UxGT("Fan Time"); @@ -522,13 +553,18 @@ namespace Language_en { LSTR MSG_TOOL_MIGRATION_END = _UxGT("Last Extruder"); LSTR MSG_TOOL_MIGRATION_SWAP = _UxGT("Migrate to *"); LSTR MSG_FILAMENTCHANGE = _UxGT("Change Filament"); - LSTR MSG_FILAMENTCHANGE_E = _UxGT("Change Filament *"); + LSTR MSG_FILAMENTCHANGE_E = _UxGT("Change * Filament"); LSTR MSG_FILAMENTLOAD = _UxGT("Load Filament"); - LSTR MSG_FILAMENTLOAD_E = _UxGT("Load *"); + LSTR MSG_FILAMENTLOAD_E = _UxGT("Load * Filament"); LSTR MSG_FILAMENTUNLOAD = _UxGT("Unload Filament"); - LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Unload *"); + LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Unload * Filament"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Unload All"); - LSTR MSG_ATTACH_MEDIA = _UxGT("Attach ") MEDIA_TYPE_EN; + #if ENABLED(MULTI_VOLUME) + LSTR MSG_ATTACH_MEDIA = _UxGT("Attach SD Card"); + LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Attach USB Drive"); + #else + LSTR MSG_ATTACH_MEDIA = _UxGT("Attach ") MEDIA_TYPE_EN; + #endif LSTR MSG_CHANGE_MEDIA = _UxGT("Change ") MEDIA_TYPE_EN; LSTR MSG_RELEASE_MEDIA = _UxGT("Release ") MEDIA_TYPE_EN; LSTR MSG_ZPROBE_OUT = _UxGT("Z Probe Past Bed"); @@ -554,7 +590,7 @@ namespace Language_en { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Deploy TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Deploy Z-Probe"); LSTR MSG_MANUAL_STOW = _UxGT("Stow Z-Probe"); - LSTR MSG_HOME_FIRST = _UxGT("Home %s%s%s First"); + LSTR MSG_HOME_FIRST = _UxGT("Home %s First"); LSTR MSG_ZPROBE_SETTINGS = _UxGT("Probe Settings"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Probe Offsets"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Probe X Offset"); @@ -594,14 +630,13 @@ namespace Language_en { LSTR MSG_CHAMBER_COOLING = _UxGT("Chamber Cooling..."); LSTR MSG_LASER_COOLING = _UxGT("Laser Cooling..."); LSTR MSG_DELTA_CALIBRATE = _UxGT("Delta Calibration"); + LSTR MSG_DELTA_CALIBRATION_IN_PROGRESS = _UxGT("Delta Calibration in progress"); LSTR MSG_DELTA_CALIBRATE_X = _UxGT("Calibrate X"); LSTR MSG_DELTA_CALIBRATE_Y = _UxGT("Calibrate Y"); LSTR MSG_DELTA_CALIBRATE_Z = _UxGT("Calibrate Z"); LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Calibrate Center"); LSTR MSG_DELTA_SETTINGS = _UxGT("Delta Settings"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Auto Calibration"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Set Delta Height"); - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Probe Z-offset"); LSTR MSG_DELTA_DIAG_ROD = _UxGT("Diag Rod"); LSTR MSG_DELTA_HEIGHT = _UxGT("Height"); LSTR MSG_DELTA_RADIUS = _UxGT("Radius"); @@ -614,6 +649,7 @@ namespace Language_en { LSTR MSG_MESH_LEVELING = _UxGT("Mesh Leveling"); LSTR MSG_MESH_DONE = _UxGT("Mesh probing done"); LSTR MSG_INFO_STATS_MENU = _UxGT("Printer Stats"); + LSTR MSG_RESET_STATS = _UxGT("Reset Print Stats?"); LSTR MSG_INFO_BOARD_MENU = _UxGT("Board Info"); LSTR MSG_INFO_THERMISTOR_MENU = _UxGT("Thermistors"); LSTR MSG_INFO_EXTRUDERS = _UxGT("Extruders"); @@ -705,7 +741,8 @@ namespace Language_en { LSTR MSG_MMU2_FILAMENT_N = _UxGT("Filament ~"); LSTR MSG_MMU2_RESET = _UxGT("Reset MMU"); LSTR MSG_MMU2_RESETTING = _UxGT("MMU Resetting..."); - LSTR MSG_MMU2_EJECT_RECOVER = _UxGT("Remove, click"); + LSTR MSG_MMU2_EJECT_RECOVER = _UxGT("MMU2 Eject Recover"); + LSTR MSG_MMU2_REMOVE_AND_CLICK = _UxGT("Remove and click..."); LSTR MSG_MIX = _UxGT("Mix"); LSTR MSG_MIX_COMPONENT_N = _UxGT("Component ="); @@ -822,11 +859,12 @@ namespace Language_en { LSTR MSG_HOST_SHUTDOWN = _UxGT("Host Shutdown"); - // These strings can be the same in all languages - LSTR MSG_MARLIN = _UxGT("Marlin"); LSTR MSG_SHORT_DAY = _UxGT("d"); // One character only LSTR MSG_SHORT_HOUR = _UxGT("h"); // One character only LSTR MSG_SHORT_MINUTE = _UxGT("m"); // One character only + + // These strings can be the same in all languages + LSTR MSG_MARLIN = _UxGT("Marlin"); LSTR MSG_PID_P = _UxGT("PID-P"); LSTR MSG_PID_P_E = _UxGT("PID-P *"); LSTR MSG_PID_I = _UxGT("PID-I"); @@ -839,11 +877,3 @@ namespace Language_en { LSTR MSG_PID_F_E = _UxGT("PID-F *"); LSTR MSG_BACKLASH_N = _UxGT("@"); } - -#if FAN_COUNT == 1 - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED -#else - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N -#endif diff --git a/Marlin/src/lcd/language/language_es.h b/Marlin/src/lcd/language/language_es.h index cc331efd4562..eb39a8a08940 100644 --- a/Marlin/src/lcd/language/language_es.h +++ b/Marlin/src/lcd/language/language_es.h @@ -226,6 +226,7 @@ namespace Language_es { LSTR MSG_MOVE_X = _UxGT("Mover X"); LSTR MSG_MOVE_Y = _UxGT("Mover Y"); LSTR MSG_MOVE_Z = _UxGT("Mover Z"); + LSTR MSG_MOVE_N = _UxGT("Mover @"); LSTR MSG_MOVE_E = _UxGT("Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Extrusor *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hotend muy frio"); @@ -233,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"); @@ -263,7 +265,6 @@ namespace Language_es { LSTR MSG_LCD_OFF = _UxGT("Apg"); LSTR MSG_PID_AUTOTUNE = _UxGT("PID Auto-ajuste"); LSTR MSG_PID_AUTOTUNE_E = _UxGT("PID Auto-ajuste *"); - LSTR MSG_SELECT = _UxGT("Seleccionar"); LSTR MSG_SELECT_E = _UxGT("Seleccionar *"); LSTR MSG_ACC = _UxGT("Aceleración"); LSTR MSG_JERK = _UxGT("Jerk"); @@ -314,7 +315,7 @@ namespace Language_es { LSTR MSG_RESTORE_DEFAULTS = _UxGT("Rest. fábrica"); LSTR MSG_INIT_EEPROM = _UxGT("Inicializar EEPROM"); LSTR MSG_ERR_EEPROM_CRC = _UxGT("Err: EEPROM CRC"); - LSTR MSG_ERR_EEPROM_INDEX = _UxGT("Err: Índice EEPROM"); + LSTR MSG_ERR_EEPROM_SIZE = _UxGT("Err: EEPROM Tamaño"); LSTR MSG_ERR_EEPROM_VERSION = _UxGT("Err: Versión EEPROM"); LSTR MSG_MEDIA_UPDATE = _UxGT("Actualizar SD/FD"); LSTR MSG_RESET_PRINTER = _UxGT("Resetear Impresora"); @@ -397,7 +398,7 @@ namespace Language_es { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Subir TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Subir Sonda Z"); LSTR MSG_MANUAL_STOW = _UxGT("Bajar Sonda Z"); - LSTR MSG_HOME_FIRST = _UxGT("Origen %s%s%s Prim."); + LSTR MSG_HOME_FIRST = _UxGT("Origen %s Prim."); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Desf. Sonda"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Desf. Sonda X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Desf. Sonda Y"); @@ -430,8 +431,6 @@ namespace Language_es { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Calibrar Centro"); LSTR MSG_DELTA_SETTINGS = _UxGT("Configuración Delta"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Auto Calibración"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Est. Altura Delta"); - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Ajustar Sonda Z"); LSTR MSG_DELTA_DIAG_ROD = _UxGT("Barra Diagonal"); LSTR MSG_DELTA_HEIGHT = _UxGT("Altura"); LSTR MSG_DELTA_RADIUS = _UxGT("Radio"); diff --git a/Marlin/src/lcd/language/language_eu.h b/Marlin/src/lcd/language/language_eu.h index 09a0fbeb6ac6..0c29cdd2aaba 100644 --- a/Marlin/src/lcd/language/language_eu.h +++ b/Marlin/src/lcd/language/language_eu.h @@ -136,12 +136,14 @@ namespace Language_eu { LSTR MSG_MOVE_X = _UxGT("Mugitu X"); LSTR MSG_MOVE_Y = _UxGT("Mugitu Y"); LSTR MSG_MOVE_Z = _UxGT("Mugitu Z"); + LSTR MSG_MOVE_N = _UxGT("Mugitu @"); LSTR MSG_MOVE_E = _UxGT("Estrusorea"); LSTR MSG_MOVE_EN = _UxGT("Estrusorea *"); LSTR MSG_MOVE_N_MM = _UxGT("Mugitu $mm"); 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"); @@ -159,7 +161,6 @@ namespace Language_eu { LSTR MSG_MAX = " " LCD_STR_THERMOMETER _UxGT(" Max"); LSTR MSG_FACTOR = " " LCD_STR_THERMOMETER _UxGT(" Fakt"); LSTR MSG_AUTOTEMP = _UxGT("Auto tenperatura"); - LSTR MSG_SELECT = _UxGT("Aukeratu"); LSTR MSG_SELECT_E = _UxGT("Aukeratu *"); LSTR MSG_ACC = _UxGT("Azelerazioa"); LSTR MSG_JERK = _UxGT("Astindua"); @@ -234,7 +235,7 @@ namespace Language_eu { LSTR MSG_BLTOUCH_RESET = _UxGT("BLTouch berrabia."); LSTR MSG_BLTOUCH_DEPLOY = _UxGT("BLTouch jaitsi/luzatu"); LSTR MSG_BLTOUCH_STOW = _UxGT("BLTouch igo/jaso"); - LSTR MSG_HOME_FIRST = _UxGT("Etxera %s%s%s lehenengo"); + LSTR MSG_HOME_FIRST = _UxGT("Etxera %s lehenengo"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Z Konpentsatu"); LSTR MSG_BABYSTEP_X = _UxGT("Mikro-urratsa X"); LSTR MSG_BABYSTEP_Y = _UxGT("Mikro-urratsa Y"); @@ -257,7 +258,6 @@ namespace Language_eu { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Kalibratu Zentrua"); LSTR MSG_DELTA_SETTINGS = _UxGT("Delta ezarpenak"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Auto Kalibraketa"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Delta Alt. Ezar."); LSTR MSG_DELTA_DIAG_ROD = _UxGT("Barra diagonala"); LSTR MSG_DELTA_HEIGHT = _UxGT("Altuera"); LSTR MSG_DELTA_RADIUS = _UxGT("Erradioa"); diff --git a/Marlin/src/lcd/language/language_fi.h b/Marlin/src/lcd/language/language_fi.h index 8fd53a79e36d..300da9b95652 100644 --- a/Marlin/src/lcd/language/language_fi.h +++ b/Marlin/src/lcd/language/language_fi.h @@ -69,12 +69,14 @@ namespace Language_fi { LSTR MSG_MOVE_X = _UxGT("Liikuta X"); LSTR MSG_MOVE_Y = _UxGT("Liikuta Y"); LSTR MSG_MOVE_Z = _UxGT("Liikuta Z"); + LSTR MSG_MOVE_N = _UxGT("Liikuta @"); LSTR MSG_MOVE_E = _UxGT("Extruder"); LSTR MSG_MOVE_EN = _UxGT("Extruder *"); LSTR MSG_MOVE_N_MM = _UxGT("Liikuta $mm"); 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 6081234607f4..8c2df5845239 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"); @@ -270,7 +272,6 @@ namespace Language_fr { LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Echec Autotune! E incorrect"); LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Echec Autotune! Temp. trop haute"); LSTR MSG_PID_TIMEOUT = _UxGT("Echec Autotune! Opér. expirée"); - LSTR MSG_SELECT = _UxGT("Sélectionner"); LSTR MSG_SELECT_E = _UxGT("Sélectionner *"); LSTR MSG_ACC = _UxGT("Accélération"); LSTR MSG_JERK = _UxGT("Jerk"); @@ -321,7 +322,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."); @@ -366,7 +367,7 @@ namespace Language_fr { LSTR MSG_STOPPED = _UxGT("STOPPÉ"); LSTR MSG_CONTROL_RETRACT = _UxGT("Rétractation mm"); LSTR MSG_CONTROL_RETRACT_SWAP = _UxGT("Ech. rétr. mm"); - LSTR MSG_CONTROL_RETRACTF = _UxGT("Vit. rétract°"); + LSTR MSG_CONTROL_RETRACTF = _UxGT("Vit. rétract") LCD_STR_DEGREE; LSTR MSG_CONTROL_RETRACT_ZHOP = _UxGT("Saut Z mm"); LSTR MSG_CONTROL_RETRACT_RECOVER = _UxGT("Rét.reprise mm"); LSTR MSG_CONTROL_RETRACT_RECOVER_SWAP = _UxGT("Ech.reprise mm"); @@ -376,7 +377,8 @@ 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_RETRACT_SPEED = _UxGT("Vitesse rétract°"); + LSTR MSG_SINGLENOZZLE_WIPE_RETRACT = _UxGT("Purge Retract"); + LSTR MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Vitesse rétract") LCD_STR_DEGREE; LSTR MSG_FILAMENT_PARK_ENABLED = _UxGT("Garer Extrudeur"); LSTR MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Vitesse reprise"); LSTR MSG_SINGLENOZZLE_FAN_SPEED = _UxGT("Vit. ventil."); @@ -422,7 +424,7 @@ namespace Language_fr { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Déployer TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Déployer Sonde Z"); LSTR MSG_MANUAL_STOW = _UxGT("Ranger Sonde Z"); - LSTR MSG_HOME_FIRST = _UxGT("Origine %s%s%s Premier"); + LSTR MSG_HOME_FIRST = _UxGT("Origine %s Premier"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Position sonde Z"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Décalage X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Décalage Y"); @@ -441,9 +443,6 @@ namespace Language_fr { LSTR MSG_HALTED = _UxGT("IMPR. STOPPÉE"); LSTR MSG_PLEASE_RESET = _UxGT("Redémarrer SVP"); - LSTR MSG_SHORT_DAY = _UxGT("j"); // One character only - LSTR MSG_SHORT_HOUR = _UxGT("h"); // One character only - LSTR MSG_SHORT_MINUTE = _UxGT("m"); // One character only LSTR MSG_HEATING = _UxGT("en chauffe..."); LSTR MSG_COOLING = _UxGT("Refroidissement"); @@ -460,8 +459,6 @@ namespace Language_fr { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Calibrer centre"); LSTR MSG_DELTA_SETTINGS = _UxGT("Réglages Delta"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Calibration Auto"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Hauteur Delta"); - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Delta Z sonde"); LSTR MSG_DELTA_DIAG_ROD = _UxGT("Diagonale"); LSTR MSG_DELTA_HEIGHT = _UxGT("Hauteur"); LSTR MSG_DELTA_RADIUS = _UxGT("Rayon"); @@ -631,4 +628,8 @@ namespace Language_fr { LSTR MSG_SD_CARD = _UxGT("Carte SD"); LSTR MSG_USB_DISK = _UxGT("Clé USB"); + + LSTR MSG_SHORT_DAY = _UxGT("j"); // One character only + LSTR MSG_SHORT_HOUR = _UxGT("h"); // One character only + LSTR MSG_SHORT_MINUTE = _UxGT("m"); // One character only } diff --git a/Marlin/src/lcd/language/language_gl.h b/Marlin/src/lcd/language/language_gl.h index dabd35efcf9b..54ae62bac94d 100644 --- a/Marlin/src/lcd/language/language_gl.h +++ b/Marlin/src/lcd/language/language_gl.h @@ -223,6 +223,7 @@ namespace Language_gl { LSTR MSG_MOVE_X = _UxGT("Mover X"); LSTR MSG_MOVE_Y = _UxGT("Mover Y"); LSTR MSG_MOVE_Z = _UxGT("Mover Z"); + LSTR MSG_MOVE_N = _UxGT("Mover @"); LSTR MSG_MOVE_E = _UxGT("Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Extrusor *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Bico moi frío"); @@ -230,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"); @@ -264,7 +266,6 @@ namespace Language_gl { LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Auto-Sint. fallida! Extrusor danado."); LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Auto-Sint. fallida! Temperatura moi alta."); LSTR MSG_PID_TIMEOUT = _UxGT("Auto-Sint. fallida! Tempo excedido."); - LSTR MSG_SELECT = _UxGT("Escolla"); LSTR MSG_SELECT_E = _UxGT("Escolla *"); LSTR MSG_ACC = _UxGT("Acel"); LSTR MSG_JERK = _UxGT("Jerk"); @@ -316,7 +317,7 @@ namespace Language_gl { LSTR MSG_RESTORE_DEFAULTS = _UxGT("Rest. Defecto"); LSTR MSG_INIT_EEPROM = _UxGT("Inicializar EEPROM"); LSTR MSG_ERR_EEPROM_CRC = _UxGT("Erro: CRC EEPROM"); - LSTR MSG_ERR_EEPROM_INDEX = _UxGT("Erro: Índice EEPROM"); + LSTR MSG_ERR_EEPROM_SIZE = _UxGT("Erro: Tamaño EEPROM"); LSTR MSG_ERR_EEPROM_VERSION = _UxGT("Erro: Versión EEPROM"); LSTR MSG_SETTINGS_STORED = _UxGT("Config Gardada"); LSTR MSG_MEDIA_UPDATE = _UxGT("Actualizar SD/FD"); @@ -412,7 +413,7 @@ namespace Language_gl { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Estender TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Estender Sonda Z"); LSTR MSG_MANUAL_STOW = _UxGT("Recoller Sonda Z"); - LSTR MSG_HOME_FIRST = _UxGT("Orixe %s%s%s Primeiro"); + LSTR MSG_HOME_FIRST = _UxGT("Orixe %s Primeiro"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Desfases Sonda"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Desfase Sonda X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Desfase Sonda Y"); @@ -445,8 +446,6 @@ namespace Language_gl { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Calibrar Centro"); LSTR MSG_DELTA_SETTINGS = _UxGT("Configuración Delta"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Auto Calibración"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Ax. Altura Delta"); - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Axustar Sonda Z"); LSTR MSG_DELTA_DIAG_ROD = _UxGT("Barra Diagonal"); LSTR MSG_DELTA_HEIGHT = _UxGT("Altura"); LSTR MSG_DELTA_RADIUS = _UxGT("Radio"); diff --git a/Marlin/src/lcd/language/language_hr.h b/Marlin/src/lcd/language/language_hr.h index 10f11f616f5f..36eaf78acb1a 100644 --- a/Marlin/src/lcd/language/language_hr.h +++ b/Marlin/src/lcd/language/language_hr.h @@ -78,10 +78,15 @@ namespace Language_hr { LSTR MSG_LEVEL_BED = _UxGT("Niveliraj bed"); LSTR MSG_MOVE_X = _UxGT("Miči X"); LSTR MSG_MOVE_Y = _UxGT("Miči Y"); + LSTR MSG_MOVE_Z = _UxGT("Miči Z"); + LSTR MSG_MOVE_N = _UxGT("Miči @"); + LSTR MSG_MOVE_E = _UxGT("Miči E"); + LSTR MSG_MOVE_EN = _UxGT("Miči *"); LSTR MSG_MOVE_N_MM = _UxGT("Miči $mm"); 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"); @@ -90,7 +95,6 @@ namespace Language_hr { LSTR MSG_BED = _UxGT("Bed"); LSTR MSG_FAN_SPEED = _UxGT("Brzina ventilatora"); LSTR MSG_FAN_SPEED_N = _UxGT("Brzina ventilatora ~"); - LSTR MSG_SELECT = _UxGT("Odaberi"); LSTR MSG_SELECT_E = _UxGT("Odaberi *"); LSTR MSG_TEMPERATURE = _UxGT("Temperature"); LSTR MSG_MOTION = _UxGT("Gibanje"); diff --git a/Marlin/src/lcd/language/language_hu.h b/Marlin/src/lcd/language/language_hu.h index 81db96df1702..148a0fb64e26 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"); @@ -307,7 +309,6 @@ namespace Language_hu { LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Hangolási hiba! Rossz adagoló."); LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Hangolási hiba! Magas hömérséklet."); LSTR MSG_PID_TIMEOUT = _UxGT("Hangolási hiba! Idötúllépés."); - LSTR MSG_SELECT = _UxGT("Kiválaszt"); LSTR MSG_SELECT_E = _UxGT("Kiválaszt *"); LSTR MSG_ACC = _UxGT("Gyorsítás"); LSTR MSG_JERK = _UxGT("Rántás"); @@ -362,7 +363,7 @@ namespace Language_hu { LSTR MSG_RESTORE_DEFAULTS = _UxGT("Alapértelmezett"); LSTR MSG_INIT_EEPROM = _UxGT("EEPROM inicializálás"); LSTR MSG_ERR_EEPROM_CRC = _UxGT("Hiba: EEPROM CRC"); - LSTR MSG_ERR_EEPROM_INDEX = _UxGT("Hiba: EEPROM index"); + LSTR MSG_ERR_EEPROM_SIZE = _UxGT("Hiba: EEPROM mérete"); LSTR MSG_ERR_EEPROM_VERSION = _UxGT("Hiba: EEPROM verzió"); LSTR MSG_SETTINGS_STORED = _UxGT("Beállítások mentve"); LSTR MSG_MEDIA_UPDATE = _UxGT("Tároló frissítés"); @@ -466,7 +467,7 @@ namespace Language_hu { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("TouchMI használ"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Z-Szonda telepítés"); LSTR MSG_MANUAL_STOW = _UxGT("Z-Szonda elhelyezés"); - LSTR MSG_HOME_FIRST = _UxGT("Elöször %s%s%s kell"); + LSTR MSG_HOME_FIRST = _UxGT("Elöször %s kell"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Szonda eltolások"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("X szonda eltolás"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Y szonda eltolás"); @@ -489,9 +490,6 @@ namespace Language_hu { LSTR MSG_ERR_MINTEMP = _UxGT("Hiba: MIN höfok"); LSTR MSG_HALTED = _UxGT("A NYOMTATÓ LEÁLLT"); LSTR MSG_PLEASE_RESET = _UxGT("Indítsd újra!"); - LSTR MSG_SHORT_DAY = _UxGT("n"); // Csak egy karakter - LSTR MSG_SHORT_HOUR = _UxGT("ó"); // Csak egy karakter - LSTR MSG_SHORT_MINUTE = _UxGT("p"); // Csak egy karakter LSTR MSG_HEATING = _UxGT("Fütés..."); LSTR MSG_COOLING = _UxGT("Hütés..."); LSTR MSG_BED_HEATING = _UxGT("Ágy fütés..."); @@ -508,8 +506,6 @@ namespace Language_hu { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Központ kalibrálás"); LSTR MSG_DELTA_SETTINGS = _UxGT("Delta beállítások"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Auto kalibráció"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Delta magasság kalib."); - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Z eltolás"); LSTR MSG_DELTA_DIAG_ROD = _UxGT("Diag rúd"); LSTR MSG_DELTA_HEIGHT = _UxGT("Magasság"); LSTR MSG_DELTA_RADIUS = _UxGT("Sugár"); @@ -697,12 +693,8 @@ namespace Language_hu { LSTR MSG_SD_CARD = _UxGT("SD Kártya"); LSTR MSG_USB_DISK = _UxGT("USB Lemez"); -} -#if FAN_COUNT == 1 - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED -#else - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N -#endif + LSTR MSG_SHORT_DAY = _UxGT("n"); // Csak egy karakter + LSTR MSG_SHORT_HOUR = _UxGT("ó"); // Csak egy karakter + LSTR MSG_SHORT_MINUTE = _UxGT("p"); // Csak egy karakter +} diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index b043ac26e168..41786f4d7bdf 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -47,7 +47,10 @@ namespace Language_it { LSTR WELCOME_MSG = MACHINE_NAME _UxGT(" pronta."); LSTR MSG_YES = _UxGT("Si"); LSTR MSG_NO = _UxGT("No"); + LSTR MSG_HIGH = _UxGT("ALTO"); + LSTR MSG_LOW = _UxGT("BASSO"); LSTR MSG_BACK = _UxGT("Indietro"); + LSTR MSG_ERROR = _UxGT("Errore"); LSTR MSG_MEDIA_ABORTING = _UxGT("Annullando..."); LSTR MSG_MEDIA_INSERTED = _UxGT("Media inserito"); LSTR MSG_MEDIA_REMOVED = _UxGT("Media rimosso"); @@ -61,6 +64,8 @@ namespace Language_it { LSTR MSG_LCD_SOFT_ENDSTOPS = _UxGT("Finecorsa Soft"); LSTR MSG_MAIN = _UxGT("Menu principale"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Impostaz. avanzate"); + LSTR MSG_TOOLBAR_SETUP = _UxGT("Cnf barra strumenti"); + LSTR MSG_OPTION_DISABLED = _UxGT("Opzione disab."); LSTR MSG_CONFIGURATION = _UxGT("Configurazione"); LSTR MSG_RUN_AUTO_FILES = _UxGT("Esegui files auto"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Disabilita Motori"); @@ -72,8 +77,10 @@ namespace Language_it { LSTR MSG_AUTO_HOME_X = _UxGT("Home X"); LSTR MSG_AUTO_HOME_Y = _UxGT("Home Y"); LSTR MSG_AUTO_HOME_Z = _UxGT("Home Z"); + LSTR MSG_Z_AFTER_HOME = _UxGT("Z dopo homing"); LSTR MSG_FILAMENT_SET = _UxGT("Impostaz.filamento"); LSTR MSG_FILAMENT_MAN = _UxGT("Gestione filamento"); + LSTR MSG_MANUAL_LEVELING = _UxGT("Livel.manuale"); LSTR MSG_LEVBED_FL = _UxGT("Davanti Sinistra"); LSTR MSG_LEVBED_FR = _UxGT("Davanti Destra"); LSTR MSG_LEVBED_C = _UxGT("Centro"); @@ -95,6 +102,7 @@ namespace Language_it { LSTR MSG_HOME_OFFSET_Y = _UxGT("Offset home Y"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Offset home Z"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Offset applicato"); + LSTR MSG_ERR_M428_TOO_FAR = _UxGT("Err: Troppo lontano!"); LSTR MSG_TRAMMING_WIZARD = _UxGT("Wizard Tramming"); LSTR MSG_SELECT_ORIGIN = _UxGT("Selez. origine"); LSTR MSG_LAST_VALUE_SP = _UxGT("Ultimo valore "); @@ -106,7 +114,14 @@ namespace Language_it { LSTR MSG_PREHEAT_1_ALL = _UxGT("Preris.") PREHEAT_1_LABEL _UxGT(" Tutto"); LSTR MSG_PREHEAT_1_BEDONLY = _UxGT("Preris.") PREHEAT_1_LABEL _UxGT(" Piatto"); LSTR MSG_PREHEAT_1_SETTINGS = _UxGT("Preris.") PREHEAT_1_LABEL _UxGT(" conf"); - + #ifdef PREHEAT_2_LABEL + LSTR MSG_PREHEAT_2 = _UxGT("Preris.") PREHEAT_2_LABEL; + LSTR MSG_PREHEAT_2_SETTINGS = _UxGT("Preris.") PREHEAT_2_LABEL _UxGT(" conf"); + #endif + #ifdef PREHEAT_3_LABEL + LSTR MSG_PREHEAT_3 = _UxGT("Preris.") PREHEAT_3_LABEL; + LSTR MSG_PREHEAT_3_SETTINGS = _UxGT("Preris.") PREHEAT_3_LABEL _UxGT(" conf"); + #endif LSTR MSG_PREHEAT_M = _UxGT("Preriscalda $"); LSTR MSG_PREHEAT_M_H = _UxGT("Preriscalda $ ~"); LSTR MSG_PREHEAT_M_END = _UxGT("Preris.$ Ugello"); @@ -115,6 +130,7 @@ namespace Language_it { LSTR MSG_PREHEAT_M_BEDONLY = _UxGT("Preris.$ Piatto"); LSTR MSG_PREHEAT_M_SETTINGS = _UxGT("Preris.$ conf"); #endif + LSTR MSG_PREHEAT_HOTEND = _UxGT("Prerisc.Hotend"); LSTR MSG_PREHEAT_CUSTOM = _UxGT("Prerisc.personal."); LSTR MSG_COOLDOWN = _UxGT("Raffredda"); @@ -153,10 +169,19 @@ namespace Language_it { LSTR MSG_MESH_VIEW = _UxGT("Visualizza Mesh"); LSTR MSG_EDITING_STOPPED = _UxGT("Modif. Mesh Fermata"); LSTR MSG_NO_VALID_MESH = _UxGT("Mesh non valida"); + LSTR MSG_ACTIVATE_MESH = _UxGT("Attiva livellamento"); LSTR MSG_PROBING_POINT = _UxGT("Punto sondato"); LSTR MSG_MESH_X = _UxGT("Indice X"); LSTR MSG_MESH_Y = _UxGT("Indice Y"); + LSTR MSG_MESH_INSET = _UxGT("Mesh Inset"); + LSTR MSG_MESH_MIN_X = _UxGT("Mesh X minimo"); + LSTR MSG_MESH_MAX_X = _UxGT("Mesh X massimo"); + LSTR MSG_MESH_MIN_Y = _UxGT("Mesh Y minimo"); + LSTR MSG_MESH_MAX_Y = _UxGT("Mesh Y massimo"); + 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 cancellata"); LSTR MSG_CUSTOM_COMMANDS = _UxGT("Comandi personaliz."); LSTR MSG_M48_TEST = _UxGT("Test sonda M48"); LSTR MSG_M48_POINT = _UxGT("Punto M48"); @@ -175,6 +200,9 @@ namespace Language_it { LSTR MSG_UBL_TOOLS = _UxGT("Strumenti UBL"); LSTR MSG_UBL_LEVEL_BED = _UxGT("Livel.letto unificato"); LSTR MSG_LCD_TILTING_MESH = _UxGT("Punto inclinaz."); + LSTR MSG_UBL_TILT_MESH = _UxGT("Inclina Mesh"); + LSTR MSG_UBL_TILTING_GRID = _UxGT("Dim.griglia inclin."); + LSTR MSG_UBL_MESH_TILTED = _UxGT("Mesh inclinata"); LSTR MSG_UBL_MANUAL_MESH = _UxGT("Mesh Manuale"); LSTR MSG_UBL_MESH_WIZARD = _UxGT("Creaz.guid.mesh UBL"); LSTR MSG_UBL_BC_INSERT = _UxGT("Metti spes. e misura"); @@ -225,6 +253,8 @@ namespace Language_it { LSTR MSG_UBL_MANUAL_FILLIN = _UxGT("Riempimento Manuale"); 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"); @@ -233,8 +263,10 @@ namespace Language_it { LSTR MSG_UBL_STORAGE_SLOT = _UxGT("Slot di memoria"); LSTR MSG_UBL_LOAD_MESH = _UxGT("Carica Mesh Piatto"); LSTR MSG_UBL_SAVE_MESH = _UxGT("Salva Mesh Piatto"); + LSTR MSG_UBL_INVALID_SLOT = _UxGT("Prima selez. uno slot Mesh"); LSTR MSG_MESH_LOADED = _UxGT("Mesh %i caricata"); LSTR MSG_MESH_SAVED = _UxGT("Mesh %i salvata"); + LSTR MSG_MESH_ACTIVE = _UxGT("Mesh %i attiva"); LSTR MSG_UBL_NO_STORAGE = _UxGT("Nessuna memoria"); LSTR MSG_UBL_SAVE_ERROR = _UxGT("Err: Salvataggio UBL"); LSTR MSG_UBL_RESTORE_ERROR = _UxGT("Err: Ripristino UBL"); @@ -285,11 +317,15 @@ 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_LIVE_MOVE = _UxGT("Modalità Live"); + LSTR MSG_SPEED = _UxGT("Velocità"); LSTR MSG_BED_Z = _UxGT("Piatto Z"); LSTR MSG_NOZZLE = _UxGT("Ugello"); LSTR MSG_NOZZLE_N = _UxGT("Ugello ~"); @@ -300,6 +336,7 @@ namespace Language_it { LSTR MSG_COOLER = _UxGT("Raffreddam. laser"); LSTR MSG_COOLER_TOGGLE = _UxGT("Alterna raffreddam."); LSTR MSG_FLOWMETER_SAFETY = _UxGT("Sicurezza flusso"); + LSTR MSG_CUTTER = _UxGT("Taglio"); LSTR MSG_LASER = _UxGT("Laser"); LSTR MSG_FAN_SPEED = _UxGT("Vel. ventola"); // Max 15 characters LSTR MSG_FAN_SPEED_N = _UxGT("Vel. ventola ~"); // Max 15 characters @@ -324,18 +361,28 @@ namespace Language_it { LSTR MSG_PID_AUTOTUNE_E = _UxGT("Calib.PID *"); LSTR MSG_PID_CYCLE = _UxGT("Ciclo PID"); LSTR MSG_PID_AUTOTUNE_DONE = _UxGT("Calibr.PID eseguita"); + LSTR MSG_PID_AUTOTUNE_FAILED = _UxGT("Calibr.PID fallito!"); + LSTR MSG_BAD_EXTRUDER_NUM = _UxGT("Estrusore invalido."); + LSTR MSG_TEMP_TOO_HIGH = _UxGT("Temp.troppo alta."); + LSTR MSG_TIMEOUT = _UxGT("Tempo scaduto."); LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Calibrazione fallita! Estrusore errato."); LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Calibrazione fallita! Temperatura troppo alta."); LSTR MSG_PID_TIMEOUT = _UxGT("Calibrazione fallita! Tempo scaduto."); - LSTR MSG_MPC_MEASURING_AMBIENT = _UxGT("Testing heat loss"); - LSTR MSG_MPC_AUTOTUNE = _UxGT("MPC Autotune"); + LSTR MSG_MPC_MEASURING_AMBIENT = _UxGT("Verif.perdita calore"); + LSTR MSG_MPC_HEATING_PAST_200 = _UxGT("Riscalda a >200C"); + LSTR MSG_MPC_COOLING_TO_AMBIENT = _UxGT("Raffredda a amb."); + LSTR MSG_MPC_AUTOTUNE = _UxGT("Calibra MPC"); LSTR MSG_MPC_EDIT = _UxGT("Modif.MPC *"); + LSTR MSG_MPC_POWER = _UxGT("Potenza riscald."); LSTR MSG_MPC_POWER_E = _UxGT("Potenza *"); - LSTR MSG_MPC_BLOCK_HEAT_CAPACITY_E = _UxGT("C blocco *"); + LSTR MSG_MPC_BLOCK_HEAT_CAPACITY = _UxGT("Capacità riscald."); + LSTR MSG_MPC_BLOCK_HEAT_CAPACITY_E = _UxGT("Capac.riscald. *"); + LSTR MSG_SENSOR_RESPONSIVENESS = _UxGT("Reattiv.Sens."); LSTR MSG_SENSOR_RESPONSIVENESS_E = _UxGT("Reattiv.Sens. *"); - LSTR MSG_MPC_AMBIENT_XFER_COEFF_E = _UxGT("H ambiente *"); - LSTR MSG_MPC_AMBIENT_XFER_COEFF_FAN_E = _UxGT("H Amb. vent. *"); - LSTR MSG_SELECT = _UxGT("Seleziona"); + LSTR MSG_MPC_AMBIENT_XFER_COEFF = _UxGT("Coeff.ambiente"); + LSTR MSG_MPC_AMBIENT_XFER_COEFF_E = _UxGT("Coeff.amb. *"); + LSTR MSG_MPC_AMBIENT_XFER_COEFF_FAN = _UxGT("Coeff.ventola"); + LSTR MSG_MPC_AMBIENT_XFER_COEFF_FAN_E = _UxGT("Coeff.ventola *"); LSTR MSG_SELECT_E = _UxGT("Seleziona *"); LSTR MSG_ACC = _UxGT("Accel"); LSTR MSG_JERK = _UxGT("Jerk"); @@ -363,6 +410,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_ENABLE = _UxGT("Abilita shaping @"); + LSTR MSG_SHAPING_DISABLE = _UxGT("Disabil. shaping @"); + LSTR MSG_SHAPING_FREQ = _UxGT("Frequenza @"); + LSTR MSG_SHAPING_ZETA = _UxGT("Smorzamento @"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Frequenza max"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Feed min"); LSTR MSG_STEPS_PER_MM = _UxGT("Passi/mm"); @@ -382,11 +434,16 @@ 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"); 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"); @@ -394,13 +451,17 @@ namespace Language_it { LSTR MSG_RESTORE_DEFAULTS = _UxGT("Ripristina imp."); LSTR MSG_INIT_EEPROM = _UxGT("Inizializza EEPROM"); LSTR MSG_ERR_EEPROM_CRC = _UxGT("Err: CRC EEPROM"); - LSTR MSG_ERR_EEPROM_INDEX = _UxGT("Err: Indice EEPROM"); + LSTR MSG_ERR_EEPROM_SIZE = _UxGT("Err: Taglia EEPROM"); LSTR MSG_ERR_EEPROM_VERSION = _UxGT("Err: Versione EEPROM"); LSTR MSG_SETTINGS_STORED = _UxGT("Impostazioni mem."); LSTR MSG_MEDIA_UPDATE = _UxGT("Aggiorna media"); LSTR MSG_RESET_PRINTER = _UxGT("Resetta stampante"); LSTR MSG_REFRESH = LCD_STR_REFRESH _UxGT("Aggiorna"); LSTR MSG_INFO_SCREEN = _UxGT("Schermata info"); + LSTR MSG_INFO_MACHINENAME = _UxGT("Nome macchina"); + LSTR MSG_INFO_SIZE = _UxGT("Dimens."); + LSTR MSG_INFO_FWVERSION = _UxGT("Versione firmware"); + LSTR MSG_INFO_BUILD = _UxGT("Dataora compilaz."); LSTR MSG_PREPARE = _UxGT("Prepara"); LSTR MSG_TUNE = _UxGT("Regola"); LSTR MSG_POWER_MONITOR = _UxGT("Controllo aliment."); @@ -426,7 +487,8 @@ namespace Language_it { LSTR MSG_BUTTON_PAUSE = _UxGT("Pausa"); LSTR MSG_BUTTON_RESUME = _UxGT("Riprendi"); LSTR MSG_BUTTON_ADVANCED = _UxGT("Avanzato"); - LSTR MSG_BUTTON_SAVE = _UxGT("Save"); + LSTR MSG_BUTTON_SAVE = _UxGT("Memorizza"); + LSTR MSG_BUTTON_PURGE = _UxGT("Spurga"); LSTR MSG_PAUSING = _UxGT("Messa in pausa..."); LSTR MSG_PAUSE_PRINT = _UxGT("Pausa stampa"); LSTR MSG_ADVANCED_PAUSE = _UxGT("Pausa Avanzata"); @@ -449,9 +511,12 @@ namespace Language_it { LSTR MSG_REMAINING_TIME = _UxGT("Rimanente"); LSTR MSG_PRINT_ABORTED = _UxGT("Stampa Annullata"); LSTR MSG_PRINT_DONE = _UxGT("Stampa Eseguita"); + LSTR MSG_PRINTER_KILLED = _UxGT("Stampante uccisa!"); + LSTR MSG_TURN_OFF = _UxGT("Spegni stampante"); LSTR MSG_NO_MOVE = _UxGT("Nessun Movimento"); LSTR MSG_KILLED = _UxGT("UCCISO. "); LSTR MSG_STOPPED = _UxGT("ARRESTATO. "); + LSTR MSG_FWRETRACT = _UxGT("Ritraz.da firmware"); LSTR MSG_CONTROL_RETRACT = _UxGT("Ritrai mm"); LSTR MSG_CONTROL_RETRACT_SWAP = _UxGT("Scamb. Ritrai mm"); LSTR MSG_CONTROL_RETRACTF = _UxGT("Ritrai V"); @@ -467,9 +532,11 @@ 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_PARK_FAILED = _UxGT("Parcheggio fallito"); + 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"); @@ -486,6 +553,7 @@ namespace Language_it { LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Rimuovi filam. *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Rimuovi tutto"); LSTR MSG_ATTACH_MEDIA = _UxGT("Collega media"); + LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Collega penna USB"); LSTR MSG_CHANGE_MEDIA = _UxGT("Cambia media"); LSTR MSG_RELEASE_MEDIA = _UxGT("Rilascia media"); LSTR MSG_ZPROBE_OUT = _UxGT("Z probe fuori piatto"); @@ -509,14 +577,19 @@ namespace Language_it { LSTR MSG_TOUCHMI_SAVE = _UxGT("Memorizzare"); LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Estendi TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Estendi Sonda-Z"); + LSTR MSG_MANUAL_PENUP = _UxGT("Penna su"); + LSTR MSG_MANUAL_PENDOWN = _UxGT("Penna giù"); LSTR MSG_BLTOUCH_STOW = _UxGT("Ritrai BLTouch"); LSTR MSG_MANUAL_STOW = _UxGT("Ritrai Sonda-Z"); - LSTR MSG_HOME_FIRST = _UxGT("Home %s%s%s prima"); + LSTR MSG_HOME_FIRST = _UxGT("Home %s prima"); LSTR MSG_ZPROBE_SETTINGS = _UxGT("Impostazioni sonda"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Offsets sonda"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Offset X sonda"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Offset Y sonda"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Offset Z sonda"); + LSTR MSG_ZPROBE_MARGIN = _UxGT("Margine sonda"); + LSTR MSG_Z_FEED_RATE = _UxGT("Velocità Z"); + LSTR MSG_ENABLE_HS_MODE = _UxGT("Abilita modo HS"); LSTR MSG_MOVE_NOZZLE_TO_BED = _UxGT("Muovi ugel.su letto"); LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); @@ -537,9 +610,9 @@ namespace Language_it { LSTR MSG_HALTED = _UxGT("STAMPANTE FERMATA"); LSTR MSG_PLEASE_WAIT = _UxGT("Attendere prego..."); LSTR MSG_PLEASE_RESET = _UxGT("Riavviare prego"); - LSTR MSG_PREHEATING = _UxGT("Preriscaldam..."); + LSTR MSG_PREHEATING = _UxGT("Preriscaldamento..."); LSTR MSG_HEATING = _UxGT("Riscaldamento..."); - LSTR MSG_COOLING = _UxGT("Raffreddamento.."); + LSTR MSG_COOLING = _UxGT("Raffreddamento..."); LSTR MSG_BED_HEATING = _UxGT("Risc. piatto..."); LSTR MSG_BED_COOLING = _UxGT("Raffr. piatto..."); LSTR MSG_PROBE_HEATING = _UxGT("Risc. sonda..."); @@ -554,8 +627,6 @@ namespace Language_it { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Calibra centro"); LSTR MSG_DELTA_SETTINGS = _UxGT("Impostaz. Delta"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Auto calibrazione"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Imp. altezza Delta"); - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Offset sonda-Z"); LSTR MSG_DELTA_DIAG_ROD = _UxGT("Barra Diagonale"); LSTR MSG_DELTA_HEIGHT = _UxGT("Altezza"); LSTR MSG_DELTA_RADIUS = _UxGT("Raggio"); @@ -568,6 +639,7 @@ namespace Language_it { LSTR MSG_MESH_LEVELING = _UxGT("Livel. Mesh"); LSTR MSG_MESH_DONE = _UxGT("Sond.mesh eseguito"); LSTR MSG_INFO_STATS_MENU = _UxGT("Statistiche"); + LSTR MSG_RESET_STATS = _UxGT("Reset stat.stampa?"); LSTR MSG_INFO_BOARD_MENU = _UxGT("Info. scheda"); LSTR MSG_INFO_THERMISTOR_MENU = _UxGT("Termistori"); LSTR MSG_INFO_EXTRUDERS = _UxGT("Estrusori"); @@ -582,34 +654,38 @@ namespace Language_it { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Luminosità Luci"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("STAMPANTE ERRATA"); + LSTR MSG_COLORS_GET = _UxGT("Ottieni colori"); + LSTR MSG_COLORS_SELECT = _UxGT("Selez.colori"); + LSTR MSG_COLORS_APPLIED = _UxGT("Colori applicati"); + LSTR MSG_COLORS_RED = _UxGT("Rosso"); + LSTR MSG_COLORS_GREEN = _UxGT("Verde"); + LSTR MSG_COLORS_BLUE = _UxGT("Blu"); + LSTR MSG_COLORS_WHITE = _UxGT("Bianco"); + LSTR MSG_UI_LANGUAGE = _UxGT("Lingua UI"); + LSTR MSG_SOUND_ENABLE = _UxGT("Abilita suono"); + LSTR MSG_LOCKSCREEN = _UxGT("Blocca Schermo"); + LSTR MSG_LOCKSCREEN_LOCKED = _UxGT("Stamp. bloccata,"); + LSTR MSG_LOCKSCREEN_UNLOCK = _UxGT("Scroll x sbloccare."); + LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Attendere fino al riavvio."); + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("Nessun supporto inserito."); - LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Attendere fino al riavvio."); LSTR MSG_PLEASE_PREHEAT = _UxGT("Si prega di preriscaldare l'hot end."); LSTR MSG_INFO_PRINT_COUNT_RESET = _UxGT("Azzera contatori stampa"); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Contatori stampa"); - LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completati"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Tempo totale"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Lavoro più lungo"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Totale estruso"); - LSTR MSG_COLORS_GET = _UxGT("Get Color"); - LSTR MSG_COLORS_SELECT = _UxGT("Seleziona colori"); - LSTR MSG_COLORS_APPLIED = _UxGT("Colori applicati"); - LSTR MSG_COLORS_RED = _UxGT("Rosso"); - LSTR MSG_COLORS_GREEN = _UxGT("Verde"); - LSTR MSG_COLORS_BLUE = _UxGT("Blu"); - LSTR MSG_COLORS_WHITE = _UxGT("Bianco"); - LSTR MSG_UI_LANGUAGE = _UxGT("Lingua UI"); - LSTR MSG_SOUND_ENABLE = _UxGT("Abilita suono"); - LSTR MSG_LOCKSCREEN = _UxGT("Blocca Schermo"); #else LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("No Supporto"); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Prerisc. hot end."); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Stampe"); - LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completati"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Durata"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Più lungo"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Estruso"); #endif + + LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completate"); LSTR MSG_INFO_MIN_TEMP = _UxGT("Temp min"); LSTR MSG_INFO_MAX_TEMP = _UxGT("Temp max"); LSTR MSG_INFO_PSU = _UxGT("Alimentatore"); @@ -624,10 +700,14 @@ namespace Language_it { LSTR MSG_FILAMENT_CHANGE_OPTION_HEADER = _UxGT("OPZIONI RIPRESA:"); LSTR MSG_FILAMENT_CHANGE_OPTION_PURGE = _UxGT("Spurga di più"); LSTR MSG_FILAMENT_CHANGE_OPTION_RESUME = _UxGT("Riprendi stampa"); + LSTR MSG_FILAMENT_CHANGE_PURGE_CONTINUE = _UxGT("Spurga o continua?"); LSTR MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Ugello: "); LSTR MSG_RUNOUT_SENSOR = _UxGT("Sens.filo termin."); // Max 17 characters LSTR MSG_RUNOUT_DISTANCE_MM = _UxGT("Dist mm filo term."); LSTR MSG_RUNOUT_ENABLE = _UxGT("Abil.filo termin."); + LSTR MSG_RUNOUT_ACTIVE = _UxGT("Filo termin. attivo"); + LSTR MSG_INVERT_EXTRUDER = _UxGT("Inverti estrusore"); + LSTR MSG_EXTRUDER_MIN_TEMP = _UxGT("Temp.min estrusore"); LSTR MSG_FANCHECK = _UxGT("Verif.tacho vent."); // Max 17 characters LSTR MSG_KILL_HOMING_FAILED = _UxGT("Home fallito"); LSTR MSG_LCD_PROBING_FAILED = _UxGT("Sondaggio fallito"); @@ -769,4 +849,28 @@ namespace Language_it { LSTR MSG_USB_DISK = _UxGT("Disco USB"); LSTR MSG_HOST_SHUTDOWN = _UxGT("Arresta host"); + +// DGUS-Specific message strings, not used elsewhere + LSTR DGUS_MSG_NOT_WHILE_PRINTING = _UxGT("Non ammesso durante la stampa"); + LSTR DGUS_MSG_NOT_WHILE_IDLE = _UxGT("Non ammesso mentre è in riposo"); + LSTR DGUS_MSG_NO_FILE_SELECTED = _UxGT("Nessun file selezionato"); + LSTR DGUS_MSG_TEMP_TOO_LOW = _UxGT("Temperatura troppo bassa"); + LSTR DGUS_MSG_EXECUTING_COMMAND = _UxGT("Esecuzione del comando..."); + LSTR DGUS_MSG_BED_PID_DISABLED = _UxGT("PID letto disabilitato"); + LSTR DGUS_MSG_PID_DISABLED = _UxGT("PID disabilitato"); + LSTR DGUS_MSG_PID_AUTOTUNING = _UxGT("Calibrazione PID..."); + LSTR DGUS_MSG_INVALID_RECOVERY_DATA = _UxGT("Dati di recupero non validi"); + + LSTR DGUS_MSG_HOMING_REQUIRED = _UxGT("Azzeramento richiesto"); + LSTR DGUS_MSG_BUSY = _UxGT("Occupato"); + LSTR DGUS_MSG_HOMING = _UxGT("Azzeramento..."); + LSTR DGUS_MSG_FW_OUTDATED = _UxGT("Richiesto aggiornamento DWIN GUI/OS"); + LSTR DGUS_MSG_ABL_REQUIRED = _UxGT("Richiesto autolivellamento letto"); + LSTR DGUS_MSG_PROBING_FAILED = _UxGT("Sondaggio fallito"); + LSTR DGUS_MSG_PROBING_SUCCESS = _UxGT("Sondaggio effettuato"); + LSTR DGUS_MSG_RESET_EEPROM = _UxGT("Reset EEPROM"); + LSTR DGUS_MSG_WRITE_EEPROM_FAILED = _UxGT("Scrittura EEPROM fallita"); + LSTR DGUS_MSG_READ_EEPROM_FAILED = _UxGT("Lettura EEPROM fallita"); + LSTR DGUS_MSG_FILAMENT_RUNOUT = _UxGT("Filament runout E%d"); + } diff --git a/Marlin/src/lcd/language/language_jp_kana.h b/Marlin/src/lcd/language/language_jp_kana.h index 0a53ee50d21f..335d4533daa6 100644 --- a/Marlin/src/lcd/language/language_jp_kana.h +++ b/Marlin/src/lcd/language/language_jp_kana.h @@ -92,11 +92,14 @@ namespace Language_jp_kana { LSTR MSG_MOVE_X = _UxGT("Xジク イドウ"); // "Move X" LSTR MSG_MOVE_Y = _UxGT("Yジク イドウ"); // "Move Y" LSTR MSG_MOVE_Z = _UxGT("Zジク イドウ"); // "Move Z" + LSTR MSG_MOVE_N = _UxGT("@ジク イドウ"); // "Move @" LSTR MSG_MOVE_E = _UxGT("エクストルーダー"); // "Extruder" + LSTR MSG_MOVE_EN = _UxGT("* エクストルーダー"); // "En" LSTR MSG_MOVE_N_MM = _UxGT("$mm イドウ"); // "Move 0.025mm" 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" @@ -111,7 +114,6 @@ namespace Language_jp_kana { LSTR MSG_AUTOTEMP = _UxGT("ジドウオンドセイギョ"); // "Autotemp" LSTR MSG_LCD_ON = _UxGT("オン"); // "On" LSTR MSG_LCD_OFF = _UxGT("オフ"); // "Off" - LSTR MSG_SELECT = _UxGT("センタク"); // "Select" LSTR MSG_SELECT_E = _UxGT("センタク *"); LSTR MSG_ACC = _UxGT("カソクド mm/s") SUPERSCRIPT_TWO; // "Accel" LSTR MSG_JERK = _UxGT("ヤクドウ mm/s"); // "Jerk" @@ -173,7 +175,7 @@ namespace Language_jp_kana { LSTR MSG_ZPROBE_OUT = _UxGT("Zプローブ ベッドガイ"); // "Z probe out. bed" LSTR MSG_BLTOUCH_SELFTEST = _UxGT("BLTouch ジコシンダン"); // "BLTouch Self-Test" LSTR MSG_BLTOUCH_RESET = _UxGT("BLTouch リセット"); // "Reset BLTouch" - LSTR MSG_HOME_FIRST = _UxGT("サキニ %s%s%s ヲフッキサセテクダサイ"); // "Home ... first" + LSTR MSG_HOME_FIRST = _UxGT("サキニ %s ヲフッキサセテクダサイ"); // "Home ... first" LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Zオフセット"); // "Z Offset" LSTR MSG_BABYSTEP_X = _UxGT("Xジク ビドウ"); // "Babystep X" LSTR MSG_BABYSTEP_Y = _UxGT("Yジク ビドウ"); // "Babystep Y" diff --git a/Marlin/src/lcd/language/language_nl.h b/Marlin/src/lcd/language/language_nl.h index 6b308ba48bac..9ad16bcd8c14 100644 --- a/Marlin/src/lcd/language/language_nl.h +++ b/Marlin/src/lcd/language/language_nl.h @@ -84,6 +84,7 @@ namespace Language_nl { LSTR MSG_MOVE_X = _UxGT("Verplaats X"); LSTR MSG_MOVE_Y = _UxGT("Verplaats Y"); LSTR MSG_MOVE_Z = _UxGT("Verplaats Z"); + LSTR MSG_MOVE_N = _UxGT("Verplaats @"); LSTR MSG_MOVE_E = _UxGT("Extruder"); LSTR MSG_MOVE_EN = _UxGT("Extruder *"); LSTR MSG_MOVE_N_MM = _UxGT("Verplaats $mm"); @@ -107,7 +108,6 @@ namespace Language_nl { LSTR MSG_AUTOTEMP = _UxGT("Autotemp"); LSTR MSG_LCD_ON = _UxGT("Aan"); LSTR MSG_LCD_OFF = _UxGT("Uit"); - LSTR MSG_SELECT = _UxGT("Selecteer"); LSTR MSG_SELECT_E = _UxGT("Selecteer *"); LSTR MSG_ACC = _UxGT("Versn"); LSTR MSG_TEMPERATURE = _UxGT("Temperatuur"); @@ -152,7 +152,7 @@ namespace Language_nl { LSTR MSG_ZPROBE_OUT = _UxGT("Z probe uit. bed"); LSTR MSG_BLTOUCH_SELFTEST = _UxGT("BLTouch Zelf-Test"); LSTR MSG_BLTOUCH_RESET = _UxGT("Reset BLTouch"); - LSTR MSG_HOME_FIRST = _UxGT("Home %s%s%s Eerst"); + LSTR MSG_HOME_FIRST = _UxGT("Home %s Eerst"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Z Offset"); // accepted English term in Dutch LSTR MSG_BABYSTEP_X = _UxGT("Babystap X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystap Y"); @@ -173,8 +173,8 @@ namespace Language_nl { LSTR MSG_DELTA_CALIBRATE_Y = _UxGT("Kalibreer Y"); LSTR MSG_DELTA_CALIBRATE_Z = _UxGT("Kalibreer Z"); LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Kalibreer Midden"); + LSTR MSG_DELTA_SETTINGS = _UxGT("Delta conf"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Auto Calibratie"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Zet Delta Hoogte"); LSTR MSG_CASE_LIGHT = _UxGT("Case licht"); diff --git a/Marlin/src/lcd/language/language_pl.h b/Marlin/src/lcd/language/language_pl.h index 630f94ab12df..9273eb105c8a 100644 --- a/Marlin/src/lcd/language/language_pl.h +++ b/Marlin/src/lcd/language/language_pl.h @@ -235,6 +235,7 @@ namespace Language_pl { LSTR MSG_MOVE_X = _UxGT("Przesuń w X"); LSTR MSG_MOVE_Y = _UxGT("Przesuń w Y"); LSTR MSG_MOVE_Z = _UxGT("Przesuń w Z"); + LSTR MSG_MOVE_N = _UxGT("Przesuń w @"); LSTR MSG_MOVE_E = _UxGT("Ekstruzja (os E)"); LSTR MSG_MOVE_EN = _UxGT("Ekstruzja (os E) *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Dysza za zimna"); @@ -268,7 +269,6 @@ namespace Language_pl { LSTR MSG_PID_AUTOTUNE = _UxGT("PID Autostrojenie"); LSTR MSG_PID_AUTOTUNE_E = _UxGT("PID Autostrojenie *"); LSTR MSG_PID_AUTOTUNE_DONE = _UxGT("Strojenie PID zakończone"); - LSTR MSG_SELECT = _UxGT("Wybierz"); LSTR MSG_SELECT_E = _UxGT("Wybierz *"); LSTR MSG_ACC = _UxGT("Przyspieszenie"); LSTR MSG_JERK = _UxGT("Zryw"); @@ -372,7 +372,7 @@ namespace Language_pl { LSTR MSG_BLTOUCH_SELFTEST = _UxGT("BLTouch Self-Test"); LSTR MSG_BLTOUCH_RESET = _UxGT("Reset BLTouch"); LSTR MSG_BLTOUCH_MODE_CHANGE = _UxGT("UWAGA: Złe ustawienia mogą uszkodzić drukarkę. Kontynuować?"); - LSTR MSG_HOME_FIRST = _UxGT("Najpierw Home %s%s%s"); + LSTR MSG_HOME_FIRST = _UxGT("Najpierw Home %s"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Offset Z"); LSTR MSG_MOVE_NOZZLE_TO_BED = _UxGT("Przesuń dyszę do stołu"); LSTR MSG_BABYSTEP_TOTAL = _UxGT("Łącznie"); @@ -400,8 +400,6 @@ namespace Language_pl { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Kalibruj środek"); LSTR MSG_DELTA_SETTINGS = _UxGT("Ustawienia delty"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Auto kalibrowanie"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Ustaw wysokość delty"); - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Przesun. Z sondy"); LSTR MSG_DELTA_DIAG_ROD = _UxGT("Ukośne ramię"); LSTR MSG_DELTA_HEIGHT = _UxGT("Wysokość"); LSTR MSG_DELTA_RADIUS = _UxGT("Promień"); @@ -540,11 +538,3 @@ namespace Language_pl { LSTR MSG_CALIBRATION_FAILED = _UxGT("Kalibracja nie powiodła się"); } - -#if FAN_COUNT == 1 - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED -#else - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N -#endif diff --git a/Marlin/src/lcd/language/language_pt.h b/Marlin/src/lcd/language/language_pt.h index 69df8bdf5427..0672f2556084 100644 --- a/Marlin/src/lcd/language/language_pt.h +++ b/Marlin/src/lcd/language/language_pt.h @@ -29,7 +29,7 @@ * See also https://marlinfw.org/docs/development/lcd_language.html */ - #define DISPLAY_CHARSET_ISO10646_1 +#define DISPLAY_CHARSET_ISO10646_1 namespace Language_pt { using namespace Language_en; // Inherit undefined strings from English @@ -78,6 +78,7 @@ namespace Language_pt { LSTR MSG_MOVE_X = _UxGT("Mover X"); LSTR MSG_MOVE_Y = _UxGT("Mover Y"); LSTR MSG_MOVE_Z = _UxGT("Mover Z"); + LSTR MSG_MOVE_N = _UxGT("Mover @"); LSTR MSG_MOVE_E = _UxGT("Mover Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Mover Extrusor *"); LSTR MSG_MOVE_N_MM = _UxGT("Mover $mm"); diff --git a/Marlin/src/lcd/language/language_pt_br.h b/Marlin/src/lcd/language/language_pt_br.h index 5b73d6df6def..d52728d10726 100644 --- a/Marlin/src/lcd/language/language_pt_br.h +++ b/Marlin/src/lcd/language/language_pt_br.h @@ -209,6 +209,7 @@ namespace Language_pt_br { LSTR MSG_MOVE_X = _UxGT("Mover X"); LSTR MSG_MOVE_Y = _UxGT("Mover Y"); LSTR MSG_MOVE_Z = _UxGT("Mover Z"); + LSTR MSG_MOVE_N = _UxGT("Mover @"); LSTR MSG_MOVE_E = _UxGT("Mover Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Mover Extrusor *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Extrus. mto fria"); @@ -235,7 +236,6 @@ namespace Language_pt_br { LSTR MSG_AUTOTEMP = _UxGT("Temp. Automática"); LSTR MSG_LCD_ON = _UxGT("Ligado"); LSTR MSG_LCD_OFF = _UxGT("Desligado"); - LSTR MSG_SELECT = _UxGT("Selecionar"); LSTR MSG_SELECT_E = _UxGT("Selecionar *"); LSTR MSG_ACC = _UxGT("Acel."); LSTR MSG_JERK = _UxGT("Arrancada"); @@ -340,7 +340,7 @@ namespace Language_pt_br { LSTR MSG_BLTOUCH_DEPLOY = _UxGT("Estender BLTouch"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Estender Sonda-Z"); LSTR MSG_MANUAL_STOW = _UxGT("Recolher Sonda-Z"); - LSTR MSG_HOME_FIRST = _UxGT("Home %s%s%s Primeiro"); + LSTR MSG_HOME_FIRST = _UxGT("Home %s Primeiro"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Compensar Sonda"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Compensar Sonda em X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Compensar Sonda em Y"); @@ -373,8 +373,6 @@ namespace Language_pt_br { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Calibrar Centro"); LSTR MSG_DELTA_SETTINGS = _UxGT("Configuração Delta"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Auto-Calibração"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Calibrar Altura"); - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Desloc. Sonda Z"); LSTR MSG_DELTA_DIAG_ROD = _UxGT("Haste Diagonal"); LSTR MSG_DELTA_HEIGHT = _UxGT("Altura"); LSTR MSG_DELTA_RADIUS = _UxGT("Raio"); diff --git a/Marlin/src/lcd/language/language_ro.h b/Marlin/src/lcd/language/language_ro.h index 79160624e7a4..4eefc11cb9c4 100644 --- a/Marlin/src/lcd/language/language_ro.h +++ b/Marlin/src/lcd/language/language_ro.h @@ -222,6 +222,7 @@ namespace Language_ro { LSTR MSG_MOVE_X = _UxGT("Move X"); LSTR MSG_MOVE_Y = _UxGT("Move Y"); LSTR MSG_MOVE_Z = _UxGT("Move Z"); + LSTR MSG_MOVE_N = _UxGT("Move @"); LSTR MSG_MOVE_E = _UxGT("Extruder"); LSTR MSG_MOVE_EN = _UxGT("Extruder *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Capat Prea Rece"); @@ -263,7 +264,6 @@ namespace Language_ro { LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Autotune failed! Bad extruder."); LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Autotune failed! Temperature too high."); LSTR MSG_PID_TIMEOUT = _UxGT("Autotune failed! Timeout."); - LSTR MSG_SELECT = _UxGT("Select"); LSTR MSG_SELECT_E = _UxGT("Select *"); LSTR MSG_ACC = _UxGT("Accel"); LSTR MSG_JERK = _UxGT("Jerk"); @@ -317,9 +317,9 @@ namespace Language_ro { LSTR MSG_LOAD_EEPROM = _UxGT("Load Settings"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Restore Defaults"); LSTR MSG_INIT_EEPROM = _UxGT("Initialize EEPROM"); - LSTR MSG_ERR_EEPROM_CRC = _UxGT("EEPROM CRC Error"); - LSTR MSG_ERR_EEPROM_INDEX = _UxGT("EEPROM Index Error"); - LSTR MSG_ERR_EEPROM_VERSION = _UxGT("EEPROM Version Error"); + LSTR MSG_ERR_EEPROM_CRC = _UxGT("Err: EEPROM CRC"); + LSTR MSG_ERR_EEPROM_SIZE = _UxGT("Err: Mărimea EEPROM"); + LSTR MSG_ERR_EEPROM_VERSION = _UxGT("Err: Versiunea EEPROM"); LSTR MSG_SETTINGS_STORED = _UxGT("Settings Stored"); LSTR MSG_MEDIA_UPDATE = _UxGT("Media Update"); LSTR MSG_RESET_PRINTER = _UxGT("Reset Imprimanta"); @@ -419,7 +419,7 @@ namespace Language_ro { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Deploy TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Deploy Z-Probe"); LSTR MSG_MANUAL_STOW = _UxGT("Stow Z-Probe"); - LSTR MSG_HOME_FIRST = _UxGT("Home %s%s%s First"); + LSTR MSG_HOME_FIRST = _UxGT("Home %s First"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Probe Offsets"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Probe X Offset"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Probe Y Offset"); @@ -452,8 +452,6 @@ namespace Language_ro { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Calibrate Center"); LSTR MSG_DELTA_SETTINGS = _UxGT("Delta Settings"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Auto Calibration"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Set Delta Height"); - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Probe Z-offset"); LSTR MSG_DELTA_DIAG_ROD = _UxGT("Diag Rod"); LSTR MSG_DELTA_HEIGHT = _UxGT("Inaltime"); LSTR MSG_DELTA_RADIUS = _UxGT("Radius"); @@ -608,11 +606,3 @@ namespace Language_ro { LSTR MSG_REHEAT = _UxGT("Reincalzire"); LSTR MSG_REHEATING = _UxGT("Reincalzire..."); } - -#if FAN_COUNT == 1 - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED -#else - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N -#endif diff --git a/Marlin/src/lcd/language/language_ru.h b/Marlin/src/lcd/language/language_ru.h index 5f05f1d2beb3..03380af15e84 100644 --- a/Marlin/src/lcd/language/language_ru.h +++ b/Marlin/src/lcd/language/language_ru.h @@ -218,10 +218,10 @@ namespace Language_ru { LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Построить свою сетку"); LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("Правка сетки завершена"); #else - LSTR MSG_UBL_SET_TEMP_BED = LCD_STR_THERMOMETER _UxGT(" стола, ") LCD_STR_DEGREE "C"; - LSTR MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Своя ") LCD_STR_THERMOMETER _UxGT(" стола,") LCD_STR_DEGREE "C"; - LSTR MSG_UBL_SET_TEMP_HOTEND = LCD_STR_THERMOMETER _UxGT(" сопла, ") LCD_STR_DEGREE "C"; - LSTR MSG_UBL_HOTEND_TEMP_CUSTOM = _UxGT("Своя ") LCD_STR_THERMOMETER _UxGT(" сопла,") LCD_STR_DEGREE "C"; + LSTR MSG_UBL_SET_TEMP_BED = LCD_STR_THERMOMETER _UxGT(" стола, ") LCD_STR_DEGREE _UxGT("C"); + LSTR MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Своя ") LCD_STR_THERMOMETER _UxGT(" стола,") LCD_STR_DEGREE _UxGT("C"); + LSTR MSG_UBL_SET_TEMP_HOTEND = LCD_STR_THERMOMETER _UxGT(" сопла, ") LCD_STR_DEGREE _UxGT("C"); + LSTR MSG_UBL_HOTEND_TEMP_CUSTOM = _UxGT("Своя ") LCD_STR_THERMOMETER _UxGT(" сопла,") LCD_STR_DEGREE _UxGT("C"); LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Построить свою"); LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("Правка завершена"); #endif @@ -336,19 +336,19 @@ 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мм"); LSTR MSG_MOVE_100MM = _UxGT("Движение 100mm"); LSTR MSG_SPEED = _UxGT("Скорость"); LSTR MSG_BED_Z = _UxGT("Z стола"); - LSTR MSG_NOZZLE = _UxGT("Сопло, ") LCD_STR_DEGREE "C"; + LSTR MSG_NOZZLE = _UxGT("Сопло, ") LCD_STR_DEGREE _UxGT("C"); LSTR MSG_NOZZLE_N = _UxGT("Сопло ~"); LSTR MSG_NOZZLE_PARKED = _UxGT("Сопло запарковано"); LSTR MSG_NOZZLE_STANDBY = _UxGT("Сопло ожидает"); - LSTR MSG_BED = _UxGT("Стол, ") LCD_STR_DEGREE "C"; - LSTR MSG_CHAMBER = _UxGT("Камера,") LCD_STR_DEGREE "C"; + LSTR MSG_BED = _UxGT("Стол, ") LCD_STR_DEGREE _UxGT("C"); + LSTR MSG_CHAMBER = _UxGT("Камера,") LCD_STR_DEGREE _UxGT("C"); #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_COOLER = _UxGT("Охлаждение лазера"); LSTR MSG_COOLER_TOGGLE = _UxGT("Переключ. охлажд."); @@ -386,7 +386,6 @@ namespace Language_ru { LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Сбой автоподбора! Температура повышена."); LSTR MSG_PID_TIMEOUT = _UxGT("Сбой автоподбора! Завершение времени."); - LSTR MSG_SELECT = _UxGT("Выбор"); LSTR MSG_SELECT_E = _UxGT("Выбор *"); LSTR MSG_ACC = _UxGT("Ускорение"); LSTR MSG_JERK = _UxGT("Рывок"); @@ -455,7 +454,7 @@ namespace Language_ru { LSTR MSG_INIT_EEPROM = _UxGT("Инициализ. EEPROM"); #endif LSTR MSG_ERR_EEPROM_CRC = _UxGT("Сбой EEPROM: CRC"); - LSTR MSG_ERR_EEPROM_INDEX = _UxGT("Сбой EEPROM: индекс"); + LSTR MSG_ERR_EEPROM_SIZE = _UxGT("Сбой EEPROM: размер"); LSTR MSG_ERR_EEPROM_VERSION = _UxGT("Сбой EEPROM: версия"); LSTR MSG_SETTINGS_STORED = _UxGT("Параметры сохранены"); LSTR MSG_MEDIA_UPDATE = _UxGT("Обновление прошивки"); @@ -582,7 +581,7 @@ namespace Language_ru { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Установить TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Установить зонд"); LSTR MSG_MANUAL_STOW = _UxGT("Загрузить зонд"); - LSTR MSG_HOME_FIRST = _UxGT("Сначала паркуй %s%s%s"); + LSTR MSG_HOME_FIRST = _UxGT("Сначала паркуй %s"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Смещения Z-зонда"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Смещение X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Смещение Y"); @@ -609,9 +608,6 @@ namespace Language_ru { LSTR MSG_ERR_MINTEMP = _UxGT("Ошибка: Т мин."); LSTR MSG_HALTED = _UxGT("ПРИНТЕР ОСТАНОВЛЕН"); LSTR MSG_PLEASE_RESET = _UxGT("Сделайте сброс"); - LSTR MSG_SHORT_DAY = _UxGT("д"); // One character only - LSTR MSG_SHORT_HOUR = _UxGT("ч"); // One character only - LSTR MSG_SHORT_MINUTE = _UxGT("м"); // One character only LSTR MSG_HEATING = _UxGT("Нагрев..."); LSTR MSG_COOLING = _UxGT("Охлаждение..."); LSTR MSG_BED_HEATING = _UxGT("Нагрев стола..."); @@ -628,12 +624,6 @@ namespace Language_ru { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Калибровать центр"); LSTR MSG_DELTA_SETTINGS = _UxGT("Настройки Delta"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Авто калибровка"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Высота Delta"); - #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Зондировать Z-смещения"); - #else - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Зондир. Z-смещения"); - #endif LSTR MSG_DELTA_DIAG_ROD = _UxGT("Стержень диаг."); LSTR MSG_DELTA_HEIGHT = _UxGT("Высота"); LSTR MSG_DELTA_RADIUS = _UxGT("Радиус"); @@ -878,12 +868,8 @@ namespace Language_ru { LSTR MSG_SD_CARD = _UxGT("SD Карта"); LSTR MSG_USB_DISK = _UxGT("USB Диск"); -} -#if FAN_COUNT == 1 - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED -#else - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N -#endif + LSTR MSG_SHORT_DAY = _UxGT("д"); // One character only + LSTR MSG_SHORT_HOUR = _UxGT("ч"); // One character only + LSTR MSG_SHORT_MINUTE = _UxGT("м"); // One character only +} diff --git a/Marlin/src/lcd/language/language_sk.h b/Marlin/src/lcd/language/language_sk.h index 124080de0b85..024d02b71345 100644 --- a/Marlin/src/lcd/language/language_sk.h +++ b/Marlin/src/lcd/language/language_sk.h @@ -50,12 +50,15 @@ namespace Language_sk { LSTR WELCOME_MSG = MACHINE_NAME _UxGT(" pripravená."); LSTR MSG_YES = _UxGT("ÁNO"); LSTR MSG_NO = _UxGT("NIE"); + LSTR MSG_HIGH = _UxGT("VYSOKÁ"); + LSTR MSG_LOW = _UxGT("NÍZKA"); LSTR MSG_BACK = _UxGT("Naspäť"); + LSTR MSG_ERROR = _UxGT("Chyba"); LSTR MSG_MEDIA_ABORTING = _UxGT("Ruším..."); LSTR MSG_MEDIA_INSERTED = _UxGT("Karta vložená"); LSTR MSG_MEDIA_REMOVED = _UxGT("Karta vybraná"); LSTR MSG_MEDIA_WAITING = _UxGT("Čakám na kartu"); - LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Inicial. SD zlyhala"); + LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Inicial.karty zlyhala"); LSTR MSG_MEDIA_READ_ERROR = _UxGT("Chyba čítania karty"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("USB zaria. odstrán."); LSTR MSG_MEDIA_USB_FAILED = _UxGT("Chyba spúšťania USB"); @@ -64,6 +67,8 @@ namespace Language_sk { LSTR MSG_LCD_SOFT_ENDSTOPS = _UxGT("Soft. endstopy"); LSTR MSG_MAIN = _UxGT("Hlavná ponuka"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Pokročilé nastav."); + LSTR MSG_TOOLBAR_SETUP = _UxGT("Panel nástrojov"); + LSTR MSG_OPTION_DISABLED = _UxGT("Možnosť vypnutá"); LSTR MSG_CONFIGURATION = _UxGT("Konfigurácia"); LSTR MSG_RUN_AUTO_FILES = _UxGT("Auto-štart"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Uvolniť motory"); @@ -75,8 +80,10 @@ namespace Language_sk { LSTR MSG_AUTO_HOME_X = _UxGT("Domov os X"); LSTR MSG_AUTO_HOME_Y = _UxGT("Domov os Y"); LSTR MSG_AUTO_HOME_Z = _UxGT("Domov os Z"); + LSTR MSG_Z_AFTER_HOME = _UxGT("Os Z po domov.poz."); LSTR MSG_FILAMENT_SET = _UxGT("Nastav. filamentu"); LSTR MSG_FILAMENT_MAN = _UxGT("Správa filamentu"); + LSTR MSG_MANUAL_LEVELING = _UxGT("Ručné rovnanie"); LSTR MSG_LEVBED_FL = _UxGT("Ľavý predný"); LSTR MSG_LEVBED_FR = _UxGT("Pravý predný"); LSTR MSG_LEVBED_C = _UxGT("Stred"); @@ -98,6 +105,7 @@ namespace Language_sk { LSTR MSG_HOME_OFFSET_Y = _UxGT("Y Ofset"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Z Ofset"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Ofsety nastavené"); + LSTR MSG_ERR_M428_TOO_FAR = _UxGT("Chyba: Príliš ďaleko!"); LSTR MSG_TRAMMING_WIZARD = _UxGT("Spriev. vyrovn."); LSTR MSG_SELECT_ORIGIN = _UxGT("Vyberte začiatok"); LSTR MSG_LAST_VALUE_SP = _UxGT("Posl. hodnota "); @@ -109,7 +117,14 @@ namespace Language_sk { LSTR MSG_PREHEAT_1_ALL = _UxGT("Zahriať ") PREHEAT_1_LABEL _UxGT(" všetko"); LSTR MSG_PREHEAT_1_BEDONLY = _UxGT("Zahriať ") PREHEAT_1_LABEL _UxGT(" podlož"); LSTR MSG_PREHEAT_1_SETTINGS = _UxGT("Zahriať ") PREHEAT_1_LABEL _UxGT(" nast."); - + #ifdef PREHEAT_2_LABEL + LSTR MSG_PREHEAT_2 = _UxGT("Zahriať ") PREHEAT_2_LABEL; + LSTR MSG_PREHEAT_2_SETTINGS = _UxGT("Zahriať ") PREHEAT_2_LABEL _UxGT(" nast."); + #endif + #ifdef PREHEAT_3_LABEL + LSTR MSG_PREHEAT_3 = _UxGT("Zahriať ") PREHEAT_3_LABEL; + LSTR MSG_PREHEAT_3_SETTINGS = _UxGT("Zahriať ") PREHEAT_3_LABEL _UxGT(" nast."); + #endif LSTR MSG_PREHEAT_M = _UxGT("Zahriať $"); LSTR MSG_PREHEAT_M_H = _UxGT("Zahriať $ ~"); LSTR MSG_PREHEAT_M_END = _UxGT("Zahriať $ hotend"); @@ -118,6 +133,7 @@ namespace Language_sk { LSTR MSG_PREHEAT_M_BEDONLY = _UxGT("Zahriať $ podlož"); LSTR MSG_PREHEAT_M_SETTINGS = _UxGT("Zahriať $ nast."); #endif + LSTR MSG_PREHEAT_HOTEND = _UxGT("Zahriať hotend"); LSTR MSG_PREHEAT_CUSTOM = _UxGT("Vlastná teplota"); LSTR MSG_COOLDOWN = _UxGT("Schladiť"); @@ -144,7 +160,8 @@ namespace Language_sk { LSTR MSG_BED_LEVELING = _UxGT("Vyrovnanie podložky"); LSTR MSG_LEVEL_BED = _UxGT("Vyrovnať podložku"); LSTR MSG_BED_TRAMMING = _UxGT("Vyrovnať rohy"); - LSTR MSG_BED_TRAMMING_RAISE = _UxGT("Zdvyhnite podl., kým sa nezopne sonda"); + LSTR MSG_BED_TRAMMING_MANUAL = _UxGT("Ručné vyrovnanie"); + LSTR MSG_BED_TRAMMING_RAISE = _UxGT("Zdvihnite podl., kým sa nezopne sonda"); LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Rohy sú vrámci odchyl. Vyrovnajte podl."); LSTR MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Dobré body: "); LSTR MSG_BED_TRAMMING_LAST_Z = _UxGT("Posl. Z: "); @@ -155,10 +172,19 @@ namespace Language_sk { LSTR MSG_MESH_VIEW = _UxGT("Zobraz. sieť bodov"); LSTR MSG_EDITING_STOPPED = _UxGT("Koniec úprav siete"); LSTR MSG_NO_VALID_MESH = _UxGT("Neplatná sieť bodov"); + LSTR MSG_ACTIVATE_MESH = _UxGT("Zapnúť vyrovnanie"); LSTR MSG_PROBING_POINT = _UxGT("Skúšam bod"); LSTR MSG_MESH_X = _UxGT("Index X"); LSTR MSG_MESH_Y = _UxGT("Index Y"); + LSTR MSG_MESH_INSET = _UxGT("Vložiť sieť"); + LSTR MSG_MESH_MIN_X = _UxGT("Min. X sieťe"); + LSTR MSG_MESH_MAX_X = _UxGT("Max. X sieťe"); + LSTR MSG_MESH_MIN_Y = _UxGT("Min. Y sieťe"); + LSTR MSG_MESH_MAX_Y = _UxGT("Max. Y sieťe"); + LSTR MSG_MESH_AMAX = _UxGT("Maximál. oblasť"); + LSTR MSG_MESH_CENTER = _UxGT("Stredová oblasť"); LSTR MSG_MESH_EDIT_Z = _UxGT("Hodnota Z"); + LSTR MSG_MESH_CANCEL = _UxGT("Mriežka zrušená"); LSTR MSG_CUSTOM_COMMANDS = _UxGT("Vlastné príkazy"); LSTR MSG_M48_TEST = _UxGT("M48 Test sondy"); LSTR MSG_M48_POINT = _UxGT("M48 Bod"); @@ -177,6 +203,9 @@ namespace Language_sk { LSTR MSG_UBL_TOOLS = _UxGT("Nástroje UBL"); LSTR MSG_UBL_LEVEL_BED = _UxGT("UBL rovnanie"); LSTR MSG_LCD_TILTING_MESH = _UxGT("Vyrovnávam bod"); + LSTR MSG_UBL_TILT_MESH = _UxGT("Nakloniť sieť"); + LSTR MSG_UBL_TILTING_GRID = _UxGT("Veľkosť nakl. siete"); + LSTR MSG_UBL_MESH_TILTED = _UxGT("Sieť naklonená"); LSTR MSG_UBL_MANUAL_MESH = _UxGT("Manuálna sieť bodov"); LSTR MSG_UBL_MESH_WIZARD = _UxGT("Spriev. UBL rovnan."); LSTR MSG_UBL_BC_INSERT = _UxGT("Položte a zmerajte"); @@ -225,6 +254,8 @@ namespace Language_sk { LSTR MSG_UBL_MANUAL_FILLIN = _UxGT("Ručné vyplnenie"); LSTR MSG_UBL_SMART_FILLIN = _UxGT("Chytré vyplnenie"); LSTR MSG_UBL_FILLIN_MESH = _UxGT("Vyplniť mriežku"); + LSTR MSG_UBL_MESH_FILLED = _UxGT("Doplnené chýb. body"); + LSTR MSG_UBL_MESH_INVALID = _UxGT("Neplatná sieť"); LSTR MSG_UBL_INVALIDATE_ALL = _UxGT("Zrušiť všetko"); LSTR MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Zrušiť najbližší"); LSTR MSG_UBL_FINE_TUNE_ALL = _UxGT("Upraviť všetky"); @@ -233,8 +264,10 @@ namespace Language_sk { LSTR MSG_UBL_STORAGE_SLOT = _UxGT("Pamäťový slot"); LSTR MSG_UBL_LOAD_MESH = _UxGT("Načítať sieť bodov"); LSTR MSG_UBL_SAVE_MESH = _UxGT("Uložiť sieť bodov"); + LSTR MSG_UBL_INVALID_SLOT = _UxGT("Najskôr zvol. slot siete"); LSTR MSG_MESH_LOADED = _UxGT("Sieť %i načítaná"); LSTR MSG_MESH_SAVED = _UxGT("Sieť %i uložená"); + LSTR MSG_MESH_ACTIVE = _UxGT("Sieť %i aktívna"); LSTR MSG_UBL_NO_STORAGE = _UxGT("Nedostatok miesta"); LSTR MSG_UBL_SAVE_ERROR = _UxGT("Chyba: Ukladanie UBL"); LSTR MSG_UBL_RESTORE_ERROR = _UxGT("Chyba: Obnovenie UBL"); @@ -285,11 +318,14 @@ namespace Language_sk { LSTR MSG_MOVE_01MM = _UxGT("Posunúť o 0,1mm"); LSTR MSG_MOVE_1MM = _UxGT("Posunúť o 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Posunúť o 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Posunúť o 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Posunúť o 100mm"); LSTR MSG_MOVE_0001IN = _UxGT("Posunúť o 0,001in"); LSTR MSG_MOVE_001IN = _UxGT("Posunúť o 0,01in"); LSTR MSG_MOVE_01IN = _UxGT("Posunúť o 0,1in"); + LSTR MSG_MOVE_05IN = _UxGT("Posunúť o 0,5in"); LSTR MSG_MOVE_1IN = _UxGT("Posunúť o 1,0in"); + LSTR MSG_LIVE_MOVE = _UxGT("Živý pohyb"); LSTR MSG_SPEED = _UxGT("Rýchlosť"); LSTR MSG_BED_Z = _UxGT("Výška podl."); LSTR MSG_NOZZLE = _UxGT("Tryska"); @@ -301,6 +337,7 @@ namespace Language_sk { LSTR MSG_COOLER = _UxGT("Chladen. lasera"); LSTR MSG_COOLER_TOGGLE = _UxGT("Prepnúť chladenie"); LSTR MSG_FLOWMETER_SAFETY = _UxGT("Bezpeč. prietok"); + LSTR MSG_CUTTER = _UxGT("Rezačka"); LSTR MSG_LASER = _UxGT("Laser"); LSTR MSG_FAN_SPEED = _UxGT("Rýchlosť vent."); LSTR MSG_FAN_SPEED_N = _UxGT("Rýchlosť vent. ~"); @@ -325,10 +362,28 @@ namespace Language_sk { LSTR MSG_PID_AUTOTUNE_E = _UxGT("Kalibrácia PID *"); LSTR MSG_PID_CYCLE = _UxGT("Cykly PID"); LSTR MSG_PID_AUTOTUNE_DONE = _UxGT("Kal. PID dokončená"); + LSTR MSG_PID_AUTOTUNE_FAILED = _UxGT("Kal. PID zlyhala!"); + LSTR MSG_BAD_EXTRUDER_NUM = _UxGT("Zlý extrudér"); + LSTR MSG_TEMP_TOO_HIGH = _UxGT("Príliš vysoká tepl."); + LSTR MSG_TIMEOUT = _UxGT("Čas vypršal."); LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Auto-kal. zlyhala! Zlý extrúder."); LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Auto-kal. zlyhala! Príliš vysoká tepl."); LSTR MSG_PID_TIMEOUT = _UxGT("Auto-kal. zlyhala! Čas vypršal."); - LSTR MSG_SELECT = _UxGT("Vybrať"); + LSTR MSG_MPC_MEASURING_AMBIENT = _UxGT("Test. tepl. straty"); + LSTR MSG_MPC_HEATING_PAST_200 = _UxGT("Zahriať na >200C"); + LSTR MSG_MPC_COOLING_TO_AMBIENT = _UxGT("Schladiť na okolie"); + LSTR MSG_MPC_AUTOTUNE = _UxGT("Auto-kal. MPC"); + LSTR MSG_MPC_EDIT = _UxGT("Upraviť * MPC"); + LSTR MSG_MPC_POWER = _UxGT("Výkon ohrievača"); + LSTR MSG_MPC_POWER_E = _UxGT("Výkon *"); + LSTR MSG_MPC_BLOCK_HEAT_CAPACITY = _UxGT("Tepelná kapacita"); + LSTR MSG_MPC_BLOCK_HEAT_CAPACITY_E = _UxGT("Tepelná kap. *"); + LSTR MSG_SENSOR_RESPONSIVENESS = _UxGT("Reakcia senzoru"); + LSTR MSG_SENSOR_RESPONSIVENESS_E = _UxGT("Reakcia senz. *"); + LSTR MSG_MPC_AMBIENT_XFER_COEFF = _UxGT("Koef. okolia"); + LSTR MSG_MPC_AMBIENT_XFER_COEFF_E = _UxGT("Koef. okolia *"); + LSTR MSG_MPC_AMBIENT_XFER_COEFF_FAN = _UxGT("Koef. vent."); + LSTR MSG_MPC_AMBIENT_XFER_COEFF_FAN_E = _UxGT("Koef. vent. *"); LSTR MSG_SELECT_E = _UxGT("Vybrať *"); LSTR MSG_ACC = _UxGT("Zrýchlenie"); LSTR MSG_JERK = _UxGT("Skok"); @@ -356,6 +411,11 @@ namespace Language_sk { LSTR MSG_AMAX_EN = _UxGT("Amax *"); LSTR MSG_A_RETRACT = _UxGT("A-retrakt"); LSTR MSG_A_TRAVEL = _UxGT("A-prejazd"); + LSTR MSG_INPUT_SHAPING = _UxGT("Tvarov. vstupu"); + LSTR MSG_SHAPING_ENABLE = _UxGT("Povol. tvarov. @"); + LSTR MSG_SHAPING_DISABLE = _UxGT("Zakáz. tvarov. @"); + LSTR MSG_SHAPING_FREQ = _UxGT("Frekvencia @"); + LSTR MSG_SHAPING_ZETA = _UxGT("Tlmenie @"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Max. frekvencia"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Min. posun"); LSTR MSG_STEPS_PER_MM = _UxGT("Kroky/mm"); @@ -375,22 +435,34 @@ namespace Language_sk { LSTR MSG_FILAMENT_DIAM_E = _UxGT("Priem. fil. *"); LSTR MSG_FILAMENT_UNLOAD = _UxGT("Vysunúť mm"); LSTR MSG_FILAMENT_LOAD = _UxGT("Zaviesť mm"); + LSTR MSG_SEGMENTS_PER_SECOND = _UxGT("Segmentov/sek"); + LSTR MSG_DRAW_MIN_X = _UxGT("Min. X kresby"); + LSTR MSG_DRAW_MAX_X = _UxGT("Max. X kresby"); + LSTR MSG_DRAW_MIN_Y = _UxGT("Min. Y kresby"); + LSTR MSG_DRAW_MAX_Y = _UxGT("Max. Y kresby"); + LSTR MSG_MAX_BELT_LEN = _UxGT("Max. dĺžka pásu"); LSTR MSG_ADVANCE_K = _UxGT("K pre posun"); LSTR MSG_ADVANCE_K_E = _UxGT("K pre posun *"); LSTR MSG_CONTRAST = _UxGT("Kontrast LCD"); LSTR MSG_BRIGHTNESS = _UxGT("Jas LCD"); + LSTR MSG_SCREEN_TIMEOUT = _UxGT("Čas. limit LCD (m)"); + LSTR MSG_BRIGHTNESS_OFF = _UxGT("Podsviet. vyp."); LSTR MSG_STORE_EEPROM = _UxGT("Uložiť nastavenie"); LSTR MSG_LOAD_EEPROM = _UxGT("Načítať nastavenie"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Obnoviť nastavenie"); LSTR MSG_INIT_EEPROM = _UxGT("Inicializ. EEPROM"); LSTR MSG_ERR_EEPROM_CRC = _UxGT("Chyba: EEPROM CRC"); - LSTR MSG_ERR_EEPROM_INDEX = _UxGT("Chyba: EEPROM Index"); + LSTR MSG_ERR_EEPROM_SIZE = _UxGT("Chyba: Veľkosť EEPROM"); LSTR MSG_ERR_EEPROM_VERSION = _UxGT("Chyba: Verzia EEPROM"); LSTR MSG_SETTINGS_STORED = _UxGT("Nastavenie uložené"); - LSTR MSG_MEDIA_UPDATE = _UxGT("Aktualizovať z SD"); + LSTR MSG_MEDIA_UPDATE = _UxGT("Aktualiz. z karty"); LSTR MSG_RESET_PRINTER = _UxGT("Reštart. tlačiar."); LSTR MSG_REFRESH = LCD_STR_REFRESH _UxGT("Obnoviť"); LSTR MSG_INFO_SCREEN = _UxGT("Info. obrazovka"); + LSTR MSG_INFO_MACHINENAME = _UxGT("Názov stroja"); + LSTR MSG_INFO_SIZE = _UxGT("Rozmer"); + LSTR MSG_INFO_FWVERSION = _UxGT("Verzia firmvéru"); + LSTR MSG_INFO_BUILD = _UxGT("Čas zostavenia"); LSTR MSG_PREPARE = _UxGT("Príprava tlače"); LSTR MSG_TUNE = _UxGT("Doladenie tlače"); LSTR MSG_POWER_MONITOR = _UxGT("Monitor napájania"); @@ -405,6 +477,8 @@ namespace Language_sk { LSTR MSG_BUTTON_RESET = _UxGT("Vynulovať"); LSTR MSG_BUTTON_IGNORE = _UxGT("Ignorovať"); LSTR MSG_BUTTON_CANCEL = _UxGT("Zrušiť"); + LSTR MSG_BUTTON_CONFIRM = _UxGT("Potvrdiť"); + LSTR MSG_BUTTON_CONTINUE = _UxGT("Pokračovať"); LSTR MSG_BUTTON_DONE = _UxGT("Hotovo"); LSTR MSG_BUTTON_BACK = _UxGT("Naspäť"); LSTR MSG_BUTTON_PROCEED = _UxGT("Pokračovať"); @@ -414,30 +488,47 @@ namespace Language_sk { LSTR MSG_BUTTON_PAUSE = _UxGT("Pauza"); LSTR MSG_BUTTON_RESUME = _UxGT("Obnoviť"); LSTR MSG_BUTTON_ADVANCED = _UxGT("Pokročilé"); + LSTR MSG_BUTTON_SAVE = _UxGT("Uložiť"); + LSTR MSG_BUTTON_PURGE = _UxGT("Vytlačiť"); LSTR MSG_PAUSING = _UxGT("Pozastavujem..."); LSTR MSG_PAUSE_PRINT = _UxGT("Pozastaviť tlač"); LSTR MSG_ADVANCED_PAUSE = _UxGT("Pokročil. pauza"); LSTR MSG_RESUME_PRINT = _UxGT("Obnoviť tlač"); - LSTR MSG_HOST_START_PRINT = _UxGT("Spustiť z hosta"); LSTR MSG_STOP_PRINT = _UxGT("Zastaviť tlač"); - LSTR MSG_END_LOOPS = _UxGT("Koniec opak. sluč."); - LSTR MSG_PRINTING_OBJECT = _UxGT("Tlačím objekt"); - LSTR MSG_CANCEL_OBJECT = _UxGT("Zrušiť objekt"); - LSTR MSG_CANCEL_OBJECT_N = _UxGT("Zrušiť objekt ="); LSTR MSG_OUTAGE_RECOVERY = _UxGT("Obnova po výp. nap."); - LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Pokračovať v úlohe"); - LSTR MSG_MEDIA_MENU = _UxGT("Tlačiť z SD"); - LSTR MSG_NO_MEDIA = _UxGT("Žiadna SD karta"); + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 + LSTR MSG_HOST_START_PRINT = _UxGT("Spustiť z hosta"); + LSTR MSG_PRINTING_OBJECT = _UxGT("Tlačím objekt"); + LSTR MSG_CANCEL_OBJECT = _UxGT("Zrušiť objekt"); + LSTR MSG_CANCEL_OBJECT_N = _UxGT("Zrušiť objekt ="); + LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Pokračovať v úlohe"); + LSTR MSG_MEDIA_MENU = _UxGT("Vytlačiť z karty"); + LSTR MSG_TURN_OFF = _UxGT("Vypnite tlačiareň"); + LSTR MSG_END_LOOPS = _UxGT("Ukončiť opak. sluč."); + #else + LSTR MSG_HOST_START_PRINT = _UxGT("Spustiť z hosta"); + LSTR MSG_PRINTING_OBJECT = _UxGT("Tlačím obj."); + LSTR MSG_CANCEL_OBJECT = _UxGT("Zrušiť obj."); + LSTR MSG_CANCEL_OBJECT_N = _UxGT("Zrušiť obj. ="); + LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Pokrač. v úlohe"); + LSTR MSG_MEDIA_MENU = _UxGT("Tlač z karty"); + LSTR MSG_TURN_OFF = _UxGT("Vypnit. teraz"); + LSTR MSG_END_LOOPS = _UxGT("Ukončiť sluč."); + #endif + LSTR MSG_NO_MEDIA = _UxGT("Žiadna karta"); LSTR MSG_DWELL = _UxGT("Spím..."); LSTR MSG_USERWAIT = _UxGT("Pokrač. kliknutím..."); LSTR MSG_PRINT_PAUSED = _UxGT("Tlač pozastavená"); LSTR MSG_PRINTING = _UxGT("Tlačím..."); LSTR MSG_STOPPING = _UxGT("Zastavujem..."); + LSTR MSG_REMAINING_TIME = _UxGT("Zostávajúci"); LSTR MSG_PRINT_ABORTED = _UxGT("Tlač zrušená"); LSTR MSG_PRINT_DONE = _UxGT("Tlač dokončená"); + LSTR MSG_PRINTER_KILLED = _UxGT("Tlačiareň zastavená!"); LSTR MSG_NO_MOVE = _UxGT("Žiadny pohyb."); LSTR MSG_KILLED = _UxGT("PRERUŠENÉ. "); LSTR MSG_STOPPED = _UxGT("ZASTAVENÉ. "); + LSTR MSG_FWRETRACT = _UxGT("Firmv. retrakcia"); LSTR MSG_CONTROL_RETRACT = _UxGT("Retrakt mm"); LSTR MSG_CONTROL_RETRACT_SWAP = _UxGT("Výmena Re.mm"); LSTR MSG_CONTROL_RETRACTF = _UxGT("Retraktovať V"); @@ -453,8 +544,10 @@ namespace Language_sk { LSTR MSG_TOOL_CHANGE = _UxGT("Výmena nástroja"); LSTR MSG_TOOL_CHANGE_ZLIFT = _UxGT("Zdvihnúť Z"); LSTR MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Primárna rýchl."); + LSTR MSG_SINGLENOZZLE_WIPE_RETRACT = _UxGT("Očist. retrakciou"); LSTR MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Rýchl. retrakcie"); LSTR MSG_FILAMENT_PARK_ENABLED = _UxGT("Parkovať hlavu"); + LSTR MSG_PARK_FAILED = _UxGT("Hlava sa nedá zapark."); LSTR MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Rýchl. obnovenia"); LSTR MSG_SINGLENOZZLE_FAN_SPEED = _UxGT("Rýchlosť vent."); LSTR MSG_SINGLENOZZLE_FAN_TIME = _UxGT("Doba fúkania"); @@ -471,9 +564,14 @@ namespace Language_sk { LSTR MSG_FILAMENTUNLOAD = _UxGT("Vysunúť filament"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Vysunúť filament *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Vysunúť všetko"); - LSTR MSG_ATTACH_MEDIA = _UxGT("Načítať SD kartu"); - LSTR MSG_CHANGE_MEDIA = _UxGT("Vymeniť SD kartu"); - LSTR MSG_RELEASE_MEDIA = _UxGT("Odpojiť SD kartu"); + #if ENABLED(MULTI_VOLUME) + LSTR MSG_ATTACH_MEDIA = _UxGT("Načítať SD kartu"); + LSTR MSG_ATTACH_USB_MEDIA = _UxGT("Načítať USB disk"); + #else + LSTR MSG_ATTACH_MEDIA = _UxGT("Načítať kartu"); + #endif + LSTR MSG_CHANGE_MEDIA = _UxGT("Vymeniť kartu"); + LSTR MSG_RELEASE_MEDIA = _UxGT("Odpojiť kartu"); LSTR MSG_ZPROBE_OUT = _UxGT("Sonda Z mimo podl."); LSTR MSG_SKEW_FACTOR = _UxGT("Faktor skosenia"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); @@ -497,12 +595,15 @@ namespace Language_sk { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Zasunúť TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Zasunúť sondu Z"); LSTR MSG_MANUAL_STOW = _UxGT("Vysunúť sondu Z"); - LSTR MSG_HOME_FIRST = _UxGT("Najskôr os %s%s%s domov"); + LSTR MSG_HOME_FIRST = _UxGT("Najskôr os %s domov"); LSTR MSG_ZPROBE_SETTINGS = _UxGT("Nastav. sondy"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Ofsety sondy Z"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("X ofset"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Y ofset"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Z ofset"); + LSTR MSG_ZPROBE_MARGIN = _UxGT("Hranica sondy"); + LSTR MSG_Z_FEED_RATE = _UxGT("Rýchl. posunu Z"); + LSTR MSG_ENABLE_HS_MODE = _UxGT("Povoliť rež. HS"); LSTR MSG_MOVE_NOZZLE_TO_BED = _UxGT("Pos. trysku k podl."); LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); @@ -540,8 +641,6 @@ namespace Language_sk { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Kalibrovať stred"); LSTR MSG_DELTA_SETTINGS = _UxGT("Delta nastavenia"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Auto-kalibrácia"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Nast. výšku delty"); - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Ofset sondy Z"); LSTR MSG_DELTA_DIAG_ROD = _UxGT("Diag. rameno"); LSTR MSG_DELTA_HEIGHT = _UxGT("Výška"); LSTR MSG_DELTA_RADIUS = _UxGT("Polomer"); @@ -554,6 +653,7 @@ namespace Language_sk { LSTR MSG_MESH_LEVELING = _UxGT("Mriežkové rovnanie"); LSTR MSG_MESH_DONE = _UxGT("Mriežka dokončená"); LSTR MSG_INFO_STATS_MENU = _UxGT("Štatistika"); + LSTR MSG_RESET_STATS = _UxGT("Vynulovať štatis.?"); LSTR MSG_INFO_BOARD_MENU = _UxGT("Info. o doske"); LSTR MSG_INFO_THERMISTOR_MENU = _UxGT("Termistory"); LSTR MSG_INFO_EXTRUDERS = _UxGT("Extrudéry"); @@ -568,30 +668,32 @@ namespace Language_sk { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Jas svetla"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Nesprávna tlačiareň"); + LSTR MSG_COLORS_GET = _UxGT("Zvoliť farbu"); + LSTR MSG_COLORS_SELECT = _UxGT("Zvoliť farby"); + LSTR MSG_COLORS_APPLIED = _UxGT("Farby aplikované"); + LSTR MSG_COLORS_RED = _UxGT("Červená"); + LSTR MSG_COLORS_GREEN = _UxGT("Zelená"); + LSTR MSG_COLORS_BLUE = _UxGT("Modrá"); + LSTR MSG_COLORS_WHITE = _UxGT("Biela"); + LSTR MSG_UI_LANGUAGE = _UxGT("Jazyk rozhrania"); + LSTR MSG_SOUND_ENABLE = _UxGT("Povoliť zvuky"); + LSTR MSG_LOCKSCREEN = _UxGT("Uzamknúť obrazovku"); + LSTR MSG_LOCKSCREEN_LOCKED = _UxGT("Tlačiareň je uzamknutá,"); + LSTR MSG_LOCKSCREEN_UNLOCK = _UxGT("potiahnite pre odomknutie."); + LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Prosím čakajte do reštartu."); + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("Nie je vložená karta."); - LSTR MSG_REMAINING_TIME = _UxGT("Zostávajúci čas"); - LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Prosím čakajte do reštartu. "); LSTR MSG_PLEASE_PREHEAT = _UxGT("Prosím zahrejte hotend."); LSTR MSG_INFO_PRINT_COUNT_RESET = _UxGT("Vynulovať počítadlo"); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Počet tlačí"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Celkový čas"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Najdlhšia tlač"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Celkom vytlačené"); - LSTR MSG_COLORS_GET = _UxGT("Zvoliť farbu"); - LSTR MSG_COLORS_SELECT = _UxGT("Zvoliť farby"); - LSTR MSG_COLORS_APPLIED = _UxGT("Farby aplikované"); - LSTR MSG_COLORS_RED = _UxGT("Červená"); - LSTR MSG_COLORS_GREEN = _UxGT("Zelená"); - LSTR MSG_COLORS_BLUE = _UxGT("Modrá"); - LSTR MSG_UI_LANGUAGE = _UxGT("Jazyk rozhrania"); - LSTR MSG_SOUND_ENABLE = _UxGT("Povoliť zvuky"); - LSTR MSG_LOCKSCREEN = _UxGT("Uzamknúť obrazovku"); #else LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("Žiadna karta"); LSTR MSG_PLEASE_PREHEAT = _UxGT("Prosím zahrejte"); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Tlače"); - LSTR MSG_REMAINING_TIME = _UxGT("Zostávajúci"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Čas"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Najdlhšia"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Vytlačené"); @@ -612,10 +714,14 @@ namespace Language_sk { LSTR MSG_FILAMENT_CHANGE_OPTION_HEADER = _UxGT("MOŽNOSTI POKRAČ.:"); LSTR MSG_FILAMENT_CHANGE_OPTION_PURGE = _UxGT("Vytlačiť viacej"); LSTR MSG_FILAMENT_CHANGE_OPTION_RESUME = _UxGT("Obnoviť tlač"); + LSTR MSG_FILAMENT_CHANGE_PURGE_CONTINUE = _UxGT("Vytlač. alebo pokrač.?"); LSTR MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Tryska: "); LSTR MSG_RUNOUT_SENSOR = _UxGT("Senzor filamentu"); LSTR MSG_RUNOUT_DISTANCE_MM = _UxGT("Vzd. mm fil. senz."); LSTR MSG_RUNOUT_ENABLE = _UxGT("Zapnúť senzor"); + LSTR MSG_RUNOUT_ACTIVE = _UxGT("Senz. fil. zapn."); + LSTR MSG_INVERT_EXTRUDER = _UxGT("Invert. extrudér"); + LSTR MSG_EXTRUDER_MIN_TEMP = _UxGT("Min. tepl. extrud."); LSTR MSG_FANCHECK = _UxGT("Kontrola rýchl."); LSTR MSG_KILL_HOMING_FAILED = _UxGT("Parkovanie zlyhalo"); LSTR MSG_LCD_PROBING_FAILED = _UxGT("Kalibrácia zlyhala"); diff --git a/Marlin/src/lcd/language/language_sv.h b/Marlin/src/lcd/language/language_sv.h index 6e6d3e11ecd0..e66de33c221e 100644 --- a/Marlin/src/lcd/language/language_sv.h +++ b/Marlin/src/lcd/language/language_sv.h @@ -249,6 +249,7 @@ namespace Language_sv { LSTR MSG_MOVE_X = _UxGT("Flytta X"); LSTR MSG_MOVE_Y = _UxGT("Flytta Y"); LSTR MSG_MOVE_Z = _UxGT("Flytta Z"); + LSTR MSG_MOVE_N = _UxGT("Flytta @"); LSTR MSG_MOVE_E = _UxGT("Extruder"); LSTR MSG_MOVE_EN = _UxGT("Extruder *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hetände för kall"); @@ -293,7 +294,6 @@ namespace Language_sv { LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Autojustera misslyckad! Dålig extruder."); LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Autojustera misslyckad! Temperatur för hög."); LSTR MSG_PID_TIMEOUT = _UxGT("Autojustera misslyckad! Tidsgräns."); - LSTR MSG_SELECT = _UxGT("Välj"); LSTR MSG_SELECT_E = _UxGT("Välj *"); LSTR MSG_ACC = _UxGT("Accel"); LSTR MSG_JERK = _UxGT("Ryck"); @@ -348,7 +348,7 @@ namespace Language_sv { LSTR MSG_RESTORE_DEFAULTS = _UxGT("Återställ Standard"); LSTR MSG_INIT_EEPROM = _UxGT("Initiera EEPROM"); LSTR MSG_ERR_EEPROM_CRC = _UxGT("EEPROM CRC Fel"); - LSTR MSG_ERR_EEPROM_INDEX = _UxGT("EEPROM Index Fel"); + LSTR MSG_ERR_EEPROM_SIZE = _UxGT("EEPROM Storlek Fel"); LSTR MSG_ERR_EEPROM_VERSION = _UxGT("EEPROM Version Fel"); LSTR MSG_SETTINGS_STORED = _UxGT("Inställningar Lagrad"); LSTR MSG_MEDIA_UPDATE = _UxGT("Media Uppdatera"); @@ -452,7 +452,7 @@ namespace Language_sv { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Fällut TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Fällut Z-Sond"); LSTR MSG_MANUAL_STOW = _UxGT("Stuva undan Z-Sond"); - LSTR MSG_HOME_FIRST = _UxGT("Hem %s%s%s Först"); + LSTR MSG_HOME_FIRST = _UxGT("Hem %s Först"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Sond Offsets"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Sond X Offset"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Sond Y Offset"); @@ -489,8 +489,6 @@ namespace Language_sv { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Kalibrera Center"); LSTR MSG_DELTA_SETTINGS = _UxGT("Delta Inställningar"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Auto Kalibrering"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Sätt Delta Höjd"); - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Sond Z-offset"); LSTR MSG_DELTA_DIAG_ROD = _UxGT("Diag Rod"); LSTR MSG_DELTA_HEIGHT = _UxGT("Höjd"); LSTR MSG_DELTA_RADIUS = _UxGT("Radius"); diff --git a/Marlin/src/lcd/language/language_tr.h b/Marlin/src/lcd/language/language_tr.h index b981127ed1cd..ca6a38142caa 100644 --- a/Marlin/src/lcd/language/language_tr.h +++ b/Marlin/src/lcd/language/language_tr.h @@ -26,10 +26,6 @@ * * LCD Menu Messages * See also https://marlinfw.org/docs/development/lcd_language.html - * - * Bu çeviri dosyasındaki sorunlar ve düzeltmeler için iletişim; - * Contact for issues and corrections in this translation file; - * Yücel Temel - (info@elektromanyetix.com) - https://elektromanyetix.com/ */ #define DISPLAY_CHARSET_ISO10646_TR @@ -40,38 +36,67 @@ namespace Language_tr { constexpr uint8_t CHARSIZE = 2; LSTR LANGUAGE = _UxGT("Turkish"); + // These strings should be translated LSTR WELCOME_MSG = MACHINE_NAME _UxGT(" hazır."); LSTR MSG_YES = _UxGT("EVET"); LSTR MSG_NO = _UxGT("HAYIR"); + LSTR MSG_HIGH = _UxGT("YÜKSEK"); + LSTR MSG_LOW = _UxGT("DÜŞÜK"); LSTR MSG_BACK = _UxGT("Geri"); + LSTR MSG_ERROR = _UxGT("Hata"); LSTR MSG_MEDIA_ABORTING = _UxGT("Durduruluyor..."); LSTR MSG_MEDIA_INSERTED = _UxGT("SD K. Yerleştirildi."); LSTR MSG_MEDIA_REMOVED = _UxGT("SD Kart Çıkarıldı."); LSTR MSG_MEDIA_WAITING = _UxGT("SD Kart Bekleniyor"); + LSTR MSG_MEDIA_INIT_FAIL = MEDIA_TYPE_EN _UxGT(" Başlatma Başarısız"); LSTR MSG_MEDIA_READ_ERROR = _UxGT("Kart Okuma Hatası"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("USB Çıkarıldı"); LSTR MSG_MEDIA_USB_FAILED = _UxGT("USB Başlat. Hatası"); - LSTR MSG_LCD_ENDSTOPS = _UxGT("Enstops"); // Max length 8 characters + LSTR MSG_KILL_SUBCALL_OVERFLOW = _UxGT("Subcall Overflow"); + LSTR MSG_LCD_ENDSTOPS = _UxGT("Endstops"); // Max length 8 characters LSTR MSG_LCD_SOFT_ENDSTOPS = _UxGT("Yazılımsal Endstops"); LSTR MSG_MAIN = _UxGT("Ana"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Gelişmiş Ayarlar"); + LSTR MSG_TOOLBAR_SETUP = _UxGT("Araç Çubuğu Kurulumu"); + LSTR MSG_OPTION_DISABLED = _UxGT("Seçenek Devre Dışı"); LSTR MSG_CONFIGURATION = _UxGT("Yapılandırma"); LSTR MSG_RUN_AUTO_FILES = _UxGT("Oto. Başlat"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Motorları Durdur"); LSTR MSG_DEBUG_MENU = _UxGT("Hata Ayıklama"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Durum Çubuğu Testi"); + LSTR MSG_HOMING = _UxGT("Sıfırlanıyor"); LSTR MSG_AUTO_HOME = _UxGT("Eksenleri Sıfırla"); + LSTR MSG_AUTO_HOME_A = _UxGT("@ Sıfırla"); LSTR MSG_AUTO_HOME_X = _UxGT("X Sıfırla"); LSTR MSG_AUTO_HOME_Y = _UxGT("Y Sıfırla"); LSTR MSG_AUTO_HOME_Z = _UxGT("Z Sıfırla"); + LSTR MSG_FILAMENT_SET = _UxGT("Filament Ayarları"); + LSTR MSG_FILAMENT_MAN = _UxGT("Filament Yönetimi"); + LSTR MSG_MANUAL_LEVELING = _UxGT("Manuel Seviyeleme"); + LSTR MSG_LEVBED_FL = _UxGT("Sol Ön"); + LSTR MSG_LEVBED_FR = _UxGT("Ön Sağ"); + LSTR MSG_LEVBED_C = _UxGT("Orta"); + LSTR MSG_LEVBED_BL = _UxGT("Arka Sol"); + LSTR MSG_LEVBED_BR = _UxGT("Arka Sağ"); + LSTR MSG_MANUAL_MESH = _UxGT("Manuel Mesh"); + LSTR MSG_AUTO_MESH = _UxGT("Oto Mesh Oluştur"); LSTR MSG_AUTO_Z_ALIGN = _UxGT("Oto. Z-Hizalama"); + LSTR MSG_ITERATION = _UxGT("G34 Yinelemesi: %i"); + LSTR MSG_DECREASING_ACCURACY = _UxGT("Doğruluk Düşüyor!"); + LSTR MSG_ACCURACY_ACHIEVED = _UxGT("Doğruluk Sağlandı"); LSTR MSG_LEVEL_BED_HOMING = _UxGT("XYZ Sıfırlanıyor"); LSTR MSG_LEVEL_BED_WAITING = _UxGT("Başlatmak için tıkla"); LSTR MSG_LEVEL_BED_NEXT_POINT = _UxGT("Sonraki Nokta"); - LSTR MSG_LEVEL_BED_DONE = _UxGT("Hizalama Tamam!"); + LSTR MSG_LEVEL_BED_DONE = _UxGT("Seviyeleme Tamam!"); LSTR MSG_Z_FADE_HEIGHT = _UxGT("Kaçınma Yüksekliği"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Ofset Ayarla"); + LSTR MSG_HOME_OFFSET_X = _UxGT("X Ofset Sıfırla"); + LSTR MSG_HOME_OFFSET_Y = _UxGT("Y Ofset Sıfırla"); + LSTR MSG_HOME_OFFSET_Z = _UxGT("Z Ofset Sıfırla"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Ofset Tamam"); + LSTR MSG_TRAMMING_WIZARD = _UxGT("Hizalama Sihirbazı"); + LSTR MSG_SELECT_ORIGIN = _UxGT("Başlangıç Seç"); + LSTR MSG_LAST_VALUE_SP = _UxGT("Son değer "); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Ön Isınma ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Ön Isınma ") PREHEAT_1_LABEL " ~"; @@ -80,7 +105,14 @@ namespace Language_tr { LSTR MSG_PREHEAT_1_ALL = _UxGT("Ön Isınma ") PREHEAT_1_LABEL _UxGT(" Tüm"); LSTR MSG_PREHEAT_1_BEDONLY = _UxGT("Ön Isınma ") PREHEAT_1_LABEL _UxGT(" Tabla"); LSTR MSG_PREHEAT_1_SETTINGS = _UxGT("Ön Isınma ") PREHEAT_1_LABEL _UxGT(" Ayarlar"); - + #ifdef PREHEAT_2_LABEL + LSTR MSG_PREHEAT_2 = _UxGT("Ön Isınma ") PREHEAT_2_LABEL; + LSTR MSG_PREHEAT_2_SETTINGS = _UxGT("Ön Isınma ") PREHEAT_2_LABEL _UxGT(" Conf"); + #endif + #ifdef PREHEAT_3_LABEL + LSTR MSG_PREHEAT_3 = _UxGT("Ön Isınma ") PREHEAT_3_LABEL; + LSTR MSG_PREHEAT_3_SETTINGS = _UxGT("Ön Isınma ") PREHEAT_3_LABEL _UxGT(" Conf"); + #endif LSTR MSG_PREHEAT_M = _UxGT("Ön Isınma $"); LSTR MSG_PREHEAT_M_H = _UxGT("Ön Isınma $ ~"); LSTR MSG_PREHEAT_M_END = _UxGT("Ön Isınma $ Nozul"); @@ -91,30 +123,59 @@ namespace Language_tr { #endif LSTR MSG_PREHEAT_CUSTOM = _UxGT("Özel Ön Isınma"); LSTR MSG_COOLDOWN = _UxGT("Soğut/(Durdur)"); + + LSTR MSG_CUTTER_FREQUENCY = _UxGT("Frekans"); LSTR MSG_LASER_MENU = _UxGT("Lazer Kontrolü"); - LSTR MSG_LASER_POWER = _UxGT("Lazer Gücü"); LSTR MSG_SPINDLE_MENU = _UxGT("Spindle Kontrolü"); + LSTR MSG_LASER_POWER = _UxGT("Lazer Gücü"); LSTR MSG_SPINDLE_POWER = _UxGT("Spindle Gücü"); - LSTR MSG_SPINDLE_REVERSE = _UxGT("Spindle Ters Yön"); + LSTR MSG_LASER_TOGGLE = _UxGT("Lazer Değiştir"); + LSTR MSG_LASER_EVAC_TOGGLE = _UxGT("Üfleyici Değiştir"); + LSTR MSG_LASER_ASSIST_TOGGLE = _UxGT("Hava Desteği"); + LSTR MSG_LASER_PULSE_MS = _UxGT("Test Pulse ms"); + LSTR MSG_LASER_FIRE_PULSE = _UxGT("Fire Pulse"); + LSTR MSG_FLOWMETER_FAULT = _UxGT("Soğutucu Akış Hatası"); + LSTR MSG_SPINDLE_TOGGLE = _UxGT("Spindle Değiştir"); + LSTR MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Vakum Değiştir"); + LSTR MSG_SPINDLE_FORWARD = _UxGT("Spindle İleri Yön"); + LSTR MSG_SPINDLE_REVERSE = _UxGT("Spindle Geri Yön"); LSTR MSG_SWITCH_PS_ON = _UxGT("Gücü Aç"); LSTR MSG_SWITCH_PS_OFF = _UxGT("Gücü Kapat"); LSTR MSG_EXTRUDE = _UxGT("Ekstrüzyon"); LSTR MSG_RETRACT = _UxGT("Geri Çek"); LSTR MSG_MOVE_AXIS = _UxGT("Eksen Hareketleri"); - LSTR MSG_BED_LEVELING = _UxGT("Tabla Hizalama"); - LSTR MSG_LEVEL_BED = _UxGT("Tabla Hizası"); - LSTR MSG_BED_TRAMMING = _UxGT("Hizalama Köşeleri"); + LSTR MSG_BED_LEVELING = _UxGT("Tabla Seviyeleme"); + LSTR MSG_LEVEL_BED = _UxGT("Tabla Seviyesi"); + LSTR MSG_BED_TRAMMING = _UxGT("Tabla Hizalama"); + LSTR MSG_BED_TRAMMING_MANUAL = _UxGT("Manuel Hizalama"); + LSTR MSG_BED_TRAMMING_RAISE = _UxGT("Prob tetiklenene kadar tablayı ayarlayın."); + LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Köşeler tolerans dahilinde. Tabla hizalandı."); + LSTR MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("İyi Noktalar: "); + LSTR MSG_BED_TRAMMING_LAST_Z = _UxGT("Son Z: "); LSTR MSG_NEXT_CORNER = _UxGT("Sonraki Köşe"); LSTR MSG_MESH_EDITOR = _UxGT("Mesh Editörü"); + LSTR MSG_MESH_VIEWER = _UxGT("Mesh görüntüleyici"); LSTR MSG_EDIT_MESH = _UxGT("Mesh Düzenle"); + LSTR MSG_MESH_VIEW = _UxGT("Mesh Göster"); LSTR MSG_EDITING_STOPPED = _UxGT("Mesh Düzenleme Durdu"); + LSTR MSG_NO_VALID_MESH = _UxGT("Geçerli Mesh yok"); + LSTR MSG_ACTIVATE_MESH = _UxGT("Seviyeleme Aç"); LSTR MSG_PROBING_POINT = _UxGT("Prop Noktası"); LSTR MSG_MESH_X = _UxGT("İndeks X"); LSTR MSG_MESH_Y = _UxGT("İndeks Y"); + LSTR MSG_MESH_INSET = _UxGT("Mesh Inset"); + LSTR MSG_MESH_MIN_X = _UxGT("Mesh X Minimum"); + LSTR MSG_MESH_MAX_X = _UxGT("Mesh X Maximum"); + LSTR MSG_MESH_MIN_Y = _UxGT("Mesh Y Minimum"); + LSTR MSG_MESH_MAX_Y = _UxGT("Mesh Y Maximum"); + LSTR MSG_MESH_AMAX = _UxGT("Alanı Büyüt"); + LSTR MSG_MESH_CENTER = _UxGT("Merkez Alan"); LSTR MSG_MESH_EDIT_Z = _UxGT("Z Değeri"); + LSTR MSG_MESH_CANCEL = _UxGT("Mesh iptal edildi"); LSTR MSG_CUSTOM_COMMANDS = _UxGT("Özel Komutlar"); LSTR MSG_M48_TEST = _UxGT("M48 Prob Testi"); LSTR MSG_M48_POINT = _UxGT("M48 Nokta"); + LSTR MSG_M48_OUT_OF_BOUNDS = _UxGT("Sınır dışı araştırma"); LSTR MSG_M48_DEVIATION = _UxGT("Sapma"); LSTR MSG_IDEX_MENU = _UxGT("IDEX Modu"); LSTR MSG_OFFSETS_MENU = _UxGT("Takım Ofsetleri"); @@ -122,21 +183,26 @@ namespace Language_tr { LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Kopyala"); LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Yansıtılmış kopya"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("Tam Kontrol"); + LSTR MSG_IDEX_DUPE_GAP = _UxGT("Yinelenen X-Boşluğu"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2. nozul Z"); LSTR MSG_HOTEND_OFFSET_A = _UxGT("2. nozul @"); LSTR MSG_UBL_DOING_G29 = _UxGT("G29 Çalışıyor"); LSTR MSG_UBL_TOOLS = _UxGT("UBL Araçları"); - LSTR MSG_UBL_LEVEL_BED = _UxGT("UBL Yatak Hizalama"); + LSTR MSG_UBL_LEVEL_BED = _UxGT("UBL Tabla Seviyeleme"); LSTR MSG_LCD_TILTING_MESH = _UxGT("Eğim Noktası"); + LSTR MSG_UBL_TILT_MESH = _UxGT("Eğimli Mesh"); + LSTR MSG_UBL_TILTING_GRID = _UxGT("Eğimli Izgara Boyutu"); + LSTR MSG_UBL_MESH_TILTED = _UxGT("Mesh Eğildi"); LSTR MSG_UBL_MANUAL_MESH = _UxGT("Elle Mesh Oluştur"); + LSTR MSG_UBL_MESH_WIZARD = _UxGT("UBL Mesh Sihirbazı"); LSTR MSG_UBL_BC_INSERT = _UxGT("Altlık & Ölçü Ver"); - LSTR MSG_UBL_BC_INSERT2 = _UxGT("Ölçü"); - LSTR MSG_UBL_BC_REMOVE = _UxGT("Yataktan Ölçü Kaldır"); + LSTR MSG_UBL_BC_INSERT2 = _UxGT("Ölçüm"); + LSTR MSG_UBL_BC_REMOVE = _UxGT("Tablayı Kaldır & Ölç"); LSTR MSG_UBL_MOVING_TO_NEXT = _UxGT("Sonrakine Git"); LSTR MSG_UBL_ACTIVATE_MESH = _UxGT("UBL'yi Etkinleştir"); LSTR MSG_UBL_DEACTIVATE_MESH = _UxGT("UBL'yi Etkisizleştir"); - LSTR MSG_UBL_SET_TEMP_BED = _UxGT("Yatak Sıcaklığı"); - LSTR MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Yatak Sıcaklığı"); + LSTR MSG_UBL_SET_TEMP_BED = _UxGT("Tabla Sıcaklığı"); + LSTR MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Tabla Sıcaklığı"); LSTR MSG_UBL_SET_TEMP_HOTEND = _UxGT("Nozul Sıcaklığı"); LSTR MSG_UBL_HOTEND_TEMP_CUSTOM = _UxGT("Nozul Sıcaklığı"); LSTR MSG_UBL_MESH_EDIT = _UxGT("Mesh Düzenleme"); @@ -145,14 +211,12 @@ namespace Language_tr { LSTR MSG_UBL_DONE_EDITING_MESH = _UxGT("Mesh Düzenleme Tamam"); LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Özel Mesh Oluştur"); LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("Mesh Oluştur"); - #if HAS_PREHEAT - LSTR MSG_UBL_BUILD_MESH_M = _UxGT("Mesh Oluştur ($)"); - LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("Doğrulama Mesh ($)"); - #endif + LSTR MSG_UBL_BUILD_MESH_M = _UxGT("Mesh Oluştur ($)"); LSTR MSG_UBL_BUILD_COLD_MESH = _UxGT("Soğuk Mesh Oluştur"); LSTR MSG_UBL_MESH_HEIGHT_ADJUST = _UxGT("Mesh Yükseklik Ayarı"); LSTR MSG_UBL_MESH_HEIGHT_AMOUNT = _UxGT("Yükseklik miktarı"); LSTR MSG_UBL_VALIDATE_MESH_MENU = _UxGT("Doğrulama Mesh"); + LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("Doğrulama Mesh ($)"); LSTR MSG_UBL_VALIDATE_CUSTOM_MESH = _UxGT("Özel Mesh Doğrulama"); LSTR MSG_G26_HEATING_BED = _UxGT("G26 Isıtma Tablası"); LSTR MSG_G26_HEATING_NOZZLE = _UxGT("G26 Isıtma Memesi"); @@ -162,29 +226,32 @@ namespace Language_tr { LSTR MSG_G26_CANCELED = _UxGT("G26 İptal edildi"); LSTR MSG_G26_LEAVING = _UxGT("Çıkış G26"); LSTR MSG_UBL_CONTINUE_MESH = _UxGT("Tabla Mesh Devam et"); - LSTR MSG_UBL_MESH_LEVELING = _UxGT("Mesh Hizalama"); - LSTR MSG_UBL_3POINT_MESH_LEVELING = _UxGT("3-Nokta Hizalama"); - LSTR MSG_UBL_GRID_MESH_LEVELING = _UxGT("Kafes Mesh Hizalama"); + LSTR MSG_UBL_MESH_LEVELING = _UxGT("Mesh Seviyeleme"); + LSTR MSG_UBL_3POINT_MESH_LEVELING = _UxGT("3-Nokta Seviyeleme"); + LSTR MSG_UBL_GRID_MESH_LEVELING = _UxGT("Kafes Mesh Seviyeleme"); LSTR MSG_UBL_MESH_LEVEL = _UxGT("Mesh Seviyesi"); LSTR MSG_UBL_SIDE_POINTS = _UxGT("Yan Noktalar"); LSTR MSG_UBL_MAP_TYPE = _UxGT("Haritalama Türü"); LSTR MSG_UBL_OUTPUT_MAP = _UxGT("Mesh Çıkış Haritası"); LSTR MSG_UBL_OUTPUT_MAP_HOST = _UxGT("Host için Çıktı"); LSTR MSG_UBL_OUTPUT_MAP_CSV = _UxGT("CSV için Çıktı"); - LSTR MSG_UBL_OUTPUT_MAP_BACKUP = _UxGT("Yazıcıda Yedek Kpalı"); + LSTR MSG_UBL_OUTPUT_MAP_BACKUP = _UxGT("Yedekleme Kapalı"); LSTR MSG_UBL_INFO_UBL = _UxGT("UBL Çıkış Bilgisi"); LSTR MSG_UBL_FILLIN_AMOUNT = _UxGT("Dolgu Miktarı"); LSTR MSG_UBL_MANUAL_FILLIN = _UxGT("Manuel Dolgu"); LSTR MSG_UBL_SMART_FILLIN = _UxGT("Akıllı Dogu"); LSTR MSG_UBL_FILLIN_MESH = _UxGT("Mesh Dolgu"); + LSTR MSG_UBL_MESH_FILLED = _UxGT("Eksikler Dolduruldu"); + LSTR MSG_UBL_MESH_INVALID = _UxGT("Geçersiz Mesh"); LSTR MSG_UBL_INVALIDATE_ALL = _UxGT("Tümünü Geçersiz Kıl"); LSTR MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Yakını Geçersiz Kıl"); LSTR MSG_UBL_FINE_TUNE_ALL = _UxGT("Tümünü İnce Ayarla"); LSTR MSG_UBL_FINE_TUNE_CLOSEST = _UxGT("Yakını İnce Ayarla"); LSTR MSG_UBL_STORAGE_MESH_MENU = _UxGT("Mesh Depolama"); LSTR MSG_UBL_STORAGE_SLOT = _UxGT("Bellek Yuvası"); - LSTR MSG_UBL_LOAD_MESH = _UxGT("Yatak Mesh Yükle"); - LSTR MSG_UBL_SAVE_MESH = _UxGT("Yatak Mesh Kayıt Et"); + LSTR MSG_UBL_LOAD_MESH = _UxGT("Tabla Mesh Yükle"); + LSTR MSG_UBL_SAVE_MESH = _UxGT("Tabla Mesh Kayıt Et"); + LSTR MSG_UBL_INVALID_SLOT = _UxGT("Önce Mesh Yuvası Seç"); LSTR MSG_MESH_LOADED = _UxGT("Mesh %i yüklendi"); LSTR MSG_MESH_SAVED = _UxGT("Mesh %i kayıtlandı"); LSTR MSG_UBL_NO_STORAGE = _UxGT("Depolama Yok"); @@ -199,7 +266,7 @@ namespace Language_tr { LSTR MSG_UBL_4_FINE_TUNE_ALL = _UxGT("4.Tümünü İnce Ayarla"); LSTR MSG_UBL_5_VALIDATE_MESH_MENU = _UxGT("5.Doğrulama Mesh"); LSTR MSG_UBL_6_FINE_TUNE_ALL = _UxGT("6.Tümünü İnce Ayarla"); - LSTR MSG_UBL_7_SAVE_MESH = _UxGT("7.Yatak Mesh Kayıt Et"); + LSTR MSG_UBL_7_SAVE_MESH = _UxGT("7.Tabla Mesh Kaydet"); LSTR MSG_LED_CONTROL = _UxGT("LED Kontrolü"); LSTR MSG_LEDS = _UxGT("LEDler"); @@ -213,6 +280,10 @@ namespace Language_tr { LSTR MSG_SET_LEDS_VIOLET = _UxGT("Menekşe"); LSTR MSG_SET_LEDS_WHITE = _UxGT("Beyaz"); LSTR MSG_SET_LEDS_DEFAULT = _UxGT("Varsayılan"); + LSTR MSG_LED_CHANNEL_N = _UxGT("Kanal ="); + LSTR MSG_LEDS2 = _UxGT("Işıklar #2"); + LSTR MSG_NEO2_PRESETS = _UxGT("Işık #2 Ön Ayarları"); + LSTR MSG_NEO2_BRIGHTNESS = _UxGT("Parlaklık"); LSTR MSG_CUSTOM_LEDS = _UxGT("Özel Işıklar"); LSTR MSG_INTENSITY_R = _UxGT("Kırmızı Şiddeti"); LSTR MSG_INTENSITY_G = _UxGT("Yeşil Şiddeti"); @@ -222,9 +293,10 @@ namespace Language_tr { LSTR MSG_MOVING = _UxGT("Hareket Ediyor.."); LSTR MSG_FREE_XY = _UxGT("Durdur XY"); - LSTR MSG_MOVE_X = _UxGT("X Hareketi"); + LSTR MSG_MOVE_X = _UxGT("X Hareketi"); // Used by draw_edit_screen LSTR MSG_MOVE_Y = _UxGT("Y Hareketi"); LSTR MSG_MOVE_Z = _UxGT("Z Hareketi"); + LSTR MSG_MOVE_N = _UxGT("@ Hareketi"); LSTR MSG_MOVE_E = _UxGT("Ekstruder"); LSTR MSG_MOVE_EN = _UxGT("Ekstruder *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Nozul Çok Soğuk"); @@ -232,18 +304,36 @@ namespace Language_tr { 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_MOVE_0001IN = _UxGT("0.001in"); + LSTR MSG_MOVE_001IN = _UxGT("0.01in"); + LSTR MSG_MOVE_01IN = _UxGT("0.1in"); + LSTR MSG_MOVE_05IN = _UxGT("0.5in"); + LSTR MSG_MOVE_1IN = _UxGT("1.0in"); LSTR MSG_SPEED = _UxGT("Hız"); LSTR MSG_BED_Z = _UxGT("Z Mesafesi"); LSTR MSG_NOZZLE = _UxGT("Nozul"); LSTR MSG_NOZZLE_N = _UxGT("Nozul ~"); + LSTR MSG_NOZZLE_PARKED = _UxGT("Nozul Park Edildi"); + LSTR MSG_NOZZLE_STANDBY = _UxGT("Nozul Beklemede"); LSTR MSG_BED = _UxGT("Tabla"); - LSTR MSG_CHAMBER = _UxGT("Çevirme"); + LSTR MSG_CHAMBER = _UxGT("Kabin"); + LSTR MSG_COOLER = _UxGT("Lazer Soğutucu"); + LSTR MSG_COOLER_TOGGLE = _UxGT("Soğutucuyu Değiştir"); + LSTR MSG_FLOWMETER_SAFETY = _UxGT("Akış Güvenliği"); + LSTR MSG_CUTTER = _UxGT("Kesici"); + LSTR MSG_LASER = _UxGT("Lazer"); LSTR MSG_FAN_SPEED = _UxGT("Fan Hızı"); LSTR MSG_FAN_SPEED_N = _UxGT("Fan Hızı ~"); LSTR MSG_STORED_FAN_N = _UxGT("Depolanan Fan ~"); LSTR MSG_EXTRA_FAN_SPEED = _UxGT("Ekstra Fan Hızı"); LSTR MSG_EXTRA_FAN_SPEED_N = _UxGT("Ekstra Fan Hızı ~"); + LSTR MSG_CONTROLLER_FAN = _UxGT("Kontrolör Fanı"); + LSTR MSG_CONTROLLER_FAN_IDLE_SPEED = _UxGT("Rölanti Hızı"); + LSTR MSG_CONTROLLER_FAN_AUTO_ON = _UxGT("Otomatik Mod"); + LSTR MSG_CONTROLLER_FAN_SPEED = _UxGT("Aktif Hız"); + LSTR MSG_CONTROLLER_FAN_DURATION = _UxGT("Rölanti Periyodu"); LSTR MSG_FLOW = _UxGT("Akış"); LSTR MSG_FLOW_N = _UxGT("Akış ~"); LSTR MSG_CONTROL = _UxGT("Kontrol"); @@ -255,35 +345,58 @@ namespace Language_tr { LSTR MSG_LCD_OFF = _UxGT("Kapalı"); LSTR MSG_PID_AUTOTUNE = _UxGT("PID Kalibrasyon"); LSTR MSG_PID_AUTOTUNE_E = _UxGT("PID Kalibrasyon *"); + LSTR MSG_PID_CYCLE = _UxGT("PID Döngüleri"); + LSTR MSG_PID_AUTOTUNE_DONE = _UxGT("PID ayarı yapıldı"); + LSTR MSG_PID_AUTOTUNE_FAILED = _UxGT("PID Autotune başarısız!"); + LSTR MSG_BAD_EXTRUDER_NUM = _UxGT("Kötü ekstruder."); + LSTR MSG_TEMP_TOO_HIGH = _UxGT("Sıcaklık çok yüksek."); + LSTR MSG_TIMEOUT = _UxGT("Zaman aşımı."); + LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Otomatik ayar başarısız! Kötü ekstruder."); + LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Otomatik ayar başarısız! Sıcaklık çok yüksek."); + LSTR MSG_PID_TIMEOUT = _UxGT("Otomatik ayar başarısız! Zaman aşımı."); + LSTR MSG_MPC_MEASURING_AMBIENT = _UxGT("Isı kaybı test ediliyor"); + LSTR MSG_MPC_AUTOTUNE = _UxGT("MPC Otomatik Ayarı"); + LSTR MSG_MPC_EDIT = _UxGT("Düzenle * MPC"); + LSTR MSG_MPC_POWER_E = _UxGT("Güç *"); + LSTR MSG_MPC_BLOCK_HEAT_CAPACITY_E = _UxGT("Blok C *"); + LSTR MSG_SENSOR_RESPONSIVENESS_E = _UxGT("Sensör çözünürlüğü *"); + LSTR MSG_MPC_AMBIENT_XFER_COEFF_E = _UxGT("Ortam h *"); + LSTR MSG_MPC_AMBIENT_XFER_COEFF_FAN_E = _UxGT("Amb. h fan *"); LSTR MSG_SELECT = _UxGT("Seç"); LSTR MSG_SELECT_E = _UxGT("Seç *"); LSTR MSG_ACC = _UxGT("İvme"); - - LSTR MSG_JERK = _UxGT("Sarsım"); - LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT("-Sarsım"); - LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT("-Sarsım"); - LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT("-Sarsım"); - LSTR MSG_VN_JERK = _UxGT("V@-Sarsım"); - LSTR MSG_VE_JERK = _UxGT("Ve-Sarsım"); + LSTR MSG_JERK = _UxGT("Sarsma"); + LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT(" Sarsma"); + LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT(" Sarsma"); + LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT(" Sarsma"); + LSTR MSG_VN_JERK = _UxGT("Max @ Sarsma"); + LSTR MSG_VE_JERK = _UxGT("Max E Sarsma"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Jonksiyon Sapması"); LSTR MSG_MAX_SPEED = _UxGT("Hız Vektörü"); - LSTR MSG_VMAX_A = _UxGT("HızVektör.max ") STR_A; - LSTR MSG_VMAX_B = _UxGT("HızVektör.max ") STR_B; - LSTR MSG_VMAX_C = _UxGT("HızVektör.max ") STR_C; - LSTR MSG_VMAX_N = _UxGT("HızVektör.max @"); - LSTR MSG_VMAX_E = _UxGT("HızVektör.max E"); - LSTR MSG_VMAX_EN = _UxGT("HızVektör.max *"); - LSTR MSG_VMIN = _UxGT("HızVektör.min"); - LSTR MSG_VTRAV_MIN = _UxGT("HV.gezinme min"); + LSTR MSG_VMAX_A = _UxGT("Max ") STR_A _UxGT(" Hız"); + LSTR MSG_VMAX_B = _UxGT("Max ") STR_B _UxGT(" Hız"); + LSTR MSG_VMAX_C = _UxGT("Max ") STR_C _UxGT(" Hız"); + LSTR MSG_VMAX_N = _UxGT("Max @ Hız"); + LSTR MSG_VMAX_E = _UxGT("Max E Hız"); + LSTR MSG_VMAX_EN = _UxGT("Max * Hız"); + LSTR MSG_VMIN = _UxGT("Min Hız"); + LSTR MSG_VTRAV_MIN = _UxGT("Min Gezme Hızı"); LSTR MSG_ACCELERATION = _UxGT("Ivme"); - LSTR MSG_AMAX_A = _UxGT("Max. ivme ") STR_A; - LSTR MSG_AMAX_B = _UxGT("Max. ivme ") STR_B; - LSTR MSG_AMAX_C = _UxGT("Max. ivme ") STR_C; - LSTR MSG_AMAX_N = _UxGT("Max. ivme @"); - LSTR MSG_AMAX_E = _UxGT("Max. ivme E"); - LSTR MSG_AMAX_EN = _UxGT("Max. ivme *"); - LSTR MSG_A_RETRACT = _UxGT("Ivme-geri çekme"); - LSTR MSG_A_TRAVEL = _UxGT("Ivme-gezinme"); + LSTR MSG_AMAX_A = _UxGT("Max ") STR_A _UxGT(" İvme"); + LSTR MSG_AMAX_B = _UxGT("Max ") STR_B _UxGT(" İvme"); + LSTR MSG_AMAX_C = _UxGT("Max ") STR_C _UxGT(" İvme"); + LSTR MSG_AMAX_N = _UxGT("Max @ İvme"); + LSTR MSG_AMAX_E = _UxGT("Max E İvme"); + LSTR MSG_AMAX_EN = _UxGT("Max * İvme"); + LSTR MSG_A_RETRACT = _UxGT("G.Çekme Hızı"); + LSTR MSG_A_TRAVEL = _UxGT("Gezinme Hızı"); + LSTR MSG_INPUT_SHAPING = _UxGT("Girdi Şekillendirme"); + LSTR MSG_SHAPING_ENABLE = _UxGT("Biçimleme @ aktif"); + LSTR MSG_SHAPING_DISABLE = _UxGT("Biçimleme @ pasif"); + LSTR MSG_SHAPING_FREQ = _UxGT("@ frekans"); + LSTR MSG_SHAPING_ZETA = _UxGT("@ sönümleme"); + LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("XY Frek. Sınırı"); + LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Min FR Factor"); LSTR MSG_STEPS_PER_MM = _UxGT("Adım/mm"); LSTR MSG_A_STEPS = STR_A _UxGT(" adım/mm"); LSTR MSG_B_STEPS = STR_B _UxGT(" adım/mm"); @@ -295,69 +408,133 @@ namespace Language_tr { LSTR MSG_MOTION = _UxGT("Hareket"); LSTR MSG_FILAMENT = _UxGT("Filaman"); LSTR MSG_VOLUMETRIC_ENABLED = _UxGT("Ekstrüzyon/mm") SUPERSCRIPT_THREE; + LSTR MSG_VOLUMETRIC_LIMIT = _UxGT("E Limit in mm") SUPERSCRIPT_THREE; + LSTR MSG_VOLUMETRIC_LIMIT_E = _UxGT("E Limit *"); LSTR MSG_FILAMENT_DIAM = _UxGT("Filaman Çapı"); LSTR MSG_FILAMENT_DIAM_E = _UxGT("Filaman Çapı *"); LSTR MSG_FILAMENT_UNLOAD = _UxGT("Çıkart mm"); LSTR MSG_FILAMENT_LOAD = _UxGT("Yükle mm"); + LSTR MSG_SEGMENTS_PER_SECOND = _UxGT("Segment/Sn"); + 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 Kayış Boyu"); LSTR MSG_ADVANCE_K = _UxGT("K İlerlet"); LSTR MSG_ADVANCE_K_E = _UxGT("K İlerlet *"); LSTR MSG_CONTRAST = _UxGT("LCD Kontrast"); + LSTR MSG_BRIGHTNESS = _UxGT("LCD Parlaklığı"); + LSTR MSG_SCREEN_TIMEOUT = _UxGT("LCD Zaman Aşımı (m)"); + LSTR MSG_BRIGHTNESS_OFF = _UxGT("Arka Işık Kapalı"); LSTR MSG_STORE_EEPROM = _UxGT("Hafızaya Al"); LSTR MSG_LOAD_EEPROM = _UxGT("Hafızadan Yükle"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Fabrika Ayarları"); LSTR MSG_INIT_EEPROM = _UxGT("EEPROM'u başlat"); LSTR MSG_ERR_EEPROM_CRC = _UxGT("Hata: EEPROM CRC"); - LSTR MSG_ERR_EEPROM_INDEX = _UxGT("Hata: EEPROM Indeks"); - LSTR MSG_ERR_EEPROM_VERSION = _UxGT("Hata: EEPROM Versiyonu"); + LSTR MSG_ERR_EEPROM_SIZE = _UxGT("Hata: EEPROM Boyutu"); + LSTR MSG_ERR_EEPROM_VERSION = _UxGT("Hata: EEPROM Sürümü"); + LSTR MSG_SETTINGS_STORED = _UxGT("Ayarlar Kaydedildi"); LSTR MSG_MEDIA_UPDATE = _UxGT("SD Güncellemesi"); LSTR MSG_RESET_PRINTER = _UxGT("Yazıcıyı Resetle"); LSTR MSG_REFRESH = LCD_STR_REFRESH _UxGT("Yenile"); LSTR MSG_INFO_SCREEN = _UxGT("Bilgi Ekranı"); + LSTR MSG_INFO_MACHINENAME = _UxGT("Makine Adı"); + LSTR MSG_INFO_SIZE = _UxGT("Boyut"); + LSTR MSG_INFO_FWVERSION = _UxGT("Yazılım Sürümü"); + LSTR MSG_INFO_BUILD = _UxGT("Tarih & Saat Oluştur"); LSTR MSG_PREPARE = _UxGT("Hazırlık"); LSTR MSG_TUNE = _UxGT("Ayar"); + LSTR MSG_POWER_MONITOR = _UxGT("Güç monitörü"); + LSTR MSG_CURRENT = _UxGT("Akım"); + LSTR MSG_VOLTAGE = _UxGT("Voltaj"); + LSTR MSG_POWER = _UxGT("Güç"); LSTR MSG_START_PRINT = _UxGT("Yaz. Başlat"); LSTR MSG_BUTTON_NEXT = _UxGT("İleri"); - LSTR MSG_BUTTON_INIT = _UxGT("İçinde"); + LSTR MSG_BUTTON_INIT = _UxGT("Başlat"); LSTR MSG_BUTTON_STOP = _UxGT("Durdur"); LSTR MSG_BUTTON_PRINT = _UxGT("Yazdır"); LSTR MSG_BUTTON_RESET = _UxGT("Resetle"); + LSTR MSG_BUTTON_IGNORE = _UxGT("Yoksay"); LSTR MSG_BUTTON_CANCEL = _UxGT("İptal"); + LSTR MSG_BUTTON_CONFIRM = _UxGT("Onayla"); + LSTR MSG_BUTTON_CONTINUE = _UxGT("Sürdür"); LSTR MSG_BUTTON_DONE = _UxGT("Tamamlandı"); LSTR MSG_BUTTON_BACK = _UxGT("Geri"); - LSTR MSG_BUTTON_PROCEED = _UxGT("Devam ediyor"); + LSTR MSG_BUTTON_PROCEED = _UxGT("Devam Et"); + LSTR MSG_BUTTON_SKIP = _UxGT("Atla"); + LSTR MSG_BUTTON_INFO = _UxGT("Bilgi"); + LSTR MSG_BUTTON_LEVEL = _UxGT("Seviye"); + LSTR MSG_BUTTON_PAUSE = _UxGT("Duraklat"); + LSTR MSG_BUTTON_RESUME = _UxGT("Devam Et"); + LSTR MSG_BUTTON_ADVANCED = _UxGT("Gelişmiş"); + LSTR MSG_BUTTON_SAVE = _UxGT("Kaydet"); + LSTR MSG_BUTTON_PURGE = _UxGT("Temizle"); + LSTR MSG_PAUSING = _UxGT("Duraklatılıyor..."); LSTR MSG_PAUSE_PRINT = _UxGT("Duraklat"); - LSTR MSG_RESUME_PRINT = _UxGT("Sürdür"); - LSTR MSG_STOP_PRINT = _UxGT("Durdur"); - LSTR MSG_PRINTING_OBJECT = _UxGT("Yazdırma Nesnesi"); - LSTR MSG_CANCEL_OBJECT = _UxGT("Nesneyi İptal Et"); - LSTR MSG_CANCEL_OBJECT_N = _UxGT("Nesneyi İptal Et ="); + LSTR MSG_ADVANCED_PAUSE = _UxGT("Gelişmiş Duraklatma"); + LSTR MSG_RESUME_PRINT = _UxGT("Baskıyı Sürdür"); + LSTR MSG_STOP_PRINT = _UxGT("Baskıyı Durdur"); LSTR MSG_OUTAGE_RECOVERY = _UxGT("Kesinti Kurtarma"); - LSTR MSG_MEDIA_MENU = _UxGT("SD Karttan Yazdır"); + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 + LSTR MSG_HOST_START_PRINT = _UxGT("Host Baskıyı başlat"); + LSTR MSG_PRINTING_OBJECT = _UxGT("Yazdırma Nesnesi"); + LSTR MSG_CANCEL_OBJECT = _UxGT("Nesneyi İptal Et"); + LSTR MSG_CANCEL_OBJECT_N = _UxGT("Nesneyi İptal Et ="); + LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Yazdırmaya Devam Et"); + LSTR MSG_MEDIA_MENU = _UxGT("SD Karttan Yazdır"); + LSTR MSG_TURN_OFF = _UxGT("Yazıcıyı kapat"); + LSTR MSG_END_LOOPS = _UxGT("Tekrr Döngüler Bitir"); + #else + LSTR MSG_HOST_START_PRINT = _UxGT("Host Başlatma"); + LSTR MSG_PRINTING_OBJECT = _UxGT("Nesneyi Yazdır"); + LSTR MSG_CANCEL_OBJECT = _UxGT("Nesneyi İptal Et"); + LSTR MSG_CANCEL_OBJECT_N = _UxGT("Nesneyi İptal Et ="); + LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("İşe Devam Et"); + LSTR MSG_MEDIA_MENU = MEDIA_TYPE_EN _UxGT(" Yazdır"); + LSTR MSG_TURN_OFF = _UxGT("Şimdi kapat"); + LSTR MSG_END_LOOPS = _UxGT("Son Döngüler"); + #endif LSTR MSG_NO_MEDIA = _UxGT("SD Kart Yok!"); LSTR MSG_DWELL = _UxGT("Uyku..."); - LSTR MSG_USERWAIT = _UxGT("Operatör bekleniyor."); + LSTR MSG_USERWAIT = _UxGT("Devam için tıkla..."); LSTR MSG_PRINT_PAUSED = _UxGT("Baskı Duraklatıldı"); LSTR MSG_PRINTING = _UxGT("Baskı Yapılıyor..."); + LSTR MSG_STOPPING = _UxGT("Durduruluyor..."); + LSTR MSG_REMAINING_TIME = _UxGT("Kalan"); LSTR MSG_PRINT_ABORTED = _UxGT("Baskı Durduruldu!"); + LSTR MSG_PRINT_DONE = _UxGT("Yazdırma Bitti"); + LSTR MSG_PRINTER_KILLED = _UxGT("Yazıcı çöktü!"); LSTR MSG_NO_MOVE = _UxGT("İşlem yok."); - LSTR MSG_KILLED = _UxGT("Kilitlendi. "); - LSTR MSG_STOPPED = _UxGT("Durdu. "); + LSTR MSG_KILLED = _UxGT("ÇÖKTÜ. "); + LSTR MSG_STOPPED = _UxGT("DURDURULDU. "); + LSTR MSG_FWRETRACT = _UxGT("Yazılım Geri Çekme"); LSTR MSG_CONTROL_RETRACT = _UxGT("Geri Çek mm"); LSTR MSG_CONTROL_RETRACT_SWAP = _UxGT("Swap Re.mm"); LSTR MSG_CONTROL_RETRACTF = _UxGT("Geri Çekme V"); LSTR MSG_CONTROL_RETRACT_ZHOP = _UxGT("Atlama mm"); - LSTR MSG_CONTROL_RETRACT_RECOVER = _UxGT("Unretr. mm"); + LSTR MSG_CONTROL_RETRACT_RECOVER = _UxGT("Geri Çek. mm"); LSTR MSG_CONTROL_RETRACT_RECOVER_SWAP = _UxGT("S Unretr. mm"); LSTR MSG_CONTROL_RETRACT_RECOVERF = _UxGT("Unretract V"); LSTR MSG_CONTROL_RETRACT_RECOVER_SWAPF = _UxGT("S UnRet V"); LSTR MSG_AUTORETRACT = _UxGT("Oto. Geri Çekme"); LSTR MSG_FILAMENT_SWAP_LENGTH = _UxGT("G.Çekme Boyu"); + LSTR MSG_FILAMENT_SWAP_EXTRA = _UxGT("Ekstra Değiştir"); LSTR MSG_FILAMENT_PURGE_LENGTH = _UxGT("Tasfiye uzunluğu"); LSTR MSG_TOOL_CHANGE = _UxGT("Takım Değişimi"); LSTR MSG_TOOL_CHANGE_ZLIFT = _UxGT("Z Yükselt"); LSTR MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Birincil Hız"); + LSTR MSG_SINGLENOZZLE_WIPE_RETRACT = _UxGT("Geri Çekme Sil"); LSTR MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Geri Çekme Hızı"); - LSTR MSG_NOZZLE_STANDBY = _UxGT("Nozul Beklemede"); + LSTR MSG_FILAMENT_PARK_ENABLED = _UxGT("Kafa Park"); + LSTR MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Kurtarma Hızı"); + LSTR MSG_SINGLENOZZLE_FAN_SPEED = _UxGT("Fan Hızı"); + LSTR MSG_SINGLENOZZLE_FAN_TIME = _UxGT("Fan Süresi"); + LSTR MSG_TOOL_MIGRATION_ON = _UxGT("Otomatik AÇIK"); + LSTR MSG_TOOL_MIGRATION_OFF = _UxGT("Otomatik KAPALI"); + LSTR MSG_TOOL_MIGRATION = _UxGT("Takım Taşıma"); + LSTR MSG_TOOL_MIGRATION_AUTO = _UxGT("Otomatik-taşıma"); + LSTR MSG_TOOL_MIGRATION_END = _UxGT("Son Ekstruder"); + LSTR MSG_TOOL_MIGRATION_SWAP = _UxGT("* konumuna taşı"); LSTR MSG_FILAMENTCHANGE = _UxGT("Filaman Değiştir"); LSTR MSG_FILAMENTCHANGE_E = _UxGT("Filaman Değiştir *"); LSTR MSG_FILAMENTLOAD = _UxGT("Filaman Yükle"); @@ -365,36 +542,42 @@ namespace Language_tr { LSTR MSG_FILAMENTUNLOAD = _UxGT("Filaman Çıkart"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Filaman Çıkart *"); LSTR MSG_FILAMENTUNLOAD_ALL = _UxGT("Tümünü Çıkart"); - LSTR MSG_ATTACH_MEDIA = _UxGT("SD Kart Başlatılıyor"); - LSTR MSG_CHANGE_MEDIA = _UxGT("SD Kart Değiştir"); - LSTR MSG_RELEASE_MEDIA = _UxGT("SD Kart Çıkart"); - LSTR MSG_ZPROBE_OUT = _UxGT("Z Prob Açık. Tabla"); + LSTR MSG_ATTACH_MEDIA = _UxGT("Ekle ") MEDIA_TYPE_EN; + LSTR MSG_CHANGE_MEDIA = _UxGT("Değiştir ") MEDIA_TYPE_EN; + LSTR MSG_RELEASE_MEDIA = _UxGT("Çıkart ") MEDIA_TYPE_EN; + LSTR MSG_ZPROBE_OUT = _UxGT("Z Prob Tablayı Geçti"); LSTR MSG_SKEW_FACTOR = _UxGT("Çarpıklık Faktörü"); LSTR MSG_BLTOUCH = _UxGT("BLTouch"); LSTR MSG_BLTOUCH_SELFTEST = _UxGT("BLTouch K. Test"); - LSTR MSG_BLTOUCH_RESET = _UxGT("Reset"); + LSTR MSG_BLTOUCH_RESET = _UxGT("Sıfırla"); LSTR MSG_BLTOUCH_STOW = _UxGT("Kapat"); LSTR MSG_BLTOUCH_DEPLOY = _UxGT("Aç"); LSTR MSG_BLTOUCH_SW_MODE = _UxGT("SW-Modu"); + LSTR MSG_BLTOUCH_SPEED_MODE = _UxGT("Yüksek Hız"); LSTR MSG_BLTOUCH_5V_MODE = _UxGT("5V-Modu"); LSTR MSG_BLTOUCH_OD_MODE = _UxGT("OD-Modu"); LSTR MSG_BLTOUCH_MODE_STORE = _UxGT("Mode-Store"); LSTR MSG_BLTOUCH_MODE_STORE_5V = _UxGT("BLTouch 5V Ayarla"); LSTR MSG_BLTOUCH_MODE_STORE_OD = _UxGT("BLTouch OD Ayarla"); LSTR MSG_BLTOUCH_MODE_ECHO = _UxGT("Drenaj Raporu"); - LSTR MSG_BLTOUCH_MODE_CHANGE = _UxGT("TEHLIKE: Kötü ayarlar hasara neden olabilir! Yine de devam edilsin mi?"); + LSTR MSG_BLTOUCH_MODE_CHANGE = _UxGT("TEHLIKE: Kötü ayarlar zarar verebilir! Yine de devam edilsin mi?"); LSTR MSG_TOUCHMI_PROBE = _UxGT("TouchMI"); - LSTR MSG_TOUCHMI_INIT = _UxGT("Init TouchMI"); + LSTR MSG_TOUCHMI_INIT = _UxGT("TouchMI'yi Başlat"); LSTR MSG_TOUCHMI_ZTEST = _UxGT("Z Ofset Testi"); LSTR MSG_TOUCHMI_SAVE = _UxGT("Kaydet"); LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("TouchMI Aç"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Z-Probe Aç"); LSTR MSG_MANUAL_STOW = _UxGT("Z-Probe Kapat"); LSTR MSG_HOME_FIRST = _UxGT("Önce %s%s%s Sıfırla"); + LSTR MSG_ZPROBE_SETTINGS = _UxGT("Prob Ayarları"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Prob Ofsetleri"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("X Prob Ofset"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Y Prob Ofset"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Z Prob Ofset"); + LSTR MSG_ZPROBE_MARGIN = _UxGT("Prob Payı"); + LSTR MSG_Z_FEED_RATE = _UxGT("Z İlerleme Hızı"); + LSTR MSG_ENABLE_HS_MODE = _UxGT("HS modunu aç"); + LSTR MSG_MOVE_NOZZLE_TO_BED = _UxGT("Nozülü Tablaya Taşı"); LSTR MSG_BABYSTEP_X = _UxGT("Miniadım X"); LSTR MSG_BABYSTEP_Y = _UxGT("Miniadım Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Miniadım Z"); @@ -402,23 +585,28 @@ namespace Language_tr { LSTR MSG_BABYSTEP_TOTAL = _UxGT("Toplam"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Endstop iptal"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Isınma başarısız"); - LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("Hata: Sıcaklık Aşımı"); - LSTR MSG_THERMAL_RUNAWAY = _UxGT("TERMAL PROBLEM"); - LSTR MSG_THERMAL_RUNAWAY_BED = _UxGT("TABLA TERMAL PROBLEM"); - LSTR MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("ODA TERMAL PROBLEM"); + LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("Hata: ISI AŞIMI"); + LSTR MSG_THERMAL_RUNAWAY = _UxGT("ISI SORUNU"); + LSTR MSG_TEMP_MALFUNCTION = _UxGT("SICAKLIK ARIZASI"); + LSTR MSG_THERMAL_RUNAWAY_BED = _UxGT("TABLA ISI SORUNU"); + LSTR MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("KABİN ISI SORUNU"); + LSTR MSG_THERMAL_RUNAWAY_COOLER = _UxGT("Soğutucu Isı Sorunu"); + LSTR MSG_COOLING_FAILED = _UxGT("Soğutma Başarısız"); LSTR MSG_ERR_MAXTEMP = _UxGT("Hata: MAX.SICAKLIK"); LSTR MSG_ERR_MINTEMP = _UxGT("Hata: MIN.SICAKLIK"); LSTR MSG_HALTED = _UxGT("YAZICI DURDURULDU"); + LSTR MSG_PLEASE_WAIT = _UxGT("Lütfen bekleyin..."); LSTR MSG_PLEASE_RESET = _UxGT("Lütfen Resetleyin"); - LSTR MSG_SHORT_DAY = _UxGT("G"); // One character only - LSTR MSG_SHORT_HOUR = _UxGT("S"); // One character only - LSTR MSG_SHORT_MINUTE = _UxGT("D"); // One character only + LSTR MSG_PREHEATING = _UxGT("ön ısıtma..."); LSTR MSG_HEATING = _UxGT("Isınıyor..."); LSTR MSG_COOLING = _UxGT("Soğuyor..."); LSTR MSG_BED_HEATING = _UxGT("Tabla Isınıyor..."); LSTR MSG_BED_COOLING = _UxGT("Tabla Soğuyor..."); - LSTR MSG_CHAMBER_HEATING = _UxGT("Oda Isınıyor..."); - LSTR MSG_CHAMBER_COOLING = _UxGT("Oda Soğuyor..."); + LSTR MSG_PROBE_HEATING = _UxGT("Prob ısınıyor..."); + LSTR MSG_PROBE_COOLING = _UxGT("Prob Soğuyor..."); + LSTR MSG_CHAMBER_HEATING = _UxGT("Kabin Isınıyor..."); + LSTR MSG_CHAMBER_COOLING = _UxGT("Kabin Soğuyor..."); + LSTR MSG_LASER_COOLING = _UxGT("Lazer Soğuyor..."); LSTR MSG_DELTA_CALIBRATE = _UxGT("Delta Kalibrasyonu"); LSTR MSG_DELTA_CALIBRATE_X = _UxGT("Ayarla X"); LSTR MSG_DELTA_CALIBRATE_Y = _UxGT("Ayarla Y"); @@ -426,42 +614,64 @@ namespace Language_tr { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Ayarla Merkez"); LSTR MSG_DELTA_SETTINGS = _UxGT("Delta Ayarları"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Oto Kalibrasyon"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Delta Yük. Ayarla"); - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Z Prob Ofseti"); LSTR MSG_DELTA_DIAG_ROD = _UxGT("Çapral Mil"); LSTR MSG_DELTA_HEIGHT = _UxGT("Yükseklik"); LSTR MSG_DELTA_RADIUS = _UxGT("Yarıçap"); LSTR MSG_INFO_MENU = _UxGT("Yazıcı Hakkında"); LSTR MSG_INFO_PRINTER_MENU = _UxGT("Yazıcı Bilgisi"); - LSTR MSG_3POINT_LEVELING = _UxGT("3-Nokta Hizalama"); - LSTR MSG_LINEAR_LEVELING = _UxGT("Doğrusal Hizalama"); + LSTR MSG_3POINT_LEVELING = _UxGT("3-Nokta Seviyeleme"); + LSTR MSG_LINEAR_LEVELING = _UxGT("Doğrusal Seviyeleme"); LSTR MSG_BILINEAR_LEVELING = _UxGT("İki Yönlü Doğ. Hiza."); LSTR MSG_UBL_LEVELING = _UxGT("Birleşik Tabla Hiza."); - LSTR MSG_MESH_LEVELING = _UxGT("Mesh Hizalama"); + LSTR MSG_MESH_LEVELING = _UxGT("Mesh Seviyeleme"); + LSTR MSG_MESH_DONE = _UxGT("Mesh sondalama tamam"); LSTR MSG_INFO_STATS_MENU = _UxGT("İstatistikler"); LSTR MSG_INFO_BOARD_MENU = _UxGT("Kontrolcü Bilgisi"); LSTR MSG_INFO_THERMISTOR_MENU = _UxGT("Termistörler"); LSTR MSG_INFO_EXTRUDERS = _UxGT("Ekstruderler"); LSTR MSG_INFO_BAUDRATE = _UxGT("İletişim Hızı"); LSTR MSG_INFO_PROTOCOL = _UxGT("Protokol"); + LSTR MSG_INFO_RUNAWAY_OFF = _UxGT("Kaçak İzleme: KAPALI"); + LSTR MSG_INFO_RUNAWAY_ON = _UxGT("Kaçak İzleme: AÇIK"); + LSTR MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Hotend Boşta Zamn Aş"); + LSTR MSG_FAN_SPEED_FAULT = _UxGT("Fan hızı hatası"); + LSTR MSG_CASE_LIGHT = _UxGT("Aydınlatmayı Aç"); - LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Aydınlatma Parlaklğı"); + LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Işık Parlaklğı"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Yanlış Yazıcı"); + LSTR MSG_COLORS_GET = _UxGT("Renk Al"); + LSTR MSG_COLORS_SELECT = _UxGT("Renkleri Seç"); + LSTR MSG_COLORS_APPLIED = _UxGT("Uygulanan renkler"); + LSTR MSG_COLORS_RED = _UxGT("Kırmızı"); + LSTR MSG_COLORS_GREEN = _UxGT("Yeşil"); + LSTR MSG_COLORS_BLUE = _UxGT("Mavi"); + LSTR MSG_COLORS_WHITE = _UxGT("Beyaz"); + LSTR MSG_UI_LANGUAGE = _UxGT("UI Dili"); + LSTR MSG_SOUND_ENABLE = _UxGT("Sesi etkinleştir"); + LSTR MSG_LOCKSCREEN = _UxGT("Kilit Ekranı"); + LSTR MSG_LOCKSCREEN_LOCKED = _UxGT("Yazıcı Kilitlendi,"); + LSTR MSG_LOCKSCREEN_UNLOCK = _UxGT("Açmak için kaydırın."); + LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Y.Başlatma bekleyin."); + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 + LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("Ortam yerleştirilmedi."); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Lütfen önce hotend'i ısıtın."); + LSTR MSG_INFO_PRINT_COUNT_RESET = _UxGT("Baskı Sayısını Sıfırla"); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Baskı Sayısı"); - LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Tamamlanan"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Toplam Baskı Süresi"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("En Uzun Baskı Süresi"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Toplam Filaman"); #else + LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("Medya Yok"); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Ön Isıtma Lütfen"); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Baskı"); - LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Tamamlanan"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Süre"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("En Uzun"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Filaman"); #endif + LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Tamamlanan"); LSTR MSG_INFO_MIN_TEMP = _UxGT("Min Sıc."); LSTR MSG_INFO_MAX_TEMP = _UxGT("Max Sıc."); LSTR MSG_INFO_PSU = _UxGT("Güç Kaynağı"); @@ -476,9 +686,15 @@ namespace Language_tr { LSTR MSG_FILAMENT_CHANGE_OPTION_HEADER = _UxGT("Seçenekler:"); LSTR MSG_FILAMENT_CHANGE_OPTION_PURGE = _UxGT("Daha Fazla Tasviye"); LSTR MSG_FILAMENT_CHANGE_OPTION_RESUME = _UxGT("Baskıyı sürdür"); + LSTR MSG_FILAMENT_CHANGE_PURGE_CONTINUE = _UxGT("Temizle veya Devam?"); LSTR MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Nozul: "); LSTR MSG_RUNOUT_SENSOR = _UxGT("Runout Sensörü"); LSTR MSG_RUNOUT_DISTANCE_MM = _UxGT("Aşınma Farkı mm"); + LSTR MSG_RUNOUT_ENABLE = _UxGT("Fil. Sens. Aç"); + LSTR MSG_RUNOUT_ACTIVE = _UxGT("Fil. Sens. Aktif"); + LSTR MSG_INVERT_EXTRUDER = _UxGT("Ekstruder Ters Çevir"); + LSTR MSG_EXTRUDER_MIN_TEMP = _UxGT("Ekstruder Min Isı"); + LSTR MSG_FANCHECK = _UxGT("Fan Takosu Kontrolü"); LSTR MSG_KILL_HOMING_FAILED = _UxGT("Sıfırlama Başarısız"); LSTR MSG_LCD_PROBING_FAILED = _UxGT("Probing Başarısız"); @@ -528,6 +744,20 @@ namespace Language_tr { LSTR MSG_SNAKE = _UxGT("Sn4k3"); LSTR MSG_MAZE = _UxGT("Maze"); + LSTR MSG_BAD_PAGE = _UxGT("Hatalı sayfa dizini"); + LSTR MSG_BAD_PAGE_SPEED = _UxGT("Kötü sayfa hızı"); + + LSTR MSG_EDIT_PASSWORD = _UxGT("Şifreyi Düzenle"); + LSTR MSG_LOGIN_REQUIRED = _UxGT("Giriş Gerekli"); + LSTR MSG_PASSWORD_SETTINGS = _UxGT("Şifre Ayarları"); + LSTR MSG_ENTER_DIGIT = _UxGT("Rakam girin"); + LSTR MSG_CHANGE_PASSWORD = _UxGT("Şifre Belirle/Düzenle"); + LSTR MSG_REMOVE_PASSWORD = _UxGT("Şifre Kaldır"); + LSTR MSG_PASSWORD_SET = _UxGT("Şifre "); + LSTR MSG_START_OVER = _UxGT("Yeniden Başla"); + LSTR MSG_REMINDER_SAVE_SETTINGS = _UxGT("Kaydetmeyi Unutma!"); + LSTR MSG_PASSWORD_REMOVED = _UxGT("Şifre Kaldırıldı"); + // // Filament Değişim ekranları 4 satırlı ekranda 3 satıra kadar gösterilir // ...veya 3 satırlı ekranda 2 satıra kadar @@ -569,12 +799,43 @@ namespace Language_tr { LSTR MSG_BACKLASH = _UxGT("Ters Tepki"); LSTR MSG_BACKLASH_CORRECTION = _UxGT("Düzeltme"); LSTR MSG_BACKLASH_SMOOTHING = _UxGT("Yumuşatma"); -} -#if FAN_COUNT == 1 - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED -#else - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N -#endif + LSTR MSG_LEVEL_X_AXIS = _UxGT("Seviye X Ekseni"); + LSTR MSG_AUTO_CALIBRATE = _UxGT("Otomatik Kalibre Et"); + #if ENABLED(TOUCH_UI_FTDI_EVE) + LSTR MSG_HEATER_TIMEOUT = _UxGT("Boşta kalma zaman aşımı, sıcaklık düştü. Yeniden ısıtmak ve tekrar devam etmek için için Tamam'a basın."); + #else + LSTR MSG_HEATER_TIMEOUT = _UxGT("Isıtıcı Zaman Aşımı"); + #endif + LSTR MSG_REHEAT = _UxGT("Yeniden ısıt"); + LSTR MSG_REHEATING = _UxGT("Yeniden ısıtılıyor..."); + LSTR MSG_REHEATDONE = _UxGT("Y. Isıtma Tamam"); + + LSTR MSG_PROBE_WIZARD = _UxGT("Z Prob Sihirbazı"); + LSTR MSG_PROBE_WIZARD_PROBING = _UxGT("Z Referansını Tarama"); + LSTR MSG_PROBE_WIZARD_MOVING = _UxGT("Prob Konumuna Geçme"); + + LSTR MSG_XATC = _UxGT("X-Twist Sihirbazı"); + LSTR MSG_XATC_DONE = _UxGT("X-Twist Sihirbazı Bitti!"); + LSTR MSG_XATC_UPDATE_Z_OFFSET = _UxGT("Prob Z-Offset güncelle "); + + LSTR MSG_SOUND = _UxGT("Ses"); + + LSTR MSG_TOP_LEFT = _UxGT("Üst Sol"); + LSTR MSG_BOTTOM_LEFT = _UxGT("Alt Sol"); + LSTR MSG_TOP_RIGHT = _UxGT("Üst Sağ"); + LSTR MSG_BOTTOM_RIGHT = _UxGT("Alt Sağ"); + LSTR MSG_CALIBRATION_COMPLETED = _UxGT("Kalibrasyon Tamamlandı"); + LSTR MSG_CALIBRATION_FAILED = _UxGT("Kalibrasyon Başarısız"); + + LSTR MSG_DRIVER_BACKWARD = _UxGT(" driver backward"); + + LSTR MSG_SD_CARD = _UxGT("SD Kart"); + LSTR MSG_USB_DISK = _UxGT("USB Disk"); + + LSTR MSG_HOST_SHUTDOWN = _UxGT("Host'u Kapat"); + + LSTR MSG_SHORT_DAY = _UxGT("g"); // One character only + LSTR MSG_SHORT_HOUR = _UxGT("s"); // One character only + LSTR MSG_SHORT_MINUTE = _UxGT("d"); // One character only +} diff --git a/Marlin/src/lcd/language/language_uk.h b/Marlin/src/lcd/language/language_uk.h index 3c47ccada916..e678cd872e48 100644 --- a/Marlin/src/lcd/language/language_uk.h +++ b/Marlin/src/lcd/language/language_uk.h @@ -213,10 +213,10 @@ namespace Language_uk { LSTR MSG_UBL_MOVING_TO_NEXT = _UxGT("Рух до наступної"); LSTR MSG_UBL_ACTIVATE_MESH = _UxGT("Активувати UBL"); LSTR MSG_UBL_DEACTIVATE_MESH = _UxGT("Деактивувати UBL"); - LSTR MSG_UBL_SET_TEMP_BED = LCD_STR_THERMOMETER _UxGT(" столу, ") LCD_STR_DEGREE "C"; - LSTR MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Своя ") LCD_STR_THERMOMETER _UxGT(" столу,") LCD_STR_DEGREE "C"; - LSTR MSG_UBL_SET_TEMP_HOTEND = LCD_STR_THERMOMETER _UxGT(" сопла, ") LCD_STR_DEGREE "C"; - LSTR MSG_UBL_HOTEND_TEMP_CUSTOM = _UxGT("Своя ") LCD_STR_THERMOMETER _UxGT(" сопла,") LCD_STR_DEGREE "C"; + LSTR MSG_UBL_SET_TEMP_BED = LCD_STR_THERMOMETER _UxGT(" столу, ") LCD_STR_DEGREE _UxGT("C"); + LSTR MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Своя ") LCD_STR_THERMOMETER _UxGT(" столу,") LCD_STR_DEGREE _UxGT("C"); + LSTR MSG_UBL_SET_TEMP_HOTEND = LCD_STR_THERMOMETER _UxGT(" сопла, ") LCD_STR_DEGREE _UxGT("C"); + LSTR MSG_UBL_HOTEND_TEMP_CUSTOM = _UxGT("Своя ") LCD_STR_THERMOMETER _UxGT(" сопла,") LCD_STR_DEGREE _UxGT("C"); #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_EDIT_CUSTOM_MESH = _UxGT("Редагувати свою сітку"); LSTR MSG_UBL_FINE_TUNE_MESH = _UxGT("Точне редагування сітки"); @@ -337,19 +337,19 @@ 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мм"); LSTR MSG_MOVE_100MM = _UxGT("Рух 100mm"); LSTR MSG_SPEED = _UxGT("Швидкість"); LSTR MSG_BED_Z = _UxGT("Z Столу"); - LSTR MSG_NOZZLE = _UxGT("Сопло, ") LCD_STR_DEGREE "C"; + LSTR MSG_NOZZLE = _UxGT("Сопло, ") LCD_STR_DEGREE _UxGT("C"); LSTR MSG_NOZZLE_N = _UxGT("Сопло ~"); LSTR MSG_NOZZLE_PARKED = _UxGT("Сопло запарковане"); LSTR MSG_NOZZLE_STANDBY = _UxGT("Сопло очікує"); - LSTR MSG_BED = _UxGT("Стіл, ") LCD_STR_DEGREE "C"; - LSTR MSG_CHAMBER = _UxGT("Камера,") LCD_STR_DEGREE "C"; + LSTR MSG_BED = _UxGT("Стіл, ") LCD_STR_DEGREE _UxGT("C"); + LSTR MSG_CHAMBER = _UxGT("Камера,") LCD_STR_DEGREE _UxGT("C"); #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_COOLER = _UxGT("Охолодження лазеру"); LSTR MSG_COOLER_TOGGLE = _UxGT("Перемк. охолодж."); @@ -391,7 +391,6 @@ namespace Language_uk { LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Збій автопідбору! Температура завищена."); LSTR MSG_PID_TIMEOUT = _UxGT("Збій автопідбору! Вичерпан час."); - LSTR MSG_SELECT = _UxGT("Вибрати"); LSTR MSG_SELECT_E = _UxGT("Вибрати *"); LSTR MSG_ACC = _UxGT("Прискорорення"); LSTR MSG_JERK = _UxGT("Ривок"); @@ -455,7 +454,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"); @@ -466,7 +465,7 @@ namespace Language_uk { LSTR MSG_INIT_EEPROM = _UxGT("Ініціаліз. EEPROM"); #endif LSTR MSG_ERR_EEPROM_CRC = _UxGT("Збій EEPROM: CRC"); - LSTR MSG_ERR_EEPROM_INDEX = _UxGT("Збій EEPROM: індекс"); + LSTR MSG_ERR_EEPROM_SIZE = _UxGT("Збій EEPROM: розмір"); LSTR MSG_ERR_EEPROM_VERSION = _UxGT("Збій EEPROM: версія"); LSTR MSG_SETTINGS_STORED = _UxGT("Параметри збережені"); LSTR MSG_MEDIA_UPDATE = _UxGT("Оновити SD-картку"); @@ -599,7 +598,7 @@ namespace Language_uk { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("Установити TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("Установити Z-зонд"); LSTR MSG_MANUAL_STOW = _UxGT("Завантажити Z-зонд"); - LSTR MSG_HOME_FIRST = _UxGT("Спочатку дім %s%s%s"); + LSTR MSG_HOME_FIRST = _UxGT("Спочатку дім %s"); LSTR MSG_ZPROBE_OFFSETS = _UxGT("Зміщення зонду"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("Зміщення по X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Зміщення по Y"); @@ -626,9 +625,6 @@ namespace Language_uk { LSTR MSG_ERR_MINTEMP = _UxGT("МІНІМАЛЬНА Т") LCD_STR_DEGREE; LSTR MSG_HALTED = _UxGT("ПРИНТЕР ЗУПИНЕНО"); LSTR MSG_PLEASE_RESET = _UxGT("Перезавантажте"); - LSTR MSG_SHORT_DAY = _UxGT("д"); // One character only - LSTR MSG_SHORT_HOUR = _UxGT("г"); // One character only - LSTR MSG_SHORT_MINUTE = _UxGT("х"); // One character only LSTR MSG_HEATING = _UxGT("Нагрівання..."); LSTR MSG_COOLING = _UxGT("Охолодження..."); LSTR MSG_BED_HEATING = _UxGT("Нагрів столу..."); @@ -652,8 +648,6 @@ namespace Language_uk { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Калібр. центр"); LSTR MSG_DELTA_SETTINGS = _UxGT("Параметри Delta"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Автокалібрування"); - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Встан. Висоту Delta"); - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Z-зміщення зонду"); LSTR MSG_DELTA_DIAG_ROD = _UxGT("Діагональ стрижня"); LSTR MSG_DELTA_HEIGHT = _UxGT("Висота"); LSTR MSG_DELTA_RADIUS = _UxGT("Радіус"); @@ -916,12 +910,8 @@ namespace Language_uk { LSTR MSG_SD_CARD = _UxGT("SD Картка"); LSTR MSG_USB_DISK = _UxGT("USB Диск"); -} -#if FAN_COUNT == 1 - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED -#else - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N -#endif + LSTR MSG_SHORT_DAY = _UxGT("д"); // One character only + LSTR MSG_SHORT_HOUR = _UxGT("г"); // One character only + LSTR MSG_SHORT_MINUTE = _UxGT("х"); // One character only +} diff --git a/Marlin/src/lcd/language/language_vi.h b/Marlin/src/lcd/language/language_vi.h index f963e3e346bc..3b83349207e6 100644 --- a/Marlin/src/lcd/language/language_vi.h +++ b/Marlin/src/lcd/language/language_vi.h @@ -198,6 +198,7 @@ namespace Language_vi { LSTR MSG_MOVE_X = _UxGT("Di chuyển X"); // Move X LSTR MSG_MOVE_Y = _UxGT("Di chuyển Y"); LSTR MSG_MOVE_Z = _UxGT("Di chuyển Z"); + LSTR MSG_MOVE_N = _UxGT("Di chuyển @"); LSTR MSG_MOVE_E = _UxGT("Máy đùn"); // Extruder LSTR MSG_MOVE_EN = _UxGT("Máy đùn *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Đầu nóng quá lạnh"); // Hotend too cold @@ -223,7 +224,6 @@ namespace Language_vi { LSTR MSG_AUTOTEMP = _UxGT("Nhiệt độ tự động"); // Autotemp LSTR MSG_LCD_ON = _UxGT("Bật"); // on LSTR MSG_LCD_OFF = _UxGT("Tắt"); // off - LSTR MSG_SELECT = _UxGT("Lựa"); // Select LSTR MSG_SELECT_E = _UxGT("Lựa *"); LSTR MSG_ACC = _UxGT("Tăng Tốc"); LSTR MSG_JERK = _UxGT("Giật"); @@ -326,7 +326,7 @@ namespace Language_vi { LSTR MSG_BLTOUCH_STOW = _UxGT("Cất BLTouch"); // Stow BLTouch LSTR MSG_MANUAL_DEPLOY = _UxGT("Đem Đầu Dò-Z"); // Deploy Z-Probe LSTR MSG_MANUAL_STOW = _UxGT("Cất Đầu Dò-Z"); // Stow Z-Probe - LSTR MSG_HOME_FIRST = _UxGT("Về nhà %s%s%s Trước"); + LSTR MSG_HOME_FIRST = _UxGT("Về nhà %s Trước"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Đầu Dò Bù Đắp Z"); // Probe Z Offset LSTR MSG_BABYSTEP_X = _UxGT("Nhít X"); // Babystep X LSTR MSG_BABYSTEP_Y = _UxGT("Nhít Y"); @@ -341,9 +341,6 @@ namespace Language_vi { LSTR MSG_ERR_MINTEMP = _UxGT("Điều sai: nhiệt độ tối thiểu"); // Err: MINTEMP LSTR MSG_HALTED = _UxGT("MÁY IN ĐÃ DỪNG LẠI"); // PRINTER HALTED LSTR MSG_PLEASE_RESET = _UxGT("Xin bặt lại"); // Please reset - LSTR MSG_SHORT_DAY = _UxGT("n"); // d - ngày - One character only - LSTR MSG_SHORT_HOUR = _UxGT("g"); // h - giờ - One character only - LSTR MSG_SHORT_MINUTE = _UxGT("p"); // m - phút - One character only LSTR MSG_HEATING = _UxGT("Đang sưởi nóng..."); // heating LSTR MSG_COOLING = _UxGT("Đang làm nguội..."); // cooling LSTR MSG_BED_HEATING = _UxGT("Đang sưởi nong bàn..."); // bed heating @@ -355,8 +352,6 @@ namespace Language_vi { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("Chỉnh Z Center"); // Calibrate Center LSTR MSG_DELTA_SETTINGS = _UxGT("Cài Đặt Delta"); // Delta Settings LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Cân Chỉnh Tự Động"); // Auto Calibration - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Đặt Chiều Cao Delta"); // Set Delta Height - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Đầu Dò Z-Bù Đắp"); // Probe Z-offset LSTR MSG_DELTA_DIAG_ROD = _UxGT("Gậy Chéo"); // Diag Rod LSTR MSG_DELTA_HEIGHT = _UxGT("Chiều Cao"); // Height LSTR MSG_DELTA_RADIUS = _UxGT("Bán Kính"); // Radius @@ -439,4 +434,8 @@ namespace Language_vi { LSTR MSG_TMC_HOMING_THRS = _UxGT("Vô cảm biến"); // Sensorless homing LSTR MSG_TMC_STEPPING_MODE = _UxGT("Chế độ từng bước"); // Stepping mode LSTR MSG_TMC_STEALTH_ENABLED = _UxGT("CắtTàngHình được kích hoạt"); // StealthChop enabled + + LSTR MSG_SHORT_DAY = _UxGT("n"); // d - ngày - One character only + LSTR MSG_SHORT_HOUR = _UxGT("g"); // h - giờ - One character only + LSTR MSG_SHORT_MINUTE = _UxGT("p"); // m - phút - One character only } diff --git a/Marlin/src/lcd/language/language_zh_CN.h b/Marlin/src/lcd/language/language_zh_CN.h index a4816ff899c0..9dbb61e70b07 100644 --- a/Marlin/src/lcd/language/language_zh_CN.h +++ b/Marlin/src/lcd/language/language_zh_CN.h @@ -222,6 +222,7 @@ namespace Language_zh_CN { LSTR MSG_MOVE_X = _UxGT("移动X"); // "Move X" LSTR MSG_MOVE_Y = _UxGT("移动Y"); // "Move Y" LSTR MSG_MOVE_Z = _UxGT("移动Z"); // "Move Z" + LSTR MSG_MOVE_N = _UxGT("移动@"); // "Move @" LSTR MSG_MOVE_E = _UxGT("挤出机"); // "Extruder" LSTR MSG_MOVE_EN = _UxGT("挤出机 *"); // "Extruder" LSTR MSG_HOTEND_TOO_COLD = _UxGT("热端太冷"); @@ -263,7 +264,6 @@ namespace Language_zh_CN { LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("自动调失败! 坏的挤出机"); LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("自动调失败! 温度太高"); LSTR MSG_PID_TIMEOUT = _UxGT("自动调失败! 超时"); - LSTR MSG_SELECT = _UxGT("选择"); // "Select" LSTR MSG_SELECT_E = _UxGT("选择 *"); LSTR MSG_ACC = _UxGT("加速度"); // "Accel" acceleration LSTR MSG_JERK = _UxGT("抖动速率"); // "Jerk" @@ -317,9 +317,9 @@ namespace Language_zh_CN { LSTR MSG_LOAD_EEPROM = _UxGT("装载设置"); // "Load memory" LSTR MSG_RESTORE_DEFAULTS = _UxGT("恢复安全值"); // "Restore Defaults" LSTR MSG_INIT_EEPROM = _UxGT("初始化设置"); // "Initialize EEPROM" - LSTR MSG_ERR_EEPROM_CRC = _UxGT("EEPROM CRC 错误"); - LSTR MSG_ERR_EEPROM_INDEX = _UxGT("EEPROM Index 错误"); - LSTR MSG_ERR_EEPROM_VERSION = _UxGT("EEPROM Version 错误"); + LSTR MSG_ERR_EEPROM_CRC = _UxGT("EEPROM 校验和 错误"); + LSTR MSG_ERR_EEPROM_SIZE = _UxGT("EEPROM 尺寸 错误"); + LSTR MSG_ERR_EEPROM_VERSION = _UxGT("EEPROM 版本 错误"); LSTR MSG_SETTINGS_STORED = _UxGT("设置已保存"); LSTR MSG_MEDIA_UPDATE = _UxGT("存储器更新"); LSTR MSG_RESET_PRINTER = _UxGT("复位打印机"); @@ -419,7 +419,7 @@ namespace Language_zh_CN { LSTR MSG_MANUAL_DEPLOY_TOUCHMI = _UxGT("部署TouchMI"); LSTR MSG_MANUAL_DEPLOY = _UxGT("部署Z探针"); LSTR MSG_MANUAL_STOW = _UxGT("收好Z探针"); - LSTR MSG_HOME_FIRST = _UxGT("归位 %s%s%s 先"); // "Home ... first" + LSTR MSG_HOME_FIRST = _UxGT("归位 %s 先"); // "Home ... first" LSTR MSG_ZPROBE_OFFSETS = _UxGT("探针偏移量"); LSTR MSG_ZPROBE_XOFFSET = _UxGT("探针X偏移"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("探针Y偏移"); @@ -438,9 +438,6 @@ namespace Language_zh_CN { LSTR MSG_ERR_MINTEMP = _UxGT("错误:最低温度"); // "Err: MINTEMP" LSTR MSG_HALTED = _UxGT("打印停机"); // "PRINTER HALTED" LSTR MSG_PLEASE_RESET = _UxGT("请重置"); // "Please reset" - LSTR MSG_SHORT_DAY = _UxGT("天"); // "d" // One character only - LSTR MSG_SHORT_HOUR = _UxGT("时"); // "h" // One character only - LSTR MSG_SHORT_MINUTE = _UxGT("分"); // "m" // One character only LSTR MSG_HEATING = _UxGT("加热中 ..."); // "Heating..." LSTR MSG_COOLING = _UxGT("冷却中 ..."); LSTR MSG_BED_HEATING = _UxGT("加热热床中 ..."); // "Bed Heating..." @@ -454,8 +451,6 @@ namespace Language_zh_CN { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("⊿校准中心"); // "Calibrate Center" LSTR MSG_DELTA_SETTINGS = _UxGT("⊿设置"); // "Delta Settings" LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("⊿自动校准"); // "Auto Calibration" - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("设置⊿高度"); // "Set Delta Height" - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("探针Z偏移量"); LSTR MSG_DELTA_DIAG_ROD = _UxGT("⊿斜柱"); // "Diag Rod" LSTR MSG_DELTA_HEIGHT = _UxGT("⊿高度"); // "Height" LSTR MSG_DELTA_RADIUS = _UxGT("⊿半径"); // "Radius" @@ -610,12 +605,8 @@ namespace Language_zh_CN { LSTR MSG_HEATER_TIMEOUT = _UxGT("加热器超时"); LSTR MSG_REHEAT = _UxGT("重新加热"); LSTR MSG_REHEATING = _UxGT("重新加热中..."); -} -#if FAN_COUNT == 1 - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED -#else - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N -#endif + LSTR MSG_SHORT_DAY = _UxGT("天"); // "d" // One character only + LSTR MSG_SHORT_HOUR = _UxGT("时"); // "h" // One character only + LSTR MSG_SHORT_MINUTE = _UxGT("分"); // "m" // One character only +} diff --git a/Marlin/src/lcd/language/language_zh_TW.h b/Marlin/src/lcd/language/language_zh_TW.h index 5f7c85c8383d..49e57d6220fd 100644 --- a/Marlin/src/lcd/language/language_zh_TW.h +++ b/Marlin/src/lcd/language/language_zh_TW.h @@ -218,6 +218,7 @@ namespace Language_zh_TW { LSTR MSG_MOVE_X = _UxGT("移動X"); // "Move X" LSTR MSG_MOVE_Y = _UxGT("移動Y"); // "Move Y" LSTR MSG_MOVE_Z = _UxGT("移動Z"); // "Move Z" + LSTR MSG_MOVE_N = _UxGT("移動Q"); // "Move @" LSTR MSG_MOVE_E = _UxGT("擠出機"); // "Extruder" LSTR MSG_MOVE_EN = _UxGT("擠出機 *"); // "Extruder *" LSTR MSG_HOTEND_TOO_COLD = _UxGT("噴嘴溫度不夠"); // "Hotend too cold" @@ -225,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" @@ -247,7 +249,6 @@ namespace Language_zh_TW { LSTR MSG_LCD_ON = _UxGT("開 "); // "On" LSTR MSG_LCD_OFF = _UxGT("關 "); // "Off" - LSTR MSG_SELECT = _UxGT("選擇"); // "Select" LSTR MSG_SELECT_E = _UxGT("選擇 *"); LSTR MSG_ACC = _UxGT("加速度"); // "Accel" acceleration LSTR MSG_JERK = _UxGT("抖動速率"); // "Jerk" @@ -298,8 +299,8 @@ namespace Language_zh_TW { LSTR MSG_RESTORE_DEFAULTS = _UxGT("恢復安全值"); // "Restore failsafe" LSTR MSG_INIT_EEPROM = _UxGT("初始化設置"); // "Initialize EEPROM" LSTR MSG_ERR_EEPROM_CRC = _UxGT("錯誤: EEPROM CRC"); // "Err: EEPROM CRC" - LSTR MSG_ERR_EEPROM_INDEX = _UxGT("錯誤: EEPROM Index"); // "Err: EEPROM Index" - LSTR MSG_ERR_EEPROM_VERSION = _UxGT("錯誤: EEPROM Version"); // "EEPROM Version" + LSTR MSG_ERR_EEPROM_SIZE = _UxGT("錯誤: EEPROM 尺寸"); // "Err: EEPROM Index" + LSTR MSG_ERR_EEPROM_VERSION = _UxGT("錯誤: EEPROM 版本"); // "EEPROM Version" LSTR MSG_MEDIA_UPDATE = _UxGT("媒體更新"); // "Media Update" LSTR MSG_RESET_PRINTER = _UxGT("重置打印機"); // "Reset Printer LSTR MSG_REFRESH = _UxGT("刷新"); // "Refresh" @@ -368,7 +369,7 @@ namespace Language_zh_TW { LSTR MSG_BLTOUCH_STOW = _UxGT("裝載BLTouch"); // "Stow BLTouch" LSTR MSG_BLTOUCH_DEPLOY = _UxGT("部署BLTouch"); // "Deploy BLTouch" - LSTR MSG_HOME_FIRST = _UxGT("歸位 %s%s%s 先"); // "Home ... first" + LSTR MSG_HOME_FIRST = _UxGT("歸位 %s 先"); // "Home ... first" LSTR MSG_ZPROBE_OFFSETS = _UxGT("探針偏移"); //Probe Offsets LSTR MSG_ZPROBE_XOFFSET = _UxGT("探針X偏移量"); //Probe X Offset LSTR MSG_ZPROBE_YOFFSET = _UxGT("探針Y偏移量"); //Probe Y Offset @@ -387,9 +388,6 @@ namespace Language_zh_TW { LSTR MSG_ERR_MINTEMP = _UxGT("錯誤:最低溫度"); // "Err: MINTEMP" LSTR MSG_HALTED = _UxGT("印表機停機"); // "PRINTER HALTED" LSTR MSG_PLEASE_RESET = _UxGT("請重置"); // "Please reset" - LSTR MSG_SHORT_DAY = _UxGT("天"); // "d" // One character only - LSTR MSG_SHORT_HOUR = _UxGT("時"); // "h" // One character only - LSTR MSG_SHORT_MINUTE = _UxGT("分"); // "m" // One character only LSTR MSG_HEATING = _UxGT("加熱中 ..."); // "Heating..." LSTR MSG_COOLING = _UxGT("冷卻中 ..."); // "Cooling..." LSTR MSG_BED_HEATING = _UxGT("加熱熱床中 ..."); // "Bed Heating..." @@ -403,8 +401,6 @@ namespace Language_zh_TW { LSTR MSG_DELTA_CALIBRATE_CENTER = _UxGT("⊿校準中心"); // "Calibrate Center" LSTR MSG_DELTA_SETTINGS = _UxGT("⊿設置"); // "Delta Settings" LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("⊿自動校準"); // "Auto Calibration" - LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("設置⊿高度"); // "Set Delta Height" - LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Z偏移"); LSTR MSG_DELTA_DIAG_ROD = _UxGT("⊿斜柱"); // "Diag Rod" LSTR MSG_DELTA_HEIGHT = _UxGT("⊿高度"); // "Height" LSTR MSG_DELTA_RADIUS = _UxGT("⊿半徑"); // "Radius" @@ -491,12 +487,8 @@ namespace Language_zh_TW { LSTR MSG_FILAMENT_CHANGE_CONT_PURGE = _UxGT(MSG_1_LINE("按下完成..")); // "Click to finish" LSTR MSG_FILAMENT_CHANGE_RESUME = _UxGT(MSG_1_LINE("恢復中 ...")); // "Resuming..." #endif // LCD_HEIGHT < 4 -} -#if FAN_COUNT == 1 - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED -#else - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N -#endif + LSTR MSG_SHORT_DAY = _UxGT("天"); // "d" // One character only + LSTR MSG_SHORT_HOUR = _UxGT("時"); // "h" // One character only + LSTR MSG_SHORT_MINUTE = _UxGT("分"); // "m" // One character only +} diff --git a/Marlin/src/lcd/lcdprint.cpp b/Marlin/src/lcd/lcdprint.cpp index deec2b1778b8..650824e553bc 100644 --- a/Marlin/src/lcd/lcdprint.cpp +++ b/Marlin/src/lcd/lcdprint.cpp @@ -47,19 +47,19 @@ lcd_uint_t lcd_put_u8str_P(PGM_P const ptpl, const int8_t ind, const char *cstr/ const uint8_t *p = (uint8_t*)ptpl; int8_t n = maxlen; while (n > 0) { - wchar_t ch; - p = get_utf8_value_cb(p, read_byte_rom, &ch); - if (!ch) break; - if (ch == '=' || ch == '~' || ch == '*') { + lchar_t wc; + p = get_utf8_value_cb(p, read_byte_rom, wc); + if (!wc) break; + if (wc == '=' || wc == '~' || wc == '*') { if (ind >= 0) { - if (ch == '*') { lcd_put_wchar('E'); n--; } + if (wc == '*') { lcd_put_u8str(F("E")); n--; } if (n) { - int8_t inum = ind + ((ch == '=') ? 0 : LCD_FIRST_TOOL); + int8_t inum = ind + ((wc == '=') ? 0 : LCD_FIRST_TOOL); if (inum >= 10) { - lcd_put_wchar('0' + (inum / 10)); n--; + lcd_put_lchar('0' + (inum / 10)); n--; inum %= 10; } - if (n) { lcd_put_wchar('0' + inum); n--; } + if (n) { lcd_put_lchar('0' + inum); n--; } } } else { @@ -71,19 +71,19 @@ lcd_uint_t lcd_put_u8str_P(PGM_P const ptpl, const int8_t ind, const char *cstr/ break; } } - else if (ch == '$' && fstr) { + else if (wc == '$' && fstr) { n -= lcd_put_u8str_max_P(FTOP(fstr), n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH); } - else if (ch == '$' && cstr) { + else if (wc == '$' && cstr) { n -= lcd_put_u8str_max(cstr, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH); } - else if (ch == '@') { - lcd_put_wchar(AXIS_CHAR(ind)); + else if (wc == '@') { + lcd_put_lchar(AXIS_CHAR(ind)); n--; } else { - lcd_put_wchar(ch); - n -= ch > 255 ? prop : 1; + lcd_put_lchar(wc); + n -= wc > 255 ? prop : 1; } } return n; @@ -97,10 +97,10 @@ int calculateWidth(PGM_P const pstr) { int n = 0; do { - wchar_t ch; - p = get_utf8_value_cb(p, read_byte_rom, &ch); - if (!ch) break; - n += (ch > 255) ? prop : 1; + lchar_t wc; + p = get_utf8_value_cb(p, read_byte_rom, wc); + if (!wc) break; + n += (wc > 255) ? prop : 1; } while (1); return n * MENU_FONT_WIDTH; diff --git a/Marlin/src/lcd/lcdprint.h b/Marlin/src/lcd/lcdprint.h index 2eb47c534b05..bcf85cb69396 100644 --- a/Marlin/src/lcd/lcdprint.h +++ b/Marlin/src/lcd/lcdprint.h @@ -138,7 +138,7 @@ int lcd_glyph_height(); * * @return the output width (in pixels on GLCD) */ -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length); +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length); /** * @brief Draw a SRAM UTF-8 string @@ -267,17 +267,17 @@ inline int lcd_put_u8str(const lcd_uint_t col, const lcd_uint_t row, const char /** * @brief Draw a UTF-8 character with no width limit * - * @param c The wchar to draw + * @param c The lchar to draw * @return the output width (in pixels on GLCD) */ -inline int lcd_put_wchar(const wchar_t c) { return lcd_put_wchar_max(c, PIXEL_LEN_NOLIMIT); } +inline int lcd_put_lchar(const lchar_t &c) { return lcd_put_lchar_max(c, PIXEL_LEN_NOLIMIT); } /** * @param col * @param row */ -inline int lcd_put_wchar(const lcd_uint_t col, const lcd_uint_t row, const wchar_t c) { +inline int lcd_put_lchar(const lcd_uint_t col, const lcd_uint_t row, const lchar_t &c) { lcd_moveto(col, row); - return lcd_put_wchar(c); + return lcd_put_lchar(c); } /** diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 3976c48dc76b..604e9bb0ca7a 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 @@ -121,17 +126,9 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; bool MarlinUI::sound_on = ENABLED(SOUND_ON_DEFAULT); #endif -#if EITHER(PCA9632_BUZZER, HAS_BEEPER) - #if ENABLED(PCA9632_BUZZER) - #include "../feature/leds/pca9632.h" - #endif - void MarlinUI::buzz(const long duration, const uint16_t freq) { - if (!sound_on) return; - #if ENABLED(PCA9632_BUZZER) - PCA9632_buzz(duration, freq); - #elif HAS_BEEPER - buzzer.tone(duration, freq); - #endif +#if ENABLED(PCA9632_BUZZER) + void MarlinUI::buzz(const long duration, const uint16_t freq/*=0*/) { + if (sound_on) PCA9632_buzz(duration, freq); } #endif @@ -152,7 +149,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; const preheat_t &pre = material_preset[m]; TERN_(HAS_HOTEND, if (TEST(pmask, PT_HOTEND)) thermalManager.setTargetHotend(pre.hotend_temp, e)); TERN_(HAS_HEATED_BED, if (TEST(pmask, PT_BED)) thermalManager.setTargetBed(pre.bed_temp)); - //TERN_(HAS_HEATED_CHAMBER, if (TEST(pmask, PT_CHAMBER)) thermalManager.setTargetBed(pre.chamber_temp)); + //TERN_(HAS_HEATED_CHAMBER, if (TEST(pmask, PT_CHAMBER)) thermalManager.setTargetChamber(pre.chamber_temp)); TERN_(HAS_FAN, if (TEST(pmask, PT_FAN)) thermalManager.set_fan_speed(0, pre.fan_speed)); } #endif @@ -161,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; @@ -176,30 +173,42 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif +#if HAS_U8GLIB_I2C_OLED && PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM) + #include +#endif + // Encoder Handling #if HAS_ENCODER_ACTION uint32_t MarlinUI::encoderPosition; volatile int8_t encoderDiff; // Updated in update_buttons, added to encoderPosition every LCD update #endif -#if LCD_BACKLIGHT_TIMEOUT +#if LCD_BACKLIGHT_TIMEOUT_MINS + + constexpr uint8_t MarlinUI::backlight_timeout_min, MarlinUI::backlight_timeout_max; - uint16_t MarlinUI::lcd_backlight_timeout; // Initialized by settings.load() + 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); } + #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() { @@ -225,14 +234,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 @@ -260,6 +269,10 @@ void MarlinUI::init() { slow_buttons = 0; #endif + #if HAS_U8GLIB_I2C_OLED && PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM) + Wire.begin(int(I2C_SDA_PIN), int(I2C_SCL_PIN)); + #endif + update_buttons(); TERN_(HAS_ENCODER_ACTION, encoderDiff = 0); @@ -314,7 +327,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 @@ -333,7 +346,6 @@ void MarlinUI::init() { #if IS_DWIN_MARLINUI bool MarlinUI::did_first_redraw; - bool MarlinUI::old_is_printing; #endif #if ENABLED(SDSUPPORT) @@ -417,26 +429,26 @@ void MarlinUI::init() { }; const uint8_t *p = (uint8_t*)string; - wchar_t ch; + lchar_t wc; if (wordwrap) { const uint8_t *wrd = nullptr; uint8_t c = 0; // find the end of the part for (;;) { if (!wrd) wrd = p; // Get word start /before/ advancing - p = get_utf8_value_cb(p, cb_read_byte, &ch); - const bool eol = !ch; // zero ends the string + p = get_utf8_value_cb(p, cb_read_byte, wc); + const bool eol = !wc; // zero ends the string // End or a break between phrases? - if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') { - if (!c && ch == ' ') { if (wrd) wrd++; continue; } // collapse extra spaces + if (eol || wc == ' ' || wc == '-' || wc == '+' || wc == '.') { + if (!c && wc == ' ') { if (wrd) wrd++; continue; } // collapse extra spaces // Past the right and the word is not too long? if (col + c > LCD_WIDTH && col >= (LCD_WIDTH) / 4) _newline(); // should it wrap? c += !eol; // +1 so the space will be printed col += c; // advance col to new position while (c) { // character countdown --c; // count down to zero - wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again - lcd_put_wchar(ch); // character to the LCD + wrd = get_utf8_value_cb(wrd, cb_read_byte, wc); // get characters again + lcd_put_lchar(wc); // character to the LCD } if (eol) break; // all done! wrd = nullptr; // set up for next word @@ -446,9 +458,9 @@ void MarlinUI::init() { } else { for (;;) { - p = get_utf8_value_cb(p, cb_read_byte, &ch); - if (!ch) break; - lcd_put_wchar(ch); + p = get_utf8_value_cb(p, cb_read_byte, wc); + if (!wc) break; + lcd_put_lchar(wc); col++; if (col >= LCD_WIDTH) _newline(); } @@ -489,13 +501,10 @@ void MarlinUI::init() { ui.manual_move.menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP; ui.encoderPosition = dir; switch (axis) { - case X_AXIS: { void lcd_move_x(); lcd_move_x(); } break; - #if HAS_Y_AXIS - case Y_AXIS: { void lcd_move_y(); lcd_move_y(); } break; - #endif - #if HAS_Z_AXIS - case Z_AXIS: { void lcd_move_z(); lcd_move_z(); } break; - #endif + case X_AXIS: + TERN_(HAS_Y_AXIS, case Y_AXIS:) + TERN_(HAS_Z_AXIS, case Z_AXIS:) + lcd_move_axis(axis); default: break; } } @@ -657,7 +666,7 @@ void MarlinUI::init() { #if HAS_MARLINUI_MENU if (use_click()) { #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) - next_filament_display = millis() + 5000UL; // Show status message for 5s + pause_filament_display(); #endif goto_screen(menu_main); reinit_lcd(); // Revive a noisy shared SPI LCD @@ -688,7 +697,7 @@ void MarlinUI::init() { if (old_frm != new_frm) { feedrate_percentage = new_frm; encoderPosition = 0; - #if BOTH(HAS_BUZZER, BEEP_ON_FEEDRATE_CHANGE) + #if BOTH(HAS_SOUND, BEEP_ON_FEEDRATE_CHANGE) static millis_t next_beep; #ifndef GOT_MS const millis_t ms = millis(); @@ -732,6 +741,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*/) { @@ -746,11 +760,12 @@ void MarlinUI::init() { UNUSED(clear_buttons); #endif - #if HAS_CHIRP - chirp(); // Buzz and wait. Is the delay needed for buttons to settle? - #if BOTH(HAS_MARLINUI_MENU, HAS_BEEPER) + chirp(); // Buzz and wait. Is the delay needed for buttons to settle? + + #if HAS_CHIRP && HAS_MARLINUI_MENU + #if HAS_BEEPER for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); } - #elif HAS_MARLINUI_MENU + #else delay(10); #endif #endif @@ -766,6 +781,7 @@ void MarlinUI::init() { millis_t ManualMove::start_time = 0; float ManualMove::menu_scale = 1; + screenFunc_t ManualMove::screen_ptr; #if IS_KINEMATIC float ManualMove::offset = 0; xyze_pos_t ManualMove::all_axes_destination = { 0 }; @@ -775,6 +791,9 @@ void MarlinUI::init() { int8_t ManualMove::e_index = 0; #endif AxisEnum ManualMove::axis = NO_AXIS_ENUM; + #if ENABLED(MANUAL_E_MOVES_RELATIVE) + float ManualMove::e_origin = 0; + #endif /** * If a manual move has been posted and its time has arrived, and if the planner @@ -791,9 +810,6 @@ void MarlinUI::init() { * For kinematic machines: * - Set manual_move.offset to modify one axis and post the move. * This is used to achieve more rapid stepping on kinematic machines. - * - * Currently used by the _lcd_move_xyz function in menu_motion.cpp - * and the ubl_map_move_to_xy function in menu_ubl.cpp. */ void ManualMove::task() { @@ -816,7 +832,7 @@ void MarlinUI::init() { // Apply a linear offset to a single axis if (axis == ALL_AXES_ENUM) destination = all_axes_destination; - else if (axis <= XYZE) { + else if (axis <= LOGICAL_AXES) { destination = current_position; destination[axis] += offset; } @@ -864,7 +880,7 @@ void MarlinUI::init() { void MarlinUI::external_encoder() { if (external_control && encoderDiff) { - bedlevel.encoder_diff += encoderDiff; // Encoder for UBL G29 mesh editing + bedlevel.encoder_diff += encoderDiff; // Encoder for UBL G29 mesh editing encoderDiff = 0; // Hide encoder events from the screen handler refresh(LCDVIEW_REDRAW_NOW); // ...but keep the refresh. } @@ -1068,7 +1084,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(); @@ -1170,7 +1186,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); @@ -1178,14 +1194,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 @@ -1302,7 +1318,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; @@ -1310,20 +1326,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) @@ -1381,10 +1397,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(); @@ -1397,6 +1413,13 @@ void MarlinUI::init() { #endif // HAS_ENCODER_ACTION + #if HAS_SOUND + void MarlinUI::completion_feedback(const bool good/*=true*/) { + TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); // Wake up on rotary encoder click... + if (good) OKAY_BUZZ(); else ERR_BUZZ(); + } + #endif + #endif // HAS_WIRED_LCD #if HAS_STATUS_MESSAGE @@ -1565,7 +1588,7 @@ void MarlinUI::init() { #endif #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) - next_filament_display = ms + 5000UL; // Show status message for 5s + pause_filament_display(ms); // Show status message for 5s #endif #endif @@ -1629,10 +1652,11 @@ 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()); + TERN_(DWIN_LCD_PROUI, HMI_flag.abort_flag = true); } #if BOTH(HAS_MARLINUI_MENU, PSU_CONTROL) @@ -1681,19 +1705,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 // @@ -1727,6 +1738,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 && DISABLED(HAS_GRAPHICAL_TFT) + 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) @@ -1856,18 +1899,22 @@ void MarlinUI::init() { #if DISABLED(EEPROM_AUTO_INIT) - static inline FSTR_P eeprom_err(const uint8_t msgid) { - switch (msgid) { - default: - case 0: return GET_TEXT_F(MSG_ERR_EEPROM_CRC); - case 1: return GET_TEXT_F(MSG_ERR_EEPROM_INDEX); - case 2: return GET_TEXT_F(MSG_ERR_EEPROM_VERSION); + static inline FSTR_P eeprom_err(const EEPROM_Error err) { + switch (err) { + case ERR_EEPROM_VERSION: return GET_TEXT_F(MSG_ERR_EEPROM_VERSION); + case ERR_EEPROM_SIZE: return GET_TEXT_F(MSG_ERR_EEPROM_SIZE); + case ERR_EEPROM_CRC: return GET_TEXT_F(MSG_ERR_EEPROM_CRC); + case ERR_EEPROM_CORRUPT: return GET_TEXT_F(MSG_ERR_EEPROM_CORRUPT); + default: return nullptr; } } - void MarlinUI::eeprom_alert(const uint8_t msgid) { + void MarlinUI::eeprom_alert(const EEPROM_Error err) { + FSTR_P const err_msg = eeprom_err(err); + set_status(err_msg); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(err_msg)); #if HAS_MARLINUI_MENU - editable.uint8 = msgid; + editable.uint8 = err; goto_screen([]{ FSTR_P const restore_msg = GET_TEXT_F(MSG_INIT_EEPROM); char msg[utf8_strlen(restore_msg) + 1]; @@ -1875,11 +1922,9 @@ void MarlinUI::init() { MenuItem_confirm::select_screen( GET_TEXT_F(MSG_BUTTON_RESET), GET_TEXT_F(MSG_BUTTON_IGNORE), init_eeprom, return_to_status, - eeprom_err(editable.uint8), msg, F("?") + eeprom_err((EEPROM_Error)editable.uint8), msg, F("?") ); }); - #else - set_status(eeprom_err(msgid)); #endif } diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 66e5e0c26181..e33eda05911c 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -25,22 +25,21 @@ #include "../sd/cardreader.h" #include "../module/motion.h" #include "../libs/buzzer.h" - #include "buttons.h" -#if ENABLED(TOUCH_SCREEN_CALIBRATION) - #include "tft_io/touch_calibration.h" +#if ENABLED(EEPROM_SETTINGS) + #include "../module/settings.h" #endif -#if ANY(HAS_MARLINUI_MENU, ULTIPANEL_FEEDMULTIPLY, SOFT_RESET_ON_KILL) - #define HAS_ENCODER_ACTION 1 +#if ENABLED(TOUCH_SCREEN_CALIBRATION) + #include "tft_io/touch_calibration.h" #endif #if E_MANUAL > 1 #define MULTI_E_MANUAL 1 #endif -#if HAS_DISPLAY +#if HAS_PRINT_PROGRESS #include "../module/printcounter.h" #endif @@ -90,6 +89,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 @@ -137,12 +137,16 @@ typedef bool (*statusResetFunc_t)(); static xyze_pos_t all_axes_destination; #endif public: + static screenFunc_t screen_ptr; static float menu_scale; #if IS_KINEMATIC static float offset; #endif + #if ENABLED(MANUAL_E_MOVES_RELATIVE) + static float e_origin; + #endif template - void set_destination(const T& dest) { + static void set_destination(const T& dest) { #if IS_KINEMATIC // Moves are segmented, so the entire move is not submitted at once. // Using a separate variable prevents corrupting the in-progress move. @@ -153,10 +157,10 @@ typedef bool (*statusResetFunc_t)(); current_position.set(dest); #endif } - float axis_value(const AxisEnum axis) { + static float axis_value(const AxisEnum axis) { return NATIVE_TO_LOGICAL(processing ? destination[axis] : SUM_TERN(IS_KINEMATIC, current_position[axis], offset), axis); } - bool apply_diff(const AxisEnum axis, const_float_t diff, const_float_t min, const_float_t max) { + static bool apply_diff(const AxisEnum axis, const_float_t diff, const_float_t min, const_float_t max) { #if IS_KINEMATIC float &valref = offset; const float rmin = min - current_position[axis], rmax = max - current_position[axis]; @@ -166,12 +170,7 @@ typedef bool (*statusResetFunc_t)(); #endif valref += diff; const float pre = valref; - if (min != max) { - if (diff < 0) - NOLESS(valref, rmin); - else - NOMORE(valref, rmax); - } + if (min != max) { if (diff < 0) NOLESS(valref, rmin); else NOMORE(valref, rmax); } return pre != valref; } #if IS_KINEMATIC @@ -183,6 +182,8 @@ typedef bool (*statusResetFunc_t)(); static void soon(const AxisEnum axis OPTARG(MULTI_E_MANUAL, const int8_t eindex=active_extruder)); }; + void lcd_move_axis(const AxisEnum); + #endif //////////////////////////////////////////// @@ -230,12 +231,12 @@ class MarlinUI { static constexpr bool sound_on = true; #endif - #if HAS_BUZZER - static void buzz(const long duration, const uint16_t freq); + #if USE_MARLINUI_BUZZER + static void buzz(const long duration, const uint16_t freq=0); #endif - FORCE_INLINE static void chirp() { - TERN_(HAS_CHIRP, TERN(HAS_BUZZER, buzz, BUZZ)(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ)); + static void chirp() { + TERN_(HAS_CHIRP, TERN(USE_MARLINUI_BUZZER, buzz, BUZZ)(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ)); } #if ENABLED(LCD_HAS_STATUS_INDICATORS) @@ -273,20 +274,19 @@ class MarlinUI { FORCE_INLINE static void refresh_brightness() { set_brightness(brightness); } #endif - #if LCD_BACKLIGHT_TIMEOUT - #define LCD_BKL_TIMEOUT_MIN 1 - #define LCD_BKL_TIMEOUT_MAX (60*60*18) // 18 hours max within uint16_t - 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 @@ -307,19 +307,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(); } @@ -327,12 +327,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 @@ -394,7 +414,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 @@ -451,6 +471,7 @@ class MarlinUI { #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) static millis_t next_filament_display; + static void pause_filament_display(const millis_t ms=millis()) { next_filament_display = ms + 5000UL; } #endif #if HAS_TOUCH_SLEEP @@ -458,7 +479,7 @@ class MarlinUI { #endif static void quick_feedback(const bool clear_buttons=true); - #if HAS_BUZZER + #if HAS_SOUND static void completion_feedback(const bool good=true); #else static void completion_feedback(const bool=true) { TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); } @@ -485,7 +506,6 @@ class MarlinUI { #if IS_DWIN_MARLINUI static bool did_first_redraw; - static bool old_is_printing; #endif #if EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY) @@ -502,11 +522,15 @@ class MarlinUI { #else // No LCD static void update() {} - static void return_to_status() {} static void kill_screen(FSTR_P const, FSTR_P const) {} #endif + #if !HAS_WIRED_LCD + static void quick_feedback(const bool=true) {} + static void completion_feedback(const bool=true) {} + #endif + #if ENABLED(SDSUPPORT) #if BOTH(SCROLL_LONG_FILENAMES, HAS_MARLINUI_MENU) #define MARLINUI_SCROLL_NAME 1 @@ -530,7 +554,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 @@ -553,6 +577,7 @@ class MarlinUI { // Manual Movement static ManualMove manual_move; + static bool can_show_slider() { return !external_control && currentScreen != manual_move.screen_ptr; } // Select Screen (modal NO/YES style dialog) static bool selection; @@ -580,11 +605,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() { @@ -609,6 +634,8 @@ class MarlinUI { #else + static void return_to_status() {} + static constexpr bool on_status_screen() { return true; } #if HAS_WIRED_LCD @@ -649,12 +676,7 @@ class MarlinUI { static void load_settings(); static void store_settings(); #endif - #if DISABLED(EEPROM_AUTO_INIT) - static void eeprom_alert(const uint8_t msgid); - static void eeprom_alert_crc() { eeprom_alert(0); } - static void eeprom_alert_index() { eeprom_alert(1); } - static void eeprom_alert_version() { eeprom_alert(2); } - #endif + static void eeprom_alert(const EEPROM_Error) TERN_(EEPROM_AUTO_INIT, {}); #endif // @@ -695,11 +717,7 @@ class MarlinUI { static void update_buttons(); - #if HAS_ENCODER_NOISE - #ifndef ENCODER_SAMPLES - #define ENCODER_SAMPLES 10 - #endif - + #if ENABLED(ENCODER_NOISE_FILTER) /** * Some printers may have issues with EMI noise especially using a motherboard with 3.3V logic levels * it may cause the logical LOW to float into the undefined region and register as a logical HIGH @@ -764,7 +782,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 @@ -788,5 +806,7 @@ class MarlinUI { #define LCD_MESSAGE_F(S) ui.set_status(F(S)) #define LCD_MESSAGE(M) ui.set_status(GET_TEXT_F(M)) +#define LCD_MESSAGE_MIN(M) ui.set_status(GET_TEXT_F(M), -1) +#define LCD_MESSAGE_MAX(M) ui.set_status(GET_TEXT_F(M), 99) #define LCD_ALERTMESSAGE_F(S) ui.set_alert_status(F(S)) #define LCD_ALERTMESSAGE(M) ui.set_alert_status(GET_TEXT_F(M)) diff --git a/Marlin/src/lcd/menu/game/brickout.cpp b/Marlin/src/lcd/menu/game/brickout.cpp index d738250b60a8..fc4d19b1d98d 100644 --- a/Marlin/src/lcd/menu/game/brickout.cpp +++ b/Marlin/src/lcd/menu/game/brickout.cpp @@ -117,13 +117,11 @@ void BrickoutGame::game_screen() { } else if (diff <= 3) { bdat.ballh += fixed_t(random(-64, 0)); - NOLESS(bdat.ballh, BTOF(-2)); - NOMORE(bdat.ballh, BTOF(2)); + LIMIT(bdat.ballh, BTOF(-2), BTOF(2)); } else if (diff >= PADDLE_W-1 - 3) { bdat.ballh += fixed_t(random( 0, 64)); - NOLESS(bdat.ballh, BTOF(-2)); - NOMORE(bdat.ballh, BTOF(2)); + LIMIT(bdat.ballh, BTOF(-2), BTOF(2)); } // Paddle hit after clearing the board? Reset the board. diff --git a/Marlin/src/lcd/menu/game/game.h b/Marlin/src/lcd/menu/game/game.h index 999aa781008d..ba123cb98bfe 100644 --- a/Marlin/src/lcd/menu/game/game.h +++ b/Marlin/src/lcd/menu/game/game.h @@ -28,7 +28,7 @@ //#define MUTE_GAMES -#if ENABLED(MUTE_GAMES) || !HAS_BUZZER +#if ENABLED(MUTE_GAMES) || !HAS_SOUND #define _BUZZ(D,F) NOOP #else #define _BUZZ(D,F) BUZZ(D,F) diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index a1e2beaf72d0..21546b0c8b8c 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -31,7 +31,7 @@ #include "../../module/temperature.h" #include "../../gcode/queue.h" -#if HAS_BUZZER +#if HAS_SOUND #include "../../libs/buzzer.h" #endif @@ -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(); @@ -117,8 +117,7 @@ void MenuEditItemBase::edit_screen(strfunc_t strfunc, loadfunc_t loadfunc) { // Reset repeat_delay for Touch Buttons TERN_(HAS_TOUCH_BUTTONS, ui.repeat_delay = BUTTON_DELAY_EDIT); // Constrain ui.encoderPosition to 0 ... maxEditValue (calculated in encoder steps) - if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = 0; - if (int32_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue; + ui.encoderPosition = constrain(int32_t(ui.encoderPosition), 0, maxEditValue); // If drawing is flagged then redraw the (whole) edit screen if (ui.should_draw()) draw_edit_screen(strfunc(ui.encoderPosition + minEditValue)); @@ -175,7 +174,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; @@ -191,7 +190,7 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co else { #if ENABLED(MOVE_Z_WHEN_IDLE) ui.manual_move.menu_scale = MOVE_Z_IDLE_MULTIPLICATOR; - screen = lcd_move_z; + screen = []{ lcd_move_axis(Z_AXIS); }; #endif } } @@ -272,13 +271,6 @@ void scroll_screen(const uint8_t limit, const bool is_menu) { encoderTopLine = encoderLine; } -#if HAS_BUZZER - void MarlinUI::completion_feedback(const bool good/*=true*/) { - TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); // Wake up on rotary encoder click... - if (good) OKAY_BUZZ(); else ERR_BUZZ(); - } -#endif - #if HAS_LINE_TO_Z void line_to_z(const_float_t z) { diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index b65214f7b572..befffe5f72d2 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -214,7 +214,6 @@ void menu_move(); //////// Menu Item Helper Functions //////// //////////////////////////////////////////// -void lcd_move_z(); void _lcd_draw_homing(); #define HAS_LINE_TO_Z ANY(DELTA, PROBE_MANUALLY, MESH_BED_LEVELING, LCD_BED_TRAMMING) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index a6ebb104076d..f56b4f899731 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); @@ -109,9 +108,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 @@ -209,37 +208,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_Kp(raw_Kp); break; + #endif + #if ENABLED(PIDTEMPCHAMBER) + case H_CHAMBER: thermalManager.temp_chamber.pid.set_Kp(raw_Kp); 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 +312,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 +331,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 +345,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) @@ -451,7 +476,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 = @@ -483,7 +510,7 @@ void menu_backlash(); // M204 T Travel Acceleration EDIT_ITEM_FAST(float5_25, MSG_A_TRAVEL, &planner.settings.travel_acceleration, 25, max_accel); - #define EDIT_AMAX(Q,L) EDIT_ITEM_FAST(long5_25, MSG_AMAX_##Q, &planner.settings.max_acceleration_mm_per_s2[_AXIS(Q)], L, max_accel_edit_scaled[_AXIS(Q)], []{ planner.reset_acceleration_rates(); }) + #define EDIT_AMAX(Q,L) EDIT_ITEM_FAST_N(long5_25, _AXIS(Q), MSG_AMAX_N, &planner.settings.max_acceleration_mm_per_s2[_AXIS(Q)], L, max_accel_edit_scaled[_AXIS(Q)], []{ planner.refresh_acceleration_rates(); }) NUM_AXIS_CODE( EDIT_AMAX(A, 100), EDIT_AMAX(B, 100), EDIT_AMAX(C, 10), EDIT_AMAX(I, 10), EDIT_AMAX(J, 10), EDIT_AMAX(K, 10), @@ -491,14 +518,14 @@ void menu_backlash(); ); #if ENABLED(DISTINCT_E_FACTORS) - EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(active_extruder)], 100, max_accel_edit_scaled.e, []{ planner.reset_acceleration_rates(); }); + EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(active_extruder)], 100, max_accel_edit_scaled.e, []{ planner.refresh_acceleration_rates(); }); LOOP_L_N(n, E_STEPPERS) EDIT_ITEM_FAST_N(long5_25, n, MSG_AMAX_EN, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(n)], 100, max_accel_edit_scaled.e, []{ if (MenuItemBase::itemIndex == active_extruder) - planner.reset_acceleration_rates(); + planner.refresh_acceleration_rates(); }); #elif E_STEPPERS - EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS], 100, max_accel_edit_scaled.e, []{ planner.reset_acceleration_rates(); }); + EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS], 100, max_accel_edit_scaled.e, []{ planner.refresh_acceleration_rates(); }); #endif #ifdef XY_FREQUENCY_LIMIT @@ -510,6 +537,43 @@ 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 and D Damping ratio + #if ENABLED(INPUT_SHAPING_X) + editable.decimal = stepper.get_shaping_frequency(X_AXIS); + 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 ENABLED(INPUT_SHAPING_Y) + editable.decimal = stepper.get_shaping_frequency(Y_AXIS); + 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(); + } + + #endif + #if HAS_CLASSIC_JERK void menu_advanced_jerk() { @@ -576,11 +640,11 @@ void menu_advanced_steps_per_mm() { BACK_ITEM(MSG_ADVANCED_SETTINGS); LOOP_NUM_AXES(a) - EDIT_ITEM_FAST_N(float61, a, MSG_N_STEPS, &planner.settings.axis_steps_per_mm[a], 5, 9999, []{ planner.refresh_positioning(); }); + EDIT_ITEM_FAST_N(float72, a, MSG_N_STEPS, &planner.settings.axis_steps_per_mm[a], 5, 9999, []{ planner.refresh_positioning(); }); #if ENABLED(DISTINCT_E_FACTORS) LOOP_L_N(n, E_STEPPERS) - EDIT_ITEM_FAST_N(float61, n, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(n)], 5, 9999, []{ + EDIT_ITEM_FAST_N(float72, n, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(n)], 5, 9999, []{ const uint8_t e = MenuItemBase::itemIndex; if (e == active_extruder) planner.refresh_positioning(); @@ -588,7 +652,7 @@ void menu_advanced_steps_per_mm() { planner.mm_per_step[E_AXIS_N(e)] = 1.0f / planner.settings.axis_steps_per_mm[E_AXIS_N(e)]; }); #elif E_STEPPERS - EDIT_ITEM_FAST_N(float61, E_AXIS, MSG_N_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); }); + EDIT_ITEM_FAST_N(float72, E_AXIS, MSG_N_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); }); #endif END_MENU(); @@ -606,10 +670,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 @@ -619,6 +693,11 @@ void menu_advanced_settings() { // M201 - Acceleration items SUBMENU(MSG_ACCELERATION, menu_advanced_acceleration); + // M593 - Acceleration items + #if ENABLED(SHAPING_MENU) + if (!is_busy) SUBMENU(MSG_INPUT_SHAPING, menu_advanced_input_shaping); + #endif + #if HAS_CLASSIC_JERK // M205 - Max Jerk SUBMENU(MSG_JERK, menu_advanced_jerk); @@ -661,11 +740,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_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 3fe0c582cb10..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_wchar('/'); + lcd_put_u8str(F("/")); lcd_put_u8str(GOOD_POINTS_TO_STR(nr_edge_points)); } diff --git a/Marlin/src/lcd/menu/menu_bed_leveling.cpp b/Marlin/src/lcd/menu/menu_bed_leveling.cpp index 294666e35621..9505a82dd77c 100644 --- a/Marlin/src/lcd/menu/menu_bed_leveling.cpp +++ b/Marlin/src/lcd/menu/menu_bed_leveling.cpp @@ -68,10 +68,12 @@ // void _lcd_level_bed_done() { if (!ui.wait_for_move) { - #if Z_AFTER_PROBING > 0 && DISABLED(MESH_BED_LEVELING) - // Display "Done" screen and wait for moves to complete - line_to_z(Z_AFTER_PROBING); - ui.synchronize(GET_TEXT_F(MSG_LEVEL_BED_DONE)); + #if DISABLED(MESH_BED_LEVELING) && defined(Z_AFTER_PROBING) + if (Z_AFTER_PROBING) { + // Display "Done" screen and wait for moves to complete + line_to_z(Z_AFTER_PROBING); + ui.synchronize(GET_TEXT_F(MSG_LEVEL_BED_DONE)); + } #endif ui.goto_previous_screen_no_defer(); ui.completion_feedback(); diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 8b6af33fd11e..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_wchar('%'); + 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); } @@ -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 @@ -547,10 +548,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_delta_calibrate.cpp b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp index b86f1012586d..04bb81569159 100644 --- a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp +++ b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp @@ -52,7 +52,7 @@ void _man_probe_pt(const xy_pos_t &xy) { ui.wait_for_move = false; ui.synchronize(); ui.manual_move.menu_scale = _MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / planner.settings.axis_steps_per_mm[0]); // Use first axis as for delta XYZ should always match - ui.goto_screen(lcd_move_z); + ui.goto_screen([]{ lcd_move_axis(Z_AXIS); }); } } @@ -68,8 +68,8 @@ void _man_probe_pt(const xy_pos_t &xy) { float lcd_probe_pt(const xy_pos_t &xy) { _man_probe_pt(xy); ui.defer_status_screen(); - TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("Delta Calibration in progress"), FPSTR(CONTINUE_STR))); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("Delta Calibration in progress"))); + TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(GET_TEXT_F(MSG_DELTA_CALIBRATION_IN_PROGRESS))); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_DELTA_CALIBRATION_IN_PROGRESS))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); ui.goto_previous_screen_no_defer(); return current_position.z; diff --git a/Marlin/src/lcd/menu/menu_filament.cpp b/Marlin/src/lcd/menu/menu_filament.cpp index 5902a2f63f35..122f0c405099 100644 --- a/Marlin/src/lcd/menu/menu_filament.cpp +++ b/Marlin/src/lcd/menu/menu_filament.cpp @@ -65,9 +65,11 @@ static void _change_filament_with_temp(const uint16_t celsius) { queue.inject(cmd); } -static void _change_filament_with_preset() { - _change_filament_with_temp(ui.material_preset[MenuItemBase::itemIndex].hotend_temp); -} +#if HAS_PREHEAT + static void _change_filament_with_preset() { + _change_filament_with_temp(ui.material_preset[MenuItemBase::itemIndex].hotend_temp); + } +#endif static void _change_filament_with_custom() { _change_filament_with_temp(thermalManager.degTargetHotend(MenuItemBase::itemIndex)); diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index b48eaf9bae06..2a6a568062b3 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -27,7 +27,9 @@ #include "../../inc/MarlinConfigPre.h" -void lcd_move_z(); +#if ENABLED(LASER_SYNCHRONOUS_M106_M107) + #include "../../module/planner.h" +#endif //////////////////////////////////////////// ///////////// Base Menu Items ////////////// @@ -77,10 +79,10 @@ template class TMenuEditItem : MenuEditItemBase { private: typedef typename NAME::type_t type_t; - static float scale(const_float_t value) { return NAME::scale(value); } - static float unscale(const_float_t value) { return NAME::unscale(value); } - static const char* to_string(const int32_t value) { return NAME::strfunc(unscale(value)); } - static void load(void *ptr, const int32_t value) { *((type_t*)ptr) = unscale(value); } + static int32_t scaleToEncoder(const type_t &value) { return NAME::scaleToEncoder(value); } + static type_t unscaleEncoder(const int32_t value) { return NAME::unscaleEncoder(value); } + static const char* to_string(const int32_t value) { return NAME::strfunc(unscaleEncoder(value)); } + static void load(void *ptr, const int32_t value) { *((type_t*)ptr) = unscaleEncoder(value); } public: FORCE_INLINE static void draw(const bool sel, const uint8_t row, FSTR_P const fstr, type_t * const data, ...) { MenuEditItemBase::draw(sel, row, fstr, NAME::strfunc(*(data))); @@ -99,9 +101,9 @@ class TMenuEditItem : MenuEditItemBase { const bool live=false // Callback during editing ) { // Make sure minv and maxv fit within int32_t - const int32_t minv = _MAX(scale(minValue), INT32_MIN), - maxv = _MIN(scale(maxValue), INT32_MAX); - goto_edit_screen(fstr, ptr, minv, maxv - minv, scale(*ptr) - minv, + const int32_t minv = _MAX(scaleToEncoder(minValue), INT32_MIN), + maxv = _MIN(scaleToEncoder(maxValue), INT32_MAX); + goto_edit_screen(fstr, ptr, minv, maxv - minv, scaleToEncoder(*ptr) - minv, edit_screen, callback, live); } }; @@ -117,9 +119,9 @@ class TMenuEditItem : MenuEditItemBase { * * struct MenuEditItemInfo_percent { * typedef uint8_t type_t; - * static float scale(const_float_t value) { return value * (100.f/255.f) +0.5f; } - * static float unscale(const_float_t value) { return value / (100.f/255.f) +0.5f; } - * static const char* strfunc(const_float_t value) { return ui8tostr4pctrj(_DOFIX(uint8_t,value)); } + * static int32_t scaleToEncoder(const type_t &value) { return value * (100.f/255.f) +0.5f; } + * static type_t unscaleEncoder(const int32_t value) { return type_t(value) / (100.f/255.f) +0.5f; } + * static const char* strfunc(const type_t &value) { return ui8tostr4pctrj(_DOFIX(uint8_t,value)); } * }; * typedef TMenuEditItem MenuItem_percent */ @@ -128,35 +130,37 @@ class TMenuEditItem : MenuEditItemBase { #define DEFINE_MENU_EDIT_ITEM_TYPE(NAME, TYPE, STRFUNC, SCALE, ETC...) \ struct MenuEditItemInfo_##NAME { \ typedef TYPE type_t; \ - static float scale(const_float_t value) { return value * (SCALE) ETC; } \ - static float unscale(const_float_t value) { return value / (SCALE) ETC; } \ - static const char* strfunc(const_float_t value) { return STRFUNC(_DOFIX(TYPE,value)); } \ + /* scale the given value to the encoder */ \ + static int32_t scaleToEncoder(const type_t &value) { return value * (SCALE) ETC; } \ + static type_t unscaleEncoder(const int32_t value) { return type_t(value) / (SCALE) ETC; } \ + static const char* strfunc(const type_t &value) { return STRFUNC(_DOFIX(TYPE,value)); } \ }; \ typedef TMenuEditItem MenuItem_##NAME // NAME TYPE STRFUNC SCALE ROUND -DEFINE_MENU_EDIT_ITEM_TYPE(percent ,uint8_t ,ui8tostr4pctrj , 100.f/255.f, +0.5f); // 100% right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(percent_3 ,uint8_t ,pcttostrpctrj , 1 ); // 100% right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(int3 ,int16_t ,i16tostr3rj , 1 ); // 123, -12 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(int4 ,int16_t ,i16tostr4signrj , 1 ); // 1234, -123 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(int8 ,int8_t ,i8tostr3rj , 1 ); // 123, -12 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(uint8 ,uint8_t ,ui8tostr3rj , 1 ); // 123 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(uint16_3 ,uint16_t ,ui16tostr3rj , 1 ); // 123 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(uint16_4 ,uint16_t ,ui16tostr4rj , 0.1f ); // 1234 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(uint16_5 ,uint16_t ,ui16tostr5rj , 0.01f ); // 12345 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(float3 ,float ,ftostr3 , 1 ); // 123 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(float42_52 ,float ,ftostr42_52 , 100 ); // _2.34, 12.34, -2.34 or 123.45, -23.45 -DEFINE_MENU_EDIT_ITEM_TYPE(float43 ,float ,ftostr43sign ,1000 ); // -1.234, _1.234, +1.234 -DEFINE_MENU_EDIT_ITEM_TYPE(float4 ,float ,ftostr4sign , 1 ); // 1234 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(float5 ,float ,ftostr5rj , 1 ); // 12345 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(float5_25 ,float ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment) -DEFINE_MENU_EDIT_ITEM_TYPE(float61 ,float ,ftostr61rj , 10 ); // 12345.6 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(float31sign ,float ,ftostr31sign , 10 ); // +12.3 -DEFINE_MENU_EDIT_ITEM_TYPE(float41sign ,float ,ftostr41sign , 10 ); // +123.4 -DEFINE_MENU_EDIT_ITEM_TYPE(float51sign ,float ,ftostr51sign , 10 ); // +1234.5 -DEFINE_MENU_EDIT_ITEM_TYPE(float52sign ,float ,ftostr52sign , 100 ); // +123.45 -DEFINE_MENU_EDIT_ITEM_TYPE(long5 ,uint32_t ,ftostr5rj , 0.01f ); // 12345 right-justified -DEFINE_MENU_EDIT_ITEM_TYPE(long5_25 ,uint32_t ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment) +DEFINE_MENU_EDIT_ITEM_TYPE(percent ,uint8_t ,ui8tostr4pctrj , 100.f/255.f, + 0.5f ); // 100% right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(percent_3 ,uint8_t ,pcttostrpctrj , 1 ); // 100% right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(int3 ,int16_t ,i16tostr3rj , 1 ); // 123, -12 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(int4 ,int16_t ,i16tostr4signrj , 1 ); // 1234, -123 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(int8 ,int8_t ,i8tostr3rj , 1 ); // 123, -12 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(uint8 ,uint8_t ,ui8tostr3rj , 1 ); // 123 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(uint16_3 ,uint16_t ,ui16tostr3rj , 1 ); // 123 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(uint16_4 ,uint16_t ,ui16tostr4rj , 0.1f ); // 1234 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(uint16_5 ,uint16_t ,ui16tostr5rj , 0.01f ); // 12345 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(float3 ,float ,ftostr3rj , 1 ); // 123 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(float42_52 ,float ,ftostr42_52 , 100 , + 0.001f ); // _2.34, 12.34, -2.34 or 123.45, -23.45 +DEFINE_MENU_EDIT_ITEM_TYPE(float43 ,float ,ftostr43sign ,1000 , + 0.0001f); // -1.234, _1.234, +1.234 +DEFINE_MENU_EDIT_ITEM_TYPE(float4 ,float ,ftostr4sign , 1 ); // 1234 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(float5 ,float ,ftostr5rj , 1 ); // 12345 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(float5_25 ,float ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment) +DEFINE_MENU_EDIT_ITEM_TYPE(float61 ,float ,ftostr61rj , 10 , + 0.01f ); // 12345.6 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(float72 ,float ,ftostr72rj , 100 , + 0.001f ); // 12345.67 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(float31sign ,float ,ftostr31sign , 10 , + 0.01f ); // +12.3 +DEFINE_MENU_EDIT_ITEM_TYPE(float41sign ,float ,ftostr41sign , 10 , + 0.01f ); // +123.4 +DEFINE_MENU_EDIT_ITEM_TYPE(float51sign ,float ,ftostr51sign , 10 , + 0.01f ); // +1234.5 +DEFINE_MENU_EDIT_ITEM_TYPE(float52sign ,float ,ftostr52sign , 100 , + 0.001f ); // +123.45 +DEFINE_MENU_EDIT_ITEM_TYPE(long5 ,uint32_t ,ftostr5rj , 0.01f ); // 12345 right-justified +DEFINE_MENU_EDIT_ITEM_TYPE(long5_25 ,uint32_t ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment) #if HAS_BED_PROBE #if Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9 @@ -357,7 +361,7 @@ class MenuItem_bool : public MenuEditItemBase { NEXT_ITEM(); \ } while(0) -#define STATIC_ITEM_N_F(FLABEL, N, V...) do{ \ +#define STATIC_ITEM_N_F(N, FLABEL, V...) do{ \ if (_menuLineNr == _thisItemNr) { \ MenuItemBase::init(N); \ STATIC_ITEM_INNER_F(FLABEL, ##V); \ @@ -380,7 +384,7 @@ class MenuItem_bool : public MenuEditItemBase { #define PSTRING_ITEM(LABEL, V...) PSTRING_ITEM_F(GET_TEXT_F(LABEL), ##V) #define STATIC_ITEM(LABEL, V...) STATIC_ITEM_F(GET_TEXT_F(LABEL), ##V) -#define STATIC_ITEM_N(LABEL, N, V...) STATIC_ITEM_N_F(GET_TEXT_F(LABEL), N, ##V) +#define STATIC_ITEM_N(N, LABEL, V...) STATIC_ITEM_N_F(N, GET_TEXT_F(LABEL), ##V) // Menu item with index and composed C-string substitution #define MENU_ITEM_N_S_F(TYPE, N, S, FLABEL, V...) _MENU_ITEM_N_S_F(TYPE, N, S, false, FLABEL, ##V) @@ -400,8 +404,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 DISABLED(DISABLE_ENCODER) + #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) @@ -538,6 +547,7 @@ class MenuItem_bool : public MenuEditItemBase { inline void on_fan_update() { thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8); + TERN_(LASER_SYNCHRONOUS_M106_M107, planner.buffer_sync_block(BLOCK_BIT_SYNC_FANS)); } #if ENABLED(EXTRA_FAN_SPEED) @@ -546,6 +556,14 @@ class MenuItem_bool : public MenuEditItemBase { #define EDIT_EXTRA_FAN_SPEED(...) #endif + #if FAN_COUNT == 1 + #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED + #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED + #else + #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N + #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N + #endif + #define _FAN_EDIT_ITEMS(F,L) do{ \ editable.uint8 = thermalManager.fan_speed[F]; \ EDIT_ITEM_FAST_N(percent, F, MSG_##L, &editable.uint8, 0, 255, on_fan_update); \ diff --git a/Marlin/src/lcd/menu/menu_led.cpp b/Marlin/src/lcd/menu/menu_led.cpp index 0c08f6fa944b..867e4dafa940 100644 --- a/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin/src/lcd/menu/menu_led.cpp @@ -83,7 +83,7 @@ START_MENU(); BACK_ITEM(MSG_LED_CONTROL); #if ENABLED(NEOPIXEL2_SEPARATE) - STATIC_ITEM_N(MSG_LED_CHANNEL_N, 1, SS_DEFAULT|SS_INVERT); + STATIC_ITEM_N(1, MSG_LED_CHANNEL_N, SS_DEFAULT|SS_INVERT); #endif EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true); @@ -95,7 +95,7 @@ EDIT_ITEM(uint8, MSG_LED_BRIGHTNESS, &leds.color.i, 0, 255, leds.update, true); #endif #if ENABLED(NEOPIXEL2_SEPARATE) - STATIC_ITEM_N(MSG_LED_CHANNEL_N, 2, SS_DEFAULT|SS_INVERT); + STATIC_ITEM_N(2, MSG_LED_CHANNEL_N, SS_DEFAULT|SS_INVERT); EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds2.color.r, 0, 255, leds2.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds2.color.g, 0, 255, leds2.update, true); EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds2.color.b, 0, 255, leds2.update, true); diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 518f1e0f502d..81b36d2b01a9 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) @@ -233,43 +243,8 @@ void menu_main() { START_MENU(); BACK_ITEM(MSG_INFO_SCREEN); - #if ENABLED(SDSUPPORT) - - #if !defined(MEDIA_MENU_AT_TOP) && !HAS_ENCODER_WHEEL - #define MEDIA_MENU_AT_TOP - #endif - - auto sdcard_menu_items = [&]{ - #if ENABLED(MENU_ADDAUTOSTART) - ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); // Run Auto Files - #endif - - if (card_detected) { - if (!card_open) { - #if HAS_SD_DETECT - GCODES_ITEM(MSG_CHANGE_MEDIA, F("M21")); // M21 Change Media - #else // - or - - ACTION_ITEM(MSG_RELEASE_MEDIA, []{ // M22 Release Media - queue.inject(F("M22")); - #if ENABLED(TFT_COLOR_UI) - // Menu display issue on item removal with multi language selection menu - if (encoderTopLine > 0) encoderTopLine--; - ui.refresh(LCDVIEW_CALL_REDRAW_NEXT); - #endif - }); - #endif - SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); // Media Menu (or Password First) - } - } - else { - #if HAS_SD_DETECT - ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media" - #else - GCODES_ITEM(MSG_ATTACH_MEDIA, F("M21")); // M21 Attach Media - #endif - } - }; - + #if ENABLED(SDSUPPORT) && !defined(MEDIA_MENU_AT_TOP) && !HAS_ENCODER_WHEEL + #define MEDIA_MENU_AT_TOP #endif if (busy) { @@ -298,9 +273,43 @@ void menu_main() { #endif } else { - #if BOTH(SDSUPPORT, MEDIA_MENU_AT_TOP) - sdcard_menu_items(); + // BEGIN MEDIA MENU + #if ENABLED(MENU_ADDAUTOSTART) + ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); // Run Auto Files + #endif + + if (card_detected) { + if (!card_open) { + #if HAS_SD_DETECT + GCODES_ITEM(MSG_CHANGE_MEDIA, F("M21" TERN_(MULTI_VOLUME, "S"))); // M21 Change Media + #if ENABLED(MULTI_VOLUME) + GCODES_ITEM(MSG_ATTACH_USB_MEDIA, F("M21U")); // M21 Attach USB Media + #endif + #else // - or - + ACTION_ITEM(MSG_RELEASE_MEDIA, []{ // M22 Release Media + queue.inject(F("M22")); + #if ENABLED(TFT_COLOR_UI) + // Menu display issue on item removal with multi language selection menu + if (encoderTopLine > 0) encoderTopLine--; + ui.refresh(LCDVIEW_CALL_REDRAW_NEXT); + #endif + }); + #endif + SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); // Media Menu (or Password First) + } + } + else { + #if HAS_SD_DETECT + ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media" + #else + GCODES_ITEM(MSG_ATTACH_MEDIA, F("M21" TERN_(MULTI_VOLUME, "S"))); // M21 Attach Media + #if ENABLED(MULTI_VOLUME) + GCODES_ITEM(MSG_ATTACH_USB_MEDIA, F("M21U")); // M21 Attach USB Media + #endif + #endif + } + // END MEDIA MENU #endif if (TERN0(MACHINE_CAN_PAUSE, printingIsPaused())) @@ -317,6 +326,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 @@ -349,17 +362,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 @@ -387,7 +389,42 @@ void menu_main() { #endif #if ENABLED(SDSUPPORT) && DISABLED(MEDIA_MENU_AT_TOP) - sdcard_menu_items(); + // BEGIN MEDIA MENU + #if ENABLED(MENU_ADDAUTOSTART) + ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); // Run Auto Files + #endif + + if (card_detected) { + if (!card_open) { + #if HAS_SD_DETECT + GCODES_ITEM(MSG_CHANGE_MEDIA, F("M21" TERN_(MULTI_VOLUME, "S"))); // M21 Change Media + #if ENABLED(MULTI_VOLUME) + GCODES_ITEM(MSG_ATTACH_USB_MEDIA, F("M21U")); // M21 Attach USB Media + #endif + #else // - or - + ACTION_ITEM(MSG_RELEASE_MEDIA, []{ // M22 Release Media + queue.inject(F("M22")); + #if ENABLED(TFT_COLOR_UI) + // Menu display issue on item removal with multi language selection menu + if (encoderTopLine > 0) encoderTopLine--; + ui.refresh(LCDVIEW_CALL_REDRAW_NEXT); + #endif + }); + #endif + SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); // Media Menu (or Password First) + } + } + else { + #if HAS_SD_DETECT + ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media" + #else + GCODES_ITEM(MSG_ATTACH_MEDIA, F("M21" TERN_(MULTI_VOLUME, "S"))); // M21 Attach Media + #if ENABLED(MULTI_VOLUME) + GCODES_ITEM(MSG_ATTACH_USB_MEDIA, F("M21U")); // M21 Attach USB Media + #endif + #endif + } + // END MEDIA MENU #endif #if HAS_SERVICE_INTERVALS @@ -458,6 +495,10 @@ void menu_main() { }); #endif + #if ENABLED(ADVANCED_PAUSE_FEATURE) && DISABLED(DISABLE_ENCODER) + FILAMENT_CHANGE_ITEM(); + #endif + END_MENU(); } diff --git a/Marlin/src/lcd/menu/menu_mixer.cpp b/Marlin/src/lcd/menu/menu_mixer.cpp index feb4c59f181c..f787d47d0f4d 100644 --- a/Marlin/src/lcd/menu/menu_mixer.cpp +++ b/Marlin/src/lcd/menu/menu_mixer.cpp @@ -50,8 +50,7 @@ if (ui.encoderPosition) { zvar += float(int32_t(ui.encoderPosition)) * 0.1; ui.encoderPosition = 0; - NOLESS(zvar, 0); - NOMORE(zvar, Z_MAX_POS); + LIMIT(zvar, 0, Z_MAX_POS); } if (ui.should_draw()) { @@ -113,7 +112,7 @@ static uint8_t v_index; #if HAS_DUAL_MIXING void _lcd_draw_mix(const uint8_t y) { char tmp[20]; // "100%_100%" - sprintf_P(tmp, PSTR("%3d%% %3d%%"), int(mixer.mix[0]), int(mixer.mix[1])); + sprintf_P(tmp, PSTR("%3d%% %3d%% "), int(mixer.mix[0]), int(mixer.mix[1])); SETCURSOR(2, y); lcd_put_u8str(GET_TEXT_F(MSG_MIX)); SETCURSOR_RJ(10, y); lcd_put_u8str(tmp); } diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index 90bd015efff4..81068ae30b53 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 || (Y_BED_SIZE) >= 1000 || (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" @@ -46,17 +52,11 @@ #include "../../feature/bedlevel/bedlevel.h" #endif -#if ENABLED(MANUAL_E_MOVES_RELATIVE) - float manual_move_e_origin = 0; -#endif - // // "Motion" > "Move Axis" submenu // -// TODO: Use substitution here with MSG_MOVE_N - -static void _lcd_move_xyz(FSTR_P const name, const AxisEnum axis) { +void lcd_move_axis(const AxisEnum axis) { if (ui.use_click()) return ui.goto_previous_screen_no_defer(); if (ui.encoderPosition && !ui.manual_move.processing) { // Get motion limit from software endstops, if any @@ -80,40 +80,16 @@ static void _lcd_move_xyz(FSTR_P const name, const AxisEnum axis) { } ui.encoderPosition = 0; if (ui.should_draw()) { + MenuEditItemBase::itemIndex = axis; const float pos = ui.manual_move.axis_value(axis); if (parser.using_inch_units()) { const float imp_pos = LINEAR_UNIT(pos); - MenuEditItemBase::draw_edit_screen(name, ftostr63(imp_pos)); + MenuEditItemBase::draw_edit_screen(GET_TEXT_F(MSG_MOVE_N), ftostr63(imp_pos)); } else - MenuEditItemBase::draw_edit_screen(name, ui.manual_move.menu_scale >= 0.1f ? (LARGE_AREA_TEST ? ftostr51sign(pos) : ftostr41sign(pos)) : ftostr63(pos)); + MenuEditItemBase::draw_edit_screen(GET_TEXT_F(MSG_MOVE_N), ui.manual_move.menu_scale >= 0.1f ? (LARGE_AREA_TEST ? ftostr51sign(pos) : ftostr41sign(pos)) : ftostr63(pos)); } } -void lcd_move_x() { _lcd_move_xyz(GET_TEXT_F(MSG_MOVE_X), X_AXIS); } -#if HAS_Y_AXIS - void lcd_move_y() { _lcd_move_xyz(GET_TEXT_F(MSG_MOVE_Y), Y_AXIS); } -#endif -#if HAS_Z_AXIS - void lcd_move_z() { _lcd_move_xyz(GET_TEXT_F(MSG_MOVE_Z), Z_AXIS); } -#endif -#if HAS_I_AXIS - void lcd_move_i() { _lcd_move_xyz(GET_TEXT_F(MSG_MOVE_I), I_AXIS); } -#endif -#if HAS_J_AXIS - void lcd_move_j() { _lcd_move_xyz(GET_TEXT_F(MSG_MOVE_J), J_AXIS); } -#endif -#if HAS_K_AXIS - void lcd_move_k() { _lcd_move_xyz(GET_TEXT_F(MSG_MOVE_K), K_AXIS); } -#endif -#if HAS_U_AXIS - void lcd_move_u() { _lcd_move_xyz(GET_TEXT_F(MSG_MOVE_U), U_AXIS); } -#endif -#if HAS_V_AXIS - void lcd_move_v() { _lcd_move_xyz(GET_TEXT_F(MSG_MOVE_V), V_AXIS); } -#endif -#if HAS_W_AXIS - void lcd_move_w() { _lcd_move_xyz(GET_TEXT_F(MSG_MOVE_W), W_AXIS); } -#endif #if E_MANUAL @@ -134,7 +110,7 @@ void lcd_move_x() { _lcd_move_xyz(GET_TEXT_F(MSG_MOVE_X), X_AXIS); } GET_TEXT_F(TERN(MULTI_E_MANUAL, MSG_MOVE_EN, MSG_MOVE_E)), ftostr41sign(current_position.e PLUS_TERN0(IS_KINEMATIC, ui.manual_move.offset) - MINUS_TERN0(MANUAL_E_MOVES_RELATIVE, manual_move_e_origin) + MINUS_TERN0(MANUAL_E_MOVES_RELATIVE, ui.manual_move.e_origin) ) ); } // should_draw @@ -146,7 +122,7 @@ void lcd_move_x() { _lcd_move_xyz(GET_TEXT_F(MSG_MOVE_X), X_AXIS); } void _goto_manual_move_z(const_float_t scale) { ui.manual_move.menu_scale = scale; - ui.goto_screen(lcd_move_z); + ui.goto_screen([]{ lcd_move_axis(Z_AXIS); }); } #endif @@ -159,43 +135,47 @@ void lcd_move_x() { _lcd_move_xyz(GET_TEXT_F(MSG_MOVE_X), X_AXIS); } #define FINE_MANUAL_MOVE 0.025 #endif -screenFunc_t _manual_move_func_ptr; - void _goto_manual_move(const_float_t scale) { ui.defer_status_screen(); ui.manual_move.menu_scale = scale; - ui.goto_screen(_manual_move_func_ptr); + ui.goto_screen(ui.manual_move.screen_ptr); thermalManager.set_menu_cold_override(true); } void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int8_t eindex=active_extruder) { - _manual_move_func_ptr = func; + ui.manual_move.screen_ptr = func; START_MENU(); if (LCD_HEIGHT >= 4) { - switch (axis) { - #define _CASE_MOVE(N) case N##_AXIS: STATIC_ITEM(MSG_MOVE_##N, SS_DEFAULT|SS_INVERT); break; - MAIN_AXIS_MAP(_CASE_MOVE) - default: - TERN_(MANUAL_E_MOVES_RELATIVE, manual_move_e_origin = current_position.e); - STATIC_ITEM(MSG_MOVE_E, SS_DEFAULT|SS_INVERT); - break; + if (axis < NUM_AXES) + STATIC_ITEM_N(axis, MSG_MOVE_N, SS_DEFAULT|SS_INVERT); + else { + TERN_(MANUAL_E_MOVES_RELATIVE, ui.manual_move.e_origin = current_position.e); + STATIC_ITEM_N(eindex, MSG_MOVE_EN, SS_DEFAULT|SS_INVERT); } } 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); }); - 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(); } @@ -230,38 +210,22 @@ void menu_move() { EDIT_ITEM(bool, MSG_LCD_SOFT_ENDSTOPS, &soft_endstop._enabled); #endif + // Move submenu for each axis if (NONE(IS_KINEMATIC, NO_MOTION_BEFORE_HOMING) || all_axes_homed()) { if (TERN1(DELTA, current_position.z <= delta_clip_start_height)) { - SUBMENU(MSG_MOVE_X, []{ _menu_move_distance(X_AXIS, lcd_move_x); }); + SUBMENU_N(X_AXIS, MSG_MOVE_N, []{ _menu_move_distance(X_AXIS, []{ lcd_move_axis(X_AXIS); }); }); #if HAS_Y_AXIS - SUBMENU(MSG_MOVE_Y, []{ _menu_move_distance(Y_AXIS, lcd_move_y); }); + SUBMENU_N(Y_AXIS, MSG_MOVE_N, []{ _menu_move_distance(Y_AXIS, []{ lcd_move_axis(Y_AXIS); }); }); #endif } - #if ENABLED(DELTA) - else + else { + #if ENABLED(DELTA) ACTION_ITEM(MSG_FREE_XY, []{ line_to_z(delta_clip_start_height); ui.synchronize(); }); - #endif - + #endif + } #if HAS_Z_AXIS - SUBMENU(MSG_MOVE_Z, []{ _menu_move_distance(Z_AXIS, lcd_move_z); }); - #endif - #if HAS_I_AXIS - SUBMENU(MSG_MOVE_I, []{ _menu_move_distance(I_AXIS, lcd_move_i); }); - #endif - #if HAS_J_AXIS - SUBMENU(MSG_MOVE_J, []{ _menu_move_distance(J_AXIS, lcd_move_j); }); - #endif - #if HAS_K_AXIS - SUBMENU(MSG_MOVE_K, []{ _menu_move_distance(K_AXIS, lcd_move_k); }); - #endif - #if HAS_U_AXIS - SUBMENU(MSG_MOVE_U, []{ _menu_move_distance(U_AXIS, lcd_move_u); }); - #endif - #if HAS_V_AXIS - SUBMENU(MSG_MOVE_V, []{ _menu_move_distance(V_AXIS, lcd_move_v); }); - #endif - #if HAS_W_AXIS - SUBMENU(MSG_MOVE_W, []{ _menu_move_distance(W_AXIS, lcd_move_w); }); + #define _AXIS_MOVE(N) SUBMENU_N(N, MSG_MOVE_N, []{ _menu_move_distance(AxisEnum(N), []{ lcd_move_axis(AxisEnum(N)); }); }); + REPEAT_S(2, NUM_AXES, _AXIS_MOVE); #endif } else @@ -281,34 +245,24 @@ void menu_move() { #endif } #elif EXTRUDERS == 3 - if (active_extruder < 2) { - if (active_extruder) - GCODES_ITEM_N(0, MSG_SELECT_E, F("T0")); - else - GCODES_ITEM_N(1, MSG_SELECT_E, F("T1")); - } + if (active_extruder < 2) + GCODES_ITEM_N(1 - active_extruder, MSG_SELECT_E, active_extruder ? F("T0") : F("T1")); #else - if (active_extruder) - GCODES_ITEM_N(0, MSG_SELECT_E, F("T0")); - else - GCODES_ITEM_N(1, MSG_SELECT_E, F("T1")); + GCODES_ITEM_N(1 - active_extruder, MSG_SELECT_E, active_extruder ? F("T0") : F("T1")); #endif #elif ENABLED(DUAL_X_CARRIAGE) - if (active_extruder) - GCODES_ITEM_N(0, MSG_SELECT_E, F("T0")); - else - GCODES_ITEM_N(1, MSG_SELECT_E, F("T1")); + GCODES_ITEM_N(1 - active_extruder, MSG_SELECT_E, active_extruder ? F("T0") : F("T1")); #endif #if E_MANUAL // The current extruder - SUBMENU(MSG_MOVE_E, []{ _menu_move_distance_e_maybe(); }); + SUBMENU(MSG_MOVE_E, _menu_move_distance_e_maybe); - #define SUBMENU_MOVE_E(N) SUBMENU_N(N, MSG_MOVE_EN, []{ _menu_move_distance(E_AXIS, []{ lcd_move_e(MenuItemBase::itemIndex); }, MenuItemBase::itemIndex); }); + #define SUBMENU_MOVE_E(N) SUBMENU_N(N, MSG_MOVE_EN, []{ _menu_move_distance(E_AXIS, []{ lcd_move_e(N); }, N); }); #if EITHER(SWITCHING_EXTRUDER, SWITCHING_NOZZLE) @@ -320,7 +274,7 @@ void menu_move() { #elif MULTI_E_MANUAL // Independent extruders with one E stepper per hotend - LOOP_L_N(n, E_MANUAL) SUBMENU_MOVE_E(n); + REPEAT(E_MANUAL, SUBMENU_MOVE_E); #endif @@ -329,6 +283,8 @@ void menu_move() { END_MENU(); } +#define _HOME_ITEM(N) GCODES_ITEM_N(N##_AXIS, MSG_AUTO_HOME_A, F("G28" STR_##N)); + #if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) // // "Motion" > "Homing" submenu @@ -338,31 +294,7 @@ void menu_move() { BACK_ITEM(MSG_MOTION); GCODES_ITEM(MSG_AUTO_HOME, FPSTR(G28_STR)); - GCODES_ITEM_N(X_AXIS, MSG_AUTO_HOME_A, F("G28X")); - #if HAS_Y_AXIS - GCODES_ITEM_N(Y_AXIS, MSG_AUTO_HOME_A, F("G28Y")); - #endif - #if HAS_Z_AXIS - GCODES_ITEM_N(Z_AXIS, MSG_AUTO_HOME_A, F("G28Z")); - #endif - #if HAS_I_AXIS - GCODES_ITEM_N(I_AXIS, MSG_AUTO_HOME_A, F("G28" STR_I)); - #endif - #if HAS_J_AXIS - GCODES_ITEM_N(J_AXIS, MSG_AUTO_HOME_A, F("G28" STR_J)); - #endif - #if HAS_K_AXIS - GCODES_ITEM_N(K_AXIS, MSG_AUTO_HOME_A, F("G28" STR_K)); - #endif - #if HAS_U_AXIS - GCODES_ITEM_N(U_AXIS, MSG_AUTO_HOME_A, F("G28" STR_U)); - #endif - #if HAS_V_AXIS - GCODES_ITEM_N(V_AXIS, MSG_AUTO_HOME_A, F("G28" STR_V)); - #endif - #if HAS_W_AXIS - GCODES_ITEM_N(W_AXIS, MSG_AUTO_HOME_A, F("G28" STR_W)); - #endif + MAIN_AXIS_MAP(_HOME_ITEM); END_MENU(); } @@ -400,31 +332,7 @@ void menu_motion() { #else GCODES_ITEM(MSG_AUTO_HOME, FPSTR(G28_STR)); #if ENABLED(INDIVIDUAL_AXIS_HOMING_MENU) - GCODES_ITEM_N(X_AXIS, MSG_AUTO_HOME_A, F("G28X")); - #if HAS_Y_AXIS - GCODES_ITEM_N(Y_AXIS, MSG_AUTO_HOME_A, F("G28Y")); - #endif - #if HAS_Z_AXIS - GCODES_ITEM_N(Z_AXIS, MSG_AUTO_HOME_A, F("G28Z")); - #endif - #if HAS_I_AXIS - GCODES_ITEM_N(I_AXIS, MSG_AUTO_HOME_A, F("G28" STR_I)); - #endif - #if HAS_J_AXIS - GCODES_ITEM_N(J_AXIS, MSG_AUTO_HOME_A, F("G28" STR_J)); - #endif - #if HAS_K_AXIS - GCODES_ITEM_N(K_AXIS, MSG_AUTO_HOME_A, F("G28" STR_K)); - #endif - #if HAS_U_AXIS - GCODES_ITEM_N(U_AXIS, MSG_AUTO_HOME_A, F("G28" STR_U)); - #endif - #if HAS_V_AXIS - GCODES_ITEM_N(V_AXIS, MSG_AUTO_HOME_A, F("G28" STR_V)); - #endif - #if HAS_W_AXIS - GCODES_ITEM_N(W_AXIS, MSG_AUTO_HOME_A, F("G28" STR_W)); - #endif + MAIN_AXIS_MAP(_HOME_ITEM); #endif #endif @@ -442,6 +350,21 @@ void menu_motion() { GCODES_ITEM(MSG_AUTO_Z_ALIGN, F("G34")); #endif + // + // Probe Deploy/Stow + // + #if ENABLED(PROBE_DEPLOY_STOW_MENU) + GCODES_ITEM(MSG_MANUAL_DEPLOY, F("M401")); + 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/lcd/menu/menu_password.cpp b/Marlin/src/lcd/menu/menu_password.cpp index 89ea42d70477..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_wchar(' '); - lcd_put_wchar('1' + digit_no); + lcd_put_u8str(F(" ")); + lcd_put_lchar('1' + digit_no); SETCURSOR_X(LCD_WIDTH - 2); - lcd_put_wchar('>'); + 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 9efd68ca005d..de16316987e6 100644 --- a/Marlin/src/lcd/menu/menu_spindle_laser.cpp +++ b/Marlin/src/lcd/menu/menu_spindle_laser.cpp @@ -33,7 +33,7 @@ #include "../../feature/spindle_laser.h" void menu_spindle_laser() { - bool is_enabled = cutter.enabled() && cutter.isReady; + bool is_enabled = cutter.enabled(); #if ENABLED(SPINDLE_CHANGE_DIR) bool is_rev = cutter.is_reverse(); #endif @@ -48,8 +48,14 @@ cutter.mpower_min(), cutter.mpower_max(), cutter.update_from_mpower); #endif - editable.state = is_enabled; - EDIT_ITEM(bool, MSG_CUTTER(TOGGLE), &is_enabled, []{ if (editable.state) cutter.disable(); else cutter.enable_same_dir(); }); + editable.state = is_enabled; // State before toggle + EDIT_ITEM(bool, MSG_CUTTER(TOGGLE), &is_enabled, []{ + #if ENABLED(SPINDLE_FEATURE) + if (editable.state) cutter.disable(); else cutter.enable_same_dir(); + #else + cutter.menu_set_enabled(!editable.state); + #endif + }); #if ENABLED(AIR_EVACUATION) bool evac_state = cutter.air_evac_state(); @@ -72,12 +78,10 @@ // Setup and fire a test pulse using the current PWM power level for for a duration of test_pulse_min to test_pulse_max ms. 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, 65535, cutter.refresh_frequency); + #endif #endif - - #if BOTH(MARLIN_DEV_MODE, 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); - #endif - END_MENU(); } diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index e493972a9712..2e5b8f1e54ce 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -47,30 +47,30 @@ // "Temperature" submenu items // -void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t indb) { - UNUSED(e); UNUSED(indh); UNUSED(indb); - #if HAS_HOTEND - if (indh >= 0 && ui.material_preset[indh].hotend_temp > 0) - setTargetHotend(_MIN(thermalManager.hotend_max_target(e), ui.material_preset[indh].hotend_temp), e); - #endif - #if HAS_HEATED_BED - if (indb >= 0 && ui.material_preset[indb].bed_temp > 0) setTargetBed(ui.material_preset[indb].bed_temp); - #endif - #if HAS_FAN - if (indh >= 0) { - const uint8_t fan_index = active_extruder < (FAN_COUNT) ? active_extruder : 0; - if (true - #if REDUNDANT_PART_COOLING_FAN - && fan_index != REDUNDANT_PART_COOLING_FAN - #endif - ) set_fan_speed(fan_index, ui.material_preset[indh].fan_speed); - } - #endif - ui.return_to_status(); -} - #if HAS_PREHEAT + void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t indb) { + UNUSED(e); UNUSED(indh); UNUSED(indb); + #if HAS_HOTEND + if (indh >= 0 && ui.material_preset[indh].hotend_temp > 0) + setTargetHotend(_MIN(thermalManager.hotend_max_target(e), ui.material_preset[indh].hotend_temp), e); + #endif + #if HAS_HEATED_BED + if (indb >= 0 && ui.material_preset[indb].bed_temp > 0) setTargetBed(ui.material_preset[indb].bed_temp); + #endif + #if HAS_FAN + if (indh >= 0) { + const uint8_t fan_index = active_extruder < (FAN_COUNT) ? active_extruder : 0; + if (true + #if REDUNDANT_PART_COOLING_FAN + && fan_index != REDUNDANT_PART_COOLING_FAN + #endif + ) set_fan_speed(fan_index, ui.material_preset[indh].fan_speed); + } + #endif + ui.return_to_status(); + } + #if HAS_TEMP_HOTEND inline void _preheat_end(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, -1); } void do_preheat_end_m() { _preheat_end(editable.int8, 0); } diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index b13c55f80a3b..a4a30882214a 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_wchar(':'); + 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_wchar(':'); + lcd_put_u8str(F(":")); #endif lcd_put_u8str(BABYSTEP_TO_STR(mps * babystep.axis_total[BS_TOTAL_IND(axis)])); } @@ -156,37 +156,37 @@ void menu_tune() { #if HAS_FAN0 _FAN_EDIT_ITEMS(0,FIRST_FAN_SPEED); #endif - #if HAS_FAN1 + #if HAS_FAN1 && REDUNDANT_PART_COOLING_FAN != 1 FAN_EDIT_ITEMS(1); #elif SNFAN(1) singlenozzle_item(1); #endif - #if HAS_FAN2 + #if HAS_FAN2 && REDUNDANT_PART_COOLING_FAN != 2 FAN_EDIT_ITEMS(2); #elif SNFAN(2) singlenozzle_item(2); #endif - #if HAS_FAN3 + #if HAS_FAN3 && REDUNDANT_PART_COOLING_FAN != 3 FAN_EDIT_ITEMS(3); #elif SNFAN(3) singlenozzle_item(3); #endif - #if HAS_FAN4 + #if HAS_FAN4 && REDUNDANT_PART_COOLING_FAN != 4 FAN_EDIT_ITEMS(4); #elif SNFAN(4) singlenozzle_item(4); #endif - #if HAS_FAN5 + #if HAS_FAN5 && REDUNDANT_PART_COOLING_FAN != 5 FAN_EDIT_ITEMS(5); #elif SNFAN(5) singlenozzle_item(5); #endif - #if HAS_FAN6 + #if HAS_FAN6 && REDUNDANT_PART_COOLING_FAN != 6 FAN_EDIT_ITEMS(6); #elif SNFAN(6) singlenozzle_item(6); #endif - #if HAS_FAN7 + #if HAS_FAN7 && REDUNDANT_PART_COOLING_FAN != 7 FAN_EDIT_ITEMS(7); #elif SNFAN(7) singlenozzle_item(7); @@ -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/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index 62c1770bd4c3..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, @@ -312,11 +315,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 +324,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); diff --git a/Marlin/src/lcd/menu/menu_x_twist.cpp b/Marlin/src/lcd/menu/menu_x_twist.cpp index e46745e8b761..a069b427c6bf 100644 --- a/Marlin/src/lcd/menu/menu_x_twist.cpp +++ b/Marlin/src/lcd/menu/menu_x_twist.cpp @@ -99,12 +99,8 @@ void xatc_wizard_menu() { SUBMENU(MSG_MOVE_1MM, []{ _goto_manual_move_z( 1); }); SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move_z( 0.1f); }); - if ((FINE_MANUAL_MOVE) > 0.0f && (FINE_MANUAL_MOVE) < 0.1f) { - // Determine digits needed right of decimal - const uint8_t digs = !UNEAR_ZERO((FINE_MANUAL_MOVE) * 1000 - int((FINE_MANUAL_MOVE) * 1000)) ? 4 : - !UNEAR_ZERO((FINE_MANUAL_MOVE) * 100 - int((FINE_MANUAL_MOVE) * 100)) ? 3 : 2; + if ((FINE_MANUAL_MOVE) > 0.0f && (FINE_MANUAL_MOVE) < 0.1f) SUBMENU_f(F(STRINGIFY(FINE_MANUAL_MOVE)), MSG_MOVE_N_MM, []{ _goto_manual_move_z(float(FINE_MANUAL_MOVE)); }); - } ACTION_ITEM(MSG_BUTTON_DONE, xatc_wizard_set_offset_and_go_to_next_point); diff --git a/Marlin/src/lcd/tft/tft.h b/Marlin/src/lcd/tft/tft.h index 67cec2ee1c7e..6df4c22d5191 100644 --- a/Marlin/src/lcd/tft/tft.h +++ b/Marlin/src/lcd/tft/tft.h @@ -65,9 +65,9 @@ #endif #endif -#if TFT_BUFFER_SIZE > 65535 +#if TFT_BUFFER_SIZE > DMA_MAX_SIZE // DMA Count parameter is uint16_t - #error "TFT_BUFFER_SIZE can not exceed 65535" + #error "TFT_BUFFER_SIZE can not exceed DMA_MAX_SIZE" #endif class TFT { @@ -86,8 +86,8 @@ class TFT { static bool is_busy() { return io.isBusy(); } static void abort() { io.Abort(); } - static void write_multiple(uint16_t Data, uint16_t Count) { io.WriteMultiple(Data, Count); } - static void write_sequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); } + static void write_multiple(uint16_t Data, uint16_t Count) { io.WriteMultipleDMA(Data, Count); } + static void write_sequence(uint16_t *Data, uint16_t Count) { io.WriteSequenceDMA(Data, Count); } static void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { io.set_window(Xmin, Ymin, Xmax, Ymax); } static void fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.fill(x, y, width, height, color); } diff --git a/Marlin/src/lcd/tft/tft_image.h b/Marlin/src/lcd/tft/tft_image.h index de046fb0c4c2..aeb1ca2bf559 100644 --- a/Marlin/src/lcd/tft/tft_image.h +++ b/Marlin/src/lcd/tft/tft_image.h @@ -114,7 +114,13 @@ enum colorMode_t : uint8_t { typedef colorMode_t ColorMode; -typedef struct __attribute__((__packed__)) { +#ifdef __AVR__ + #define IMG_PACKED __attribute__((__packed__)) +#else + #define IMG_PACKED +#endif + +typedef struct IMG_PACKED { void *data; uint16_t width; uint16_t height; diff --git a/Marlin/src/lcd/tft/tft_queue.cpp b/Marlin/src/lcd/tft/tft_queue.cpp index 25ab452cef31..19dd810dc7dc 100644 --- a/Marlin/src/lcd/tft/tft_queue.cpp +++ b/Marlin/src/lcd/tft/tft_queue.cpp @@ -86,9 +86,9 @@ void TFT_Queue::fill(queueTask_t *task) { task->state = TASK_STATE_IN_PROGRESS; } - if (task_parameters->count > 65535) { - count = 65535; - task_parameters->count -= 65535; + if (task_parameters->count > DMA_MAX_SIZE) { + count = DMA_MAX_SIZE; + task_parameters->count -= DMA_MAX_SIZE; } else { count = task_parameters->count; diff --git a/Marlin/src/lcd/tft/tft_queue.h b/Marlin/src/lcd/tft/tft_queue.h index 55d0a526b5e3..bc45af822a45 100644 --- a/Marlin/src/lcd/tft/tft_queue.h +++ b/Marlin/src/lcd/tft/tft_queue.h @@ -135,6 +135,7 @@ class TFT_Queue { static void reset(); static void async(); static void sync() { while (current_task != nullptr) async(); } + static bool is_empty() { return current_task == nullptr; } static void fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color); static void canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height); diff --git a/Marlin/src/lcd/tft/tft_string.cpp b/Marlin/src/lcd/tft/tft_string.cpp index d8c419d1a078..d589b0465b7f 100644 --- a/Marlin/src/lcd/tft/tft_string.cpp +++ b/Marlin/src/lcd/tft/tft_string.cpp @@ -94,12 +94,12 @@ void TFT_String::set() { * @ displays an axis name such as XYZUVW, or E for an extruder */ void TFT_String::add(const char *tpl, const int8_t index, const char *cstr/*=nullptr*/, FSTR_P const fstr/*=nullptr*/) { - wchar_t wchar; + lchar_t wc; while (*tpl) { - tpl = get_utf8_value_cb(tpl, read_byte_ram, &wchar); - if (wchar > 255) wchar |= 0x0080; - const uint8_t ch = uint8_t(wchar & 0x00FF); + tpl = get_utf8_value_cb(tpl, read_byte_ram, wc); + if (wc > 255) wc |= 0x0080; + const uint8_t ch = uint8_t(wc & 0x00FF); if (ch == '=' || ch == '~' || ch == '*') { if (index >= 0) { @@ -124,11 +124,11 @@ void TFT_String::add(const char *tpl, const int8_t index, const char *cstr/*=nul } void TFT_String::add(const char *cstr, uint8_t max_len/*=MAX_STRING_LENGTH*/) { - wchar_t wchar; + lchar_t wc; while (*cstr && max_len) { - cstr = get_utf8_value_cb(cstr, read_byte_ram, &wchar); - if (wchar > 255) wchar |= 0x0080; - const uint8_t ch = uint8_t(wchar & 0x00FF); + cstr = get_utf8_value_cb(cstr, read_byte_ram, wc); + if (wc > 255) wc |= 0x0080; + const uint8_t ch = uint8_t(wc & 0x00FF); add_character(ch); max_len--; } diff --git a/Marlin/src/lcd/tft/tft_string.h b/Marlin/src/lcd/tft/tft_string.h index 5940a48ac98b..d43e0b0df2b4 100644 --- a/Marlin/src/lcd/tft/tft_string.h +++ b/Marlin/src/lcd/tft/tft_string.h @@ -25,6 +25,8 @@ #include +#include "../fontutils.h" + extern const uint8_t ISO10646_1_5x7[]; extern const uint8_t font10x20[]; @@ -97,7 +99,7 @@ class TFT_String { * @param character The ASCII character */ static void add(const char character) { add_character(character); eol(); } - static void set(wchar_t character) { set(); add(character); } + static void set(const lchar_t &character) { set(); add(character); } /** * @brief Append / Set C-string diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index a152907a9dde..1665e9ab7700 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -27,7 +27,7 @@ #include "touch.h" #include "../marlinui.h" // for ui methods -#include "../menu/menu_item.h" // for touch_screen_calibration +#include "../menu/menu_item.h" // for MSG_FIRST_FAN_SPEED #include "../../module/temperature.h" #include "../../module/planner.h" @@ -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,26 +97,24 @@ 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) { if (WITHIN(x, current_control->x - FREE_MOVE_RANGE, current_control->x + current_control->width + FREE_MOVE_RANGE) && WITHIN(y, current_control->y - FREE_MOVE_RANGE, current_control->y + current_control->height + FREE_MOVE_RANGE)) { - NOLESS(x, current_control->x); - NOMORE(x, current_control->x + current_control->width); - NOLESS(y, current_control->y); - NOMORE(y, current_control->y + current_control->height); + LIMIT(x, current_control->x, current_control->x + current_control->width); + LIMIT(y, current_control->y, current_control->y + current_control->height); touch(current_control); } else @@ -133,7 +131,7 @@ void Touch::idle() { } if (!current_control) - touch_time = last_touch_ms; + touch_time = now; } x = _x; y = _y; @@ -154,7 +152,7 @@ void Touch::touch(touch_control_t *control) { case CALIBRATE: if (touch_calibration.handleTouch(x, y)) ui.refresh(); break; - #endif // TOUCH_SCREEN_CALIBRATION + #endif case MENU_SCREEN: ui.goto_screen((screenFunc_t)control->data); break; case BACK: ui.goto_previous_screen(); break; @@ -175,7 +173,7 @@ void Touch::touch(touch_control_t *control) { ui.refresh(); break; case PAGE_DOWN: - encoderTopLine = encoderTopLine + 2 * LCD_HEIGHT < screen_items ? encoderTopLine + LCD_HEIGHT : screen_items - LCD_HEIGHT; + encoderTopLine = (encoderTopLine + 2 * LCD_HEIGHT < screen_items) ? encoderTopLine + LCD_HEIGHT : screen_items - LCD_HEIGHT; ui.encoderPosition = ui.encoderPosition + LCD_HEIGHT < (uint32_t)screen_items ? ui.encoderPosition + LCD_HEIGHT : screen_items; ui.refresh(); break; @@ -252,8 +250,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, uint32_t(MIN_REPEAT_DELAY)); + time_to_hold = next_touch_ms + repeat_delay; } ui.refresh(); } @@ -301,8 +299,10 @@ 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(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/tft/touch.h b/Marlin/src/lcd/tft/touch.h index 6021a840b65e..eab85604f107 100644 --- a/Marlin/src/lcd/tft/touch.h +++ b/Marlin/src/lcd/tft/touch.h @@ -31,10 +31,10 @@ #endif #if ENABLED(TFT_TOUCH_DEVICE_GT911) - #include HAL_PATH(../../HAL, tft/gt911.h) + #include HAL_PATH(../.., tft/gt911.h) #define TOUCH_DRIVER_CLASS GT911 #elif ENABLED(TFT_TOUCH_DEVICE_XPT2046) - #include HAL_PATH(../../HAL, tft/xpt2046.h) + #include HAL_PATH(../.., tft/xpt2046.h) #define TOUCH_DRIVER_CLASS XPT2046 #else #error "Unknown Touch Screen Type." @@ -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/lcd/tft/ui_1024x600.cpp b/Marlin/src/lcd/tft/ui_1024x600.cpp index 15a51f56b8ec..08d6b51fdbba 100644 --- a/Marlin/src/lcd/tft/ui_1024x600.cpp +++ b/Marlin/src/lcd/tft/ui_1024x600.cpp @@ -57,7 +57,8 @@ void MarlinUI::tft_idle() { #endif tft.queue.async(); - TERN_(TOUCH_SCREEN, touch.idle()); + + TERN_(TOUCH_SCREEN, if (tft.queue.is_empty()) touch.idle()); // Touch driver is not DMA-aware, so only check for touch controls after screen drawing is completed } #if ENABLED(SHOW_BOOTSCREEN) @@ -227,25 +228,25 @@ void MarlinUI::draw_status_screen() { for (i = 0 ; i < ITEMS_COUNT; i++) { x = (TFT_WIDTH / ITEMS_COUNT - 80) / 2 + (TFT_WIDTH * i / ITEMS_COUNT); switch (i) { - #ifdef ITEM_E0 + #if HAS_EXTRUDERS case ITEM_E0: draw_heater_status(x, y, H_E0); break; #endif - #ifdef ITEM_E1 + #if HAS_MULTI_HOTEND case ITEM_E1: draw_heater_status(x, y, H_E1); break; #endif - #ifdef ITEM_E2 + #if HOTENDS > 2 case ITEM_E2: draw_heater_status(x, y, H_E2); break; #endif - #ifdef ITEM_BED + #if HAS_HEATED_BED case ITEM_BED: draw_heater_status(x, y, H_BED); break; #endif - #ifdef ITEM_CHAMBER + #if HAS_TEMP_CHAMBER case ITEM_CHAMBER: draw_heater_status(x, y, H_CHAMBER); break; #endif - #ifdef ITEM_COOLER + #if HAS_TEMP_COOLER case ITEM_COOLER: draw_heater_status(x, y, H_COOLER); break; #endif - #ifdef ITEM_FAN + #if HAS_FAN case ITEM_FAN: draw_fan_status(x, y, blink); break; #endif } @@ -325,7 +326,10 @@ void MarlinUI::draw_status_screen() { #if ENABLED(TOUCH_SCREEN) add_control(900, y, menu_main, imgSettings); - TERN_(SDSUPPORT, add_control(12, y, menu_media, imgSD, !printingIsActive(), COLOR_CONTROL_ENABLED, card.isMounted() && printingIsActive() ? COLOR_BUSY : COLOR_CONTROL_DISABLED)); + #if ENABLED(SDSUPPORT) + const bool cm = card.isMounted(), pa = printingIsActive(); + add_control(12, y, menu_media, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, cm && pa ? COLOR_BUSY : COLOR_CONTROL_DISABLED); + #endif #endif y += 100; @@ -394,8 +398,7 @@ void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const va } #endif - extern screenFunc_t _manual_move_func_ptr; - if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) { + if (ui.can_show_slider()) { #define SLIDER_LENGTH 600 #define SLIDER_Y_POSITION 200 @@ -792,7 +795,7 @@ static void z_minus() { moveAxis(Z_AXIS, -1); } } #endif -#if HAS_BED_PROBE +#if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) static void z_select() { motionAxisState.z_selection *= -1; quick_feedback(); diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index a4fcc35bd039..9014d4ed1216 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -57,7 +57,8 @@ void MarlinUI::tft_idle() { #endif tft.queue.async(); - TERN_(TOUCH_SCREEN, touch.idle()); + + TERN_(TOUCH_SCREEN, if (tft.queue.is_empty()) touch.idle()); // Touch driver is not DMA-aware, so only check for touch controls after screen drawing is completed } #if ENABLED(SHOW_BOOTSCREEN) @@ -227,25 +228,25 @@ void MarlinUI::draw_status_screen() { for (i = 0 ; i < ITEMS_COUNT; i++) { x = (320 / ITEMS_COUNT - 64) / 2 + (320 * i / ITEMS_COUNT); switch (i) { - #ifdef ITEM_E0 + #if HAS_EXTRUDERS case ITEM_E0: draw_heater_status(x, y, H_E0); break; #endif - #ifdef ITEM_E1 + #if HAS_MULTI_HOTEND case ITEM_E1: draw_heater_status(x, y, H_E1); break; #endif - #ifdef ITEM_E2 + #if HOTENDS > 2 case ITEM_E2: draw_heater_status(x, y, H_E2); break; #endif - #ifdef ITEM_BED + #if HAS_HEATED_BED case ITEM_BED: draw_heater_status(x, y, H_BED); break; #endif - #ifdef ITEM_CHAMBER + #if HAS_TEMP_CHAMBER case ITEM_CHAMBER: draw_heater_status(x, y, H_CHAMBER); break; #endif - #ifdef ITEM_COOLER + #if HAS_TEMP_COOLER case ITEM_COOLER: draw_heater_status(x, y, H_COOLER); break; #endif - #ifdef ITEM_FAN + #if HAS_FAN case ITEM_FAN: draw_fan_status(x, y, blink); break; #endif } @@ -342,7 +343,10 @@ void MarlinUI::draw_status_screen() { #if ENABLED(TOUCH_SCREEN) add_control(256, 130, menu_main, imgSettings); - TERN_(SDSUPPORT, add_control(0, 130, menu_media, imgSD, !printingIsActive(), COLOR_CONTROL_ENABLED, card.isMounted() && printingIsActive() ? COLOR_BUSY : COLOR_CONTROL_DISABLED)); + #if ENABLED(SDSUPPORT) + const bool cm = card.isMounted(), pa = printingIsActive(); + add_control(0, 130, menu_media, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, cm && pa ? COLOR_BUSY : COLOR_CONTROL_DISABLED); + #endif #endif } @@ -383,8 +387,7 @@ void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const va } #endif - extern screenFunc_t _manual_move_func_ptr; - if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) { + if (ui.can_show_slider()) { #define SLIDER_LENGTH 224 #define SLIDER_Y_POSITION 140 @@ -772,7 +775,7 @@ static void z_minus() { moveAxis(Z_AXIS, -1); } } #endif -#if HAS_BED_PROBE +#if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) static void z_select() { motionAxisState.z_selection *= -1; quick_feedback(); diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index 8a5fa6335420..22c3a3fc19c1 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -57,7 +57,8 @@ void MarlinUI::tft_idle() { #endif tft.queue.async(); - TERN_(TOUCH_SCREEN, touch.idle()); + + TERN_(TOUCH_SCREEN, if (tft.queue.is_empty()) touch.idle()); // Touch driver is not DMA-aware, so only check for touch controls after screen drawing is completed } #if ENABLED(SHOW_BOOTSCREEN) @@ -227,25 +228,25 @@ void MarlinUI::draw_status_screen() { for (i = 0 ; i < ITEMS_COUNT; i++) { x = (TFT_WIDTH / ITEMS_COUNT - 80) / 2 + (TFT_WIDTH * i / ITEMS_COUNT); switch (i) { - #ifdef ITEM_E0 + #if HAS_EXTRUDERS case ITEM_E0: draw_heater_status(x, y, H_E0); break; #endif - #ifdef ITEM_E1 + #if HAS_MULTI_HOTEND case ITEM_E1: draw_heater_status(x, y, H_E1); break; #endif - #ifdef ITEM_E2 + #if HOTENDS > 2 case ITEM_E2: draw_heater_status(x, y, H_E2); break; #endif - #ifdef ITEM_BED + #if HAS_HEATED_BED case ITEM_BED: draw_heater_status(x, y, H_BED); break; #endif - #ifdef ITEM_CHAMBER + #if HAS_TEMP_CHAMBER case ITEM_CHAMBER: draw_heater_status(x, y, H_CHAMBER); break; #endif - #ifdef ITEM_COOLER + #if HAS_TEMP_COOLER case ITEM_COOLER: draw_heater_status(x, y, H_COOLER); break; #endif - #ifdef ITEM_FAN + #if HAS_FAN case ITEM_FAN: draw_fan_status(x, y, blink); break; #endif } @@ -319,7 +320,10 @@ void MarlinUI::draw_status_screen() { #if ENABLED(TOUCH_SCREEN) add_control(404, y, menu_main, imgSettings); - TERN_(SDSUPPORT, add_control(12, y, menu_media, imgSD, !printingIsActive(), COLOR_CONTROL_ENABLED, card.isMounted() && printingIsActive() ? COLOR_BUSY : COLOR_CONTROL_DISABLED)); + #if ENABLED(SDSUPPORT) + const bool cm = card.isMounted(), pa = printingIsActive(); + add_control(12, y, menu_media, imgSD, cm && !pa, COLOR_CONTROL_ENABLED, cm && pa ? COLOR_BUSY : COLOR_CONTROL_DISABLED); + #endif #endif y += TERN(HAS_UI_480x272, 36, 44); @@ -388,8 +392,7 @@ void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const va } #endif - extern screenFunc_t _manual_move_func_ptr; - if (ui.currentScreen != _manual_move_func_ptr && !ui.external_control) { + if (ui.can_show_slider()) { #define SLIDER_LENGTH 336 #define SLIDER_Y_POSITION 186 @@ -773,7 +776,7 @@ static void z_minus() { moveAxis(Z_AXIS, -1); } } #endif -#if HAS_BED_PROBE +#if BOTH(HAS_BED_PROBE, TOUCH_SCREEN) static void z_select() { motionAxisState.z_selection *= -1; quick_feedback(); diff --git a/Marlin/src/lcd/tft/ui_common.cpp b/Marlin/src/lcd/tft/ui_common.cpp index c9e069dbbd6f..55e433b5e4fa 100644 --- a/Marlin/src/lcd/tft/ui_common.cpp +++ b/Marlin/src/lcd/tft/ui_common.cpp @@ -96,7 +96,7 @@ void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row) { lcd_gotopixel(int(col) * (TFT_COL_WIDTH), int(row) * MENU_LINE_HEIGHT); } -int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { +int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length) { if (max_length < 1) return 0; tft_string.set(c); tft.add_text(MENU_TEXT_X_OFFSET, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); @@ -225,24 +225,24 @@ void MarlinUI::clear_lcd() { void MarlinUI::touch_calibration_screen() { uint16_t x, y; - calibrationState calibration_stage = touch_calibration.get_calibration_state(); + calibrationState stage = touch_calibration.get_calibration_state(); - if (calibration_stage == CALIBRATION_NONE) { + if (stage == CALIBRATION_NONE) { defer_status_screen(true); clear_lcd(); - calibration_stage = touch_calibration.calibration_start(); + stage = touch_calibration.calibration_start(); } else { - x = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].x; - y = touch_calibration.calibration_points[_MIN(calibration_stage - 1, CALIBRATION_BOTTOM_RIGHT)].y; + x = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].x; + y = touch_calibration.calibration_points[_MIN(stage - 1, CALIBRATION_BOTTOM_RIGHT)].y; tft.canvas(x - 15, y - 15, 31, 31); tft.set_background(COLOR_BACKGROUND); } touch.clear(); - if (calibration_stage < CALIBRATION_SUCCESS) { - switch (calibration_stage) { + if (stage < CALIBRATION_SUCCESS) { + switch (stage) { case CALIBRATION_TOP_LEFT: tft_string.set(GET_TEXT(MSG_TOP_LEFT)); break; case CALIBRATION_BOTTOM_LEFT: tft_string.set(GET_TEXT(MSG_BOTTOM_LEFT)); break; case CALIBRATION_TOP_RIGHT: tft_string.set(GET_TEXT(MSG_TOP_RIGHT)); break; @@ -250,8 +250,8 @@ void MarlinUI::clear_lcd() { default: break; } - x = touch_calibration.calibration_points[calibration_stage].x; - y = touch_calibration.calibration_points[calibration_stage].y; + x = touch_calibration.calibration_points[stage].x; + y = touch_calibration.calibration_points[stage].y; tft.canvas(x - 15, y - 15, 31, 31); tft.set_background(COLOR_BACKGROUND); @@ -261,7 +261,7 @@ void MarlinUI::clear_lcd() { touch.add_control(CALIBRATE, 0, 0, TFT_WIDTH, TFT_HEIGHT, uint32_t(x) << 16 | uint32_t(y)); } else { - tft_string.set(calibration_stage == CALIBRATION_SUCCESS ? GET_TEXT(MSG_CALIBRATION_COMPLETED) : GET_TEXT(MSG_CALIBRATION_FAILED)); + tft_string.set(stage == CALIBRATION_SUCCESS ? GET_TEXT(MSG_CALIBRATION_COMPLETED) : GET_TEXT(MSG_CALIBRATION_FAILED)); defer_status_screen(false); touch_calibration.calibration_end(); touch.add_control(BACK, 0, 0, TFT_WIDTH, TFT_HEIGHT); diff --git a/Marlin/src/lcd/tft/ui_common.h b/Marlin/src/lcd/tft/ui_common.h index 7329c31a52a5..2a81ee2114b3 100644 --- a/Marlin/src/lcd/tft/ui_common.h +++ b/Marlin/src/lcd/tft/ui_common.h @@ -57,32 +57,15 @@ void menu_item(const uint8_t row, bool sel = false); #define ABSOLUTE_ZERO -273.15 -#if HAS_TEMP_CHAMBER && HAS_MULTI_HOTEND - #define ITEM_E0 0 - #define ITEM_E1 1 - #define ITEM_BED 2 - #define ITEM_CHAMBER 3 - #define ITEM_FAN 4 - #define ITEMS_COUNT 5 -#elif HAS_TEMP_CHAMBER - #define ITEM_E0 0 - #define ITEM_BED 1 - #define ITEM_CHAMBER 2 - #define ITEM_FAN 3 - #define ITEMS_COUNT 4 -#elif HAS_TEMP_COOLER - #define ITEM_COOLER 0 - #define ITEM_FAN 1 - #define ITEMS_COUNT 2 -#elif HAS_MULTI_HOTEND - #define ITEM_E0 0 - #define ITEM_E1 1 - #define ITEM_BED 2 - #define ITEM_FAN 3 - #define ITEMS_COUNT 4 -#else - #define ITEM_E0 0 - #define ITEM_BED 1 - #define ITEM_FAN 2 - #define ITEMS_COUNT 3 -#endif +enum { + OPTITEM(HAS_EXTRUDERS, ITEM_E0) + OPTITEM(HAS_MULTI_HOTEND, ITEM_E1) + #if HOTENDS > 2 + ITEM_E2, + #endif + OPTITEM(HAS_HEATED_BED, ITEM_BED) + OPTITEM(HAS_TEMP_CHAMBER, ITEM_CHAMBER) + OPTITEM(HAS_TEMP_COOLER, ITEM_COOLER) + OPTITEM(HAS_FAN, ITEM_FAN) + ITEMS_COUNT +}; diff --git a/Marlin/src/lcd/tft_io/tft_io.cpp b/Marlin/src/lcd/tft_io/tft_io.cpp index acb78c3e6e9f..294c146d5cb9 100644 --- a/Marlin/src/lcd/tft_io/tft_io.cpp +++ b/Marlin/src/lcd/tft_io/tft_io.cpp @@ -60,7 +60,7 @@ TFT_IO_DRIVER TFT_IO::io; uint32_t TFT_IO::lcd_id = 0xFFFFFFFF; void TFT_IO::InitTFT() { -if (lcd_id != 0xFFFFFFFF) return; + if (lcd_id != 0xFFFFFFFF) return; #if PIN_EXISTS(TFT_BACKLIGHT) OUT_WRITE(TFT_BACKLIGHT_PIN, LOW); @@ -243,7 +243,7 @@ void TFT_IO::write_esc_sequence(const uint16_t *Sequence) { continue; } data = *Sequence++; - if (data == 0x7FFF) return; + if (data == 0x7FFF) break; if (data == 0xFFFF) io.WriteData(0xFFFF); else if (data & 0x8000) diff --git a/Marlin/src/lcd/tft_io/tft_io.h b/Marlin/src/lcd/tft_io/tft_io.h index 50b921cd2a93..d6f178a020c1 100644 --- a/Marlin/src/lcd/tft_io/tft_io.h +++ b/Marlin/src/lcd/tft_io/tft_io.h @@ -24,13 +24,17 @@ #include "../../inc/MarlinConfig.h" #if HAS_SPI_TFT - #include HAL_PATH(../../HAL, tft/tft_spi.h) + #include HAL_PATH(../.., tft/tft_spi.h) #elif HAS_FSMC_TFT - #include HAL_PATH(../../HAL, tft/tft_fsmc.h) + #include HAL_PATH(../.., tft/tft_fsmc.h) #elif HAS_LTDC_TFT - #include HAL_PATH(../../HAL, tft/tft_ltdc.h) + #include HAL_PATH(../.., tft/tft_ltdc.h) #else - #error "TFT IO only supports SPI, FSMC or LTDC interface" + #error "TFT IO only supports SPI, FSMC or LTDC interface." +#endif + +#ifndef DMA_MAX_SIZE + #error "MAX_DMA_SIZE is not configured for this platform." #endif #define TFT_EXCHANGE_XY _BV32(1) @@ -108,27 +112,33 @@ class TFT_IO { static void write_esc_sequence(const uint16_t *Sequence); // Deletaged methods - inline static void Init() { io.Init(); io.Abort(); }; - inline static bool isBusy() { return io.isBusy(); }; - inline static void Abort() { io.Abort(); }; - inline static uint32_t GetID() { return io.GetID(); }; + inline static void Init() { io.Init(); } + inline static bool isBusy() { return io.isBusy(); } + inline static void Abort() { io.Abort(); } + inline static uint32_t GetID() { return io.GetID(); } inline static void DataTransferBegin(uint16_t DataWidth = DATASIZE_16BIT) { io.DataTransferBegin(DataWidth); } - inline static void DataTransferEnd() { io.DataTransferEnd(); }; - // inline static void DataTransferAbort() { io.DataTransferAbort(); }; + inline static void DataTransferEnd() { io.DataTransferEnd(); } - inline static void WriteData(uint16_t Data) { io.WriteData(Data); }; - inline static void WriteReg(uint16_t Reg) { io.WriteReg(Reg); }; + inline static void WriteData(uint16_t Data) { io.WriteData(Data); } + inline static void WriteReg(uint16_t Reg) { io.WriteReg(Reg); } - inline static void WriteSequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); }; + // Blocking IO used by TFT_CLASSIC_UI and TFT_LVGL_UI + // These functions start data transfer and WAIT for data transfer completion + inline static void WriteSequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); } + inline static void WriteMultiple(uint16_t Color, uint32_t Count) { io.WriteMultiple(Color, Count); } + // Non-blocking DMA-based IO used by TFT_COLOR_UI only + // These functions start data transfer using DMA and do NOT wait for data transfer completion + inline static void WriteSequenceDMA(uint16_t *Data, uint16_t Count) { io.WriteSequence_DMA(Data, Count); } + inline static void WriteMultipleDMA(uint16_t Color, uint16_t Count) { io.WriteMultiple_DMA(Color, Count); } + + // Non-blocking DMA-based IO with IRQ callback used by TFT_LVGL_UI only + // This function starts data transfer using DMA and does NOT wait for data transfer completion #if ENABLED(USE_SPI_DMA_TC) - inline static void WriteSequenceIT(uint16_t *Data, uint16_t Count) { io.WriteSequenceIT(Data, Count); }; + inline static void WriteSequenceIT(uint16_t *Data, uint16_t Count) { io.WriteSequenceIT(Data, Count); } #endif - // static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } - inline static void WriteMultiple(uint16_t Color, uint32_t Count) { io.WriteMultiple(Color, Count); }; - protected: static uint32_t lcd_id; }; diff --git a/Marlin/src/lcd/tft_io/touch_calibration.cpp b/Marlin/src/lcd/tft_io/touch_calibration.cpp index 44ebc73d71a2..c239a94b41f9 100644 --- a/Marlin/src/lcd/tft_io/touch_calibration.cpp +++ b/Marlin/src/lcd/tft_io/touch_calibration.cpp @@ -41,6 +41,7 @@ touch_calibration_t TouchCalibration::calibration; calibrationState TouchCalibration::calibration_state = CALIBRATION_NONE; touch_calibration_point_t TouchCalibration::calibration_points[4]; uint8_t TouchCalibration::failed_count; +millis_t TouchCalibration::next_touch_update_ms; // = 0; void TouchCalibration::validate_calibration() { #define VALIDATE_PRECISION(XY, A, B) validate_precision_##XY(CALIBRATION_##A, CALIBRATION_##B) @@ -74,7 +75,7 @@ void TouchCalibration::validate_calibration() { else { calibration_state = CALIBRATION_FAIL; calibration_reset(); - if (need_calibration() && failed_count++ < TOUCH_CALIBRATION_MAX_RETRIES) calibration_state = CALIBRATION_TOP_LEFT; + if (need_calibration() && failed_count++ < TOUCH_CALIBRATION_MAX_RETRIES) calibration_state = CALIBRATION_NONE; } #undef CAL_PTS @@ -89,11 +90,11 @@ void TouchCalibration::validate_calibration() { } } -bool TouchCalibration::handleTouch(uint16_t x, uint16_t y) { - static millis_t next_button_update_ms = 0; +bool TouchCalibration::handleTouch(const uint16_t x, const uint16_t y) { const millis_t now = millis(); - if (PENDING(now, next_button_update_ms)) return false; - next_button_update_ms = now + BUTTON_DELAY_MENU; + + if (next_touch_update_ms && PENDING(now, next_touch_update_ms)) return false; + next_touch_update_ms = now + BUTTON_DELAY_MENU; if (calibration_state < CALIBRATION_SUCCESS) { calibration_points[calibration_state].raw_x = x; diff --git a/Marlin/src/lcd/tft_io/touch_calibration.h b/Marlin/src/lcd/tft_io/touch_calibration.h index abd566770007..030b4977db51 100644 --- a/Marlin/src/lcd/tft_io/touch_calibration.h +++ b/Marlin/src/lcd/tft_io/touch_calibration.h @@ -57,6 +57,7 @@ class TouchCalibration { public: static calibrationState calibration_state; static touch_calibration_point_t calibration_points[4]; + static millis_t next_touch_update_ms; static bool validate_precision(int32_t a, int32_t b) { return (a > b ? (100 * b) / a : (100 * a) / b) > TOUCH_SCREEN_CALIBRATION_PRECISION; } static bool validate_precision_x(uint8_t a, uint8_t b) { return validate_precision(calibration_points[a].raw_x, calibration_points[b].raw_x); } @@ -64,11 +65,12 @@ class TouchCalibration { static void validate_calibration(); static touch_calibration_t calibration; - static uint8_t failed_count; + static uint8_t failed_count; static void calibration_reset() { calibration = { TOUCH_CALIBRATION_X, TOUCH_CALIBRATION_Y, TOUCH_OFFSET_X, TOUCH_OFFSET_Y, TOUCH_ORIENTATION }; } static bool need_calibration() { return !calibration.offset_x && !calibration.offset_y && !calibration.x && !calibration.y; } static calibrationState calibration_start() { + next_touch_update_ms = millis() + 750UL; calibration = { 0, 0, 0, 0, TOUCH_ORIENTATION_NONE }; calibration_state = CALIBRATION_TOP_LEFT; calibration_points[CALIBRATION_TOP_LEFT].x = 30; @@ -89,7 +91,7 @@ class TouchCalibration { return !need_calibration(); } - static bool handleTouch(uint16_t x, uint16_t y); + static bool handleTouch(const uint16_t x, const uint16_t y); }; extern TouchCalibration touch_calibration; diff --git a/Marlin/src/lcd/thermistornames.h b/Marlin/src/lcd/thermistornames.h index 2571efe0759c..54542bed4ed8 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 @@ -139,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/lcd/touch/touch_buttons.cpp b/Marlin/src/lcd/touch/touch_buttons.cpp index dcdc7def8667..032015cdd0ed 100644 --- a/Marlin/src/lcd/touch/touch_buttons.cpp +++ b/Marlin/src/lcd/touch/touch_buttons.cpp @@ -28,10 +28,10 @@ #include "../scaled_tft.h" #if ENABLED(TFT_TOUCH_DEVICE_GT911) - #include HAL_PATH(../../HAL, tft/gt911.h) + #include HAL_PATH(../.., tft/gt911.h) GT911 touchIO; #elif ENABLED(TFT_TOUCH_DEVICE_XPT2046) - #include HAL_PATH(../../HAL, tft/xpt2046.h) + #include HAL_PATH(../.., tft/xpt2046.h) XPT2046 touchIO; #else #error "Unknown Touch Screen Type." @@ -61,33 +61,38 @@ 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() { #ifdef HAS_WIRED_LCD int16_t x, y; - const bool is_touched = (TERN(TOUCH_SCREEN_CALIBRATION, touch_calibration.calibration.orientation, TOUCH_ORIENTATION) == TOUCH_PORTRAIT ? touchIO.getRawPoint(&y, &x) : touchIO.getRawPoint(&x, &y)); - #if HAS_TOUCH_SLEEP - if (is_touched) - wakeUp(); - else if (!isSleeping() && ELAPSED(millis(), next_sleep_ms) && ui.on_status_screen()) - sleepTimeout(); - #endif - if (!is_touched) return 0; - - #if ENABLED(TOUCH_SCREEN_CALIBRATION) - const calibrationState state = touch_calibration.get_calibration_state(); - if (WITHIN(state, CALIBRATION_TOP_LEFT, CALIBRATION_BOTTOM_RIGHT)) { - if (touch_calibration.handleTouch(x, y)) ui.refresh(); - return 0; - } - x = int16_t((int32_t(x) * touch_calibration.calibration.x) >> 16) + touch_calibration.calibration.offset_x; - y = int16_t((int32_t(y) * touch_calibration.calibration.y) >> 16) + touch_calibration.calibration.offset_y; - #else - x = uint16_t((uint32_t(x) * TOUCH_CALIBRATION_X) >> 16) + TOUCH_OFFSET_X; - y = uint16_t((uint32_t(y) * TOUCH_CALIBRATION_Y) >> 16) + TOUCH_OFFSET_Y; + #if ENABLED(TFT_TOUCH_DEVICE_XPT2046) + const bool is_touched = (TERN(TOUCH_SCREEN_CALIBRATION, touch_calibration.calibration.orientation, TOUCH_ORIENTATION) == TOUCH_PORTRAIT ? touchIO.getRawPoint(&y, &x) : touchIO.getRawPoint(&x, &y)); + #if HAS_TOUCH_SLEEP + if (is_touched) + wakeUp(); + else if (!isSleeping() && ELAPSED(millis(), next_sleep_ms) && ui.on_status_screen()) + sleepTimeout(); + #endif + if (!is_touched) return 0; + + #if ENABLED(TOUCH_SCREEN_CALIBRATION) + const calibrationState state = touch_calibration.get_calibration_state(); + if (WITHIN(state, CALIBRATION_TOP_LEFT, CALIBRATION_BOTTOM_RIGHT)) { + if (touch_calibration.handleTouch(x, y)) ui.refresh(); + return 0; + } + x = int16_t((int32_t(x) * touch_calibration.calibration.x) >> 16) + touch_calibration.calibration.offset_x; + y = int16_t((int32_t(y) * touch_calibration.calibration.y) >> 16) + touch_calibration.calibration.offset_y; + #else + x = uint16_t((uint32_t(x) * TOUCH_CALIBRATION_X) >> 16) + TOUCH_OFFSET_X; + y = uint16_t((uint32_t(y) * TOUCH_CALIBRATION_Y) >> 16) + TOUCH_OFFSET_Y; + #endif + #elif ENABLED(TFT_TOUCH_DEVICE_GT911) + const bool is_touched = (TOUCH_ORIENTATION == TOUCH_PORTRAIT ? touchIO.getPoint(&y, &x) : touchIO.getPoint(&x, &y)); + if (!is_touched) return 0; #endif // Touch within the button area simulates an encoder button @@ -130,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/libs/BL24CXX.h b/Marlin/src/libs/BL24CXX.h index b069c196c035..654ceffc3e54 100644 --- a/Marlin/src/libs/BL24CXX.h +++ b/Marlin/src/libs/BL24CXX.h @@ -23,7 +23,7 @@ /******************************************************************************** * @file BL24CXX.h - * @brief i2c EEPROM for Ender 3 v2 board (4.2.2) + * @brief i2c EEPROM for Ender-3 v2 board (4.2.2) ********************************************************************************/ /******************** IIC ********************/ diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp deleted file mode 100644 index 1d6943406722..000000000000 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp +++ /dev/null @@ -1,998 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 . - * - */ - -/** - * The monitor_driver routines are a close copy of the TMC code - */ - -#include "../../inc/MarlinConfig.h" - -#if HAS_L64XX - -#include "L64XX_Marlin.h" - -L64XX_Marlin L64xxManager; - -#include "../../module/stepper/indirection.h" -#include "../../gcode/gcode.h" -#include "../../module/planner.h" -#include "../../HAL/shared/Delay.h" - -static const char NUM_AXIS_LIST( - str_X[] PROGMEM = "X ", str_Y[] PROGMEM = "Y ", str_Z[] PROGMEM = "Z ", - str_I[] PROGMEM = STR_I " ", str_J[] PROGMEM = STR_J " ", str_K[] PROGMEM = STR_K " " - ), - str_X2[] PROGMEM = "X2", str_Y2[] PROGMEM = "Y2", - str_Z2[] PROGMEM = "Z2", str_Z3[] PROGMEM = "Z3", str_Z4[] PROGMEM = "Z4", - LIST_N(EXTRUDERS, - str_E0[] PROGMEM = "E0", str_E1[] PROGMEM = "E1", - str_E2[] PROGMEM = "E2", str_E3[] PROGMEM = "E3", - str_E4[] PROGMEM = "E4", str_E5[] PROGMEM = "E5", - str_E6[] PROGMEM = "E6", str_E7[] PROGMEM = "E7" - ) - ; - -#define _EN_ITEM(N) , str_E##N -PGM_P const L64XX_Marlin::index_to_axis[] PROGMEM = { - NUM_AXIS_LIST(str_X, str_Y, str_Z, str_I, str_J, str_K), - str_X2, str_Y2, str_Z2, str_Z3, str_Z4 - REPEAT(E_STEPPERS, _EN_ITEM) -}; -#undef _EN_ITEM - -#define DEBUG_OUT ENABLED(L6470_CHITCHAT) -#include "../../core/debug_out.h" - -void echo_yes_no(const bool yes) { DEBUG_ECHOPGM_P(yes ? PSTR(" YES") : PSTR(" NO ")); UNUSED(yes); } - -uint8_t L64XX_Marlin::dir_commands[MAX_L64XX]; // array to hold direction command for each driver - -#define _EN_ITEM(N) , ENABLED(INVERT_E##N##_DIR) -const uint8_t L64XX_Marlin::index_to_dir[MAX_L64XX] = { - NUM_AXIS_LIST(ENABLED(INVERT_X_DIR), ENABLED(INVERT_Y_DIR), ENABLED(INVERT_Z_DIR), ENABLED(INVERT_I_DIR), ENABLED(INVERT_J_DIR), ENABLED(INVERT_K_DIR), ENABLED(INVERT_U_DIR), ENABLED(INVERT_V_DIR), ENABLED(INVERT_W_DIR)) - , ENABLED(INVERT_X_DIR) ^ BOTH(HAS_DUAL_X_STEPPERS, INVERT_X2_VS_X_DIR) // X2 - , ENABLED(INVERT_Y_DIR) ^ BOTH(HAS_DUAL_Y_STEPPERS, INVERT_Y2_VS_Y_DIR) // Y2 - , ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z2_VS_Z_DIR) // Z2 - , ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z3_VS_Z_DIR) // Z3 - , ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z4_VS_Z_DIR) // Z4 - REPEAT(E_STEPPERS, _EN_ITEM) -}; -#undef _EN_ITEM - -volatile uint8_t L64XX_Marlin::spi_abort = false; -uint8_t L64XX_Marlin::spi_active = false; - -L64XX_Marlin::L64XX_shadow_t L64XX_Marlin::shadow; - -//uint32_t UVLO_ADC = 0x0400; // ADC undervoltage event - -void L6470_populate_chain_array() { - - #define _L6470_INIT_SPI(Q) do{ stepper##Q.set_chain_info(Q, Q##_CHAIN_POS); }while(0) - - #if AXIS_IS_L64XX(X) - _L6470_INIT_SPI(X); - #endif - #if AXIS_IS_L64XX(X2) - _L6470_INIT_SPI(X2); - #endif - #if AXIS_IS_L64XX(Y) - _L6470_INIT_SPI(Y); - #endif - #if AXIS_IS_L64XX(Y2) - _L6470_INIT_SPI(Y2); - #endif - #if AXIS_IS_L64XX(Z) - _L6470_INIT_SPI(Z); - #endif - #if AXIS_IS_L64XX(Z2) - _L6470_INIT_SPI(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - _L6470_INIT_SPI(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - _L6470_INIT_SPI(Z4); - #endif - #if AXIS_IS_L64XX(E0) - _L6470_INIT_SPI(E0); - #endif - #if AXIS_IS_L64XX(E1) - _L6470_INIT_SPI(E1); - #endif - #if AXIS_IS_L64XX(E2) - _L6470_INIT_SPI(E2); - #endif - #if AXIS_IS_L64XX(E3) - _L6470_INIT_SPI(E3); - #endif - #if AXIS_IS_L64XX(E4) - _L6470_INIT_SPI(E4); - #endif - #if AXIS_IS_L64XX(E5) - _L6470_INIT_SPI(E5); - #endif - #if AXIS_IS_L64XX(E6) - _L6470_INIT_SPI(E6); - #endif - #if AXIS_IS_L64XX(E7) - _L6470_INIT_SPI(E7); - #endif -} - - -/** - * Some status bit positions & definitions differ per driver. - * Copy info to known locations to simplfy check/display logic. - * 1. Copy stepper status - * 2. Copy status bit definitions - * 3. Copy status layout - * 4. Make all error bits active low (as needed) - */ -uint16_t L64XX_Marlin::get_stepper_status(L64XX &st) { - shadow.STATUS_AXIS_RAW = st.getStatus(); - shadow.STATUS_AXIS = shadow.STATUS_AXIS_RAW; - shadow.STATUS_AXIS_LAYOUT = st.L6470_status_layout; - shadow.AXIS_OCD_TH_MAX = st.OCD_TH_MAX; - shadow.AXIS_STALL_TH_MAX = st.STALL_TH_MAX; - shadow.AXIS_OCD_CURRENT_CONSTANT_INV = st.OCD_CURRENT_CONSTANT_INV; - shadow.AXIS_STALL_CURRENT_CONSTANT_INV = st.STALL_CURRENT_CONSTANT_INV; - shadow.L6470_AXIS_CONFIG = st.L64XX_CONFIG; - shadow.L6470_AXIS_STATUS = st.L64XX_STATUS; - shadow.STATUS_AXIS_OCD = st.STATUS_OCD; - shadow.STATUS_AXIS_SCK_MOD = st.STATUS_SCK_MOD; - shadow.STATUS_AXIS_STEP_LOSS_A = st.STATUS_STEP_LOSS_A; - shadow.STATUS_AXIS_STEP_LOSS_B = st.STATUS_STEP_LOSS_B; - shadow.STATUS_AXIS_TH_SD = st.STATUS_TH_SD; - shadow.STATUS_AXIS_TH_WRN = st.STATUS_TH_WRN; - shadow.STATUS_AXIS_UVLO = st.STATUS_UVLO; - shadow.STATUS_AXIS_WRONG_CMD = st.STATUS_WRONG_CMD; - shadow.STATUS_AXIS_CMD_ERR = st.STATUS_CMD_ERR; - shadow.STATUS_AXIS_NOTPERF_CMD = st.STATUS_NOTPERF_CMD; - - switch (shadow.STATUS_AXIS_LAYOUT) { - case L6470_STATUS_LAYOUT: { // L6470 - shadow.L6470_ERROR_MASK = shadow.STATUS_AXIS_UVLO | shadow.STATUS_AXIS_TH_WRN | shadow.STATUS_AXIS_TH_SD | shadow.STATUS_AXIS_OCD | shadow.STATUS_AXIS_STEP_LOSS_A | shadow.STATUS_AXIS_STEP_LOSS_B; - shadow.STATUS_AXIS ^= (shadow.STATUS_AXIS_WRONG_CMD | shadow.STATUS_AXIS_NOTPERF_CMD); // invert just error bits that are active high - break; - } - case L6474_STATUS_LAYOUT: { // L6474 - shadow.L6470_ERROR_MASK = shadow.STATUS_AXIS_UVLO | shadow.STATUS_AXIS_TH_WRN | shadow.STATUS_AXIS_TH_SD | shadow.STATUS_AXIS_OCD ; - shadow.STATUS_AXIS ^= (shadow.STATUS_AXIS_WRONG_CMD | shadow.STATUS_AXIS_NOTPERF_CMD); // invert just error bits that are active high - break; - } - case L6480_STATUS_LAYOUT: { // L6480 & powerSTEP01 - shadow.L6470_ERROR_MASK = shadow.STATUS_AXIS_UVLO | shadow.STATUS_AXIS_TH_WRN | shadow.STATUS_AXIS_TH_SD | shadow.STATUS_AXIS_OCD | shadow.STATUS_AXIS_STEP_LOSS_A | shadow.STATUS_AXIS_STEP_LOSS_B; - shadow.STATUS_AXIS ^= (shadow.STATUS_AXIS_CMD_ERR | shadow.STATUS_AXIS_TH_WRN | shadow.STATUS_AXIS_TH_SD); // invert just error bits that are active high - break; - } - } - return shadow.STATUS_AXIS; -} - - -void L64XX_Marlin::init() { // Set up SPI and then init chips - ENABLE_RESET_L64XX_CHIPS(LOW); // hardware reset of drivers - DELAY_US(100); - ENABLE_RESET_L64XX_CHIPS(HIGH); - DELAY_US(1000); // need about 650µs for the chip(s) to fully start up - L6470_populate_chain_array(); // Set up array to control where in the SPI transfer sequence a particular stepper's data goes - - spi_init(); // Since L64XX SPI pins are unset we must init SPI here - - init_to_defaults(); // init the chips -} - -uint16_t L64XX_Marlin::get_status(const L64XX_axis_t axis) { - - #define STATUS_L6470(Q) get_stepper_status(stepper##Q) - - switch (axis) { - default: break; - #if AXIS_IS_L64XX(X) - case X : return STATUS_L6470(X); - #endif - #if AXIS_IS_L64XX(Y) - case Y : return STATUS_L6470(Y); - #endif - #if AXIS_IS_L64XX(Z) - case Z : return STATUS_L6470(Z); - #endif - #if AXIS_IS_L64XX(X2) - case X2: return STATUS_L6470(X2); - #endif - #if AXIS_IS_L64XX(Y2) - case Y2: return STATUS_L6470(Y2); - #endif - #if AXIS_IS_L64XX(Z2) - case Z2: return STATUS_L6470(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - case Z3: return STATUS_L6470(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - case Z4: return STATUS_L6470(Z4); - #endif - #if AXIS_IS_L64XX(E0) - case E0: return STATUS_L6470(E0); - #endif - #if AXIS_IS_L64XX(E1) - case E1: return STATUS_L6470(E1); - #endif - #if AXIS_IS_L64XX(E2) - case E2: return STATUS_L6470(E2); - #endif - #if AXIS_IS_L64XX(E3) - case E3: return STATUS_L6470(E3); - #endif - #if AXIS_IS_L64XX(E4) - case E4: return STATUS_L6470(E4); - #endif - #if AXIS_IS_L64XX(E5) - case E5: return STATUS_L6470(E5); - #endif - #if AXIS_IS_L64XX(E6) - case E6: return STATUS_L6470(E6); - #endif - #if AXIS_IS_L64XX(E7) - case E7: return STATUS_L6470(E7); - #endif - } - - return 0; // Not needed but kills a compiler warning -} - -uint32_t L64XX_Marlin::get_param(const L64XX_axis_t axis, const uint8_t param) { - - #define GET_L6470_PARAM(Q) L6470_GETPARAM(param, Q) - - switch (axis) { - default: break; - #if AXIS_IS_L64XX(X) - case X : return GET_L6470_PARAM(X); - #endif - #if AXIS_IS_L64XX(Y) - case Y : return GET_L6470_PARAM(Y); - #endif - #if AXIS_IS_L64XX(Z) - case Z : return GET_L6470_PARAM(Z); - #endif - #if AXIS_IS_L64XX(X2) - case X2: return GET_L6470_PARAM(X2); - #endif - #if AXIS_IS_L64XX(Y2) - case Y2: return GET_L6470_PARAM(Y2); - #endif - #if AXIS_IS_L64XX(Z2) - case Z2: return GET_L6470_PARAM(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - case Z3: return GET_L6470_PARAM(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - case Z4: return GET_L6470_PARAM(Z4); - #endif - #if AXIS_IS_L64XX(E0) - case E0: return GET_L6470_PARAM(E0); - #endif - #if AXIS_IS_L64XX(E1) - case E1: return GET_L6470_PARAM(E1); - #endif - #if AXIS_IS_L64XX(E2) - case E2: return GET_L6470_PARAM(E2); - #endif - #if AXIS_IS_L64XX(E3) - case E3: return GET_L6470_PARAM(E3); - #endif - #if AXIS_IS_L64XX(E4) - case E4: return GET_L6470_PARAM(E4); - #endif - #if AXIS_IS_L64XX(E5) - case E5: return GET_L6470_PARAM(E5); - #endif - #if AXIS_IS_L64XX(E6) - case E6: return GET_L6470_PARAM(E6); - #endif - #if AXIS_IS_L64XX(E7) - case E7: return GET_L6470_PARAM(E7); - #endif - } - - return 0; // not needed but kills a compiler warning -} - -void L64XX_Marlin::set_param(const L64XX_axis_t axis, const uint8_t param, const uint32_t value) { - - #define SET_L6470_PARAM(Q) stepper##Q.SetParam(param, value) - - switch (axis) { - default: break; - #if AXIS_IS_L64XX(X) - case X : SET_L6470_PARAM(X); break; - #endif - #if AXIS_IS_L64XX(Y) - case Y : SET_L6470_PARAM(Y); break; - #endif - #if AXIS_IS_L64XX(Z) - case Z : SET_L6470_PARAM(Z); break; - #endif - #if AXIS_IS_L64XX(I) - case I : SET_L6470_PARAM(I); break; - #endif - #if AXIS_IS_L64XX(J) - case J : SET_L6470_PARAM(J); break; - #endif - #if AXIS_IS_L64XX(K) - case K : SET_L6470_PARAM(K); break; - #endif - #if AXIS_IS_L64XX(X2) - case X2: SET_L6470_PARAM(X2); break; - #endif - #if AXIS_IS_L64XX(Y2) - case Y2: SET_L6470_PARAM(Y2); break; - #endif - #if AXIS_IS_L64XX(Z2) - case Z2: SET_L6470_PARAM(Z2); break; - #endif - #if AXIS_IS_L64XX(Z3) - case Z3: SET_L6470_PARAM(Z3); break; - #endif - #if AXIS_IS_L64XX(Z4) - case Z4: SET_L6470_PARAM(Z4); break; - #endif - #if AXIS_IS_L64XX(E0) - case E0: SET_L6470_PARAM(E0); break; - #endif - #if AXIS_IS_L64XX(E1) - case E1: SET_L6470_PARAM(E1); break; - #endif - #if AXIS_IS_L64XX(E2) - case E2: SET_L6470_PARAM(E2); break; - #endif - #if AXIS_IS_L64XX(E3) - case E3: SET_L6470_PARAM(E3); break; - #endif - #if AXIS_IS_L64XX(E4) - case E4: SET_L6470_PARAM(E4); break; - #endif - #if AXIS_IS_L64XX(E5) - case E5: SET_L6470_PARAM(E5); break; - #endif - #if AXIS_IS_L64XX(E6) - case E6: SET_L6470_PARAM(E6); break; - #endif - #if AXIS_IS_L64XX(E7) - case E7: SET_L6470_PARAM(E7); break; - #endif - } -} - -inline void echo_min_max(const char a, const_float_t min, const_float_t max) { - DEBUG_CHAR(' '); DEBUG_CHAR(a); - DEBUG_ECHOLNPGM(" min = ", min, " max = ", max); -} -inline void echo_oct_used(const_float_t oct, const uint8_t stall) { - DEBUG_ECHOPGM("over_current_threshold used : ", oct); - DEBUG_ECHOPGM_P(stall ? PSTR(" (Stall") : PSTR(" (OCD")); - DEBUG_ECHOLNPGM(" threshold)"); -} -inline void err_out_of_bounds() { DEBUG_ECHOLNPGM("Test aborted - motion out of bounds"); } - -uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_index[3], char axis_mon[3][3], - float &position_max, float &position_min, float &final_feedrate, uint8_t &kval_hold, - uint8_t over_current_flag, uint8_t &OCD_TH_val, uint8_t &STALL_TH_val, uint16_t &over_current_threshold -) { - // Return TRUE if the calling routine needs to abort/kill - - uint16_t displacement = 0; // " = 0" to eliminate compiler warning - uint8_t j; // general purpose counter - - if (!all_axes_homed()) { - DEBUG_ECHOLNPGM("Test aborted - home all before running this command"); - return true; - } - - uint8_t found_displacement = false; - LOOP_LOGICAL_AXES(i) if (uint16_t _displacement = parser.intval(AXIS_CHAR(i))) { - found_displacement = true; - displacement = _displacement; - const uint8_t axis_offset = parser.byteval('J'); - axis_mon[0][0] = AXIS_CHAR(i); // Axis first character, one of XYZ...E - const bool single_or_e = axis_offset >= 2 || axis_mon[0][0] == 'E', - one_or_more = !single_or_e && axis_offset == 0; - uint8_t driver_count_local = 0; // Can't use "driver_count" directly as a subscript because it's passed by reference - if (single_or_e) // Single axis, E0, or E1 - axis_mon[0][1] = axis_offset + '0'; // Index given by 'J' parameter - - if (single_or_e || one_or_more) { - for (j = 0; j < MAX_L64XX; j++) { // Count up the drivers on this axis - PGM_P str = (PGM_P)pgm_read_ptr(&index_to_axis[j]); // Get a PGM_P from progmem - const char c = pgm_read_byte(str); // Get a char from progmem - if (axis_mon[0][0] == c) { // For each stepper on this axis... - char *mon = axis_mon[driver_count_local]; - *mon++ = c; // Copy the 3 letter axis name - *mon++ = pgm_read_byte(&str[1]); // to the axis_mon array - *mon = pgm_read_byte(&str[2]); - axis_index[driver_count_local] = (L64XX_axis_t)j; // And store the L64XX axis index - driver_count_local++; - } - } - if (one_or_more) driver_count = driver_count_local; - } - break; // only take first axis found - } - - if (!found_displacement) { - DEBUG_ECHOLNPGM("Test aborted - AXIS with displacement is required"); - return true; - } - - // - // Position calcs & checks - // - - const float LOGICAL_AXIS_LIST( - E_center = current_position.e, - X_center = LOGICAL_X_POSITION(current_position.x), - Y_center = LOGICAL_Y_POSITION(current_position.y), - Z_center = LOGICAL_Z_POSITION(current_position.z), - I_center = LOGICAL_I_POSITION(current_position.i), - J_center = LOGICAL_J_POSITION(current_position.j), - K_center = LOGICAL_K_POSITION(current_position.k) - ); - - switch (axis_mon[0][0]) { - default: position_max = position_min = 0; break; - - case 'X': { - position_min = X_center - displacement; - position_max = X_center + displacement; - echo_min_max('X', position_min, position_max); - if (TERN0(HAS_ENDSTOPS, position_min < (X_MIN_POS) || position_max > (X_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - - #if HAS_Y_AXIS - case 'Y': { - position_min = Y_center - displacement; - position_max = Y_center + displacement; - echo_min_max('Y', position_min, position_max); - if (TERN0(HAS_ENDSTOPS, position_min < (Y_MIN_POS) || position_max > (Y_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - #endif - - #if HAS_Z_AXIS - case 'Z': { - position_min = Z_center - displacement; - position_max = Z_center + displacement; - echo_min_max('Z', position_min, position_max); - if (TERN0(HAS_ENDSTOPS, position_min < (Z_MIN_POS) || position_max > (Z_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - #endif - - #if HAS_I_AXIS - case AXIS4_NAME: { - position_min = I_center - displacement; - position_max = I_center + displacement; - echo_min_max(AXIS4_NAME, position_min, position_max); - if (TERN0(HAS_ENDSTOPS, position_min < (I_MIN_POS) || position_max > (I_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - #endif - - #if HAS_J_AXIS - case AXIS5_NAME: { - position_min = J_center - displacement; - position_max = J_center + displacement; - echo_min_max(AXIS5_NAME, position_min, position_max); - if (TERN1(HAS_ENDSTOPS, position_min < (J_MIN_POS) || position_max > (J_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - #endif - - #if HAS_K_AXIS - case AXIS6_NAME: { - position_min = K_center - displacement; - position_max = K_center + displacement; - echo_min_max(AXIS6_NAME, position_min, position_max); - if (TERN2(HAS_ENDSTOPS, position_min < (K_MIN_POS) || position_max > (K_MAX_POS))) { - err_out_of_bounds(); - return true; - } - } break; - #endif - - #if HAS_EXTRUDERS - case 'E': { - position_min = E_center - displacement; - position_max = E_center + displacement; - echo_min_max('E', position_min, position_max); - } break; - #endif - } - - // - // Work on the drivers - // - - LOOP_L_N(k, driver_count) { - uint8_t not_found = true; - for (j = 1; j <= L64XX::chain[0]; j++) { - PGM_P const str = (PGM_P)pgm_read_ptr(&index_to_axis[L64XX::chain[j]]); - if (pgm_read_byte(&str[0]) == axis_mon[k][0] && pgm_read_byte(&str[1]) == axis_mon[k][1]) { // See if a L6470 driver - not_found = false; - break; - } - } - if (not_found) { - driver_count = k; - axis_mon[k][0] = ' '; // mark this entry invalid - break; - } - } - - if (driver_count == 0) { - DEBUG_ECHOLNPGM("Test aborted - not a L6470 axis"); - return true; - } - - DEBUG_ECHOPGM("Monitoring:"); - for (j = 0; j < driver_count; j++) DEBUG_ECHOPGM(" ", axis_mon[j]); - DEBUG_EOL(); - - // now have a list of driver(s) to monitor - - // - // TVAL & kVAL_HOLD checks & settings - // - const L64XX_shadow_t &sh = shadow; - get_status(axis_index[0]); // populate shadow array - - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // L6474 - use TVAL - uint16_t TVAL_current = parser.ushortval('T'); - if (TVAL_current) { - uint8_t TVAL_count = (TVAL_current / sh.AXIS_STALL_CURRENT_CONSTANT_INV) - 1; - LIMIT(TVAL_count, 0, sh.AXIS_STALL_TH_MAX); - for (j = 0; j < driver_count; j++) - set_param(axis_index[j], L6474_TVAL, TVAL_count); - } - // only print the tval from one of the drivers - kval_hold = get_param(axis_index[0], L6474_TVAL); - DEBUG_ECHOLNPGM("TVAL current (mA) = ", (kval_hold + 1) * sh.AXIS_STALL_CURRENT_CONSTANT_INV); - } - else { - kval_hold = parser.byteval('K'); - if (kval_hold) { - DEBUG_ECHOLNPGM("kval_hold = ", kval_hold); - for (j = 0; j < driver_count; j++) - set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold); - } - else { - // only print the KVAL_HOLD from one of the drivers - kval_hold = get_param(axis_index[0], L6470_KVAL_HOLD); - DEBUG_ECHOLNPGM("KVAL_HOLD = ", kval_hold); - } - } - - // - // Overcurrent checks & settings - // - - if (over_current_flag) { - - uint8_t OCD_TH_val_local = 0, // compiler thinks OCD_TH_val is unused if use it directly - STALL_TH_val_local = 0; // just in case ... - - over_current_threshold = parser.intval('I'); - - if (over_current_threshold) { - - OCD_TH_val_local = over_current_threshold/375; - LIMIT(OCD_TH_val_local, 0, 15); - STALL_TH_val_local = over_current_threshold/31.25; - LIMIT(STALL_TH_val_local, 0, 127); - uint16_t OCD_TH_actual = (OCD_TH_val_local + 1) * 375, - STALL_TH_actual = (STALL_TH_val_local + 1) * 31.25; - if (OCD_TH_actual < STALL_TH_actual) { - OCD_TH_val_local++; - OCD_TH_actual = (OCD_TH_val_local + 1) * 375; - } - - DEBUG_ECHOLNPGM("over_current_threshold specified: ", over_current_threshold); - if (!(sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT)) echo_oct_used((STALL_TH_val_local + 1) * 31.25, true); - echo_oct_used((OCD_TH_val_local + 1) * 375, false); - - #define SET_OVER_CURRENT(Q) do { stepper##Q.SetParam(L6470_STALL_TH, STALL_TH_val_local); stepper##Q.SetParam(L6470_OCD_TH, OCD_TH_val_local);} while (0) - - for (j = 0; j < driver_count; j++) { - set_param(axis_index[j], L6470_STALL_TH, STALL_TH_val_local); - set_param(axis_index[j], L6470_OCD_TH, OCD_TH_val_local); - } - } - else { - // only get & print the OVER_CURRENT values from one of the drivers - STALL_TH_val_local = get_param(axis_index[0], L6470_STALL_TH); - OCD_TH_val_local = get_param(axis_index[0], L6470_OCD_TH); - - if (!(sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT)) echo_oct_used((STALL_TH_val_local + 1) * 31.25, true); - echo_oct_used((OCD_TH_val_local + 1) * 375, false); - } // over_current_threshold - - for (j = 0; j < driver_count; j++) { // set all drivers on axis the same - set_param(axis_index[j], L6470_STALL_TH, STALL_TH_val_local); - set_param(axis_index[j], L6470_OCD_TH, OCD_TH_val_local); - } - - OCD_TH_val = OCD_TH_val_local; // force compiler to update the main routine's copy - STALL_TH_val = STALL_TH_val_local; // force compiler to update the main routine's copy - } // end of overcurrent - - // - // Feedrate - // - - final_feedrate = parser.floatval('F'); - if (final_feedrate == 0) { - static constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE; - const uint8_t num_feedrates = COUNT(default_max_feedrate); - for (j = 0; j < num_feedrates; j++) { - if (AXIS_CHAR(j) == axis_mon[0][0]) { - final_feedrate = default_max_feedrate[j]; - break; - } - } - if (j == 3 && num_feedrates > 4) { // have more than one extruder feedrate - uint8_t extruder_num = axis_mon[0][1] - '0'; - if (j <= num_feedrates - extruder_num) // have a feedrate specifically for this extruder - final_feedrate = default_max_feedrate[j + extruder_num]; - else - final_feedrate = default_max_feedrate[3]; // use E0 feedrate for this extruder - } - final_feedrate *= 60; // convert to mm/minute - } // end of feedrate - - return false; // FALSE indicates no user input problems -} - -void L64XX_Marlin::say_axis(const L64XX_axis_t axis, const uint8_t label/*=true*/) { - if (label) SERIAL_ECHOPGM("AXIS:"); - const char * const str = L64xxManager.index_to_axis[axis]; - SERIAL_CHAR(' ', str[0], str[1], ' '); -} - -#if ENABLED(L6470_CHITCHAT) - - // Assumes status bits have been inverted - void L64XX_Marlin::error_status_decode(const uint16_t status, const L64XX_axis_t axis, - const uint16_t _status_axis_th_sd, const uint16_t _status_axis_th_wrn, - const uint16_t _status_axis_step_loss_a, const uint16_t _status_axis_step_loss_b, - const uint16_t _status_axis_ocd, const uint8_t _status_axis_layout - ) { - say_axis(axis); - DEBUG_ECHOPGM(" THERMAL: "); - DEBUG_ECHOPGM_P((status & _status_axis_th_sd) ? PSTR("SHUTDOWN") : (status & _status_axis_th_wrn) ? PSTR("WARNING ") : PSTR("OK ")); - DEBUG_ECHOPGM(" OVERCURRENT: "); - echo_yes_no((status & _status_axis_ocd) != 0); - if (!(_status_axis_layout == L6474_STATUS_LAYOUT)) { // L6474 doesn't have these bits - DEBUG_ECHOPGM(" STALL: "); - echo_yes_no((status & (_status_axis_step_loss_a | _status_axis_step_loss_b)) != 0); - } - DEBUG_EOL(); - } - -#endif - -////////////////////////////////////////////////////////////////////////////////////////////////// -//// -//// MONITOR_L6470_DRIVER_STATUS routines -//// -////////////////////////////////////////////////////////////////////////////////////////////////// - -#if ENABLED(MONITOR_L6470_DRIVER_STATUS) - - bool L64XX_Marlin::monitor_paused = false; // Flag to skip monitor during M122, M906, M916, M917, M918, etc. - - struct L6470_driver_data { - L64XX_axis_t driver_index; - uint32_t driver_status; - uint8_t is_otw; - uint8_t otw_counter; - uint8_t is_ot; - uint8_t is_hi_Z; - uint8_t com_counter; - }; - - L6470_driver_data driver_L6470_data[] = { - #if AXIS_IS_L64XX(X) - { X, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Y) - { Y, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Z) - { Z, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(I) - { I, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(J) - { J, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(K) - { K, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(X2) - { X2, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Y2) - { Y2, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Z2) - { Z2, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Z3) - { Z3, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(Z4) - { Z4, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E0) - { E0, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E1) - { E1, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E2) - { E2, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E3) - { E3, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E4) - { E4, 0, 0, 0, 0, 0, 0 }, - #endif - #if AXIS_IS_L64XX(E5) - { E5, 0, 0, 0, 0, 0, 0 } - #endif - #if AXIS_IS_L64XX(E6) - { E6, 0, 0, 0, 0, 0, 0 } - #endif - #if AXIS_IS_L64XX(E7) - { E7, 0, 0, 0, 0, 0, 0 } - #endif - }; - - void L64XX_Marlin::append_stepper_err(char* &p, const uint8_t stepper_index, const char * const err/*=nullptr*/) { - PGM_P const str = (PGM_P)pgm_read_ptr(&index_to_axis[stepper_index]); - p += sprintf_P(p, PSTR("Stepper %c%c "), pgm_read_byte(&str[0]), pgm_read_byte(&str[1])); - if (err) p += sprintf_P(p, err); - } - - void L64XX_Marlin::monitor_update(L64XX_axis_t stepper_index) { - if (spi_abort) return; // don't do anything if set_directions() has occurred - const L64XX_shadow_t &sh = shadow; - get_status(stepper_index); // get stepper status and details - uint16_t status = sh.STATUS_AXIS; - uint8_t kval_hold, tval; - char temp_buf[120], *p = temp_buf; - uint8_t j; - for (j = 0; j < L64XX::chain[0]; j++) // find the table for this stepper - if (driver_L6470_data[j].driver_index == stepper_index) break; - - driver_L6470_data[j].driver_status = status; - uint16_t _status = ~status; // all error bits are active low - - if (status == 0 || status == 0xFFFF) { // com problem - if (driver_L6470_data[j].com_counter == 0) { // warn user when it first happens - driver_L6470_data[j].com_counter++; - append_stepper_err(p, stepper_index, PSTR(" - communications lost\n")); - DEBUG_ECHO(temp_buf); - } - else { - driver_L6470_data[j].com_counter++; - if (driver_L6470_data[j].com_counter > 240) { // remind of com problem about every 2 minutes - driver_L6470_data[j].com_counter = 1; - append_stepper_err(p, stepper_index, PSTR(" - still no communications\n")); - DEBUG_ECHO(temp_buf); - } - } - } - else { - if (driver_L6470_data[j].com_counter) { // comms re-established - driver_L6470_data[j].com_counter = 0; - append_stepper_err(p, stepper_index, PSTR(" - communications re-established\n.. setting all drivers to default values\n")); - DEBUG_ECHO(temp_buf); - init_to_defaults(); - } - else { - // no com problems - do the usual checks - if (_status & sh.L6470_ERROR_MASK) { - append_stepper_err(p, stepper_index); - - if (status & STATUS_HIZ) { // The driver has shut down. HiZ is active high - driver_L6470_data[j].is_hi_Z = true; - p += sprintf_P(p, PSTR("%cIS SHUT DOWN"), ' '); - //if (_status & sh.STATUS_AXIS_TH_SD) { // strange - TH_SD never seems to go active, must be implied by the HiZ and TH_WRN - if (_status & sh.STATUS_AXIS_TH_WRN) { // over current shutdown - p += sprintf_P(p, PSTR("%cdue to over temperature"), ' '); - driver_L6470_data[j].is_ot = true; - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // L6474 - tval = get_param(stepper_index, L6474_TVAL) - 2 * KVAL_HOLD_STEP_DOWN; - set_param(stepper_index, L6474_TVAL, tval); // reduce TVAL - p += sprintf_P(p, PSTR(" - TVAL reduced by %d to %d mA"), uint16_t (2 * KVAL_HOLD_STEP_DOWN * sh.AXIS_STALL_CURRENT_CONSTANT_INV), uint16_t ((tval + 1) * sh.AXIS_STALL_CURRENT_CONSTANT_INV)); // let user know - } - else { - kval_hold = get_param(stepper_index, L6470_KVAL_HOLD) - 2 * KVAL_HOLD_STEP_DOWN; - set_param(stepper_index, L6470_KVAL_HOLD, kval_hold); // reduce KVAL_HOLD - p += sprintf_P(p, PSTR(" - KVAL_HOLD reduced by %d to %d"), 2 * KVAL_HOLD_STEP_DOWN, kval_hold); // let user know - } - } - else - driver_L6470_data[j].is_ot = false; - } - else { - driver_L6470_data[j].is_hi_Z = false; - - if (_status & sh.STATUS_AXIS_TH_WRN) { // have an over temperature warning - driver_L6470_data[j].is_otw = true; - driver_L6470_data[j].otw_counter++; - kval_hold = get_param(stepper_index, L6470_KVAL_HOLD); - if (driver_L6470_data[j].otw_counter > 4) { // otw present for 2 - 2.5 seconds, reduce KVAL_HOLD - driver_L6470_data[j].otw_counter = 0; - driver_L6470_data[j].is_otw = true; - if (sh.STATUS_AXIS_LAYOUT == L6474_STATUS_LAYOUT) { // L6474 - tval = get_param(stepper_index, L6474_TVAL) - KVAL_HOLD_STEP_DOWN; - set_param(stepper_index, L6474_TVAL, tval); // reduce TVAL - p += sprintf_P(p, PSTR(" - TVAL reduced by %d to %d mA"), uint16_t (KVAL_HOLD_STEP_DOWN * sh.AXIS_STALL_CURRENT_CONSTANT_INV), uint16_t ((tval + 1) * sh.AXIS_STALL_CURRENT_CONSTANT_INV)); // let user know - } - else { - kval_hold = get_param(stepper_index, L6470_KVAL_HOLD) - KVAL_HOLD_STEP_DOWN; - set_param(stepper_index, L6470_KVAL_HOLD, kval_hold); // reduce KVAL_HOLD - p += sprintf_P(p, PSTR(" - KVAL_HOLD reduced by %d to %d"), KVAL_HOLD_STEP_DOWN, kval_hold); // let user know - } - } - else if (driver_L6470_data[j].otw_counter) - p += sprintf_P(p, PSTR("%c- thermal warning"), ' '); // warn user - } - } - - #if ENABLED(L6470_STOP_ON_ERROR) - if (_status & (sh.STATUS_AXIS_UVLO | sh.STATUS_AXIS_TH_WRN | sh.STATUS_AXIS_TH_SD)) - kill(temp_buf); - #endif - - #if ENABLED(L6470_CHITCHAT) - if (_status & sh.STATUS_AXIS_OCD) - p += sprintf_P(p, PSTR("%c over current"), ' '); - - if (_status & (sh.STATUS_AXIS_STEP_LOSS_A | sh.STATUS_AXIS_STEP_LOSS_B)) - p += sprintf_P(p, PSTR("%c stall"), ' '); - - if (_status & sh.STATUS_AXIS_UVLO) - p += sprintf_P(p, PSTR("%c under voltage lock out"), ' '); - - p += sprintf_P(p, PSTR("%c\n"), ' '); - #endif - - DEBUG_ECHOLN(temp_buf); // print the error message - } - else { - driver_L6470_data[j].is_ot = false; - driver_L6470_data[j].otw_counter = 0; //clear out warning indicators - driver_L6470_data[j].is_otw = false; - } // end usual checks - - } // comms established but have errors - } // comms re-established - } // end monitor_update() - - - void L64XX_Marlin::monitor_driver() { - static millis_t next_cOT = 0; - if (ELAPSED(millis(), next_cOT)) { - next_cOT = millis() + 500; - - if (!monitor_paused) { // Skip during M122, M906, M916, M917 or M918 (could steal status result from test) - - spi_active = true; // Tell set_directions() a series of SPI transfers is underway - - #if AXIS_IS_L64XX(X) - monitor_update(X); - #endif - #if AXIS_IS_L64XX(Y) - monitor_update(Y); - #endif - #if AXIS_IS_L64XX(Z) - monitor_update(Z); - #endif - #if AXIS_IS_L64XX(I) - monitor_update(I); - #endif - #if AXIS_IS_L64XX(J) - monitor_update(J); - #endif - #if AXIS_IS_L64XX(K) - monitor_update(K); - #endif - #if AXIS_IS_L64XX(X2) - monitor_update(X2); - #endif - #if AXIS_IS_L64XX(Y2) - monitor_update(Y2); - #endif - #if AXIS_IS_L64XX(Z2) - monitor_update(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - monitor_update(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - monitor_update(Z4); - #endif - #if AXIS_IS_L64XX(E0) - monitor_update(E0); - #endif - #if AXIS_IS_L64XX(E1) - monitor_update(E1); - #endif - #if AXIS_IS_L64XX(E2) - monitor_update(E2); - #endif - #if AXIS_IS_L64XX(E3) - monitor_update(E3); - #endif - #if AXIS_IS_L64XX(E4) - monitor_update(E4); - #endif - #if AXIS_IS_L64XX(E5) - monitor_update(E5); - #endif - #if AXIS_IS_L64XX(E6) - monitor_update(E6); - #endif - #if AXIS_IS_L64XX(E7) - monitor_update(E7); - #endif - - if (TERN0(L6470_DEBUG, report_L6470_status)) DEBUG_EOL(); - - spi_active = false; // done with all SPI transfers - clear handshake flags - spi_abort = false; - } - } - } - -#endif // MONITOR_L6470_DRIVER_STATUS - -#endif // HAS_L64XX diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.h b/Marlin/src/libs/L64XX/L64XX_Marlin.h deleted file mode 100644 index e8d8498ac7a6..000000000000 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 "../../inc/MarlinConfig.h" - -#include -#if !(L6470_LIBRARY_VERSION >= 0x000800) - #error 'L6470_LIBRARY_VERSION 0x000800 or later required' -#endif - -#define L6470_GETPARAM(P,Q) stepper##Q.GetParam(P) - -#define dSPIN_STEP_CLOCK 0x58 -#define dSPIN_STEP_CLOCK_FWD dSPIN_STEP_CLOCK -#define dSPIN_STEP_CLOCK_REV dSPIN_STEP_CLOCK+1 -#define HAS_L64XX_EXTRUDER (AXIS_IS_L64XX(E0) || AXIS_IS_L64XX(E1) || AXIS_IS_L64XX(E2) || AXIS_IS_L64XX(E3) || AXIS_IS_L64XX(E4) || AXIS_IS_L64XX(E5) || AXIS_IS_L64XX(E6) || AXIS_IS_L64XX(E7)) - -#define _EN_ITEM(N) , E##N -enum L64XX_axis_t : uint8_t { MAIN_AXIS_NAMES, X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM), MAX_L64XX }; -#undef _EN_ITEM - -class L64XX_Marlin : public L64XXHelper { -public: - static PGM_P const index_to_axis[MAX_L64XX]; - - static const uint8_t index_to_dir[MAX_L64XX]; - - static uint8_t dir_commands[MAX_L64XX]; - - // Flags to guarantee graceful switch if stepper interrupts L6470 SPI transfer - static volatile uint8_t spi_abort; - static uint8_t spi_active; - - L64XX_Marlin() {} - - static void init(); - static void init_to_defaults(); - - static uint16_t get_stepper_status(L64XX &st); - - static uint16_t get_status(const L64XX_axis_t axis); - - static uint32_t get_param(const L64XX_axis_t axis, const uint8_t param); - - static void set_param(const L64XX_axis_t axis, const uint8_t param, const uint32_t value); - - //static void send_command(const L64XX_axis_t axis, uint8_t command); - - static uint8_t get_user_input(uint8_t &driver_count, L64XX_axis_t axis_index[3], char axis_mon[3][3], - float &position_max, float &position_min, float &final_feedrate, uint8_t &kval_hold, - uint8_t over_current_flag, uint8_t &OCD_TH_val, uint8_t &STALL_TH_val, uint16_t &over_current_threshold); - - static void transfer(uint8_t L6470_buf[], const uint8_t length); - - static void say_axis(const L64XX_axis_t axis, const uint8_t label=true); - #if ENABLED(L6470_CHITCHAT) - static void error_status_decode( - const uint16_t status, const L64XX_axis_t axis, - const uint16_t _status_axis_th_sd, const uint16_t _status_axis_th_wrn, - const uint16_t _status_axis_step_loss_a, const uint16_t _status_axis_step_loss_b, - const uint16_t _status_axis_ocd, const uint8_t _status_axis_layout - ); - #else - FORCE_INLINE static void error_status_decode( - const uint16_t, const L64XX_axis_t, - const uint16_t, const uint16_t, - const uint16_t, const uint16_t, - const uint16_t, const uint8_t - ){} - #endif - - // ~40 bytes SRAM to simplify status decode routines - typedef struct { - uint8_t STATUS_AXIS_LAYOUT; // Copy of L6470_status_layout - uint8_t AXIS_OCD_TH_MAX; // Size of OCD_TH field - uint8_t AXIS_STALL_TH_MAX; // Size of STALL_TH field - float AXIS_OCD_CURRENT_CONSTANT_INV; // mA per count - float AXIS_STALL_CURRENT_CONSTANT_INV; // mA per count - uint8_t L6470_AXIS_CONFIG, // Address of the CONFIG register - L6470_AXIS_STATUS; // Address of the STATUS register - uint16_t L6470_ERROR_MASK, // STATUS_UVLO | STATUS_TH_WRN | STATUS_TH_SD | STATUS_OCD | STATUS_STEP_LOSS_A | STATUS_STEP_LOSS_B - L6474_ERROR_MASK, // STATUS_UVLO | STATUS_TH_WRN | STATUS_TH_SD | STATUS_OCD - STATUS_AXIS_RAW, // Copy of status register contents - STATUS_AXIS, // Copy of status register contents but with all error bits active low - STATUS_AXIS_OCD, // Overcurrent detected bit position - STATUS_AXIS_SCK_MOD, // Step clock mode is active bit position - STATUS_AXIS_STEP_LOSS_A, // Stall detected on A bridge bit position - STATUS_AXIS_STEP_LOSS_B, // Stall detected on B bridge bit position - STATUS_AXIS_TH_SD, // Thermal shutdown bit position - STATUS_AXIS_TH_WRN, // Thermal warning bit position - STATUS_AXIS_UVLO, // Undervoltage lockout is active bit position - STATUS_AXIS_WRONG_CMD, // Last command not valid bit position - STATUS_AXIS_CMD_ERR, // Command error bit position - STATUS_AXIS_NOTPERF_CMD; // Last command not performed bit position - } L64XX_shadow_t; - - static L64XX_shadow_t shadow; - - #if ENABLED(MONITOR_L6470_DRIVER_STATUS) - static bool monitor_paused; - static void pause_monitor(const bool p) { monitor_paused = p; } - static void monitor_update(L64XX_axis_t stepper_index); - static void monitor_driver(); - #else - static void pause_monitor(const bool) {} - #endif - -//protected: - // L64XXHelper methods - static void spi_init(); - static uint8_t transfer_single(uint8_t data, int16_t ss_pin); - static uint8_t transfer_chain(uint8_t data, int16_t ss_pin, uint8_t chain_position); - -private: - static void append_stepper_err(char* &p, const uint8_t stepper_index, const char * const err=nullptr); - -}; - -void echo_yes_no(const bool yes); - -extern L64XX_Marlin L64xxManager; diff --git a/Marlin/src/libs/L64XX/README.md b/Marlin/src/libs/L64XX/README.md deleted file mode 100644 index d28bec5e67f5..000000000000 --- a/Marlin/src/libs/L64XX/README.md +++ /dev/null @@ -1,98 +0,0 @@ -### L64XX Stepper Driver - -*Arduino-L6470* library revision 0.8.0 or above is required. - -This software can be used with the L6470, L6474, L6480 and the powerSTEP01 (collectively referred to as "L64xx" from now on). Different drivers can be mixed within a system. - -These devices use voltage PWMs to drive the stepper phases. On the L6474 the phase current is controlled by the `TVAL` register. On all the other drivers the phase current is indirectly controlled via the `KVAL_HOLD` register which scales the PWM duty cycle. - -This software assumes that all drivers are in one SPI daisy chain. - -### Hardware Setup - -- MOSI from controller tied to SDI on the first device - -- SDO of the first device is tied to SDI of the next device - -- SDO of the last device is tied to MISO of the controller - -- All devices share the same `SCK_PIN` and `SS_PIN` pins. The user must supply a macro to control the `RESET_PIN`(s). - -- Each L6470 passes the data it saw on its SDI to its neighbor on the **NEXT** SPI cycle (8 bit delay). - -- Each L6470 acts on the **last** SPI data it saw when the `SS_PIN` **goes high**. - -The L6474 uses the standard STEP DIR interface. Phase currents are changed in response to step pulses. The direction is set by the DIR pin. Instead of an ENA pin, stepper power is controlled with SPI commands. - -The other drivers operate in `STEP_CLOCK` mode. In this mode the Direction / Enable functions are done with SPI commands and the phase currents are changed in response to STEP pulses. - -### Hardware / Software Interaction - -Except for the L6474, powering up a stepper and setting the direction are done by the same command. You can't do one without the other. - -**All** directions are set **every time** a new block is popped off the queue by the stepper ISR. - -When setting direction, SPI transfers are minimized by using arrays and a specialized SPI method. *Arduino-L6470* library calls are not used. For N L64xx drivers, this results in N bytes transferred. If library calls were used then N2 bytes would be sent. - -### Power-up (Reset) Sequence - -- Stepper objects are instantiated before the `setup()` entry point is reached. - -- In `setup()` (before stepper drivers are initialized) the `L6470_init()` method is called to do the following: - - - If present, pulse the hardware reset pin. - - - Populate the `L6470_chain` array, which maps positions in the SPI stream to commands/data for L64XX stepper drivers. - - - Initialize the L64XX Software SPI pin states. - - - Initialize L64XX drivers. They may be reset later by a call to `L6470_init_to_defaults()`. - -The steppers are **NOT** powered up (enabled) during this sequence. - -### `L6470_chain` array - -This array is used by all routines that transmit SPI data. For a chain with N devices, the array contains: - -Index|Value ------|----- -0|Number of drivers in chain -1|Axis index of the first device in the chain (closest to MOSI) -...| -N|Axis index of the last device chain (closest to MISO) - -### Set Direction and Enable - -The `DIR_WRITE` macros for the L64xx drivers are written so that the standard X, Y, Z and extruder logic used by the `set_directions()` routine is not altered. These macros write the correct forward/reverse command to the corresponding location in the array `L6470_dir_commands`. On the L6474 the array the command used just enables the stepper because direction is set by the DIR pin. - -At the end of the `set_directions()` routine, the array `L6470_chain` is used to grab the corresponding direction/enable commands out of the array `L6470_dir_commands` and put them in the correct sequence in the array `L6470_buf`. Array `L6470_buf` is then passed to the **`void`** `L6470_Transfer` function which actually sends the data to the devices. - -### Utilities, etc. - -The **absolute position** registers should accurately reflect Marlin’s stepper position counts. They are set to zero during initialization. `G28` sets them to the Marlin counts for the corresponding axis after homing. NOTE: These registers are often the negative of the Marlin counts. This is because the Marlin counts reflect the logical direction while the registers reflect the stepper direction. The register contents are displayed via the `M114 D` command. - -The `L6470_monitor` feature reads the status of each device every half second. It will report if there are any error conditions present or if communications has been lost/restored. The `KVAL_HOLD` value is reduced every 2 – 2.5 seconds if the thermal warning or thermal shutdown conditions are present. - -**M122** displays the settings of most of the bits in the status register plus a couple of other items. - -**M906** can be used to set the `KVAL_HOLD` register (`TVAL` on L6474) one driver at a time. If a setting is not included with the command then the contents of the registers that affect the phase current/voltage are displayed. - -**M916, M917 & M918** - -These utilities are used to tune the system. They can get you in the ballpark for acceptable jerk, acceleration, top speed and `KVAL_HOLD` settings (`TVAL` on L6474). In general they seem to provide an overly optimistic `KVAL_HOLD` (`TVAL`) setting because of the lag between setting `KVAL_HOLD` (`TVAL`) and the driver reaching final temperature. Enabling the `L6470_monitor` feature during prints will provide the **final useful setting**. - -The amount of power needed to move the stepper without skipping steps increases as jerk, acceleration, top speed, and micro-steps increase. The power dissipated by the driver increases as the power to the stepper increases. The net result is a balancing act between jerk, acceleration, top speed, micro-steps, and power dissipated by the driver. - -**M916** - Increases `KVAL_HOLD` (`TVAL`) while moving one axis until a thermal warning is generated. This routine is also useful for determining the approximate `KVAL_HOLD` (`TVAL`) where the stepper stops losing steps. The sound will get noticeably quieter as it stops losing steps. - -**M917** - Find minimum current thresholds. This is accomplished by doing the following steps while moving an axis: - -1. Decrease OCD current until overcurrent error. - -2. Increase OCD until overcurrent error goes away. - -3. Decrease stall threshold until stall error (not available on the L6474). - -4. Increase stall until stall error goes away (not available on the L6474). - -**M918** - Increase speed until error or max feedrate achieved. diff --git a/Marlin/src/libs/MAX31865.cpp b/Marlin/src/libs/MAX31865.cpp index c042504cf872..3fe069464463 100644 --- a/Marlin/src/libs/MAX31865.cpp +++ b/Marlin/src/libs/MAX31865.cpp @@ -133,13 +133,13 @@ SPISettings MAX31865::spiConfig = SPISettings( /** * Initialize the SPI interface and set the number of RTD wires used * - * @param wires The number of wires in enum format. Can be MAX31865_2WIRE, MAX31865_3WIRE, or MAX31865_4WIRE. - * @param zero The resistance of the RTD at 0 degC, in ohms. - * @param ref The resistance of the reference resistor, in ohms. - * @param wire The resistance of the wire connecting the sensor to the RTD, in ohms. + * @param wires The number of wires as an enum: MAX31865_2WIRE, MAX31865_3WIRE, or MAX31865_4WIRE. + * @param zero_res The resistance of the RTD at 0°C, in ohms. + * @param ref_res The resistance of the reference resistor, in ohms. + * @param wire_res The resistance of the wire connecting the sensor to the RTD, in ohms. */ -void MAX31865::begin(max31865_numwires_t wires, float zero_res, float ref_res, float wire_res) { - zeroRes = zero_res; +void MAX31865::begin(max31865_numwires_t wires, const_float_t zero_res, const_float_t ref_res, const_float_t wire_res) { + resNormalizer = 100.0f / zero_res; // reciprocal of resistance, scaled by 100 refRes = ref_res; wireRes = wire_res; @@ -437,42 +437,61 @@ float MAX31865::temperature() { * * @return Temperature in C */ -float MAX31865::temperature(uint16_t adc_val) { +float MAX31865::temperature(const uint16_t adc_val) { return temperature(((adc_val) * RECIPROCAL(32768.0f)) * refRes - wireRes); } /** * Calculate the temperature in C from the RTD resistance. - * Uses the technique outlined in this PDF: - * http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf * * @param rtd_res the resistance value in ohms - * @return the temperature in degC + * @return the temperature in °C */ float MAX31865::temperature(float rtd_res) { + + rtd_res *= resNormalizer; // normalize to 100 ohm + + // Constants for calculating temperature from the measured RTD resistance. + // http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf + constexpr float RTD_Z1 = -0.0039083, + RTD_Z2 = +1.758480889e-5, + RTD_Z3 = -2.31e-8, + RTD_Z4 = -1.155e-6; + + // Callender-Van Dusen equation float temp = (RTD_Z1 + sqrt(RTD_Z2 + (RTD_Z3 * rtd_res))) * RECIPROCAL(RTD_Z4); - // From the PDF... // // The previous equation is valid only for temperatures of 0°C and above. // The equation for RRTD(t) that defines negative temperature behavior is a // fourth-order polynomial (after expanding the third term) and is quite // impractical to solve for a single expression of temperature as a function - // of resistance. + // of resistance. So here we use a Linear Approximation instead. // if (temp < 0) { - rtd_res = (rtd_res / zeroRes) * 100; // normalize to 100 ohm - float rpoly = rtd_res; + #ifndef MAX31865_APPROX + #define MAX31865_APPROX 5 + #endif + + constexpr float RTD_C[] = { + #if MAX31865_APPROX == 5 + -242.02, +2.2228, +2.5859e-3, -4.8260e-6, -2.8183e-8, +1.5243e-10 + #elif MAX31865_APPROX == 4 + -241.96, +2.2163, +2.8541e-3, -9.9121e-6, -1.7152e-8 + #elif MAX31865_APPROX == 3 + -242.09, +2.2276, +2.5178e-3, -5.8620e-6 + #else + -242.97, +2.2838, +1.4727e-3 + #endif + }; - temp = -242.02 + (2.2228 * rpoly); - rpoly *= rtd_res; // square - temp += 2.5859e-3 * rpoly; - rpoly *= rtd_res; // ^3 - temp -= 4.8260e-6 * rpoly; - rpoly *= rtd_res; // ^4 - temp -= 2.8183e-8 * rpoly; - rpoly *= rtd_res; // ^5 - temp += 1.5243e-10 * rpoly; + float rpoly = rtd_res; + temp = RTD_C[0]; + temp += rpoly * RTD_C[1]; + rpoly *= rtd_res; temp += rpoly * RTD_C[2]; + if (MAX31865_APPROX >= 3) { rpoly *= rtd_res; temp += rpoly * RTD_C[3]; } + if (MAX31865_APPROX >= 4) { rpoly *= rtd_res; temp += rpoly * RTD_C[4]; } + if (MAX31865_APPROX >= 5) { rpoly *= rtd_res; temp += rpoly * RTD_C[5]; } } return temp; diff --git a/Marlin/src/libs/MAX31865.h b/Marlin/src/libs/MAX31865.h index baea455485d4..3e9b0c139ff6 100644 --- a/Marlin/src/libs/MAX31865.h +++ b/Marlin/src/libs/MAX31865.h @@ -45,7 +45,7 @@ #include "../inc/MarlinConfig.h" #include "../HAL/shared/Delay.h" -#include HAL_PATH(../HAL, MarlinSPI.h) +#include HAL_PATH(.., MarlinSPI.h) #define MAX31865_CONFIG_REG 0x00 #define MAX31865_CONFIG_BIAS 0x80 @@ -73,13 +73,6 @@ #define MAX31865_FAULT_RTDINLOW 0x08 // D3 #define MAX31865_FAULT_OVUV 0x04 // D2 -// http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf -// constants for calculating temperature from the measured RTD resistance. -#define RTD_Z1 -0.0039083 -#define RTD_Z2 0.00001758480889 -#define RTD_Z3 -0.0000000231 -#define RTD_Z4 -0.000001155 - typedef enum max31865_numwires { MAX31865_2WIRE = 0, MAX31865_3WIRE = 1, @@ -103,7 +96,7 @@ class MAX31865 { uint16_t spiDelay; - float zeroRes, refRes, wireRes; + float resNormalizer, refRes, wireRes; #if ENABLED(MAX31865_USE_READ_ERROR_DETECTION) millis_t lastReadStamp = 0; @@ -160,7 +153,7 @@ class MAX31865 { int8_t spi_clk); #endif - void begin(max31865_numwires_t wires, float zero_res, float ref_res, float wire_res); + void begin(max31865_numwires_t wires, const_float_t zero_res, const_float_t ref_res, const_float_t wire_res); uint8_t readFault(); void clearFault(); @@ -168,6 +161,6 @@ class MAX31865 { uint16_t readRaw(); float readResistance(); float temperature(); - float temperature(uint16_t adc_val); + float temperature(const uint16_t adc_val); float temperature(float rtd_res); }; 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/libs/W25Qxx.h b/Marlin/src/libs/W25Qxx.h index 778463477d82..55490b025256 100644 --- a/Marlin/src/libs/W25Qxx.h +++ b/Marlin/src/libs/W25Qxx.h @@ -23,7 +23,7 @@ #include -#include HAL_PATH(../HAL, MarlinSPI.h) +#include HAL_PATH(.., MarlinSPI.h) #define W25X_WriteEnable 0x06 #define W25X_WriteDisable 0x04 diff --git a/Marlin/src/libs/buzzer.cpp b/Marlin/src/libs/buzzer.cpp index a3c838ebc0a3..1e2f23c5fdef 100644 --- a/Marlin/src/libs/buzzer.cpp +++ b/Marlin/src/libs/buzzer.cpp @@ -48,7 +48,7 @@ void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) { if (!ui.sound_on) return; while (buffer.isFull()) { tick(); - thermalManager.manage_heater(); + thermalManager.task(); } tone_t tone = { duration, frequency }; buffer.enqueue(tone); diff --git a/Marlin/src/libs/buzzer.h b/Marlin/src/libs/buzzer.h index b1c286a66222..cd86e7e7ecf7 100644 --- a/Marlin/src/libs/buzzer.h +++ b/Marlin/src/libs/buzzer.h @@ -115,21 +115,20 @@ extern Buzzer buzzer; // Buzz directly via the BEEPER pin tone queue - #define BUZZ(d,f) buzzer.tone(d, f) + #define BUZZ(V...) buzzer.tone(V) -#elif HAS_BUZZER +#elif USE_MARLINUI_BUZZER - // Buzz indirectly via the MarlinUI instance - #define BUZZ(d,f) ui.buzz(d,f) - #include "../lcd/marlinui.h" + // Use MarlinUI for a buzzer on the LCD + #define BUZZ(V...) ui.buzz(V) #else // No buzz capability - #define BUZZ(d,f) NOOP + #define BUZZ(...) NOOP #endif -#define ERR_BUZZ() BUZZ(400, 40); -#define OKAY_BUZZ() do{ BUZZ(100, 659); BUZZ(10, 0); BUZZ(100, 698); }while(0) -#define DONE_BUZZ(OK) do{ if (OK) OKAY_BUZZ(); else ERR_BUZZ(); }while(0) +#define ERR_BUZZ() BUZZ(400, 40) +#define OKAY_BUZZ() do{ BUZZ(100, 659); BUZZ(10); BUZZ(100, 698); }while(0) +#define DONE_BUZZ(ok) do{ if (ok) OKAY_BUZZ(); else ERR_BUZZ(); }while(0) diff --git a/Marlin/src/libs/duration_t.h b/Marlin/src/libs/duration_t.h index df2c9cd099c1..69a648441feb 100644 --- a/Marlin/src/libs/duration_t.h +++ b/Marlin/src/libs/duration_t.h @@ -151,7 +151,9 @@ struct duration_t { * 123456789 (strlen) * 12'34 * 99:59 - * 11d 12:33 + * 123:45 + * 1d 12:33 + * 9999d 12:33 */ uint8_t toDigital(char *buffer, bool with_days=false) const { const uint16_t h = uint16_t(this->hour()), @@ -159,7 +161,7 @@ struct duration_t { if (with_days) { const uint16_t d = this->day(); sprintf_P(buffer, PSTR("%hud %02hu:%02hu"), d, h % 24, m); // 1d 23:45 - return d >= 10 ? 9 : 8; + return strlen_P(buffer); } else if (!h) { const uint16_t s = uint16_t(this->second() % 60UL); diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index 4ca8fa2cae1e..575e74a81472 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -161,7 +161,7 @@ Nozzle nozzle; void Nozzle::clean(const uint8_t &pattern, const uint8_t &strokes, const_float_t radius, const uint8_t &objects, const uint8_t cleans) { xyz_pos_t start[HOTENDS] = NOZZLE_CLEAN_START_POINT, end[HOTENDS] = NOZZLE_CLEAN_END_POINT, middle[HOTENDS] = NOZZLE_CLEAN_CIRCLE_MIDDLE; - const uint8_t arrPos = ANY(SINGLENOZZLE, MIXING_EXTRUDER) ? 0 : active_extruder; + const uint8_t arrPos = EITHER(SINGLENOZZLE, MIXING_EXTRUDER) ? 0 : active_extruder; #if NOZZLE_CLEAN_MIN_TEMP > 20 if (thermalManager.degTargetHotend(arrPos) < NOZZLE_CLEAN_MIN_TEMP) { diff --git a/Marlin/src/libs/numtostr.cpp b/Marlin/src/libs/numtostr.cpp index f4d47983d225..c28d1246d693 100644 --- a/Marlin/src/libs/numtostr.cpp +++ b/Marlin/src/libs/numtostr.cpp @@ -25,7 +25,7 @@ #include "../inc/MarlinConfigPre.h" #include "../core/utility.h" -char conv[8] = { 0 }; +char conv[9] = { 0 }; #define DIGIT(n) ('0' + (n)) #define DIGIMOD(n, f) DIGIT((n)/(f) % 10) @@ -36,11 +36,11 @@ char conv[8] = { 0 }; // Format uint8_t (0-100) as rj string with 123% / _12% / __1% format const char* pcttostrpctrj(const uint8_t i) { - conv[3] = RJDIGIT(i, 100); - conv[4] = RJDIGIT(i, 10); - conv[5] = DIGIMOD(i, 1); - conv[6] = '%'; - return &conv[3]; + conv[4] = RJDIGIT(i, 100); + conv[5] = RJDIGIT(i, 10); + conv[6] = DIGIMOD(i, 1); + conv[7] = '%'; + return &conv[4]; } // Convert uint8_t (0-255) to a percentage, format as above @@ -50,95 +50,89 @@ const char* ui8tostr4pctrj(const uint8_t i) { // Convert unsigned 8bit int to string 123 format const char* ui8tostr3rj(const uint8_t i) { - conv[4] = RJDIGIT(i, 100); - conv[5] = RJDIGIT(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[4]; + conv[5] = RJDIGIT(i, 100); + conv[6] = RJDIGIT(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[5]; } // Convert uint8_t to string with 12 format const char* ui8tostr2(const uint8_t i) { - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[5]; + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[6]; } // Convert signed 8bit int to rj string with 123 or -12 format const char* i8tostr3rj(const int8_t x) { int xx = x; - conv[4] = MINUSOR(xx, RJDIGIT(xx, 100)); - conv[5] = RJDIGIT(xx, 10); - conv[6] = DIGIMOD(xx, 1); - return &conv[4]; + conv[5] = MINUSOR(xx, RJDIGIT(xx, 100)); + conv[6] = RJDIGIT(xx, 10); + conv[7] = DIGIMOD(xx, 1); + return &conv[5]; } #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, 1000); + conv[5] = DIGIMOD(xx, 100); + conv[6] = '.'; + conv[7] = DIGIMOD(xx, 10); + return &conv[4]; + } + else { conv[4] = DIGIMOD(xx, 100); conv[5] = '.'; 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); + conv[7] = RJDIGIT(xx, 1); return &conv[4]; } - else { - conv[3] = DIGIMOD(xx, 100); - conv[4] = '.'; - conv[5] = DIGIMOD(xx, 10); - conv[6] = RJDIGIT(xx, 1); - return &conv[3]; - } } #endif // Convert unsigned 16bit int to string 12345 format const char* ui16tostr5rj(const uint16_t xx) { - conv[2] = RJDIGIT(xx, 10000); - conv[3] = RJDIGIT(xx, 1000); - conv[4] = RJDIGIT(xx, 100); - conv[5] = RJDIGIT(xx, 10); - conv[6] = DIGIMOD(xx, 1); - return &conv[2]; + conv[3] = RJDIGIT(xx, 10000); + conv[4] = RJDIGIT(xx, 1000); + conv[5] = RJDIGIT(xx, 100); + conv[6] = RJDIGIT(xx, 10); + conv[7] = DIGIMOD(xx, 1); + return &conv[3]; } // Convert unsigned 16bit int to string 1234 format const char* ui16tostr4rj(const uint16_t xx) { - conv[3] = RJDIGIT(xx, 1000); - conv[4] = RJDIGIT(xx, 100); - conv[5] = RJDIGIT(xx, 10); - conv[6] = DIGIMOD(xx, 1); - return &conv[3]; + conv[4] = RJDIGIT(xx, 1000); + conv[5] = RJDIGIT(xx, 100); + conv[6] = RJDIGIT(xx, 10); + conv[7] = DIGIMOD(xx, 1); + return &conv[4]; } // Convert unsigned 16bit int to string 123 format const char* ui16tostr3rj(const uint16_t xx) { - conv[4] = RJDIGIT(xx, 100); - conv[5] = RJDIGIT(xx, 10); - conv[6] = DIGIMOD(xx, 1); - return &conv[4]; + conv[5] = RJDIGIT(xx, 100); + conv[6] = RJDIGIT(xx, 10); + conv[7] = DIGIMOD(xx, 1); + return &conv[5]; } // Convert signed 16bit int to rj string with 123 or -12 format const char* i16tostr3rj(const int16_t x) { int xx = x; - conv[4] = MINUSOR(xx, RJDIGIT(xx, 100)); - conv[5] = RJDIGIT(xx, 10); - conv[6] = DIGIMOD(xx, 1); - return &conv[4]; + conv[5] = MINUSOR(xx, RJDIGIT(xx, 100)); + conv[6] = RJDIGIT(xx, 10); + conv[7] = DIGIMOD(xx, 1); + return &conv[5]; } // Convert unsigned 16bit int to lj string with 123 format const char* i16tostr3left(const int16_t i) { - char *str = &conv[6]; + char *str = &conv[7]; *str = DIGIMOD(i, 1); if (i >= 10) { *(--str) = DIGIMOD(i, 10); @@ -153,118 +147,118 @@ const char* i16tostr4signrj(const int16_t i) { const bool neg = i < 0; const int ii = neg ? -i : i; if (i >= 1000) { - conv[3] = DIGIMOD(ii, 1000); - conv[4] = DIGIMOD(ii, 100); - conv[5] = DIGIMOD(ii, 10); + conv[4] = DIGIMOD(ii, 1000); + conv[5] = DIGIMOD(ii, 100); + conv[6] = DIGIMOD(ii, 10); } else if (ii >= 100) { - conv[3] = neg ? '-' : ' '; - conv[4] = DIGIMOD(ii, 100); - conv[5] = DIGIMOD(ii, 10); + conv[4] = neg ? '-' : ' '; + conv[5] = DIGIMOD(ii, 100); + conv[6] = DIGIMOD(ii, 10); } else { - conv[3] = ' '; conv[4] = ' '; + conv[5] = ' '; if (ii >= 10) { - conv[4] = neg ? '-' : ' '; - conv[5] = DIGIMOD(ii, 10); + conv[5] = neg ? '-' : ' '; + conv[6] = DIGIMOD(ii, 10); } else { - conv[5] = neg ? '-' : ' '; + conv[6] = neg ? '-' : ' '; } } - conv[6] = DIGIMOD(ii, 1); - return &conv[3]; + conv[7] = DIGIMOD(ii, 1); + return &conv[4]; } // Convert unsigned float to string with 1.1 format const char* ftostr11ns(const_float_t f) { const long i = UINTFLOAT(f, 1); - conv[4] = DIGIMOD(i, 10); - conv[5] = '.'; - conv[6] = DIGIMOD(i, 1); - return &conv[4]; + conv[5] = DIGIMOD(i, 10); + conv[6] = '.'; + conv[7] = DIGIMOD(i, 1); + return &conv[5]; } // Convert unsigned float to string with 1.23 format const char* ftostr12ns(const_float_t f) { const long i = UINTFLOAT(f, 2); - conv[3] = DIGIMOD(i, 100); - conv[4] = '.'; - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[3]; + conv[4] = DIGIMOD(i, 100); + conv[5] = '.'; + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[4]; } // Convert unsigned float to string with 12.3 format const char* ftostr31ns(const_float_t f) { const long i = UINTFLOAT(f, 1); - conv[3] = DIGIMOD(i, 100); - conv[4] = DIGIMOD(i, 10); - conv[5] = '.'; - conv[6] = DIGIMOD(i, 1); - return &conv[3]; + conv[4] = DIGIMOD(i, 100); + conv[5] = DIGIMOD(i, 10); + conv[6] = '.'; + conv[7] = DIGIMOD(i, 1); + return &conv[4]; } // Convert unsigned float to string with 123.4 format const char* ftostr41ns(const_float_t f) { const long i = UINTFLOAT(f, 1); - conv[2] = DIGIMOD(i, 1000); - conv[3] = DIGIMOD(i, 100); - conv[4] = DIGIMOD(i, 10); - conv[5] = '.'; - conv[6] = DIGIMOD(i, 1); - return &conv[2]; + conv[3] = DIGIMOD(i, 1000); + conv[4] = DIGIMOD(i, 100); + conv[5] = DIGIMOD(i, 10); + conv[6] = '.'; + conv[7] = DIGIMOD(i, 1); + return &conv[3]; } // Convert signed float to fixed-length string with 12.34 / _2.34 / -2.34 or -23.45 / 123.45 format const char* ftostr42_52(const_float_t f) { if (f <= -10 || f >= 100) return ftostr52(f); // -23.45 / 123.45 long i = INTFLOAT(f, 2); - conv[2] = (f >= 0 && f < 10) ? ' ' : MINUSOR(i, DIGIMOD(i, 1000)); - conv[3] = DIGIMOD(i, 100); - conv[4] = '.'; - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[2]; + conv[3] = (f >= 0 && f < 10) ? ' ' : MINUSOR(i, DIGIMOD(i, 1000)); + conv[4] = DIGIMOD(i, 100); + conv[5] = '.'; + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[3]; } // Convert signed float to fixed-length string with 023.45 / -23.45 format const char* ftostr52(const_float_t f) { long i = INTFLOAT(f, 2); - conv[1] = MINUSOR(i, DIGIMOD(i, 10000)); - conv[2] = DIGIMOD(i, 1000); - conv[3] = DIGIMOD(i, 100); - conv[4] = '.'; - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[1]; + conv[2] = MINUSOR(i, DIGIMOD(i, 10000)); + conv[3] = DIGIMOD(i, 1000); + conv[4] = DIGIMOD(i, 100); + conv[5] = '.'; + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[2]; } // Convert signed float to fixed-length string with 12.345 / _2.345 / -2.345 or -23.45 / 123.45 format const char* ftostr53_63(const_float_t f) { if (f <= -10 || f >= 100) return ftostr63(f); // -23.456 / 123.456 long i = INTFLOAT(f, 3); - conv[1] = (f >= 0 && f < 10) ? ' ' : MINUSOR(i, DIGIMOD(i, 10000)); - conv[2] = DIGIMOD(i, 1000); - conv[3] = '.'; - conv[4] = DIGIMOD(i, 100); - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[1]; + conv[2] = (f >= 0 && f < 10) ? ' ' : MINUSOR(i, DIGIMOD(i, 10000)); + conv[3] = DIGIMOD(i, 1000); + conv[4] = '.'; + conv[5] = DIGIMOD(i, 100); + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[2]; } // Convert signed float to fixed-length string with 023.456 / -23.456 format const char* ftostr63(const_float_t f) { long i = INTFLOAT(f, 3); - conv[0] = MINUSOR(i, DIGIMOD(i, 100000)); - conv[1] = DIGIMOD(i, 10000); - conv[2] = DIGIMOD(i, 1000); - conv[3] = '.'; - conv[4] = DIGIMOD(i, 100); - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[0]; + conv[1] = MINUSOR(i, DIGIMOD(i, 100000)); + conv[2] = DIGIMOD(i, 10000); + conv[3] = DIGIMOD(i, 1000); + conv[4] = '.'; + conv[5] = DIGIMOD(i, 100); + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[1]; } #if ENABLED(LCD_DECIMAL_SMALL_XY) @@ -275,11 +269,11 @@ const char* ftostr63(const_float_t f) { if (!WITHIN(i, -99, 999)) return i16tostr4signrj((int)f); const bool neg = i < 0; const int ii = neg ? -i : i; - conv[3] = neg ? '-' : (ii >= 100 ? DIGIMOD(ii, 100) : ' '); - conv[4] = DIGIMOD(ii, 10); - conv[5] = '.'; - conv[6] = DIGIMOD(ii, 1); - return &conv[3]; + conv[4] = neg ? '-' : (ii >= 100 ? DIGIMOD(ii, 100) : ' '); + conv[5] = DIGIMOD(ii, 10); + conv[6] = '.'; + conv[7] = DIGIMOD(ii, 1); + return &conv[4]; } #endif @@ -287,49 +281,49 @@ const char* ftostr63(const_float_t f) { // Convert float to fixed-length string with +12.3 / -12.3 format const char* ftostr31sign(const_float_t f) { int i = INTFLOAT(f, 1); - conv[2] = MINUSOR(i, '+'); - conv[3] = DIGIMOD(i, 100); - conv[4] = DIGIMOD(i, 10); - conv[5] = '.'; - conv[6] = DIGIMOD(i, 1); - return &conv[2]; + conv[3] = MINUSOR(i, '+'); + conv[4] = DIGIMOD(i, 100); + conv[5] = DIGIMOD(i, 10); + conv[6] = '.'; + conv[7] = DIGIMOD(i, 1); + return &conv[3]; } // Convert float to fixed-length string with +123.4 / -123.4 format const char* ftostr41sign(const_float_t f) { int i = INTFLOAT(f, 1); - conv[1] = MINUSOR(i, '+'); - conv[2] = DIGIMOD(i, 1000); - conv[3] = DIGIMOD(i, 100); - conv[4] = DIGIMOD(i, 10); - conv[5] = '.'; - conv[6] = DIGIMOD(i, 1); - return &conv[1]; + conv[2] = MINUSOR(i, '+'); + conv[3] = DIGIMOD(i, 1000); + conv[4] = DIGIMOD(i, 100); + conv[5] = DIGIMOD(i, 10); + conv[6] = '.'; + conv[7] = DIGIMOD(i, 1); + return &conv[2]; } // Convert signed float to string (6 digit) with -1.234 / _0.000 / +1.234 format const char* ftostr43sign(const_float_t f, char plus/*=' '*/) { long i = INTFLOAT(f, 3); - conv[1] = i ? MINUSOR(i, plus) : ' '; - conv[2] = DIGIMOD(i, 1000); - conv[3] = '.'; - conv[4] = DIGIMOD(i, 100); - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[1]; + conv[2] = i ? MINUSOR(i, plus) : ' '; + conv[3] = DIGIMOD(i, 1000); + conv[4] = '.'; + conv[5] = DIGIMOD(i, 100); + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[2]; } // Convert signed float to string (5 digit) with -1.2345 / _0.0000 / +1.2345 format const char* ftostr54sign(const_float_t f, char plus/*=' '*/) { long i = INTFLOAT(f, 4); - conv[0] = i ? MINUSOR(i, plus) : ' '; - conv[1] = DIGIMOD(i, 10000); - conv[2] = '.'; - conv[3] = DIGIMOD(i, 1000); - conv[4] = DIGIMOD(i, 100); - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return &conv[0]; + conv[1] = i ? MINUSOR(i, plus) : ' '; + conv[2] = DIGIMOD(i, 10000); + conv[3] = '.'; + conv[4] = DIGIMOD(i, 1000); + conv[5] = DIGIMOD(i, 100); + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[1]; } // Convert unsigned float to rj string with 12345 format @@ -341,52 +335,66 @@ const char* ftostr5rj(const_float_t f) { // Convert signed float to string with +1234.5 format const char* ftostr51sign(const_float_t f) { long i = INTFLOAT(f, 1); - conv[0] = MINUSOR(i, '+'); - conv[1] = DIGIMOD(i, 10000); - conv[2] = DIGIMOD(i, 1000); - conv[3] = DIGIMOD(i, 100); - conv[4] = DIGIMOD(i, 10); - conv[5] = '.'; - conv[6] = DIGIMOD(i, 1); - return conv; + conv[1] = MINUSOR(i, '+'); + conv[2] = DIGIMOD(i, 10000); + conv[3] = DIGIMOD(i, 1000); + conv[4] = DIGIMOD(i, 100); + conv[5] = DIGIMOD(i, 10); + conv[6] = '.'; + conv[7] = DIGIMOD(i, 1); + return &conv[1]; } // Convert signed float to string with +123.45 format const char* ftostr52sign(const_float_t f) { long i = INTFLOAT(f, 2); - conv[0] = MINUSOR(i, '+'); - conv[1] = DIGIMOD(i, 10000); - conv[2] = DIGIMOD(i, 1000); - conv[3] = DIGIMOD(i, 100); - conv[4] = '.'; - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return conv; + conv[1] = MINUSOR(i, '+'); + conv[2] = DIGIMOD(i, 10000); + conv[3] = DIGIMOD(i, 1000); + conv[4] = DIGIMOD(i, 100); + conv[5] = '.'; + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[1]; } // Convert signed float to string with +12.345 format const char* ftostr53sign(const_float_t f) { long i = INTFLOAT(f, 3); - conv[0] = MINUSOR(i, '+'); - conv[1] = DIGIMOD(i, 10000); - conv[2] = DIGIMOD(i, 1000); - conv[3] = '.'; - conv[4] = DIGIMOD(i, 100); - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIMOD(i, 1); - return conv; + conv[1] = MINUSOR(i, '+'); + conv[2] = DIGIMOD(i, 10000); + conv[3] = DIGIMOD(i, 1000); + conv[4] = '.'; + conv[5] = DIGIMOD(i, 100); + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); + return &conv[1]; } // Convert unsigned float to string with ____5.6, ___45.6, __345.6, _2345.6, 12345.6 format const char* ftostr61rj(const_float_t f) { const long i = UINTFLOAT(f, 1); - conv[0] = RJDIGIT(i, 100000); - conv[1] = RJDIGIT(i, 10000); - conv[2] = RJDIGIT(i, 1000); - conv[3] = RJDIGIT(i, 100); - conv[4] = DIGIMOD(i, 10); + conv[1] = RJDIGIT(i, 100000); + conv[2] = RJDIGIT(i, 10000); + conv[3] = RJDIGIT(i, 1000); + conv[4] = RJDIGIT(i, 100); + conv[5] = DIGIMOD(i, 10); + conv[6] = '.'; + conv[7] = DIGIMOD(i, 1); + return &conv[1]; +} + +// Convert unsigned float to string with ____5.67, ___45.67, __345.67, _2345.67, 12345.67 format +const char* ftostr72rj(const_float_t f) { + const long i = UINTFLOAT(f, 2); + conv[0] = RJDIGIT(i, 1000000); + conv[1] = RJDIGIT(i, 100000); + conv[2] = RJDIGIT(i, 10000); + conv[3] = RJDIGIT(i, 1000); + conv[4] = DIGIMOD(i, 100); conv[5] = '.'; - conv[6] = DIGIMOD(i, 1); + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIMOD(i, 1); return conv; } @@ -394,24 +402,24 @@ const char* ftostr61rj(const_float_t f) { const char* ftostr52sp(const_float_t f) { long i = INTFLOAT(f, 2); uint8_t dig; - conv[0] = MINUSOR(i, ' '); - conv[1] = RJDIGIT(i, 10000); - conv[2] = RJDIGIT(i, 1000); - conv[3] = DIGIMOD(i, 100); + conv[1] = MINUSOR(i, ' '); + conv[2] = RJDIGIT(i, 10000); + conv[3] = RJDIGIT(i, 1000); + conv[4] = DIGIMOD(i, 100); if ((dig = i % 10)) { // second digit after decimal point? - conv[4] = '.'; - conv[5] = DIGIMOD(i, 10); - conv[6] = DIGIT(dig); + conv[5] = '.'; + conv[6] = DIGIMOD(i, 10); + conv[7] = DIGIT(dig); } else { if ((dig = (i / 10) % 10)) { // first digit after decimal point? - conv[4] = '.'; - conv[5] = DIGIT(dig); + conv[5] = '.'; + conv[6] = DIGIT(dig); } else // nothing after decimal point - conv[4] = conv[5] = ' '; - conv[6] = ' '; + conv[5] = conv[6] = ' '; + conv[7] = ' '; } - return conv; + return &conv[1]; } diff --git a/Marlin/src/libs/numtostr.h b/Marlin/src/libs/numtostr.h index 1704d35e889d..84027b44cde5 100644 --- a/Marlin/src/libs/numtostr.h +++ b/Marlin/src/libs/numtostr.h @@ -116,8 +116,11 @@ const char* ftostr53sign(const_float_t f); // Convert unsigned float to string with 12345.6 format omitting trailing zeros const char* ftostr61rj(const_float_t x); +// Convert unsigned float to string with 12345.67 format omitting trailing zeros +const char* ftostr72rj(const_float_t x); + // Convert float to rj string with 123 or -12 format -FORCE_INLINE const char* ftostr3(const_float_t x) { return i16tostr3rj(int16_t(x + (x < 0 ? -0.5f : 0.5f))); } +FORCE_INLINE const char* ftostr3rj(const_float_t x) { return i16tostr3rj(int16_t(x + (x < 0 ? -0.5f : 0.5f))); } #if ENABLED(LCD_DECIMAL_SMALL_XY) // Convert float to rj string with 1234, _123, 12.3, _1.2, -123, _-12, or -1.2 format 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); }; diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index 8207dacaf700..ce2a6f4adad0 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -60,10 +60,6 @@ xy_float_t delta_tower[ABC]; abc_float_t delta_diagonal_rod_2_tower; float delta_clip_start_height = Z_MAX_POS; abc_float_t delta_diagonal_rod_trim; -#if HAS_DELTA_SENSORLESS_PROBING - abc_float_t offset_sensorless_adj{0}; - float largest_sensorless_adj = 0; -#endif float delta_safe_distance_from_top(); diff --git a/Marlin/src/module/delta.h b/Marlin/src/module/delta.h index f7067ef9c713..0a0c6124eecf 100644 --- a/Marlin/src/module/delta.h +++ b/Marlin/src/module/delta.h @@ -38,10 +38,6 @@ extern xy_float_t delta_tower[ABC]; extern abc_float_t delta_diagonal_rod_2_tower; extern float delta_clip_start_height; extern abc_float_t delta_diagonal_rod_trim; -#if HAS_DELTA_SENSORLESS_PROBING - extern abc_float_t offset_sensorless_adj; - extern float largest_sensorless_adj; -#endif /** * Recalculate factors used for delta kinematics whenever diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 1ee4b92b5f36..a5daf7afbdd8 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -35,7 +35,7 @@ #include "../core/debug_out.h" #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE) - #include HAL_PATH(../HAL, endstop_interrupts.h) + #include HAL_PATH(.., endstop_interrupts.h) #endif #if BOTH(SD_ABORT_ON_ENDSTOP_HIT, SDSUPPORT) @@ -63,6 +63,13 @@ bool Endstops::enabled, Endstops::enabled_globally; // Initialized by settings.l volatile Endstops::endstop_mask_t Endstops::hit_state; Endstops::endstop_mask_t Endstops::live_state = 0; +#if ENABLED(BD_SENSOR) + bool Endstops::bdp_state; // = false + #define READ_ENDSTOP(P) ((P == Z_MIN_PIN) ? bdp_state : READ(P)) +#else + #define READ_ENDSTOP(P) READ(P) +#endif + #if ENDSTOP_NOISE_THRESHOLD Endstops::endstop_mask_t Endstops::validated_live_state; uint8_t Endstops::endstop_poll_count; @@ -544,6 +551,10 @@ void Endstops::event_handler() { card.abortFilePrintNow(); quickstop_stepper(); thermalManager.disable_all_heaters(); + #ifdef SD_ABORT_ON_ENDSTOP_HIT_GCODE + queue.clear(); + queue.inject(F(SD_ABORT_ON_ENDSTOP_HIT_GCODE)); + #endif print_job_timer.stop(); } #endif @@ -566,7 +577,7 @@ static void print_es_state(const bool is_hit, FSTR_P const flabel=nullptr) { void __O2 Endstops::report_states() { TERN_(BLTOUCH, bltouch._set_SW_mode()); SERIAL_ECHOLNPGM(STR_M119_REPORT); - #define ES_REPORT(S) print_es_state(READ(S##_PIN) != S##_ENDSTOP_INVERTING, F(STR_##S)) + #define ES_REPORT(S) print_es_state(READ_ENDSTOP(S##_PIN) != S##_ENDSTOP_INVERTING, F(STR_##S)) #if HAS_X_MIN ES_REPORT(X_MIN); #endif @@ -680,15 +691,9 @@ void __O2 Endstops::report_states() { } // Endstops::report_states -#if HAS_DELTA_SENSORLESS_PROBING - #define __ENDSTOP(AXIS, ...) AXIS ##_MAX - #define _ENDSTOP_PIN(AXIS, ...) AXIS ##_MAX_PIN - #define _ENDSTOP_INVERTING(AXIS, ...) AXIS ##_MAX_ENDSTOP_INVERTING -#else - #define __ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX - #define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN - #define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING -#endif +#define __ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX +#define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN +#define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING #define _ENDSTOP(AXIS, MINMAX) __ENDSTOP(AXIS, MINMAX) /** @@ -703,11 +708,10 @@ void Endstops::update() { #endif // Macros to update / copy the live_state - #define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX))) + #define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ_ENDSTOP(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX))) #define COPY_LIVE_STATE(SRC_BIT, DST_BIT) SET_BIT_TO(live_state, DST_BIT, TEST(live_state, SRC_BIT)) - #if ENABLED(G38_PROBE_TARGET) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, MARKFORGED_YX) - #define HAS_G38_PROBE 1 + #if ENABLED(G38_PROBE_TARGET) // For G38 moves check the probe's pin for ALL movement if (G38_move) UPDATE_ENDSTOP_BIT(Z, TERN(USES_Z_MIN_PROBE_PIN, MIN_PROBE, MIN)); #endif @@ -1101,18 +1105,14 @@ void Endstops::update() { #define PROCESS_ENDSTOP_Z(MINMAX) PROCESS_DUAL_ENDSTOP(Z, MINMAX) #endif - #if HAS_G38_PROBE // TODO (DerAndere): Add support for HAS_I_AXIS - #define _G38_OPEN_STATE TERN(G38_PROBE_AWAY, (G38_move >= 4), LOW) + #if ENABLED(G38_PROBE_TARGET) // For G38 moves check the probe's pin for ALL movement - if (G38_move && TEST_ENDSTOP(_ENDSTOP(Z, TERN(USES_Z_MIN_PROBE_PIN, MIN_PROBE, MIN))) != _G38_OPEN_STATE) { - if (stepper.axis_is_moving(X_AXIS)) { _ENDSTOP_HIT(X, TERN(X_HOME_TO_MIN, MIN, MAX)); planner.endstop_triggered(X_AXIS); } - #if HAS_Y_AXIS - else if (stepper.axis_is_moving(Y_AXIS)) { _ENDSTOP_HIT(Y, TERN(Y_HOME_TO_MIN, MIN, MAX)); planner.endstop_triggered(Y_AXIS); } - #endif - #if HAS_Z_AXIS - else if (stepper.axis_is_moving(Z_AXIS)) { _ENDSTOP_HIT(Z, TERN(Z_HOME_TO_MIN, MIN, MAX)); planner.endstop_triggered(Z_AXIS); } - #endif + if (G38_move && TEST_ENDSTOP(Z_MIN_PROBE) == TERN1(G38_PROBE_AWAY, (G38_move < 4))) { G38_did_trigger = true; + #define _G38_SET(Q) | (stepper.axis_is_moving(_AXIS(Q)) << _AXIS(Q)) + #define _G38_RESP(Q) if (moving[_AXIS(Q)]) { _ENDSTOP_HIT(Q, ENDSTOP); planner.endstop_triggered(_AXIS(Q)); } + const Flags moving = { value_t(NUM_AXES)(0 MAIN_AXIS_MAP(_G38_SET)) }; + MAIN_AXIS_MAP(_G38_RESP); } #endif @@ -1325,75 +1325,54 @@ void Endstops::update() { bool hit = false; #if X_SPI_SENSORLESS if (tmc_spi_homing.x && (stepperX.test_stall_status() - #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && Y_SPI_SENSORLESS + #if Y_SPI_SENSORLESS && ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) || stepperY.test_stall_status() - #elif CORE_IS_XZ && Z_SPI_SENSORLESS + #elif Z_SPI_SENSORLESS && CORE_IS_XZ || stepperZ.test_stall_status() #endif - )) { - SBI(live_state, X_ENDSTOP); - hit = true; - } + )) { SBI(live_state, X_ENDSTOP); hit = true; } + #if ENABLED(X_DUAL_ENDSTOPS) + if (tmc_spi_homing.x && stepperX2.test_stall_status()) { SBI(live_state, X2_ENDSTOP); hit = true; } + #endif #endif #if Y_SPI_SENSORLESS if (tmc_spi_homing.y && (stepperY.test_stall_status() - #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && X_SPI_SENSORLESS + #if X_SPI_SENSORLESS && ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) || stepperX.test_stall_status() - #elif CORE_IS_YZ && Z_SPI_SENSORLESS + #elif Z_SPI_SENSORLESS && CORE_IS_YZ || stepperZ.test_stall_status() #endif - )) { - SBI(live_state, Y_ENDSTOP); - hit = true; - } + )) { SBI(live_state, Y_ENDSTOP); hit = true; } + #if ENABLED(Y_DUAL_ENDSTOPS) + if (tmc_spi_homing.y && stepperY2.test_stall_status()) { SBI(live_state, Y2_ENDSTOP); hit = true; } + #endif #endif #if Z_SPI_SENSORLESS if (tmc_spi_homing.z && (stepperZ.test_stall_status() - #if CORE_IS_XZ && X_SPI_SENSORLESS + #if X_SPI_SENSORLESS && CORE_IS_XZ || stepperX.test_stall_status() - #elif CORE_IS_YZ && Y_SPI_SENSORLESS + #elif Y_SPI_SENSORLESS && CORE_IS_YZ || stepperY.test_stall_status() #endif - )) { - SBI(live_state, Z_ENDSTOP); - hit = true; - } + )) { SBI(live_state, Z_ENDSTOP); hit = true; } #endif #if I_SPI_SENSORLESS - if (tmc_spi_homing.i && stepperI.test_stall_status()) { - SBI(live_state, I_ENDSTOP); - hit = true; - } + if (tmc_spi_homing.i && stepperI.test_stall_status()) { SBI(live_state, I_ENDSTOP); hit = true; } #endif #if J_SPI_SENSORLESS - if (tmc_spi_homing.j && stepperJ.test_stall_status()) { - SBI(live_state, J_ENDSTOP); - hit = true; - } + if (tmc_spi_homing.j && stepperJ.test_stall_status()) { SBI(live_state, J_ENDSTOP); hit = true; } #endif #if K_SPI_SENSORLESS - if (tmc_spi_homing.k && stepperK.test_stall_status()) { - SBI(live_state, K_ENDSTOP); - hit = true; - } + if (tmc_spi_homing.k && stepperK.test_stall_status()) { SBI(live_state, K_ENDSTOP); hit = true; } #endif #if U_SPI_SENSORLESS - if (tmc_spi_homing.u && stepperU.test_stall_status()) { - SBI(live_state, U_ENDSTOP); - hit = true; - } + if (tmc_spi_homing.u && stepperU.test_stall_status()) { SBI(live_state, U_ENDSTOP); hit = true; } #endif #if V_SPI_SENSORLESS - if (tmc_spi_homing.v && stepperV.test_stall_status()) { - SBI(live_state, V_ENDSTOP); - hit = true; - } + if (tmc_spi_homing.v && stepperV.test_stall_status()) { SBI(live_state, V_ENDSTOP); hit = true; } #endif #if W_SPI_SENSORLESS - if (tmc_spi_homing.w && stepperW.test_stall_status()) { - SBI(live_state, W_ENDSTOP); - hit = true; - } + if (tmc_spi_homing.w && stepperW.test_stall_status()) { SBI(live_state, W_ENDSTOP); hit = true; } #endif if (TERN0(ENDSTOP_INTERRUPTS_FEATURE, hit)) update(); @@ -1403,7 +1382,13 @@ void Endstops::update() { void Endstops::clear_endstop_state() { TERN_(X_SPI_SENSORLESS, CBI(live_state, X_ENDSTOP)); + #if BOTH(X_SPI_SENSORLESS, X_DUAL_ENDSTOPS) + CBI(live_state, X2_ENDSTOP); + #endif TERN_(Y_SPI_SENSORLESS, CBI(live_state, Y_ENDSTOP)); + #if BOTH(Y_SPI_SENSORLESS, Y_DUAL_ENDSTOPS) + CBI(live_state, Y2_ENDSTOP); + #endif TERN_(Z_SPI_SENSORLESS, CBI(live_state, Z_ENDSTOP)); TERN_(I_SPI_SENSORLESS, CBI(live_state, I_ENDSTOP)); TERN_(J_SPI_SENSORLESS, CBI(live_state, J_ENDSTOP)); @@ -1434,7 +1419,7 @@ void Endstops::update() { static uint8_t local_LED_status = 0; uint16_t live_state_local = 0; - #define ES_GET_STATE(S) if (READ(S##_PIN)) SBI(live_state_local, S) + #define ES_GET_STATE(S) if (READ_ENDSTOP(S##_PIN)) SBI(live_state_local, S) #if HAS_X_MIN ES_GET_STATE(X_MIN); diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index 9e411adbdaee..20e258f65255 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -85,12 +85,18 @@ enum EndstopEnum : char { // Endstops can be either MIN or MAX but not both #if HAS_X_MIN || HAS_X_MAX , X_ENDSTOP = TERN(X_HOME_TO_MAX, X_MAX, X_MIN) + #if ENABLED(X_DUAL_ENDSTOPS) + , X2_ENDSTOP = TERN(X_HOME_TO_MAX, X2_MAX, X2_MIN) + #endif #endif #if HAS_Y_MIN || HAS_Y_MAX , Y_ENDSTOP = TERN(Y_HOME_TO_MAX, Y_MAX, Y_MIN) + #if ENABLED(Y_DUAL_ENDSTOPS) + , Y2_ENDSTOP = TERN(Y_HOME_TO_MAX, Y2_MAX, Y2_MIN) + #endif #endif #if HAS_Z_MIN || HAS_Z_MAX || HOMING_Z_WITH_PROBE - , Z_ENDSTOP = TERN(Z_HOME_TO_MAX, Z_MAX, TERN(HOMING_Z_WITH_PROBE, Z_MIN_PROBE, Z_MIN)) + , Z_ENDSTOP = TERN(HOMING_Z_WITH_PROBE, Z_MIN_PROBE, TERN(Z_HOME_TO_MAX, Z_MAX, Z_MIN)) #endif #if HAS_I_MIN || HAS_I_MAX , I_ENDSTOP = TERN(I_HOME_TO_MAX, I_MAX, I_MIN) @@ -166,6 +172,11 @@ class Endstops { */ static void update(); + #if ENABLED(BD_SENSOR) + static bool bdp_state; + static void bdp_state_update(const bool z_state) { bdp_state = z_state; } + #endif + /** * Get Endstop hit state. */ diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 36afdb2e485f..51081f5165fb 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -128,7 +128,10 @@ xyze_pos_t destination; // {0} // no other feedrate is specified. Overridden for special moves. // Set by the last G0 through G5 command's "F" parameter. // Functions that override this for custom moves *must always* restore it! -feedRate_t feedrate_mm_s = MMM_TO_MMS(1500); +#ifndef DEFAULT_FEEDRATE_MM_M + #define DEFAULT_FEEDRATE_MM_M 4000 +#endif +feedRate_t feedrate_mm_s = MMM_TO_MMS(DEFAULT_FEEDRATE_MM_M); int16_t feedrate_percentage = 100; // Cartesian conversion result goes here: @@ -300,6 +303,72 @@ void report_current_position_projected() { #endif +#if IS_KINEMATIC + + bool position_is_reachable(const_float_t rx, const_float_t ry, const float inset/*=0*/) { + + bool can_reach; + + #if ENABLED(DELTA) + + can_reach = HYPOT2(rx, ry) <= sq(DELTA_PRINTABLE_RADIUS - inset + fslop); + + #elif ENABLED(AXEL_TPARA) + + const float R2 = HYPOT2(rx - TPARA_OFFSET_X, ry - TPARA_OFFSET_Y); + can_reach = ( + R2 <= sq(L1 + L2) - inset + #if MIDDLE_DEAD_ZONE_R > 0 + && R2 >= sq(float(MIDDLE_DEAD_ZONE_R)) + #endif + ); + + #elif IS_SCARA + + const float R2 = HYPOT2(rx - SCARA_OFFSET_X, ry - SCARA_OFFSET_Y); + can_reach = ( + R2 <= sq(L1 + L2) - inset + #if MIDDLE_DEAD_ZONE_R > 0 + && R2 >= sq(float(MIDDLE_DEAD_ZONE_R)) + #endif + ); + + #elif ENABLED(POLARGRAPH) + + const float d1 = rx - (draw_area_min.x), + d2 = (draw_area_max.x) - rx, + y = ry - (draw_area_max.y), + a = HYPOT(d1, y), + b = HYPOT(d2, y); + + can_reach = ( + a < polargraph_max_belt_len + 1 + && b < polargraph_max_belt_len + 1 + ); + + #endif + + return can_reach; + } + +#else // CARTESIAN + + // Return true if the given position is within the machine bounds. + bool position_is_reachable(const_float_t rx, const_float_t ry) { + if (TERN0(HAS_Y_AXIS, !COORDINATE_OKAY(ry, Y_MIN_POS - fslop, Y_MAX_POS + fslop))) return false; + #if ENABLED(DUAL_X_CARRIAGE) + if (active_extruder) + return COORDINATE_OKAY(rx, X2_MIN_POS - fslop, X2_MAX_POS + fslop); + else + return COORDINATE_OKAY(rx, X1_MIN_POS - fslop, X1_MAX_POS + fslop); + #else + return COORDINATE_OKAY(rx, X_MIN_POS - fslop, X_MAX_POS + fslop); + #endif + } + +#endif // CARTESIAN + + void home_if_needed(const bool keeplev/*=false*/) { if (!all_axes_trusted()) gcode.home_all_axes(keeplev); } @@ -477,7 +546,7 @@ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/ * - Delta may lower Z first to get into the free motion zone. * - Before returning, wait for the planner buffer to empty. */ -void do_blocking_move_to(NUM_AXIS_ARGS(const float), const_feedRate_t fr_mm_s/*=0.0f*/) { +void do_blocking_move_to(NUM_AXIS_ARGS(const_float_t), const_feedRate_t fr_mm_s/*=0.0f*/) { DEBUG_SECTION(log_move, "do_blocking_move_to", DEBUGGING(LEVELING)); if (DEBUGGING(LEVELING)) DEBUG_XYZ("> ", NUM_AXIS_ARGS()); @@ -495,7 +564,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 @@ -551,7 +621,7 @@ void do_blocking_move_to(NUM_AXIS_ARGS(const float), const_feedRate_t fr_mm_s/*= if (current_position.z < z) { current_position.z = z; line_to_current_position(z_feedrate); } #endif - current_position.set(x, y); line_to_current_position(xy_feedrate); + current_position.set(x OPTARG(HAS_Y_AXIS, y)); line_to_current_position(xy_feedrate); #if HAS_I_AXIS current_position.i = i; line_to_current_position(i_feedrate); @@ -852,11 +922,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 @@ -966,7 +1041,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { next_idle_ms = ms + 200UL; return idle(); } - thermalManager.manage_heater(); // Returns immediately on most calls + thermalManager.task(); // Returns immediately on most calls } #if IS_KINEMATIC @@ -1017,7 +1092,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { if (!position_is_reachable(destination)) return true; // Get the linear distance in XYZ - float cartesian_mm = diff.magnitude(); + float cartesian_mm = xyz_float_t(diff).magnitude(); // If the move is very short, check the E move distance TERN_(HAS_EXTRUDERS, if (UNEAR_ZERO(cartesian_mm)) cartesian_mm = ABS(diff.e)); @@ -1041,19 +1116,18 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { NOLESS(segments, 1U); // The approximate length of each segment - const float inv_segments = 1.0f / float(segments), - cartesian_segment_mm = cartesian_mm * inv_segments; + const float inv_segments = 1.0f / float(segments); const xyze_float_t segment_distance = diff * inv_segments; - #if ENABLED(SCARA_FEEDRATE_SCALING) - const float inv_duration = scaled_fr_mm_s / cartesian_segment_mm; - #endif + // Add hints to help optimize the move + PlannerHints hints(cartesian_mm * inv_segments); + TERN_(SCARA_FEEDRATE_SCALING, hints.inv_duration = scaled_fr_mm_s / hints.millimeters); /* SERIAL_ECHOPGM("mm=", cartesian_mm); SERIAL_ECHOPGM(" seconds=", seconds); SERIAL_ECHOPGM(" segments=", segments); - SERIAL_ECHOPGM(" segment_mm=", cartesian_segment_mm); + SERIAL_ECHOPGM(" segment_mm=", hints.millimeters); SERIAL_EOL(); //*/ @@ -1065,11 +1139,12 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { while (--segments) { segment_idle(next_idle_ms); raw += segment_distance; - if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, cartesian_segment_mm OPTARG(SCARA_FEEDRATE_SCALING, inv_duration))) break; + if (!planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, hints)) + break; } // Ensure last segment arrives at target location. - planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, cartesian_segment_mm OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)); + planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, hints); return false; // caller will update current_position } @@ -1108,17 +1183,16 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { NOLESS(segments, 1U); // The approximate length of each segment - const float inv_segments = 1.0f / float(segments), - cartesian_segment_mm = cartesian_mm * inv_segments; + const float inv_segments = 1.0f / float(segments); const xyze_float_t segment_distance = diff * inv_segments; - #if ENABLED(SCARA_FEEDRATE_SCALING) - const float inv_duration = scaled_fr_mm_s / cartesian_segment_mm; - #endif + // Add hints to help optimize the move + PlannerHints hints(cartesian_mm * inv_segments); + TERN_(SCARA_FEEDRATE_SCALING, hints.inv_duration = scaled_fr_mm_s / hints.millimeters); //SERIAL_ECHOPGM("mm=", cartesian_mm); //SERIAL_ECHOLNPGM(" segments=", segments); - //SERIAL_ECHOLNPGM(" segment_mm=", cartesian_segment_mm); + //SERIAL_ECHOLNPGM(" segment_mm=", hints.millimeters); // Get the raw current position as starting point xyze_pos_t raw = current_position; @@ -1128,12 +1202,13 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { while (--segments) { segment_idle(next_idle_ms); raw += segment_distance; - if (!planner.buffer_line(raw, fr_mm_s, active_extruder, cartesian_segment_mm OPTARG(SCARA_FEEDRATE_SCALING, inv_duration))) break; + if (!planner.buffer_line(raw, fr_mm_s, active_extruder, hints)) + break; } // Since segment_distance is only approximate, // the final move must be to the exact destination. - planner.buffer_line(destination, fr_mm_s, active_extruder, cartesian_segment_mm OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)); + planner.buffer_line(destination, fr_mm_s, active_extruder, hints); } #endif // SEGMENT_LEVELED_MOVES && !AUTO_BED_LEVELING_UBL @@ -1399,13 +1474,18 @@ void prepare_line_to_destination() { } bool homing_needed_error(main_axes_bits_t axis_bits/*=main_axes_mask*/) { - if ((axis_bits = axes_should_home(axis_bits))) { - PGM_P home_first = GET_TEXT(MSG_HOME_FIRST); + if ((axis_bits &= axes_should_home(axis_bits))) { + char all_axes[] = STR_AXES_MAIN, need[NUM_AXES + 1]; + uint8_t n = 0; + LOOP_NUM_AXES(i) if (TEST(axis_bits, i)) need[n++] = all_axes[i]; + need[n] = '\0'; + char msg[30]; - #define _AXIS_CHAR(N) TEST(axis_bits, _AXIS(N)) ? STR_##N : "" - sprintf_P(msg, home_first, MAPLIST(_AXIS_CHAR, MAIN_AXIS_NAMES)); + sprintf_P(msg, GET_EN_TEXT(MSG_HOME_FIRST), need); SERIAL_ECHO_START(); SERIAL_ECHOLN(msg); + + sprintf_P(msg, GET_TEXT(MSG_HOME_FIRST), need); ui.set_status(msg); return true; } @@ -1927,6 +2007,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)); @@ -2175,25 +2266,18 @@ void prepare_line_to_destination() { #endif // Put away the Z probe - #if HOMING_Z_WITH_PROBE - if (axis == Z_AXIS && probe.stow()) return; - #endif + if (TERN0(HOMING_Z_WITH_PROBE, axis == Z_AXIS && probe.stow())) return; #if DISABLED(DELTA) && defined(HOMING_BACKOFF_POST_MM) const xyz_float_t endstop_backoff = HOMING_BACKOFF_POST_MM; if (endstop_backoff[axis]) { current_position[axis] -= ABS(endstop_backoff[axis]) * axis_home_dir; - line_to_current_position( - #if HOMING_Z_WITH_PROBE - (axis == Z_AXIS) ? z_probe_fast_mm_s : - #endif - homing_feedrate(axis) - ); + line_to_current_position(TERN_(HOMING_Z_WITH_PROBE, (axis == Z_AXIS) ? z_probe_fast_mm_s :) homing_feedrate(axis)); #if ENABLED(SENSORLESS_HOMING) planner.synchronize(); if (false - #if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX) + #ifdef NORMAL_AXIS || axis != NORMAL_AXIS #endif ) safe_delay(200); // Short delay to allow belts to spring back @@ -2300,7 +2384,7 @@ void set_axis_is_at_home(const AxisEnum axis) { * Change the home offset for an axis. * Also refreshes the workspace offset. */ - void set_home_offset(const AxisEnum axis, const float v) { + void set_home_offset(const AxisEnum axis, const_float_t v) { home_offset[axis] = v; update_workspace_offset(axis); } diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index ec478188772c..68cadcc47fc9 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -344,7 +344,7 @@ inline void prepare_internal_move_to_destination(const_feedRate_t fr_mm_s=0.0f) /** * Blocking movement and shorthand functions */ -void do_blocking_move_to(NUM_AXIS_ARGS(const float), const_feedRate_t fr_mm_s=0.0f); +void do_blocking_move_to(NUM_AXIS_ARGS(const_float_t), const_feedRate_t fr_mm_s=0.0f); void do_blocking_move_to(const xy_pos_t &raw, const_feedRate_t fr_mm_s=0.0f); void do_blocking_move_to(const xyz_pos_t &raw, const_feedRate_t fr_mm_s=0.0f); void do_blocking_move_to(const xyze_pos_t &raw, const_feedRate_t fr_mm_s=0.0f); @@ -549,63 +549,21 @@ void home_if_needed(const bool keeplev=false); #endif // Return true if the given point is within the printable area - inline bool position_is_reachable(const_float_t rx, const_float_t ry, const float inset=0) { - #if ENABLED(DELTA) - - return HYPOT2(rx, ry) <= sq(DELTA_PRINTABLE_RADIUS - inset + fslop); - - #elif ENABLED(POLARGRAPH) - - const float x1 = rx - (X_MIN_POS), x2 = (X_MAX_POS) - rx, y = ry - (Y_MAX_POS), - a = HYPOT(x1, y), b = HYPOT(x2, y); - return a < (POLARGRAPH_MAX_BELT_LEN) + 1 - && b < (POLARGRAPH_MAX_BELT_LEN) + 1 - && (a + b) > _MIN(X_BED_SIZE, Y_BED_SIZE); - - #elif ENABLED(AXEL_TPARA) - - const float R2 = HYPOT2(rx - TPARA_OFFSET_X, ry - TPARA_OFFSET_Y); - return ( - R2 <= sq(L1 + L2) - inset - #if MIDDLE_DEAD_ZONE_R > 0 - && R2 >= sq(float(MIDDLE_DEAD_ZONE_R)) - #endif - ); - - #elif IS_SCARA - - const float R2 = HYPOT2(rx - SCARA_OFFSET_X, ry - SCARA_OFFSET_Y); - return ( - R2 <= sq(L1 + L2) - inset - #if MIDDLE_DEAD_ZONE_R > 0 - && R2 >= sq(float(MIDDLE_DEAD_ZONE_R)) - #endif - ); - - #endif - } + bool position_is_reachable(const_float_t rx, const_float_t ry, const float inset=0); inline bool position_is_reachable(const xy_pos_t &pos, const float inset=0) { return position_is_reachable(pos.x, pos.y, inset); } -#else // CARTESIAN +#else // Return true if the given position is within the machine bounds. - inline bool position_is_reachable(const_float_t rx, const_float_t ry) { - if (!COORDINATE_OKAY(ry, Y_MIN_POS - fslop, Y_MAX_POS + fslop)) return false; - #if ENABLED(DUAL_X_CARRIAGE) - if (active_extruder) - return COORDINATE_OKAY(rx, X2_MIN_POS - fslop, X2_MAX_POS + fslop); - else - return COORDINATE_OKAY(rx, X1_MIN_POS - fslop, X1_MAX_POS + fslop); - #else - return COORDINATE_OKAY(rx, X_MIN_POS - fslop, X_MAX_POS + fslop); - #endif + bool position_is_reachable(const_float_t rx, const_float_t ry); + inline bool position_is_reachable(const xy_pos_t &pos) { + return position_is_reachable(pos.x, pos.y); } - inline bool position_is_reachable(const xy_pos_t &pos) { return position_is_reachable(pos.x, pos.y); } -#endif // CARTESIAN +#endif /** * Duplication mode @@ -658,7 +616,7 @@ void home_if_needed(const bool keeplev=false); #endif #if HAS_M206_COMMAND - void set_home_offset(const AxisEnum axis, const float v); + void set_home_offset(const AxisEnum axis, const_float_t v); #endif #if USE_SENSORLESS diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 6aa363890e44..d4e5be306eea 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -28,12 +28,14 @@ * Derived from Grbl * Copyright (c) 2009-2011 Simen Svale Skogsrud * - * The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis. + * Ring buffer gleaned from wiring_serial library by David A. Mellis. * + * Fast inverse function needed for Bézier interpolation for AVR + * was designed, written and tested by Eduardo José Tagle, April 2018. * - * Reasoning behind the mathematics in this module (in the key of 'Mathematica'): + * Planner mathematics (Mathematica-style): * - * s == speed, a == acceleration, t == time, d == distance + * Where: s == speed, a == acceleration, t == time, d == distance * * Basic definitions: * Speed[s_, a_, t_] := s + (a*t) @@ -41,7 +43,7 @@ * * Distance to reach a specific speed with a constant acceleration: * Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, d, t] - * d -> (m^2 - s^2)/(2 a) --> estimate_acceleration_distance() + * d -> (m^2 - s^2) / (2 a) * * Speed after a given distance of travel with constant acceleration: * Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t] @@ -49,17 +51,18 @@ * * DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2] * - * When to start braking (di) to reach a specified destination speed (s2) after accelerating - * from initial speed s1 without ever stopping at a plateau: + * When to start braking (di) to reach a specified destination speed (s2) after + * acceleration from initial speed s1 without ever reaching a plateau: * Solve[{DestinationSpeed[s1, a, di] == DestinationSpeed[s2, a, d - di]}, di] - * di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance() + * di -> (2 a d - s1^2 + s2^2)/(4 a) * - * IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a) + * We note, as an optimization, that if we have already calculated an + * acceleration distance d1 from s1 to m and a deceration distance d2 + * from m to s2 then * - * -- - * - * The fast inverse function needed for Bézier interpolation for AVR - * was designed, written and tested by Eduardo José Tagle on April/2018 + * d1 -> (m^2 - s1^2) / (2 a) + * d2 -> (m^2 - s2^2) / (2 a) + * di -> (d + d1 - d2) / 2 */ #include "planner.h" @@ -128,8 +131,13 @@ uint8_t Planner::delay_before_delivering; // This counter delays delivery planner_settings_t Planner::settings; // Initialized by settings.load() -#if ENABLED(LASER_POWER_INLINE) +/** + * Set up inline block variables + * Set laser_power_floor based on SPEED_POWER_MIN to pevent a zero power output state with LASER_POWER_TRAP + */ +#if ENABLED(LASER_FEATURE) laser_state_t Planner::laser_inline; // Current state for blocks + const uint8_t laser_power_floor = cutter.pct_to_ocr(SPEED_POWER_MIN); #endif uint32_t Planner::max_acceleration_steps_per_s2[DISTINCT_AXES]; // (steps/s^2) Derived from mm_per_s2 @@ -206,7 +214,7 @@ xyze_long_t Planner::position{0}; uint32_t Planner::acceleration_long_cutoff; xyze_float_t Planner::previous_speed; -float Planner::previous_nominal_speed_sqr; +float Planner::previous_nominal_speed; #if ENABLED(DISABLE_INACTIVE_EXTRUDER) last_move_t Planner::g_uc_extruder_last_move[E_STEPPERS] = { 0 }; @@ -215,11 +223,11 @@ float Planner::previous_nominal_speed_sqr; #ifdef XY_FREQUENCY_LIMIT int8_t Planner::xy_freq_limit_hz = XY_FREQUENCY_LIMIT; float Planner::xy_freq_min_speed_factor = (XY_FREQUENCY_MIN_PERCENT) * 0.01f; - int32_t Planner::xy_freq_min_interval_us = LROUND(1000000.0 / (XY_FREQUENCY_LIMIT)); + int32_t Planner::xy_freq_min_interval_us = LROUND(1000000.0f / (XY_FREQUENCY_LIMIT)); #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 @@ -245,7 +253,7 @@ void Planner::init() { TERN_(HAS_POSITION_FLOAT, position_float.reset()); TERN_(IS_KINEMATIC, position_cart.reset()); previous_speed.reset(); - previous_nominal_speed_sqr = 0; + previous_nominal_speed = 0; TERN_(ABL_PLANAR, bed_level_matrix.set_to_identity()); clear_block_buffer(); delay_before_delivering = 0; @@ -739,7 +747,7 @@ block_t* Planner::get_current_block() { block_t * const block = &block_buffer[block_buffer_tail]; // No trapezoid calculated? Don't execute yet. - if (TEST(block->flag, BLOCK_BIT_RECALCULATE)) return nullptr; + if (block->flag.recalculate) return nullptr; // We can't be sure how long an active block will take, so don't count it. TERN_(HAS_WIRED_LCD, block_buffer_runtime_us -= block->segment_time_us); @@ -780,41 +788,52 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t NOLESS(initial_rate, uint32_t(MINIMAL_STEP_RATE)); NOLESS(final_rate, uint32_t(MINIMAL_STEP_RATE)); - #if ENABLED(S_CURVE_ACCELERATION) - uint32_t cruise_rate = initial_rate; + #if EITHER(S_CURVE_ACCELERATION, LIN_ADVANCE) + // If we have some plateau time, the cruise rate will be the nominal rate + 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; - // Steps required for acceleration, deceleration to/from nominal rate - uint32_t accelerate_steps = CEIL(estimate_acceleration_distance(initial_rate, block->nominal_rate, accel)), - decelerate_steps = FLOOR(estimate_acceleration_distance(block->nominal_rate, final_rate, -accel)); - // Steps between acceleration and deceleration, if any - int32_t plateau_steps = block->step_event_count - accelerate_steps - decelerate_steps; - - // Does accelerate_steps + decelerate_steps exceed step_event_count? - // Then we can't possibly reach the nominal rate, there will be no cruising. - // Use intersection_distance() to calculate accel / braking time in order to - // reach the final_rate exactly at the end of this block. - if (plateau_steps < 0) { - const float accelerate_steps_float = CEIL(intersection_distance(initial_rate, final_rate, accel, block->step_event_count)); - accelerate_steps = _MIN(uint32_t(_MAX(accelerate_steps_float, 0)), block->step_event_count); - plateau_steps = 0; - - #if ENABLED(S_CURVE_ACCELERATION) - // We won't reach the cruising rate. Let's calculate the speed we will reach - cruise_rate = final_speed(initial_rate, accel, accelerate_steps); - #endif + const int32_t accel = block->acceleration_steps_per_s2; + float inverse_accel = 0.0f; + if (accel != 0) { + 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); + decelerate_steps = FLOOR(decelerate_steps_float); + + // Steps between acceleration and deceleration, if any + plateau_steps -= accelerate_steps + decelerate_steps; + + // Does accelerate_steps + decelerate_steps exceed step_event_count? + // Then we can't possibly reach the nominal rate, there will be no cruising. + // Calculate accel / braking time in order to reach the final_rate exactly + // at the end of this block. + if (plateau_steps < 0) { + accelerate_steps_float = CEIL((block->step_event_count + accelerate_steps_float - decelerate_steps_float) * 0.5f); + accelerate_steps = _MIN(uint32_t(_MAX(accelerate_steps_float, 0)), block->step_event_count); + decelerate_steps = block->step_event_count - accelerate_steps; + + #if EITHER(S_CURVE_ACCELERATION, LIN_ADVANCE) + // We won't reach the cruising rate. Let's calculate the speed we will reach + cruise_rate = final_speed(initial_rate, accel, accelerate_steps); + #endif + } } - #if ENABLED(S_CURVE_ACCELERATION) - else // We have some plateau time, so the cruise rate will be the nominal rate - cruise_rate = block->nominal_rate; - #endif #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); @@ -822,7 +841,7 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t // Store new block parameters block->accelerate_until = accelerate_steps; - block->decelerate_after = accelerate_steps + plateau_steps; + block->decelerate_after = block->step_event_count - decelerate_steps; block->initial_rate = initial_rate; #if ENABLED(S_CURVE_ACCELERATION) block->acceleration_time = acceleration_time; @@ -833,112 +852,139 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t #endif block->final_rate = final_rate; - /** - * Laser trapezoid calculations - * - * Approximate the trapezoid with the laser, incrementing the power every `entry_per` while accelerating - * and decrementing it every `exit_power_per` while decelerating, thus ensuring power is related to feedrate. - * - * LASER_POWER_INLINE_TRAPEZOID_CONT doesn't need this as it continuously approximates - * - * Note this may behave unreliably when running with S_CURVE_ACCELERATION - */ - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - if (block->laser.power > 0) { // No need to care if power == 0 - const uint8_t entry_power = block->laser.power * entry_factor; // Power on block entry - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - // Speedup power - const uint8_t entry_power_diff = block->laser.power - entry_power; - if (entry_power_diff) { - block->laser.entry_per = accelerate_steps / entry_power_diff; - block->laser.power_entry = entry_power; - } - else { - block->laser.entry_per = 0; - block->laser.power_entry = block->laser.power; - } - // Slowdown power - const uint8_t exit_power = block->laser.power * exit_factor, // Power on block entry - exit_power_diff = block->laser.power - exit_power; - if (exit_power_diff) { - block->laser.exit_per = (block->step_event_count - block->decelerate_after) / exit_power_diff; - block->laser.power_exit = exit_power; + #if ENABLED(LIN_ADVANCE) + if (block->la_advance_rate) { + 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; + } + #endif + + #if ENABLED(LASER_POWER_TRAP) + /** + * Laser Trapezoid Calculations + * + * Approximate the trapezoid with the laser, incrementing the power every `trap_ramp_entry_incr` + * steps while accelerating, and decrementing the power every `trap_ramp_exit_decr` while decelerating, + * to keep power proportional to feedrate. Laser power trap will reduce the initial power to no less + * than the laser_power_floor value. Based on the number of calculated accel/decel steps the power is + * distributed over the trapezoid entry- and exit-ramp steps. + * + * trap_ramp_active_pwr - The active power is initially set at a reduced level factor of initial + * power / accel steps and will be additively incremented using a trap_ramp_entry_incr value for each + * accel step processed later in the stepper code. The trap_ramp_exit_decr value is calculated as + * power / decel steps and is also adjusted to no less than the power floor. + * + * If the power == 0 the inline mode variables need to be set to zero to prevent stepper processing. + * The method allows for simpler non-powered moves like G0 or G28. + * + * Laser Trap Power works for all Jerk and Curve modes; however Arc-based moves will have issues since + * the segments are usually too small. + */ + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { + if (planner.laser_inline.status.isPowered && planner.laser_inline.status.isEnabled) { + if (block->laser.power > 0) { + NOLESS(block->laser.power, laser_power_floor); + block->laser.trap_ramp_active_pwr = (block->laser.power - laser_power_floor) * (initial_rate / float(block->nominal_rate)) + laser_power_floor; + block->laser.trap_ramp_entry_incr = (block->laser.power - block->laser.trap_ramp_active_pwr) / accelerate_steps; + float laser_pwr = block->laser.power * (final_rate / float(block->nominal_rate)); + NOLESS(laser_pwr, laser_power_floor); + block->laser.trap_ramp_exit_decr = (block->laser.power - laser_pwr) / decelerate_steps; + #if ENABLED(DEBUG_LASER_TRAP) + SERIAL_ECHO_MSG("lp:",block->laser.power); + SERIAL_ECHO_MSG("as:",accelerate_steps); + SERIAL_ECHO_MSG("ds:",decelerate_steps); + SERIAL_ECHO_MSG("p.trap:",block->laser.trap_ramp_active_pwr); + SERIAL_ECHO_MSG("p.incr:",block->laser.trap_ramp_entry_incr); + SERIAL_ECHO_MSG("p.decr:",block->laser.trap_ramp_exit_decr); + #endif } else { - block->laser.exit_per = 0; - block->laser.power_exit = block->laser.power; + block->laser.trap_ramp_active_pwr = 0; + block->laser.trap_ramp_entry_incr = 0; + block->laser.trap_ramp_exit_decr = 0; } - #else - block->laser.power_entry = entry_power; - #endif + + } } - #endif + #endif // LASER_POWER_TRAP } -/* PLANNER SPEED DEFINITION - +--------+ <- current->nominal_speed - / \ - current->entry_speed -> + \ - | + <- next->entry_speed (aka exit speed) - +-------------+ - time --> - - Recalculates the motion plan according to the following basic guidelines: - - 1. Go over every feasible block sequentially in reverse order and calculate the junction speeds - (i.e. current->entry_speed) such that: - a. No junction speed exceeds the pre-computed maximum junction speed limit or nominal speeds of - neighboring blocks. - b. A block entry speed cannot exceed one reverse-computed from its exit speed (next->entry_speed) - with a maximum allowable deceleration over the block travel distance. - c. The last (or newest appended) block is planned from a complete stop (an exit speed of zero). - 2. Go over every block in chronological (forward) order and dial down junction speed values if - a. The exit speed exceeds the one forward-computed from its entry speed with the maximum allowable - acceleration over the block travel distance. - - When these stages are complete, the planner will have maximized the velocity profiles throughout the all - of the planner blocks, where every block is operating at its maximum allowable acceleration limits. In - other words, for all of the blocks in the planner, the plan is optimal and no further speed improvements - are possible. If a new block is added to the buffer, the plan is recomputed according to the said - guidelines for a new optimal plan. - - To increase computational efficiency of these guidelines, a set of planner block pointers have been - created to indicate stop-compute points for when the planner guidelines cannot logically make any further - changes or improvements to the plan when in normal operation and new blocks are streamed and added to the - planner buffer. For example, if a subset of sequential blocks in the planner have been planned and are - bracketed by junction velocities at their maximums (or by the first planner block as well), no new block - added to the planner buffer will alter the velocity profiles within them. So we no longer have to compute - them. Or, if a set of sequential blocks from the first block in the planner (or a optimal stop-compute - point) are all accelerating, they are all optimal and can not be altered by a new block added to the - planner buffer, as this will only further increase the plan speed to chronological blocks until a maximum - junction velocity is reached. However, if the operational conditions of the plan changes from infrequently - used feed holds or feedrate overrides, the stop-compute pointers will be reset and the entire plan is - recomputed as stated in the general guidelines. - - Planner buffer index mapping: - - block_buffer_tail: Points to the beginning of the planner buffer. First to be executed or being executed. - - block_buffer_head: Points to the buffer block after the last block in the buffer. Used to indicate whether - the buffer is full or empty. As described for standard ring buffers, this block is always empty. - - block_buffer_planned: Points to the first buffer block after the last optimally planned block for normal - streaming operating conditions. Use for planning optimizations by avoiding recomputing parts of the - planner buffer that don't change with the addition of a new block, as describe above. In addition, - this block can never be less than block_buffer_tail and will always be pushed forward and maintain - this requirement when encountered by the Planner::release_current_block() routine during a cycle. - - NOTE: Since the planner only computes on what's in the planner buffer, some motions with lots of short - line segments, like G2/3 arcs or complex curves, may seem to move slow. This is because there simply isn't - enough combined distance traveled in the entire buffer to accelerate up to the nominal speed and then - decelerate to a complete stop at the end of the buffer, as stated by the guidelines. If this happens and - becomes an annoyance, there are a few simple solutions: (1) Maximize the machine acceleration. The planner - will be able to compute higher velocity profiles within the same combined distance. (2) Maximize line - motion(s) distance per block to a desired tolerance. The more combined distance the planner has to use, - the faster it can go. (3) Maximize the planner buffer size. This also will increase the combined distance - for the planner to compute over. It also increases the number of computations the planner has to perform - to compute an optimal plan, so select carefully. -*/ +/** + * PLANNER SPEED DEFINITION + * +--------+ <- current->nominal_speed + * / \ + * current->entry_speed -> + \ + * | + <- next->entry_speed (aka exit speed) + * +-------------+ + * time --> + * + * Recalculates the motion plan according to the following basic guidelines: + * + * 1. Go over every feasible block sequentially in reverse order and calculate the junction speeds + * (i.e. current->entry_speed) such that: + * a. No junction speed exceeds the pre-computed maximum junction speed limit or nominal speeds of + * neighboring blocks. + * b. A block entry speed cannot exceed one reverse-computed from its exit speed (next->entry_speed) + * with a maximum allowable deceleration over the block travel distance. + * c. The last (or newest appended) block is planned from a complete stop (an exit speed of zero). + * 2. Go over every block in chronological (forward) order and dial down junction speed values if + * a. The exit speed exceeds the one forward-computed from its entry speed with the maximum allowable + * acceleration over the block travel distance. + * + * When these stages are complete, the planner will have maximized the velocity profiles throughout the all + * of the planner blocks, where every block is operating at its maximum allowable acceleration limits. In + * other words, for all of the blocks in the planner, the plan is optimal and no further speed improvements + * are possible. If a new block is added to the buffer, the plan is recomputed according to the said + * guidelines for a new optimal plan. + * + * To increase computational efficiency of these guidelines, a set of planner block pointers have been + * created to indicate stop-compute points for when the planner guidelines cannot logically make any further + * changes or improvements to the plan when in normal operation and new blocks are streamed and added to the + * planner buffer. For example, if a subset of sequential blocks in the planner have been planned and are + * bracketed by junction velocities at their maximums (or by the first planner block as well), no new block + * added to the planner buffer will alter the velocity profiles within them. So we no longer have to compute + * them. Or, if a set of sequential blocks from the first block in the planner (or a optimal stop-compute + * point) are all accelerating, they are all optimal and can not be altered by a new block added to the + * planner buffer, as this will only further increase the plan speed to chronological blocks until a maximum + * junction velocity is reached. However, if the operational conditions of the plan changes from infrequently + * used feed holds or feedrate overrides, the stop-compute pointers will be reset and the entire plan is + * recomputed as stated in the general guidelines. + * + * Planner buffer index mapping: + * - block_buffer_tail: Points to the beginning of the planner buffer. First to be executed or being executed. + * - block_buffer_head: Points to the buffer block after the last block in the buffer. Used to indicate whether + * the buffer is full or empty. As described for standard ring buffers, this block is always empty. + * - block_buffer_planned: Points to the first buffer block after the last optimally planned block for normal + * streaming operating conditions. Use for planning optimizations by avoiding recomputing parts of the + * planner buffer that don't change with the addition of a new block, as describe above. In addition, + * this block can never be less than block_buffer_tail and will always be pushed forward and maintain + * this requirement when encountered by the Planner::release_current_block() routine during a cycle. + * + * NOTE: Since the planner only computes on what's in the planner buffer, some motions with many short + * segments (e.g., complex curves) may seem to move slowly. This is because there simply isn't + * enough combined distance traveled in the entire buffer to accelerate up to the nominal speed and + * then decelerate to a complete stop at the end of the buffer, as stated by the guidelines. If this + * happens and becomes an annoyance, there are a few simple solutions: + * + * - Maximize the machine acceleration. The planner will be able to compute higher velocity profiles + * within the same combined distance. + * + * - Maximize line motion(s) distance per block to a desired tolerance. The more combined distance the + * planner has to use, the faster it can go. + * + * - Maximize the planner buffer size. This also will increase the combined distance for the planner to + * compute over. It also increases the number of computations the planner has to perform to compute an + * optimal plan, so select carefully. + * + * - Use G2/G3 arcs instead of many short segments. Arcs inform the planner of a safe exit speed at the + * end of the last segment, which alleviates this problem. + */ // The kernel called by recalculate() when scanning the plan from last to first entry. -void Planner::reverse_pass_kernel(block_t * const current, const block_t * const next) { +void Planner::reverse_pass_kernel(block_t * const current, const block_t * const next + OPTARG(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_speed_sqr) +) { if (current) { // If entry speed is already at the maximum entry speed, and there was no change of speed // in the next block, there is no need to recheck. Block is cruising and there is no need to @@ -948,7 +994,7 @@ void Planner::reverse_pass_kernel(block_t * const current, const block_t * const // Compute maximum entry speed decelerating over the current block from its exit speed. // If not at the maximum entry speed, or the previous block entry speed changed - if (current->entry_speed_sqr != max_entry_speed_sqr || (next && TEST(next->flag, BLOCK_BIT_RECALCULATE))) { + if (current->entry_speed_sqr != max_entry_speed_sqr || (next && next->flag.recalculate)) { // If nominal length true, max junction speed is guaranteed to be reached. // If a block can de/ac-celerate from nominal speed to zero within the length of the block, then @@ -958,14 +1004,15 @@ void Planner::reverse_pass_kernel(block_t * const current, const block_t * const // the reverse and forward planners, the corresponding block junction speed will always be at the // the maximum junction speed and may always be ignored for any speed reduction checks. - const float new_entry_speed_sqr = TEST(current->flag, BLOCK_BIT_NOMINAL_LENGTH) - ? max_entry_speed_sqr - : _MIN(max_entry_speed_sqr, max_allowable_speed_sqr(-current->acceleration, next ? next->entry_speed_sqr : sq(float(MINIMUM_PLANNER_SPEED)), current->millimeters)); + const float next_entry_speed_sqr = next ? next->entry_speed_sqr : _MAX(TERN0(HINTS_SAFE_EXIT_SPEED, safe_exit_speed_sqr), sq(float(MINIMUM_PLANNER_SPEED))), + new_entry_speed_sqr = current->flag.nominal_length + ? max_entry_speed_sqr + : _MIN(max_entry_speed_sqr, max_allowable_speed_sqr(-current->acceleration, next_entry_speed_sqr, current->millimeters)); if (current->entry_speed_sqr != new_entry_speed_sqr) { // Need to recalculate the block speed - Mark it now, so the stepper // ISR does not consume the block before being recalculated - SBI(current->flag, BLOCK_BIT_RECALCULATE); + current->flag.recalculate = true; // But there is an inherent race condition here, as the block may have // become BUSY just before being marked RECALCULATE, so check for that! @@ -973,7 +1020,7 @@ void Planner::reverse_pass_kernel(block_t * const current, const block_t * const // Block became busy. Clear the RECALCULATE flag (no point in // recalculating BUSY blocks). And don't set its speed, as it can't // be updated at this time. - CBI(current->flag, BLOCK_BIT_RECALCULATE); + current->flag.recalculate = false; } else { // Block is not BUSY so this is ahead of the Stepper ISR: @@ -989,7 +1036,7 @@ void Planner::reverse_pass_kernel(block_t * const current, const block_t * const * recalculate() needs to go over the current plan twice. * Once in reverse and once forward. This implements the reverse pass. */ -void Planner::reverse_pass() { +void Planner::reverse_pass(TERN_(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_speed_sqr)) { // Initialize block index to the last block in the planner buffer. uint8_t block_index = prev_block_index(block_buffer_head); @@ -1011,9 +1058,9 @@ void Planner::reverse_pass() { // Perform the reverse pass block_t *current = &block_buffer[block_index]; - // Only consider non sync-and-page blocks - if (!(current->flag & BLOCK_MASK_SYNC) && !IS_PAGE(current)) { - reverse_pass_kernel(current, next); + // Only process movement blocks + if (current->is_move()) { + reverse_pass_kernel(current, next OPTARG(HINTS_SAFE_EXIT_SPEED, safe_exit_speed_sqr)); next = current; } @@ -1041,8 +1088,7 @@ void Planner::forward_pass_kernel(const block_t * const previous, block_t * cons // change, adjust the entry speed accordingly. Entry speeds have already been reset, // maximized, and reverse-planned. If nominal length is set, max junction speed is // guaranteed to be reached. No need to recheck. - if (!TEST(previous->flag, BLOCK_BIT_NOMINAL_LENGTH) && - previous->entry_speed_sqr < current->entry_speed_sqr) { + if (!previous->flag.nominal_length && previous->entry_speed_sqr < current->entry_speed_sqr) { // Compute the maximum allowable speed const float new_entry_speed_sqr = max_allowable_speed_sqr(-previous->acceleration, previous->entry_speed_sqr, previous->millimeters); @@ -1052,7 +1098,7 @@ void Planner::forward_pass_kernel(const block_t * const previous, block_t * cons // Mark we need to recompute the trapezoidal shape, and do it now, // so the stepper ISR does not consume the block before being recalculated - SBI(current->flag, BLOCK_BIT_RECALCULATE); + current->flag.recalculate = true; // But there is an inherent race condition here, as the block maybe // became BUSY, just before it was marked as RECALCULATE, so check @@ -1061,7 +1107,7 @@ void Planner::forward_pass_kernel(const block_t * const previous, block_t * cons // Block became busy. Clear the RECALCULATE flag (no point in // recalculating BUSY blocks and don't set its speed, as it can't // be updated at this time. - CBI(current->flag, BLOCK_BIT_RECALCULATE); + current->flag.recalculate = false; } else { // Block is not BUSY, we won the race against the Stepper ISR: @@ -1106,8 +1152,8 @@ void Planner::forward_pass() { // Perform the forward pass block = &block_buffer[block_index]; - // Skip SYNC and page blocks - if (!(block->flag & BLOCK_MASK_SYNC) && !IS_PAGE(block)) { + // Only process movement blocks + if (block->is_move()) { // If there's no previous block or the previous block is not // BUSY (thus, modifiable) run the forward_pass_kernel. Otherwise, // the previous block became BUSY, so assume the current block's @@ -1127,7 +1173,7 @@ void Planner::forward_pass() { * according to the entry_factor for each junction. Must be called by * recalculate() after updating the blocks. */ -void Planner::recalculate_trapezoids() { +void Planner::recalculate_trapezoids(TERN_(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_speed_sqr)) { // The tail may be changed by the ISR so get a local copy. uint8_t block_index = block_buffer_tail, head_block_index = block_buffer_head; @@ -1142,8 +1188,8 @@ void Planner::recalculate_trapezoids() { // Get the pointer to the block block_t *prev = &block_buffer[prev_index]; - // If not dealing with a sync block, we are done. The last block is not a SYNC block - if (!(prev->flag & BLOCK_MASK_SYNC)) break; + // It the block is a move, we're done with this loop + if (prev->is_move()) break; // Examine the previous block. This and all following are SYNC blocks head_block_index = prev_index; @@ -1151,23 +1197,22 @@ void Planner::recalculate_trapezoids() { // Go from the tail (currently executed block) to the first block, without including it) block_t *block = nullptr, *next = nullptr; - float current_entry_speed = 0.0, next_entry_speed = 0.0; + float current_entry_speed = 0.0f, next_entry_speed = 0.0f; while (block_index != head_block_index) { next = &block_buffer[block_index]; - // Skip sync and page blocks - if (!(next->flag & BLOCK_MASK_SYNC) && !IS_PAGE(next)) { + // Only process movement blocks + if (next->is_move()) { next_entry_speed = SQRT(next->entry_speed_sqr); if (block) { - // Recalculate if current block entry or exit junction speed has changed. - if (TEST(block->flag, BLOCK_BIT_RECALCULATE) || TEST(next->flag, BLOCK_BIT_RECALCULATE)) { - // Mark the current block as RECALCULATE, to protect it from the Stepper ISR running it. - // Note that due to the above condition, there's a chance the current block isn't marked as - // RECALCULATE yet, but the next one is. That's the reason for the following line. - SBI(block->flag, BLOCK_BIT_RECALCULATE); + // If the next block is marked to RECALCULATE, also mark the previously-fetched one + if (next->flag.recalculate) block->flag.recalculate = true; + + // Recalculate if current block entry or exit junction speed has changed. + if (block->flag.recalculate) { // But there is an inherent race condition here, as the block maybe // became BUSY, just before it was marked as RECALCULATE, so check @@ -1176,21 +1221,13 @@ void Planner::recalculate_trapezoids() { // Block is not BUSY, we won the race against the Stepper ISR: // NOTE: Entry and exit factors always > 0 by all previous logic operations. - const float current_nominal_speed = SQRT(block->nominal_speed_sqr), - nomr = 1.0f / current_nominal_speed; + const float nomr = 1.0f / block->nominal_speed; calculate_trapezoid_for_block(block, current_entry_speed * nomr, next_entry_speed * nomr); - #if ENABLED(LIN_ADVANCE) - if (block->use_advance_lead) { - const float comp = block->e_D_ratio * extruder_advance_K[active_extruder] * settings.axis_steps_per_mm[E_AXIS]; - block->max_adv_steps = current_nominal_speed * comp; - block->final_adv_steps = next_entry_speed * comp; - } - #endif } // Reset current only to ensure next trapezoid is computed - The // stepper is free to use the block from now on. - CBI(block->flag, BLOCK_BIT_RECALCULATE); + block->flag.recalculate = false; } } @@ -1201,13 +1238,15 @@ void Planner::recalculate_trapezoids() { block_index = next_block_index(block_index); } - // Last/newest block in buffer. Exit speed is set with MINIMUM_PLANNER_SPEED. Always recalculated. - if (next) { + // Last/newest block in buffer. Always recalculated. + if (block) { + // Exit speed is set with MINIMUM_PLANNER_SPEED unless some code higher up knows better. + next_entry_speed = _MAX(TERN0(HINTS_SAFE_EXIT_SPEED, SQRT(safe_exit_speed_sqr)), float(MINIMUM_PLANNER_SPEED)); // Mark the next(last) block as RECALCULATE, to prevent the Stepper ISR running it. // As the last block is always recalculated here, there is a chance the block isn't // marked as RECALCULATE yet. That's the reason for the following line. - SBI(next->flag, BLOCK_BIT_RECALCULATE); + block->flag.recalculate = true; // But there is an inherent race condition here, as the block maybe // became BUSY, just before it was marked as RECALCULATE, so check @@ -1215,33 +1254,25 @@ void Planner::recalculate_trapezoids() { if (!stepper.is_block_busy(block)) { // Block is not BUSY, we won the race against the Stepper ISR: - const float next_nominal_speed = SQRT(next->nominal_speed_sqr), - nomr = 1.0f / next_nominal_speed; - calculate_trapezoid_for_block(next, next_entry_speed * nomr, float(MINIMUM_PLANNER_SPEED) * nomr); - #if ENABLED(LIN_ADVANCE) - if (next->use_advance_lead) { - const float comp = next->e_D_ratio * extruder_advance_K[active_extruder] * settings.axis_steps_per_mm[E_AXIS]; - next->max_adv_steps = next_nominal_speed * comp; - next->final_adv_steps = (MINIMUM_PLANNER_SPEED) * comp; - } - #endif + const float nomr = 1.0f / block->nominal_speed; + calculate_trapezoid_for_block(block, current_entry_speed * nomr, next_entry_speed * nomr); } - // Reset next only to ensure its trapezoid is computed - The stepper is free to use + // Reset block to ensure its trapezoid is computed - The stepper is free to use // the block from now on. - CBI(next->flag, BLOCK_BIT_RECALCULATE); + block->flag.recalculate = false; } } -void Planner::recalculate() { +void Planner::recalculate(TERN_(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_speed_sqr)) { // Initialize block index to the last block in the planner buffer. const uint8_t block_index = prev_block_index(block_buffer_head); // If there is just one block, no planning can be done. Avoid it! if (block_index != block_buffer_planned) { - reverse_pass(); + reverse_pass(TERN_(HINTS_SAFE_EXIT_SPEED, safe_exit_speed_sqr)); forward_pass(); } - recalculate_trapezoids(); + recalculate_trapezoids(TERN_(HINTS_SAFE_EXIT_SPEED, safe_exit_speed_sqr)); } /** @@ -1251,41 +1282,31 @@ void Planner::recalculate() { 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) const millis_t ms = millis(); - TERN_(HAS_FAN0, FAN_SET(0)); - TERN_(HAS_FAN1, FAN_SET(1)); - TERN_(HAS_FAN2, FAN_SET(2)); - TERN_(HAS_FAN3, FAN_SET(3)); - TERN_(HAS_FAN4, FAN_SET(4)); - TERN_(HAS_FAN5, FAN_SET(5)); - TERN_(HAS_FAN6, FAN_SET(6)); - TERN_(HAS_FAN7, FAN_SET(7)); + TERN_(HAS_FAN0, FAN_SET(0)); TERN_(HAS_FAN1, FAN_SET(1)); + TERN_(HAS_FAN2, FAN_SET(2)); TERN_(HAS_FAN3, FAN_SET(3)); + TERN_(HAS_FAN4, FAN_SET(4)); TERN_(HAS_FAN5, FAN_SET(5)); + TERN_(HAS_FAN6, FAN_SET(6)); TERN_(HAS_FAN7, FAN_SET(7)); } #if FAN_KICKSTART_TIME 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; @@ -1296,7 +1317,7 @@ void Planner::recalculate() { #endif // HAS_FAN /** - * Maintain fans, paste extruder pressure, + * Maintain fans, paste extruder pressure, spindle/laser power */ void Planner::check_axes_activity() { @@ -1360,7 +1381,7 @@ void Planner::check_axes_activity() { } else { - TERN_(HAS_CUTTER, cutter.refresh()); + TERN_(HAS_CUTTER, if (cutter.cutter_mode == CUTTER_MODE_STANDARD) cutter.refresh()); #if HAS_TAIL_FAN_SPEED FANS_LOOP(i) { @@ -1460,7 +1481,7 @@ void Planner::check_axes_activity() { for (uint8_t b = block_buffer_tail; b != block_buffer_head; b = next_block_index(b)) { const block_t * const block = &block_buffer[b]; if (NUM_AXIS_GANG(block->steps.x, || block->steps.y, || block->steps.z, || block->steps.i, || block->steps.j, || block->steps.k, || block->steps.u, || block->steps.v, || block->steps.w)) { - const float se = (float)block->steps.e / block->step_event_count * SQRT(block->nominal_speed_sqr); // mm/sec; + const float se = float(block->steps.e) / block->step_event_count * block->nominal_speed; // mm/sec NOLESS(high, se); } } @@ -1558,7 +1579,7 @@ void Planner::check_axes_activity() { TERN_(DELTA, settings.max_acceleration_mm_per_s2[Z_AXIS] = saved_motion_state.acceleration.z); TERN_(HAS_CLASSIC_JERK, max_jerk = saved_motion_state.jerk_state); } - reset_acceleration_rates(); + refresh_acceleration_rates(); } #endif @@ -1703,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(); @@ -1767,22 +1795,21 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { void Planner::synchronize() { while (busy()) idle(); } /** - * Planner::_buffer_steps - * - * Add a new linear movement to the planner queue (in terms of steps). + * @brief Add a new linear movement to the planner queue (in terms of steps). * - * target - target position in steps units - * target_float - target position in direct (mm, degrees) units. optional - * fr_mm_s - (target) speed of the move - * extruder - target extruder - * millimeters - the length of the movement, if known + * @param target Target position in steps units + * @param target_float Target position in direct (mm, degrees) units. + * @param cart_dist_mm The pre-calculated move lengths for all axes, in mm + * @param fr_mm_s (target) speed of the move + * @param extruder target extruder + * @param hints parameters to aid planner calculations * - * Returns true if movement was properly queued, false otherwise (if cleaning) + * @return true if movement was properly queued, false otherwise (if cleaning) */ bool Planner::_buffer_steps(const xyze_long_t &target OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters + , feedRate_t fr_mm_s, const uint8_t extruder, const PlannerHints &hints ) { // Wait for the next available block @@ -1795,11 +1822,12 @@ bool Planner::_buffer_steps(const xyze_long_t &target if (cleaning_buffer_counter) return false; // Fill the block with the specified movement - if (!_populate_block(block, false, target - OPTARG(HAS_POSITION_FLOAT, target_float) - OPTARG(HAS_DIST_MM_ARG, cart_dist_mm) - , fr_mm_s, extruder, millimeters - )) { + if (!_populate_block(block, target + OPTARG(HAS_POSITION_FLOAT, target_float) + OPTARG(HAS_DIST_MM_ARG, cart_dist_mm) + , fr_mm_s, extruder, hints + ) + ) { // Movement was not queued, probably because it was too short. // Simply accept that as movement queued and done return true; @@ -1819,28 +1847,34 @@ bool Planner::_buffer_steps(const xyze_long_t &target block_buffer_head = next_buffer_head; // Recalculate and optimize trapezoidal speed profiles - recalculate(); + recalculate(TERN_(HINTS_SAFE_EXIT_SPEED, hints.safe_exit_speed_sqr)); // Movement successfully queued! return true; } /** - * Planner::_populate_block + * @brief Populate a block in preparation for insertion + * @details Populate the fields of a new linear movement block + * that will be added to the queue and processed soon + * by the Stepper ISR. * - * Fills a new linear movement in the block (in terms of steps). + * @param block A block to populate + * @param target Target position in steps units + * @param target_float Target position in native mm + * @param cart_dist_mm The pre-calculated move lengths for all axes, in mm + * @param fr_mm_s (target) speed of the move + * @param extruder target extruder + * @param hints parameters to aid planner calculations * - * target - target position in steps units - * fr_mm_s - (target) speed of the move - * extruder - target extruder - * - * Returns true if movement is acceptable, false otherwise + * @return true if movement is acceptable, false otherwise */ -bool Planner::_populate_block(block_t * const block, bool split_move, +bool Planner::_populate_block( + block_t * const block, const abce_long_t &target OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters/*=0.0*/ + , feedRate_t fr_mm_s, const uint8_t extruder, const PlannerHints &hints ) { int32_t LOGICAL_AXIS_LIST( de = target.e - position.e, @@ -1905,7 +1939,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #if ENABLED(MIXING_EXTRUDER) bool ignore_e = false; float collector[MIXING_STEPPERS]; - mixer.refresh_collector(1.0, mixer.get_current_vtool(), collector); + mixer.refresh_collector(1.0f, mixer.get_current_vtool(), collector); MIXER_STEPPER_LOOP(e) if (e_steps * collector[e] > max_e_steps) { ignore_e = true; break; } #else @@ -1927,7 +1961,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) if (da < 0) SBI(dm, X_HEAD); // Save the toolhead's true direction in X if (db < 0) SBI(dm, Y_HEAD); // ...and Y - if (dc < 0) SBI(dm, Z_AXIS); + TERN_(HAS_Z_AXIS, if (dc < 0) SBI(dm, Z_AXIS)); #endif #if IS_CORE #if CORE_IS_XY @@ -1978,16 +2012,39 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif // Clear all flags, including the "busy" bit - block->flag = 0x00; + block->flag.clear(); // Set direction bits block->direction_bits = dm; - // Update block laser power - #if ENABLED(LASER_POWER_INLINE) - laser_inline.status.isPlanned = true; - block->laser.status = laser_inline.status; - block->laser.power = laser_inline.power; + /** + * Update block laser power + * For standard mode get the cutter.power value for processing, since it's + * only set by apply_power(). + */ + #if HAS_CUTTER + switch (cutter.cutter_mode) { + default: break; + + case CUTTER_MODE_STANDARD: block->cutter_power = cutter.power; break; + + #if ENABLED(LASER_FEATURE) + /** + * For inline mode get the laser_inline variables, including power and status. + * Dynamic mode only needs to update if the feedrate has changed, since it's + * calculated from the current feedrate and power level. + */ + case CUTTER_MODE_CONTINUOUS: + block->laser.power = laser_inline.power; + block->laser.status = laser_inline.status; + break; + + case CUTTER_MODE_DYNAMIC: + if (cutter.laser_feedrate_changed()) // Only process changes in rate + block->laser.power = laser_inline.power = cutter.calc_dynamic_power(); + break; + #endif + } #endif // Number of steps for each axis @@ -2028,7 +2085,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) steps_dist_mm.head.x = da * mm_per_step[A_AXIS]; steps_dist_mm.head.y = db * mm_per_step[B_AXIS]; - steps_dist_mm.z = dc * mm_per_step[Z_AXIS]; + TERN_(HAS_Z_AXIS, steps_dist_mm.z = dc * mm_per_step[Z_AXIS]); #endif #if IS_CORE #if CORE_IS_XY @@ -2093,8 +2150,8 @@ bool Planner::_populate_block(block_t * const block, bool split_move, block->millimeters = TERN0(HAS_EXTRUDERS, ABS(steps_dist_mm.e)); } else { - if (millimeters) - block->millimeters = millimeters; + if (hints.millimeters) + block->millimeters = hints.millimeters; else { /** * Distance for interpretation of feedrate in accordance with LinuxCNC (the successor of NIST @@ -2117,11 +2174,11 @@ bool Planner::_populate_block(block_t * const block, bool split_move, 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 - _MAX(sq(steps_dist_mm.x) + sq(steps_dist_mm.y), sq(steps_dist_mm.i) + sq(steps_dist_mm.j)) + // Special 5 axis kinematics. Return the largest distance move from either X/Y or I/J plane + _MAX(sq(steps_dist_mm.x) + sq(steps_dist_mm.y), sq(steps_dist_mm.i) + sq(steps_dist_mm.j)) #else // Foamcutter with only two axes (XY) sq(steps_dist_mm.x) + sq(steps_dist_mm.y) #endif @@ -2136,10 +2193,10 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif ); - #if SECONDARY_LINEAR_AXES >= 1 && NONE(FOAMCUTTER_XYUV, ARTICULATED_ROBOT_ARM) - if (NEAR_ZERO(distance_sqr)) { + #if SECONDARY_LINEAR_AXES && NONE(FOAMCUTTER_XYUV, ARTICULATED_ROBOT_ARM) + if (UNEAR_ZERO(distance_sqr)) { // Move does not involve any primary linear axes (xyz) but might involve secondary linear axes - distance_sqr = (0.0 + distance_sqr = (0.0f SECONDARY_AXIS_GANG( IF_DISABLED(AXIS4_ROTATES, + sq(steps_dist_mm.i)), IF_DISABLED(AXIS5_ROTATES, + sq(steps_dist_mm.j)), @@ -2153,7 +2210,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif #if HAS_ROTATIONAL_AXES && NONE(FOAMCUTTER_XYUV, ARTICULATED_ROBOT_ARM) - if (NEAR_ZERO(distance_sqr)) { + if (UNEAR_ZERO(distance_sqr)) { // Move involves only rotational axes. Calculate angular distance in accordance with LinuxCNC TERN_(INCH_MODE_SUPPORT, cartesian_move = false); distance_sqr = ROTATIONAL_AXIS_GANG(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)); @@ -2188,8 +2245,6 @@ bool Planner::_populate_block(block_t * const block, bool split_move, TERN_(MIXING_EXTRUDER, mixer.populate_block(block->b_color)); - TERN_(HAS_CUTTER, block->cutter_power = cutter.power); - #if HAS_FAN FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; #endif @@ -2203,15 +2258,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #if ENABLED(AUTO_POWER_CONTROL) if (NUM_AXIS_GANG( - block->steps.x, - || block->steps.y, - || block->steps.z, - || block->steps.i, - || block->steps.j, - || block->steps.k, - || block->steps.u, - || block->steps.v, - || block->steps.w + block->steps.x, || block->steps.y, || block->steps.z, + || block->steps.i, || block->steps.j, || block->steps.k, + || block->steps.u, || block->steps.v, || block->steps.w )) powerManager.power_on(); #endif @@ -2221,7 +2270,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, stepper.enable_axis(X_AXIS); stepper.enable_axis(Y_AXIS); } - #if DISABLED(Z_LATE_ENABLE) + #if HAS_Z_AXIS && DISABLED(Z_LATE_ENABLE) if (block->steps.z) stepper.enable_axis(Z_AXIS); #endif #elif CORE_IS_XZ @@ -2349,7 +2398,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (was_enabled) stepper.wake_up(); #endif - block->nominal_speed_sqr = sq(block->millimeters * inverse_secs); // (mm/sec)^2 Always > 0 + block->nominal_speed = block->millimeters * inverse_secs; // (mm/sec) Always > 0 block->nominal_rate = CEIL(block->step_event_count * inverse_secs); // (step/sec) Always > 0 #if ENABLED(FILAMENT_WIDTH_SENSOR) @@ -2445,19 +2494,21 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (speed_factor < 1.0f) { current_speed *= speed_factor; block->nominal_rate *= speed_factor; - block->nominal_speed_sqr = block->nominal_speed_sqr * sq(speed_factor); + block->nominal_speed *= speed_factor; } // Compute and limit the acceleration rate for the trapezoid generator. const float steps_per_mm = block->step_event_count * inverse_millimeters; uint32_t accel; + #if ENABLED(LIN_ADVANCE) + bool use_advance_lead = false; + #endif if (NUM_AXIS_GANG( !block->steps.a, && !block->steps.b, && !block->steps.c, && !block->steps.i, && !block->steps.j, && !block->steps.k, && !block->steps.u, && !block->steps.v, && !block->steps.w) ) { // Is this a retract / recover move? accel = CEIL(settings.retract_acceleration * steps_per_mm); // Convert to: acceleration steps/sec^2 - TERN_(LIN_ADVANCE, block->use_advance_lead = false); // No linear advance for simple retract/recover } else { #define LIMIT_ACCEL_LONG(AXIS,INDX) do{ \ @@ -2484,33 +2535,29 @@ bool Planner::_populate_block(block_t * const block, bool split_move, /** * Use LIN_ADVANCE for blocks if all these are true: * - * esteps : This is a print move, because we checked for A, B, C steps before. + * esteps : This is a print move, because we checked for A, B, C steps before. * - * extruder_advance_K[active_extruder] : There is an advance factor set for this extruder. + * extruder_advance_K[extruder] : There is an advance factor set for this extruder. * - * de > 0 : Extruder is running forward (e.g., for "Wipe while retracting" (Slic3r) or "Combing" (Cura) moves) + * de > 0 : Extruder is running forward (e.g., for "Wipe while retracting" (Slic3r) or "Combing" (Cura) moves) */ - block->use_advance_lead = esteps - && extruder_advance_K[active_extruder] - && de > 0; - - if (block->use_advance_lead) { - block->e_D_ratio = (target_float.e - position_float.e) / - #if IS_KINEMATIC - block->millimeters - #else + 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) / + TERN(IS_KINEMATIC, block->millimeters, SQRT(sq(target_float.x - position_float.x) + sq(target_float.y - position_float.y) + sq(target_float.z - position_float.z)) - #endif - ; + ); // Check for unusual high e_D ratio to detect if a retract move was combined with the last print move due to min. steps per segment. Never execute this with advance! // This assumes no one will use a retract length of 0mm < retr_length < ~0.2mm and no one will print 100mm wide lines using 3mm filament or 35mm wide lines using 1.75mm filament. - if (block->e_D_ratio > 3.0f) - block->use_advance_lead = false; + if (e_D_ratio > 3.0f) + use_advance_lead = false; else { - const uint32_t max_accel_steps_per_s2 = MAX_E_JERK(extruder) / (extruder_advance_K[active_extruder] * block->e_D_ratio) * steps_per_mm; + // 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[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); @@ -2522,29 +2569,17 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (block->step_event_count <= acceleration_long_cutoff) { LOGICAL_AXIS_CODE( LIMIT_ACCEL_LONG(E_AXIS, E_INDEX_N(extruder)), - LIMIT_ACCEL_LONG(A_AXIS, 0), - LIMIT_ACCEL_LONG(B_AXIS, 0), - LIMIT_ACCEL_LONG(C_AXIS, 0), - LIMIT_ACCEL_LONG(I_AXIS, 0), - LIMIT_ACCEL_LONG(J_AXIS, 0), - LIMIT_ACCEL_LONG(K_AXIS, 0), - LIMIT_ACCEL_LONG(U_AXIS, 0), - LIMIT_ACCEL_LONG(V_AXIS, 0), - LIMIT_ACCEL_LONG(W_AXIS, 0) + LIMIT_ACCEL_LONG(A_AXIS, 0), LIMIT_ACCEL_LONG(B_AXIS, 0), LIMIT_ACCEL_LONG(C_AXIS, 0), + LIMIT_ACCEL_LONG(I_AXIS, 0), LIMIT_ACCEL_LONG(J_AXIS, 0), LIMIT_ACCEL_LONG(K_AXIS, 0), + LIMIT_ACCEL_LONG(U_AXIS, 0), LIMIT_ACCEL_LONG(V_AXIS, 0), LIMIT_ACCEL_LONG(W_AXIS, 0) ); } else { LOGICAL_AXIS_CODE( LIMIT_ACCEL_FLOAT(E_AXIS, E_INDEX_N(extruder)), - LIMIT_ACCEL_FLOAT(A_AXIS, 0), - LIMIT_ACCEL_FLOAT(B_AXIS, 0), - LIMIT_ACCEL_FLOAT(C_AXIS, 0), - LIMIT_ACCEL_FLOAT(I_AXIS, 0), - LIMIT_ACCEL_FLOAT(J_AXIS, 0), - LIMIT_ACCEL_FLOAT(K_AXIS, 0), - LIMIT_ACCEL_FLOAT(U_AXIS, 0), - LIMIT_ACCEL_FLOAT(V_AXIS, 0), - LIMIT_ACCEL_FLOAT(W_AXIS, 0) + LIMIT_ACCEL_FLOAT(A_AXIS, 0), LIMIT_ACCEL_FLOAT(B_AXIS, 0), LIMIT_ACCEL_FLOAT(C_AXIS, 0), + LIMIT_ACCEL_FLOAT(I_AXIS, 0), LIMIT_ACCEL_FLOAT(J_AXIS, 0), LIMIT_ACCEL_FLOAT(K_AXIS, 0), + LIMIT_ACCEL_FLOAT(U_AXIS, 0), LIMIT_ACCEL_FLOAT(V_AXIS, 0), LIMIT_ACCEL_FLOAT(W_AXIS, 0) ); } } @@ -2554,13 +2589,21 @@ bool Planner::_populate_block(block_t * const block, bool split_move, block->acceleration_rate = (uint32_t)(accel * (float(1UL << 24) / (STEPPER_TIMER_RATE))); #endif #if ENABLED(LIN_ADVANCE) - if (block->use_advance_lead) { - block->advance_speed = (STEPPER_TIMER_RATE) / (extruder_advance_K[active_extruder] * block->e_D_ratio * block->acceleration * settings.axis_steps_per_mm[E_AXIS_N(extruder)]); + block->la_advance_rate = 0; + block->la_scaling = 0; + + if (use_advance_lead) { + // the Bresenham algorithm will convert this step rate into extruder steps + 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 + for (uint32_t dividend = block->steps.e << 1; dividend <= (block->step_event_count >> 2); dividend <<= 1) + block->la_scaling++; + #if ENABLED(LA_DEBUG) - if (extruder_advance_K[active_extruder] * block->e_D_ratio * block->acceleration * 2 < SQRT(block->nominal_speed_sqr) * block->e_D_ratio) - SERIAL_ECHOLNPGM("More than 2 steps per eISR loop executed."); - if (block->advance_speed < 200) - SERIAL_ECHOLNPGM("eISR running at > 10kHz."); + if (block->la_advance_rate >> block->la_scaling > 10000) + SERIAL_ECHOLNPGM("eISR running at > 10kHz: ", block->la_advance_rate); #endif } #endif @@ -2609,7 +2652,10 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #if HAS_DIST_MM_ARG cart_dist_mm #else - LOGICAL_AXIS_ARRAY(steps_dist_mm.e, steps_dist_mm.x, steps_dist_mm.y, steps_dist_mm.z, steps_dist_mm.i, steps_dist_mm.j, steps_dist_mm.k, steps_dist_mm.u, steps_dist_mm.v, steps_dist_mm.w) + LOGICAL_AXIS_ARRAY(steps_dist_mm.e, + steps_dist_mm.x, steps_dist_mm.y, steps_dist_mm.z, + steps_dist_mm.i, steps_dist_mm.j, steps_dist_mm.k, + steps_dist_mm.u, steps_dist_mm.v, steps_dist_mm.w) #endif ; @@ -2625,12 +2671,12 @@ bool Planner::_populate_block(block_t * const block, bool split_move, unit_vec *= inverse_millimeters; // Use pre-calculated (1 / SQRT(x^2 + y^2 + z^2)) // Skip first block or when previous_nominal_speed is used as a flag for homing and offset cycles. - if (moves_queued && !UNEAR_ZERO(previous_nominal_speed_sqr)) { + if (moves_queued && !UNEAR_ZERO(previous_nominal_speed)) { // Compute cosine of angle between previous and current path. (prev_unit_vec is negative) // NOTE: Max junction velocity is computed without sin() or acos() by trig half angle identity. float junction_cos_theta = LOGICAL_AXIS_GANG( + (-prev_unit_vec.e * unit_vec.e), - (-prev_unit_vec.x * unit_vec.x), + + (-prev_unit_vec.x * unit_vec.x), + (-prev_unit_vec.y * unit_vec.y), + (-prev_unit_vec.z * unit_vec.z), + (-prev_unit_vec.i * unit_vec.i), @@ -2647,108 +2693,114 @@ bool Planner::_populate_block(block_t * const block, bool split_move, vmax_junction_sqr = sq(float(MINIMUM_PLANNER_SPEED)); } else { - NOLESS(junction_cos_theta, -0.999999f); // Check for numerical round-off to avoid divide by zero. - // Convert delta vector to unit vector xyze_float_t junction_unit_vec = unit_vec - prev_unit_vec; normalize_junction_vector(junction_unit_vec); - const float junction_acceleration = limit_value_by_axis_maximum(block->acceleration, junction_unit_vec), - sin_theta_d2 = SQRT(0.5f * (1.0f - junction_cos_theta)); // Trig half angle identity. Always positive. - - vmax_junction_sqr = junction_acceleration * junction_deviation_mm * sin_theta_d2 / (1.0f - sin_theta_d2); - - #if ENABLED(JD_HANDLE_SMALL_SEGMENTS) - - // For small moves with >135° junction (octagon) find speed for approximate arc - if (block->millimeters < 1 && junction_cos_theta < -0.7071067812f) { - - #if ENABLED(JD_USE_MATH_ACOS) - - #error "TODO: Inline maths with the MCU / FPU." - - #elif ENABLED(JD_USE_LOOKUP_TABLE) - - // Fast acos approximation (max. error +-0.01 rads) - // Based on LUT table and linear interpolation - - /** - * // Generate the JD Lookup Table - * constexpr float c = 1.00751495f; // Correction factor to center error around 0 - * for (int i = 0; i < jd_lut_count - 1; ++i) { - * const float x0 = (sq(i) - 1) / sq(i), - * y0 = acos(x0) * (i == 0 ? 1 : c), - * x1 = i < jd_lut_count - 1 ? 0.5 * x0 + 0.5 : 0.999999f, - * y1 = acos(x1) * (i < jd_lut_count - 1 ? c : 1); - * jd_lut_k[i] = (y0 - y1) / (x0 - x1); - * jd_lut_b[i] = (y1 * x0 - y0 * x1) / (x0 - x1); - * } - * - * // Compute correction factor (Set c to 1.0f first!) - * float min = INFINITY, max = -min; - * for (float t = 0; t <= 1; t += 0.0003f) { - * const float e = acos(t) / approx(t); - * if (isfinite(e)) { - * if (e < min) min = e; - * if (e > max) max = e; - * } - * } - * fprintf(stderr, "%.9gf, ", (min + max) / 2); - */ - static constexpr int16_t jd_lut_count = 16; - static constexpr uint16_t jd_lut_tll = _BV(jd_lut_count - 1); - static constexpr int16_t jd_lut_tll0 = __builtin_clz(jd_lut_tll) + 1; // i.e., 16 - jd_lut_count + 1 - static constexpr float jd_lut_k[jd_lut_count] PROGMEM = { - -1.03145837f, -1.30760646f, -1.75205851f, -2.41705704f, - -3.37769222f, -4.74888992f, -6.69649887f, -9.45661736f, - -13.3640480f, -18.8928222f, -26.7136841f, -37.7754593f, - -53.4201813f, -75.5458374f, -106.836761f, -218.532821f }; - static constexpr float jd_lut_b[jd_lut_count] PROGMEM = { - 1.57079637f, 1.70887053f, 2.04220939f, 2.62408352f, - 3.52467871f, 4.85302639f, 6.77020454f, 9.50875854f, - 13.4009285f, 18.9188995f, 26.7321243f, 37.7885055f, - 53.4293975f, 75.5523529f, 106.841369f, 218.534011f }; - - const float neg = junction_cos_theta < 0 ? -1 : 1, - t = neg * junction_cos_theta; - - const int16_t idx = (t < 0.00000003f) ? 0 : __builtin_clz(uint16_t((1.0f - t) * jd_lut_tll)) - jd_lut_tll0; - - float junction_theta = t * pgm_read_float(&jd_lut_k[idx]) + pgm_read_float(&jd_lut_b[idx]); - if (neg > 0) junction_theta = RADIANS(180) - junction_theta; // acos(-t) - - #else - - // Fast acos(-t) approximation (max. error +-0.033rad = 1.89°) - // Based on MinMax polynomial published by W. Randolph Franklin, see - // https://wrf.ecse.rpi.edu/Research/Short_Notes/arcsin/onlyelem.html - // acos( t) = pi / 2 - asin(x) - // acos(-t) = pi - acos(t) ... pi / 2 + asin(x) - - const float neg = junction_cos_theta < 0 ? -1 : 1, - t = neg * junction_cos_theta, - asinx = 0.032843707f - + t * (-1.451838349f - + t * ( 29.66153956f - + t * (-131.1123477f - + t * ( 262.8130562f - + t * (-242.7199627f - + t * ( 84.31466202f ) ))))), - junction_theta = RADIANS(90) + neg * asinx; // acos(-t) - - // NOTE: junction_theta bottoms out at 0.033 which avoids divide by 0. - - #endif - - const float limit_sqr = (block->millimeters * junction_acceleration) / junction_theta; - NOMORE(vmax_junction_sqr, limit_sqr); - } + const float junction_acceleration = limit_value_by_axis_maximum(block->acceleration, junction_unit_vec); - #endif // JD_HANDLE_SMALL_SEGMENTS + if (TERN0(HINTS_CURVE_RADIUS, hints.curve_radius)) { + TERN_(HINTS_CURVE_RADIUS, vmax_junction_sqr = junction_acceleration * hints.curve_radius); + } + else { + NOLESS(junction_cos_theta, -0.999999f); // Check for numerical round-off to avoid divide by zero. + + const float sin_theta_d2 = SQRT(0.5f * (1.0f - junction_cos_theta)); // Trig half angle identity. Always positive. + + vmax_junction_sqr = junction_acceleration * junction_deviation_mm * sin_theta_d2 / (1.0f - sin_theta_d2); + + #if ENABLED(JD_HANDLE_SMALL_SEGMENTS) + + // For small moves with >135° junction (octagon) find speed for approximate arc + if (block->millimeters < 1 && junction_cos_theta < -0.7071067812f) { + + #if ENABLED(JD_USE_MATH_ACOS) + + #error "TODO: Inline maths with the MCU / FPU." + + #elif ENABLED(JD_USE_LOOKUP_TABLE) + + // Fast acos approximation (max. error +-0.01 rads) + // Based on LUT table and linear interpolation + + /** + * // Generate the JD Lookup Table + * constexpr float c = 1.00751495f; // Correction factor to center error around 0 + * for (int i = 0; i < jd_lut_count - 1; ++i) { + * const float x0 = (sq(i) - 1) / sq(i), + * y0 = acos(x0) * (i == 0 ? 1 : c), + * x1 = i < jd_lut_count - 1 ? 0.5 * x0 + 0.5 : 0.999999f, + * y1 = acos(x1) * (i < jd_lut_count - 1 ? c : 1); + * jd_lut_k[i] = (y0 - y1) / (x0 - x1); + * jd_lut_b[i] = (y1 * x0 - y0 * x1) / (x0 - x1); + * } + * + * // Compute correction factor (Set c to 1.0f first!) + * float min = INFINITY, max = -min; + * for (float t = 0; t <= 1; t += 0.0003f) { + * const float e = acos(t) / approx(t); + * if (isfinite(e)) { + * if (e < min) min = e; + * if (e > max) max = e; + * } + * } + * fprintf(stderr, "%.9gf, ", (min + max) / 2); + */ + static constexpr int16_t jd_lut_count = 16; + static constexpr uint16_t jd_lut_tll = _BV(jd_lut_count - 1); + static constexpr int16_t jd_lut_tll0 = __builtin_clz(jd_lut_tll) + 1; // i.e., 16 - jd_lut_count + 1 + static constexpr float jd_lut_k[jd_lut_count] PROGMEM = { + -1.03145837f, -1.30760646f, -1.75205851f, -2.41705704f, + -3.37769222f, -4.74888992f, -6.69649887f, -9.45661736f, + -13.3640480f, -18.8928222f, -26.7136841f, -37.7754593f, + -53.4201813f, -75.5458374f, -106.836761f, -218.532821f }; + static constexpr float jd_lut_b[jd_lut_count] PROGMEM = { + 1.57079637f, 1.70887053f, 2.04220939f, 2.62408352f, + 3.52467871f, 4.85302639f, 6.77020454f, 9.50875854f, + 13.4009285f, 18.9188995f, 26.7321243f, 37.7885055f, + 53.4293975f, 75.5523529f, 106.841369f, 218.534011f }; + + const float neg = junction_cos_theta < 0 ? -1 : 1, + t = neg * junction_cos_theta; + + const int16_t idx = (t < 0.00000003f) ? 0 : __builtin_clz(uint16_t((1.0f - t) * jd_lut_tll)) - jd_lut_tll0; + + float junction_theta = t * pgm_read_float(&jd_lut_k[idx]) + pgm_read_float(&jd_lut_b[idx]); + if (neg > 0) junction_theta = RADIANS(180) - junction_theta; // acos(-t) + + #else + + // Fast acos(-t) approximation (max. error +-0.033rad = 1.89°) + // Based on MinMax polynomial published by W. Randolph Franklin, see + // https://wrf.ecse.rpi.edu/Research/Short_Notes/arcsin/onlyelem.html + // acos( t) = pi / 2 - asin(x) + // acos(-t) = pi - acos(t) ... pi / 2 + asin(x) + + const float neg = junction_cos_theta < 0 ? -1 : 1, + t = neg * junction_cos_theta, + asinx = 0.032843707f + + t * (-1.451838349f + + t * ( 29.66153956f + + t * (-131.1123477f + + t * ( 262.8130562f + + t * (-242.7199627f + + t * ( 84.31466202f ) ))))), + junction_theta = RADIANS(90) + neg * asinx; // acos(-t) + + // NOTE: junction_theta bottoms out at 0.033 which avoids divide by 0. + + #endif + + const float limit_sqr = (block->millimeters * junction_acceleration) / junction_theta; + NOMORE(vmax_junction_sqr, limit_sqr); + } + + #endif // JD_HANDLE_SMALL_SEGMENTS + } } // Get the lowest speed - vmax_junction_sqr = _MIN(vmax_junction_sqr, block->nominal_speed_sqr, previous_nominal_speed_sqr); + vmax_junction_sqr = _MIN(vmax_junction_sqr, sq(block->nominal_speed), sq(previous_nominal_speed)); } else // Init entry speed to zero. Assume it starts from rest. Planner will correct this later. vmax_junction_sqr = 0; @@ -2757,27 +2809,17 @@ bool Planner::_populate_block(block_t * const block, bool split_move, #endif - #ifdef USE_CACHED_SQRT - #define CACHED_SQRT(N, V) \ - static float saved_V, N; \ - if (V != saved_V) { N = SQRT(V); saved_V = V; } - #else - #define CACHED_SQRT(N, V) const float N = SQRT(V) - #endif - #if HAS_CLASSIC_JERK /** * Adapted from Průša MKS firmware * https://github.com/prusa3d/Prusa-Firmware */ - CACHED_SQRT(nominal_speed, block->nominal_speed_sqr); - // Exit speed limited by a jerk to full halt of a previous last segment static float previous_safe_speed; // Start with a safe speed (from which the machine may halt to stop immediately). - float safe_speed = nominal_speed; + float safe_speed = block->nominal_speed; #ifndef TRAVEL_EXTRA_XYJERK #define TRAVEL_EXTRA_XYJERK 0 @@ -2790,7 +2832,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, maxj = (max_jerk[i] + (i == X_AXIS || i == Y_AXIS ? extra_xyjerk : 0.0f)); // mj : The max jerk setting for this axis if (jerk > maxj) { // cs > mj : New current speed too fast? if (limited) { // limited already? - const float mjerk = nominal_speed * maxj; // ns*mj + const float mjerk = block->nominal_speed * maxj; // ns*mj if (jerk * safe_speed > mjerk) safe_speed = mjerk / jerk; // ns*mj/cs } else { @@ -2801,7 +2843,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, } float vmax_junction; - if (moves_queued && !UNEAR_ZERO(previous_nominal_speed_sqr)) { + if (moves_queued && !UNEAR_ZERO(previous_nominal_speed)) { // Estimate a maximum velocity allowed at a joint of two successive segments. // If this maximum velocity allowed is lower than the minimum of the entry / exit safe velocities, // then the machine is not coasting anymore and the safe entry / exit velocities shall be used. @@ -2812,11 +2854,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // The junction velocity will be shared between successive segments. Limit the junction velocity to their minimum. // Pick the smaller of the nominal speeds. Higher speed shall not be achieved at the junction during coasting. - CACHED_SQRT(previous_nominal_speed, previous_nominal_speed_sqr); - float smaller_speed_factor = 1.0f; - if (nominal_speed < previous_nominal_speed) { - vmax_junction = nominal_speed; + if (block->nominal_speed < previous_nominal_speed) { + vmax_junction = block->nominal_speed; smaller_speed_factor = vmax_junction / previous_nominal_speed; } else @@ -2872,9 +2912,8 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // Initialize block entry speed. Compute based on deceleration to user-defined MINIMUM_PLANNER_SPEED. const float v_allowable_sqr = max_allowable_speed_sqr(-block->acceleration, sq(float(MINIMUM_PLANNER_SPEED)), block->millimeters); - // If we are trying to add a split block, start with the - // max. allowed speed to avoid an interrupted first move. - block->entry_speed_sqr = !split_move ? sq(float(MINIMUM_PLANNER_SPEED)) : _MIN(vmax_junction_sqr, v_allowable_sqr); + // Start with the minimum allowed speed + block->entry_speed_sqr = sq(float(MINIMUM_PLANNER_SPEED)); // Initialize planner efficiency flags // Set flag if block will always reach maximum junction speed regardless of entry/exit speeds. @@ -2884,11 +2923,11 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // block nominal speed limits both the current and next maximum junction speeds. Hence, in both // the reverse and forward planners, the corresponding block junction speed will always be at the // the maximum junction speed and may always be ignored for any speed reduction checks. - block->flag |= block->nominal_speed_sqr <= v_allowable_sqr ? BLOCK_FLAG_RECALCULATE | BLOCK_FLAG_NOMINAL_LENGTH : BLOCK_FLAG_RECALCULATE; + block->flag.set_nominal(sq(block->nominal_speed) <= v_allowable_sqr); // Update previous path unit_vector and nominal speed previous_speed = current_speed; - previous_nominal_speed_sqr = block->nominal_speed_sqr; + previous_nominal_speed = block->nominal_speed; position = target; // Update the position @@ -2905,33 +2944,35 @@ bool Planner::_populate_block(block_t * const block, bool split_move, } // _populate_block() /** - * Planner::buffer_sync_block - * Add a block to the buffer that just updates the position, - * or in case of LASER_SYNCHRONOUS_M106_M107 the fan PWM + * @brief Add a block to the buffer that just updates the position + * Supports LASER_SYNCHRONOUS_M106_M107 and LASER_POWER_SYNC power sync block buffer queueing. + * + * @param sync_flag The sync flag to set, determining the type of sync the block will do */ -void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_flag)) { - #if DISABLED(LASER_SYNCHRONOUS_M106_M107) - constexpr uint8_t sync_flag = BLOCK_FLAG_SYNC_POSITION; - #endif +void Planner::buffer_sync_block(const BlockFlagBit sync_flag/*=BLOCK_BIT_SYNC_POSITION*/) { // Wait for the next available block uint8_t next_buffer_head; block_t * const block = get_next_free_block(next_buffer_head); // Clear block - memset(block, 0, sizeof(block_t)); - - block->flag = sync_flag; + block->reset(); + block->flag.apply(sync_flag); block->position = position; #if ENABLED(BACKLASH_COMPENSATION) LOOP_NUM_AXES(axis) block->position[axis] += backlash.get_applied_steps((AxisEnum)axis); #endif - #if BOTH(HAS_FAN, LASER_SYNCHRONOUS_M106_M107) FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; #endif + /** + * M3-based power setting can be processed inline with a laser power sync block. + * During active moves cutter.power is processed immediately, otherwise on the next move. + */ + TERN_(LASER_POWER_SYNC, block->laser.power = cutter.power); + // If this is the first added movement, reload the delay, otherwise, cancel it. if (block_buffer_head == block_buffer_tail) { // If it was the first queued block, restart the 1st block delivery delay, to @@ -2948,22 +2989,24 @@ void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_ } // buffer_sync_block() /** - * Planner::buffer_segment + * @brief Add a single linear movement * - * Add a new linear movement to the buffer in axis units. + * @description Add a new linear movement to the buffer in axis units. + * Leveling and kinematics should be applied before calling this. * - * Leveling and kinematics should be applied ahead of calling this. + * @param abce Target position in mm and/or degrees + * @param cart_dist_mm The pre-calculated move lengths for all axes, in mm + * @param fr_mm_s (target) speed of the move + * @param extruder optional target extruder (otherwise active_extruder) + * @param hints optional parameters to aid planner calculations * - * a,b,c,e - target positions in mm and/or degrees - * fr_mm_s - (target) speed of the move - * extruder - target extruder - * millimeters - the length of the movement, if known - * - * Return 'false' if no segment was queued due to cleaning, cold extrusion, full queue, etc. + * @return false if no segment was queued due to cleaning, cold extrusion, full queue, etc. */ bool Planner::buffer_segment(const abce_pos_t &abce OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , const_feedRate_t fr_mm_s, const uint8_t extruder/*=active_extruder*/, const_float_t millimeters/*=0.0*/ + , const_feedRate_t fr_mm_s + , const uint8_t extruder/*=active_extruder*/ + , const PlannerHints &hints/*=PlannerHints()*/ ) { // If we are cleaning, do not accept queuing of movements @@ -3069,8 +3112,8 @@ bool Planner::buffer_segment(const abce_pos_t &abce if (!_buffer_steps(target OPTARG(HAS_POSITION_FLOAT, target_float) OPTARG(HAS_DIST_MM_ARG, cart_dist_mm) - , fr_mm_s, extruder, millimeters) - ) return false; + , fr_mm_s, extruder, hints + )) return false; stepper.wake_up(); return true; @@ -3083,12 +3126,12 @@ bool Planner::buffer_segment(const abce_pos_t &abce * * cart - target position in mm or degrees * fr_mm_s - (target) speed of the move (mm/s) - * extruder - target extruder - * millimeters - the length of the movement, if known - * inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled) + * extruder - optional target extruder (otherwise active_extruder) + * hints - optional parameters to aid planner calculations */ -bool Planner::buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, const uint8_t extruder/*=active_extruder*/, const float millimeters/*=0.0*/ - OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration/*=0.0*/) +bool Planner::buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s + , const uint8_t extruder/*=active_extruder*/ + , const PlannerHints &hints/*=PlannerHints()*/ ) { xyze_pos_t machine = cart; TERN_(HAS_POSITION_MODIFIERS, apply_modifiers(machine)); @@ -3110,28 +3153,32 @@ bool Planner::buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, cons ); #endif - const float mm = millimeters ?: (cart_dist_mm.x || cart_dist_mm.y) ? cart_dist_mm.magnitude() : TERN0(HAS_Z_AXIS, ABS(cart_dist_mm.z)); - // Cartesian XYZ to kinematic ABC, stored in global 'delta' inverse_kinematics(machine); + PlannerHints ph = hints; + if (!hints.millimeters) + ph.millimeters = (cart_dist_mm.x || cart_dist_mm.y) + ? xyz_pos_t(cart_dist_mm).magnitude() + : TERN0(HAS_Z_AXIS, ABS(cart_dist_mm.z)); + #if ENABLED(SCARA_FEEDRATE_SCALING) - // For SCARA scale the feed rate from mm/s to degrees/s + // For SCARA scale the feedrate from mm/s to degrees/s // i.e., Complete the angular vector in the given time. - const float duration_recip = inv_duration ?: fr_mm_s / mm; + const float duration_recip = hints.inv_duration ?: fr_mm_s / ph.millimeters; const xyz_pos_t diff = delta - position_float; const feedRate_t feedrate = diff.magnitude() * duration_recip; #else const feedRate_t feedrate = fr_mm_s; #endif TERN_(HAS_EXTRUDERS, delta.e = machine.e); - if (buffer_segment(delta OPTARG(HAS_DIST_MM_ARG, cart_dist_mm), feedrate, extruder, mm)) { + if (buffer_segment(delta OPTARG(HAS_DIST_MM_ARG, cart_dist_mm), feedrate, extruder, ph)) { position_cart = cart; return true; } return false; #else - return buffer_segment(machine, fr_mm_s, extruder, millimeters); + return buffer_segment(machine, fr_mm_s, extruder, hints); #endif } // buffer_line() @@ -3146,7 +3193,7 @@ bool Planner::buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, cons uint8_t next_buffer_head; block_t * const block = get_next_free_block(next_buffer_head); - block->flag = BLOCK_FLAG_IS_PAGE; + block->flag.reset(BLOCK_BIT_PAGE); #if HAS_FAN FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; @@ -3219,9 +3266,9 @@ void Planner::set_machine_position_mm(const abce_pos_t &abce) { ); if (has_blocks_queued()) { - //previous_nominal_speed_sqr = 0.0; // Reset planner junction speeds. Assume start from rest. + //previous_nominal_speed = 0.0f; // Reset planner junction speeds. Assume start from rest. //previous_speed.reset(); - buffer_sync_block(); + buffer_sync_block(BLOCK_BIT_SYNC_POSITION); } else { #if ENABLED(BACKLASH_COMPENSATION) @@ -3262,7 +3309,7 @@ void Planner::set_position_mm(const xyze_pos_t &xyze) { TERN_(IS_KINEMATIC, TERN_(HAS_EXTRUDERS, position_cart.e = e)); if (has_blocks_queued()) - buffer_sync_block(); + buffer_sync_block(BLOCK_BIT_SYNC_POSITION); else stepper.set_axis_position(E_AXIS, position.e); } @@ -3270,7 +3317,7 @@ void Planner::set_position_mm(const xyze_pos_t &xyze) { #endif // Recalculate the steps/s^2 acceleration rates, based on the mm/s^2 -void Planner::reset_acceleration_rates() { +void Planner::refresh_acceleration_rates() { uint32_t highest_rate = 1; LOOP_DISTINCT_AXES(i) { max_acceleration_steps_per_s2[i] = settings.max_acceleration_mm_per_s2[i] * settings.axis_steps_per_mm[i]; @@ -3288,14 +3335,14 @@ void Planner::reset_acceleration_rates() { void Planner::refresh_positioning() { LOOP_DISTINCT_AXES(i) mm_per_step[i] = 1.0f / settings.axis_steps_per_mm[i]; set_position_mm(current_position); - reset_acceleration_rates(); + refresh_acceleration_rates(); } // Apply limits to a variable and give a warning if the value was out of range inline void limit_and_warn(float &val, const AxisEnum axis, PGM_P const setting_name, const xyze_float_t &max_limit) { const uint8_t lim_axis = TERN_(HAS_EXTRUDERS, axis > E_AXIS ? E_AXIS :) axis; const float before = val; - LIMIT(val, 0.1, max_limit[lim_axis]); + LIMIT(val, 0.1f, max_limit[lim_axis]); if (before != val) { SERIAL_CHAR(AXIS_CHAR(lim_axis)); SERIAL_ECHOPGM(" Max "); @@ -3307,7 +3354,7 @@ inline void limit_and_warn(float &val, const AxisEnum axis, PGM_P const setting_ /** * For the specified 'axis' set the Maximum Acceleration to the given value (mm/s^2) * The value may be limited with warning feedback, if configured. - * Calls reset_acceleration_rates to precalculate planner terms in steps. + * Calls refresh_acceleration_rates to precalculate planner terms in steps. * * This hard limit is applied as a block is being added to the planner queue. */ @@ -3325,7 +3372,7 @@ void Planner::set_max_acceleration(const AxisEnum axis, float inMaxAccelMMS2) { settings.max_acceleration_mm_per_s2[axis] = inMaxAccelMMS2; // Update steps per s2 to agree with the units per s2 (since they are used in the planner) - reset_acceleration_rates(); + refresh_acceleration_rates(); } /** @@ -3394,8 +3441,7 @@ void Planner::set_max_feedrate(const AxisEnum axis, float inMaxFeedrateMMS) { // Doesn't matter because block_buffer_runtime_us is already too small an estimation. bbru >>= 10; // limit to about a minute. - NOMORE(bbru, 0x0000FFFFUL); - return bbru; + return _MIN(bbru, 0x0000FFFFUL); } void Planner::clear_block_buffer_runtime() { diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index bef381b5c7c4..dcfdb1c28e6b 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -70,9 +70,6 @@ #if ENABLED(DIRECT_STEPPING) #include "../feature/direct_stepping.h" - #define IS_PAGE(B) TEST(B->flag, BLOCK_BIT_IS_PAGE) -#else - #define IS_PAGE(B) false #endif #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER) @@ -92,7 +89,10 @@ #define HAS_DIST_MM_ARG 1 #endif -enum BlockFlagBit : char { +/** + * Planner block flags as boolean bit fields + */ +enum BlockFlagBit { // Recalculate trapezoids on entry junction. For optimization. BLOCK_BIT_RECALCULATE, @@ -108,50 +108,72 @@ enum BlockFlagBit : char { BLOCK_BIT_SYNC_POSITION // Direct stepping page - #if ENABLED(DIRECT_STEPPING) - , BLOCK_BIT_IS_PAGE - #endif + OPTARG(DIRECT_STEPPING, BLOCK_BIT_PAGE) + // Sync the fan speeds from the block - #if ENABLED(LASER_SYNCHRONOUS_M106_M107) - , BLOCK_BIT_SYNC_FANS - #endif -}; + OPTARG(LASER_SYNCHRONOUS_M106_M107, BLOCK_BIT_SYNC_FANS) -enum BlockFlag : char { - BLOCK_FLAG_RECALCULATE = _BV(BLOCK_BIT_RECALCULATE) - , BLOCK_FLAG_NOMINAL_LENGTH = _BV(BLOCK_BIT_NOMINAL_LENGTH) - , BLOCK_FLAG_CONTINUED = _BV(BLOCK_BIT_CONTINUED) - , BLOCK_FLAG_SYNC_POSITION = _BV(BLOCK_BIT_SYNC_POSITION) - #if ENABLED(DIRECT_STEPPING) - , BLOCK_FLAG_IS_PAGE = _BV(BLOCK_BIT_IS_PAGE) - #endif - #if ENABLED(LASER_SYNCHRONOUS_M106_M107) - , BLOCK_FLAG_SYNC_FANS = _BV(BLOCK_BIT_SYNC_FANS) - #endif + // Sync laser power from a queued block + OPTARG(LASER_POWER_SYNC, BLOCK_BIT_LASER_PWR) }; -#define BLOCK_MASK_SYNC ( BLOCK_FLAG_SYNC_POSITION | TERN0(LASER_SYNCHRONOUS_M106_M107, BLOCK_FLAG_SYNC_FANS) ) +/** + * Planner block flags as boolean bit fields + */ +typedef struct { + union { + uint8_t bits; + + struct { + bool recalculate:1; -#if ENABLED(LASER_POWER_INLINE) + bool nominal_length:1; + + bool continued:1; + + bool sync_position:1; + + #if ENABLED(DIRECT_STEPPING) + bool page:1; + #endif + + #if ENABLED(LASER_SYNCHRONOUS_M106_M107) + bool sync_fans:1; + #endif + + #if ENABLED(LASER_POWER_SYNC) + bool sync_laser_pwr:1; + #endif + }; + }; + + void clear() volatile { bits = 0; } + void apply(const uint8_t f) volatile { bits |= f; } + void apply(const BlockFlagBit b) volatile { SBI(bits, b); } + void reset(const BlockFlagBit b) volatile { bits = _BV(b); } + void set_nominal(const bool n) volatile { recalculate = true; if (n) nominal_length = true; } + +} block_flags_t; + +#if ENABLED(LASER_FEATURE) typedef struct { - bool isPlanned:1; - bool isEnabled:1; + bool isEnabled:1; // Set to engage the inline laser power output. bool dir:1; - bool Reserved:6; + bool isPowered:1; // Set on any parsed G1, G2, G3, or G5 powered move, cleared on G0 and G28. + bool isSyncPower:1; // Set on a M3 sync based set laser power, used to determine active trap power + bool Reserved:4; } power_status_t; typedef struct { - power_status_t status; // See planner settings for meaning - uint8_t power; // Ditto; When in trapezoid mode this is nominal power - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - uint8_t power_entry; // Entry power for the laser - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - uint8_t power_exit; // Exit power for the laser - uint32_t entry_per, // Steps per power increment (to avoid floats in stepper calcs) - exit_per; // Steps per power decrement - #endif + power_status_t status; // See planner settings for meaning + uint8_t power; // Ditto; When in trapezoid mode this is nominal power + + #if ENABLED(LASER_POWER_TRAP) + float trap_ramp_active_pwr; // Laser power level during active trapezoid smoothing + float trap_ramp_entry_incr; // Acceleration per step laser power increment (trap entry) + float trap_ramp_exit_decr; // Deceleration per step laser power decrement (trap exit) #endif } block_laser_t; @@ -166,12 +188,18 @@ enum BlockFlag : char { * The "nominal" values are as-specified by G-code, and * may never actually be reached due to acceleration limits. */ -typedef struct block_t { +typedef struct PlannerBlock { - volatile uint8_t flag; // Block flags (See BlockFlag enum above) - Modified by ISR and main thread! + volatile block_flags_t flag; // Block flags + + 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_sqr, // The nominal speed for this block in (mm/sec)^2 + float nominal_speed, // The nominal speed for this block in (mm/sec) entry_speed_sqr, // Entry speed at previous-current junction in (mm/sec)^2 max_entry_speed_sqr, // Maximum allowable junction entry speed in (mm/sec)^2 millimeters, // The total travel of this block in mm @@ -211,11 +239,10 @@ typedef struct block_t { // Advance extrusion #if ENABLED(LIN_ADVANCE) - bool use_advance_lead; - uint16_t advance_speed, // STEP timer value for extruder speed offset ISR - max_adv_steps, // max. advance steps to get cruising speed pressure (not always nominal_speed!) - final_adv_steps; // advance steps due to exit speed - float e_D_ratio; + uint32_t la_advance_rate; // The rate at which steps are added whilst accelerating + uint8_t la_scaling; // Scale ISR frequency down and step frequency up by 2 ^ la_scaling + uint16_t max_adv_steps, // Max advance steps to get cruising speed pressure + final_adv_steps; // Advance steps for exit speed pressure #endif uint32_t nominal_rate, // The nominal step rate for this block in step_events/sec @@ -248,10 +275,12 @@ typedef struct block_t { xyze_pos_t start_position; #endif - #if ENABLED(LASER_POWER_INLINE) + #if ENABLED(LASER_FEATURE) block_laser_t laser; #endif + void reset() { memset((char*)this, 0, sizeof(*this)); } + } block_t; #if ANY(LIN_ADVANCE, SCARA_FEEDRATE_SCALING, GRADIENT_MIX, LCD_SHOW_E_TOTAL, POWER_LOSS_RECOVERY) @@ -260,7 +289,7 @@ typedef struct block_t { #define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1)) -#if ENABLED(LASER_POWER_INLINE) +#if ENABLED(LASER_FEATURE) typedef struct { /** * Laser status flags @@ -269,11 +298,10 @@ typedef struct block_t { /** * Laser power: 0 or 255 in case of PWM-less laser, * or the OCR (oscillator count register) value; - * * Using OCR instead of raw power, because it avoids * floating point operations during the move loop. */ - uint8_t power; + volatile uint8_t power; } laser_state_t; #endif @@ -322,6 +350,30 @@ typedef struct { typedef IF<(BLOCK_BUFFER_SIZE > 64), uint16_t, uint8_t>::type last_move_t; #endif +#if ENABLED(ARC_SUPPORT) + #define HINTS_CURVE_RADIUS + #define HINTS_SAFE_EXIT_SPEED +#endif + +struct PlannerHints { + float millimeters = 0.0; // Move Length, if known, else 0. + #if ENABLED(SCARA_FEEDRATE_SCALING) + float inv_duration = 0.0; // Reciprocal of the move duration, if known + #endif + #if ENABLED(HINTS_CURVE_RADIUS) + float curve_radius = 0.0; // Radius of curvature of the motion path - to calculate cornering speed + #else + static constexpr float curve_radius = 0.0; + #endif + #if ENABLED(HINTS_SAFE_EXIT_SPEED) + float safe_exit_speed_sqr = 0.0; // Square of the speed considered "safe" at the end of the segment + // i.e., at or below the exit speed of the segment that the planner + // would calculate if it knew the as-yet-unbuffered path + #endif + + PlannerHints(const_float_t mm=0.0f) : millimeters(mm) {} +}; + class Planner { public: @@ -375,7 +427,7 @@ class Planner { static planner_settings_t settings; - #if ENABLED(LASER_POWER_INLINE) + #if ENABLED(LASER_FEATURE) static laser_state_t laser_inline; #endif @@ -407,7 +459,7 @@ class Planner { #endif #if ENABLED(LIN_ADVANCE) - static float extruder_advance_K[EXTRUDERS]; + static float extruder_advance_K[DISTINCT_E]; #endif /** @@ -457,7 +509,7 @@ class Planner { /** * Nominal speed of previous path line segment (mm/s)^2 */ - static float previous_nominal_speed_sqr; + static float previous_nominal_speed; /** * Limit where 64bit math is necessary for acceleration calculation @@ -492,7 +544,7 @@ class Planner { */ // Recalculate steps/s^2 accelerations based on mm/s^2 settings - static void reset_acceleration_rates(); + static void refresh_acceleration_rates(); /** * Recalculate 'position' and 'mm_per_step'. @@ -725,42 +777,45 @@ class Planner { * target - target position in steps units * fr_mm_s - (target) speed of the move * extruder - target extruder - * millimeters - the length of the movement, if known + * hints - parameters to aid planner calculations * * Returns true if movement was buffered, false otherwise */ static bool _buffer_steps(const xyze_long_t &target OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 + , feedRate_t fr_mm_s, const uint8_t extruder, const PlannerHints &hints ); /** - * Planner::_populate_block + * @brief Populate a block in preparation for insertion + * @details Populate the fields of a new linear movement block + * that will be added to the queue and processed soon + * by the Stepper ISR. * - * Fills a new linear movement in the block (in terms of steps). + * @param block A block to populate + * @param target Target position in steps units + * @param target_float Target position in native mm + * @param cart_dist_mm The pre-calculated move lengths for all axes, in mm + * @param fr_mm_s (target) speed of the move + * @param extruder target extruder + * @param hints parameters to aid planner calculations * - * target - target position in steps units - * fr_mm_s - (target) speed of the move - * extruder - target extruder - * millimeters - the length of the movement, if known - * - * Returns true is movement is acceptable, false otherwise + * @return true if movement is acceptable, false otherwise */ - static bool _populate_block(block_t * const block, bool split_move, const xyze_long_t &target + static bool _populate_block(block_t * const block, const xyze_long_t &target OPTARG(HAS_POSITION_FLOAT, const xyze_pos_t &target_float) OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , feedRate_t fr_mm_s, const uint8_t extruder, const_float_t millimeters=0.0 + , feedRate_t fr_mm_s, const uint8_t extruder, const PlannerHints &hints ); /** * Planner::buffer_sync_block - * Add a block to the buffer that just updates the position or in - * case of LASER_SYNCHRONOUS_M106_M107 the fan pwm + * Add a block to the buffer that just updates the position + * @param sync_flag sets a condition bit to process additional items + * such as sync fan pwm or sync M3/M4 laser power into a queued block */ - static void buffer_sync_block( - TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_flag=BLOCK_FLAG_SYNC_POSITION) - ); + static void buffer_sync_block(const BlockFlagBit flag=BLOCK_BIT_SYNC_POSITION); #if IS_KINEMATIC private: @@ -778,12 +833,14 @@ class Planner { * * a,b,c,e - target positions in mm and/or degrees * fr_mm_s - (target) speed of the move - * extruder - target extruder - * millimeters - the length of the movement, if known + * extruder - optional target extruder (otherwise active_extruder) + * hints - optional parameters to aid planner calculations */ static bool buffer_segment(const abce_pos_t &abce OPTARG(HAS_DIST_MM_ARG, const xyze_float_t &cart_dist_mm) - , const_feedRate_t fr_mm_s, const uint8_t extruder=active_extruder, const_float_t millimeters=0.0 + , const_feedRate_t fr_mm_s + , const uint8_t extruder=active_extruder + , const PlannerHints &hints=PlannerHints() ); public: @@ -795,12 +852,12 @@ class Planner { * * cart - target position in mm or degrees * fr_mm_s - (target) speed of the move (mm/s) - * extruder - target extruder - * millimeters - the length of the movement, if known - * inv_duration - the reciprocal if the duration of the movement, if known (kinematic only if feeedrate scaling is enabled) + * extruder - optional target extruder (otherwise active_extruder) + * hints - optional parameters to aid planner calculations */ - static bool buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s, const uint8_t extruder=active_extruder, const float millimeters=0.0 - OPTARG(SCARA_FEEDRATE_SCALING, const_float_t inv_duration=0.0) + static bool buffer_line(const xyze_pos_t &cart, const_feedRate_t fr_mm_s + , const uint8_t extruder=active_extruder + , const PlannerHints &hints=PlannerHints() ); #if ENABLED(DIRECT_STEPPING) @@ -873,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(); @@ -931,7 +984,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 @@ -951,28 +1004,6 @@ class Planner { static constexpr uint8_t next_block_index(const uint8_t block_index) { return BLOCK_MOD(block_index + 1); } static constexpr uint8_t prev_block_index(const uint8_t block_index) { return BLOCK_MOD(block_index - 1); } - /** - * Calculate the distance (not time) it takes to accelerate - * from initial_rate to target_rate using the given acceleration: - */ - static float estimate_acceleration_distance(const_float_t initial_rate, const_float_t target_rate, const_float_t accel) { - if (accel == 0) return 0; // accel was 0, set acceleration distance to 0 - return (sq(target_rate) - sq(initial_rate)) / (accel * 2); - } - - /** - * Return the point at which you must start braking (at the rate of -'accel') if - * you start at 'initial_rate', accelerate (until reaching the point), and want to end at - * 'final_rate' after traveling 'distance'. - * - * This is used to compute the intersection point between acceleration and deceleration - * in cases where the "trapezoid" has no plateau (i.e., never reaches maximum speed) - */ - static float intersection_distance(const_float_t initial_rate, const_float_t final_rate, const_float_t accel, const_float_t distance) { - if (accel == 0) return 0; // accel was 0, set intersection distance to 0 - return (accel * 2 * distance - sq(initial_rate) + sq(final_rate)) / (accel * 4); - } - /** * Calculate the maximum allowable speed squared at this point, in order * to reach 'target_velocity_sqr' using 'acceleration' within a given @@ -982,7 +1013,7 @@ class Planner { return target_velocity_sqr - 2 * accel * distance; } - #if ENABLED(S_CURVE_ACCELERATION) + #if EITHER(S_CURVE_ACCELERATION, LIN_ADVANCE) /** * Calculate the speed reached given initial speed, acceleration and distance */ @@ -993,15 +1024,15 @@ class Planner { static void calculate_trapezoid_for_block(block_t * const block, const_float_t entry_factor, const_float_t exit_factor); - static void reverse_pass_kernel(block_t * const current, const block_t * const next); + static void reverse_pass_kernel(block_t * const current, const block_t * const next OPTARG(ARC_SUPPORT, const_float_t safe_exit_speed_sqr)); static void forward_pass_kernel(const block_t * const previous, block_t * const current, uint8_t block_index); - static void reverse_pass(); + static void reverse_pass(TERN_(ARC_SUPPORT, const_float_t safe_exit_speed_sqr)); static void forward_pass(); - static void recalculate_trapezoids(); + static void recalculate_trapezoids(TERN_(ARC_SUPPORT, const_float_t safe_exit_speed_sqr)); - static void recalculate(); + static void recalculate(TERN_(ARC_SUPPORT, const_float_t safe_exit_speed_sqr)); #if HAS_JUNCTION_DEVIATION diff --git a/Marlin/src/module/planner_bezier.cpp b/Marlin/src/module/planner_bezier.cpp index fa7e16a387e6..a3f98435d04a 100644 --- a/Marlin/src/module/planner_bezier.cpp +++ b/Marlin/src/module/planner_bezier.cpp @@ -121,9 +121,12 @@ void cubic_b_spline( millis_t next_idle_ms = millis() + 200UL; + // Hints to help optimize the move + PlannerHints hints; + for (float t = 0; t < 1;) { - thermalManager.manage_heater(); + thermalManager.task(); millis_t now = millis(); if (ELAPSED(now, next_idle_ms)) { next_idle_ms = now + 200UL; @@ -177,7 +180,7 @@ void cubic_b_spline( } */ - step = new_t - t; + hints.millimeters = new_t - t; t = new_t; // Compute and send new position @@ -203,7 +206,7 @@ void cubic_b_spline( const xyze_pos_t &pos = bez_target; #endif - if (!planner.buffer_line(pos, scaled_fr_mm_s, active_extruder, step)) + if (!planner.buffer_line(pos, scaled_fr_mm_s, active_extruder, hints)) break; } } diff --git a/Marlin/src/module/polargraph.cpp b/Marlin/src/module/polargraph.cpp index b7eeeee8af5d..d55d36a6d654 100644 --- a/Marlin/src/module/polargraph.cpp +++ b/Marlin/src/module/polargraph.cpp @@ -37,10 +37,12 @@ #include "../lcd/marlinui.h" #include "../MarlinCore.h" -float segments_per_second; // Initialized by settings.load() +// 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 - (X_MIN_POS), x2 = (X_MAX_POS) - raw.x, y = raw.y - (Y_MAX_POS); + 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 040603425334..f4904ebfe21c 100644 --- a/Marlin/src/module/polargraph.h +++ b/Marlin/src/module/polargraph.h @@ -29,5 +29,7 @@ #include "../core/macros.h" extern float segments_per_second; +extern xy_pos_t draw_area_min, draw_area_max; +extern float polargraph_max_belt_len; void inverse_kinematics(const xyz_pos_t &raw); diff --git a/Marlin/src/module/printcounter.cpp b/Marlin/src/module/printcounter.cpp index 619fbc137ce4..f3d9ec8a9d85 100644 --- a/Marlin/src/module/printcounter.cpp +++ b/Marlin/src/module/printcounter.cpp @@ -37,11 +37,11 @@ Stopwatch print_job_timer; // Global Print Job Timer instance #include "../MarlinCore.h" #include "../HAL/shared/eeprom_api.h" -#if HAS_BUZZER && SERVICE_WARNING_BUZZES > 0 +#if HAS_SOUND && SERVICE_WARNING_BUZZES > 0 #include "../libs/buzzer.h" #endif -#if PRINTCOUNTER_SYNC +#if ENABLED(PRINTCOUNTER_SYNC) #include "../module/planner.h" #endif @@ -156,7 +156,7 @@ void PrintCounter::loadStats() { #if SERVICE_INTERVAL_3 > 0 if (data.nextService3 == 0) doBuzz = _service_warn(PSTR(" " SERVICE_NAME_3)); #endif - #if HAS_BUZZER && SERVICE_WARNING_BUZZES > 0 + #if HAS_SOUND && SERVICE_WARNING_BUZZES > 0 if (doBuzz) for (int i = 0; i < SERVICE_WARNING_BUZZES; i++) { BUZZ(200, 404); BUZZ(10, 0); } #else UNUSED(doBuzz); @@ -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/module/probe.cpp b/Marlin/src/module/probe.cpp index 2649aa41b634..d4f25126b8c6 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -44,11 +44,20 @@ #include "../feature/bedlevel/bedlevel.h" #endif +#if ENABLED(BD_SENSOR) + #include "../feature/bedlevel/bdl/bdl.h" +#endif + #if ENABLED(DELTA) #include "delta.h" #endif -#if ANY(HAS_QUIET_PROBING, USE_SENSORLESS) +#if ENABLED(SENSORLESS_PROBING) + abc_float_t offset_sensorless_adj{0}; + float largest_sensorless_adj = 0; +#endif + +#if EITHER(HAS_QUIET_PROBING, USE_SENSORLESS) #include "stepper/indirection.h" #if BOTH(HAS_QUIET_PROBING, PROBING_ESTEPPERS_OFF) #include "stepper.h" @@ -143,7 +152,7 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() #elif ENABLED(TOUCH_MI_PROBE) // Move to the magnet to unlock the probe - inline void run_deploy_moves_script() { + inline void run_deploy_moves() { #ifndef TOUCH_MI_DEPLOY_XPOS #define TOUCH_MI_DEPLOY_XPOS X_MIN_POS #elif TOUCH_MI_DEPLOY_XPOS > X_MAX_BED @@ -159,7 +168,7 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() LCD_MESSAGE(MSG_MANUAL_DEPLOY_TOUCHMI); ui.return_to_status(); - TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("Deploy TouchMI"), FPSTR(CONTINUE_STR))); + TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(F("Deploy TouchMI"))); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); ui.reset_status(); ui.goto_screen(prev_screen); @@ -174,16 +183,17 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() } // Move down to the bed to stow the probe - inline void run_stow_moves_script() { - const xyz_pos_t oldpos = current_position; + // TODO: Handle cases where it would be a bad idea to move down. + inline void run_stow_moves() { + const float oldz = current_position.z; endstops.enable_z_probe(false); do_blocking_move_to_z(TOUCH_MI_RETRACT_Z, homing_feedrate(Z_AXIS)); - do_blocking_move_to(oldpos, homing_feedrate(Z_AXIS)); + do_blocking_move_to_z(oldz, homing_feedrate(Z_AXIS)); } #elif ENABLED(Z_PROBE_ALLEN_KEY) - inline void run_deploy_moves_script() { + inline void run_deploy_moves() { #ifdef Z_PROBE_ALLEN_KEY_DEPLOY_1 #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE #define Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE 0.0 @@ -221,7 +231,7 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() #endif } - inline void run_stow_moves_script() { + inline void run_stow_moves() { #ifdef Z_PROBE_ALLEN_KEY_STOW_1 #ifndef Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE #define Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE 0.0 @@ -259,7 +269,57 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() #endif } -#endif // Z_PROBE_ALLEN_KEY +#elif ENABLED(MAG_MOUNTED_PROBE) + + typedef struct { float fr_mm_min; xyz_pos_t where; } mag_probe_move_t; + + inline void run_deploy_moves() { + #ifdef MAG_MOUNTED_DEPLOY_1 + constexpr mag_probe_move_t deploy_1 = MAG_MOUNTED_DEPLOY_1; + do_blocking_move_to(deploy_1.where, MMM_TO_MMS(deploy_1.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_DEPLOY_2 + constexpr mag_probe_move_t deploy_2 = MAG_MOUNTED_DEPLOY_2; + do_blocking_move_to(deploy_2.where, MMM_TO_MMS(deploy_2.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_DEPLOY_3 + constexpr mag_probe_move_t deploy_3 = MAG_MOUNTED_DEPLOY_3; + do_blocking_move_to(deploy_3.where, MMM_TO_MMS(deploy_3.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_DEPLOY_4 + constexpr mag_probe_move_t deploy_4 = MAG_MOUNTED_DEPLOY_4; + do_blocking_move_to(deploy_4.where, MMM_TO_MMS(deploy_4.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_DEPLOY_5 + constexpr mag_probe_move_t deploy_5 = MAG_MOUNTED_DEPLOY_5; + do_blocking_move_to(deploy_5.where, MMM_TO_MMS(deploy_5.fr_mm_min)); + #endif + } + + inline void run_stow_moves() { + #ifdef MAG_MOUNTED_STOW_1 + constexpr mag_probe_move_t stow_1 = MAG_MOUNTED_STOW_1; + do_blocking_move_to(stow_1.where, MMM_TO_MMS(stow_1.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_STOW_2 + constexpr mag_probe_move_t stow_2 = MAG_MOUNTED_STOW_2; + do_blocking_move_to(stow_2.where, MMM_TO_MMS(stow_2.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_STOW_3 + constexpr mag_probe_move_t stow_3 = MAG_MOUNTED_STOW_3; + do_blocking_move_to(stow_3.where, MMM_TO_MMS(stow_3.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_STOW_4 + constexpr mag_probe_move_t stow_4 = MAG_MOUNTED_STOW_4; + do_blocking_move_to(stow_4.where, MMM_TO_MMS(stow_4.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_STOW_5 + constexpr mag_probe_move_t stow_5 = MAG_MOUNTED_STOW_5; + do_blocking_move_to(stow_5.where, MMM_TO_MMS(stow_5.fr_mm_min)); + #endif + } + +#endif // MAG_MOUNTED_PROBE #if HAS_QUIET_PROBING @@ -301,25 +361,35 @@ void Probe::do_z_raise(const float z_raise) { FORCE_INLINE void probe_specific_action(const bool deploy) { #if ENABLED(PAUSE_BEFORE_DEPLOY_STOW) - do { - #if ENABLED(PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED) - if (deploy != PROBE_TRIGGERED()) break; - #endif - - OKAY_BUZZ(); - FSTR_P const ds_str = deploy ? GET_TEXT_F(MSG_MANUAL_DEPLOY) : GET_TEXT_F(MSG_MANUAL_STOW); - ui.return_to_status(); // To display the new status message - ui.set_status(ds_str, 99); - SERIAL_ECHOLNF(deploy ? GET_EN_TEXT_F(MSG_MANUAL_DEPLOY) : GET_EN_TEXT_F(MSG_MANUAL_STOW)); + // Start preheating before waiting for user confirmation that the probe is ready. + TERN_(PREHEAT_BEFORE_PROBING, if (deploy) probe.preheat_for_probing(0, PROBING_BED_TEMP, true)); + + FSTR_P const ds_str = deploy ? GET_TEXT_F(MSG_MANUAL_DEPLOY) : GET_TEXT_F(MSG_MANUAL_STOW); + ui.return_to_status(); // To display the new status message + ui.set_status(ds_str, 99); + SERIAL_ECHOLNF(deploy ? GET_EN_TEXT_F(MSG_MANUAL_DEPLOY) : GET_EN_TEXT_F(MSG_MANUAL_STOW)); + + OKAY_BUZZ(); + + #if ENABLED(PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED) + // Wait for the probe to be attached or detached before asking for explicit user confirmation + // Allow the user to interrupt + { + KEEPALIVE_STATE(PAUSED_FOR_USER); + TERN_(HAS_RESUME_CONTINUE, wait_for_user = true); + while (deploy == PROBE_TRIGGERED() && TERN1(HAS_RESUME_CONTINUE, wait_for_user)) idle_no_sleep(); + TERN_(HAS_RESUME_CONTINUE, wait_for_user = false); + OKAY_BUZZ(); + } + #endif - TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, ds_str, FPSTR(CONTINUE_STR))); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(ds_str)); - TERN_(DWIN_LCD_PROUI, DWIN_Popup_Confirm(ICON_BLTouch, ds_str, FPSTR(CONTINUE_STR))); - TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); - ui.reset_status(); + TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(ds_str)); + TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(ds_str)); + TERN_(DWIN_LCD_PROUI, DWIN_Popup_Confirm(ICON_BLTouch, ds_str, FPSTR(CONTINUE_STR))); + TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); - } while (ENABLED(PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED)); + ui.reset_status(); #endif // PAUSE_BEFORE_DEPLOY_STOW @@ -345,9 +415,9 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { servo[Z_PROBE_SERVO_NR].move(servo_angles[Z_PROBE_SERVO_NR][deploy ? 0 : 1]); - #elif EITHER(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY) + #elif ANY(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, MAG_MOUNTED_PROBE) - deploy ? run_deploy_moves_script() : run_stow_moves_script(); + deploy ? run_deploy_moves() : run_stow_moves(); #elif ENABLED(RACK_AND_PINION_PROBE) @@ -376,7 +446,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { * - If a preheat input is higher than the current target, raise the target temperature. * - If a preheat input is higher than the current temperature, wait for stabilization. */ - void Probe::preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp) { + void Probe::preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp, const bool early/*=false*/) { #if HAS_HOTEND && (PROBING_NOZZLE_TEMP || LEVELING_NOZZLE_TEMP) #define WAIT_FOR_NOZZLE_HEAT #endif @@ -384,7 +454,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { #define WAIT_FOR_BED_HEAT #endif - LCD_MESSAGE(MSG_PREHEATING); + if (!early) LCD_MESSAGE(MSG_PREHEATING); DEBUG_ECHOPGM("Preheating "); @@ -394,14 +464,12 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { DEBUG_ECHOPGM("hotend (", hotendPreheat, ")"); thermalManager.setTargetHotend(hotendPreheat, 0); } - #elif ENABLED(WAIT_FOR_BED_HEAT) - constexpr celsius_t hotendPreheat = 0; #endif #if ENABLED(WAIT_FOR_BED_HEAT) const celsius_t bedPreheat = bed_temp > thermalManager.degTargetBed() ? bed_temp : 0; if (bedPreheat) { - if (hotendPreheat) DEBUG_ECHOPGM(" and "); + if (TERN0(WAIT_FOR_NOZZLE_HEAT, hotendPreheat)) DEBUG_ECHOPGM(" and "); DEBUG_ECHOPGM("bed (", bedPreheat, ")"); thermalManager.setTargetBed(bedPreheat); } @@ -409,8 +477,10 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { DEBUG_EOL(); - TERN_(WAIT_FOR_NOZZLE_HEAT, if (hotend_temp > thermalManager.wholeDegHotend(0) + (TEMP_WINDOW)) thermalManager.wait_for_hotend(0)); - TERN_(WAIT_FOR_BED_HEAT, if (bed_temp > thermalManager.wholeDegBed() + (TEMP_BED_WINDOW)) thermalManager.wait_for_bed_heating()); + if (!early) { + TERN_(WAIT_FOR_NOZZLE_HEAT, if (hotend_temp > thermalManager.wholeDegHotend(0) + (TEMP_WINDOW)) thermalManager.wait_for_hotend(0)); + TERN_(WAIT_FOR_BED_HEAT, if (bed_temp > thermalManager.wholeDegBed() + (TEMP_BED_WINDOW)) thermalManager.wait_for_bed_heating()); + } } #endif @@ -823,6 +893,10 @@ 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)); + #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()) { measured_z = run_z_probe(sanity_check) + offset.z; @@ -867,76 +941,38 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai #endif // HAS_Z_SERVO_PROBE -#if USE_SENSORLESS - - sensorless_t stealth_states { false }; - - /** - * Disable stealthChop if used. Enable diag1 pin on driver. - */ - void Probe::enable_stallguard_diag1() { - #if ENABLED(SENSORLESS_PROBING) - #if HAS_DELTA_SENSORLESS_PROBING - stealth_states.x = tmc_enable_stallguard(stepperX); - stealth_states.y = tmc_enable_stallguard(stepperY); - #endif - stealth_states.z = tmc_enable_stallguard(stepperZ); - endstops.enable(true); - #endif - } - - /** - * Re-enable stealthChop if used. Disable diag1 pin on driver. - */ - void Probe::disable_stallguard_diag1() { - #if ENABLED(SENSORLESS_PROBING) - endstops.not_homing(); - #if HAS_DELTA_SENSORLESS_PROBING - tmc_disable_stallguard(stepperX, stealth_states.x); - tmc_disable_stallguard(stepperY, stealth_states.y); - #endif - tmc_disable_stallguard(stepperZ, stealth_states.z); - #endif - } +#if HAS_DELTA_SENSORLESS_PROBING /** * Set the sensorless Z offset */ void Probe::set_offset_sensorless_adj(const_float_t sz) { - #if ENABLED(SENSORLESS_PROBING) - DEBUG_SECTION(pso, "Probe::set_offset_sensorless_adj", true); - #if HAS_DELTA_SENSORLESS_PROBING - if (test_sensitivity.x) offset_sensorless_adj.a = sz; - if (test_sensitivity.y) offset_sensorless_adj.b = sz; - #endif - if (test_sensitivity.z) offset_sensorless_adj.c = sz; - #endif + DEBUG_SECTION(pso, "Probe::set_offset_sensorless_adj", true); + if (test_sensitivity.x) offset_sensorless_adj.a = sz; + if (test_sensitivity.y) offset_sensorless_adj.b = sz; + if (test_sensitivity.z) offset_sensorless_adj.c = sz; } /** * Refresh largest_sensorless_adj based on triggered endstops */ void Probe::refresh_largest_sensorless_adj() { - #if ENABLED(SENSORLESS_PROBING) - DEBUG_SECTION(rso, "Probe::refresh_largest_sensorless_adj", true); - largest_sensorless_adj = -3; // A reference away from any real probe height - #if HAS_DELTA_SENSORLESS_PROBING - if (TEST(endstops.state(), X_MAX)) { - NOLESS(largest_sensorless_adj, offset_sensorless_adj.a); - DEBUG_ECHOLNPGM("Endstop_X: ", largest_sensorless_adj, " TowerX"); - } - if (TEST(endstops.state(), Y_MAX)) { - NOLESS(largest_sensorless_adj, offset_sensorless_adj.b); - DEBUG_ECHOLNPGM("Endstop_Y: ", largest_sensorless_adj, " TowerY"); - } - #endif - if (TEST(endstops.state(), Z_MAX)) { - NOLESS(largest_sensorless_adj, offset_sensorless_adj.c); - DEBUG_ECHOLNPGM("Endstop_Z: ", largest_sensorless_adj, " TowerZ"); - } - #endif + DEBUG_SECTION(rso, "Probe::refresh_largest_sensorless_adj", true); + largest_sensorless_adj = -3; // A reference away from any real probe height + if (TEST(endstops.state(), X_MAX)) { + NOLESS(largest_sensorless_adj, offset_sensorless_adj.a); + DEBUG_ECHOLNPGM("Endstop_X: ", largest_sensorless_adj, " TowerX"); + } + if (TEST(endstops.state(), Y_MAX)) { + NOLESS(largest_sensorless_adj, offset_sensorless_adj.b); + DEBUG_ECHOLNPGM("Endstop_Y: ", largest_sensorless_adj, " TowerY"); + } + if (TEST(endstops.state(), Z_MAX)) { + NOLESS(largest_sensorless_adj, offset_sensorless_adj.c); + DEBUG_ECHOLNPGM("Endstop_Z: ", largest_sensorless_adj, " TowerZ"); + } } -#endif // SENSORLESS_PROBING || SENSORLESS_HOMING +#endif #endif // HAS_BED_PROBE diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index ca596e896977..5b1f7149f248 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -29,6 +29,10 @@ #include "motion.h" +#if ENABLED(DWIN_LCD_PROUI) + #include "../lcd/e3v2/proui/dwin.h" +#endif + #if HAS_BED_PROBE enum ProbePtRaise : uint8_t { PROBE_PT_NONE, // No raise or stow after run_z_probe @@ -45,12 +49,14 @@ #define PROBE_TRIGGERED() (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) #endif -#ifdef Z_AFTER_HOMING - #define Z_POST_CLEARANCE Z_AFTER_HOMING +#if ALL(DWIN_LCD_PROUI, INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) + #define Z_POST_CLEARANCE HMI_data.z_after_homing +#elif defined(Z_AFTER_HOMING) + #define Z_POST_CLEARANCE Z_AFTER_HOMING #elif defined(Z_HOMING_HEIGHT) - #define Z_POST_CLEARANCE Z_HOMING_HEIGHT + #define Z_POST_CLEARANCE Z_HOMING_HEIGHT #else - #define Z_POST_CLEARANCE 10 + #define Z_POST_CLEARANCE 10 #endif #if ENABLED(PREHEAT_BEFORE_LEVELING) @@ -62,16 +68,16 @@ #endif #endif +#if ENABLED(SENSORLESS_PROBING) + extern abc_float_t offset_sensorless_adj; +#endif + class Probe { public: #if ENABLED(SENSORLESS_PROBING) typedef struct { - #if HAS_DELTA_SENSORLESS_PROBING bool x:1, y:1, z:1; - #else - bool z; - #endif } sense_bool_t; static sense_bool_t test_sensitivity; #endif @@ -81,7 +87,7 @@ class Probe { static xyz_pos_t offset; #if EITHER(PREHEAT_BEFORE_PROBING, PREHEAT_BEFORE_LEVELING) - static void preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp); + static void preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp, const bool early=false); #endif static void probe_error_stop(); @@ -146,7 +152,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; } @@ -155,9 +161,9 @@ class Probe { #endif static void move_z_after_homing() { - #ifdef Z_AFTER_HOMING - do_z_clearance(Z_AFTER_HOMING, true); - #elif BOTH(Z_AFTER_PROBING, HAS_BED_PROBE) + #if ALL(DWIN_LCD_PROUI, INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) || defined(Z_AFTER_HOMING) + do_z_clearance(Z_POST_CLEARANCE, true); + #elif HAS_BED_PROBE move_z_after_probing(); #endif } @@ -302,9 +308,7 @@ class Probe { #endif // Basic functions for Sensorless Homing and Probing - #if USE_SENSORLESS - static void enable_stallguard_diag1(); - static void disable_stallguard_diag1(); + #if HAS_DELTA_SENSORLESS_PROBING static void set_offset_sensorless_adj(const_float_t sz); static void refresh_largest_sensorless_adj(); #endif 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 149b1b6dc1e0..e01bd9ae600a 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -36,12 +36,13 @@ */ // Change EEPROM version if the structure changes -#define EEPROM_VERSION "V86" +#define EEPROM_VERSION "V88" #define EEPROM_OFFSET 100 // Check the integrity of data offsets. // Can be disabled for production build. //#define DEBUG_EEPROM_READWRITE +//#define DEBUG_EEPROM_OBSERVE #include "settings.h" @@ -76,6 +77,7 @@ #include "../lcd/extui/ui_api.h" #elif ENABLED(DWIN_LCD_PROUI) #include "../lcd/e3v2/proui/dwin.h" + #include "../lcd/e3v2/proui/bedlevel_tools.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "../lcd/e3v2/jyersui/dwin.h" #endif @@ -117,8 +119,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 @@ -206,7 +208,8 @@ typedef struct SettingsDataStruct { #if ENABLED(EEPROM_INIT_NOW) uint32_t build_hash; // Unique build hash #endif - uint16_t crc; // Data Checksum + uint16_t crc; // Data Checksum for validation + uint16_t data_size; // Data Size for validation // // DISTINCT_E_FACTORS @@ -249,6 +252,7 @@ typedef struct SettingsDataStruct { // float mbl_z_offset; // bedlevel.z_offset uint8_t mesh_num_x, mesh_num_y; // GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y + uint16_t mesh_check; // Hash to check against X/Y float mbl_z_values[TERN(MESH_BED_LEVELING, GRID_MAX_POINTS_X, 3)] // bedlevel.z_values [TERN(MESH_BED_LEVELING, GRID_MAX_POINTS_Y, 3)]; @@ -256,7 +260,7 @@ typedef struct SettingsDataStruct { // HAS_BED_PROBE // - xyz_pos_t probe_offset; + xyz_pos_t probe_offset; // M851 X Y Z // // ABL_PLANAR @@ -267,6 +271,7 @@ typedef struct SettingsDataStruct { // AUTO_BED_LEVELING_BILINEAR // uint8_t grid_max_x, grid_max_y; // GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y + uint16_t grid_check; // Hash to check against X/Y xy_pos_t bilinear_grid_spacing, bilinear_start; // G29 L F #if ENABLED(AUTO_BED_LEVELING_BILINEAR) bed_mesh_t z_values; // G29 @@ -318,7 +323,7 @@ typedef struct SettingsDataStruct { #endif // - // Kinematic Settings + // Kinematic Settings (Delta, SCARA, TPARA, Polargraph...) // #if IS_KINEMATIC float segments_per_second; // M665 S @@ -329,7 +334,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 // @@ -363,18 +372,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 @@ -401,8 +410,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 @@ -441,7 +450,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 @@ -467,7 +476,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 @@ -572,6 +581,18 @@ typedef struct SettingsDataStruct { MPC_t mpc_constants[HOTENDS]; // M306 #endif + // + // Input Shaping + // + #if ENABLED(INPUT_SHAPING_X) + float shaping_x_frequency, // M593 X F + shaping_x_zeta; // M593 X D + #endif + #if ENABLED(INPUT_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!"); @@ -592,7 +613,7 @@ void MarlinSettings::postprocess() { xyze_pos_t oldpos = current_position; // steps per s2 needs to be updated to agree with units per s2 - planner.reset_acceleration_rates(); + planner.refresh_acceleration_rates(); // Make sure delta kinematics are updated before refreshing the // planner position so the stepper counts will be set correctly. @@ -639,7 +660,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(); @@ -699,10 +720,13 @@ void MarlinSettings::postprocess() { #if ENABLED(EEPROM_SETTINGS) - #define EEPROM_ASSERT(TST,ERR) do{ if (!(TST)) { SERIAL_ERROR_MSG(ERR); eeprom_error = true; } }while(0) + #define EEPROM_ASSERT(TST,ERR) do{ if (!(TST)) { SERIAL_ERROR_MSG(ERR); eeprom_error = ERR_EEPROM_SIZE; } }while(0) + + #define TWO_BYTE_HASH(A,B) uint16_t((uint16_t(A ^ 0xC3) << 4) ^ (uint16_t(B ^ 0xC3) << 12)) #if ENABLED(DEBUG_EEPROM_READWRITE) #define _FIELD_TEST(FIELD) \ + SERIAL_ECHOLNPGM("Field: " STRINGIFY(FIELD)); \ EEPROM_ASSERT( \ eeprom_error || eeprom_index == offsetof(SettingsData, FIELD) + EEPROM_OFFSET, \ "Field " STRINGIFY(FIELD) " mismatch." \ @@ -711,6 +735,14 @@ void MarlinSettings::postprocess() { #define _FIELD_TEST(FIELD) NOOP #endif + #if ENABLED(DEBUG_EEPROM_OBSERVE) + #define EEPROM_READ(V...) do{ SERIAL_ECHOLNPGM("READ: ", F(STRINGIFY(FIRST(V)))); EEPROM_READ_(V); }while(0) + #define EEPROM_READ_ALWAYS(V...) do{ SERIAL_ECHOLNPGM("READ: ", F(STRINGIFY(FIRST(V)))); EEPROM_READ_ALWAYS_(V); }while(0) + #else + #define EEPROM_READ(V...) EEPROM_READ_(V) + #define EEPROM_READ_ALWAYS(V...) EEPROM_READ_ALWAYS_(V) + #endif + const char version[4] = EEPROM_VERSION; #if ENABLED(EEPROM_INIT_NOW) @@ -720,20 +752,20 @@ void MarlinSettings::postprocess() { constexpr uint32_t build_hash = strhash32(__DATE__ __TIME__); #endif - bool MarlinSettings::eeprom_error, MarlinSettings::validating; + bool MarlinSettings::validating; int MarlinSettings::eeprom_index; uint16_t MarlinSettings::working_crc; - bool MarlinSettings::size_error(const uint16_t size) { + EEPROM_Error MarlinSettings::size_error(const uint16_t size) { if (size != datasize()) { DEBUG_ERROR_MSG("EEPROM datasize error." #if ENABLED(MARLIN_DEV_MODE) " (Actual:", size, " Expected:", datasize(), ")" #endif ); - return true; + return ERR_EEPROM_SIZE; } - return false; + return ERR_EEPROM_NOERR; } /** @@ -745,18 +777,25 @@ void MarlinSettings::postprocess() { if (!EEPROM_START(EEPROM_OFFSET)) return false; - eeprom_error = false; + EEPROM_Error eeprom_error = ERR_EEPROM_NOERR; // Write or Skip version. (Flash doesn't allow rewrite without erase.) TERN(FLASH_EEPROM_EMULATION, EEPROM_SKIP, EEPROM_WRITE)(ver); #if ENABLED(EEPROM_INIT_NOW) - EEPROM_SKIP(build_hash); // Skip the hash slot + EEPROM_SKIP(build_hash); // Skip the hash slot which will be written later #endif EEPROM_SKIP(working_crc); // Skip the checksum slot - working_crc = 0; // clear before first "real data" + // + // Clear after skipping CRC and before writing the CRC'ed data + // + working_crc = 0; + + // Write the size of the data structure for use in validation + const uint16_t data_size = datasize(); + EEPROM_WRITE(data_size); const uint8_t e_factors = DISTINCT_AXES - (NUM_AXES); _FIELD_TEST(e_factors); @@ -858,6 +897,10 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(mesh_num_x); EEPROM_WRITE(mesh_num_y); + // Check value for the X/Y values + const uint16_t mesh_check = TWO_BYTE_HASH(mesh_num_x, mesh_num_y); + EEPROM_WRITE(mesh_check); + #if ENABLED(MESH_BED_LEVELING) EEPROM_WRITE(bedlevel.z_values); #else @@ -905,6 +948,11 @@ void MarlinSettings::postprocess() { grid_max_y = TERN(AUTO_BED_LEVELING_BILINEAR, GRID_MAX_POINTS_Y, 3); EEPROM_WRITE(grid_max_x); EEPROM_WRITE(grid_max_y); + + // Check value for the X/Y values + const uint16_t grid_check = TWO_BYTE_HASH(grid_max_x, grid_max_y); + EEPROM_WRITE(grid_check); + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) EEPROM_WRITE(bedlevel.grid_spacing); EEPROM_WRITE(bedlevel.grid_start); @@ -987,7 +1035,7 @@ void MarlinSettings::postprocess() { } // - // Kinematic Settings + // Kinematic Settings (Delta, SCARA, TPARA, Polargraph...) // #if IS_KINEMATIC { @@ -1000,6 +1048,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 @@ -1051,27 +1104,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); } // @@ -1079,17 +1125,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 auto &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); } @@ -1098,17 +1139,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 auto &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); } @@ -1116,10 +1152,8 @@ void MarlinSettings::postprocess() { // User-defined Thermistors // #if HAS_USER_THERMISTORS - { _FIELD_TEST(user_thermistor); EEPROM_WRITE(thermalManager.user_thermistor); - } #endif // @@ -1156,8 +1190,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 @@ -1418,7 +1452,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 } @@ -1611,10 +1645,24 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(thermalManager.temp_hotend[e].constants); #endif + // + // Input Shaping + /// + #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 ENABLED(INPUT_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 // - if (!eeprom_error) { + if (eeprom_error == ERR_EEPROM_NOERR) { const uint16_t eeprom_size = eeprom_index - (EEPROM_OFFSET), final_crc = working_crc; @@ -1630,7 +1678,7 @@ void MarlinSettings::postprocess() { // Report storage size DEBUG_ECHO_MSG("Settings Stored (", eeprom_size, " bytes; crc ", (uint32_t)final_crc, ")"); - eeprom_error |= size_error(eeprom_size); + eeprom_error = size_error(eeprom_size); } EEPROM_FINISH(); @@ -1642,56 +1690,82 @@ void MarlinSettings::postprocess() { store_mesh(bedlevel.storage_slot); #endif - if (!eeprom_error) { + const bool success = (eeprom_error == ERR_EEPROM_NOERR); + if (success) { LCD_MESSAGE(MSG_SETTINGS_STORED); TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_SETTINGS_STORED))); } - TERN_(EXTENSIBLE_UI, ExtUI::onSettingsStored(!eeprom_error)); + TERN_(EXTENSIBLE_UI, ExtUI::onSettingsStored(success)); - return !eeprom_error; + return success; } /** * M501 - Retrieve Configuration */ - bool MarlinSettings::_load() { - if (!EEPROM_START(EEPROM_OFFSET)) return false; + EEPROM_Error MarlinSettings::_load() { + EEPROM_Error eeprom_error = ERR_EEPROM_NOERR; + + if (!EEPROM_START(EEPROM_OFFSET)) return eeprom_error; char stored_ver[4]; EEPROM_READ_ALWAYS(stored_ver); - // Version has to match or defaults are used - if (strncmp(version, stored_ver, 3) != 0) { - if (stored_ver[3] != '\0') { - stored_ver[0] = '?'; - stored_ver[1] = '\0'; - } - DEBUG_ECHO_MSG("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")"); - TERN_(DWIN_LCD_PROUI, LCD_MESSAGE(MSG_ERR_EEPROM_VERSION)); - TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_ERR_EEPROM_VERSION))); + uint16_t stored_crc; - IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_version()); - eeprom_error = true; - } - else { + do { // A block to break out of on error - // Optionally reset on the first boot after flashing + // Version has to match or defaults are used + if (strncmp(version, stored_ver, 3) != 0) { + if (stored_ver[3] != '\0') { + stored_ver[0] = '?'; + stored_ver[1] = '\0'; + } + DEBUG_ECHO_MSG("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")"); + eeprom_error = ERR_EEPROM_VERSION; + break; + } + + // + // Optionally reset on first boot after flashing + // #if ENABLED(EEPROM_INIT_NOW) uint32_t stored_hash; EEPROM_READ_ALWAYS(stored_hash); - if (stored_hash != build_hash) { EEPROM_FINISH(); return false; } + if (stored_hash != build_hash) { + eeprom_error = ERR_EEPROM_CORRUPT; + break; + } #endif - uint16_t stored_crc; + // + // Get the stored CRC to compare at the end + // EEPROM_READ_ALWAYS(stored_crc); + // + // A temporary float for safe storage + // float dummyf = 0; - working_crc = 0; // Init to 0. Accumulated by EEPROM_READ - _FIELD_TEST(e_factors); + // + // Init to 0. Accumulated by EEPROM_READ + // + working_crc = 0; + + // + // Validate the stored size against the current data structure size + // + uint16_t stored_size; + EEPROM_READ_ALWAYS(stored_size); + if ((eeprom_error = size_error(stored_size))) break; + // + // Extruder Parameter Count // Number of e_factors may change + // + _FIELD_TEST(e_factors); uint8_t e_factors; EEPROM_READ_ALWAYS(e_factors); @@ -1791,16 +1865,28 @@ void MarlinSettings::postprocess() { // { uint8_t mesh_num_x, mesh_num_y; + uint16_t mesh_check; EEPROM_READ(dummyf); EEPROM_READ_ALWAYS(mesh_num_x); EEPROM_READ_ALWAYS(mesh_num_y); + // Check value must correspond to the X/Y values + EEPROM_READ_ALWAYS(mesh_check); + if (mesh_check != TWO_BYTE_HASH(mesh_num_x, mesh_num_y)) { + eeprom_error = ERR_EEPROM_CORRUPT; + break; + } + #if ENABLED(MESH_BED_LEVELING) if (!validating) bedlevel.z_offset = dummyf; if (mesh_num_x == (GRID_MAX_POINTS_X) && mesh_num_y == (GRID_MAX_POINTS_Y)) { // EEPROM data fits the current mesh EEPROM_READ(bedlevel.z_values); } + else if (mesh_num_x > (GRID_MAX_POINTS_X) || mesh_num_y > (GRID_MAX_POINTS_Y)) { + eeprom_error = ERR_EEPROM_CORRUPT; + break; + } else { // EEPROM data is stale if (!validating) bedlevel.reset(); @@ -1843,6 +1929,15 @@ void MarlinSettings::postprocess() { uint8_t grid_max_x, grid_max_y; EEPROM_READ_ALWAYS(grid_max_x); // 1 byte EEPROM_READ_ALWAYS(grid_max_y); // 1 byte + + // Check value must correspond to the X/Y values + uint16_t grid_check; + EEPROM_READ_ALWAYS(grid_check); + if (grid_check != TWO_BYTE_HASH(grid_max_x, grid_max_y)) { + eeprom_error = ERR_EEPROM_CORRUPT; + break; + } + xy_pos_t spacing, start; EEPROM_READ(spacing); // 2 ints EEPROM_READ(start); // 2 ints @@ -1852,6 +1947,10 @@ void MarlinSettings::postprocess() { bedlevel.set_grid(spacing, start); EEPROM_READ(bedlevel.z_values); // 9 to 256 floats } + else if (grid_max_x > (GRID_MAX_POINTS_X) || grid_max_y > (GRID_MAX_POINTS_Y)) { + eeprom_error = ERR_EEPROM_CORRUPT; + break; + } else // EEPROM data is stale #endif // AUTO_BED_LEVELING_BILINEAR { @@ -1941,7 +2040,7 @@ void MarlinSettings::postprocess() { } // - // Kinematic Segments-per-second + // Kinematic Settings (Delta, SCARA, TPARA, Polargraph...) // #if IS_KINEMATIC { @@ -1954,6 +2053,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 @@ -2002,17 +2106,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 } } @@ -2034,15 +2132,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 } @@ -2050,15 +2144,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 } @@ -2107,8 +2197,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 @@ -2366,7 +2456,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) @@ -2486,7 +2576,7 @@ void MarlinSettings::postprocess() { #endif // - // Creality DWIN User Data + // DWIN User Data // #if ENABLED(DWIN_LCD_PROUI) { @@ -2591,30 +2681,46 @@ void MarlinSettings::postprocess() { } #endif + // + // Input Shaping + // + #if ENABLED(INPUT_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 ENABLED(INPUT_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 // - eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET)); - if (eeprom_error) { - DEBUG_ECHO_MSG("Index: ", eeprom_index - (EEPROM_OFFSET), " Size: ", datasize()); - IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_index()); + const uint16_t eeprom_total = eeprom_index - (EEPROM_OFFSET); + if ((eeprom_error = size_error(eeprom_total))) { + // Handle below and on return + break; } else if (working_crc != stored_crc) { - eeprom_error = true; - DEBUG_ERROR_MSG("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!"); - TERN_(DWIN_LCD_PROUI, LCD_MESSAGE(MSG_ERR_EEPROM_CRC)); - TERN_(HOST_EEPROM_CHITCHAT, hostui.notify(GET_TEXT_F(MSG_ERR_EEPROM_CRC))); - IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_crc()); + eeprom_error = ERR_EEPROM_CRC; + break; } else if (!validating) { DEBUG_ECHO_START(); DEBUG_ECHO(version); - DEBUG_ECHOLNPGM(" stored settings retrieved (", eeprom_index - (EEPROM_OFFSET), " bytes; crc ", (uint32_t)working_crc, ")"); + DEBUG_ECHOLNPGM(" stored settings retrieved (", eeprom_total, " bytes; crc ", working_crc, ")"); TERN_(HOST_EEPROM_CHITCHAT, hostui.notify(F("Stored settings retrieved"))); } - if (!validating && !eeprom_error) postprocess(); - #if ENABLED(AUTO_BED_LEVELING_UBL) if (!validating) { bedlevel.report_state(); @@ -2626,7 +2732,7 @@ void MarlinSettings::postprocess() { #endif } else { - eeprom_error = true; + eeprom_error = ERR_EEPROM_CORRUPT; #if BOTH(EEPROM_CHITCHAT, DEBUG_LEVELING_FEATURE) DEBUG_ECHOPGM("?Can't enable "); bedlevel.echo_name(); @@ -2645,6 +2751,26 @@ void MarlinSettings::postprocess() { } } #endif + + } while(0); + + EEPROM_FINISH(); + + switch (eeprom_error) { + case ERR_EEPROM_NOERR: + if (!validating) postprocess(); + break; + case ERR_EEPROM_SIZE: + DEBUG_ECHO_MSG("Index: ", eeprom_index - (EEPROM_OFFSET), " Size: ", datasize()); + break; + case ERR_EEPROM_CORRUPT: + DEBUG_ERROR_MSG(STR_ERR_EEPROM_CORRUPT); + break; + case ERR_EEPROM_CRC: + DEBUG_ERROR_MSG("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!"); + TERN_(HOST_EEPROM_CHITCHAT, hostui.notify(GET_TEXT_F(MSG_ERR_EEPROM_CRC))); + break; + default: break; } #if ENABLED(EEPROM_CHITCHAT) && DISABLED(DISABLE_M503) @@ -2652,9 +2778,7 @@ void MarlinSettings::postprocess() { if (!validating && TERN1(EEPROM_BOOT_SILENT, IsRunning())) report(); #endif - EEPROM_FINISH(); - - return !eeprom_error; + return eeprom_error; } #ifdef ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE @@ -2664,21 +2788,25 @@ void MarlinSettings::postprocess() { bool MarlinSettings::validate() { validating = true; #ifdef ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE - bool success = _load(); - if (!success && restoreEEPROM()) { + EEPROM_Error err = _load(); + if (err != ERR_EEPROM_NOERR && restoreEEPROM()) { SERIAL_ECHOLNPGM("Recovered backup EEPROM settings from SPI Flash"); - success = _load(); + err = _load(); } #else - const bool success = _load(); + const EEPROM_Error err = _load(); #endif validating = false; - return success; + + if (err) ui.eeprom_alert(err); + + return (err == ERR_EEPROM_NOERR); } bool MarlinSettings::load() { if (validate()) { - const bool success = _load(); + const EEPROM_Error err = _load(); + const bool success = (err == ERR_EEPROM_NOERR); TERN_(EXTENSIBLE_UI, ExtUI::onSettingsLoaded(success)); return success; } @@ -2776,7 +2904,7 @@ void MarlinSettings::postprocess() { #endif persistentStore.access_start(); - const uint16_t status = persistentStore.read_data(pos, dest, MESH_STORE_SIZE, &crc); + uint16_t status = persistentStore.read_data(pos, dest, MESH_STORE_SIZE, &crc); persistentStore.access_finish(); #if ENABLED(OPTIMIZED_MESH_STORAGE) @@ -2789,6 +2917,16 @@ void MarlinSettings::postprocess() { bedlevel.set_mesh_from_store(z_mesh_store, bedlevel.z_values); #endif + #if ENABLED(DWIN_LCD_PROUI) + status = !bedLevelTools.meshvalidate(); + if (status) { + bedlevel.invalidate(); + LCD_MESSAGE(MSG_UBL_MESH_INVALID); + } + else + ui.status_printf(0, GET_TEXT_F(MSG_MESH_LOADED), bedlevel.storage_slot); + #endif + if (status) SERIAL_ECHOLNPGM("?Unable to load mesh data."); else DEBUG_ECHOLNPGM("Mesh loaded from slot ", slot); @@ -2898,6 +3036,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 @@ -3000,15 +3139,11 @@ void MarlinSettings::reset() { #endif // - // Kinematic settings + // Kinematic Settings (Delta, SCARA, TPARA, Polargraph...) // #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; @@ -3017,6 +3152,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 @@ -3131,11 +3270,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 @@ -3149,9 +3290,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 // @@ -3159,9 +3298,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 // @@ -3187,10 +3324,10 @@ 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; + ui.sleep_timeout_minutes = TERN(TOUCH_SCREEN, TOUCH_IDLE_SLEEP_MINS, DISPLAY_SLEEP_MINUTES); #endif // @@ -3229,12 +3366,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(uint8_t(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 // @@ -3331,17 +3473,32 @@ 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 + // + // Input Shaping + // + #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 ENABLED(INPUT_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) @@ -3509,9 +3666,7 @@ void MarlinSettings::reset() { // // LCD Preheat Settings // - #if HAS_PREHEAT - gcode.M145_report(forReplay); - #endif + TERN_(HAS_PREHEAT, gcode.M145_report(forReplay)); // // PID @@ -3591,6 +3746,11 @@ void MarlinSettings::reset() { // TERN_(HAS_STEALTHCHOP, gcode.M569_report(forReplay)); + // + // Input Shaping + // + TERN_(HAS_SHAPING, gcode.M593_report(forReplay)); + // // Linear Advance // diff --git a/Marlin/src/module/settings.h b/Marlin/src/module/settings.h index a8fca60baa12..b7c5210db5b2 100644 --- a/Marlin/src/module/settings.h +++ b/Marlin/src/module/settings.h @@ -29,6 +29,13 @@ #if ENABLED(EEPROM_SETTINGS) #include "../HAL/shared/eeprom_api.h" + enum EEPROM_Error : uint8_t { + ERR_EEPROM_NOERR, + ERR_EEPROM_VERSION, + ERR_EEPROM_SIZE, + ERR_EEPROM_CRC, + ERR_EEPROM_CORRUPT + }; #endif class MarlinSettings { @@ -98,7 +105,7 @@ class MarlinSettings { #if ENABLED(EEPROM_SETTINGS) - static bool eeprom_error, validating; + static bool validating; #if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system // That can store is enabled @@ -106,8 +113,8 @@ class MarlinSettings { // live at the very end of the eeprom #endif - static bool _load(); - static bool size_error(const uint16_t size); + static EEPROM_Error _load(); + static EEPROM_Error size_error(const uint16_t size); static int eeprom_index; static uint16_t working_crc; @@ -130,16 +137,16 @@ class MarlinSettings { } template - static void EEPROM_READ(T &VAR) { + static void EEPROM_READ_(T &VAR) { persistentStore.read_data(eeprom_index, (uint8_t *) &VAR, sizeof(VAR), &working_crc, !validating); } - static void EEPROM_READ(uint8_t *VAR, size_t sizeof_VAR) { + static void EEPROM_READ_(uint8_t *VAR, size_t sizeof_VAR) { persistentStore.read_data(eeprom_index, VAR, sizeof_VAR, &working_crc, !validating); } template - static void EEPROM_READ_ALWAYS(T &VAR) { + static void EEPROM_READ_ALWAYS_(T &VAR) { persistentStore.read_data(eeprom_index, (uint8_t *) &VAR, sizeof(VAR), &working_crc); } diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index d098179fc183..1705c60daa20 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -97,6 +97,10 @@ Stepper stepper; // Singleton #include "../MarlinCore.h" #include "../HAL/shared/Delay.h" +#if ENABLED(BD_SENSOR) + #include "../feature/bedlevel/bdl/bdl.h" +#endif + #if ENABLED(INTEGRATED_BABYSTEPPING) #include "../feature/babystep.h" #endif @@ -117,12 +121,6 @@ Stepper stepper; // Singleton #include "../feature/runout.h" #endif -#if HAS_L64XX - #include "../libs/L64XX/L64XX_Marlin.h" - uint8_t L6470_buf[MAX_L64XX + 1]; // chip command sequence - element 0 not used - bool L64XX_OK_to_power_up = false; // flag to keep L64xx steppers powered down after a reset or power up -#endif - #if ENABLED(AUTO_POWER_CONTROL) #include "../feature/power.h" #endif @@ -139,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) @@ -197,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 @@ -223,18 +225,34 @@ uint32_t Stepper::advance_divisor = 0, #endif #if ENABLED(LIN_ADVANCE) - uint32_t Stepper::nextAdvanceISR = LA_ADV_NEVER, - Stepper::LA_isr_rate = LA_ADV_NEVER; - uint16_t Stepper::LA_current_adv_steps = 0, - Stepper::LA_final_adv_steps, - Stepper::LA_max_adv_steps; - - int8_t Stepper::LA_steps = 0; - - bool Stepper::LA_use_advance_lead; + Stepper::la_interval = LA_ADV_NEVER; + int32_t Stepper::la_delta_error = 0, + Stepper::la_dividend = 0, + Stepper::la_advance_steps = 0; +#endif -#endif // LIN_ADVANCE +#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 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 #if ENABLED(INTEGRATED_BABYSTEPPING) uint32_t Stepper::nextBabystepISR = BABYSTEP_NEVER; @@ -253,20 +271,6 @@ xyz_long_t Stepper::endstops_trigsteps; xyze_long_t Stepper::count_position{0}; xyze_int8_t Stepper::count_direction{0}; -#if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - Stepper::stepper_laser_t Stepper::laser_trap = { - .enabled = false, - .cur_power = 0, - .cruise_set = false, - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - .last_step_count = 0, - .acc_step_count = 0 - #else - .till_update = 0 - #endif - }; -#endif - #define MINDIR(A) (count_direction[_AXIS(A)] < 0) #define MAXDIR(A) (count_direction[_AXIS(A)] > 0) @@ -476,12 +480,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) @@ -577,6 +579,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 * @@ -588,16 +600,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 @@ -608,48 +610,25 @@ void Stepper::set_directions() { TERN_(HAS_V_DIR, SET_STEP_DIR(V)); TERN_(HAS_W_DIR, SET_STEP_DIR(W)); - #if DISABLED(LIN_ADVANCE) - #if ENABLED(MIXING_EXTRUDER) - // Because this is valid for the whole block we don't know - // what E steppers will step. Likely all. Set all. - if (motor_direction(E_AXIS)) { - MIXER_STEPPER_LOOP(j) REV_E_DIR(j); - count_direction.e = -1; - } - else { - MIXER_STEPPER_LOOP(j) NORM_E_DIR(j); - count_direction.e = 1; - } - #elif HAS_EXTRUDERS - if (motor_direction(E_AXIS)) { - REV_E_DIR(stepper_extruder); - count_direction.e = -1; - } - else { - NORM_E_DIR(stepper_extruder); - count_direction.e = 1; - } - #endif - #endif // !LIN_ADVANCE - - #if HAS_L64XX - if (L64XX_OK_to_power_up) { // OK to send the direction commands (which powers up the L64XX steppers) - if (L64xxManager.spi_active) { - L64xxManager.spi_abort = true; // Interrupted SPI transfer needs to shut down gracefully - for (uint8_t j = 1; j <= L64XX::chain[0]; j++) - L6470_buf[j] = dSPIN_NOP; // Fill buffer with NOOPs - L64xxManager.transfer(L6470_buf, L64XX::chain[0]); // Send enough NOOPs to complete any command - L64xxManager.transfer(L6470_buf, L64XX::chain[0]); - L64xxManager.transfer(L6470_buf, L64XX::chain[0]); - } - - // L64xxManager.dir_commands[] is an array that holds direction command for each stepper - - // Scan command array, copy matches into L64xxManager.transfer - for (uint8_t j = 1; j <= L64XX::chain[0]; j++) - L6470_buf[j] = L64xxManager.dir_commands[L64XX::chain[j]]; - - L64xxManager.transfer(L6470_buf, L64XX::chain[0]); // send the command stream to the drivers + #if ENABLED(MIXING_EXTRUDER) + // Because this is valid for the whole block we don't know + // what E steppers will step. Likely all. Set all. + if (motor_direction(E_AXIS)) { + MIXER_STEPPER_LOOP(j) REV_E_DIR(j); + count_direction.e = -1; + } + else { + MIXER_STEPPER_LOOP(j) NORM_E_DIR(j); + count_direction.e = 1; + } + #elif HAS_EXTRUDERS + if (motor_direction(E_AXIS)) { + REV_E_DIR(stepper_extruder); + count_direction.e = -1; + } + else { + NORM_E_DIR(stepper_extruder); + count_direction.e = 1; } #endif @@ -1394,7 +1373,7 @@ void Stepper::set_directions() { } FORCE_INLINE int32_t Stepper::_eval_bezier_curve(const uint32_t curr_step) { - #if (defined(__arm__) || defined(__thumb__)) && !defined(STM32G0B1xx) // TODO: Test define STM32G0xx versus STM32G0B1xx + #if (defined(__arm__) || defined(__thumb__)) && __ARM_ARCH >= 6 && !defined(STM32G0B1xx) // TODO: Test define STM32G0xx versus STM32G0B1xx // For ARM Cortex M3/M4 CPUs, we have the optimized assembler version, that takes 43 cycles to execute uint32_t flo = 0; @@ -1508,14 +1487,21 @@ void Stepper::isr() { // Enable ISRs to reduce USART processing latency hal.isr_on(); - if (!nextMainISR) pulse_phase_isr(); // 0 = Do coordinated axes Stepper pulses + TERN_(HAS_SHAPING, shaping_isr()); // Do Shaper stepping, if needed + + if (!nextMainISR) pulse_phase_isr(); // 0 = Do coordinated axes Stepper pulses #if ENABLED(LIN_ADVANCE) - if (!nextAdvanceISR) nextAdvanceISR = advance_isr(); // 0 = Do Linear Advance E Stepper pulses + if (!nextAdvanceISR) { // 0 = Do Linear Advance E Stepper pulses + advance_isr(); + nextAdvanceISR = la_interval; + } + else if (nextAdvanceISR == LA_ADV_NEVER) // Start LA steps if necessary + nextAdvanceISR = la_interval; #endif #if ENABLED(INTEGRATED_BABYSTEPPING) - const bool is_babystep = (nextBabystepISR == 0); // 0 = Do Babystepping (XY)Z pulses + const bool is_babystep = (nextBabystepISR == 0); // 0 = Do Babystepping (XY)Z pulses if (is_babystep) nextBabystepISR = babystepping_isr(); #endif @@ -1533,10 +1519,12 @@ 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(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? ); // @@ -1547,14 +1535,9 @@ void Stepper::isr() { // nextMainISR -= 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 @@ -1598,14 +1581,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 @@ -1624,8 +1600,11 @@ void Stepper::isr() { // Set the next ISR to fire at the proper time HAL_timer_set_compare(MF_TIMER_STEP, hal_timer_t(next_isr_ticks)); - // Don't forget to finally reenable interrupts - hal.isr_on(); + // Don't forget to finally reenable interrupts on non-AVR. + // AVR automatically calls sei() for us on Return-from-Interrupt. + #ifndef __AVR__ + hal.isr_on(); + #endif } #if MINIMUM_STEPPER_PULSE || MAXIMUM_STEPPER_RATE @@ -1647,11 +1626,24 @@ 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 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 + } } // 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; @@ -1670,6 +1662,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 @@ -1678,15 +1673,50 @@ 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) + + // 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) || \ + 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) || \ + AXIS_DRIVER_TYPE_Y(TMC5160) || AXIS_DRIVER_TYPE_Y(TMC5160_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)]) { \ + 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) @@ -1698,9 +1728,6 @@ void Stepper::pulse_phase_isr() { } \ }while(0) - // Direct Stepping page? - const bool is_page = IS_PAGE(current_block); - #if ENABLED(DIRECT_STEPPING) // Direct stepping is currently not ready for HAS_I_AXIS if (is_page) { @@ -1837,20 +1864,35 @@ void Stepper::pulse_phase_isr() { PULSE_PREP(W); #endif - #if EITHER(LIN_ADVANCE, MIXING_EXTRUDER) - delta_error.e += advance_dividend.e; - if (delta_error.e >= 0) { - #if ENABLED(LIN_ADVANCE) - delta_error.e -= advance_divisor; - // Don't step E here - But remember the number of steps to perform - motor_direction(E_AXIS) ? --LA_steps : ++LA_steps; - #else - count_position.e += count_direction.e; - step_needed.e = true; - #endif - } - #elif HAS_E0_STEP + #if EITHER(HAS_E0_STEP, MIXING_EXTRUDER) PULSE_PREP(E); + + #if ENABLED(LIN_ADVANCE) + if (step_needed.e && current_block->la_advance_rate) { + // don't actually step here, but do subtract movements steps + // from the linear advance step count + step_needed.e = false; + la_advance_steps--; + } + #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 } @@ -1890,21 +1932,20 @@ void Stepper::pulse_phase_isr() { PULSE_START(W); #endif - #if DISABLED(LIN_ADVANCE) - #if ENABLED(MIXING_EXTRUDER) - if (step_needed.e) E_STEP_WRITE(mixer.get_next_stepper(), !INVERT_E_STEP_PIN); - #elif HAS_E0_STEP - PULSE_START(E); - #endif + #if ENABLED(MIXING_EXTRUDER) + 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 - #if ENABLED(I2S_STEPPER_STREAM) - i2s_push_sample(); - #endif + TERN_(I2S_STEPPER_STREAM, i2s_push_sample()); // TODO: need to deal with MINIMUM_STEPPER_PULSE over i2s #if ISR_MULTI_STEPS - START_HIGH_PULSE(); + START_TIMED_PULSE(); AWAIT_HIGH_PULSE(); #endif @@ -1937,24 +1978,136 @@ void Stepper::pulse_phase_isr() { PULSE_STOP(W); #endif - #if DISABLED(LIN_ADVANCE) - #if ENABLED(MIXING_EXTRUDER) - if (delta_error.e >= 0) { - delta_error.e -= advance_divisor; - E_STEP_WRITE(mixer.get_stepper(), INVERT_E_STEP_PIN); - } - #elif HAS_E0_STEP - PULSE_STOP(E); - #endif + #if ENABLED(MIXING_EXTRUDER) + if (step_needed.e) E_STEP_WRITE(mixer.get_stepper(), INVERT_E_STEP_PIN); + #elif HAS_E0_STEP + PULSE_STOP(E); #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 HAS_SHAPING + + void Stepper::shaping_isr() { + 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 + + #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 + + TERN_(I2S_STEPPER_STREAM, i2s_push_sample()); + + 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 + } + + 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)) break; + + START_TIMED_PULSE(); + AWAIT_LOW_PULSE(); + } + } + +#endif // HAS_SHAPING + +// Calculate timer interval, with all limits applied. +uint32_t Stepper::calc_timer_interval(uint32_t step_rate) { + #ifdef CPU_32_BIT + // In case of high-performance processor, it is able to calculate in real-time + return uint32_t(STEPPER_TIMER_RATE) / step_rate; + #else + // AVR is able to keep up at 30khz Stepping ISR rate. + constexpr uint32_t min_step_rate = (F_CPU) / 500000U; + if (step_rate <= min_step_rate) { + step_rate = 0; + uintptr_t table_address = (uintptr_t)&speed_lookuptable_slow[0][0]; + return uint16_t(pgm_read_word(table_address)); + } + else { + step_rate -= min_step_rate; // Correct for minimal speed + if (step_rate >= 0x0800) { // higher step rate + const uint8_t rate_mod_256 = (step_rate & 0x00FF); + const uintptr_t table_address = uintptr_t(&speed_lookuptable_fast[uint8_t(step_rate >> 8)][0]), + gain = uint16_t(pgm_read_word(table_address + 2)); + return uint16_t(pgm_read_word(table_address)) - MultiU8X16toH16(rate_mod_256, gain); + } + else { // lower step rates + uintptr_t table_address = uintptr_t(&speed_lookuptable_slow[0][0]); + table_address += (step_rate >> 1) & 0xFFFC; + return uint16_t(pgm_read_word(table_address)) + - ((uint16_t(pgm_read_word(table_address + 2)) * uint8_t(step_rate & 0x0007)) >> 3); + } + } + #endif +} + +// Get the timer interval and the number of loops to perform per tick +uint32_t Stepper::calc_timer_interval(uint32_t step_rate, uint8_t &loops) { + uint8_t multistep = 1; + #if DISABLED(DISABLE_MULTI_STEPPING) + + // The stepping frequency limits for each multistepping rate + static const uint32_t limit[] PROGMEM = { + ( MAX_STEP_ISR_FREQUENCY_1X ), + ( MAX_STEP_ISR_FREQUENCY_2X >> 1), + ( MAX_STEP_ISR_FREQUENCY_4X >> 2), + ( MAX_STEP_ISR_FREQUENCY_8X >> 3), + ( MAX_STEP_ISR_FREQUENCY_16X >> 4), + ( MAX_STEP_ISR_FREQUENCY_32X >> 5), + ( MAX_STEP_ISR_FREQUENCY_64X >> 6), + (MAX_STEP_ISR_FREQUENCY_128X >> 7) + }; + + // Select the proper multistepping + uint8_t idx = 0; + while (idx < 7 && step_rate > (uint32_t)pgm_read_dword(&limit[idx])) { + step_rate >>= 1; + multistep <<= 1; + ++idx; + }; + #else + NOMORE(step_rate, uint32_t(MAX_STEP_ISR_FREQUENCY_1X)); + #endif + loops = multistep; + + return calc_timer_interval(step_rate); +} + // This is the last half of the stepper interrupt: This one processes and // properly schedules blocks from the planner. This is executed after creating // the step pulses, so it is not time critical, as pulses are already done. @@ -1966,7 +2119,6 @@ uint32_t Stepper::block_phase_isr() { // If there is a current block if (current_block) { - // If current block is finished, reset pointer and finalize state if (step_events_completed >= step_event_count) { #if ENABLED(DIRECT_STEPPING) @@ -1979,7 +2131,7 @@ uint32_t Stepper::block_phase_isr() { count_position[_AXIS(AXIS)] += page_step_state.bd[_AXIS(AXIS)] * count_direction[_AXIS(AXIS)]; #endif - if (IS_PAGE(current_block)) { + if (current_block->is_page()) { PAGE_SEGMENT_UPDATE_POS(X); PAGE_SEGMENT_UPDATE_POS(Y); PAGE_SEGMENT_UPDATE_POS(Z); @@ -2008,43 +2160,39 @@ uint32_t Stepper::block_phase_isr() { // acc_step_rate is in steps/second // step_rate to timer interval and steps per stepper isr - interval = calc_timer_interval(acc_step_rate, &steps_per_isr); + interval = calc_timer_interval(acc_step_rate << oversampling_factor, steps_per_isr); acceleration_time += interval; #if ENABLED(LIN_ADVANCE) - if (LA_use_advance_lead) { - // Fire ISR if final adv_rate is reached - if (LA_steps && LA_isr_rate != current_block->advance_speed) nextAdvanceISR = 0; + if (current_block->la_advance_rate) { + const uint32_t la_step_rate = la_advance_steps < current_block->max_adv_steps ? current_block->la_advance_rate : 0; + la_interval = calc_timer_interval(acc_step_rate + la_step_rate) << current_block->la_scaling; } - else if (LA_steps) nextAdvanceISR = 0; #endif - // Update laser - Accelerating - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - if (laser_trap.enabled) { - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - if (current_block->laser.entry_per) { - laser_trap.acc_step_count -= step_events_completed - laser_trap.last_step_count; - laser_trap.last_step_count = step_events_completed; - - // Should be faster than a divide, since this should trip just once - if (laser_trap.acc_step_count < 0) { - while (laser_trap.acc_step_count < 0) { - laser_trap.acc_step_count += current_block->laser.entry_per; - if (laser_trap.cur_power < current_block->laser.power) laser_trap.cur_power++; - } - cutter.ocr_set_power(laser_trap.cur_power); - } - } - #else - if (laser_trap.till_update) - laser_trap.till_update--; - else { - laser_trap.till_update = LASER_POWER_INLINE_TRAPEZOID_CONT_PER; - laser_trap.cur_power = (current_block->laser.power * acc_step_rate) / current_block->nominal_rate; - cutter.ocr_set_power(laser_trap.cur_power); // Cycle efficiency is irrelevant it the last line was many cycles + /** + * Adjust Laser Power - Accelerating + * + * isPowered - True when a move is powered. + * isEnabled - laser power is active. + * + * Laser power variables are calulated and stored in this block by the planner code. + * trap_ramp_active_pwr - the active power in this block across accel or decel trap steps. + * trap_ramp_entry_incr - holds the precalculated value to increase the current power per accel step. + * + * Apply the starting active power and then increase power per step by the trap_ramp_entry_incr value if positive. + */ + + #if ENABLED(LASER_POWER_TRAP) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { + if (planner.laser_inline.status.isPowered && planner.laser_inline.status.isEnabled) { + if (current_block->laser.trap_ramp_entry_incr > 0) { + cutter.apply_power(current_block->laser.trap_ramp_active_pwr); + current_block->laser.trap_ramp_active_pwr += current_block->laser.trap_ramp_entry_incr; } - #endif + } + // Not a powered move. + else cutter.apply_power(0); } #endif } @@ -2053,6 +2201,7 @@ uint32_t Stepper::block_phase_isr() { uint32_t step_rate; #if ENABLED(S_CURVE_ACCELERATION) + // If this is the 1st time we process the 2nd half of the trapezoid... if (!bezier_2nd_half) { // Initialize the Bézier speed curve @@ -2067,8 +2216,8 @@ uint32_t Stepper::block_phase_isr() { ? _eval_bezier_curve(deceleration_time) : current_block->final_rate; } - #else + #else // Using the old trapezoidal control step_rate = STEP_MULTIPLY(deceleration_time, current_block->acceleration_rate); if (step_rate < acc_step_rate) { // Still decelerating? @@ -2077,88 +2226,125 @@ uint32_t Stepper::block_phase_isr() { } else step_rate = current_block->final_rate; - #endif - // step_rate is in steps/second + #endif // step_rate to timer interval and steps per stepper isr - interval = calc_timer_interval(step_rate, &steps_per_isr); + interval = calc_timer_interval(step_rate << oversampling_factor, steps_per_isr); deceleration_time += interval; #if ENABLED(LIN_ADVANCE) - if (LA_use_advance_lead) { - // Wake up eISR on first deceleration loop and fire ISR if final adv_rate is reached - if (step_events_completed <= decelerate_after + steps_per_isr || (LA_steps && LA_isr_rate != current_block->advance_speed)) { - initiateLA(); - LA_isr_rate = current_block->advance_speed; + if (current_block->la_advance_rate) { + const uint32_t la_step_rate = la_advance_steps > current_block->final_adv_steps ? current_block->la_advance_rate : 0; + if (la_step_rate != step_rate) { + bool reverse_e = la_step_rate > step_rate; + la_interval = calc_timer_interval(reverse_e ? la_step_rate - step_rate : step_rate - la_step_rate) << current_block->la_scaling; + + if (reverse_e != motor_direction(E_AXIS)) { + TBI(last_direction_bits, E_AXIS); + count_direction.e = -count_direction.e; + + DIR_WAIT_BEFORE(); + + if (reverse_e) { + #if ENABLED(MIXING_EXTRUDER) + MIXER_STEPPER_LOOP(j) REV_E_DIR(j); + #else + REV_E_DIR(stepper_extruder); + #endif + } + else { + #if ENABLED(MIXING_EXTRUDER) + MIXER_STEPPER_LOOP(j) NORM_E_DIR(j); + #else + NORM_E_DIR(stepper_extruder); + #endif + } + + DIR_WAIT_AFTER(); + } } + else + la_interval = LA_ADV_NEVER; } - else if (LA_steps) nextAdvanceISR = 0; #endif // LIN_ADVANCE - // Update laser - Decelerating - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - if (laser_trap.enabled) { - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - if (current_block->laser.exit_per) { - laser_trap.acc_step_count -= step_events_completed - laser_trap.last_step_count; - laser_trap.last_step_count = step_events_completed; - - // Should be faster than a divide, since this should trip just once - if (laser_trap.acc_step_count < 0) { - while (laser_trap.acc_step_count < 0) { - laser_trap.acc_step_count += current_block->laser.exit_per; - if (laser_trap.cur_power > current_block->laser.power_exit) laser_trap.cur_power--; - } - cutter.ocr_set_power(laser_trap.cur_power); - } - } - #else - if (laser_trap.till_update) - laser_trap.till_update--; - else { - laser_trap.till_update = LASER_POWER_INLINE_TRAPEZOID_CONT_PER; - laser_trap.cur_power = (current_block->laser.power * step_rate) / current_block->nominal_rate; - cutter.ocr_set_power(laser_trap.cur_power); // Cycle efficiency isn't relevant when the last line was many cycles + /* + * Adjust Laser Power - Decelerating + * trap_ramp_entry_decr - holds the precalculated value to decrease the current power per decel step. + */ + #if ENABLED(LASER_POWER_TRAP) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { + if (planner.laser_inline.status.isPowered && planner.laser_inline.status.isEnabled) { + if (current_block->laser.trap_ramp_exit_decr > 0) { + current_block->laser.trap_ramp_active_pwr -= current_block->laser.trap_ramp_exit_decr; + cutter.apply_power(current_block->laser.trap_ramp_active_pwr); } - #endif + // Not a powered move. + else cutter.apply_power(0); + } } #endif - } - // Must be in cruise phase otherwise - else { - #if ENABLED(LIN_ADVANCE) - // If there are any esteps, fire the next advance_isr "now" - if (LA_steps && LA_isr_rate != current_block->advance_speed) initiateLA(); - #endif + } + else { // Must be in cruise phase otherwise // Calculate the ticks_nominal for this nominal speed, if not done yet if (ticks_nominal < 0) { // step_rate to timer interval and loops for the nominal speed - ticks_nominal = calc_timer_interval(current_block->nominal_rate, &steps_per_isr); + ticks_nominal = calc_timer_interval(current_block->nominal_rate << oversampling_factor, steps_per_isr); + + #if ENABLED(LIN_ADVANCE) + if (current_block->la_advance_rate) + la_interval = calc_timer_interval(current_block->nominal_rate) << current_block->la_scaling; + #endif } // The timer interval is just the nominal value for the nominal speed interval = ticks_nominal; + } - // Update laser - Cruising - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - if (laser_trap.enabled) { - if (!laser_trap.cruise_set) { - laser_trap.cur_power = current_block->laser.power; - cutter.ocr_set_power(laser_trap.cur_power); - laser_trap.cruise_set = true; + /** + * Adjust Laser Power - Cruise + * power - direct or floor adjusted active laser power. + */ + #if ENABLED(LASER_POWER_TRAP) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { + if (step_events_completed + 1 == accelerate_until) { + if (planner.laser_inline.status.isPowered && planner.laser_inline.status.isEnabled) { + if (current_block->laser.trap_ramp_entry_incr > 0) { + current_block->laser.trap_ramp_active_pwr = current_block->laser.power; + cutter.apply_power(current_block->laser.power); + } } - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - laser_trap.till_update = LASER_POWER_INLINE_TRAPEZOID_CONT_PER; - #else - laser_trap.last_step_count = step_events_completed; - #endif + // Not a powered move. + else cutter.apply_power(0); } - #endif - } + } + #endif } + + #if ENABLED(LASER_FEATURE) + /** + * CUTTER_MODE_DYNAMIC is experimental and developing. + * Super-fast method to dynamically adjust the laser power OCR value based on the input feedrate in mm-per-minute. + * TODO: Set up Min/Max OCR offsets to allow tuning and scaling of various lasers. + * TODO: Integrate accel/decel +-rate into the dynamic laser power calc. + */ + if (cutter.cutter_mode == CUTTER_MODE_DYNAMIC + && planner.laser_inline.status.isPowered // isPowered flag set on any parsed G1, G2, G3, or G5 move; cleared on any others. + && cutter.last_block_power != current_block->laser.power // Prevent constant update without change + ) { + cutter.apply_power(current_block->laser.power); + cutter.last_block_power = current_block->laser.power; + } + #endif + } + else { // !current_block + #if ENABLED(LASER_FEATURE) + if (cutter.cutter_mode == CUTTER_MODE_DYNAMIC) + cutter.apply_power(0); // No movement in dynamic mode so turn Laser off + #endif } // If there is no current block at this point, attempt to pop one from the buffer @@ -2169,16 +2355,20 @@ uint32_t Stepper::block_phase_isr() { if ((current_block = planner.get_current_block())) { // Sync block? Sync the stepper counts or fan speeds and return - while (current_block->flag & BLOCK_MASK_SYNC) { + while (current_block->is_sync()) { - #if ENABLED(LASER_SYNCHRONOUS_M106_M107) - const bool is_sync_fans = TEST(current_block->flag, BLOCK_BIT_SYNC_FANS); - if (is_sync_fans) planner.sync_fan_speeds(current_block->fan_speed); - #else - constexpr bool is_sync_fans = false; + #if ENABLED(LASER_POWER_SYNC) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { + if (current_block->is_pwr_sync()) { + planner.laser_inline.status.isSyncPower = true; + cutter.apply_power(current_block->laser.power); + } + } #endif - if (!is_sync_fans) _set_position(current_block->position); + TERN_(LASER_SYNCHRONOUS_M106_M107, if (current_block->is_fan_sync()) planner.sync_fan_speeds(current_block->fan_speed)); + + if (!(current_block->is_fan_sync() || current_block->is_pwr_sync())) _set_position(current_block->position); discard_current_block(); @@ -2188,8 +2378,10 @@ uint32_t Stepper::block_phase_isr() { } // For non-inline cutter, grossly apply power - #if ENABLED(LASER_FEATURE) && DISABLED(LASER_POWER_INLINE) - cutter.apply_power(current_block->cutter_power); + #if HAS_CUTTER + if (cutter.cutter_mode == CUTTER_MODE_STANDARD) { + cutter.apply_power(current_block->cutter_power); + } #endif #if ENABLED(POWER_LOSS_RECOVERY) @@ -2198,7 +2390,7 @@ uint32_t Stepper::block_phase_isr() { #endif #if ENABLED(DIRECT_STEPPING) - if (IS_PAGE(current_block)) { + if (current_block->is_page()) { page_step_state.segment_steps = 0; page_step_state.segment_idx = 0; page_step_state.page = page_manager.get_page(current_block->page_idx); @@ -2302,35 +2494,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 - delta_error = -int32_t(step_event_count); + 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; + #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)); @@ -2340,58 +2552,38 @@ uint32_t Stepper::block_phase_isr() { #if ENABLED(LIN_ADVANCE) #if DISABLED(MIXING_EXTRUDER) && E_STEPPERS > 1 // If the now active extruder wasn't in use during the last move, its pressure is most likely gone. - if (stepper_extruder != last_moved_extruder) LA_current_adv_steps = 0; + if (stepper_extruder != last_moved_extruder) la_advance_steps = 0; #endif - - if ((LA_use_advance_lead = current_block->use_advance_lead)) { - LA_final_adv_steps = current_block->final_adv_steps; - LA_max_adv_steps = current_block->max_adv_steps; - initiateLA(); // Start the ISR - LA_isr_rate = current_block->advance_speed; + 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_factor; } - else LA_isr_rate = LA_ADV_NEVER; #endif - if ( ENABLED(HAS_L64XX) // Always set direction for L64xx (Also enables the chips) - || ENABLED(DUAL_X_CARRIAGE) // TODO: Find out why this fixes "jittery" small circles + if ( ENABLED(DUAL_X_CARRIAGE) // TODO: Find out why this fixes "jittery" small circles || current_block->direction_bits != last_direction_bits || TERN(MIXING_EXTRUDER, false, stepper_extruder != last_moved_extruder) ) { E_TERN_(last_moved_extruder = stepper_extruder); - TERN_(HAS_L64XX, L64XX_OK_to_power_up = true); set_directions(current_block->direction_bits); } - #if ENABLED(LASER_POWER_INLINE) - const power_status_t stat = current_block->laser.status; - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - laser_trap.enabled = stat.isPlanned && stat.isEnabled; - laser_trap.cur_power = current_block->laser.power_entry; // RESET STATE - laser_trap.cruise_set = false; - #if DISABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - laser_trap.last_step_count = 0; - laser_trap.acc_step_count = current_block->laser.entry_per / 2; - #else - laser_trap.till_update = 0; - #endif - // Always have PWM in this case - if (stat.isPlanned) { // Planner controls the laser - cutter.ocr_set_power( - stat.isEnabled ? laser_trap.cur_power : 0 // ON with power or OFF - ); - } - #else - if (stat.isPlanned) { // Planner controls the laser - #if ENABLED(SPINDLE_LASER_USE_PWM) - cutter.ocr_set_power( - stat.isEnabled ? current_block->laser.power : 0 // ON with power or OFF - ); + #if ENABLED(LASER_FEATURE) + if (cutter.cutter_mode == CUTTER_MODE_CONTINUOUS) { // Planner controls the laser + if (planner.laser_inline.status.isSyncPower) + // If the previous block was a M3 sync power then skip the trap power init otherwise it will 0 the sync power. + planner.laser_inline.status.isSyncPower = false; // Clear the flag to process subsequent trap calc's. + else if (current_block->laser.status.isEnabled) { + #if ENABLED(LASER_POWER_TRAP) + TERN_(DEBUG_LASER_TRAP, SERIAL_ECHO_MSG("InitTrapPwr:",current_block->laser.trap_ramp_active_pwr)); + cutter.apply_power(current_block->laser.status.isPowered ? current_block->laser.trap_ramp_active_pwr : 0); #else - cutter.set_enabled(stat.isEnabled); + TERN_(DEBUG_CUTTER_POWER, SERIAL_ECHO_MSG("InlinePwr:",current_block->laser.power)); + cutter.apply_power(current_block->laser.status.isPowered ? current_block->laser.power : 0); #endif } - #endif - #endif // LASER_POWER_INLINE + } + #endif // LASER_FEATURE // If the endstop is already pressed, endstop interrupts won't invoke // endstop_triggered and the move will grind. So check here for a @@ -2419,23 +2611,16 @@ uint32_t Stepper::block_phase_isr() { #endif // Calculate the initial timer interval - interval = calc_timer_interval(current_block->initial_rate, &steps_per_isr); - } - #if ENABLED(LASER_POWER_INLINE_CONTINUOUS) - else { // No new block found; so apply inline laser parameters - // This should mean ending file with 'M5 I' will stop the laser; thus the inline flag isn't needed - const power_status_t stat = planner.laser_inline.status; - if (stat.isPlanned) { // Planner controls the laser - #if ENABLED(SPINDLE_LASER_USE_PWM) - cutter.ocr_set_power( - stat.isEnabled ? planner.laser_inline.power : 0 // ON with power or OFF - ); - #else - cutter.set_enabled(stat.isEnabled); - #endif + interval = calc_timer_interval(current_block->initial_rate << oversampling_factor, steps_per_isr); + acceleration_time += interval; + + #if ENABLED(LIN_ADVANCE) + if (current_block->la_advance_rate) { + const uint32_t la_step_rate = la_advance_steps < current_block->max_adv_steps ? current_block->la_advance_rate : 0; + la_interval = calc_timer_interval(current_block->initial_rate + la_step_rate) << current_block->la_scaling; } - } - #endif + #endif + } } // Return the interval to wait @@ -2445,105 +2630,34 @@ uint32_t Stepper::block_phase_isr() { #if ENABLED(LIN_ADVANCE) // Timer interrupt for E. LA_steps is set in the main routine - uint32_t Stepper::advance_isr() { - uint32_t interval; - - if (LA_use_advance_lead) { - if (step_events_completed > decelerate_after && LA_current_adv_steps > LA_final_adv_steps) { - LA_steps--; - LA_current_adv_steps--; - interval = LA_isr_rate; - } - else if (step_events_completed < decelerate_after && LA_current_adv_steps < LA_max_adv_steps) { - LA_steps++; - LA_current_adv_steps++; - interval = LA_isr_rate; - } - else - interval = LA_isr_rate = LA_ADV_NEVER; - } - else - interval = LA_ADV_NEVER; - - if (!LA_steps) return interval; // Leave pins alone if there are no steps! - - DIR_WAIT_BEFORE(); - - #if ENABLED(MIXING_EXTRUDER) - // We don't know which steppers will be stepped because LA loop follows, - // with potentially multiple steps. Set all. - if (LA_steps > 0) { - MIXER_STEPPER_LOOP(j) NORM_E_DIR(j); - count_direction.e = 1; - } - else if (LA_steps < 0) { - MIXER_STEPPER_LOOP(j) REV_E_DIR(j); - count_direction.e = -1; - } - #else - if (LA_steps > 0) { - NORM_E_DIR(stepper_extruder); - count_direction.e = 1; - } - else if (LA_steps < 0) { - REV_E_DIR(stepper_extruder); - count_direction.e = -1; - } - #endif - - DIR_WAIT_AFTER(); - - //const hal_timer_t added_step_ticks = hal_timer_t(ADDED_STEP_TICKS); - - // Step E stepper if we have steps - #if ISR_MULTI_STEPS - bool firstStep = true; - USING_TIMED_PULSE(); - #endif - - while (LA_steps) { - #if ISR_MULTI_STEPS - if (firstStep) - firstStep = false; - else - AWAIT_LOW_PULSE(); - #endif - + void Stepper::advance_isr() { + // Apply Bresenham algorithm so that linear advance can piggy back on + // 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; + 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 - - // Enforce a minimum duration for STEP pulse ON - #if ISR_PULSE_CONTROL - START_HIGH_PULSE(); - #endif + E_STEP_WRITE(TERN(MIXING_EXTRUDER, mixer.get_next_stepper(), stepper_extruder), !INVERT_E_STEP_PIN); + } - LA_steps < 0 ? ++LA_steps : --LA_steps; + 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(); + START_TIMED_PULSE(); AWAIT_HIGH_PULSE(); #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 - - // For minimum pulse time wait before looping - // Just wait for the requested pulse duration - #if ISR_PULSE_CONTROL - if (LA_steps) START_LOW_PULSE(); - #endif - } // LA_steps - - return interval; + E_STEP_WRITE(TERN(MIXING_EXTRUDER, mixer.get_stepper(), stepper_extruder), INVERT_E_STEP_PIN); + } } #endif // LIN_ADVANCE @@ -2666,35 +2780,44 @@ void Stepper::init() { // Init Enable Pins - steppers default to disabled. #if HAS_X_ENABLE + #ifndef X_ENABLE_INIT_STATE + #define X_ENABLE_INIT_STATE !X_ENABLE_ON + #endif X_ENABLE_INIT(); - if (!X_ENABLE_ON) X_ENABLE_WRITE(HIGH); + if (X_ENABLE_INIT_STATE) X_ENABLE_WRITE(X_ENABLE_INIT_STATE); #if BOTH(HAS_X2_STEPPER, HAS_X2_ENABLE) X2_ENABLE_INIT(); - if (!X_ENABLE_ON) X2_ENABLE_WRITE(HIGH); + if (X_ENABLE_INIT_STATE) X2_ENABLE_WRITE(X_ENABLE_INIT_STATE); #endif #endif #if HAS_Y_ENABLE + #ifndef Y_ENABLE_INIT_STATE + #define Y_ENABLE_INIT_STATE !Y_ENABLE_ON + #endif Y_ENABLE_INIT(); - if (!Y_ENABLE_ON) Y_ENABLE_WRITE(HIGH); + if (Y_ENABLE_INIT_STATE) Y_ENABLE_WRITE(Y_ENABLE_INIT_STATE); #if BOTH(HAS_DUAL_Y_STEPPERS, HAS_Y2_ENABLE) Y2_ENABLE_INIT(); - if (!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH); + if (Y_ENABLE_INIT_STATE) Y2_ENABLE_WRITE(Y_ENABLE_INIT_STATE); #endif #endif #if HAS_Z_ENABLE + #ifndef Z_ENABLE_INIT_STATE + #define Z_ENABLE_INIT_STATE !Z_ENABLE_ON + #endif Z_ENABLE_INIT(); - if (!Z_ENABLE_ON) Z_ENABLE_WRITE(HIGH); + if (Z_ENABLE_INIT_STATE) Z_ENABLE_WRITE(Z_ENABLE_INIT_STATE); #if NUM_Z_STEPPERS >= 2 && HAS_Z2_ENABLE Z2_ENABLE_INIT(); - if (!Z_ENABLE_ON) Z2_ENABLE_WRITE(HIGH); + if (Z_ENABLE_INIT_STATE) Z2_ENABLE_WRITE(Z_ENABLE_INIT_STATE); #endif #if NUM_Z_STEPPERS >= 3 && HAS_Z3_ENABLE Z3_ENABLE_INIT(); - if (!Z_ENABLE_ON) Z3_ENABLE_WRITE(HIGH); + if (Z_ENABLE_INIT_STATE) Z3_ENABLE_WRITE(Z_ENABLE_INIT_STATE); #endif #if NUM_Z_STEPPERS >= 4 && HAS_Z4_ENABLE Z4_ENABLE_INIT(); - if (!Z_ENABLE_ON) Z4_ENABLE_WRITE(HIGH); + if (Z_ENABLE_INIT_STATE) Z4_ENABLE_WRITE(Z_ENABLE_INIT_STATE); #endif #endif #if HAS_I_ENABLE @@ -2722,36 +2845,63 @@ void Stepper::init() { if (!W_ENABLE_ON) W_ENABLE_WRITE(HIGH); #endif #if HAS_E0_ENABLE + #ifndef E_ENABLE_INIT_STATE + #define E_ENABLE_INIT_STATE !E_ENABLE_ON + #endif + #ifndef E0_ENABLE_INIT_STATE + #define E0_ENABLE_INIT_STATE E_ENABLE_INIT_STATE + #endif E0_ENABLE_INIT(); - if (!E_ENABLE_ON) E0_ENABLE_WRITE(HIGH); + if (E0_ENABLE_INIT_STATE) E0_ENABLE_WRITE(E0_ENABLE_INIT_STATE); #endif #if HAS_E1_ENABLE + #ifndef E1_ENABLE_INIT_STATE + #define E1_ENABLE_INIT_STATE E_ENABLE_INIT_STATE + #endif E1_ENABLE_INIT(); - if (!E_ENABLE_ON) E1_ENABLE_WRITE(HIGH); + if (E1_ENABLE_INIT_STATE) E1_ENABLE_WRITE(E1_ENABLE_INIT_STATE); #endif #if HAS_E2_ENABLE + #ifndef E2_ENABLE_INIT_STATE + #define E2_ENABLE_INIT_STATE E_ENABLE_INIT_STATE + #endif E2_ENABLE_INIT(); - if (!E_ENABLE_ON) E2_ENABLE_WRITE(HIGH); + if (E2_ENABLE_INIT_STATE) E2_ENABLE_WRITE(E2_ENABLE_INIT_STATE); #endif #if HAS_E3_ENABLE + #ifndef E3_ENABLE_INIT_STATE + #define E3_ENABLE_INIT_STATE E_ENABLE_INIT_STATE + #endif E3_ENABLE_INIT(); - if (!E_ENABLE_ON) E3_ENABLE_WRITE(HIGH); + if (E3_ENABLE_INIT_STATE) E3_ENABLE_WRITE(E3_ENABLE_INIT_STATE); #endif #if HAS_E4_ENABLE + #ifndef E4_ENABLE_INIT_STATE + #define E4_ENABLE_INIT_STATE E_ENABLE_INIT_STATE + #endif E4_ENABLE_INIT(); - if (!E_ENABLE_ON) E4_ENABLE_WRITE(HIGH); + if (E4_ENABLE_INIT_STATE) E4_ENABLE_WRITE(E4_ENABLE_INIT_STATE); #endif #if HAS_E5_ENABLE + #ifndef E5_ENABLE_INIT_STATE + #define E5_ENABLE_INIT_STATE E_ENABLE_INIT_STATE + #endif E5_ENABLE_INIT(); - if (!E_ENABLE_ON) E5_ENABLE_WRITE(HIGH); + if (E5_ENABLE_INIT_STATE) E5_ENABLE_WRITE(E5_ENABLE_INIT_STATE); #endif #if HAS_E6_ENABLE + #ifndef E6_ENABLE_INIT_STATE + #define E6_ENABLE_INIT_STATE E_ENABLE_INIT_STATE + #endif E6_ENABLE_INIT(); - if (!E_ENABLE_ON) E6_ENABLE_WRITE(HIGH); + if (E6_ENABLE_INIT_STATE) E6_ENABLE_WRITE(E6_ENABLE_INIT_STATE); #endif #if HAS_E7_ENABLE + #ifndef E7_ENABLE_INIT_STATE + #define E7_ENABLE_INIT_STATE E_ENABLE_INIT_STATE + #endif E7_ENABLE_INIT(); - if (!E_ENABLE_ON) E7_ENABLE_WRITE(HIGH); + if (E7_ENABLE_INIT_STATE) E7_ENABLE_WRITE(E7_ENABLE_INIT_STATE); #endif #define _STEP_INIT(AXIS) AXIS ##_STEP_INIT() @@ -2868,6 +3018,79 @@ void Stepper::init() { #endif } +#if HAS_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_t 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 factor2; + if (zeta <= 0.0f) factor2 = 64.0f; + else if (zeta >= 1.0f) factor2 = 0.0f; + else { + factor2 = 64.44056192 + -99.02008832 * zeta; + const_float_t zeta2 = zeta * zeta; + factor2 += -7.58095488 * zeta2; + const_float_t zeta3 = zeta2 * zeta; + factor2 += 43.073216 * zeta3; + factor2 = floor(factor2); + } + + const bool was_on = hal.isr_state(); + hal.isr_off(); + 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_(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_t 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_(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 // HAS_SHAPING + /** * Set the stepper positions directly in steps * @@ -2878,11 +3101,18 @@ 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 // these equations follow the form of the dA and dB equations on https://www.corexy.com/theory.html - count_position.set(spos.a + spos.b, CORESIGN(spos.a - spos.b), spos.c); + count_position.set(spos.a + spos.b, CORESIGN(spos.a - spos.b) OPTARG(HAS_Z_AXIS, spos.c)); #elif CORE_IS_XZ // corexz planning count_position.set(spos.a + spos.c, spos.b, CORESIGN(spos.a - spos.c)); @@ -2907,6 +3137,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 } /** @@ -2946,6 +3189,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 @@ -3073,7 +3318,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 @@ -3519,7 +3764,7 @@ void Stepper::report_positions() { #else // PRINTRBOARD_G2 - #include HAL_PATH(../HAL, fastio/G2_PWM.h) + #include HAL_PATH(.., fastio/G2_PWM.h) #endif @@ -3911,30 +4156,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/module/stepper.h b/Marlin/src/module/stepper.h index 3b899e93e27c..dcb9babde7d9 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) @@ -87,30 +87,38 @@ // 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 + // 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 996UL // Linear advance base time is 32 cycles #if ENABLED(LIN_ADVANCE) - #define ISR_LA_BASE_CYCLES 32UL + #define ISR_LA_BASE_CYCLES 30UL #else #define ISR_LA_BASE_CYCLES 0UL #endif @@ -122,12 +130,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 @@ -142,38 +154,39 @@ // Add time for each stepper #if HAS_X_STEP - #define ISR_X_STEPPER_CYCLES ISR_STEPPER_CYCLES + #define ISR_X_STEPPER_CYCLES ISR_STEPPER_CYCLES #endif #if HAS_Y_STEP - #define ISR_Y_STEPPER_CYCLES ISR_STEPPER_CYCLES + #define ISR_Y_STEPPER_CYCLES ISR_STEPPER_CYCLES #endif #if HAS_Z_STEP - #define ISR_Z_STEPPER_CYCLES ISR_STEPPER_CYCLES + #define ISR_Z_STEPPER_CYCLES ISR_STEPPER_CYCLES #endif #if HAS_I_STEP - #define ISR_I_STEPPER_CYCLES ISR_STEPPER_CYCLES + #define ISR_I_STEPPER_CYCLES ISR_STEPPER_CYCLES #endif #if HAS_J_STEP - #define ISR_J_STEPPER_CYCLES ISR_STEPPER_CYCLES + #define ISR_J_STEPPER_CYCLES ISR_STEPPER_CYCLES #endif #if HAS_K_STEP - #define ISR_K_STEPPER_CYCLES ISR_STEPPER_CYCLES + #define ISR_K_STEPPER_CYCLES ISR_STEPPER_CYCLES #endif #if HAS_U_STEP - #define ISR_U_STEPPER_CYCLES ISR_STEPPER_CYCLES + #define ISR_U_STEPPER_CYCLES ISR_STEPPER_CYCLES #endif #if HAS_V_STEP - #define ISR_V_STEPPER_CYCLES ISR_STEPPER_CYCLES + #define ISR_V_STEPPER_CYCLES ISR_STEPPER_CYCLES #endif #if HAS_W_STEP - #define ISR_W_STEPPER_CYCLES ISR_STEPPER_CYCLES + #define ISR_W_STEPPER_CYCLES ISR_STEPPER_CYCLES #endif #if HAS_EXTRUDERS - #define ISR_E_STEPPER_CYCLES ISR_STEPPER_CYCLES // E is always interpolated, even for mixing extruders + #define ISR_E_STEPPER_CYCLES ISR_STEPPER_CYCLES // E is always interpolated, even for mixing extruders #endif // And the total minimum loop time, not including the base -#define MIN_ISR_LOOP_CYCLES (ISR_MIXING_STEPPER_CYCLES LOGICAL_AXIS_GANG(+ ISR_E_STEPPER_CYCLES, + ISR_X_STEPPER_CYCLES, + ISR_Y_STEPPER_CYCLES, + ISR_Z_STEPPER_CYCLES, + ISR_I_STEPPER_CYCLES, + ISR_J_STEPPER_CYCLES, + ISR_K_STEPPER_CYCLES, + ISR_U_STEPPER_CYCLES, + ISR_V_STEPPER_CYCLES, + ISR_W_STEPPER_CYCLES)) +#define _PLUS_AXIS_CYCLES(A) + (ISR_##A##_STEPPER_CYCLES) +#define MIN_ISR_LOOP_CYCLES (ISR_MIXING_STEPPER_CYCLES LOGICAL_AXIS_MAP(_PLUS_AXIS_CYCLES)) // Calculate the minimum MPU cycles needed per pulse to enforce, limited to the max stepper rate #define _MIN_STEPPER_PULSE_CYCLES(N) _MAX(uint32_t((F_CPU) / (MAXIMUM_STEPPER_RATE)), ((F_CPU) / 500000UL) * (N)) @@ -202,8 +215,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, (R) * ((ISR_LOOP_BASE_CYCLES) + TERN0(INPUT_SHAPING_X, ISR_X_STEPPER_CYCLES) + TERN0(INPUT_SHAPING_Y, ISR_Y_STEPPER_CYCLES))) // If linear advance is enabled, then it is handled separately #if ENABLED(LIN_ADVANCE) @@ -228,7 +245,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,10 +329,143 @@ constexpr ena_mask_t enable_overlap[] = { //static_assert(!any_enable_overlap(), "There is some overlap."); +#if HAS_SHAPING + + #ifdef SHAPING_MAX_STEPRATE + constexpr float max_step_rate = SHAPING_MAX_STEPRATE; + #else + constexpr float _ISDASU[] = DEFAULT_AXIS_STEPS_PER_UNIT; + constexpr feedRate_t _ISDMF[] = DEFAULT_MAX_FEEDRATE; + constexpr float max_shaped_rate = TERN0(INPUT_SHAPING_X, _ISDMF[X_AXIS] * _ISDASU[X_AXIS]) + + TERN0(INPUT_SHAPING_Y, _ISDMF[Y_AXIS] * _ISDASU[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(_ISDMF[INDEX - 1] * _ISDASU[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 + + #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 { + TERN_(INPUT_SHAPING_X, shaping_echo_t x:2); + TERN_(INPUT_SHAPING_Y, shaping_echo_t y:2); + }; + + class ShapingQueue { + private: + 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 + #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: + 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); + } + 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 + #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; + 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 // HAS_SHAPING + // // Stepper class definition // class Stepper { + friend class KinematicSystem; + friend class DeltaKinematicSystem; + friend void stepperTask(void *); public: @@ -388,7 +538,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 @@ -413,12 +563,22 @@ class Stepper { static bool bezier_2nd_half; // If Bézier curve has been initialized or not #endif + #if HAS_SHAPING + #if ENABLED(INPUT_SHAPING_X) + static ShapeParams shaping_x; + #endif + #if ENABLED(INPUT_SHAPING_Y) + static ShapeParams shaping_y; + #endif + #endif + #if ENABLED(LIN_ADVANCE) static constexpr uint32_t LA_ADV_NEVER = 0xFFFFFFFF; - static uint32_t nextAdvanceISR, LA_isr_rate; - static uint16_t LA_current_adv_steps, LA_final_adv_steps, LA_max_adv_steps; // Copy from current executed block. Needed because current_block is set to NULL "too early". - static int8_t LA_steps; - static bool LA_use_advance_lead; + static uint32_t nextAdvanceISR, + la_interval; // Interval between ISR calls for LA + static int32_t la_delta_error, // Analogue of delta_error.e for E steps in LA ISR + la_dividend, // Analogue of advance_dividend.e for E steps in LA ISR + la_advance_steps; // Count of steps added to increase nozzle pressure #endif #if ENABLED(INTEGRATED_BABYSTEPPING) @@ -444,25 +604,6 @@ class Stepper { // Current stepper motor directions (+1 or -1) static xyze_int8_t count_direction; - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID) - - typedef struct { - bool enabled; // Trapezoid needed flag (i.e., laser on, planner in control) - uint8_t cur_power; // Current laser power - bool cruise_set; // Power set up for cruising? - - #if ENABLED(LASER_POWER_INLINE_TRAPEZOID_CONT) - uint16_t till_update; // Countdown to the next update - #else - uint32_t last_step_count, // Step count from the last update - acc_step_count; // Bresenham counter for laser accel/decel - #endif - } stepper_laser_t; - - static stepper_laser_t laser_trap; - - #endif - public: // Initialize stepper hardware static void init(); @@ -490,10 +631,13 @@ class Stepper { // The stepper block processing ISR phase static uint32_t block_phase_isr(); + #if HAS_SHAPING + static void shaping_isr(); + #endif + #if ENABLED(LIN_ADVANCE) // The Linear advance ISR phase - static uint32_t advance_isr(); - FORCE_INLINE static void initiateLA() { nextAdvanceISR = 0; } + static void advance_isr(); #endif #if ENABLED(INTEGRATED_BABYSTEPPING) @@ -510,6 +654,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); @@ -524,12 +682,12 @@ class Stepper { // Discard current block and free any resources FORCE_INLINE static void discard_current_block() { #if ENABLED(DIRECT_STEPPING) - if (IS_PAGE(current_block)) - page_manager.free_page(current_block->page_idx); + if (current_block->is_page()) page_manager.free_page(current_block->page_idx); #endif current_block = nullptr; axis_did_move = 0; planner.release_current_block(); + TERN_(LIN_ADVANCE, la_interval = nextAdvanceISR = LA_ADV_NEVER); } // Quickly stop all steppers @@ -644,70 +802,21 @@ class Stepper { set_directions(); } + #if HAS_SHAPING + static void set_shaping_damping_ratio(const AxisEnum axis, const_float_t zeta); + static float get_shaping_damping_ratio(const AxisEnum axis); + static void set_shaping_frequency(const AxisEnum axis, const_float_t freq); + static float get_shaping_frequency(const AxisEnum axis); + #endif + private: // Set the current position in steps static void _set_position(const abce_long_t &spos); - FORCE_INLINE static uint32_t calc_timer_interval(uint32_t step_rate, uint8_t *loops) { - uint32_t timer; - - // Scale the frequency, as requested by the caller - step_rate <<= oversampling_factor; - - uint8_t multistep = 1; - #if DISABLED(DISABLE_MULTI_STEPPING) - - // The stepping frequency limits for each multistepping rate - static const uint32_t limit[] PROGMEM = { - ( MAX_STEP_ISR_FREQUENCY_1X ), - ( MAX_STEP_ISR_FREQUENCY_2X >> 1), - ( MAX_STEP_ISR_FREQUENCY_4X >> 2), - ( MAX_STEP_ISR_FREQUENCY_8X >> 3), - ( MAX_STEP_ISR_FREQUENCY_16X >> 4), - ( MAX_STEP_ISR_FREQUENCY_32X >> 5), - ( MAX_STEP_ISR_FREQUENCY_64X >> 6), - (MAX_STEP_ISR_FREQUENCY_128X >> 7) - }; - - // Select the proper multistepping - uint8_t idx = 0; - while (idx < 7 && step_rate > (uint32_t)pgm_read_dword(&limit[idx])) { - step_rate >>= 1; - multistep <<= 1; - ++idx; - }; - #else - NOMORE(step_rate, uint32_t(MAX_STEP_ISR_FREQUENCY_1X)); - #endif - *loops = multistep; - - #ifdef CPU_32_BIT - // In case of high-performance processor, it is able to calculate in real-time - timer = uint32_t(STEPPER_TIMER_RATE) / step_rate; - #else - constexpr uint32_t min_step_rate = (F_CPU) / 500000U; - NOLESS(step_rate, min_step_rate); - step_rate -= min_step_rate; // Correct for minimal speed - if (step_rate >= (8 * 256)) { // higher step rate - const uint8_t tmp_step_rate = (step_rate & 0x00FF); - const uint16_t table_address = (uint16_t)&speed_lookuptable_fast[(uint8_t)(step_rate >> 8)][0], - gain = (uint16_t)pgm_read_word(table_address + 2); - timer = MultiU16X8toH16(tmp_step_rate, gain); - timer = (uint16_t)pgm_read_word(table_address) - timer; - } - else { // lower step rates - uint16_t table_address = (uint16_t)&speed_lookuptable_slow[0][0]; - table_address += ((step_rate) >> 1) & 0xFFFC; - timer = (uint16_t)pgm_read_word(table_address) - - (((uint16_t)pgm_read_word(table_address + 2) * (uint8_t)(step_rate & 0x0007)) >> 3); - } - // (there is no need to limit the timer value here. All limits have been - // applied above, and AVR is able to keep up at 30khz Stepping ISR rate) - #endif - - return timer; - } + // Calculate timing interval for the given step rate + static uint32_t calc_timer_interval(uint32_t step_rate); + static uint32_t calc_timer_interval(uint32_t step_rate, uint8_t &loops); #if ENABLED(S_CURVE_ACCELERATION) static void _calc_bezier_curve_coeffs(const int32_t v0, const int32_t v1, const uint32_t av); diff --git a/Marlin/src/module/stepper/L64xx.cpp b/Marlin/src/module/stepper/L64xx.cpp deleted file mode 100644 index 5b607463969f..000000000000 --- a/Marlin/src/module/stepper/L64xx.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 . - * - */ - -/** - * stepper/L64xx.cpp - * Stepper driver indirection for L64XX drivers - */ - -#include "../../inc/MarlinConfig.h" - -#if HAS_L64XX - -#include "L64xx.h" - -#if AXIS_IS_L64XX(X) - L64XX_CLASS(X) stepperX(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(X2) - L64XX_CLASS(X2) stepperX2(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Y) - L64XX_CLASS(Y) stepperY(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Y2) - L64XX_CLASS(Y2) stepperY2(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Z) - L64XX_CLASS(Z) stepperZ(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Z2) - L64XX_CLASS(Z2) stepperZ2(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Z3) - L64XX_CLASS(Z3) stepperZ3(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(Z4) - L64XX_CLASS(Z4) stepperZ4(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(I) - L64XX_CLASS(I) stepperI(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(J) - L64XX_CLASS(J) stepperJ(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(K) - L64XX_CLASS(K) stepperK(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(U) - L64XX_CLASS(u) stepperU(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(V) - L64XX_CLASS(v) stepperV(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(W) - L64XX_CLASS(w) stepperW(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E0) - L64XX_CLASS(E0) stepperE0(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E1) - L64XX_CLASS(E1) stepperE1(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E2) - L64XX_CLASS(E2) stepperE2(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E3) - L64XX_CLASS(E3) stepperE3(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E4) - L64XX_CLASS(E4) stepperE4(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E5) - L64XX_CLASS(E5) stepperE5(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E6) - L64XX_CLASS(E6) stepperE6(L6470_CHAIN_SS_PIN); -#endif -#if AXIS_IS_L64XX(E7) - L64XX_CLASS(E7) stepperE7(L6470_CHAIN_SS_PIN); -#endif - -// Not using L64XX class init method because it -// briefly sends power to the steppers - -inline void L6470_init_chip(L64XX &st, const int ms, const int oc, const int sc, const int mv, const int slew_rate) { - st.set_handlers(L64xxManager.spi_init, L64xxManager.transfer_single, L64xxManager.transfer_chain); // specify which external SPI routines to use - switch (st.L6470_status_layout) { - case L6470_STATUS_LAYOUT: { - st.resetDev(); - st.softFree(); - st.SetParam(st.L64XX_CONFIG, CONFIG_PWM_DIV_1 | CONFIG_PWM_MUL_2 | CONFIG_OC_SD_DISABLE | CONFIG_VS_COMP_DISABLE | CONFIG_SW_HARD_STOP | CONFIG_INT_16MHZ); - st.SetParam(L6470_KVAL_RUN, 0xFF); - st.SetParam(L6470_KVAL_ACC, 0xFF); - st.SetParam(L6470_KVAL_DEC, 0xFF); - st.setMicroSteps(ms); - st.setOverCurrent(oc); - st.setStallCurrent(sc); - st.SetParam(L6470_KVAL_HOLD, mv); - st.SetParam(L6470_ABS_POS, 0); - uint32_t config_temp = st.GetParam(st.L64XX_CONFIG); - config_temp &= ~CONFIG_POW_SR; - switch (slew_rate) { - case 0: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_75V_us); break; - default: - case 1: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_110V_us); break; - case 3: - case 2: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_260V_us); break; - } - st.getStatus(); - st.getStatus(); - break; - } - - case L6474_STATUS_LAYOUT: { - st.free(); - //st.SetParam(st.L64XX_CONFIG, CONFIG_PWM_DIV_1 | CONFIG_PWM_MUL_2 | CONFIG_OC_SD_DISABLE | CONFIG_VS_COMP_DISABLE | CONFIG_SW_HARD_STOP | CONFIG_INT_16MHZ); - //st.SetParam(L6474_TVAL, 0xFF); - st.setMicroSteps(ms); - st.setOverCurrent(oc); - st.setTVALCurrent(sc); - st.SetParam(L6470_ABS_POS, 0); - uint32_t config_temp = st.GetParam(st.L64XX_CONFIG); - config_temp &= ~CONFIG_POW_SR & ~CONFIG_EN_TQREG; // clear out slew rate and set current to be controlled by TVAL register - switch (slew_rate) { - case 0: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_75V_us); break; - default: - case 1: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_110V_us); break; - case 3: - case 2: st.SetParam(st.L64XX_CONFIG, config_temp | CONFIG_SR_260V_us); break; - //case 0: st.SetParam(st.L64XX_CONFIG, 0x2E88 | CONFIG_EN_TQREG | CONFIG_SR_75V_us); break; - //default: - //case 1: st.SetParam(st.L64XX_CONFIG, 0x2E88 | CONFIG_EN_TQREG | CONFIG_SR_110V_us); break; - //case 3: - //case 2: st.SetParam(st.L64XX_CONFIG, 0x2E88 | CONFIG_EN_TQREG | CONFIG_SR_260V_us); break; - - //case 0: st.SetParam(st.L64XX_CONFIG, 0x2E88 ); break; - //default: - //case 1: st.SetParam(st.L64XX_CONFIG, 0x2E88 ); break; - //case 3: - //case 2: st.SetParam(st.L64XX_CONFIG, 0x2E88 ); break; - } - st.getStatus(); - st.getStatus(); - break; - } - - case L6480_STATUS_LAYOUT: { - st.resetDev(); - st.softFree(); - st.SetParam(st.L64XX_CONFIG, CONFIG_PWM_DIV_1 | CONFIG_PWM_MUL_2 | CONFIG_OC_SD_DISABLE | CONFIG_VS_COMP_DISABLE | CONFIG_SW_HARD_STOP | CONFIG_INT_16MHZ); - st.SetParam(L6470_KVAL_RUN, 0xFF); - st.SetParam(L6470_KVAL_ACC, 0xFF); - st.SetParam(L6470_KVAL_DEC, 0xFF); - st.setMicroSteps(ms); - st.setOverCurrent(oc); - st.setStallCurrent(sc); - st.SetParam(+-L6470_KVAL_HOLD, mv); - st.SetParam(L6470_ABS_POS, 0); - st.SetParam(st.L64XX_CONFIG,(st.GetParam(st.L64XX_CONFIG) | PWR_VCC_7_5V)); - st.getStatus(); // must clear out status bits before can set slew rate - st.getStatus(); - switch (slew_rate) { - case 0: st.SetParam(L6470_GATECFG1, CONFIG1_SR_220V_us); st.SetParam(L6470_GATECFG2, CONFIG2_SR_220V_us); break; - default: - case 1: st.SetParam(L6470_GATECFG1, CONFIG1_SR_400V_us); st.SetParam(L6470_GATECFG2, CONFIG2_SR_400V_us); break; - case 2: st.SetParam(L6470_GATECFG1, CONFIG1_SR_520V_us); st.SetParam(L6470_GATECFG2, CONFIG2_SR_520V_us); break; - case 3: st.SetParam(L6470_GATECFG1, CONFIG1_SR_980V_us); st.SetParam(L6470_GATECFG2, CONFIG2_SR_980V_us); break; - } - break; - } - } -} - -#define L6470_INIT_CHIP(Q) L6470_init_chip(stepper##Q, Q##_MICROSTEPS, Q##_OVERCURRENT, Q##_STALLCURRENT, Q##_MAX_VOLTAGE, Q##_SLEW_RATE) - -void L64XX_Marlin::init_to_defaults() { - #if AXIS_IS_L64XX(X) - L6470_INIT_CHIP(X); - #endif - #if AXIS_IS_L64XX(X2) - L6470_INIT_CHIP(X2); - #endif - #if AXIS_IS_L64XX(Y) - L6470_INIT_CHIP(Y); - #endif - #if AXIS_IS_L64XX(Y2) - L6470_INIT_CHIP(Y2); - #endif - #if AXIS_IS_L64XX(Z) - L6470_INIT_CHIP(Z); - #endif - #if AXIS_IS_L64XX(Z2) - L6470_INIT_CHIP(Z2); - #endif - #if AXIS_IS_L64XX(Z3) - L6470_INIT_CHIP(Z3); - #endif - #if AXIS_IS_L64XX(Z4) - L6470_INIT_CHIP(Z4); - #endif - #if AXIS_IS_L64XX(I) - L6470_INIT_CHIP(I); - #endif - #if AXIS_IS_L64XX(J) - L6470_INIT_CHIP(J); - #endif - #if AXIS_IS_L64XX(K) - L6470_INIT_CHIP(K); - #endif - #if AXIS_IS_L64XX(U) - L6470_INIT_CHIP(U); - #endif - #if AXIS_IS_L64XX(V) - L6470_INIT_CHIP(V); - #endif - #if AXIS_IS_L64XX(W) - L6470_INIT_CHIP(W); - #endif - #if AXIS_IS_L64XX(E0) - L6470_INIT_CHIP(E0); - #endif - #if AXIS_IS_L64XX(E1) - L6470_INIT_CHIP(E1); - #endif - #if AXIS_IS_L64XX(E2) - L6470_INIT_CHIP(E2); - #endif - #if AXIS_IS_L64XX(E3) - L6470_INIT_CHIP(E3); - #endif - #if AXIS_IS_L64XX(E4) - L6470_INIT_CHIP(E4); - #endif - #if AXIS_IS_L64XX(E5) - L6470_INIT_CHIP(E5); - #endif - #if AXIS_IS_L64XX(E6) - L6470_INIT_CHIP(E6); - #endif - #if AXIS_IS_L64XX(E7) - L6470_INIT_CHIP(E7); - #endif -} - -#endif // HAS_L64XX diff --git a/Marlin/src/module/stepper/L64xx.h b/Marlin/src/module/stepper/L64xx.h deleted file mode 100644 index 870b0414f8eb..000000000000 --- a/Marlin/src/module/stepper/L64xx.h +++ /dev/null @@ -1,490 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 - -/** - * stepper/L64xx.h - * Stepper driver indirection for L64XX drivers - */ - -#include "../../inc/MarlinConfig.h" -#include "../../libs/L64XX/L64XX_Marlin.h" - -// Convert option names to L64XX classes -#define CLASS_L6470 L6470 -#define CLASS_L6474 L6474 -#define CLASS_POWERSTEP01 powerSTEP01 - -#define __L64XX_CLASS(TYPE) CLASS_##TYPE -#define _L64XX_CLASS(TYPE) __L64XX_CLASS(TYPE) -#define L64XX_CLASS(ST) _L64XX_CLASS(ST##_DRIVER_TYPE) - -#define L6474_DIR_WRITE(A,STATE) do{ L64xxManager.dir_commands[A] = dSPIN_L6474_ENABLE; WRITE(A##_DIR_PIN, STATE); }while(0) -#define L64XX_DIR_WRITE(A,STATE) do{ L64xxManager.dir_commands[A] = (STATE) ? dSPIN_STEP_CLOCK_REV : dSPIN_STEP_CLOCK_FWD; }while(0) - -// X Stepper -#if AXIS_IS_L64XX(X) - extern L64XX_CLASS(X) stepperX; - #define X_ENABLE_INIT() NOOP - #define X_ENABLE_WRITE(STATE) (STATE ? stepperX.hardStop() : stepperX.free()) - #define X_ENABLE_READ() (stepperX.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_X(L6474) - #define X_DIR_INIT() SET_OUTPUT(X_DIR_PIN) - #define X_DIR_WRITE(STATE) L6474_DIR_WRITE(X, STATE) - #define X_DIR_READ() READ(X_DIR_PIN) - #else - #define X_DIR_INIT() NOOP - #define X_DIR_WRITE(STATE) L64XX_DIR_WRITE(X, STATE) - #define X_DIR_READ() (stepper##X.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_X(L6470) - #define DISABLE_STEPPER_X() stepperX.free() - #endif - #endif -#endif - -// Y Stepper -#if AXIS_IS_L64XX(Y) - extern L64XX_CLASS(Y) stepperY; - #define Y_ENABLE_INIT() NOOP - #define Y_ENABLE_WRITE(STATE) (STATE ? stepperY.hardStop() : stepperY.free()) - #define Y_ENABLE_READ() (stepperY.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Y(L6474) - #define Y_DIR_INIT() SET_OUTPUT(Y_DIR_PIN) - #define Y_DIR_WRITE(STATE) L6474_DIR_WRITE(Y, STATE) - #define Y_DIR_READ() READ(Y_DIR_PIN) - #else - #define Y_DIR_INIT() NOOP - #define Y_DIR_WRITE(STATE) L64XX_DIR_WRITE(Y, STATE) - #define Y_DIR_READ() (stepper##Y.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_Y(L6470) - #define DISABLE_STEPPER_Y() stepperY.free() - #endif - #endif -#endif - -// Z Stepper -#if AXIS_IS_L64XX(Z) - extern L64XX_CLASS(Z) stepperZ; - #define Z_ENABLE_INIT() NOOP - #define Z_ENABLE_WRITE(STATE) (STATE ? stepperZ.hardStop() : stepperZ.free()) - #define Z_ENABLE_READ() (stepperZ.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Z(L6474) - #define Z_DIR_INIT() SET_OUTPUT(Z_DIR_PIN) - #define Z_DIR_WRITE(STATE) L6474_DIR_WRITE(Z, STATE) - #define Z_DIR_READ() READ(Z_DIR_PIN) - #else - #define Z_DIR_INIT() NOOP - #define Z_DIR_WRITE(STATE) L64XX_DIR_WRITE(Z, STATE) - #define Z_DIR_READ() (stepper##Z.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_Z(L6470) - #define DISABLE_STEPPER_Z() stepperZ.free() - #endif - #endif -#endif - -// X2 Stepper -#if HAS_X2_ENABLE && AXIS_IS_L64XX(X2) - extern L64XX_CLASS(X2) stepperX2; - #define X2_ENABLE_INIT() NOOP - #define X2_ENABLE_WRITE(STATE) (STATE ? stepperX2.hardStop() : stepperX2.free()) - #define X2_ENABLE_READ() (stepperX2.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_X2(L6474) - #define X2_DIR_INIT() SET_OUTPUT(X2_DIR_PIN) - #define X2_DIR_WRITE(STATE) L6474_DIR_WRITE(X2, STATE) - #define X2_DIR_READ() READ(X2_DIR_PIN) - #else - #define X2_DIR_INIT() NOOP - #define X2_DIR_WRITE(STATE) L64XX_DIR_WRITE(X2, STATE) - #define X2_DIR_READ() (stepper##X2.getStatus() & STATUS_DIR); - #endif -#endif - -#if AXIS_DRIVER_TYPE_X2(L6470) - #define DISABLE_STEPPER_X2() stepperX2.free() -#endif - -// Y2 Stepper -#if HAS_Y2_ENABLE && AXIS_IS_L64XX(Y2) - extern L64XX_CLASS(Y2) stepperY2; - #define Y2_ENABLE_INIT() NOOP - #define Y2_ENABLE_WRITE(STATE) (STATE ? stepperY2.hardStop() : stepperY2.free()) - #define Y2_ENABLE_READ() (stepperY2.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Y2(L6474) - #define Y2_DIR_INIT() SET_OUTPUT(Y2_DIR_PIN) - #define Y2_DIR_WRITE(STATE) L6474_DIR_WRITE(Y2, STATE) - #define Y2_DIR_READ() READ(Y2_DIR_PIN) - #else - #define Y2_DIR_INIT() NOOP - #define Y2_DIR_WRITE(STATE) L64XX_DIR_WRITE(Y2, STATE) - #define Y2_DIR_READ() (stepper##Y2.getStatus() & STATUS_DIR); - #endif -#endif - -#if AXIS_DRIVER_TYPE_Y2(L6470) - #define DISABLE_STEPPER_Y2() stepperY2.free() -#endif - -// Z2 Stepper -#if HAS_Z2_ENABLE && AXIS_IS_L64XX(Z2) - extern L64XX_CLASS(Z2) stepperZ2; - #define Z2_ENABLE_INIT() NOOP - #define Z2_ENABLE_WRITE(STATE) (STATE ? stepperZ2.hardStop() : stepperZ2.free()) - #define Z2_ENABLE_READ() (stepperZ2.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Z2(L6474) - #define Z2_DIR_INIT() SET_OUTPUT(Z2_DIR_PIN) - #define Z2_DIR_WRITE(STATE) L6474_DIR_WRITE(Z2, STATE) - #define Z2_DIR_READ() READ(Z2_DIR_PIN) - #else - #define Z2_DIR_INIT() NOOP - #define Z2_DIR_WRITE(STATE) L64XX_DIR_WRITE(Z2, STATE) - #define Z2_DIR_READ() (stepper##Z2.getStatus() & STATUS_DIR); - #endif -#endif - -#if AXIS_DRIVER_TYPE_Z2(L6470) - #define DISABLE_STEPPER_Z2() stepperZ2.free() -#endif - -// Z3 Stepper -#if HAS_Z3_ENABLE && AXIS_IS_L64XX(Z3) - extern L64XX_CLASS(Z3) stepperZ3; - #define Z3_ENABLE_INIT() NOOP - #define Z3_ENABLE_WRITE(STATE) (STATE ? stepperZ3.hardStop() : stepperZ3.free()) - #define Z3_ENABLE_READ() (stepperZ3.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Z3(L6474) - #define Z3_DIR_INIT() SET_OUTPUT(Z3_DIR_PIN) - #define Z3_DIR_WRITE(STATE) L6474_DIR_WRITE(Z3, STATE) - #define Z3_DIR_READ() READ(Z3_DIR_PIN) - #else - #define Z3_DIR_INIT() NOOP - #define Z3_DIR_WRITE(STATE) L64XX_DIR_WRITE(Z3, STATE) - #define Z3_DIR_READ() (stepper##Z3.getStatus() & STATUS_DIR); - #endif -#endif - -#if AXIS_DRIVER_TYPE_Z3(L6470) - #define DISABLE_STEPPER_Z3() stepperZ3.free() -#endif - -// Z4 Stepper -#if HAS_Z4_ENABLE && AXIS_IS_L64XX(Z4) - extern L64XX_CLASS(Z4) stepperZ4; - #define Z4_ENABLE_INIT() NOOP - #define Z4_ENABLE_WRITE(STATE) (STATE ? stepperZ4.hardStop() : stepperZ4.free()) - #define Z4_ENABLE_READ() (stepperZ4.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_Z4(L6474) - #define Z4_DIR_INIT() SET_OUTPUT(Z4_DIR_PIN) - #define Z4_DIR_WRITE(STATE) L6474_DIR_WRITE(Z4, STATE) - #define Z4_DIR_READ() READ(Z4_DIR_PIN) - #else - #define Z4_DIR_INIT() NOOP - #define Z4_DIR_WRITE(STATE) L64XX_DIR_WRITE(Z4, STATE) - #define Z4_DIR_READ() (stepper##Z4.getStatus() & STATUS_DIR); - #endif -#endif - -#if AXIS_DRIVER_TYPE_Z4(L6470) - #define DISABLE_STEPPER_Z4() stepperZ4.free() -#endif - -// I Stepper -#if AXIS_IS_L64XX(I) - extern L64XX_CLASS(I) stepperI; - #define I_ENABLE_INIT() NOOP - #define I_ENABLE_WRITE(STATE) (STATE ? stepperI.hardStop() : stepperI.free()) - #define I_ENABLE_READ() (stepperI.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_I(L6474) - #define I_DIR_INIT() SET_OUTPUT(I_DIR_PIN) - #define I_DIR_WRITE(STATE) L6474_DIR_WRITE(I, STATE) - #define I_DIR_READ() READ(I_DIR_PIN) - #else - #define I_DIR_INIT() NOOP - #define I_DIR_WRITE(STATE) L64XX_DIR_WRITE(I, STATE) - #define I_DIR_READ() (stepper##I.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_I(L6470) - #define DISABLE_STEPPER_I() stepperI.free() - #endif - #endif -#endif - -// J Stepper -#if AXIS_IS_L64XX(J) - extern L64XX_CLASS(J) stepperJ; - #define J_ENABLE_INIT() NOOP - #define J_ENABLE_WRITE(STATE) (STATE ? stepperJ.hardStop() : stepperJ.free()) - #define J_ENABLE_READ() (stepperJ.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_J(L6474) - #define J_DIR_INIT() SET_OUTPUT(J_DIR_PIN) - #define J_DIR_WRITE(STATE) L6474_DIR_WRITE(J, STATE) - #define J_DIR_READ() READ(J_DIR_PIN) - #else - #define J_DIR_INIT() NOOP - #define J_DIR_WRITE(STATE) L64XX_DIR_WRITE(J, STATE) - #define J_DIR_READ() (stepper##J.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_J(L6470) - #define DISABLE_STEPPER_J() stepperJ.free() - #endif - #endif -#endif - -// K Stepper -#if AXIS_IS_L64XX(K) - extern L64XX_CLASS(K) stepperK; - #define K_ENABLE_INIT() NOOP - #define K_ENABLE_WRITE(STATE) (STATE ? stepperK.hardStop() : stepperK.free()) - #define K_ENABLE_READ() (stepperK.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_K(L6474) - #define K_DIR_INIT() SET_OUTPUT(K_DIR_PIN) - #define K_DIR_WRITE(STATE) L6474_DIR_WRITE(K, STATE) - #define K_DIR_READ() READ(K_DIR_PIN) - #else - #define K_DIR_INIT() NOOP - #define K_DIR_WRITE(STATE) L64XX_DIR_WRITE(K, STATE) - #define K_DIR_READ() (stepper##K.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_K(L6470) - #define DISABLE_STEPPER_K() stepperK.free() - #endif - #endif -#endif - -// U Stepper -#if HAS_U_AXIS - #if AXIS_IS_L64XX(U) - extern L64XX_CLASS(U) stepperU; - #define U_ENABLE_INIT() NOOP - #define U_ENABLE_WRITE(STATE) (STATE ? stepperU.hardStop() : stepperU.free()) - #define U_ENABLE_READ() (stepperU.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_U(L6474) - #define U_DIR_INIT() SET_OUTPUT(U_DIR_PIN) - #define U_DIR_WRITE(STATE) L6474_DIR_WRITE(U, STATE) - #define U_DIR_READ() READ(U_DIR_PIN) - #else - #define U_DIR_INIT() NOOP - #define U_DIR_WRITE(STATE) L64XX_DIR_WRITE(U, STATE) - #define U_DIR_READ() (stepper##U.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_U(L6470) - #define DISABLE_STEPPER_U() stepperU.free() - #endif - #endif - #endif -#endif - -// V Stepper -#if HAS_V_AXIS - #if AXIS_IS_L64XX(V) - extern L64XX_CLASS(V) stepperV; - #define V_ENABLE_INIT() NOOP - #define V_ENABLE_WRITE(STATE) (STATE ? stepperV.hardStop() : stepperV.free()) - #define V_ENABLE_READ() (stepperV.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_V(L6474) - #define V_DIR_INIT() SET_OUTPUT(V_DIR_PIN) - #define V_DIR_WRITE(STATE) L6474_DIR_WRITE(V, STATE) - #define V_DIR_READ() READ(V_DIR_PIN) - #else - #define V_DIR_INIT() NOOP - #define V_DIR_WRITE(STATE) L64XX_DIR_WRITE(V, STATE) - #define V_DIR_READ() (stepper##V.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_V(L6470) - #define DISABLE_STEPPER_V() stepperV.free() - #endif - #endif - #endif -#endif - -// W Stepper -#if HAS_W_AXIS - #if AXIS_IS_L64XX(W) - extern L64XX_CLASS(w) stepperW; - #define W_ENABLE_INIT() NOOP - #define W_ENABLE_WRITE(STATE) (STATE ? stepperW.hardStop() : stepperW.free()) - #define W_ENABLE_READ() (stepperW.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_W(L6474) - #define W_DIR_INIT() SET_OUTPUT(W_DIR_PIN) - #define W_DIR_WRITE(STATE) L6474_DIR_WRITE(W, STATE) - #define W_DIR_READ() READ(W_DIR_PIN) - #else - #define W_DIR_INIT() NOOP - #define W_DIR_WRITE(STATE) L64XX_DIR_WRITE(W, STATE) - #define W_DIR_READ() (stepper##W.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_W(L6470) - #define DISABLE_STEPPER_W() stepperW.free() - #endif - #endif - #endif -#endif - -// E0 Stepper -#if AXIS_IS_L64XX(E0) - extern L64XX_CLASS(E0) stepperE0; - #define E0_ENABLE_INIT() NOOP - #define E0_ENABLE_WRITE(STATE) (STATE ? stepperE0.hardStop() : stepperE0.free()) - #define E0_ENABLE_READ() (stepperE0.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E0(L6474) - #define E0_DIR_INIT() SET_OUTPUT(E0_DIR_PIN) - #define E0_DIR_WRITE(STATE) L6474_DIR_WRITE(E0, STATE) - #define E0_DIR_READ() READ(E0_DIR_PIN) - #else - #define E0_DIR_INIT() NOOP - #define E0_DIR_WRITE(STATE) L64XX_DIR_WRITE(E0, STATE) - #define E0_DIR_READ() (stepper##E0.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E0(L6470) - #define DISABLE_STEPPER_E0() do{ stepperE0.free(); }while(0) - #endif - #endif -#endif - -// E1 Stepper -#if AXIS_IS_L64XX(E1) - extern L64XX_CLASS(E1) stepperE1; - #define E1_ENABLE_INIT() NOOP - #define E1_ENABLE_WRITE(STATE) (STATE ? stepperE1.hardStop() : stepperE1.free()) - #define E1_ENABLE_READ() (stepperE1.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E1(L6474) - #define E1_DIR_INIT() SET_OUTPUT(E1_DIR_PIN) - #define E1_DIR_WRITE(STATE) L6474_DIR_WRITE(E1, STATE) - #define E1_DIR_READ() READ(E1_DIR_PIN) - #else - #define E1_DIR_INIT() NOOP - #define E1_DIR_WRITE(STATE) L64XX_DIR_WRITE(E1, STATE) - #define E1_DIR_READ() (stepper##E1.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E1(L6470) - #define DISABLE_STEPPER_E1() do{ stepperE1.free(); }while(0) - #endif - #endif -#endif - -// E2 Stepper -#if AXIS_IS_L64XX(E2) - extern L64XX_CLASS(E2) stepperE2; - #define E2_ENABLE_INIT() NOOP - #define E2_ENABLE_WRITE(STATE) (STATE ? stepperE2.hardStop() : stepperE2.free()) - #define E2_ENABLE_READ() (stepperE2.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E2(L6474) - #define E2_DIR_INIT() SET_OUTPUT(E2_DIR_PIN) - #define E2_DIR_WRITE(STATE) L6474_DIR_WRITE(E2, STATE) - #define E2_DIR_READ() READ(E2_DIR_PIN) - #else - #define E2_DIR_INIT() NOOP - #define E2_DIR_WRITE(STATE) L64XX_DIR_WRITE(E2, STATE) - #define E2_DIR_READ() (stepper##E2.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E2(L6470) - #define DISABLE_STEPPER_E2() do{ stepperE2.free(); }while(0) - #endif - #endif -#endif - -// E3 Stepper -#if AXIS_IS_L64XX(E3) - extern L64XX_CLASS(E3) stepperE3; - #define E3_ENABLE_INIT() NOOP - #define E3_ENABLE_WRITE(STATE) (STATE ? stepperE3.hardStop() : stepperE3.free()) - #define E3_ENABLE_READ() (stepperE3.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E3(L6474) - #define E3_DIR_INIT() SET_OUTPUT(E3_DIR_PIN) - #define E3_DIR_WRITE(STATE) L6474_DIR_WRITE(E3, STATE) - #define E3_DIR_READ() READ(E3_DIR_PIN) - #else - #define E3_DIR_INIT() NOOP - #define E3_DIR_WRITE(STATE) L64XX_DIR_WRITE(E3, STATE) - #define E3_DIR_READ() (stepper##E3.getStatus() & STATUS_DIR); - #endif -#endif - -// E4 Stepper -#if AXIS_IS_L64XX(E4) - extern L64XX_CLASS(E4) stepperE4; - #define E4_ENABLE_INIT() NOOP - #define E4_ENABLE_WRITE(STATE) (STATE ? stepperE4.hardStop() : stepperE4.free()) - #define E4_ENABLE_READ() (stepperE4.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E4(L6474) - #define E4_DIR_INIT() SET_OUTPUT(E4_DIR_PIN) - #define E4_DIR_WRITE(STATE) L6474_DIR_WRITE(E4, STATE) - #define E4_DIR_READ() READ(E4_DIR_PIN) - #else - #define E4_DIR_INIT() NOOP - #define E4_DIR_WRITE(STATE) L64XX_DIR_WRITE(E4, STATE) - #define E4_DIR_READ() (stepper##E4.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E4(L6470) - #define DISABLE_STEPPER_E4() do{ stepperE4.free(); }while(0) - #endif - #endif -#endif - -// E5 Stepper -#if AXIS_IS_L64XX(E5) - extern L64XX_CLASS(E5) stepperE5; - #define E5_ENABLE_INIT() NOOP - #define E5_ENABLE_WRITE(STATE) (STATE ? stepperE5.hardStop() : stepperE5.free()) - #define E5_ENABLE_READ() (stepperE5.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E5(L6474) - #define E5_DIR_INIT() SET_OUTPUT(E5_DIR_PIN) - #define E5_DIR_WRITE(STATE) L6474_DIR_WRITE(E5, STATE) - #define E5_DIR_READ() READ(E5_DIR_PIN) - #else - #define E5_DIR_INIT() NOOP - #define E5_DIR_WRITE(STATE) L64XX_DIR_WRITE(E5, STATE) - #define E5_DIR_READ() (stepper##E5.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E5(L6470) - #define DISABLE_STEPPER_E5() do{ stepperE5.free(); }while(0) - #endif - #endif -#endif - -// E6 Stepper -#if AXIS_IS_L64XX(E6) - extern L64XX_CLASS(E6) stepperE6; - #define E6_ENABLE_INIT() NOOP - #define E6_ENABLE_WRITE(STATE) (STATE ? stepperE6.hardStop() : stepperE6.free()) - #define E6_ENABLE_READ() (stepperE6.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E6(L6474) - #define E6_DIR_INIT() SET_OUTPUT(E6_DIR_PIN) - #define E6_DIR_WRITE(STATE) L6474_DIR_WRITE(E6, STATE) - #define E6_DIR_READ() READ(E6_DIR_PIN) - #else - #define E6_DIR_INIT() NOOP - #define E6_DIR_WRITE(STATE) L64XX_DIR_WRITE(E6, STATE) - #define E6_DIR_READ() (stepper##E6.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E6(L6470) - #define DISABLE_STEPPER_E6() do{ stepperE6.free(); }while(0) - #endif - #endif -#endif - -// E7 Stepper -#if AXIS_IS_L64XX(E7) - extern L64XX_CLASS(E7) stepperE7; - #define E7_ENABLE_INIT() NOOP - #define E7_ENABLE_WRITE(STATE) (STATE ? stepperE7.hardStop() : stepperE7.free()) - #define E7_ENABLE_READ() (stepperE7.getStatus() & STATUS_HIZ) - #if AXIS_DRIVER_TYPE_E7(L6474) - #define E7_DIR_INIT() SET_OUTPUT(E7_DIR_PIN) - #define E7_DIR_WRITE(STATE) L6474_DIR_WRITE(E7, STATE) - #define E7_DIR_READ() READ(E7_DIR_PIN) - #else - #define E7_DIR_INIT() NOOP - #define E7_DIR_WRITE(STATE) L64XX_DIR_WRITE(E7, STATE) - #define E7_DIR_READ() (stepper##E7.getStatus() & STATUS_DIR); - #if AXIS_DRIVER_TYPE_E7(L6470) - #define DISABLE_STEPPER_E7() do{ stepperE7.free(); }while(0) - #endif - #endif -#endif 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/indirection.cpp b/Marlin/src/module/stepper/indirection.cpp index e44496d0224c..427fd71cbe7d 100644 --- a/Marlin/src/module/stepper/indirection.cpp +++ b/Marlin/src/module/stepper/indirection.cpp @@ -38,7 +38,6 @@ void restore_stepper_drivers() { void reset_stepper_drivers() { TERN_(HAS_TMC26X, tmc26x_init_to_defaults()); - TERN_(HAS_L64XX, L64xxManager.init_to_defaults()); TERN_(HAS_TRINAMIC_CONFIG, reset_trinamic_drivers()); } diff --git a/Marlin/src/module/stepper/indirection.h b/Marlin/src/module/stepper/indirection.h index 687a0f289628..e9a9aa7de90c 100644 --- a/Marlin/src/module/stepper/indirection.h +++ b/Marlin/src/module/stepper/indirection.h @@ -32,10 +32,6 @@ #include "../../inc/MarlinConfig.h" -#if HAS_L64XX - #include "L64xx.h" -#endif - #if HAS_TMC26X #include "TMC26X.h" #endif @@ -985,7 +981,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #if HAS_Z_AXIS #define ENABLE_AXIS_Z() if (SHOULD_ENABLE(z)) { ENABLE_STEPPER_Z(); ENABLE_STEPPER_Z2(); ENABLE_STEPPER_Z3(); ENABLE_STEPPER_Z4(); AFTER_CHANGE(z, true); } - #define DISABLE_AXIS_Z() if (SHOULD_DISABLE(z)) { DISABLE_STEPPER_Z(); DISABLE_STEPPER_Z2(); DISABLE_STEPPER_Z3(); DISABLE_STEPPER_Z4(); AFTER_CHANGE(z, false); set_axis_untrusted(Z_AXIS); Z_RESET(); } + #define DISABLE_AXIS_Z() if (SHOULD_DISABLE(z)) { DISABLE_STEPPER_Z(); DISABLE_STEPPER_Z2(); DISABLE_STEPPER_Z3(); DISABLE_STEPPER_Z4(); AFTER_CHANGE(z, false); set_axis_untrusted(Z_AXIS); Z_RESET(); TERN_(BD_SENSOR, bdl.config_state = 0); } #else #define ENABLE_AXIS_Z() NOOP #define DISABLE_AXIS_Z() NOOP diff --git a/Marlin/src/module/stepper/trinamic.cpp b/Marlin/src/module/stepper/trinamic.cpp index 76373515569e..48ce020d3dca 100644 --- a/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin/src/module/stepper/trinamic.cpp @@ -1023,17 +1023,13 @@ 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. struct SanityHwSerialDetails { const char port[20]; uint32_t address; }; #define TMC_HW_DETAIL_ARGS(A) TERN(A##_HAS_HW_SERIAL, STRINGIFY(A##_HARDWARE_SERIAL), ""), TERN0(A##_HAS_HW_SERIAL, A##_SLAVE_ADDRESS) - #define TMC_HW_DETAIL(A) { TMC_HW_DETAIL_ARGS(A) }, - constexpr SanityHwSerialDetails sanity_tmc_hw_details[] = { - MAP(TMC_HW_DETAIL, ALL_AXIS_NAMES) - }; + #define TMC_HW_DETAIL(A) { TMC_HW_DETAIL_ARGS(A) } + constexpr SanityHwSerialDetails sanity_tmc_hw_details[] = { MAPLIST(TMC_HW_DETAIL, ALL_AXIS_NAMES) }; // constexpr compatible string comparison constexpr bool str_eq_ce(const char * a, const char * b) { @@ -1057,10 +1053,8 @@ void reset_trinamic_drivers() { #if ANY_AXIS_HAS(SW_SERIAL) struct SanitySwSerialDetails { int32_t txpin; int32_t rxpin; uint32_t address; }; #define TMC_SW_DETAIL_ARGS(A) TERN(A##_HAS_SW_SERIAL, A##_SERIAL_TX_PIN, -1), TERN(A##_HAS_SW_SERIAL, A##_SERIAL_RX_PIN, -1), TERN0(A##_HAS_SW_SERIAL, A##_SLAVE_ADDRESS) - #define TMC_SW_DETAIL(A) TMC_SW_DETAIL_ARGS(A), - constexpr SanitySwSerialDetails sanity_tmc_sw_details[] = { - MAP(TMC_SW_DETAIL, ALL_AXIS_NAMES) - }; + #define TMC_SW_DETAIL(A) { TMC_SW_DETAIL_ARGS(A) } + constexpr SanitySwSerialDetails sanity_tmc_sw_details[] = { MAPLIST(TMC_SW_DETAIL, ALL_AXIS_NAMES) }; constexpr bool sc_sw_done(size_t start, size_t end) { return start == end; } constexpr bool sc_sw_skip(int32_t txpin) { return txpin < 0; } diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 17ab08d4c20e..b3c5934b43ea 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 HAS_TEMP_SENSOR - #include "../gcode/gcode.h" -#endif - #if ENABLED(NOZZLE_PARK_FEATURE) #include "../libs/nozzle.h" #endif @@ -77,7 +74,7 @@ // MAX TC related macros #define TEMP_SENSOR_IS_MAX(n, M) (ENABLED(TEMP_SENSOR_##n##_IS_MAX##M) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_MAX##M) && REDUNDANT_TEMP_MATCH(SOURCE, E##n))) -#define TEMP_SENSOR_IS_ANY_MAX_TC(n) (ENABLED(TEMP_SENSOR_##n##_IS_MAX_TC) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_MAX_TC) && REDUNDANT_TEMP_MATCH(SOURCE, E##n))) +#define TEMP_SENSOR_IS_ANY_MAX_TC(n) (TEMP_SENSOR_IS_MAX_TC(n) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E##n))) // LIB_MAX6675 can be added to the build_flags in platformio.ini to use a user-defined library // If LIB_MAX6675 is not on the build_flags then raw SPI reads will be used. @@ -116,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 @@ -133,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 @@ -259,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 @@ -268,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); @@ -281,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 @@ -300,28 +317,71 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if HAS_HOTEND hotend_info_t Temperature::temp_hotend[HOTENDS]; - #define _HMT(N) HEATER_##N##_MAXTEMP, - const celsius_t Temperature::hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP); -#endif + constexpr celsius_t Temperature::hotend_maxtemp[HOTENDS]; + + // Sanity-check max readable temperatures + #define CHECK_MAXTEMP_(N,M,S) static_assert( \ + S >= 998 || M <= _MAX(TT_NAME(S)[0].celsius, TT_NAME(S)[COUNT(TT_NAME(S)) - 1].celsius) - HOTEND_OVERSHOOT, \ + "HEATER_" STRINGIFY(N) "_MAXTEMP (" STRINGIFY(M) ") is too high for thermistor_" STRINGIFY(S) ".h with HOTEND_OVERSHOOT=" STRINGIFY(HOTEND_OVERSHOOT) "."); + #define CHECK_MAXTEMP(N) TERN(TEMP_SENSOR_##N##_IS_THERMISTOR, CHECK_MAXTEMP_, CODE_0)(N, HEATER_##N##_MAXTEMP, TEMP_SENSOR_##N) + REPEAT(HOTENDS, CHECK_MAXTEMP) + + #if HAS_PREHEAT + #define CHECK_PREHEAT__(N,P,T,M) static_assert(T <= M - HOTEND_OVERSHOOT, "PREHEAT_" STRINGIFY(P) "_TEMP_HOTEND (" STRINGIFY(T) ") must be less than HEATER_" STRINGIFY(N) "_MAXTEMP (" STRINGIFY(M) ") - " STRINGIFY(HOTEND_OVERSHOOT) "."); + #define CHECK_PREHEAT_(N,P) CHECK_PREHEAT__(N, P, PREHEAT_##P##_TEMP_HOTEND, HEATER_##N##_MAXTEMP) + #define CHECK_PREHEAT(P) REPEAT2(HOTENDS, CHECK_PREHEAT_, P) + #if PREHEAT_COUNT >= 1 + CHECK_PREHEAT(1) + #endif + #if PREHEAT_COUNT >= 2 + CHECK_PREHEAT(2) + #endif + #if PREHEAT_COUNT >= 3 + CHECK_PREHEAT(3) + #endif + #if PREHEAT_COUNT >= 4 + CHECK_PREHEAT(4) + #endif + #if PREHEAT_COUNT >= 5 + CHECK_PREHEAT(5) + #endif + #if PREHEAT_COUNT >= 6 + CHECK_PREHEAT(6) + #endif + #if PREHEAT_COUNT >= 7 + CHECK_PREHEAT(7) + #endif + #if PREHEAT_COUNT >= 8 + CHECK_PREHEAT(8) + #endif + #if PREHEAT_COUNT >= 9 + CHECK_PREHEAT(9) + #endif + #if PREHEAT_COUNT >= 10 + CHECK_PREHEAT(10) + #endif + #endif // HAS_PREHEAT + +#endif // HAS_HOTEND #if HAS_TEMP_REDUNDANT redundant_info_t Temperature::temp_redundant; #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 @@ -345,11 +405,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: @@ -376,7 +436,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) @@ -448,8 +508,12 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); // Init min and max temp with extreme values to prevent false errors during startup raw_adc_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP, Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP; - TERN_(WATCH_BED, bed_watch_t Temperature::watch_bed); // = { 0 } - IF_DISABLED(PIDTEMPBED, millis_t Temperature::next_bed_check_ms); + #if WATCH_BED + bed_watch_t Temperature::watch_bed; // = { 0 } + #endif + #if DISABLED(PIDTEMPBED) + millis_t Temperature::next_bed_check_ms; + #endif #endif #if HAS_TEMP_CHAMBER @@ -459,8 +523,12 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); celsius_float_t old_temp = 9999; raw_adc_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP, Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP; - TERN_(WATCH_CHAMBER, chamber_watch_t Temperature::watch_chamber{0}); - IF_DISABLED(PIDTEMPCHAMBER, millis_t Temperature::next_chamber_check_ms); + #if WATCH_CHAMBER + chamber_watch_t Temperature::watch_chamber; // = { 0 } + #endif + #if DISABLED(PIDTEMPCHAMBER) + millis_t Temperature::next_chamber_check_ms; + #endif #endif #endif @@ -517,10 +585,6 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); volatile bool Temperature::raw_temps_ready = false; -#if ENABLED(PID_EXTRUSION_SCALING) - int32_t Temperature::pes_e_position, Temperature::lpq[LPQ_MAX_LEN]; - lpq_ptr_t Temperature::lpq_ptr = 0; -#endif #if ENABLED(MPCTEMP) int32_t Temperature::mpc_e_position; // = 0 @@ -544,6 +608,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 @@ -597,7 +662,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), @@ -643,7 +708,7 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(HAS_FAN_LOGIC, fan_update_ms = next_temp_ms + fan_update_interval_ms); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_STARTED)); - TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(isbed ? PIDTEMPBED_START : PIDTEMP_START)); if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - (HOTEND_OVERSHOOT))) { SERIAL_ECHOPGM(STR_PID_AUTOTUNE); @@ -716,16 +781,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 +860,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 @@ -904,7 +966,7 @@ volatile bool Temperature::raw_temps_ready = false; temp_hotend[active_extruder].target = 0.0f; temp_hotend[active_extruder].soft_pwm_amount = 0; #if HAS_FAN - set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0); + set_fan_speed(EITHER(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0); planner.sync_fan_speeds(fan_speed); #endif @@ -918,13 +980,13 @@ volatile bool Temperature::raw_temps_ready = false; MPC_t &constants = hotend.constants; // Move to center of bed, just above bed height and cool with max fan + gcode.home_all_axes(true); disable_all_heaters(); #if HAS_FAN zero_fan_speeds(); - set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255); + set_fan_speed(EITHER(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255); planner.sync_fan_speeds(fan_speed); #endif - gcode.home_all_axes(true); const xyz_pos_t tuningpos = MPC_TUNING_POS; do_blocking_move_to(tuningpos); @@ -949,7 +1011,7 @@ volatile bool Temperature::raw_temps_ready = false; } #if HAS_FAN - set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0); + set_fan_speed(EITHER(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0); planner.sync_fan_speeds(fan_speed); #endif @@ -1031,7 +1093,7 @@ volatile bool Temperature::raw_temps_ready = false; total_energy_fan0 += constants.heater_power * hotend.soft_pwm_amount / 127 * MPC_dT + (last_temp - current_temp) * constants.block_heat_capacity; #if HAS_FAN else if (ELAPSED(ms, test_end_ms) && !fan0_done) { - set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255); + set_fan_speed(EITHER(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 255); planner.sync_fan_speeds(fan_speed); settle_end_ms = ms + settle_time; test_end_ms = settle_end_ms + test_duration; @@ -1104,44 +1166,55 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { } } -#define _EFANOVERLAP(A,B) _FANOVERLAP(E##A,B) - #if HAS_AUTO_FAN + #define _EFANOVERLAP(I,N) ((I != N) && _FANOVERLAP(I,E##N)) + #if EXTRUDER_AUTO_FAN_SPEED != 255 - #define INIT_E_AUTO_FAN_PIN(P) do{ if (P == FAN1_PIN || P == FAN2_PIN) { SET_PWM(P); SET_FAST_PWM_FREQ(P); } else SET_OUTPUT(P); }while(0) + #define INIT_E_AUTO_FAN_PIN(P) do{ if (PWM_PIN(P)) { SET_PWM(P); SET_FAST_PWM_FREQ(P); } else SET_OUTPUT(P); }while(0) #else #define INIT_E_AUTO_FAN_PIN(P) SET_OUTPUT(P) #endif #if CHAMBER_AUTO_FAN_SPEED != 255 - #define INIT_CHAMBER_AUTO_FAN_PIN(P) do{ if (P == FAN1_PIN || P == FAN2_PIN) { SET_PWM(P); SET_FAST_PWM_FREQ(P); } else SET_OUTPUT(P); }while(0) + #define INIT_CHAMBER_AUTO_FAN_PIN(P) do{ if (PWM_PIN(P)) { SET_PWM(P); SET_FAST_PWM_FREQ(P); } else SET_OUTPUT(P); }while(0) #else #define INIT_CHAMBER_AUTO_FAN_PIN(P) SET_OUTPUT(P) #endif + #if COOLER_AUTO_FAN_SPEED != 255 + #define INIT_COOLER_AUTO_FAN_PIN(P) do{ if (PWM_PIN(P)) { SET_PWM(P); SET_FAST_PWM_FREQ(P); } else SET_OUTPUT(P); }while(0) + #else + #define INIT_COOLER_AUTO_FAN_PIN(P) SET_OUTPUT(P) + #endif #ifndef CHAMBER_FAN_INDEX #define CHAMBER_FAN_INDEX HOTENDS #endif void Temperature::update_autofans() { - #define _EFAN(B,A) _EFANOVERLAP(A,B) ? B : + #define _EFAN(I,N) _EFANOVERLAP(I,N) ? I : static const uint8_t fanBit[] PROGMEM = { 0 #if HAS_MULTI_HOTEND #define _NEXT_FAN(N) , REPEAT2(N,_EFAN,N) N RREPEAT_S(1, HOTENDS, _NEXT_FAN) #endif + #define _NFAN HOTENDS #if HAS_AUTO_CHAMBER_FAN - #define _CFAN(B) _FANOVERLAP(CHAMBER,B) ? B : - , REPEAT(HOTENDS,_CFAN) (HOTENDS) + #define _CHFAN(I) _FANOVERLAP(I,CHAMBER) ? I : + , (REPEAT(HOTENDS,_CHFAN) (_NFAN)) + #undef _NFAN + #define _NFAN INCREMENT(HOTENDS) + #endif + #if HAS_AUTO_COOLER_FAN + #define _COFAN(I) _FANOVERLAP(I,COOLER) ? I : + , (REPEAT(HOTENDS,_COFAN) (_NFAN)) #endif }; uint8_t fanState = 0; HOTEND_LOOP() { - if (temp_hotend[e].celsius >= EXTRUDER_AUTO_FAN_TEMPERATURE) { + if (temp_hotend[e].celsius >= EXTRUDER_AUTO_FAN_TEMPERATURE) SBI(fanState, pgm_read_byte(&fanBit[e])); - } } #if HAS_AUTO_CHAMBER_FAN @@ -1172,6 +1245,11 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { chamberfan_speed = fan_on ? CHAMBER_AUTO_FAN_SPEED : 0; break; #endif + #if ENABLED(AUTO_POWER_COOLER_FAN) + case COOLER_FAN_INDEX: + coolerfan_speed = fan_on ? COOLER_AUTO_FAN_SPEED : 0; + break; + #endif default: #if EITHER(AUTO_POWER_E_FANS, HAS_FANCHECK) autofan_speed[realFan] = fan_on ? EXTRUDER_AUTO_FAN_SPEED : 0; @@ -1184,36 +1262,18 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { #else #define _AUTOFAN_SPEED() EXTRUDER_AUTO_FAN_SPEED #endif - #define _AUTOFAN_CASE(N) case N: _UPDATE_AUTO_FAN(E##N, fan_on, _AUTOFAN_SPEED()); break + #define _AUTOFAN_CASE(N) case N: _UPDATE_AUTO_FAN(E##N, fan_on, _AUTOFAN_SPEED()); break; + #define _AUTOFAN_NOT(N) + #define AUTOFAN_CASE(N) TERN(HAS_AUTO_FAN_##N, _AUTOFAN_CASE, _AUTOFAN_NOT)(N) switch (f) { - #if HAS_AUTO_FAN_0 - _AUTOFAN_CASE(0); - #endif - #if HAS_AUTO_FAN_1 - _AUTOFAN_CASE(1); - #endif - #if HAS_AUTO_FAN_2 - _AUTOFAN_CASE(2); - #endif - #if HAS_AUTO_FAN_3 - _AUTOFAN_CASE(3); - #endif - #if HAS_AUTO_FAN_4 - _AUTOFAN_CASE(4); - #endif - #if HAS_AUTO_FAN_5 - _AUTOFAN_CASE(5); - #endif - #if HAS_AUTO_FAN_6 - _AUTOFAN_CASE(6); - #endif - #if HAS_AUTO_FAN_7 - _AUTOFAN_CASE(7); - #endif + REPEAT(8, AUTOFAN_CASE) #if HAS_AUTO_CHAMBER_FAN && !AUTO_CHAMBER_IS_E case CHAMBER_FAN_INDEX: _UPDATE_AUTO_FAN(CHAMBER, fan_on, CHAMBER_AUTO_FAN_SPEED); break; #endif + #if HAS_AUTO_COOLER_FAN && !AUTO_COOLER_IS_E + case COOLER_FAN_INDEX: _UPDATE_AUTO_FAN(COOLER, fan_on, COOLER_AUTO_FAN_SPEED); break; + #endif } SBI(fanDone, realFan); } @@ -1303,125 +1363,107 @@ void Temperature::_temp_error(const heater_id_t heater_id, FSTR_P const serial_m #endif } -void Temperature::max_temp_error(const heater_id_t heater_id) { +void Temperature::maxtemp_error(const heater_id_t heater_id) { #if HAS_DWIN_E3V2_BASIC && (HAS_HOTEND || HAS_HEATED_BED) DWIN_Popup_Temperature(1); #endif _temp_error(heater_id, F(STR_T_MAXTEMP), GET_TEXT_F(MSG_ERR_MAXTEMP)); } -void Temperature::min_temp_error(const heater_id_t heater_id) { +void Temperature::mintemp_error(const heater_id_t heater_id) { #if HAS_DWIN_E3V2_BASIC && (HAS_HOTEND || HAS_HEATED_BED) DWIN_Popup_Temperature(0); #endif _temp_error(heater_id, F(STR_T_MINTEMP), GET_TEXT_F(MSG_ERR_MINTEMP)); } -#if ANY(PID_DEBUG, PID_BED_DEBUG, PID_CHAMBER_DEBUG) - bool Temperature::pid_debug_flag; // = 0 +#if HAS_PID_DEBUG + bool Temperature::pid_debug_flag; // = false #endif +#if HAS_PID_HEATING + + template + class PIDRunner { + public: + TT &tempinfo; + + PIDRunner(TT &t) : tempinfo(t) { } + + float get_pid_output(const uint8_t extr=0) { + #if ENABLED(PID_OPENLOOP) + + return constrain(tempinfo.target, 0, MAX_POW); + + #else // !PID_OPENLOOP + + float out = tempinfo.pid.get_pid_output(tempinfo.target, tempinfo.celsius); + + #if ENABLED(PID_FAN_SCALING) + out += tempinfo.pid.get_fan_scale_output(thermalManager.fan_speed[extr]); + #endif + + #if ENABLED(PID_EXTRUSION_SCALING) + out += tempinfo.pid.get_extrusion_scale_output( + extr == active_extruder, stepper.position(E_AXIS), planner.mm_per_step[E_AXIS], thermalManager.lpq_len + ); + #endif + + return constrain(out, tempinfo.pid.low(), tempinfo.pid.high()); + + #endif // !PID_OPENLOOP + } + + 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_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 ", tempinfo.pid.pTerm(), " iTerm ", tempinfo.pid.iTerm(), " dTerm ", tempinfo.pid.dTerm() + , " cTerm ", tempinfo.pid.cTerm(), " fTerm ", tempinfo.pid.fTerm() + #endif + ); + } + } + }; + +#endif // HAS_PID_HEATING + #if HAS_HOTEND float Temperature::get_pid_output_hotend(const uint8_t E_NAME) { const uint8_t ee = HOTEND_INDEX; - #if ENABLED(PIDTEMP) - #if DISABLED(PID_OPENLOOP) - static hotend_pid_t work_pid[HOTENDS]; - static float temp_iState[HOTENDS] = { 0 }, - temp_dState[HOTENDS] = { 0 }; - static Flags pid_reset; - const float pid_error = temp_hotend[ee].target - temp_hotend[ee].celsius; - - float pid_output; - - if (temp_hotend[ee].target == 0 - || pid_error < -(PID_FUNCTIONAL_RANGE) - || TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out) - ) { - pid_output = 0; - pid_reset.set(ee); - } - else if (pid_error > PID_FUNCTIONAL_RANGE) { - pid_output = PID_MAX; - pid_reset.set(ee); - } - else { - if (pid_reset[ee]) { - temp_iState[ee] = 0.0; - work_pid[ee].Kd = 0.0; - pid_reset.clear(ee); - } - - work_pid[ee].Kd = work_pid[ee].Kd + PID_K2 * (PID_PARAM(Kd, ee) * (temp_dState[ee] - temp_hotend[ee].celsius) - work_pid[ee].Kd); - const float max_power_over_i_gain = float(PID_MAX) / PID_PARAM(Ki, ee) - float(MIN_POWER); - temp_iState[ee] = constrain(temp_iState[ee] + pid_error, 0, max_power_over_i_gain); - work_pid[ee].Kp = PID_PARAM(Kp, ee) * pid_error; - work_pid[ee].Ki = PID_PARAM(Ki, ee) * temp_iState[ee]; - pid_output = work_pid[ee].Kp + work_pid[ee].Ki + work_pid[ee].Kd + float(MIN_POWER); + const bool is_idling = TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out); - #if ENABLED(PID_EXTRUSION_SCALING) - #if HOTENDS == 1 - constexpr bool this_hotend = true; - #else - const bool this_hotend = (ee == active_extruder); - #endif - work_pid[ee].Kc = 0; - if (this_hotend) { - const long e_position = stepper.position(E_AXIS); - if (e_position > pes_e_position) { - lpq[lpq_ptr] = e_position - pes_e_position; - pes_e_position = e_position; - } - else - lpq[lpq_ptr] = 0; - - if (++lpq_ptr >= lpq_len) lpq_ptr = 0; - work_pid[ee].Kc = (lpq[lpq_ptr] * planner.mm_per_step[E_AXIS]) * PID_PARAM(Kc, ee); - pid_output += work_pid[ee].Kc; - } - #endif // PID_EXTRUSION_SCALING - #if ENABLED(PID_FAN_SCALING) - if (fan_speed[active_extruder] > PID_FAN_SCALING_MIN_SPEED) { - work_pid[ee].Kf = PID_PARAM(Kf, ee) + (PID_FAN_SCALING_LIN_FACTOR) * fan_speed[active_extruder]; - pid_output += work_pid[ee].Kf; - } - //pid_output -= work_pid[ee].Ki; - //pid_output += work_pid[ee].Ki * work_pid[ee].Kf - #endif // PID_FAN_SCALING - LIMIT(pid_output, 0, PID_MAX); - } - temp_dState[ee] = temp_hotend[ee].celsius; + #if ENABLED(PIDTEMP) - #else // PID_OPENLOOP + typedef PIDRunner PIDRunnerHotend; - const float pid_output = constrain(temp_hotend[ee].target, 0, PID_MAX); + static PIDRunnerHotend hotend_pid[HOTENDS] = { + #define _HOTENDPID(E) temp_hotend[E], + REPEAT(HOTENDS, _HOTENDPID) + }; - #endif // PID_OPENLOOP + const float pid_output = is_idling ? 0 : hotend_pid[ee].get_pid_output(ee); #if ENABLED(PID_DEBUG) - if (ee == active_extruder && pid_debug_flag) { - SERIAL_ECHO_MSG(STR_PID_DEBUG, ee, STR_PID_DEBUG_INPUT, temp_hotend[ee].celsius, STR_PID_DEBUG_OUTPUT, pid_output - #if DISABLED(PID_OPENLOOP) - , STR_PID_DEBUG_PTERM, work_pid[ee].Kp - , STR_PID_DEBUG_ITERM, work_pid[ee].Ki - , STR_PID_DEBUG_DTERM, work_pid[ee].Kd - #if ENABLED(PID_EXTRUSION_SCALING) - , STR_PID_DEBUG_CTERM, work_pid[ee].Kc - #endif - #endif - ); - } + if (ee == active_extruder) + hotend_pid[ee].debug(temp_hotend[ee].celsius, pid_output, F("E"), ee); #endif #elif ENABLED(MPCTEMP) + MPCHeaterInfo &hotend = temp_hotend[ee]; MPC_t &constants = hotend.constants; // At startup, initialize modeled temperatures if (isnan(hotend.modeled_block_temp)) { - hotend.modeled_ambient_temp = min(30.0f, hotend.celsius); // Cap initial value at reasonable max room temperature of 30C + hotend.modeled_ambient_temp = _MIN(30.0f, hotend.celsius); // Cap initial value at reasonable max room temperature of 30C hotend.modeled_block_temp = hotend.modeled_sensor_temp = hotend.celsius; } @@ -1433,7 +1475,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { float ambient_xfer_coeff = constants.ambient_xfer_coeff_fan0; #if ENABLED(MPC_INCLUDE_FAN) - const uint8_t fan_index = ANY(MPC_FAN_0_ACTIVE_HOTEND, MPC_FAN_0_ALL_HOTENDS) ? 0 : ee; + const uint8_t fan_index = EITHER(MPC_FAN_0_ACTIVE_HOTEND, MPC_FAN_0_ALL_HOTENDS) ? 0 : ee; const float fan_fraction = TERN_(MPC_FAN_0_ACTIVE_HOTEND, !this_hotend ? 0.0f : ) fan_speed[fan_index] * RECIPROCAL(255); ambient_xfer_coeff += fan_fraction * constants.fan255_adjustment; #endif @@ -1467,10 +1509,10 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { // Only correct ambient when close to steady state (output power is not clipped or asymptotic temperature is reached) if (WITHIN(hotend.soft_pwm_amount, 1, 126) || fabs(blocktempdelta + delta_to_apply) < (MPC_STEADYSTATE * MPC_dT)) - 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); + 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; @@ -1496,8 +1538,7 @@ 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].celsius < temp_hotend[ee].target) ? BANG_MAX : 0; + const float pid_output = (!is_idling && temp_hotend[ee].is_below_target()) ? BANG_MAX : 0; #endif @@ -1509,61 +1550,9 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { #if ENABLED(PIDTEMPBED) float Temperature::get_pid_output_bed() { - - #if DISABLED(PID_OPENLOOP) - - static PID_t work_pid{0}; - static float temp_iState = 0, temp_dState = 0; - static bool pid_reset = true; - float pid_output = 0; - const float max_power_over_i_gain = float(MAX_BED_POWER) / temp_bed.pid.Ki - float(MIN_BED_POWER), - pid_error = temp_bed.target - temp_bed.celsius; - - if (!temp_bed.target || pid_error < -(PID_FUNCTIONAL_RANGE)) { - pid_output = 0; - pid_reset = true; - } - else if (pid_error > PID_FUNCTIONAL_RANGE) { - pid_output = MAX_BED_POWER; - pid_reset = true; - } - else { - if (pid_reset) { - temp_iState = 0.0; - work_pid.Kd = 0.0; - pid_reset = false; - } - - temp_iState = constrain(temp_iState + pid_error, 0, max_power_over_i_gain); - - work_pid.Kp = temp_bed.pid.Kp * pid_error; - work_pid.Ki = temp_bed.pid.Ki * temp_iState; - work_pid.Kd = work_pid.Kd + PID_K2 * (temp_bed.pid.Kd * (temp_dState - temp_bed.celsius) - work_pid.Kd); - - temp_dState = temp_bed.celsius; - - pid_output = constrain(work_pid.Kp + work_pid.Ki + work_pid.Kd + float(MIN_BED_POWER), 0, MAX_BED_POWER); - } - - #else // PID_OPENLOOP - - const float pid_output = constrain(temp_bed.target, 0, MAX_BED_POWER); - - #endif // PID_OPENLOOP - - #if ENABLED(PID_BED_DEBUG) - if (pid_debug_flag) { - SERIAL_ECHO_MSG( - " PID_BED_DEBUG : Input ", temp_bed.celsius, " Output ", pid_output - #if DISABLED(PID_OPENLOOP) - , STR_PID_DEBUG_PTERM, work_pid.Kp - , STR_PID_DEBUG_ITERM, work_pid.Ki - , STR_PID_DEBUG_DTERM, work_pid.Kd - #endif - ); - } - #endif - + static PIDRunner bed_pid(temp_bed); + const float pid_output = bed_pid.get_pid_output(); + TERN_(PID_BED_DEBUG, bed_pid.debug(temp_bed.celsius, pid_output, F("(Bed)"))); return pid_output; } @@ -1572,117 +1561,20 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { #if ENABLED(PIDTEMPCHAMBER) float Temperature::get_pid_output_chamber() { - - #if DISABLED(PID_OPENLOOP) - - static PID_t work_pid{0}; - static float temp_iState = 0, temp_dState = 0; - static bool pid_reset = true; - float pid_output = 0; - const float max_power_over_i_gain = float(MAX_CHAMBER_POWER) / temp_chamber.pid.Ki - float(MIN_CHAMBER_POWER), - pid_error = temp_chamber.target - temp_chamber.celsius; - - if (!temp_chamber.target || pid_error < -(PID_FUNCTIONAL_RANGE)) { - pid_output = 0; - pid_reset = true; - } - else if (pid_error > PID_FUNCTIONAL_RANGE) { - pid_output = MAX_CHAMBER_POWER; - pid_reset = true; - } - else { - if (pid_reset) { - temp_iState = 0.0; - work_pid.Kd = 0.0; - pid_reset = false; - } - - temp_iState = constrain(temp_iState + pid_error, 0, max_power_over_i_gain); - - work_pid.Kp = temp_chamber.pid.Kp * pid_error; - work_pid.Ki = temp_chamber.pid.Ki * temp_iState; - work_pid.Kd = work_pid.Kd + PID_K2 * (temp_chamber.pid.Kd * (temp_dState - temp_chamber.celsius) - work_pid.Kd); - - temp_dState = temp_chamber.celsius; - - pid_output = constrain(work_pid.Kp + work_pid.Ki + work_pid.Kd + float(MIN_CHAMBER_POWER), 0, MAX_CHAMBER_POWER); - } - - #else // PID_OPENLOOP - - const float pid_output = constrain(temp_chamber.target, 0, MAX_CHAMBER_POWER); - - #endif // PID_OPENLOOP - - #if ENABLED(PID_CHAMBER_DEBUG) - { - SERIAL_ECHO_MSG( - " PID_CHAMBER_DEBUG : Input ", temp_chamber.celsius, " Output ", pid_output - #if DISABLED(PID_OPENLOOP) - , STR_PID_DEBUG_PTERM, work_pid.Kp - , STR_PID_DEBUG_ITERM, work_pid.Ki - , STR_PID_DEBUG_DTERM, work_pid.Kd - #endif - ); - } - #endif - + static PIDRunner chamber_pid(temp_chamber); + const float pid_output = chamber_pid.get_pid_output(); + TERN_(PID_CHAMBER_DEBUG, chamber_pid.debug(temp_chamber.celsius, pid_output, F("(Chamber)"))); return pid_output; } #endif // PIDTEMPCHAMBER -/** - * Manage heating activities for extruder hot-ends and a heated bed - * - Acquire updated temperature readings - * - Also resets the watchdog timer - * - Invoke thermal runaway protection - * - Manage extruder auto-fan - * - Apply filament width to the extrusion rate (may move) - * - Update the heated bed PID output value - */ -void Temperature::manage_heater() { - if (marlin_state == MF_INITIALIZING) return hal.watchdog_refresh(); // If Marlin isn't started, at least reset the watchdog! - - static bool no_reentry = false; // Prevent recursion - if (no_reentry) return; - REMEMBER(mh, no_reentry, true); - - #if ENABLED(EMERGENCY_PARSER) - if (emergency_parser.killed_by_M112) kill(FPSTR(M112_KILL_STR), nullptr, true); - - if (emergency_parser.quickstop_by_M410) { - emergency_parser.quickstop_by_M410 = false; // quickstop_stepper may call idle so clear this now! - quickstop_stepper(); - } - #endif - - if (!updateTemperaturesIfReady()) return; // Will also reset the watchdog if temperatures are ready - - #if DISABLED(IGNORE_THERMOCOUPLE_ERRORS) - #if TEMP_SENSOR_0_IS_MAX_TC - if (degHotend(0) > _MIN(HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.0)) max_temp_error(H_E0); - if (degHotend(0) < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01)) min_temp_error(H_E0); - #endif - #if TEMP_SENSOR_1_IS_MAX_TC - 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_REDUNDANT_IS_MAX_TC - 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); - #endif - #else - #warning "Safety Alert! Disable IGNORE_THERMOCOUPLE_ERRORS for the final build!" - #endif - - millis_t ms = millis(); - - #if HAS_HOTEND +#if HAS_HOTEND + void Temperature::manage_hotends(const millis_t &ms) { HOTEND_LOOP() { #if ENABLED(THERMAL_PROTECTION_HOTENDS) - if (degHotend(e) > temp_range[e].maxtemp) max_temp_error((heater_id_t)e); + if (degHotend(e) > temp_range[e].maxtemp) maxtemp_error((heater_id_t)e); #endif TERN_(HEATER_IDLE_HANDLER, heater_idle[e].update(ms)); @@ -1707,28 +1599,16 @@ void Temperature::manage_heater() { #endif } // HOTEND_LOOP + } - #endif // HAS_HOTEND - - #if HAS_TEMP_REDUNDANT - // Make sure measured temperatures are close together - if (ABS(degRedundantTarget() - degRedundant()) > TEMP_SENSOR_REDUNDANT_MAX_DIFF) - _temp_error((heater_id_t)HEATER_ID(TEMP_SENSOR_REDUNDANT_TARGET), F(STR_REDUNDANCY), GET_TEXT_F(MSG_ERR_REDUNDANT_TEMP)); - #endif - - // Manage extruder auto fans and/or read fan tachometers - TERN_(HAS_FAN_LOGIC, manage_extruder_fans(ms)); +#endif // HAS_HOTEND - /** - * Dynamically set the volumetric multiplier based - * on the delayed Filament Width measurement. - */ - TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_volumetric()); +#if HAS_HEATED_BED - #if HAS_HEATED_BED + void Temperature::manage_heated_bed(const millis_t &ms) { #if ENABLED(THERMAL_PROTECTION_BED) - if (degBed() > BED_MAXTEMP) max_temp_error(H_BED); + if (degBed() > BED_MAXTEMP) maxtemp_error(H_BED); #endif #if WATCH_BED @@ -1768,27 +1648,28 @@ void Temperature::manage_heater() { #endif #if HEATER_IDLE_HANDLER - if (heater_idle[IDLE_INDEX_BED].timed_out) { + const bool bed_timed_out = heater_idle[IDLE_INDEX_BED].timed_out; + if (bed_timed_out) { temp_bed.soft_pwm_amount = 0; - #if DISABLED(PIDTEMPBED) - WRITE_HEATER_BED(LOW); - #endif + if (DISABLED(PIDTEMPBED)) WRITE_HEATER_BED(LOW); } - else + #else + constexpr bool bed_timed_out = false; #endif - { + + if (!bed_timed_out) { #if ENABLED(PIDTEMPBED) temp_bed.soft_pwm_amount = WITHIN(temp_bed.celsius, BED_MINTEMP, BED_MAXTEMP) ? (int)get_pid_output_bed() >> 1 : 0; #else // Check if temperature is within the correct band if (WITHIN(temp_bed.celsius, BED_MINTEMP, BED_MAXTEMP)) { #if ENABLED(BED_LIMIT_SWITCHING) - if (temp_bed.celsius >= temp_bed.target + BED_HYSTERESIS) + if (temp_bed.is_above_target((BED_HYSTERESIS) - 1)) temp_bed.soft_pwm_amount = 0; - else if (temp_bed.celsius <= temp_bed.target - (BED_HYSTERESIS)) + else if (temp_bed.is_below_target((BED_HYSTERESIS) - 1)) temp_bed.soft_pwm_amount = MAX_BED_POWER >> 1; #else // !PIDTEMPBED && !BED_LIMIT_SWITCHING - temp_bed.soft_pwm_amount = temp_bed.celsius < temp_bed.target ? MAX_BED_POWER >> 1 : 0; + temp_bed.soft_pwm_amount = temp_bed.is_below_target() ? MAX_BED_POWER >> 1 : 0; #endif } else { @@ -1799,17 +1680,20 @@ void Temperature::manage_heater() { } } while (false); + } - #endif // HAS_HEATED_BED +#endif // HAS_HEATED_BED - #if HAS_HEATED_CHAMBER +#if HAS_HEATED_CHAMBER + + void Temperature::manage_heated_chamber(const millis_t &ms) { #ifndef CHAMBER_CHECK_INTERVAL #define CHAMBER_CHECK_INTERVAL 1000UL #endif #if ENABLED(THERMAL_PROTECTION_CHAMBER) - if (degChamber() > CHAMBER_MAXTEMP) max_temp_error(H_CHAMBER); + if (degChamber() > (CHAMBER_MAXTEMP)) maxtemp_error(H_CHAMBER); #endif #if WATCH_CHAMBER @@ -1837,13 +1721,12 @@ void Temperature::manage_heater() { #if CHAMBER_FAN_MODE == 0 fan_chamber_pwm = CHAMBER_FAN_BASE; #elif CHAMBER_FAN_MODE == 1 - fan_chamber_pwm = (temp_chamber.celsius > temp_chamber.target) ? (CHAMBER_FAN_BASE) + (CHAMBER_FAN_FACTOR) * (temp_chamber.celsius - temp_chamber.target) : 0; + fan_chamber_pwm = temp_chamber.is_above_target() ? (CHAMBER_FAN_BASE) + (CHAMBER_FAN_FACTOR) * (temp_chamber.celsius - temp_chamber.target) : 0; #elif CHAMBER_FAN_MODE == 2 fan_chamber_pwm = (CHAMBER_FAN_BASE) + (CHAMBER_FAN_FACTOR) * ABS(temp_chamber.celsius - temp_chamber.target); - if (temp_chamber.soft_pwm_amount) - fan_chamber_pwm += (CHAMBER_FAN_FACTOR) * 2; + if (temp_chamber.soft_pwm_amount) fan_chamber_pwm += (CHAMBER_FAN_FACTOR) * 2; #elif CHAMBER_FAN_MODE == 3 - fan_chamber_pwm = CHAMBER_FAN_BASE + _MAX((CHAMBER_FAN_FACTOR) * (temp_chamber.celsius - temp_chamber.target), 0); + fan_chamber_pwm = (CHAMBER_FAN_BASE) + _MAX((CHAMBER_FAN_FACTOR) * (temp_chamber.celsius - temp_chamber.target), 0); #endif NOMORE(fan_chamber_pwm, 255); set_fan_speed(CHAMBER_FAN_INDEX, fan_chamber_pwm); @@ -1856,7 +1739,7 @@ void Temperature::manage_heater() { #ifndef MIN_COOLING_SLOPE_DEG_CHAMBER_VENT #define MIN_COOLING_SLOPE_DEG_CHAMBER_VENT 1.5 #endif - if (!flag_chamber_excess_heat && temp_chamber.celsius - temp_chamber.target >= HIGH_EXCESS_HEAT_LIMIT) { + if (!flag_chamber_excess_heat && temp_chamber.is_above_target((HIGH_EXCESS_HEAT_LIMIT) - 1)) { // Open vent after MIN_COOLING_SLOPE_TIME_CHAMBER_VENT seconds if the // temperature didn't drop at least MIN_COOLING_SLOPE_DEG_CHAMBER_VENT if (next_cool_check_ms_2 == 0 || ELAPSED(ms, next_cool_check_ms_2)) { @@ -1870,7 +1753,7 @@ void Temperature::manage_heater() { next_cool_check_ms_2 = 0; old_temp = 9999; } - if (flag_chamber_excess_heat && (temp_chamber.target - temp_chamber.celsius >= LOW_EXCESS_HEAT_LIMIT)) + if (flag_chamber_excess_heat && temp_chamber.is_above_target((LOW_EXCESS_HEAT_LIMIT) - 1)) flag_chamber_excess_heat = false; #endif } @@ -1897,17 +1780,17 @@ void Temperature::manage_heater() { if (flag_chamber_excess_heat) { temp_chamber.soft_pwm_amount = 0; #if ENABLED(CHAMBER_VENT) - if (!flag_chamber_off) servo[CHAMBER_VENT_SERVO_NR].move(temp_chamber.celsius <= temp_chamber.target ? 0 : 90); + if (!flag_chamber_off) servo[CHAMBER_VENT_SERVO_NR].move(temp_chamber.is_below_target() ? 0 : 90); #endif } else { #if ENABLED(CHAMBER_LIMIT_SWITCHING) - if (temp_chamber.celsius >= temp_chamber.target + TEMP_CHAMBER_HYSTERESIS) + if (temp_chamber.is_above_target((TEMP_CHAMBER_HYSTERESIS) - 1)) temp_chamber.soft_pwm_amount = 0; - else if (temp_chamber.celsius <= temp_chamber.target - (TEMP_CHAMBER_HYSTERESIS)) + else if (temp_chamber.is_below_target((TEMP_CHAMBER_HYSTERESIS) - 1)) temp_chamber.soft_pwm_amount = (MAX_CHAMBER_POWER) >> 1; #else - temp_chamber.soft_pwm_amount = temp_chamber.celsius < temp_chamber.target ? (MAX_CHAMBER_POWER) >> 1 : 0; + temp_chamber.soft_pwm_amount = temp_chamber.is_below_target() ? (MAX_CHAMBER_POWER) >> 1 : 0; #endif #if ENABLED(CHAMBER_VENT) if (!flag_chamber_off) servo[CHAMBER_VENT_SERVO_NR].move(0); @@ -1923,17 +1806,20 @@ void Temperature::manage_heater() { tr_state_machine[RUNAWAY_IND_CHAMBER].run(temp_chamber.celsius, temp_chamber.target, H_CHAMBER, THERMAL_PROTECTION_CHAMBER_PERIOD, THERMAL_PROTECTION_CHAMBER_HYSTERESIS); #endif #endif + } - #endif // HAS_HEATED_CHAMBER +#endif // HAS_HEATED_CHAMBER - #if HAS_COOLER +#if HAS_COOLER + + void Temperature::manage_cooler(const millis_t &ms) { #ifndef COOLER_CHECK_INTERVAL #define COOLER_CHECK_INTERVAL 2000UL #endif #if ENABLED(THERMAL_PROTECTION_COOLER) - if (degCooler() > COOLER_MAXTEMP) max_temp_error(H_COOLER); + if (degCooler() > COOLER_MAXTEMP) maxtemp_error(H_COOLER); #endif #if WATCH_COOLER @@ -1953,20 +1839,18 @@ void Temperature::manage_heater() { if (temp_cooler.target == 0) temp_cooler.target = COOLER_MIN_TARGET; if (ELAPSED(ms, next_cooler_check_ms)) { next_cooler_check_ms = ms + COOLER_CHECK_INTERVAL; - if (temp_cooler.celsius > temp_cooler.target) { - temp_cooler.soft_pwm_amount = temp_cooler.celsius > temp_cooler.target ? MAX_COOLER_POWER : 0; - flag_cooler_state = temp_cooler.soft_pwm_amount > 0 ? true : false; // used to allow M106 fan control when cooler is disabled + if (temp_cooler.is_above_target()) { // too warm? + temp_cooler.soft_pwm_amount = MAX_COOLER_POWER; #if ENABLED(COOLER_FAN) - int16_t fan_cooler_pwm = (COOLER_FAN_BASE) + (COOLER_FAN_FACTOR) * ABS(temp_cooler.celsius - temp_cooler.target); - NOMORE(fan_cooler_pwm, 255); - set_fan_speed(COOLER_FAN_INDEX, fan_cooler_pwm); // Set cooler fan pwm + const int16_t fan_cooler_pwm = (COOLER_FAN_BASE) + (COOLER_FAN_FACTOR) * ABS(temp_cooler.celsius - temp_cooler.target); + set_fan_speed(COOLER_FAN_INDEX, _MIN(fan_cooler_pwm, 255)); // Set cooler fan pwm cooler_fan_flush_ms = ms + 5000; #endif } else { temp_cooler.soft_pwm_amount = 0; #if ENABLED(COOLER_FAN) - set_fan_speed(COOLER_FAN_INDEX, temp_cooler.celsius > temp_cooler.target - 2 ? COOLER_FAN_BASE : 0); + set_fan_speed(COOLER_FAN_INDEX, temp_cooler.is_above_target(-2) ? COOLER_FAN_BASE : 0); #endif WRITE_HEATER_COOLER(LOW); } @@ -1984,15 +1868,102 @@ void Temperature::manage_heater() { #if ENABLED(THERMAL_PROTECTION_COOLER) tr_state_machine[RUNAWAY_IND_COOLER].run(temp_cooler.celsius, temp_cooler.target, H_COOLER, THERMAL_PROTECTION_COOLER_PERIOD, THERMAL_PROTECTION_COOLER_HYSTERESIS); #endif + } - #endif // HAS_COOLER +#endif // HAS_COOLER + +/** + * Manage heating activities for extruder hot-ends and a heated bed + * - Acquire updated temperature readings + * - Also resets the watchdog timer + * - Invoke thermal runaway protection + * - Manage extruder auto-fan + * - Apply filament width to the extrusion rate (may move) + * - Update the heated bed PID output value + */ +void Temperature::task() { + if (marlin_state == MF_INITIALIZING) return hal.watchdog_refresh(); // If Marlin isn't started, at least reset the watchdog! + + static bool no_reentry = false; // Prevent recursion + if (no_reentry) return; + REMEMBER(mh, no_reentry, true); + + #if ENABLED(EMERGENCY_PARSER) + if (emergency_parser.killed_by_M112) kill(FPSTR(M112_KILL_STR), nullptr, true); + + if (emergency_parser.quickstop_by_M410) { + emergency_parser.quickstop_by_M410 = false; // quickstop_stepper may call idle so clear this now! + quickstop_stepper(); + } + + #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 + + #if DISABLED(IGNORE_THERMOCOUPLE_ERRORS) + #if TEMP_SENSOR_IS_MAX_TC(0) + if (degHotend(0) > _MIN(HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.0)) maxtemp_error(H_E0); + if (degHotend(0) < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01)) mintemp_error(H_E0); + #endif + #if TEMP_SENSOR_IS_MAX_TC(1) + if (degHotend(1) > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) maxtemp_error(H_E1); + if (degHotend(1) < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) mintemp_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)) maxtemp_error(H_E2); + if (degHotend(2) < _MAX(HEATER_2_MINTEMP, TEMP_SENSOR_2_MAX_TC_TMIN + .01)) mintemp_error(H_E2); + #endif + #if TEMP_SENSOR_IS_MAX_TC(REDUNDANT) + if (degRedundant() > TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - 1.0) maxtemp_error(H_REDUNDANT); + if (degRedundant() < TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + .01) mintemp_error(H_REDUNDANT); + #endif + #else + #warning "Safety Alert! Disable IGNORE_THERMOCOUPLE_ERRORS for the final build!" + #endif + + const millis_t ms = millis(); + + // Handle Hotend Temp Errors, Heating Watch, etc. + TERN_(HAS_HOTEND, manage_hotends(ms)); + + #if HAS_TEMP_REDUNDANT + // Make sure measured temperatures are close together + if (ABS(degRedundantTarget() - degRedundant()) > TEMP_SENSOR_REDUNDANT_MAX_DIFF) + _temp_error((heater_id_t)HEATER_ID(TEMP_SENSOR_REDUNDANT_TARGET), F(STR_REDUNDANCY), GET_TEXT_F(MSG_ERR_REDUNDANT_TEMP)); + #endif + + // Manage extruder auto fans and/or read fan tachometers + TERN_(HAS_FAN_LOGIC, manage_extruder_fans(ms)); + + /** + * Dynamically set the volumetric multiplier based + * on the delayed Filament Width measurement. + */ + TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_volumetric()); + + // Handle Bed Temp Errors, Heating Watch, etc. + TERN_(HAS_HEATED_BED, manage_heated_bed(ms)); + + // Handle Heated Chamber Temp Errors, Heating Watch, etc. + TERN_(HAS_HEATED_CHAMBER, manage_heated_chamber(ms)); + + // Handle Cooler Temp Errors, Cooling Watch, etc. + TERN_(HAS_COOLER, manage_cooler(ms)); #if ENABLED(LASER_COOLANT_FLOW_METER) cooler.flowmeter_task(ms); #if ENABLED(FLOWMETER_SAFETY) - if (cutter.enabled() && cooler.check_flow_too_low()) { + if (cooler.check_flow_too_low()) { + TERN_(HAS_DISPLAY, if (cutter.enabled()) ui.flow_fault()); cutter.disable(); - TERN_(HAS_DISPLAY, ui.flow_fault()); + cutter.cutter_mode = CUTTER_MODE_ERROR; // Immediately kill stepper inline power output } #endif #endif @@ -2032,46 +2003,46 @@ void Temperature::manage_heater() { void Temperature::reset_user_thermistors() { user_thermistor_t default_user_thermistor[USER_THERMISTORS] = { #if TEMP_SENSOR_0_IS_CUSTOM - { true, 0, 0, HOTEND0_PULLUP_RESISTOR_OHMS, HOTEND0_RESISTANCE_25C_OHMS, 0, 0, HOTEND0_BETA, 0 }, + { true, HOTEND0_SH_C_COEFF, 0, HOTEND0_PULLUP_RESISTOR_OHMS, HOTEND0_RESISTANCE_25C_OHMS, 0, 0, HOTEND0_BETA, 0 }, #endif #if TEMP_SENSOR_1_IS_CUSTOM - { true, 0, 0, HOTEND1_PULLUP_RESISTOR_OHMS, HOTEND1_RESISTANCE_25C_OHMS, 0, 0, HOTEND1_BETA, 0 }, + { true, HOTEND1_SH_C_COEFF, 0, HOTEND1_PULLUP_RESISTOR_OHMS, HOTEND1_RESISTANCE_25C_OHMS, 0, 0, HOTEND1_BETA, 0 }, #endif #if TEMP_SENSOR_2_IS_CUSTOM - { true, 0, 0, HOTEND2_PULLUP_RESISTOR_OHMS, HOTEND2_RESISTANCE_25C_OHMS, 0, 0, HOTEND2_BETA, 0 }, + { true, HOTEND2_SH_C_COEFF, 0, HOTEND2_PULLUP_RESISTOR_OHMS, HOTEND2_RESISTANCE_25C_OHMS, 0, 0, HOTEND2_BETA, 0 }, #endif #if TEMP_SENSOR_3_IS_CUSTOM - { true, 0, 0, HOTEND3_PULLUP_RESISTOR_OHMS, HOTEND3_RESISTANCE_25C_OHMS, 0, 0, HOTEND3_BETA, 0 }, + { true, HOTEND3_SH_C_COEFF, 0, HOTEND3_PULLUP_RESISTOR_OHMS, HOTEND3_RESISTANCE_25C_OHMS, 0, 0, HOTEND3_BETA, 0 }, #endif #if TEMP_SENSOR_4_IS_CUSTOM - { true, 0, 0, HOTEND4_PULLUP_RESISTOR_OHMS, HOTEND4_RESISTANCE_25C_OHMS, 0, 0, HOTEND4_BETA, 0 }, + { true, HOTEND4_SH_C_COEFF, 0, HOTEND4_PULLUP_RESISTOR_OHMS, HOTEND4_RESISTANCE_25C_OHMS, 0, 0, HOTEND4_BETA, 0 }, #endif #if TEMP_SENSOR_5_IS_CUSTOM - { true, 0, 0, HOTEND5_PULLUP_RESISTOR_OHMS, HOTEND5_RESISTANCE_25C_OHMS, 0, 0, HOTEND5_BETA, 0 }, + { true, HOTEND5_SH_C_COEFF, 0, HOTEND5_PULLUP_RESISTOR_OHMS, HOTEND5_RESISTANCE_25C_OHMS, 0, 0, HOTEND5_BETA, 0 }, #endif #if TEMP_SENSOR_6_IS_CUSTOM - { true, 0, 0, HOTEND6_PULLUP_RESISTOR_OHMS, HOTEND6_RESISTANCE_25C_OHMS, 0, 0, HOTEND6_BETA, 0 }, + { true, HOTEND6_SH_C_COEFF, 0, HOTEND6_PULLUP_RESISTOR_OHMS, HOTEND6_RESISTANCE_25C_OHMS, 0, 0, HOTEND6_BETA, 0 }, #endif #if TEMP_SENSOR_7_IS_CUSTOM - { true, 0, 0, HOTEND7_PULLUP_RESISTOR_OHMS, HOTEND7_RESISTANCE_25C_OHMS, 0, 0, HOTEND7_BETA, 0 }, + { true, HOTEND7_SH_C_COEFF, 0, HOTEND7_PULLUP_RESISTOR_OHMS, HOTEND7_RESISTANCE_25C_OHMS, 0, 0, HOTEND7_BETA, 0 }, #endif #if TEMP_SENSOR_BED_IS_CUSTOM - { true, 0, 0, BED_PULLUP_RESISTOR_OHMS, BED_RESISTANCE_25C_OHMS, 0, 0, BED_BETA, 0 }, + { true, BED_SH_C_COEFF, 0, BED_PULLUP_RESISTOR_OHMS, BED_RESISTANCE_25C_OHMS, 0, 0, BED_BETA, 0 }, #endif #if TEMP_SENSOR_CHAMBER_IS_CUSTOM - { true, 0, 0, CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS, 0, 0, CHAMBER_BETA, 0 }, + { true, CHAMBER_SH_C_COEFF, 0, CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS, 0, 0, CHAMBER_BETA, 0 }, #endif #if TEMP_SENSOR_COOLER_IS_CUSTOM - { true, 0, 0, COOLER_PULLUP_RESISTOR_OHMS, COOLER_RESISTANCE_25C_OHMS, 0, 0, COOLER_BETA, 0 }, + { true, COOLER_SH_C_COEFF, 0, COOLER_PULLUP_RESISTOR_OHMS, COOLER_RESISTANCE_25C_OHMS, 0, 0, COOLER_BETA, 0 }, #endif #if TEMP_SENSOR_PROBE_IS_CUSTOM - { true, 0, 0, PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS, 0, 0, PROBE_BETA, 0 }, + { true, PROBE_SH_C_COEFF, 0, PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS, 0, 0, PROBE_BETA, 0 }, #endif #if TEMP_SENSOR_BOARD_IS_CUSTOM - { true, 0, 0, BOARD_PULLUP_RESISTOR_OHMS, BOARD_RESISTANCE_25C_OHMS, 0, 0, BOARD_BETA, 0 }, + { true, BOARD_SH_C_COEFF, 0, BOARD_PULLUP_RESISTOR_OHMS, BOARD_RESISTANCE_25C_OHMS, 0, 0, BOARD_BETA, 0 }, #endif #if TEMP_SENSOR_REDUNDANT_IS_CUSTOM - { true, 0, 0, REDUNDANT_PULLUP_RESISTOR_OHMS, REDUNDANT_RESISTANCE_25C_OHMS, 0, 0, REDUNDANT_BETA, 0 }, + { true, REDUNDANT_SH_C_COEFF, 0, REDUNDANT_PULLUP_RESISTOR_OHMS, REDUNDANT_RESISTANCE_25C_OHMS, 0, 0, REDUNDANT_BETA, 0 }, #endif }; COPY(user_thermistor, default_user_thermistor); @@ -2157,7 +2128,7 @@ void Temperature::manage_heater() { case 0: #if TEMP_SENSOR_0_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_0, raw); - #elif TEMP_SENSOR_0_IS_MAX_TC + #elif TEMP_SENSOR_IS_MAX_TC(0) #if TEMP_SENSOR_0_IS_MAX31865 return TERN(LIB_INTERNAL_MAX31865, max31865_0.temperature(raw), @@ -2176,7 +2147,7 @@ void Temperature::manage_heater() { case 1: #if TEMP_SENSOR_1_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_1, raw); - #elif TEMP_SENSOR_1_IS_MAX_TC + #elif TEMP_SENSOR_IS_MAX_TC(1) #if TEMP_SENSOR_0_IS_MAX31865 return TERN(LIB_INTERNAL_MAX31865, max31865_1.temperature(raw), @@ -2195,6 +2166,15 @@ void Temperature::manage_heater() { 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 @@ -2360,10 +2340,12 @@ void Temperature::manage_heater() { celsius_float_t Temperature::analog_to_celsius_redundant(const raw_adc_t raw) { #if TEMP_SENSOR_REDUNDANT_IS_CUSTOM return user_thermistor_to_deg_c(CTI_REDUNDANT, raw); - #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0) + #elif TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E0) return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_0.temperature(raw), (int16_t)raw * 0.25); - #elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1) + #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 @@ -2393,9 +2375,18 @@ void Temperature::updateTemperaturesFromRawValues() { hal.watchdog_refresh(); // Reset because raw_temps_ready was set by the interrupt - TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].setraw(READ_MAX_TC(0))); - TERN_(TEMP_SENSOR_1_IS_MAX_TC, temp_hotend[1].setraw(READ_MAX_TC(1))); - TERN_(TEMP_SENSOR_REDUNDANT_IS_MAX_TC, temp_redundant.setraw(READ_MAX_TC(HEATER_ID(TEMP_SENSOR_REDUNDANT_SOURCE)))); + #if TEMP_SENSOR_IS_MAX_TC(0) + temp_hotend[0].setraw(READ_MAX_TC(0)); + #endif + #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 #if HAS_HOTEND HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].getraw(), e); @@ -2412,7 +2403,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 @@ -2424,53 +2415,64 @@ void Temperature::updateTemperaturesFromRawValues() { #else , TEMPDIR(1) #endif - #if HOTENDS > 2 - #define _TEMPDIR(N) , TEMPDIR(N) - REPEAT_S(2, HOTENDS, _TEMPDIR) + #endif + #if HOTENDS > 2 + #if TEMP_SENSOR_IS_ANY_MAX_TC(2) + , 0 + #else + , TEMPDIR(2) #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)) - max_temp_error((heater_id_t)e); + maxtemp_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 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 (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)) + mintemp_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 #define TP_CMP(S,A,B) (TEMPDIR(S) < 0 ? ((A)<(B)) : ((A)>(B))) #if ENABLED(THERMAL_PROTECTION_BED) - if (TP_CMP(BED, temp_bed.getraw(), maxtemp_raw_BED)) max_temp_error(H_BED); - if (temp_bed.target > 0 && TP_CMP(BED, mintemp_raw_BED, temp_bed.getraw())) min_temp_error(H_BED); + if (TP_CMP(BED, temp_bed.getraw(), maxtemp_raw_BED)) maxtemp_error(H_BED); + if (temp_bed.target > 0 && TP_CMP(BED, mintemp_raw_BED, temp_bed.getraw())) mintemp_error(H_BED); #endif #if BOTH(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER) - if (TP_CMP(CHAMBER, temp_chamber.getraw(), maxtemp_raw_CHAMBER)) max_temp_error(H_CHAMBER); - if (temp_chamber.target > 0 && TP_CMP(CHAMBER, mintemp_raw_CHAMBER, temp_chamber.getraw())) min_temp_error(H_CHAMBER); + if (TP_CMP(CHAMBER, temp_chamber.getraw(), maxtemp_raw_CHAMBER)) maxtemp_error(H_CHAMBER); + if (temp_chamber.target > 0 && TP_CMP(CHAMBER, mintemp_raw_CHAMBER, temp_chamber.getraw())) mintemp_error(H_CHAMBER); #endif #if BOTH(HAS_COOLER, THERMAL_PROTECTION_COOLER) - if (cutter.unitPower > 0 && TP_CMP(COOLER, temp_cooler.getraw(), maxtemp_raw_COOLER)) max_temp_error(H_COOLER); - if (TP_CMP(COOLER, mintemp_raw_COOLER, temp_cooler.getraw())) min_temp_error(H_COOLER); + if (cutter.unitPower > 0 && TP_CMP(COOLER, temp_cooler.getraw(), maxtemp_raw_COOLER)) maxtemp_error(H_COOLER); + if (TP_CMP(COOLER, mintemp_raw_COOLER, temp_cooler.getraw())) mintemp_error(H_COOLER); #endif #if BOTH(HAS_TEMP_BOARD, THERMAL_PROTECTION_BOARD) - if (TP_CMP(BOARD, temp_board.getraw(), maxtemp_raw_BOARD)) max_temp_error(H_BOARD); - if (TP_CMP(BOARD, mintemp_raw_BOARD, temp_board.getraw())) min_temp_error(H_BOARD); + if (TP_CMP(BOARD, temp_board.getraw(), maxtemp_raw_BOARD)) maxtemp_error(H_BOARD); + if (TP_CMP(BOARD, mintemp_raw_BOARD, temp_board.getraw())) mintemp_error(H_BOARD); #endif #undef TP_CMP @@ -2479,7 +2481,7 @@ void Temperature::updateTemperaturesFromRawValues() { /** * Initialize the temperature manager * - * The manager is implemented by periodic calls to manage_heater() + * The manager is implemented by periodic calls to task() * * - Init (and disable) SPI thermocouples like MAX6675 and MAX31865 * - Disable RUMBA JTAG to accommodate a thermocouple extension @@ -2498,9 +2500,6 @@ void Temperature::init() { TERN_(PROBING_HEATERS_OFF, paused_for_probing = false); - #if BOTH(PIDTEMP, PID_EXTRUSION_SCALING) - pes_e_position = 0; - #endif // Init (and disable) SPI thermocouples #if TEMP_SENSOR_IS_ANY_MAX_TC(0) && PIN_EXISTS(TEMP_0_CS) @@ -2509,6 +2508,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 @@ -2536,6 +2538,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 @@ -2568,6 +2582,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; @@ -2679,33 +2702,39 @@ void Temperature::init() { HAL_timer_start(MF_TIMER_TEMP, TEMP_TIMER_FREQUENCY); ENABLE_TEMPERATURE_INTERRUPT(); - #if HAS_AUTO_FAN_0 - INIT_E_AUTO_FAN_PIN(E0_AUTO_FAN_PIN); - #endif - #if HAS_AUTO_FAN_1 && !_EFANOVERLAP(1,0) - INIT_E_AUTO_FAN_PIN(E1_AUTO_FAN_PIN); - #endif - #if HAS_AUTO_FAN_2 && !(_EFANOVERLAP(2,0) || _EFANOVERLAP(2,1)) - INIT_E_AUTO_FAN_PIN(E2_AUTO_FAN_PIN); - #endif - #if HAS_AUTO_FAN_3 && !(_EFANOVERLAP(3,0) || _EFANOVERLAP(3,1) || _EFANOVERLAP(3,2)) - INIT_E_AUTO_FAN_PIN(E3_AUTO_FAN_PIN); - #endif - #if HAS_AUTO_FAN_4 && !(_EFANOVERLAP(4,0) || _EFANOVERLAP(4,1) || _EFANOVERLAP(4,2) || _EFANOVERLAP(4,3)) - INIT_E_AUTO_FAN_PIN(E4_AUTO_FAN_PIN); - #endif - #if HAS_AUTO_FAN_5 && !(_EFANOVERLAP(5,0) || _EFANOVERLAP(5,1) || _EFANOVERLAP(5,2) || _EFANOVERLAP(5,3) || _EFANOVERLAP(5,4)) - INIT_E_AUTO_FAN_PIN(E5_AUTO_FAN_PIN); - #endif - #if HAS_AUTO_FAN_6 && !(_EFANOVERLAP(6,0) || _EFANOVERLAP(6,1) || _EFANOVERLAP(6,2) || _EFANOVERLAP(6,3) || _EFANOVERLAP(6,4) || _EFANOVERLAP(6,5)) - INIT_E_AUTO_FAN_PIN(E6_AUTO_FAN_PIN); - #endif - #if HAS_AUTO_FAN_7 && !(_EFANOVERLAP(7,0) || _EFANOVERLAP(7,1) || _EFANOVERLAP(7,2) || _EFANOVERLAP(7,3) || _EFANOVERLAP(7,4) || _EFANOVERLAP(7,5) || _EFANOVERLAP(7,6)) - INIT_E_AUTO_FAN_PIN(E7_AUTO_FAN_PIN); - #endif - #if HAS_AUTO_CHAMBER_FAN && !AUTO_CHAMBER_IS_E - INIT_CHAMBER_AUTO_FAN_PIN(CHAMBER_AUTO_FAN_PIN); - #endif + #if HAS_AUTO_FAN + #define _OREFAN(I,N) || _EFANOVERLAP(I,N) + #if HAS_AUTO_FAN_0 + INIT_E_AUTO_FAN_PIN(E0_AUTO_FAN_PIN); + #endif + #if HAS_AUTO_FAN_1 && !_EFANOVERLAP(0,1) + INIT_E_AUTO_FAN_PIN(E1_AUTO_FAN_PIN); + #endif + #if HAS_AUTO_FAN_2 && !(0 REPEAT2(2, _OREFAN, 2)) + INIT_E_AUTO_FAN_PIN(E2_AUTO_FAN_PIN); + #endif + #if HAS_AUTO_FAN_3 && !(0 REPEAT2(3, _OREFAN, 3)) + INIT_E_AUTO_FAN_PIN(E3_AUTO_FAN_PIN); + #endif + #if HAS_AUTO_FAN_4 && !(0 REPEAT2(4, _OREFAN, 4)) + INIT_E_AUTO_FAN_PIN(E4_AUTO_FAN_PIN); + #endif + #if HAS_AUTO_FAN_5 && !(0 REPEAT2(5, _OREFAN, 5)) + INIT_E_AUTO_FAN_PIN(E5_AUTO_FAN_PIN); + #endif + #if HAS_AUTO_FAN_6 && !(0 REPEAT2(6, _OREFAN, 6)) + INIT_E_AUTO_FAN_PIN(E6_AUTO_FAN_PIN); + #endif + #if HAS_AUTO_FAN_7 && !(0 REPEAT2(7, _OREFAN, 7)) + INIT_E_AUTO_FAN_PIN(E7_AUTO_FAN_PIN); + #endif + #if HAS_AUTO_CHAMBER_FAN && !AUTO_CHAMBER_IS_E + INIT_CHAMBER_AUTO_FAN_PIN(CHAMBER_AUTO_FAN_PIN); + #endif + #if HAS_AUTO_COOLER_FAN && !AUTO_COOLER_IS_E + INIT_COOLER_AUTO_FAN_PIN(COOLER_AUTO_FAN_PIN); + #endif + #endif // HAS_AUTO_FAN #if HAS_HOTEND #define _TEMP_MIN_E(NR) do{ \ @@ -2723,7 +2752,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); @@ -2832,7 +2861,7 @@ void Temperature::init() { * * TODO: Embed the last 3 parameters during init, if not less optimal */ - void Temperature::tr_state_machine_t::run(const_celsius_float_t current, const_celsius_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc) { + void Temperature::tr_state_machine_t::run(const_celsius_float_t current, const_celsius_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_float_t hysteresis_degc) { #if HEATER_IDLE_HANDLER // Convert the given heater_id_t to an idle array index @@ -2894,21 +2923,26 @@ void Temperature::init() { // While the temperature is stable watch for a bad temperature case TRStable: { + const celsius_float_t rdiff = running_temp - current; + #if ENABLED(ADAPTIVE_FAN_SLOWING) if (adaptive_fan_slowing && heater_id >= 0) { - const int fan_index = _MIN(heater_id, FAN_COUNT - 1); - if (fan_speed[fan_index] == 0 || current >= running_temp - (hysteresis_degc * 0.25f)) - fan_speed_scaler[fan_index] = 128; - else if (current >= running_temp - (hysteresis_degc * 0.3335f)) - fan_speed_scaler[fan_index] = 96; - else if (current >= running_temp - (hysteresis_degc * 0.5f)) - fan_speed_scaler[fan_index] = 64; - else if (current >= running_temp - (hysteresis_degc * 0.8f)) - fan_speed_scaler[fan_index] = 32; + const int_fast8_t fan_index = _MIN(heater_id, FAN_COUNT - 1); + uint8_t scale; + if (fan_speed[fan_index] == 0 || rdiff <= hysteresis_degc * 0.25f) + scale = 128; + else if (rdiff <= hysteresis_degc * 0.3335f) + scale = 96; + else if (rdiff <= hysteresis_degc * 0.5f) + scale = 64; + else if (rdiff <= hysteresis_degc * 0.8f) + scale = 32; else - fan_speed_scaler[fan_index] = 0; + scale = 0; + + fan_speed_scaler[fan_index] = scale; } - #endif + #endif // ADAPTIVE_FAN_SLOWING const millis_t now = millis(); @@ -2928,7 +2962,7 @@ void Temperature::init() { } #endif - if (current >= running_temp - hysteresis_degc) { + if (rdiff <= hysteresis_degc) { timer = now + SEC_TO_MS(period_seconds); break; } @@ -3086,32 +3120,41 @@ 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) + #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. 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 }; static millis_t next_max_tc_ms[MAX_TC_COUNT] = { 0 }; // Return last-read value between readings - millis_t ms = millis(); + const millis_t ms = millis(); if (PENDING(ms, next_max_tc_ms[hindex])) return THERMO_TEMP(hindex); @@ -3139,23 +3182,23 @@ 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 // Handle an error. If there have been more than THERMOCOUPLE_MAX_ERRORS, send an error over serial. - // Either way, return the TMAX for the thermocouple to trigger a max_temp_error() + // Either way, return the TMAX for the thermocouple to trigger a maxtemp_error() if (max_tc_temp & MAX_TC_ERROR_MASK) { max_tc_errors[hindex]++; @@ -3194,7 +3237,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 { @@ -3224,15 +3267,19 @@ void Temperature::disable_all_heaters() { void Temperature::update_raw_temperatures() { // TODO: can this be collapsed into a HOTEND_LOOP()? - #if HAS_TEMP_ADC_0 && !TEMP_SENSOR_0_IS_MAX_TC + #if HAS_TEMP_ADC_0 && !TEMP_SENSOR_IS_MAX_TC(0) temp_hotend[0].update(); #endif - #if HAS_TEMP_ADC_1 && !TEMP_SENSOR_1_IS_MAX_TC + #if HAS_TEMP_ADC_1 && !TEMP_SENSOR_IS_MAX_TC(1) temp_hotend[1].update(); #endif - #if HAS_TEMP_ADC_REDUNDANT && !TEMP_SENSOR_REDUNDANT_IS_MAX_TC + #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 @@ -3354,6 +3401,10 @@ void Temperature::isr() { static int8_t temp_count = -1; static ADCSensorState adc_sensor_state = StartupDelay; + + #ifndef SOFT_PWM_SCALE + #define SOFT_PWM_SCALE 0 + #endif static uint8_t pwm_count = _BV(SOFT_PWM_SCALE); // Avoid multiple loads of pwm_count @@ -3419,16 +3470,18 @@ void Temperature::isr() { _PWM_MOD(COOLER, soft_pwm_cooler, temp_cooler); #endif - #if BOTH(USE_CONTROLLER_FAN, FAN_SOFT_PWM) - WRITE(CONTROLLER_FAN_PIN, soft_pwm_controller.add(pwm_mask, soft_pwm_controller_speed)); - #endif - #if ENABLED(FAN_SOFT_PWM) + + #if ENABLED(USE_CONTROLLER_FAN) + WRITE(CONTROLLER_FAN_PIN, soft_pwm_controller.add(pwm_mask, soft_pwm_controller_speed)); + #endif + #define _FAN_PWM(N) do{ \ uint8_t &spcf = soft_pwm_count_fan[N]; \ spcf = (spcf & pwm_mask) + (soft_pwm_amount_fan[N] >> 1); \ WRITE_FAN(N, spcf > pwm_mask ? HIGH : LOW); \ }while(0) + #if HAS_FAN0 _FAN_PWM(0); #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index c11c9d76defb..bd67785383b0 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -41,15 +41,11 @@ #include "../feature/fancheck.h" #endif -#ifndef SOFT_PWM_SCALE - #define SOFT_PWM_SCALE 0 -#endif - #define HOTEND_INDEX TERN(HAS_MULTI_HOTEND, e, 0) #define E_NAME TERN_(HAS_MULTI_HOTEND, e) // Element identifiers. Positive values are hotends. Negative values are other heaters or coolers. -typedef enum : int8_t { +typedef enum : int_fast8_t { H_REDUNDANT = HID_REDUNDANT, H_COOLER = HID_COOLER, H_PROBE = HID_PROBE, @@ -60,53 +56,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 +137,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 +154,238 @@ 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 ) + + /// @brief The default PID class, only has Kp, Ki, Kd, other classes extend this one + /// @tparam MIN_POW output when current is above target by functional_range + /// @tparam MAX_POW output when current is below target by functional_range + /// @details This class has methods for Kc and Kf terms, but returns constant default values + /// PID classes that implement these features are expected to override these methods + /// Since the finally used PID class is typedef-d, there is no need to use virtual functions + template + struct PID_t{ + protected: + bool pid_reset = true; + float temp_iState = 0.0f, temp_dState = 0.0f; + float work_p = 0, work_i = 0, work_d = 0; + + public: + float Kp = 0, Ki = 0, Kd = 0; + 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; } + float pTerm() const { return work_p; } + float iTerm() const { return work_i; } + float dTerm() const { return work_d; } + float cTerm() const { return 0; } + float fTerm() 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) {} + int low() const { return MIN_POW; } + int high() const { return MAX_POW; } + void reset() { pid_reset = true; } + 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); } + + float get_fan_scale_output(const uint8_t) { return 0; } + + float get_extrusion_scale_output(const bool, const int32_t, const float, const int16_t) { return 0; } + + float get_pid_output(const float target, const float current) { + const float pid_error = target - current; + if (!target || pid_error < -(PID_FUNCTIONAL_RANGE)) { + pid_reset = true; + return 0; + } + else if (pid_error > PID_FUNCTIONAL_RANGE) { + pid_reset = true; + return MAX_POW; + } + + if (pid_reset) { + pid_reset = false; + temp_iState = 0.0; + work_d = 0.0; + } + + const float max_power_over_i_gain = float(MAX_POW) / Ki - float(MIN_POW); + temp_iState = constrain(temp_iState + pid_error, 0, max_power_over_i_gain); + + work_p = Kp * pid_error; + work_i = Ki * temp_iState; + work_d = work_d + PID_K2 * (Kd * (temp_dState - current) - work_d); + + temp_dState = current; + + return constrain(work_p + work_i + work_d + float(MIN_POW), 0, MAX_POW); + } + + }; + #endif -#if ENABLED(MPCTEMP) +#if ENABLED(PIDTEMP) + + /// @brief Extrusion scaled PID class + template + struct PIDC_t : public PID_t { + private: + using base = PID_t; + float work_c = 0; + float prev_e_pos = 0; + int32_t lpq[LPQ_ARR_SZ] = {}; + int16_t lpq_ptr = 0; + public: + float Kc = 0; + float c() const { return Kc; } + void set_Kc(float c) { Kc = c; } + float cTerm() const { return work_c; } + void set(float p, float i, float d, float c=1, float f=0) { + base::set_Kp(p); + base::set_Ki(i); + base::set_Kd(d); + set_Kc(c); + base::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); } + void reset() { + base::reset(); + prev_e_pos = 0; + lpq_ptr = 0; + LOOP_L_N(i, LPQ_ARR_SZ) lpq[i] = 0; + } + + float get_extrusion_scale_output(const bool is_active, const int32_t e_position, const float e_mm_per_step, const int16_t lpq_len) { + work_c = 0; + if (!is_active) return work_c; + + if (e_position > prev_e_pos) { + lpq[lpq_ptr] = e_position - prev_e_pos; + prev_e_pos = e_position; + } + else + lpq[lpq_ptr] = 0; + + ++lpq_ptr; + + if (lpq_ptr >= LPQ_ARR_SZ || lpq_ptr >= lpq_len) + lpq_ptr = 0; + + work_c = (lpq[lpq_ptr] * e_mm_per_step) * Kc; + + return work_c; + } + }; + + /// @brief Fan scaled PID, this class implements the get_fan_scale_output() method + /// @tparam MIN_POW @see PID_t + /// @tparam MAX_POW @see PID_t + /// @tparam SCALE_MIN_SPEED parameter from Configuration_adv.h + /// @tparam SCALE_LIN_FACTOR parameter from Configuration_adv.h + template + struct PIDF_t : public PID_t { + private: + using base = PID_t; + float work_f = 0; + public: + float Kf = 0; + float f() const { return Kf; } + void set_Kf(float f) { Kf = f; } + float fTerm() const { return work_f; } + void set(float p, float i, float d, float c=1, float f=0) { + base::set_Kp(p); + base::set_Ki(i); + base::set_Kd(d); + base::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); } + + float get_fan_scale_output(const uint8_t fan_speed) { + work_f = 0; + if (fan_speed > SCALE_MIN_SPEED) + work_f = Kf + (SCALE_LIN_FACTOR) * fan_speed; + + return work_f; + } + }; + + /// @brief Inherits PID and PIDC - can't use proper diamond inheritance w/o virtual + template + struct PIDCF_t : public PIDC_t { + private: + using base = PID_t; + using cPID = PIDC_t; + float work_f = 0; + public: + float Kf = 0; + float c() const { return cPID::c(); } + float f() const { return Kf; } + void set_Kc(float c) { cPID::set_Kc(c); } + void set_Kf(float f) { Kf = f; } + float cTerm() const { return cPID::cTerm(); } + float fTerm() const { return work_f; } + void set(float p, float i, float d, float c=1, float f=0) { + base::set_Kp(p); + base::set_Ki(i); + base::set_Kd(d); + cPID::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); } + + void reset() { cPID::reset(); } + + float get_fan_scale_output(const uint8_t fan_speed) { + work_f = fan_speed > (SCALE_MIN_SPEED) ? Kf + (SCALE_LIN_FACTOR) * fan_speed : 0; + return work_f; + } + float get_extrusion_scale_output(const bool is_active, const int32_t e_position, const float e_mm_per_step, const int16_t lpq_len) { + return cPID::get_extrusion_scale_output(is_active, e_position, e_mm_per_step, lpq_len); + } + }; + + typedef + #if BOTH(PID_EXTRUSION_SCALING, PID_FAN_SCALING) + PIDCF_t<0, PID_MAX, LPQ_MAX_LEN, PID_FAN_SCALING_MIN_SPEED, PID_FAN_SCALING_LIN_FACTOR> + #elif ENABLED(PID_EXTRUSION_SCALING) + PIDC_t<0, PID_MAX, LPQ_MAX_LEN> + #elif ENABLED(PID_FAN_SCALING) + PIDF_t<0, PID_MAX, PID_FAN_SCALING_MIN_SPEED, PID_FAN_SCALING_LIN_FACTOR> + #else + PID_t<0, PID_MAX> + #endif + hotend_pid_t; + + #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 +403,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 @@ -232,6 +417,8 @@ typedef struct TempInfo { typedef struct HeaterInfo : public TempInfo { celsius_t target; uint8_t soft_pwm_amount; + bool is_below_target(const celsius_t offs=0) const { return (target - celsius > offs); } // celsius < target - offs + bool is_above_target(const celsius_t offs=0) const { return (celsius - target > offs); } // celsius > target + offs } heater_info_t; // A heater with PID stabilization @@ -258,14 +445,14 @@ struct PIDHeaterInfo : public HeaterInfo { #endif #if HAS_HEATED_BED #if ENABLED(PIDTEMPBED) - typedef struct PIDHeaterInfo bed_info_t; + typedef struct PIDHeaterInfo> bed_info_t; #else typedef heater_info_t bed_info_t; #endif #endif #if HAS_HEATED_CHAMBER #if ENABLED(PIDTEMPCHAMBER) - typedef struct PIDHeaterInfo chamber_info_t; + typedef struct PIDHeaterInfo> chamber_info_t; #else typedef heater_info_t chamber_info_t; #endif @@ -389,9 +576,10 @@ class Temperature { #if HAS_HOTEND static hotend_info_t temp_hotend[HOTENDS]; - static const celsius_t hotend_maxtemp[HOTENDS]; + static constexpr celsius_t hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP); 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 @@ -516,11 +704,6 @@ class Temperature { static hotend_watch_t watch_hotend[HOTENDS]; #endif - #if ENABLED(PID_EXTRUSION_SCALING) - static int32_t pes_e_position, lpq[LPQ_MAX_LEN]; - static lpq_ptr_t lpq_ptr; - #endif - #if ENABLED(MPCTEMP) static int32_t mpc_e_position; #endif @@ -530,23 +713,27 @@ class Temperature { #endif #if HAS_HEATED_BED - #if ENABLED(WATCH_BED) + #if WATCH_BED static bed_watch_t watch_bed; #endif - IF_DISABLED(PIDTEMPBED, static millis_t next_bed_check_ms); + #if DISABLED(PIDTEMPBED) + static millis_t next_bed_check_ms; + #endif static raw_adc_t mintemp_raw_BED, maxtemp_raw_BED; #endif #if HAS_HEATED_CHAMBER - #if ENABLED(WATCH_CHAMBER) + #if WATCH_CHAMBER static chamber_watch_t watch_chamber; #endif - TERN(PIDTEMPCHAMBER,,static millis_t next_chamber_check_ms); + #if DISABLED(PIDTEMPCHAMBER) + static millis_t next_chamber_check_ms; + #endif static raw_adc_t mintemp_raw_CHAMBER, maxtemp_raw_CHAMBER; #endif #if HAS_COOLER - #if ENABLED(WATCH_COOLER) + #if WATCH_COOLER static cooler_watch_t watch_cooler; #endif static millis_t next_cooler_check_ms, cooler_fan_flush_ms; @@ -715,9 +902,9 @@ class Temperature { static void readings_ready(); /** - * Call periodically to manage heaters + * Call periodically to manage heaters and keep the watchdog fed */ - static void manage_heater() __O2; // __O2 added to work around a compiler error + static void task(); /** * Preheating hotends @@ -807,6 +994,8 @@ class Temperature { #endif } + static void manage_hotends(const millis_t &ms); + #endif // HAS_HOTEND #if HAS_HEATED_BED @@ -819,6 +1008,9 @@ class Temperature { static celsius_t degTargetBed() { return temp_bed.target; } static bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; } static bool isCoolingBed() { return temp_bed.target < temp_bed.celsius; } + static bool degBedNear(const celsius_t temp) { + return ABS(wholeDegBed() - temp) < (TEMP_BED_HYSTERESIS); + } // Start watching the Bed to make sure it's really heating up static void start_watching_bed() { TERN_(WATCH_BED, watch_bed.restart(degBed(), degTargetBed())); } @@ -835,9 +1027,7 @@ class Temperature { static void wait_for_bed_heating(); - static bool degBedNear(const celsius_t temp) { - return ABS(wholeDegBed() - temp) < (TEMP_BED_HYSTERESIS); - } + static void manage_heated_bed(const millis_t &ms); #endif // HAS_HEATED_BED @@ -863,6 +1053,7 @@ class Temperature { static bool isHeatingChamber() { return temp_chamber.target > temp_chamber.celsius; } static bool isCoolingChamber() { return temp_chamber.target < temp_chamber.celsius; } static bool wait_for_chamber(const bool no_wait_for_cooling=true); + static void manage_heated_chamber(const millis_t &ms); #endif #endif @@ -886,6 +1077,7 @@ class Temperature { static bool isLaserHeating() { return temp_cooler.target > temp_cooler.celsius; } static bool isLaserCooling() { return temp_cooler.target < temp_cooler.celsius; } static bool wait_for_cooler(const bool no_wait_for_cooling=true); + static void manage_cooler(const millis_t &ms); #endif #endif @@ -947,7 +1139,7 @@ class Temperature { */ #if HAS_PID_HEATING - #if ANY(PID_DEBUG, PID_BED_DEBUG, PID_CHAMBER_DEBUG) + #if HAS_PID_DEBUG static bool pid_debug_flag; #endif @@ -959,12 +1151,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() { HOTEND_LOOP() temp_hotend[e].pid.reset(); } + 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 @@ -1010,7 +1206,7 @@ class Temperature { static void set_heating_message(const uint8_t, const bool=false) {} #endif - #if HAS_MARLINUI_MENU && HAS_TEMPERATURE + #if HAS_MARLINUI_MENU && HAS_TEMPERATURE && HAS_PREHEAT static void lcd_preheat(const uint8_t e, const int8_t indh, const int8_t indb); #endif @@ -1029,7 +1225,7 @@ class Temperature { // MAX Thermocouples #if HAS_MAX_TC - #define MAX_TC_COUNT COUNT_ENABLED(TEMP_SENSOR_0_IS_MAX_TC, TEMP_SENSOR_1_IS_MAX_TC, TEMP_SENSOR_REDUNDANT_IS_MAX_TC) + #define MAX_TC_COUNT TEMP_SENSOR_IS_MAX_TC(0) + TEMP_SENSOR_IS_MAX_TC(1) + TEMP_SENSOR_IS_MAX_TC(REDUNDANT) #if MAX_TC_COUNT > 1 #define HAS_MULTI_MAX_TC 1 #define READ_MAX_TC(N) read_max_tc(N) @@ -1057,8 +1253,8 @@ class Temperature { #endif static void _temp_error(const heater_id_t e, FSTR_P const serial_msg, FSTR_P const lcd_msg); - static void min_temp_error(const heater_id_t e); - static void max_temp_error(const heater_id_t e); + static void mintemp_error(const heater_id_t e); + static void maxtemp_error(const heater_id_t e); #define HAS_THERMAL_PROTECTION ANY(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_CHAMBER, THERMAL_PROTECTION_BED, THERMAL_PROTECTION_COOLER) @@ -1093,12 +1289,12 @@ class Temperature { typedef struct { millis_t timer = 0; TRState state = TRInactive; - float running_temp; + celsius_float_t running_temp; #if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR) millis_t variance_timer = 0; celsius_float_t last_temp = 0.0, variance = 0.0; #endif - void run(const_celsius_float_t current, const_celsius_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_t hysteresis_degc); + void run(const_celsius_float_t current, const_celsius_float_t target, const heater_id_t heater_id, const uint16_t period_seconds, const celsius_float_t hysteresis_degc); } tr_state_machine_t; static tr_state_machine_t tr_state_machine[NR_HEATER_RUNAWAY]; 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/thermistor_2000.h b/Marlin/src/module/thermistor/thermistor_2000.h index 3815a6f2569a..6393c980eac6 100644 --- a/Marlin/src/module/thermistor/thermistor_2000.h +++ b/Marlin/src/module/thermistor/thermistor_2000.h @@ -23,12 +23,12 @@ // R25 = 100 KOhm, beta25 = 4550 K, 4.7 kOhm pull-up, TDK NTCG104LH104KT1 https://product.tdk.com/en/search/sensor/ntc/chip-ntc-thermistor/info?part_no=NTCG104LH104KT1 constexpr temp_entry_t temptable_2000[] PROGMEM = { -{ OV(313), 125 }, -{ OV(347), 120 }, -{ OV(383), 115 }, -{ OV(422), 110 }, -{ OV(463), 105 }, -{ OV(506), 100 }, +{ OV(313), 125 }, +{ OV(347), 120 }, +{ OV(383), 115 }, +{ OV(422), 110 }, +{ OV(463), 105 }, +{ OV(506), 100 }, { OV(549), 95 }, { OV(594), 90 }, { OV(638), 85 }, diff --git a/Marlin/src/module/thermistor/thermistor_504.h b/Marlin/src/module/thermistor/thermistor_504.h index 61ce3ae1358c..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 @@ -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..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 @@ -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_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 a38b7f381feb..c596d746f7fd 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 @@ -335,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)) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 4b292c92f98b..5c831c74124d 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 ((EXTRUDERS & 1) && e < EXTRUDERS - 1) { + 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); } @@ -132,7 +133,7 @@ constexpr int16_t sns_angles[2] = SWITCHING_NOZZLE_SERVO_ANGLES; planner.synchronize(); servo[sns_index[e]].move(sns_angles[angle_index]); - safe_delay(500); + safe_delay(SWITCHING_NOZZLE_SERVO_DWELL); } void lower_nozzle(const uint8_t e) { _move_nozzle_servo(e, 0); } @@ -143,7 +144,7 @@ void move_nozzle_servo(const uint8_t angle_index) { planner.synchronize(); servo[SWITCHING_NOZZLE_SERVO_NR].move(servo_angles[SWITCHING_NOZZLE_SERVO_NR][angle_index]); - safe_delay(500); + safe_delay(SWITCHING_NOZZLE_SERVO_DWELL); } #endif @@ -440,6 +441,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 +458,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 +498,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; @@ -918,7 +918,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 } @@ -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 @@ -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 @@ -1350,6 +1350,14 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { #else do_blocking_move_to_xy(destination, planner.settings.max_feedrate_mm_s[X_AXIS]); do_blocking_move_to_z(destination.z, planner.settings.max_feedrate_mm_s[Z_AXIS]); + SECONDARY_AXIS_CODE( + do_blocking_move_to_i(destination.i, planner.settings.max_feedrate_mm_s[I_AXIS]), + do_blocking_move_to_j(destination.j, planner.settings.max_feedrate_mm_s[J_AXIS]), + do_blocking_move_to_k(destination.k, planner.settings.max_feedrate_mm_s[K_AXIS]), + do_blocking_move_to_u(destination.u, planner.settings.max_feedrate_mm_s[U_AXIS]), + do_blocking_move_to_v(destination.v, planner.settings.max_feedrate_mm_s[V_AXIS]), + do_blocking_move_to_w(destination.w, planner.settings.max_feedrate_mm_s[W_AXIS]) + ); #endif #endif 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 diff --git a/Marlin/src/pins/esp32/pins_E4D.h b/Marlin/src/pins/esp32/pins_E4D.h index 42177e9a4e31..d12b5276b7be 100644 --- a/Marlin/src/pins/esp32/pins_E4D.h +++ b/Marlin/src/pins/esp32/pins_E4D.h @@ -40,19 +40,14 @@ #define BOARD_WEBSITE_URL "github.com/Exilaus/E4d@box" #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME -// -// Disable I2S stepper stream -// -#undef I2S_STEPPER_STREAM - // // Redefine I2S for ESP32 // #undef I2S_WS -#define I2S_WS 23 #undef I2S_BCK -#define I2S_BCK 22 #undef I2S_DATA +#define I2S_WS 23 +#define I2S_BCK 22 #define I2S_DATA 21 // diff --git a/Marlin/src/pins/esp32/pins_ENWI_ESPNP.h b/Marlin/src/pins/esp32/pins_ENWI_ESPNP.h index aff7f742edf9..80923d972deb 100644 --- a/Marlin/src/pins/esp32/pins_ENWI_ESPNP.h +++ b/Marlin/src/pins/esp32/pins_ENWI_ESPNP.h @@ -35,9 +35,11 @@ // I2S (steppers & other output-only pins) // #define I2S_STEPPER_STREAM -#define I2S_WS 17 -#define I2S_BCK 22 -#define I2S_DATA 21 +#if ENABLED(I2S_STEPPER_STREAM) + #define I2S_WS 17 + #define I2S_BCK 22 + #define I2S_DATA 21 +#endif // // Servos diff --git a/Marlin/src/pins/esp32/pins_ESP32.h b/Marlin/src/pins/esp32/pins_ESP32.h index 6578770ba0e2..266de7e9f60e 100644 --- a/Marlin/src/pins/esp32/pins_ESP32.h +++ b/Marlin/src/pins/esp32/pins_ESP32.h @@ -33,9 +33,11 @@ // I2S (steppers & other output-only pins) // #define I2S_STEPPER_STREAM -#define I2S_WS 25 -#define I2S_BCK 26 -#define I2S_DATA 27 +#if ENABLED(I2S_STEPPER_STREAM) + #define I2S_WS 25 + #define I2S_BCK 26 + #define I2S_DATA 27 +#endif // // Limit Switches diff --git a/Marlin/src/pins/esp32/pins_ESPA_common.h b/Marlin/src/pins/esp32/pins_ESPA_common.h index 2fcacb3002b4..ca949cdf9716 100644 --- a/Marlin/src/pins/esp32/pins_ESPA_common.h +++ b/Marlin/src/pins/esp32/pins_ESPA_common.h @@ -32,14 +32,6 @@ #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME #endif -// -// Disable I2S stepper stream, by default -// -#undef I2S_STEPPER_STREAM -#undef I2S_WS -#undef I2S_BCK -#undef I2S_DATA - // // Limit Switches // diff --git a/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h b/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h index 9938d9b4fa01..37ce4ee94e56 100644 --- a/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h +++ b/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h @@ -40,6 +40,8 @@ #define BOARD_WEBSITE_URL "https://github.com/makerbase-mks" #define DEFAULT_MACHINE_NAME BOARD_INFO_NAME +// MAX_EXPANDER_BITS is defined for MKS TinyBee in HAL/ESP32/inc/Conditionals_adv.h + // // Servos // @@ -61,9 +63,6 @@ #define I2S_WS 26 #define I2S_BCK 25 #define I2S_DATA 27 - #if ENABLED(LIN_ADVANCE) - #error "I2S stream is currently incompatible with LIN_ADVANCE." - #endif #endif // @@ -116,76 +115,79 @@ // // ADC Reference Voltage // -#define ADC_REFERENCE_VOLTAGE 2.5 // 2.5V reference VDDA +#define ADC_REFERENCE_VOLTAGE 2.565 // 2.5V reference VDDA /** * ------ ------ - * (BEEPER) 149 |10 9 | 13 (BTN_ENC) (SPI MISO) 19 |10 9 | 18 (SPI SCK) - * (LCD_EN) 21 | 8 7 | 4 (LCD_RS) (BTN_EN1) 14 | 8 7 | 5 (SPI CS) - * (LCD_D4) 0 6 5 | 16 (LCD_D5) (BTN_EN2) 12 6 5 | 23 (SPI MOSI) - * (LCD_D6) 15 | 4 3 | 17 (LCD_D7) (SPI_DET) 34 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | 3.3V + * (BEEPER) 149 | 1 2 | 13 (BTN_ENC) (SPI MISO) 19 | 1 2 | 18 (SPI SCK) + * (LCD_EN) 21 | 3 4 | 4 (LCD_RS) (BTN_EN1) 14 | 3 4 | 5 (SPI CS) + * (LCD_D4) 0 5 6 | 16 (LCD_D5) (BTN_EN2) 12 5 6 | 23 (SPI MOSI) + * (LCD_D6) 15 | 7 8 | 17 (LCD_D7) (SPI_DET) 34 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN 17 -#define EXP1_04_PIN 15 -#define EXP1_05_PIN 16 -#define EXP1_06_PIN 0 -#define EXP1_07_PIN 4 -#define EXP1_08_PIN 21 -#define EXP1_09_PIN 13 -#define EXP1_10_PIN 149 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN 34 -#define EXP2_05_PIN 23 -#define EXP2_06_PIN 12 -#define EXP2_07_PIN 5 -#define EXP2_08_PIN 14 -#define EXP2_09_PIN 18 -#define EXP2_10_PIN 19 +#define EXP1_01_PIN 149 +#define EXP1_02_PIN 13 +#define EXP1_03_PIN 21 +#define EXP1_04_PIN 4 +#define EXP1_05_PIN 0 +#define EXP1_06_PIN 16 +#define EXP1_07_PIN 15 +#define EXP1_08_PIN 17 + +#define EXP2_01_PIN 19 +#define EXP2_02_PIN 18 +#define EXP2_03_PIN 14 +#define EXP2_04_PIN 5 +#define EXP2_05_PIN 12 +#define EXP2_06_PIN 23 +#define EXP2_07_PIN 34 +#define EXP2_08_PIN -1 // RESET // // MicroSD card // -//#define SD_MOSI_PIN EXP2_05_PIN // uses esp32 default 23 -//#define SD_MISO_PIN EXP2_10_PIN // uses esp32 default 19 -//#define SD_SCK_PIN EXP2_09_PIN // uses esp32 default 18 -#define SDSS EXP2_07_PIN -#define SD_DETECT_PIN EXP2_04_PIN // IO34 default is SD_DET signal (Jump to SDDET) +//#define SD_MOSI_PIN EXP2_06_PIN // uses esp32 default 23 +//#define SD_MISO_PIN EXP2_01_PIN // uses esp32 default 19 +//#define SD_SCK_PIN EXP2_02_PIN // uses esp32 default 18 +#define SDSS EXP2_04_PIN +#define SD_DETECT_PIN EXP2_07_PIN // IO34 default is SD_DET signal (Jump to SDDET) #define USES_SHARED_SPI // SPI is shared by SD card with TMC SPI drivers #if HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define BTN_ENC EXP1_09_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BEEPER_PIN EXP1_01_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #define LCD_BACKLIGHT_PIN -1 #if ENABLED(MKS_MINI_12864) - // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) - #define DOGLCD_CS EXP1_05_PIN - #define DOGLCD_A0 EXP1_04_PIN + // 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 - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define LCD_RESET_PIN EXP1_06_PIN - #define NEOPIXEL_PIN EXP1_05_PIN + // 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 + #define NEOPIXEL_PIN EXP1_06_PIN #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_06_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #endif #define BOARD_ST7920_DELAY_1 96 #define BOARD_ST7920_DELAY_2 48 diff --git a/Marlin/src/pins/esp32/pins_MRR_ESPE.h b/Marlin/src/pins/esp32/pins_MRR_ESPE.h index b59cc7bb39ba..f372de9e0110 100644 --- a/Marlin/src/pins/esp32/pins_MRR_ESPE.h +++ b/Marlin/src/pins/esp32/pins_MRR_ESPE.h @@ -52,11 +52,10 @@ // Enable I2S stepper stream // #define I2S_STEPPER_STREAM -#define I2S_WS 26 -#define I2S_BCK 25 -#define I2S_DATA 27 -#if ENABLED(LIN_ADVANCE) - #error "I2S stream is currently incompatible with LIN_ADVANCE." +#if ENABLED(I2S_STEPPER_STREAM) + #define I2S_WS 26 + #define I2S_BCK 25 + #define I2S_DATA 27 #endif // diff --git a/Marlin/src/pins/esp32/pins_PANDA_common.h b/Marlin/src/pins/esp32/pins_PANDA_common.h index 7deeca3f6227..afc9a78aec01 100644 --- a/Marlin/src/pins/esp32/pins_PANDA_common.h +++ b/Marlin/src/pins/esp32/pins_PANDA_common.h @@ -82,47 +82,47 @@ #endif /** ------ ------ - * (MISO 19?) |10 9 | (18 SCK?) (BEEPER) 129 |10 9 | 12 (^ENC) - * (EN1) 33 | 8 7 | (5 SDSS?) (EN) 26 | 8 7 | 27 (RS) - * (EN2) 32 6 5 | (23 MOSI?) (D4) 14 | 6 5 -- - * (SDDET 2?) | 4 3 | (RESET) -- | 4 3 | -- - * -- | 2 1 | -- (GND) | 2 1 | (5V) + * (MISO 19?) | 1 2 | (18 SCK?) (BEEPER) 129 | 1 2 | 12 (^ENC) + * (EN1) 33 | 3 4 | (5 SDSS?) (EN) 26 | 3 4 | 27 (RS) + * (EN2) 32 5 6 | (23 MOSI?) (D4) 14 | 5 6 -- + * (SDDET 2?) | 7 8 | (RESET) -- | 7 8 | -- + * -- | 9 10 | -- (GND) | 9 10 | (5V) * ------ ------ * EXP2 EXP1 */ -#define EXP1_06_PIN 14 -#define EXP1_07_PIN 27 -#define EXP1_08_PIN 26 -#define EXP1_09_PIN 12 -#define EXP1_10_PIN 129 - -#define EXP2_04_PIN 2 // ? -#define EXP2_05_PIN 23 // ? -#define EXP2_06_PIN 32 -#define EXP2_07_PIN 5 // ? -#define EXP2_08_PIN 33 -#define EXP2_09_PIN 18 // ? -#define EXP2_10_PIN 19 // ? +#define EXP1_01_PIN 129 +#define EXP1_02_PIN 12 +#define EXP1_03_PIN 26 +#define EXP1_04_PIN 27 +#define EXP1_05_PIN 14 + +#define EXP2_01_PIN 19 // ? +#define EXP2_02_PIN 18 // ? +#define EXP2_03_PIN 33 +#define EXP2_04_PIN 5 // ? +#define EXP2_05_PIN 32 +#define EXP2_06_PIN 23 // ? +#define EXP2_07_PIN 2 // ? // // SD Card // #if ENABLED(SDSUPPORT) - #define SD_MOSI_PIN EXP2_05_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SDSS EXP2_07_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SDSS EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif #if HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN - #define BTN_ENC EXP1_09_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #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 EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #endif diff --git a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h index 7953f678fa48..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 @@ -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 @@ -582,7 +595,7 @@ #define LCD_SDSS SDSS #define SD_DETECT_PIN 49 - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #define DOGLCD_CS 45 #define DOGLCD_A0 44 diff --git a/Marlin/src/pins/lpc1768/pins_AZSMZ_MINI.h b/Marlin/src/pins/lpc1768/pins_AZSMZ_MINI.h index 4d1dbecf2e8f..657eb8a0466c 100644 --- a/Marlin/src/pins/lpc1768/pins_AZSMZ_MINI.h +++ b/Marlin/src/pins/lpc1768/pins_AZSMZ_MINI.h @@ -23,6 +23,8 @@ /** * AZSMZ MINI pin assignments + * Schematic: http://green-candy.osdn.jp/external/MarlinFW/board_schematics/AZSMZ%20MINI/AZSMZ.svg + * Source: https://raw.githubusercontent.com/Rose-Fish/AZSMZ-mini/master/AZSMZ.sch */ #include "env_validate.h" diff --git a/Marlin/src/pins/lpc1768/pins_BIQU_B300_V1.0.h b/Marlin/src/pins/lpc1768/pins_BIQU_B300_V1.0.h index 10a610ff95f7..217e270b9caa 100644 --- a/Marlin/src/pins/lpc1768/pins_BIQU_B300_V1.0.h +++ b/Marlin/src/pins/lpc1768/pins_BIQU_B300_V1.0.h @@ -22,11 +22,7 @@ #pragma once /** - * BIQU BQ111-A4 - * - * Applies to the following boards: - * - * BOARD_BIQU_BQ111_A4 (Hotend, Fan, Bed) + * BIQU Thunder B300 V1.0 */ #include "env_validate.h" diff --git a/Marlin/src/pins/lpc1768/pins_BIQU_BQ111_A4.h b/Marlin/src/pins/lpc1768/pins_BIQU_BQ111_A4.h index 92152170a013..2c0d52ef9a10 100644 --- a/Marlin/src/pins/lpc1768/pins_BIQU_BQ111_A4.h +++ b/Marlin/src/pins/lpc1768/pins_BIQU_BQ111_A4.h @@ -23,6 +23,10 @@ /** * BIQU BQ111-A4 pin assignments + * + * Applies to the following boards: + * + * BOARD_BIQU_BQ111_A4 (Hotend, Fan, Bed) */ #include "env_validate.h" diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h index f0f57c63eedc..879e98243cef 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h @@ -23,6 +23,8 @@ /** * BigTreeTech SKR 1.1 pin assignments + * Schematic: http://green-candy.osdn.jp/external/MarlinFW/board_schematics/BTT%20SKR%20V1.1/SKR-V1.1SchDoc.pdf + * Origin: https://github.com/bigtreetech/BIGTREETECH-SKR-V1.1/blob/master/hardware/SKR-V1.1SchDoc.pdf */ #define BOARD_INFO_NAME "BTT SKR V1.1" @@ -58,31 +60,31 @@ /** ------ ------ - * 1.30 |10 9 | 2.11 0.17 |10 9 | 0.15 - * 0.18 | 8 7 | 0.16 3.26 | 8 7 | 1.23 - * 0.15 6 5 | -- 3.25 6 5 | 0.18 - * -- | 4 3 | -- 1.31 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * 1.30 | 1 2 | 2.11 0.17 | 1 2 | 0.15 + * 0.18 | 3 4 | 0.16 3.26 | 3 4 | 1.23 + * 0.15 5 6 | -- 3.25 5 6 | 0.18 + * -- | 7 8 | -- 1.31 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN -1 // NC -#define EXP1_04_PIN -1 // NC -#define EXP1_05_PIN -1 // NC -#define EXP1_06_PIN P0_15 -#define EXP1_07_PIN P0_16 -#define EXP1_08_PIN P0_18 -#define EXP1_09_PIN P2_11 -#define EXP1_10_PIN P1_30 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN P1_31 -#define EXP2_05_PIN P0_18 -#define EXP2_06_PIN P3_25 -#define EXP2_07_PIN P1_23 -#define EXP2_08_PIN P3_26 -#define EXP2_09_PIN P0_15 -#define EXP2_10_PIN P0_17 +#define EXP1_01_PIN P1_30 +#define EXP1_02_PIN P2_11 +#define EXP1_03_PIN P0_18 +#define EXP1_04_PIN P0_16 +#define EXP1_05_PIN P0_15 +#define EXP1_06_PIN -1 // NC +#define EXP1_07_PIN -1 // NC +#define EXP1_08_PIN -1 // NC + +#define EXP2_01_PIN P0_17 +#define EXP2_02_PIN P0_15 +#define EXP2_03_PIN P3_26 +#define EXP2_04_PIN P1_23 +#define EXP2_05_PIN P3_25 +#define EXP2_06_PIN P0_18 +#define EXP2_07_PIN P1_31 +#define EXP2_08_PIN -1 // RESET /** * LCD / Controller @@ -100,23 +102,23 @@ #if IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif #elif HAS_WIRED_LCD - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN - #define LCD_SDSS EXP2_07_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP2_05_PIN - #define LCD_PINS_D4 EXP2_09_PIN + #define LCD_SDSS EXP2_04_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP2_06_PIN + #define LCD_PINS_D4 EXP2_02_PIN #if ENABLED(MKS_MINI_12864) #define DOGLCD_CS P2_06 - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_A0 EXP1_04_PIN #endif #endif // HAS_WIRED_LCD @@ -165,10 +167,10 @@ // When using any TMC SPI-based drivers, software SPI is used // because pins may be shared with the display or SD card. #define TMC_USE_SW_SPI - #define TMC_SW_MOSI EXP2_05_PIN - #define TMC_SW_MISO EXP2_10_PIN + #define TMC_SW_MOSI EXP2_06_PIN + #define TMC_SW_MISO EXP2_01_PIN // To minimize pin usage use the same clock pin as the display/SD card reader. (May generate LCD noise.) - #define TMC_SW_SCK EXP2_09_PIN + #define TMC_SW_SCK EXP2_02_PIN // If pin 2_06 is unused, it can be used for the clock to avoid the LCD noise. //#define TMC_SW_SCK P2_06 @@ -211,11 +213,11 @@ // SDCARD_CONNECTION must not be 'LCD'. Nothing should be connected to EXP1/EXP2. //#define SKR_USE_LCD_PINS_FOR_CS #if ENABLED(SKR_USE_LCD_PINS_FOR_CS) - #define X_CS_PIN EXP2_07_PIN - #define Y_CS_PIN EXP2_08_PIN - #define Z_CS_PIN EXP1_09_PIN - #define E0_CS_PIN EXP2_06_PIN - #define E1_CS_PIN EXP2_04_PIN + #define X_CS_PIN EXP2_04_PIN + #define Y_CS_PIN EXP2_03_PIN + #define Z_CS_PIN EXP1_02_PIN + #define E0_CS_PIN EXP2_05_PIN + #define E1_CS_PIN EXP2_07_PIN #endif // Example 2: A REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER @@ -228,11 +230,11 @@ #define Z_CS_PIN P2_06 // We use SD_DETECT_PIN for E0 #undef SD_DETECT_PIN - #define E0_CS_PIN EXP2_04_PIN + #define E0_CS_PIN EXP2_07_PIN // We use LCD_SDSS pin for E1 #undef LCD_SDSS #define LCD_SDSS -1 - #define E1_CS_PIN EXP2_07_PIN + #define E1_CS_PIN EXP2_04_PIN #endif // Example 3: Use the driver enable pins for chip-select. 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 4ab5b109372f..6653a94f8059 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -23,6 +23,8 @@ /** * BigTreeTech SKR 1.3 pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/BTT%20SKR%20V1.3/SKR-V1.3-SCH.pdf + * Origin: https://github.com/bigtreetech/BIGTREETECH-SKR-V1.3/blob/master/BTT%20SKR%20V1.3/hardware/SKR-V1.3-SCH.pdf */ #define BOARD_INFO_NAME "BTT SKR V1.3" @@ -191,31 +193,31 @@ /** * ------ ------ - * (BEEPER) 1.30 |10 9 | 0.28 (BTN_ENC) (MISO) 0.17 |10 9 | 0.15 (SCK) - * (LCD_EN) 1.18 | 8 7 | 1.19 (LCD_RS) (BTN_EN1) 3.26 | 8 7 | 0.16 (SD_SS) - * (LCD_D4) 1.20 6 5 | 1.21 (LCD_D5) (BTN_EN2) 3.25 6 5 | 0.18 (MOSI) - * (LCD_D6) 1.22 | 4 3 | 1.23 (LCD_D7) (SD_DETECT) 1.31 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) 1.30 | 1 2 | 0.28 (BTN_ENC) (MISO) 0.17 | 1 2 | 0.15 (SCK) + * (LCD_EN) 1.18 | 3 4 | 1.19 (LCD_RS) (BTN_EN1) 3.26 | 3 4 | 0.16 (SD_SS) + * (LCD_D4) 1.20 5 6 | 1.21 (LCD_D5) (BTN_EN2) 3.25 5 6 | 0.18 (MOSI) + * (LCD_D6) 1.22 | 7 8 | 1.23 (LCD_D7) (SD_DETECT) 1.31 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN P1_23 -#define EXP1_04_PIN P1_22 -#define EXP1_05_PIN P1_21 -#define EXP1_06_PIN P1_20 -#define EXP1_07_PIN P1_19 -#define EXP1_08_PIN P1_18 -#define EXP1_09_PIN P0_28 -#define EXP1_10_PIN P1_30 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN P1_31 -#define EXP2_05_PIN P0_18 -#define EXP2_06_PIN P3_25 -#define EXP2_07_PIN P0_16 -#define EXP2_08_PIN P3_26 -#define EXP2_09_PIN P0_15 -#define EXP2_10_PIN P0_17 +#define EXP1_01_PIN P1_30 +#define EXP1_02_PIN P0_28 +#define EXP1_03_PIN P1_18 +#define EXP1_04_PIN P1_19 +#define EXP1_05_PIN P1_20 +#define EXP1_06_PIN P1_21 +#define EXP1_07_PIN P1_22 +#define EXP1_08_PIN P1_23 + +#define EXP2_01_PIN P0_17 +#define EXP2_02_PIN P0_15 +#define EXP2_03_PIN P3_26 +#define EXP2_04_PIN P0_16 +#define EXP2_05_PIN P3_25 +#define EXP2_06_PIN P0_18 +#define EXP2_07_PIN P1_31 +#define EXP2_08_PIN -1 #if HAS_WIRED_LCD #if ENABLED(ANET_FULL_GRAPHICS_LCD_ALT_WIRING) @@ -239,23 +241,23 @@ * * BEFORE AFTER * ------ ------ - * (CLK) |10 9 | (BEEPER) (BEEPER) |10 9 | -- - * -- | 8 7 | (BTN_ENC) (BTN_ENC) | 8 7 | (CLK) - * (SID) 6 5 | (BTN_EN1) (BTN_EN1) 6 5 | (SID) - * (CS) | 4 3 | (BTN_EN2) (BTN_EN2) | 4 3 | (CS) - * GND | 2 1 | 5V GND | 2 1 | 5V + * (CLK) | 1 2 | (BEEPER) (BEEPER) |10 9 | -- + * -- | 3 4 | (BTN_ENC) (BTN_ENC) | 8 7 | (CLK) + * (SID) 5 6 | (BTN_EN1) (BTN_EN1) 6 5 | (SID) + * (CS) | 7 8 | (BTN_EN2) (BTN_EN2) | 4 3 | (CS) + * GND | 9 10 | 5V GND | 2 1 | 5V * ------ ------ * LCD LCD */ - #define LCD_PINS_RS EXP1_03_PIN + #define LCD_PINS_RS EXP1_08_PIN - #define BTN_EN1 EXP1_06_PIN - #define BTN_EN2 EXP1_04_PIN - #define BTN_ENC EXP1_08_PIN + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_03_PIN - #define LCD_PINS_ENABLE EXP1_05_PIN - #define LCD_PINS_D4 EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_06_PIN + #define LCD_PINS_D4 EXP1_04_PIN #elif ENABLED(WYH_L12864) @@ -274,33 +276,33 @@ * * BEFORE AFTER * ______ ______ - * |10 9 | (MOSI) (MOSI) |10 9 | -- - * (BTN_ENC) | 8 7 | (SCK) (BTN_ENC) | 8 7 | (SCK) - * (BTN_EN1) 6 5 | (SID) (BTN_EN1) 6 5 | (SID) - * (BTN_EN2) | 4 3 | (CS) (BTN_EN2) | 4 3 | (CS) - * 5V | 2 1 | GND GND | 2 1 | 5V + * | 1 2 | (MOSI) (MOSI) |10 9 | -- + * (BTN_ENC) | 3 4 | (SCK) (BTN_ENC) | 8 7 | (SCK) + * (BTN_EN1) 5 6 | (SID) (BTN_EN1) 6 5 | (SID) + * (BTN_EN2) | 7 8 | (CS) (BTN_EN2) | 4 3 | (CS) + * 5V | 9 10 | GND GND | 2 1 | 5V * ------ ------ * LCD LCD */ - #define BTN_EN1 EXP1_06_PIN - #define BTN_EN2 EXP1_04_PIN - #define BTN_ENC EXP1_08_PIN - #define DOGLCD_CS EXP1_03_PIN - #define DOGLCD_A0 EXP1_05_PIN - #define DOGLCD_SCK EXP1_07_PIN - #define DOGLCD_MOSI EXP1_10_PIN + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_03_PIN + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_04_PIN + #define DOGLCD_MOSI EXP1_01_PIN #define LCD_BACKLIGHT_PIN -1 #elif ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_09_PIN // (58) open-drain + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN // (58) open-drain - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif HAS_ADC_BUTTONS @@ -308,20 +310,23 @@ #elif HAS_SPI_TFT // Config for Classic UI (emulated DOGM) and Color UI - #define TFT_A0_PIN EXP1_03_PIN - #define TFT_DC_PIN EXP1_03_PIN - #define TFT_CS_PIN EXP1_04_PIN - #define TFT_RESET_PIN EXP1_07_PIN - #define TFT_BACKLIGHT_PIN EXP1_08_PIN + #define TFT_A0_PIN EXP1_08_PIN + #define TFT_DC_PIN EXP1_08_PIN + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_RESET_PIN EXP1_04_PIN + #define TFT_BACKLIGHT_PIN EXP1_03_PIN + + //#define TFT_RST_PIN EXP2_07_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN - //#define TFT_RST_PIN EXP2_04_PIN - #define TFT_MOSI_PIN EXP2_05_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_ENC EXP1_02_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define SDCARD_CONNECTION ONBOARD #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 @@ -369,90 +374,91 @@ #elif IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #else // !CR10_STOCKDISPLAY - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN // (31) J3-2 & AUX-4 - #define BTN_EN2 EXP2_06_PIN // (33) J3-4 & AUX-4 - #define BTN_ENC EXP1_09_PIN // (58) open-drain + #define BTN_EN1 EXP2_03_PIN // (31) J3-2 & AUX-4 + #define BTN_EN2 EXP2_05_PIN // (33) J3-4 & AUX-4 + #define BTN_ENC EXP1_02_PIN // (58) open-drain - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN - #define LCD_SDSS EXP2_07_PIN // (16) J3-7 & AUX-4 - #define SD_DETECT_PIN EXP2_04_PIN // (49) (NOT 5V tolerant) + #define LCD_SDSS EXP2_04_PIN // (16) J3-7 & AUX-4 + #define SD_DETECT_PIN EXP2_07_PIN // (49) (NOT 5V tolerant) #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN #define LCD_BACKLIGHT_PIN -1 #define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems // results in LCD soft SPI mode 3, SD soft SPI mode 0 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #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_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #else // !FYSETC_MINI_12864 #if ENABLED(MKS_MINI_12864) - #define DOGLCD_CS EXP1_05_PIN - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_CS EXP1_06_PIN + #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) /** * Creality Ender-2 display pinout * ------ - * (SCK) P1_30 |10 9 | P0_28 (BTN_ENC) - * (BTN_EN1) P1_18 | 8 7 | P1_19 (RESET) - * (BTN_EN2) P1_20 6 5 | P1_21 (LCD_A0) - * (LCD_CS) P1_22 | 4 3 | P1_23 (MOSI) - * GND | 2 1 | 5V + * (SCK) P1_30 | 1 2 | P0_28 (BTN_ENC) + * (BTN_EN1) P1_18 | 3 4 | P1_19 (RESET) + * (BTN_EN2) P1_20 5 6 | P1_21 (LCD_A0) + * (LCD_CS) P1_22 | 7 8 | P1_23 (MOSI) + * GND | 9 10 | 5V * ------ * EXP1 */ - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_09_PIN - #define DOGLCD_CS EXP1_04_PIN - #define DOGLCD_A0 EXP1_05_PIN - #define DOGLCD_SCK EXP1_10_PIN - #define DOGLCD_MOSI EXP1_03_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_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 #endif #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #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 @@ -467,11 +473,11 @@ #endif // HAS_WIRED_LCD #if NEED_TOUCH_PINS - #define TOUCH_CS_PIN EXP1_06_PIN - #define TOUCH_SCK_PIN EXP2_09_PIN - #define TOUCH_MOSI_PIN EXP2_05_PIN - #define TOUCH_MISO_PIN EXP2_10_PIN - #define TOUCH_INT_PIN EXP1_05_PIN + #define TOUCH_CS_PIN EXP1_05_PIN + #define TOUCH_SCK_PIN EXP2_02_PIN + #define TOUCH_MOSI_PIN EXP2_06_PIN + #define TOUCH_MISO_PIN EXP2_01_PIN + #define TOUCH_INT_PIN EXP1_06_PIN #endif /** 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 b50e8e578006..667b0fa949c3 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -23,6 +23,8 @@ /** * BigTreeTech SKR 1.4 pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/BTT%20SKR%20V1.4%20+%20Turbo/BTT%20SKR%20V1.4-SCH.pdf + * Origin: https://github.com/bigtreetech/BIGTREETECH-SKR-V1.3/blob/master/BTT%20SKR%20V1.4/Hardware/BTT%20SKR%20V1.4-SCH.pdf */ #include "env_validate.h" @@ -43,6 +45,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) @@ -246,41 +249,41 @@ #endif /** ------ ------ - * 1.30 |10 9 | 0.28 0.17 |10 9 | 0.15 - * 1.18 | 8 7 | 1.19 3.26 | 8 7 | 0.16 - * 1.20 6 5 | 1.21 3.25 6 5 | 0.18 - * 1.22 | 4 3 | 1.23 1.31 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * 1.30 | 1 2 | 0.28 0.17 | 1 2 | 0.15 + * 1.18 | 3 4 | 1.19 3.26 | 3 4 | 0.16 + * 1.20 5 6 | 1.21 3.25 5 6 | 0.18 + * 1.22 | 7 8 | 1.23 1.31 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN P1_23 -#define EXP1_04_PIN P1_22 -#define EXP1_05_PIN P1_21 -#define EXP1_06_PIN P1_20 -#define EXP1_07_PIN P1_19 -#define EXP1_08_PIN P1_18 -#define EXP1_09_PIN P0_28 -#define EXP1_10_PIN P1_30 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN P1_31 -#define EXP2_05_PIN P0_18 -#define EXP2_06_PIN P3_25 -#define EXP2_07_PIN P0_16 -#define EXP2_08_PIN P3_26 -#define EXP2_09_PIN P0_15 -#define EXP2_10_PIN P0_17 +#define EXP1_01_PIN P1_30 +#define EXP1_02_PIN P0_28 +#define EXP1_03_PIN P1_18 +#define EXP1_04_PIN P1_19 +#define EXP1_05_PIN P1_20 +#define EXP1_06_PIN P1_21 +#define EXP1_07_PIN P1_22 +#define EXP1_08_PIN P1_23 + +#define EXP2_01_PIN P0_17 +#define EXP2_02_PIN P0_15 +#define EXP2_03_PIN P3_26 +#define EXP2_04_PIN P0_16 +#define EXP2_05_PIN P3_25 +#define EXP2_06_PIN P0_18 +#define EXP2_07_PIN P1_31 +#define EXP2_08_PIN -1 // RESET #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI // RET6 DWIN ENCODER LCD - #define BTN_ENC EXP1_06_PIN - #define BTN_EN1 EXP1_03_PIN - #define BTN_EN2 EXP1_04_PIN + #define BTN_ENC EXP1_05_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN #ifndef BEEPER_PIN - #define BEEPER_PIN EXP1_05_PIN + #define BEEPER_PIN EXP1_06_PIN #endif #elif HAS_WIRED_LCD @@ -300,24 +303,24 @@ * * BEFORE AFTER * ------ ------ - * (BEEPER) | 10 9 | (CLK) (BEEPER) | 10 9 | (CLK) - * (BTN_ENC) | 8 7 | -- (BTN_ENC) | 8 7 | -- - * (BTN_EN1) 6 5 | (SID) (BTN_EN1) 6 5 | (SID) - * (BTN_EN2) | 4 3 | (CS) (BTN_EN2) | 4 3 | (CS) - * 5V | 2 1 | GND GND | 2 1 | 5V + * (BEEPER) | 1 2 | (CLK) (BEEPER) |10 9 | (CLK) + * (BTN_ENC) | 3 4 | -- (BTN_ENC) | 8 7 | -- + * (BTN_EN1) 5 6 | (SID) (BTN_EN1) 6 5 | (SID) + * (BTN_EN2) | 7 8 | (CS) (BTN_EN2) | 4 3 | (CS) + * 5V | 9 10 | GND GND | 2 1 | 5V * ------ ------ * LCD LCD */ - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP1_05_PIN - #define BTN_EN2 EXP1_04_PIN - #define BTN_ENC EXP1_10_PIN + #define BTN_EN1 EXP1_06_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_01_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define BEEPER_PIN EXP1_03_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define BEEPER_PIN EXP1_08_PIN #elif ENABLED(ANET_FULL_GRAPHICS_LCD) #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING @@ -336,147 +339,147 @@ * * BEFORE AFTER * ------ ------ - * (BEEPER) |10 9 | (CLK) (BEEPER) |10 9 | -- - * (BTN_ENC) | 8 7 | -- (BTN_ENC) | 8 7 | (CLK) - * (BTN_EN1) 6 5 | (SID) (BTN_EN1) 6 5 | (SID) - * (BTN_EN2) | 4 3 | (CS) (BTN_EN2) | 4 3 | (CS) - * 5V | 2 1 | GND GND | 2 1 | 5V + * (BEEPER) | 1 2 | (CLK) (BEEPER) |10 9 | -- + * (BTN_ENC) | 3 4 | -- (BTN_ENC) | 8 7 | (CLK) + * (BTN_EN1) 5 6 | (SID) (BTN_EN1) 6 5 | (SID) + * (BTN_EN2) | 7 8 | (CS) (BTN_EN2) | 4 3 | (CS) + * 5V | 9 10 | GND GND | 2 1 | 5V * ------ ------ * LCD LCD */ - #define LCD_PINS_RS EXP1_03_PIN + #define LCD_PINS_RS EXP1_08_PIN - #define BTN_EN1 EXP1_06_PIN - #define BTN_EN2 EXP1_04_PIN - #define BTN_ENC EXP1_08_PIN + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_03_PIN - #define LCD_PINS_ENABLE EXP1_05_PIN - #define LCD_PINS_D4 EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_06_PIN + #define LCD_PINS_D4 EXP1_04_PIN - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #elif ENABLED(CR10_STOCKDISPLAY) - #define BTN_ENC EXP1_09_PIN // (58) open-drain - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif ENABLED(ENDER2_STOCKDISPLAY) /** Creality Ender-2 display pinout * ------ - * (SCK) 1.30 |10 9 | 0.28 (BTN_ENC) - * (BTN_EN1) 1.18 | 8 7 | 1.19 (RESET) - * (BTN_EN2) 1.20 6 5 | 1.21 (LCD_A0) - * (LCD_RS) 1.22 | 4 3 | 1.23 (MOSI) - * GND | 2 1 | 5V + * (SCK) 1.30 | 1 2 | 0.28 (BTN_ENC) + * (BTN_EN1) 1.18 | 3 4 | 1.19 (RESET) + * (BTN_EN2) 1.20 5 6 | 1.21 (LCD_A0) + * (LCD_RS) 1.22 | 7 8 | 1.23 (MOSI) + * GND | 9 10 | 5V * ------ * EXP1 */ - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN - #define DOGLCD_CS EXP1_04_PIN - #define DOGLCD_A0 EXP1_05_PIN - #define DOGLCD_SCK EXP1_10_PIN - #define DOGLCD_MOSI EXP1_03_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 HAS_SPI_TFT // Config for Classic UI (emulated DOGM) and Color UI - #define TFT_CS_PIN EXP1_04_PIN - #define TFT_A0_PIN EXP1_03_PIN - #define TFT_DC_PIN EXP1_03_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_BACKLIGHT_PIN EXP1_08_PIN - #define TFT_RESET_PIN EXP1_07_PIN + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_A0_PIN EXP1_08_PIN + #define TFT_DC_PIN EXP1_08_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_BACKLIGHT_PIN EXP1_03_PIN + #define TFT_RESET_PIN EXP1_04_PIN #define LCD_USE_DMA_SPI - #define TOUCH_INT_PIN EXP1_05_PIN - #define TOUCH_CS_PIN EXP1_06_PIN + #define TOUCH_INT_PIN EXP1_06_PIN + #define TOUCH_CS_PIN EXP1_05_PIN #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 // SPI 1 - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN #define TFT_BUFFER_SIZE 2400 #elif IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #else - #define BTN_ENC EXP1_09_PIN // (58) open-drain - #define LCD_PINS_RS EXP1_07_PIN + #define BTN_ENC EXP1_02_PIN // (58) open-drain + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN // (31) J3-2 & AUX-4 - #define BTN_EN2 EXP2_06_PIN // (33) J3-4 & AUX-4 + #define BTN_EN1 EXP2_03_PIN // (31) J3-2 & AUX-4 + #define BTN_EN2 EXP2_05_PIN // (33) J3-4 & AUX-4 - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN - #define LCD_SDSS EXP2_07_PIN // (16) J3-7 & AUX-4 + #define LCD_SDSS EXP2_04_PIN // (16) J3-7 & AUX-4 #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN #define LCD_BACKLIGHT_PIN -1 #define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems // results in LCD soft SPI mode 3, SD soft SPI mode 0 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #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_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #else // !FYSETC_MINI_12864 #if ENABLED(MKS_MINI_12864) - #define DOGLCD_CS EXP1_05_PIN - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN #define FORCE_SOFT_SPI #endif #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #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 EXP1_03_PIN // Detect the presence of the encoder + #define BTN_ENC_EN EXP1_08_PIN // Detect the presence of the encoder #endif #endif diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h index 37d0cb7fb1e0..ec74cc640e85 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h @@ -134,8 +134,8 @@ #define SD_SCK_PIN P0_15 #define SD_MISO_PIN P0_17 #define SD_MOSI_PIN P0_18 - #define SD_SS_PIN EXP2_07_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_SS_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #elif SD_CONNECTION_IS(ONBOARD) #undef SD_DETECT_PIN @@ -152,11 +152,11 @@ #if ENABLED(BTT_MOTOR_EXPANSION) /** * ------ ------ - * (M3STP) |10 9 | (M3DIR) (M3DIAG) |10 9 | (M3RX) - * (M2STP) | 8 7 | (M2DIR) (M2DIAG) | 8 7 | (M2RX) - * (M1DIR) 6 5 | (M1STP) (M1DIAG) 6 5 | (M1RX) - * (M1EN) | 4 3 | -- (M3EN) | 4 3 | (M2EN) - * GND | 2 1 | -- GND | 2 1 | -- + * (M3STP) | 1 2 | (M3DIR) (M3DIAG) | 1 2 | (M3RX) + * (M2STP) | 3 4 | (M2DIR) (M2DIAG) | 3 4 | (M2RX) + * (M1DIR) 5 6 | (M1STP) (M1DIAG) 5 6 | (M1RX) + * (M1EN) | 7 8 | -- (M3EN) | 7 8 | (M2EN) + * GND | 9 10 | -- GND | 9 10 | -- * ------ ------ * EXP2 EXP1 * @@ -164,46 +164,46 @@ */ // M1 on Driver Expansion Module - #define E2_STEP_PIN EXP2_05_PIN - #define E2_DIR_PIN EXP2_06_PIN - #define E2_ENABLE_PIN EXP2_04_PIN + #define E2_STEP_PIN EXP2_06_PIN + #define E2_DIR_PIN EXP2_05_PIN + #define E2_ENABLE_PIN EXP2_07_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E2_DIAG_PIN EXP1_06_PIN - #define E2_CS_PIN EXP1_05_PIN + #define E2_DIAG_PIN EXP1_05_PIN + #define E2_CS_PIN EXP1_06_PIN #if HAS_TMC_UART - #define E2_SERIAL_TX_PIN EXP1_05_PIN + #define E2_SERIAL_TX_PIN EXP1_06_PIN #define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN #endif #endif // M2 on Driver Expansion Module - #define E3_STEP_PIN EXP2_08_PIN - #define E3_DIR_PIN EXP2_07_PIN + #define E3_STEP_PIN EXP2_03_PIN + #define E3_DIR_PIN EXP2_04_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E3_ENABLE_PIN EXP1_03_PIN - #define E3_DIAG_PIN EXP1_08_PIN - #define E3_CS_PIN EXP1_07_PIN + #define E3_ENABLE_PIN EXP1_08_PIN + #define E3_DIAG_PIN EXP1_03_PIN + #define E3_CS_PIN EXP1_04_PIN #if HAS_TMC_UART - #define E3_SERIAL_TX_PIN EXP1_07_PIN + #define E3_SERIAL_TX_PIN EXP1_04_PIN #define E3_SERIAL_RX_PIN E3_SERIAL_TX_PIN #endif #else - #define E3_ENABLE_PIN EXP2_04_PIN + #define E3_ENABLE_PIN EXP2_07_PIN #endif // M3 on Driver Expansion Module - #define E4_STEP_PIN EXP2_10_PIN - #define E4_DIR_PIN EXP2_09_PIN + #define E4_STEP_PIN EXP2_01_PIN + #define E4_DIR_PIN EXP2_02_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E4_ENABLE_PIN EXP1_04_PIN - #define E4_DIAG_PIN EXP1_10_PIN - #define E4_CS_PIN EXP1_09_PIN + #define E4_ENABLE_PIN EXP1_07_PIN + #define E4_DIAG_PIN EXP1_01_PIN + #define E4_CS_PIN EXP1_02_PIN #if HAS_TMC_UART - #define E4_SERIAL_TX_PIN EXP1_09_PIN + #define E4_SERIAL_TX_PIN EXP1_02_PIN #define E4_SERIAL_RX_PIN E4_SERIAL_TX_PIN #endif #else - #define E4_ENABLE_PIN EXP2_04_PIN + #define E4_ENABLE_PIN EXP2_07_PIN #endif #endif // BTT_MOTOR_EXPANSION diff --git a/Marlin/src/pins/lpc1768/pins_EMOTRONIC.h b/Marlin/src/pins/lpc1768/pins_EMOTRONIC.h new file mode 100644 index 000000000000..9e62be8edb57 --- /dev/null +++ b/Marlin/src/pins/lpc1768/pins_EMOTRONIC.h @@ -0,0 +1,151 @@ +/** + * 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 + +/** + * eMotion-Tech eMotronic pin assignments + * Schematic: http://green-candy.osdn.jp/external/MarlinFW/board_schematics/eMotion-Tech%20eMotronic/eMotronic_brd_sources_1.0.4/eMotronic_sch.pdf + * Origin: https://data.emotion-tech.com/ftp/Datasheets_et_sources/Sources/eMotronic_brd_sources_1.0.4.zip + * + * Board pins<->features assignments are based on the + * Micro-Delta Rework printer default connections. + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "eMotronic" +#define BOARD_WEBSITE_URL "www.reprap-france.com/article/lemotronic-quesaco" + +// +// Limit Switches +// +#define X_STOP_PIN P1_22 // S0 +#define Y_STOP_PIN P1_23 // S1 +#define Z_STOP_PIN P1_24 // S2 +#define I_STOP_PIN P1_25 // S3 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN P0_26 // S4 (opto) +#endif + +// +// Steppers +// +#define X_STEP_PIN P2_02 // M3 +#define X_DIR_PIN P4_28 +#define X_ENABLE_PIN P4_29 + +#define Y_STEP_PIN P2_01 // M2 +#define Y_DIR_PIN P0_22 +#define Y_ENABLE_PIN P0_21 + +#define Z_STEP_PIN P2_00 // M1 +#define Z_DIR_PIN P3_26 +#define Z_ENABLE_PIN P3_25 + +#define E0_STEP_PIN P2_03 // M4 +#define E0_DIR_PIN P0_04 +#define E0_ENABLE_PIN P0_05 // Correct! + +#define E1_STEP_PIN P2_08 // M5 +#define E1_DIR_PIN P0_20 +#define E1_ENABLE_PIN P0_19 + +// +// Temperature Sensors +// 3.3V max when defined as an analog input +// +#define TEMP_0_PIN P0_24_A1 // A1 (TH1) +#define TEMP_1_PIN P0_23_A0 // A0 (TH0) +#define TEMP_BED_PIN P0_25_A2 // A2 (TH2) + +// +// Heaters / Fans +// +#define _H0_PIN P2_04 // (H0: 15A) + +#define HEATER_BED_PIN P2_05 // (H1: 10A shared) +#define HEATER_0_PIN P2_06 // (H2: 10A shared) +#define HEATER_1_PIN P2_07 // (H3: 10A shared) + +#define FAN_PIN P2_11 // (FAN0: 1A) +#define FAN1_PIN P2_13 // (FAN1: 1A) + +// +// Extension ports +// +#define EXP1_01_PIN P0_03 // RX0 +#define EXP1_02_PIN P0_02 // TX0 +#define EXP1_03_PIN P1_30 +#define EXP1_04_PIN P1_31 +#define EXP1_05_PIN P0_17 // MISO0 +#define EXP1_06_PIN P0_18 // MOSI0 +#define EXP1_07_PIN P0_15 // SCK0 +#define EXP1_08_PIN P0_16 // SSEL0 +#define EXP1_09_PIN P0_27 // SDA0 +#define EXP1_10_PIN P0_28 // SCL0 + +#define EXP2_01_PIN P0_10 +#define EXP2_02_PIN P0_11 +#define EXP2_03_PIN P0_00 // SDA1 +#define EXP2_04_PIN P0_01 // SCL1 +#define EXP2_05_PIN P1_28 +#define EXP2_06_PIN P1_29 +#define EXP2_07_PIN P1_26 +#define EXP2_08_PIN P1_27 + +// +// SD Support +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SD_SCK_PIN P0_07 + #define SD_MISO_PIN P0_08 + #define SD_MOSI_PIN P0_09 + #define SD_SS_PIN P0_06 +#elif SD_CONNECTION_IS(LCD) + #define SD_SCK_PIN EXP1_07_PIN + #define SD_MISO_PIN EXP1_05_PIN + #define SD_MOSI_PIN EXP1_06_PIN + #define SD_SS_PIN EXP1_08_PIN + #define SD_DETECT_PIN EXP1_04_PIN +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#endif + +// +// LCD / Controller +// +#if ENABLED(EMOTION_TECH_LCD) + #define BEEPER_PIN EXP2_01_PIN + #define DOGLCD_A0 EXP2_06_PIN + #define DOGLCD_CS EXP2_04_PIN + #define DOGLCD_SCK EXP1_07_PIN + #define DOGLCD_MOSI EXP1_06_PIN + + #define BTN_EN1 EXP2_07_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP2_02_PIN +#endif diff --git a/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h b/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h index 39ab0bbd8968..aedbd7be606e 100644 --- a/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h +++ b/Marlin/src/pins/lpc1768/pins_GMARSH_X6_REV1.h @@ -23,6 +23,8 @@ /** * GMARSH X6 Rev.1 pin assignments + * Schematic: http://green-candy.osdn.jp/external/MarlinFW/board_schematics/GMARSH%20X6%20Rev.1/armprinter_2208_1heater.pdf + * Origin: https://github.com/gmarsh/gmarsh_x6/blob/master/armprinter_2208_1heater.pdf */ #include "env_validate.h" diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h index 7f9e530f3c72..1c300cbcdb0f 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h @@ -23,6 +23,8 @@ /** * Makerbase MKS SBASE pin assignments + * Schematic (V1.3): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/MKS%20SBASE%20V1.3/MKS%20SBASE%20V1.3_002%20SCH.pdf + * Origin (V1.3): http://green-candy.osdn.jp/external/MarlinFW/board_schematics/MKS%20SBASE%20V1.3/MKS%20SBASE%20V1.3_002%20SCH.pdf */ #include "env_validate.h" @@ -184,7 +186,7 @@ #define SD_MISO_PIN P1_23 // J8-3 (moved from EXP2 P0.8) #define SD_MOSI_PIN P2_12 // J8-4 (moved from EXP2 P0.9) #define SD_SS_PIN P0_28 - #define LPC_SOFTWARE_SPI // With a custom cable we need software SPI because the + #define SOFTWARE_SPI // With a custom cable we need software SPI because the // selected pins are not on a hardware SPI controller #elif SD_CONNECTION_IS(LCD) || SD_CONNECTION_IS(ONBOARD) #define SD_SCK_PIN P0_07 @@ -238,7 +240,7 @@ #define LCD_SDSS P0_28 // EXP2.4 #define LCD_PINS_ENABLE P0_18 // EXP1.3 #define LCD_PINS_D4 P0_15 // EXP1.5 - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define DOGLCD_SCK SD_SCK_PIN #define DOGLCD_MOSI SD_MOSI_PIN #endif diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h index 95bbe17b9b38..cdbc6d154fce 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h @@ -23,6 +23,8 @@ /** * Makerbase MKS SGEN-L pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/MKS_GEN_L_V1_0/MKS%20Gen_L%20V1.0_008%20SCH.pdf + * Origin: https://github.com/makerbase-mks/SGEN_L/blob/master/Hardware/MKS%20SGEN_L%20V1.0_001/MKS%20SGEN_L%20V1.0_001%20SCH.pdf */ #include "env_validate.h" @@ -231,46 +233,46 @@ #define LED4_PIN P1_21 /** ------ ------ - * (BEEPER) 1.31 |10 9 | 1.30 (BTN_ENC) (MISO) 0.8 |10 9 | 0.7 (SD_SCK) - * (LCD_EN) 0.18 | 8 7 | 0.16 (LCD_RS) (BTN_EN1) 3.25 | 8 7 | 0.28 (SD_CS2) - * (LCD_D4) 0.15 6 5 | 0.17 (LCD_D5) (BTN_EN2) 3.26 6 5 | 0.9 (SD_MOSI) - * (LCD_D6) 1.0 | 4 3 | 1.22 (LCD_D7) (SD_DETECT) 0.27 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) 1.31 | 1 2 | 1.30 (BTN_ENC) (MISO) 0.8 | 1 2 | 0.7 (SD_SCK) + * (LCD_EN) 0.18 | 3 4 | 0.16 (LCD_RS) (BTN_EN1) 3.25 | 3 4 | 0.28 (SD_CS2) + * (LCD_D4) 0.15 5 6 | 0.17 (LCD_D5) (BTN_EN2) 3.26 5 6 | 0.9 (SD_MOSI) + * (LCD_D6) 1.0 | 7 8 | 1.22 (LCD_D7) (SD_DETECT) 0.27 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN P1_22 -#define EXP1_04_PIN P1_00 -#define EXP1_05_PIN P0_17 -#define EXP1_06_PIN P0_15 -#define EXP1_07_PIN P0_16 -#define EXP1_08_PIN P0_18 -#define EXP1_09_PIN P1_30 -#define EXP1_10_PIN P1_31 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN P0_27 -#define EXP2_05_PIN P0_09 -#define EXP2_06_PIN P3_26 -#define EXP2_07_PIN P0_28 -#define EXP2_08_PIN P3_25 -#define EXP2_09_PIN P0_07 -#define EXP2_10_PIN P0_08 +#define EXP1_01_PIN P1_31 +#define EXP1_02_PIN P1_30 +#define EXP1_03_PIN P0_18 +#define EXP1_04_PIN P0_16 +#define EXP1_05_PIN P0_15 +#define EXP1_06_PIN P0_17 +#define EXP1_07_PIN P1_00 +#define EXP1_08_PIN P1_22 + +#define EXP2_01_PIN P0_08 +#define EXP2_02_PIN P0_07 +#define EXP2_03_PIN P3_25 +#define EXP2_04_PIN P0_28 +#define EXP2_05_PIN P3_26 +#define EXP2_06_PIN P0_09 +#define EXP2_07_PIN P0_27 +#define EXP2_08_PIN -1 // RESET #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION ONBOARD #endif #if SD_CONNECTION_IS(LCD) || SD_CONNECTION_IS(ONBOARD) - #define SD_DETECT_PIN EXP2_04_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN #if SD_CONNECTION_IS(ONBOARD) #define ONBOARD_SD_CS_PIN P0_06 // Chip select for "System" SD card #define SD_SS_PIN ONBOARD_SD_CS_PIN #else - #define SD_SS_PIN EXP2_07_PIN + #define SD_SS_PIN EXP2_04_PIN #endif #elif SD_CONNECTION_IS(CUSTOM_CABLE) #error "No custom SD drive cable defined for this board." @@ -278,30 +280,30 @@ #if HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif HAS_SPI_TFT // Config for Classic UI (emulated DOGM) and Color UI - #define TFT_CS_PIN EXP1_04_PIN - #define TFT_A0_PIN EXP1_03_PIN - #define TFT_DC_PIN EXP1_03_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_BACKLIGHT_PIN EXP1_08_PIN - #define TFT_RESET_PIN EXP1_07_PIN + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_A0_PIN EXP1_08_PIN + #define TFT_DC_PIN EXP1_08_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_BACKLIGHT_PIN EXP1_03_PIN + #define TFT_RESET_PIN EXP1_04_PIN #define LCD_USE_DMA_SPI - #define TOUCH_INT_PIN EXP1_05_PIN - #define TOUCH_CS_PIN EXP1_06_PIN + #define TOUCH_INT_PIN EXP1_06_PIN + #define TOUCH_CS_PIN EXP1_05_PIN #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 2 @@ -316,8 +318,8 @@ #define TFT_QUEUE_SIZE 6144 #endif - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #elif IS_TFTGLCD_PANEL @@ -325,74 +327,74 @@ #undef BTN_ENC #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif #else - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_SDSS EXP2_07_PIN + #define LCD_SDSS EXP2_04_PIN #if ENABLED(MKS_12864OLED_SSD1306) - #define LCD_PINS_DC EXP1_05_PIN - #define DOGLCD_CS EXP1_07_PIN + #define LCD_PINS_DC EXP1_06_PIN + #define DOGLCD_CS EXP1_04_PIN #define DOGLCD_A0 LCD_PINS_DC - #define DOGLCD_SCK EXP1_06_PIN - #define DOGLCD_MOSI EXP1_08_PIN + #define DOGLCD_SCK EXP1_05_PIN + #define DOGLCD_MOSI EXP1_03_PIN - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #define KILL_PIN -1 // NC #else // !MKS_12864OLED_SSD1306 - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN #define LCD_BACKLIGHT_PIN -1 #define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems // results in LCD soft SPI mode 3, SD soft SPI mode 0 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #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_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #else // !FYSETC_MINI_12864 #if ENABLED(MKS_MINI_12864) - #define DOGLCD_CS EXP1_05_PIN - #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_A0 EXP1_07_PIN #endif #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #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 diff --git a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h index 56d75a748cbc..28d8d3cfb5ef 100644 --- a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h +++ b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h @@ -23,6 +23,8 @@ /** * Re-ARM with RAMPS v1.4 pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Re-ARM%20RAMPS%201.4/Re_ARM_Schematic.pdf + * Origin: https://reprap.org/mediawiki/images/f/fa/Re_ARM_Schematic.pdf * * Applies to the following boards: * @@ -351,11 +353,11 @@ //#define SHIFT_EN_PIN P1_22 // (41) J5-4 & AUX-4 #endif - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define DOGLCD_CS P0_16 // (16) #define DOGLCD_A0 P2_06 // (59) J3-8 & AUX-2 - #define DOGLCD_SCK SD_SCK_PIN - #define DOGLCD_MOSI SD_MOSI_PIN + #define DOGLCD_SCK P0_15 // (52) (SCK) J3-9 & AUX-3 + #define DOGLCD_MOSI P0_18 // (51) (MOSI) J3-10 & AUX-3 #define STAT_LED_BLUE_PIN P0_26 // (63) may change if cable changes #define STAT_LED_RED_PIN P1_21 // ( 6) may change if cable changes diff --git a/Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h b/Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h index 2972ac756079..30cd76b9a22d 100644 --- a/Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h +++ b/Marlin/src/pins/lpc1768/pins_SELENA_COMPACT.h @@ -23,6 +23,8 @@ /** * Selena Compact pin assignments + * Pinout: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Selena%20Compact/Compact%20Pinout.pdf + * Origin: https://github.com/f61/Selena/blob/master/Compact%20Pinout.pdf */ #include "env_validate.h" diff --git a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h index 7ce78ad2832d..a9c61cb8c9e6 100644 --- a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h +++ b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_GT.h @@ -23,6 +23,8 @@ /** * Azteeg X5 GT pin assignments + * Wiring diagram: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Azteeg%20X5%20GT/X5%20GT%20Wiring%20Diagram.pdf + * Origin: https://panucattdevices.freshdesk.com/support/solutions/articles/1000244740-support-files */ #include "env_validate.h" @@ -107,7 +109,7 @@ // Display // -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN P1_31 #define DOGLCD_A0 P2_06 #define DOGLCD_CS P0_16 diff --git a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h index 4fbc19eed843..eabb338504f8 100644 --- a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h +++ b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h @@ -23,6 +23,10 @@ /** * Azteeg X5 MINI pin assignments + * Schematic (V1): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Azteeg%20X5%20MINI/x5mini_design_files/X5mini_design_files/V1/X5%20Mini%20PUB%20v1.0.pdf + * Schematic (V2): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Azteeg%20X5%20MINI/x5mini_design_files/X5mini_design_files/V2/X5%20Mini%20V2%20SCH%20Pub.pdf + * Schematic (V3): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Azteeg%20X5%20MINI/x5mini_design_files/X5mini_design_files/V3/X5%20Mini%20V3%20SCH%20Pub.pdf + * Origin: http://files.panucatt.com/datasheets/x5mini_design_files.zip */ #include "env_validate.h" @@ -154,7 +158,7 @@ //#define SHIFT_EN_PIN P1_22 // (41) J5-4 & AUX-4 #endif - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN P1_30 // (37) may change if cable changes #define DOGLCD_CS P0_26 // (63) J5-3 & AUX-2 #define DOGLCD_SCK SD_SCK_PIN diff --git a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI_WIFI.h b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI_WIFI.h index 086bacbac0f6..74439e4f3d27 100644 --- a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI_WIFI.h +++ b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI_WIFI.h @@ -23,6 +23,8 @@ /** * Azteeg X5 MINI WIFI pin assignments + * Wiring diagram: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Azteeg%20X5%20MINI%20WIFI/x5mini_wifi_wiring.pdf + * Origin: http://files.panucatt.com/datasheets/x5mini_wifi_wiring.pdf */ #include "env_validate.h" diff --git a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h index 090a2e40517e..d9f56407e294 100644 --- a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h +++ b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h @@ -23,6 +23,8 @@ /** * BigTreeTech SKR E3 Turbo pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/BTT%20SKR%20E3%20Turbo/BTT%20SKR%20E3%20Turbo-SCH.pdf + * Origin: https://github.com/bigtreetech/BIGTREETECH-SKR-E3-Turbo/blob/master/Hardware/BTT%20SKR%20E3%20Turbo-SCH.pdf */ #include "env_validate.h" @@ -186,22 +188,22 @@ /** * ------ - * (BEEPER) P2_08 |10 9 | P0_16 (BTN_ENC) - * (BTN_EN1) P0_19 | 8 7 | RESET - * (BTN_EN2) P0_20 6 5 | P0_15 (LCD_D4) - * (LCD_RS) P0_17 | 4 3 | P0_18 (LCD_EN) - * GND | 2 1 | 5V + * (BEEPER) P2_08 | 1 2 | P0_16 (BTN_ENC) + * (BTN_EN1) P0_19 | 3 4 | RESET + * (BTN_EN2) P0_20 5 6 | P0_15 (LCD_D4) + * (LCD_RS) P0_17 | 7 8 | P0_18 (LCD_EN) + * GND | 9 10 | 5V * ------ * EXP */ -#define EXP1_03_PIN P0_18 -#define EXP1_04_PIN P0_17 -#define EXP1_05_PIN P0_15 -#define EXP1_06_PIN P0_20 -#define EXP1_07_PIN -1 -#define EXP1_08_PIN P0_19 -#define EXP1_09_PIN P0_16 -#define EXP1_10_PIN P2_08 +#define EXP1_01_PIN P2_08 +#define EXP1_02_PIN P0_16 +#define EXP1_03_PIN P0_19 +#define EXP1_04_PIN -1 +#define EXP1_05_PIN P0_20 +#define EXP1_06_PIN P0_15 +#define EXP1_07_PIN P0_17 +#define EXP1_08_PIN P0_18 #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING @@ -209,34 +211,34 @@ #endif /** - * Ender 3 V2 display SKR E3 Turbo (EXP1) Ender 3 V2 display --> SKR E3 Turbo - * ------ ------ RX 8 --> 5 P0_15 - * -- |10 9 | -- (BEEPER) P2_08 |10 9 | P0_16 (BTN_ENC) TX 7 --> 9 P0_16 - * (SKR_TX1) RX | 8 7 | TX (SKR_RX1) (BTN_EN1) P0_19 | 8 7 | RESET BEEPER 5 --> 10 P2_08 - * (BTN_ENC) ENT 6 5 | BEEPER (BTN_EN2) P0_20 6 5 | P0_15 (LCD_D4) - * (BTN_E2) B | 4 3 | A (BTN_E1) (LCD_RS) P0_17 | 4 3 | P0_18 (LCD_EN) - * GND | 2 1 | 5V GND | 2 1 | 5V + * Ender-3 V2 display SKR E3 Turbo (EXP1) Ender-3 V2 display --> SKR E3 Turbo + * ------ ------ RX 3 --> 5 P0_15 + * -- | 1 2 | -- (BEEPER) P2_08 |10 9 | P0_16 (BTN_ENC) TX 4 --> 9 P0_16 + * (SKR_TX1) RX | 3 4 | TX (SKR_RX1) (BTN_EN1) P0_19 | 8 7 | RESET BEEPER 6 --> 10 P2_08 + * (BTN_ENC) ENT 5 6 | BEEPER (BTN_EN2) P0_20 6 5 | P0_15 (LCD_D4) + * (BTN_E2) B | 7 8 | A (BTN_E1) (LCD_RS) P0_17 | 4 3 | P0_18 (LCD_EN) + * GND | 9 10 | 5V GND | 2 1 | 5V * ------ ------ */ - #define BEEPER_PIN EXP1_10_PIN - #define BTN_EN1 EXP1_03_PIN - #define BTN_EN2 EXP1_04_PIN - #define BTN_ENC EXP1_06_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_05_PIN #elif HAS_WIRED_LCD #if ENABLED(CR10_STOCKDISPLAY) - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 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! @@ -244,24 +246,24 @@ #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_E3_TURBO.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" #endif - #define LCD_PINS_RS EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_09_PIN - #define LCD_PINS_D4 EXP1_04_PIN - #define LCD_PINS_D5 EXP1_06_PIN - #define LCD_PINS_D6 EXP1_08_PIN - #define LCD_PINS_D7 EXP1_10_PIN + #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 P1_23 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN - #define DOGLCD_CS EXP1_04_PIN - #define DOGLCD_A0 EXP1_05_PIN - #define DOGLCD_SCK EXP1_10_PIN - #define DOGLCD_MOSI EXP1_03_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 diff --git a/Marlin/src/pins/lpc1769/pins_BTT_SKR_V1_4_TURBO.h b/Marlin/src/pins/lpc1769/pins_BTT_SKR_V1_4_TURBO.h index 7f428fc91881..1bd70d8fb598 100644 --- a/Marlin/src/pins/lpc1769/pins_BTT_SKR_V1_4_TURBO.h +++ b/Marlin/src/pins/lpc1769/pins_BTT_SKR_V1_4_TURBO.h @@ -23,6 +23,8 @@ /** * BigTreeTech SKR 1.4 Turbo pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/BTT%20SKR%20V1.4%20+%20Turbo/BTT%20SKR%20V1.4-SCH.pdf + * Origin: https://github.com/bigtreetech/BIGTREETECH-SKR-V1.3/blob/master/BTT%20SKR%20V1.4/Hardware/BTT%20SKR%20V1.4-SCH.pdf */ #define BOARD_INFO_NAME "BTT SKR V1.4 TURBO" diff --git a/Marlin/src/pins/lpc1769/pins_COHESION3D_MINI.h b/Marlin/src/pins/lpc1769/pins_COHESION3D_MINI.h index 237dfaec36fb..03d681d333d1 100644 --- a/Marlin/src/pins/lpc1769/pins_COHESION3D_MINI.h +++ b/Marlin/src/pins/lpc1769/pins_COHESION3D_MINI.h @@ -23,6 +23,8 @@ /** * Cohesion3D Mini pin assignments + * Pinout: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Cohesion3D%20Mini/c3d-pinout.jpg + * Origin: https://lasergods.com/cohesion3d-mini-pinout-diagram/ */ #include "env_validate.h" diff --git a/Marlin/src/pins/lpc1769/pins_COHESION3D_REMIX.h b/Marlin/src/pins/lpc1769/pins_COHESION3D_REMIX.h index ea2e0b708251..e25a6688990a 100644 --- a/Marlin/src/pins/lpc1769/pins_COHESION3D_REMIX.h +++ b/Marlin/src/pins/lpc1769/pins_COHESION3D_REMIX.h @@ -23,6 +23,8 @@ /** * Cohesion3D ReMix pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Cohesion3D%20ReMix/C3D%20ReMix%20rev2.svg + * Origin: https://github.com/Cohesion3D/Cohesion3D-ReMix/blob/master/C3D%20ReMix%20rev2.sch */ #include "env_validate.h" diff --git a/Marlin/src/pins/lpc1769/pins_FLY_CDY.h b/Marlin/src/pins/lpc1769/pins_FLY_CDY.h index ec0b14af9043..1c0cb05892a7 100644 --- a/Marlin/src/pins/lpc1769/pins_FLY_CDY.h +++ b/Marlin/src/pins/lpc1769/pins_FLY_CDY.h @@ -23,6 +23,8 @@ /** * FLYmaker FLY-CDY pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/FLYmaker%20FLY-CDY%20V1/FLY_CDY%20SCH.pdf + * Origin: https://github.com/Mellow-3D/FLY-CDY/blob/master/Motherboard%20information/FLY_CDY%20SCH.pdf */ #include "env_validate.h" diff --git a/Marlin/src/pins/lpc1769/pins_MKS_SGEN.h b/Marlin/src/pins/lpc1769/pins_MKS_SGEN.h index 23bcecc78d74..1e71fccfe5c5 100644 --- a/Marlin/src/pins/lpc1769/pins_MKS_SGEN.h +++ b/Marlin/src/pins/lpc1769/pins_MKS_SGEN.h @@ -23,6 +23,8 @@ /** * MKS SGen pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/MKS%20SGEN/MKS%20SGEN%20V1.0_001%20SCH.pdf + * Origin: https://github.com/makerbase-mks/MKS-SGen/blob/master/Hardware/MKS%20SGEN%20V1.0_001/MKS%20SGEN%20V1.0_001%20SCH.pdf * * Pins diagram: * https://github.com/makerbase-mks/MKS-SGen/blob/master/Hardware/MKS%20SGEN%20V1.0_001/MKS%20SGEN%20V1.0_001%20PIN.pdf diff --git a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h index 4cff5d59e17d..cf3b884683a9 100644 --- a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h +++ b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h @@ -23,6 +23,8 @@ /** * MKS SGen-L V2 pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/MKS%20SGEN_L%20V2/MKS%20SGEN_L%20V2.0_003%20SCH.pdf + * Origin: https://github.com/makerbase-mks/MKS-SGEN_L-V2/blob/master/Hardware/MKS%20SGEN_L%20V2.0_003/MKS%20SGEN_L%20V2.0_003%20SCH.pdf */ #include "env_validate.h" @@ -270,87 +272,87 @@ #endif /** ------ ------ - * (BEEPER) 1.31 |10 9 | 1.30 (BTN_ENC) (MISO) 0.8 |10 9 | 0.7 (SD_SCK) - * (LCD_EN) 0.18 | 8 7 | 0.16 (LCD_RS) (BTN_EN1) 3.25 | 8 7 | 0.28 (SD_CS2) - * (LCD_D4) 0.15 6 5 | 0.17 (LCD_D5) (BTN_EN2) 3.26 6 5 | 0.9 (SD_MOSI) - * (LCD_D6) 1.0 | 4 3 | 1.22 (LCD_D7) (SD_DETECT) 0.27 | 4 3 | RST - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) 1.31 | 1 2 | 1.30 (BTN_ENC) (MISO) 0.8 | 1 2 | 0.7 (SD_SCK) + * (LCD_EN) 0.18 | 3 4 | 0.16 (LCD_RS) (BTN_EN1) 3.25 | 3 4 | 0.28 (SD_CS2) + * (LCD_D4) 0.15 5 6 | 0.17 (LCD_D5) (BTN_EN2) 3.26 5 6 | 0.9 (SD_MOSI) + * (LCD_D6) 1.0 | 7 8 | 1.22 (LCD_D7) (SD_DETECT) 0.27 | 7 8 | RST + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN P1_22 -#define EXP1_04_PIN P1_00 -#define EXP1_05_PIN P0_17 -#define EXP1_06_PIN P0_15 -#define EXP1_07_PIN P0_16 -#define EXP1_08_PIN P0_18 -#define EXP1_09_PIN P1_30 -#define EXP1_10_PIN P1_31 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN P0_27 -#define EXP2_05_PIN P0_09 -#define EXP2_06_PIN P3_26 -#define EXP2_07_PIN P0_28 -#define EXP2_08_PIN P3_25 -#define EXP2_09_PIN P0_07 -#define EXP2_10_PIN P0_08 +#define EXP1_01_PIN P1_31 +#define EXP1_02_PIN P1_30 +#define EXP1_03_PIN P0_18 +#define EXP1_04_PIN P0_16 +#define EXP1_05_PIN P0_15 +#define EXP1_06_PIN P0_17 +#define EXP1_07_PIN P1_00 +#define EXP1_08_PIN P1_22 + +#define EXP2_01_PIN P0_08 +#define EXP2_02_PIN P0_07 +#define EXP2_03_PIN P3_25 +#define EXP2_04_PIN P0_28 +#define EXP2_05_PIN P3_26 +#define EXP2_06_PIN P0_09 +#define EXP2_07_PIN P0_27 +#define EXP2_08_PIN -1 // RESET #if IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #elif HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #else - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_SDSS EXP2_07_PIN + #define LCD_SDSS EXP2_04_PIN #if ENABLED(MKS_12864OLED_SSD1306) - #define LCD_PINS_DC EXP1_05_PIN - #define DOGLCD_CS EXP1_07_PIN + #define LCD_PINS_DC EXP1_06_PIN + #define DOGLCD_CS EXP1_04_PIN #define DOGLCD_A0 LCD_PINS_DC - #define DOGLCD_SCK EXP1_06_PIN - #define DOGLCD_MOSI EXP1_08_PIN + #define DOGLCD_SCK EXP1_05_PIN + #define DOGLCD_MOSI EXP1_03_PIN - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #define KILL_PIN -1 // NC #elif HAS_SPI_TFT // Config for Classic UI (emulated DOGM) and Color UI - #define TFT_CS_PIN EXP1_04_PIN - #define TFT_DC_PIN EXP1_03_PIN + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_DC_PIN EXP1_08_PIN #define TFT_A0_PIN TFT_DC_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_BACKLIGHT_PIN EXP1_08_PIN - #define TFT_RESET_PIN EXP1_07_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_BACKLIGHT_PIN EXP1_03_PIN + #define TFT_RESET_PIN EXP1_04_PIN #define LCD_USE_DMA_SPI - #define TOUCH_INT_PIN EXP1_05_PIN - #define TOUCH_CS_PIN EXP1_06_PIN + #define TOUCH_INT_PIN EXP1_06_PIN + #define TOUCH_CS_PIN EXP1_05_PIN #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 2 @@ -367,50 +369,50 @@ #else // !MKS_12864OLED_SSD1306 - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN #define LCD_BACKLIGHT_PIN -1 #define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems // results in LCD soft SPI mode 3, SD soft SPI mode 0 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #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_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #else // !FYSETC_MINI_12864 #if ENABLED(MKS_MINI_12864) - #define DOGLCD_CS EXP1_05_PIN - #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_A0 EXP1_07_PIN #endif #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #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 @@ -431,15 +433,15 @@ #endif #if SD_CONNECTION_IS(LCD) || SD_CONNECTION_IS(ONBOARD) - #define SD_DETECT_PIN EXP2_04_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN #if SD_CONNECTION_IS(ONBOARD) #define ONBOARD_SD_CS_PIN P0_06 // Chip select for "System" SD card #define SD_SS_PIN ONBOARD_SD_CS_PIN #else - #define SD_SS_PIN EXP2_07_PIN + #define SD_SS_PIN EXP2_04_PIN #endif #elif SD_CONNECTION_IS(CUSTOM_CABLE) #error "No custom SD drive cable defined for this board." diff --git a/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h b/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h index e80116efd036..124c8f63c2e8 100644 --- a/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h +++ b/Marlin/src/pins/lpc1769/pins_SMOOTHIEBOARD.h @@ -23,6 +23,8 @@ /** * Smoothieware Smoothieboard pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Smoothieware%20Smoothieboard%20V1/http.i.imgur.com.oj4zqs3.png + * Origin: http://smoothieware.org/_media///external/http.i.imgur.com.oj4zqs3.png */ #include "env_validate.h" @@ -91,7 +93,7 @@ // // LCD / Controller // -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN P1_31 #define DOGLCD_A0 P2_11 diff --git a/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h b/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h index 81c7dc9403db..f39b0374c28a 100644 --- a/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h +++ b/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h @@ -131,12 +131,6 @@ #ifndef E0_AUTO_FAN_PIN #define E0_AUTO_FAN_PIN AUTO_FAN_PIN #endif -#ifndef E1_AUTO_FAN_PIN - #define E1_AUTO_FAN_PIN AUTO_FAN_PIN -#endif -#ifndef E2_AUTO_FAN_PIN - #define E2_AUTO_FAN_PIN AUTO_FAN_PIN -#endif // // SD Card @@ -144,7 +138,7 @@ #define SDCARD_CONNECTION ONBOARD -//#define SD_DETECT_PIN P0_25 // SD_CD +#define SD_DETECT_PIN P0_27 // SD_CD #define SD_SCK_PIN P0_07 #define SD_MISO_PIN P0_08 #define SD_MOSI_PIN P0_09 @@ -157,11 +151,11 @@ /** * ------ - * P1_31 |10 9 | P1_30 - * P3_26 | 8 7 | P2_11 - * P3_25 6 5 | P0_15 - * P0_16 | 4 3 | P0_18 - * GND | 2 1 | 5V + * P1_31 | 1 2 | P1_30 + * P3_26 | 3 4 | P2_11 + * P3_25 5 6 | P0_15 + * P0_16 | 7 8 | P0_18 + * GND | 9 10 | 5V * ------ * EXP1 * @@ -171,43 +165,43 @@ * A remote SD card is currently not supported because the pins routed to the EXP2 * connector are shared with the onboard SD card. */ -#define EXP1_03_PIN P0_18 -#define EXP1_04_PIN P0_16 -#define EXP1_05_PIN P0_15 -#define EXP1_06_PIN P3_25 -#define EXP1_07_PIN P2_11 -#define EXP1_08_PIN P3_26 -#define EXP1_09_PIN P1_30 -#define EXP1_10_PIN P1_31 +#define EXP1_01_PIN P1_31 +#define EXP1_02_PIN P1_30 +#define EXP1_03_PIN P3_26 +#define EXP1_04_PIN P2_11 +#define EXP1_05_PIN P3_25 +#define EXP1_06_PIN P0_15 +#define EXP1_07_PIN P0_16 +#define EXP1_08_PIN P0_18 #if ENABLED(CR10_STOCKDISPLAY) /** ------ - * BEEPER |10 9 | ENC - * EN1 | 8 7 | KILL - * EN2 6 5 | LCD_D4 - * LCD_RS | 4 3 | LCD_EN - * GND | 2 1 | 5V + * BEEPER | 1 2 | ENC + * EN1 | 3 4 | KILL + * EN2 5 6 | LCD_D4 + * LCD_RS | 7 8 | LCD_EN + * GND | 9 10 | 5V * ------ */ - #define BEEPER_PIN EXP1_10_PIN - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN - #define KILL_PIN EXP1_07_PIN + #define BEEPER_PIN EXP1_01_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + #define KILL_PIN EXP1_04_PIN #elif ENABLED(MKS_MINI_12864) /** ------ - * SCK |10 9 | ENC - * EN1 | 8 7 | -- - * EN2 6 5 | A0 - * CS | 4 3 | MOSI - * GND | 2 1 | 5V + * SCK | 1 2 | ENC + * EN1 | 3 4 | -- + * EN2 5 6 | A0 + * CS | 7 8 | MOSI + * GND | 9 10 | 5V * ------ */ - #define DOGLCD_CS EXP1_04_PIN - #define DOGLCD_A0 EXP1_05_PIN - #define DOGLCD_SCK EXP1_10_PIN - #define DOGLCD_MOSI EXP1_03_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 LCD_CONTRAST_INIT 160 #define LCD_CONTRAST_MIN 120 #define LCD_CONTRAST_MAX 180 @@ -221,7 +215,7 @@ #endif #if EITHER(CR10_STOCKDISPLAY, MKS_MINI_12864) - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN #endif diff --git a/Marlin/src/pins/mega/pins_CHEAPTRONIC.h b/Marlin/src/pins/mega/pins_CHEAPTRONIC.h index 8bcb263bc1fd..e95f6c4adead 100644 --- a/Marlin/src/pins/mega/pins_CHEAPTRONIC.h +++ b/Marlin/src/pins/mega/pins_CHEAPTRONIC.h @@ -23,6 +23,7 @@ /** * Cheaptronic v1.0 pin assignments + * ATmega2560 */ #include "env_validate.h" diff --git a/Marlin/src/pins/mega/pins_CHEAPTRONICv2.h b/Marlin/src/pins/mega/pins_CHEAPTRONICv2.h index 01438975b979..e81295a6530a 100644 --- a/Marlin/src/pins/mega/pins_CHEAPTRONICv2.h +++ b/Marlin/src/pins/mega/pins_CHEAPTRONICv2.h @@ -24,7 +24,9 @@ /** * Cheaptronic v2.0 pin assignments * Built and sold by Michal Dyntar - RRO - * www.reprapobchod.cz + * www.reprapobchod.cz (DOES NOT EXIST ANYMORE) + * https://web.archive.org/web/20190306201523/http://reprapobchod.cz/ + * ATmega2560 */ #include "env_validate.h" diff --git a/Marlin/src/pins/mega/pins_CNCONTROLS_11.h b/Marlin/src/pins/mega/pins_CNCONTROLS_11.h index 5f7a534d115b..d996635c8c94 100644 --- a/Marlin/src/pins/mega/pins_CNCONTROLS_11.h +++ b/Marlin/src/pins/mega/pins_CNCONTROLS_11.h @@ -23,6 +23,9 @@ /** * CartesioV11 pin assignments + * Comes with an Arduino Mega, see + * https://web.archive.org/web/20171024190029/http://mauk.cc/mediawiki/index.php/Electronical_assembly + * ATmega2560, ATmega1280 */ #define ALLOW_MEGA1280 diff --git a/Marlin/src/pins/mega/pins_CNCONTROLS_12.h b/Marlin/src/pins/mega/pins_CNCONTROLS_12.h index 0aa0b59ca945..ea82fe429c33 100644 --- a/Marlin/src/pins/mega/pins_CNCONTROLS_12.h +++ b/Marlin/src/pins/mega/pins_CNCONTROLS_12.h @@ -23,6 +23,9 @@ /** * CartesioV12 pin assignments + * Comes with an Arduino Mega, see + * https://web.archive.org/web/20171024190029/http://mauk.cc/mediawiki/index.php/Electronical_assembly + * ATmega2560, ATmega1280 */ #define ALLOW_MEGA1280 diff --git a/Marlin/src/pins/mega/pins_CNCONTROLS_15.h b/Marlin/src/pins/mega/pins_CNCONTROLS_15.h index 6de3b7172eb0..c77e711f9c22 100644 --- a/Marlin/src/pins/mega/pins_CNCONTROLS_15.h +++ b/Marlin/src/pins/mega/pins_CNCONTROLS_15.h @@ -23,6 +23,7 @@ /** * CNControls V15 for HMS434 pin assignments + * ATmega2560, ATmega1280 */ #define ALLOW_MEGA1280 diff --git a/Marlin/src/pins/mega/pins_EINSTART-S.h b/Marlin/src/pins/mega/pins_EINSTART-S.h index d42efe73617f..274684f337d2 100644 --- a/Marlin/src/pins/mega/pins_EINSTART-S.h +++ b/Marlin/src/pins/mega/pins_EINSTART-S.h @@ -23,6 +23,7 @@ /** * Einstart-S pin assignments + * ATmega2560, ATmega1280 * PCB Silkscreen: 3DPrinterCon_v3.5 */ @@ -101,9 +102,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_ELEFU_3.h b/Marlin/src/pins/mega/pins_ELEFU_3.h index f5e146cff99c..6cf9e1b4e1af 100644 --- a/Marlin/src/pins/mega/pins_ELEFU_3.h +++ b/Marlin/src/pins/mega/pins_ELEFU_3.h @@ -23,6 +23,9 @@ /** * Elefu RA Board Pin Assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Elefu%20Ra%20v3/schematic.pdf + * Origin: https://github.com/kiyoshigawa/Elefu-RAv3/blob/master/RA_Circuits.zip + * ATmega2560 */ #include "env_validate.h" diff --git a/Marlin/src/pins/mega/pins_GT2560_REV_A.h b/Marlin/src/pins/mega/pins_GT2560_REV_A.h index 99e8704ea558..bb251dfb4e18 100644 --- a/Marlin/src/pins/mega/pins_GT2560_REV_A.h +++ b/Marlin/src/pins/mega/pins_GT2560_REV_A.h @@ -25,6 +25,9 @@ * Geeetech GT2560 Revision A board pin assignments, based on the work of * George Robles (https://georges3dprinters.com) and * Richard Smith + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Geeetech%20GT2560%20Revision%20A/GT2560_sch.pdf + * Origin: https://www.geeetech.com/wiki/images/9/90/GT2560_sch.pdf + * ATmega2560 */ #define ALLOW_MEGA1280 diff --git a/Marlin/src/pins/mega/pins_GT2560_REV_A_PLUS.h b/Marlin/src/pins/mega/pins_GT2560_REV_A_PLUS.h index 7e2ce20c6798..a982a0e00e73 100644 --- a/Marlin/src/pins/mega/pins_GT2560_REV_A_PLUS.h +++ b/Marlin/src/pins/mega/pins_GT2560_REV_A_PLUS.h @@ -23,6 +23,9 @@ /** * Geeetech GT2560 Revision A+ board pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Geeetech%20GT2560%20Revision%20A+/Hardware_GT2560_RevA+.pdf + * Origin: https://www.geeetech.com/wiki/images/d/d3/Hardware_GT2560_RevA%2B.pdf + * ATmega2560 */ #define BOARD_INFO_NAME "GT2560 Rev.A+" diff --git a/Marlin/src/pins/mega/pins_GT2560_REV_B.h b/Marlin/src/pins/mega/pins_GT2560_REV_B.h index be71ec4902dc..0702d14eb8d2 100644 --- a/Marlin/src/pins/mega/pins_GT2560_REV_B.h +++ b/Marlin/src/pins/mega/pins_GT2560_REV_B.h @@ -23,6 +23,9 @@ /** * Geeetech GT2560 Rev B Pins + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Geeetech%20GT2560%20Rev%20B/GT2560_REVB.pdf + * Origin: https://www.geeetech.com/wiki/images/7/72/GT2560_REVB.pdf + * ATmega2560 */ #define BOARD_INFO_NAME "GT2560 Rev B" diff --git a/Marlin/src/pins/mega/pins_GT2560_V3.h b/Marlin/src/pins/mega/pins_GT2560_V3.h index 46b4ebf4287e..5d2436b68406 100644 --- a/Marlin/src/pins/mega/pins_GT2560_V3.h +++ b/Marlin/src/pins/mega/pins_GT2560_V3.h @@ -23,6 +23,9 @@ /** * Geeetech GT2560 3.0/3.1 pin assignments + * Schematic (3.0): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Geeetech%20GT2560%203.0/GT2560_V3.0_SCH.pdf + * Origin (3.0): https://github.com/Geeetech3D/Diagram/blob/master/GT2560_V3.0_SCH.pdf + * ATmega2560 * * Also GT2560 RevB and GT2560 4.0/4.1 */ diff --git a/Marlin/src/pins/mega/pins_GT2560_V3_A20.h b/Marlin/src/pins/mega/pins_GT2560_V3_A20.h index 986dd1cb04bb..b5bf349eebf2 100644 --- a/Marlin/src/pins/mega/pins_GT2560_V3_A20.h +++ b/Marlin/src/pins/mega/pins_GT2560_V3_A20.h @@ -23,6 +23,7 @@ /** * Geeetech A20M board pin assignments + * ATmega2560 */ #define LCD_PINS_RS 5 diff --git a/Marlin/src/pins/mega/pins_GT2560_V3_MC2.h b/Marlin/src/pins/mega/pins_GT2560_V3_MC2.h index e683d4dfda4b..70854c5716dd 100644 --- a/Marlin/src/pins/mega/pins_GT2560_V3_MC2.h +++ b/Marlin/src/pins/mega/pins_GT2560_V3_MC2.h @@ -23,6 +23,7 @@ /** * Geeetech GT2560 V 3.0 board pin assignments (for Mecreator 2) + * ATmega2560 */ #define BOARD_INFO_NAME "GT2560 V3.0 (MC2)" diff --git a/Marlin/src/pins/mega/pins_GT2560_V4.h b/Marlin/src/pins/mega/pins_GT2560_V4.h index 6ac07b70bfce..98f503886f89 100644 --- a/Marlin/src/pins/mega/pins_GT2560_V4.h +++ b/Marlin/src/pins/mega/pins_GT2560_V4.h @@ -23,6 +23,9 @@ /** * Geeetech GT2560 V4.X Pins + * Schematic (4.0): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Geeetech%20GT2560%20V4.x%20+%20A20/GT2560V4.0SCHA20T.pdf + * Schematic (4.1B): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Geeetech%20GT2560%20V4.x%20+%20A20/GT2560V4.1BSCHA20T.pdf + * Origin: https://www.geeetech.com/download.html?spm=a2g0s.imconversation.0.0.22d23e5fXlQBWv&download_id=45 */ #define BOARD_INFO_NAME "GT2560 4.x" diff --git a/Marlin/src/pins/mega/pins_GT2560_V4_A20.h b/Marlin/src/pins/mega/pins_GT2560_V4_A20.h index 83a612e67cdc..eeba1485d77b 100644 --- a/Marlin/src/pins/mega/pins_GT2560_V4_A20.h +++ b/Marlin/src/pins/mega/pins_GT2560_V4_A20.h @@ -23,6 +23,7 @@ /** * Geeetech A20 GT2560 V4.x board pin assignments + * ATmega2560 */ #define BOARD_INFO_NAME "GT2560 4.x" diff --git a/Marlin/src/pins/mega/pins_HJC2560C_REV2.h b/Marlin/src/pins/mega/pins_HJC2560C_REV2.h index 5c3b1dc9f6d6..1b3b7b29afe6 100644 --- a/Marlin/src/pins/mega/pins_HJC2560C_REV2.h +++ b/Marlin/src/pins/mega/pins_HJC2560C_REV2.h @@ -23,6 +23,7 @@ /** * Geeetech HJC2560-C Rev 2.x board pin assignments + * ATmega2560 */ #include "env_validate.h" diff --git a/Marlin/src/pins/mega/pins_INTAMSYS40.h b/Marlin/src/pins/mega/pins_INTAMSYS40.h index 2e2a9b85db14..ec466fb09faa 100644 --- a/Marlin/src/pins/mega/pins_INTAMSYS40.h +++ b/Marlin/src/pins/mega/pins_INTAMSYS40.h @@ -23,6 +23,7 @@ /** * Intamsys Funmat HT V4.0 Mainboard + * ATmega2560 * 4988 Drivers Tested * 2208 version exists and may or may not work */ diff --git a/Marlin/src/pins/mega/pins_LEAPFROG.h b/Marlin/src/pins/mega/pins_LEAPFROG.h index 4700fd6729bd..3762ea98f051 100644 --- a/Marlin/src/pins/mega/pins_LEAPFROG.h +++ b/Marlin/src/pins/mega/pins_LEAPFROG.h @@ -23,6 +23,7 @@ /** * Leapfrog Driver board pin assignments + * ATmega2560, ATmega1280 */ #define ALLOW_MEGA1280 diff --git a/Marlin/src/pins/mega/pins_LEAPFROG_XEED2015.h b/Marlin/src/pins/mega/pins_LEAPFROG_XEED2015.h index 4a32472949a3..7be96c5defc5 100644 --- a/Marlin/src/pins/mega/pins_LEAPFROG_XEED2015.h +++ b/Marlin/src/pins/mega/pins_LEAPFROG_XEED2015.h @@ -23,6 +23,7 @@ /** * Leapfrog Xeed Driver board pin assignments + * ATmega2560 * * This board is used by other Leapfrog printers in addition to the Xeed, * such as the Creatr HS and Bolt. The pin assignments vary wildly between diff --git a/Marlin/src/pins/mega/pins_MALYAN_M180.h b/Marlin/src/pins/mega/pins_MALYAN_M180.h index 19095a53799f..3ef606de7723 100644 --- a/Marlin/src/pins/mega/pins_MALYAN_M180.h +++ b/Marlin/src/pins/mega/pins_MALYAN_M180.h @@ -24,6 +24,8 @@ /** * Malyan M180 pin assignments * Contributed by Timo Birnschein (timo.birnschein@microforge.de) + * @Timo: sind diese Pin Definitionen immernoch korrekt? (Antwort an turningtides@outlook.de bitte) + * ATmega2560 */ #include "env_validate.h" diff --git a/Marlin/src/pins/mega/pins_MEGACONTROLLER.h b/Marlin/src/pins/mega/pins_MEGACONTROLLER.h index 7ebef6e281cf..f45da25f623a 100644 --- a/Marlin/src/pins/mega/pins_MEGACONTROLLER.h +++ b/Marlin/src/pins/mega/pins_MEGACONTROLLER.h @@ -23,6 +23,9 @@ /** * Mega controller pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Mega%20Controller/Mega_controller.pdf + * Origin: https://reprap.org/mediawiki/images/b/ba/Mega_controller.pdf + * ATmega2560 */ #if HOTENDS > 2 || E_STEPPERS > 2 diff --git a/Marlin/src/pins/mega/pins_MEGATRONICS.h b/Marlin/src/pins/mega/pins_MEGATRONICS.h index ac0ba4eea662..a51615e3d91e 100644 --- a/Marlin/src/pins/mega/pins_MEGATRONICS.h +++ b/Marlin/src/pins/mega/pins_MEGATRONICS.h @@ -23,6 +23,9 @@ /** * MegaTronics pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/MegaTronics/Megatronics_1_0_sch.pdf + * Origin: https://reprap.org/mediawiki/images/a/a3/Megatronics_1_0_sch.pdf + * ATmega2560 */ #include "env_validate.h" diff --git a/Marlin/src/pins/mega/pins_MEGATRONICS_2.h b/Marlin/src/pins/mega/pins_MEGATRONICS_2.h index e52703591063..3f7afe562b72 100644 --- a/Marlin/src/pins/mega/pins_MEGATRONICS_2.h +++ b/Marlin/src/pins/mega/pins_MEGATRONICS_2.h @@ -23,6 +23,9 @@ /** * MegaTronics v2.0 pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Megatronics%20v2.0/megatronics%20-%20Project.pdf + * Origin: https://reprap.org/wiki/File:Megatronicsv2PDF.zip + * ATmega2560 */ #include "env_validate.h" diff --git a/Marlin/src/pins/mega/pins_MEGATRONICS_3.h b/Marlin/src/pins/mega/pins_MEGATRONICS_3.h index 86aff16f920e..b194c31b5d91 100644 --- a/Marlin/src/pins/mega/pins_MEGATRONICS_3.h +++ b/Marlin/src/pins/mega/pins_MEGATRONICS_3.h @@ -23,6 +23,8 @@ /** * MegaTronics v3.0 / v3.1 / v3.2 pin assignments + * Schematic Origin: https://github.com/brupje/Megatronics_3/blob/master/Design%20Files/megatronics.sch + * ATmega2560 */ #include "env_validate.h" diff --git a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h index 3bcece400f96..db41ef75d557 100644 --- a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h +++ b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h @@ -23,6 +23,8 @@ /** * Mightyboard Rev.E pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Mightyboard%20Rev.E/MakerBot%20MightyBoard%20REVE%20Schematic.pdf + * Origin: https://github.com/sciguy14/HelioWatcher/blob/master/HelioWatcher%20Circuit/MakerBot%20MightyBoard%20REVE%20Schematic.pdf * also works for Rev D boards. It's all rev E despite what the silk screen says */ @@ -203,14 +205,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 +221,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_MINITRONICS.h b/Marlin/src/pins/mega/pins_MINITRONICS.h index ec712a3b90e5..ddf6d2047deb 100644 --- a/Marlin/src/pins/mega/pins_MINITRONICS.h +++ b/Marlin/src/pins/mega/pins_MINITRONICS.h @@ -23,6 +23,11 @@ /** * Minitronics v1.0/1.1 pin assignments + * Schematic (1.0): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Minitronics%20v1.0/minitronics%20-%20Project.pdf + * Origin (1.0): https://reprap.org/wiki/File:MinitronicsPDF.zip + * Datasheet (1.1): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Minitronics%20v1.1/datasheet%20minitronics%20v1.1.pdf + * Origin (1.1): https://reprapworld.nl/documentation/datasheet%20minitronics%20v1.1.pdf + * ATmega1281 */ /** diff --git a/Marlin/src/pins/mega/pins_OVERLORD.h b/Marlin/src/pins/mega/pins_OVERLORD.h index f1062b413e83..01c02dafe24f 100644 --- a/Marlin/src/pins/mega/pins_OVERLORD.h +++ b/Marlin/src/pins/mega/pins_OVERLORD.h @@ -23,6 +23,9 @@ /** * Dreammaker Overlord v1.1 pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Dreammaker%20Overlord%20v1.1/Schematic.pdf + * Origin: https://github.com/jdpiercy/Overlord-Pro/blob/master/Motherboard/Schematic.pdf + * ATmega2560 */ #if HOTENDS > 2 || E_STEPPERS > 2 @@ -135,7 +138,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/mega/pins_PICA.h b/Marlin/src/pins/mega/pins_PICA.h index 0e29d8dffe75..109859388c60 100644 --- a/Marlin/src/pins/mega/pins_PICA.h +++ b/Marlin/src/pins/mega/pins_PICA.h @@ -23,6 +23,9 @@ /** * Arduino Mega with PICA pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/PICA/pica_schematic.pdf + * Origin: https://github.com/mjrice/PICA/blob/master/pica_schematic.pdf + * ATmega2560 * * PICA is Power, Interface, and Control Adapter and is open source hardware. * See https://github.com/mjrice/PICA for schematics etc. diff --git a/Marlin/src/pins/mega/pins_PICAOLD.h b/Marlin/src/pins/mega/pins_PICAOLD.h index e19ea744e5eb..961462fc5279 100644 --- a/Marlin/src/pins/mega/pins_PICAOLD.h +++ b/Marlin/src/pins/mega/pins_PICAOLD.h @@ -21,6 +21,10 @@ */ #pragma once +// Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/PICAOLD/pica_schematic.pdf +// Origin: https://github.com/mjrice/PICA/blob/97ab9e7771a8e5eef97788f3adcc17a9fa9de9b9/pica_schematic.pdf +// ATmega2560 + #define HEATER_0_PIN 9 // E0 #define HEATER_1_PIN 10 // E1 #define FAN_PIN 11 diff --git a/Marlin/src/pins/mega/pins_PROTONEER_CNC_SHIELD_V3.h b/Marlin/src/pins/mega/pins_PROTONEER_CNC_SHIELD_V3.h index f2e4d3da0266..18e2c0f64747 100644 --- a/Marlin/src/pins/mega/pins_PROTONEER_CNC_SHIELD_V3.h +++ b/Marlin/src/pins/mega/pins_PROTONEER_CNC_SHIELD_V3.h @@ -23,6 +23,9 @@ /** * Protoneer v3.00 pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Protoneer%20CNC%20Shield%20v3.00/Arduino-CNC-Shield-Scematics-V3.XX_.webp + * Origin: https://i0.wp.com/blog.protoneer.co.nz/wp-content/uploads/2013/07/Arduino-CNC-Shield-Scematics-V3.XX_.jpg + * ATmega2560 * * This CNC shield has an UNO pinout and fits all Arduino-compatibles. * diff --git a/Marlin/src/pins/mega/pins_SILVER_GATE.h b/Marlin/src/pins/mega/pins_SILVER_GATE.h index c2ca5b31038a..18ada3aa251b 100644 --- a/Marlin/src/pins/mega/pins_SILVER_GATE.h +++ b/Marlin/src/pins/mega/pins_SILVER_GATE.h @@ -21,6 +21,8 @@ */ #pragma once +// ATmega2561 + #if NOT_TARGET(__AVR_ATmega1281__, __AVR_ATmega2561__) #error "Oops! Select 'Silvergate' in 'Tools > Board.'" #endif diff --git a/Marlin/src/pins/mega/pins_WANHAO_ONEPLUS.h b/Marlin/src/pins/mega/pins_WANHAO_ONEPLUS.h index 503dd9ec8148..6ab6c4ceb9b2 100644 --- a/Marlin/src/pins/mega/pins_WANHAO_ONEPLUS.h +++ b/Marlin/src/pins/mega/pins_WANHAO_ONEPLUS.h @@ -23,6 +23,7 @@ /** * Wanhao 0ne+ pin assignments + * ATmega2560 */ #include "env_validate.h" diff --git a/Marlin/src/pins/mega/pins_WEEDO_62A.h b/Marlin/src/pins/mega/pins_WEEDO_62A.h index 4b3bf6a43bee..4165d9e2341b 100644 --- a/Marlin/src/pins/mega/pins_WEEDO_62A.h +++ b/Marlin/src/pins/mega/pins_WEEDO_62A.h @@ -23,6 +23,7 @@ /** * Based on WEEDO 62A pin configuration * Copyright (c) 2019 WEEDO3D Perron + * ATmega2560 */ #pragma once diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 40b0c714c6dd..724c34897707 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) @@ -232,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) @@ -402,6 +404,8 @@ #include "lpc1768/pins_BTT_SKR_V1_3.h" // LPC1768 env:LPC1768 #elif MB(BTT_SKR_V1_4) #include "lpc1768/pins_BTT_SKR_V1_4.h" // LPC1768 env:LPC1768 +#elif MB(EMOTRONIC) + #include "lpc1768/pins_EMOTRONIC.h" // LPC1768 env:LPC1768 // // LPC1769 ARM Cortex M3 @@ -510,9 +514,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_v1v2_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_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) @@ -529,6 +533,8 @@ #include "stm32f1/pins_MKS_ROBIN_E3D_V1_1.h" // STM32F1 env:mks_robin_e3 #elif MB(MKS_ROBIN_E3P) #include "stm32f1/pins_MKS_ROBIN_E3P.h" // STM32F1 env:mks_robin_e3p env:mks_robin_e3p_maple +#elif MB(BTT_EBB42_V1_1) + #include "stm32g0/pins_BTT_EBB42_V1_1.h" // STM32G0 env:BTT_EBB42_V1_1_filament_extruder #elif MB(BTT_SKR_MINI_V1_1) #include "stm32f1/pins_BTT_SKR_MINI_V1_1.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple #elif MB(BTT_SKR_MINI_E3_V1_0) @@ -539,6 +545,18 @@ #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_MANTA_M4P_V1_0) + #include "stm32g0/pins_BTT_MANTA_M4P_V1_0.h" // STM32G0 env:STM32G0B1RE_manta_btt env:STM32G0B1RE_manta_btt_xfer +#elif MB(BTT_MANTA_M5P_V1_0) + #include "stm32g0/pins_BTT_MANTA_M5P_V1_0.h" // STM32G0 env:STM32G0B1RE_manta_btt env:STM32G0B1RE_manta_btt_xfer +#elif MB(BTT_MANTA_E3_EZ_V1_0) + #include "stm32g0/pins_BTT_MANTA_E3_EZ_V1_0.h" // STM32G0 env:STM32G0B1RE_manta_btt env:STM32G0B1RE_manta_btt_xfer +#elif MB(BTT_MANTA_M8P_V1_0) + #include "stm32g0/pins_BTT_MANTA_M8P_V1_0.h" // STM32G0 env:STM32G0B1VE_btt env:STM32G0B1VE_btt_xfer +#elif MB(BTT_MANTA_M8P_V1_1) + #include "stm32g0/pins_BTT_MANTA_M8P_V1_1.h" // STM32G0 env:STM32G0B1VE_btt env:STM32G0B1VE_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) @@ -567,6 +585,8 @@ #include "stm32f1/pins_CREALITY_V4.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V4210) #include "stm32f1/pins_CREALITY_V4210.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple +#elif MB(CREALITY_V425) + #include "stm32f1/pins_CREALITY_V425.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V422) #include "stm32f1/pins_CREALITY_V422.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V423) @@ -585,8 +605,10 @@ #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 + #include "stm32f1/pins_TRIGORILLA_PRO.h" // STM32F1 env:trigorilla_pro env:trigorilla_pro_maple env:trigorilla_pro_disk #elif MB(FLY_MINI) #include "stm32f1/pins_FLY_MINI.h" // STM32F1 env:FLY_MINI env:FLY_MINI_maple #elif MB(FLSUN_HISPEED) @@ -605,6 +627,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(SOVOL_V131) + #include "stm32f1/pins_SOVOL_V131.h" // GD32F1 env:GD32F103RET6_sovol_maple // // ARM Cortex-M4F @@ -629,8 +653,6 @@ #include "stm32f4/pins_RUMBA32_BTT.h" // STM32F4 env:rumba32 #elif MB(BLACK_STM32F407VE) #include "stm32f4/pins_BLACK_STM32F407VE.h" // STM32F4 env:STM32F407VE_black -#elif MB(STEVAL_3DP001V1) - #include "stm32f4/pins_STEVAL_3DP001V1.h" // STM32F4 env:STM32F401VE_STEVAL #elif MB(BTT_SKR_PRO_V1_1) #include "stm32f4/pins_BTT_SKR_PRO_V1_1.h" // STM32F4 env:BIGTREE_SKR_PRO env:BIGTREE_SKR_PRO_usb_flash_drive #elif MB(BTT_SKR_PRO_V1_2) @@ -646,11 +668,11 @@ #elif MB(BTT_SKR_V2_0_REV_B) #include "stm32f4/pins_BTT_SKR_V2_0_REV_B.h" // STM32F4 env:BIGTREE_SKR_2 env:BIGTREE_SKR_2_USB env:BIGTREE_SKR_2_USB_debug env:BIGTREE_SKR_2_F429 env:BIGTREE_SKR_2_F429_USB env:BIGTREE_SKR_2_F429_USB_debug #elif MB(BTT_OCTOPUS_V1_0) - #include "stm32f4/pins_BTT_OCTOPUS_V1_0.h" // STM32F4 env:BIGTREE_OCTOPUS_V1 env:BIGTREE_OCTOPUS_V1_USB + #include "stm32f4/pins_BTT_OCTOPUS_V1_0.h" // STM32F4 env:STM32F446ZE_btt env:STM32F446ZE_btt_USB #elif MB(BTT_OCTOPUS_V1_1) - #include "stm32f4/pins_BTT_OCTOPUS_V1_1.h" // STM32F4 env:BIGTREE_OCTOPUS_V1 env:BIGTREE_OCTOPUS_V1_USB + #include "stm32f4/pins_BTT_OCTOPUS_V1_1.h" // STM32F4 env:STM32F446ZE_btt env:STM32F446ZE_btt_USB env:STM32F429ZG_btt env:STM32F429ZG_btt_USB env:STM32F407ZE_btt env:STM32F407ZE_btt_USB #elif MB(BTT_OCTOPUS_PRO_V1_0) - #include "stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h" // STM32F4 env:BIGTREE_OCTOPUS_V1 env:BIGTREE_OCTOPUS_V1_USB env:BIGTREE_OCTOPUS_PRO_V1_F429 env:BIGTREE_OCTOPUS_PRO_V1_F429_USB + #include "stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h" // STM32F4 env:STM32F446ZE_btt env:STM32F446ZE_btt_USB env:STM32F429ZG_btt env:STM32F429ZG_btt_USB env:STM32H723Zx_btt #elif MB(LERDGE_K) #include "stm32f4/pins_LERDGE_K.h" // STM32F4 env:LERDGEK env:LERDGEK_usb_flash_drive #elif MB(LERDGE_S) @@ -670,7 +692,7 @@ #elif MB(FLYF407ZG) #include "stm32f4/pins_FLYF407ZG.h" // STM32F4 env:FLYF407ZG #elif MB(MKS_ROBIN2) - #include "stm32f4/pins_MKS_ROBIN2.h" // STM32F4 env:MKS_ROBIN2 + #include "stm32f4/pins_MKS_ROBIN2.h" // STM32F4 env:mks_robin2 #elif MB(MKS_ROBIN_PRO_V2) #include "stm32f4/pins_MKS_ROBIN_PRO_V2.h" // STM32F4 env:mks_robin_pro2 #elif MB(MKS_ROBIN_NANO_V3) @@ -678,25 +700,35 @@ #elif MB(MKS_ROBIN_NANO_V3_1) #include "stm32f4/pins_MKS_ROBIN_NANO_V3.h" // STM32F4 env:mks_robin_nano_v3_1 env:mks_robin_nano_v3_1_usb_flash_drive env:mks_robin_nano_v3_1_usb_flash_drive_msc #elif MB(ANET_ET4) - #include "stm32f4/pins_ANET_ET4.h" // STM32F4 env:Anet_ET4_OpenBLT + #include "stm32f4/pins_ANET_ET4.h" // STM32F4 env:Anet_ET4_no_bootloader env:Anet_ET4_OpenBLT #elif MB(ANET_ET4P) - #include "stm32f4/pins_ANET_ET4P.h" // STM32F4 env:Anet_ET4_OpenBLT + #include "stm32f4/pins_ANET_ET4P.h" // STM32F4 env:Anet_ET4_no_bootloader env:Anet_ET4_OpenBLT #elif MB(FYSETC_CHEETAH_V20) #include "stm32f4/pins_FYSETC_CHEETAH_V20.h" // STM32F4 env:FYSETC_CHEETAH_V20 -#elif MB(MKS_MONSTER8) - #include "stm32f4/pins_MKS_MONSTER8.h" // STM32F4 env:mks_monster8 env:mks_monster8_usb_flash_drive env:mks_monster8_usb_flash_drive_msc +#elif MB(MKS_MONSTER8_V1) + #include "stm32f4/pins_MKS_MONSTER8_V1.h" // STM32F4 env:mks_monster8 env:mks_monster8_usb_flash_drive env:mks_monster8_usb_flash_drive_msc +#elif MB(MKS_MONSTER8_V2) + #include "stm32f4/pins_MKS_MONSTER8_V2.h" // STM32F4 env:mks_monster8 env:mks_monster8_usb_flash_drive env:mks_monster8_usb_flash_drive_msc #elif MB(TH3D_EZBOARD_V2) - #include "stm32f4/pins_TH3D_EZBOARD_V2.h" // STM32F4 env:TH3D_EZBoard_V2 -#elif MB(INDEX_REV03) - #include "stm32f4/pins_INDEX_REV03.h" // STM32F4 env:Index_Mobo_Rev03 + #include "stm32f4/pins_TH3D_EZBOARD_V2.h" // STM32F4 env:TH3D_EZBoard_V2_no_bootloader env:TH3D_EZBoard_V2_OpenBLT +#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) #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 +#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 +#elif MB(TRONXY_V10) + #include "stm32f4/pins_TRONXY_V10.h" // STM32F4 env:STM32F446_tronxy // // ARM Cortex M7 @@ -706,12 +738,16 @@ #include "stm32f7/pins_REMRAM_V1.h" // STM32F7 env:REMRAM_V1 #elif MB(NUCLEO_F767ZI) #include "stm32f7/pins_NUCLEO_F767ZI.h" // STM32F7 env:NUCLEO_F767ZI -#elif MB(BTT_SKR_SE_BX) - #include "stm32h7/pins_BTT_SKR_SE_BX.h" // STM32H7 env:BTT_SKR_SE_BX +#elif MB(BTT_SKR_SE_BX_V2) + #include "stm32h7/pins_BTT_SKR_SE_BX_V2.h" // STM32H7 env:BTT_SKR_SE_BX +#elif MB(BTT_SKR_SE_BX_V3) + #include "stm32h7/pins_BTT_SKR_SE_BX_V3.h" // STM32H7 env:BTT_SKR_SE_BX #elif MB(BTT_SKR_V3_0) - #include "stm32h7/pins_BTT_SKR_V3_0.h" // STM32H7 env:STM32H743Vx_btt + #include "stm32h7/pins_BTT_SKR_V3_0.h" // STM32H7 env:STM32H723Vx_btt env:STM32H743Vx_btt #elif MB(BTT_SKR_V3_0_EZ) - #include "stm32h7/pins_BTT_SKR_V3_0_EZ.h" // STM32H7 env:STM32H743Vx_btt + #include "stm32h7/pins_BTT_SKR_V3_0_EZ.h" // STM32H7 env:STM32H723Vx_btt env:STM32H743Vx_btt +#elif MB(BTT_OCTOPUS_MAX_EZ_V1_0) + #include "stm32h7/pins_BTT_OCTOPUS_MAX_EZ.h" // STM32H7 env:STM32H723Vx_btt env:STM32H723Zx_btt #elif MB(TEENSY41) #include "teensy4/pins_TEENSY41.h" // Teensy-4.x env:teensy41 #elif MB(T41U5XBB) @@ -753,6 +789,13 @@ #elif MB(BRICOLEMON_LITE_V1_0) #include "samd/pins_BRICOLEMON_LITE_V1_0.h" // SAMD51 env:SAMD51_grandcentral_m4 +// +// ReprapWorld Minitronics (SAMD21) +// + +#elif MB(MINITRONICS20) + #include "samd/pins_MINITRONICS20.h" // SAMD21 env:SAMD21_minitronics20 + // // Custom board (with custom PIO env) // @@ -764,7 +807,7 @@ // Linux Native Debug board // -#elif MB(LINUX_RAMPS) +#elif MB(SIMULATED) #include "linux/pins_RAMPS_LINUX.h" // Native or Simulation lin:linux_native mac:simulator_macos_debug mac:simulator_macos_release win:simulator_windows lin:simulator_linux_debug lin:simulator_linux_release #else @@ -782,6 +825,7 @@ #define BOARD_STM32F103R 99906 #define BOARD_ESP32 99907 #define BOARD_STEVAL 99908 + #define BOARD_STEVAL_3DP001V1 99908 #define BOARD_BIGTREE_SKR_V1_1 99909 #define BOARD_BIGTREE_SKR_V1_3 99910 #define BOARD_BIGTREE_SKR_V1_4 99911 @@ -797,6 +841,9 @@ #define BOARD_RAMPS_LONGER3D_LK4PRO 99921 #define BOARD_BTT_SKR_V2_0 99922 #define BOARD_TH3D_EZBOARD_LITE_V2 99923 + #define BOARD_BTT_SKR_SE_BX 99924 + #define BOARD_MKS_MONSTER8 99925 + #define BOARD_LINUX_RAMPS 99926 #if MB(MKS_13) #error "BOARD_MKS_13 has been renamed BOARD_MKS_GEN_13. Please update your configuration." @@ -835,7 +882,7 @@ #elif MOTHERBOARD == BOARD_ESP32 #error "BOARD_ESP32 has been renamed BOARD_ESPRESSIF_ESP32. Please update your configuration." #elif MB(STEVAL) - #error "BOARD_STEVAL has been renamed BOARD_STEVAL_3DP001V1. Please update your configuration." + #error "BOARD_STEVAL_3DP001V1 (BOARD_STEVAL) is no longer supported in Marlin." #elif MB(RUMBA32) #error "BOARD_RUMBA32 is now BOARD_RUMBA32_MKS or BOARD_RUMBA32_V1_0. Please update your configuration." #elif MB(RUMBA32_AUS3D) @@ -848,6 +895,12 @@ #error "BOARD_BTT_SKR_V2_0 is now BOARD_BTT_SKR_V2_0_REV_A or BOARD_BTT_SKR_V2_0_REV_B. See https://bit.ly/3t5d9JQ for more information. Please update your configuration." #elif MB(TH3D_EZBOARD_LITE_V2) #error "BOARD_TH3D_EZBOARD_LITE_V2 is now BOARD_TH3D_EZBOARD_V2. Please update your configuration." + #elif MB(BTT_SKR_SE_BX) + #error "BOARD_BTT_SKR_SE_BX is now BOARD_BTT_SKR_SE_BX_V2 or BOARD_BTT_SKR_SE_BX_V3. Please update your configuration." + #elif MB(MKS_MONSTER8) + #error "BOARD_MKS_MONSTER8 is now BOARD_MKS_MONSTER8_V1 or BOARD_MKS_MONSTER8_V2. Please update your configuration." + #elif MB(LINUX_RAMPS) + #error "BOARD_LINUX_RAMPS is now BOARD_SIMULATED. Please update your configuration." #elif defined(MOTHERBOARD) #error "Unknown MOTHERBOARD value set in Configuration.h." #else @@ -863,7 +916,7 @@ #undef BOARD_STM32F103R #undef BOARD_ESP32 #undef BOARD_STEVAL - #undef BOARD_BIGTREE_SKR_MINI_E3 + #undef BOARD_STEVAL_3DP001V1 #undef BOARD_BIGTREE_SKR_V1_1 #undef BOARD_BIGTREE_SKR_V1_3 #undef BOARD_BIGTREE_SKR_V1_4 @@ -871,6 +924,7 @@ #undef BOARD_BIGTREE_BTT002_V1_0 #undef BOARD_BIGTREE_SKR_PRO_V1_1 #undef BOARD_BIGTREE_SKR_MINI_V1_1 + #undef BOARD_BIGTREE_SKR_MINI_E3 #undef BOARD_BIGTREE_SKR_E3_DIP #undef BOARD_RUMBA32 #undef BOARD_RUMBA32_AUS3D @@ -878,6 +932,9 @@ #undef BOARD_RAMPS_LONGER3D_LK4PRO #undef BOARD_BTT_SKR_V2_0 #undef BOARD_TH3D_EZBOARD_LITE_V2 + #undef BOARD_BTT_SKR_SE_BX + #undef BOARD_MKS_MONSTER8 + #undef BOARD_LINUX_RAMPS #endif diff --git a/Marlin/src/pins/pinsDebug.h b/Marlin/src/pins/pinsDebug.h index b662f09ba9ef..56e1039c4eed 100644 --- a/Marlin/src/pins/pinsDebug.h +++ b/Marlin/src/pins/pinsDebug.h @@ -45,23 +45,23 @@ #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) - #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 }, @@ -164,22 +164,26 @@ const PinInfo pin_array[] PROGMEM = { #endif #include "pinsDebug_list.h" - #line 167 + #line 168 }; -#include HAL_PATH(../HAL, pinsDebug.h) // get the correct support file for this CPU +#include HAL_PATH(.., pinsDebug.h) // get the correct support file for this CPU #ifndef M43_NEVER_TOUCH #define M43_NEVER_TOUCH(Q) false #endif static void print_input_or_output(const bool isout) { - SERIAL_ECHOPGM_P(isout ? PSTR("Output = ") : PSTR("Input = ")); + SERIAL_ECHOF(isout ? F("Output ") : F("Input ")); +} + +static void print_pin_state(const bool state) { + SERIAL_ECHOF(state ? F("HIGH") : F("LOW")); } // pretty report with PWM info -inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool extended=false, FSTR_P const start_string=nullptr) { +inline void report_pin_state_extended(const pin_t pin, const bool ignore, const bool extended=false, FSTR_P const start_string=nullptr) { char buffer[MAX_NAME_LENGTH + 1]; // for the sprintf statements bool found = false, multi_name_pin = false; @@ -188,12 +192,12 @@ inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool e // Use FastIO for pins Teensy doesn't expose if (pin == 46) { print_input_or_output(IS_OUTPUT(46)); - SERIAL_CHAR('0' + READ(46)); + print_pin_state(READ(46)); return false; } else if (pin == 47) { print_input_or_output(IS_OUTPUT(47)); - SERIAL_CHAR('0' + READ(47)); + print_pin_state(READ(47)); return false; } #endif @@ -230,14 +234,14 @@ inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool e // because this could interfere with inductive/capacitive // sensors (high impedance voltage divider) and with Pt100 amplifier print_input_or_output(false); - SERIAL_ECHO(digitalRead_mod(pin)); + print_pin_state(digitalRead_mod(pin)); } else if (pwm_status(pin)) { // do nothing } else { print_input_or_output(true); - SERIAL_ECHO(digitalRead_mod(pin)); + print_pin_state(digitalRead_mod(pin)); } } if (!multi_name_pin && extended) pwm_details(pin); // report PWM capabilities only on the first pass & only if doing an extended report @@ -267,7 +271,7 @@ inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool e else if (GET_PINMODE(pin)) { SERIAL_ECHO_SP(MAX_NAME_LENGTH - 16); print_input_or_output(true); - SERIAL_ECHO(digitalRead_mod(pin)); + print_pin_state(digitalRead_mod(pin)); } else { if (IS_ANALOG(pin)) { @@ -279,7 +283,7 @@ inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool e SERIAL_ECHO_SP(MAX_NAME_LENGTH - 16); // add padding if not an analog pin print_input_or_output(false); - SERIAL_ECHO(digitalRead_mod(pin)); + print_pin_state(digitalRead_mod(pin)); } //if (!pwm_status(pin)) SERIAL_CHAR(' '); // add padding if it's not a PWM pin if (extended) { diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index 8969997e9a54..39e07c739a23 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,55 @@ #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(OUTAGECON) + REPORT_NAME_DIGITAL(__LINE__, OUTAGECON_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 +929,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 +951,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 +1019,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 +1035,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 +1180,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 +1193,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 +1221,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 +1235,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 +1248,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 +1258,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 +1274,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 +1305,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,44 +1561,91 @@ #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(I_DIR) - REPORT_NAME_DIGITAL(__LINE__, I_DIR_PIN) +#if PIN_EXISTS(X_STEP) + REPORT_NAME_DIGITAL(__LINE__, X_STEP_PIN) #endif -#if PIN_EXISTS(I_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, I_ENABLE_PIN) +#if PIN_EXISTS(X2_DIR) + REPORT_NAME_DIGITAL(__LINE__, X2_DIR_PIN) #endif -#if PIN_EXISTS(I_MAX) - REPORT_NAME_DIGITAL(__LINE__, I_MAX_PIN) +#if PIN_EXISTS(X2_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, X2_ENABLE_PIN) #endif -#if PIN_EXISTS(I_MIN) - REPORT_NAME_DIGITAL(__LINE__, I_MIN_PIN) +#if PIN_EXISTS(X2_STEP) + REPORT_NAME_DIGITAL(__LINE__, X2_STEP_PIN) #endif -#if PIN_EXISTS(I_MS1) - REPORT_NAME_DIGITAL(__LINE__, I_MS1_PIN) +#if PIN_EXISTS(Y_DIR) + REPORT_NAME_DIGITAL(__LINE__, Y_DIR_PIN) #endif -#if PIN_EXISTS(I_MS2) - REPORT_NAME_DIGITAL(__LINE__, I_MS2_PIN) +#if PIN_EXISTS(Y_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Y_ENABLE_PIN) #endif -#if PIN_EXISTS(I_MS3) - REPORT_NAME_DIGITAL(__LINE__, I_MS3_PIN) +#if PIN_EXISTS(Y_STEP) + REPORT_NAME_DIGITAL(__LINE__, Y_STEP_PIN) #endif -#if PIN_EXISTS(I_STEP) - REPORT_NAME_DIGITAL(__LINE__, I_STEP_PIN) +#if PIN_EXISTS(Y2_DIR) + REPORT_NAME_DIGITAL(__LINE__, Y2_DIR_PIN) #endif -#if PIN_EXISTS(I_STOP) - REPORT_NAME_DIGITAL(__LINE__, I_STOP_PIN) +#if PIN_EXISTS(Y2_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Y2_ENABLE_PIN) #endif -#if PIN_EXISTS(J_ATT) - REPORT_NAME_DIGITAL(__LINE__, J_ATT_PIN) +#if PIN_EXISTS(Y2_STEP) + REPORT_NAME_DIGITAL(__LINE__, Y2_STEP_PIN) #endif -#if PIN_EXISTS(J_CS) - REPORT_NAME_DIGITAL(__LINE__, J_CS_PIN) +#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_STEP) + REPORT_NAME_DIGITAL(__LINE__, I_STEP_PIN) #endif #if PIN_EXISTS(J_DIR) REPORT_NAME_DIGITAL(__LINE__, J_DIR_PIN) @@ -1493,11 +1653,129 @@ #if PIN_EXISTS(J_ENABLE) REPORT_NAME_DIGITAL(__LINE__, J_ENABLE_PIN) #endif -#if PIN_EXISTS(J_MAX) - REPORT_NAME_DIGITAL(__LINE__, J_MAX_PIN) +#if PIN_EXISTS(J_STEP) + REPORT_NAME_DIGITAL(__LINE__, J_STEP_PIN) #endif -#if PIN_EXISTS(J_MIN) - REPORT_NAME_DIGITAL(__LINE__, J_MIN_PIN) +#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) +#endif +#if PIN_EXISTS(I_MS2) + REPORT_NAME_DIGITAL(__LINE__, I_MS2_PIN) +#endif +#if PIN_EXISTS(I_MS3) + REPORT_NAME_DIGITAL(__LINE__, I_MS3_PIN) #endif #if PIN_EXISTS(J_MS1) REPORT_NAME_DIGITAL(__LINE__, J_MS1_PIN) @@ -1508,150 +1786,222 @@ #if PIN_EXISTS(J_MS3) REPORT_NAME_DIGITAL(__LINE__, J_MS3_PIN) #endif -#if PIN_EXISTS(J_STEP) - REPORT_NAME_DIGITAL(__LINE__, J_STEP_PIN) +#if PIN_EXISTS(K_MS1) + REPORT_NAME_DIGITAL(__LINE__, K_MS1_PIN) #endif -#if PIN_EXISTS(J_STOP) - REPORT_NAME_DIGITAL(__LINE__, J_STOP_PIN) +#if PIN_EXISTS(K_MS2) + REPORT_NAME_DIGITAL(__LINE__, K_MS2_PIN) #endif -#if PIN_EXISTS(K_ATT) - REPORT_NAME_DIGITAL(__LINE__, K_ATT_PIN) +#if PIN_EXISTS(K_MS3) + REPORT_NAME_DIGITAL(__LINE__, K_MS3_PIN) #endif -#if PIN_EXISTS(K_CS) - REPORT_NAME_DIGITAL(__LINE__, K_CS_PIN) +#if PIN_EXISTS(U_MS1) + REPORT_NAME_DIGITAL(__LINE__, U_MS1_PIN) #endif -#if PIN_EXISTS(K_DIR) - REPORT_NAME_DIGITAL(__LINE__, K_DIR_PIN) +#if PIN_EXISTS(U_MS2) + REPORT_NAME_DIGITAL(__LINE__, U_MS2_PIN) #endif -#if PIN_EXISTS(K_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, K_ENABLE_PIN) +#if PIN_EXISTS(U_MS3) + REPORT_NAME_DIGITAL(__LINE__, U_MS3_PIN) #endif -#if PIN_EXISTS(K_MAX) - REPORT_NAME_DIGITAL(__LINE__, K_MAX_PIN) +#if PIN_EXISTS(V_MS1) + REPORT_NAME_DIGITAL(__LINE__, V_MS1_PIN) #endif -#if PIN_EXISTS(K_MIN) - REPORT_NAME_DIGITAL(__LINE__, K_MIN_PIN) +#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(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(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(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(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,114 +2086,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(L6470_CHAIN_SCK) - REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_SCK_PIN) -#endif -#if PIN_EXISTS(L6470_CHAIN_MISO) - REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_MISO_PIN) -#endif -#if PIN_EXISTS(L6470_CHAIN_MOSI) - REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_MOSI_PIN) -#endif -#if PIN_EXISTS(L6470_CHAIN_SS) - REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_SS_PIN) -#endif -#if PIN_EXISTS(L6470_RESET_CHAIN) - REPORT_NAME_DIGITAL(__LINE__, L6470_RESET_CHAIN_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 @@ -1859,27 +2154,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 @@ -1892,7 +2211,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 @@ -1911,3 +2233,84 @@ #if PIN_EXISTS(TFT_RESET) 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 +// +#if _EXISTS(UNUSED_PWM) + REPORT_NAME_DIGITAL(__LINE__, UNUSED_PWM) +#endif diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h index c3c217557beb..6191532b1c11 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 @@ -417,6 +487,11 @@ #define NUM_SERVO_PLUGS 4 #endif +// Only used within pins files +#undef NEEDS_X_MINMAX +#undef NEEDS_Y_MINMAX +#undef NEEDS_Z_MINMAX + // // Assign endstop pins for boards with only 3 connectors // @@ -645,6 +720,8 @@ #undef FIL_RUNOUT2_PIN #endif +#undef LCD_PINS_DEFINED + #ifndef LCD_PINS_D4 #define LCD_PINS_D4 -1 #endif @@ -1642,6 +1719,24 @@ #if !defined(USE_ZMAX_PLUG) && _STOP_IN_USE(_ZMAX_) #define USE_ZMAX_PLUG #endif +#if !defined(USE_IMAX_PLUG) && _STOP_IN_USE(_IMAX_) + #define USE_IMAX_PLUG +#endif +#if !defined(USE_JMAX_PLUG) && _STOP_IN_USE(_JMAX_) + #define USE_JMAX_PLUG +#endif +#if !defined(USE_KMAX_PLUG) && _STOP_IN_USE(_KMAX_) + #define USE_KMAX_PLUG +#endif +#if !defined(USE_UMAX_PLUG) && _STOP_IN_USE(_UMAX_) + #define USE_UMAX_PLUG +#endif +#if !defined(USE_VMAX_PLUG) && _STOP_IN_USE(_VMAX_) + #define USE_VMAX_PLUG +#endif +#if !defined(USE_WMAX_PLUG) && _STOP_IN_USE(_WMAX_) + #define USE_WMAX_PLUG +#endif #if !defined(USE_XMIN_PLUG) && _STOP_IN_USE(_XMIN_) #define USE_XMIN_PLUG #endif @@ -1651,6 +1746,24 @@ #if !defined(USE_ZMIN_PLUG) && _STOP_IN_USE(_ZMIN_) #define USE_ZMIN_PLUG #endif +#if !defined(USE_IMIN_PLUG) && _STOP_IN_USE(_IMIN_) + #define USE_IMIN_PLUG +#endif +#if !defined(USE_JMIN_PLUG) && _STOP_IN_USE(_JMIN_) + #define USE_JMIN_PLUG +#endif +#if !defined(USE_KMIN_PLUG) && _STOP_IN_USE(_KMIN_) + #define USE_KMIN_PLUG +#endif +#if !defined(USE_UMIN_PLUG) && _STOP_IN_USE(_UMIN_) + #define USE_UMIN_PLUG +#endif +#if !defined(USE_VMIN_PLUG) && _STOP_IN_USE(_VMIN_) + #define USE_VMIN_PLUG +#endif +#if !defined(USE_WMIN_PLUG) && _STOP_IN_USE(_WMIN_) + #define USE_WMIN_PLUG +#endif #undef _STOP_IN_USE #if !USES_Z_MIN_PROBE_PIN #undef Z_MIN_PROBE_PIN @@ -1787,6 +1900,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/rambo/pins_EINSY_RAMBO.h b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h index 9150bf13655d..c28fbd059c60 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h @@ -23,6 +23,8 @@ /** * Einsy-Rambo pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Einsy-Rambo/Schematic%20Prints_Einsy%20Rambo_1.1a.PDF + * Origin: https://github.com/ultimachine/Einsy-Rambo/blob/1.1a/board/Project%20Outputs/Schematic%20Prints_Einsy%20Rambo_1.1a.PDF */ #include "env_validate.h" @@ -35,8 +37,8 @@ // // TMC2130 Configuration_adv defaults for EinsyRambo // -#if !AXIS_DRIVER_TYPE_X(TMC2130) || !AXIS_DRIVER_TYPE_Y(TMC2130) || !AXIS_DRIVER_TYPE_Z(TMC2130) || !AXIS_DRIVER_TYPE_E0(TMC2130) - #error "You must set ([XYZ]|E0)_DRIVER_TYPE to TMC2130 in Configuration.h for EinsyRambo." +#if (HAS_X_AXIS && !AXIS_DRIVER_TYPE_X(TMC2130)) || (HAS_Y_AXIS && !AXIS_DRIVER_TYPE_Y(TMC2130)) || (HAS_Z_AXIS && !AXIS_DRIVER_TYPE_Z(TMC2130)) || (HAS_EXTRUDERS && !AXIS_DRIVER_TYPE_E0(TMC2130)) + #error "For EinsyRambo you must set all *_DRIVER_TYPE to TMC2130 in Configuration.h." #endif // TMC2130 Diag Pins (currently just for reference) @@ -136,27 +138,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 +210,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 +231,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 diff --git a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h index 413eb8c98cc6..dc91c47e9a1b 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h @@ -23,6 +23,10 @@ /** * Einsy-Retro pin assignments + * Schematic (1.0b): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Einsy-Retro/Schematic%20Prints_EinsyRetro_1.0b.PDF + * Origin (1.0b): https://github.com/ultimachine/EinsyRetro/blob/master/board/Project%20Outputs/Schematic%20Prints_EinsyRetro_1.0b.PDF + * Schematic (1.0c): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Einsy-Retro/Schematic%20Prints_EinsyRetro_1.0c.PDF + * Origin (1.0c): https://github.com/ultimachine/EinsyRetro/blob/master/board/Project%20Outputs/Schematic%20Prints_EinsyRetro_1.0c.PDF */ #include "env_validate.h" diff --git a/Marlin/src/pins/rambo/pins_MINIRAMBO.h b/Marlin/src/pins/rambo/pins_MINIRAMBO.h index 31d44f2b34ba..353fbd664111 100644 --- a/Marlin/src/pins/rambo/pins_MINIRAMBO.h +++ b/Marlin/src/pins/rambo/pins_MINIRAMBO.h @@ -23,6 +23,10 @@ /** * Mini-RAMBo pin assignments + * Schematic (1.3a): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Mini%20RAMBo/Mini-Rambo.PDF + * Origin (1.3a): https://github.com/ultimachine/Mini-Rambo/blob/1.3a/board/Project%20Outputs%20for%20Mini-Rambo/Mini-Rambo.PDF + * Schematic (1.0a): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Mini%20RAMBo%201.0a/Mini-Rambo.PDF + * Origin (1.0a): https://github.com/ultimachine/Mini-Rambo/blob/v1.1b/board/Project%20Outputs%20for%20Mini-Rambo/Mini-Rambo.PDF */ #include "env_validate.h" diff --git a/Marlin/src/pins/rambo/pins_RAMBO.h b/Marlin/src/pins/rambo/pins_RAMBO.h index 5484b193b93b..3a26811538c9 100644 --- a/Marlin/src/pins/rambo/pins_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_RAMBO.h @@ -39,6 +39,8 @@ /** * Rambo pin assignments + * Schematic (1.1b): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMBo/Rambo1-1-schematic.png + * Origin (1.1b): https://www.reprap.org/wiki/File:Rambo1-1-schematic.png */ #include "env_validate.h" @@ -208,7 +210,7 @@ #define LCD_PINS_D6 74 #define LCD_PINS_D7 75 - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN 44 // NB: Panucatt's Viki 2.0 wiring diagram (v1.2) indicates that the // beeper/buzzer is connected to pin 33; however, the pin used in the diff --git a/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h b/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h index 4c2645e64b2a..ca073f5ab991 100644 --- a/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h +++ b/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h @@ -25,7 +25,7 @@ * Rambo pin assignments MODIFIED FOR Scoovo X9H ************************************************/ -#include "env_target.h" +#include "env_validate.h" #define BOARD_INFO_NAME "Scoovo X9H" @@ -143,7 +143,7 @@ #define HOME_PIN BTN_HOME -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN 44 // Pins for DOGM SPI LCD Support #define DOGLCD_A0 70 diff --git a/Marlin/src/pins/ramps/pins_3DRAG.h b/Marlin/src/pins/ramps/pins_3DRAG.h index 6f5b775af9ce..9929fa6e12a8 100644 --- a/Marlin/src/pins/ramps/pins_3DRAG.h +++ b/Marlin/src/pins/ramps/pins_3DRAG.h @@ -23,6 +23,10 @@ /** * 3DRAG (and K8200 / K8400) Arduino Mega with RAMPS v1.4 pin assignments + * This may be compatible with the standalone Controller variant. + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/3DRAG%20+%20Controller/Schema_base.jpg + * Origin: https://reprap.org/wiki/File:Schema_base.jpg + * ATmega2560, ATmega1280 */ #ifndef BOARD_INFO_NAME @@ -66,6 +70,8 @@ #define MOSFET_C_PIN 9 #define MOSFET_D_PIN 12 +#define HEATER_2_PIN 6 + // // Misc. Functions // @@ -122,16 +128,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 +135,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 +143,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 +160,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_AZTEEG_X3.h b/Marlin/src/pins/ramps/pins_AZTEEG_X3.h index 44d8341c11d6..4d3722655df9 100644 --- a/Marlin/src/pins/ramps/pins_AZTEEG_X3.h +++ b/Marlin/src/pins/ramps/pins_AZTEEG_X3.h @@ -23,6 +23,9 @@ /** * AZTEEG_X3 Arduino Mega with RAMPS v1.4 pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/AZTEEG_X3/AZTEEG%20X3%20PUB%20v1.12.pdf + * Origin: http://files.panucatt.com/datasheets/azteegx3_designfiles.zip + * ATmega2560 */ #define REQUIRE_MEGA2560 @@ -51,7 +54,7 @@ #undef STAT_LED_RED_PIN #undef STAT_LED_BLUE_PIN -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) #undef DOGLCD_A0 #undef DOGLCD_CS diff --git a/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h b/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h index 5dc191cd2016..2c666a6f16a4 100644 --- a/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h +++ b/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h @@ -23,6 +23,9 @@ /** * AZTEEG_X3_PRO (Arduino Mega) pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/AZTEEG_X3_PRO/AZTEEG%20X3%20PRO%201.0%20PUB.pdf + * Origin: http://files.panucatt.com/datasheets/x3pro_sch_v1.0.zip + * ATmega2560 */ #define REQUIRE_MEGA2560 @@ -142,7 +145,7 @@ #undef BEEPER_PIN #define BEEPER_PIN 33 -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) #undef SD_DETECT_PIN #define SD_DETECT_PIN 49 // For easy adapter board #undef BEEPER_PIN @@ -169,7 +172,7 @@ #undef SPINDLE_DIR_PIN #if HAS_CUTTER // EXP2 header - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define BTN_EN2 31 // Pin 7 needed for Spindle PWM #endif #define SPINDLE_LASER_PWM_PIN 7 // Hardware PWM diff --git a/Marlin/src/pins/ramps/pins_BAM_DICE_DUE.h b/Marlin/src/pins/ramps/pins_BAM_DICE_DUE.h index fa622ffb15dc..f3439aa6bbba 100644 --- a/Marlin/src/pins/ramps/pins_BAM_DICE_DUE.h +++ b/Marlin/src/pins/ramps/pins_BAM_DICE_DUE.h @@ -23,6 +23,9 @@ /** * BAM&DICE Due (Arduino Mega) pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/BAM&DICE%20Due/2PRINTBETA-BAM&DICE-DUE-V1.1-sch.pdf + * Origin: http://www.2printbeta.de/download/2PRINTBETA-BAM&DICE-DUE-V1.1-sch.pdf + * ATmega2560, ATmega1280 */ #if HOTENDS > 2 || E_STEPPERS > 2 diff --git a/Marlin/src/pins/ramps/pins_BIQU_KFB_2.h b/Marlin/src/pins/ramps/pins_BIQU_KFB_2.h index 58a62fb8bc74..6155e9842aad 100644 --- a/Marlin/src/pins/ramps/pins_BIQU_KFB_2.h +++ b/Marlin/src/pins/ramps/pins_BIQU_KFB_2.h @@ -23,6 +23,7 @@ /** * KFB 2.0 – Arduino Mega2560 with RAMPS v1.4 pin assignments + * ATmega2560 */ #if HOTENDS > 2 || E_STEPPERS > 2 diff --git a/Marlin/src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h b/Marlin/src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h index 4a54b85ae0bd..cd3ada25bf30 100644 --- a/Marlin/src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h +++ b/Marlin/src/pins/ramps/pins_BQ_ZUM_MEGA_3D.h @@ -23,6 +23,9 @@ /** * bq ZUM Mega 3D board definition + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/bq%20ZUM%20Mega%203D/Zum%20Mega%203D.PDF + * Origin: https://github.com/bq/zum/blob/master/zum-mega3d/Zum%20Mega%203D.PDF + * ATmega2560 */ #define REQUIRE_MEGA2560 diff --git a/Marlin/src/pins/ramps/pins_COPYMASTER_3D.h b/Marlin/src/pins/ramps/pins_COPYMASTER_3D.h index 020941027aaf..1285d0244c2e 100644 --- a/Marlin/src/pins/ramps/pins_COPYMASTER_3D.h +++ b/Marlin/src/pins/ramps/pins_COPYMASTER_3D.h @@ -21,6 +21,8 @@ */ #pragma once +// ATmega2560 + #define BOARD_INFO_NAME "Copymaster 3D RAMPS" #define Z_STEP_PIN 47 diff --git a/Marlin/src/pins/ramps/pins_DAGOMA_F5.h b/Marlin/src/pins/ramps/pins_DAGOMA_F5.h index e1bd2ec4ed54..9760ccbef52a 100644 --- a/Marlin/src/pins/ramps/pins_DAGOMA_F5.h +++ b/Marlin/src/pins/ramps/pins_DAGOMA_F5.h @@ -21,6 +21,8 @@ */ #pragma once +// ATmega2560 + #if HOTENDS > 2 || E_STEPPERS > 2 #error "Dagoma3D F5 supports up to 2 hotends / E steppers." #endif diff --git a/Marlin/src/pins/ramps/pins_DUPLICATOR_I3_PLUS.h b/Marlin/src/pins/ramps/pins_DUPLICATOR_I3_PLUS.h index 1a4b83f02dce..7e370a398bcd 100644 --- a/Marlin/src/pins/ramps/pins_DUPLICATOR_I3_PLUS.h +++ b/Marlin/src/pins/ramps/pins_DUPLICATOR_I3_PLUS.h @@ -23,6 +23,7 @@ /** * Wanhao Duplicator i3 Plus pin assignments + * ATmega2560 */ #define REQUIRE_MEGA2560 diff --git a/Marlin/src/pins/ramps/pins_FELIX2.h b/Marlin/src/pins/ramps/pins_FELIX2.h index 3e7849d71f23..48ef896e96b5 100644 --- a/Marlin/src/pins/ramps/pins_FELIX2.h +++ b/Marlin/src/pins/ramps/pins_FELIX2.h @@ -23,6 +23,7 @@ /** * FELIXprinters v2.0/3.0 (RAMPS v1.4) pin assignments + * ATmega2560, ATmega1280 */ #if HOTENDS > 2 || E_STEPPERS > 2 diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h b/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h index a6791ff7c8b5..7bed4c088433 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR.h @@ -23,6 +23,7 @@ /** * Formbot Raptor pin assignments + * ATmega2560 */ #define REQUIRE_MEGA2560 diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR2.h b/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR2.h index 4fb10bfd356b..f0e86ac4a7f3 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR2.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_RAPTOR2.h @@ -23,6 +23,7 @@ /** * Formbot Raptor 2 pin assignments + * ATmega2560 */ #define BOARD_INFO_NAME "Formbot Raptor2" diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h b/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h index 17d3abc71f37..a5ca7e86073f 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_TREX2PLUS.h @@ -22,7 +22,8 @@ #pragma once /** - * Formbot pin assignments + * Formbot T-Rex 2+ pin assignments + * ATmega2560 */ #define REQUIRE_MEGA2560 diff --git a/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h b/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h index e23a63994faa..2fa3d60f6722 100644 --- a/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h +++ b/Marlin/src/pins/ramps/pins_FORMBOT_TREX3.h @@ -22,7 +22,8 @@ #pragma once /** - * Formbot pin assignments + * Formbot T-Rex 3 pin assignments + * ATmega2560 */ #define REQUIRE_MEGA2560 diff --git a/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h b/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h index b8de260909b6..9f23647c42b2 100644 --- a/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h +++ b/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h @@ -23,6 +23,9 @@ // // FYSETC F6 1.3 (and 1.4) pin assignments +// Schematic (1.3): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/FYSETC%20F6%201.3/F6_V13.pdf +// Origin: https://github.com/FYSETC/FYSETC-F6/blob/master/Hardware/V1.3/F6_V13.pdf +// ATmega2560 // #if NOT_TARGET(__AVR_ATmega2560__) diff --git a/Marlin/src/pins/ramps/pins_FYSETC_F6_14.h b/Marlin/src/pins/ramps/pins_FYSETC_F6_14.h index 1fc24154b733..9604d0ecbfc1 100644 --- a/Marlin/src/pins/ramps/pins_FYSETC_F6_14.h +++ b/Marlin/src/pins/ramps/pins_FYSETC_F6_14.h @@ -23,6 +23,9 @@ // // FYSETC F6 v1.4 pin assignments +// Schematic (1.4): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/FYSETC%20F6%20v1.4/F6%20V1.4%20Sch.pdf +// Origin (1.4): https://github.com/FYSETC/FYSETC-F6/blob/master/Hardware/V1.4/F6%20V1.4%20Sch.pdf +// ATmega2560 // #define BOARD_INFO_NAME "FYSETC F6 1.4" diff --git a/Marlin/src/pins/ramps/pins_K8200.h b/Marlin/src/pins/ramps/pins_K8200.h index 395e1ccca50e..d2557b26c3ee 100644 --- a/Marlin/src/pins/ramps/pins_K8200.h +++ b/Marlin/src/pins/ramps/pins_K8200.h @@ -24,6 +24,9 @@ /** * K8200 Arduino Mega with RAMPS v1.3 pin assignments * Identical to 3DRAG + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/Velleman%20K8200/K8200diagram.jpg + * Origin: https://www.velleman.eu/images/tmp/K8200diagram.jpg + * ATmega2560 */ #define BOARD_INFO_NAME "Velleman K8200" diff --git a/Marlin/src/pins/ramps/pins_K8400.h b/Marlin/src/pins/ramps/pins_K8400.h index 36c438aca2de..56ec66191b32 100644 --- a/Marlin/src/pins/ramps/pins_K8400.h +++ b/Marlin/src/pins/ramps/pins_K8400.h @@ -24,6 +24,9 @@ /** * Velleman K8400 (Vertex) * 3DRAG clone + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/Velleman%20K8400/k8400-schema-electronique.jpg + * Origin: https://filimprimante3d.fr/documents/k8400-schema-electronique.jpg + * ATmega2560, ATmega1280 * * K8400 has some minor differences over a normal 3Drag: * - No X/Y max endstops @@ -50,6 +53,10 @@ #define X_STOP_PIN 3 #define Y_STOP_PIN 14 +#if EITHER(BLTOUCH, TOUCH_MI_PROBE) + #define INVERTED_PROBE_STATE +#endif + #include "pins_3DRAG.h" // ... RAMPS // diff --git a/Marlin/src/pins/ramps/pins_K8600.h b/Marlin/src/pins/ramps/pins_K8600.h index a9613e8eb27f..3081b0436188 100644 --- a/Marlin/src/pins/ramps/pins_K8600.h +++ b/Marlin/src/pins/ramps/pins_K8600.h @@ -23,6 +23,7 @@ /** * VERTEX NANO Arduino Mega with RAMPS EFB v1.4 pin assignments. + * ATmega2560, ATmega1280 */ #if HAS_MULTI_HOTEND @@ -37,8 +38,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 +48,7 @@ // // Heaters / Fans // +#define HEATER_BED_PIN -1 #define FAN_PIN 8 // @@ -56,28 +57,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 +70,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_K8800.h b/Marlin/src/pins/ramps/pins_K8800.h index f1362ec61d34..a9669764cef1 100644 --- a/Marlin/src/pins/ramps/pins_K8800.h +++ b/Marlin/src/pins/ramps/pins_K8800.h @@ -23,6 +23,9 @@ /** * Velleman K8800 (Vertex) + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/Velleman%20K8800/K8800-schematic-V1.4.pdf + * Origin: https://www.velleman.eu/downloads/files/vertex-delta/schematics/K8800-schematic-V1.4.pdf + * ATmega2560, ATmega1280 */ #include "env_validate.h" @@ -105,9 +108,6 @@ #define LCD_PINS_D6 33 #define LCD_PINS_D7 31 - #define LCD_CONTRAST_MIN 0 - #define LCD_CONTRAST_MAX 100 - #define LCD_CONTRAST_INIT 30 //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #if IS_NEWPANEL diff --git a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h index af1d33c83c60..d9759153c334 100644 --- a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h +++ b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h @@ -23,6 +23,7 @@ /** * Longer3D LK1/LK4/LK5 Pro board pin assignments + * ATmega2560 */ #define REQUIRE_MEGA2560 @@ -33,56 +34,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 +105,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 +123,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_MAKEBOARD_MINI.h b/Marlin/src/pins/ramps/pins_MAKEBOARD_MINI.h index a42dba874f41..2ab463d681af 100644 --- a/Marlin/src/pins/ramps/pins_MAKEBOARD_MINI.h +++ b/Marlin/src/pins/ramps/pins_MAKEBOARD_MINI.h @@ -21,6 +21,8 @@ */ #pragma once +// ATmega2560 + #define BOARD_INFO_NAME "MAKEboard Mini" // diff --git a/Marlin/src/pins/ramps/pins_MKS_BASE_10.h b/Marlin/src/pins/ramps/pins_MKS_BASE_10.h index 64efa46c0550..8d46ac36fa6e 100644 --- a/Marlin/src/pins/ramps/pins_MKS_BASE_10.h +++ b/Marlin/src/pins/ramps/pins_MKS_BASE_10.h @@ -23,6 +23,12 @@ /** * MKS BASE 1.0 – Arduino Mega2560 with RAMPS v1.4 pin assignments + * Schematics: + * - https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/MKS%20BASE%201.0/PAGE1.pdf + * - https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/MKS%20BASE%201.0/PAGE2.pdf + * - https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/MKS%20BASE%201.0/PAGE3.pdf + * Origin: https://reprap.org/wiki/File:MKS_Base_V1.0_source.zip + * ATmega2560 * * Rev B - Override pin definitions for CASE_LIGHT and M3/M4/M5 spindle control */ diff --git a/Marlin/src/pins/ramps/pins_MKS_BASE_14.h b/Marlin/src/pins/ramps/pins_MKS_BASE_14.h index 7e2a722cf222..d302def795b1 100644 --- a/Marlin/src/pins/ramps/pins_MKS_BASE_14.h +++ b/Marlin/src/pins/ramps/pins_MKS_BASE_14.h @@ -23,6 +23,7 @@ /** * MKS BASE v1.4 with A4982 stepper drivers and digital micro-stepping + * ATmega2560 */ #if HOTENDS > 2 || E_STEPPERS > 2 diff --git a/Marlin/src/pins/ramps/pins_MKS_BASE_15.h b/Marlin/src/pins/ramps/pins_MKS_BASE_15.h index 5fedd3f97c8a..1d93ec5cf9bf 100644 --- a/Marlin/src/pins/ramps/pins_MKS_BASE_15.h +++ b/Marlin/src/pins/ramps/pins_MKS_BASE_15.h @@ -23,6 +23,7 @@ /** * MKS BASE v1.5 with A4982 stepper drivers and digital micro-stepping + * ATmega2560 */ #if HOTENDS > 2 || E_STEPPERS > 2 diff --git a/Marlin/src/pins/ramps/pins_MKS_BASE_16.h b/Marlin/src/pins/ramps/pins_MKS_BASE_16.h index 63e0b51d3cc5..765a601fd029 100644 --- a/Marlin/src/pins/ramps/pins_MKS_BASE_16.h +++ b/Marlin/src/pins/ramps/pins_MKS_BASE_16.h @@ -23,6 +23,9 @@ /** * MKS BASE v1.6 with A4982 stepper drivers and digital micro-stepping + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/MKS%20BASE%201.6/MKS%20Base%20V1.6_004%20SCH.pdf + * Origin: https://github.com/makerbase-mks/MKS-BASE/blob/master/hardware/MKS%20Base%20V1.6_004/MKS%20Base%20V1.6_004%20SCH.pdf + * ATmega2560 */ #if HOTENDS > 2 || E_STEPPERS > 2 diff --git a/Marlin/src/pins/ramps/pins_MKS_BASE_HEROIC.h b/Marlin/src/pins/ramps/pins_MKS_BASE_HEROIC.h index 973f924e7c16..c50f28a40734 100644 --- a/Marlin/src/pins/ramps/pins_MKS_BASE_HEROIC.h +++ b/Marlin/src/pins/ramps/pins_MKS_BASE_HEROIC.h @@ -23,6 +23,7 @@ /** * MKS BASE with Heroic HR4982 stepper drivers + * ATmega2560 */ #include "pins_MKS_BASE_15.h" // ... MKS_BASE_common ... RAMPS diff --git a/Marlin/src/pins/ramps/pins_MKS_BASE_common.h b/Marlin/src/pins/ramps/pins_MKS_BASE_common.h index 9047a4bcf0e6..7608745a4b1d 100644 --- a/Marlin/src/pins/ramps/pins_MKS_BASE_common.h +++ b/Marlin/src/pins/ramps/pins_MKS_BASE_common.h @@ -23,6 +23,7 @@ /** * MKS BASE – Arduino Mega2560 with RAMPS pin assignments + * ATmega2560 */ #ifndef BOARD_INFO_NAME diff --git a/Marlin/src/pins/ramps/pins_MKS_GEN_13.h b/Marlin/src/pins/ramps/pins_MKS_GEN_13.h index bb7b55893ec1..5c13288f8558 100644 --- a/Marlin/src/pins/ramps/pins_MKS_GEN_13.h +++ b/Marlin/src/pins/ramps/pins_MKS_GEN_13.h @@ -23,6 +23,9 @@ /** * Arduino Mega with RAMPS v1.4 adjusted pin assignments + * Schematic (1.4): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/MKS%20GEN%20v1.4/MKS%20GEN%20V1.4_004%20SCH.pdf + * Origin (1.4): https://github.com/makerbase-mks/MKS-GEN/blob/master/hardware/MKS%20GEN%20V1.4_004/MKS%20GEN%20V1.4_004%20SCH.pdf + * ATmega2560, ATmega1280 * * MKS GEN v1.3 (Extruder, Fan, Bed) * MKS GEN v1.3 (Extruder, Extruder, Fan, Bed) @@ -40,7 +43,9 @@ // Heaters / Fans // // Power outputs EFBF or EFBE -#define MOSFET_D_PIN 7 +// +#define MOSFET_B_PIN 7 +#define FAN_PIN 9 // // PSU / SERVO @@ -54,13 +59,13 @@ #include "pins_RAMPS.h" -#undef EXP2_03_PIN -#define EXP2_03_PIN -1 // RESET +#undef EXP2_08_PIN +#define EXP2_08_PIN -1 // RESET // // LCD / Controller // -#if ANY(VIKI2, miniVIKI) +#if EITHER(VIKI2, miniVIKI) /** * VIKI2 Has two groups of wires with... * @@ -85,11 +90,11 @@ * This configuration uses the following arrangement: * * ------ ------ - * ENCB |10 9 | ENCA MISO |10 9 | SCK - * BLUE_LED | 8 7 | RED_LED ENCBTN | 8 7 | SDCS - * KILL 6 5 | BEEPER 6 5 | MOSI - * A0 | 4 3 | LCD_CS SDCD | 4 3 | - * GND | 2 1 | 5V GND | 2 1 | -- + * ENCB | 1 2 | ENCA MISO | 1 2 | SCK + * BLUE_LED | 3 4 | RED_LED ENCBTN | 3 4 | SDCS + * KILL 5 6 | BEEPER 5 6 | MOSI + * A0 | 7 8 | LCD_CS SDCD | 7 8 | + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ @@ -107,24 +112,24 @@ // // VIKI2 12-wire lead // - #define SD_DETECT_PIN EXP2_04_PIN // SDCD orange/white - #define BTN_EN1 EXP1_09_PIN // ENCA white - #define BTN_EN2 EXP1_10_PIN // ENCB green - #define BTN_ENC EXP2_08_PIN // ENCBTN purple - #define DOGLCD_A0 EXP1_04_PIN // A0 brown - #define DOGLCD_CS EXP1_03_PIN // LCS green/white + #define SD_DETECT_PIN EXP2_07_PIN // SDCD orange/white + #define BTN_EN1 EXP1_02_PIN // ENCA white + #define BTN_EN2 EXP1_01_PIN // ENCB green + #define BTN_ENC EXP2_03_PIN // ENCBTN purple + #define DOGLCD_A0 EXP1_07_PIN // A0 brown + #define DOGLCD_CS EXP1_08_PIN // LCS green/white - // EXP2_10_PIN gray MISO - // EXP2_05_PIN yellow MOSI - // EXP2_09_PIN orange SCK + // EXP2_01_PIN gray MISO + // EXP2_06_PIN yellow MOSI + // EXP2_02_PIN orange SCK - //#define SDSS EXP2_07_PIN // SDCS blue + //#define SDSS EXP2_04_PIN // SDCS blue // // VIKI2 4-wire lead // - #define KILL_PIN EXP1_06_PIN // BTN blue - #define BEEPER_PIN EXP1_05_PIN // BUZZER green - #define STAT_LED_RED_PIN EXP1_07_PIN // RED-LED yellow - #define STAT_LED_BLUE_PIN EXP1_08_PIN // BLUE-LED white + #define KILL_PIN EXP1_05_PIN // BTN blue + #define BEEPER_PIN EXP1_06_PIN // BUZZER green + #define STAT_LED_RED_PIN EXP1_04_PIN // RED-LED yellow + #define STAT_LED_BLUE_PIN EXP1_03_PIN // BLUE-LED white #endif diff --git a/Marlin/src/pins/ramps/pins_MKS_GEN_L.h b/Marlin/src/pins/ramps/pins_MKS_GEN_L.h index ca1f1338164e..9faacf24fc5c 100644 --- a/Marlin/src/pins/ramps/pins_MKS_GEN_L.h +++ b/Marlin/src/pins/ramps/pins_MKS_GEN_L.h @@ -23,6 +23,9 @@ /** * MKS GEN L – Arduino Mega2560 with RAMPS v1.4 pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/MKS%20GEN%20L%20v1.0/MKS%20Gen_L%20V1.0_008%20SCH.pdf + * Origin: https://github.com/makerbase-mks/MKS-GEN_L/blob/master/hardware/MKS%20Gen_L%20V1.0_008/MKS%20Gen_L%20V1.0_008%20SCH.pdf + * ATmega2560, ATmega1280 */ #if HOTENDS > 2 || E_STEPPERS > 2 diff --git a/Marlin/src/pins/ramps/pins_MKS_GEN_L_V2.h b/Marlin/src/pins/ramps/pins_MKS_GEN_L_V2.h index 0378b166a2d4..d82c4353fd03 100644 --- a/Marlin/src/pins/ramps/pins_MKS_GEN_L_V2.h +++ b/Marlin/src/pins/ramps/pins_MKS_GEN_L_V2.h @@ -23,6 +23,9 @@ /** * MKS GEN L V2 – Arduino Mega2560 with RAMPS v1.4 pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/MKS%20GEN%20L%20V2.0/MKS%20Gen_L%20V2.0_001%20SCH.pdf + * Origin: https://github.com/makerbase-mks/MKS-GEN_L/blob/master/hardware/MKS%20Gen_L%20V2.0_001/MKS%20Gen_L%20V2.0_001%20SCH.pdf + * ATmega2560 */ #if HOTENDS > 2 || E_STEPPERS > 2 diff --git a/Marlin/src/pins/ramps/pins_MKS_GEN_L_V21.h b/Marlin/src/pins/ramps/pins_MKS_GEN_L_V21.h index d508cb453f4d..c2ab34c82560 100644 --- a/Marlin/src/pins/ramps/pins_MKS_GEN_L_V21.h +++ b/Marlin/src/pins/ramps/pins_MKS_GEN_L_V21.h @@ -23,6 +23,9 @@ /** * MKS GEN L V2 – Arduino Mega2560 with RAMPS v1.4 pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/MKS%20GEN%20L%20V2.1/MKS%20GEN_L%20V2.1_001%20SCH.pdf + * Origin: https://github.com/makerbase-mks/MKS-GEN_L/blob/master/hardware/MKS%20Gen_L%20V2.1_001/MKS%20GEN_L%20V2.1_001%20SCH.pdf + * ATmega2560 */ #if HOTENDS > 2 || E_STEPPERS > 2 diff --git a/Marlin/src/pins/ramps/pins_ORTUR_4.h b/Marlin/src/pins/ramps/pins_ORTUR_4.h index bc86c1a8c66a..7f0fe93084b7 100644 --- a/Marlin/src/pins/ramps/pins_ORTUR_4.h +++ b/Marlin/src/pins/ramps/pins_ORTUR_4.h @@ -23,6 +23,7 @@ /** * Ortur 4 Arduino Mega based on RAMPS v1.4 pin assignments + * ATmega2560 */ #define BOARD_INFO_NAME "Ortur 4.3" @@ -75,31 +76,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_PXMALION_CORE_I3.h b/Marlin/src/pins/ramps/pins_PXMALION_CORE_I3.h index 12c40c7dca03..ee0633992e60 100644 --- a/Marlin/src/pins/ramps/pins_PXMALION_CORE_I3.h +++ b/Marlin/src/pins/ramps/pins_PXMALION_CORE_I3.h @@ -22,6 +22,7 @@ /** * Pxmalion Core i3 - https://github.com/Pxmalion + * ATmega2560 */ #include "env_validate.h" diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index 199be4a1c92a..3d4e0426f6ad 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -23,6 +23,7 @@ /** * Arduino Mega with RAMPS v1.4 (or v1.3) pin assignments + * ATmega2560, ATmega1280 * * Applies to the following boards: * @@ -78,31 +79,56 @@ #define SERVO3_PIN 4 #endif +// +// Foam Cutter requirements +// + +#if ENABLED(FOAMCUTTER_XYUV) + #ifndef MOSFET_C_PIN + #define MOSFET_C_PIN -1 + #endif + #if HAS_CUTTER && !defined(SPINDLE_LASER_ENA_PIN) && NUM_SERVOS < 2 + #define SPINDLE_LASER_PWM_PIN 8 // Hardware PWM + #endif + #ifndef Z_MIN_PIN + #define Z_MIN_PIN -1 + #endif + #ifndef Z_MAX_PIN + #define Z_MAX_PIN -1 + #endif + #ifndef I_STOP_PIN + #define I_STOP_PIN 18 // Z- + #endif + #ifndef J_STOP_PIN + #define J_STOP_PIN 19 // Z+ + #endif +#endif + // // Limit Switches // #ifndef X_STOP_PIN #ifndef X_MIN_PIN - #define X_MIN_PIN 3 + #define X_MIN_PIN 3 // X- #endif #ifndef X_MAX_PIN - #define X_MAX_PIN 2 + #define X_MAX_PIN 2 // X+ #endif #endif #ifndef Y_STOP_PIN #ifndef Y_MIN_PIN - #define Y_MIN_PIN 14 + #define Y_MIN_PIN 14 // Y- #endif #ifndef Y_MAX_PIN - #define Y_MAX_PIN 15 + #define Y_MAX_PIN 15 // Y+ #endif #endif #ifndef Z_STOP_PIN #ifndef Z_MIN_PIN - #define Z_MIN_PIN 18 + #define Z_MIN_PIN 18 // Z- #endif #ifndef Z_MAX_PIN - #define Z_MAX_PIN 19 + #define Z_MAX_PIN 19 // Z+ #endif #endif @@ -208,16 +234,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 @@ -272,7 +304,9 @@ #if HAS_CUTTER && !defined(SPINDLE_LASER_ENA_PIN) #if NUM_SERVOS < 2 // Use servo connector if possible #define SPINDLE_LASER_ENA_PIN 4 // Pullup or pulldown! - #define SPINDLE_LASER_PWM_PIN 6 // Hardware PWM + #ifndef SPINDLE_LASER_PWM_PIN + #define SPINDLE_LASER_PWM_PIN 6 // Hardware PWM + #endif #define SPINDLE_DIR_PIN 5 #elif HAS_FREE_AUX2_PINS #define SPINDLE_LASER_ENA_PIN 40 // Pullup or pulldown! @@ -486,62 +520,62 @@ * LCD adapters come in different variants. The socket keys can be * on either side, and may be backwards on some boards / displays. */ -#ifndef EXP1_03_PIN +#ifndef EXP1_08_PIN - #define EXP1_03_PIN AUX4_13_PIN - #define EXP1_04_PIN AUX4_14_PIN - #define EXP1_05_PIN AUX4_15_PIN - #define EXP1_06_PIN AUX4_16_PIN - #define EXP1_07_PIN AUX4_18_PIN - #define EXP1_08_PIN AUX4_17_PIN + #define EXP1_03_PIN AUX4_17_PIN + #define EXP1_04_PIN AUX4_18_PIN + #define EXP1_05_PIN AUX4_16_PIN + #define EXP1_06_PIN AUX4_15_PIN + #define EXP1_07_PIN AUX4_14_PIN + #define EXP1_08_PIN AUX4_13_PIN - #define EXP2_04_PIN AUX3_02_PIN - #define EXP2_05_PIN AUX3_04_PIN - #define EXP2_07_PIN AUX3_06_PIN - #define EXP2_09_PIN AUX3_05_PIN - #define EXP2_10_PIN AUX3_03_PIN + #define EXP2_01_PIN AUX3_03_PIN + #define EXP2_02_PIN AUX3_05_PIN + #define EXP2_04_PIN AUX3_06_PIN + #define EXP2_06_PIN AUX3_04_PIN + #define EXP2_07_PIN AUX3_02_PIN #if ENABLED(G3D_PANEL) /** Gadgets3D Smart Adapter * ------ ------ - * 4-11 |10 9 | 4-12 (MISO) 3-03 |10 9 | 3-05 (SCK) - * 4-17 | 8 7 | 4-18 4-10 | 8 7 | 3-06 - * 4-16 6 5 | 4-15 4-09 6 5 | 3-04 (MOSI) - * 4-14 | 4 3 | 4-13 3-02 | 4 3 | 4-07 - * (GND) 4-02 | 2 1 | 4-01 (5V) -- | 2 1 | -- + * 4-11 | 1 2 | 4-12 (MISO) 3-03 | 1 2 | 3-05 (SCK) + * 4-17 | 3 4 | 4-18 4-10 | 3 4 | 3-06 + * 4-16 5 6 | 4-15 4-09 5 6 | 3-04 (MOSI) + * 4-14 | 7 8 | 4-13 3-02 | 7 8 | 4-07 + * (GND) 4-02 | 9 10 | 4-01 (5V) -- | 9 10 | -- * ------ ------ * EXP1 EXP2 */ - #define EXP1_09_PIN AUX4_12_PIN - #define EXP1_10_PIN AUX4_11_PIN + #define EXP1_01_PIN AUX4_11_PIN + #define EXP1_02_PIN AUX4_12_PIN - #define EXP2_03_PIN AUX4_07_PIN - #define EXP2_06_PIN AUX4_09_PIN - #define EXP2_08_PIN AUX4_10_PIN + #define EXP2_03_PIN AUX4_10_PIN + #define EXP2_05_PIN AUX4_09_PIN + #define EXP2_08_PIN AUX4_07_PIN #else /** Smart Adapter (c) RRD * ------ ------ - * 4-09 |10 9 | 4-10 (MISO) 3-03 |10 9 | 3-05 (SCK) - * 4-17 | 8 7 | 4-18 4-12 | 8 7 | 3-06 - * 4-16 6 5 | 4-15 4-11 6 5 | 3-04 (MOSI) - * 4-14 | 4 3 | 4-13 3-02 | 4 3 | 4-07 - * (GND) 3-07 | 2 1 | 3-01 (5V) (GND) 3-07 | 2 1 | -- + * 4-09 | 1 2 | 4-10 (MISO) 3-03 | 1 2 | 3-05 (SCK) + * 4-17 | 3 4 | 4-18 4-12 | 3 4 | 3-06 + * 4-16 5 6 | 4-15 4-11 5 6 | 3-04 (MOSI) + * 4-14 | 7 8 | 4-13 3-02 | 7 8 | 4-07 + * (GND) 3-07 | 9 10 | 3-01 (5V) (GND) 3-07 | 9 10 | -- * ------ ------ * EXP1 EXP2 */ - #define EXP1_09_PIN AUX4_10_PIN - #define EXP1_10_PIN AUX4_09_PIN + #define EXP1_01_PIN AUX4_09_PIN + #define EXP1_02_PIN AUX4_10_PIN #if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) - #define EXP2_03_PIN -1 // RESET - #define EXP2_06_PIN AUX4_12_PIN - #define EXP2_08_PIN AUX4_11_PIN + #define EXP2_03_PIN AUX4_11_PIN + #define EXP2_05_PIN AUX4_12_PIN + #define EXP2_08_PIN -1 // RESET #else - #define EXP2_03_PIN AUX4_07_PIN - #define EXP2_06_PIN AUX4_11_PIN - #define EXP2_08_PIN AUX4_12_PIN + #define EXP2_03_PIN AUX4_12_PIN + #define EXP2_05_PIN AUX4_11_PIN + #define EXP2_08_PIN AUX4_07_PIN #endif #endif @@ -552,7 +586,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 @@ -561,9 +595,9 @@ // #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) - #define LCD_PINS_RS EXP2_04_PIN // CS chip select /SS chip slave select - #define LCD_PINS_ENABLE EXP2_05_PIN // SID (MOSI) - #define LCD_PINS_D4 EXP2_09_PIN // SCK (CLK) clock + #define LCD_PINS_RS EXP2_07_PIN // CS chip select /SS chip slave select + #define LCD_PINS_ENABLE EXP2_06_PIN // SID (MOSI) + #define LCD_PINS_D4 EXP2_02_PIN // SCK (CLK) clock #elif BOTH(IS_NEWPANEL, PANEL_ONE) @@ -576,18 +610,18 @@ #elif ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_06_PIN + #define TFTGLCD_CS EXP2_05_PIN #else #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #if !IS_NEWPANEL - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #endif #elif ENABLED(ZONESTAR_LCD) @@ -610,25 +644,25 @@ #else #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306) - #define LCD_PINS_DC EXP1_05_PIN // Set as output on init - #define LCD_PINS_RS EXP1_04_PIN // Pull low for 1s to init + #define LCD_PINS_DC EXP1_06_PIN // Set as output on init + #define LCD_PINS_RS EXP1_07_PIN // Pull low for 1s to init // DOGM SPI LCD Support #define DOGLCD_A0 LCD_PINS_DC - #define DOGLCD_CS EXP1_07_PIN - #define DOGLCD_MOSI EXP1_08_PIN - #define DOGLCD_SCK EXP1_06_PIN + #define DOGLCD_CS EXP1_04_PIN + #define DOGLCD_MOSI EXP1_03_PIN + #define DOGLCD_SCK EXP1_05_PIN #else - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN + #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 #endif - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if !IS_NEWPANEL - #define BEEPER_PIN EXP2_06_PIN + #define BEEPER_PIN EXP2_05_PIN #endif #endif @@ -639,7 +673,7 @@ //#define SHIFT_CLK_PIN 38 //#define SHIFT_LD_PIN AUX2_08_PIN //#define SHIFT_OUT_PIN AUX2_06_PIN - //#define SHIFT_EN_PIN EXP1_08_PIN + //#define SHIFT_EN_PIN EXP1_03_PIN #endif #endif @@ -655,22 +689,20 @@ #if IS_RRD_SC - #define BEEPER_PIN EXP1_10_PIN - #if ENABLED(CR10_STOCKDISPLAY) - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN #else - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #endif - #define BTN_ENC EXP1_09_PIN + #define BTN_ENC EXP1_02_PIN #ifndef SD_DETECT_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif #ifndef KILL_PIN - #define KILL_PIN EXP2_03_PIN + #define KILL_PIN EXP2_08_PIN #endif #if ENABLED(BQ_LCD_SMART_CONTROLLER) @@ -682,7 +714,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) @@ -690,7 +724,7 @@ #define BTN_EN2 AUX4_06_PIN #define BTN_ENC AUX4_03_PIN #define LCD_SDSS SDSS - #define KILL_PIN EXP2_03_PIN + #define KILL_PIN EXP2_08_PIN #elif ENABLED(LCD_I2C_VIKI) @@ -699,98 +733,109 @@ #define BTN_ENC -1 #define LCD_SDSS SDSS - #define SD_DETECT_PIN EXP2_04_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #define DOGLCD_CS AUX4_05_PIN #define DOGLCD_A0 AUX2_07_PIN #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 - #define BEEPER_PIN EXP2_06_PIN + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP2_05_PIN + #endif #define STAT_LED_RED_PIN AUX4_03_PIN - #define STAT_LED_BLUE_PIN EXP1_09_PIN + #define STAT_LED_BLUE_PIN EXP1_02_PIN #define BTN_EN1 22 #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 - #define KILL_PIN EXP2_08_PIN + #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) - #define DOGLCD_CS EXP1_03_PIN - #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_A0 EXP1_07_PIN - #define BEEPER_PIN EXP1_06_PIN - #define LCD_BACKLIGHT_PIN EXP2_06_PIN + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP1_05_PIN + #endif + #define LCD_BACKLIGHT_PIN EXP2_05_PIN - #define BTN_EN1 EXP1_09_PIN - #define BTN_EN2 EXP1_10_PIN - #define BTN_ENC EXP2_08_PIN + #define BTN_EN1 EXP1_02_PIN + #define BTN_EN2 EXP1_01_PIN + #define BTN_ENC EXP2_03_PIN #define LCD_SDSS SDSS - #define SD_DETECT_PIN EXP2_04_PIN - #define KILL_PIN EXP2_03_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) - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_ENC EXP1_02_PIN #ifndef SD_DETECT_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif #ifndef KILL_PIN - #define KILL_PIN EXP2_03_PIN + #define KILL_PIN EXP2_08_PIN #endif #if ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN // not connected to a pin #define LCD_BACKLIGHT_PIN -1 // 65 (MKS mini12864 can't adjust backlight by software!) - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #elif ENABLED(FYSETC_MINI_12864) // From https://wiki.fysetc.com/Mini12864_Panel/ - #define DOGLCD_A0 EXP1_07_PIN - #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN - #define BTN_EN1 EXP2_06_PIN - #define BTN_EN2 EXP2_08_PIN + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems // results in LCD soft SPI mode 3, SD soft SPI mode 0 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #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_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif #elif ENABLED(MINIPANEL) - #define BEEPER_PIN AUX2_08_PIN + #ifndef BEEPER_PIN + #define BEEPER_PIN AUX2_08_PIN + #endif #define LCD_BACKLIGHT_PIN AUX2_10_PIN #define DOGLCD_A0 AUX2_07_PIN @@ -800,7 +845,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) @@ -813,37 +860,45 @@ #elif ENABLED(G3D_PANEL) - #define BEEPER_PIN EXP1_10_PIN - - #define SD_DETECT_PIN EXP2_04_PIN - #define KILL_PIN EXP2_03_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif + #define KILL_PIN EXP2_08_PIN - #define BTN_EN1 EXP2_06_PIN - #define BTN_EN2 EXP2_08_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN + #define BTN_ENC EXP1_02_PIN #elif IS_TFTGLCD_PANEL - #define SD_DETECT_PIN EXP2_04_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif #else - #define BEEPER_PIN EXP2_06_PIN + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP2_05_PIN + #endif #if ENABLED(PANEL_ONE) // Buttons connect directly to AUX-2 #define BTN_EN1 AUX2_03_PIN #define BTN_EN2 AUX2_04_PIN #define BTN_ENC AUX3_02_PIN #else - #define BTN_EN1 EXP1_10_PIN - #define BTN_EN2 EXP1_09_PIN - #define BTN_ENC EXP2_08_PIN + #define BTN_EN1 EXP1_01_PIN + #define BTN_EN2 EXP1_02_PIN + #define BTN_ENC EXP2_03_PIN #endif #endif #endif // IS_NEWPANEL -#endif // HAS_WIRED_LCD + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP1_01_PIN // Most common mapping + #endif + +#endif // HAS_WIRED_LCD && !LCD_PINS_DEFINED #if IS_RRW_KEYPAD && !HAS_ADC_BUTTONS #define SHIFT_OUT_PIN AUX2_06_PIN @@ -871,38 +926,40 @@ * * Board Display * ------ ------ - * (MISO) 50 |10 9 | 52 (SCK) 5V |10 9 | GND - * (BTN_EN2) 33 | 8 7 | 53 (SD_CS) RESET | 8 7 | (SD_DET) - * (BTN_EN1) 31 6 5 | 51 (MOSI) (MOSI) 6 5 | (LCD_CS) - * (SD_DET) 49 | 4 3 | RESET (SD_CS) | 4 3 | (MOD_RESET) - * GND | 2 1 | -- (SCK) | 2 1 | (MISO) + * (MISO) 50 | 1 2 | 52 (SCK) 5V |10 9 | GND + * (LCD_CS) 33 | 3 4 | 53 (SD_CS) RESET | 8 7 | (SD_DET) + * 31 5 6 | 51 (MOSI) (MOSI) 6 5 | (LCD_CS) + * (SD_DET) 49 | 7 8 | RESET (SD_CS) | 4 3 | (MOD_RESET) + * GND | 9 10 | -- (SCK) | 2 1 | (MISO) * ------ ------ - * EXP2 + * EXP2 EXP1 * * Needs custom cable: * * Board Adapter Display - * _________ - * EXP2-1 ----------- EXP1-10 - * EXP2-2 ----------- EXP1-9 - * EXP2-4 ----------- EXP1-8 - * EXP2-4 ----------- EXP1-7 - * EXP2-3 ----------- EXP1-6 - * EXP2-6 ----------- EXP1-5 - * EXP2-7 ----------- EXP1-4 - * EXP2-8 ----------- EXP1-3 - * EXP2-1 ----------- EXP1-2 - * EXP1-10 ---------- EXP1-1 + * ---------------------------------- + * EXP2-1 <--diode--- EXP1-1 MISO + * EXP2-2 ----------- EXP1-2 SCK + * EXP2-4 ----------- EXP1-3 MOD_RST + * EXP2-4 ----------- EXP1-4 SD_CS + * EXP2-3 ----------- EXP1-5 LCD_CS + * EXP2-6 ----------- EXP1-6 MOSI + * EXP2-7 ----------- EXP1-7 SD DET + * EXP2-8 ----------- EXP1-8 RESET + * EXP2-1 ----------- EXP1-9 MISO->GND + * EXP1-10 ---------- EXP1-10 5V * * NOTE: The MISO pin should not get a 5V signal. * To fix, insert a 1N4148 diode in the MISO line. */ - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif - #define CLCD_MOD_RESET EXP2_06_PIN - #define CLCD_SPI_CS EXP2_08_PIN + #define CLCD_MOD_RESET EXP2_05_PIN + #define CLCD_SPI_CS EXP2_03_PIN #endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 diff --git a/Marlin/src/pins/ramps/pins_RAMPS_13.h b/Marlin/src/pins/ramps/pins_RAMPS_13.h index 6e7c8cbab592..026492e4a871 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_13.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_13.h @@ -23,6 +23,7 @@ /** * Arduino Mega with RAMPS v1.3 pin assignments + * ATmega2560, ATmega1280 * * Applies to the following boards: * diff --git a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h index 3d5f5d6f9107..5e4366e259cb 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h @@ -21,6 +21,8 @@ */ #pragma once +// ATmega2560 + #if HOTENDS > 2 || E_STEPPERS > 2 #error "Creality RAMPS supports up to 2 hotends / E steppers." #endif diff --git a/Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h b/Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h index 8f9148b732ee..3ffa940c482d 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_ENDER_4.h @@ -21,6 +21,8 @@ */ #pragma once +// ATmega2560 + #if HAS_MULTI_HOTEND || E_STEPPERS > 1 #error "Ender-4 only supports 1 hotend / E stepper." #endif diff --git a/Marlin/src/pins/ramps/pins_RAMPS_OLD.h b/Marlin/src/pins/ramps/pins_RAMPS_OLD.h index 974766623594..526045c1558d 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_OLD.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_OLD.h @@ -23,6 +23,7 @@ /** * Arduino Mega with RAMPS v1.0, v1.1, v1.2 pin assignments + * ATmega2560, ATmega1280 */ #include "env_validate.h" diff --git a/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h b/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h index 0c554c353faf..f93c6919d960 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h @@ -23,6 +23,7 @@ /** * Arduino Mega with RAMPS v1.4Plus, also known as 3DYMY version, pin assignments + * ATmega2560, ATmega1280 * * Applies to the following boards: * @@ -65,30 +66,30 @@ /** 3DYMY Expansion Headers * ------ ------ - * 37 |10 9 | 35 (MISO) 50 |10 9 | 52 (SCK) - * 31 | 8 7 | 41 29 | 8 7 | 53 - * 33 6 5 | 23 25 6 5 | 51 (MOSI) - * 42 | 4 3 | 44 49 | 4 3 | 27 - * GND | 2 1 | 5V GND | 2 1 | -- + * 37 | 1 2 | 35 (MISO) 50 | 1 2 | 52 (SCK) + * 31 | 3 4 | 41 29 | 3 4 | 53 + * 33 5 6 | 23 25 5 6 | 51 (MOSI) + * 42 | 7 8 | 44 49 | 7 8 | 27 + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN 44 -#define EXP1_04_PIN 42 -#define EXP1_05_PIN 23 -#define EXP1_06_PIN 33 -#define EXP1_07_PIN 41 -#define EXP1_08_PIN 31 -#define EXP1_09_PIN 35 -#define EXP1_10_PIN 37 +#define EXP1_01_PIN 37 +#define EXP1_02_PIN 35 +#define EXP1_03_PIN 31 +#define EXP1_04_PIN 41 +#define EXP1_05_PIN 33 +#define EXP1_06_PIN 23 +#define EXP1_07_PIN 42 +#define EXP1_08_PIN 44 -#define EXP2_03_PIN 27 -#define EXP2_04_PIN 49 -#define EXP2_05_PIN 51 -#define EXP2_06_PIN 25 -#define EXP2_07_PIN 53 -#define EXP2_08_PIN 29 -#define EXP2_09_PIN 52 -#define EXP2_10_PIN 50 +#define EXP2_01_PIN 50 +#define EXP2_02_PIN 52 +#define EXP2_03_PIN 29 +#define EXP2_04_PIN 53 +#define EXP2_05_PIN 25 +#define EXP2_06_PIN 51 +#define EXP2_07_PIN 49 +#define EXP2_08_PIN 27 #include "pins_RAMPS.h" diff --git a/Marlin/src/pins/ramps/pins_RAMPS_S_12.h b/Marlin/src/pins/ramps/pins_RAMPS_S_12.h index f41573b527cd..4f3de969f7e8 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_S_12.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_S_12.h @@ -24,6 +24,7 @@ /** * Arduino Mega with RAMPS-S v1.2 by Sakul.cz pin assignments * Written by Michal Rábek + * ATmega2560 * * Applies to the following boards: * diff --git a/Marlin/src/pins/ramps/pins_RIGIDBOARD.h b/Marlin/src/pins/ramps/pins_RIGIDBOARD.h index 2d68577f7c86..d1824d3813a0 100644 --- a/Marlin/src/pins/ramps/pins_RIGIDBOARD.h +++ b/Marlin/src/pins/ramps/pins_RIGIDBOARD.h @@ -23,6 +23,7 @@ /** * RIGIDBOARD Arduino Mega with RAMPS v1.4 pin assignments + * ATmega2560, ATmega1280 */ #ifndef BOARD_INFO_NAME @@ -103,9 +104,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_RIGIDBOARD_V2.h b/Marlin/src/pins/ramps/pins_RIGIDBOARD_V2.h index 8242f1a77294..dc27378a15bc 100644 --- a/Marlin/src/pins/ramps/pins_RIGIDBOARD_V2.h +++ b/Marlin/src/pins/ramps/pins_RIGIDBOARD_V2.h @@ -23,6 +23,7 @@ /** * RIGIDBOARD V2 Arduino Mega with RAMPS v1.4 pin assignments + * ATmega2560, ATmega1280 */ #define BOARD_INFO_NAME "RigidBoard V2" diff --git a/Marlin/src/pins/ramps/pins_RL200.h b/Marlin/src/pins/ramps/pins_RL200.h index 00fb39a43901..219a3a525d02 100644 --- a/Marlin/src/pins/ramps/pins_RL200.h +++ b/Marlin/src/pins/ramps/pins_RL200.h @@ -24,6 +24,7 @@ /** * Rapide Lite 200 v1 (RUMBA clone) pin assignments. Has slightly different assignment for * extruder motors due to dual Z motors. Pinout therefore based on pins_RUMBA.h. + * ATmega2560 */ #define BOARD_INFO_NAME "RL200" diff --git a/Marlin/src/pins/ramps/pins_RUMBA.h b/Marlin/src/pins/ramps/pins_RUMBA.h index eb049c48dd99..6b1f4c569170 100644 --- a/Marlin/src/pins/ramps/pins_RUMBA.h +++ b/Marlin/src/pins/ramps/pins_RUMBA.h @@ -23,6 +23,9 @@ /** * RUMBA pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/RUMBA/RRD-RUMBA_SCHEMATICS.png + * Origin: https://reprap.org/wiki/File:RRD-RUMBA_SCHEMATICS.png + * ATmega2560 */ #define REQUIRE_MEGA2560 diff --git a/Marlin/src/pins/ramps/pins_RUMBA_RAISE3D.h b/Marlin/src/pins/ramps/pins_RUMBA_RAISE3D.h index 39942613ffbf..57ee32ab2969 100644 --- a/Marlin/src/pins/ramps/pins_RUMBA_RAISE3D.h +++ b/Marlin/src/pins/ramps/pins_RUMBA_RAISE3D.h @@ -21,6 +21,8 @@ */ #pragma once +// ATmega2560 + #define BOARD_INFO_NAME "Raise3D Rumba" #define DEFAULT_MACHINE_NAME "Raise3D N Series" diff --git a/Marlin/src/pins/ramps/pins_SAINSMART_2IN1.h b/Marlin/src/pins/ramps/pins_SAINSMART_2IN1.h index d25029a7a39c..6354cc7618e1 100644 --- a/Marlin/src/pins/ramps/pins_SAINSMART_2IN1.h +++ b/Marlin/src/pins/ramps/pins_SAINSMART_2IN1.h @@ -23,13 +23,14 @@ /** * Sainsmart 2-in-1 pin assignments + * ATmega2560, ATmega1280 */ #if HOTENDS > 2 || E_STEPPERS > 2 #error "Sainsmart 2-in-1 supports up to 2 hotends / E steppers." #endif -#define BOARD_INFO_NAME "Sainsmart" +#define BOARD_INFO_NAME "Sainsmart 2-in-1" // // Heaters / Fans diff --git a/Marlin/src/pins/ramps/pins_TANGO.h b/Marlin/src/pins/ramps/pins_TANGO.h index 451d2f874d7f..936751e9ebf7 100644 --- a/Marlin/src/pins/ramps/pins_TANGO.h +++ b/Marlin/src/pins/ramps/pins_TANGO.h @@ -23,6 +23,9 @@ /** * BIQU Tango pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/BIQU%20Tango/schematic.png + * Origin: https://github.com/bigtreetech/Tango-3D-Printer-Motherboard/blob/master/Schematic/Tango%20V1.0.SchDoc + * ATmega2560 */ #define BOARD_INFO_NAME "Tango" diff --git a/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h b/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h index b11487b21d36..dd6fb2fa7036 100644 --- a/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h +++ b/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h @@ -22,7 +22,8 @@ #pragma once /** - * Tenlog pin assignments + * Tenlog D3 Hero pin assignments + * ATmega2560 */ #define REQUIRE_MEGA2560 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..780ab8daa49e --- /dev/null +++ b/Marlin/src/pins/ramps/pins_TENLOG_MB1_V23.h @@ -0,0 +1,156 @@ +/** + * 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 MB1 V2.3 pin assignments + * ATmega2560 + */ + +#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 diff --git a/Marlin/src/pins/ramps/pins_TRIGORILLA_13.h b/Marlin/src/pins/ramps/pins_TRIGORILLA_13.h index 71dfb8c70441..a286c13a30a5 100644 --- a/Marlin/src/pins/ramps/pins_TRIGORILLA_13.h +++ b/Marlin/src/pins/ramps/pins_TRIGORILLA_13.h @@ -23,6 +23,7 @@ /** * Arduino Mega with RAMPS v1.3 for Anycubic + * ATmega2560 */ #define BOARD_INFO_NAME "Anycubic RAMPS 1.3" diff --git a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h index 994a54297f7c..ce2a9e4cdc72 100644 --- a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h +++ b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h @@ -23,6 +23,7 @@ /** * Arduino Mega with RAMPS v1.4 for Anycubic + * ATmega2560 */ #define BOARD_INFO_NAME "Anycubic RAMPS 1.4" @@ -40,108 +41,141 @@ // // 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 -// -// 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 +/** + * Trigorilla Plugs (oriented with stepper plugs at the top) + * + * SENSORS : GND GND GND GND + * A12 A15 A14 A13 + * (D66 D69 D68 D67) + * + * AUX : D42 GND 5V (Chiron Y-STOP) + * D43 GND 5V (Chiron Z-STOP) + * + * UART3 : GND D15 D14 5V + * (RX3 TX3) + * + * IIC : 12V GND D21 D20 GND 5V + * (SCL SDA) + * + * END STOPS : D19 D18 D15 D14 D2 D3 + * GND GND GND GND GND GND + * 5V 5V 5V 5V 5V 5V + */ + +/** Expansion Headers + * ------ ------ + * 37 | 1 2 | 35 (MISO) 50 | 1 2 | 52 (SCK) + * 17 | 3 4 | 16 31 | 3 4 | 53 + * 23 5 6 | 25 33 5 6 | 51 (MOSI) + * 27 | 7 8 | 29 49 | 7 8 | 41 + * (GND) | 9 10 | (5V) (GND) | 9 10 | RESET + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN 37 +#define EXP1_02_PIN 35 +#define EXP1_03_PIN 17 +#define EXP1_04_PIN 16 +#define EXP1_05_PIN 23 +#define EXP1_06_PIN 25 +#define EXP1_07_PIN 27 +#define EXP1_08_PIN 29 + +#define EXP2_01_PIN 50 // MISO +#define EXP2_02_PIN 52 // SCK +#define EXP2_03_PIN 31 +#define EXP2_04_PIN 53 +#define EXP2_05_PIN 33 +#define EXP2_06_PIN 51 // MOSI +#define EXP2_07_PIN 49 +#define EXP2_08_PIN 41 // -// Limit Switches +// AnyCubic pin mappings +// +// Define the appropriate mapping option in Configuration.h: +// - TRIGORILLA_MAPPING_CHIRON +// - TRIGORILLA_MAPPING_I3MEGA // -//#define ANYCUBIC_4_MAX_PRO_ENDSTOPS +//#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 + #define X_MAX_PIN 43 // AUX (2) + #define Y_STOP_PIN 19 // Z+ +#elif EITHER(TRIGORILLA_MAPPING_CHIRON, TRIGORILLA_MAPPING_I3MEGA) + // Chiron uses AUX header for Y and Z endstops + #define Y_STOP_PIN 42 // AUX (1) + #define Z_STOP_PIN 43 // AUX (2) + #define Z2_MIN_PIN 18 // Z- + #ifndef Z_MIN_PROBE_PIN - #define Z_MIN_PROBE_PIN 2 + #define Z_MIN_PROBE_PIN 2 // X+ #endif - #ifndef FIL_RUNOUT_PIN - #if ENABLED(ANYCUBIC_LCD_CHIRON) - #define FIL_RUNOUT_PIN 33 - #else - #define FIL_RUNOUT_PIN 19 + + #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) + #if ENABLED(ANYCUBIC_LCD_CHIRON) && !defined(FIL_RUNOUT_PIN) + #define FIL_RUNOUT_PIN EXP2_05_PIN // Chiron Standard Adapter #endif + #define HEATER_BED_PIN MOSFET_B_PIN // HEATER1 #endif - #define BEEPER_PIN 31 - #define SD_DETECT_PIN 49 -#endif -#include "pins_RAMPS.h" + #ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 19 // Z+ + #endif -// -// AnyCubic made the following changes to 1.1.0-RC8 -// If these are appropriate for your LCD let us know. -// -#if 0 && HAS_WIRED_LCD + #if EITHER(TRIGORILLA_MAPPING_CHIRON, SWAP_Z_MOTORS) + // Chiron and some Anycubic i3 MEGAs swap Z steppers + #define Z_STEP_PIN 36 + #define Z_DIR_PIN 34 + #define Z_ENABLE_PIN 30 + #define Z_CS_PIN 44 - // LCD Display output pins - #if BOTH(IS_NEWPANEL, PANEL_ONE) - #undef LCD_PINS_D6 - #define LCD_PINS_D6 57 + #define Z2_STEP_PIN 46 + #define Z2_DIR_PIN 48 + #define Z2_ENABLE_PIN 62 + #define Z2_CS_PIN 40 #endif +#endif - // LCD Display input pins - #if IS_NEWPANEL - #if ANY(VIKI2, miniVIKI) - #undef DOGLCD_A0 - #define DOGLCD_A0 23 - #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) - #undef BEEPER_PIN - #define BEEPER_PIN 33 - #undef LCD_BACKLIGHT_PIN - #define LCD_BACKLIGHT_PIN 67 - #endif - #elif ENABLED(MINIPANEL) - #undef BEEPER_PIN - #define BEEPER_PIN 33 - #undef DOGLCD_A0 - #define DOGLCD_A0 42 +#if EITHER(ANYCUBIC_LCD_CHIRON, ANYCUBIC_LCD_I3MEGA) + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP2_03_PIN // Chiron Standard Adapter #endif + #define SD_DETECT_PIN EXP2_07_PIN // Chiron Standard Adapter +#endif -#endif // HAS_WIRED_LCD +#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" diff --git a/Marlin/src/pins/ramps/pins_TRONXY_V3_1_0.h b/Marlin/src/pins/ramps/pins_TRONXY_V3_1_0.h index 04c6af67b002..0104dadf7ff2 100644 --- a/Marlin/src/pins/ramps/pins_TRONXY_V3_1_0.h +++ b/Marlin/src/pins/ramps/pins_TRONXY_V3_1_0.h @@ -23,6 +23,7 @@ /** * Arduino Mega for Tronxy X5S-2E, etc. + * ATmega2560 */ #define REQUIRE_MEGA2560 diff --git a/Marlin/src/pins/ramps/pins_TT_OSCAR.h b/Marlin/src/pins/ramps/pins_TT_OSCAR.h index f81cc6039aed..430d7b3ec06b 100644 --- a/Marlin/src/pins/ramps/pins_TT_OSCAR.h +++ b/Marlin/src/pins/ramps/pins_TT_OSCAR.h @@ -21,10 +21,12 @@ */ #pragma once +// ATmega2560 + #include "env_validate.h" #if HOTENDS > 5 || E_STEPPERS > 5 - #error "TTOSCAR supports up to 5 hotends / E steppers." + #error "TT OSCAR supports up to 5 hotends / E steppers." #endif #define BOARD_INFO_NAME "TT OSCAR" diff --git a/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h b/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h index 128f1974e0e6..4ee0a6950d39 100644 --- a/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h +++ b/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h @@ -23,6 +23,25 @@ /** * Ultiboard v2.0 pin assignments + * Schematics (2.1.4): + * - https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/Ultimaker%202.1.4/schema1.png + * - https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/Ultimaker%202.1.4/schema2.png + * - https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/Ultimaker%202.1.4/schema3.png + * - https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/Ultimaker%202.1.4/schema4.png + * - https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/Ultimaker%202.1.4/schema5.png + * Origins (2.1.4): + * - https://github.com/Ultimaker/Ultimaker2/blob/master/1546%20ultimainboard%20V2.1.4/schema1.SchDoc + * - https://github.com/Ultimaker/Ultimaker2/blob/master/1546%20ultimainboard%20V2.1.4/schema2.SchDoc + * - https://github.com/Ultimaker/Ultimaker2/blob/master/1546%20ultimainboard%20V2.1.4/schema3.SchDoc + * - https://github.com/Ultimaker/Ultimaker2/blob/master/1546%20ultimainboard%20V2.1.4/schema4.SchDoc + * - https://github.com/Ultimaker/Ultimaker2/blob/master/1546%20ultimainboard%20V2.1.4/schema5.SchDoc + * Schematics (Original+): + * - https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/Ultimaker%20Original+/Ultimainboard%20rev.%202.1.1%20altium/schema1.png + * - https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/Ultimaker%20Original+/Ultimainboard%20rev.%202.1.1%20altium/schema2.png + * - https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/Ultimaker%20Original+/Ultimainboard%20rev.%202.1.1%20altium/schema3.png + * - https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/Ultimaker%20Original+/Ultimainboard%20rev.%202.1.1%20altium/schema4.png + * Origin (Original+): https://github.com/Ultimaker/Ultimaker-Original-Plus/blob/master/1091_Main_board_v2.1.1_(x1)/Ultimainboard%20rev.%202.1.1%20altium.zip + * ATmega2560 */ /** @@ -107,8 +126,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_ULTIMAKER.h b/Marlin/src/pins/ramps/pins_ULTIMAKER.h index 0bc04d962aaf..e3e91428dfa7 100644 --- a/Marlin/src/pins/ramps/pins_ULTIMAKER.h +++ b/Marlin/src/pins/ramps/pins_ULTIMAKER.h @@ -23,6 +23,7 @@ /** * Ultimaker pin assignments + * ATmega2560, ATmega1280 */ /** diff --git a/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h b/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h index 37060ab94541..25cc278adab8 100644 --- a/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h +++ b/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h @@ -23,6 +23,9 @@ /** * Ultimaker pin assignments (Old electronics) + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/Ultimaker%201.0/ultipanel%20rev1.1.sch.pdf + * Origin: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/Ultimaker%201.0/ultipanel%20rev1.1.sch.pdf + * ATmega2560, ATmega1280 */ /** @@ -163,7 +166,7 @@ // // LCD / Controller // -#if ANY(BOARD_REV_1_0, BOARD_REV_1_1_TO_1_3) +#if EITHER(BOARD_REV_1_0, BOARD_REV_1_1_TO_1_3) #define LCD_PINS_RS 24 #define LCD_PINS_ENABLE 22 diff --git a/Marlin/src/pins/ramps/pins_VORON.h b/Marlin/src/pins/ramps/pins_VORON.h index 93903810104f..f56b0cb8fcfb 100644 --- a/Marlin/src/pins/ramps/pins_VORON.h +++ b/Marlin/src/pins/ramps/pins_VORON.h @@ -24,6 +24,7 @@ /** * VORON Design v2 pin assignments * See https://github.com/mzbotreprap/VORON/blob/master/Firmware/Marlin/pins_RAMPS_VORON.h + * ATmega2560 */ #define BOARD_INFO_NAME "VORON Design v2" diff --git a/Marlin/src/pins/ramps/pins_ZRIB_V20.h b/Marlin/src/pins/ramps/pins_ZRIB_V20.h index e9328ca7bae9..127fffa7944b 100644 --- a/Marlin/src/pins/ramps/pins_ZRIB_V20.h +++ b/Marlin/src/pins/ramps/pins_ZRIB_V20.h @@ -22,66 +22,46 @@ #pragma once /** - * ZRIB V2.0 & V3.0 pin assignments + * ZONESTAR ZRIB V2.0 & V3.0 pin assignments * V2 and V3 Boards only differ in USB controller, nothing affecting the pins. + * Schematic (2.0): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/ZONESTAR%20ZRIB%20V2.0/ZRIB_V2_Schematic.pdf + * Origin (2.0): https://github.com/ZONESTAR3D/Control-Board/blob/main/8bit/ZRIB/ZRIB_V2/ZRIB_V2_Schematic.pdf + * Schematic (3.0): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/ZONESTAR%20ZRIB%20V3.0/ZRIB_V3_Schematic.pdf + * Origin (3.0): https://github.com/ZONESTAR3D/Control-Board/blob/main/8bit/ZRIB/ZRIB_V3/ZRIB_V3_Schematic.pdf + * ATmega2560, ATmega1280 */ -#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 +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN 11 // Analog Input +#endif // // 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 -#endif - -#ifndef FILWIDTH_PIN - #define FILWIDTH_PIN 11 // Analog Input + #define E3_AUTO_FAN_PIN 6 #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 + #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 - #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 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_DEFINED #endif + +#include "pins_MKS_GEN_13.h" // ... RAMPS diff --git a/Marlin/src/pins/ramps/pins_ZRIB_V52.h b/Marlin/src/pins/ramps/pins_ZRIB_V52.h index 2df789cd6f7f..34eee07c95db 100644 --- a/Marlin/src/pins/ramps/pins_ZRIB_V52.h +++ b/Marlin/src/pins/ramps/pins_ZRIB_V52.h @@ -22,7 +22,10 @@ #pragma once /** - * ZRIB V5.2 Based on MKS BASE v1.4 with A4982 stepper drivers and digital micro-stepping + * ZONESTAR ZRIB V5.2 Based on MKS BASE v1.4 with A4982 stepper drivers and digital micro-stepping + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/RAMPS/ZONESTAR%20ZRIB%20V5.2/ZRIB_V52_Schematic.pdf + * Origin: https://github.com/ZONESTAR3D/Control-Board/blob/main/8bit/ZRIB/ZRIB_V5/ZRIB_V52_Schematic.pdf + * ATmega2560, ATmega1280 */ #if HOTENDS > 2 || E_STEPPERS > 2 @@ -47,6 +50,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 +91,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 48808d9601c8..050516791e40 100644 --- a/Marlin/src/pins/ramps/pins_ZRIB_V53.h +++ b/Marlin/src/pins/ramps/pins_ZRIB_V53.h @@ -22,7 +22,8 @@ #pragma once /** - * ZRIB V5.3 Based on MKS BASE v1.4 with A4982 stepper drivers and digital micro-stepping + * ZONESTAR ZRIB V5.3 Based on MKS BASE v1.4 with A4982 stepper drivers and digital micro-stepping + * ATmega2560, ATmega1280 */ #include "env_validate.h" @@ -62,10 +63,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 // @@ -299,33 +300,33 @@ * LCD adapter. NOTE: These come in two variants. The socket keys can be * on either side, and may be backwards on some displays. * ------ ------ - * D37 |10 9 | D35 (MISO) D50 |10 9 | D52 (SCK) - * D17 | 8 7 | D16 D31 | 8 7 | D53 + * D37 | 1 2 | D35 (MISO) D50 | 1 2 | D52 (SCK) + * D17 | 3 4 | D16 D31 | 3 4 | D53 * D23 6 5 D25 D33 6 5 D51 (MOSI) - * D27 | 4 3 | D29 D49 | 4 3 | D41 - * GND | 2 1 | 5V GND | 2 1 | -- + * D27 | 7 8 | D29 D49 | 7 8 | D41 + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#ifndef EXP1_03_PIN - #define EXP1_03_PIN 29 - #define EXP1_04_PIN 27 - #define EXP1_05_PIN 25 - #define EXP1_06_PIN 23 - #define EXP1_07_PIN 16 - #define EXP1_08_PIN 17 - #define EXP1_09_PIN 35 - #define EXP1_10_PIN 37 - - #define EXP2_03_PIN 41 - #define EXP2_04_PIN 49 - #define EXP2_05_PIN XS6_05_PIN - #define EXP2_06_PIN 33 - #define EXP2_07_PIN 53 - #define EXP2_08_PIN 31 - #define EXP2_09_PIN XS6_03_PIN - #define EXP2_10_PIN XS6_07_PIN +#ifndef EXP1_08_PIN + #define EXP1_01_PIN 37 + #define EXP1_02_PIN 35 + #define EXP1_03_PIN 17 + #define EXP1_04_PIN 16 + #define EXP1_05_PIN 23 + #define EXP1_06_PIN 25 + #define EXP1_07_PIN 27 + #define EXP1_08_PIN 29 + + #define EXP2_01_PIN XS6_07_PIN + #define EXP2_02_PIN XS6_03_PIN + #define EXP2_03_PIN 31 + #define EXP2_04_PIN 53 + #define EXP2_05_PIN 33 + #define EXP2_06_PIN XS6_05_PIN + #define EXP2_07_PIN 49 + #define EXP2_08_PIN 41 #endif ////////////////////////// @@ -386,14 +387,14 @@ #if ENABLED(ZONESTAR_LCD) #define LCDSCREEN_NAME "LCD2004 ADCKEY" - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #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 ADC_KEYPAD_PIN 10 // A10 for ADCKEY - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #endif /** @@ -424,18 +425,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 diff --git a/Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h b/Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h index b68e3edb4567..69fa55f0dcbe 100644 --- a/Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h +++ b/Marlin/src/pins/ramps/pins_Z_BOLT_X_SERIES.h @@ -23,6 +23,7 @@ /** * Z-Bolt X Series board – based on Arduino Mega2560 + * ATmega2560 */ #define REQUIRE_MEGA2560 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 // diff --git a/Marlin/src/pins/sam/pins_ARCHIM2.h b/Marlin/src/pins/sam/pins_ARCHIM2.h index ecff888ff05e..310dd8e2ac27 100644 --- a/Marlin/src/pins/sam/pins_ARCHIM2.h +++ b/Marlin/src/pins/sam/pins_ARCHIM2.h @@ -245,8 +245,6 @@ #define LCD_PINS_D5 54 // D54 PA16_SCK1 #define LCD_PINS_D6 68 // D68 PA1_CANRX0 #define LCD_PINS_D7 34 // D34 PC2_PWML0 - - #define SD_DETECT_PIN 2 // D2 PB25_TIOA0 #endif #if ANY(IS_ULTIPANEL, TOUCH_UI_ULTIPANEL, TOUCH_UI_FTDI_EVE) @@ -255,3 +253,10 @@ #define BTN_EN2 13 // D13 PB27_TIOB0 #define BTN_ENC 16 // D16 PA13_TXD1 // the click #endif + +#if ANY(HAS_WIRED_LCD, TOUCH_UI_ULTIPANEL, TOUCH_UI_FTDI_EVE, USB_FLASH_DRIVE_SUPPORT) + #define SD_DETECT_PIN 2 // D2 PB25_TIOA0 + #if ENABLED(USB_FLASH_DRIVE_SUPPORT) + #define DISABLE_DUE_SD_MMC + #endif +#endif diff --git a/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h b/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h index 980a957a505a..00eba994a8d9 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h +++ b/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h @@ -135,31 +135,31 @@ #define LED_PIN 13 /** ------ ------ - * 37 |10 9 | 35 (MISO) 50 |10 9 | 76 (SCK) - * 29 | 8 7 | 27 (EN2) 31 | 8 7 | 4 (SD_SS) - * 25 6 5 | 23 (EN1) 33 6 5 | 75 (MOSI) - * 16 | 4 3 | 17 (SDD) 49 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * 37 | 1 2 | 35 (MISO) 50 | 1 2 | 76 (SCK) + * 29 | 3 4 | 27 (EN2) 31 | 3 4 | 4 (SD_SS) + * 25 5 6 | 23 (EN1) 33 5 6 | 75 (MOSI) + * 16 | 7 8 | 17 (SDD) 49 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN 17 -#define EXP1_04_PIN 16 -#define EXP1_05_PIN 23 -#define EXP1_06_PIN 25 -#define EXP1_07_PIN 27 -#define EXP1_08_PIN 29 -#define EXP1_09_PIN 35 -#define EXP1_10_PIN 37 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN 49 -#define EXP2_05_PIN 75 -#define EXP2_06_PIN 33 -#define EXP2_07_PIN 4 -#define EXP2_08_PIN 31 -#define EXP2_09_PIN 76 -#define EXP2_10_PIN 74 +#define EXP1_01_PIN 37 +#define EXP1_02_PIN 35 +#define EXP1_03_PIN 29 +#define EXP1_04_PIN 27 +#define EXP1_05_PIN 25 +#define EXP1_06_PIN 23 +#define EXP1_07_PIN 16 +#define EXP1_08_PIN 17 + +#define EXP2_01_PIN 74 +#define EXP2_02_PIN 76 +#define EXP2_03_PIN 31 +#define EXP2_04_PIN 4 +#define EXP2_05_PIN 33 +#define EXP2_06_PIN 75 +#define EXP2_07_PIN 49 +#define EXP2_08_PIN -1 // // LCD / Controller @@ -167,65 +167,65 @@ #if HAS_WIRED_LCD // ramps-fd lcd adaptor - #define BEEPER_PIN EXP1_10_PIN - #define BTN_EN1 EXP2_06_PIN - #define BTN_EN2 EXP2_08_PIN - #define BTN_ENC EXP1_09_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN + #define BTN_ENC EXP1_02_PIN + #define SD_DETECT_PIN EXP2_07_PIN #if IS_NEWPANEL - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN #endif #if ENABLED(FYSETC_MINI_12864) #define DOGLCD_CS LCD_PINS_ENABLE #define DOGLCD_A0 LCD_PINS_RS - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems // results in LCD soft SPI mode 3, SD soft SPI mode 0 - #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + #define LCD_RESET_PIN EXP1_06_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 + #define RGB_LED_R_PIN EXP1_05_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_07_PIN + #define RGB_LED_G_PIN EXP1_04_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_08_PIN + #define RGB_LED_B_PIN EXP1_03_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_06_PIN + #define NEOPIXEL_PIN EXP1_05_PIN #endif #elif IS_NEWPANEL - #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 LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_04_PIN + #define LCD_PINS_D7 EXP1_03_PIN #if ENABLED(MINIPANEL) - #define DOGLCD_CS EXP1_06_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_05_PIN + #define DOGLCD_A0 EXP1_04_PIN #endif #endif - #if ANY(VIKI2, miniVIKI) - #define DOGLCD_A0 EXP1_04_PIN + #if EITHER(VIKI2, miniVIKI) + #define DOGLCD_A0 EXP1_07_PIN #define KILL_PIN 51 - #define STAT_LED_BLUE_PIN EXP1_08_PIN - #define STAT_LED_RED_PIN EXP1_05_PIN - #define DOGLCD_CS EXP1_03_PIN - #define DOGLCD_SCK EXP2_09_PIN // SCK_PIN - Required for DUE Hardware SPI - #define DOGLCD_MOSI EXP2_05_PIN // MOSI_PIN - #define DOGLCD_MISO EXP2_10_PIN // MISO_PIN + #define STAT_LED_BLUE_PIN EXP1_03_PIN + #define STAT_LED_RED_PIN EXP1_06_PIN + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_SCK EXP2_02_PIN // SCK_PIN - Required for DUE Hardware SPI + #define DOGLCD_MOSI EXP2_06_PIN // MOSI_PIN + #define DOGLCD_MISO EXP2_01_PIN // MISO_PIN #endif #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) diff --git a/Marlin/src/pins/sam/pins_RAMPS_SMART.h b/Marlin/src/pins/sam/pins_RAMPS_SMART.h index 2b8942c6ad2d..b02ddef16628 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_SMART.h +++ b/Marlin/src/pins/sam/pins_RAMPS_SMART.h @@ -110,31 +110,31 @@ #else /** ------ ------ - * 37 |10 9 | 35 (MISO) 50 |10 9 | 52 (SCK) - * 31 | 8 7 | 41 29 | 8 7 | 53 - * 33 6 5 | 23 25 6 5 | 51 (MOSI) - * 42 | 4 3 | 44 49 | 4 3 | 27 - * GND | 2 1 | 5V GND | 2 1 | -- + * 37 | 1 2 | 35 (MISO) 50 | 1 2 | 52 (SCK) + * 31 | 3 4 | 41 29 | 3 4 | 53 + * 33 5 6 | 23 25 5 6 | 51 (MOSI) + * 42 | 7 8 | 44 49 | 7 8 | 27 + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ - #define EXP1_03_PIN 44 - #define EXP1_04_PIN 42 - #define EXP1_05_PIN 23 - #define EXP1_06_PIN 33 - #define EXP1_07_PIN 41 - #define EXP1_08_PIN 31 - #define EXP1_09_PIN 35 - #define EXP1_10_PIN 37 + #define EXP1_01_PIN 37 + #define EXP1_02_PIN 35 + #define EXP1_03_PIN 31 + #define EXP1_04_PIN 41 + #define EXP1_05_PIN 33 + #define EXP1_06_PIN 23 + #define EXP1_07_PIN 42 + #define EXP1_08_PIN 44 - #define EXP2_03_PIN 27 - #define EXP2_04_PIN 49 - #define EXP2_05_PIN 51 - #define EXP2_06_PIN 25 - #define EXP2_07_PIN 53 - #define EXP2_08_PIN 29 - #define EXP2_09_PIN 52 - #define EXP2_10_PIN 50 + #define EXP2_01_PIN 50 + #define EXP2_02_PIN 52 + #define EXP2_03_PIN 29 + #define EXP2_04_PIN 53 + #define EXP2_05_PIN 25 + #define EXP2_06_PIN 51 + #define EXP2_07_PIN 49 + #define EXP2_08_PIN 27 #endif diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h index 064ce2751ab3..35279bf2e513 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h @@ -146,7 +146,7 @@ // SPI for MAX Thermocouple /* #if DISABLED(SDSUPPORT) - #define TEMP_0_CS_PIN EXP1_03_PIN + #define TEMP_0_CS_PIN EXP1_08_PIN #else #define TEMP_0_CS_PIN 49 #endif @@ -163,11 +163,13 @@ #define TFT_LCD_MODULE_COM 1 #define TFT_LCD_MODULE_BAUDRATE 115600 -// ESP WiFi Use internal USART-2 -#define ESP_WIFI_MODULE_COM 2 -#define ESP_WIFI_MODULE_BAUDRATE 115600 -#define ESP_WIFI_MODULE_RESET_PIN -1 -#define PIGGY_GPIO_PIN -1 +#if ENABLED(WIFISUPPORT) + // ESP WiFi Use internal USART-2 + #define ESP_WIFI_MODULE_COM 2 + #define ESP_WIFI_MODULE_BAUDRATE 115600 + #define ESP_WIFI_MODULE_RESET_PIN -1 + #define PIGGY_GPIO_PIN -1 +#endif // // EEPROM @@ -185,31 +187,31 @@ /** * ------ ------ - * (BEEPER) 62 |10 9 | 40 (BTN_ENC) (MISO) 74 |10 9 | 76 (SCK) - * (LCD_EN) 64 | 8 7 | 63 (LCD_RS) (BTN_EN1) 44 | 8 7 | 10 (SD_SS) - * (LCD_D4) 48 | 6 5 50 (LCD_D5) (BTN_EN2) 42 | 6 5 75 (MOSI) - * (LCD_D6) 52 | 4 3 | 53 (LCD_D7) (SD_DETECT) 51 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) 62 | 1 2 | 40 (BTN_ENC) (MISO) 74 | 1 2 | 76 (SCK) + * (LCD_EN) 64 | 3 4 | 63 (LCD_RS) (BTN_EN1) 44 | 3 4 | 10 (SD_SS) + * (LCD_D4) 48 | 5 6 50 (LCD_D5) (BTN_EN2) 42 | 5 6 75 (MOSI) + * (LCD_D6) 52 | 7 8 | 53 (LCD_D7) (SD_DETECT) 51 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN 53 -#define EXP1_04_PIN 52 -#define EXP1_05_PIN 50 -#define EXP1_06_PIN 48 -#define EXP1_07_PIN 63 -#define EXP1_08_PIN 64 -#define EXP1_09_PIN 40 -#define EXP1_10_PIN 62 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN 51 -#define EXP2_05_PIN 75 // MOSI -#define EXP2_06_PIN 42 -#define EXP2_07_PIN 10 -#define EXP2_08_PIN 44 -#define EXP2_09_PIN 76 // SCK -#define EXP2_10_PIN 74 // MISO +#define EXP1_01_PIN 62 +#define EXP1_02_PIN 40 +#define EXP1_03_PIN 64 +#define EXP1_04_PIN 63 +#define EXP1_05_PIN 48 +#define EXP1_06_PIN 50 +#define EXP1_07_PIN 52 +#define EXP1_08_PIN 53 + +#define EXP2_01_PIN 74 // MISO +#define EXP2_02_PIN 76 // SCK +#define EXP2_03_PIN 44 +#define EXP2_04_PIN 10 +#define EXP2_05_PIN 42 +#define EXP2_06_PIN 75 // MOSI +#define EXP2_07_PIN 51 +#define EXP2_08_PIN -1 // RESET // // LCD / Controller @@ -217,53 +219,53 @@ #if HAS_WIRED_LCD #if ANY(RADDS_DISPLAY, IS_RRD_SC, IS_RRD_FG_SC) - #define BEEPER_PIN EXP1_10_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define BEEPER_PIN EXP1_01_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 SD_DETECT_PIN EXP2_07_PIN #endif #if EITHER(RADDS_DISPLAY, IS_RRD_SC) - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN #elif IS_RRD_FG_SC - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN #elif HAS_U8GLIB_I2C_OLED - #define BEEPER_PIN EXP1_10_PIN - #define LCD_SDSS EXP2_07_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define BEEPER_PIN EXP1_01_PIN + #define LCD_SDSS EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #elif ENABLED(FYSETC_MINI_12864) - #define BEEPER_PIN EXP1_10_PIN - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define BEEPER_PIN EXP1_01_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems // results in LCD soft SPI mode 3, SD soft SPI mode 0 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #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_05_PIN // D5 + #define RGB_LED_R_PIN EXP1_06_PIN // D5 #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN // D6 + #define RGB_LED_G_PIN EXP1_07_PIN // D6 #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN // D7 + #define RGB_LED_B_PIN EXP1_08_PIN // D7 #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN // D5 + #define NEOPIXEL_PIN EXP1_06_PIN // D5 #endif #elif ENABLED(SPARK_FULL_GRAPHICS) @@ -280,9 +282,9 @@ #endif // SPARK_FULL_GRAPHICS #if IS_NEWPANEL - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN #endif #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h index cc919d0a4fdc..78cf3f6e1065 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h @@ -153,11 +153,13 @@ #define TFT_LCD_MODULE_COM 1 #define TFT_LCD_MODULE_BAUDRATE 115200 -// ESP WiFi Use internal USART-2 -#define ESP_WIFI_MODULE_COM 2 -#define ESP_WIFI_MODULE_BAUDRATE 115200 -#define ESP_WIFI_MODULE_RESET_PIN -1 -#define PIGGY_GPIO_PIN -1 +#if ENABLED(WIFISUPPORT) + // ESP WiFi Use internal USART-2 + #define ESP_WIFI_MODULE_COM 2 + #define ESP_WIFI_MODULE_BAUDRATE 115200 + #define ESP_WIFI_MODULE_RESET_PIN -1 + #define PIGGY_GPIO_PIN -1 +#endif // // EEPROM @@ -175,31 +177,31 @@ /** * ------ ------ - * (BEEPER) 62 |10 9 | 40 (BTN_ENC) (MISO) 74 |10 9 | 76 (SCK) - * (LCD_EN) 64 | 8 7 | 63 (LCD_RS) (BTN_EN1) 44 | 8 7 | 10 (SD_SS) - * (LCD_D4) 48 | 6 5 50 (LCD_D5) (BTN_EN2) 42 | 6 5 75 (MOSI) - * (LCD_D6) 52 | 4 3 | 53 (LCD_D7) (SD_DETECT) 51 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) 62 | 1 2 | 40 (BTN_ENC) (MISO) 74 | 1 2 | 76 (SCK) + * (LCD_EN) 64 | 3 4 | 63 (LCD_RS) (BTN_EN1) 44 | 3 4 | 10 (SD_SS) + * (LCD_D4) 48 | 5 6 50 (LCD_D5) (BTN_EN2) 42 | 5 6 75 (MOSI) + * (LCD_D6) 52 | 7 8 | 53 (LCD_D7) (SD_DETECT) 51 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN 53 -#define EXP1_04_PIN 52 -#define EXP1_05_PIN 50 -#define EXP1_06_PIN 48 -#define EXP1_07_PIN 63 -#define EXP1_08_PIN 64 -#define EXP1_09_PIN 40 -#define EXP1_10_PIN 62 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN 51 -#define EXP2_05_PIN 75 // MOSI -#define EXP2_06_PIN 42 -#define EXP2_07_PIN 10 -#define EXP2_08_PIN 44 -#define EXP2_09_PIN 76 // SCK -#define EXP2_10_PIN 74 // MISO +#define EXP1_01_PIN 62 +#define EXP1_02_PIN 40 +#define EXP1_03_PIN 64 +#define EXP1_04_PIN 63 +#define EXP1_05_PIN 48 +#define EXP1_06_PIN 50 +#define EXP1_07_PIN 52 +#define EXP1_08_PIN 53 + +#define EXP2_01_PIN 74 // MISO +#define EXP2_02_PIN 76 // SCK +#define EXP2_03_PIN 44 +#define EXP2_04_PIN 10 +#define EXP2_05_PIN 42 +#define EXP2_06_PIN 75 // MOSI +#define EXP2_07_PIN 51 +#define EXP2_08_PIN -1 // RESET // // LCD / Controller @@ -207,67 +209,67 @@ #if HAS_WIRED_LCD #if ANY(RADDS_DISPLAY, IS_RRD_SC, IS_RRD_FG_SC) - #define BEEPER_PIN EXP1_10_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define BEEPER_PIN EXP1_01_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 SD_DETECT_PIN EXP2_07_PIN #endif #if EITHER(RADDS_DISPLAY, IS_RRD_SC) - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN #elif IS_RRD_FG_SC - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN #elif HAS_U8GLIB_I2C_OLED - #define BEEPER_PIN EXP1_10_PIN - #define LCD_SDSS EXP2_07_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define BEEPER_PIN EXP1_01_PIN + #define LCD_SDSS EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #elif ENABLED(FYSETC_MINI_12864) - #define BEEPER_PIN EXP1_10_PIN - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define BEEPER_PIN EXP1_01_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems // results in LCD soft SPI mode 3, SD soft SPI mode 0 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #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_05_PIN // D5 + #define RGB_LED_R_PIN EXP1_06_PIN // D5 #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN // D6 + #define RGB_LED_G_PIN EXP1_07_PIN // D6 #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN // D7 + #define RGB_LED_B_PIN EXP1_08_PIN // D7 #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN // D5 + #define NEOPIXEL_PIN EXP1_06_PIN // D5 #endif #elif ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif #if IS_NEWPANEL - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN #endif #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) diff --git a/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h b/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h index fd30c2b69a86..616f47f8562a 100644 --- a/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h +++ b/Marlin/src/pins/sam/pins_ULTRATRONICS_PRO.h @@ -153,7 +153,7 @@ #define TEMP_0_CS_PIN 65 #define TEMP_1_CS_PIN 52 #define TEMP_2_CS_PIN 50 -#define TEMP_3_CS_PIN 51 +#define TEMP_3_CS_PIN 51 // Not yet supported #define ENC424_SS 61 diff --git a/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h b/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h index 382c607d239b..9901b78c4663 100644 --- a/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h +++ b/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h @@ -166,33 +166,33 @@ * BTN_ENCODER 40 KILL_PIN 49 */ -#define EXP1_03_PIN 39 -#define EXP1_04_PIN 38 -#define EXP1_05_PIN 37 -#define EXP1_06_PIN 36 -#define EXP1_07_PIN 34 -#define EXP1_08_PIN 35 -#define EXP1_09_PIN 40 -#define EXP1_10_PIN 41 - -#define EXP2_01_PIN 49 -#define EXP2_04_PIN 44 -#define EXP2_05_PIN 51 -#define EXP2_06_PIN 42 -#define EXP2_07_PIN 53 -#define EXP2_08_PIN 43 -#define EXP2_09_PIN 52 -#define EXP2_10_PIN 50 +#define EXP1_01_PIN 41 +#define EXP1_02_PIN 40 +#define EXP1_03_PIN 35 +#define EXP1_04_PIN 34 +#define EXP1_05_PIN 36 +#define EXP1_06_PIN 37 +#define EXP1_07_PIN 38 +#define EXP1_08_PIN 39 + +#define EXP2_01_PIN 50 +#define EXP2_02_PIN 52 +#define EXP2_03_PIN 43 +#define EXP2_04_PIN 53 +#define EXP2_05_PIN 42 +#define EXP2_06_PIN 51 +#define EXP2_07_PIN 44 +#define EXP2_10_PIN 49 #if ENABLED(CR10_STOCKDISPLAY) + #define EXP3_01_PIN EXP1_01_PIN + #define EXP3_02_PIN EXP1_02_PIN #define EXP3_03_PIN EXP1_03_PIN #define EXP3_04_PIN EXP1_04_PIN #define EXP3_05_PIN EXP1_05_PIN #define EXP3_06_PIN EXP1_06_PIN #define EXP3_07_PIN EXP1_07_PIN #define EXP3_08_PIN EXP1_08_PIN - #define EXP3_09_PIN EXP1_09_PIN - #define EXP3_10_PIN EXP1_10_PIN #endif /************************************/ @@ -203,10 +203,10 @@ * This section starts with the pins_RAMPS_144.h as example, after if you need any new * display, you could use normal duponts and connect it with with the scheme showed before. * Tested: - * - Ender 3 Old display (Character LCD) - * - Ender 3 New Serial DWING Display + * - Ender-3 Old display (Character LCD) + * - Ender-3 New Serial DWING Display * - Reprap Display - * - Ender 5 New Serial Display + * - Ender-5 New Serial Display * - Any Reprap character display like */ @@ -222,30 +222,30 @@ #endif // DWIN Encoder - #define BTN_ENC EXP1_09_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_04_PIN #ifndef BEEPER_PIN - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #undef SPEAKER #endif #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) // TO TEST - //#define LCD_PINS_RS EXP2_01_PIN // CS chip select /SS chip slave select - //#define LCD_PINS_ENABLE EXP2_05_PIN // SID (MOSI) - //#define LCD_PINS_D4 EXP2_09_PIN // SCK (CLK) clock + //#define LCD_PINS_RS EXP2_10_PIN // CS chip select /SS chip slave select + //#define LCD_PINS_ENABLE EXP2_06_PIN // SID (MOSI) + //#define LCD_PINS_D4 EXP2_02_PIN // SCK (CLK) clock #elif BOTH(IS_NEWPANEL, PANEL_ONE) // TO TEST - //#define LCD_PINS_RS EXP1_09_PIN - //#define LCD_PINS_ENABLE EXP2_06_PIN + //#define LCD_PINS_RS EXP1_02_PIN + //#define LCD_PINS_ENABLE EXP2_05_PIN //#define LCD_PINS_D4 57 // Mega/Due:65 - AGCM4:57 //#define LCD_PINS_D5 58 // Mega/Due:66 - AGCM4:58 - //#define LCD_PINS_D6 EXP2_04_PIN + //#define LCD_PINS_D6 EXP2_07_PIN //#define LCD_PINS_D7 56 // Mega/Due:64 - AGCM4:56 #else @@ -266,10 +266,10 @@ // TO TEST //#define LCD_PINS_RS 56 // Mega/Due:64 - AGCM4:56 - //#define LCD_PINS_ENABLE EXP2_04_PIN + //#define LCD_PINS_ENABLE EXP2_07_PIN //#define LCD_PINS_D4 55 // Mega/Due:63 - AGCM4:55 - //#define LCD_PINS_D5 EXP1_09_PIN - //#define LCD_PINS_D6 EXP2_06_PIN + //#define LCD_PINS_D5 EXP1_02_PIN + //#define LCD_PINS_D6 EXP2_05_PIN //#define LCD_PINS_D7 57 // Mega/Due:65 - AGCM4:57 #else @@ -287,17 +287,17 @@ #else // Definitions for any standard Display - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN + #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 #endif - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if !IS_NEWPANEL - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #endif #endif @@ -305,9 +305,9 @@ #if !IS_NEWPANEL // Buttons attached to a shift register // Not wired yet - //#define SHIFT_CLK_PIN EXP1_04_PIN - //#define SHIFT_LD_PIN EXP2_06_PIN - //#define SHIFT_OUT_PIN EXP1_09_PIN + //#define SHIFT_CLK_PIN EXP1_07_PIN + //#define SHIFT_LD_PIN EXP2_05_PIN + //#define SHIFT_OUT_PIN EXP1_02_PIN //#define SHIFT_EN_PIN 17 #endif @@ -320,7 +320,7 @@ #if IS_RRD_SC - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #if ENABLED(CR10_STOCKDISPLAY) // TO TEST @@ -329,21 +329,21 @@ #else // Definitions for any standard Display - #define BTN_EN1 EXP2_06_PIN - #define BTN_EN2 EXP2_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 #endif #endif - #define BTN_ENC EXP1_09_PIN + #define BTN_ENC EXP1_02_PIN #ifndef SD_DETECT_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif - #define KILL_PIN EXP2_01_PIN + #define KILL_PIN EXP2_10_PIN #if ENABLED(BQ_LCD_SMART_CONTROLLER) - //#define LCD_BACKLIGHT_PIN EXP1_03_PIN // TO TEST + //#define LCD_BACKLIGHT_PIN EXP1_08_PIN // TO TEST #endif #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) @@ -352,41 +352,41 @@ //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 //#define BTN_ENC 55 - //#define SD_DETECT_PIN EXP2_06_PIN + //#define SD_DETECT_PIN EXP2_05_PIN #elif ENABLED(LCD_I2C_PANELOLU2) // TO TEST //#define BTN_EN1 47 - //#define BTN_EN2 EXP2_08_PIN + //#define BTN_EN2 EXP2_03_PIN //#define BTN_ENC 32 //#define LCD_SDSS SDSS - //#define KILL_PIN EXP1_10_PIN + //#define KILL_PIN EXP1_01_PIN #elif ENABLED(LCD_I2C_VIKI) // TO TEST - //#define BTN_EN1 EXP1_09_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. - //#define BTN_EN2 EXP2_06_PIN + //#define BTN_EN1 EXP1_02_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. + //#define BTN_EN2 EXP2_05_PIN //#define BTN_ENC -1 //#define LCD_SDSS SDSS - //#define SD_DETECT_PIN EXP2_01_PIN + //#define SD_DETECT_PIN EXP2_10_PIN - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) // TO TEST //#define DOGLCD_CS 45 - //#define DOGLCD_A0 EXP2_04_PIN + //#define DOGLCD_A0 EXP2_07_PIN //#define LCD_SCREEN_ROT_180 //#define BEEPER_PIN 33 //#define STAT_LED_RED_PIN 32 - //#define STAT_LED_BLUE_PIN EXP1_08_PIN + //#define STAT_LED_BLUE_PIN EXP1_03_PIN //#define BTN_EN1 22 //#define BTN_EN2 7 - //#define BTN_ENC EXP1_03_PIN + //#define BTN_ENC EXP1_08_PIN //#define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board //#define KILL_PIN 31 @@ -400,23 +400,23 @@ //#define BEEPER_PIN 23 //#define LCD_BACKLIGHT_PIN 33 - //#define BTN_EN1 EXP1_08_PIN - //#define BTN_EN2 EXP1_05_PIN + //#define BTN_EN1 EXP1_03_PIN + //#define BTN_EN2 EXP1_06_PIN //#define BTN_ENC 31 //#define LCD_SDSS SDSS - //#define SD_DETECT_PIN EXP2_01_PIN - //#define KILL_PIN EXP1_10_PIN + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN EXP1_01_PIN #elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864) // TO TEST - //#define BEEPER_PIN EXP1_05_PIN - //#define BTN_ENC EXP1_08_PIN - //#define SD_DETECT_PIN EXP2_01_PIN + //#define BEEPER_PIN EXP1_06_PIN + //#define BTN_ENC EXP1_03_PIN + //#define SD_DETECT_PIN EXP2_10_PIN //#ifndef KILL_PIN - // #define KILL_PIN EXP1_10_PIN + // #define KILL_PIN EXP1_01_PIN //#endif #if ENABLED(MKS_MINI_12864) @@ -476,11 +476,11 @@ #elif ENABLED(MINIPANEL) // TO TEST - //#define BEEPER_PIN EXP2_06_PIN + //#define BEEPER_PIN EXP2_05_PIN // not connected to a pin //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) - //#define DOGLCD_A0 EXP2_04_PIN + //#define DOGLCD_A0 EXP2_07_PIN //#define DOGLCD_CS 58 // Mega/Due:66 - AGCM4:58 // GLCD features @@ -489,11 +489,11 @@ //#define LCD_SCREEN_ROT_180 //#define LCD_SCREEN_ROT_270 - //#define BTN_EN1 EXP1_09_PIN + //#define BTN_EN1 EXP1_02_PIN //#define BTN_EN2 55 // Mega/Due:63 - AGCM4:55 //#define BTN_ENC 72 // Mega/Due:59 - AGCM4:72 - //#define SD_DETECT_PIN EXP2_01_PIN + //#define SD_DETECT_PIN EXP2_10_PIN //#define KILL_PIN 56 // Mega/Due:64 - AGCM4:56 #elif ENABLED(ZONESTAR_LCD) @@ -513,9 +513,9 @@ // Buttons are directly attached to AUX-2 #if IS_RRW_KEYPAD // TO TEST - //#define SHIFT_OUT_PIN EXP1_09_PIN - //#define SHIFT_CLK_PIN EXP2_04_PIN - //#define SHIFT_LD_PIN EXP2_06_PIN + //#define SHIFT_OUT_PIN EXP1_02_PIN + //#define SHIFT_CLK_PIN EXP2_07_PIN + //#define SHIFT_LD_PIN EXP2_05_PIN //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 //#define BTN_ENC 55 // Mega/Due:63 - AGCM4:55 @@ -523,18 +523,18 @@ // TO TEST //#define BTN_EN1 72 // AUX2 PIN 3 (Mega/Due:59 - AGCM4:72) //#define BTN_EN2 55 // AUX2 PIN 4 (Mega/Due:63 - AGCM4:55) - //#define BTN_ENC EXP2_01_PIN // AUX3 PIN 7 + //#define BTN_ENC EXP2_10_PIN // AUX3 PIN 7 #else // TO TEST - //#define BTN_EN1 EXP1_05_PIN - //#define BTN_EN2 EXP1_08_PIN + //#define BTN_EN1 EXP1_06_PIN + //#define BTN_EN2 EXP1_03_PIN //#define BTN_ENC 31 #endif #if ENABLED(G3D_PANEL) // TO TEST - //#define SD_DETECT_PIN EXP2_01_PIN - //#define KILL_PIN EXP1_10_PIN + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN EXP1_01_PIN #endif #endif @@ -565,7 +565,7 @@ #undef SD_DETECT_PIN #define SD_DETECT_PIN 95 #else - #define SDSS EXP2_07_PIN + #define SDSS EXP2_04_PIN #endif #if HAS_TMC_UART diff --git a/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h b/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h index 0f4bb1d0b591..1c73926781ac 100644 --- a/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h +++ b/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h @@ -218,33 +218,33 @@ * BTN_ENCODER 40 */ -#define EXP1_03_PIN 39 -#define EXP1_04_PIN 38 -#define EXP1_05_PIN 37 -#define EXP1_06_PIN 36 -#define EXP1_07_PIN 34 -#define EXP1_08_PIN 35 -#define EXP1_09_PIN 40 -#define EXP1_10_PIN 41 - -#define EXP2_01_PIN 49 -#define EXP2_04_PIN 44 -#define EXP2_05_PIN 51 -#define EXP2_06_PIN 42 -#define EXP2_07_PIN 53 -#define EXP2_08_PIN 43 -#define EXP2_09_PIN 52 -#define EXP2_10_PIN 50 +#define EXP1_01_PIN 41 +#define EXP1_02_PIN 40 +#define EXP1_03_PIN 35 +#define EXP1_04_PIN 34 +#define EXP1_05_PIN 36 +#define EXP1_06_PIN 37 +#define EXP1_07_PIN 38 +#define EXP1_08_PIN 39 + +#define EXP2_01_PIN 50 +#define EXP2_02_PIN 52 +#define EXP2_03_PIN 43 +#define EXP2_04_PIN 53 +#define EXP2_05_PIN 42 +#define EXP2_06_PIN 51 +#define EXP2_07_PIN 44 +#define EXP2_10_PIN 49 #if ENABLED(CR10_STOCKDISPLAY) + #define EXP3_01_PIN EXP1_01_PIN + #define EXP3_02_PIN EXP1_02_PIN #define EXP3_03_PIN EXP1_03_PIN #define EXP3_04_PIN EXP1_04_PIN #define EXP3_05_PIN EXP1_05_PIN #define EXP3_06_PIN EXP1_06_PIN #define EXP3_07_PIN EXP1_07_PIN #define EXP3_08_PIN EXP1_08_PIN - #define EXP3_09_PIN EXP1_09_PIN - #define EXP3_10_PIN EXP1_10_PIN #endif /************************************/ @@ -255,10 +255,10 @@ * This sections starts with the pins_RAMPS_144.h as example, after if you need any new * display, you could use normal duponts and connect it with with the scheme showed before. * Tested: - * - Ender 3 Old display (Character LCD) - * - Ender 3 New Serial DWING Display + * - Ender-3 Old display (Character LCD) + * - Ender-3 New Serial DWING Display * - Reprap Display - * - Ender 5 New Serial Display + * - Ender-5 New Serial Display * - Any Reprap character display like */ @@ -275,30 +275,30 @@ #endif // DWIN Encoder - #define BTN_ENC EXP1_09_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_04_PIN #ifndef BEEPER_PIN - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #undef SPEAKER #endif #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) // TO TEST - //#define LCD_PINS_RS EXP2_01_PIN // CS chip select /SS chip slave select - //#define LCD_PINS_ENABLE EXP2_05_PIN // SID (MOSI) - //#define LCD_PINS_D4 EXP2_09_PIN // SCK (CLK) clock + //#define LCD_PINS_RS EXP2_10_PIN // CS chip select /SS chip slave select + //#define LCD_PINS_ENABLE EXP2_06_PIN // SID (MOSI) + //#define LCD_PINS_D4 EXP2_02_PIN // SCK (CLK) clock #elif BOTH(IS_NEWPANEL, PANEL_ONE) // TO TEST - //#define LCD_PINS_RS EXP1_09_PIN - //#define LCD_PINS_ENABLE EXP2_06_PIN + //#define LCD_PINS_RS EXP1_02_PIN + //#define LCD_PINS_ENABLE EXP2_05_PIN //#define LCD_PINS_D4 57 // Mega/Due:65 - AGCM4:57 //#define LCD_PINS_D5 58 // Mega/Due:66 - AGCM4:58 - //#define LCD_PINS_D6 EXP2_04_PIN + //#define LCD_PINS_D6 EXP2_07_PIN //#define LCD_PINS_D7 56 // Mega/Due:64 - AGCM4:56 #else @@ -319,10 +319,10 @@ // TO TEST //#define LCD_PINS_RS 56 // Mega/Due:64 - AGCM4:56 - //#define LCD_PINS_ENABLE EXP2_04_PIN + //#define LCD_PINS_ENABLE EXP2_07_PIN //#define LCD_PINS_D4 55 // Mega/Due:63 - AGCM4:55 - //#define LCD_PINS_D5 EXP1_09_PIN - //#define LCD_PINS_D6 EXP2_06_PIN + //#define LCD_PINS_D5 EXP1_02_PIN + //#define LCD_PINS_D6 EXP2_05_PIN //#define LCD_PINS_D7 57 // Mega/Due:65 - AGCM4:57 #else @@ -339,17 +339,17 @@ #else // Definitions for any standard Display - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN + #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 #endif - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if !IS_NEWPANEL - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #endif #endif @@ -357,9 +357,9 @@ #if !IS_NEWPANEL // Buttons attached to a shift register // Not wired yet - //#define SHIFT_CLK_PIN EXP1_04_PIN - //#define SHIFT_LD_PIN EXP2_06_PIN - //#define SHIFT_OUT_PIN EXP1_09_PIN + //#define SHIFT_CLK_PIN EXP1_07_PIN + //#define SHIFT_LD_PIN EXP2_05_PIN + //#define SHIFT_OUT_PIN EXP1_02_PIN //#define SHIFT_EN_PIN 17 #endif @@ -372,29 +372,29 @@ #if IS_RRD_SC - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #if ENABLED(CR10_STOCKDISPLAY) // TO TEST - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN #else // Definitions fpr any standard Display - #define BTN_EN1 EXP2_06_PIN - #define BTN_EN2 EXP2_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 #endif #endif - #define BTN_ENC EXP1_09_PIN + #define BTN_ENC EXP1_02_PIN #ifndef SD_DETECT_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif - #define KILL_PIN EXP2_01_PIN + #define KILL_PIN EXP2_10_PIN #if ENABLED(BQ_LCD_SMART_CONTROLLER) - //#define LCD_BACKLIGHT_PIN EXP1_03_PIN // TO TEST + //#define LCD_BACKLIGHT_PIN EXP1_08_PIN // TO TEST #endif #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) @@ -403,41 +403,41 @@ //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 //#define BTN_ENC 55 - //#define SD_DETECT_PIN EXP2_06_PIN + //#define SD_DETECT_PIN EXP2_05_PIN #elif ENABLED(LCD_I2C_PANELOLU2) // TO TEST //#define BTN_EN1 47 - //#define BTN_EN2 EXP2_08_PIN + //#define BTN_EN2 EXP2_03_PIN //#define BTN_ENC 32 //#define LCD_SDSS SDSS - //#define KILL_PIN EXP1_10_PIN + //#define KILL_PIN EXP1_01_PIN #elif ENABLED(LCD_I2C_VIKI) // TO TEST - //#define BTN_EN1 EXP1_09_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. - //#define BTN_EN2 EXP2_06_PIN + //#define BTN_EN1 EXP1_02_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. + //#define BTN_EN2 EXP2_05_PIN //#define BTN_ENC -1 //#define LCD_SDSS SDSS - //#define SD_DETECT_PIN EXP2_01_PIN + //#define SD_DETECT_PIN EXP2_10_PIN - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) // TO TEST //#define DOGLCD_CS 45 - //#define DOGLCD_A0 EXP2_04_PIN + //#define DOGLCD_A0 EXP2_07_PIN //#define LCD_SCREEN_ROT_180 //#define BEEPER_PIN 33 //#define STAT_LED_RED_PIN 32 - //#define STAT_LED_BLUE_PIN EXP1_08_PIN + //#define STAT_LED_BLUE_PIN EXP1_03_PIN //#define BTN_EN1 22 //#define BTN_EN2 7 - //#define BTN_ENC EXP1_03_PIN + //#define BTN_ENC EXP1_08_PIN //#define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board //#define KILL_PIN 31 @@ -451,23 +451,23 @@ //#define BEEPER_PIN 23 //#define LCD_BACKLIGHT_PIN 33 - //#define BTN_EN1 EXP1_08_PIN - //#define BTN_EN2 EXP1_05_PIN + //#define BTN_EN1 EXP1_03_PIN + //#define BTN_EN2 EXP1_06_PIN //#define BTN_ENC 31 //#define LCD_SDSS SDSS - //#define SD_DETECT_PIN EXP2_01_PIN - //#define KILL_PIN EXP1_10_PIN + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN EXP1_01_PIN #elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864) // TO TEST - //#define BEEPER_PIN EXP1_05_PIN - //#define BTN_ENC EXP1_08_PIN - //#define SD_DETECT_PIN EXP2_01_PIN + //#define BEEPER_PIN EXP1_06_PIN + //#define BTN_ENC EXP1_03_PIN + //#define SD_DETECT_PIN EXP2_10_PIN //#ifndef KILL_PIN - // #define KILL_PIN EXP1_10_PIN + // #define KILL_PIN EXP1_01_PIN //#endif #if ENABLED(MKS_MINI_12864) @@ -527,11 +527,11 @@ #elif ENABLED(MINIPANEL) // TO TEST - //#define BEEPER_PIN EXP2_06_PIN + //#define BEEPER_PIN EXP2_05_PIN // not connected to a pin //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) - //#define DOGLCD_A0 EXP2_04_PIN + //#define DOGLCD_A0 EXP2_07_PIN //#define DOGLCD_CS 58 // Mega/Due:66 - AGCM4:58 // GLCD features @@ -540,11 +540,11 @@ //#define LCD_SCREEN_ROT_180 //#define LCD_SCREEN_ROT_270 - //#define BTN_EN1 EXP1_09_PIN + //#define BTN_EN1 EXP1_02_PIN //#define BTN_EN2 55 // Mega/Due:63 - AGCM4:55 //#define BTN_ENC 72 // Mega/Due:59 - AGCM4:72 - //#define SD_DETECT_PIN EXP2_01_PIN + //#define SD_DETECT_PIN EXP2_10_PIN //#define KILL_PIN 56 // Mega/Due:64 - AGCM4:56 #elif ENABLED(ZONESTAR_LCD) @@ -564,9 +564,9 @@ // Buttons are directly attached to AUX-2 #if IS_RRW_KEYPAD // TO TEST - //#define SHIFT_OUT_PIN EXP1_09_PIN - //#define SHIFT_CLK_PIN EXP2_04_PIN - //#define SHIFT_LD_PIN EXP2_06_PIN + //#define SHIFT_OUT_PIN EXP1_02_PIN + //#define SHIFT_CLK_PIN EXP2_07_PIN + //#define SHIFT_LD_PIN EXP2_05_PIN //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 //#define BTN_ENC 55 // Mega/Due:63 - AGCM4:55 @@ -574,18 +574,18 @@ // TO TEST //#define BTN_EN1 72 // AUX2 PIN 3 (Mega/Due:59 - AGCM4:72) //#define BTN_EN2 55 // AUX2 PIN 4 (Mega/Due:63 - AGCM4:55) - //#define BTN_ENC EXP2_01_PIN // AUX3 PIN 7 + //#define BTN_ENC EXP2_10_PIN // AUX3 PIN 7 #else // TO TEST - //#define BTN_EN1 EXP1_05_PIN - //#define BTN_EN2 EXP1_08_PIN + //#define BTN_EN1 EXP1_06_PIN + //#define BTN_EN2 EXP1_03_PIN //#define BTN_ENC 31 #endif #if ENABLED(G3D_PANEL) // TO TEST - //#define SD_DETECT_PIN EXP2_01_PIN - //#define KILL_PIN EXP1_10_PIN + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN EXP1_01_PIN #endif #endif @@ -616,7 +616,7 @@ #undef SD_DETECT_PIN #define SD_DETECT_PIN 95 #else - #define SDSS EXP2_07_PIN + #define SDSS EXP2_04_PIN #endif #if HAS_TMC_UART diff --git a/Marlin/src/pins/samd/pins_MINITRONICS20.h b/Marlin/src/pins/samd/pins_MINITRONICS20.h new file mode 100644 index 000000000000..ed83c835469a --- /dev/null +++ b/Marlin/src/pins/samd/pins_MINITRONICS20.h @@ -0,0 +1,556 @@ +/** + * 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 + +/** + * ReprapWorld's Minitronics v2.0 + */ + +#if NOT_TARGET(__SAMD21__) + #error "Oops! Select 'Minitronics v2.0' in 'Tools > Board.'" +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Minitronics V2.0" +#endif + +/** + * NOTE: We need the Serial port on the -1 to make it work!!. Remember to change it on configuration.h #define SERIAL_PORT -1 + */ + +/** + * EEPROM EMULATION: Works with some bugs already, but the board needs an I2C EEPROM memory soldered on. + */ +//#define FLASH_EEPROM_EMULATION +//#define I2C_EEPROM // EEPROM on I2C-0 +#define MARLIN_EEPROM_SIZE 500 // 4000 bytes + +//This its another option to emulate an EEPROM, but its more efficient to dont loose the data the first One. +//#define SDCARD_EEPROM_EMULATION + +// +// BLTouch +// +#define SERVO0_PIN 33 // BLTouch PWM + +// +// Limit Switches +// +#define X_STOP_PIN 54 +#define Y_STOP_PIN 55 +#define Z_STOP_PIN 4 + +/** + * NOTE: Useful if extra TMC2209 are to be used as independent axes. + * We need to configure the new digital PIN, for this we could configure on the board the extra pin of this stepper, for example as a MIN_PIN/MAX_PIN. This pin is the D14. + */ +//#define Z2_STOP_PIN 14 +//#define X2_STOP_PIN 14 +//#define Y2_STOP_PIN 14 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 12 +#endif + +// +// Steppers +// +#define X_STEP_PIN 1 +#define X_DIR_PIN 3 +#define X_ENABLE_PIN 0 + +#define Y_STEP_PIN 29 +#define Y_DIR_PIN 28 +#define Y_ENABLE_PIN 0 + +#define Z_STEP_PIN 16 +#define Z_DIR_PIN 17 +#define Z_ENABLE_PIN 0 + +#define E0_STEP_PIN 14 +#define E0_DIR_PIN 15 +#define E0_ENABLE_PIN 0 + +#define E1_STEP_PIN 20 +#define E1_DIR_PIN 13 +#define E1_ENABLE_PIN 21 + +// Filament runout. You may choose to use this pin for some other purpose. It's a normal GPIO that can be configured as I/O. +// For example, a switch to detect any kind of behavior, Power supply pin .... etc. +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN 44 +#endif + +// This board have the option to use an extra TMC2209 stepper, one of the use could be as a second extruder. +#if EXTRUDERS < 2 + // TODO: Corregir aquí que cuando tenemos dos extrusores o lo que sea, utiliza los endstop que le sobran, osea los max, no hay Z2_endstop + #if NUM_Z_STEPPERS > 1 + #define Z2_STOP_PIN 14 + #endif +#else + // If we want to configure the extra stepper as a Extruder, we should have undef all of the extra motors. + #undef X2_DRIVER_TYPE + #undef Y2_DRIVER_TYPE + #undef Z2_DRIVER_TYPE + #undef Z3_DRIVER_TYPE + #undef Z4_DRIVER_TYPE + + // Si tenemos más de un extrusor lo que hacemos es definir el nuevo extrusor así como sus pines + // Acordarse de definir el #define TEMP_SENSOR_1, ya que este contiene el tipo de sonda del extrusor E1 + + #define FIL_RUNOUT2_PIN 14 + +#endif + +// +// Extruder / Bed +// + +// Temperature Sensors +#define TEMP_0_PIN 4 // T1 + +// You could use one of the ADC for a temp chamber if you don't use the second extruder, for example. +#if TEMP_SENSOR_CHAMBER > 0 + #define TEMP_CHAMBER_PIN 3 +#else + #define TEMP_1_PIN 2 // T3 +#endif + +#define TEMP_BED_PIN 3 // T2 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 10 +#define HEATER_1_PIN 11 +#define HEATER_BED_PIN 6 +#define SPINDLE_LASER_PWM_PIN 6 + +// The board has 4 PWM fans, use and configure as desired +#define FAN_PIN 24 + +// +// LCD / Controller +// + +#if ENABLED(CR10_STOCKDISPLAY) + #define EXP3_01_PIN EXP1_01_PIN + #define EXP3_02_PIN EXP1_02_PIN + #define EXP3_03_PIN EXP1_03_PIN + #define EXP3_04_PIN EXP1_04_PIN + #define EXP3_05_PIN EXP1_05_PIN + #define EXP3_06_PIN EXP1_06_PIN + #define EXP3_07_PIN EXP1_07_PIN + #define EXP3_08_PIN EXP1_08_PIN +#endif + +/************************************/ +/***** Configurations Section ******/ +/************************************/ + +/** + * This sections starts with the pins_RAMPS_144.h as example, after if you need any new + * display, you could use normal duponts and connect it with with the scheme showed before. + * Tested: + * - Ender-3 Old display (Character LCD) + * - Ender-3 New Serial DWING Display + * - Reprap Display + * - Ender-5 New Serial Display + * - Any Reprap character display like + */ + +#if HAS_WIRED_LCD + + // + // LCD Display output pins + // + + #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + #define LCD_PINS_RS 18 // CS chip select /SS chip slave select + #define LCD_PINS_ENABLE MOSI // SID (MOSI) + #define LCD_PINS_D4 SCK // SCK (CLK) clock + + #define BTN_ENC 23 + #define BTN_EN1 27 + #define BTN_EN2 33 + + #elif BOTH(IS_NEWPANEL, PANEL_ONE) + + // TO TEST + //#define LCD_PINS_RS EXP1_02_PIN + //#define LCD_PINS_ENABLE EXP2_05_PIN + //#define LCD_PINS_D4 57 // Mega/Due:65 - AGCM4:57 + //#define LCD_PINS_D5 58 // Mega/Due:66 - AGCM4:58 + //#define LCD_PINS_D6 EXP2_07_PIN + //#define LCD_PINS_D7 56 // Mega/Due:64 - AGCM4:56 + + #else + + #if ENABLED(CR10_STOCKDISPLAY) + + // TO TEST + //#define LCD_PINS_RS EXP3_04_PIN + //#define LCD_PINS_ENABLE EXP3_03_PIN + //#define LCD_PINS_D4 EXP3_05_PIN + + #if !IS_NEWPANEL + // TO TEST + //#define BEEPER_PIN EXP3_05_PIN + #endif + + #elif ENABLED(ZONESTAR_LCD) + + // TO TEST + //#define LCD_PINS_RS 56 // Mega/Due:64 - AGCM4:56 + //#define LCD_PINS_ENABLE EXP2_07_PIN + //#define LCD_PINS_D4 55 // Mega/Due:63 - AGCM4:55 + //#define LCD_PINS_D5 EXP1_02_PIN + //#define LCD_PINS_D6 EXP2_05_PIN + //#define LCD_PINS_D7 57 // Mega/Due:65 - AGCM4:57 + + #else + + #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306) + // TO TEST + //#define LCD_PINS_DC 25 // Set as output on init + //#define LCD_PINS_RS 27 // Pull low for 1s to init + // DOGM SPI LCD Support + //#define DOGLCD_CS 16 + //#define DOGLCD_MOSI 17 + //#define DOGLCD_SCK 23 + //#define DOGLCD_A0 LCD_PINS_DC + + #else + // Definitions for any standard Display + #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 + #endif + + #define LCD_PINS_D7 EXP1_08_PIN + + #if !IS_NEWPANEL + #define BEEPER_PIN EXP1_01_PIN + #endif + + #endif + + #if !IS_NEWPANEL + // Buttons attached to a shift register + // Not wired yet + //#define SHIFT_CLK_PIN EXP1_07_PIN + //#define SHIFT_LD_PIN EXP2_05_PIN + //#define SHIFT_OUT_PIN EXP1_02_PIN + //#define SHIFT_EN_PIN 17 + #endif + + #endif + + // + // LCD Display input pins + // + #if IS_NEWPANEL + + #if IS_RRD_SC + + //#define BEEPER_PIN EXP1_01_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + // TO TEST + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #else + // Definitions fpr any standard Display + #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 + #endif + #endif + + #define BTN_ENC EXP1_02_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif + //#define KILL_PIN EXP2_10_PIN + + #if ENABLED(BQ_LCD_SMART_CONTROLLER) + //#define LCD_BACKLIGHT_PIN EXP1_08_PIN // TO TEST + #endif + + #elif ENABLED(LCD_I2C_PANELOLU2) + + // TO TEST + //#define BTN_EN1 47 + //#define BTN_EN2 EXP2_03_PIN + //#define BTN_ENC 32 + //#define LCD_SDSS SDSS + //#define KILL_PIN EXP1_01_PIN + + #elif ENABLED(LCD_I2C_VIKI) + + // TO TEST + //#define BTN_EN1 EXP1_02_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. + //#define BTN_EN2 EXP2_05_PIN + //#define BTN_ENC -1 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN EXP2_10_PIN + + #elif EITHER(VIKI2, miniVIKI) + + // TO TEST + //#define DOGLCD_CS 45 + //#define DOGLCD_A0 EXP2_07_PIN + //#define LCD_SCREEN_ROT_180 + + //#define BEEPER_PIN 33 + //#define STAT_LED_RED_PIN 32 + //#define STAT_LED_BLUE_PIN EXP1_03_PIN + + //#define BTN_EN1 22 + //#define BTN_EN2 7 + //#define BTN_ENC EXP1_08_PIN + + //#define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board + //#define KILL_PIN 31 + + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) + + // TO TEST + //#define DOGLCD_CS 29 + //#define DOGLCD_A0 27 + + //#define BEEPER_PIN 23 + //#define LCD_BACKLIGHT_PIN 33 + + //#define BTN_EN1 EXP1_03_PIN + //#define BTN_EN2 EXP1_06_PIN + //#define BTN_ENC 31 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN EXP1_01_PIN + + #elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864) + + // TO TEST + //#define BEEPER_PIN EXP1_06_PIN + //#define BTN_ENC EXP1_03_PIN + //#define SD_DETECT_PIN EXP2_10_PIN + + //#ifndef KILL_PIN + // #define KILL_PIN EXP1_01_PIN + //#endif + + #if ENABLED(MKS_MINI_12864) + + // TO TEST + //#define DOGLCD_A0 27 + //#define DOGLCD_CS 25 + + // GLCD features + // Uncomment screen orientation + //#define LCD_SCREEN_ROT_90 + //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROT_270 + + // not connected to a pin + //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) + + //#define BTN_EN1 31 + //#define BTN_EN2 33 + + #elif ENABLED(FYSETC_MINI_12864) + + // From https://wiki.fysetc.com/Mini12864_Panel/ + + // TO TEST + //#define DOGLCD_A0 16 + //#define DOGLCD_CS 17 + + //#define BTN_EN1 33 + //#define BTN_EN2 31 + + //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + //#define LCD_RESET_PIN 23 // 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 + // TO TEST + //#define RGB_LED_R_PIN 25 + #endif + #ifndef RGB_LED_G_PIN + // TO TEST + //#define RGB_LED_G_PIN 27 + #endif + #ifndef RGB_LED_B_PIN + // TO TEST + //#define RGB_LED_B_PIN 29 + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + // TO TEST + //#define NEOPIXEL_PIN 25 + #endif + + #endif + + #elif ENABLED(MINIPANEL) + + // TO TEST + //#define BEEPER_PIN EXP2_05_PIN + // not connected to a pin + //#define LCD_BACKLIGHT_PIN 57 // backlight LED on A11/D? (Mega/Due:65 - AGCM4:57) + + //#define DOGLCD_A0 EXP2_07_PIN + //#define DOGLCD_CS 58 // Mega/Due:66 - AGCM4:58 + + // GLCD features + // Uncomment screen orientation + //#define LCD_SCREEN_ROT_90 + //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROT_270 + + //#define BTN_EN1 EXP1_02_PIN + //#define BTN_EN2 55 // Mega/Due:63 - AGCM4:55 + //#define BTN_ENC 72 // Mega/Due:59 - AGCM4:72 + + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN 56 // Mega/Due:64 - AGCM4:56 + + #elif ENABLED(ZONESTAR_LCD) + + // TO TEST + //#define ADC_KEYPAD_PIN 12 + + #elif ENABLED(AZSMZ_12864) + + // TO TEST + + #else + + // Beeper on AUX-4 + //#define BEEPER_PIN 33 + + // Buttons are directly attached to AUX-2 + #if IS_RRW_KEYPAD + // TO TEST + //#define SHIFT_OUT_PIN EXP1_02_PIN + //#define SHIFT_CLK_PIN EXP2_07_PIN + //#define SHIFT_LD_PIN EXP2_05_PIN + //#define BTN_EN1 56 // Mega/Due:64 - AGCM4:56 + //#define BTN_EN2 72 // Mega/Due:59 - AGCM4:72 + //#define BTN_ENC 55 // Mega/Due:63 - AGCM4:55 + #elif ENABLED(PANEL_ONE) + // TO TEST + //#define BTN_EN1 72 // AUX2 PIN 3 (Mega/Due:59 - AGCM4:72) + //#define BTN_EN2 55 // AUX2 PIN 4 (Mega/Due:63 - AGCM4:55) + //#define BTN_ENC EXP2_10_PIN // AUX3 PIN 7 + #else + // TO TEST + //#define BTN_EN1 EXP1_06_PIN + //#define BTN_EN2 EXP1_03_PIN + //#define BTN_ENC 31 + #endif + + #if ENABLED(G3D_PANEL) + // TO TEST + //#define SD_DETECT_PIN EXP2_10_PIN + //#define KILL_PIN EXP1_01_PIN + #endif + + #endif + #endif // IS_NEWPANEL + +#endif // HAS_WIRED_LCD + +// +// SD Support +// + +#define SDSS 2 +#undef SD_DETECT_PIN +#define SD_DETECT_PIN 22 + +#if HAS_TMC_UART + + /** + * Address for the UART Configuration of the TMC2209. Override in Configuration files. + * To test TMC2209 Steppers enable TMC_DEBUG in Configuration_adv.h and test the M122 command with voltage on the steppers. + */ + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0b00 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 0b01 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 0b10 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 0b11 + #endif + #ifndef E1_SLAVE_ADDRESS + #define E1_SLAVE_ADDRESS 0b00 + #endif + + /** + * TMC2208/TMC2209 stepper drivers + * It seems to work perfectly fine on Software Serial, if an advanced user wants to test, you could use the SAMD51 Serial1 and Serial 2. Be careful with the Sercom configurations. + * Steppers 1,2,3,4 (X,Y,Z,E0) are on the Serial1, Sercom (RX = 0, TX = 1), extra stepper 5 (E1 or any axis you want) is on Serial2, Sercom (RX = 17, TX = 16) + */ + + //#define X_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial2 + + #define TMC_BAUD_RATE 250000 + + // + // Software serial + // + #define X_SERIAL_TX_PIN 0 + #define X_SERIAL_RX_PIN 1 + + #define Y_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define Y_SERIAL_RX_PIN X_SERIAL_RX_PIN + + #define Z_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define Z_SERIAL_RX_PIN X_SERIAL_RX_PIN + + #define E0_SERIAL_TX_PIN X_SERIAL_TX_PIN + #define E0_SERIAL_RX_PIN X_SERIAL_RX_PIN + + #define E1_SERIAL_TX_PIN 17 + #define E1_SERIAL_RX_PIN 16 + +#endif diff --git a/Marlin/src/pins/samd/pins_RAMPS_144.h b/Marlin/src/pins/samd/pins_RAMPS_144.h index 406162c0896e..7adb2404c158 100644 --- a/Marlin/src/pins/samd/pins_RAMPS_144.h +++ b/Marlin/src/pins/samd/pins_RAMPS_144.h @@ -408,7 +408,7 @@ //#define LCD_SDSS SDSS //#define SD_DETECT_PIN 49 - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) // TO TEST //#define DOGLCD_CS 45 @@ -452,7 +452,7 @@ //#define SD_DETECT_PIN 49 //#ifndef KILL_PIN - // #define KILL_PIN 41 + // #define KILL_PIN 41 //#endif #if ENABLED(MKS_MINI_12864) diff --git a/Marlin/src/pins/sanguino/pins_ANET_10.h b/Marlin/src/pins/sanguino/pins_ANET_10.h index bd69e167dc05..f6816bfb953c 100644 --- a/Marlin/src/pins/sanguino/pins_ANET_10.h +++ b/Marlin/src/pins/sanguino/pins_ANET_10.h @@ -23,6 +23,8 @@ /** * Anet V1.0 board pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Anet%20V1.0/ANET3D_Board_Schematic.pdf + * Origin: https://github.com/ralf-e/ANET-3D-Board-V1.0/blob/master/ANET3D_Board_Schematic.pdf */ /** diff --git a/Marlin/src/pins/sanguino/pins_AZTEEG_X1.h b/Marlin/src/pins/sanguino/pins_AZTEEG_X1.h index 3edb14ec413f..76d53c6021db 100644 --- a/Marlin/src/pins/sanguino/pins_AZTEEG_X1.h +++ b/Marlin/src/pins/sanguino/pins_AZTEEG_X1.h @@ -23,8 +23,12 @@ /** * Azteeg X1 pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Azteeg%20X1/Azteeg_X1_schematics.pdf + * Origin: https://reprap.org/mediawiki/images/0/07/Azteeg_X1_schematics.pdf */ #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_GEN3_MONOLITHIC.h b/Marlin/src/pins/sanguino/pins_GEN3_MONOLITHIC.h index 1343739a119e..a5afc30187ed 100644 --- a/Marlin/src/pins/sanguino/pins_GEN3_MONOLITHIC.h +++ b/Marlin/src/pins/sanguino/pins_GEN3_MONOLITHIC.h @@ -23,6 +23,7 @@ /** * Gen3 Monolithic Electronics pin assignments + * https://reprap.org/wiki/Generation_3_Electronics */ /** diff --git a/Marlin/src/pins/sanguino/pins_GEN6.h b/Marlin/src/pins/sanguino/pins_GEN6.h index 51e8200b9570..75138845f402 100644 --- a/Marlin/src/pins/sanguino/pins_GEN6.h +++ b/Marlin/src/pins/sanguino/pins_GEN6.h @@ -23,6 +23,8 @@ /** * Gen6 pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Gen6/GEN6_Mendel_Circuit.pdf + * Origin: https://reprap.org/mediawiki/images/0/0f/GEN6_Mendel_Circuit.pdf */ /** diff --git a/Marlin/src/pins/sanguino/pins_GEN7_12.h b/Marlin/src/pins/sanguino/pins_GEN7_12.h index 0834da78c45c..ade59fd80794 100644 --- a/Marlin/src/pins/sanguino/pins_GEN7_12.h +++ b/Marlin/src/pins/sanguino/pins_GEN7_12.h @@ -23,6 +23,14 @@ /** * Gen7 v1.1, v1.2, v1.3 pin assignments + * Schematic (1.1): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Gen7%20v1.1/Gen7Board%20Schematic.pdf + * Origin (1.1): https://github.com/Traumflug/Generation_7_Electronics/blob/release-1.1/release%20documents/Gen7Board%20Schematic.pdf + * Schematic (1.2): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Gen7%20v1.2/Gen7Board%20Schematic.pdf + * Origin (1.2): https://github.com/Traumflug/Generation_7_Electronics/blob/release-1.2/release%20documents/Gen7Board%20Schematic.pdf + * Schematic (1.3): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Gen7%20v1.3/Gen7Board%20Schematic.pdf + * Origin (1.3): https://github.com/Traumflug/Generation_7_Electronics/blob/release-1.3/release%20documents/Gen7Board%20Schematic.pdf + * Schematic (1.3.1): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Gen7%20v1.3.1/Gen7Board%20Schematic.pdf + * Origin (1.3.1): https://github.com/Traumflug/Generation_7_Electronics/blob/release-1.3.1/release%20documents/Gen7Board%20Schematic.pdf */ /** @@ -54,7 +62,7 @@ #include "env_validate.h" #ifndef BOARD_INFO_NAME - #define BOARD_INFO_NAME "Gen7 v1.1 / 1.2" + #define BOARD_INFO_NAME "Gen7 v1.1 - v1.3" #endif #ifndef GEN7_VERSION diff --git a/Marlin/src/pins/sanguino/pins_GEN7_14.h b/Marlin/src/pins/sanguino/pins_GEN7_14.h index 97bfdd28a727..698bd066066a 100644 --- a/Marlin/src/pins/sanguino/pins_GEN7_14.h +++ b/Marlin/src/pins/sanguino/pins_GEN7_14.h @@ -23,6 +23,10 @@ /** * Gen7 v1.4 pin assignments + * Schematic (1.4): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Gen7%20v1.4/Gen7Board%201.4%20Schematic.pdf + * Origin (1.4): https://github.com/Traumflug/Generation_7_Electronics/blob/Gen7Board-1.4/release%20documents/Gen7Board%201.4%20Schematic.pdf + * Schematic (1.4.1): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Gen7%20v1.4.1/Gen7Board%201.4.1%20Schematic.pdf + * Origin (1.4.1): https://github.com/Traumflug/Generation_7_Electronics/blob/Gen7Board-1.4.1/release%20documents/Gen7Board%201.4.1%20Schematic.pdf */ /** diff --git a/Marlin/src/pins/sanguino/pins_MELZI.h b/Marlin/src/pins/sanguino/pins_MELZI.h index e24636c8e03c..be1b7934c81f 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI.h +++ b/Marlin/src/pins/sanguino/pins_MELZI.h @@ -23,6 +23,8 @@ /** * Melzi pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Melzi/schematic.pdf + * Origin: https://github.com/mosfet/melzi/blob/master/melzi.sch */ #ifndef BOARD_INFO_NAME @@ -31,6 +33,10 @@ #define IS_MELZI 1 +#ifndef FAN_PIN + #define FAN_PIN 4 +#endif + // Alter timing for graphical display #if IS_U8GLIB_ST7920 #ifndef BOARD_ST7920_DELAY_1 diff --git a/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h b/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h index a450515a79ff..a61692c9f1fa 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h +++ b/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h @@ -23,6 +23,9 @@ /** * Melzi (Creality) pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Melzi%20(Creality)/CR-10%20Schematic.pdf + * Origin: https://github.com/Creality3DPrinting/CR10-Melzi-1.1.2/blob/master/Circuit%20diagram/Motherboard/CR-10%20Schematic.pdf + * ATmega1284P * * The Creality board needs a bootloader installed before Marlin can be uploaded. * If you don't have a chip programmer you can use a spare Arduino plus a few @@ -42,24 +45,32 @@ #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 +// LCD / Controller // -#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 ANY(MKS_MINI_12864, CR10_STOCKDISPLAY, ENDER2_STOCKDISPLAY) + #if EITHER(CR10_STOCKDISPLAY, ENDER2_STOCKDISPLAY) + #define LCD_PINS_RS 28 // ST9720 CS + #define LCD_PINS_ENABLE 17 // ST9720 DAT + #define LCD_PINS_D4 30 // ST9720 CLK + #endif + #if EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) + #define DOGLCD_CS 28 + #define DOGLCD_A0 30 + #endif + + #define LCD_SDSS 31 // Controller's SD card -#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 BTN_ENC 16 + #define BTN_EN1 11 + #define BTN_EN2 10 + #define BEEPER_PIN 27 + + #define LCD_PINS_DEFINED + +#endif + +#include "pins_MELZI.h" // ... SANGUINOLOLU_12 ... SANGUINOLOLU_11 #if ENABLED(BLTOUCH) #ifndef SERVO0_PIN @@ -132,10 +143,10 @@ /** * EXP1 Connector EXP1 as CR10 STOCKDISPLAY * ------ ------ - * PA4 |10 9 | PC0 BEEPER_PIN |10 9 | BTN_ENC - * PD3 | 8 7 | RESET BTN_EN1 | 8 7 | RESET - * PD2 6 5 | PA1 BTN_EN2 6 5 | LCD_PINS_D4 (ST9720 CLK) - * PA3 | 4 3 | PC1 (ST9720 CS) LCD_PINS_RS | 4 3 | LCD_PINS_ENABLE (ST9720 DAT) - * GND | 2 1 | 5V GND | 2 1 | 5V + * PA4 | 1 2 | PC0 BEEPER_PIN | 1 2 | BTN_ENC + * PD3 | 3 4 | RESET BTN_EN1 | 3 4 | RESET + * PD2 5 6 | PA1 BTN_EN2 5 6 | LCD_PINS_D4 (ST9720 CLK) + * PA3 | 7 8 | PC1 (ST9720 CS) LCD_PINS_RS | 7 8 | LCD_PINS_ENABLE (ST9720 DAT) + * GND | 9 10 | 5V GND | 9 10 | 5V * ------ ------ */ diff --git a/Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h b/Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h index a0421dcf5cc6..00c9db6f81a8 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h +++ b/Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h @@ -23,23 +23,20 @@ /** * Melzi (Malyan M150) pin assignments + * ATmega644P, ATmega1284P */ #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..da010ab1a6e2 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI_TRONXY.h +++ b/Marlin/src/pins/sanguino/pins_MELZI_TRONXY.h @@ -23,10 +23,29 @@ /** * Melzi pin assignments + * ATmega644P, ATmega1284P */ #define BOARD_INFO_NAME "Melzi (Tronxy)" +#define Z_ENABLE_PIN 14 + +#define LCD_SDSS -1 + +#if EITHER(CR10_STOCKDISPLAY, LCD_FOR_MELZI) + #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 +54,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_MELZI_V2.h b/Marlin/src/pins/sanguino/pins_MELZI_V2.h index e49eb57b1137..2cd949e095de 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI_V2.h +++ b/Marlin/src/pins/sanguino/pins_MELZI_V2.h @@ -23,6 +23,8 @@ /** * Melzi V2.0 as found at https://www.reprap.org/wiki/Melzi + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Melzi%20V2/Melzi-circuit.png + * Origin: https://www.reprap.org/mediawiki/images/7/7d/Melzi-circuit.png */ #define BOARD_INFO_NAME "Melzi V2" diff --git a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h index 5fe0d3842dd4..a9e40b2b17a6 100644 --- a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h +++ b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h @@ -23,6 +23,16 @@ /** * Sanguinololu board pin assignments + * Schematic (0.1): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Sanguinololu%20v0.1/schematic.png + * Origin (0.1): https://github.com/mosfet/Sanguinololu/blob/master/rev0.1/sanguinololu.sch + * Schematic (0.6): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Sanguinololu%20v0.6/schematic.jpg + * Origin (0.6): https://github.com/mosfet/Sanguinololu/blob/master/rev0.6/images/schematic.jpg + * Schematic (0.7): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Sanguinololu%20v0.7/schematic.jpg + * Origin (0.7): https://github.com/mosfet/Sanguinololu/blob/master/rev0.7/images/schematic.jpg + * Schematic (1.0): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Sanguinololu%20v1.0/Sanguinololu-schematic.jpg + * Origin (1.0): https://reprap.org/wiki/File:Sanguinololu-schematic.jpg + * Schematic (1.1): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Sanguinololu%20v1.1/schematic.png + * Origin (1.1): https://github.com/mosfet/Sanguinololu/blob/master/rev1.1/sanguinololu.sch */ /** @@ -90,30 +100,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 +149,7 @@ // // LCD / Controller // -#if HAS_WIRED_LCD +#if HAS_WIRED_LCD && DISABLED(LCD_PINS_DEFINED) #define SD_DETECT_PIN -1 @@ -245,7 +243,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 +253,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..220956926143 100644 --- a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_12.h +++ b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_12.h @@ -23,6 +23,12 @@ /** * Sanguinololu V1.2 pin assignments + * Schematic (1.2): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Sanguinololu%20v1.2/schematic.png + * Origin (1.2): https://github.com/mosfet/Sanguinololu/blob/master/rev1.2/sanguinololu.sch + * Schematic (1.3): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Sanguinololu%20v1.3/schematic.png + * Origin (1.3): https://github.com/mosfet/Sanguinololu/blob/master/rev1.3/sanguinololu.sch + * Schematic (1.3a): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Sanguinololu%20v1.3a/schematic.png + * Origin (1.3a): https://github.com/mosfet/Sanguinololu/blob/master/rev1.3a/sanguinololu.sch * * Applies to the following boards: * @@ -38,5 +44,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..1bda25b3d4f7 100644 --- a/Marlin/src/pins/sanguino/pins_STB_11.h +++ b/Marlin/src/pins/sanguino/pins_STB_11.h @@ -22,9 +22,14 @@ #pragma once /** - * STB V1.1 pin assignments + * STB Electronics V1.1 pin assignments + * https://www.reprap.org/wiki/STB_Electronics */ #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 diff --git a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h index 0a8143c37600..bd9230c32a82 100644 --- a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h +++ b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h @@ -31,12 +31,14 @@ /** * ZMIB pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/ZONESTAR%20ZMIB%20V2/ZMIB_V2_Schmatic.pdf + * Origin: https://github.com/ZONESTAR3D/Control-Board/blob/main/8bit/ZMIB/ZMIB%20V2/ZMIB_V2_Schmatic.pdf * * The ZMIB board needs a bootloader installed before Marlin can be uploaded. * 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/ */ /** @@ -164,25 +166,25 @@ /** EXP1 * ------ - * (MOSI) D5 |10 9 | D7 (SCK) - * (CS) D11 | 8 7 | D10 (DC/D4) - * (EN2) D12 6 5 | D4 or D3 (EN/RS) - * (ENC) D29 | 4 3 | D2 (EN1) - * (GND) | 2 1 | (5V) + * (MOSI) D5 | 1 2 | D7 (SCK) + * (CS) D11 | 3 4 | D10 (DC/D4) + * (EN2) D12 5 6 | D4 or D3 (EN/RS) + * (ENC) D29 | 7 8 | D2 (EN1) + * (GND) | 9 10 | (5V) * ------ */ -#define EXP1_03_PIN 2 -#define EXP1_04_PIN 29 +#define EXP1_01_PIN 5 +#define EXP1_02_PIN 7 +#define EXP1_03_PIN 11 +#define EXP1_04_PIN 10 +#define EXP1_05_PIN 12 #ifndef IS_ZMIB_V2 - #define EXP1_05_PIN 4 // ZMIB V1 + #define EXP1_06_PIN 4 // ZMIB V1 #else - #define EXP1_05_PIN 3 // ZMIB V2 + #define EXP1_06_PIN 3 // ZMIB V2 #endif -#define EXP1_06_PIN 12 -#define EXP1_07_PIN 10 -#define EXP1_08_PIN 11 -#define EXP1_09_PIN 7 -#define EXP1_10_PIN 5 +#define EXP1_07_PIN 29 +#define EXP1_08_PIN 2 #if ENABLED(ZONESTAR_12864LCD) // @@ -190,10 +192,10 @@ // #define LCDSCREEN_NAME "ZONESTAR_12864LCD" #define FORCE_SOFT_SPI - //#define LCD_SDSS EXP1_08_PIN - #define LCD_PINS_RS EXP1_08_PIN // ST7920_CS_PIN (LCD module pin 4) - #define LCD_PINS_ENABLE EXP1_05_PIN // ST7920_DAT_PIN (LCD module pin 5) - #define LCD_PINS_D4 EXP1_07_PIN // ST7920_CLK_PIN (LCD module pin 6) + //#define LCD_SDSS EXP1_03_PIN + #define LCD_PINS_RS EXP1_03_PIN // ST7920_CS_PIN (LCD module pin 4) + #define LCD_PINS_ENABLE EXP1_06_PIN // ST7920_DAT_PIN (LCD module pin 5) + #define LCD_PINS_D4 EXP1_04_PIN // ST7920_CLK_PIN (LCD module pin 6) #define BOARD_ST7920_DELAY_1 DELAY_2_NOP #define BOARD_ST7920_DELAY_2 DELAY_2_NOP @@ -205,9 +207,9 @@ // #define LCDSCREEN_NAME "ZONESTAR 12864OLED" #define FORCE_SOFT_SPI - #define LCD_PINS_RS EXP1_05_PIN - #define LCD_PINS_DC EXP1_07_PIN - #define DOGLCD_CS EXP1_08_PIN + #define LCD_PINS_RS EXP1_06_PIN + #define LCD_PINS_DC EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN #if ENABLED(OLED_HW_IIC) #error "Oops! can't choose HW IIC for ZMIB board!!" @@ -224,9 +226,9 @@ // All the above are also RRDSC with rotary encoder // #if IS_RRD_SC - #define BTN_EN1 EXP1_03_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_04_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_07_PIN #define BEEPER_PIN -1 #define KILL_PIN -1 #endif diff --git a/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h b/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h index d38d4bbdb378..c55c63aa29b6 100644 --- a/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h +++ b/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h @@ -51,10 +51,13 @@ // // Limit Switches // -#define X_MAX_PIN PC13 -#define Y_MAX_PIN PC14 -#define Z_MAX_PIN PC15 -#define Z_MIN_PIN PB7 +#define X_STOP_PIN PC13 +#define Y_STOP_PIN PC14 +#define Z_STOP_PIN PC15 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PB7 +#endif // // Steppers diff --git a/Marlin/src/pins/stm32f1/pins_BEAST.h b/Marlin/src/pins/stm32f1/pins_BEAST.h index d494b29c1448..4dafe2f27365 100644 --- a/Marlin/src/pins/stm32f1/pins_BEAST.h +++ b/Marlin/src/pins/stm32f1/pins_BEAST.h @@ -131,7 +131,7 @@ #error "LCD_I2C_PANELOLU2 is not supported." #elif ENABLED(LCD_I2C_VIKI) #error "LCD_I2C_VIKI is not supported." - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #error "VIKI2 / miniVIKI is not supported." #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #error "ELB_FULL_GRAPHIC_CONTROLLER is not supported." 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 06788139f01f..075258991ddd 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h @@ -157,28 +157,37 @@ /** * ------ - * (BEEPER) PA15 |10 9 | PB6 (BTN_ENC) - * (BTN_EN1) PA9 | 8 7 | RESET - * (BTN_EN2) PA10 6 5 | PB9 (LCD_D4) - * (LCD_RS) PB8 | 4 3 | PB7 (LCD_EN) - * GND | 2 1 | 5V + * (BEEPER) PA15 | 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 */ +#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,40 +195,102 @@ #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) /** Creality Ender-2 display pinout * ------ - * (SCK) PA15 |10 9 | PB6 (BTN_ENC) - * (BTN_EN1) PA9 | 8 7 | RESET - * (BTN_EN2) PA10 6 5 | PB9 (LCD_A0) - * (LCD_RS) PB8 | 4 3 | PB7 (MOSI) - * GND | 2 1 | 5V + * (SCK) PA15 | 1 2 | PB6 (BTN_ENC) + * (BTN_EN1) PA9 | 3 4 | RESET + * (BTN_EN2) PA10 5 6 | PB9 (LCD_A0) + * (LCD_RS) PB8 | 7 8 | PB7 (MOSI) + * GND | 9 10 | 5V * ------ * 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 @@ -234,36 +305,36 @@ * * Board Display * ------ ------ - * (SD_DET) PA15 |10 9 | PB6 (BEEPER) 5V |10 9 | GND - * (MOD_RESET) PA9 | 8 7 | RESET (RESET) | 8 7 | (SD_DET) - * (SD_CS) PA10 6 5 | PB9 (MOSI) 6 5 | (LCD_CS) - * (LCD_CS) PB8 | 4 3 | PB7 (SD_CS) | 4 3 | (MOD_RESET) - * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) + * (SD_DET) PA15 | 1 2 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 3 4 | RESET (RESET) | 8 7 | (SD_DET) + * (SD_CS) PA10 5 6 | PB9 (MOSI) 6 5 | (LCD_CS) + * (LCD_CS) PB8 | 7 8 | PB7 (SD_CS) | 4 3 | (MOD_RESET) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) * ------ ------ * EXP1 EXP1 * * Needs custom cable: * * Board Adapter Display - * _________ - * EXP1-1 ----------- EXP1-10 - * EXP1-2 ----------- EXP1-9 - * SPI1-4 ----------- EXP1-6 - * EXP1-4 ----------- EXP1-5 - * SP11-3 ----------- EXP1-2 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- EXP1-8 - * EXP1-8 ----------- EXP1-3 - * SPI1-1 ----------- EXP1-1 - * EXP1-10 ----------- EXP1-7 + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- EXP1-5 LCD_CS + * SP11-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- EXP1-8 RESET + * EXP1-3 ----------- EXP1-3 MOD_RST + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET */ #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 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 fa7eb3dd115c..5770f4a5ba01 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,50 +100,49 @@ #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 |10 9 | PB6 (BTN_ENC) (BEEPER) PB5 |10 9 | PA15 (BTN_ENC) - * (BTN_EN1) PA9 | 8 7 | RESET (BTN_EN1) PA9 | 8 7 | RESET - * (BTN_EN2) PA10 6 5 | PB9 (LCD_D4) (BTN_EN2) PA10 6 5 | PB9 (LCD_D4) - * (LCD_RS) PB8 | 4 3 | PB7 (LCD_EN) (LCD_RS) PB8 | 4 3 | PB15 (LCD_EN) - * GND | 2 1 | 5V GND | 2 1 | 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_9 PA15 - #define EXP1_3 PB15 -#else - #define EXP1_9 PB6 - #define EXP1_3 PB7 +#ifndef EXP1_02_PIN + #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 /** * ------ ------ ------ - * (ENT) |10 9 | (BEEP) |10 9 | |10 9 | - * (RX) | 8 7 | (RX) | 8 7 | (TX) RX | 8 7 | TX - * (TX) 6 5 | (ENT) 6 5 | (BEEP) ENT | 6 5 | BEEP - * (B) | 4 3 | (A) (B) | 4 3 | (A) B | 4 3 | A - * GND | 2 1 | (VCC) GND | 2 1 | VCC GND | 2 1 | VCC + * (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) * @@ -154,24 +153,55 @@ #error "CAUTION! Ender-3 V2 display requires a custom cable. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" #endif - #define BEEPER_PIN EXP1_9 - #define BTN_EN1 EXP1_3 - #define BTN_EN2 PB8 - #define BTN_ENC PB5 + #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 PB5 - #define BTN_ENC EXP1_9 + #define BEEPER_PIN EXP1_01_PIN - #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 EXP1_3 - #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(LCD_FOR_MELZI) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! LCD for Melzi v4 display requires a custom cable. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * LCD for Melzi v4 needs a custom cable with reversed GND/5V pins; plugging in a standard cable may damage the board or LCD! + * 1. Swap the LCD's +5V (Pin2) and GND (Pin1) wires. (This is the critical part!) + * 2. Swap pin 4 on the Melzi LCD to pin 7 on the SKR Mini E3 EXP1 connector (pin 4 on the SKR is a RESET and cannot be used) + * + * LCD for Melzi V4 SKR Mini E3 V2.0 + * ------ ------ + * LCD RS | 1 2 | EN1 LCD RS | 1 2 | EN1 + * LCD EN | 3 4 | EN2 LCD EN | 3 4 | OPEN (RESET) + * LCD D4 | 5 6 | ENC LCD D4 | 5 6 | ENC + * E-Stop | 7 8 | BEEP EN2 | 7 8 | BEEP + * 5V | 9 10 | GND GND | 9 10 | 5V + * ------ ------ + * EXP1 EXP1 + */ + #define BEEPER_PIN EXP1_08_PIN + + #define BTN_ENC EXP1_06_PIN + #define BTN_EN1 EXP1_02_PIN + #define BTN_EN2 EXP1_07_PIN + + #define LCD_PINS_RS EXP1_01_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! @@ -179,24 +209,24 @@ #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_ENABLE EXP1_9 - #define LCD_PINS_D4 PB8 - #define LCD_PINS_D5 PA10 - #define LCD_PINS_D6 PA9 - #define LCD_PINS_D7 PB5 + #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_9 - #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 PB5 - #define DOGLCD_MOSI EXP1_3 + #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 @@ -214,31 +244,31 @@ * * Board Display * ------ ------ - * (SD_DET) PB5 |10 9 | PB6 (BEEPER) 5V |10 9 | GND - * (MOD_RESET) PA9 | 8 7 | RESET -- | 8 7 | (SD_DET) - * (SD_CS) PA10 6 5 | PB9 (MOSI) | 6 5 | -- - * (LCD_CS) PB8 | 4 3 | PB7 (SD_CS) | 4 3 | (LCD_CS) - * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) + * (SD_DET) PB5 | 1 2 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 3 4 | RESET -- | 8 7 | (SD_DET) + * (SD_CS) PA10 5 6 | PB9 (MOSI) | 6 5 | -- + * (LCD_CS) PB8 | 7 8 | PB7 (SD_CS) | 4 3 | (LCD_CS) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) * ------ ------ * EXP1 EXP1 * * Needs custom cable: * - * Board Display - * - * EXP1-1 ----------- EXP1-10 - * EXP1-2 ----------- EXP1-9 - * SPI1-4 ----------- EXP1-6 - * EXP1-4 ----------- FREE - * SPI1-3 ----------- EXP1-2 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- FREE - * EXP1-8 ----------- EXP1-3 - * SPI1-1 ----------- EXP1-1 - * EXP1-10 ----------- EXP1-7 + * Board Adapter Display + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- n/c + * SPI1-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- n/c + * EXP1-3 ----------- EXP1-3 LCD_CS + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET */ - #define TFTGLCD_CS PA9 + #define TFTGLCD_CS EXP1_03_PIN #endif @@ -253,18 +283,18 @@ * * Board Display * ------ ------ - * PB5 |10 9 | PA15 (BEEP) |10 9 | BTN_ENC - * PA9 | 8 7 | RESET LCD_CS | 8 7 | LCD A0 - * PA10 | 6 5 | PB9 LCD_RST | 6 5 | RED - * PB8 | 4 3 | PB15 (GREEN) | 4 3 | (BLUE) - * GND | 2 1 | 5V GND | 2 1 | 5V + * PB5 | 1 2 | PA15 (BEEP) |10 9 | BTN_ENC + * PA9 | 3 4 | RESET LCD_CS | 8 7 | LCD A0 + * PA10 | 5 6 | PB9 LCD_RST | 6 5 | RED + * PB8 | 7 8 | PB15 (GREEN) | 4 3 | (BLUE) + * GND | 9 10 | 5V GND | 2 1 | 5V * ------ ------ * EXP1 EXP1 * * --- ------ * 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) * --- ------ @@ -274,42 +304,40 @@ * * Board Display * - * EXP1-1 ----------- EXP1-1 - * EXP1-2 ----------- EXP1-2 - * EXP1-3 ----------- EXP2-6 - * EXP1-4 ----------- EXP1-5 - * EXP1-5 ----------- EXP2-8 - * EXP1-6 ----------- EXP1-6 - * EXP1-8 ----------- EXP1-8 - * EXP1-9 ----------- EXP1-9 - * EXP1-10 ----------- EXP1-7 + * EXP1-10 ---------- EXP1-1 5V + * EXP1-9 ----------- EXP1-2 GND + * EXP1-8 ----------- EXP2-6 EN2 + * EXP1-7 ----------- EXP1-5 RED + * EXP1-6 ----------- EXP2-8 EN1 + * 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 - * TFT-3 ----------- EXP2-5 + * TFT-2 ----------- EXP2-5 MOSI + * TFT-3 ----------- EXP2-9 SCK * * 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_ENABLE PA3 // MOSI #define LCD_BACKLIGHT_PIN -1 - #define NEOPIXEL_PIN PB8 - #define LCD_CONTRAST 255 - #define LCD_RESET_PIN PA10 + #define NEOPIXEL_PIN EXP1_07_PIN + #define LCD_CONTRAST 255 - #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 #else - #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, TFTGLCD_PANEL_(SPI|I2C), FYSETC_MINI_12864_2_1, MKS_MINI_12864_V3, and BTT_MINI_12864_V1 are currently supported on the BIGTREE_SKR_MINI_E3." + #error "Only CR10_STOCKDISPLAY, LCD_FOR_MELZI, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, TFTGLCD_PANEL_(SPI|I2C), FYSETC_MINI_12864_2_1, MKS_MINI_12864_V3, and BTT_MINI_12864_V1 are currently supported on the BIGTREE_SKR_MINI_E3." #endif #endif // HAS_WIRED_LCD @@ -325,36 +353,36 @@ * * Board Display * ------ ------ - * (SD_DET) PB5 |10 9 | PB6 (BEEPER) 5V |10 9 | GND - * (MOD_RESET) PA9 | 8 7 | RESET (RESET) | 8 7 | (SD_DET) - * (SD_CS) PA10 6 5 | PB9 (MOSI) | 6 5 | (LCD_CS) - * (LCD_CS) PB8 | 4 3 | PB7 (SD_CS) | 4 3 | (MOD_RESET) - * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) + * (SD_DET) PB5 | 1 2 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 3 4 | RESET (RESET) | 8 7 | (SD_DET) + * (SD_CS) PA10 5 6 | PB9 (MOSI) | 6 5 | (LCD_CS) + * (LCD_CS) PB8 | 7 8 | PB7 (SD_CS) | 4 3 | (MOD_RESET) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) * ------ ------ * EXP1 EXP1 * * Needs custom cable: * * Board Adapter Display - * _________ - * EXP1-1 ----------- EXP1-10 - * EXP1-2 ----------- EXP1-9 - * SPI1-4 ----------- EXP1-6 - * EXP1-4 ----------- EXP1-5 - * SPI1-3 ----------- EXP1-2 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- EXP1-8 - * EXP1-8 ----------- EXP1-3 - * SPI1-1 ----------- EXP1-1 - * EXP1-10 ----------- EXP1-7 + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- EXP1-5 LCD_CS + * SPI1-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- EXP1-8 RESET + * EXP1-3 ----------- EXP1-3 MOD_RST + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET */ - #define CLCD_SPI_BUS 1 // SPI1 connector + #define CLCD_SPI_BUS 1 // SPI1 connector - #define BEEPER_PIN EXP1_9 + #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 @@ -369,13 +397,13 @@ #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 -#define ONBOARD_SPI_DEVICE 1 // SPI1 -> used only by HAL/STM32F1... +#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 diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h index 1ea947ffdf18..c544e1353c1f 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h @@ -111,47 +111,78 @@ #define TEMP_0_PIN PA0 // Analog Input /** ------ ------ - * (BEEPER) PC10 |10 9 | PC11 (BTN_ENC) (MISO) PB4 |10 9 | PB3 (SCK) - * (LCD_EN) PB6 | 8 7 | PC12 (LCD_RS) (BTN_EN1) PD2 | 8 7 | PA15 (SD_SS) - * (LCD_D4) PC13 6 5 | PB7 (LCD_D5) (BTN_EN2) PB8 6 5 | PB5 (MOSI) - * (LCD_D6) PC15 | 4 3 | PC14 (LCD_D7) (SD_DETECT) PB9 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) PC10 | 1 2 | PC11 (BTN_ENC) (MISO) PB4 | 1 2 | PB3 (SCK) + * (LCD_EN) PB6 | 3 4 | PC12 (LCD_RS) (BTN_EN1) PD2 | 3 4 | PA15 (SD_SS) + * (LCD_D4) PC13 5 6 | PB7 (LCD_D5) (BTN_EN2) PB8 5 6 | PB5 (MOSI) + * (LCD_D6) PC15 | 7 8 | PC14 (LCD_D7) (SD_DETECT) PB9 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PC14 -#define EXP1_04_PIN PC15 -#define EXP1_05_PIN PB7 -#define EXP1_06_PIN PC13 -#define EXP1_07_PIN PC12 -#define EXP1_08_PIN PB6 -#define EXP1_09_PIN PC11 -#define EXP1_10_PIN PC10 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN PB9 -#define EXP2_05_PIN PB5 -#define EXP2_06_PIN PB8 -#define EXP2_07_PIN PA15 -#define EXP2_08_PIN PD2 -#define EXP2_09_PIN PB3 -#define EXP2_10_PIN PB4 +#define EXP1_01_PIN PC10 +#define EXP1_02_PIN PC11 +#define EXP1_03_PIN PB6 +#define EXP1_04_PIN PC12 +#define EXP1_05_PIN PC13 +#define EXP1_06_PIN PB7 +#define EXP1_07_PIN PC15 +#define EXP1_08_PIN PC14 + +#define EXP2_01_PIN PB4 +#define EXP2_02_PIN PB3 +#define EXP2_03_PIN PD2 +#define EXP2_04_PIN PA15 +#define EXP2_05_PIN PB8 +#define EXP2_06_PIN PB5 +#define EXP2_07_PIN PB9 +#define EXP2_08_PIN -1 // RESET // // LCD / Controller // -#if HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN +#if EITHER(TFT_COLOR_UI, TFT_CLASSIC_UI) + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + #define TFT_DC_PIN EXP1_08_PIN + #define TFT_A0_PIN TFT_DC_PIN + + #define TFT_RESET_PIN EXP1_04_PIN + + #define LCD_BACKLIGHT_PIN EXP1_03_PIN + #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN + + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 3 + + #define TOUCH_CS_PIN EXP1_05_PIN // SPI3_NSS + #define TOUCH_SCK_PIN EXP2_02_PIN // SPI3_SCK + #define TOUCH_MISO_PIN EXP2_01_PIN // SPI3_MISO + #define TOUCH_MOSI_PIN EXP2_06_PIN // SPI3_MOSI + + #define LCD_READ_ID 0xD3 + #define LCD_USE_DMA_SPI + + #define TFT_BUFFER_SIZE 9600 + +#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_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif IS_TFTGLCD_PANEL @@ -159,56 +190,56 @@ #undef BTN_ENC #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN #if ENABLED(FYSETC_MINI_12864) #define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define LCD_RESET_PIN EXP1_05_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN #define FORCE_SOFT_SPI // SPI MODE3 - #define LED_PIN EXP1_05_PIN // red pwm - //#define LED_PIN EXP1_04_PIN // green - //#define LED_PIN EXP1_03_PIN // blue + #define LED_PIN EXP1_06_PIN // red pwm + //#define LED_PIN EXP1_07_PIN // green + //#define LED_PIN EXP1_08_PIN // blue //#if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) // #ifndef RGB_LED_R_PIN - // #define RGB_LED_R_PIN EXP1_05_PIN + // #define RGB_LED_R_PIN EXP1_06_PIN // #endif // #ifndef RGB_LED_G_PIN - // #define RGB_LED_G_PIN EXP1_04_PIN + // #define RGB_LED_G_PIN EXP1_07_PIN // #endif // #ifndef RGB_LED_B_PIN - // #define RGB_LED_B_PIN EXP1_03_PIN + // #define RGB_LED_B_PIN EXP1_08_PIN // #endif //#elif ENABLED(FYSETC_MINI_12864_2_1) - // #define NEOPIXEL_PIN EXP1_05_PIN + // #define NEOPIXEL_PIN EXP1_06_PIN //#endif #else // !FYSETC_MINI_12864 - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #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 @@ -241,11 +272,11 @@ #if SD_CONNECTION_IS(LCD) #define SPI_DEVICE 3 - #define SD_DETECT_PIN EXP2_04_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN - #define SD_SS_PIN EXP2_07_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_SS_PIN EXP2_04_PIN #elif SD_CONNECTION_IS(ONBOARD) #define SD_DETECT_PIN PA3 #define SD_SCK_PIN PA5 @@ -253,5 +284,7 @@ #define SD_MOSI_PIN PA7 #define SD_SS_PIN PA4 #endif + #define ONBOARD_SPI_DEVICE 1 // SPI1 #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card +#define SDSS SD_SS_PIN diff --git a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h index 9dec1e127967..c73544bf436f 100644 --- a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h +++ b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h @@ -123,35 +123,35 @@ /** * ------ - * PB5 |10 9 | PB6 - * PA2 | 8 7 | RESET - * PA3 6 5 | PB8 - * PB7 | 4 3 | PA4 - * GND | 2 1 | VCC5 + * PB5 | 1 2 | PB6 + * PA2 | 3 4 | RESET + * PA3 5 6 | PB8 + * PB7 | 7 8 | PA4 + * GND | 9 10 | VCC5 * ------ * EXP1 */ -#define EXP1_03_PIN PA4 -#define EXP1_04_PIN PB7 -#define EXP1_05_PIN PB8 -#define EXP1_06_PIN PA3 -#define EXP1_07_PIN -1 // RESET -#define EXP1_08_PIN PA2 -#define EXP1_09_PIN PB6 -#define EXP1_10_PIN PB5 +#define EXP1_01_PIN PB5 +#define EXP1_02_PIN PB6 +#define EXP1_03_PIN PA2 +#define EXP1_04_PIN -1 // RESET +#define EXP1_05_PIN PA3 +#define EXP1_06_PIN PB8 +#define EXP1_07_PIN PB7 +#define EXP1_08_PIN PA4 // // LCD / Controller // #if ENABLED(CR10_STOCKDISPLAY) - #define BEEPER_PIN EXP1_10_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_09_PIN - - #define LCD_PINS_RS EXP1_04_PIN // CS -- SOFT SPI for ENDER3 LCD - #define LCD_PINS_D4 EXP1_05_PIN // SCLK - #define LCD_PINS_ENABLE EXP1_03_PIN // DATA MOSI + #define BEEPER_PIN EXP1_01_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN + + #define LCD_PINS_RS EXP1_07_PIN // CS -- SOFT SPI for ENDER3 LCD + #define LCD_PINS_D4 EXP1_06_PIN // SCLK + #define LCD_PINS_ENABLE EXP1_08_PIN // DATA MOSI #endif // Alter timing for graphical display diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D.h b/Marlin/src/pins/stm32f1/pins_CHITU3D.h index 1f56e59a23c5..3b66096a270d 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D.h @@ -171,7 +171,7 @@ #define LCD_SDSS PD5 // 53 #define SD_DETECT_PIN PD1 // 49 - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #define BEEPER_PIN PC1 // 33 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" diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h index b76ef52c420a..02daab3e63ac 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h @@ -27,8 +27,61 @@ #define Z2_STEP_PIN PF5 #define Z2_DIR_PIN PF1 +#define Z_STOP_PIN PA14 + #ifndef FIL_RUNOUT2_PIN #define FIL_RUNOUT2_PIN PF13 #endif +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PG9 +#endif + #include "pins_CHITU3D_common.h" + +/* + * Circuit diagram https://github.com/MarlinFirmware/Marlin/files/3401484/x5sa-main_board-2.pdf + * + * Details on the 30 pin ribbon pins. From: https://3dtoday.ru/blogs/artem-sr/tronxy-x5sa-pro-ustanovka-bfp-touch-na-board-chitu3d-v6-cxy-v6-191017 + * + * JP2 Ribbon 30 on CXY-V6-191017 + * ---------------------------------------------- + * | 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30| + * | 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29| + * ---------------------- ---------------------- + * + * -------------------------------------------------------------------------------------- + * | Pin | Label | Function & Notes | + * -------------------------------------------------------------------------------------- + * | 1 | Hotend | Hotend driver Q6 HY1403 via MCU Pin127 PG12 | + * | 2 | Hotend | Hotend driver Q6 HY1403 via MCU Pin127 PG12 | + * | 3 | Hotend | Hotend driver Q6 HY1403 via MCU Pin127 PG12 | + * | 4 | Hotend | Hotend driver Q6 HY1403 via MCU Pin127 PG12 | + * | 5 | +24v | Hotend +24v | + * | 6 | +24v | Hotend +24v | + * | 7 | +24v | Hotend +24v | + * | 8 | +24v | Hotend +24v | + * | 9 | F_2 | Extruder Fan2 driver Q8 AO3400A X07S via MCU Pin129 PG14 | + * | 10 | +24v | Extruder cooling Fan2 +24v | + * | 11 | F_1 | Part Fan1 driver Q7 AO3400A X07S via MCU Pin128 PG13 | + * | 12 | +24v | Part cooling Fanl +24v | + * | 13 | 1B | X-MOTOR Winding Drive | + * | 14 | 1A | X-MOTOR Winding Drive | + * | 15 | 2B | X-MOTOR Winding Drive | + * | 16 | 2A | X-MOTOR Winding Drive | + * | 17 | lA | El-Motor Winding Drive | + * | 18 | 1B | El-Motor Winding Drive | + * | 19 | 2B | El-Motor Winding Drive | + * | 20 | 2A | El-Motor Winding Drive | + * | 21 | PROXIMITY | 10kΩ Pullup to +5V and 100nF to GND, then 20kΩ to MCU Pin124 PG9 | + * | 22 | +24v | Proximity sensor +24v | + * | 23 | +5V | Filament sensor +5V XSTOP sensor +5V | + * | 24 | GND | Proximity sensor GND | + * | 25 | FILAMENT1 | 10kΩ Pullup to +5V and 100nF to GND, then 47kΩ to MCU Pin110 PA15| + * | 26 | GND | Filament Sensor GND | + * | 27 | XSTOP | 10kΩ Pullup to +5V and 100nF to GND, then 47kΩ to MCU Pin125 PG10| + * | 28 | GND | XSTOP sensor GND | + * | 29 | GND | Extruder temperature NTC sensor return GND | + * | 30 | ETEMP | 4k7Ω Pullup to +3V3 and 100nF to GND, then 4k7Ω to MCU Pin35 PA1 | + * -------------------------------------------------------------------------------------- + */ 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_CREALITY_V24S1.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1.h index 0d2ad835d397..f7a73de28471 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1.h @@ -22,7 +22,7 @@ #pragma once /** - * Creality v2.4.S1 (STM32F103RE / STM32F103RC) v101 as found in the Ender 7 + * Creality v2.4.S1 (STM32F103RE / STM32F103RC) v101 as found in the Ender-7 */ #define BOARD_INFO_NAME "Creality v2.4.S1 V101" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1_301.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1_301.h index 53953f9ebccc..b7ea20725b25 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1_301.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1_301.h @@ -22,7 +22,7 @@ #pragma once /** - * Creality V24S1_301 (STM32F103RE / STM32F103RC) board pin assignments as found on Ender 3 S1. + * Creality V24S1_301 (STM32F103RE / STM32F103RC) board pin assignments as found on Ender-3 S1. * Also supports the STM32F4 version of the board with identical pin mapping. */ @@ -40,7 +40,7 @@ #define BOARD_INFO_NAME "Creality V24S1-301" #endif #ifndef DEFAULT_MACHINE_NAME - #define DEFAULT_MACHINE_NAME "Ender 3 S1" + #define DEFAULT_MACHINE_NAME "Ender-3 S1" #endif // diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index cb11c3e53b5b..c5125aaff4d8 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -35,7 +35,7 @@ #define BOARD_INFO_NAME "Creality V4" #endif #ifndef DEFAULT_MACHINE_NAME - #define DEFAULT_MACHINE_NAME "Ender 3 V2" + #define DEFAULT_MACHINE_NAME "Ender-3 V2" #endif #define BOARD_NO_NATIVE_USB @@ -53,6 +53,7 @@ #if NO_EEPROM_SELECTED #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 //#define SDCARD_EEPROM_EMULATION + #undef NO_EEPROM_SELECTED #endif #if ENABLED(IIC_BL24CXX_EEPROM) @@ -77,8 +78,12 @@ // // Limit Switches // -#define X_STOP_PIN PA5 -#define Y_STOP_PIN PA6 +#ifndef X_STOP_PIN + #define X_STOP_PIN PA5 +#endif +#ifndef Y_STOP_PIN + #define Y_STOP_PIN PA6 +#endif #ifndef Z_STOP_PIN #define Z_STOP_PIN PA7 #endif @@ -153,61 +158,152 @@ // SD Card // #define SD_DETECT_PIN PC7 -#define SDCARD_CONNECTION ONBOARD +#define SDCARD_CONNECTION ONBOARD #define SDIO_SUPPORT #define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer -#if ENABLED(CR10_STOCKDISPLAY) - - #if ENABLED(RET6_12864_LCD) - - // RET6 12864 LCD - #define LCD_PINS_RS PB12 - #define LCD_PINS_ENABLE PB15 - #define LCD_PINS_D4 PB13 - - #define BTN_ENC PB2 - #define BTN_EN1 PB10 - #define BTN_EN2 PB14 - - #ifndef HAS_PIN_27_BOARD - #define BEEPER_PIN PC6 - #endif +#if ANY(RET6_12864_LCD, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) + + /** + * 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 - #elif ENABLED(VET6_12864_LCD) +#if ENABLED(CR10_STOCKDISPLAY) - // VET6 12864 LCD - #define LCD_PINS_RS PA4 - #define LCD_PINS_ENABLE PA7 - #define LCD_PINS_D4 PA5 + #define LCD_PINS_RS EXP3_07_PIN + #define LCD_PINS_ENABLE EXP3_08_PIN + #define LCD_PINS_D4 EXP3_06_PIN - #define BTN_ENC PC5 - #define BTN_EN1 PB10 - #define BTN_EN2 PA6 + #define BTN_ENC EXP3_02_PIN + #define BTN_EN1 EXP3_03_PIN + #define BTN_EN2 EXP3_05_PIN - #else - #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for CR10_STOCKDISPLAY with the Creality V4 controller." + #ifndef HAS_PIN_27_BOARD + #define BEEPER_PIN EXP3_01_PIN #endif -#elif HAS_DWIN_E3V2 || IS_DWIN_MARLINUI +#elif ANY(HAS_DWIN_E3V2, IS_DWIN_MARLINUI, DWIN_VET6_CREALITY_LCD) - // RET6 DWIN ENCODER LCD - #define BTN_ENC PB14 - #define BTN_EN1 PB15 - #define BTN_EN2 PB12 + #define BTN_ENC EXP3_05_PIN + #define BTN_EN1 EXP3_08_PIN + #define BTN_EN2 EXP3_07_PIN - //#define LCD_LED_PIN PB2 #ifndef BEEPER_PIN - #define BEEPER_PIN PB13 + #define BEEPER_PIN EXP3_06_PIN #endif -#elif ENABLED(DWIN_VET6_CREALITY_LCD) +#elif ENABLED(FYSETC_MINI_12864_2_1) - // VET6 DWIN ENCODER LCD - #define BTN_ENC PA6 - #define BTN_EN1 PA7 - #define BTN_EN2 PA4 + #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 - #define BEEPER_PIN PA5 + #if SD_CONNECTION_IS(LCD) + #error "The LCD SD Card 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 EXP3_02_PIN + #define BTN_EN1 EXP3_01_PIN + #define BTN_EN2 EXP3_06_PIN + #define BEEPER_PIN -1 + + #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 + #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 diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h index 484ff6544275..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 |10 9 | PB2 - * PB10 | 8 7 | PE8 - * PB14 6 5 | PB13 - * PB12 | 4 3 | PB15 - * GND | 2 1 | 5V - * ------ - * EXP1 - */ - #define EXP1_03_PIN PB15 - #define EXP1_04_PIN PB12 - #define EXP1_05_PIN PB13 - #define EXP1_06_PIN PB14 - #define EXP1_07_PIN PE8 - #define EXP1_08_PIN PB10 - #define EXP1_09_PIN PB2 - #define EXP1_10_PIN PC6 - - #define BEEPER_PIN EXP1_10_PIN - - #elif ENABLED(VET6_12864_LCD) - - /** - * VET6 12864 LCD - * ------ - * ? |10 9 | PC5 - * PB10 | 8 7 | ? - * PA6 6 5 | PA5 - * PA4 | 4 3 | PA7 - * GND | 2 1 | 5V - * ------ - * EXP1 - */ - #define EXP1_03_PIN PA7 - #define EXP1_04_PIN PA4 - #define EXP1_05_PIN PA5 - #define EXP1_06_PIN PA6 - #define EXP1_07_PIN -1 - #define EXP1_08_PIN PB10 - #define EXP1_09_PIN PC5 - #define EXP1_10_PIN -1 - - #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_04_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_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_09_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_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_V422.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h index 5499adb07668..9e26b37de0d3 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h @@ -28,4 +28,6 @@ #define BOARD_INFO_NAME "Creality v4.2.2" #define DEFAULT_MACHINE_NAME "Creality3D" +#define EMIT_CREALITY_422_WARNING + #include "pins_CREALITY_V4.h" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V425.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V425.h new file mode 100644 index 000000000000..1c62d19a99e4 --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V425.h @@ -0,0 +1,77 @@ +/** + * 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 4.2.5 (STM32F103RE / STM32F103RC) board pin assignments + */ + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "Creality v4.2.5 only supports 1 hotend / E stepper." +#endif + +#define BOARD_INFO_NAME "Creality V4.2.5" +#define DEFAULT_MACHINE_NAME "CR200B" + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 + #undef NO_EEPROM_SELECTED +#elif DISABLED(IIC_BL24CXX_EEPROM) + #define SDCARD_EEPROM_EMULATION // SD EEPROM until all EEPROM is BL24CXX +#endif + +// +// Servos +// +#define SERVO0_PIN PB1 // BLTouch OUT + +// +// Limit Switches +// +#define X_STOP_PIN PA3 +#define Y_STOP_PIN PA4 +#define Z_STOP_PIN PA5 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PB0 // BLTouch IN +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA6 // "Pulled-high" +#endif + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA0 // HEATER1 +#define HEATER_BED_PIN PA1 // HOT BED +#define FAN_PIN PA2 // FAN + +#include "pins_CREALITY_V4.h" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h index 077f4c73a657..ccb7a810cdf5 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h @@ -33,9 +33,10 @@ // #define X_STEP_PIN PB9 #define X_DIR_PIN PC2 -#define Y_STEP_PIN PB7 +#define Y_STEP_PIN PB7 #define Y_DIR_PIN PB8 + #define Z_STEP_PIN PB5 #define Z_DIR_PIN PB6 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/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h b/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h index dd621eb5c126..c6b65962a5d1 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 @@ -138,27 +138,29 @@ #define DEFAULT_PWM_MOTOR_CURRENT { 800, 800, 800 } #endif - /** - * MKS Robin_Wifi or another ESP8266 module - * - * __ESP(M1)__ -J1- - * GND| 15 | | 08 |+3v3 (22) RXD1 (PA10) - * | 16 | | 07 |MOSI (21) TXD1 (PA9) Active LOW, probably OK to leave floating - * IO2| 17 | | 06 |MISO (19) IO1 (PC7) Leave as unused (ESP3D software configures this with a pullup so OK to leave as floating) - * IO0| 18 | | 05 |CLK (18) IO0 (PA8) Must be HIGH (ESP3D software configures this with a pullup so OK to leave as floating) - * IO1| 19 | | 03 |EN (03) WIFI_EN Must be HIGH for module to run - * | nc | | nc | (01) WIFI_CTRL (PA5) - * RX| 21 | | nc | - * TX| 22 | | 01 |RST - *  ̄ ̄ AE ̄ ̄ - */ - // Module ESP-WIFI - #define ESP_WIFI_MODULE_COM 2 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this - #define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 - #define ESP_WIFI_MODULE_RESET_PIN PA5 // WIFI CTRL/RST - #define ESP_WIFI_MODULE_ENABLE_PIN -1 - #define ESP_WIFI_MODULE_TXD_PIN PA9 // MKS or ESP WIFI RX PIN - #define ESP_WIFI_MODULE_RXD_PIN PA10 // MKS or ESP WIFI TX PIN + #if ENABLED(WIFISUPPORT) + /** + * MKS Robin_Wifi or another ESP8266 module + * + * __ESP(M1)__ -J1- + * GND| 15 | | 08 |+3v3 (22) RXD1 (PA10) + * | 16 | | 07 |MOSI (21) TXD1 (PA9) Active LOW, probably OK to leave floating + * IO2| 17 | | 06 |MISO (19) IO1 (PC7) Leave as unused (ESP3D software configures this with a pullup so OK to leave as floating) + * IO0| 18 | | 05 |CLK (18) IO0 (PA8) Must be HIGH (ESP3D software configures this with a pullup so OK to leave as floating) + * IO1| 19 | | 03 |EN (03) WIFI_EN Must be HIGH for module to run + * | nc | | nc | (01) WIFI_CTRL (PA5) + * RX| 21 | | nc | + * TX| 22 | | 01 |RST + *  ̄ ̄ AE ̄ ̄ + */ + // Module ESP-WIFI + #define ESP_WIFI_MODULE_COM 2 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this + #define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 + #define ESP_WIFI_MODULE_RESET_PIN PA5 // WIFI CTRL/RST + #define ESP_WIFI_MODULE_ENABLE_PIN -1 + #define ESP_WIFI_MODULE_TXD_PIN PA9 // MKS or ESP WIFI RX PIN + #define ESP_WIFI_MODULE_RXD_PIN PA10 // MKS or ESP WIFI TX PIN + #endif #endif // diff --git a/Marlin/src/pins/stm32f1/pins_FLY_MINI.h b/Marlin/src/pins/stm32f1/pins_FLY_MINI.h index 952b40c1dedb..f39850f755f1 100644 --- a/Marlin/src/pins/stm32f1/pins_FLY_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_FLY_MINI.h @@ -85,13 +85,13 @@ #if ENABLED(TMC_USE_SW_SPI) #ifndef TMC_SW_MOSI - #define TMC_SW_MOSI EXP2_05_PIN + #define TMC_SW_MOSI EXP2_06_PIN #endif #ifndef TMC_SW_MISO - #define TMC_SW_MISO EXP2_10_PIN + #define TMC_SW_MISO EXP2_01_PIN #endif #ifndef TMC_SW_SCK - #define TMC_SW_SCK EXP2_09_PIN + #define TMC_SW_SCK EXP2_02_PIN #endif #endif @@ -123,31 +123,31 @@ #define TEMP_0_PIN PC1 // Analog Input /** ------ ------ - * (BEEPER) PC14 |10 9 | PC13 (BTN_ENC) (MISO) PB14 |10 9 | PB13 (SD_SCK) - * (LCD_EN) PB9 | 8 7 | PB8 (LCD_RS) (BTN_EN1) PB3 | 8 7 | PB12 (SD_CS2) - * (LCD_D4) PB7 6 5 | PB6 (LCD_D5) (BTN_EN2) PD2 6 5 | PB15 (SD_MOSI) - * (LCD_D6) PB5 | 4 3 | PB4 (LCD_D7) (SD_DETECT) PB11 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) PC14 | 1 2 | PC13 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SD_SCK) + * (LCD_EN) PB9 | 3 4 | PB8 (LCD_RS) (BTN_EN1) PB3 | 3 4 | PB12 (SD_CS2) + * (LCD_D4) PB7 5 6 | PB6 (LCD_D5) (BTN_EN2) PD2 5 6 | PB15 (SD_MOSI) + * (LCD_D6) PB5 | 7 8 | PB4 (LCD_D7) (SD_DETECT) PB11 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PB4 -#define EXP1_04_PIN PB5 -#define EXP1_05_PIN PB6 -#define EXP1_06_PIN PB7 -#define EXP1_07_PIN PB8 -#define EXP1_08_PIN PB9 -#define EXP1_09_PIN PC13 -#define EXP1_10_PIN PC14 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN PB11 -#define EXP2_05_PIN PB15 -#define EXP2_06_PIN PD2 -#define EXP2_07_PIN PB12 -#define EXP2_08_PIN PB3 -#define EXP2_09_PIN PB13 -#define EXP2_10_PIN PB14 +#define EXP1_01_PIN PC14 +#define EXP1_02_PIN PC13 +#define EXP1_03_PIN PB9 +#define EXP1_04_PIN PB8 +#define EXP1_05_PIN PB7 +#define EXP1_06_PIN PB6 +#define EXP1_07_PIN PB5 +#define EXP1_08_PIN PB4 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PB3 +#define EXP2_04_PIN PB12 +#define EXP2_05_PIN PD2 +#define EXP2_06_PIN PB15 +#define EXP2_07_PIN PB11 +#define EXP2_08_PIN -1 // RESET // // LCD / Controller @@ -155,26 +155,26 @@ #if HAS_WIRED_LCD #define SPI_DEVICE 2 - #define SD_SS_PIN EXP2_07_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN + #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 SDSS SD_SS_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #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_06_PIN - #define BTN_EN2 EXP2_08_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h index beda50d29b1b..e59e8aef595f 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h @@ -133,11 +133,11 @@ /** * EXP1 pinout for the LCD according to FYSETC's Cheetah board schematic * ------ - * (BEEPER) PC9 |10 9 | PC12 (BTN_ENC) - * (BTN_EN2) PC11 | 8 7 | PB14 (LCD_RS / MISO) - * (BTN_EN1) PC10 6 5 | PB13 (SCK) - * (LCD_EN) PB12 | 4 3 | PB15 (MOSI) - * GND | 2 1 | 5V + * (BEEPER) PC9 | 1 2 | PC12 (BTN_ENC) + * (BTN_EN2) PC11 | 3 4 | PB14 (LCD_RS / MISO) + * (BTN_EN1) PC10 5 6 | PB13 (SCK) + * (LCD_EN) PB12 | 7 8 | PB15 (MOSI) + * GND | 9 10 | 5V * ------ * EXP1 * @@ -146,23 +146,23 @@ * - Functionally the pins are assigned in the same order as on the Ender-3 board. * - Pin 4 on the Cheetah board is assigned to an I/O, it is assigned to RESET on the Ender-3 board. */ -#define EXP1_03_PIN PB15 -#define EXP1_04_PIN PB12 -#define EXP1_05_PIN PB13 -#define EXP1_06_PIN PC10 -#define EXP1_07_PIN PB14 -#define EXP1_08_PIN PC11 -#define EXP1_09_PIN PC12 -#define EXP1_10_PIN PC9 +#define EXP1_01_PIN PC9 +#define EXP1_02_PIN PC12 +#define EXP1_03_PIN PC11 +#define EXP1_04_PIN PB14 +#define EXP1_05_PIN PC10 +#define EXP1_06_PIN PB13 +#define EXP1_07_PIN PB12 +#define EXP1_08_PIN PB15 #if HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #if HAS_MARLINUI_U8GLIB - #define DOGLCD_A0 EXP1_07_PIN - #define DOGLCD_CS EXP1_04_PIN - #define DOGLCD_SCK EXP1_05_PIN - #define DOGLCD_MOSI EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_SCK EXP1_06_PIN + #define DOGLCD_MOSI EXP1_08_PIN #if EITHER(FYSETC_MINI_12864, U8GLIB_ST7920) #define FORCE_SOFT_SPI @@ -170,30 +170,30 @@ //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #endif - #define LCD_PINS_RS EXP1_04_PIN // CS -- SOFT SPI for ENDER3 LCD - #define LCD_PINS_D4 EXP1_05_PIN // SCLK - #define LCD_PINS_ENABLE EXP1_03_PIN // DATA MOSI + #define LCD_PINS_RS EXP1_07_PIN // CS -- SOFT SPI for ENDER3 LCD + #define LCD_PINS_D4 EXP1_06_PIN // SCLK + #define LCD_PINS_ENABLE EXP1_08_PIN // DATA MOSI //#define LCD_CONTRAST_INIT 190 #if IS_NEWPANEL - #define BTN_EN1 EXP1_06_PIN - #define BTN_EN2 EXP1_08_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_03_PIN + #define BTN_ENC EXP1_02_PIN #endif #endif #if ENABLED(TOUCH_UI_FTDI_EVE) - #define BEEPER_PIN EXP1_10_PIN - #define CLCD_MOD_RESET EXP1_08_PIN - #define CLCD_SPI_CS EXP1_04_PIN + #define BEEPER_PIN EXP1_01_PIN + #define CLCD_MOD_RESET EXP1_03_PIN + #define CLCD_SPI_CS EXP1_07_PIN //#define CLCD_USE_SOFT_SPI // the Cheetah can use hardware-SPI so we do not really need this #if ENABLED(CLCD_USE_SOFT_SPI) - #define CLCD_SOFT_SPI_MOSI EXP1_03_PIN - #define CLCD_SOFT_SPI_MISO EXP1_07_PIN - #define CLCD_SOFT_SPI_SCLK EXP1_05_PIN + #define CLCD_SOFT_SPI_MOSI EXP1_08_PIN + #define CLCD_SOFT_SPI_MISO EXP1_04_PIN + #define CLCD_SOFT_SPI_SCLK EXP1_06_PIN #else #define CLCD_SPI_BUS 2 #endif diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h b/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h index 5515132c7844..24981cda61f4 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h @@ -226,10 +226,11 @@ #define SDSS SD_SS_PIN -// -// ESP WiFi can be soldered to J9 connector which is wired to USART2. -// Must define WIFISUPPORT in Configuration.h for the printer. -// -#define ESP_WIFI_MODULE_COM 2 -#define ESP_WIFI_MODULE_BAUDRATE 115200 -#define ESP_WIFI_MODULE_RESET_PIN -1 +#if ENABLED(WIFISUPPORT) + // + // ESP WiFi can be soldered to J9 connector which is wired to USART2. + // + #define ESP_WIFI_MODULE_COM 2 + #define ESP_WIFI_MODULE_BAUDRATE 115200 + #define ESP_WIFI_MODULE_RESET_PIN -1 +#endif diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h b/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h index dc23680b8c20..cbe23356e38b 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h @@ -220,10 +220,11 @@ #define SDSS SD_SS_PIN -// -// ESP WiFi can be soldered to J9 connector which is wired to USART2. -// Must define WIFISUPPORT in Configuration.h for the printer. -// -#define ESP_WIFI_MODULE_COM 2 -#define ESP_WIFI_MODULE_BAUDRATE 115200 -#define ESP_WIFI_MODULE_RESET_PIN -1 +#if ENABLED(WIFISUPPORT) + // + // ESP WiFi can be soldered to J9 connector which is wired to USART2. + // + #define ESP_WIFI_MODULE_COM 2 + #define ESP_WIFI_MODULE_BAUDRATE 115200 + #define ESP_WIFI_MODULE_RESET_PIN -1 +#endif diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h index 4b5d38e8c544..1418340d2dcf 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 */ @@ -231,10 +231,11 @@ #define SDSS SD_SS_PIN -// -// ESP WiFi can be soldered to J9 connector which is wired to USART2. -// Must define WIFISUPPORT in Configuration.h for the printer. -// -#define ESP_WIFI_MODULE_COM 2 -#define ESP_WIFI_MODULE_BAUDRATE 115200 -#define ESP_WIFI_MODULE_RESET_PIN -1 +#if ENABLED(WIFISUPPORT) + // + // ESP WiFi can be soldered to J9 connector which is wired to USART2. + // + #define ESP_WIFI_MODULE_COM 2 + #define ESP_WIFI_MODULE_BAUDRATE 115200 + #define ESP_WIFI_MODULE_RESET_PIN -1 +#endif diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h b/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h index 968d9cb6bd58..22ff91aeac45 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h @@ -223,10 +223,11 @@ #define SDSS SD_SS_PIN -// -// ESP WiFi can be soldered to J9 connector which is wired to USART2. -// Must define WIFISUPPORT in Configuration.h for the printer. -// -#define ESP_WIFI_MODULE_COM 2 -#define ESP_WIFI_MODULE_BAUDRATE 115200 -#define ESP_WIFI_MODULE_RESET_PIN -1 +#if ENABLED(WIFISUPPORT) + // + // ESP WiFi can be soldered to J9 connector which is wired to USART2. + // + #define ESP_WIFI_MODULE_COM 2 + #define ESP_WIFI_MODULE_BAUDRATE 115200 + #define ESP_WIFI_MODULE_RESET_PIN -1 +#endif 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 38f10f671359..89525d93ef48 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h @@ -207,31 +207,31 @@ /** * ------ ------ - * PC5 |10 9 | PE13 PA6 |10 9 | PA5 - * PD13 | 8 7 | PC6 PE8 | 8 7 | PE10 - * PE14 | 6 5 PE15 PE11 | 6 5 PA7 - * PD11 | 4 3 | PD10 PE12 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | 3.3V + * PC5 | 1 2 | PE13 PA6 | 1 2 | PA5 + * PD13 | 3 4 | PC6 PE8 | 3 4 | PE10 + * PE14 | 5 6 PE15 PE11 | 5 6 PA7 + * PD11 | 7 8 | PD10 PE12 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PD10 -#define EXP1_04_PIN PD11 -#define EXP1_05_PIN PE15 -#define EXP1_06_PIN PE14 -#define EXP1_07_PIN PC6 -#define EXP1_08_PIN PD13 -#define EXP1_09_PIN PE13 -#define EXP1_10_PIN PC5 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN PE12 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PE11 -#define EXP2_07_PIN PE10 -#define EXP2_08_PIN PE8 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PC5 +#define EXP1_02_PIN PE13 +#define EXP1_03_PIN PD13 +#define EXP1_04_PIN PC6 +#define EXP1_05_PIN PE14 +#define EXP1_06_PIN PE15 +#define EXP1_07_PIN PD11 +#define EXP1_08_PIN PD10 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE8 +#define EXP2_04_PIN PE10 +#define EXP2_05_PIN PE11 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PE12 +#define EXP2_08_PIN -1 // // SD Card @@ -247,11 +247,11 @@ #define ONBOARD_SD_CS_PIN PC11 #elif SD_CONNECTION_IS(LCD) #define ENABLE_SPI1 - #define SDSS EXP2_07_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SDSS 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 #endif // @@ -268,25 +268,25 @@ // Shared SPI TFT - #define LCD_BACKLIGHT_PIN EXP1_08_PIN + #define LCD_BACKLIGHT_PIN EXP1_03_PIN - #define TOUCH_CS_PIN EXP1_06_PIN // SPI1_NSS - #define TOUCH_SCK_PIN EXP2_09_PIN // SPI1_SCK - #define TOUCH_MISO_PIN EXP2_10_PIN // SPI1_MISO - #define TOUCH_MOSI_PIN EXP2_05_PIN // SPI1_MOSI + #define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS + #define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK + #define TOUCH_MISO_PIN EXP2_01_PIN // SPI1_MISO + #define TOUCH_MOSI_PIN EXP2_06_PIN // SPI1_MOSI - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN - #define TFT_CS_PIN EXP1_04_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_MOSI_PIN EXP2_05_PIN - #define TFT_DC_PIN EXP1_03_PIN + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + #define TFT_DC_PIN EXP1_08_PIN #define TFT_A0_PIN TFT_DC_PIN - #define TFT_RESET_PIN EXP1_07_PIN + #define TFT_RESET_PIN EXP1_04_PIN #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN #define TOUCH_BUTTONS_HW_SPI @@ -298,22 +298,22 @@ #if ENABLED(TFT_CLASSIC_UI) // Emulated DOGM SPI - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define BTN_ENC EXP1_09_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #elif ENABLED(TFT_COLOR_UI) #define TFT_BUFFER_SIZE 14400 #endif #if HAS_WIRED_LCD && !HAS_SPI_TFT - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #define LCD_BACKLIGHT_PIN -1 #if ENABLED(MKS_MINI_12864) @@ -323,18 +323,18 @@ #define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN -1 - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN #elif IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define PIN_SPI_SCK EXP2_09_PIN - #define PIN_TFT_MISO EXP2_10_PIN - #define PIN_TFT_MOSI EXP2_05_PIN - #define TFTGLCD_CS EXP2_08_PIN + #define PIN_SPI_SCK EXP2_02_PIN + #define PIN_TFT_MISO EXP2_01_PIN + #define PIN_TFT_MOSI EXP2_06_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif #ifndef BEEPER_PIN @@ -342,14 +342,14 @@ #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define LCD_PINS_DC EXP1_07_PIN - #define DOGLCD_CS EXP1_08_PIN + #define LCD_PINS_DC EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN #define DOGLCD_A0 DOGLCD_A0 #define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN - #define NEOPIXEL_PIN EXP1_05_PIN - #define DOGLCD_MOSI EXP2_05_PIN - #define DOGLCD_SCK EXP2_09_PIN + #define LCD_RESET_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN + #define DOGLCD_MOSI EXP2_06_PIN + #define DOGLCD_SCK EXP2_02_PIN #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif @@ -357,11 +357,11 @@ #else // !MKS_MINI_12864 - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #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 @@ -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 @@ -387,7 +387,7 @@ #endif #ifndef BEEPER_PIN - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #endif #if ENABLED(SPEAKER) && BEEPER_PIN == PC5 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h index 4af88c18482a..642c97bb1144 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h @@ -141,82 +141,82 @@ /** * ------ ------ ------ - * (BEEPER) PC1 |10 9 | PC3 (BTN_ENC) (MISO) PB14 |10 9 | PB13 (SD_SCK) (BEEPER) PC1 |10 9 | PC3 (BTN_ENC) - * (LCD_EN) PA4 | 8 7 | PA5 (LCD_RS) (BTN_EN1) PB11 | 8 7 | PA15 (SD_SS) (BTN_EN1) PB11 | 8 7 | RESET - * (LCD_D4) PA6 6 5 | PA7 (LCD_D5) (BTN_EN2) PB0 6 5 | PB15 (SD_MOSI) (BTN_EN2) PB0 6 5 | PA6 (LCD_D4) - * (LCD_D6) PC4 | 4 3 | PC5 (LCD_D7) (SD_DETECT) PC10 | 4 3 | RESET (LCD_RS) PA5 | 4 3 | PA4 (LCD_EN) - * GND | 2 1 | 5V GND | 2 1 | -- GND | 2 1 | 5V + * (BEEPER) PC1 | 1 2 | PC3 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SD_SCK) (BEEPER) PC1 | 1 2 | PC3 (BTN_ENC) + * (LCD_EN) PA4 | 3 4 | PA5 (LCD_RS) (BTN_EN1) PB11 | 3 4 | PA15 (SD_SS) (BTN_EN1) PB11 | 3 4 | RESET + * (LCD_D4) PA6 5 6 | PA7 (LCD_D5) (BTN_EN2) PB0 5 6 | PB15 (SD_MOSI) (BTN_EN2) PB0 5 6 | PA6 (LCD_D4) + * (LCD_D6) PC4 | 7 8 | PC5 (LCD_D7) (SD_DETECT) PC10 | 7 8 | RESET (LCD_RS) PA5 | 7 8 | PA4 (LCD_EN) + * GND | 9 10 | 5V GND | 9 10 | -- GND | 9 10 | 5V * ------ ------ ------ * EXP1 EXP2 "Ender-3 EXP1" */ -#define EXP1_03_PIN PC5 -#define EXP1_04_PIN PC4 -#define EXP1_05_PIN PA7 -#define EXP1_06_PIN PA6 -#define EXP1_07_PIN PA5 -#define EXP1_08_PIN PA4 -#define EXP1_09_PIN PC3 -#define EXP1_10_PIN PC1 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN PC10 -#define EXP2_05_PIN PB15 -#define EXP2_06_PIN PB0 -#define EXP2_07_PIN PA15 -#define EXP2_08_PIN PB11 -#define EXP2_09_PIN PB13 -#define EXP2_10_PIN PB14 +#define EXP1_01_PIN PC1 +#define EXP1_02_PIN PC3 +#define EXP1_03_PIN PA4 +#define EXP1_04_PIN PA5 +#define EXP1_05_PIN PA6 +#define EXP1_06_PIN PA7 +#define EXP1_07_PIN PC4 +#define EXP1_08_PIN PC5 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PB11 +#define EXP2_04_PIN PA15 +#define EXP2_05_PIN PB0 +#define EXP2_06_PIN PB15 +#define EXP2_07_PIN PC10 +#define EXP2_08_PIN -1 // RESET // "Ender-3 EXP1" -#define E3_EXP1_03_PIN PA4 -#define E3_EXP1_04_PIN PA5 -#define E3_EXP1_05_PIN PA6 -#define E3_EXP1_06_PIN PB0 -#define E3_EXP1_07_PIN -1 // RESET -#define E3_EXP1_08_PIN PB11 -#define E3_EXP1_09_PIN PC3 -#define E3_EXP1_10_PIN PC1 +#define EXP3_01_PIN PC1 +#define EXP3_02_PIN PC3 +#define EXP3_03_PIN PB11 +#define EXP3_04_PIN -1 // RESET +#define EXP3_05_PIN PB0 +#define EXP3_06_PIN PA6 +#define EXP3_07_PIN PA5 +#define EXP3_08_PIN PA4 #if HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) #if ENABLED(MKS_MINI_12864) #define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN -1 - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN #elif ENABLED(FYSETC_MINI_12864_2_1) - #define LCD_PINS_DC EXP1_07_PIN - #define DOGLCD_CS EXP1_08_PIN + #define LCD_PINS_DC EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN #define DOGLCD_A0 LCD_PINS_DC #define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN - #define NEOPIXEL_PIN EXP1_05_PIN - #define DOGLCD_MOSI EXP2_05_PIN - #define DOGLCD_SCK EXP2_09_PIN + #define LCD_RESET_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN + #define DOGLCD_MOSI EXP2_06_PIN + #define DOGLCD_SCK EXP2_02_PIN #define FORCE_SOFT_SPI #define SOFTWARE_SPI //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #else - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #if !defined(BTN_ENC_EN) && ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder @@ -254,12 +254,12 @@ #define ONBOARD_SPI_DEVICE 2 #define SDSS SD_SS_PIN #define ONBOARD_SD_CS_PIN SD_SS_PIN -#define SD_DETECT_PIN PC10 // EXP2_04_PIN +#define SD_DETECT_PIN PC10 // EXP2_07_PIN #define NO_SD_HOST_DRIVE // TODO: This is the only way to set SPI for SD on STM32 (for now) #define ENABLE_SPI2 -#define SD_SCK_PIN EXP2_09_PIN -#define SD_MISO_PIN EXP2_10_PIN -#define SD_MOSI_PIN EXP2_05_PIN -#define SD_SS_PIN EXP2_07_PIN +#define SD_SCK_PIN EXP2_02_PIN +#define SD_MISO_PIN EXP2_01_PIN +#define SD_MOSI_PIN EXP2_06_PIN +#define SD_SS_PIN EXP2_04_PIN diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h index bc42bd02eba0..7ead6aa28820 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h @@ -80,50 +80,50 @@ #define FIL_RUNOUT_PIN PB8 // MT_DET /** ------ - * (BEEPER) PD2 |10 9 | PB3 (BTN_ENC) - * (BTN_EN1) PB5 | 8 7 | PA11 (RESET?) - * (BTN_EN2) PB4 6 5 | PC1 (LCD_D4) - * (LCD_RS) PC3 | 4 3 | PC2 (LCD_EN) - * GND | 2 1 | 5V + * (BEEPER) PD2 | 1 2 | PB3 (BTN_ENC) + * (BTN_EN1) PB5 | 3 4 | PA11 (RESET?) + * (BTN_EN2) PB4 5 6 | PC1 (LCD_D4) + * (LCD_RS) PC3 | 7 8 | PC2 (LCD_EN) + * GND | 9 10 | 5V * ------ * "E3" EXP1 */ -#define E3_EXP1_01_PIN -1 // 5V -#define E3_EXP1_02_PIN -1 // GND -#define E3_EXP1_03_PIN PC2 -#define E3_EXP1_04_PIN PC3 -#define E3_EXP1_05_PIN PC1 -#define E3_EXP1_06_PIN PB4 -#define E3_EXP1_07_PIN PA11 // RESET? -#define E3_EXP1_08_PIN PB5 -#define E3_EXP1_09_PIN PB3 -#define E3_EXP1_10_PIN PD2 +#define EXP3_01_PIN PD2 +#define EXP3_02_PIN PB3 +#define EXP3_03_PIN PB5 +#define EXP3_04_PIN PA11 // RESET? +#define EXP3_05_PIN PB4 +#define EXP3_06_PIN PC1 +#define EXP3_07_PIN PC3 +#define EXP3_08_PIN PC2 +#define EXP3_09_PIN -1 // GND +#define EXP3_10_PIN -1 // 5V // // LCD Pins // #if HAS_WIRED_LCD - #define BEEPER_PIN E3_EXP1_10_PIN - #define BTN_ENC E3_EXP1_09_PIN - #define LCD_PINS_RS E3_EXP1_04_PIN + #define BEEPER_PIN EXP3_01_PIN + #define BTN_ENC EXP3_02_PIN + #define LCD_PINS_RS EXP3_07_PIN - #define BTN_EN1 E3_EXP1_08_PIN - #define BTN_EN2 E3_EXP1_06_PIN + #define BTN_EN1 EXP3_03_PIN + #define BTN_EN2 EXP3_05_PIN - #define LCD_PINS_ENABLE E3_EXP1_03_PIN + #define LCD_PINS_ENABLE EXP3_08_PIN #if ENABLED(MKS_MINI_12864) #define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN -1 - #define DOGLCD_A0 E3_EXP1_05_PIN - #define DOGLCD_CS E3_EXP1_03_PIN + #define DOGLCD_A0 EXP3_06_PIN + #define DOGLCD_CS EXP3_08_PIN #define DOGLCD_SCK PB13 #define DOGLCD_MOSI PB15 #else // !MKS_MINI_12864 - #define LCD_PINS_D4 E3_EXP1_05_PIN + #define LCD_PINS_D4 EXP3_06_PIN #if IS_ULTIPANEL #define LCD_PINS_D5 -1 #define LCD_PINS_D6 -1 @@ -164,12 +164,12 @@ // EXP1 replace LCD with keys for EasyThreeD ET4000+ Mainboard #if ENABLED(EASYTHREED_UI) - #define BTN_HOME E3_EXP1_04_PIN // INPUT_PULLUP (unused) - #define BTN_FEED E3_EXP1_09_PIN // Run E Forward - #define BTN_RETRACT E3_EXP1_08_PIN // Run E Backward - #define BTN_PRINT E3_EXP1_07_PIN // Start File Print - #define BTN_HOME_GND E3_EXP1_03_PIN // OUTPUT (LOW) - #define BTN_FEED_GND E3_EXP1_06_PIN // OUTPUT (LOW) - #define BTN_RETRACT_GND E3_EXP1_05_PIN // OUTPUT (LOW) - #define EASYTHREED_LED_PIN E3_EXP1_10_PIN // Indicator LED + #define BTN_HOME EXP3_07_PIN // INPUT_PULLUP (unused) + #define BTN_FEED EXP3_02_PIN // Run E Forward + #define BTN_RETRACT EXP3_03_PIN // Run E Backward + #define BTN_PRINT EXP3_04_PIN // Start File Print + #define BTN_HOME_GND EXP3_08_PIN // OUTPUT (LOW) + #define BTN_FEED_GND EXP3_05_PIN // OUTPUT (LOW) + #define BTN_RETRACT_GND EXP3_06_PIN // OUTPUT (LOW) + #define EASYTHREED_LED_PIN EXP3_01_PIN // Indicator LED #endif 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.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 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..8dba94313651 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 @@ -377,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 0eb7bbdffeb4..858dabb8b986 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 @@ -201,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/stm32f1/pins_PANDA_PI_V29.h b/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h index ad28e5c47b64..ed602d8d011e 100644 --- a/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h +++ b/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h @@ -38,6 +38,12 @@ #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K #endif +#if ENABLED(BD_SENSOR) + #define I2C_BD_SDA_PIN PC6 + #define I2C_BD_SCL_PIN PB2 + #define I2C_BD_DELAY 10 // (seconds) +#endif + // // Servos // @@ -179,30 +185,30 @@ /** FYSETC TFT TFT81050 display pinout * - * Board Display - * ----- ----- - * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) - * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) MOD_RESET | 3 4 | SD_CS (PA10) - * (FREE) PB9 | 5 6 PA10 (SD_CS) (PB8) LCD_CS | 5 6 MOSI (SPI1-MOSI) - * RESET | 7 8 | PA9 (MOD_RESET) (PA15) SD_DET | 7 8 | RESET - * (BEEPER) PB6 | 9 10| PA15 (SD_DET) GND | 9 10| 5V - * ----- ----- - * EXP1 EXP1 + * Board Display + * ------ ------ + * (SD_DET) PA15 | 1 2 | PB6 (BEEPER) (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) + * (MOD_RESET) PA9 | 3 4 | RESET MOD_RESET | 3 4 | SD_CS + * (SD_CS) PA10 5 6 | PB9 (FREE) LCD_CS | 5 6 MOSI (SPI1-MOSI) + * (LCD_CS) PB8 | 7 8 | PB7 (FREE) SD_DET | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 5V + * ------ ------ + * EXP1 EXP1 * * Needs custom cable: * * Board Adapter Display - * _________ - * EXP1-1 ----------- EXP1-10 - * EXP1-2 ----------- EXP1-9 - * SPI1-4 ----------- EXP1-6 - * EXP1-4 ----------- EXP1-5 - * SP11-3 ----------- EXP1-2 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- EXP1-8 - * EXP1-8 ----------- EXP1-3 - * SPI1-1 ----------- EXP1-1 - * EXP1-10 ----------- EXP1-7 + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- EXP1-5 LCD_CS + * SP11-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- EXP1-8 RESET + * EXP1-3 ----------- EXP1-3 MOD_RST + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET */ #define CLCD_SPI_BUS 1 // SPI1 connector diff --git a/Marlin/src/pins/stm32f1/pins_SOVOL_V131.h b/Marlin/src/pins/stm32f1/pins_SOVOL_V131.h new file mode 100644 index 000000000000..67b2944f4560 --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_SOVOL_V131.h @@ -0,0 +1,236 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 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 + +/** + * Sovol 1.3.1 (GD32F103RET6) board pin assignments + */ + +#include "env_validate.h" + +#if HOTENDS > 1 || E_STEPPERS > 1 + #error "SOVOL V131 only supports 1 hotend / E-stepper." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Sovol V131" +#endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME "Sovol SV06" +#endif + +//#define BOARD_NO_NATIVE_USB + +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +#ifndef DISABLE_DEBUG + #define DISABLE_DEBUG +#endif + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 + //#define SDCARD_EEPROM_EMULATION + #undef NO_EEPROM_SELECTED +#endif + +#if ENABLED(IIC_BL24CXX_EEPROM) + #define IIC_EEPROM_SDA PA11 + #define IIC_EEPROM_SCL PA12 + #define MARLIN_EEPROM_SIZE 0x800 // 2K (24C16) +#elif ENABLED(SDCARD_EEPROM_EMULATION) + #define MARLIN_EEPROM_SIZE 0x800 // 2K +#endif + +// +// Servos +// +#ifndef SERVO0_PIN + #ifndef HAS_PIN_27_BOARD + #define SERVO0_PIN PB0 // BLTouch OUT + #else + #define SERVO0_PIN PC6 + #endif +#endif + +// +// Limit Switches +// +#ifndef X_STOP_PIN + #define X_STOP_PIN PA5 +#endif +#ifndef Y_STOP_PIN + #define Y_STOP_PIN PA6 +#endif +#ifndef Z_STOP_PIN + #define Z_STOP_PIN PA7 +#endif + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PB1 // BLTouch IN +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PA4 // "Pulled-high" +#endif + +// +// Steppers +// +#ifndef X_STEP_PIN + #define X_STEP_PIN PC2 +#endif +#ifndef X_DIR_PIN + #define X_DIR_PIN PB9 +#endif +#define X_ENABLE_PIN PC3 // Shared + +#ifndef Y_STEP_PIN + #define Y_STEP_PIN PB8 +#endif +#ifndef Y_DIR_PIN + #define Y_DIR_PIN PB7 +#endif +#define Y_ENABLE_PIN X_ENABLE_PIN + +#ifndef Z_STEP_PIN + #define Z_STEP_PIN PB6 +#endif +#ifndef Z_DIR_PIN + #define Z_DIR_PIN PB5 +#endif +#define Z_ENABLE_PIN X_ENABLE_PIN + +#ifndef E0_STEP_PIN + #define E0_STEP_PIN PB4 +#endif +#ifndef E0_DIR_PIN + #define E0_DIR_PIN PB3 +#endif +#define E0_ENABLE_PIN X_ENABLE_PIN + +#if HAS_TMC_UART + + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + + #define X_SERIAL_TX_PIN PC1 + #define X_SERIAL_RX_PIN PC1 + + #define Y_SERIAL_TX_PIN PC0 + #define Y_SERIAL_RX_PIN PC0 + + #define Z_SERIAL_TX_PIN PA15 + #define Z_SERIAL_RX_PIN PA15 + + #define E0_SERIAL_TX_PIN PC14 + #define E0_SERIAL_RX_PIN PC14 + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 + +#endif // HAS_TMC_UART + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC5 // TH1 +#define TEMP_BED_PIN PC4 // TB1 + +// +// Heaters / Fans +// +#ifndef HEATER_0_PIN + #define HEATER_0_PIN PA1 // HEATER1 +#endif +#ifndef HEATER_BED_PIN + #define HEATER_BED_PIN PA2 // HOT BED +#endif +#ifndef FAN_PIN + #define FAN_PIN PA0 // FAN +#endif +#define FAN_SOFT_PWM_REQUIRED + +// +// SD Card +// +#define SD_DETECT_PIN PC7 +#define SDCARD_CONNECTION ONBOARD +#define ONBOARD_SPI_DEVICE 1 +#define ONBOARD_SD_CS_PIN PA4 // 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 | 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 +#endif + +#if ENABLED(CR10_STOCKDISPLAY) + + #if ENABLED(RET6_12864_LCD) + + #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 + + #ifndef HAS_PIN_27_BOARD + #define BEEPER_PIN EXP3_01_PIN + #endif + + #else + + #error "Only the RET6_12864_LCD variant of CR10_STOCKDISPLAY is supported." + + #endif + +#endif diff --git a/Marlin/src/pins/stm32f1/pins_STM32F1R.h b/Marlin/src/pins/stm32f1/pins_STM32F1R.h index c08b707d7e99..634cadc1aa8e 100644 --- a/Marlin/src/pins/stm32f1/pins_STM32F1R.h +++ b/Marlin/src/pins/stm32f1/pins_STM32F1R.h @@ -120,7 +120,7 @@ #error "LCD_I2C_PANELOLU2 is not supported." #elif ENABLED(LCD_I2C_VIKI) #error "LCD_I2C_VIKI is not supported." - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #error "VIKI2 / miniVIKI is not supported." #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #error "ELB_FULL_GRAPHIC_CONTROLLER is not supported." diff --git a/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h b/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h index e189fc3f97b9..eee7dbf31669 100644 --- a/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h @@ -144,7 +144,7 @@ #error "LCD_I2C_PANELOLU2 is not supported." #elif ENABLED(LCD_I2C_VIKI) #error "LCD_I2C_VIKI is not supported." - #elif ANY(VIKI2, miniVIKI) + #elif EITHER(VIKI2, miniVIKI) #error "VIKI2 / miniVIKI is not supported." #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #error "ELB_FULL_GRAPHIC_CONTROLLER is not supported." diff --git a/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h b/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h index f1f03a7dd789..1347a1467882 100644 --- a/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h +++ b/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h @@ -72,14 +72,14 @@ // 2 +5V // 1 GND -#define EXP1_03_PIN PB11 -#define EXP1_04_PIN PB10 -#define EXP1_05_PIN PB2 -#define EXP1_06_PIN PC5 -#define EXP1_07_PIN PA10 -#define EXP1_08_PIN PA9 -#define EXP1_09_PIN PB0 -#define EXP1_10_PIN PB1 +#define EXP1_01_PIN PB1 +#define EXP1_02_PIN PB0 +#define EXP1_03_PIN PA9 +#define EXP1_04_PIN PA10 +#define EXP1_05_PIN PC5 +#define EXP1_06_PIN PB2 +#define EXP1_07_PIN PB10 +#define EXP1_08_PIN PB11 // AUX1 connector // 1 +5V @@ -193,14 +193,14 @@ // 1 GND #define LCDSCREEN_NAME "ZONESTAR LCD12864" - #define LCD_PINS_RS EXP1_08_PIN - #define LCD_PINS_ENABLE EXP1_05_PIN - #define LCD_PINS_D4 EXP1_07_PIN - //#define KILL_PIN EXP1_10_PIN - #define BEEPER_PIN EXP1_09_PIN - #define BTN_EN1 EXP1_03_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_04_PIN + #define LCD_PINS_RS EXP1_03_PIN + #define LCD_PINS_ENABLE EXP1_06_PIN + #define LCD_PINS_D4 EXP1_04_PIN + //#define KILL_PIN EXP1_01_PIN + #define BEEPER_PIN EXP1_02_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_07_PIN #define BOARD_ST7920_DELAY_1 125 #define BOARD_ST7920_DELAY_2 200 #define BOARD_ST7920_DELAY_3 125 @@ -221,15 +221,15 @@ #define FORCE_SOFT_SPI #define LCDSCREEN_NAME "ZONESTAR 12864OLED" - #define LCD_PINS_RS EXP1_05_PIN // = LCD_RESET_PIN - #define LCD_PINS_DC EXP1_07_PIN // DC - #define DOGLCD_CS EXP1_08_PIN // CS + #define LCD_PINS_RS EXP1_06_PIN // = LCD_RESET_PIN + #define LCD_PINS_DC EXP1_04_PIN // DC + #define DOGLCD_CS EXP1_03_PIN // CS #define DOGLCD_A0 LCD_PINS_DC - #define DOGLCD_MOSI EXP1_10_PIN // SDA - #define DOGLCD_SCK EXP1_09_PIN // SCK + #define DOGLCD_MOSI EXP1_01_PIN // SDA + #define DOGLCD_SCK EXP1_02_PIN // SCK // Encoder - #define BTN_EN1 EXP1_03_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_04_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_07_PIN #endif diff --git a/Marlin/src/pins/stm32f1/pins_ZM3E4_V1_0.h b/Marlin/src/pins/stm32f1/pins_ZM3E4_V1_0.h index 17e13bdc87ba..9618b3ad1abb 100644 --- a/Marlin/src/pins/stm32f1/pins_ZM3E4_V1_0.h +++ b/Marlin/src/pins/stm32f1/pins_ZM3E4_V1_0.h @@ -89,14 +89,14 @@ // 2 +5V +5V // 1 GND GND -#define EXP1_03_PIN PE14 -#define EXP1_04_PIN PE15 -#define EXP1_05_PIN PE9 -#define EXP1_06_PIN PE8 -#define EXP1_07_PIN PE10 -#define EXP1_08_PIN PE12 -#define EXP1_09_PIN PE11 -#define EXP1_10_PIN PE13 +#define EXP1_01_PIN PE13 +#define EXP1_02_PIN PE11 +#define EXP1_03_PIN PE12 +#define EXP1_04_PIN PE10 +#define EXP1_05_PIN PE8 +#define EXP1_06_PIN PE9 +#define EXP1_07_PIN PE15 +#define EXP1_08_PIN PE14 // EXP2 connector // MARK I/O ZONESTAR_LCD12864 REPRAPDISCOUNT_LCD12864 @@ -111,12 +111,12 @@ // 2 +5V +5V // 1 GND GND -#define EXP2_03_PIN PB3 -#define EXP2_04_PIN PB5 -#define EXP2_05_PIN PB4 -#define EXP2_06_PIN PA15 -#define EXP2_07_PIN PA10 -#define EXP2_08_PIN PA9 +#define EXP2_03_PIN PA9 +#define EXP2_04_PIN PA10 +#define EXP2_05_PIN PA15 +#define EXP2_06_PIN PB4 +#define EXP2_07_PIN PB5 +#define EXP2_08_PIN PB3 // AUX1 connector // 1 +5V @@ -279,55 +279,55 @@ // #if ENABLED(ZONESTAR_12864LCD) #define LCDSCREEN_NAME "ZONESTAR LCD12864" - #define LCD_PINS_RS EXP1_08_PIN // 7 CS make sure for zonestar zm3e4! - #define LCD_PINS_ENABLE EXP1_05_PIN // 6 DATA make sure for zonestar zm3e4! - #define LCD_PINS_D4 EXP1_07_PIN // 8 SCK make sure for zonestar zm3e4! - #define BEEPER_PIN EXP1_09_PIN - #define KILL_PIN -1 // EXP1_10_PIN - #define BTN_EN1 EXP1_06_PIN - #define BTN_EN2 EXP1_03_PIN - #define BTN_ENC EXP1_04_PIN + #define LCD_PINS_RS EXP1_03_PIN // 7 CS make sure for zonestar zm3e4! + #define LCD_PINS_ENABLE EXP1_06_PIN // 6 DATA make sure for zonestar zm3e4! + #define LCD_PINS_D4 EXP1_04_PIN // 8 SCK make sure for zonestar zm3e4! + #define BEEPER_PIN EXP1_02_PIN + #define KILL_PIN -1 // EXP1_01_PIN + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_08_PIN + #define BTN_ENC EXP1_07_PIN #elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define LCDSCREEN_NAME "REPRAPDISCOUNT LCD12864" - #define LCD_PINS_RS EXP1_08_PIN // 7 CS make sure for zonestar zm3e4! - #define LCD_PINS_ENABLE EXP1_07_PIN // 6 DATA make sure for zonestar zm3e4! - #define LCD_PINS_D4 EXP1_05_PIN // 8 SCK make sure for zonestar zm3e4! - #define BEEPER_PIN EXP1_09_PIN - #define KILL_PIN EXP2_04_PIN - #define BTN_EN1 EXP2_05_PIN - #define BTN_EN2 EXP2_07_PIN - #define BTN_ENC EXP1_10_PIN + #define LCD_PINS_RS EXP1_03_PIN // 7 CS make sure for zonestar zm3e4! + #define LCD_PINS_ENABLE EXP1_04_PIN // 6 DATA make sure for zonestar zm3e4! + #define LCD_PINS_D4 EXP1_06_PIN // 8 SCK make sure for zonestar zm3e4! + #define BEEPER_PIN EXP1_02_PIN + #define KILL_PIN EXP2_07_PIN + #define BTN_EN1 EXP2_06_PIN + #define BTN_EN2 EXP2_04_PIN + #define BTN_ENC EXP1_01_PIN #elif ENABLED(ZONESTAR_DWIN_LCD) // Connect to EXP2 connector #define LCDSCREEN_NAME "ZONESTAR DWIN LCD" - #define BEEPER_PIN EXP2_06_PIN + #define BEEPER_PIN EXP2_05_PIN #define KILL_PIN PC0 - #define BTN_EN1 EXP2_03_PIN - #define BTN_EN2 EXP2_04_PIN - #define BTN_ENC EXP2_05_PIN + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_07_PIN + #define BTN_ENC EXP2_06_PIN #endif #if ENABLED(ZONESTAR_LCD2004_KNOB) #define LCDSCREEN_NAME "LCD2004 KNOB" - #define LCD_PINS_RS EXP1_08_PIN - #define LCD_PINS_ENABLE EXP1_07_PIN - #define LCD_PINS_D4 EXP1_05_PIN - #define LCD_PINS_D5 EXP1_06_PIN - #define LCD_PINS_D6 EXP1_03_PIN - #define LCD_PINS_D7 EXP1_04_PIN - #define BTN_EN1 EXP2_07_PIN - #define BTN_EN2 EXP2_05_PIN - #define BTN_ENC EXP1_10_PIN - #define BEEPER_PIN EXP1_09_PIN - #define KILL_PIN EXP2_04_PIN + #define LCD_PINS_RS EXP1_03_PIN + #define LCD_PINS_ENABLE EXP1_04_PIN + #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_08_PIN + #define LCD_PINS_D7 EXP1_07_PIN + #define BTN_EN1 EXP2_04_PIN + #define BTN_EN2 EXP2_06_PIN + #define BTN_ENC EXP1_01_PIN + #define BEEPER_PIN EXP1_02_PIN + #define KILL_PIN EXP2_07_PIN #elif ENABLED(ZONESTAR_LCD2004_ADCKEY) #define LCDSCREEN_NAME "LCD2004 5KEY" - #define LCD_PINS_RS EXP1_08_PIN - #define LCD_PINS_ENABLE EXP1_07_PIN - #define LCD_PINS_D4 EXP1_05_PIN - #define LCD_PINS_D5 EXP1_06_PIN - #define LCD_PINS_D6 EXP1_03_PIN - #define LCD_PINS_D7 EXP1_04_PIN + #define LCD_PINS_RS EXP1_03_PIN + #define LCD_PINS_ENABLE EXP1_04_PIN + #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_08_PIN + #define LCD_PINS_D7 EXP1_07_PIN #define ADC_KEYPAD_PIN PC0 // PIN6 of AUX1 #endif @@ -341,16 +341,16 @@ // Remap SERVO0 PIN for BLTouch #if ENABLED(BLTOUCH_ON_EXP1) // BLTouch connected to EXP1 - #define BLTOUCH_PROBE_PIN EXP1_06_PIN - #define BLTOUCH_GND_PIN EXP1_04_PIN + #define BLTOUCH_PROBE_PIN EXP1_05_PIN + #define BLTOUCH_GND_PIN EXP1_07_PIN #undef SERVO0_PIN - #define SERVO0_PIN EXP1_03_PIN + #define SERVO0_PIN EXP1_08_PIN #elif ENABLED(BLTOUCH_ON_EXP2) // BLTouch connected to EXP2 - #define BLTOUCH_PROBE_PIN EXP2_03_PIN - #define BLTOUCH_GND_PIN EXP2_04_PIN + #define BLTOUCH_PROBE_PIN EXP2_08_PIN + #define BLTOUCH_GND_PIN EXP2_07_PIN #undef SERVO0_PIN - #define SERVO0_PIN EXP2_06_PIN + #define SERVO0_PIN EXP2_05_PIN #else #define BLTOUCH_PROBE_PIN PB13 #endif diff --git a/Marlin/src/pins/stm32f1/pins_ZM3E4_V2_0.h b/Marlin/src/pins/stm32f1/pins_ZM3E4_V2_0.h index df0eb9c3d812..d1d8a4c68fcf 100644 --- a/Marlin/src/pins/stm32f1/pins_ZM3E4_V2_0.h +++ b/Marlin/src/pins/stm32f1/pins_ZM3E4_V2_0.h @@ -90,14 +90,14 @@ // 2 +5V // 1 GND -#define EXP1_03_PIN PE14 -#define EXP1_04_PIN PE15 -#define EXP1_05_PIN PE9 -#define EXP1_06_PIN PE8 -#define EXP1_07_PIN PE10 -#define EXP1_08_PIN PE12 -#define EXP1_09_PIN PE11 -#define EXP1_10_PIN PE13 +#define EXP1_01_PIN PE13 +#define EXP1_02_PIN PE11 +#define EXP1_03_PIN PE12 +#define EXP1_04_PIN PE10 +#define EXP1_05_PIN PE8 +#define EXP1_06_PIN PE9 +#define EXP1_07_PIN PE15 +#define EXP1_08_PIN PE14 // EXP2 connector // MARK I/O ZONESTAR_LCD12864 REPRAPDISCOUNT_LCD12864 @@ -112,14 +112,14 @@ // 2 +5V // 1 GND -#define EXP2_03_PIN PB3 -#define EXP2_04_PIN PB5 -#define EXP2_05_PIN PB4 -#define EXP2_06_PIN PA15 -#define EXP2_07_PIN PA10 -#define EXP2_08_PIN PA9 -#define EXP2_09_PIN PE7 -#define EXP2_10_PIN PC0 +#define EXP2_01_PIN PC0 +#define EXP2_02_PIN PE7 +#define EXP2_03_PIN PA9 +#define EXP2_04_PIN PA10 +#define EXP2_05_PIN PA15 +#define EXP2_06_PIN PB4 +#define EXP2_07_PIN PB5 +#define EXP2_08_PIN PB3 // AUX1 connector // 1 +5V @@ -276,32 +276,32 @@ #if ENABLED(ZONESTAR_12864LCD) #define LCDSCREEN_NAME "ZONESTAR LCD12864" - #define LCD_PINS_RS EXP1_08_PIN // 7 CS make sure for zonestar zm3e4! - #define LCD_PINS_ENABLE EXP1_05_PIN // 6 DATA make sure for zonestar zm3e4! - #define LCD_PINS_D4 EXP1_07_PIN // 8 SCK make sure for zonestar zm3e4! - #define BEEPER_PIN EXP1_09_PIN - #define KILL_PIN -1 // EXP1_10_PIN - #define BTN_EN1 EXP1_06_PIN - #define BTN_EN2 EXP1_03_PIN - #define BTN_ENC EXP1_04_PIN + #define LCD_PINS_RS EXP1_03_PIN // 7 CS make sure for zonestar zm3e4! + #define LCD_PINS_ENABLE EXP1_06_PIN // 6 DATA make sure for zonestar zm3e4! + #define LCD_PINS_D4 EXP1_04_PIN // 8 SCK make sure for zonestar zm3e4! + #define BEEPER_PIN EXP1_02_PIN + #define KILL_PIN -1 // EXP1_01_PIN + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_08_PIN + #define BTN_ENC EXP1_07_PIN #elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define LCDSCREEN_NAME "REPRAPDISCOUNT LCD12864" - #define LCD_PINS_RS EXP2_08_PIN // 7 CS make sure for zonestar zm3e4! - #define LCD_PINS_ENABLE EXP2_05_PIN // 6 DATA make sure for zonestar zm3e4! - #define LCD_PINS_D4 EXP2_07_PIN // 8 SCK make sure for zonestar zm3e4! - #define BEEPER_PIN EXP2_10_PIN - #define KILL_PIN EXP2_09_PIN - #define BTN_EN1 EXP2_03_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP2_04_PIN + #define LCD_PINS_RS EXP2_03_PIN // 7 CS make sure for zonestar zm3e4! + #define LCD_PINS_ENABLE EXP2_06_PIN // 6 DATA make sure for zonestar zm3e4! + #define LCD_PINS_D4 EXP2_04_PIN // 8 SCK make sure for zonestar zm3e4! + #define BEEPER_PIN EXP2_01_PIN + #define KILL_PIN EXP2_02_PIN + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP2_07_PIN #elif ENABLED(ZONESTAR_DWIN_LCD) // Connect to EXP2 connector #define LCDSCREEN_NAME "ZONESTAR DWIN LCD" - #define BEEPER_PIN EXP2_06_PIN // PE11 - #define KILL_PIN -1 // EXP1_10_PIN - #define BTN_EN2 EXP2_04_PIN // PE8 - #define BTN_EN1 EXP2_03_PIN // PE14 - #define BTN_ENC EXP2_05_PIN // PE15 + #define BEEPER_PIN EXP2_05_PIN // PE11 + #define KILL_PIN -1 // EXP1_01_PIN + #define BTN_EN2 EXP2_07_PIN // PE8 + #define BTN_EN1 EXP2_08_PIN // PE14 + #define BTN_ENC EXP2_06_PIN // PE15 #endif // Alter timing for graphical display @@ -314,16 +314,16 @@ // Remap SERVO0 PIN for BLTouch #if ENABLED(BLTOUCH_ON_EXP1) // BLTouch connected to EXP1 - #define BLTOUCH_PROBE_PIN EXP1_06_PIN - #define BLTOUCH_GND_PIN EXP1_04_PIN + #define BLTOUCH_PROBE_PIN EXP1_05_PIN + #define BLTOUCH_GND_PIN EXP1_07_PIN #undef SERVO0_PIN - #define SERVO0_PIN EXP1_03_PIN + #define SERVO0_PIN EXP1_08_PIN #elif ENABLED(BLTOUCH_ON_EXP2) // BLTouch connected to EXP2 - #define BLTOUCH_PROBE_PIN EXP2_03_PIN - #define BLTOUCH_GND_PIN EXP2_04_PIN + #define BLTOUCH_PROBE_PIN EXP2_08_PIN + #define BLTOUCH_GND_PIN EXP2_07_PIN #undef SERVO0_PIN - #define SERVO0_PIN EXP2_06_PIN + #define SERVO0_PIN EXP2_05_PIN #else #define BLTOUCH_PROBE_PIN PB13 // Z1_MAX #endif diff --git a/Marlin/src/pins/stm32f4/pins_ANET_ET4.h b/Marlin/src/pins/stm32f4/pins_ANET_ET4.h index 7816e5e5056a..7c6eaca812d9 100644 --- a/Marlin/src/pins/stm32f4/pins_ANET_ET4.h +++ b/Marlin/src/pins/stm32f4/pins_ANET_ET4.h @@ -64,7 +64,7 @@ // Z Probe // #if ENABLED(BLTOUCH) - #error "You will need to use 24V to 5V converter and remove one resistor and capacitor from the motherboard. See https://github.com/davidtgbe/Marlin/blob/bugfix-2.0.x/docs/Tutorials/bltouch-en.md for more information. Comment out this line to proceed at your own risk." + #error "You will need to use 24V to 5V converter and remove one resistor and capacitor from the motherboard. See https://bit.ly/3xg9cXO for more information. Comment out this line to proceed at your own risk." #define SERVO0_PIN PC3 #elif !defined(Z_MIN_PROBE_PIN) #define Z_MIN_PROBE_PIN PC3 @@ -206,6 +206,7 @@ #if DISABLED(SDIO_SUPPORT) #define SOFTWARE_SPI #define SDSS PC11 + #define SD_SS_PIN SDSS #define SD_SCK_PIN PC12 #define SD_MISO_PIN PC8 #define SD_MOSI_PIN PD2 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_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 diff --git a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h index 531ab7a9581d..2147dd9b4fa7 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h @@ -199,109 +199,109 @@ /** * ---------------------------------BTT002 V1.0--------------------------------- * ------ ------ | - * (BEEPER) PE7 |10 9 | PB1 (BTN_ENC) (MISO) PA6 |10 9 | PA5 (SCK) | - * (LCD_EN) PE9 | 8 7 | PE8 (LCD_RS) (BTN_EN1) PC5 | 8 7 | PA4 (SD_SS) | - * (LCD_D4) PE10 6 5 | PE11 (LCD_D5) (BTN_EN2) PB0 6 5 | PA7 (MOSI) | - * (LCD_D6) PE12 | 4 3 | PE13 (LCD_D7) (SD_DET) PC4 | 4 3 | RESET | - * GND | 2 1 | 5V GND | 2 1 | PA3 | + * (BEEPER) PE7 | 1 2 | PB1 (BTN_ENC) (MISO) PA6 | 1 2 | PA5 (SCK) | + * (LCD_EN) PE9 | 3 4 | PE8 (LCD_RS) (BTN_EN1) PC5 | 3 4 | PA4 (SD_SS) | + * (LCD_D4) PE10 5 6 | PE11 (LCD_D5) (BTN_EN2) PB0 5 6 | PA7 (MOSI) | + * (LCD_D6) PE12 | 7 8 | PE13 (LCD_D7) (SD_DET) PC4 | 7 8 | RESET | + * GND | 9 10 | 5V GND | 9 10 | PA3 | * ------ ------ | * EXP1 EXP2 | * ------------------------------------------------------------------------------ */ -#define EXP1_03_PIN PE13 -#define EXP1_04_PIN PE12 -#define EXP1_05_PIN PE11 -#define EXP1_06_PIN PE10 -#define EXP1_07_PIN PE8 -#define EXP1_08_PIN PE9 -#define EXP1_09_PIN PB1 -#define EXP1_10_PIN PE7 - -#define EXP2_01_PIN PA3 -#define EXP2_03_PIN -1 -#define EXP2_04_PIN PC4 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PB0 -#define EXP2_07_PIN PA4 -#define EXP2_08_PIN PC5 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PE7 +#define EXP1_02_PIN PB1 +#define EXP1_03_PIN PE9 +#define EXP1_04_PIN PE8 +#define EXP1_05_PIN PE10 +#define EXP1_06_PIN PE11 +#define EXP1_07_PIN PE12 +#define EXP1_08_PIN PE13 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PC5 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PB0 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PC4 +#define EXP2_08_PIN -1 +#define EXP2_10_PIN PA3 // HAL SPI1 pins -#define SD_SCK_PIN EXP2_09_PIN // SPI1 SCLK -#define SD_SS_PIN EXP2_07_PIN // SPI1 SSEL -#define SD_MISO_PIN EXP2_10_PIN // SPI1 MISO -#define SD_MOSI_PIN EXP2_05_PIN // SPI1 MOSI +#define SD_SCK_PIN EXP2_02_PIN // SPI1 SCLK +#define SD_SS_PIN EXP2_04_PIN // SPI1 SSEL +#define SD_MISO_PIN EXP2_01_PIN // SPI1 MISO +#define SD_MOSI_PIN EXP2_06_PIN // SPI1 MOSI -#define SDSS EXP2_07_PIN +#define SDSS EXP2_04_PIN // // LCDs and Controllers // #if HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define DOGLCD_MOSI EXP2_05_PIN - #define DOGLCD_MISO EXP2_10_PIN - #define DOGLCD_SCK EXP2_09_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_MOSI EXP2_06_PIN + #define DOGLCD_MISO EXP2_01_PIN + #define DOGLCD_SCK EXP2_02_PIN #define LCD_BACKLIGHT_PIN -1 #define FORCE_SOFT_SPI - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #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_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif // !FYSETC_MINI_12864 #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #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 diff --git a/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h b/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h index c7cd35c7ad85..60e33d9dc4ad 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h @@ -186,11 +186,11 @@ /** * BTT E3 RRF * ------ - * (BEEPER) PE8 |10 9 | PE9 (BTN_ENC) - * (BTN_EN1) PE7 | 8 7 | RESET - * (BTN_EN2) PB2 6 5 | PE10 (LCD_D4) - * (LCD_RS) PB1 | 4 3 | PE11 (LCD_EN) - * GND | 2 1 | 5V + * (BEEPER) PE8 | 1 2 | PE9 (BTN_ENC) + * (BTN_EN1) PE7 | 3 4 | RESET + * (BTN_EN2) PB2 5 6 | PE10 (LCD_D4) + * (LCD_RS) PB1 | 7 8 | PE11 (LCD_EN) + * GND | 9 10 | 5V * ------ * EXP1 */ @@ -219,28 +219,28 @@ * * BTT E3 RRF Display Ribbon * ------ ------ - * (BEEPER) PE8 |10 9 | PE9 (BTN_ENC) GND |10 9 | 5V - * (BTN_EN1) PE7 | 8 7 | RESET BEEPER | 8 7 | ESTOP (RESET) - * (BTN_EN2) PB2 6 5 | PE10 (LCD_D4) (BTN_ENC) ENC_BTN | 6 5 | LCD_SCLK (LCD_D4) - * (LCD_RS) PB1 | 4 3 | PE11 (LCD_EN) (BTN_EN2) ENC_A | 4 3 | LCD_DATA (LCD_EN) - * GND | 2 1 | 5V (BTN_EN1) ENC_B | 2 1 | LCD_CS (LCD_RS) + * (BEEPER) PE8 | 1 2 | PE9 (BTN_ENC) GND |10 9 | 5V + * (BTN_EN1) PE7 | 3 4 | RESET BEEPER | 8 7 | ESTOP (RESET) + * (BTN_EN2) PB2 5 6 | PE10 (LCD_D4) (BTN_ENC) ENC_BTN | 6 5 | LCD_SCLK (LCD_D4) + * (LCD_RS) PB1 | 7 8 | PE11 (LCD_EN) (BTN_EN2) ENC_A | 4 3 | LCD_DATA (LCD_EN) + * GND | 9 10 | 5V (BTN_EN1) ENC_B | 2 1 | LCD_CS (LCD_RS) * ------ ------ - * EXP1 Ribbon + * EXP1 LCD * * Needs custom cable: * * Board Adapter Display Ribbon (coming from display) - * - * EXP1-1 ----------- EXP1-9 - * EXP1-2 ----------- EXP1-10 - * EXP1-3 ----------- EXP1-3 - * EXP1-4 ----------- EXP1-1 - * EXP1-5 ----------- EXP1-5 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- EXP1-7 - * EXP1-8 ----------- EXP1-8 - * EXP1-9 ----------- EXP1-6 - * EXP1-10 ----------- EXP1-8 + * ---------------------------------- + * EXP1-10 ---------- LCD-9 5V + * EXP1-9 ----------- LCD-10 GND + * EXP1-8 ----------- LCD-3 LCD_EN + * EXP1-7 ----------- LCD-1 LCD_RS + * EXP1-6 ----------- LCD-5 LCD_D4 + * EXP1-5 ----------- LCD-4 EN2 + * EXP1-4 ----------- LCD-7 RESET + * EXP1-3 ----------- LCD-2 EN1 + * EXP1-2 ----------- LCD-6 BTN + * EXP1-1 ----------- LCD-8 BEEPER */ #endif @@ -286,28 +286,28 @@ * * Board Display * ------ ------ - * (SD_DET) PE8 |10 9 | PE9 (BEEPER) 5V |10 9 | GND - * (MOD_RESET) PE7 | 8 7 | RESET -- | 8 7 | (SD_DET) - * (SD_CS) PB2 6 5 | PE10 (MOSI) 6 5 | -- - * (LCD_CS) PB1 | 4 3 | PE11 (SD_CS) | 4 3 | (LCD_CS) - * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) + * (SD_DET) PE8 | 1 2 | PE9 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PE7 | 3 4 | RESET -- | 8 7 | (SD_DET) + * (SD_CS) PB2 5 6 | PE10 (MOSI) 6 5 | -- + * (LCD_CS) PB1 | 7 8 | PE11 (SD_CS) | 4 3 | (LCD_CS) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) * ------ ------ * EXP1 EXP1 * * Needs custom cable: * * Board Adapter Display - * _________ - * EXP1-1 ----------- EXP1-10 - * EXP1-2 ----------- EXP1-9 - * SPI1-4 ----------- EXP1-6 - * EXP1-4 ----------- FREE - * SPI1-3 ----------- EXP1-2 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- FREE - * EXP1-8 ----------- EXP1-3 - * SPI1-1 ----------- EXP1-1 - * EXP1-10 ----------- EXP1-7 + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- n/c + * SPI1-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- n/c + * EXP1-3 ----------- EXP1-3 LCD_CS + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET */ #define TFTGLCD_CS PE7 @@ -341,28 +341,28 @@ * * Board Display * ------ ------ - * (SD_DET) PE8 |10 9 | PE9 (BEEPER) 5V |10 9 | GND - * (MOD_RESET) PE7 | 8 7 | RESET RESET | 8 7 | (SD_DET) - * (SD_CS) PB2 6 5 | PE10 (MOSI) | 6 5 | (LCD_CS) - * (LCD_CS) PB1 | 4 3 | PE11 (SD_CS) | 4 3 | (MOD_RESET) - * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) + * (SD_DET) PE8 | 1 2 | PE9 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PE7 | 3 4 | RESET RESET | 8 7 | (SD_DET) + * (SD_CS) PB2 5 6 | PE10 (MOSI) | 6 5 | (LCD_CS) + * (LCD_CS) PB1 | 7 8 | PE11 (SD_CS) | 4 3 | (MOD_RESET) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) * ------ ------ * EXP1 EXP1 * * Needs custom cable: * * Board Adapter Display - * - * EXP1-1 ----------- EXP1-10 - * EXP1-2 ----------- EXP1-9 - * SPI1-4 ----------- EXP1-6 - * EXP1-4 ----------- EXP1-5 - * SPI1-3 ----------- EXP1-2 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- EXP1-8 - * EXP1-8 ----------- EXP1-3 - * SPI1-1 ----------- EXP1-1 - * EXP1-10 ----------- EXP1-7 + * ---------------------------------- + * EXP1-10 ---------- EXP1-10 5V + * EXP1-9 ----------- EXP1-9 GND + * SPI1-4 ----------- EXP1-6 MOSI + * EXP1-7 ----------- EXP1-5 LCD_CS + * SPI1-3 ----------- EXP1-2 SCK + * EXP1-5 ----------- EXP1-4 SD_CS + * EXP1-4 ----------- EXP1-8 RESET + * EXP1-3 ----------- EXP1-3 MOD_RST + * SPI1-1 ----------- EXP1-1 MISO + * EXP1-1 ----------- EXP1-7 SD_DET */ #define CLCD_SPI_BUS 1 // SPI1 connector @@ -390,15 +390,16 @@ #error "SD CUSTOM_CABLE is not compatible with BTT E3 RRF." #endif -// -// WIFI -// - -#define ESP_WIFI_MODULE_COM 3 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this -#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 -#define ESP_WIFI_MODULE_RESET_PIN PA4 -#define ESP_WIFI_MODULE_ENABLE_PIN PA5 -#define ESP_WIFI_MODULE_GPIO0_PIN PA6 +#if ENABLED(WIFISUPPORT) + // + // WIFI + // + #define ESP_WIFI_MODULE_COM 3 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this + #define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 + #define ESP_WIFI_MODULE_RESET_PIN PA4 + #define ESP_WIFI_MODULE_ENABLE_PIN PA5 + #define ESP_WIFI_MODULE_GPIO0_PIN PA6 +#endif #if ENABLED(BTT_E3_RRF_IDEX_BOARD) #define FPC2_PIN PB11 diff --git a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h index b9525a9267ab..fe03ec8983ff 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -348,8 +348,8 @@ // #if SD_CONNECTION_IS(LCD) - #define SD_DETECT_PIN EXP2_04_PIN - #define SDSS EXP2_07_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #define SDSS EXP2_04_PIN #elif SD_CONNECTION_IS(ONBOARD) @@ -366,112 +366,112 @@ /** * ------ ------ - * (BEEPER) PC11 |10 9 | PA15 (BTN_ENC) (MISO) PB14 |10 9 | PB13 (SCK) - * (LCD_EN) PC10 | 8 7 | PA8 (LCD_RS) (BTN_EN1) PD10 | 8 7 | PB12 (SD_SS) - * (LCD_D4) PG8 6 5 | PG7 (LCD_D5) (BTN_EN2) PH10 6 5 | PB15 (MOSI) - * (LCD_D6) PG6 | 4 3 | PG5 (LCD_D7) (SD_DETECT) PB10 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) PC11 | 1 2 | PA15 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SCK) + * (LCD_EN) PC10 | 3 4 | PA8 (LCD_RS) (BTN_EN1) PD10 | 3 4 | PB12 (SD_SS) + * (LCD_D4) PG8 5 6 | PG7 (LCD_D5) (BTN_EN2) PH10 5 6 | PB15 (MOSI) + * (LCD_D6) PG6 | 7 8 | PG5 (LCD_D7) (SD_DETECT) PB10 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PG5 -#define EXP1_04_PIN PG6 -#define EXP1_05_PIN PG7 -#define EXP1_06_PIN PG8 -#define EXP1_07_PIN PA8 -#define EXP1_08_PIN PC10 -#define EXP1_09_PIN PA15 -#define EXP1_10_PIN PC11 - -#define EXP2_04_PIN PB10 -#define EXP2_05_PIN PB15 -#define EXP2_06_PIN PH10 -#define EXP2_07_PIN PB12 -#define EXP2_08_PIN PD10 -#define EXP2_09_PIN PB13 -#define EXP2_10_PIN PB14 +#define EXP1_01_PIN PC11 +#define EXP1_02_PIN PA15 +#define EXP1_03_PIN PC10 +#define EXP1_04_PIN PA8 +#define EXP1_05_PIN PG8 +#define EXP1_06_PIN PG7 +#define EXP1_07_PIN PG6 +#define EXP1_08_PIN PG5 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PD10 +#define EXP2_04_PIN PB12 +#define EXP2_05_PIN PH10 +#define EXP2_06_PIN PB15 +#define EXP2_07_PIN PB10 // // LCDs and Controllers // #if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) - #define TFT_CS_PIN EXP2_07_PIN - #define TFT_A0_PIN EXP2_04_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_MOSI_PIN EXP2_05_PIN - - #define TOUCH_INT_PIN EXP1_04_PIN - #define TOUCH_MISO_PIN EXP1_05_PIN - #define TOUCH_MOSI_PIN EXP1_08_PIN - #define TOUCH_SCK_PIN EXP1_06_PIN - #define TOUCH_CS_PIN EXP1_07_PIN - #define BTN_ENC EXP1_09_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define TFT_CS_PIN EXP2_04_PIN + #define TFT_A0_PIN EXP2_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + + #define TOUCH_INT_PIN EXP1_07_PIN + #define TOUCH_MISO_PIN EXP1_06_PIN + #define TOUCH_MOSI_PIN EXP1_03_PIN + #define TOUCH_SCK_PIN EXP1_05_PIN + #define TOUCH_CS_PIN EXP1_04_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #elif HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #if SD_CONNECTION_IS(ONBOARD) #define SOFTWARE_SPI #endif #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN #if SD_CONNECTION_IS(ONBOARD) #define SOFTWARE_SPI #endif //#define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #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_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif // !FYSETC_MINI_12864 #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #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 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 4255881baf86..8b061a431c13 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h @@ -27,13 +27,17 @@ #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 +#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) + #undef NO_EEPROM_SELECTED + #define I2C_EEPROM + #define MARLIN_EEPROM_SIZE 0x1000 // 4K (AT24C32) + #define SOFT_I2C_EEPROM // Force the use of Software I2C + #define I2C_SCL_PIN PB8 + #define I2C_SDA_PIN PB9 +#endif // Avoid conflict with TIMER_TONE -#define STEP_TIMER 10 +#define STEP_TIMER 8 // // Servos @@ -70,13 +74,13 @@ #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 + #define NEEDS_X_MINMAX #endif #if _ENDSTOP_IS_ANY(_YMIN_) || _ENDSTOP_IS_ANY(_YMAX_) - #define NEEDS_Y_MINMAX 1 + #define NEEDS_Y_MINMAX #endif #if _ENDSTOP_IS_ANY(_ZMIN_) || _ENDSTOP_IS_ANY(_ZMAX_) - #define NEEDS_Z_MINMAX 1 + #define NEEDS_Z_MINMAX #endif #undef _ENDSTOP_IS_ANY #endif @@ -109,7 +113,7 @@ #else #define Y_MIN_PIN E1_DIAG_PIN // E1DET #endif -#elif NEEDS_Y_MINMAX +#elif ENABLED(NEEDS_Y_MINMAX) #ifndef Y_MIN_PIN #define Y_MIN_PIN Y_DIAG_PIN // Y-STOP #endif @@ -127,7 +131,7 @@ #else #define Z_MIN_PIN E2_DIAG_PIN // PWRDET #endif -#elif NEEDS_Z_MINMAX +#elif ENABLED(NEEDS_Z_MINMAX) #ifndef Z_MIN_PIN #define Z_MIN_PIN Z_DIAG_PIN // Z-STOP #endif @@ -138,10 +142,6 @@ #define Z_STOP_PIN Z_DIAG_PIN // Z-STOP #endif -#undef NEEDS_X_MINMAX -#undef NEEDS_Y_MINMAX -#undef NEEDS_Z_MINMAX - // // Filament Runout Sensor // @@ -322,31 +322,31 @@ #endif /** ------ ------ - * (BEEPER) PE8 |10 9 | PE7 (BTN_ENC) (MISO) PA6 |10 9 | PA5 (SCK) - * (LCD_EN) PE9 | 8 7 | PE10 (LCD_RS) (BTN_EN1) PB2 | 8 7 | PA4 (SD_SS) - * (LCD_D4) PE12 6 5 | PE13 (LCD_D5) (BTN_EN2) PB1 6 5 | PA7 (MOSI) - * (LCD_D6) PE14 | 4 3 | PE15 (LCD_D7) (SD_DETECT) PC15 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) PE8 | 1 2 | PE7 (BTN_ENC) (MISO) PA6 | 1 2 | PA5 (SCK) + * (LCD_EN) PE9 | 3 4 | PE10 (LCD_RS) (BTN_EN1) PB2 | 3 4 | PA4 (SD_SS) + * (LCD_D4) PE12 5 6 | PE13 (LCD_D5) (BTN_EN2) PB1 5 6 | PA7 (MOSI) + * (LCD_D6) PE14 | 7 8 | PE15 (LCD_D7) (SD_DETECT) PC15 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PE15 -#define EXP1_04_PIN PE14 -#define EXP1_05_PIN PE13 -#define EXP1_06_PIN PE12 -#define EXP1_07_PIN PE10 -#define EXP1_08_PIN PE9 -#define EXP1_09_PIN PE7 -#define EXP1_10_PIN PE8 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN PC15 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PB2 -#define EXP2_07_PIN PA4 -#define EXP2_08_PIN PB1 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PE8 +#define EXP1_02_PIN PE7 +#define EXP1_03_PIN PE9 +#define EXP1_04_PIN PE10 +#define EXP1_05_PIN PE12 +#define EXP1_06_PIN PE13 +#define EXP1_07_PIN PE14 +#define EXP1_08_PIN PE15 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PB1 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PB2 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PC15 +#define EXP2_08_PIN -1 // // Onboard SD card @@ -376,45 +376,45 @@ #if ENABLED(BTT_MOTOR_EXPANSION) /** * ------ ------ - * M3DIAG |10 9 | M3RX M3STP |10 9 | M3DIR - * M2DIAG | 8 7 | M2RX M2STP | 8 7 | M2DIR - * M1DIAG 6 5 | M1RX M1DIR 6 5 | M1STP - * M3EN | 4 3 | M2EN M1EN | 4 3 | -- - * GND | 2 1 | -- GND | 2 1 | -- + * M3DIAG | 1 2 | M3RX M3STP | 1 2 | M3DIR + * M2DIAG | 3 4 | M2RX M2STP | 3 4 | M2DIR + * M1DIAG 5 6 | M1RX M1DIR 5 6 | M1STP + * M3EN | 7 8 | M2EN M1EN | 7 8 | -- + * GND | 9 10 | -- GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ // M1 on Driver Expansion Module - #define E4_STEP_PIN EXP2_05_PIN - #define E4_DIR_PIN EXP2_06_PIN - #define E4_ENABLE_PIN EXP2_04_PIN - #define E4_DIAG_PIN EXP1_06_PIN - #define E4_CS_PIN EXP1_05_PIN + #define E4_STEP_PIN EXP2_06_PIN + #define E4_DIR_PIN EXP2_05_PIN + #define E4_ENABLE_PIN EXP2_07_PIN + #define E4_DIAG_PIN EXP1_05_PIN + #define E4_CS_PIN EXP1_06_PIN #if HAS_TMC_UART - #define E4_SERIAL_TX_PIN EXP1_05_PIN + #define E4_SERIAL_TX_PIN EXP1_06_PIN #define E4_SERIAL_RX_PIN E4_SERIAL_TX_PIN #endif // M2 on Driver Expansion Module - #define E5_STEP_PIN EXP2_08_PIN - #define E5_DIR_PIN EXP2_07_PIN - #define E5_ENABLE_PIN EXP1_03_PIN - #define E5_DIAG_PIN EXP1_08_PIN - #define E5_CS_PIN EXP1_07_PIN + #define E5_STEP_PIN EXP2_03_PIN + #define E5_DIR_PIN EXP2_04_PIN + #define E5_ENABLE_PIN EXP1_08_PIN + #define E5_DIAG_PIN EXP1_03_PIN + #define E5_CS_PIN EXP1_04_PIN #if HAS_TMC_UART - #define E5_SERIAL_TX_PIN EXP1_07_PIN + #define E5_SERIAL_TX_PIN EXP1_04_PIN #define E5_SERIAL_RX_PIN E5_SERIAL_TX_PIN #endif // M3 on Driver Expansion Module - #define E6_STEP_PIN EXP2_10_PIN - #define E6_DIR_PIN EXP2_09_PIN - #define E6_ENABLE_PIN EXP1_04_PIN - #define E6_DIAG_PIN EXP1_10_PIN - #define E6_CS_PIN EXP1_09_PIN + #define E6_STEP_PIN EXP2_01_PIN + #define E6_DIR_PIN EXP2_02_PIN + #define E6_ENABLE_PIN EXP1_07_PIN + #define E6_DIAG_PIN EXP1_01_PIN + #define E6_CS_PIN EXP1_02_PIN #if HAS_TMC_UART - #define E6_SERIAL_TX_PIN EXP1_09_PIN + #define E6_SERIAL_TX_PIN EXP1_02_PIN #define E6_SERIAL_RX_PIN E6_SERIAL_TX_PIN #endif @@ -426,58 +426,82 @@ #if IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #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_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN //#define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #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_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif // !FYSETC_MINI_12864 #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #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 @@ -496,21 +520,21 @@ #endif #if HAS_SPI_TFT - #define TFT_CS_PIN EXP2_07_PIN - #define TFT_A0_PIN EXP2_04_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_MOSI_PIN EXP2_05_PIN - - #define TOUCH_INT_PIN EXP1_04_PIN - #define TOUCH_MISO_PIN EXP1_05_PIN - #define TOUCH_MOSI_PIN EXP1_08_PIN - #define TOUCH_SCK_PIN EXP1_06_PIN - #define TOUCH_CS_PIN EXP1_07_PIN - - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define TFT_CS_PIN EXP2_04_PIN + #define TFT_A0_PIN EXP2_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + + #define TOUCH_INT_PIN EXP1_07_PIN + #define TOUCH_MISO_PIN EXP1_06_PIN + #define TOUCH_MOSI_PIN EXP1_03_PIN + #define TOUCH_SCK_PIN EXP1_05_PIN + #define TOUCH_CS_PIN EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN #endif // @@ -520,26 +544,28 @@ #define NEOPIXEL_PIN PB0 #endif -// -// WIFI -// +#if ENABLED(WIFISUPPORT) + // + // WIFI + // -/** - * ------- - * GND | 9 | | 8 | 3.3V - * (ESP-CS) PB12 | 10 | | 7 | PB15 (ESP-MOSI) - * 3.3V | 11 | | 6 | PB14 (ESP-MISO) - * (ESP-IO0) PD7 | 12 | | 5 | PB13 (ESP-CLK) - * (ESP-IO4) PD10 | 13 | | 4 | -- - * -- | 14 | | 3 | PE15 (ESP-EN) - * (ESP-RX) PD8 | 15 | | 2 | -- - * (ESP-TX) PD9 | 16 | | 1 | PE14 (ESP-RST) - * ------- - * WIFI - */ -#define ESP_WIFI_MODULE_COM 3 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this -#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 -#define ESP_WIFI_MODULE_RESET_PIN PG7 -#define ESP_WIFI_MODULE_ENABLE_PIN PG8 -#define ESP_WIFI_MODULE_GPIO0_PIN PD7 -#define ESP_WIFI_MODULE_GPIO4_PIN PD10 + /** + * ------- + * GND | 9 | | 8 | 3.3V + * (ESP-CS) PB12 | 10 | | 7 | PB15 (ESP-MOSI) + * 3.3V | 11 | | 6 | PB14 (ESP-MISO) + * (ESP-IO0) PD7 | 12 | | 5 | PB13 (ESP-CLK) + * (ESP-IO4) PD10 | 13 | | 4 | -- + * -- | 14 | | 3 | PE15 (ESP-EN) + * (ESP-RX) PD8 | 15 | | 2 | -- + * (ESP-TX) PD9 | 16 | | 1 | PE14 (ESP-RST) + * ------- + * WIFI + */ + #define ESP_WIFI_MODULE_COM 3 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this + #define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 + #define ESP_WIFI_MODULE_RESET_PIN PG7 + #define ESP_WIFI_MODULE_ENABLE_PIN PG8 + #define ESP_WIFI_MODULE_GPIO0_PIN PD7 + #define ESP_WIFI_MODULE_GPIO4_PIN PD10 +#endif 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..31551f6ff6f4 --- /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 // 4K +#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/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h index 7c902b008cf6..f848a181131b 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -313,31 +313,31 @@ #endif /** ------ ------ - * (BEEPER) PG4 |10 9 | PA8 (BTN_ENC) (MISO) PB14 |10 9 | PB13 (SCK) - * (LCD_EN) PD11 | 8 7 | PD10 (LCD_RS) (BTN_EN1) PG10 | 8 7 | PB12 (SD_SS) - * (LCD_D4) PG2 6 5 | PG3 (LCD_D5) (BTN_EN2) PF11 6 5 | PB15 (MOSI) - * (LCD_D6) PG6 | 4 3 | PG7 (LCD_D7) (SD_DETECT) PF12 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) PG4 | 1 2 | PA8 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SCK) + * (LCD_EN) PD11 | 3 4 | PD10 (LCD_RS) (BTN_EN1) PG10 | 3 4 | PB12 (SD_SS) + * (LCD_D4) PG2 5 6 | PG3 (LCD_D5) (BTN_EN2) PF11 5 6 | PB15 (MOSI) + * (LCD_D6) PG6 | 7 8 | PG7 (LCD_D7) (SD_DETECT) PF12 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PG7 -#define EXP1_04_PIN PG6 -#define EXP1_05_PIN PG3 -#define EXP1_06_PIN PG2 -#define EXP1_07_PIN PD10 -#define EXP1_08_PIN PD11 -#define EXP1_09_PIN PA8 -#define EXP1_10_PIN PG4 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN PF12 -#define EXP2_05_PIN PB15 -#define EXP2_06_PIN PF11 -#define EXP2_07_PIN PB12 -#define EXP2_08_PIN PG10 -#define EXP2_09_PIN PB13 -#define EXP2_10_PIN PB14 +#define EXP1_01_PIN PG4 +#define EXP1_02_PIN PA8 +#define EXP1_03_PIN PD11 +#define EXP1_04_PIN PD10 +#define EXP1_05_PIN PG2 +#define EXP1_06_PIN PG3 +#define EXP1_07_PIN PG6 +#define EXP1_08_PIN PG7 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PG10 +#define EXP2_04_PIN PB12 +#define EXP2_05_PIN PF11 +#define EXP2_06_PIN PB15 +#define EXP2_07_PIN PF12 +#define EXP2_08_PIN -1 // // Onboard SD card @@ -345,8 +345,8 @@ // #if SD_CONNECTION_IS(LCD) - #define SD_DETECT_PIN EXP2_04_PIN - #define SDSS EXP2_07_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #define SDSS EXP2_04_PIN #elif SD_CONNECTION_IS(ONBOARD) @@ -379,46 +379,46 @@ */ // M1 on Driver Expansion Module - #define E3_STEP_PIN EXP2_05_PIN - #define E3_DIR_PIN EXP2_06_PIN - #define E3_ENABLE_PIN EXP2_04_PIN + #define E3_STEP_PIN EXP2_06_PIN + #define E3_DIR_PIN EXP2_05_PIN + #define E3_ENABLE_PIN EXP2_07_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E3_DIAG_PIN EXP1_06_PIN - #define E3_CS_PIN EXP1_05_PIN + #define E3_DIAG_PIN EXP1_05_PIN + #define E3_CS_PIN EXP1_06_PIN #if HAS_TMC_UART - #define E3_SERIAL_TX_PIN EXP1_05_PIN - #define E3_SERIAL_RX_PIN EXP1_05_PIN + #define E3_SERIAL_TX_PIN EXP1_06_PIN + #define E3_SERIAL_RX_PIN EXP1_06_PIN #endif #endif // M2 on Driver Expansion Module - #define E4_STEP_PIN EXP2_08_PIN - #define E4_DIR_PIN EXP2_07_PIN + #define E4_STEP_PIN EXP2_03_PIN + #define E4_DIR_PIN EXP2_04_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E4_ENABLE_PIN EXP1_03_PIN - #define E4_DIAG_PIN EXP1_08_PIN - #define E4_CS_PIN EXP1_07_PIN + #define E4_ENABLE_PIN EXP1_08_PIN + #define E4_DIAG_PIN EXP1_03_PIN + #define E4_CS_PIN EXP1_04_PIN #if HAS_TMC_UART - #define E4_SERIAL_TX_PIN EXP1_07_PIN - #define E4_SERIAL_RX_PIN EXP1_07_PIN + #define E4_SERIAL_TX_PIN EXP1_04_PIN + #define E4_SERIAL_RX_PIN EXP1_04_PIN #endif #else - #define E4_ENABLE_PIN EXP2_04_PIN + #define E4_ENABLE_PIN EXP2_07_PIN #endif // M3 on Driver Expansion Module - #define E5_STEP_PIN EXP2_10_PIN - #define E5_DIR_PIN EXP2_09_PIN + #define E5_STEP_PIN EXP2_01_PIN + #define E5_DIR_PIN EXP2_02_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E5_ENABLE_PIN EXP1_04_PIN - #define E5_DIAG_PIN EXP1_10_PIN - #define E5_CS_PIN EXP1_09_PIN + #define E5_ENABLE_PIN EXP1_07_PIN + #define E5_DIAG_PIN EXP1_01_PIN + #define E5_CS_PIN EXP1_02_PIN #if HAS_TMC_UART - #define E5_SERIAL_TX_PIN EXP1_09_PIN - #define E5_SERIAL_RX_PIN EXP1_09_PIN + #define E5_SERIAL_TX_PIN EXP1_02_PIN + #define E5_SERIAL_RX_PIN EXP1_02_PIN #endif #else - #define E5_ENABLE_PIN EXP2_04_PIN + #define E5_ENABLE_PIN EXP2_07_PIN #endif #endif // BTT_MOTOR_EXPANSION @@ -429,30 +429,30 @@ #if IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif #elif HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #elif ENABLED(WYH_L12864) @@ -470,59 +470,59 @@ * * BEFORE AFTER * ------ ------ - * -- |10 9 | MOSI -- |10 9 | MOSI - * BTN_ENC | 8 7 | SCK BTN_ENC | 8 7 | SCK - * BTN_EN1 | 6 5 SID BTN_EN1 | 6 5 SID - * BTN_EN2 | 4 3 | CS BTN_EN2 | 4 3 | CS - * 5V | 2 1 | GND GND | 2 1 | 5V + * -- | 1 2 | MOSI -- | 1 2 | MOSI + * BTN_ENC | 3 4 | SCK BTN_ENC | 3 4 | SCK + * BTN_EN1 | 5 6 SID BTN_EN1 | 5 6 SID + * BTN_EN2 | 7 8 | CS BTN_EN2 | 7 8 | CS + * 5V | 9 10 | GND GND | 9 10 | 5V * ------ ------ * LCD LCD */ #undef BEEPER_PIN #undef BTN_ENC - #define BTN_EN1 EXP1_06_PIN - #define BTN_EN2 EXP1_04_PIN - #define BTN_ENC EXP1_08_PIN - #define DOGLCD_CS EXP1_03_PIN - #define DOGLCD_A0 EXP1_05_PIN - #define DOGLCD_SCK EXP1_07_PIN - #define DOGLCD_MOSI EXP1_09_PIN + #define BTN_EN1 EXP1_05_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_03_PIN + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_04_PIN + #define DOGLCD_MOSI EXP1_02_PIN #define LCD_BACKLIGHT_PIN -1 #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN //#define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #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_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif // !FYSETC_MINI_12864 #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #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 @@ -547,22 +547,24 @@ #endif #endif -// -// WIFI -// +#if ENABLED(WIFISUPPORT) + // + // WIFI + // -/** - * ------ - * RX | 8 7 | 3.3V GPIO0 PF14 ... Leave as unused (ESP3D software configures this with a pullup so OK to leave as floating) - * GPIO0 | 6 5 | Reset GPIO2 PF15 ... must be high (ESP3D software configures this with a pullup so OK to leave as floating) - * GPIO2 | 4 3 | Enable Reset PG0 ... active low, probably OK to leave floating - * GND | 2 1 | TX Enable PG1 ... Must be high for module to run - * ------ - * W1 - */ -#define ESP_WIFI_MODULE_COM 6 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this -#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 -#define ESP_WIFI_MODULE_RESET_PIN PG0 -#define ESP_WIFI_MODULE_ENABLE_PIN PG1 -#define ESP_WIFI_MODULE_GPIO0_PIN PF14 -#define ESP_WIFI_MODULE_GPIO2_PIN PF15 + /** + * ------ + * RX | 8 7 | 3.3V GPIO0 PF14 ... Leave as unused (ESP3D software configures this with a pullup so OK to leave as floating) + * GPIO0 | 6 5 | Reset GPIO2 PF15 ... must be high (ESP3D software configures this with a pullup so OK to leave as floating) + * GPIO2 | 4 3 | Enable Reset PG0 ... active low, probably OK to leave floating + * GND | 2 1 | TX Enable PG1 ... Must be high for module to run + * ------ + * W1 + */ + #define ESP_WIFI_MODULE_COM 6 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this + #define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 + #define ESP_WIFI_MODULE_RESET_PIN PG0 + #define ESP_WIFI_MODULE_ENABLE_PIN PG1 + #define ESP_WIFI_MODULE_GPIO0_PIN PF14 + #define ESP_WIFI_MODULE_GPIO2_PIN PF15 +#endif diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h index 4e311d48628a..10105a6ce830 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_V2_0_common.h @@ -336,43 +336,43 @@ /** * ------ ------ - * (BEEPER) PC5 |10 9 | PB0 (BTN_ENC) (MISO) PA6 |10 9 | PA5 (SCK) - * (LCD_EN) PB1 | 8 7 | PE9 (LCD_RS) (BTN_EN1) PE7 | 8 7 | PA4 (SD_SS) - * (LCD_D4) PE10 | 6 5 PE11 (LCD_D5) (BTN_EN2) PB2 | 6 5 PA7 (MOSI) - * (LCD_D6) PE12 | 4 3 | PE13 (LCD_D7) (SD_DETECT) PC4 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) PC5 | 1 2 | PB0 (BTN_ENC) (MISO) PA6 | 1 2 | PA5 (SCK) + * (LCD_EN) PB1 | 3 4 | PE9 (LCD_RS) (BTN_EN1) PE7 | 3 4 | PA4 (SD_SS) + * (LCD_D4) PE10 | 5 6 PE11 (LCD_D5) (BTN_EN2) PB2 | 5 6 PA7 (MOSI) + * (LCD_D6) PE12 | 7 8 | PE13 (LCD_D7) (SD_DETECT) PC4 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PE13 -#define EXP1_04_PIN PE12 -#define EXP1_05_PIN PE11 -#define EXP1_06_PIN PE10 -#define EXP1_07_PIN PE9 -#define EXP1_08_PIN PB1 -#define EXP1_09_PIN PB0 -#define EXP1_10_PIN PC5 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN PC4 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PB2 -#define EXP2_07_PIN PA4 -#define EXP2_08_PIN PE7 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PC5 +#define EXP1_02_PIN PB0 +#define EXP1_03_PIN PB1 +#define EXP1_04_PIN PE9 +#define EXP1_05_PIN PE10 +#define EXP1_06_PIN PE11 +#define EXP1_07_PIN PE12 +#define EXP1_08_PIN PE13 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE7 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PB2 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PC4 +#define EXP2_08_PIN -1 // // Onboard SD card // Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 // #if SD_CONNECTION_IS(LCD) - #define SDSS EXP2_07_PIN + #define SDSS EXP2_04_PIN #define SD_SS_PIN SDSS - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN - #define SD_DETECT_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(ONBOARD) #define SDIO_SUPPORT // Use SDIO for onboard SD #elif SD_CONNECTION_IS(CUSTOM_CABLE) @@ -393,46 +393,46 @@ */ // M1 on Driver Expansion Module - #define E2_STEP_PIN EXP2_05_PIN - #define E2_DIR_PIN EXP2_06_PIN - #define E2_ENABLE_PIN EXP2_04_PIN + #define E2_STEP_PIN EXP2_06_PIN + #define E2_DIR_PIN EXP2_05_PIN + #define E2_ENABLE_PIN EXP2_07_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E2_DIAG_PIN EXP1_06_PIN - #define E2_CS_PIN EXP1_05_PIN + #define E2_DIAG_PIN EXP1_05_PIN + #define E2_CS_PIN EXP1_06_PIN #if HAS_TMC_UART - #define E2_SERIAL_TX_PIN EXP1_05_PIN - #define E2_SERIAL_RX_PIN EXP1_05_PIN + #define E2_SERIAL_TX_PIN EXP1_06_PIN + #define E2_SERIAL_RX_PIN EXP1_06_PIN #endif #endif // M2 on Driver Expansion Module - #define E3_STEP_PIN EXP2_08_PIN - #define E3_DIR_PIN EXP2_07_PIN + #define E3_STEP_PIN EXP2_03_PIN + #define E3_DIR_PIN EXP2_04_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E3_ENABLE_PIN EXP1_03_PIN - #define E3_DIAG_PIN EXP1_08_PIN - #define E3_CS_PIN EXP1_07_PIN + #define E3_ENABLE_PIN EXP1_08_PIN + #define E3_DIAG_PIN EXP1_03_PIN + #define E3_CS_PIN EXP1_04_PIN #if HAS_TMC_UART - #define E3_SERIAL_TX_PIN EXP1_07_PIN - #define E3_SERIAL_RX_PIN EXP1_07_PIN + #define E3_SERIAL_TX_PIN EXP1_04_PIN + #define E3_SERIAL_RX_PIN EXP1_04_PIN #endif #else - #define E3_ENABLE_PIN EXP2_04_PIN + #define E3_ENABLE_PIN EXP2_07_PIN #endif // M3 on Driver Expansion Module - #define E4_STEP_PIN EXP2_10_PIN - #define E4_DIR_PIN EXP2_09_PIN + #define E4_STEP_PIN EXP2_01_PIN + #define E4_DIR_PIN EXP2_02_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E4_ENABLE_PIN EXP1_04_PIN - #define E4_DIAG_PIN EXP1_10_PIN - #define E4_CS_PIN EXP1_09_PIN + #define E4_ENABLE_PIN EXP1_07_PIN + #define E4_DIAG_PIN EXP1_01_PIN + #define E4_CS_PIN EXP1_02_PIN #if HAS_TMC_UART - #define E4_SERIAL_TX_PIN EXP1_09_PIN - #define E4_SERIAL_RX_PIN EXP1_09_PIN + #define E4_SERIAL_TX_PIN EXP1_02_PIN + #define E4_SERIAL_RX_PIN EXP1_02_PIN #endif #else - #define E4_ENABLE_PIN EXP2_04_PIN + #define E4_ENABLE_PIN EXP2_07_PIN #endif #endif // BTT_MOTOR_EXPANSION @@ -443,65 +443,65 @@ #if IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif #elif HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN //#define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #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_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif // !FYSETC_MINI_12864 #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #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 @@ -528,24 +528,24 @@ #if HAS_SPI_TFT - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN // // e.g., BTT_TFT35_SPI_V1_0 (480x320, 3.5", SPI Stock Display with Rotary Encoder in BIQU B1 SE) // - #define TFT_CS_PIN EXP2_07_PIN - #define TFT_A0_PIN EXP2_04_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_MOSI_PIN EXP2_05_PIN + #define TFT_CS_PIN EXP2_04_PIN + #define TFT_A0_PIN EXP2_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN - #define TOUCH_INT_PIN EXP1_04_PIN - #define TOUCH_MISO_PIN EXP1_05_PIN - #define TOUCH_MOSI_PIN EXP1_08_PIN - #define TOUCH_SCK_PIN EXP1_06_PIN - #define TOUCH_CS_PIN EXP1_07_PIN + #define TOUCH_INT_PIN EXP1_07_PIN + #define TOUCH_MISO_PIN EXP1_06_PIN + #define TOUCH_MOSI_PIN EXP1_03_PIN + #define TOUCH_SCK_PIN EXP1_05_PIN + #define TOUCH_CS_PIN EXP1_04_PIN #endif @@ -556,25 +556,27 @@ #define NEOPIXEL_PIN PE6 #endif -// -// WIFI -// +#if ENABLED(WIFISUPPORT) + // + // WIFI + // -/** - * ------- - * GND | 9 | | 8 | 3.3V - * (ESP-CS) PB12 | 10 | | 7 | PB15 (ESP-MOSI) - * 3.3V | 11 | | 6 | PB14 (ESP-MISO) - * (ESP-IO0) PB10 | 12 | | 5 | PB13 (ESP-CLK) - * (ESP-IO4) PB11 | 13 | | 4 | -- - * -- | 14 | | 3 | 3.3V (ESP-EN) - * (ESP-RX) PD8 | 15 | | 2 | -- - * (ESP-TX) PD9 | 16 | | 1 | PC14 (ESP-RST) - * ------- - * WIFI - */ -#define ESP_WIFI_MODULE_COM 3 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this -#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 -#define ESP_WIFI_MODULE_RESET_PIN PC14 -#define ESP_WIFI_MODULE_GPIO0_PIN PB10 -#define ESP_WIFI_MODULE_GPIO4_PIN PB11 + /** + * ------- + * GND | 9 | | 8 | 3.3V + * (ESP-CS) PB12 | 10 | | 7 | PB15 (ESP-MOSI) + * 3.3V | 11 | | 6 | PB14 (ESP-MISO) + * (ESP-IO0) PB10 | 12 | | 5 | PB13 (ESP-CLK) + * (ESP-IO4) PB11 | 13 | | 4 | -- + * -- | 14 | | 3 | 3.3V (ESP-EN) + * (ESP-RX) PD8 | 15 | | 2 | -- + * (ESP-TX) PD9 | 16 | | 1 | PC14 (ESP-RST) + * ------- + * WIFI + */ + #define ESP_WIFI_MODULE_COM 3 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this + #define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 + #define ESP_WIFI_MODULE_RESET_PIN PC14 + #define ESP_WIFI_MODULE_GPIO0_PIN PB10 + #define ESP_WIFI_MODULE_GPIO4_PIN PB11 +#endif diff --git a/Marlin/src/pins/stm32f4/pins_CREALITY_V24S1_301F4.h b/Marlin/src/pins/stm32f4/pins_CREALITY_V24S1_301F4.h index 883640d5772e..32f70a371540 100644 --- a/Marlin/src/pins/stm32f4/pins_CREALITY_V24S1_301F4.h +++ b/Marlin/src/pins/stm32f4/pins_CREALITY_V24S1_301F4.h @@ -22,7 +22,7 @@ #pragma once /** - * Creality V24S1_301F4 (STM32F401RC) board pin assignments as found on Ender 3 S1. + * Creality V24S1_301F4 (STM32F401RC) board pin assignments as found on Ender-3 S1. */ #ifndef BOARD_INFO_NAME diff --git a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h index 11b5dbbb6cc4..8d5e094122f4 100644 --- a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h +++ b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h @@ -177,31 +177,31 @@ /** * ------ ------ - * PB10 |10 9 | PE15 PB14 |10 9 | PB13 - * PE14 | 8 7 | PE12 PC5 | 8 7 | PF11 - * PE10 6 5 | PE9 PC4 6 5 | PB15 - * PE8 | 4 3 | PE7 PB2 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * PB10 | 1 2 | PE15 PB14 | 1 2 | PB13 + * PE14 | 3 4 | PE12 PC5 | 3 4 | PF11 + * PE10 5 6 | PE9 PC4 5 6 | PB15 + * PE8 | 7 8 | PE7 PB2 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PE7 -#define EXP1_04_PIN PE8 -#define EXP1_05_PIN PE9 -#define EXP1_06_PIN PE10 -#define EXP1_07_PIN PE12 -#define EXP1_08_PIN PE14 -#define EXP1_09_PIN PE15 -#define EXP1_10_PIN PB10 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN PB2 -#define EXP2_05_PIN PB15 -#define EXP2_06_PIN PC4 -#define EXP2_07_PIN PF11 -#define EXP2_08_PIN PC5 -#define EXP2_09_PIN PB13 -#define EXP2_10_PIN PB14 +#define EXP1_01_PIN PB10 +#define EXP1_02_PIN PE15 +#define EXP1_03_PIN PE14 +#define EXP1_04_PIN PE12 +#define EXP1_05_PIN PE10 +#define EXP1_06_PIN PE9 +#define EXP1_07_PIN PE8 +#define EXP1_08_PIN PE7 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PC5 +#define EXP2_04_PIN PF11 +#define EXP2_05_PIN PC4 +#define EXP2_06_PIN PB15 +#define EXP2_07_PIN PB2 +#define EXP2_08_PIN -1 // RESET // // Onboard SD support @@ -226,11 +226,11 @@ #elif SD_CONNECTION_IS(LCD) - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN - #define SDSS EXP2_07_PIN - #define SD_DETECT_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 SDSS EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #endif @@ -239,13 +239,13 @@ // #if ENABLED(TMC_USE_SW_SPI) #ifndef TMC_SW_SCK - #define TMC_SW_SCK EXP2_09_PIN + #define TMC_SW_SCK EXP2_02_PIN #endif #ifndef TMC_SW_MISO - #define TMC_SW_MISO EXP2_10_PIN + #define TMC_SW_MISO EXP2_01_PIN #endif #ifndef TMC_SW_MOSI - #define TMC_SW_MOSI EXP2_05_PIN + #define TMC_SW_MOSI EXP2_06_PIN #endif #endif @@ -286,16 +286,16 @@ // LCD / Controller // #if IS_RRD_SC - #define BEEPER_PIN EXP1_10_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN - #define BTN_EN1 EXP2_06_PIN - #define BTN_EN2 EXP2_08_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #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 + #define BTN_ENC EXP1_02_PIN #endif // diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h b/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h index 29aff20ffd4f..031caa1ce174 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h @@ -43,22 +43,24 @@ #define FLASH_ADDRESS_START 0x8004000 #endif +#define SERVO0_PIN PB1 // BL-TOUCH/PWM + // -// Z Probe +// Limit Switches // -#if ENABLED(BLTOUCH) - #error "You need to set jumper to 5v for Bltouch, then comment out this line to proceed." - #define SERVO0_PIN PA0 -#elif !defined(Z_MIN_PROBE_PIN) - #define Z_MIN_PROBE_PIN PA0 -#endif +#define X_STOP_PIN PB4 // X-MIN +#define Y_STOP_PIN PC8 // Y-MIN +#define Z_STOP_PIN PA0 // Z-MIN // -// Limit Switches +// Z Probe // -#define X_STOP_PIN PB4 -#define Y_STOP_PIN PC8 -#define Z_STOP_PIN PB1 +#if ENABLED(BLTOUCH) + #error "You need to set jumper to 5V for BLTouch, then comment out this line to proceed." +#endif +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PB1 // BL-TOUCH/PWM repurposed +#endif // // Filament runout @@ -140,100 +142,100 @@ /** * ------ ------ - * (SD_MISO) PA6 |10 9 | PA5 (SD_SCK) (BEEPER) PC9 |10 9 | PC12 (BTN_ENC) - * (BTN_EN1) PC10 | 8 7 | PA4 (SD_SS) (LCD_EN) PB15 | 8 7 | PB12 (LCD_RS) - * (BTN_EN2) PC11 6 5 | PA7 (SD_MOSI) (LCD_D4) PB13 6 5 | PB14 (LCD_D5) - * (SD_DETECT) PC3 | 4 3 | RESET (LCD_D6) PB6 | 4 3 | PB7 (LCD_D7) - * GND | 2 1 | 5V GND | 2 1 | 5V + * (SD_MISO) PA6 | 1 2 | PA5 (SD_SCK) (BEEPER) PC9 | 1 2 | PC12 (BTN_ENC) + * (BTN_EN1) PC10 | 3 4 | PA4 (SD_SS) (LCD_EN) PB15 | 3 4 | PB12 (LCD_RS) + * (BTN_EN2) PC11 5 6 | PA7 (SD_MOSI) (LCD_D4) PB13 5 6 | PB14 (LCD_D5) + * (SD_DETECT) PC3 | 7 8 | RESET (LCD_D6) PB6 | 7 8 | PB7 (LCD_D7) + * GND | 9 10 | 5V GND | 9 10 | 5V * ------ ------ * EXP2 EXP1 */ /** * ------ - * 5V |10 9 | GND - * (LCD_EN/MOSI) PB15 | 8 7 | PB12 (LCD_RS) - * (LCD_D4/SCK) PB13 6 5 | PC11 (BTN_EN2) - * (LCD_D5/MISO) PB14 | 4 3 | PC10 (BTN_EN1) - * (BTN_ENC) PC12 | 2 1 | PC9 (BEEPER) + * 5V | 1 2 | GND + * (LCD_EN/MOSI) PB15 | 3 4 | PB12 (LCD_RS) + * (LCD_D4/SCK) PB13 5 6 | PC11 (BTN_EN2) + * (LCD_D5/MISO) PB14 | 7 8 | PC10 (BTN_EN1) + * (BTN_ENC) PC12 | 9 10 | PC9 (BEEPER) * ------ * EXP3 */ -#define EXP1_03_PIN PB7 -#define EXP1_04_PIN PB6 -#define EXP1_05_PIN PB14 -#define EXP1_06_PIN PB13 -#define EXP1_07_PIN PB12 -#define EXP1_08_PIN PB15 -#define EXP1_09_PIN PC12 -#define EXP1_10_PIN PC9 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN PC3 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PC11 -#define EXP2_07_PIN PA4 -#define EXP2_08_PIN PC10 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PC9 +#define EXP1_02_PIN PC12 +#define EXP1_03_PIN PB15 +#define EXP1_04_PIN PB12 +#define EXP1_05_PIN PB13 +#define EXP1_06_PIN PB14 +#define EXP1_07_PIN PB6 +#define EXP1_08_PIN PB7 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PC10 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PC11 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PC3 +#define EXP2_08_PIN -1 #if HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #elif ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_06_PIN - #define BTN_EN2 EXP2_08_PIN + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN //#define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #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_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif // !FYSETC_MINI_12864 #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #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 @@ -253,7 +255,7 @@ #endif #if ENABLED(TOUCH_UI_FTDI_EVE) - #define BEEPER_PIN EXP1_10_PIN - #define CLCD_MOD_RESET EXP2_08_PIN - #define CLCD_SPI_CS EXP2_06_PIN + #define BEEPER_PIN EXP1_01_PIN + #define CLCD_MOD_RESET EXP2_03_PIN + #define CLCD_SPI_CS EXP2_05_PIN #endif diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h index 3ed18f9abc68..fca181c1f46a 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h @@ -199,117 +199,117 @@ /** * ------ ------ - * PC9 |10 9 | PA8 PA6 |10 9 | PA5 - * PC11 | 8 7 | PD2 PC6 | 8 7 | PA4 - * PC10 6 5 | PC12 PC7 6 5 | PA7 - * PD0 | 4 3 | PD1 PB10 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | 5V + * PC9 | 1 2 | PA8 PA6 | 1 2 | PA5 + * PC11 | 3 4 | PD2 PC6 | 3 4 | PA4 + * PC10 5 6 | PC12 PC7 5 6 | PA7 + * PD0 | 7 8 | PD1 PB10 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 5V * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PD1 -#define EXP1_04_PIN PD0 -#define EXP1_05_PIN PC12 -#define EXP1_06_PIN PC10 -#define EXP1_07_PIN PD2 -#define EXP1_08_PIN PC11 -#define EXP1_09_PIN PA8 -#define EXP1_10_PIN PC9 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN PB10 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PC7 -#define EXP2_07_PIN PA4 -#define EXP2_08_PIN PC6 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PC9 +#define EXP1_02_PIN PA8 +#define EXP1_03_PIN PC11 +#define EXP1_04_PIN PD2 +#define EXP1_05_PIN PC10 +#define EXP1_06_PIN PC12 +#define EXP1_07_PIN PD0 +#define EXP1_08_PIN PD1 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PC6 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PC7 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PB10 +#define EXP2_08_PIN -1 // RESET // // SPI / SD Card // -#define SD_SCK_PIN EXP2_09_PIN -#define SD_MISO_PIN EXP2_10_PIN -#define SD_MOSI_PIN EXP2_05_PIN +#define SD_SCK_PIN EXP2_02_PIN +#define SD_MISO_PIN EXP2_01_PIN +#define SD_MOSI_PIN EXP2_06_PIN -#define SDSS EXP2_07_PIN -#define SD_DETECT_PIN EXP2_04_PIN +#define SDSS EXP2_04_PIN +#define SD_DETECT_PIN EXP2_07_PIN // // LCD / Controller // #if ENABLED(FYSETC_242_OLED_12864) - #define BTN_EN1 EXP1_10_PIN - #define BTN_EN2 EXP1_03_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_01_PIN + #define BTN_EN2 EXP1_08_PIN + #define BTN_ENC EXP1_02_PIN - #define BEEPER_PIN EXP2_08_PIN + #define BEEPER_PIN EXP2_03_PIN - #define LCD_PINS_DC EXP1_05_PIN - #define LCD_PINS_RS EXP2_06_PIN // LCD_RST - #define DOGLCD_CS EXP1_07_PIN - #define DOGLCD_MOSI EXP1_06_PIN - #define DOGLCD_SCK EXP1_08_PIN + #define LCD_PINS_DC EXP1_06_PIN + #define LCD_PINS_RS EXP2_05_PIN // LCD_RST + #define DOGLCD_CS EXP1_04_PIN + #define DOGLCD_MOSI EXP1_05_PIN + #define DOGLCD_SCK EXP1_03_PIN #define DOGLCD_A0 LCD_PINS_DC #define FORCE_SOFT_SPI #define KILL_PIN -1 // NC - #define NEOPIXEL_PIN EXP1_04_PIN + #define NEOPIXEL_PIN EXP1_07_PIN #elif HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_SDSS EXP2_07_PIN + #define LCD_SDSS EXP2_04_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) // See https://wiki.fysetc.com/Mini12864_Panel - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN #if ENABLED(FYSETC_GENERIC_12864_1_1) - #define LCD_BACKLIGHT_PIN EXP1_04_PIN + #define LCD_BACKLIGHT_PIN EXP1_07_PIN #endif - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #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_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #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 diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h new file mode 100644 index 000000000000..50fe790dc34d --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h @@ -0,0 +1,53 @@ +/** + * 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_INFO_NAME "MKS Monster8 V1" + +// +// Limit Switches +// +#define X_MIN_PIN PA14 +#define X_MAX_PIN PA13 +#define Y_MIN_PIN PA15 +#define Y_MAX_PIN PC5 + +// +// Steppers +// +#define E4_ENABLE_PIN PD14 // Driver7 + +// +// Misc. Functions +// +#define PW_DET PC5 // Y+ +#define PW_OFF PB12 // Z+ +#define MT_DET_1_PIN PW_DET +#define MT_DET_2_PIN PW_OFF +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN MT_DET_1_PIN +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN MT_DET_2_PIN +#endif + +#include "pins_MKS_MONSTER8_common.h" diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h new file mode 100644 index 000000000000..d70e935f0a29 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h @@ -0,0 +1,63 @@ +/** + * 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_INFO_NAME "MKS Monster8 V2" + +// +// Limit Switches +// +#define X_STOP_PIN PA14 +#define Y_STOP_PIN PA15 + +// +// Steppers +// +#define E4_ENABLE_PIN PB6 // Driver7 + +// +// Misc. Functions +// +#define PW_DET PA13 // MT_DET +#define PW_OFF PB12 // Z+ +#define MT_DET_1_PIN PW_DET +#define MT_DET_2_PIN PW_OFF +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN MT_DET_1_PIN +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN MT_DET_2_PIN +#endif + +// +// MKS WIFI MODULE +// +//#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 +#endif + +#define NEOPIXEL_PIN PC5 + +#include "pins_MKS_MONSTER8_common.h" diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h similarity index 65% rename from Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h rename to Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h index e55f3170d03e..1896cd5441b3 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h @@ -30,8 +30,6 @@ #error "MKS Monster doesn't support FSMC-based TFT displays." #endif -#define BOARD_INFO_NAME "MKS Monster8 V1.x" - #define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support #define USES_DIAG_JUMPERS @@ -54,82 +52,74 @@ #define SERVO0_PIN PA8 // Enable BLTOUCH // -// Limit Switches for diag signal +// Limit Switches for diag signals // -#define X_DIAG_PIN PA14 // Driver0 diag signal is connect to X- -#define Y_DIAG_PIN PA15 // Driver1 diag signal is connect to Y- -#define Z_DIAG_PIN PB13 // Driver2 diag signal is connect to Z- -#define E0_DIAG_PIN PA13 // Driver3 diag signal is connect to X+ -#define E1_DIAG_PIN PC5 // Driver4 diag signal is connect to Y+ -#define E2_DIAG_PIN PB12 // Driver5 diag signal is connect to Z+ -#define E3_DIAG_PIN -1 // Driver6 diag signal is not connect -#define E4_DIAG_PIN -1 // Driver7 diag signal is not connect - -// Limit Switches for endstop -#define X_MIN_PIN PA14 -#define X_MAX_PIN PA13 -#define Y_MIN_PIN PA15 -#define Y_MAX_PIN PC5 +#define X_DIAG_PIN PA14 // Driver0 diag signal is connected to X- +#define Y_DIAG_PIN PA15 // Driver1 diag signal is connected to Y- +#define Z_DIAG_PIN PB13 // Driver2 diag signal is connected to Z- +#define E0_DIAG_PIN PA13 // Driver3 diag signal is connected to X+ +#define E1_DIAG_PIN PC5 // Driver4 diag signal is connected to Y+ +#define E2_DIAG_PIN PB12 // Driver5 diag signal is connected to Z+ +#define E3_DIAG_PIN -1 // Driver6 diag signal is not connected +#define E4_DIAG_PIN -1 // Driver7 diag signal is not connected + +// Limit Switches for endstops #define Z_MIN_PIN PB13 #define Z_MAX_PIN PB12 // // Steppers -// Driver 0 1 2 3 4 5 6 7 -// For X Y Z E0 E1 E2 E3 E4(default pin settings) // -//Driver0 -#define X_ENABLE_PIN PC15 +#define X_ENABLE_PIN PC15 // Driver0 #define X_STEP_PIN PC14 #define X_DIR_PIN PC13 #ifndef X_CS_PIN #define X_CS_PIN PE6 #endif -//Driver1 -#define Y_ENABLE_PIN PC15 + +#define Y_ENABLE_PIN PC15 // Driver1 #define Y_STEP_PIN PE5 #define Y_DIR_PIN PE4 #ifndef Y_CS_PIN #define Y_CS_PIN PE3 #endif -//Driver2 -#define Z_ENABLE_PIN PE2 + +#define Z_ENABLE_PIN PE2 // Driver2 #define Z_STEP_PIN PE1 #define Z_DIR_PIN PE0 #ifndef Z_CS_PIN #define Z_CS_PIN PB7 #endif -//Driver3 -#define E0_ENABLE_PIN PB6 + +#define E0_ENABLE_PIN PB6 // Driver3 #define E0_STEP_PIN PB5 #define E0_DIR_PIN PB4 #ifndef E0_CS_PIN #define E0_CS_PIN PB3 #endif -//Driver4 -#define E1_ENABLE_PIN PD7 + +#define E1_ENABLE_PIN PD7 // Driver4 #define E1_STEP_PIN PD6 #define E1_DIR_PIN PD5 #ifndef E1_CS_PIN #define E1_CS_PIN PD4 #endif -//Driver5 -#define E2_ENABLE_PIN PD3 + +#define E2_ENABLE_PIN PD3 // Driver5 #define E2_STEP_PIN PD2 #define E2_DIR_PIN PD1 #ifndef E2_CS_PIN #define E2_CS_PIN PD0 #endif -//Driver6 -#define E3_ENABLE_PIN PC8 + +#define E3_ENABLE_PIN PC8 // Driver6 #define E3_STEP_PIN PC7 #define E3_DIR_PIN PC6 #ifndef E3_CS_PIN #define E3_CS_PIN PD15 #endif -//Driver7 -#define E4_ENABLE_PIN PD14 -#define E4_STEP_PIN PD13 + +#define E4_STEP_PIN PD13 // Driver7 #define E4_DIR_PIN PD12 #ifndef E4_CS_PIN #define E4_CS_PIN PD11 @@ -207,20 +197,6 @@ #define FAN1_PIN PA1 // FAN1 #define FAN2_PIN PA0 // FAN2 -// -// Misc. Functions -// -#define PW_DET PC5 // Y+ -#define PW_OFF PB12 // Z+ -#define MT_DET_1_PIN PW_DET -#define MT_DET_2_PIN PW_OFF -#ifndef FIL_RUNOUT_PIN - #define FIL_RUNOUT_PIN MT_DET_1_PIN -#endif -#ifndef FIL_RUNOUT2_PIN - #define FIL_RUNOUT2_PIN MT_DET_2_PIN -#endif - // // Power Supply Control // @@ -235,31 +211,31 @@ /** * ------ ------ - * (BEEPER) PB2 |10 9 | PE10 (BTN_ENC) (SPI1 MISO) PA6 |10 9 | PA5 (SPI1 SCK) - * (LCD_EN) PE11 | 8 7 | PD10 (LCD_RS) (BTN_EN1) PE9 | 8 7 | PA4 (SPI1 CS) - * (LCD_D4) PD9 6 5 | PD8 (LCD_D5) (BTN_EN2) PE8 6 5 | PA7 (SPI1 MOSI) - * (LCD_D6) PE15 | 4 3 | PE7 (LCD_D7) (SPI1_RS) PB11 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | 3.3V + * (BEEPER) PB2 | 1 2 | PE10 (BTN_ENC) (SPI1 MISO) PA6 | 1 2 | PA5 (SPI1 SCK) + * (LCD_EN) PE11 | 3 4 | PD10 (LCD_RS) (BTN_EN1) PE9 | 3 4 | PA4 (SPI1 CS) + * (LCD_D4) PD9 5 6 | PD8 (LCD_D5) (BTN_EN2) PE8 5 6 | PA7 (SPI1 MOSI) + * (LCD_D6) PE15 | 7 8 | PE7 (LCD_D7) (SPI1_RS) PB11 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PE7 -#define EXP1_04_PIN PE15 -#define EXP1_05_PIN PD8 -#define EXP1_06_PIN PD9 -#define EXP1_07_PIN PD10 -#define EXP1_08_PIN PE11 -#define EXP1_09_PIN PE10 -#define EXP1_10_PIN PB2 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN PB11 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PE8 -#define EXP2_07_PIN PA4 -#define EXP2_08_PIN PE9 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#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 PB11 +#define EXP2_08_PIN -1 // RESET #if ENABLED(SDSUPPORT) #ifndef SDCARD_CONNECTION @@ -275,25 +251,25 @@ #define SD_DETECT_PIN PC4 // SD_DETECT_PIN doesn't work with NO_SD_HOST_DRIVE disabled #elif SD_CONNECTION_IS(LCD) #define ENABLE_SPI1 - #define SDSS EXP2_07_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SDSS 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 #endif #endif -#if ANY(TFT_COLOR_UI, TFT_CLASSIC_UI) - #define TFT_CS_PIN EXP1_04_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_MOSI_PIN EXP2_05_PIN - #define TFT_DC_PIN EXP1_03_PIN +#if EITHER(TFT_COLOR_UI, TFT_CLASSIC_UI) + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + #define TFT_DC_PIN EXP1_08_PIN #define TFT_A0_PIN TFT_DC_PIN - #define TFT_RESET_PIN EXP1_07_PIN + #define TFT_RESET_PIN EXP1_04_PIN - #define LCD_BACKLIGHT_PIN EXP1_08_PIN + #define LCD_BACKLIGHT_PIN EXP1_03_PIN #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN #define TOUCH_BUTTONS_HW_SPI @@ -306,10 +282,10 @@ #define TFT_HEIGHT 320 #endif - #define TOUCH_CS_PIN EXP1_06_PIN // SPI1_NSS - #define TOUCH_SCK_PIN EXP2_09_PIN // SPI1_SCK - #define TOUCH_MISO_PIN EXP2_10_PIN // SPI1_MISO - #define TOUCH_MOSI_PIN EXP2_05_PIN // SPI1_MOSI + #define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS + #define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK + #define TOUCH_MISO_PIN EXP2_01_PIN // SPI1_MISO + #define TOUCH_MOSI_PIN EXP2_06_PIN // SPI1_MOSI #define LCD_READ_ID 0xD3 #define LCD_USE_DMA_SPI @@ -334,8 +310,8 @@ #elif HAS_WIRED_LCD - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN #define LCD_BACKLIGHT_PIN -1 // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) @@ -343,23 +319,23 @@ #define ENABLE_SPI1 #define FORCE_SOFT_SPI - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define DOGLCD_SCK EXP2_09_PIN - #define DOGLCD_MOSI EXP2_05_PIN - //#define LCD_BACKLIGHT_PIN -1 - //#define LCD_RESET_PIN -1 + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN + //#define LCD_BACKLIGHT_PIN -1 + //#define LCD_RESET_PIN -1 #elif ENABLED(FYSETC_MINI_12864_2_1) - #define LCD_PINS_DC EXP1_07_PIN - #define DOGLCD_CS EXP1_08_PIN + #define LCD_PINS_DC EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN #define DOGLCD_A0 LCD_PINS_DC #define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN - #define NEOPIXEL_PIN EXP1_05_PIN - #define DOGLCD_MOSI EXP2_05_PIN - #define DOGLCD_SCK EXP2_09_PIN + #define LCD_RESET_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN + #define DOGLCD_MOSI EXP2_06_PIN + #define DOGLCD_SCK EXP2_02_PIN #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif @@ -367,11 +343,11 @@ #else - #define LCD_PINS_D4 EXP1_06_PIN - #if ENABLED(ULTIPANEL) - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #endif #define BOARD_ST7920_DELAY_1 96 @@ -383,8 +359,8 @@ #endif // HAS_WIRED_LCD #if ANY(TFT_COLOR_UI, TFT_CLASSIC_UI, HAS_WIRED_LCD) - #define BEEPER_PIN EXP1_10_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN #endif diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN2.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN2.h index 2274d0c0dff3..322739725e10 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN2.h @@ -99,3 +99,39 @@ #define SD_DETECT_PIN PF9 #define BEEPER_PIN PG2 + +// +// TFT with FSMC interface +// +#if HAS_FSMC_TFT + /** + * Note: MKS Robin TFT screens use various TFT controllers. + * If the screen stays white, disable 'LCD_RESET_PIN' + * to let the bootloader init the screen. + */ + #define LCD_RESET_PIN PD13 + #define LCD_BACKLIGHT_PIN PD12 + + #define TFT_RESET_PIN LCD_RESET_PIN + #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN + + #define FSMC_CS_PIN PG12 // NE4 + #define FSMC_RS_PIN PF12 // A0 + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN + + #define TFT_BUFFER_SIZE 14400 + + #define BEEPER_PIN PG2 + + #if NEED_TOUCH_PINS + #define TOUCH_BUTTONS_HW_SPI + #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 + #define TOUCH_CS_PIN PD11 // SPI1_NSS + #define TOUCH_SCK_PIN PB3 // SPI1_SCK + #define TOUCH_MISO_PIN PB4 // SPI1_MISO + #define TOUCH_MOSI_PIN PB5 // SPI1_MOSI + #endif + +#endif diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h index 3cba69a7b30a..a0a711647b7b 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h @@ -40,6 +40,4 @@ //#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation #endif -#define LED_PIN PB1 - #include "../stm32f1/pins_MKS_ROBIN_NANO_common.h" 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 989010e47f36..42b252d320e7 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 @@ -19,7 +19,6 @@ * along with this program. If not, see . * */ - #pragma once // @@ -225,7 +224,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 @@ -236,58 +235,58 @@ /** * ------ ------ - * (BEEPER) PC5 |10 9 | PE13 (BTN_ENC) (SPI1 MISO) PA6 |10 9 | PA5 (SPI1 SCK) - * (LCD_EN) PD13 | 8 7 | PC6 (LCD_RS) (BTN_EN1) PE8 | 8 7 | PE10 (SPI1 CS) - * (LCD_D4) PE14 6 5 | PE15 (LCD_D5) (BTN_EN2) PE11 6 5 | PA7 (SPI1 MOSI) - * (LCD_D6) PD11 | 4 3 | PD10 (LCD_D7) (SPI1_RS) PE12 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | 3.3V + * (BEEPER) PC5 | 1 2 | PE13 (BTN_ENC) (SPI1 MISO) PA6 | 1 2 | PA5 (SPI1 SCK) + * (LCD_EN) PD13 | 3 4 | PC6 (LCD_RS) (BTN_EN1) PE8 | 3 4 | PE10 (SPI1 CS) + * (LCD_D4) PE14 5 6 | PE15 (LCD_D5) (BTN_EN2) PE11 5 6 | PA7 (SPI1 MOSI) + * (LCD_D6) PD11 | 7 8 | PD10 (LCD_D7) (SPI1_RS) PE12 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PD10 -#define EXP1_04_PIN PD11 -#define EXP1_05_PIN PE15 -#define EXP1_06_PIN PE14 -#define EXP1_07_PIN PC6 -#define EXP1_08_PIN PD13 -#define EXP1_09_PIN PE13 -#define EXP1_10_PIN PC5 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN PE12 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PE11 -#define EXP2_07_PIN PE10 -#define EXP2_08_PIN PE8 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PC5 +#define EXP1_02_PIN PE13 +#define EXP1_03_PIN PD13 +#define EXP1_04_PIN PC6 +#define EXP1_05_PIN PE14 +#define EXP1_06_PIN PE15 +#define EXP1_07_PIN PD11 +#define EXP1_08_PIN PD10 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE8 +#define EXP2_04_PIN PE10 +#define EXP2_05_PIN PE11 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PE12 +#define EXP2_08_PIN -1 // RESET // // SPI SD Card // #if SD_CONNECTION_IS(LCD) #define ENABLE_SPI1 - #define SDSS EXP2_07_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SDSS 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 #endif // // LCD / Controller // #if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) - #define TFT_CS_PIN EXP1_04_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_MOSI_PIN EXP2_05_PIN - #define TFT_DC_PIN EXP1_03_PIN + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + #define TFT_DC_PIN EXP1_08_PIN #define TFT_A0_PIN TFT_DC_PIN - #define TFT_RESET_PIN EXP1_07_PIN + #define TFT_RESET_PIN EXP1_04_PIN - #define LCD_BACKLIGHT_PIN EXP1_08_PIN + #define LCD_BACKLIGHT_PIN EXP1_03_PIN #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN #define TOUCH_BUTTONS_HW_SPI @@ -300,10 +299,10 @@ #define TFT_HEIGHT 320 #endif - #define TOUCH_CS_PIN EXP1_06_PIN // SPI1_NSS - #define TOUCH_SCK_PIN EXP2_09_PIN // SPI1_SCK - #define TOUCH_MISO_PIN EXP2_10_PIN // SPI1_MISO - #define TOUCH_MOSI_PIN EXP2_05_PIN // SPI1_MOSI + #define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS + #define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK + #define TOUCH_MISO_PIN EXP2_01_PIN // SPI1_MISO + #define TOUCH_MOSI_PIN EXP2_06_PIN // SPI1_MOSI #define LCD_READ_ID 0xD3 #define LCD_USE_DMA_SPI @@ -328,32 +327,32 @@ #elif HAS_WIRED_LCD - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN #define LCD_BACKLIGHT_PIN -1 // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) #if ENABLED(MKS_MINI_12864) //#define LCD_BACKLIGHT_PIN -1 //#define LCD_RESET_PIN -1 - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - //#define DOGLCD_SCK EXP2_09_PIN - //#define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + //#define DOGLCD_SCK EXP2_02_PIN + //#define DOGLCD_MOSI EXP2_06_PIN // Required for MKS_MINI_12864 with this board //#define MKS_LCD12864B //#undef SHOW_BOOTSCREEN #elif ENABLED(FYSETC_MINI_12864_2_1) - #define LCD_PINS_DC EXP1_07_PIN - #define DOGLCD_CS EXP1_08_PIN + #define LCD_PINS_DC EXP1_04_PIN + #define DOGLCD_CS EXP1_03_PIN #define DOGLCD_A0 LCD_PINS_DC #define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN - #define NEOPIXEL_PIN EXP1_05_PIN - #define DOGLCD_MOSI EXP2_05_PIN - #define DOGLCD_SCK EXP2_09_PIN + #define LCD_RESET_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN + #define DOGLCD_MOSI EXP2_06_PIN + #define DOGLCD_SCK EXP2_02_PIN #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif @@ -361,11 +360,11 @@ #else // !MKS_MINI_12864 - #define LCD_PINS_D4 EXP1_06_PIN - #if ENABLED(ULTIPANEL) - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #endif #define BOARD_ST7920_DELAY_1 96 @@ -382,10 +381,10 @@ #endif #if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI, HAS_WIRED_LCD) - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN #if DISABLED(USE_SPI_DMA_TC) - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN #endif #endif 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 1627bb909b4c..14b3d6616830 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h @@ -230,31 +230,31 @@ #endif /** ------ ------ - * (BEEPER) PC5 |10 9 | PE13 (BTN_ENC) (SPI1 MISO) PA6 |10 9 | PA5 (SPI1 SCK) - * (LCD_EN) PD13 | 8 7 | PC6 (LCD_RS) (BTN_EN1) PE8 | 8 7 | PE10 (SPI1 CS) - * (LCD_D4) PE14 6 5 | PE15 (LCD_D5) (BTN_EN2) PE11 6 5 | PA7 (SPI1 MOSI) - * (LCD_D6) PD11 | 4 3 | PD10 (LCD_D7) (SPI DET) PE12 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | 3.3V + * (BEEPER) PC5 | 1 2 | PE13 (BTN_ENC) (SPI1 MISO) PA6 | 1 2 | PA5 (SPI1 SCK) + * (LCD_EN) PD13 | 3 4 | PC6 (LCD_RS) (BTN_EN1) PE8 | 3 4 | PE10 (SPI1 CS) + * (LCD_D4) PE14 5 6 | PE15 (LCD_D5) (BTN_EN2) PE11 5 6 | PA7 (SPI1 MOSI) + * (LCD_D6) PD11 | 7 8 | PD10 (LCD_D7) (SPI DET) PE12 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PD10 -#define EXP1_04_PIN PD11 -#define EXP1_05_PIN PE15 -#define EXP1_06_PIN PE14 -#define EXP1_07_PIN PC6 -#define EXP1_08_PIN PD13 -#define EXP1_09_PIN PE13 -#define EXP1_10_PIN PC5 - -#define EXP2_03_PIN -1 // RESET -#define EXP2_04_PIN PE12 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PE11 -#define EXP2_07_PIN PE10 -#define EXP2_08_PIN PE8 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PC5 +#define EXP1_02_PIN PE13 +#define EXP1_03_PIN PD13 +#define EXP1_04_PIN PC6 +#define EXP1_05_PIN PE14 +#define EXP1_06_PIN PE15 +#define EXP1_07_PIN PD11 +#define EXP1_08_PIN PD10 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE8 +#define EXP2_04_PIN PE10 +#define EXP2_05_PIN PE11 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PE12 +#define EXP2_08_PIN -1 // RESET // // LCD SD @@ -262,18 +262,18 @@ /* #if SD_CONNECTION_IS(LCD) #define ENABLE_SPI1 - #define SDSS EXP2_07_PIN - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN - #define SD_DETECT_PIN EXP2_04_PIN + #define SDSS 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 #endif */ // // 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) @@ -300,15 +300,15 @@ #define TOUCH_ORIENTATION TOUCH_LANDSCAPE #endif - #define TFT_CS_PIN EXP1_04_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_MOSI_PIN EXP2_05_PIN - #define TFT_DC_PIN EXP1_03_PIN + #define TFT_CS_PIN EXP1_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + #define TFT_DC_PIN EXP1_08_PIN #define TFT_A0_PIN TFT_DC_PIN - #define TFT_RESET_PIN EXP1_07_PIN - #define LCD_BACKLIGHT_PIN EXP1_08_PIN + #define TFT_RESET_PIN EXP1_04_PIN + #define LCD_BACKLIGHT_PIN EXP1_03_PIN #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN #define TOUCH_BUTTONS_HW_SPI @@ -321,15 +321,15 @@ #define TFT_HEIGHT 320 #endif - #define TOUCH_CS_PIN EXP1_06_PIN // SPI1_NSS - #define TOUCH_SCK_PIN EXP2_09_PIN // SPI1_SCK - #define TOUCH_MISO_PIN EXP2_10_PIN // SPI1_MISO - #define TOUCH_MOSI_PIN EXP2_05_PIN // SPI1_MOSI + #define TOUCH_CS_PIN EXP1_05_PIN // SPI1_NSS + #define TOUCH_SCK_PIN EXP2_02_PIN // SPI1_SCK + #define TOUCH_MISO_PIN EXP2_01_PIN // SPI1_MISO + #define TOUCH_MOSI_PIN EXP2_06_PIN // SPI1_MOSI - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #define LCD_READ_ID 0xD3 #define LCD_USE_DMA_SPI @@ -339,22 +339,22 @@ #elif HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #define LCD_BACKLIGHT_PIN -1 // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) #if ENABLED(MKS_MINI_12864) //#define LCD_BACKLIGHT_PIN -1 //#define LCD_RESET_PIN -1 - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - //#define DOGLCD_SCK EXP2_09_PIN - //#define DOGLCD_MOSI EXP2_05_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + //#define DOGLCD_SCK EXP2_02_PIN + //#define DOGLCD_MOSI EXP2_06_PIN // Required for MKS_MINI_12864 with this board //#define MKS_LCD12864B @@ -362,11 +362,11 @@ #else // !MKS_MINI_12864 - #define LCD_PINS_D4 EXP1_06_PIN - #if ENABLED(ULTIPANEL) - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN #endif #define BOARD_ST7920_DELAY_1 96 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..3f0d4e5ee924 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_MKS_SKIPR_V1_0.h @@ -0,0 +1,377 @@ +/** + * 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 // 4K (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 + #endif + #if _ENDSTOP_IS_ANY(_YMIN_) || _ENDSTOP_IS_ANY(_YMAX_) + #define NEEDS_Y_MINMAX + #endif + #if _ENDSTOP_IS_ANY(_ZMIN_) || _ENDSTOP_IS_ANY(_ZMAX_) + #define NEEDS_Z_MINMAX + #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 ENABLED(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 ENABLED(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 + +// +// 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/Marlin/src/pins/stm32f4/pins_INDEX_REV03.h b/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h similarity index 96% rename from Marlin/src/pins/stm32f4/pins_INDEX_REV03.h rename to Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h index ba3172aa8008..06bf09402c06 100644 --- a/Marlin/src/pins/stm32f4/pins_INDEX_REV03.h +++ b/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h @@ -22,15 +22,15 @@ #pragma once /** - * STM32F407VET6 on Index PnP Mobo Rev03 - * Website - https://indexmachines.io/ + * STM32F407VET6 on Opulo Lumen PnP Rev3 + * Website - https://opulo.io/ */ #define ALLOW_STM32DUINO #include "env_validate.h" -#define BOARD_INFO_NAME "Index Mobo Rev03" -#define DEFAULT_MACHINE_NAME "Index Pick and Place" +#define BOARD_INFO_NAME "Opulo Lumen REV3" +#define DEFAULT_MACHINE_NAME "Opulo Pick-and-Place" /** * By default, the extra stepper motor configuration is: @@ -44,6 +44,9 @@ // I2C MCP3426 (16-Bit, 240SPS, dual-channel ADC) #define HAS_MCP3426_ADC +#ifdef STM32F4 + #define HAS_STM32_UID +#endif // // Servos 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/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h b/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h deleted file mode 100644 index 0b527a6fdb78..000000000000 --- a/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h +++ /dev/null @@ -1,325 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 - -// Source: https://github.com/stm32duino/Arduino_Core_STM32/blob/master/variants/ST3DP001_EVAL/variant.cpp - -/** - * HOW TO COMPILE - * - * PlatformIO - Use the STM32F401VE_STEVAL environment (or the "Auto Build Marlin" extension). - * - * Arduino - Tested with 1.8.10 - * Install library per https://github.com/stm32duino/Arduino_Core_STM32 - * Make the following selections under the TOOL menu in the Arduino IDE - * Board: "3D printer boards" - * Board part number: "STEVAL-3DP001V1" - * U(S)ART support: "Enabled (generic "Serial")" - * USB support (if available): "CDC (no generic "Serial")" - * Optimize: "Smallest (-Os default)" - * C Runtime Library: "newlib Nano (default)" - */ - -#include "env_validate.h" - -#ifndef MACHINE_NAME - #define MACHINE_NAME "STEVAL-3DP001V1" -#endif - -// -// Limit Switches -// -#define X_MIN_PIN PD8 // X_STOP -#define Y_MIN_PIN PD9 // Y_STOP -#define Z_MIN_PIN PD10 // Z_STOP - -#define X_MAX_PIN PD0 // W_STOP -#define Y_MAX_PIN PA8 // V_STOP -#define Z_MAX_PIN PD11 // U_STOP - -// -// Z Probe (when not Z_MIN_PIN) -// -//#ifndef Z_MIN_PROBE_PIN -// #define Z_MIN_PROBE_PIN PA4 // SPI1_CS -//#endif - -// -// Filament runout -// -//#define FIL_RUNOUT_PIN PA3 // BED_THERMISTOR_3 - -// -// Steppers -// - -#define X_STEP_PIN PE14 // X_PWM -#define X_DIR_PIN PE15 // X_DIR -#define X_ENABLE_PIN PE13 // X_RESET -#define X_CS_PIN PA4 // SPI1_CS - -#define Y_STEP_PIN PB10 // Y_PWM -#define Y_DIR_PIN PE9 // Y_DIR -#define Y_ENABLE_PIN PE10 // Y_RESET -#define Y_CS_PIN PA4 // SPI1_CS - -#define Z_STEP_PIN PC6 // Z_PWM -#define Z_DIR_PIN PC0 // Z_DIR -#define Z_ENABLE_PIN PC15 // Z_RESET -#define Z_CS_PIN PA4 // SPI1_CS - -#define E0_STEP_PIN PD12 // E1_PW -#define E0_DIR_PIN PC13 // E1_DIR -#define E0_ENABLE_PIN PC14 // E1_RESET -#define E0_CS_PIN PA4 // SPI1_CS - -#define E1_STEP_PIN PE5 // E2_PWM -#define E1_DIR_PIN PE6 // E2_DIR -#define E1_ENABLE_PIN PE4 // E2_RESET -#define E1_CS_PIN PA4 // SPI1_CS - -#define E2_STEP_PIN PB8 // E3_PWM -#define E2_DIR_PIN PE2 // E3_DIR -#define E2_ENABLE_PIN PE3 // E3_RESET -#define E2_CS_PIN PA4 // SPI1_CS - -// needed to pass a sanity check -#define X2_CS_PIN PA4 // SPI1_CS -#define Y2_CS_PIN PA4 // SPI1_CS -#define Z2_CS_PIN PA4 // SPI1_CS -#define Z3_CS_PIN PA4 // SPI1_CS -#define E3_CS_PIN PA4 // SPI1_CS -#define E4_CS_PIN PA4 // SPI1_CS -#define E5_CS_PIN PA4 // SPI1_CS - -#if HAS_L64XX - #define L6470_CHAIN_SCK_PIN PA5 // SPI1_SCK - #define L6470_CHAIN_MISO_PIN PA6 // SPI1_MISO - #define L6470_CHAIN_MOSI_PIN PA7 // SPI1_MOSI - #define L6470_CHAIN_SS_PIN PA4 // SPI1_CS - - //#define SD_SCK_PIN L6470_CHAIN_SCK_PIN - //#define SD_MISO_PIN L6470_CHAIN_MISO_PIN - //#define SD_MOSI_PIN L6470_CHAIN_MOSI_PIN -#else - //#define SD_SCK_PIN PB13 // SPI2_SCK - //#define SD_MISO_PIN PB14 // SPI2_MISO - //#define SD_MOSI_PIN PB15 // SPI2_MOSI -#endif - -/** - * Macro to reset/enable L6474 stepper drivers - * - * IMPORTANT - To disable (bypass) L6474s, install the corresponding - * resistors (R11 - R17) and change the "V" to "0" for the - * corresponding pins here: - */ -#define ENABLE_RESET_L64XX_CHIPS(V) do{ OUT_WRITE(X_ENABLE_PIN, V); \ - OUT_WRITE(Y_ENABLE_PIN, V); \ - OUT_WRITE(Z_ENABLE_PIN, V); \ - OUT_WRITE(E0_ENABLE_PIN,V); \ - OUT_WRITE(E1_ENABLE_PIN,V); \ - OUT_WRITE(E2_ENABLE_PIN,V); \ - }while(0) - -// -// Temperature Sensors -// -#define TEMP_0_PIN PA0 // Analog Input 3 -#define TEMP_1_PIN PA1 // Analog Input 4 -#define TEMP_2_PIN PA2 // Analog Input 5 -#define TEMP_BED_PIN PC2 // Analog Input 0 -#define TEMP_BED_1_PIN PC3 // Analog Input 1 -#define TEMP_BED_2_PIN PA3 // Analog Input 2 - -// -// Heaters / Fans -// -#define HEATER_0_PIN PC7 // E1_HEAT_PWM -#define HEATER_1_PIN PB0 // E2_HEAT_PWM -#define HEATER_2_PIN PB1 // E3_HEAT_PWM -#define HEATER_BED_PIN PD14 // BED_HEAT_1 FET -#define HEATER_BED_1_PIN PD13 // BED_HEAT_2 FET -#define HEATER_BED_2_PIN PD15 // BED_HEAT_3 FET - -#define FAN_PIN PC4 // E1_FAN PWM pin, Part cooling fan FET -#define FAN1_PIN PC5 // E2_FAN PWM pin, Extruder fan FET -#define FAN2_PIN PE8 // E3_FAN PWM pin, Controller fan FET - -#ifndef E0_AUTO_FAN_PIN - #define E0_AUTO_FAN_PIN PC5 // FAN1_PIN -#endif - -// -// Misc functions -// -#define LED_PIN -1 // PE1 Green LED Heartbeat -#define PS_ON_PIN -1 -#define KILL_PIN -1 -#define POWER_LOSS_PIN -1 // PWR_LOSS / nAC_FAULT - -// -// LCD / Controller -// -//#define SD_DETECT_PIN PA15 // SD_CARD_DETECT -//#define BEEPER_PIN PC9 // SDIO_D1 -//#define LCD_PINS_RS PE9 // Y_DIR -//#define LCD_PINS_ENABLE PE8 // E3_FAN -//#define LCD_PINS_D4 PB12 // SPI2_CS -//#define LCD_PINS_D5 PB13 // SPI2_SCK -//#define LCD_PINS_D6 PB14 // SPI2_MISO -//#define LCD_PINS_D7 PB15 // SPI2_MOSI -//#define BTN_EN1 PC4 // E1_FAN -//#define BTN_EN2 PC5 // E2_FAN -//#define BTN_ENC PC3 // BED_THERMISTOR_2 - -// -// Extension pins -// -//#define EXT0_PIN PB0 // E2_HEAT -//#define EXT1_PIN PB1 // E3_HEAT -//#define EXT2_PIN PB2 // not used (tied to ground) -//#define EXT3_PIN PD8 // X_STOP -//#define EXT4_PIN PD9 // Y_STOP -//#define EXT5_PIN PD10 // Z_STOP -//#define EXT6_PIN PD11 // U_STOP -//#define EXT7_PIN PD12 // E1_PWM -//#define EXT8_PIN PB10 // Y_PWM - -// WIFI -// PD3 CTS -// PD4 RTS -// PD5 TX -// PD6 RX -// PB5 WIFI_WAKEUP -// PE11 WIFI_RESET -// PE12 WIFI_BOOT - -// I2C USER -// PB7 SDA -// PB6 SCL - -// JTAG -// PA13 JTAG_TMS/SWDIO -// PA14 JTAG_TCK/SWCLK -// PB3 JTAG_TDO/SWO - -// -// Onboard SD support -// -#ifndef SDCARD_CONNECTION - #define SDCARD_CONNECTION ONBOARD -#endif - -#if SD_CONNECTION_IS(ONBOARD) - - #define SDIO_SUPPORT // Use SDIO for onboard SD - #if DISABLED(SDIO_SUPPORT) - #define SOFTWARE_SPI // Use soft SPI for onboard SD - #define SDSS PC11 - #define SD_SCK_PIN PC12 - #define SD_MISO_PIN PC8 - #define SD_MOSI_PIN PD2 - #endif - - //#define SD_DETECT_PIN PA15 - -#endif - -#ifndef SDSS - #define SDSS PA4 // SPI1_CS -#endif - -// OTG -// PA11 OTG_DM -// PA12 OTG_DP - -// USER_PINS -// PD7 USER3 -// PB9 USER1 -// PE0 USER2 -// PB4 USER4 - -// USERKET -// PE7 USER_BUTTON - -// PA9 TX -// PA10 RX - -// IR/PROBE -// PD1 IR_OUT -// PC1 IR_ON - -/** - * Logical pin vs. port/pin cross reference - * - * PA0 E1_THERMISTOR PD0 W_STOP - * PA1 E2_THERMISTOR PD1 IR_OUT - * PA2 E3_THERMISTOR PD2 SDIO_CMD - * PA3 BED_THERMISTOR_3 PD3 CTS - * PA4 SPI1_CS PD4 RTS - * PA5 SPI1_SCK PD5 TX - * PA6 SPI1_MISO PD6 RX - * PA7 SPI1_MOSI PD7 USER3 - * PA8 V_STOP PD8 X_STOP - * PA9 TX PD9 Y_STOP - * PA10 RX PD10 Z_STOP - * PA11 OTG_DM PD11 U_STOP - * PA12 OTG_DP PD12 E1_PWM - * PA13 JTAG_TMS/SWDIO PD13 BED_HEAT_2 - * PA14 JTAG_TCK/SWCLK PD14 BED_HEAT_1 - * PA15 SD_CARD_DETECT PD15 BED_HEAT_3 - * - * PB0 E2_HEAT_PWM PE0 USER2 - * PB1 E3_HEAT_PWM PE1 STATUS_LED - * PB2 --- PE2 E3_DIR - * PB3 JTAG_TDO/SWO PE3 E3_RESET - * PB4 USER4 PE4 E2_RESET - * PB5 WIFI_WAKEUP PE5 E2_PWM - * PB6 SCL PE6 E2_DIR - * PB7 SDA PE7 USER_BUTTON - * PB8 E3_PWM PE8 E3_FAN - * PB9 USER1 PE9 Y_DIR - * PB10 Y_PWM PE10 Y_RESET - * PB11 --- PE11 WIFI_RESET - * PB12 SPI2_CS PE12 WIFI_BOOT - * PB13 SPI2_SCK PE13 X_RESET - * PB14 SPI2_MISO PE14 X_PWM - * PB15 SPI2_MOSI PE15 X_DIR - * - * PC0 Z_DIR - * PC1 IR_ON - * PC2 BED_THERMISTOR_1 - * PC3 BED_THERMISTOR_2 - * PC4 E1_FAN - * PC5 E2_FAN - * PC6 Z_PWM - * PC7 E1_HEAT_PWM - * PC8 SDIO_D0 - * PC9 SDIO_D1 - * PC10 SDIO_D2 - * PC11 SDIO_D3 - * PC12 SDIO_CK - * PC13 E1_DIR - * PC14 E1_RESET - * PC15 Z_RESET - */ diff --git a/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h b/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h index 1439e6de651c..4fb57985b993 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" @@ -170,12 +174,6 @@ #ifndef E0_AUTO_FAN_PIN #define E0_AUTO_FAN_PIN AUTO_FAN_PIN #endif -#ifndef E1_AUTO_FAN_PIN - #define E1_AUTO_FAN_PIN AUTO_FAN_PIN -#endif -#ifndef E2_AUTO_FAN_PIN - #define E2_AUTO_FAN_PIN AUTO_FAN_PIN -#endif // // SD Card @@ -199,11 +197,11 @@ /** * ------ - * PA14 |10 9 | PB0 - * PC4 | 8 7 | -- - * PC5 | 6 5 PB13 - * PB12 | 4 3 | PB15 - * GND | 2 1 | 5V + * PA14 | 1 2 | PB0 + * PC4 | 3 4 | -- + * PC5 | 5 6 PB13 + * PB12 | 7 8 | PB15 + * GND | 9 10 | 5V * ------ * EXP1 * @@ -213,30 +211,30 @@ * A remote SD card is currently not supported because the pins routed to the EXP2 * connector are shared with the onboard SD card. */ -#define EXP1_03_PIN PB15 -#define EXP1_04_PIN PB12 -#define EXP1_05_PIN PB13 -#define EXP1_06_PIN PC5 -//#define EXP1_07_PIN -1 -#define EXP1_08_PIN PC4 -#define EXP1_09_PIN PB0 -#define EXP1_10_PIN PA14 +#define EXP1_01_PIN PA14 +#define EXP1_02_PIN PB0 +#define EXP1_03_PIN PC4 +//#define EXP1_04_PIN -1 +#define EXP1_05_PIN PC5 +#define EXP1_06_PIN PB13 +#define EXP1_07_PIN PB12 +#define EXP1_08_PIN PB15 #if ENABLED(CR10_STOCKDISPLAY) /** ------ - * BEEPER |10 9 | ENC - * EN1 | 8 7 | RESET - * EN2 | 6 5 LCD_D4 - * LCD_RS | 4 3 | LCD_EN - * GND | 2 1 | 5V + * BEEPER | 1 2 | ENC + * EN1 | 3 4 | RESET + * EN2 | 5 6 LCD_D4 + * LCD_RS | 7 8 | LCD_EN + * GND | 9 10 | 5V * ------ */ #ifdef DISABLE_JTAGSWD - #define BEEPER_PIN EXP1_10_PIN // Not connected in dev board + #define BEEPER_PIN EXP1_01_PIN // Not connected in dev board #endif - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN //#define KILL_PIN -1 #define BOARD_ST7920_DELAY_1 600 @@ -245,17 +243,17 @@ #elif ENABLED(MKS_MINI_12864) /** ------ - * SCK |10 9 | ENC - * EN1 | 8 7 | -- - * EN2 | 6 5 A0 - * CS | 4 3 | MOSI - * GND | 2 1 | 5V + * SCK | 1 2 | ENC + * EN1 | 3 4 | -- + * EN2 | 5 6 A0 + * CS | 7 8 | MOSI + * GND | 9 10 | 5V * ------ */ - #define DOGLCD_CS EXP1_04_PIN - #define DOGLCD_A0 EXP1_05_PIN - #define DOGLCD_SCK EXP1_10_PIN - #define DOGLCD_MOSI EXP1_03_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 LCD_CONTRAST_INIT 160 #define LCD_CONTRAST_MIN 120 #define LCD_CONTRAST_MAX 180 @@ -269,7 +267,7 @@ #endif #if EITHER(CR10_STOCKDISPLAY, MKS_MINI_12864) - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_PIN #endif 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..475dc42266a0 --- /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 SPI_FLASH_CS_PIN PG15 // SPI2 + #define SPI_FLASH_MOSI_PIN PB5 + #define SPI_FLASH_MISO_PIN PB4 + #define SPI_FLASH_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/Marlin/src/pins/stm32f4/pins_VAKE403D.h b/Marlin/src/pins/stm32f4/pins_VAKE403D.h index 66caec588f60..21ab9d0e7019 100644 --- a/Marlin/src/pins/stm32f4/pins_VAKE403D.h +++ b/Marlin/src/pins/stm32f4/pins_VAKE403D.h @@ -161,37 +161,37 @@ #define POWER_LOSS_PIN PA4 // ?? Power loss / nAC_FAULT #if ENABLED(SDSUPPORT) - #define SD_DETECT_PIN EXP2_04_PIN + #define SD_DETECT_PIN EXP2_07_PIN #define SD_SS_PIN PB15 // USD_CS -> CS for onboard SD #endif /** * ------ ------ - * PC9 |10 9 | PB12 ? |10 9 | ? - * PD7 | 8 7 | PC12 PD6 | 8 7 | ? - * PD1 | 6 5 PD2 PD0 | 6 5 ? - * PD3 | 4 3 | PD4 PB7 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | 3.3V + * PC9 | 1 2 | PB12 ? | 1 2 | ? + * PD7 | 3 4 | PC12 PD6 | 3 4 | ? + * PD1 | 5 6 PD2 PD0 | 5 6 ? + * PD3 | 7 8 | PD4 PB7 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | 3.3V * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PD4 -#define EXP1_04_PIN PD3 -#define EXP1_05_PIN PD2 -#define EXP1_06_PIN PD1 -#define EXP1_07_PIN PC12 -#define EXP1_08_PIN PD7 -#define EXP1_09_PIN PB12 -#define EXP1_10_PIN PC9 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN PB7 -//#define EXP2_05_PIN ? -#define EXP2_06_PIN PD0 -//#define EXP2_07_PIN ? -#define EXP2_08_PIN PD6 -//#define EXP2_09_PIN ? -//#define EXP2_10_PIN ? +#define EXP1_01_PIN PC9 +#define EXP1_02_PIN PB12 +#define EXP1_03_PIN PD7 +#define EXP1_04_PIN PC12 +#define EXP1_05_PIN PD1 +#define EXP1_06_PIN PD2 +#define EXP1_07_PIN PD3 +#define EXP1_08_PIN PD4 + +//#define EXP2_01_PIN ? +//#define EXP2_02_PIN ? +#define EXP2_03_PIN PD6 +//#define EXP2_04_PIN ? +#define EXP2_05_PIN PD0 +//#define EXP2_06_PIN ? +#define EXP2_07_PIN PB7 +#define EXP2_08_PIN -1 // // LCD / Controller @@ -202,19 +202,19 @@ #define SDSS PB6 // CS for SD card in LCD #endif - #define BEEPER_PIN EXP1_10_PIN + #define BEEPER_PIN EXP1_01_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_D4 EXP1_06_PIN - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 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 #endif diff --git a/Marlin/src/pins/stm32g0/env_validate.h b/Marlin/src/pins/stm32g0/env_validate.h new file mode 100644 index 000000000000..a7be76bd8bb1 --- /dev/null +++ b/Marlin/src/pins/stm32g0/env_validate.h @@ -0,0 +1,26 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 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 + +#if NOT_TARGET(STM32G0xx) || NOT_TARGET(STM32G0B1xx) + #error "Oops! Select an STM32G0 board in 'Tools > Board.'" +#endif diff --git a/Marlin/src/pins/stm32g0/pins_BTT_EBB42_V1_1.h b/Marlin/src/pins/stm32g0/pins_BTT_EBB42_V1_1.h new file mode 100644 index 000000000000..3de67ea8d591 --- /dev/null +++ b/Marlin/src/pins/stm32g0/pins_BTT_EBB42_V1_1.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 + +#include "env_validate.h" + +/** CAUTION ** + * This board definition is to facilitate support for a Filament Extrusion + * devices, used to convert waste plastic into 3D printable filament. + * This board is NOT a general 3D printing controller; it is NOT supported + * as a toolboard via CANBUS (as it was originally designed) or any device + * that requires kinematics. + */ + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT EBB42 V1.1" +#endif + +// +// EEPROM +// +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #undef NO_EEPROM_SELECTED + #ifndef FLASH_EEPROM_EMULATION + #define FLASH_EEPROM_EMULATION + #endif + #define EEPROM_PAGE_SIZE (0x800UL) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 1UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE +#endif + +//#define USES_DIAG_JUMPERS + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +#define LED_PIN PA13 + +#define I2C_SDA_PIN PB4 +#define I2C_SCL_PIN PB3 + +// +// Servos +// +#define SERVO0_PIN PB9 // SERVOS + +// +// Limit Switches +// +#if !HAS_WIRED_LCD + #define X_STOP_PIN PB6 + #define Y_STOP_PIN PB5 + #define Z_STOP_PIN PB7 +#endif + +// +// Z Probe must be this pin +// +#define Z_MIN_PROBE_PIN PB8 // PROBE + +// +// Steppers +// +#define X_ENABLE_PIN -1 +#define X_STEP_PIN PA10 // Unused. Assigned so Marlin will compile +#define X_DIR_PIN -1 + +#define Y_ENABLE_PIN -1 +#define Y_STEP_PIN PA10 // Unused. Assigned so Marlin will compile +#define Y_DIR_PIN -1 + +#define Z_ENABLE_PIN -1 +#define Z_STEP_PIN PA10 // Unused. Assigned so Marlin will compile +#define Z_DIR_PIN -1 + +#define E0_ENABLE_PIN PD2 +#define E0_STEP_PIN PD0 +#define E0_DIR_PIN PD1 + +#if HAS_TMC_UART + /** + * TMC220x stepper drivers + * Hardware serial communication ports + */ + //#define E0_HARDWARE_SERIAL MSerial4 + + // This is the stable default value after testing, but, higher UART rates could be configured, remeber to test the Steppers with the M122 command to check if everything works. + //#define TMC_BAUD_RATE 250000 + + #define E0_SERIAL_TX_PIN PA15 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 + + // Default TMC slave addresses + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 0b00 + #endif +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA3 // Analog Input "TH0" + +// SPI for MAX Thermocouple +// Uses a separate SPI bus + +#define TEMP_0_CS_PIN PA4 // GTR K-TEMP +#define TEMP_0_SCK_PIN PA5 // SCK +#define TEMP_0_MISO_PIN PA6 // MISO +#define TEMP_0_MOSI_PIN PA7 // For MAX31865 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA2 // "HE" +#define FAN_PIN PA0 // "FAN0" +#define FAN1_PIN PA1 // "FAN1" + +// +// Default NEOPIXEL_PIN +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PD3 // LED driving pin +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + #define BTN_EN1 PB7 + #define BTN_EN2 PB5 + #define BTN_ENC PB6 +#endif diff --git a/Marlin/src/pins/stm32g0/pins_BTT_MANTA_E3_EZ_V1_0.h b/Marlin/src/pins/stm32g0/pins_BTT_MANTA_E3_EZ_V1_0.h new file mode 100644 index 000000000000..54c2c4c77b2d --- /dev/null +++ b/Marlin/src/pins/stm32g0/pins_BTT_MANTA_E3_EZ_V1_0.h @@ -0,0 +1,340 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 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" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT Manta E3 EZ V1.0" +#endif + +#define USES_DIAG_JUMPERS + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +// +// EEPROM +// +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #undef NO_EEPROM_SELECTED + #ifndef FLASH_EEPROM_EMULATION + #define FLASH_EEPROM_EMULATION + #endif + #define EEPROM_PAGE_SIZE (0x800UL) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE +#endif + +// +// Servos +// +#define SERVO0_PIN PA7 // BLTouch + +// +// Probe enable +// +#if ENABLED(PROBE_ENABLE_DISABLE) + #ifndef PROBE_ENABLE_PIN + #define PROBE_ENABLE_PIN SERVO0_PIN + #endif +#endif + +// +// Trinamic StallGuard pins +// +#define X_DIAG_PIN PC4 // X-STOP +#define Y_DIAG_PIN PB0 // Y-STOP +#define Z_DIAG_PIN PC6 // Z-STOP +#define E0_DIAG_PIN PC5 // E0-DET +#define E1_DIAG_PIN PB1 // E1-DET + +// +// Limit Switches +// +#define X_STOP_PIN X_DIAG_PIN // X-STOP +#define Y_STOP_PIN Y_DIAG_PIN // Y-STOP +#define Z_STOP_PIN Z_DIAG_PIN // Z-STOP + +// +// Z Probe (when not Z_STOP_PIN) +// +#define Z_MIN_PROBE_PIN PA6 // BLTouch + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN E0_DIAG_PIN // E0-DET +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN E1_DIAG_PIN // E1-DET +#endif + +// +// Power Supply Control +// +#ifndef PS_ON_PIN + #define PS_ON_PIN PA9 // PS-ON +#endif + +// +// Power Loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PB9 // PWRDET +#endif + +// +// Steppers +// +#define X_STEP_PIN PA14 +#define X_DIR_PIN PA10 +#define X_ENABLE_PIN PA13 +#ifndef X_CS_PIN + #define X_CS_PIN PB8 +#endif + +#define Y_STEP_PIN PC8 +#define Y_DIR_PIN PA15 +#define Y_ENABLE_PIN PC14 +#ifndef Y_CS_PIN + #define Y_CS_PIN PC9 +#endif + +#define Z_STEP_PIN PD2 +#define Z_DIR_PIN PD4 +#define Z_ENABLE_PIN PD3 +#ifndef Z_CS_PIN + #define Z_CS_PIN PD0 +#endif + +#define E0_STEP_PIN PD5 +#define E0_DIR_PIN PD6 +#define E0_ENABLE_PIN PB3 +#ifndef E0_CS_PIN + #define E0_CS_PIN PD1 +#endif + +#define E1_STEP_PIN PB7 +#define E1_DIR_PIN PB6 +#define E1_ENABLE_PIN PB4 +#ifndef E1_CS_PIN + #define E1_CS_PIN PB5 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PC12 // Shared with SPI header, Pin 5 (SPI3) + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PC11 // Shared with SPI header, Pin 6 (SPI3) + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PC10 // Shared with SPI header, Pin 4 (SPI3) + #endif +#endif + +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN PB8 // X_CS_PIN + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PC9 // Y_CS_PIN + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PD0 // Z_CS_PIN + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PD1 // E0_CS_PIN + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PB5 // E1_CS_PIN + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA4 // Analog Input "TH0" +#define TEMP_1_PIN PA5 // Analog Input "TH1" +#define TEMP_BED_PIN PA3 // Analog Input "TB" + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB11 // "HE0" +#define HEATER_1_PIN PB10 // "HE1" +#define HEATER_BED_PIN PB2 // "HB" + +#define FAN_PIN PA8 // "FAN0" +#define FAN1_PIN PB15 // "FAN1" +#define FAN2_PIN PB14 // "FAN2" + +// +// Auto fans +// +#if HOTENDS == 2 + #ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN FAN1_PIN + #endif + #ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN FAN2_PIN + #endif +#else + #ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN FAN1_PIN + #endif + #ifndef CONTROLLER_FAN_PIN + #define CONTROLLER_FAN_PIN FAN2_PIN + #endif +#endif + +/** + * Manta E3 EZ V1.0 + * ------ + * (BEEPER) PC1 | 1 2 | PC2 (BTN_ENC) + * (BTN_EN1) PC3 | 3 4 | RESET + * (BTN_EN2) PC0 5 6 | PA0 (LCD_D4) + * (LCD_RS) PA2 | 7 8 | PA1 (LCD_EN) + * GND | 9 10 | 5V + * ------ + * EXP1 + */ +#define EXP1_01_PIN PC1 +#define EXP1_02_PIN PC2 +#define EXP1_03_PIN PC3 +#define EXP1_04_PIN -1 +#define EXP1_05_PIN PC0 +#define EXP1_06_PIN PA0 +#define EXP1_07_PIN PA2 +#define EXP1_08_PIN PA1 +#define EXP1_09_PIN -1 +#define EXP1_10_PIN -1 + +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! Ender-3 V2 display requires a custom cable with TX = PA0, RX = PC2. See 'pins_BTT_MANTA_E3_EZ_V1_0.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * Ender-3 V2 display Manta E3 EZ V1.0 Ender-3 V2 display --> Manta E3 EZ V1.0 + * ------ ------ RX 3 --> 5 P0_15 + * -- | 1 2 | -- (BEEPER) PC1 | 1 2 | PC2 (BTN_ENC) TX 4 --> 9 P0_16 + * (MANTA TX1) RX | 3 4 | TX (MANTA RX1) (BTN_EN1) PC3 | 3 4 | RESET BEEPER 6 --> 10 P2_08 + * (BTN_ENC) ENT 5 6 | BEEPER (BTN_EN2) PC0 5 6 | PA0 (LCD_D4) + * (BTN_E2) B | 7 8 | A (BTN_E1) (LCD_RS) PA2 | 7 8 | PA1 (LCD_EN) + * GND | 9 10 | 5V GND | 9 10 | 5V + * ------ ------ + */ + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_05_PIN + +#elif HAS_WIRED_LCD + + #if ENABLED(CR10_STOCKDISPLAY) + + #define BEEPER_PIN EXP1_01_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_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_MANTA_E3_EZ_V1_0.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 PA7 // Repurpose default SERVO0_PIN for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP1_02_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 + + #else + + #error "Only ZONESTAR_LCD, MKS_MINI_12864, ENDER2_STOCKDISPLAY, and CR10_STOCKDISPLAY are currently supported on the BTT_MANTA_E3_EZ_V1_0." + + #endif + +#endif // HAS_WIRED_LCD + +// +// SD Support +// + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#define SD_DETECT_PIN -1 + +#if SD_CONNECTION_IS(LCD) && (BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) || IS_TFTGLCD_PANEL) + #define SD_SS_PIN EXP1_05_PIN +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "SD CUSTOM_CABLE is not compatible with Manta E3 EZ." +#endif + +#define ONBOARD_SPI_DEVICE 3 // SPI3 -> used only by HAL/STM32F1... +#define ONBOARD_SD_CS_PIN PC13 // Chip select for "System" SD card + +#define ENABLE_SPI3 +#define SDSS ONBOARD_SD_CS_PIN +#define SD_SS_PIN ONBOARD_SD_CS_PIN +#define SD_SCK_PIN PC10 +#define SD_MISO_PIN PC11 +#define SD_MOSI_PIN PC12 + +// +// NeoPixel LED +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PC7 // RGB +#endif diff --git a/Marlin/src/pins/stm32g0/pins_BTT_MANTA_M4P_V1_0.h b/Marlin/src/pins/stm32g0/pins_BTT_MANTA_M4P_V1_0.h new file mode 100644 index 000000000000..876475f88355 --- /dev/null +++ b/Marlin/src/pins/stm32g0/pins_BTT_MANTA_M4P_V1_0.h @@ -0,0 +1,313 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 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" + +//#define BOARD_CUSTOM_BUILD_FLAGS -DTONE_CHANNEL=4 -DTONE_TIMER=4 -DTIMER_TONE=4 + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT Manta M4P V1.0" +#endif + +#define USES_DIAG_JUMPERS + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +// +// EEPROM +// +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #undef NO_EEPROM_SELECTED + #ifndef FLASH_EEPROM_EMULATION + #define FLASH_EEPROM_EMULATION + #endif + #define EEPROM_PAGE_SIZE (0x800UL) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE +#endif + +// +// Servos +// +#define SERVO0_PIN PA1 // SERVOS + +// +// Probe enable +// +#if ENABLED(PROBE_ENABLE_DISABLE) + #ifndef PROBE_ENABLE_PIN + #define PROBE_ENABLE_PIN SERVO0_PIN + #endif +#endif + +// +// Limit Switches +// +#define X_STOP_PIN PC0 // X-STOP +#define Y_STOP_PIN PC1 // Y-STOP +#define Z_STOP_PIN PC2 // Z-STOP + +// +// Z Probe must be this pin +// +#define Z_MIN_PROBE_PIN PC14 // PROBE + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PC15 // E0-STOP +#endif + +// +// Steppers +// +#define X_STEP_PIN PC6 +#define X_DIR_PIN PA14 +#define X_ENABLE_PIN PC7 +#ifndef X_CS_PIN + #define X_CS_PIN PB12 +#endif + +#define Y_STEP_PIN PB10 +#define Y_DIR_PIN PB2 +#define Y_ENABLE_PIN PB11 +#ifndef Y_CS_PIN + #define Y_CS_PIN PC10 +#endif + +#define Z_STEP_PIN PB0 +#define Z_DIR_PIN PC5 +#define Z_ENABLE_PIN PB1 +#ifndef Z_CS_PIN + #define Z_CS_PIN PC9 +#endif + +#define E0_STEP_PIN PB3 +#define E0_DIR_PIN PB4 +#define E0_ENABLE_PIN PD5 +#ifndef E0_CS_PIN + #define E0_CS_PIN PA13 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PB15 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PB14 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PB13 + #endif +#endif + +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN PB12 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PC10 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PC9 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PA13 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA0 // Analog Input "TH0" +#define TEMP_BED_PIN PC4 // Analog Input "TB0" + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC8 // "HE" +#define HEATER_BED_PIN PD8 // "HB" + +#define FAN_PIN PD2 // "FAN0" +#define FAN1_PIN PD3 // "FAN1" +#define FAN2_PIN PD4 // "FAN2" + +/** + * ------ ------ + * (BEEPER) PD6 | 1 2 | PB8 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SCK) + * (LCD_EN) PB9 | 3 4 | PC3 (LCD_RS) (BTN_EN1) PC11 | 3 4 | PA8 (SD_SS) + * (LCD_D4) PA15 | 5 6 PA10 (LCD_D5) (BTN_EN2) PC12 | 5 6 PB15 (MOSI) + * (LCD_D6) PA9 | 7 8 | PB5 (LCD_D7) (SD_DETECT) PC13 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PD6 +#define EXP1_02_PIN PB8 +#define EXP1_03_PIN PB9 +#define EXP1_04_PIN PC3 +#define EXP1_05_PIN PA15 +#define EXP1_06_PIN PA10 +#define EXP1_07_PIN PA9 +#define EXP1_08_PIN PB5 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PC11 +#define EXP2_04_PIN PA8 +#define EXP2_05_PIN PC12 +#define EXP2_06_PIN PB15 +#define EXP2_07_PIN PC13 +#define EXP2_08_PIN -1 + +// +// Onboard SD card +// Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 +// +#if SD_CONNECTION_IS(LCD) + #define SDSS EXP2_04_PIN + #define SD_SS_PIN SDSS + #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(ONBOARD) + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 + #define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card + #define SD_SS_PIN ONBOARD_SD_CS_PIN +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#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 + + #elif ENABLED(MKS_MINI_12864) + + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_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 FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + #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 + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 120 + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 80 + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 580 + #endif +#endif + +// +// NeoPixel LED +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PD0 +#endif + +#ifndef NEOPIXEL2_PIN + #define NEOPIXEL2_PIN PD1 +#endif diff --git a/Marlin/src/pins/stm32g0/pins_BTT_MANTA_M5P_V1_0.h b/Marlin/src/pins/stm32g0/pins_BTT_MANTA_M5P_V1_0.h new file mode 100644 index 000000000000..f4ce5a16d3b0 --- /dev/null +++ b/Marlin/src/pins/stm32g0/pins_BTT_MANTA_M5P_V1_0.h @@ -0,0 +1,341 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 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" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT Manta M5P V1.0" +#endif + +#define USES_DIAG_JUMPERS + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +// +// EEPROM +// +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #undef NO_EEPROM_SELECTED + #ifndef FLASH_EEPROM_EMULATION + #define FLASH_EEPROM_EMULATION + #endif + #define EEPROM_PAGE_SIZE (0x800UL) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE +#endif + +// +// Servos +// +#define SERVO0_PIN PC15 // PROBE + +// +// Probe enable +// +#if ENABLED(PROBE_ENABLE_DISABLE) + #ifndef PROBE_ENABLE_PIN + #define PROBE_ENABLE_PIN SERVO0_PIN + #endif +#endif + +// +// Trinamic StallGuard pins +// +#define X_DIAG_PIN PD3 // MIN1 +#define Y_DIAG_PIN PD2 // MIN2 +#define Z_DIAG_PIN PC3 // MIN3 +#define E0_DIAG_PIN PC2 // MIN4 +#define E1_DIAG_PIN -1 + +// +// Limit Switches +// +#define X_STOP_PIN X_DIAG_PIN // MIN1 +#define Y_STOP_PIN Y_DIAG_PIN // MIN1 +#define Z_STOP_PIN Z_DIAG_PIN // MIN3 + +// +// Z Probe (when not Z_STOP_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PC13 // PROBE + //#define Z_MIN_PROBE_PIN PC15 // IND-DET (with adjustable pullup set via jumper) +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN E0_DIAG_PIN // MIN4 +#endif + +// +// Steppers +// +#define X_STEP_PIN PC8 +#define X_DIR_PIN PC9 +#define X_ENABLE_PIN PA15 +#ifndef X_CS_PIN + #define X_CS_PIN PD9 +#endif + +#define Y_STEP_PIN PA10 +#define Y_DIR_PIN PA14 +#define Y_ENABLE_PIN PA13 +#ifndef Y_CS_PIN + #define Y_CS_PIN PD8 +#endif + +#define Z_STEP_PIN PC6 +#define Z_DIR_PIN PC7 +#define Z_ENABLE_PIN PA9 +#ifndef Z_CS_PIN + #define Z_CS_PIN PB10 +#endif + +#define E0_STEP_PIN PB12 +#define E0_DIR_PIN PB11 +#define E0_ENABLE_PIN PA8 +#ifndef E0_CS_PIN + #define E0_CS_PIN PB2 +#endif + +#define E1_STEP_PIN PB0 +#define E1_DIR_PIN PB1 +#define E1_ENABLE_PIN PC4 +#ifndef E1_CS_PIN + #define E1_CS_PIN PA6 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PB15 // Shared with SPI header, Pin 5 (SPI2) + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PB14 // Shared with SPI header, Pin 6 (SPI2) + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PB13 // Shared with SPI header, Pin 4 (SPI2) + #endif +#endif + +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN PD9 // X_CS_PIN + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PD8 // Y_CS_PIN + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PB10 // Z_CS_PIN + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PB2 // E0_CS_PIN + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PA6 // E1_CS_PIN + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA1 // Analog Input "TH0" +#define TEMP_1_PIN PA2 // Analog Input "TH1" +#define TEMP_BED_PIN PA0 // Analog Input "TB" + +// +// Heaters / Fans +// +#define HEATER_0_PIN PC5 // "HE0" +#define HEATER_1_PIN PA7 // "HE1" +#define HEATER_BED_PIN PA5 // "HB" + +#define FAN_PIN PA4 // "FAN0" +#define FAN1_PIN PA3 // "FAN1" + +// +// Auto fans +// +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN FAN1_PIN +#endif + +/** + * ------ ------ + * (BEEPER) PD5 | 1 2 | PD4 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SCK) + * (LCD_EN) PB3 | 3 4 | PD6 (LCD_RS) (BTN_EN1) PB8 | 3 4 | PB9 (SD_SS) + * (LCD_D4) PB5 | 5 6 PB4 (LCD_D5) (BTN_EN2) PC10 | 5 6 PB15 (MOSI) + * (LCD_D6) PB7 | 7 8 | PB6 (LCD_D7) (SD_DETECT) PC12 | 7 8 | PF2 + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PD5 +#define EXP1_02_PIN PD4 +#define EXP1_03_PIN PB3 +#define EXP1_04_PIN PD6 +#define EXP1_05_PIN PB5 +#define EXP1_06_PIN PB4 +#define EXP1_07_PIN PB7 +#define EXP1_08_PIN PB6 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PB8 +#define EXP2_04_PIN PB9 +#define EXP2_05_PIN PC10 +#define EXP2_06_PIN PB15 +#define EXP2_07_PIN PC12 +#define EXP2_08_PIN -1 + +// +// Onboard SD card +// Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 +// +#if SD_CONNECTION_IS(LCD) + #define SDSS EXP2_04_PIN + #define SD_SS_PIN SDSS + #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(ONBOARD) + #define SD_SCK_PIN PB13 + #define SD_MISO_PIN PB14 + #define SD_MOSI_PIN PB15 + #define ONBOARD_SD_CS_PIN PC1 // Chip select for "System" SD card + #define SD_SS_PIN ONBOARD_SD_CS_PIN +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#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 + + #elif ENABLED(MKS_MINI_12864) + + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_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 FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + #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 + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 120 + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 80 + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 580 + #endif +#endif + +// +// NeoPixel LED +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PC11 // RGB1 +#endif + +#ifndef NEOPIXEL2_PIN + #define NEOPIXEL2_PIN PC14 // RGB2 +#endif diff --git a/Marlin/src/pins/stm32g0/pins_BTT_MANTA_M8P_V1_0.h b/Marlin/src/pins/stm32g0/pins_BTT_MANTA_M8P_V1_0.h new file mode 100644 index 000000000000..4f8d30b6b7fa --- /dev/null +++ b/Marlin/src/pins/stm32g0/pins_BTT_MANTA_M8P_V1_0.h @@ -0,0 +1,79 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 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 common Manta M8P pins +#include "pins_BTT_MANTA_M8P_common.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT Manta M8P V1.0" +#endif + +// +// Steppers +// + +#define E1_STEP_PIN PA10 // M6 +#define E1_DIR_PIN PD15 +#define E1_ENABLE_PIN PA15 +#ifndef E1_CS_PIN + #define E1_CS_PIN PF8 +#endif + +#define E2_STEP_PIN PD12 // M7 +#define E2_DIR_PIN PD11 +#define E2_ENABLE_PIN PD14 +#ifndef E2_CS_PIN + #define E2_CS_PIN PD13 +#endif + +#define E3_STEP_PIN PD10 // M8 +#define E3_DIR_PIN PD8 +#define E3_ENABLE_PIN PD9 +#ifndef E3_CS_PIN + #define E3_CS_PIN PC7 +#endif + +#if HAS_TMC_UART + #define E1_SERIAL_TX_PIN PF8 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + #define E2_SERIAL_TX_PIN PD13 + #define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN + + #define E3_SERIAL_TX_PIN PC7 + #define E3_SERIAL_RX_PIN E3_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// NeoPixel LED +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PC6 +#endif + +#ifndef NEOPIXEL2_PIN + #define NEOPIXEL2_PIN PA9 +#endif diff --git a/Marlin/src/pins/stm32g0/pins_BTT_MANTA_M8P_V1_1.h b/Marlin/src/pins/stm32g0/pins_BTT_MANTA_M8P_V1_1.h new file mode 100644 index 000000000000..a21bb59e69c3 --- /dev/null +++ b/Marlin/src/pins/stm32g0/pins_BTT_MANTA_M8P_V1_1.h @@ -0,0 +1,78 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 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 common Manta M8P pins +#include "pins_BTT_MANTA_M8P_common.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT Manta M8P V1.1" +#endif + +// +// Steppers +// +#define E1_STEP_PIN PA10 // M6 +#define E1_DIR_PIN PA14 +#define E1_ENABLE_PIN PA15 +#ifndef E1_CS_PIN + #define E1_CS_PIN PF8 +#endif + +#define E2_STEP_PIN PD11 // M7 +#define E2_DIR_PIN PD9 +#define E2_ENABLE_PIN PD15 +#ifndef E2_CS_PIN + #define E2_CS_PIN PD14 +#endif + +#define E3_STEP_PIN PD8 // M8 +#define E3_DIR_PIN PC6 +#define E3_ENABLE_PIN PC7 +#ifndef E3_CS_PIN + #define E3_CS_PIN PD10 +#endif + +#if HAS_TMC_UART + #define E1_SERIAL_TX_PIN PF8 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + #define E2_SERIAL_TX_PIN PD14 + #define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN + + #define E3_SERIAL_TX_PIN PD10 + #define E3_SERIAL_RX_PIN E3_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// NeoPixel LED +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PA9 +#endif + +#ifndef NEOPIXEL2_PIN + #define NEOPIXEL2_PIN PB15 +#endif diff --git a/Marlin/src/pins/stm32g0/pins_BTT_MANTA_M8P_common.h b/Marlin/src/pins/stm32g0/pins_BTT_MANTA_M8P_common.h new file mode 100644 index 000000000000..6516538c4402 --- /dev/null +++ b/Marlin/src/pins/stm32g0/pins_BTT_MANTA_M8P_common.h @@ -0,0 +1,394 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 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" + +//#define BOARD_CUSTOM_BUILD_FLAGS -DTONE_CHANNEL=4 -DTONE_TIMER=4 -DTIMER_TONE=4 + +#define USES_DIAG_JUMPERS + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +// +// EEPROM +// +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #undef NO_EEPROM_SELECTED + #ifndef FLASH_EEPROM_EMULATION + #define FLASH_EEPROM_EMULATION + #endif + #define EEPROM_PAGE_SIZE (0x800UL) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE +#endif + +// +// Servos +// +#define SERVO0_PIN PB1 // PROBE + +// +// Probe enable +// +#if ENABLED(PROBE_ENABLE_DISABLE) + #ifndef PROBE_ENABLE_PIN + #define PROBE_ENABLE_PIN SERVO0_PIN + #endif +#endif + +// +// Trinamic Stallguard pins +// +#define X_DIAG_PIN PF3 // MIN1 +#define Y_DIAG_PIN PF4 // MIN2 +#define Z_DIAG_PIN PF5 // MIN3 +#define Z2_DIAG_PIN PC0 // MIN4 +#define E0_DIAG_PIN PC1 // MIN5 +#define E1_DIAG_PIN PC2 // MIN6 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PB2 // PROBE + //#define Z_MIN_PROBE_PIN PF6 // IND-PROBE (with adjustable voltage & pullup set via jumpers) +#endif + +// +// 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 + #endif + #if _ENDSTOP_IS_ANY(_YMIN_) || _ENDSTOP_IS_ANY(_YMAX_) + #define NEEDS_Y_MINMAX + #endif + #undef _ENDSTOP_IS_ANY +#endif + +// +// Limit Switches +// +#ifdef X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN + #if X_HOME_TO_MIN + #define X_MAX_PIN E0_DIAG_PIN // MIN5 + #else + #define X_MIN_PIN E0_DIAG_PIN // MIN5 + #endif +#elif EITHER(DUAL_X_CARRIAGE, NEEDS_X_MINMAX) + #ifndef X_MIN_PIN + #define X_MIN_PIN X_DIAG_PIN // MIN1 + #endif + #ifndef X_MAX_PIN + #define X_MAX_PIN E0_DIAG_PIN // MIN5 + #endif +#else + #define X_STOP_PIN X_DIAG_PIN // MIN1 +#endif + +#ifdef Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN + #if Y_HOME_TO_MIN + #define Y_MAX_PIN E1_DIAG_PIN // MIN6 + #else + #define Y_MIN_PIN E1_DIAG_PIN // MIN6 + #endif +#elif ENABLED(NEEDS_Y_MINMAX) + #ifndef Y_MIN_PIN + #define Y_MIN_PIN Y_DIAG_PIN // MIN2 + #endif + #ifndef Y_MAX_PIN + #define Y_MAX_PIN E1_DIAG_PIN // MIN6 + #endif +#else + #define Y_STOP_PIN Y_DIAG_PIN // MIN2 +#endif + +#define Z_STOP_PIN Z_DIAG_PIN // MIN3 + +// +// Filament Runout Sensors +// +#define FIL_RUNOUT_PIN PC1 // MIN5 +#define FIL_RUNOUT2_PIN PC2 // MIN6 + +#ifndef PS_ON_PIN + #define PS_ON_PIN PC3 // PS-ON +#endif + +// +// Steppers +// +#define X_STEP_PIN PE2 // M1 +#define X_DIR_PIN PB4 +#define X_ENABLE_PIN PC11 +#ifndef X_CS_PIN + #define X_CS_PIN PC10 +#endif + +#define Y_STEP_PIN PF12 // M2 +#define Y_DIR_PIN PF11 +#define Y_ENABLE_PIN PB3 +#ifndef Y_CS_PIN + #define Y_CS_PIN PF13 +#endif + +#define Z_STEP_PIN PD7 // M3 +#define Z_DIR_PIN PD6 +#define Z_ENABLE_PIN PF10 +#ifndef Z_CS_PIN + #define Z_CS_PIN PF9 +#endif + +#define Z2_STEP_PIN PD3 // M4 +#define Z2_DIR_PIN PD2 +#define Z2_ENABLE_PIN PD5 +#ifndef Z2_CS_PIN + #define Z2_CS_PIN PD4 +#endif + +#define E0_STEP_PIN PC9 // M5 +#define E0_DIR_PIN PC8 +#define E0_ENABLE_PIN PD1 +#ifndef E0_CS_PIN + #define E0_CS_PIN PD0 +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PA7 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PA6 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PA5 + #endif +#endif + +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN PC10 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PF13 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PF9 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define Z2_SERIAL_TX_PIN PD4 + #define Z2_SERIAL_RX_PIN Z2_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PD0 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PA0 // TB +#define TEMP_0_PIN PA1 // TH0 +#define TEMP_1_PIN PA2 // TH1 +#define TEMP_2_PIN PA3 // TH2 +#define TEMP_3_PIN PA4 // TH3 + +// +// Heaters / Fans +// +#define HEATER_BED_PIN PB7 // BED-OUT +#define HEATER_0_PIN PE3 // HE0 +#define HEATER_1_PIN PB5 // HE1 +#define HEATER_2_PIN PB6 // HE2 +#define HEATER_3_PIN PE1 // HE3 + +#define FAN_PIN PE6 // FAN0 +#define FAN1_PIN PE0 // FAN1 +#define FAN2_PIN PC12 // FAN2 +#define FAN3_PIN PE5 // FAN3 +#define FAN4_PIN PE4 // FAN4 +#define FAN5_PIN PB8 // FAN5 +#define FAN6_PIN PB9 // FAN6 + +// +// SD Support +// +#ifndef SDCARD_CONNECTION + #if HAS_WIRED_LCD + #define SDCARD_CONNECTION LCD + #else + #define SDCARD_CONNECTION ONBOARD + #endif +#endif + +/** + * ------ ------ + * (BEEPER) PE9 | 1 2 | PE10 (BTN_ENC) (MISO) PB14 | 1 2 | PB13 (SCK) + * (LCD_EN) PE11 | 3 4 | PE12 (LCD_RS) (BTN_EN1) PF7 | 3 4 | PB12 (SD_SS) + * (LCD_D4) PE13 | 5 6 PE14 (LCD_D5) (BTN_EN2) PE7 | 5 6 PB11 (MOSI) + * (LCD_D6) PE15 | 7 8 | PB10 (LCD_D7) (SD_DETECT) PE8 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PE9 +#define EXP1_02_PIN PE10 +#define EXP1_03_PIN PE11 +#define EXP1_04_PIN PE12 +#define EXP1_05_PIN PE13 +#define EXP1_06_PIN PE14 +#define EXP1_07_PIN PE15 +#define EXP1_08_PIN PB10 + +#define EXP2_01_PIN PB14 +#define EXP2_02_PIN PB13 +#define EXP2_03_PIN PF7 +#define EXP2_04_PIN PB12 +#define EXP2_05_PIN PE7 +#define EXP2_06_PIN PB11 +#define EXP2_07_PIN PE8 +#define EXP2_08_PIN -1 + +// +// Onboard SD card +// Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 +// +#if SD_CONNECTION_IS(LCD) + #define SDSS EXP2_04_PIN + #define SD_SS_PIN SDSS + #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(ONBOARD) + #define SD_DETECT_PIN PE8 + #define SD_SCK_PIN PB13 + #define SD_MISO_PIN PB14 + #define SD_MOSI_PIN PB11 + #define ONBOARD_SD_CS_PIN PB14 // Chip select for "System" SD card + #define SD_SS_PIN ONBOARD_SD_CS_PIN +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#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 + + #elif ENABLED(MKS_MINI_12864) + + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_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 FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + + #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 + #ifndef BOARD_ST7920_DELAY_1 + #define BOARD_ST7920_DELAY_1 120 + #endif + #ifndef BOARD_ST7920_DELAY_2 + #define BOARD_ST7920_DELAY_2 80 + #endif + #ifndef BOARD_ST7920_DELAY_3 + #define BOARD_ST7920_DELAY_3 580 + #endif +#endif 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 769f10c8a48b..f71b7b40ebd1 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 @@ -21,6 +21,8 @@ */ #pragma once +#include "env_validate.h" + //#define BOARD_CUSTOM_BUILD_FLAGS -DTONE_CHANNEL=4 -DTONE_TIMER=4 -DTIMER_TONE=4 #ifndef BOARD_INFO_NAME @@ -75,10 +77,6 @@ #define POWER_LOSS_PIN PC12 // Power Loss Detection: PWR-DET #endif -#ifndef NEOPIXEL_PIN - #define NEOPIXEL_PIN PA8 // LED driving pin -#endif - #ifndef PS_ON_PIN #define PS_ON_PIN PC13 // Power Supply Control #endif @@ -145,25 +143,33 @@ /** * SKR Mini E3 V3.0 * ------ - * (BEEPER) PB5 |10 9 | PA15 (BTN_ENC) - * (BTN_EN1) PA9 | 8 7 | RESET - * (BTN_EN2) PA10 6 5 | PB9 (LCD_D4) - * (LCD_RS) PB8 | 4 3 | PD6 (LCD_EN) - * GND | 2 1 | 5V + * (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 | PD6 (LCD_EN) + * GND | 9 10 | 5V * ------ * EXP1 */ -#define EXP1_09_PIN PA15 -#define EXP1_03_PIN PD6 +#define EXP1_01_PIN PB5 +#define EXP1_02_PIN PA15 +#define EXP1_03_PIN PA9 +#define EXP1_04_PIN -1 +#define EXP1_05_PIN PA10 +#define EXP1_06_PIN PB9 +#define EXP1_07_PIN PB8 +#define EXP1_08_PIN PD6 +#define EXP1_09_PIN -1 +#define EXP1_10_PIN -1 #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI /** * ------ ------ ------ - * (ENT) |10 9 | (BEEP) |10 9 | |10 9 | - * (RX) | 8 7 | (RX) | 8 7 | (TX) RX | 8 7 | TX - * (TX) 6 5 | (ENT) 6 5 | (BEEP) ENT | 6 5 | BEEP - * (B) | 4 3 | (A) (B) | 4 3 | (A) B | 4 3 | A - * GND | 2 1 | (VCC) GND | 2 1 | VCC GND | 2 1 | VCC + * (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) * @@ -174,116 +180,158 @@ #error "CAUTION! DWIN_CREALITY_LCD requires a custom cable, see diagram above this line. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" #endif - #define BEEPER_PIN EXP1_09_PIN - #define BTN_EN1 EXP1_03_PIN - #define BTN_EN2 PB8 - #define BTN_ENC PB5 + #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 PB5 - #define BTN_ENC EXP1_09_PIN - - #define BTN_EN1 PA9 - #define BTN_EN2 PA10 - - #define LCD_PINS_RS PB8 - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 PB9 - - #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.)" + #if ENABLED(SKR_MINI_SCREEN_ADAPTER) + /** https://github.com/VoronDesign/Voron-Hardware/tree/master/SKR-Mini_Screen_Adaptor/SRK%20Mini%20E3%20V3.0 + * + * SKR Mini E3 V3.0 SKR Mini Screen Adaptor + * ------ ------ + * 5V | 1 2 | GND MISO | 1 2 | SCK + * CS | 3 4 | SCK (EN1) PA10 | 3 4 | -- + * MOSI | 5 6 | MISO (EN2) PA9 5 6 | MOSI + * 3V3 | 7 8 | GND -- | 7 8 | -- + * ------ GND | 9 10| RESET (Kill) + * SPI ------ + * EXP2 + * + * ------ ------ + * PB5 | 1 2 | PA15 -- | 1 2 | PB5 (BTN_ENC) + * PA9 | 3 4 | RESET (LCD CS) PB8 | 3 4 | PD6 (LCD_A0) + * PA10 5 6 | PB9 (RESET) PB9 5 6 | PA15 (DIN) + * PB8 | 7 8 | PD6 -- | 7 8 | -- + * GND | 9 10| 5V GND | 9 10| 5V + * ------ ------ + * EXP1 EXP1 + */ + #if ENABLED(FYSETC_MINI_12864_2_1) + #define BTN_ENC EXP1_01_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define BEEPER_PIN -1 + #define LCD_RESET_PIN EXP1_06_PIN + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_08_PIN + #define DOGLCD_SCK PA5 + #define DOGLCD_MOSI PA7 + + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + #define NEOPIXEL_PIN EXP1_02_PIN + #else + #error "Only CR10_FYSETC_MINI_12864_2_1 and compatibles are currently supported on the BIGTREE_SKR_MINI_E3 with SKR_MINI_SCREEN_ADAPTER" #endif - #define LCD_PINS_RS PB9 - #define LCD_PINS_ENABLE EXP1_09_PIN - #define LCD_PINS_D4 PB8 - #define LCD_PINS_D5 PA10 - #define LCD_PINS_D6 PA9 - #define LCD_PINS_D7 PB5 - #define ADC_KEYPAD_PIN PA1 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! - - #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) + #else - #define BTN_ENC EXP1_09_PIN - #define BTN_EN1 PA9 - #define BTN_EN2 PA10 + #if ENABLED(CR10_STOCKDISPLAY) - #define DOGLCD_CS PB8 - #define DOGLCD_A0 PB9 - #define DOGLCD_SCK PB5 - #define DOGLCD_MOSI EXP1_03_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN - #define FORCE_SOFT_SPI - #define LCD_BACKLIGHT_PIN -1 + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #elif IS_TFTGLCD_PANEL + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN - #if ENABLED(TFTGLCD_PANEL_SPI) + #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! 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.)" + #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 - /** - * TFTGLCD_PANEL_SPI display pinout - * - * Board Display - * ------ ------ - * (BEEPER) PB6 |10 9 | PB5 (SD_DET) 5V |10 9 | GND - * RESET | 8 7 | PA9 (MOD_RESET) -- | 8 7 | (SD_DET) - * PB9 6 5 | PA10 (SD_CS) (MOSI) | 6 5 | -- - * PB7 | 4 3 | PB8 (LCD_CS) (SD_CS) | 4 3 | (LCD_CS) - * GND | 2 1 | 5V (SCK) | 2 1 | (MISO) - * ------ ------ - * EXP1 EXP1 - * - * Needs custom cable: - * - * Board Display - * - * EXP1-1 ----------- EXP1-10 - * EXP1-2 ----------- EXP1-9 - * SPI1-4 ----------- EXP1-6 - * EXP1-4 ----------- FREE - * SPI1-3 ----------- EXP1-2 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- FREE - * EXP1-8 ----------- EXP1-3 - * SPI1-1 ----------- EXP1-1 - * EXP1-10 ----------- EXP1-7 - */ - - #define TFTGLCD_CS PA9 + #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 | PB5 (SD_DET) 5V |10 9 | GND + * RESET | 3 4 | PA9 (MOD_RESET) -- | 8 7 | (SD_DET) + * PB9 5 6 | PA10 (SD_CS) (MOSI) | 6 5 | -- + * PB7 | 7 8 | PB8 (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 5V + * EXP1-9 ------------ EXP1-9 GND + * SPI1-4 ------------ EXP1-6 MOSI + * EXP1-7 ------------ n/c + * SPI1-3 ------------ EXP1-2 SCK + * EXP1-5 ------------ EXP1-4 SD_CS + * EXP1-4 ------------ n/c + * EXP1-3 ------------ EXP1-3 LCD_CS + * SPI1-1 ------------ EXP1-1 MISO + * EXP1-1 ------------ EXP1-7 SD_DET + */ + + #define TFTGLCD_CS EXP1_03_PIN - #endif + #endif - #elif ENABLED(FYSETC_MINI_12864_2_1) + #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 /** * * Board Display * ------ ------ - * (EN2) PB5 |10 9 | PA15(BTN_ENC) 5V |10 9 | GND - * (LCD_CS) PA9 | 8 7 | RST (RESET) -- | 8 7 | -- - * (LCD_A0) PA10 |#6 5 | PB9 (EN1) (DIN) | 6 5#| (RESET) - * (LCD_SCK)PB8 | 4 3 | PD6 (MOSI) (LCD_A0) | 4 3 | (LCD_CS) - * GND | 2 1 | 5V (BTN_ENC) | 2 1 | -- + * (EN2) PB5 | 1 2 | PA15(BTN_ENC) 5V |10 9 | GND + * (LCD_CS) PA9 | 3 4 | RST (RESET) -- | 8 7 | -- + * (LCD_A0) PA10 5 6 | PB9 (EN1) (DIN) | 6 5 (RESET) + * (LCD_SCK)PB8 | 7 8 | PD6 (MOSI) (LCD_A0) | 4 3 | (LCD_CS) + * GND | 9 10 | 5V (BTN_ENC) | 2 1 | -- * ------ ------ * EXP1 EXP1 * * ------ * -- |10 9 | -- * --- (RESET) | 8 7 | -- - * | 3 | (MOSI) | 6 5#| (EN2) + * | 3 | (MOSI) | 6 5 (EN2) * | 2 | (DIN) -- | 4 3 | (EN1) * | 1 | (LCD_SCK)| 2 1 | -- * --- ------ @@ -291,25 +339,27 @@ * * Needs custom cable. Connect EN2-EN2, LCD_CS-LCD_CS and so on. * - * Check twice index position!!! (marked as # here) + * Check the index/notch position twice!!! * On BTT boards pins from IDC10 connector are numbered in unusual order. */ - #define BTN_ENC EXP1_09_PIN - #define BTN_EN1 PB9 - #define BTN_EN2 PB5 - #define BEEPER_PIN -1 + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_06_PIN + #define BTN_EN2 EXP1_01_PIN + #define BEEPER_PIN -1 - #define DOGLCD_CS PA9 - #define DOGLCD_A0 PA10 - #define DOGLCD_SCK PB8 - #define DOGLCD_MOSI PD6 + #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 FORCE_SOFT_SPI - #define LCD_BACKLIGHT_PIN -1 + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 - #else - #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, FYSETC_MINI_12864_2_1, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BIGTREE_SKR_MINI_E3." - #endif + #else + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, FYSETC_MINI_12864_2_1, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BIGTREE_SKR_MINI_E3." + #endif + + #endif // SKR_MINI_SCREEN_ADAPTER #endif // HAS_WIRED_LCD @@ -324,37 +374,36 @@ * * Board Display * ------ ------ - * (SD_DET) PB5 |10 9 | PB6 (BEEPER) 5V |10 9 | GND - * (MOD_RESET) PA9 | 8 7 | RESET (RESET) | 8 7 | (SD_DET) - * (SD_CS) PA10 6 5 | PB9 (FREE) (MOSI) | 6 5 | (LCD_CS) - * (LCD_CS) PB8 | 4 3 | PB7 (FREE) (SD_CS) | 4 3 | (MOD_RESET) - * 5V | 2 1 | GND (SCK) | 2 1 | (MISO) + * (SD_DET) PB5 | 1 2 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 3 4 | RESET (RESET) | 8 7 | (SD_DET) + * (SD_CS) PA10 5 6 | PB9 (FREE) (MOSI) | 6 5 | (LCD_CS) + * (LCD_CS) PB8 | 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-1 ----------- EXP1-10 - * EXP1-2 ----------- EXP1-9 - * SPI1-4 ----------- EXP1-6 - * EXP1-4 ----------- EXP1-5 - * SPI1-3 ----------- EXP1-2 - * EXP1-6 ----------- EXP1-4 - * EXP1-7 ----------- EXP1-8 - * EXP1-8 ----------- EXP1-3 - * SPI1-1 ----------- EXP1-1 - * EXP1-10 ----------- EXP1-7 + * ---------------------------------- + * EXP1-10 ----------- EXP1-10 5V + * EXP1-9 ------------ EXP1-9 GND + * SPI1-4 ------------ EXP1-6 MOSI + * EXP1-7 ------------ EXP1-5 LCD_CS + * SPI1-3 ------------ EXP1-2 SCK + * EXP1-5 ------------ EXP1-4 SD_CS + * EXP1-4 ------------ EXP1-8 RESET + * EXP1-3 ------------ EXP1-3 MOD_RST + * SPI1-1 ------------ EXP1-1 MISO + * EXP1-1 ------------ EXP1-7 SD_DET */ #define CLCD_SPI_BUS 1 // SPI1 connector - #define BEEPER_PIN EXP1_09_PIN - - #define CLCD_MOD_RESET PA9 - #define CLCD_SPI_CS PB8 + #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 // @@ -368,8 +417,8 @@ #if SD_CONNECTION_IS(ONBOARD) #define SD_DETECT_PIN PC3 #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 @@ -383,3 +432,10 @@ #define SD_SCK_PIN PA5 #define SD_MISO_PIN PA6 #define SD_MOSI_PIN PA7 + +// +// Default NEOPIXEL_PIN +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PA8 // LED driving pin +#endif diff --git a/Marlin/src/pins/stm32h7/env_validate.h b/Marlin/src/pins/stm32h7/env_validate.h new file mode 100644 index 000000000000..0c515e5df6be --- /dev/null +++ b/Marlin/src/pins/stm32h7/env_validate.h @@ -0,0 +1,26 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 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 + +#if NOT_TARGET(STM32H7) + #error "Oops! Select an STM32H7 board in 'Tools > Board.'" +#endif diff --git a/Marlin/src/pins/stm32h7/pins_BTT_OCTOPUS_MAX_EZ.h b/Marlin/src/pins/stm32h7/pins_BTT_OCTOPUS_MAX_EZ.h new file mode 100644 index 000000000000..13e30591ba6a --- /dev/null +++ b/Marlin/src/pins/stm32h7/pins_BTT_OCTOPUS_MAX_EZ.h @@ -0,0 +1,547 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 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" + +#define BOARD_INFO_NAME "OCTOPUS MAX EZ V1.0" + +#define USES_DIAG_JUMPERS + +// 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 PB10 + #define I2C_SDA_PIN PB11 + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#endif + +// Avoid conflict with TIMER_TONE +#define STEP_TIMER 8 + +// +// Servos +// +#define SERVO0_PIN PB14 + +// +// Misc. Functions +// +#define LED_PIN PA14 + +// +// Trinamic Stallguard pins +// +#define X_DIAG_PIN PF0 // M1-STOP +#define Y_DIAG_PIN PF2 // M2-STOP +#define Z_DIAG_PIN PF4 // M3-STOP +#define Z2_DIAG_PIN PF3 // M4-STOP +#define E0_DIAG_PIN PF1 // M5-STOP +#define E1_DIAG_PIN PC15 // M6-STOP +#define E2_DIAG_PIN PF12 // PWRDET + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PB15 +#endif + +// +// 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 + #endif + #if _ENDSTOP_IS_ANY(_YMIN_) || _ENDSTOP_IS_ANY(_YMAX_) + #define NEEDS_Y_MINMAX + #endif + #if _ENDSTOP_IS_ANY(_ZMIN_) || _ENDSTOP_IS_ANY(_ZMAX_) + #define NEEDS_Z_MINMAX + #endif + #undef _ENDSTOP_IS_ANY +#endif + +// +// Limit Switches +// +#ifdef X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN + #if X_HOME_TO_MIN + #define X_MAX_PIN E0_DIAG_PIN // E0DET + #else + #define X_MIN_PIN E0_DIAG_PIN // E0DET + #endif +#elif EITHER(DUAL_X_CARRIAGE, NEEDS_X_MINMAX) + #ifndef X_MIN_PIN + #define X_MIN_PIN X_DIAG_PIN // X-STOP + #endif + #ifndef X_MAX_PIN + #define X_MAX_PIN E0_DIAG_PIN // E0DET + #endif +#else + #define X_STOP_PIN X_DIAG_PIN // X-STOP +#endif + +#ifdef Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN + #if Y_HOME_TO_MIN + #define Y_MAX_PIN E1_DIAG_PIN // E1DET + #else + #define Y_MIN_PIN E1_DIAG_PIN // E1DET + #endif +#elif ENABLED(NEEDS_Y_MINMAX) + #ifndef Y_MIN_PIN + #define Y_MIN_PIN Y_DIAG_PIN // Y-STOP + #endif + #ifndef Y_MAX_PIN + #define Y_MAX_PIN E1_DIAG_PIN // E1DET + #endif +#else + #define Y_STOP_PIN Y_DIAG_PIN // Y-STOP +#endif + +#ifdef Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN + #if Z_HOME_TO_MIN + #define Z_MAX_PIN E2_DIAG_PIN // PWRDET + #else + #define Z_MIN_PIN E2_DIAG_PIN // PWRDET + #endif +#elif ENABLED(NEEDS_Z_MINMAX) + #ifndef Z_MIN_PIN + #define Z_MIN_PIN Z_DIAG_PIN // Z-STOP + #endif + #ifndef Z_MAX_PIN + #define Z_MAX_PIN E2_DIAG_PIN // PWRDET + #endif +#else + #define Z_STOP_PIN Z_DIAG_PIN // Z-STOP +#endif + +// +// Filament Runout Sensor +// +#define FIL_RUNOUT_PIN PF1 // E0DET +#define FIL_RUNOUT2_PIN PF15 // E1DET + +// +// Power Supply Control +// +#ifndef PS_ON_PIN + #define PS_ON_PIN PF13 // PS-ON +#endif + +// +// Power Loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PF12 // PWRDET +#endif + +// +// Steppers +// +#define X_STEP_PIN PC13 // MOTOR 1 +#define X_DIR_PIN PC14 +#define X_ENABLE_PIN PE6 +#ifndef X_CS_PIN + #define X_CS_PIN PG14 +#endif + +#define Y_STEP_PIN PE4 // MOTOR 2 +#define Y_DIR_PIN PE5 +#define Y_ENABLE_PIN PE3 +#ifndef Y_CS_PIN + #define Y_CS_PIN PG13 +#endif + +#define Z_STEP_PIN PE1 // MOTOR 3 +#define Z_DIR_PIN PE0 +#define Z_ENABLE_PIN PE2 +#ifndef Z_CS_PIN + #define Z_CS_PIN PG12 +#endif + +#define Z2_STEP_PIN PB8 // MOTOR 4 +#define Z2_DIR_PIN PB9 +#define Z2_ENABLE_PIN PB7 +#ifndef Z2_CS_PIN + #define Z2_CS_PIN PG11 +#endif + +#define E0_STEP_PIN PB5 // MOTOR 5 +#define E0_DIR_PIN PB4 +#define E0_ENABLE_PIN PB6 +#ifndef E0_CS_PIN + #define E0_CS_PIN PG10 +#endif + +#define E1_STEP_PIN PG15 // MOTOR 6 +#define E1_DIR_PIN PB3 +#define E1_ENABLE_PIN PD5 +#ifndef E1_CS_PIN + #define E1_CS_PIN PG9 +#endif + +#define E2_STEP_PIN PD3 // MOTOR 7 +#define E2_DIR_PIN PD2 +#define E2_ENABLE_PIN PD4 +#ifndef E2_CS_PIN + #define E2_CS_PIN PD7 +#endif + +#define E3_STEP_PIN PA10 // MOTOR 8 +#define E3_DIR_PIN PA9 +#define E3_ENABLE_PIN PA15 +#ifndef E3_CS_PIN + #define E3_CS_PIN PD6 +#endif + +#define E4_STEP_PIN PA8 // MOTOR 9 +#define E4_DIR_PIN PC7 +#define E4_ENABLE_PIN PC9 +#ifndef E4_CS_PIN + #define E4_CS_PIN PG8 +#endif + +#define E5_STEP_PIN PG6 // MOTOR 10 +#define E5_DIR_PIN PC6 +#define E5_ENABLE_PIN PC8 +#ifndef E5_CS_PIN + #define E5_CS_PIN PG7 +#endif + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PB1 // TB +#define TEMP_0_PIN PB0 // TH0 +#define TEMP_1_PIN PC5 // TH1 +#define TEMP_2_PIN PC4 // TH2 +#define TEMP_3_PIN PA7 // TH3 + +// +// Heaters / Fans +// +#define HEATER_BED_PIN PF5 // Hotbed +#define HEATER_0_PIN PF6 // Heater0 +#define HEATER_1_PIN PA0 // Heater1 +#define HEATER_2_PIN PF9 // Heater2 +#define HEATER_3_PIN PF7 // Heater3 + +#define FAN_PIN PA6 // Fan0 +#define FAN1_PIN PA5 // Fan1 +#define FAN2_PIN PA4 // Fan2 +#define FAN3_PIN PA3 // Fan3 +#define FAN4_PIN PA1 // 4 wire Fan4 +#define FAN5_PIN PF8 // 4 wire Fan5 +#define FAN6_PIN PA2 // 4 wire Fan6 + +// +// SD Support +// +#ifndef SDCARD_CONNECTION + #if HAS_WIRED_LCD + #define SDCARD_CONNECTION LCD + #else + #define SDCARD_CONNECTION ONBOARD + #endif +#endif + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PE14 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PE13 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PE12 + #endif +#endif + +#if HAS_TMC_UART + /** + * TMC2208/TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define X2_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Y2_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define Z2_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + //#define E1_HARDWARE_SERIAL Serial1 + //#define E2_HARDWARE_SERIAL Serial1 + //#define E3_HARDWARE_SERIAL Serial1 + //#define E4_HARDWARE_SERIAL Serial1 + + #define X_SERIAL_TX_PIN PG14 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PG13 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PG12 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define Z2_SERIAL_TX_PIN PG11 + #define Z2_SERIAL_RX_PIN Z2_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PG10 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PG9 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + #define E2_SERIAL_TX_PIN PD7 + #define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN + + #define E3_SERIAL_TX_PIN PD6 + #define E3_SERIAL_RX_PIN E3_SERIAL_TX_PIN + + #define E4_SERIAL_TX_PIN PG8 + #define E4_SERIAL_RX_PIN E3_SERIAL_TX_PIN + + #define E5_SERIAL_TX_PIN PG7 + #define E5_SERIAL_RX_PIN E3_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +/** + * ---- + * (MISO) PE13 | 1 | + * (SCK) PE12 | 2 | + * (BTN_EN1) PG5 | 3 | + * (SD_SS) PE11 | 4 | + * (BTN_EN2) PG4 | 5 | + * (MOSI) PE14 | 6 | + * (SD_DETECT) PG3 | 7 | + * RESET | 8 | + * (BEEPER) PG2 | 9 | + * (BTN_ENC) PD15 | 10 | + * (LCD_EN) PD14 | 11 | + * (LCD_RS) PD13 | 12 | + * (LCD_D4) PD12 | 13 | + * (LCD_D5) PD11 | 14 | + * (LCD_D6) PD10 | 15 | + * (LCD_D7) PE15 | 16 | + * GND | 17 | + * 5V | 18 | + * ---- + * LCD + */ + +#define EXP1_01_PIN PG2 +#define EXP1_02_PIN PD15 +#define EXP1_03_PIN PD14 +#define EXP1_04_PIN PD13 +#define EXP1_05_PIN PD12 +#define EXP1_06_PIN PD11 +#define EXP1_07_PIN PD10 +#define EXP1_08_PIN PE15 + +#define EXP2_01_PIN PE13 +#define EXP2_02_PIN PE12 +#define EXP2_03_PIN PG5 +#define EXP2_04_PIN PE11 +#define EXP2_05_PIN PG4 +#define EXP2_06_PIN PE14 +#define EXP2_07_PIN PG3 +#define EXP2_08_PIN -1 + +// +// Onboard SD card +// Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 +// +#if SD_CONNECTION_IS(ONBOARD) + #ifndef SD_DETECT_STATE + #define SD_DETECT_STATE HIGH + #elif SD_DETECT_STATE == LOW + #error "BOARD_BTT_OCTOPUS_MAX_EZ onboard SD requires SD_DETECT_STATE set to HIGH." + #endif + #define SDSS PB12 + #define SD_SS_PIN SDSS + #define SD_SCK_PIN PE12 + #define SD_MISO_PIN PE13 + #define SD_MOSI_PIN PE14 + #define SD_DETECT_PIN PB13 + #define SOFTWARE_SPI +#elif SD_CONNECTION_IS(LCD) + #define SDSS EXP2_04_PIN + #define SD_SS_PIN SDSS + #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 + #define SOFTWARE_SPI +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board" +#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 DOGLCD_SCK EXP2_02_PIN + #define DOGLCD_MOSI EXP2_06_PIN + + #define SOFTWARE_SPI + #define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems + // results in LCD soft SPI mode 3, SD soft SPI mode 0 + //#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 + +#if HAS_SPI_TFT + #define TFT_CS_PIN EXP2_04_PIN + #define TFT_A0_PIN EXP2_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN + + #define TOUCH_INT_PIN EXP1_07_PIN + #define TOUCH_MISO_PIN EXP1_06_PIN + #define TOUCH_MOSI_PIN EXP1_03_PIN + #define TOUCH_SCK_PIN EXP1_05_PIN + #define TOUCH_CS_PIN EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN +#endif + +// +// NeoPixel LED +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PE10 +#endif + +#ifndef NEOPIXEL2_PIN + #define NEOPIXEL2_PIN PE9 +#endif + +#if ENABLED(WIFISUPPORT) + // + // WIFI + // + + /** + * ------- + * GND | 9 | | 8 | 3.3V + * (ESP-CS) PG1 | 10 | | 7 | PB15 (ESP-MOSI) + * 3.3V | 11 | | 6 | PB14 (ESP-MISO) + * (ESP-IO0) PG0 | 12 | | 5 | PB13 (ESP-CLK) + * (ESP-IO4) PF15 | 13 | | 4 | -- + * -- | 14 | | 3 | 3.3V (ESP-EN) + * (ESP-RX) PE7 | 15 | | 2 | -- + * (ESP-TX) PE8 | 16 | | 1 | PB2 (ESP-RST) + * ------- + * WIFI + */ + #define ESP_WIFI_MODULE_COM 7 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this + #define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 + #define ESP_WIFI_MODULE_RESET_PIN PB2 + #define ESP_WIFI_MODULE_GPIO0_PIN PG0 + #define ESP_WIFI_MODULE_GPIO4_PIN PF15 +#endif diff --git a/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V2.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V2.h new file mode 100644 index 000000000000..8be6dadee43b --- /dev/null +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V2.h @@ -0,0 +1,28 @@ +/** + * 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_INFO_NAME "BTT SKR SE BX V2.0" + +#define SAFE_POWER_PIN PI11 + +#include "pins_BTT_SKR_SE_BX_common.h" diff --git a/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V3.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V3.h new file mode 100644 index 000000000000..8d8143ee622b --- /dev/null +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_V3.h @@ -0,0 +1,26 @@ +/** + * 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_INFO_NAME "BTT SKR SE BX V3.0" + +#include "pins_BTT_SKR_SE_BX_common.h" diff --git a/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_common.h similarity index 95% rename from Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h rename to Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_common.h index 5a772eb21b09..d06e27d9c0b1 100644 --- a/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX_common.h @@ -21,18 +21,16 @@ */ #pragma once -#if NOT_TARGET(STM32H7) - #error "Oops! Select an STM32H7 board in 'Tools > Board.'" -#endif +#include "env_validate.h" -#define BOARD_INFO_NAME "BTT SKR SE BX" -#define DEFAULT_MACHINE_NAME "BIQU-BX" +#define DEFAULT_MACHINE_NAME "Biqu BX" // Onboard I2C EEPROM #define I2C_EEPROM #define MARLIN_EEPROM_SIZE 0x1000 // 4K (24C32) #define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support +//#define SWD_DEBUG // Use pins PA13 and PA14 on STM32H7 for the SWD debugger // // Limit Switches @@ -47,13 +45,14 @@ #define FIL_RUNOUT_PIN PD13 #define FIL_RUNOUT2_PIN PB13 -#define LED_PIN PA13 -#define BEEPER_PIN PA14 +#ifndef SWD_DEBUG + #define LED_PIN PA13 + #define BEEPER_PIN PA14 +#endif #define POWER_MONITOR_PIN PB0 #define RPI_POWER_PIN PE5 -#define SAFE_POWER_PIN PI11 #define SERVO0_PIN PA2 // 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 02e195a1852e..b9e1ff10ad16 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 @@ -21,9 +21,7 @@ */ #pragma once -#if NOT_TARGET(STM32H7) - #error "Oops! Select an STM32H7 board in 'Tools > Board.'" -#endif +#include "env_validate.h" // If you have the BigTreeTech driver expansion module, enable BTT_MOTOR_EXPANSION // https://github.com/bigtreetech/BTT-Expansion-module/tree/master/BTT%20EXP-MOT @@ -46,7 +44,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 // @@ -326,43 +324,43 @@ /** * ------ ------ - * (BEEPER) PC5 |10 9 | PB0 (BTN_ENC) (MISO) PA6 |10 9 | PA5 (SCK) - * (LCD_EN) PB1 | 8 7 | PE8 (LCD_RS) (BTN_EN1) PE7 | 8 7 | PA4 (SD_SS) - * (LCD_D4) PE9 | 6 5 PE10 (LCD_D5) (BTN_EN2) PB2 | 6 5 PA7 (MOSI) - * (LCD_D6) PE11 | 4 3 | PE12 (LCD_D7) (SD_DETECT) PC4 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | -- + * (BEEPER) PC5 | 1 2 | PB0 (BTN_ENC) (MISO) PA6 | 1 2 | PA5 (SCK) + * (LCD_EN) PB1 | 3 4 | PE8 (LCD_RS) (BTN_EN1) PE7 | 3 4 | PA4 (SD_SS) + * (LCD_D4) PE9 | 5 6 PE10 (LCD_D5) (BTN_EN2) PB2 | 5 6 PA7 (MOSI) + * (LCD_D6) PE11 | 7 8 | PE12 (LCD_D7) (SD_DETECT) PC4 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- * ------ ------ * EXP1 EXP2 */ -#define EXP1_03_PIN PE12 -#define EXP1_04_PIN PE11 -#define EXP1_05_PIN PE10 -#define EXP1_06_PIN PE9 -#define EXP1_07_PIN PE8 -#define EXP1_08_PIN PB1 -#define EXP1_09_PIN PB0 -#define EXP1_10_PIN PC5 - -#define EXP2_03_PIN -1 -#define EXP2_04_PIN PC4 -#define EXP2_05_PIN PA7 -#define EXP2_06_PIN PB2 -#define EXP2_07_PIN PA4 -#define EXP2_08_PIN PE7 -#define EXP2_09_PIN PA5 -#define EXP2_10_PIN PA6 +#define EXP1_01_PIN PC5 +#define EXP1_02_PIN PB0 +#define EXP1_03_PIN PB1 +#define EXP1_04_PIN PE8 +#define EXP1_05_PIN PE9 +#define EXP1_06_PIN PE10 +#define EXP1_07_PIN PE11 +#define EXP1_08_PIN PE12 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE7 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PB2 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PC4 +#define EXP2_08_PIN -1 // // Onboard SD card // Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 // #if SD_CONNECTION_IS(LCD) - #define SDSS EXP2_07_PIN + #define SDSS EXP2_04_PIN #define SD_SS_PIN SDSS - #define SD_SCK_PIN EXP2_09_PIN - #define SD_MISO_PIN EXP2_10_PIN - #define SD_MOSI_PIN EXP2_05_PIN - #define SD_DETECT_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(ONBOARD) #define SDIO_SUPPORT #define SDIO_CLOCK 24000000 // 24MHz @@ -371,59 +369,59 @@ #endif #if ENABLED(BTT_MOTOR_EXPANSION) - /** ----- ----- - * -- | . . | GND -- | . . | GND - * -- | . . | M1EN M2EN | . . | M3EN - * M1STP | . . M1DIR M1RX | . . M1DIAG - * M2DIR | . . | M2STP M2RX | . . | M2DIAG - * M3DIR | . . | M3STP M3RX | . . | M3DIAG - * ----- ----- - * EXP2 EXP1 + /** ------ ------ + * M3DIAG | 1 2 | M3RX M3STP | 1 2 | M3DIR + * M2DIAG | 3 4 | M2RX M2STP | 3 4 | M2DIR + * M1DIAG 5 6 | M1RX M1DIR 5 6 | M1STP + * M3EN | 7 8 | M2EN M1EN | 7 8 | -- + * GND | 9 10 | -- GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 * * NB In EXP_MOT_USE_EXP2_ONLY mode EXP1 is not used and M2EN and M3EN need to be jumpered to M1EN */ // M1 on Driver Expansion Module - #define E2_STEP_PIN EXP2_05_PIN - #define E2_DIR_PIN EXP2_06_PIN - #define E2_ENABLE_PIN EXP2_04_PIN + #define E2_STEP_PIN EXP2_06_PIN + #define E2_DIR_PIN EXP2_05_PIN + #define E2_ENABLE_PIN EXP2_07_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E2_DIAG_PIN EXP1_06_PIN - #define E2_CS_PIN EXP1_05_PIN + #define E2_DIAG_PIN EXP1_05_PIN + #define E2_CS_PIN EXP1_06_PIN #if HAS_TMC_UART - #define E2_SERIAL_TX_PIN EXP1_05_PIN - #define E2_SERIAL_RX_PIN EXP1_05_PIN + #define E2_SERIAL_TX_PIN EXP1_06_PIN + #define E2_SERIAL_RX_PIN EXP1_06_PIN #endif #endif // M2 on Driver Expansion Module - #define E3_STEP_PIN EXP2_08_PIN - #define E3_DIR_PIN EXP2_07_PIN + #define E3_STEP_PIN EXP2_03_PIN + #define E3_DIR_PIN EXP2_04_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E3_ENABLE_PIN EXP1_03_PIN - #define E3_DIAG_PIN EXP1_08_PIN - #define E3_CS_PIN EXP1_07_PIN + #define E3_ENABLE_PIN EXP1_08_PIN + #define E3_DIAG_PIN EXP1_03_PIN + #define E3_CS_PIN EXP1_04_PIN #if HAS_TMC_UART - #define E3_SERIAL_TX_PIN EXP1_07_PIN - #define E3_SERIAL_RX_PIN EXP1_07_PIN + #define E3_SERIAL_TX_PIN EXP1_04_PIN + #define E3_SERIAL_RX_PIN EXP1_04_PIN #endif #else - #define E3_ENABLE_PIN EXP2_04_PIN + #define E3_ENABLE_PIN EXP2_07_PIN #endif // M3 on Driver Expansion Module - #define E4_STEP_PIN EXP2_10_PIN - #define E4_DIR_PIN EXP2_09_PIN + #define E4_STEP_PIN EXP2_01_PIN + #define E4_DIR_PIN EXP2_02_PIN #if !EXP_MOT_USE_EXP2_ONLY - #define E4_ENABLE_PIN EXP1_04_PIN - #define E4_DIAG_PIN EXP1_10_PIN - #define E4_CS_PIN EXP1_09_PIN + #define E4_ENABLE_PIN EXP1_07_PIN + #define E4_DIAG_PIN EXP1_01_PIN + #define E4_CS_PIN EXP1_02_PIN #if HAS_TMC_UART - #define E4_SERIAL_TX_PIN EXP1_09_PIN - #define E4_SERIAL_RX_PIN EXP1_09_PIN + #define E4_SERIAL_TX_PIN EXP1_02_PIN + #define E4_SERIAL_RX_PIN EXP1_02_PIN #endif #else - #define E4_ENABLE_PIN EXP2_04_PIN + #define E4_ENABLE_PIN EXP2_07_PIN #endif #endif // BTT_MOTOR_EXPANSION @@ -434,65 +432,65 @@ #if IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define TFTGLCD_CS EXP2_08_PIN + #define TFTGLCD_CS EXP2_03_PIN #endif #elif HAS_WIRED_LCD - #define BEEPER_PIN EXP1_10_PIN - #define BTN_ENC EXP1_09_PIN + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_RS EXP1_07_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_ENABLE EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 EXP1_04_PIN - #define DOGLCD_CS EXP1_05_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN #else - #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_RS EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(FYSETC_MINI_12864) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN //#define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN EXP1_06_PIN // Must be high or open for LCD to operate normally. + #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_05_PIN + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN EXP1_04_PIN + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN EXP1_03_PIN + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN EXP1_05_PIN + #define NEOPIXEL_PIN EXP1_06_PIN #endif #endif // !FYSETC_MINI_12864 #if IS_ULTIPANEL - #define LCD_PINS_D5 EXP1_05_PIN - #define LCD_PINS_D6 EXP1_04_PIN - #define LCD_PINS_D7 EXP1_03_PIN + #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 @@ -521,21 +519,21 @@ // // e.g., BTT_TFT35_SPI_V1_0 (480x320, 3.5", SPI Stock Display with Rotary Encoder in BIQU B1 SE) // - #define TFT_CS_PIN EXP2_07_PIN - #define TFT_A0_PIN EXP2_04_PIN - #define TFT_SCK_PIN EXP2_09_PIN - #define TFT_MISO_PIN EXP2_10_PIN - #define TFT_MOSI_PIN EXP2_05_PIN + #define TFT_CS_PIN EXP2_04_PIN + #define TFT_A0_PIN EXP2_07_PIN + #define TFT_SCK_PIN EXP2_02_PIN + #define TFT_MISO_PIN EXP2_01_PIN + #define TFT_MOSI_PIN EXP2_06_PIN - #define TOUCH_INT_PIN EXP1_04_PIN - #define TOUCH_MISO_PIN EXP1_05_PIN - #define TOUCH_MOSI_PIN EXP1_08_PIN - #define TOUCH_SCK_PIN EXP1_06_PIN - #define TOUCH_CS_PIN EXP1_07_PIN + #define TOUCH_INT_PIN EXP1_07_PIN + #define TOUCH_MISO_PIN EXP1_06_PIN + #define TOUCH_MOSI_PIN EXP1_03_PIN + #define TOUCH_SCK_PIN EXP1_05_PIN + #define TOUCH_CS_PIN EXP1_04_PIN - #define BTN_EN1 EXP2_08_PIN - #define BTN_EN2 EXP2_06_PIN - #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + #define BTN_ENC EXP1_02_PIN #endif // @@ -545,25 +543,27 @@ #define NEOPIXEL_PIN PE6 #endif -// -// WIFI -// +#if ENABLED(WIFISUPPORT) + // + // WIFI + // -/** - * ------- - * GND | 9 | | 8 | 3.3V - * (ESP-CS) PB12 | 10 | | 7 | PB15 (ESP-MOSI) - * 3.3V | 11 | | 6 | PB14 (ESP-MISO) - * (ESP-IO0) PB10 | 12 | | 5 | PB13 (ESP-CLK) - * (ESP-IO4) PB11 | 13 | | 4 | -- - * -- | 14 | | 3 | 3.3V (ESP-EN) - * (ESP-RX) PD8 | 15 | | 2 | -- - * (ESP-TX) PD9 | 16 | | 1 | PC14 (ESP-RST) - * ------- - * WIFI - */ -#define ESP_WIFI_MODULE_COM 3 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this -#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 -#define ESP_WIFI_MODULE_RESET_PIN PC14 -#define ESP_WIFI_MODULE_GPIO0_PIN PB10 -#define ESP_WIFI_MODULE_GPIO4_PIN PB11 + /** + * ------- + * GND | 9 | | 8 | 3.3V + * (ESP-CS) PB12 | 10 | | 7 | PB15 (ESP-MOSI) + * 3.3V | 11 | | 6 | PB14 (ESP-MISO) + * (ESP-IO0) PB10 | 12 | | 5 | PB13 (ESP-CLK) + * (ESP-IO4) PB11 | 13 | | 4 | -- + * -- | 14 | | 3 | 3.3V (ESP-EN) + * (ESP-RX) PD8 | 15 | | 2 | -- + * (ESP-TX) PD9 | 16 | | 1 | PC14 (ESP-RST) + * ------- + * WIFI + */ + #define ESP_WIFI_MODULE_COM 3 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this + #define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2 + #define ESP_WIFI_MODULE_RESET_PIN PC14 + #define ESP_WIFI_MODULE_GPIO0_PIN PB10 + #define ESP_WIFI_MODULE_GPIO4_PIN PB11 +#endif diff --git a/Marlin/src/pins/teensy2/pins_5DPRINT.h b/Marlin/src/pins/teensy2/pins_5DPRINT.h index 6e1f9c021746..9eb1da36f413 100644 --- a/Marlin/src/pins/teensy2/pins_5DPRINT.h +++ b/Marlin/src/pins/teensy2/pins_5DPRINT.h @@ -64,6 +64,8 @@ /** * 5DPrint D8 Driver board pin assignments + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/5DPrint%20D8/5DPD8_v1.0_OS_schematics.PDF + * Origin: https://bitbucket.org/makible/5dprint-d8-controller-board/src/master/5DPD8_v1.0_OS_schematics.PDF * * https://bitbucket.org/makible/5dprint-d8-controller-board */ diff --git a/Marlin/src/pins/teensy2/pins_BRAINWAVE.h b/Marlin/src/pins/teensy2/pins_BRAINWAVE.h index cdcc249c00d2..bbda3730ee00 100644 --- a/Marlin/src/pins/teensy2/pins_BRAINWAVE.h +++ b/Marlin/src/pins/teensy2/pins_BRAINWAVE.h @@ -23,9 +23,13 @@ /** * Brainwave 1.0 pin assignments (AT90USB646) + * https://www.reprap.org/wiki/Brainwave * * Requires hardware bundle for Arduino: * https://github.com/unrepentantgeek/brainwave-arduino + * + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Brainwave/schematic.pdf + * Origin: https://github.com/unrepentantgeek/Brainwave/blob/master/brainwave/brainwave.sch */ /** diff --git a/Marlin/src/pins/teensy2/pins_BRAINWAVE_PRO.h b/Marlin/src/pins/teensy2/pins_BRAINWAVE_PRO.h index 319130ef968d..969ec845588f 100644 --- a/Marlin/src/pins/teensy2/pins_BRAINWAVE_PRO.h +++ b/Marlin/src/pins/teensy2/pins_BRAINWAVE_PRO.h @@ -26,6 +26,8 @@ * * Requires hardware bundle for Arduino: * https://github.com/unrepentantgeek/brainwave-arduino + * + * Not to be confused with the regular Brainwave controller (https://www.reprap.org/wiki/Brainwave) */ /** diff --git a/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h b/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h index 82d9cec8949b..1fb7387d160c 100644 --- a/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h +++ b/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h @@ -25,6 +25,15 @@ * Rev B 2 JUN 2017 * * Converted to Arduino pin numbering + * + * Schematic (RevA): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Printrboard%20Rev.A/schematic.png + * Origin (RevA): https://raw.githubusercontent.com/lwalkera/printrboard/revA/Printrboard.sch + * Schematic (RevB): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Printrboard%20Rev.B/schematic.png + * Origin (RevB): https://raw.githubusercontent.com/lwalkera/printrboard/revB/Printrboard.sch + * Schematic (RevC): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Printrboard%20Rev.C/schematic.png + * Origin (RevC): https://raw.githubusercontent.com/lwalkera/printrboard/revC/Printrboard.sch + * Schematic (RevD): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Printrboard%20Rev.D/schematic.png + * Origin (RevD): https://raw.githubusercontent.com/lwalkera/printrboard/RevD/Printrboard.sch */ /** @@ -130,7 +139,7 @@ #define LCD_PINS_D6 5 // D5 JP11-6 #define LCD_PINS_D7 4 // D4 JP11-5 - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN 8 // E0 JP11-10 #define DOGLCD_A0 40 // F2 JP2-2 diff --git a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h index 1ac953c89f8b..5ce106b485cc 100644 --- a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h +++ b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h @@ -25,6 +25,19 @@ * Rev B 2 JUN 2017 * * Converted to Arduino pin numbering + * + * Schematic (RevF): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Printrboard%20Rev.F/schematic.png + * Origin (RevF): https://github.com/lwalkera/printrboard/raw/revF/Printrboard.sch + * Schematic (RevF2): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Printrboard%20Rev.F2/schematic.png + * Origin (RevF2): https://raw.githubusercontent.com/lwalkera/printrboard/revF2/Printrboard.sch + * Schematic (RevF3): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Printrboard%20Rev.F3/schematic.png + * Origin (RevF3): https://raw.githubusercontent.com/lwalkera/printrboard/revF3/Printrboard.sch + * Schematic (RevF4): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Printrboard%20Rev.F4/schematic.png + * Origin (RevF4): https://raw.githubusercontent.com/lwalkera/printrboard/revF4/Printrboard.sch + * Schematic (RevF5): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Printrboard%20Rev.F5/schematic.png + * Origin (RevF5): https://raw.githubusercontent.com/lwalkera/printrboard/revF5/Printrboard.sch + * Schematic (RevF6): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Printrboard%20Rev.F6/schematic.png + * Origin (RevF6): https://raw.githubusercontent.com/lwalkera/printrboard/revF6/Printrboard.sch */ /** @@ -207,7 +220,7 @@ #define LCD_PINS_D6 5 // D5 JP11-6 #define LCD_PINS_D7 4 // D4 JP11-5 - #if ANY(VIKI2, miniVIKI) + #if EITHER(VIKI2, miniVIKI) #define BEEPER_PIN 8 // E0 JP11-10 #define DOGLCD_A0 40 // F2 JP2-2 diff --git a/Marlin/src/pins/teensy2/pins_SAV_MKI.h b/Marlin/src/pins/teensy2/pins_SAV_MKI.h index cdba535090e4..a469bba59b32 100644 --- a/Marlin/src/pins/teensy2/pins_SAV_MKI.h +++ b/Marlin/src/pins/teensy2/pins_SAV_MKI.h @@ -25,6 +25,9 @@ * Rev B 2 JUN 2017 * * Converted to Arduino pin numbering + * + * Schematic: https://green-candy.osdn.jp/external/MarlinFW/board_schematics/SAV%20MkI/SAV_MK-I.pdf + * Origin: https://reprap.org/mediawiki/images/3/3c/SAV_MK-I.pdf */ /** diff --git a/Marlin/src/pins/teensy2/pins_TEENSY2.h b/Marlin/src/pins/teensy2/pins_TEENSY2.h index efb409bf3259..b95e9cae48a1 100644 --- a/Marlin/src/pins/teensy2/pins_TEENSY2.h +++ b/Marlin/src/pins/teensy2/pins_TEENSY2.h @@ -109,6 +109,7 @@ #include "env_validate.h" +// https://reprap.org/wiki/Teensy_Breadboard #define BOARD_INFO_NAME "Teensy++2.0" // diff --git a/Marlin/src/pins/teensy2/pins_TEENSYLU.h b/Marlin/src/pins/teensy2/pins_TEENSYLU.h index ab722478fd93..294a289cdb0d 100644 --- a/Marlin/src/pins/teensy2/pins_TEENSYLU.h +++ b/Marlin/src/pins/teensy2/pins_TEENSYLU.h @@ -24,6 +24,10 @@ * Rev C 2 JUN 2017 * * Converted to Arduino pin numbering + * + * Schematic (1.0): https://green-candy.osdn.jp/external/MarlinFW/board_schematics/Teensylu%20v1.0/schematic.png + * Origin (1.0): https://raw.githubusercontent.com/StephS/Teensylu/master/working/Teensylu-1.0.sch + * (*) Other versions are discouraged by creator. */ /** diff --git a/Marlin/src/sd/Sd2Card.cpp b/Marlin/src/sd/Sd2Card.cpp index 2d84c95a3d19..81cc03230483 100644 --- a/Marlin/src/sd/Sd2Card.cpp +++ b/Marlin/src/sd/Sd2Card.cpp @@ -345,7 +345,7 @@ bool DiskIODriver_SPI_SD::init(const uint8_t sckRateID, const pin_t chipSelectPi * \param[out] dst Pointer to the location that will receive the data. * \return true for success, false for failure. */ -bool DiskIODriver_SPI_SD::readBlock(uint32_t blockNumber, uint8_t *dst) { +bool DiskIODriver_SPI_SD::readBlock(uint32_t blockNumber, uint8_t * const dst) { #if IS_TEENSY_35_36 || IS_TEENSY_40_41 return 0 == SDHC_CardReadBlock(dst, blockNumber); #endif @@ -385,7 +385,7 @@ bool DiskIODriver_SPI_SD::readBlock(uint32_t blockNumber, uint8_t *dst) { * * \return true for success, false for failure. */ -bool DiskIODriver_SPI_SD::readData(uint8_t *dst) { +bool DiskIODriver_SPI_SD::readData(uint8_t * const dst) { chipSelect(); return readData(dst, 512); } @@ -455,7 +455,7 @@ bool DiskIODriver_SPI_SD::readData(uint8_t *dst) { #endif // SD_CHECK_AND_RETRY -bool DiskIODriver_SPI_SD::readData(uint8_t *dst, const uint16_t count) { +bool DiskIODriver_SPI_SD::readData(uint8_t * const dst, const uint16_t count) { bool success = false; const millis_t read_timeout = millis() + SD_READ_TIMEOUT; @@ -487,8 +487,8 @@ bool DiskIODriver_SPI_SD::readData(uint8_t *dst, const uint16_t count) { } /** read CID or CSR register */ -bool DiskIODriver_SPI_SD::readRegister(const uint8_t cmd, void *buf) { - uint8_t *dst = reinterpret_cast(buf); +bool DiskIODriver_SPI_SD::readRegister(const uint8_t cmd, void * const buf) { + uint8_t * const dst = reinterpret_cast(buf); if (cardCommand(cmd, 0)) { error(SD_CARD_ERROR_READ_REG); chipDeselect(); @@ -567,7 +567,7 @@ void DiskIODriver_SPI_SD::error(const uint8_t code) { errorCode_ = code; } * \param[in] src Pointer to the location of the data to be written. * \return true for success, false for failure. */ -bool DiskIODriver_SPI_SD::writeBlock(uint32_t blockNumber, const uint8_t *src) { +bool DiskIODriver_SPI_SD::writeBlock(uint32_t blockNumber, const uint8_t * const src) { if (ENABLED(SDCARD_READONLY)) return false; #if IS_TEENSY_35_36 || IS_TEENSY_40_41 @@ -598,7 +598,7 @@ bool DiskIODriver_SPI_SD::writeBlock(uint32_t blockNumber, const uint8_t *src) { * \param[in] src Pointer to the location of the data to be written. * \return true for success, false for failure. */ -bool DiskIODriver_SPI_SD::writeData(const uint8_t *src) { +bool DiskIODriver_SPI_SD::writeData(const uint8_t * const src) { if (ENABLED(SDCARD_READONLY)) return false; bool success = true; @@ -613,7 +613,7 @@ bool DiskIODriver_SPI_SD::writeData(const uint8_t *src) { } // Send one block of data for write block or write multiple blocks -bool DiskIODriver_SPI_SD::writeData(const uint8_t token, const uint8_t *src) { +bool DiskIODriver_SPI_SD::writeData(const uint8_t token, const uint8_t * const src) { if (ENABLED(SDCARD_READONLY)) return false; const uint16_t crc = TERN(SD_CHECK_AND_RETRY, CRC_CCITT(src, 512), 0xFFFF); diff --git a/Marlin/src/sd/Sd2Card.h b/Marlin/src/sd/Sd2Card.h index e0dce02a0236..23677b24fa4b 100644 --- a/Marlin/src/sd/Sd2Card.h +++ b/Marlin/src/sd/Sd2Card.h @@ -143,7 +143,7 @@ class DiskIODriver_SPI_SD : public DiskIODriver { * * \return true for success or false for failure. */ - bool readCID(cid_t *cid) { return readRegister(CMD10, cid); } + bool readCID(cid_t * const cid) { return readRegister(CMD10, cid); } /** * Read a card's CSD register. The CSD contains Card-Specific Data that @@ -153,18 +153,18 @@ class DiskIODriver_SPI_SD : public DiskIODriver { * * \return true for success or false for failure. */ - inline bool readCSD(csd_t *csd) override { return readRegister(CMD9, csd); } + inline bool readCSD(csd_t * const csd) override { return readRegister(CMD9, csd); } - bool readData(uint8_t *dst) override; + bool readData(uint8_t * const dst) override; bool readStart(uint32_t blockNumber) override; bool readStop() override; - bool writeData(const uint8_t *src) override; - bool writeStart(const uint32_t blockNumber, const uint32_t eraseCount) override; + bool writeData(const uint8_t * const src) override; + bool writeStart(uint32_t blockNumber, const uint32_t eraseCount) override; bool writeStop() override; - bool readBlock(uint32_t block, uint8_t *dst) override; - bool writeBlock(uint32_t blockNumber, const uint8_t *src) override; + bool readBlock(uint32_t blockNumber, uint8_t * const dst) override; + bool writeBlock(uint32_t blockNumber, const uint8_t * const src) override; uint32_t cardSize() override; @@ -187,11 +187,11 @@ class DiskIODriver_SPI_SD : public DiskIODriver { } uint8_t cardCommand(const uint8_t cmd, const uint32_t arg); - bool readData(uint8_t *dst, const uint16_t count); - bool readRegister(const uint8_t cmd, void *buf); + bool readData(uint8_t * const dst, const uint16_t count); + bool readRegister(const uint8_t cmd, void * const buf); void chipDeselect(); void chipSelect(); inline void type(const uint8_t value) { type_ = value; } bool waitNotBusy(const millis_t timeout_ms); - bool writeData(const uint8_t token, const uint8_t *src); + bool writeData(const uint8_t token, const uint8_t * const src); }; diff --git a/Marlin/src/sd/SdBaseFile.cpp b/Marlin/src/sd/SdBaseFile.cpp index 1c1e0c7d145a..2dcbb9fad985 100644 --- a/Marlin/src/sd/SdBaseFile.cpp +++ b/Marlin/src/sd/SdBaseFile.cpp @@ -91,7 +91,7 @@ bool SdBaseFile::addDirCluster() { // cache a file's directory entry // cache the current "dirBlock_" and return the entry at index "dirIndex_" // return pointer to cached entry or null for failure -dir_t* SdBaseFile::cacheDirEntry(uint8_t action) { +dir_t* SdBaseFile::cacheDirEntry(const uint8_t action) { if (!vol_->cacheRawBlock(dirBlock_, action)) return nullptr; return vol_->cache()->dir + dirIndex_; } @@ -119,7 +119,7 @@ bool SdBaseFile::close() { * Reasons for failure include file is not contiguous, file has zero length * or an I/O error occurred. */ -bool SdBaseFile::contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock) { +bool SdBaseFile::contiguousRange(uint32_t * const bgnBlock, uint32_t * const endBlock) { // error if no blocks if (firstCluster_ == 0) return false; @@ -156,7 +156,7 @@ bool SdBaseFile::contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock) { * a file is already open, the file already exists, the root * directory is full or an I/O error. */ -bool SdBaseFile::createContiguous(SdBaseFile *dirFile, const char *path, uint32_t size) { +bool SdBaseFile::createContiguous(SdBaseFile * const dirFile, const char * const path, const uint32_t size) { if (ENABLED(SDCARD_READONLY)) return false; uint32_t count; @@ -301,7 +301,7 @@ bool SdBaseFile::getDosName(char * const name) { return true; } -void SdBaseFile::getpos(filepos_t *pos) { +void SdBaseFile::getpos(filepos_t * const pos) { pos->position = curPosition_; pos->cluster = curCluster_; } @@ -337,7 +337,7 @@ void SdBaseFile::ls(uint8_t flags, uint8_t indent) { // saves 32 bytes on stack for ls recursion // return 0 - EOF, 1 - normal file, or 2 - directory -int8_t SdBaseFile::lsPrintNext(uint8_t flags, uint8_t indent) { +int8_t SdBaseFile::lsPrintNext(const uint8_t flags, const uint8_t indent) { dir_t dir; uint8_t w = 0; @@ -400,7 +400,7 @@ uint8_t lfn_checksum(const uint8_t *name) { } // Format directory name field from a 8.3 name string -bool SdBaseFile::make83Name(const char *str, uint8_t *name, const char **ptr) { +bool SdBaseFile::make83Name(const char *str, uint8_t * const name, const char **ptr) { uint8_t n = 7, // Max index until a dot is found i = 11; while (i) name[--i] = ' '; // Set whole FILENAME.EXT to spaces @@ -437,13 +437,11 @@ bool SdBaseFile::make83Name(const char *str, uint8_t *name, const char **ptr) { * Reasons for failure include this file is already open, \a parent is not a * directory, \a path is invalid or already exists in \a parent. */ -bool SdBaseFile::mkdir(SdBaseFile *parent, const char *path, bool pFlag) { +bool SdBaseFile::mkdir(SdBaseFile *parent, const char *path, const bool pFlag/*=true*/) { if (ENABLED(SDCARD_READONLY)) return false; - uint8_t dname[11]; - SdBaseFile dir1, dir2; - SdBaseFile *sub = &dir1; - SdBaseFile *start = parent; + SdBaseFile dir1, dir2, *sub = &dir1; + SdBaseFile * const start = parent; #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) uint8_t dlname[LONG_FILENAME_LENGTH]; @@ -459,6 +457,7 @@ bool SdBaseFile::mkdir(SdBaseFile *parent, const char *path, bool pFlag) { } } + uint8_t dname[11]; for (;;) { if (!TERN(LONG_FILENAME_WRITE_SUPPORT, parsePath(path, dname, dlname, &path), make83Name(path, dname, &path))) return false; while (*path == '/') path++; @@ -474,7 +473,7 @@ bool SdBaseFile::mkdir(SdBaseFile *parent, const char *path, bool pFlag) { return mkdir(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname)); } -bool SdBaseFile::mkdir(SdBaseFile *parent, const uint8_t dname[11] +bool SdBaseFile::mkdir(SdBaseFile * const parent, const uint8_t dname[11] OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) ) { if (ENABLED(SDCARD_READONLY)) return false; @@ -541,7 +540,7 @@ bool SdBaseFile::mkdir(SdBaseFile *parent, const uint8_t dname[11] * * \return true for success, false for failure. */ -bool SdBaseFile::open(const char *path, uint8_t oflag) { +bool SdBaseFile::open(const char * const path, const uint8_t oflag) { return open(cwd_, path, oflag); } @@ -595,7 +594,7 @@ bool SdBaseFile::open(const char *path, uint8_t oflag) { * a directory, \a path is invalid, the file does not exist * or can't be opened in the access mode specified by oflag. */ -bool SdBaseFile::open(SdBaseFile *dirFile, const char *path, uint8_t oflag) { +bool SdBaseFile::open(SdBaseFile * const dirFile, const char *path, const uint8_t oflag) { uint8_t dname[11]; SdBaseFile dir1, dir2; SdBaseFile *parent = dirFile, *sub = &dir1; @@ -627,9 +626,9 @@ bool SdBaseFile::open(SdBaseFile *dirFile, const char *path, uint8_t oflag) { } // open with filename in dname and long filename in dlname -bool SdBaseFile::open(SdBaseFile *dirFile, const uint8_t dname[11] +bool SdBaseFile::open(SdBaseFile * const dirFile, const uint8_t dname[11] OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) - , uint8_t oflag + , const uint8_t oflag ) { bool emptyFound = false, fileFound = false; uint8_t index = 0; @@ -703,7 +702,10 @@ bool SdBaseFile::open(SdBaseFile *dirFile, const uint8_t dname[11] // Get VFat dir entry pvFat = (vfat_t *) p; // Get checksum from the last entry of the sequence - if (pvFat->sequenceNumber & 0x40) lfnChecksum = pvFat->checksum; + if (pvFat->sequenceNumber & 0x40) { + lfnChecksum = pvFat->checksum; + ZERO(lfnName); + } // Get LFN sequence number lfnSequenceNumber = pvFat->sequenceNumber & 0x1F; if WITHIN(lfnSequenceNumber, 1, reqEntriesNum) { @@ -711,6 +713,7 @@ bool SdBaseFile::open(SdBaseFile *dirFile, const uint8_t dname[11] if (lfnChecksum == pvFat->checksum) { // Set chunk of LFN from VFAT entry into lfnName getLFNName(pvFat, (char *)lfnName, lfnSequenceNumber); + TERN_(UTF_FILENAME_SUPPORT, convertUtf16ToUtf8((char *)lfnName)); // LFN found? if (!strncasecmp((char*)dlname, (char*)lfnName, lfnNameLength)) lfnFileFound = true; } @@ -872,7 +875,7 @@ bool SdBaseFile::open(SdBaseFile *dirFile, const uint8_t dname[11] * See open() by path for definition of flags. * \return true for success or false for failure. */ -bool SdBaseFile::open(SdBaseFile *dirFile, uint16_t index, uint8_t oflag) { +bool SdBaseFile::open(SdBaseFile *dirFile, uint16_t index, const uint8_t oflag) { vol_ = dirFile->vol_; // error if already open @@ -898,7 +901,7 @@ bool SdBaseFile::open(SdBaseFile *dirFile, uint16_t index, uint8_t oflag) { } // open a cached directory entry. Assumes vol_ is initialized -bool SdBaseFile::openCachedEntry(uint8_t dirIndex, uint8_t oflag) { +bool SdBaseFile::openCachedEntry(const uint8_t dirIndex, const uint8_t oflag) { dir_t *p; #if ENABLED(SDCARD_READONLY) @@ -958,7 +961,7 @@ bool SdBaseFile::openCachedEntry(uint8_t dirIndex, uint8_t oflag) { * See open() by path for definition of flags. * \return true for success or false for failure. */ -bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) { +bool SdBaseFile::openNext(SdBaseFile *dirFile, const uint8_t oflag) { if (!dirFile) return false; // error if already open @@ -1012,9 +1015,8 @@ bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) { * \return true if the dirname is a long file name (LFN) * \return false if the dirname is a short file name 8.3 (SFN) */ - bool SdBaseFile::isDirNameLFN(const char *dirname) { - uint8_t length = strlen(dirname); - uint8_t idx = length; + bool SdBaseFile::isDirNameLFN(const char * const dirname) { + uint8_t length = strlen(dirname), idx = length; bool dotFound = false; if (idx > 12) return true; // LFN due to filename length > 12 ("filename.ext") // Check dot(s) position @@ -1044,7 +1046,7 @@ bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) { * The SFN is without dot ("FILENAMEEXT") * The LFN is complete ("Filename.ext") */ - bool SdBaseFile::parsePath(const char *path, uint8_t *name, uint8_t *lname, const char **ptrNextPath) { + bool SdBaseFile::parsePath(const char *path, uint8_t * const name, uint8_t * const lname, const char **ptrNextPath) { // Init randomizer for SFN generation randomSeed(millis()); // Parse the LFN @@ -1132,14 +1134,14 @@ bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) { /** * Get the LFN filename block from a dir. Get the block in lname at startOffset */ - void SdBaseFile::getLFNName(vfat_t *pFatDir, char *lname, uint8_t sequenceNumber) { - uint8_t startOffset = (sequenceNumber - 1) * FILENAME_LENGTH; + void SdBaseFile::getLFNName(vfat_t *pFatDir, char *lname, const uint8_t sequenceNumber) { + const uint8_t startOffset = (sequenceNumber - 1) * FILENAME_LENGTH; LOOP_L_N(i, FILENAME_LENGTH) { const uint16_t utf16_ch = (i >= 11) ? pFatDir->name3[i - 11] : (i >= 5) ? pFatDir->name2[i - 5] : pFatDir->name1[i]; #if ENABLED(UTF_FILENAME_SUPPORT) // We can't reconvert to UTF-8 here as UTF-8 is variable-size encoding, but joining LFN blocks // needs static bytes addressing. So here just store full UTF-16LE words to re-convert later. - uint16_t idx = (startOffset + i) * 2; // This is fixed as FAT LFN always contain UTF-16LE encoding + const uint16_t idx = (startOffset + i) * 2; // This is fixed as FAT LFN always contain UTF-16LE encoding lname[idx] = utf16_ch & 0xFF; lname[idx + 1] = (utf16_ch >> 8) & 0xFF; #else @@ -1152,9 +1154,9 @@ bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) { /** * Set the LFN filename block lname to a dir. Put the block based on sequence number */ - void SdBaseFile::setLFNName(vfat_t *pFatDir, char *lname, uint8_t sequenceNumber) { - uint8_t startOffset = (sequenceNumber - 1) * FILENAME_LENGTH; - uint8_t nameLength = strlen(lname); + void SdBaseFile::setLFNName(vfat_t *pFatDir, char *lname, const uint8_t sequenceNumber) { + const uint8_t startOffset = (sequenceNumber - 1) * FILENAME_LENGTH, + nameLength = strlen(lname); LOOP_L_N(i, FILENAME_LENGTH) { uint16_t ch = 0; if ((startOffset + i) < nameLength) @@ -1301,7 +1303,7 @@ static void print2u(const uint8_t v) { * \param[in] pr Print stream for output. * \param[in] fatDate The date field from a directory entry. */ -void SdBaseFile::printFatDate(uint16_t fatDate) { +void SdBaseFile::printFatDate(const uint16_t fatDate) { SERIAL_ECHO(FAT_YEAR(fatDate)); SERIAL_CHAR('-'); print2u(FAT_MONTH(fatDate)); @@ -1318,7 +1320,7 @@ void SdBaseFile::printFatDate(uint16_t fatDate) { * \param[in] pr Print stream for output. * \param[in] fatTime The time field from a directory entry. */ -void SdBaseFile::printFatTime(uint16_t fatTime) { +void SdBaseFile::printFatTime(const uint16_t fatTime) { print2u(FAT_HOUR(fatTime)); SERIAL_CHAR(':'); print2u(FAT_MINUTE(fatTime)); @@ -1363,7 +1365,7 @@ int16_t SdBaseFile::read() { * read() called before a file has been opened, corrupt file system * or an I/O error occurred. */ -int16_t SdBaseFile::read(void *buf, uint16_t nbyte) { +int16_t SdBaseFile::read(void * const buf, uint16_t nbyte) { uint8_t *dst = reinterpret_cast(buf); uint16_t offset, toRead; uint32_t block; // raw device block number @@ -1425,7 +1427,7 @@ int16_t SdBaseFile::read(void *buf, uint16_t nbyte) { * readDir() called before a directory has been opened, this is not * a directory file or an I/O error occurred. */ -int8_t SdBaseFile::readDir(dir_t *dir, char *longFilename) { +int8_t SdBaseFile::readDir(dir_t * const dir, char * const longFilename) { int16_t n; // if not a directory file or miss-positioned return an error if (!isDir() || (0x1F & curPosition_)) return -1; @@ -1507,44 +1509,55 @@ int8_t SdBaseFile::readDir(dir_t *dir, char *longFilename) { // Post-process normal file or subdirectory longname, if any if (DIR_IS_FILE_OR_SUBDIR(dir)) { #if ENABLED(UTF_FILENAME_SUPPORT) - #if LONG_FILENAME_CHARSIZE > 2 - // Add warning for developers for currently not supported 3-byte cases (Conversion series of 2-byte - // codepoints to 3-byte in-place will break the rest of filename) - #error "Currently filename re-encoding is done in-place. It may break the remaining chars to use 3-byte codepoints." - #endif - // Is there a long filename to decode? if (longFilename) { - // Reset n to the start of the long name - n = 0; - for (uint16_t idx = 0; idx < (LONG_FILENAME_LENGTH) / 2; idx += 2) { // idx is fixed since FAT LFN always contains UTF-16LE encoding - const uint16_t utf16_ch = longFilename[idx] | (longFilename[idx + 1] << 8); - if (0xD800 == (utf16_ch & 0xF800)) // Surrogate pair - encode as '_' - longFilename[n++] = '_'; - else if (0 == (utf16_ch & 0xFF80)) // Encode as 1-byte UTF-8 char - longFilename[n++] = utf16_ch & 0x007F; - else if (0 == (utf16_ch & 0xF800)) { // Encode as 2-byte UTF-8 char - longFilename[n++] = 0xC0 | ((utf16_ch >> 6) & 0x1F); - longFilename[n++] = 0x80 | ( utf16_ch & 0x3F); - } - else { - #if LONG_FILENAME_CHARSIZE > 2 // Encode as 3-byte UTF-8 char - longFilename[n++] = 0xE0 | ((utf16_ch >> 12) & 0x0F); - longFilename[n++] = 0xC0 | ((utf16_ch >> 6) & 0x3F); - longFilename[n++] = 0xC0 | ( utf16_ch & 0x3F); - #else // Encode as '_' - longFilename[n++] = '_'; - #endif - } - if (0 == utf16_ch) break; // End of filename - } // idx - } // longFilename + n = convertUtf16ToUtf8(longFilename); + } #endif return n; } // DIR_IS_FILE_OR_SUBDIR } } +#if ENABLED(UTF_FILENAME_SUPPORT) + + uint8_t SdBaseFile::convertUtf16ToUtf8(char * const longFilename) { + #if LONG_FILENAME_CHARSIZE > 2 + // Add warning for developers for unsupported 3-byte cases. + // (Converting 2-byte codepoints to 3-byte in-place would break the rest of filename.) + #error "Currently filename re-encoding is done in-place. It may break the remaining chars to use 3-byte codepoints." + #endif + + int16_t n; + // Reset n to the start of the long name + n = 0; + for (uint16_t idx = 0; idx < (LONG_FILENAME_LENGTH); idx += 2) { // idx is fixed since FAT LFN always contains UTF-16LE encoding + const uint16_t utf16_ch = longFilename[idx] | (longFilename[idx + 1] << 8); + if (0xD800 == (utf16_ch & 0xF800)) // Surrogate pair - encode as '_' + longFilename[n++] = '_'; + else if (0 == (utf16_ch & 0xFF80)) // Encode as 1-byte UTF-8 char + longFilename[n++] = utf16_ch & 0x007F; + else if (0 == (utf16_ch & 0xF800)) { // Encode as 2-byte UTF-8 char + longFilename[n++] = 0xC0 | ((utf16_ch >> 6) & 0x1F); + longFilename[n++] = 0x80 | ( utf16_ch & 0x3F); + } + else { + #if LONG_FILENAME_CHARSIZE > 2 // Encode as 3-byte UTF-8 char + longFilename[n++] = 0xE0 | ((utf16_ch >> 12) & 0x0F); + longFilename[n++] = 0xC0 | ((utf16_ch >> 6) & 0x3F); + longFilename[n++] = 0xC0 | ( utf16_ch & 0x3F); + #else // Encode as '_' + longFilename[n++] = '_'; + #endif + } + if (0 == utf16_ch) break; // End of filename + } // idx + + return n; + } + +#endif // UTF_FILENAME_SUPPORT + // Read next directory entry into the cache // Assumes file is correctly positioned dir_t* SdBaseFile::readDirCache() { @@ -1661,13 +1674,35 @@ bool SdBaseFile::remove() { * \a dirFile is not a directory, \a path is not found * or an I/O error occurred. */ -bool SdBaseFile::remove(SdBaseFile *dirFile, const char *path) { +bool SdBaseFile::remove(SdBaseFile * const dirFile, const char * const path) { if (ENABLED(SDCARD_READONLY)) return false; SdBaseFile file; return file.open(dirFile, path, O_WRITE) ? file.remove() : false; } +bool SdBaseFile::hide(const bool hidden) { + if (ENABLED(SDCARD_READONLY)) return false; + // must be an open file or subdirectory + if (!(isFile() || isSubDir())) return false; + // sync() and cache directory entry + sync(); + dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!d) return false; + uint8_t a = d->attributes; + if (hidden) + a |= DIR_ATT_HIDDEN; + else + a &= ~DIR_ATT_HIDDEN; + + if (a != d->attributes) { + d->attributes = a; + return vol_->cacheFlush(); + } + + return true; +} + /** * Rename a file or subdirectory. * @@ -1678,7 +1713,7 @@ bool SdBaseFile::remove(SdBaseFile *dirFile, const char *path) { * Reasons for failure include \a dirFile is not open or is not a directory * file, newPath is invalid or already exists, or an I/O error occurs. */ -bool SdBaseFile::rename(SdBaseFile *dirFile, const char *newPath) { +bool SdBaseFile::rename(SdBaseFile * const dirFile, const char * const newPath) { if (ENABLED(SDCARD_READONLY)) return false; uint32_t dirCluster = 0; @@ -1863,7 +1898,7 @@ bool SdBaseFile::rmRfStar() { * \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive * OR of open flags. see SdBaseFile::open(SdBaseFile*, const char*, uint8_t). */ -SdBaseFile::SdBaseFile(const char *path, uint8_t oflag) { +SdBaseFile::SdBaseFile(const char * const path, const uint8_t oflag) { type_ = FAT_FILE_TYPE_CLOSED; writeError = false; open(path, oflag); @@ -1906,7 +1941,7 @@ bool SdBaseFile::seekSet(const uint32_t pos) { return true; } -void SdBaseFile::setpos(filepos_t *pos) { +void SdBaseFile::setpos(filepos_t * const pos) { curPosition_ = pos->position; curCluster_ = pos->cluster; } @@ -1961,7 +1996,7 @@ bool SdBaseFile::sync() { * * \return true for success, false for failure. */ -bool SdBaseFile::timestamp(SdBaseFile *file) { +bool SdBaseFile::timestamp(SdBaseFile * const file) { dir_t dir; // get timestamps @@ -2018,8 +2053,8 @@ bool SdBaseFile::timestamp(SdBaseFile *file) { * * \return true for success, false for failure. */ -bool SdBaseFile::timestamp(uint8_t flags, uint16_t year, uint8_t month, - uint8_t day, uint8_t hour, uint8_t minute, uint8_t second) { +bool SdBaseFile::timestamp(const uint8_t flags, const uint16_t year, const uint8_t month, + const uint8_t day, const uint8_t hour, const uint8_t minute, const uint8_t second) { if (ENABLED(SDCARD_READONLY)) return false; uint16_t dirDate, dirTime; @@ -2133,7 +2168,7 @@ bool SdBaseFile::truncate(uint32_t length) { * include write() is called before a file has been opened, write is called * for a read-only file, device is full, a corrupt file system or an I/O error. */ -int16_t SdBaseFile::write(const void *buf, uint16_t nbyte) { +int16_t SdBaseFile::write(const void *buf, const uint16_t nbyte) { #if ENABLED(SDCARD_READONLY) writeError = true; return -1; #endif diff --git a/Marlin/src/sd/SdBaseFile.h b/Marlin/src/sd/SdBaseFile.h index bda44c6bd5c3..3ac23138b154 100644 --- a/Marlin/src/sd/SdBaseFile.h +++ b/Marlin/src/sd/SdBaseFile.h @@ -89,7 +89,7 @@ uint8_t const FAT_FILE_TYPE_CLOSED = 0, // This file h * * \return Packed date for dir_t entry. */ -static inline uint16_t FAT_DATE(uint16_t year, uint8_t month, uint8_t day) { return (year - 1980) << 9 | month << 5 | day; } +static inline uint16_t FAT_DATE(const uint16_t year, const uint8_t month, const uint8_t day) { return (year - 1980) << 9 | month << 5 | day; } /** * year part of FAT directory date field @@ -97,7 +97,7 @@ static inline uint16_t FAT_DATE(uint16_t year, uint8_t month, uint8_t day) { ret * * \return Extracted year [1980,2107] */ -static inline uint16_t FAT_YEAR(uint16_t fatDate) { return 1980 + (fatDate >> 9); } +static inline uint16_t FAT_YEAR(const uint16_t fatDate) { return 1980 + (fatDate >> 9); } /** * month part of FAT directory date field @@ -105,7 +105,7 @@ static inline uint16_t FAT_YEAR(uint16_t fatDate) { return 1980 + (fatDate >> 9) * * \return Extracted month [1,12] */ -static inline uint8_t FAT_MONTH(uint16_t fatDate) { return (fatDate >> 5) & 0xF; } +static inline uint8_t FAT_MONTH(const uint16_t fatDate) { return (fatDate >> 5) & 0xF; } /** * day part of FAT directory date field @@ -113,7 +113,7 @@ static inline uint8_t FAT_MONTH(uint16_t fatDate) { return (fatDate >> 5) & 0xF; * * \return Extracted day [1,31] */ -static inline uint8_t FAT_DAY(uint16_t fatDate) { return fatDate & 0x1F; } +static inline uint8_t FAT_DAY(const uint16_t fatDate) { return fatDate & 0x1F; } /** * time field for FAT directory entry @@ -123,7 +123,7 @@ static inline uint8_t FAT_DAY(uint16_t fatDate) { return fatDate & 0x1F; } * * \return Packed time for dir_t entry. */ -static inline uint16_t FAT_TIME(uint8_t hour, uint8_t minute, uint8_t second) { return hour << 11 | minute << 5 | second >> 1; } +static inline uint16_t FAT_TIME(const uint8_t hour, const uint8_t minute, const uint8_t second) { return hour << 11 | minute << 5 | second >> 1; } /** * hour part of FAT directory time field @@ -131,7 +131,7 @@ static inline uint16_t FAT_TIME(uint8_t hour, uint8_t minute, uint8_t second) { * * \return Extracted hour [0,23] */ -static inline uint8_t FAT_HOUR(uint16_t fatTime) { return fatTime >> 11; } +static inline uint8_t FAT_HOUR(const uint16_t fatTime) { return fatTime >> 11; } /** * minute part of FAT directory time field @@ -139,7 +139,7 @@ static inline uint8_t FAT_HOUR(uint16_t fatTime) { return fatTime >> 11; } * * \return Extracted minute [0,59] */ -static inline uint8_t FAT_MINUTE(uint16_t fatTime) { return (fatTime >> 5) & 0x3F; } +static inline uint8_t FAT_MINUTE(const uint16_t fatTime) { return (fatTime >> 5) & 0x3F; } /** * second part of FAT directory time field @@ -149,7 +149,7 @@ static inline uint8_t FAT_MINUTE(uint16_t fatTime) { return (fatTime >> 5) & 0x3 * * \return Extracted second [0,58] */ -static inline uint8_t FAT_SECOND(uint16_t fatTime) { return 2 * (fatTime & 0x1F); } +static inline uint8_t FAT_SECOND(const uint16_t fatTime) { return 2 * (fatTime & 0x1F); } // Default date for file timestamps is 1 Jan 2000 uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | (1 << 5) | 1; @@ -163,7 +163,7 @@ uint16_t const FAT_DEFAULT_TIME = (1 << 11); class SdBaseFile { public: SdBaseFile() : writeError(false), type_(FAT_FILE_TYPE_CLOSED) {} - SdBaseFile(const char *path, uint8_t oflag); + SdBaseFile(const char * const path, const uint8_t oflag); ~SdBaseFile() { if (isOpen()) close(); } /** @@ -179,18 +179,17 @@ class SdBaseFile { * get position for streams * \param[out] pos struct to receive position */ - void getpos(filepos_t *pos); + void getpos(filepos_t * const pos); /** * set position for streams * \param[out] pos struct with value for new position */ - void setpos(filepos_t *pos); + void setpos(filepos_t * const pos); bool close(); - bool contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock); - bool createContiguous(SdBaseFile *dirFile, - const char *path, uint32_t size); + bool contiguousRange(uint32_t * const bgnBlock, uint32_t * const endBlock); + bool createContiguous(SdBaseFile * const dirFile, const char * const path, const uint32_t size); /** * \return The current cluster number for a file or directory. */ @@ -235,7 +234,7 @@ class SdBaseFile { * See the timestamp() function. */ static void dateTimeCallback( - void (*dateTime)(uint16_t *date, uint16_t *time)) { + void (*dateTime)(uint16_t * const date, uint16_t * const time)) { dateTime_ = dateTime; } @@ -246,7 +245,7 @@ class SdBaseFile { bool dirEntry(dir_t *dir); static void dirName(const dir_t& dir, char *name); bool exists(const char *name); - int16_t fgets(char *str, int16_t num, char *delim = 0); + int16_t fgets(char *str, int16_t num, char *delim=0); /** * \return The total number of bytes in a file or directory. @@ -284,32 +283,37 @@ class SdBaseFile { bool isRoot() const { return type_ == FAT_FILE_TYPE_ROOT_FIXED || type_ == FAT_FILE_TYPE_ROOT32; } bool getDosName(char * const name); - void ls(uint8_t flags = 0, uint8_t indent = 0); - - bool mkdir(SdBaseFile *dir, const char *path, bool pFlag = true); - bool open(SdBaseFile *dirFile, uint16_t index, uint8_t oflag); - bool open(SdBaseFile *dirFile, const char *path, uint8_t oflag); - bool open(const char *path, uint8_t oflag = O_READ); - bool openNext(SdBaseFile *dirFile, uint8_t oflag); - bool openRoot(SdVolume *vol); + void ls(uint8_t flags=0, uint8_t indent=0); + + bool mkdir(SdBaseFile *parent, const char *path, const bool pFlag=true); + bool open(SdBaseFile * const dirFile, uint16_t index, const uint8_t oflag); + bool open(SdBaseFile * const dirFile, const char *path, const uint8_t oflag); + bool open(const char * const path, const uint8_t oflag=O_READ); + bool openNext(SdBaseFile * const dirFile, const uint8_t oflag); + bool openRoot(SdVolume * const vol); int peek(); - static void printFatDate(uint16_t fatDate); - static void printFatTime(uint16_t fatTime); + static void printFatDate(const uint16_t fatDate); + static void printFatTime(const uint16_t fatTime); bool printName(); int16_t read(); - int16_t read(void *buf, uint16_t nbyte); - int8_t readDir(dir_t *dir, char *longFilename); - static bool remove(SdBaseFile *dirFile, const char *path); + int16_t read(void * const buf, uint16_t nbyte); + int8_t readDir(dir_t * const dir, char * const longFilename); + static bool remove(SdBaseFile * const dirFile, const char * const path); bool remove(); /** * Set the file's current position to zero. */ void rewind() { seekSet(0); } - bool rename(SdBaseFile *dirFile, const char *newPath); + bool rename(SdBaseFile * const dirFile, const char * const newPath); bool rmdir(); bool rmRfStar(); + /** + * Set or clear DIR_ATT_HIDDEN attribute for directory entry + */ + bool hide(const bool hidden); + /** * Set the files position to current position + \a pos. See seekSet(). * \param[in] offset The new position in bytes from the current position. @@ -322,12 +326,12 @@ class SdBaseFile { * \param[in] offset The new position in bytes from end-of-file. * \return true for success or false for failure. */ - bool seekEnd(const int32_t offset = 0) { return seekSet(fileSize_ + offset); } + bool seekEnd(const int32_t offset=0) { return seekSet(fileSize_ + offset); } bool seekSet(const uint32_t pos); bool sync(); - bool timestamp(SdBaseFile *file); - bool timestamp(uint8_t flag, uint16_t year, uint8_t month, uint8_t day, - uint8_t hour, uint8_t minute, uint8_t second); + bool timestamp(SdBaseFile * const file); + bool timestamp(const uint8_t flag, const uint16_t year, const uint8_t month, const uint8_t day, + const uint8_t hour, const uint8_t minute, const uint8_t second); /** * Type of file. Use isFile() or isDir() instead of type() if possible. @@ -341,7 +345,7 @@ class SdBaseFile { * \return SdVolume that contains this file. */ SdVolume* volume() const { return vol_; } - int16_t write(const void *buf, uint16_t nbyte); + int16_t write(const void *buf, const uint16_t nbyte); private: friend class SdFat; // allow SdFat to set cwd_ @@ -374,29 +378,31 @@ class SdBaseFile { // private functions bool addCluster(); bool addDirCluster(); - dir_t* cacheDirEntry(uint8_t action); - int8_t lsPrintNext(uint8_t flags, uint8_t indent); - static bool make83Name(const char *str, uint8_t *name, const char **ptr); - bool mkdir(SdBaseFile *parent, const uint8_t dname[11] + dir_t* cacheDirEntry(const uint8_t action); + int8_t lsPrintNext(const uint8_t flags, const uint8_t indent); + static bool make83Name(const char *str, uint8_t * const name, const char **ptr); + bool mkdir(SdBaseFile * const parent, const uint8_t dname[11] OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) ); bool open(SdBaseFile *dirFile, const uint8_t dname[11] OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) - , uint8_t oflag + , const uint8_t oflag ); - bool openCachedEntry(uint8_t cacheIndex, uint8_t oflags); + bool openCachedEntry(const uint8_t dirIndex, const uint8_t oflags); dir_t* readDirCache(); + #if ENABLED(UTF_FILENAME_SUPPORT) + uint8_t convertUtf16ToUtf8(char * const longFilename); + #endif + // Long Filename create/write support #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) static bool isDirLFN(const dir_t* dir); - static bool isDirNameLFN(const char *dirname); - static bool parsePath(const char *str, uint8_t *name, uint8_t *lname, const char **ptr); - /** - * Return the number of entries needed in the FAT for this LFN - */ - static inline uint8_t getLFNEntriesNum(const char *lname) { return (strlen(lname) + 12) / 13; } - static void getLFNName(vfat_t *vFatDir, char *lname, uint8_t startOffset); - static void setLFNName(vfat_t *vFatDir, char *lname, uint8_t lfnSequenceNumber); + static bool isDirNameLFN(const char * const dirname); + static bool parsePath(const char *str, uint8_t * const name, uint8_t * const lname, const char **ptr); + // Return the number of entries needed in the FAT for this LFN + static uint8_t getLFNEntriesNum(const char * const lname) { return (strlen(lname) + 12) / 13; } + static void getLFNName(vfat_t *vFatDir, char *lname, const uint8_t sequenceNumber); + static void setLFNName(vfat_t *vFatDir, char *lname, const uint8_t sequenceNumber); #endif }; diff --git a/Marlin/src/sd/SdFatStructs.h b/Marlin/src/sd/SdFatStructs.h index 03bbc1c194c9..b3f94b57a055 100644 --- a/Marlin/src/sd/SdFatStructs.h +++ b/Marlin/src/sd/SdFatStructs.h @@ -66,9 +66,9 @@ struct partitionTable { * Sector part of Cylinder-head-sector address of the first block in * the partition. Legal values are 1-63. Only used in old PC BIOS. */ - unsigned beginSector : 6; + uint8_t beginSector : 6; /** High bits cylinder for first block in partition. */ - unsigned beginCylinderHigh : 2; + uint8_t beginCylinderHigh : 2; /** * Combine beginCylinderLow with beginCylinderHigh. Legal values * are 0-1023. Only used in old PC BIOS. @@ -88,9 +88,9 @@ struct partitionTable { * Sector part of cylinder-head-sector address of the last sector in * the partition. Legal values are 1-63. Only used in old PC BIOS. */ - unsigned endSector : 6; + uint8_t endSector : 6; /** High bits of end cylinder */ - unsigned endCylinderHigh : 2; + uint8_t endCylinderHigh : 2; /** * Combine endCylinderLow with endCylinderHigh. Legal values * are 0-1023. Only used in old PC BIOS. diff --git a/Marlin/src/sd/SdFile.cpp b/Marlin/src/sd/SdFile.cpp index bce96ef02db5..a1dd79372747 100644 --- a/Marlin/src/sd/SdFile.cpp +++ b/Marlin/src/sd/SdFile.cpp @@ -43,7 +43,7 @@ * \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive * OR of open flags. see SdBaseFile::open(SdBaseFile*, const char*, uint8_t). */ -SdFile::SdFile(const char *path, uint8_t oflag) : SdBaseFile(path, oflag) { } +SdFile::SdFile(const char * const path, const uint8_t oflag) : SdBaseFile(path, oflag) { } /** * Write data to an open file. @@ -60,25 +60,21 @@ SdFile::SdFile(const char *path, uint8_t oflag) : SdBaseFile(path, oflag) { } * include write() is called before a file has been opened, write is called * for a read-only file, device is full, a corrupt file system or an I/O error. */ -int16_t SdFile::write(const void *buf, uint16_t nbyte) { return SdBaseFile::write(buf, nbyte); } +int16_t SdFile::write(const void * const buf, const uint16_t nbyte) { return SdBaseFile::write(buf, nbyte); } /** * Write a byte to a file. Required by the Arduino Print class. * \param[in] b the byte to be written. * Use writeError to check for errors. */ -#if ARDUINO >= 100 - size_t SdFile::write(uint8_t b) { return SdBaseFile::write(&b, 1); } -#else - void SdFile::write(uint8_t b) { SdBaseFile::write(&b, 1); } -#endif +size_t SdFile::write(const uint8_t b) { return SdBaseFile::write(&b, 1); } /** * Write a string to a file. Used by the Arduino Print class. * \param[in] str Pointer to the string. * Use writeError to check for errors. */ -void SdFile::write(const char *str) { SdBaseFile::write(str, strlen(str)); } +void SdFile::write(const char * const str) { SdBaseFile::write(str, strlen(str)); } /** * Write a PROGMEM string to a file. @@ -94,7 +90,7 @@ void SdFile::write_P(PGM_P str) { * \param[in] str Pointer to the PROGMEM string. * Use writeError to check for errors. */ -void SdFile::writeln_P(PGM_P str) { +void SdFile::writeln_P(PGM_P const str) { write_P(str); write_P(PSTR("\r\n")); } diff --git a/Marlin/src/sd/SdFile.h b/Marlin/src/sd/SdFile.h index 1ff05828d272..cdce1ffe12e3 100644 --- a/Marlin/src/sd/SdFile.h +++ b/Marlin/src/sd/SdFile.h @@ -41,15 +41,12 @@ class SdFile : public SdBaseFile { public: SdFile() {} - SdFile(const char *name, uint8_t oflag); - #if ARDUINO >= 100 - size_t write(uint8_t b); - #else - void write(uint8_t b); - #endif - - int16_t write(const void *buf, uint16_t nbyte); - void write(const char *str); + SdFile(const char * const name, const uint8_t oflag); + size_t write(const uint8_t b); + int16_t write(const void * const buf, const uint16_t nbyte); + void write(const char * const str); void write_P(PGM_P str); - void writeln_P(PGM_P str); + void writeln_P(PGM_P const str); }; + +using MediaFile = SdFile; diff --git a/Marlin/src/sd/SdVolume.cpp b/Marlin/src/sd/SdVolume.cpp index 1b1fdc5a7c1e..8c06c745371b 100644 --- a/Marlin/src/sd/SdVolume.cpp +++ b/Marlin/src/sd/SdVolume.cpp @@ -47,7 +47,7 @@ #endif // find a contiguous group of clusters -bool SdVolume::allocContiguous(uint32_t count, uint32_t *curCluster) { +bool SdVolume::allocContiguous(const uint32_t count, uint32_t * const curCluster) { if (ENABLED(SDCARD_READONLY)) return false; // start of group @@ -138,7 +138,7 @@ bool SdVolume::cacheFlush() { return true; } -bool SdVolume::cacheRawBlock(uint32_t blockNumber, bool dirty) { +bool SdVolume::cacheRawBlock(const uint32_t blockNumber, const bool dirty) { if (cacheBlockNumber_ != blockNumber) { if (!cacheFlush()) return false; if (!sdCard_->readBlock(blockNumber, cacheBuffer_.data)) return false; @@ -149,7 +149,7 @@ bool SdVolume::cacheRawBlock(uint32_t blockNumber, bool dirty) { } // return the size in bytes of a cluster chain -bool SdVolume::chainSize(uint32_t cluster, uint32_t *size) { +bool SdVolume::chainSize(uint32_t cluster, uint32_t * const size) { uint32_t s = 0; do { if (!fatGet(cluster, &cluster)) return false; @@ -160,7 +160,7 @@ bool SdVolume::chainSize(uint32_t cluster, uint32_t *size) { } // Fetch a FAT entry -bool SdVolume::fatGet(uint32_t cluster, uint32_t *value) { +bool SdVolume::fatGet(const uint32_t cluster, uint32_t * const value) { uint32_t lba; if (cluster > (clusterCount_ + 1)) return false; if (FAT12_SUPPORT && fatType_ == 12) { @@ -195,7 +195,7 @@ bool SdVolume::fatGet(uint32_t cluster, uint32_t *value) { } // Store a FAT entry -bool SdVolume::fatPut(uint32_t cluster, uint32_t value) { +bool SdVolume::fatPut(const uint32_t cluster, const uint32_t value) { if (ENABLED(SDCARD_READONLY)) return false; uint32_t lba; @@ -326,7 +326,7 @@ int32_t SdVolume::freeClusterCount() { * Reasons for failure include not finding a valid partition, not finding a valid * FAT file system in the specified partition or an I/O error. */ -bool SdVolume::init(DiskIODriver* dev, uint8_t part) { +bool SdVolume::init(DiskIODriver * const dev, const uint8_t part) { uint32_t totalBlocks, volumeStartBlock = 0; fat32_boot_t *fbs; diff --git a/Marlin/src/sd/SdVolume.h b/Marlin/src/sd/SdVolume.h index b8e70ca9d7f5..ccf595a593d6 100644 --- a/Marlin/src/sd/SdVolume.h +++ b/Marlin/src/sd/SdVolume.h @@ -93,8 +93,8 @@ class SdVolume { * Reasons for failure include not finding a valid partition, not finding * a valid FAT file system or an I/O error. */ - bool init(DiskIODriver *dev) { return init(dev, 1) || init(dev, 0); } - bool init(DiskIODriver *dev, uint8_t part); + bool init(DiskIODriver * const dev) { return init(dev, 1) || init(dev, 0); } + bool init(DiskIODriver * const dev, const uint8_t part); // inline functions that return volume info uint8_t blocksPerCluster() const { return blocksPerCluster_; } //> \return The volume's cluster size in blocks. @@ -127,7 +127,7 @@ class SdVolume { * \param[out] v value of entry * \return true for success or false for failure */ - bool dbgFat(uint32_t n, uint32_t *v) { return fatGet(n, v); } + bool dbgFat(const uint32_t n, uint32_t * const v) { return fatGet(n, v); } private: // Allow SdBaseFile access to SdVolume private data. @@ -164,20 +164,20 @@ class SdVolume { uint16_t rootDirEntryCount_; // number of entries in FAT16 root dir uint32_t rootDirStart_; // root start block for FAT16, cluster for FAT32 - bool allocContiguous(uint32_t count, uint32_t *curCluster); - uint8_t blockOfCluster(uint32_t position) const { return (position >> 9) & (blocksPerCluster_ - 1); } - uint32_t clusterStartBlock(uint32_t cluster) const { return dataStartBlock_ + ((cluster - 2) << clusterSizeShift_); } - uint32_t blockNumber(uint32_t cluster, uint32_t position) const { return clusterStartBlock(cluster) + blockOfCluster(position); } + bool allocContiguous(const uint32_t count, uint32_t * const curCluster); + uint8_t blockOfCluster(const uint32_t position) const { return (position >> 9) & (blocksPerCluster_ - 1); } + uint32_t clusterStartBlock(const uint32_t cluster) const { return dataStartBlock_ + ((cluster - 2) << clusterSizeShift_); } + uint32_t blockNumber(const uint32_t cluster, const uint32_t position) const { return clusterStartBlock(cluster) + blockOfCluster(position); } cache_t* cache() { return &cacheBuffer_; } uint32_t cacheBlockNumber() const { return cacheBlockNumber_; } #if USE_MULTIPLE_CARDS bool cacheFlush(); - bool cacheRawBlock(uint32_t blockNumber, bool dirty); + bool cacheRawBlock(const uint32_t blockNumber, const bool dirty); #else static bool cacheFlush(); - static bool cacheRawBlock(uint32_t blockNumber, bool dirty); + static bool cacheRawBlock(const uint32_t blockNumber, const bool dirty); #endif // used by SdBaseFile write to assign cache to SD location @@ -186,16 +186,18 @@ class SdVolume { cacheBlockNumber_ = blockNumber; } void cacheSetDirty() { cacheDirty_ |= CACHE_FOR_WRITE; } - bool chainSize(uint32_t beginCluster, uint32_t *size); - bool fatGet(uint32_t cluster, uint32_t *value); - bool fatPut(uint32_t cluster, uint32_t value); - bool fatPutEOC(uint32_t cluster) { return fatPut(cluster, 0x0FFFFFFF); } + bool chainSize(uint32_t cluster, uint32_t * const size); + bool fatGet(const uint32_t cluster, uint32_t * const value); + bool fatPut(const uint32_t cluster, const uint32_t value); + bool fatPutEOC(const uint32_t cluster) { return fatPut(cluster, 0x0FFFFFFF); } bool freeChain(uint32_t cluster); - bool isEOC(uint32_t cluster) const { - if (FAT12_SUPPORT && fatType_ == 12) return cluster >= FAT12EOC_MIN; + bool isEOC(const uint32_t cluster) const { + if (FAT12_SUPPORT && fatType_ == 12) return cluster >= FAT12EOC_MIN; if (fatType_ == 16) return cluster >= FAT16EOC_MIN; - return cluster >= FAT32EOC_MIN; + return cluster >= FAT32EOC_MIN; } - bool readBlock(uint32_t block, uint8_t *dst) { return sdCard_->readBlock(block, dst); } - bool writeBlock(uint32_t block, const uint8_t *dst) { return sdCard_->writeBlock(block, dst); } + bool readBlock(const uint32_t block, uint8_t * const dst) { return sdCard_->readBlock(block, dst); } + bool writeBlock(const uint32_t block, const uint8_t * const dst) { return sdCard_->writeBlock(block, dst); } }; + +using MarlinVolume = SdVolume; diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 5e03795692da..fb2721a2b282 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) @@ -78,7 +79,7 @@ IF_DISABLED(NO_SD_AUTOSTART, uint8_t CardReader::autofile_index); // = 0 // private: -SdFile CardReader::root, CardReader::workDir, CardReader::workDirParents[MAX_DIR_DEPTH]; +MediaFile CardReader::root, CardReader::workDir, CardReader::workDirParents[MAX_DIR_DEPTH]; uint8_t CardReader::workDirDepth; #if ENABLED(SDCARD_SORT_ALPHA) @@ -132,8 +133,8 @@ uint8_t CardReader::workDirDepth; #endif DiskIODriver* CardReader::driver = nullptr; -SdVolume CardReader::volume; -SdFile CardReader::file; +MarlinVolume CardReader::volume; +MediaFile CardReader::file; #if HAS_MEDIA_SUBCALLS uint8_t CardReader::file_subcall_ctr; @@ -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) @@ -227,7 +228,7 @@ bool CardReader::is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, // // Get the number of (compliant) items in the folder // -int CardReader::countItems(SdFile dir) { +int CardReader::countItems(MediaFile dir) { dir_t p; int c = 0; while (dir.readDir(&p, longFilename) > 0) @@ -243,7 +244,7 @@ int CardReader::countItems(SdFile dir) { // // Get file/folder info for an item by index // -void CardReader::selectByIndex(SdFile dir, const uint8_t index) { +void CardReader::selectByIndex(MediaFile dir, const uint8_t index) { dir_t p; for (uint8_t cnt = 0; dir.readDir(&p, longFilename) > 0;) { if (is_visible_entity(p)) { @@ -259,7 +260,7 @@ void CardReader::selectByIndex(SdFile dir, const uint8_t index) { // // Get file/folder info for an item by name // -void CardReader::selectByName(SdFile dir, const char * const match) { +void CardReader::selectByName(MediaFile dir, const char * const match) { dir_t p; for (uint8_t cnt = 0; dir.readDir(&p, longFilename) > 0; cnt++) { if (is_visible_entity(p)) { @@ -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(MediaFile 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)) { @@ -298,22 +304,20 @@ void CardReader::printListing( // Get a new directory object using the full path // and dive recursively into it. - SdFile child; // child.close() in destructor + MediaFile 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); } } @@ -367,7 +375,7 @@ void CardReader::ls( // Zero out slashes to make segments for (i = 0; i < pathLen; i++) if (path[i] == '/') path[i] = '\0'; - SdFile diveDir = root; // start from the root for segment 1 + MediaFile diveDir = root; // start from the root for segment 1 for (i = 0; i < pathLen;) { if (path[i] == '\0') i++; // move past a single nul @@ -396,7 +404,7 @@ void CardReader::ls( // SERIAL_ECHOPGM("Opening dir: "); SERIAL_ECHOLN(segment); // Open the sub-item as the new dive parent - SdFile dir; + MediaFile dir; if (!dir.open(&diveDir, segment, O_READ)) { SERIAL_EOL(); SERIAL_ECHO_START(); @@ -495,12 +503,7 @@ void CardReader::manage_media() { // Try to mount the media (only later with SD_IGNORE_AT_STARTUP) if (TERN1(SD_IGNORE_AT_STARTUP, old_stat != 2)) mount(); - if (!isMounted()) { // Not mounted? - stat = 0; - #if HAS_SD_DETECT && DISABLED(SD_IGNORE_AT_STARTUP) - prev_stat = 0; - #endif - } + if (!isMounted()) stat = 0; // Not mounted? TERN_(RESET_STEPPERS_ON_MEDIA_INSERT, reset_stepper_drivers()); // Workaround for Cheetah bug } @@ -512,21 +515,13 @@ void CardReader::manage_media() { if (!stat) return; // Exit if no media is present - static bool did_first_insert = false; - if (did_first_insert) return; // Did a media insert already happen? - did_first_insert = true; // Definitely handling this media insert... + if (old_stat != 2) return; // First mount? DEBUG_ECHOLNPGM("First mount."); // Load settings the first time media is inserted (not just during init) TERN_(SDCARD_EEPROM_EMULATION, settings.first_load()); - #if HAS_USB_FLASH_DRIVE - const millis_t ms = millis(); - DEBUG_ECHOLNPGM("USB mount waiting time = ", ms); - if (ms > 5000) return; // Too late to be considered "already inserted"? - #endif - bool do_auto = true; UNUSED(do_auto); // Check for PLR file. @@ -552,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); } /** @@ -585,7 +581,7 @@ void CardReader::startOrResumeFilePrinting() { // void CardReader::endFilePrintNow(TERN_(SD_RESORT, const bool re_sort/*=false*/)) { TERN_(ADVANCED_PAUSE_FEATURE, did_pause_print = 0); - TERN_(HAS_DWIN_E3V2_BASIC, HMI_flag.print_finish = flag.sdprinting); + TERN_(DWIN_CREALITY_LCD, HMI_flag.print_finish = flag.sdprinting); flag.abort_sd_printing = false; if (isFileOpen()) file.close(); TERN_(SD_RESORT, if (re_sort) presort()); @@ -608,7 +604,7 @@ void CardReader::getAbsFilenameInCWD(char *dst) { *dst++ = '/'; uint8_t cnt = 1; - auto appendAtom = [&](SdFile &file) { + auto appendAtom = [&](MediaFile &file) { file.getDosName(dst); while (*dst && cnt < MAXPATHNAMELENGTH) { dst++; cnt++; } if (cnt < MAXPATHNAMELENGTH) { *dst = '/'; dst++; cnt++; } @@ -647,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: ..." @@ -687,9 +683,9 @@ void CardReader::openFileRead(const char * const path, const uint8_t subcall_typ abortFilePrintNow(); - SdFile *diveDir; + MediaFile *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(); @@ -723,23 +719,22 @@ void CardReader::openFileWrite(const char * const path) { abortFilePrintNow(); - SdFile *diveDir; + MediaFile *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); } // @@ -752,7 +747,7 @@ bool CardReader::fileExists(const char * const path) { DEBUG_ECHOLNPGM("fileExists: ", path); // Dive to the file's directory and get the base name - SdFile *diveDir = nullptr; + MediaFile *diveDir = nullptr; const char * const fname = diveToFile(false, diveDir, path); if (!fname) return false; @@ -762,7 +757,7 @@ bool CardReader::fileExists(const char * const path) { //diveDir->close(); // Try to open the file and return the result - SdFile tmpFile; + MediaFile tmpFile; const bool success = tmpFile.open(diveDir, fname, O_READ); if (success) tmpFile.close(); return success; @@ -776,7 +771,7 @@ void CardReader::removeFile(const char * const name) { //abortFilePrintNow(); - SdFile *itsDirPtr; + MediaFile *itsDirPtr; const char * const fname = diveToFile(false, itsDirPtr, name); if (!fname) return; @@ -794,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); @@ -924,23 +919,23 @@ uint16_t CardReader::countFilesInWorkDir() { * - The workDir points to the last-set navigation target by cd, cdup, cdroot, or diveToFile(true, ...) * * On exit: - * - Your curDir pointer contains an SdFile reference to the file's directory. + * - Your curDir pointer contains an MediaFile reference to the file's directory. * - If update_cwd was 'true' the workDir now points to the file's directory. * * Returns a pointer to the last segment (filename) of the given DOS 8.3 path. - * On exit, inDirPtr contains an SdFile reference to the file's directory. + * On exit, inDirPtr contains an MediaFile reference to the file's directory. * * A nullptr result indicates an unrecoverable error. * * NOTE: End the path with a slash to dive to a folder. In this case the * returned filename will be blank (points to the end of the path). */ -const char* CardReader::diveToFile(const bool update_cwd, SdFile* &inDirPtr, const char * const path, const bool echo/*=false*/) { +const char* CardReader::diveToFile(const bool update_cwd, MediaFile* &inDirPtr, const char * const path, const bool echo/*=false*/) { DEBUG_SECTION(est, "diveToFile", true); // Track both parent and subfolder - static SdFile newDir1, newDir2; - SdFile *sub = &newDir1, *startDirPtr; + static MediaFile newDir1, newDir2; + MediaFile *sub = &newDir1, *startDirPtr; // Parsing the path string const char *atom_ptr = path; @@ -1022,7 +1017,7 @@ const char* CardReader::diveToFile(const bool update_cwd, SdFile* &inDirPtr, con } void CardReader::cd(const char * relpath) { - SdFile newDir, *parent = &getWorkDir(); + MediaFile newDir, *parent = &getWorkDir(); if (newDir.open(parent, relpath, O_READ)) { workDir = newDir; diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index d2f462c2a777..86acb1b8628c 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 @@ -114,7 +116,7 @@ class CardReader { static void changeMedia(DiskIODriver *_driver) { driver = _driver; } - static SdFile getroot() { return root; } + static MediaFile getroot() { return root; } static void mount(); static void release(); @@ -188,12 +190,12 @@ class CardReader { * Relative paths apply to the workDir. * * update_cwd: Pass 'true' to update the workDir on success. - * inDirPtr: On exit your pointer points to the target SdFile. + * inDirPtr: On exit your pointer points to the target MediaFile. * A nullptr indicates failure. * path: Start with '/' for abs path. End with '/' to get a folder ref. * echo: Set 'true' to print the path throughout the loop. */ - static const char* diveToFile(const bool update_cwd, SdFile* &inDirPtr, const char * const path, const bool echo=false); + static const char* diveToFile(const bool update_cwd, MediaFile* &inDirPtr, const char * const path, const bool echo=false); #if ENABLED(SDCARD_SORT_ALPHA) static void presort(); @@ -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(); @@ -227,7 +223,7 @@ class CardReader { // Current Working Dir - Set by cd, cdup, cdroot, and diveToFile(true, ...) static char* getWorkDirName() { workDir.getDosName(filename); return filename; } - static SdFile& getWorkDir() { return workDir.isOpen() ? workDir : root; } + static MediaFile& getWorkDir() { return workDir.isOpen() ? workDir : root; } // Print File stats static uint32_t getFileSize() { return filesize; } @@ -266,7 +262,7 @@ class CardReader { // // Working directory and parents // - static SdFile root, workDir, workDirParents[MAX_DIR_DEPTH]; + static MediaFile root, workDir, workDirParents[MAX_DIR_DEPTH]; static uint8_t workDirDepth; // @@ -326,8 +322,8 @@ class CardReader { #endif // SDCARD_SORT_ALPHA static DiskIODriver *driver; - static SdVolume volume; - static SdFile file; + static MarlinVolume volume; + static MediaFile file; static uint32_t filesize, // Total size of the current file, in bytes sdpos; // Index most recently read (one behind file.getPos) @@ -345,13 +341,11 @@ class CardReader { // Directory items // static bool is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin=false)); - static int countItems(SdFile dir); - static void selectByIndex(SdFile dir, const uint8_t index); - static void selectByName(SdFile dir, const char * const match); + static int countItems(MediaFile dir); + static void selectByIndex(MediaFile dir, const uint8_t index); + static void selectByName(MediaFile 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) + MediaFile parent, const char * const prepend, const uint8_t lsflags OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong=nullptr) ); diff --git a/Marlin/src/sd/disk_io_driver.h b/Marlin/src/sd/disk_io_driver.h index 02e2b3c73991..f1f49cf85f46 100644 --- a/Marlin/src/sd/disk_io_driver.h +++ b/Marlin/src/sd/disk_io_driver.h @@ -22,6 +22,7 @@ #pragma once #include +#include "SdInfo.h" /** * DiskIO Interface @@ -46,18 +47,18 @@ class DiskIODriver { * * \return true for success or false for failure. */ - virtual bool readCSD(csd_t* csd) = 0; + virtual bool readCSD(csd_t * const csd) = 0; virtual bool readStart(const uint32_t block) = 0; - virtual bool readData(uint8_t* dst) = 0; + virtual bool readData(uint8_t * const dst) = 0; virtual bool readStop() = 0; virtual bool writeStart(const uint32_t block, const uint32_t) = 0; virtual bool writeData(const uint8_t* src) = 0; virtual bool writeStop() = 0; - virtual bool readBlock(uint32_t block, uint8_t* dst) = 0; - virtual bool writeBlock(uint32_t blockNumber, const uint8_t* src) = 0; + virtual bool readBlock(const uint32_t block, uint8_t * const dst) = 0; + virtual bool writeBlock(const uint32_t blockNumber, const uint8_t * const src) = 0; virtual uint32_t cardSize() = 0; diff --git a/Marlin/src/sd/storage.h b/Marlin/src/sd/storage.h new file mode 100644 index 000000000000..3510e04bbe55 --- /dev/null +++ b/Marlin/src/sd/storage.h @@ -0,0 +1,74 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 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 + +/** + * Marlin Storage Architecture: + * + * DiskIODriver: + * Do all low level IO with the underline hardware or block device: SPI, SDIO, OTG + * + * FilesystemDriver: + * Handle the filesystem format / implementation. Uses the io driver to read and write data. + * Sd2Card is the very first and current filesystem implementation on Marlin, supporting FAT. + * FatFS - Work in progress. + * + * + * Marlin Abstractions: + * + * Using this names allow us to isolate filesystem driver code, keeping all Marlin code agnostic. + * + * MediaFilesystem: + * Abstraction of systemwide filesystem operation. + * + * MarlinVolume: + * Abstraction of a filesystem volume. + * + * MediaFile: + * Abstraction of a generic file. Using this name allow us to isolate filesystem driver code, + * keeping all Marlin code agnostic. + * + * PrintFromStorage: + * Class to handle printing from any attached storage. + * + */ + +/* + +Interface definition. Doesn't need to be compiled, as we use duck typing, +allowing drivers to just use type alias. + +Class MarlinVolume { +public: +}; + +Class MediaFile { +public: +}; + +Class MediaFilesystem { +public: + static void init(); + static MarlinVolume* openVolume(const char *); +}; + +*/ diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp index a681af4efa63..76d69c789ec8 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp @@ -62,7 +62,7 @@ #define USB_HOST_MANUAL_POLL // Optimization to shut off IRQ automatically // Workarounds to keep Marlin's watchdog timer from barking... - void marlin_yield() { thermalManager.manage_heater(); } + void marlin_yield() { thermalManager.task(); } #define SYSTEM_OR_SPECIAL_YIELD(...) marlin_yield(); #define delay(x) safe_delay(x) @@ -84,10 +84,10 @@ #elif ENABLED(USE_OTG_USB_HOST) #if HAS_SD_HOST_DRIVE - #include HAL_PATH(../../HAL, msc_sd.h) + #include HAL_PATH(../.., msc_sd.h) #endif - #include HAL_PATH(../../HAL, usb_host.h) + #include HAL_PATH(../.., usb_host.h) #define UHS_START usb.start() #define rREVISION 0 @@ -159,18 +159,18 @@ void DiskIODriver_USBFlash::idle() { static uint8_t laststate = 232; if (task_state != laststate) { laststate = task_state; - #define UHS_USB_DEBUG(x) case UHS_STATE(x): SERIAL_ECHOLNPGM(#x); break + #define UHS_USB_DEBUG(x,y) case UHS_STATE(x): SERIAL_ECHOLNPGM(y); break switch (task_state) { - UHS_USB_DEBUG(IDLE); - UHS_USB_DEBUG(RESET_DEVICE); - UHS_USB_DEBUG(RESET_NOT_COMPLETE); - UHS_USB_DEBUG(DEBOUNCE); - UHS_USB_DEBUG(DEBOUNCE_NOT_COMPLETE); - UHS_USB_DEBUG(WAIT_SOF); - UHS_USB_DEBUG(ERROR); - UHS_USB_DEBUG(CONFIGURING); - UHS_USB_DEBUG(CONFIGURING_DONE); - UHS_USB_DEBUG(RUNNING); + UHS_USB_DEBUG(IDLE, "IDLE"); + UHS_USB_DEBUG(RESET_DEVICE, "RESET_DEVICE"); + UHS_USB_DEBUG(RESET_NOT_COMPLETE, "RESET_NOT_COMPLETE"); + UHS_USB_DEBUG(DEBOUNCE, "DEBOUNCE"); + UHS_USB_DEBUG(DEBOUNCE_NOT_COMPLETE, "DEBOUNCE_NOT_COMPLETE"); + UHS_USB_DEBUG(WAIT_SOF, "WAIT_SOF"); + UHS_USB_DEBUG(ERROR, "ERROR"); + UHS_USB_DEBUG(CONFIGURING, "CONFIGURING"); + UHS_USB_DEBUG(CONFIGURING_DONE, "CONFIGURING_DONE"); + UHS_USB_DEBUG(RUNNING, "RUNNING"); default: SERIAL_ECHOLNPGM("UHS_USB_HOST_STATE: ", task_state); break; diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp b/Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp index dcc309025a69..1c1131cd3caf 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/message.cpp @@ -59,7 +59,7 @@ void E_NotifyStr(char const * msg, int lvl) { void E_Notify(uint8_t b, int lvl) { if (UsbDEBUGlvl < lvl) return; USB_HOST_SERIAL.print(b - #if !defined(ARDUINO) || ARDUINO < 100 + #if !defined(ARDUINO) && !defined(ARDUINO_ARCH_LPC176X) , DEC #endif ); diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/settings.h b/Marlin/src/sd/usb_flashdrive/lib-uhs2/settings.h index 7ce7b5e6ba85..268c0e1d1dcd 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/settings.h +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/settings.h @@ -65,12 +65,12 @@ * multiple serial ports are available. * For example Serial3. */ -#if ENABLED(USB_FLASH_DRIVE_SUPPORT) - #define USB_HOST_SERIAL MYSERIAL1 -#endif - #ifndef USB_HOST_SERIAL - #define USB_HOST_SERIAL Serial + #if ENABLED(USB_FLASH_DRIVE_SUPPORT) + #define USB_HOST_SERIAL MYSERIAL1 + #else + #define USB_HOST_SERIAL Serial + #endif #endif //////////////////////////////////////////////////////////////////////////////// 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 diff --git a/Marlin/src/tests/marlin_tests.cpp b/Marlin/src/tests/marlin_tests.cpp new file mode 100644 index 000000000000..89e5664345d8 --- /dev/null +++ b/Marlin/src/tests/marlin_tests.cpp @@ -0,0 +1,47 @@ +/** + * 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/MarlinConfigPre.h" + +#if ENABLED(MARLIN_TEST_BUILD) + +#include "../module/endstops.h" +#include "../module/motion.h" +#include "../module/planner.h" +#include "../module/settings.h" +#include "../module/stepper.h" +#include "../module/temperature.h" + +// Individual tests are localized in each module. +// Each test produces its own report. + +// Startup tests are run at the end of setup() +void runStartupTests() { + // Call post-setup tests here to validate behaviors. +} + +// Periodic tests are run from within loop() +void runPeriodicTests() { + // Call periodic tests here to validate behaviors. +} + +#endif // MARLIN_TEST_BUILD diff --git a/Marlin/src/tests/marlin_tests.h b/Marlin/src/tests/marlin_tests.h new file mode 100644 index 000000000000..6afce1ef3780 --- /dev/null +++ b/Marlin/src/tests/marlin_tests.h @@ -0,0 +1,25 @@ +/** + * 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 + +void runStartupTests(); +void runPeriodicTests(); diff --git a/README.md b/README.md index 3b0268caf525..7a992115b9f0 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ CI Status GitHub Sponsors
- Follow MarlinFirmware on Twitter + Follow MarlinFirmware on Mastodon

Additional documentation can be found at the [Marlin Home Page](https://marlinfw.org/). @@ -23,14 +23,27 @@ Download earlier versions of Marlin on the [Releases page](https://github.com/Ma ## Example Configurations -Before building Marlin you'll need to configure it for your specific hardware. Your vendor should have already provided source code with configurations for the installed firmware, but if you ever decide to upgrade you'll need updated configuration files. Marlin users have contributed dozens of tested example configurations to get you started. Visit the [MarlinFirmware/Configurations](https://github.com/MarlinFirmware/Configurations) repository to find the right configuration for your hardware. +Before you can build Marlin for your machine you'll need a configuration for your specific hardware. Upon request, your vendor will be happy to provide you with the complete source code and configurations for your machine, but you'll need to get updated configuration files if you want to install a newer version of Marlin. Fortunately, Marlin users have contributed dozens of tested configurations to get you started. Visit the [MarlinFirmware/Configurations](https://github.com/MarlinFirmware/Configurations) repository to find the right configuration for your hardware. ## Building Marlin 2.1 -To build Marlin 2.1 you'll need [Arduino IDE 1.8.8 or newer](https://www.arduino.cc/en/main/software) or [PlatformIO](http://docs.platformio.org/en/latest/ide.html#platformio-ide). Detailed build and install instructions are posted at: +To build and upload Marlin you will use one of these tools: - - [Installing Marlin (Arduino)](http://marlinfw.org/docs/basics/install_arduino.html) - - [Installing Marlin (VSCode)](http://marlinfw.org/docs/basics/install_platformio_vscode.html). +- The free [Visual Studio Code](https://code.visualstudio.com/download) using the [Auto Build Marlin](https://marlinfw.org/docs/basics/auto_build_marlin.html) extension. +- The free [Arduino IDE](https://www.arduino.cc/en/main/software) : See [Building Marlin with Arduino](https://marlinfw.org/docs/basics/install_arduino.html) +- You can also use VSCode with devcontainer : See [Installing Marlin (VSCode devcontainer)](http://marlinfw.org/docs/basics/install_devcontainer_vscode.html). + +Marlin is optimized to build with the **PlatformIO IDE** extension for **Visual Studio Code**. You can still build Marlin with **Arduino IDE**, and we hope to improve the Arduino build experience, but at this time PlatformIO is the better choice. + +## Hardware Abstraction Layer (HAL) + +Marlin includes an abstraction layer to provide a common API for all the platforms it targets. This allows Marlin code to address the details of motion and user interface tasks at the lowest and highest levels with no system overhead, tying all events directly to the hardware clock. + +Every new HAL opens up a world of hardware. At this time we need HALs for RP2040 and the Duet3D family of boards. A HAL that wraps an RTOS is an interesting concept that could be explored. Did you know that Marlin includes a Simulator that can run on Windows, macOS, and Linux? Join the Discord to help move these sub-projects forward! + +## 8-Bit AVR Boards + +A core tenet of this project is to keep supporting 8-bit AVR boards while also maintaining a single codebase that applies equally to all machines. We want casual hobbyists to benefit from the community's innovations as much as possible just as much as those with fancier machines. Plus, those old AVR-based machines are often the best for your testing and feedback! ### Supported Platforms @@ -43,8 +56,10 @@ To build Marlin 2.1 you'll need [Arduino IDE 1.8.8 or newer](https://www.arduino [LPC1768](https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/lpc1700-cortex-m3/512-kb-flash-64-kb-sram-ethernet-usb-lqfp100-package:LPC1768FBD100)|ARM® Cortex-M3|MKS SBASE, Re-ARM, Selena Compact [LPC1769](https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/lpc1700-cortex-m3/512-kb-flash-64-kb-sram-ethernet-usb-lqfp100-package:LPC1769FBD100)|ARM® Cortex-M3|Smoothieboard, Azteeg X5 mini, TH3D EZBoard [STM32F103](https://www.st.com/en/microcontrollers-microprocessors/stm32f103.html)|ARM® Cortex-M3|Malyan M200, GTM32 Pro, MKS Robin, BTT SKR Mini - [STM32F401](https://www.st.com/en/microcontrollers-microprocessors/stm32f401.html)|ARM® Cortex-M4|ARMED, Rumba32, SKR Pro, Lerdge, FYSETC S6 + [STM32F401](https://www.st.com/en/microcontrollers-microprocessors/stm32f401.html)|ARM® Cortex-M4|ARMED, Rumba32, SKR Pro, Lerdge, FYSETC S6, Artillery Ruby [STM32F7x6](https://www.st.com/en/microcontrollers-microprocessors/stm32f7x6.html)|ARM® Cortex-M7|The Borg, RemRam V1 + [STM32G0B1RET6](https://www.st.com/en/microcontrollers-microprocessors/stm32g0x1.html)|ARM® Cortex-M0+|BigTreeTech SKR mini E3 V3.0 + [STM32H743xIT6](https://www.st.com/en/microcontrollers-microprocessors/stm32h743-753.html)|ARM® Cortex-M7|BigTreeTech SKR V3.0, SKR EZ V3.0, SKR SE BX V2.0/V3.0 [SAMD51P20A](https://www.adafruit.com/product/4064)|ARM® Cortex-M4|Adafruit Grand Central M4 [Teensy 3.5](https://www.pjrc.com/store/teensy35.html)|ARM® Cortex-M4| [Teensy 3.6](https://www.pjrc.com/store/teensy36.html)|ARM® Cortex-M4| @@ -54,9 +69,15 @@ To build Marlin 2.1 you'll need [Arduino IDE 1.8.8 or newer](https://www.arduino ## Submitting Patches -- Submit **Bug Fixes** as Pull Requests to the ([bugfix-2.1.x](https://github.com/MarlinFirmware/Marlin/tree/bugfix-2.1.x)) branch. -- Follow the [Coding Standards](http://marlinfw.org/docs/development/coding_standards.html) to gain points with the maintainers. -- Please submit your questions and concerns to the [Issue Queue](https://github.com/MarlinFirmware/Marlin/issues). +Proposed patches should be submitted as a Pull Request against the ([bugfix-2.1.x](https://github.com/MarlinFirmware/Marlin/tree/bugfix-2.1.x)) branch. + +- Follow the [Coding Standards](https://marlinfw.org/docs/development/coding_standards.html) to gain points with the maintainers. +- Please submit Feature Requests and Bug Reports to the [Issue Queue](https://github.com/MarlinFirmware/Marlin/issues/new/choose). Support resources are also listed there. +- Whenever you add new features, be sure to add tests to `buildroot/tests` and then run your tests locally, if possible. + - It's optional: Running all the tests on Windows might take a long time, and they will run anyway on GitHub. + - If you're running the tests on Linux (or on WSL with the code on a Linux volume) the speed is much faster. + - You can use `make tests-all-local` or `make tests-single-local TEST_TARGET=...`. + - If you prefer Docker you can use `make tests-all-local-docker` or `make tests-all-local-docker TEST_TARGET=...`. ## Marlin Support @@ -77,16 +98,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 - - 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 diff --git a/buildroot/bin/build_all_examples b/buildroot/bin/build_all_examples index bce95dce8861..a6d6ede47d79 100755 --- a/buildroot/bin/build_all_examples +++ b/buildroot/bin/build_all_examples @@ -1,57 +1,97 @@ #!/usr/bin/env bash # -# build_all_examples base_branch [resume_point] +# Usage: # +# build_all_examples [-b|--branch=] - Branch to fetch from Configurations repo +# [-c|--continue] - Continue the paused build +# [-d|--debug] - Print extra debug output +# [-i|--ini] - Archive ini/json/yml files in the temp config folder +# [-l|--limit=#] - Limit the number of builds in this run +# [-n|--nobuild] - Don't actually build anything. +# [-r|--resume=] - Start at some config in the filesystem order +# [-s|--skip] - Do the thing +# +# build_all_examples [...] branch [resume-from] +# + +. mfutil GITREPO=https://github.com/MarlinFirmware/Configurations.git STAT_FILE=./.pio/.buildall -# Check dependencies -which curl 1>/dev/null 2>&1 || { echo "curl not found! Please install it."; exit ; } -which git 1>/dev/null 2>&1 || { echo "git not found! Please install it."; exit ; } +usage() { echo " +Usage: $SELF [-b|--branch=] [-d|--debug] [-i|--ini] [-r|--resume=] + $SELF [-b|--branch=] [-d|--debug] [-i|--ini] [-c|--continue] + $SELF [-b|--branch=] [-d|--debug] [-i|--ini] [-s|--skip] + $SELF [-b|--branch=] [-d|--debug] [-n|--nobuild] + $SELF [...] branch [resume-point] +" +} -SED=$(command -v gsed 2>/dev/null || command -v sed 2>/dev/null) -[[ -z "$SED" ]] && { echo "No sed found, please install sed" ; exit 1 ; } +# Assume the most recent configs +BRANCH=import-2.1.x +unset FIRST_CONF +EXIT_USAGE= +LIMIT=1000 -SELF=`basename "$0"` -HERE=`dirname "$0"` +while getopts 'b:cdhil:nqr:sv-:' OFLAG; do + case "${OFLAG}" in + b) BRANCH=$OPTARG ; bugout "Branch: $BRANCH" ;; + r) FIRST_CONF="$OPTARG" ; bugout "Resume: $FIRST_CONF" ;; + c) CONTINUE=1 ; bugout "Continue" ;; + s) CONTSKIP=1 ; bugout "Continue, skipping" ;; + i) COPY_INI=1 ; bugout "Archive INI/JSON/YML files" ;; + h) EXIT_USAGE=1 ; break ;; + l) LIMIT=$OPTARG ; bugout "Limit to $LIMIT build(s)" ;; + d|v) DEBUG=1 ; bugout "Debug ON" ;; + n) DRYRUN=1 ; bugout "Dry Run" ;; + -) IFS="=" read -r ONAM OVAL <<< "$OPTARG" + case "$ONAM" in + branch) BRANCH=$OVAL ; bugout "Branch: $BRANCH" ;; + resume) FIRST_CONF="$OVAL" ; bugout "Resume: $FIRST_CONF" ;; + continue) CONTINUE=1 ; bugout "Continue" ;; + skip) CONTSKIP=2 ; bugout "Continue, skipping" ;; + limit) LIMIT=$OVAL ; bugout "Limit to $LIMIT build(s)" ;; + ini) COPY_INI=1 ; bugout "Archive INI/JSON/YML files" ;; + help) [[ -z "$OVAL" ]] || perror "option can't take value $OVAL" $ONAM ; EXIT_USAGE=1 ;; + debug) DEBUG=1 ; bugout "Debug ON" ;; + nobuild) DRYRUN=1 ; bugout "Dry Run" ;; + *) EXIT_USAGE=2 ; echo "$SELF: unrecognized option \`--$ONAM'" ; break ;; + esac + ;; + *) EXIT_USAGE=2 ; break ;; + esac +done -# Check if called in the right location -[[ -e "Marlin/src" ]] || { echo -e "This script must be called from a Marlin working copy with:\n ./buildroot/bin/$SELF $1" ; exit ; } +# Extra arguments count as BRANCH, FIRST_CONF +shift $((OPTIND - 1)) +[[ $# > 0 ]] && { BRANCH=$1 ; shift 1 ; bugout "BRANCH=$BRANCH" ; } +[[ $# > 0 ]] && { FIRST_CONF=$1 ; shift 1 ; bugout "FIRST_CONF=$FIRST_CONF" ; } +[[ $# > 0 ]] && { EXIT_USAGE=2 ; echo "too many arguments" ; } -if [[ $# -lt 1 || $# -gt 2 ]]; then - echo "Usage: $SELF base_branch [resume_point] - base_branch - Configuration branch to download and build - resume_point - Configuration path to start from" - exit -fi +((EXIT_USAGE)) && { usage ; let EXIT_USAGE-- ; exit $EXIT_USAGE ; } -echo "This script downloads all Configurations and builds Marlin with each one." +echo "This script downloads each Configuration and attempts to build it." echo "On failure the last-built configs will be left in your working copy." echo "Restore your configs with 'git checkout -f' or 'git reset --hard HEAD'." -unset BRANCH -unset FIRST_CONF if [[ -f "$STAT_FILE" ]]; then IFS='*' read BRANCH FIRST_CONF <"$STAT_FILE" fi # If -c is given start from the last attempted build -if [[ $1 == '-c' ]]; then +if ((CONTINUE)); then if [[ -z $BRANCH || -z $FIRST_CONF ]]; then echo "Nothing to continue" exit fi -elif [[ $1 == '-s' ]]; then +elif ((CONTSKIP)); then if [[ -n $BRANCH && -n $FIRST_CONF ]]; then SKIP_CONF=1 else echo "Nothing to skip" exit fi -else - BRANCH=${1:-"import-2.0.x"} - FIRST_CONF=$2 fi # Check if the current repository has unmerged changes @@ -69,33 +109,63 @@ TMP=./.pio/build-$BRANCH # Download Configurations into the temporary folder if [[ ! -e "$TMP/README.md" ]]; then - echo "Downloading Configurations from GitHub into $TMP" + echo "Fetching Configurations from GitHub to $TMP" git clone --depth=1 --single-branch --branch "$BRANCH" $GITREPO "$TMP" || { echo "Failed to clone the configuration repository"; exit ; } else - echo "Using previously downloaded Configurations at $TMP" + echo "Using cached Configurations at $TMP" fi -echo -e "Start building now...\n=====================" +echo -e "Start build...\n=====================" shopt -s nullglob IFS=' ' CONF_TREE=$( ls -d "$TMP"/config/examples/*/ "$TMP"/config/examples/*/*/ "$TMP"/config/examples/*/*/*/ "$TMP"/config/examples/*/*/*/*/ | grep -vE ".+\.(\w+)$" ) -DOSKIP=0 for CONF in $CONF_TREE ; do + # Get a config's directory name DIR=$( echo $CONF | sed "s|$TMP/config/examples/||" ) + # If looking for a config, skip others [[ $FIRST_CONF ]] && [[ $FIRST_CONF != $DIR && "$FIRST_CONF/" != $DIR ]] && continue # Once found, stop looking unset FIRST_CONF + # If skipping, don't build the found one [[ $SKIP_CONF ]] && { unset SKIP_CONF ; continue ; } + # ...if skipping, don't build this one compgen -G "${CONF}Con*.h" > /dev/null || continue - echo "${BRANCH}*${DIR}" >"$STAT_FILE" - "$HERE/build_example" "internal" "$TMP" "$DIR" || { echo "Failed to build $DIR"; exit ; } + + # Build or print build command for --nobuild + if [[ $DRYRUN ]]; then + echo -e "\033[0;32m[DRYRUN] build_example internal \"$TMP\" \"$DIR\"\033[0m" + else + # Remember where we are in case of failure + echo "${BRANCH}*${DIR}" >"$STAT_FILE" + # Build folder is unknown so delete all report files + if [[ $COPY_INI ]]; then + IFIND='find ./.pio/build/ -name "config.ini" -o -name "schema.json" -o -name "schema.yml"' + $IFIND -exec rm "{}" \; + fi + ((DEBUG)) && echo "\"$HERE/build_example\" internal \"$TMP\" \"$DIR\"" + "$HERE/build_example" internal "$TMP" "$DIR" || { echo "Failed to build $DIR"; exit ; } + # Build folder is unknown so copy all report files + [[ $COPY_INI ]] && $IFIND -exec cp "{}" "$CONF" \; + fi + + ((--LIMIT)) || { echo "Limit reached" ; PAUSE=1 ; break ; } + done -# Delete the temp folder and build state -[[ -e "$TMP/config/examples" ]] && rm -rf "$TMP" -rm "$STAT_FILE" +# Delete the build state if not paused early +[[ $PAUSE ]] || rm "$STAT_FILE" + +# Delete the temp folder if not preserving generated INI files +if [[ -e "$TMP/config/examples" ]]; then + if [[ $COPY_INI ]]; then + OPEN=$( which gnome-open xdg-open open | head -n1 ) + $OPEN "$TMP" + elif [[ ! $PAUSE ]]; then + rm -rf "$TMP" + fi +fi diff --git a/buildroot/bin/build_example b/buildroot/bin/build_example index cff8ea253e62..34549769bbb1 100755 --- a/buildroot/bin/build_example +++ b/buildroot/bin/build_example @@ -5,6 +5,8 @@ # Usage: build_example internal config-home config-folder # +. mfutil + # Require 'internal' as the first argument [[ "$1" == "internal" ]] || { echo "Don't call this script directly, use build_all_examples instead." ; exit 1 ; } @@ -22,8 +24,15 @@ cp "$SUB"/Configuration_adv.h Marlin/ 2>/dev/null cp "$SUB"/_Bootscreen.h Marlin/ 2>/dev/null cp "$SUB"/_Statusscreen.h Marlin/ 2>/dev/null +set -e + +# Strip #error lines from Configuration.h +IFS=$'\n'; set -f +$SED -i~ -e "20,30{/#error/d}" Marlin/Configuration.h +rm Marlin/Configuration.h~ +unset IFS; set +f + echo "Building the firmware now..." -HERE=`dirname "$0"` $HERE/mftest -s -a -n1 || { echo "Failed"; exit 1; } echo "Success" diff --git a/buildroot/bin/ci_src_filter b/buildroot/bin/ci_src_filter new file mode 100755 index 000000000000..928f492e69fa --- /dev/null +++ b/buildroot/bin/ci_src_filter @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# exit on first failure +set -e + +SED=$(which gsed sed | head -n1) +FN="platformio.ini" + +if [[ $1 == "-n" ]]; then + "${SED}" -i "s/default_src_filter/org_src_filter/" $FN + "${SED}" -i "/org_src_filter/ s/^/default_src_filter = +\n/" $FN +else + git checkout $FN 2>/dev/null +fi diff --git a/buildroot/bin/mftest b/buildroot/bin/mftest index 9aa5e127327e..e4132f02a75c 100755 --- a/buildroot/bin/mftest +++ b/buildroot/bin/mftest @@ -3,7 +3,7 @@ # mftest Select a test to apply and build # mftest -b [#] Build the auto-detected environment # mftest -u [#] Upload the auto-detected environment -# mftest [name] [index] [-y] Set config options and optionally build a test +# mftest -tname -n# [-y] Set config options and optionally build a test # [[ -d Marlin/src ]] || { echo "Please 'cd' to the Marlin repo root." ; exit 1 ; } @@ -30,6 +30,7 @@ OPTIONS -u --autoupload PIO Upload using the MOTHERBOARD environment. -v --verbose Extra output for debugging. -s --silent Silence build output from PlatformIO. + -d --default Restore to defaults before applying configs. env shortcuts: tree due esp lin lp8|lpc8 lp9|lpc9 m128 m256|mega stm|f1 f4 f7 s6 teensy|t31|t32 t35|t36 t40|t41 " @@ -44,6 +45,7 @@ shopt -s extglob nocasematch # Matching patterns ISNUM='^[0-9]+$' +ISRST='^(restore)_' ISCMD='^(restore|opt|exec|use|pins|env)_' ISEXEC='^exec_' ISCONT='\\ *$' @@ -53,9 +55,10 @@ TESTENV='-' CHOICE=0 DEBUG=0 -while getopts 'abhmrsuvyn:t:-:' OFLAG; do +while getopts 'abdhmrsuvyn:t:-:' OFLAG; do case "${OFLAG}" in a) AUTO_BUILD=1 ; bugout "Auto-Build target..." ;; + d) DL_DEFAULTS=1 ; bugout "Restore to defaults..." ;; h) EXIT_USAGE=1 ;; m) USE_MAKE=1 ; bugout "Using make with Docker..." ;; n) case "$OPTARG" in @@ -88,6 +91,7 @@ while getopts 'abhmrsuvyn:t:-:' OFLAG; do silent) SILENT_FLAG="-s" ;; make) USE_MAKE=1 ; bugout "Using make with Docker..." ;; debug|verbose) DEBUG=1 ; bugout "Debug ON" ;; + default) DL_DEFAULTS=1 ; bugout "Restore to defaults..." ;; build) case "$OVAL" in ''|y|yes) BUILD_YES='Y' ;; n|no) BUILD_YES='N' ;; @@ -198,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 # @@ -282,6 +286,11 @@ if [[ $CHOICE == 0 ]]; then fi fi +# +# Restore to defaults if requested +# +((DL_DEFAULTS)) && use_example_configs + # # Run the specified test lines # @@ -303,6 +312,7 @@ echo "$OUT" | { } ((IND == CHOICE)) && { GOTX=1 + [[ -n $DL_DEFAULTS && $LINE =~ $ISRST ]] && LINE="use_example_configs" [[ $CMD == "" ]] && CMD="$LINE" || CMD=$( echo -e "$CMD$LINE" | $SED -e 's/\\//g' | $SED -E 's/ +/ /g' ) [[ $LINE =~ $ISCONT ]] || { echo "$CMD" ; eval "$CMD" ; CMD="" ; } } diff --git a/buildroot/bin/mfutil b/buildroot/bin/mfutil new file mode 100755 index 000000000000..75a2791cfedf --- /dev/null +++ b/buildroot/bin/mfutil @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# +# mfutil - check env and define helpers +# + +# Check dependencies +which curl 1>/dev/null 2>&1 || { echo "curl not found! Please install it."; exit ; } +which git 1>/dev/null 2>&1 || { echo "git not found! Please install it."; exit ; } + +SED=$(command -v gsed 2>/dev/null || command -v sed 2>/dev/null) +[[ -z "$SED" ]] && { echo "No sed found, please install sed" ; exit 1 ; } + +OPEN=$( which gnome-open xdg-open open | head -n1 ) + +SELF=`basename "$0"` +HERE=`dirname "$0"` + +# Check if called in the right location +[[ -e "Marlin/src" ]] || { echo -e "This script must be called from a Marlin working copy with:\n ./buildroot/bin/$SELF $1" ; exit ; } + +perror() { echo -e "$0: \033[0;31m$1 -- $2\033[0m" ; } +bugout() { ((DEBUG)) && echo -e "\033[0;32m$1\033[0m" ; } diff --git a/buildroot/bin/restore_configs b/buildroot/bin/restore_configs index 61aa3f9ee18e..ea998484c243 100755 --- a/buildroot/bin/restore_configs +++ b/buildroot/bin/restore_configs @@ -1,5 +1,11 @@ #!/usr/bin/env bash -git checkout Marlin/Configuration*.h 2>/dev/null -git checkout Marlin/src/pins/ramps/pins_RAMPS.h 2>/dev/null rm -f Marlin/_Bootscreen.h Marlin/_Statusscreen.h marlin_config.json .pio/build/mc.zip + +if [[ $1 == '-d' || $1 == '--default' ]]; then + use_example_configs +else + git checkout Marlin/Configuration.h 2>/dev/null + git checkout Marlin/Configuration_adv.h 2>/dev/null + git checkout Marlin/src/pins/ramps/pins_RAMPS.h 2>/dev/null +fi diff --git a/buildroot/bin/run_tests b/buildroot/bin/run_tests index 26284fa69330..9a03be3cc734 100755 --- a/buildroot/bin/run_tests +++ b/buildroot/bin/run_tests @@ -67,7 +67,7 @@ else printf "\033[0;32mMatching test \033[0m#$3\033[0;32m: '\033[0m$test_name\033[0;32m'\n" fi fi - $TESTS/$2 $1 $2 "$test_name" + "$TESTS/$2" $1 $2 "$test_name" if [[ $GIT_RESET_HARD == "true" ]]; then git reset --hard HEAD else diff --git a/buildroot/bin/use_example_configs b/buildroot/bin/use_example_configs index bfd4aa612f0e..1fdab1de6c5b 100755 --- a/buildroot/bin/use_example_configs +++ b/buildroot/bin/use_example_configs @@ -3,33 +3,42 @@ # use_example_configs [repo:]configpath # # Examples: +# use_example_configs # use_example_configs Creality/CR-10/CrealityV1 # use_example_configs release-2.0.9.4:Creality/CR-10/CrealityV1 # # If a configpath has spaces (or quotes) escape them or enquote the path # +which curl >/dev/null && TOOL='curl -L -s -S -f -o wgot' +which wget >/dev/null && TOOL='wget -q -O wgot' + CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g') [[ $CURR == "bugfix-2.0.x" ]] && BRANCH=bugfix-2.0.x || BRANCH=bugfix-2.1.x -IFS=: read -r PART1 PART2 <<< "$@" -[[ -n $PART2 ]] && { REPO="$PART1" ; RDIR="${PART2// /%20}" ; } \ - || { REPO=$BRANCH ; RDIR="${PART1// /%20}" ; } -EXAMPLES="https://raw.githubusercontent.com/MarlinFirmware/Configurations/$REPO/config/examples" +REPO=$BRANCH -which curl >/dev/null && TOOL='curl -L -s -S -f -o wgot' -which wget >/dev/null && TOOL='wget -q -O wgot' +if [[ $# > 0 ]]; then + IFS=: read -r PART1 PART2 <<< "$@" + [[ -n $PART2 ]] && { UDIR="$PART2" ; REPO="$PART1" ; } \ + || { UDIR="$PART1" ; } + RDIR="${UDIR// /%20}" + echo "Fetching $UDIR configurations from $REPO..." + EXAMPLES="examples/$RDIR" +else + EXAMPLES="default" +fi + +CONFIGS="https://raw.githubusercontent.com/MarlinFirmware/Configurations/$REPO/config/${EXAMPLES}" restore_configs cd Marlin -echo "Fetching $RDIR configurations from $REPO..." - -$TOOL "$EXAMPLES/$RDIR/Configuration.h" >/dev/null 2>&1 && mv wgot Configuration.h -$TOOL "$EXAMPLES/$RDIR/Configuration_adv.h" >/dev/null 2>&1 && mv wgot Configuration_adv.h -$TOOL "$EXAMPLES/$RDIR/_Bootscreen.h" >/dev/null 2>&1 && mv wgot _Bootscreen.h -$TOOL "$EXAMPLES/$RDIR/_Statusscreen.h" >/dev/null 2>&1 && mv wgot _Statusscreen.h +$TOOL "$CONFIGS/Configuration.h" >/dev/null 2>&1 && mv wgot Configuration.h +$TOOL "$CONFIGS/Configuration_adv.h" >/dev/null 2>&1 && mv wgot Configuration_adv.h +$TOOL "$CONFIGS/_Bootscreen.h" >/dev/null 2>&1 && mv wgot _Bootscreen.h +$TOOL "$CONFIGS/_Statusscreen.h" >/dev/null 2>&1 && mv wgot _Statusscreen.h rm -f wgot cd - >/dev/null diff --git a/buildroot/share/PlatformIO/boards/marlin_BTT_EBB42_V1_1.json b/buildroot/share/PlatformIO/boards/marlin_BTT_EBB42_V1_1.json new file mode 100644 index 000000000000..51b6b9984e39 --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_BTT_EBB42_V1_1.json @@ -0,0 +1,47 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m0plus", + "extra_flags": "-DSTM32G0xx -DSTM32G0B1xx", + "f_cpu": "64000000L", + "framework_extra_flags": { + "arduino": "-D__CORTEX_SC=0" + }, + "mcu": "stm32g0b1cbt6", + "product_line": "STM32G0B1xx", + "variant": "MARLIN_BTT_EBB42_V1_1" + }, + "debug": { + "default_tools": [ + "stlink" + ], + "jlink_device": "STM32G0B1CB", + "onboard_tools": [ + "stlink" + ], + "openocd_target": "stm32g0x", + "svd_path": "STM32G0B1.svd" + }, + "frameworks": [ + "arduino", + "cmsis", + "libopencm3", + "stm32cube", + "zephyr" + ], + "name": "STM32G0B1CB", + "upload": { + "maximum_ram_size": 147456, + "maximum_size": 131072, + "protocol": "stlink", + "protocols": [ + "stlink", + "jlink", + "cmsis-dap", + "blackmagic", + "mbed" + ] + }, + "url": "https://www.st.com/content/st_com/en/products/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus/stm32-mainstream-mcus/stm32g0-series/stm32g0x1.html", + "vendor": "ST" +} diff --git a/buildroot/share/PlatformIO/boards/marlin_BTT_SKR_SE_BX.json b/buildroot/share/PlatformIO/boards/marlin_BTT_SKR_SE_BX.json index 65735d433b17..3ed21e393b9c 100644 --- a/buildroot/share/PlatformIO/boards/marlin_BTT_SKR_SE_BX.json +++ b/buildroot/share/PlatformIO/boards/marlin_BTT_SKR_SE_BX.json @@ -3,7 +3,7 @@ "core": "stm32", "cpu": "cortex-m7", "extra_flags": "-DSTM32H743xx", - "f_cpu": "400000000L", + "f_cpu": "480000000L", "mcu": "stm32h743iit6", "variant": "MARLIN_BTT_SKR_SE_BX" }, diff --git a/buildroot/share/PlatformIO/boards/marlin_FYSETC_CHEETAH_V20.json b/buildroot/share/PlatformIO/boards/marlin_FYSETC_CHEETAH_V20.json index 6c2e093c3bad..7dd7542c6d0c 100644 --- a/buildroot/share/PlatformIO/boards/marlin_FYSETC_CHEETAH_V20.json +++ b/buildroot/share/PlatformIO/boards/marlin_FYSETC_CHEETAH_V20.json @@ -55,7 +55,7 @@ "dfu", "jlink" ], - "offset_address": "0x8008000", + "offset_address": "0x8008000", "require_upload_port": true, "use_1200bps_touch": false, "wait_for_upload_port": false diff --git a/buildroot/share/PlatformIO/boards/marlin_STEVAL_STM32F401VE.json b/buildroot/share/PlatformIO/boards/marlin_MKS_ROBIN2.json similarity index 73% rename from buildroot/share/PlatformIO/boards/marlin_STEVAL_STM32F401VE.json rename to buildroot/share/PlatformIO/boards/marlin_MKS_ROBIN2.json index e260950f25d5..325001df1b44 100644 --- a/buildroot/share/PlatformIO/boards/marlin_STEVAL_STM32F401VE.json +++ b/buildroot/share/PlatformIO/boards/marlin_MKS_ROBIN2.json @@ -1,9 +1,8 @@ { "build": { - "core": "stm32", "cpu": "cortex-m4", - "extra_flags": "-DSTM32F401xx -DARDUINO_STEVAL", - "f_cpu": "84000000L", + "extra_flags": "-DSTM32F407xx", + "f_cpu": "168000000L", "hwids": [ [ "0x1EAF", @@ -14,11 +13,12 @@ "0x3748" ] ], - "mcu": "stm32f401vet6", - "variant": "MARLIN_STEVAL_F401VE" + "ldscript": "ldscript.ld", + "mcu": "stm32f407zet6", + "variant": "MARLIN_MKS_ROBIN2" }, "debug": { - "jlink_device": "STM32F401VE", + "jlink_device": "STM32F407ZE", "openocd_target": "stm32f4x", "svd_path": "STM32F40x.svd", "tools": { @@ -44,21 +44,22 @@ "arduino", "stm32cube" ], - "name": "STM32F401VE (96k RAM. 512k Flash)", + "name": "STM32F407ZE (192k RAM. 512k Flash)", "upload": { "disable_flushing": false, - "maximum_ram_size": 98304, + "maximum_ram_size": 131072, "maximum_size": 514288, "protocol": "stlink", "protocols": [ "stlink", "dfu", - "jlink" + "jlink", + "cmsis-dap" ], "require_upload_port": true, "use_1200bps_touch": false, "wait_for_upload_port": false }, - "url": "https://www.st.com/en/evaluation-tools/steval-3dp001v1.html", + "url": "http://www.st.com/en/microcontrollers/stm32f407ze.html", "vendor": "Generic" } 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/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/boards/marlin_STM32F407ZE.json b/buildroot/share/PlatformIO/boards/marlin_STM32F407ZE.json new file mode 100644 index 000000000000..ce09de53c41c --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_STM32F407ZE.json @@ -0,0 +1,50 @@ +{ + "build": { + "cpu": "cortex-m4", + "extra_flags": "-DSTM32F4 -DSTM32F407xx", + "f_cpu": "168000000L", + "mcu": "stm32f407zgt6", + "product_line": "STM32F407xx", + "variant": "MARLIN_F407ZE" + }, + "connectivity": [ + "can" + ], + "debug": { + "default_tools": [ + "stlink" + ], + "jlink_device": "STM32F407ZE", + "onboard_tools": [ + "stlink" + ], + "openocd_board": "stm32f407", + "openocd_target": "stm32f4x", + "svd_path": "STM32F407x.svd" + }, + "frameworks": [ + "arduino", + "cmsis", + "mbed", + "stm32cube", + "libopencm3", + "zephyr" + ], + "name": "STM32F407ZE (128k RAM, 64k CCM RAM, 512k Flash", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 131072, + "maximum_size": 524288, + "protocol": "stlink", + "protocols": [ + "stlink", + "dfu", + "jlink" + ], + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f407-417.html", + "vendor": "ST" +} 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/boards/marlin_STM32G0B1VE.json b/buildroot/share/PlatformIO/boards/marlin_STM32G0B1VE.json new file mode 100644 index 000000000000..a3ac6ea6793a --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_STM32G0B1VE.json @@ -0,0 +1,47 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m0plus", + "extra_flags": "-DSTM32G0xx -DSTM32G0B1xx", + "f_cpu": "64000000L", + "framework_extra_flags": { + "arduino": "-D__CORTEX_SC=0" + }, + "mcu": "stm32g0b1vet6", + "product_line": "STM32G0B1xx", + "variant": "MARLIN_G0B1VE" + }, + "debug": { + "default_tools": [ + "stlink" + ], + "jlink_device": "STM32G0B1VE", + "onboard_tools": [ + "stlink" + ], + "openocd_target": "stm32g0x", + "svd_path": "STM32G0B1.svd" + }, + "frameworks": [ + "arduino", + "cmsis", + "libopencm3", + "stm32cube", + "zephyr" + ], + "name": "STM32G0B1VE", + "upload": { + "maximum_ram_size": 147456, + "maximum_size": 524288, + "protocol": "stlink", + "protocols": [ + "stlink", + "jlink", + "cmsis-dap", + "blackmagic", + "mbed" + ] + }, + "url": "https://www.st.com/content/st_com/en/products/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus/stm32-mainstream-mcus/stm32g0-series/stm32g0x1.html", + "vendor": "ST" +} diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32H723Vx.json b/buildroot/share/PlatformIO/boards/marlin_STM32H723Vx.json new file mode 100644 index 000000000000..a2154d448a9e --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_STM32H723Vx.json @@ -0,0 +1,61 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m7", + "extra_flags": "-DSTM32H7xx -DSTM32H723xx", + "f_cpu": "550000000L", + "mcu": "stm32h723vet6", + "product_line": "STM32H723xx", + "variant": "MARLIN_H723Vx" + }, + "connectivity": [ + "can", + "ethernet" + ], + "debug": { + "jlink_device": "STM32H723VE", + "openocd_target": "stm32h7x", + "svd_path": "STM32H7x3.svd", + "tools": { + "stlink": { + "server": { + "arguments": [ + "-f", + "scripts/interface/stlink.cfg", + "-c", + "transport select hla_swd", + "-f", + "scripts/target/stm32h7x.cfg", + "-c", + "reset_config none" + ], + "executable": "bin/openocd", + "package": "tool-openocd" + } + } + } + }, + "frameworks": [ + "arduino", + "stm32cube" + ], + "name": "STM32H723VE (564k RAM. 512k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 577536, + "maximum_size": 524288, + "protocol": "stlink", + "protocols": [ + "stlink", + "dfu", + "jlink", + "cmsis-dap" + ], + "offset_address": "0x8020000", + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32h723ze.html", + "vendor": "ST" +} diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32H723Zx.json b/buildroot/share/PlatformIO/boards/marlin_STM32H723Zx.json new file mode 100644 index 000000000000..8525793c4e01 --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_STM32H723Zx.json @@ -0,0 +1,61 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m7", + "extra_flags": "-DSTM32H7xx -DSTM32H723xx", + "f_cpu": "550000000L", + "mcu": "stm32h723zet6", + "product_line": "STM32H723xx", + "variant": "MARLIN_H723Zx" + }, + "connectivity": [ + "can", + "ethernet" + ], + "debug": { + "jlink_device": "STM32H723ZE", + "openocd_target": "stm32h7x", + "svd_path": "STM32H7x3.svd", + "tools": { + "stlink": { + "server": { + "arguments": [ + "-f", + "scripts/interface/stlink.cfg", + "-c", + "transport select hla_swd", + "-f", + "scripts/target/stm32h7x.cfg", + "-c", + "reset_config none" + ], + "executable": "bin/openocd", + "package": "tool-openocd" + } + } + } + }, + "frameworks": [ + "arduino", + "stm32cube" + ], + "name": "STM32H723ZE (564k RAM. 512k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 577536, + "maximum_size": 524288, + "protocol": "stlink", + "protocols": [ + "stlink", + "dfu", + "jlink", + "cmsis-dap" + ], + "offset_address": "0x8020000", + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32h723ze.html", + "vendor": "ST" +} 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/buildroot/share/PlatformIO/boards/marlin_index_mobo_rev03.json b/buildroot/share/PlatformIO/boards/marlin_opulo_lumen_rev3.json similarity index 100% rename from buildroot/share/PlatformIO/boards/marlin_index_mobo_rev03.json rename to buildroot/share/PlatformIO/boards/marlin_opulo_lumen_rev3.json 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/buildroot/share/PlatformIO/debugging/launch.json b/buildroot/share/PlatformIO/debugging/launch.json index 583d860eb36c..f9936ebcedf9 100644 --- a/buildroot/share/PlatformIO/debugging/launch.json +++ b/buildroot/share/PlatformIO/debugging/launch.json @@ -25,15 +25,26 @@ "svdFile": "${env:HOME}/.platformio/platforms/ststm32@12.1.1/misc/svd/STM32F40x.svd", }, { - "name": "Debug Sim", + "name": "Launch Sim (ggdb)", "request": "launch", "type": "cppdbg", "cwd": "${workspaceRoot}", - //"program": ".pio/build/simulator_linux_debug/MarlinSimulator", - //"program": ".pio/build/simulator_windows/MarlinSimulator", - "program": ".pio/build/simulator_macos_debug/MarlinSimulator", + "program": "${workspaceRoot}/.pio/build/simulator_macos_debug/debug/MarlinSimulator", + //"program": "${workspaceRoot}/.pio/build/simulator_linux_debug/MarlinSimulator", + //"program": "${workspaceRoot}/.pio/build/simulator_windows/MarlinSimulator", "miDebuggerPath": "/opt/local/bin/ggdb", "MIMode": "gdb" + }, + { + "name": "Launch Sim (lldb)", + "request": "launch", + "type": "cppdbg", + "cwd": "${workspaceRoot}", + "program": "${workspaceRoot}/.pio/build/simulator_macos_debug/debug/MarlinSimulator", + //"program": "${workspaceRoot}/.pio/build/simulator_linux_debug/MarlinSimulator", + //"program": "${workspaceRoot}/.pio/build/simulator_windows/MarlinSimulator", + //"targetArchitecture": "arm64", + "MIMode": "lldb" } ] } diff --git a/buildroot/share/PlatformIO/ldscripts/sovol.ld b/buildroot/share/PlatformIO/ldscripts/sovol.ld new file mode 100644 index 000000000000..785345543c0c --- /dev/null +++ b/buildroot/share/PlatformIO/ldscripts/sovol.ld @@ -0,0 +1,14 @@ +MEMORY +{ + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - 40 + rom (rx) : ORIGIN = 0x08007000, LENGTH = 512K - 28K +} + +/* Provide memory region aliases for common.inc */ +REGION_ALIAS("REGION_TEXT", rom); +REGION_ALIAS("REGION_DATA", ram); +REGION_ALIAS("REGION_BSS", ram); +REGION_ALIAS("REGION_RODATA", rom); + +/* Let common.inc handle the real work. */ +INCLUDE common.inc diff --git a/buildroot/share/PlatformIO/scripts/SAMD21_minitronics20.py b/buildroot/share/PlatformIO/scripts/SAMD21_minitronics20.py new file mode 100644 index 000000000000..81099f58ccef --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/SAMD21_minitronics20.py @@ -0,0 +1,19 @@ +# +# SAMD21_minitronics20.py +# Customizations for env:SAMD21_minitronics20 +# +import pioutil +if pioutil.is_pio_build(): + from os.path import join, isfile + import shutil + + 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" + + serialBuf = str(max(int(rxBuf), int(txBuf), 350)) + + build_flags = env.get('BUILD_FLAGS') + env.Replace(BUILD_FLAGS=build_flags) 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/STM32F103RC_MEEB_3DP.py b/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py index 551f4c63160b..4f2da9cdc0d0 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py +++ b/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py @@ -4,17 +4,16 @@ import pioutil if pioutil.is_pio_build(): - import os - 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 c9794702c34a..ecb0cc145c04 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py +++ b/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py @@ -3,26 +3,25 @@ # import pioutil if pioutil.is_pio_build(): - import os - 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 592fa50e5e68..4189cb5899bc 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py +++ b/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py @@ -3,30 +3,29 @@ # import pioutil if pioutil.is_pio_build(): - import os,shutil,marlin - from SCons.Script import DefaultEnvironment - from platformio import util + import shutil,marlin + from pathlib import Path - env = DefaultEnvironment() - platform = env.PioPlatform() - board = env.BoardConfig() + Import("env") + platform = env.PioPlatform() + board = env.BoardConfig() - FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoststm32-maple") - assert os.path.isdir(FRAMEWORK_DIR) + FRAMEWORK_DIR = Path(platform.get_package_dir("framework-arduinoststm32-maple")) + assert FRAMEWORK_DIR.is_dir() - source_root = os.path.join("buildroot", "share", "PlatformIO", "variants") - assert os.path.isdir(source_root) + source_root = Path("buildroot/share/PlatformIO/variants") + assert source_root.is_dir() - variant = board.get("build.variant") - variant_dir = os.path.join(FRAMEWORK_DIR, "STM32F1", "variants", variant) + variant = board.get("build.variant") + variant_dir = FRAMEWORK_DIR / "STM32F1/variants" / variant - source_dir = os.path.join(source_root, variant) - assert os.path.isdir(source_dir) + source_dir = source_root / variant + assert source_dir.is_dir() - if os.path.isdir(variant_dir): - shutil.rmtree(variant_dir) + if variant_dir.is_dir(): + shutil.rmtree(variant_dir) - if not os.path.isdir(variant_dir): - os.mkdir(variant_dir) + 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/PlatformIO/scripts/chitu_crypt.py b/buildroot/share/PlatformIO/scripts/chitu_crypt.py index b28156bfb9f1..4e81061a19ad 100644 --- a/buildroot/share/PlatformIO/scripts/chitu_crypt.py +++ b/buildroot/share/PlatformIO/scripts/chitu_crypt.py @@ -4,114 +4,123 @@ # import pioutil if pioutil.is_pio_build(): - import os,random,struct,uuid,marlin - # Relocate firmware from 0x08000000 to 0x08008800 - marlin.relocate_firmware("0x08008800") + import struct,uuid,marlin - def calculate_crc(contents, seed): - accumulating_xor_value = seed; + board = marlin.env.BoardConfig() - for i in range(0, len(contents), 4): - value = struct.unpack('> ip + # xor_seed = (loop_counter * loop_counter) + block_number + xor_seed = (loop_counter * loop_counter) + block_number - # load a byte into IP - ip = r0[loop_counter] + # shift the xor_seed left by the bits in IP. + xor_seed = xor_seed >> ip - # XOR the seed with r7 - xor_seed = xor_seed ^ r7 + # load a byte into IP + ip = r0[loop_counter] - # and then with IP - xor_seed = xor_seed ^ ip + # XOR the seed with r7 + xor_seed = xor_seed ^ r7 - #Now store the byte back - r1[loop_counter] = xor_seed & 0xFF + # and then with IP + xor_seed = xor_seed ^ ip - #increment the loop_counter - loop_counter = loop_counter + 1 + #Now store the byte back + r1[loop_counter] = xor_seed & 0xFF - def encrypt_file(input, output_file, file_length): - input_file = bytearray(input.read()) - block_size = 0x800 - key_length = 0x18 + #increment the loop_counter + loop_counter = loop_counter + 1 - uid_value = uuid.uuid4() - file_key = int(uid_value.hex[0:8], 16) + def encrypt_file(input, output_file, file_length): + input_file = bytearray(input.read()) + block_size = 0x800 + key_length = 0x18 - xor_crc = 0xEF3D4323; + uid_value = uuid.uuid4() + file_key = int(uid_value.hex[0:8], 16) - # 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') + xor_crc = 0xEF3D4323; - # write the file header - output_file.write(struct.pack(">I", 0x443D2D3F)) - # encrypt the contents using a known file header key + # 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_key - output_file.write(struct.pack("I", 0x443D2D3F)) + # encrypt the contents using a known file header key - #TODO - how to enforce that the firmware aligns to block boundaries? - block_count = int(len(input_file) / block_size) - print ("Block Count is ", block_count) - for block_number in range(0, block_count): - block_offset = (block_number * block_size) - block_end = block_offset + block_size - block_array = bytearray(input_file[block_offset: block_end]) - xor_block(block_array, block_array, block_number, block_size, file_key) - for n in range (0, block_size): - input_file[block_offset + n] = block_array[n] + # 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_config(): - blab("========== Gather [features] entries...") - items = ProjectConfig().items('features') - for key in items: - 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...") - all_opts = env.GetProjectOptions() - for n in all_opts: - key = n[0] - mat = re.match(r'custom_marlin\.(.+)', key) - if mat: - try: - val = env.GetProjectOption(key) - except: - val = None - if val: - opt = mat.group(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_config() - blab("========== Apply enabled features...") - for feature in FEATURE_CONFIG: - if not env.MarlinFeatureIsEnabled(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 MarlinFeatureIsEnabled(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.MarlinFeatureIsEnabled(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(MarlinFeatureIsEnabled) - - # - # 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', 'build_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)') + if not 'lib_deps' in feat: feat['lib_deps'] = {} + 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 'build_src_filter' in feat: + blab("========== Adding build_src_filter for %s... " % feature, 2) + build_src_filter = ' '.join(env.GetProjectOption('build_src_filter')) + # first we need to remove the references to the same folder + my_srcs = re.findall(r'[+-](<.*?>)', feat['build_src_filter']) + cur_srcs = re.findall(r'[+-](<.*?>)', build_src_filter) + for d in my_srcs: + if d in cur_srcs: + build_src_filter = re.sub(r'[+-]' + d, '', build_src_filter) + + build_src_filter = feat['build_src_filter'] + ' ' + build_src_filter + set_env_field('build_src_filter', [build_src_filter]) + env.Replace(SRC_FILTER=build_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 new file mode 100644 index 000000000000..250d9bbd7f11 --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/configuration.py @@ -0,0 +1,250 @@ +# +# configuration.py +# Apply options from config.ini to the existing Configuration headers +# +import re, shutil, configparser +from pathlib import Path + +verbose = 0 +def blab(str,level=1): + if verbose >= level: print(f"[config] {str}") + +def config_path(cpath): + return Path("Marlin", cpath, encoding='utf-8') + +# 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 + # 1: Indentation + # 2: Comment + # 3: #define and whitespace + # 4: Option name + # 5: First space after name + # 6: Remaining spaces between name and value + # 7: Option value + # 8: Whitespace after value + # 9: End comment + regex = re.compile(rf'^(\s*)(//\s*)?(#define\s+)({name}\b)(\s?)(\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(encoding='utf-8').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 + addsp = '' if match[5] else ' ' + newline = match[1] + match[3] + match[4] + match[5] + addsp + val + match[6] + if match[9]: + sp = match[8] if match[8] else ' ' + newline += sp + match[9] + 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), encoding='utf-8') + 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(encoding='utf-8') 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: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. +def fetch_example(url): + if url.endswith("/"): url = url[:-1] + if not url.startswith('http'): + brch = "bugfix-2.1.x" + if '@' in url: url, brch = map(str.strip, url.split('@')) + if url == 'examples/default': url = 'default' + url = f"https://raw.githubusercontent.com/MarlinFirmware/Configurations/{brch}/config/{url}" + url = url.replace("%", "%25").replace(" ", "%20") + + # 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 checkout HEAD Marlin/*.h") + + # 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 [] + +# 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 = section_items(cp, sect) + + 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) + +# 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) + +# 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 = map(str.strip, ckey.split('@')) + cp2 = configparser.ConfigParser() + cp2.read(config_path(ckey)) + apply_sections(cp2, sect) + ckey = 'base'; + + # (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. + if ckey.startswith('examples/') or ckey.startswith('http'): + fetch_example(ckey) + ckey = 'base' + + if ckey == 'all': + apply_sections(cp) + + else: + # 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) + +else: + # + # From within PlatformIO use the loaded INI file + # + import pioutil + if pioutil.is_pio_build(): + + Import("env") + + try: + verbose = int(env.GetProjectOption('custom_verbose')) + except: + pass + + 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 199040022282..661fb2e438e4 100644 --- a/buildroot/share/PlatformIO/scripts/download_mks_assets.py +++ b/buildroot/share/PlatformIO/scripts/download_mks_assets.py @@ -4,46 +4,50 @@ # import pioutil if pioutil.is_pio_build(): - Import("env") - import os,requests,zipfile,tempfile,shutil + 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 = env.Dictionary("PROJECT_LIBDEPS_DIR") - zip_path = os.path.join(deps_path, "mks-assets.zip") - assets_path = os.path.join(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 os.path.exists(deps_path) == False: - os.mkdir(deps_path) - with open(zip_path, '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 = tempfile.mkdtemp() - zip_obj = zipfile.ZipFile(zip_path, 'r') - zip_obj.extractall(output_path) - zip_obj.close() - if os.path.exists(assets_path) == True and os.path.isdir(assets_path) == False: - os.unlink(assets_path) - if os.path.exists(assets_path) == False: - os.mkdir(assets_path) - base_path = '' - for filename in os.listdir(output_path): - base_path = filename - for filename in os.listdir(os.path.join(output_path, base_path, 'Firmware', 'mks_font')): - shutil.copy(os.path.join(output_path, base_path, 'Firmware', 'mks_font', filename), assets_path) - for filename in os.listdir(os.path.join(output_path, base_path, 'Firmware', 'mks_pic')): - shutil.copy(os.path.join(output_path, base_path, 'Firmware', 'mks_pic', 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 os.path.exists(zip_path) == False: - download_mks_assets() + if not zip_path.exists(): + download_mks_assets() - if os.path.exists(assets_path) == False: - 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 663e7c76d96a..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.MarlinFeatureIsEnabled("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 d572873ad764..49d4c98d3e15 100644 --- a/buildroot/share/PlatformIO/scripts/generic_create_variant.py +++ b/buildroot/share/PlatformIO/scripts/generic_create_variant.py @@ -7,50 +7,52 @@ # import pioutil if pioutil.is_pio_build(): - import os,shutil,marlin - from SCons.Script import DefaultEnvironment - from platformio import util - - env = DefaultEnvironment() - - # - # Get the platform name from the 'platform_packages' option, - # or look it up by the platform.class.name. - # - platform = env.PioPlatform() - - from platformio.package.meta import PackageSpec - platform_packages = env.GetProjectOption('platform_packages') - 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 = platform.get_package_dir(platform_name) - assert os.path.isdir(FRAMEWORK_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 = os.path.join(FRAMEWORK_DIR, "variants", variant) - if os.path.isdir(variant_dir): - shutil.rmtree(variant_dir) - if not os.path.isdir(variant_dir): - os.mkdir(variant_dir) - - # Source dir is a local variant sub-folder - source_dir = os.path.join("buildroot/share/PlatformIO/variants", variant) - assert os.path.isdir(source_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 0af9c1046d1e..9256751096c5 100644 --- a/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py +++ b/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py @@ -4,37 +4,32 @@ # import pioutil if pioutil.is_pio_build(): - import os,marlin - # Append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin' - def addboot(source, target, env): - firmware = open(target[0].path, "rb") - lengthfirmware = os.path.getsize(target[0].path) - bootloader_bin = "buildroot/share/PlatformIO/scripts/" + "jgaurora_bootloader.bin" - bootloader = open(bootloader_bin, "rb") - lengthbootloader = os.path.getsize(bootloader_bin) - firmware_with_boothloader_bin = target[0].dir.path + '/firmware_with_bootloader.bin' - if os.path.exists(firmware_with_boothloader_bin): - os.remove(firmware_with_boothloader_bin) - firmwareimage = open(firmware_with_boothloader_bin, "wb") - position = 0 - while position < lengthbootloader: - byte = bootloader.read(1) - firmwareimage.write(byte) - position += 1 - position = 0 - while position < lengthfirmware: - byte = firmware.read(1) - firmwareimage.write(byte) - position += 1 - bootloader.close() - firmware.close() - firmwareimage.close() + # Append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin' + def addboot(source, target, env): + from pathlib import Path - firmware_without_bootloader_bin = target[0].dir.path + '/firmware_for_sd_upload.bin' - if os.path.exists(firmware_without_bootloader_bin): - os.remove(firmware_without_bootloader_bin) - os.rename(target[0].path, firmware_without_bootloader_bin) - #os.rename(target[0].dir.path+'/firmware_with_bootloader.bin', target[0].dir.path+'/firmware.bin') + 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) - marlin.add_post_action(addboot); + 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() + + fw_path.rename(fws_path) + + import marlin + marlin.add_post_action(addboot); diff --git a/buildroot/share/PlatformIO/scripts/lerdge.py b/buildroot/share/PlatformIO/scripts/lerdge.py index 505a935560a9..607fe312ac84 100644 --- a/buildroot/share/PlatformIO/scripts/lerdge.py +++ b/buildroot/share/PlatformIO/scripts/lerdge.py @@ -7,43 +7,41 @@ # import pioutil if pioutil.is_pio_build(): - import os,marlin - Import("env") + import os,marlin - from SCons.Script import DefaultEnvironment - board = DefaultEnvironment().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.encrypt - def encrypt(source, target, env): - fwpath = target[0].path - enname = board.get("build.encrypt") - 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 'encrypt' in board.get("build").keys(): - if board.get("build.encrypt") != "": - marlin.add_post_action(encrypt) - else: - print("LERDGE builds require output file via board_build.encrypt = '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 8ac36b7d59b5..8d8dbb5b63d4 100644 --- a/buildroot/share/PlatformIO/scripts/marlin.py +++ b/buildroot/share/PlatformIO/scripts/marlin.py @@ -2,74 +2,72 @@ # marlin.py # Helper module with some commonly-used functions # -import os,shutil +import shutil +from pathlib import Path from SCons.Script import DefaultEnvironment env = DefaultEnvironment() -from os.path import join - def copytree(src, dst, symlinks=False, ignore=None): - for item in os.listdir(src): - s = join(src, item) - d = join(dst, item) - if os.path.isdir(s): - shutil.copytree(s, d, symlinks, ignore) - else: - shutil.copy2(s, d) + 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)) + envdefs = env['CPPDEFINES'].copy() + for define in envdefs: + 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 = os.path.abspath("buildroot/share/PlatformIO/ldscripts/" + ldname) - 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 -# Called by specific encrypt() functions, mostly for MKS boards +# 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 = target[0].path - fwfile = open(fwpath, "rb") - enfile = open(target[0].dir.path + "/" + new_name, "wb") - length = os.path.getsize(fwpath) - position = 0 - try: - while position < length: - byte = fwfile.read(1) - if position >= 320 and 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() - os.remove(fwpath) + 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(join("$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..b42ba12f7adf 100755 --- a/buildroot/share/PlatformIO/scripts/mc-apply.py +++ b/buildroot/share/PlatformIO/scripts/mc-apply.py @@ -5,65 +5,64 @@ 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' 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 ddbb786fecd1..de14ccbbbf5f 100644 --- a/buildroot/share/PlatformIO/scripts/offset_and_rename.py +++ b/buildroot/share/PlatformIO/scripts/offset_and_rename.py @@ -2,61 +2,64 @@ # 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 os,sys,marlin - Import("env") + import marlin - from SCons.Script import DefaultEnvironment - board = DefaultEnvironment().BoardConfig() + env = marlin.env + board = env.BoardConfig() + board_keys = board.get("build").keys() - 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) - # - # 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) - # 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") - # 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 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: - # - # For build.encrypt rename and encode the firmware file. - # - if 'encrypt' 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")) - # Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt - def encrypt(source, target, env): - marlin.encrypt_mks(source, target, env, board.get("build.encrypt")) + if board.get("build.encrypt_mks") != "": + marlin.add_post_action(encrypt) - if board.get("build.encrypt") != "": - marlin.add_post_action(encrypt) + # + # For build.rename simply rename the firmware file. + # + if 'rename' in board_keys: - # - # For build.rename simply rename the firmware file. - # - 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): - firmware = os.path.join(target[0].dir.path, board.get("build.rename")) - os.replace(target[0].path, firmware) + def rename_target(source, target, env): + from pathlib import Path + Path(target[0].path).replace(Path(target[0].dir.path, new_name)) - marlin.add_post_action(rename_target) + marlin.add_post_action(rename_target) diff --git a/buildroot/share/PlatformIO/scripts/openblt.py b/buildroot/share/PlatformIO/scripts/openblt.py index 61b38a5e87f7..6db8727ce4eb 100644 --- a/buildroot/share/PlatformIO/scripts/openblt.py +++ b/buildroot/share/PlatformIO/scripts/openblt.py @@ -3,18 +3,17 @@ # import pioutil if pioutil.is_pio_build(): - import os,sys - from os.path import join + from os.path import join - Import("env") + Import("env") - board = env.BoardConfig() - board_keys = board.get("build").keys() - if 'encrypt' 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.encrypt")) + "\"" - ]), "Building $TARGET") - ) + 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 b8c1e9cfca6c..18e6dba92889 100644 --- a/buildroot/share/PlatformIO/scripts/pioutil.py +++ b/buildroot/share/PlatformIO/scripts/pioutil.py @@ -4,5 +4,11 @@ # Make sure 'vscode init' is not the current command def is_pio_build(): - from SCons.Script import COMMAND_LINE_TARGETS - return "idedata" not in COMMAND_LINE_TARGETS and "_idedata" not in COMMAND_LINE_TARGETS + from SCons.Script import DefaultEnvironment + env = DefaultEnvironment() + if "IsCleanTarget" in dir(env) and env.IsCleanTarget(): return False + return not env.IsIntegrationDump() + +def get_pio_version(): + 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 dbd0510b5dff..3f7c97af9d78 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -5,109 +5,134 @@ import pioutil if pioutil.is_pio_build(): - import os,re,sys - Import("env") - - def get_envs_for_board(board): - with open(os.path.join("Marlin", "src", "pins", "pins.h"), "r") 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") - - 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 - # - for p in [ env['PROJECT_DIR'], os.path.join(env['PROJECT_DIR'], "config") ]: - for f in [ "Configuration.h", "Configuration_adv.h" ]: - if os.path.isfile(os.path.join(p, f)): - err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p - raise SystemExit(err) - - # - # Give warnings on every build - # - srcpath = os.path.join(env['PROJECT_BUILD_DIR'], build_env, "src", "src") - warnfile = os.path.join(srcpath, "inc", "Warnings.cpp.o") - if os.path.exists(warnfile): - os.remove(warnfile) - - # - # Rebuild 'settings.cpp' for EEPROM_INIT_NOW - # - if 'EEPROM_INIT_NOW' in env['MARLIN_FEATURES']: - setfile = os.path.join(srcpath, "module", "settings.cpp.o") - if os.path.exists(setfile): - os.remove(setfile) - - # - # Check for old files indicating an entangled Marlin (mixing old and new code) - # - mixedin = [] - p = os.path.join(env['PROJECT_DIR'], "Marlin", "src", "lcd", "dogm") - for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]: - if os.path.isfile(os.path.join(p, f)): - mixedin += [ f ] - p = os.path.join(env['PROJECT_DIR'], "Marlin", "src", "feature", "bedlevel", "abl") - for f in [ "abl.cpp", "abl.h" ]: - if os.path.isfile(os.path.join(p, f)): - 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 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 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'] + 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) + + # + # Check FILAMENT_RUNOUT_SCRIPT has a %c parammeter when required + # + if 'FILAMENT_RUNOUT_SENSOR' in env['MARLIN_FEATURES'] and 'NUM_RUNOUT_SENSORS' in env['MARLIN_FEATURES']: + if env['MARLIN_FEATURES']['NUM_RUNOUT_SENSORS'].isdigit() and int(env['MARLIN_FEATURES']['NUM_RUNOUT_SENSORS']) > 1: + if 'FILAMENT_RUNOUT_SCRIPT' in env['MARLIN_FEATURES']: + frs = env['MARLIN_FEATURES']['FILAMENT_RUNOUT_SCRIPT'] + if "M600" in frs and "%c" not in frs: + err = "ERROR: FILAMENT_RUNOUT_SCRIPT needs a %c parameter (e.g., \"M600 T%c\") when NUM_RUNOUT_SENSORS is > 1" + raise SystemExit(err) + + sanity_check_target() diff --git a/buildroot/share/PlatformIO/scripts/preprocessor.py b/buildroot/share/PlatformIO/scripts/preprocessor.py index d9c472006c28..b0fec52bfa10 100644 --- a/buildroot/share/PlatformIO/scripts/preprocessor.py +++ b/buildroot/share/PlatformIO/scripts/preprocessor.py @@ -1,14 +1,14 @@ # # preprocessor.py # -import subprocess,os,re +import subprocess nocache = 1 verbose = 0 def blab(str): - if verbose: - print(str) + if verbose: + print(str) ################################################################################ # @@ -16,33 +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) - define_list = subprocess.check_output(cmd, shell=True).splitlines() - 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 ################################################################################ @@ -51,51 +54,41 @@ def run_preprocessor(env, fn=None): # def search_compiler(env): - ENV_BUILD_PATH = os.path.join(env['PROJECT_BUILD_DIR'], env['PIOENV']) - GCC_PATH_CACHE = os.path.join(ENV_BUILD_PATH, ".gcc_path") - - try: - filepath = env.GetProjectOption('custom_gcc') - blab("Getting compiler from env") - return filepath - except: - pass - - # Warning: The cached .gcc_path will obscure a newly-installed toolkit - if not nocache and os.path.exists(GCC_PATH_CACHE): - blab("Getting g++ path from cache") - with open(GCC_PATH_CACHE, 'r') as f: - return f.read() - - # Find the current platform compiler by searching the $PATH - # which will be in a platformio toolchain bin folder - path_regex = re.escape(env['PROJECT_PACKAGES_DIR']) - gcc = "g++" - if env['PLATFORM'] == 'win32': - path_separator = ';' - path_regex += r'.*\\bin' - gcc += ".exe" - else: - path_separator = ':' - path_regex += r'/.+/bin' - - # Search for the compiler - for pathdir in env['ENV']['PATH'].split(path_separator): - if not re.search(path_regex, pathdir, re.IGNORECASE): - continue - for filepath in os.listdir(pathdir): - if not filepath.endswith(gcc): - continue - # Use entire path to not rely on env PATH - filepath = os.path.sep.join([pathdir, filepath]) - # Cache the g++ path to no search always - if not nocache and os.path.exists(ENV_BUILD_PATH): - blab("Caching g++ for current env") - with open(GCC_PATH_CACHE, 'w+') as f: - f.write(filepath) - - return filepath - - filepath = env.get('CXX') - blab("Couldn't find a compiler! Fallback to %s" % filepath) - return filepath + 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 new file mode 100755 index 000000000000..103aa1f072dc --- /dev/null +++ b/buildroot/share/PlatformIO/scripts/schema.py @@ -0,0 +1,421 @@ +#!/usr/bin/env python3 +# +# schema.py +# +# Used by signature.py via common-dependencies.py to generate a schema file during the PlatformIO build. +# This script can also be run standalone from within the Marlin repo to generate all schema files. +# +import re,json +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]] = {} + +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)$') +] +# 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)) + +# 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] + +# 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 '' + +# +# 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 + +def dump_json(schema:dict, jpath:Path): + 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) + +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')) + +if __name__ == '__main__': + main() diff --git a/buildroot/share/PlatformIO/scripts/signature.py b/buildroot/share/PlatformIO/scripts/signature.py index 593f9580b330..84312da01bd9 100644 --- a/buildroot/share/PlatformIO/scripts/signature.py +++ b/buildroot/share/PlatformIO/scripts/signature.py @@ -1,43 +1,47 @@ # # signature.py # -import os,subprocess,re,json,hashlib +import schema + +import subprocess,re,json,hashlib +from datetime import datetime +from pathlib import Path # -# The dumbest preprocessor in the world -# Extract macro name from an header file and store them in an array -# No processing is done here, so they are raw values here and it does not match what actually enabled -# in the file (since you can have #if SOMETHING_UNDEFINED / #define BOB / #endif) -# But it's useful to filter the useful macro spit out by the preprocessor from noise from the system -# headers. +# Return all macro names in a header as an array, so we can take +# the intersection with the preprocessor output, giving a decent +# reflection of all enabled options that (probably) came from the +# configuration files. We end up with the actual configured state, +# better than what the config files say. You can then use the +# 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(" \t\n\r") - 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, outputbase): - with zipfile.ZipFile(outputbase + '.zip', 'w', compression=zipfile.ZIP_BZIP2, compresslevel=9) as zipf: - zipf.write(filepath, compress_type=zipfile.ZIP_BZIP2, compresslevel=9) +def compress_file(filepath, storedname, outpath): + with zipfile.ZipFile(outpath, 'w', compression=zipfile.ZIP_BZIP2, compresslevel=9) as zipf: + zipf.write(filepath, arcname=storedname, compress_type=zipfile.ZIP_BZIP2, compresslevel=9) # # Compute the build signature. The idea is to extract all defines in the configuration headers @@ -45,134 +49,228 @@ def compress_file(filepath, outputbase): # 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_dir=os.path.join(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 = os.path.join(build_dir, 'marlin_config.json') - marlin_zip = os.path.join(build_dir, 'mc') - - # Read existing config file - try: - with open(marlin_json, 'r') 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 - real_defines = {} - all_defines = [] - for header in files_to_keep: - defines = extract_defines(header) - # To filter only the define we want - all_defines = all_defines + defines - # To remember from which file it cames from - real_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 "" - - if not 'CONFIGURATION_EMBEDDING' in defines: - return - - # Second step is to filter useless macro - resolved_defines = {} - for key in defines: - # Remove all boards now - if key[0:6] == "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[-5:] == "_NAME" and key != "CUSTOM_MACHINE_NAME": - continue - # Remove all keys ending by "_T_DECLARED" as it's a copy of not important system stuff - if key[-11:] == "_T_DECLARED": - continue - # Remove keys that are not in the #define list in the Configuration list - if not (key in all_defines) and key != "DETAILED_BUILD_VERSION" and key != "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 real_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 real_defines: - if key in real_defines[header]: - data[header][key] = resolved_defines[key] - - # 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 - - with open(marlin_json, 'w') as outfile: - json.dump(data, outfile, separators=(',', ':')) - - # 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') - result_file.write(b' #warning "Generated file \'mc.zip\' is embedded (Define NO_CONFIGURATION_EMBEDDING_WARNING to suppress this warning.)"\n') - result_file.write(b'#endif\n') - result_file.write(b'const unsigned char mc_zip[] PROGMEM = {\n ') - count = 0 - for b in open(os.path.join(build_dir, 'mc.zip'), '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_config.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_config.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 c6a5277b92ad..608258c4d17a 100644 --- a/buildroot/share/PlatformIO/scripts/simulator.py +++ b/buildroot/share/PlatformIO/scripts/simulator.py @@ -2,53 +2,52 @@ # simulator.py # PlatformIO pre: script for simulator builds # + import pioutil if pioutil.is_pio_build(): - # Get the environment thus far for the build - Import("env") - - #print(env.Dump()) + # Get the environment thus far for the build + Import("env") - # - # Give the binary a distinctive name - # + #print(env.Dump()) - env['PROGNAME'] = "MarlinSimulator" + # + # Give the binary a distinctive name + # - # - # If Xcode is installed add the path to its Frameworks folder, - # or if Mesa is installed try to use its GL/gl.h. - # + env['PROGNAME'] = "MarlinSimulator" - import sys - if sys.platform == 'darwin': + # + # If Xcode is installed add the path to its Frameworks folder, + # or if Mesa is installed try to use its GL/gl.h. + # - # - # Silence half of the ranlib warnings. (No equivalent for 'ARFLAGS') - # - env['RANLIBFLAGS'] += [ "-no_warning_for_no_symbols" ] + import sys + if sys.platform == 'darwin': - # 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" + # + # Silence half of the ranlib warnings. (No equivalent for 'ARFLAGS') + # + env['RANLIBFLAGS'] += [ "-no_warning_for_no_symbols" ] - import os.path + # 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" - if os.path.exists(xcode_path): + import os.path - env['BUILD_FLAGS'] += [ "-F" + xcode_path ] - print("Using OpenGL framework headers from Xcode.app") + if os.path.exists(xcode_path): - elif os.path.exists(mesa_path): + env['BUILD_FLAGS'] += [ "-F" + xcode_path ] + print("Using OpenGL framework headers from Xcode.app") - env['BUILD_FLAGS'] += [ '-D__MESA__' ] - print("Using OpenGL header from", mesa_path) + elif os.path.exists(mesa_path): - else: + env['BUILD_FLAGS'] += [ '-D__MESA__' ] + print("Using OpenGL header from", mesa_path) - 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") + else: - # Break out of the PIO build immediately - sys.exit(1) + 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") - env.AddCustomTarget("upload", "$BUILD_DIR/${PROGNAME}", "$BUILD_DIR/${PROGNAME}") + # 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/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_ARCHIM/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/variant.h index 11f8f63bfb59..c073e9bbdd5b 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/variant.h @@ -24,10 +24,10 @@ *----------------------------------------------------------------------------*/ /** Frequency of the board main oscillator */ -#define VARIANT_MAINOSC 12000000 +#define VARIANT_MAINOSC 12000000 /** Master clock frequency */ -#define VARIANT_MCK 84000000 +#define VARIANT_MCK 84000000 /*---------------------------------------------------------------------------- * Headers @@ -119,13 +119,13 @@ extern "C"{ #define BOARD_SPI_DEFAULT_SS BOARD_SPI_SS3 #define BOARD_PIN_TO_SPI_PIN(x) \ - (x==BOARD_SPI_SS0 ? PIN_SPI_SS0 : \ - (x==BOARD_SPI_SS1 ? PIN_SPI_SS1 : \ - (x==BOARD_SPI_SS2 ? PIN_SPI_SS2 : PIN_SPI_SS3 ))) + (x==BOARD_SPI_SS0 ? PIN_SPI_SS0 : \ + (x==BOARD_SPI_SS1 ? PIN_SPI_SS1 : \ + (x==BOARD_SPI_SS2 ? PIN_SPI_SS2 : PIN_SPI_SS3 ))) #define BOARD_PIN_TO_SPI_CHANNEL(x) \ - (x==BOARD_SPI_SS0 ? 0 : \ - (x==BOARD_SPI_SS1 ? 1 : \ - (x==BOARD_SPI_SS2 ? 2 : 3))) + (x==BOARD_SPI_SS0 ? 0 : \ + (x==BOARD_SPI_SS1 ? 1 : \ + (x==BOARD_SPI_SS2 ? 2 : 3))) static const uint8_t SS = BOARD_SPI_SS0; static const uint8_t SS1 = BOARD_SPI_SS1; @@ -195,7 +195,7 @@ static const uint8_t DAC0 = 66; static const uint8_t DAC1 = 67; static const uint8_t CANRX = 68; static const uint8_t CANTX = 69; -#define ADC_RESOLUTION 12 +#define ADC_RESOLUTION 12 /* * Complementary CAN pins @@ -212,21 +212,21 @@ static const uint8_t CAN1TX = 89; /* * DACC */ -#define DACC_INTERFACE DACC -#define DACC_INTERFACE_ID ID_DACC -#define DACC_RESOLUTION 12 +#define DACC_INTERFACE DACC +#define DACC_INTERFACE_ID ID_DACC +#define DACC_RESOLUTION 12 #define DACC_ISR_HANDLER DACC_Handler #define DACC_ISR_ID DACC_IRQn /* * PWM */ -#define PWM_INTERFACE PWM -#define PWM_INTERFACE_ID ID_PWM -#define PWM_FREQUENCY 31000 -#define PWM_MAX_DUTY_CYCLE 255 -#define PWM_MIN_DUTY_CYCLE 0 -#define PWM_RESOLUTION 8 +#define PWM_INTERFACE PWM +#define PWM_INTERFACE_ID ID_PWM +#define PWM_FREQUENCY 31000 +#define PWM_MAX_DUTY_CYCLE 255 +#define PWM_MIN_DUTY_CYCLE 0 +#define PWM_RESOLUTION 8 /* * TC @@ -236,7 +236,7 @@ static const uint8_t CAN1TX = 89; #define TC_FREQUENCY 100000 #define TC_MAX_DUTY_CYCLE 255 #define TC_MIN_DUTY_CYCLE 0 -#define TC_RESOLUTION 8 +#define TC_RESOLUTION 8 #ifdef __cplusplus } @@ -281,4 +281,3 @@ extern USARTClass Serial3; #define SERIAL_PORT_HARDWARE3 Serial3 #endif /* _VARIANT_ARDUINO_DUE_X_ */ - 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_ARTILLERY_RUBY/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/variant.h index ca7a53d7827b..f32ff3c28d8c 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/variant.h @@ -121,6 +121,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ 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_BTT002/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h index 068d0b9ee587..88b6e4529232 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h @@ -272,6 +272,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ 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_E3_RRF/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/variant.h index edc1c91c5374..90e9998d10e4 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/variant.h @@ -267,6 +267,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ 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_GTR_V1/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/variant.h index 2c70693991ed..01f19a79331b 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/variant.h @@ -280,7 +280,7 @@ extern "C" { #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. +// Used when the user instantiates 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 @@ -295,6 +295,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ 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_BIGTREE_SKR_PRO_11/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/variant.h index b5cf0bad9d50..56bc3bdd9e94 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/variant.h @@ -280,7 +280,7 @@ extern "C" { #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. +// Used when the user instantiates 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 @@ -295,6 +295,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/PeripheralPins.c new file mode 100644 index 000000000000..a8a98fc6c59d --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/PeripheralPins.c @@ -0,0 +1,377 @@ +/* + ******************************************************************************* + * 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 + * + ******************************************************************************* + */ +/* + * Automatically generated from STM32G0B1C(B-C-E)Tx.xml, STM32G0B1C(B-C-E)Ux.xml + * STM32G0C1C(C-E)Tx.xml, STM32G0C1C(C-E)Ux.xml + * CubeMX DB release 6.0.60 + */ +#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 + {PB_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + {PB_10, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 + {PB_11, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + {PB_12, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 16, 0)}, // ADC1_IN16 + {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)}, // DAC1_OUT1 + {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC1_OUT2 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SDA[] = { + {PA_6, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_6_ALT1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)}, + {PA_10, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PA_10_ALT1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_10_R, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PA_10_R_ALT1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_12, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PB_4, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PB_4_ALT1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C3)}, + {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PB_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PB_14, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SCL[] = { + {PA_7, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_7_ALT1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)}, + {PA_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PA_9_ALT1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_9_R, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PA_9_R_ALT1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PB_3_ALT1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C3)}, + {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PB_13, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_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_AF2_TIM2, 1, 0)}, // TIM2_CH1 + {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 2, 0)}, // TIM2_CH2 + {PA_1_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 1, 1)}, // TIM15_CH1N + {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 3, 0)}, // TIM2_CH3 + {PA_2_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 1, 0)}, // TIM15_CH1 + {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 4, 0)}, // TIM2_CH4 + {PA_3_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 2, 0)}, // TIM15_CH2 + {PA_4, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM14, 1, 0)}, // TIM14_CH1 + {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 1, 0)}, // TIM2_CH1 + {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 1, 0)}, // TIM3_CH1 + {PA_6_ALT1, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM16, 1, 0)}, // TIM16_CH1 + {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 1)}, // TIM1_CH1N + {PA_7_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 2, 0)}, // TIM3_CH2 + {PA_7_ALT2, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM14, 1, 0)}, // TIM14_CH1 + {PA_7_ALT3, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM17, 1, 0)}, // TIM17_CH1 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 0)}, // TIM1_CH1 + {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 0)}, // TIM1_CH2 + {PA_9_R, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 0)}, // TIM1_CH2 + {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 0)}, // TIM1_CH3 + {PA_10_R, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 0)}, // TIM1_CH3 + {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 4, 0)}, // TIM1_CH4 + {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 1, 0)}, // TIM2_CH1 + {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 1)}, // TIM1_CH2N + {PB_0_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 3, 0)}, // TIM3_CH3 + {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 1)}, // TIM1_CH3N + {PB_1_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 4, 0)}, // TIM3_CH4 + {PB_1_ALT2, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_TIM14, 1, 0)}, // TIM14_CH1 + {PB_3, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + {PB_3_ALT1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 2, 0)}, // TIM2_CH2 + {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 1, 0)}, // TIM3_CH1 + {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 2, 0)}, // TIM3_CH2 + {PB_6, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + {PB_6_ALT1, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM4, 1, 0)}, // TIM4_CH1 + {PB_6_ALT2, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM16, 1, 1)}, // TIM16_CH1N + {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM4, 2, 0)}, // TIM4_CH2 + {PB_7_ALT1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM17, 1, 1)}, // TIM17_CH1N + {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM4, 3, 0)}, // TIM4_CH3 + {PB_8_ALT1, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM16, 1, 0)}, // TIM16_CH1 + {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM4, 4, 0)}, // TIM4_CH4 + {PB_9_ALT1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM17, 1, 0)}, // TIM17_CH1 + {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 3, 0)}, // TIM2_CH3 + {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 4, 0)}, // TIM2_CH4 + {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 1)}, // TIM1_CH1N + {PB_13_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 1, 1)}, // TIM15_CH1N + {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 1)}, // TIM1_CH2N + {PB_14_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 1, 0)}, // TIM15_CH1 + {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 1)}, // TIM1_CH3N + {PB_15_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 1)}, // TIM15_CH1N + {PB_15_ALT2, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 2, 0)}, // TIM15_CH2 + {PC_6, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 3, 0)}, // TIM2_CH3 + {PC_6_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 1, 0)}, // TIM3_CH1 + {PC_7, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 4, 0)}, // TIM2_CH4 + {PC_7_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 2, 0)}, // TIM3_CH2 + {PD_0, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM16, 1, 0)}, // TIM16_CH1 + {PD_1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM17, 1, 0)}, // TIM17_CH1 + {PD_2, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 1)}, // TIM1_CH1N + {PD_3, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 1)}, // TIM1_CH2N + {PF_0, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM14, 1, 0)}, // TIM14_CH1 + {PF_1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM15, 1, 1)}, // TIM15_CH1N + {NC, NP, 0} +}; +#endif + +//*** UART *** + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_TX[] = { + {PA_0, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)}, + {PA_2, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, + {PA_2_ALT1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PA_4, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {PA_5, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_9_R, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_14, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PA_14_ALT1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PB_0, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART5)}, + {PB_2, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_3, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PB_6, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PB_6_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)}, + {PB_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_8_ALT1, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_11, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PC_6, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {PD_3, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PF_2, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_RX[] = { + {PA_1, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)}, + {PA_3, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, + {PA_3_ALT1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PA_5, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_10_R, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_13, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PA_15, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PB_0, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_1, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART5)}, + {PB_4, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PB_7, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PB_7_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)}, + {PB_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_9_ALT1, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PB_10, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PC_7, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {PD_2, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {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_AF1_USART2)}, + {PA_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_15, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_USART3)}, + {PA_15_ALT1, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)}, + {PB_1, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, + {PB_1_ALT1, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PB_1_ALT2, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_3, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, + {PB_5, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART5)}, + {PB_12, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_14_ALT1, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PD_2, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART3)}, + {PF_2, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {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_AF1_USART2)}, + {PA_6, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, + {PA_6_ALT1, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PA_6_ALT2, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PB_0, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PB_4, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, + {PB_6, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART5)}, + {PB_7, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)}, + {PB_13, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PB_13_ALT1, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_15, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART2)}, + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MOSI[] = { + {PA_2, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PA_10_R, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PA_12, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_5_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PB_7, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PB_11, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MISO[] = { + {PA_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI2)}, + {PA_9_R, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI2)}, + {PA_11, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_4_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PB_6, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI2)}, + {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SCLK[] = { + {PA_0, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PA_1, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_3_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PB_8, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {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_AF0_SPI2)}, + {PD_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {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_AF0_SPI1)}, + {PA_4_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PA_8, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_15_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PB_0, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {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_AF0_SPI2)}, + {PD_0, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {NC, NP, 0} +}; +#endif + +//*** FDCAN *** + +#ifdef HAL_FDCAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_RD[] = { + {PA_11, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PB_0, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PB_5, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PB_8, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PB_12, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PD_0, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_FDCAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_TD[] = { + {PA_12, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PB_1, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PB_6, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PB_9, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PB_13, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PD_1, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {NC, NP, 0} +}; +#endif + +//*** No ETHERNET *** + +//*** No QUADSPI *** + +//*** USB *** + +#if defined(HAL_PCD_MODULE_ENABLED) || defined(HAL_HCD_MODULE_ENABLED) +WEAK const PinMap PinMap_USB_DRD_FS[] = { + {PA_4, USB_DRD_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_USB)}, // USB_NOE + {PA_11, USB_DRD_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_DM + {PA_12, USB_DRD_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_DP + {PA_13, USB_DRD_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_USB)}, // USB_NOE + {PA_15, USB_DRD_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_USB)}, // USB_NOE + {NC, NP, 0} +}; +#endif + +//*** No SD *** + +#endif /* !CUSTOM_PERIPHERAL_PINS */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/PinNamesVar.h new file mode 100644 index 000000000000..4e91fa322c9c --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/PinNamesVar.h @@ -0,0 +1,78 @@ +/* Remap pin name */ +PA_9_R = PA_9 | PREMAP, +PA_10_R = PA_10 | PREMAP, + +/* Alternate pin name */ +PA_1_ALT1 = PA_1 | ALT1, +PA_2_ALT1 = PA_2 | ALT1, +PA_3_ALT1 = PA_3 | ALT1, +PA_4_ALT1 = PA_4 | ALT1, +PA_6_ALT1 = PA_6 | ALT1, +PA_6_ALT2 = PA_6 | ALT2, +PA_7_ALT1 = PA_7 | ALT1, +PA_7_ALT2 = PA_7 | ALT2, +PA_7_ALT3 = PA_7 | ALT3, +PA_9_ALT1 = PA_9 | ALT1, +PA_9_R_ALT1 = PA_9_R | ALT1, +PA_10_ALT1 = PA_10 | ALT1, +PA_10_R_ALT1 = PA_10_R | ALT1, +PA_14_ALT1 = PA_14 | ALT1, +PA_15_ALT1 = PA_15 | ALT1, +PB_0_ALT1 = PB_0 | ALT1, +PB_1_ALT1 = PB_1 | ALT1, +PB_1_ALT2 = PB_1 | ALT2, +PB_3_ALT1 = PB_3 | ALT1, +PB_4_ALT1 = PB_4 | ALT1, +PB_5_ALT1 = PB_5 | ALT1, +PB_6_ALT1 = PB_6 | ALT1, +PB_6_ALT2 = PB_6 | ALT2, +PB_7_ALT1 = PB_7 | ALT1, +PB_8_ALT1 = PB_8 | ALT1, +PB_9_ALT1 = PB_9 | ALT1, +PB_13_ALT1 = PB_13 | ALT1, +PB_14_ALT1 = PB_14 | ALT1, +PB_15_ALT1 = PB_15 | ALT1, +PB_15_ALT2 = PB_15 | ALT2, +PC_6_ALT1 = PC_6 | ALT1, +PC_7_ALT1 = PC_7 | ALT1, + +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 + SYS_WKUP1 = PA_0, +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = PC_13, +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = PA_2, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = PB_5, +#endif +#ifdef PWR_WAKEUP_PIN7 + SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 + SYS_WKUP8 = NC, +#endif + +/* USB */ +#ifdef USBCON + USB_DM = PA_11, + USB_DP = PA_12, + #ifdef USB_NOE_PA_4 + USB_NOE = PA_4, + #endif + #ifdef USB_NOE_PA_13 + USB_NOE = PA_13, + #endif + #ifdef USB_NOE_PA_15 + USB_NOE = PA_15, + #endif +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/ldscript.ld new file mode 100644 index 000000000000..ce97a9f4ae31 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/ldscript.ld @@ -0,0 +1,185 @@ +/* +****************************************************************************** +** +** @file : LinkerScript.ld +** +** @author : Auto-generated by STM32CubeIDE +** +** @brief : Linker script for STM32G0B1CBTx Device from STM32G0 series +** 128Kbytes FLASH +** 144Kbytes 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) 2022 STMicroelectronics. +** All rights reserved. +** +** This software is licensed under terms that can be found in the LICENSE file +** in the root directory of this software component. +** If no LICENSE file comes with this software, it is provided AS-IS. +** +****************************************************************************** +*/ + +/* 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_BTT_EBB42_V1_1/variant_MARLIN_BTT_EBB42_V1_1.cpp b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/variant_MARLIN_BTT_EBB42_V1_1.cpp new file mode 100644 index 000000000000..3bb5f755b7ce --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/variant_MARLIN_BTT_EBB42_V1_1.cpp @@ -0,0 +1,138 @@ +/* + ******************************************************************************* + * Copyright (c) 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(ARDUINO_EBB42_V1_1) +#include "pins_arduino.h" + +// Pin number +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/A10 + PB_3, // D19 + PB_4, // D20 + PB_5, // D21 + PB_6, // D22 + PB_7, // D23 + PB_8, // D24 + PB_9, // D25 + PB_10, // D26/A11 + PB_11, // D27/A12 + PB_12, // D28/A13 + PB_13, // D29 + PB_14, // D30 + PB_15, // D31 + PC_6, // D32 + PC_7, // D33 + PC_13, // D34 + PC_14, // D35 + PC_15, // D36 + PD_0, // D37 + PD_1, // D38 + PD_2, // D39 + PD_3, // D40 + PF_0, // D41 + PF_1, // D42 + PF_2, // D43 + PA_9_R, // D44 + PA_10_R // D45 +}; + +// 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 + 18, // A10, PB2 + 26, // A11, PB10 + 27, // A12, PB11 + 28 // A13, PB12 +}; + +// ---------------------------------------------------------------------------- + +#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_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1); + + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI48; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1; + RCC_OscInitStruct.PLL.PLLN = 16; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; + RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + Error_Handler(); + } + + /** Initializes the CPU, AHB and APB buses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK + | RCC_CLOCKTYPE_PCLK1; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { + Error_Handler(); + } +} + +#ifdef __cplusplus +} +#endif +//#endif /* ARDUINO_EBB42_V1_1 */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/variant_MARLIN_BTT_EBB42_V1_1.h b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/variant_MARLIN_BTT_EBB42_V1_1.h new file mode 100644 index 000000000000..9373e2fa3ba5 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_EBB42_V1_1/variant_MARLIN_BTT_EBB42_V1_1.h @@ -0,0 +1,200 @@ +/* + ******************************************************************************* + * 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 + * + ******************************************************************************* + */ +#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 PIN_A10 +#define PB3 19 +#define PB4 20 +#define PB5 21 +#define PB6 22 +#define PB7 23 +#define PB8 24 +#define PB9 25 +#define PB10 PIN_A11 +#define PB11 PIN_A12 +#define PB12 PIN_A13 +#define PB13 29 +#define PB14 30 +#define PB15 31 +#define PC6 32 +#define PC7 33 +#define PC13 34 +#define PC14 35 +#define PC15 36 +#define PD0 37 +#define PD1 38 +#define PD2 39 +#define PD3 40 +#define PF0 41 +#define PF1 42 +#define PF2 43 +#define PA9_R 44 +#define PA10_R 45 + +// Alternate pins number +#define PA1_ALT1 (PA1 | ALT1) +#define PA2_ALT1 (PA2 | ALT1) +#define PA3_ALT1 (PA3 | ALT1) +#define PA4_ALT1 (PA4 | ALT1) +#define PA6_ALT1 (PA6 | ALT1) +#define PA6_ALT2 (PA6 | ALT2) +#define PA7_ALT1 (PA7 | ALT1) +#define PA7_ALT2 (PA7 | ALT2) +#define PA7_ALT3 (PA7 | ALT3) +#define PA9_ALT1 (PA9 | ALT1) +#define PA9_R_ALT1 (PA9_R | ALT1) +#define PA10_ALT1 (PA10 | ALT1) +#define PA10_R_ALT1 (PA10_R | ALT1) +#define PA14_ALT1 (PA14 | ALT1) +#define PA15_ALT1 (PA15 | ALT1) +#define PB0_ALT1 (PB0 | ALT1) +#define PB1_ALT1 (PB1 | ALT1) +#define PB1_ALT2 (PB1 | ALT2) +#define PB3_ALT1 (PB3 | ALT1) +#define PB4_ALT1 (PB4 | ALT1) +#define PB5_ALT1 (PB5 | ALT1) +#define PB6_ALT1 (PB6 | ALT1) +#define PB6_ALT2 (PB6 | ALT2) +#define PB7_ALT1 (PB7 | ALT1) +#define PB8_ALT1 (PB8 | ALT1) +#define PB9_ALT1 (PB9 | ALT1) +#define PB13_ALT1 (PB13 | ALT1) +#define PB14_ALT1 (PB14 | ALT1) +#define PB15_ALT1 (PB15 | ALT1) +#define PB15_ALT2 (PB15 | ALT2) +#define PC6_ALT1 (PC6 | ALT1) +#define PC7_ALT1 (PC7 | ALT1) + +#define NUM_DIGITAL_PINS 46 +#define NUM_REMAP_PINS 2 +#define NUM_ANALOG_INPUTS 14 + +// 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 PB0 +#endif +#ifndef PIN_SPI_SS3 + #define PIN_SPI_SS3 PNUM_NOT_DEFINED +#endif +#ifndef PIN_SPI_MOSI + #define PIN_SPI_MOSI PA2 +#endif +#ifndef PIN_SPI_MISO + #define PIN_SPI_MISO PA6 +#endif +#ifndef PIN_SPI_SCK + #define PIN_SPI_SCK PA1 +#endif + +// I2C definitions +#ifndef PIN_WIRE_SDA + #define PIN_WIRE_SDA PA6 +#endif +#ifndef PIN_WIRE_SCL + #define PIN_WIRE_SCL PA7 +#endif + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE + #define TIMER_TONE TIM6 +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM7 +#endif + +// UART Definitions +#ifndef SERIAL_UART_INSTANCE + #define SERIAL_UART_INSTANCE 4 +#endif + +#define FLASH_BANK_NUMBER FLASH_BANK_1 + +// Default pin used for generic 'Serial' instance +// Mandatory for Firmata +#ifndef PIN_SERIAL_RX + #define PIN_SERIAL_RX PA1 +#endif +#ifndef PIN_SERIAL_TX + #define PIN_SERIAL_TX PA0 +#endif + +// Extra HAL modules +#if !defined(HAL_DAC_MODULE_DISABLED) + #define HAL_DAC_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/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..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 @@ -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/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_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_BTT_SKR_SE_BX/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.h index 285ad662e0fe..f03ba3263724 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.h @@ -195,6 +195,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ 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_CREALITY_STM32F401RC/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/variant.h index b5a4e5ef80c2..722a29d00dd4 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/variant.h @@ -112,7 +112,7 @@ extern "C" { #define PIN_SERIAL_RX PA10 #define PIN_SERIAL_TX PA9 -// Used when user instanciate a hardware Serial using its peripheral name. +// Used when the user instantiates 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 @@ -123,6 +123,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ @@ -148,4 +149,4 @@ extern "C" { #define SERIAL_PORT_HARDWARE_OPEN Serial2 #endif -#endif /* _VARIANT_ARDUINO_STM32_ */ \ No newline at end of file +#endif /* _VARIANT_ARDUINO_STM32_ */ 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_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_F103Rx/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/variant.h index 8f17d052bba9..4a0245e7e9d5 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/variant.h @@ -148,6 +148,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ 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/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_F103VE_LONGER/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/variant.h index e64272745b9d..3fac64958c06 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 @@ -148,6 +148,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ 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_F103Vx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/ldscript.ld index a65b07d61c5f..ac7ac2e904df 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/ldscript.ld @@ -4,7 +4,7 @@ ** File : LinkerScript.ld ** -** Author : Auto-generated by STM32CubeIDE +** Author : Auto-generated by STM32CubeIDE ** ** Abstract : Linker script for STM32F103V(8/B/C/E/F/GTx Device from STM32F1 series ** 64/128/256/512/768/1024Kbytes FLASH @@ -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: @@ -54,15 +54,15 @@ ENTRY(Reset_Handler) /* Highest address of the user mode stack */ -_estack = 0x20000000 + LD_MAX_DATA_SIZE; /* end of "RAM" Ram type memory */ +_estack = 0x20000000 + LD_MAX_DATA_SIZE; /* 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 + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE + FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET } /* Sections */ @@ -103,9 +103,9 @@ SECTIONS } >FLASH .ARM.extab : { - . = ALIGN(4); - *(.ARM.extab* .gnu.linkonce.armextab.*) - . = ALIGN(4); + . = ALIGN(4); + *(.ARM.extab* .gnu.linkonce.armextab.*) + . = ALIGN(4); } >FLASH .ARM : { . = ALIGN(4); diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/variant.h index e01d67fd59c1..4061db4e2670 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/variant.h @@ -158,6 +158,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ 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..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 @@ -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_F103Zx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/ldscript.ld index cc4b323f763a..d995458f959b 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/ldscript.ld @@ -1,10 +1,9 @@ /* ****************************************************************************** ** - ** File : LinkerScript.ld ** -** Author : Auto-generated by STM32CubeIDE +** Author : Auto-generated by STM32CubeIDE ** ** Abstract : Linker script for STM32F103Z(C/D/E/G/GTx Device from STM32F1 series ** 256/386/512K/786/1024bytes FLASH @@ -23,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: @@ -54,7 +53,7 @@ ENTRY(Reset_Handler) /* Highest address of the user mode stack */ -_estack = 0x20000000 + LD_MAX_DATA_SIZE; /* end of "RAM" Ram type memory */ +_estack = 0x20000000 + LD_MAX_DATA_SIZE; /* end of "RAM" Ram type memory */ _Min_Heap_Size = 0x200; /* required amount of heap */ _Min_Stack_Size = 0x400; /* required amount of stack */ @@ -62,7 +61,7 @@ _Min_Stack_Size = 0x400; /* required amount of stack */ MEMORY { RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE - FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET + FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET } /* Sections */ @@ -103,9 +102,9 @@ SECTIONS } >FLASH .ARM.extab : { - . = ALIGN(4); - *(.ARM.extab* .gnu.linkonce.armextab.*) - . = ALIGN(4); + . = ALIGN(4); + *(.ARM.extab* .gnu.linkonce.armextab.*) + . = ALIGN(4); } >FLASH .ARM : { . = ALIGN(4); diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/variant.h index 330a7efbf83a..8de1e062f9c6 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/variant.h @@ -205,6 +205,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ 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..d028dfc00034 --- /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/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_F407VE/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F407VE/variant.h index df8bf064fca1..df45a5dbbbe5 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F407VE/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407VE/variant.h @@ -326,6 +326,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/PeripheralPins.c new file mode 100644 index 000000000000..d0905853a9a9 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/PeripheralPins.c @@ -0,0 +1,433 @@ +/* + ******************************************************************************* + * 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_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 + {PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 + {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 + {PF_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC3_IN9 TH_0 + {PF_4, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC3_IN14 TH_1 + {PF_5, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC3_IN15 TH_2 + {PF_6, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4 TH_3 + {PF_7, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC3_IN5 EXP_13 + {PF_8, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC3_IN6 PT100 + {NC, NP, 0} + + // {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, 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_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, 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, 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, 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, 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, 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 + +}; +#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_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 BED + {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 HEATER0 + {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 HEATER1 + {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 HEATER2 + {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 HEATER3 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 FAN0 + {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 FAN1 + {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 FAN2 + {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 FAN3 + {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 FAN5 + + /** + * Unused by specifications on Octopus. + * Uncomment the corresponding line if you want to have HardwarePWM on some pins. + * WARNING: check timers' usage first to avoid conflicts. + * If you don't know what you're doing leave things as they are or you WILL break something (including hardware) + * If you alter this section DO NOT report bugs to Marlin team since they are most likely caused by you. Thank you. + */ + //{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 BLTOUCH is a "servo" + //{PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 BLTOUCH is a "servo" + //{PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + //{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 + //{PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + //{PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + //{PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + //{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_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, 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_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + //{PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + //{PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + //{PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + //{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 + //{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 + //144 pins mcu, 114 gpio + //{PF_6, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + //{PF_7, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + //{PF_8, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + //{PF_9, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 + + //176 pins mcu, 140 gpio + //{PH_10, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + //{PH_6, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 + //{PH_11, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + //{PI_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 + //{PI_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 + + {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)}, + {PD_5, 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)}, + {PD_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {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)}, + {PD_6, 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)}, + {PD_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {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} +}; + +const PinMap PinMap_USB_OTG_HS[] = { + //{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 + + /*#error "USB in HS mode isn't supported by the board" + {PA_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D0 + {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_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 + */ + {NC, NP, 0} +}; + + +#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 diff --git a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/PinNamesVar.h similarity index 72% rename from buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PinNamesVar.h rename to buildroot/share/PlatformIO/variants/MARLIN_F407ZE/PinNamesVar.h index 6a1eb9b887f4..bff3f2134987 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PinNamesVar.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/PinNamesVar.h @@ -1,6 +1,6 @@ /* SYS_WKUP */ #ifdef PWR_WAKEUP_PIN1 - SYS_WKUP1 = PA_0, + SYS_WKUP1 = PA_0, /* SYS_WKUP0 */ #endif #ifdef PWR_WAKEUP_PIN2 SYS_WKUP2 = NC, @@ -25,9 +25,6 @@ #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_FS_DM = PA_11, + USB_OTG_FS_DP = PA_12, #endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/hal_conf_extra.h new file mode 100644 index 000000000000..d62c510095c9 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/hal_conf_extra.h @@ -0,0 +1,53 @@ +#pragma once + +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CRC_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_RTC_MODULE_ENABLED // Real Time Clock...do we use it? +#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 // by default +//#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) +#define HAL_SD_MODULE_ENABLED + +//#undef HAL_SD_MODULE_ENABLED +#undef HAL_DAC_MODULE_ENABLED +#undef HAL_FLASH_MODULE_ENABLED +#undef HAL_CAN_MODULE_ENABLED +#undef HAL_CAN_LEGACY_MODULE_ENABLED +#undef HAL_CEC_MODULE_ENABLED +#undef HAL_CRYP_MODULE_ENABLED +#undef HAL_DCMI_MODULE_ENABLED +#undef HAL_DMA2D_MODULE_ENABLED +#undef HAL_ETH_MODULE_ENABLED +#undef HAL_NAND_MODULE_ENABLED +#undef HAL_NOR_MODULE_ENABLED +#undef HAL_PCCARD_MODULE_ENABLED +#undef HAL_SRAM_MODULE_ENABLED +#undef HAL_SDRAM_MODULE_ENABLED +#undef HAL_HASH_MODULE_ENABLED +#undef HAL_SMBUS_MODULE_ENABLED +#undef HAL_I2S_MODULE_ENABLED +#undef HAL_IWDG_MODULE_ENABLED +#undef HAL_LTDC_MODULE_ENABLED +#undef HAL_DSI_MODULE_ENABLED +#undef HAL_QSPI_MODULE_ENABLED +#undef HAL_RNG_MODULE_ENABLED +#undef HAL_SAI_MODULE_ENABLED +#undef HAL_IRDA_MODULE_ENABLED +#undef HAL_SMARTCARD_MODULE_ENABLED +#undef HAL_WWDG_MODULE_ENABLED +//#undef HAL_HCD_MODULE_ENABLED +#undef HAL_FMPI2C_MODULE_ENABLED +#undef HAL_SPDIFRX_MODULE_ENABLED +#undef HAL_DFSDM_MODULE_ENABLED +#undef HAL_LPTIM_MODULE_ENABLED +#undef HAL_MMC_MODULE_ENABLED diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/ldscript.ld new file mode 100644 index 000000000000..0edf17b8e815 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/ldscript.ld @@ -0,0 +1,209 @@ +/* +***************************************************************************** +** + +** File : LinkerScript.ld +** +** Abstract : Linker script for STM32F407ZETx Device with +** 512KByte FLASH, 64KByte 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 = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ +FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE +CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K +MEMORY_ARRAY (rw) : ORIGIN = 0x10000000, LENGTH = 0x144 +} + +/* 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 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(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) } + ExtRAMData : {*(.ExtRAMData)} >MEMORY_ARRAY +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/variant.cpp new file mode 100644 index 000000000000..7b5fdd0b712e --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/variant.cpp @@ -0,0 +1,228 @@ +/* + 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 + + //Duplicated ADC Pins + PA_3, //D112/A0 + PA_4, //D113/A1 + PC_0, //D114/A2 + PC_1, //D115/A3 + PC_2, //D116/A4 + PC_3, //D117/A5 + PC_4, //D118/A6 + PF_3, //D119/A16 - 1:FSMC_A3 2:ADC3_IN9 + PF_4, //D120/A17 - 1:FSMC_A4 2:ADC3_IN14 + PF_5, //D121/A18 - 1:FSMC_A5 2:ADC3_IN15 + PF_6, //D122/A19 - 1:TIM10_CH1 2:ADC3_IN4 + PF_7, //D123/A20 - 1:TIM11_CH1 2:ADC3_IN5 + PF_8, //D124/A20 - 1:TIM11_CH1 2:ADC3_IN6 +}; + +#ifdef __cplusplus +} +#endif + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief System Clock Configuration + * The system Clock is configured as follow : + * System Clock source = PLL (HSE) + * SYSCLK(Hz) = 168000000 + * HCLK(Hz) = 168000000 + * AHB Prescaler = 1 + * APB1 Prescaler = 4 + * APB2 Prescaler = 2 + * HSE Frequency(Hz) = 8000000 + * PLL_M = 8 + * PLL_N = 336 + * PLL_P = 2 + * PLL_Q = 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; + + /* 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 = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = 7; + if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + /* Initialization Error */ + } + + /* 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; + if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) + { + /* Initialization Error */ + } +} + +#ifdef __cplusplus +} +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/variant.h new file mode 100644 index 000000000000..b8e4b9667e80 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407ZE/variant.h @@ -0,0 +1,216 @@ +/* + 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 + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +#define PA0 0 //D0 +#define PA1 1 //D1 +#define PA2 2 //D2 +#define PA3 3 //D3 +#define PA4 4 //D4 +#define PA5 5 //D5 +#define PA6 6 //D6 +#define PA7 7 //D7 +#define PA8 8 //D8 +#define PA9 9 //D9 +#define PA10 10 //D10 +#define PA11 11 //D11 +#define PA12 12 //D12 +#define PA13 13 //D13 +#define PA14 14 //D14 +#define PA15 15 //D15 +#define PB0 16 //D16 +#define PB1 17 //D17 +#define PB2 18 //D18 +#define PB3 19 //D19 +#define PB4 20 //D20 +#define PB5 21 //D21 +#define PB6 22 //D22 +#define PB7 23 //D23 +#define PB8 24 //D24 +#define PB9 25 //D25 +#define PB10 26 //D26 +#define PB11 27 //D27 +#define PB12 28 //D28 +#define PB13 29 //D29 +#define PB14 30 //D30 +#define PB15 31 //D31 +#define PC0 32 //D32 +#define PC1 33 //D33 +#define PC2 34 //D34 +#define PC3 35 //D35 +#define PC4 36 //D36 +#define PC5 37 //D37 +#define PC6 38 //D38 +#define PC7 39 //D39 +#define PC8 40 //D40 +#define PC9 41 //D41 +#define PC10 42 //D42 +#define PC11 43 //D43 +#define PC12 44 //D44 +#define PC13 45 //D45 +#define PC14 46 //D46 +#define PC15 47 //D47 +#define PD0 48 //D48 +#define PD1 49 //D49 +#define PD2 50 //D50 +#define PD3 51 //D51 +#define PD4 52 //D52 +#define PD5 53 //D53 +#define PD6 54 //D54 +#define PD7 55 //D55 +#define PD8 56 //D56 +#define PD9 57 //D57 +#define PD10 58 //D58 +#define PD11 59 //D59 +#define PD12 60 //D60 +#define PD13 61 //D61 +#define PD14 62 //D62 +#define PD15 63 //D63 +#define PE0 64 //D64 +#define PE1 65 //D65 +#define PE2 66 //D66 +#define PE3 67 //D67 +#define PE4 68 //D68 +#define PE5 69 //D69 +#define PE6 70 //D70 +#define PE7 71 //D71 +#define PE8 72 //D72 +#define PE9 73 //D73 +#define PE10 74 //D74 +#define PE11 75 //D75 +#define PE12 76 //D76 +#define PE13 77 //D77 +#define PE14 78 //D78 +#define PE15 79 //D79 +#define PF0 80 //D64 +#define PF1 81 //D65 +#define PF2 82 //D66 +#define PF3 83 //D67 +#define PF4 84 //D68 +#define PF5 85 //D69 +#define PF6 86 //D70 +#define PF7 87 //D71 +#define PF8 88 //D72 +#define PF9 89 //D73 +#define PF10 90 //D74 +#define PF11 91 //D75 +#define PF12 92 //D76 +#define PF13 93 //D77 +#define PF14 94 //D78 +#define PF15 95 //D79 +#define PG0 96 //D64 +#define PG1 97 //D65 +#define PG2 98 //D66 +#define PG3 99 //D67 +#define PG4 100 //D68 +#define PG5 101 //D69 +#define PG6 102 //D70 +#define PG7 103 //D71 +#define PG8 104 //D72 +#define PG9 105 //D73 +#define PG10 106 //D74 +#define PG11 107 //D75 +#define PG12 108 //D76 +#define PG13 109 //D77 +#define PG14 110 //D78 +#define PG15 111 //D79 + +// This must be a literal with the same value as PEND +#define NUM_DIGITAL_PINS 112 +// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 13 +#define NUM_ANALOG_FIRST NUM_DIGITAL_PINS + +//#define ADC_RESOLUTION 12 + +// PWM resolution +//#define PWM_RESOLUTION 12 +#define PWM_FREQUENCY 1000 // >= 20 Khz => inaudible noise for fans +#define PWM_MAX_DUTY_CYCLE 255 + +// 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 PB9 +#define PIN_WIRE_SCL PB8 + +// Timer Definitions +// Do not use timer used by PWM pin. See PinMap_PWM. +#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file +#define TIMER_SERIAL TIM7 // TIMER_SERIAL must be defined in this file + +// 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/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_F446VE/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.h index 855616f66b4a..b2111d04f2d4 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.h @@ -159,6 +159,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ 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_STEVAL_F401VE/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/hal_conf_custom.h similarity index 91% rename from buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/hal_conf_custom.h rename to buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/hal_conf_custom.h index 7d013d2b27f4..c23d30ce88a9 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/hal_conf_custom.h @@ -33,54 +33,55 @@ extern "C" { */ #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_EXTI_MODULE_ENABLED // Needed for Endstop (and other external) Interrupts +/* #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_IWDG_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 -//#define HAL_PCD_MODULE_ENABLED // Automatically added if any type of USB is enabled, as in Arduino IDE. (STM32 v3.10700.191028) - -//#define HAL_CAN_MODULE_ENABLED -//#define HAL_CAN_LEGACY_MODULE_ENABLED -//#define HAL_CEC_MODULE_ENABLED -//#define HAL_CRYP_MODULE_ENABLED -//#define HAL_DAC_MODULE_ENABLED -//#define HAL_DCMI_MODULE_ENABLED -//#define HAL_DMA2D_MODULE_ENABLED -//#define HAL_ETH_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_LTDC_MODULE_ENABLED -//#define HAL_DSI_MODULE_ENABLED -//#define HAL_QSPI_MODULE_ENABLED -//#define HAL_RNG_MODULE_ENABLED -//#define HAL_SAI_MODULE_ENABLED -//#define HAL_UART_MODULE_ENABLED // by default -//#define HAL_USART_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 +#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 ##################### */ /** @@ -93,7 +94,11 @@ extern "C" { #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 */ /** @@ -282,6 +287,7 @@ in voltage and temperature. */ #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 @@ -468,6 +474,10 @@ in voltage and temperature. */ #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 /** diff --git a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/ldscript.ld similarity index 90% rename from buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/ldscript.ld rename to buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/ldscript.ld index c5788dbebe6c..20a9f1db1bb0 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/ldscript.ld @@ -1,10 +1,11 @@ /* ***************************************************************************** ** -** File : ldscript.ld + +** File : LinkerScript.ld ** -** Abstract : Linker script for STM32F401RETx Device with -** 512KByte FLASH, 96KByte RAM +** Abstract : Linker script for STM32F446RETx Device with +** 512KByte FLASH, 128KByte RAM ** ** Set heap size, stack size and stack location according ** to application requirements. @@ -51,16 +52,16 @@ ENTRY(Reset_Handler) /* Highest address of the user mode stack */ -_estack = 0x20018000; /* end of RAM */ +_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_Heap_Size = 0x2000; /* required amount of heap */ _Min_Stack_Size = 0x400; /* required amount of stack */ /* Specify the memory areas */ MEMORY { -FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K -RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K +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 */ @@ -75,7 +76,7 @@ SECTIONS } >FLASH /* The program code and other data goes into FLASH */ - .text : + .text ALIGN(4): { . = ALIGN(4); *(.text) /* .text sections (code) */ @@ -87,7 +88,7 @@ SECTIONS KEEP (*(.init)) KEEP (*(.fini)) - . = ALIGN(4); + . = ALIGN(8); /*YSZ-WORK:4->8*/ _etext = .; /* define a global symbols at end of code */ } >FLASH @@ -148,7 +149,7 @@ SECTIONS . = ALIGN(4); .bss : { - /* This is used by the startup in order to initialize the .bss section */ + /* 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) @@ -163,12 +164,12 @@ SECTIONS /* User_heap_stack section, used to check that there is enough RAM left */ ._user_heap_stack : { - . = ALIGN(4); + . = ALIGN(4);/*YSZ-WORK:8->4*/ PROVIDE ( end = . ); PROVIDE ( _end = . ); . = . + _Min_Heap_Size; . = . + _Min_Stack_Size; - . = ALIGN(4); + . = ALIGN(4);/*YSZ-WORK:8->4*/ } >RAM 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..7e18e33f7e29 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.cpp @@ -0,0 +1,320 @@ +/* + 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; // 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(); + 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); // send CMD13 + do status = SDIOx->STA; + 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)) { // 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; // 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)); + 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 follows: + * 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(); + /* 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(); // 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 new file mode 100644 index 000000000000..082be9403ed5 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.h @@ -0,0 +1,243 @@ +/* + 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/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h index 952fe3c5b881..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 @@ -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_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_F4x7Vx/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/variant.h index ba145d058cb3..d6f8e9fe834e 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 @@ -176,6 +176,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ 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_FLY_F407ZG/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/variant.h index 2bfce85e21f9..80d5d3e00983 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/variant.h @@ -37,121 +37,120 @@ extern "C" { * 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 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 +#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 @@ -212,6 +211,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ @@ -234,5 +234,5 @@ extern "C" { // pins are NOT connected to anything by default. #define SERIAL_PORT_MONITOR Serial #define SERIAL_PORT_HARDWARE Serial1 -#endif +#endif 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_CHEETAH_V20/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/variant.h index d4982113a010..ca3664daa165 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/variant.h @@ -95,7 +95,7 @@ extern "C" { // Timer Definitions #define TIMER_TONE TIM2 // TIMER_TONE must be defined in this file -#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file +#define TIMER_SERVO TIM3 // TIMER_SERVO must be defined in this file #define TIMER_SERIAL TIM11 // TIMER_SERIAL must be defined in this file // UART Definitions @@ -110,7 +110,7 @@ extern "C" { #define PIN_SERIAL_RX PA10 #define PIN_SERIAL_TX PA9 -// Used when user instantiate a hardware Serial using its peripheral name. +// Used when the user instantiates 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 @@ -121,6 +121,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ 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/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PeripheralPins.c new file mode 100644 index 000000000000..4411065d21d8 --- /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..f7e09b8ef0e7 --- /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..abcbba8595f7 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/variant.h @@ -0,0 +1,236 @@ +/* + ******************************************************************************* + * 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 the user instantiates 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/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PeripheralPins.c index 0abfc70700d8..3187367a2d99 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" @@ -218,6 +218,7 @@ WEAK const PinMap PinMap_UART_TX[] = { {PC_12, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, {PD_3, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, {PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART2)}, + {PD_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, {PF_2, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART2)}, {NC, NP, 0} }; @@ -252,6 +253,7 @@ WEAK const PinMap PinMap_UART_RX[] = { {PC_11_ALT1, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART4)}, {PD_2, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, {PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART2)}, + {PD_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, {NC, NP, 0} }; #endif 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_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp index 8af7150dc781..fa4ebfa71329 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 @@ -130,14 +130,7 @@ WEAK void SystemClock_Config(void) RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; // Reset clock registers (in case bootloader has changed them) - RCC->CR |= RCC_CR_HSION; - while (!(RCC->CR & RCC_CR_HSIRDY)) - ; - RCC->CFGR = 0x00000000; - RCC->CR = RCC_CR_HSION; - while (RCC->CR & RCC_CR_PLLRDY) - ; - RCC->PLLCFGR = 0x00001000; + SystemInit(); /** Configure the main internal regulator output voltage */ 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 diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1VE/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_G0B1VE/PeripheralPins.c new file mode 100644 index 000000000000..a6b1e4423718 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1VE/PeripheralPins.c @@ -0,0 +1,480 @@ +/* + ******************************************************************************* + * 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 STM32G0B1V(B-C-E)Ix.xml, STM32G0B1V(B-C-E)Tx.xml + * STM32G0B1V(C-E)Ix.xml, STM32G0B1V(C-E)Tx.xml + * STM32G0C1V(C-E)Ix.xml, STM32G0C1V(C-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 + {PB_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + {PB_10, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 + {PB_11, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + {PB_12, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 16, 0)}, // ADC1_IN16 + {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 17, 0)}, // ADC1_IN17 + {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)}, // ADC1_IN18 + {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)}, // DAC1_OUT1 + {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC1_OUT2 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SDA[] = { + {PA_6, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_6_ALT1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)}, + {PA_10, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PA_10_ALT1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_10_R, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PA_10_R_ALT1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_12, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PB_4, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PB_4_ALT1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C3)}, + {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PB_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PB_14, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PC_1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SCL[] = { + {PA_7, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_7_ALT1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)}, + {PA_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PA_9_ALT1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_9_R, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PA_9_R_ALT1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PA_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF8_I2C2)}, + {PB_3_ALT1, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C3)}, + {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, + {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PB_13, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C2)}, + {PC_0, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C3)}, + {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_AF2_TIM2, 1, 0)}, // TIM2_CH1 + {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 2, 0)}, // TIM2_CH2 + {PA_1_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 1, 1)}, // TIM15_CH1N + {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 3, 0)}, // TIM2_CH3 + {PA_2_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 1, 0)}, // TIM15_CH1 + {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 4, 0)}, // TIM2_CH4 + {PA_3_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 2, 0)}, // TIM15_CH2 + {PA_4, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM14, 1, 0)}, // TIM14_CH1 + {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 1, 0)}, // TIM2_CH1 + {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 1, 0)}, // TIM3_CH1 + {PA_6_ALT1, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM16, 1, 0)}, // TIM16_CH1 + {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 1)}, // TIM1_CH1N + {PA_7_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 2, 0)}, // TIM3_CH2 + {PA_7_ALT2, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM14, 1, 0)}, // TIM14_CH1 + {PA_7_ALT3, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM17, 1, 0)}, // TIM17_CH1 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 0)}, // TIM1_CH1 + {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 0)}, // TIM1_CH2 + {PA_9_R, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 0)}, // TIM1_CH2 + {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 0)}, // TIM1_CH3 + {PA_10_R, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 0)}, // TIM1_CH3 + {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 4, 0)}, // TIM1_CH4 + {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 1, 0)}, // TIM2_CH1 + {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 1)}, // TIM1_CH2N + {PB_0_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 3, 0)}, // TIM3_CH3 + {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 1)}, // TIM1_CH3N + {PB_1_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 4, 0)}, // TIM3_CH4 + {PB_1_ALT2, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_TIM14, 1, 0)}, // TIM14_CH1 + {PB_3, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + {PB_3_ALT1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 2, 0)}, // TIM2_CH2 + {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 1, 0)}, // TIM3_CH1 + {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 2, 0)}, // TIM3_CH2 + {PB_6, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + {PB_6_ALT1, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM4, 1, 0)}, // TIM4_CH1 + {PB_6_ALT2, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM16, 1, 1)}, // TIM16_CH1N + {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM4, 2, 0)}, // TIM4_CH2 + {PB_7_ALT1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM17, 1, 1)}, // TIM17_CH1N + {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM4, 3, 0)}, // TIM4_CH3 + {PB_8_ALT1, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM16, 1, 0)}, // TIM16_CH1 + {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM4, 4, 0)}, // TIM4_CH4 + {PB_9_ALT1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM17, 1, 0)}, // TIM17_CH1 + {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 3, 0)}, // TIM2_CH3 + {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 4, 0)}, // TIM2_CH4 + {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 1)}, // TIM1_CH1N + {PB_13_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 1, 1)}, // TIM15_CH1N + {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 1)}, // TIM1_CH2N + {PB_14_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 1, 0)}, // TIM15_CH1 + {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 1)}, // TIM1_CH3N + {PB_15_ALT1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 1)}, // TIM15_CH1N + {PB_15_ALT2, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM15, 2, 0)}, // TIM15_CH2 + {PC_1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM15, 1, 0)}, // TIM15_CH1 + {PC_2, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM15, 2, 0)}, // TIM15_CH2 + {PC_4, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 1, 0)}, // TIM2_CH1 + {PC_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 2, 0)}, // TIM2_CH2 + {PC_6, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 3, 0)}, // TIM2_CH3 + {PC_6_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 1, 0)}, // TIM3_CH1 + {PC_7, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 4, 0)}, // TIM2_CH4 + {PC_7_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 2, 0)}, // TIM3_CH2 + {PC_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 0)}, // TIM1_CH1 + {PC_8_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 3, 0)}, // TIM3_CH3 + {PC_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 0)}, // TIM1_CH2 + {PC_9_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 4, 0)}, // TIM3_CH4 + {PC_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 0)}, // TIM1_CH3 + {PC_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 4, 0)}, // TIM1_CH4 + {PC_12, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM14, 1, 0)}, // TIM14_CH1 + {PD_0, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM16, 1, 0)}, // TIM16_CH1 + {PD_1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM17, 1, 0)}, // TIM17_CH1 + {PD_2, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 1)}, // TIM1_CH1N + {PD_3, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 1)}, // TIM1_CH2N + {PD_4, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 1)}, // TIM1_CH3N + {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PE_0, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_TIM16, 1, 0)}, // TIM16_CH1 + {PE_1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_TIM17, 1, 0)}, // TIM17_CH1 + {PE_3, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 1, 0)}, // TIM3_CH1 + {PE_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 2, 0)}, // TIM3_CH2 + {PE_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 3, 0)}, // TIM3_CH3 + {PE_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 4, 0)}, // TIM3_CH4 + {PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + {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 + {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 + {PF_0, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM14, 1, 0)}, // TIM14_CH1 + {PF_1, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM15, 1, 1)}, // TIM15_CH1N + {PF_12, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_TIM15, 1, 0)}, // TIM15_CH1 + {PF_13, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_TIM15, 2, 0)}, // TIM15_CH2 + {NC, NP, 0} +}; +#endif + +//*** UART *** + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_TX[] = { + {PA_0, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)}, + {PA_2, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, + {PA_2_ALT1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PA_4, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {PA_5, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_9_R, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_14, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PA_14_ALT1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PB_0, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART5)}, + {PB_2, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_3, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PB_6, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PB_6_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)}, + {PB_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_8_ALT1, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_11, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PC_0, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {PC_0_ALT1, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART6)}, + {PC_1, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PC_4, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PC_4_ALT1, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART3)}, + {PC_6, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART3)}, + {PC_10_ALT1, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART4)}, + {PC_12, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PD_3, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART2)}, + {PD_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART3)}, + {PE_8, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART4)}, + {PE_10, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PF_2, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART2)}, + {PF_4, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PF_9, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_RX[] = { + {PA_1, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)}, + {PA_3, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, + {PA_3_ALT1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PA_5, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_10_R, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_13, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PA_15, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)}, + {PB_0, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_1, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART5)}, + {PB_4, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PB_7, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PB_7_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)}, + {PB_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_9_ALT1, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PB_10, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PC_0, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PC_1, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {PC_1_ALT1, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART6)}, + {PC_5, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PC_5_ALT1, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART3)}, + {PC_7, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {PC_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART3)}, + {PC_11_ALT1, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART4)}, + {PD_2, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART2)}, + {PD_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART3)}, + {PE_9, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART4)}, + {PE_11, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PF_3, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART2)}, + {PF_5, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PF_10, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_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_AF1_USART2)}, + {PA_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_15, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_USART3)}, + {PA_15_ALT1, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)}, + {PB_1, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, + {PB_1_ALT1, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PB_1_ALT2, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_3, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, + {PB_5, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART5)}, + {PB_12, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_14_ALT1, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PC_9, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {PD_2, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART3)}, + {PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART2)}, + {PD_4_ALT1, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PD_12, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART3)}, + {PD_15, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART2)}, + {PE_7, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PF_2, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {PF_3, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {PF_6, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PF_11, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {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_AF1_USART2)}, + {PA_6, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, + {PA_6_ALT1, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PA_6_ALT2, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PB_0, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)}, + {PB_4, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, + {PB_6, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART5)}, + {PB_7, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART4)}, + {PB_13, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PB_13_ALT1, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART3)}, + {PB_15, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PC_8, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART2)}, + {PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART2)}, + {PD_5, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PD_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART3)}, + {PD_14, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART2)}, + {PF_7, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_LPUART1)}, + {PF_7_ALT1, USART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART5)}, + {PF_12, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART6)}, + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MOSI[] = { + {PA_2, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PA_10_R, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PA_12, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_5_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PB_7, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PB_11, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI3)}, + {PD_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PD_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI1)}, + {PE_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MISO[] = { + {PA_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI2)}, + {PA_9_R, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI2)}, + {PA_11, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_4_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PB_6, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI2)}, + {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI3)}, + {PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PD_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI1)}, + {PE_14, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SCLK[] = { + {PA_0, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)}, + {PA_1, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_3_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PB_8, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {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_AF0_SPI2)}, + {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_SPI3)}, + {PD_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PD_8, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI1)}, + {PE_13, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {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_AF0_SPI1)}, + {PA_4_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PA_8, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_15_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SPI3)}, + {PB_0, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {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_AF0_SPI2)}, + {PD_0, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI2)}, + {PD_9, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_SPI1)}, + {PE_12, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {NC, NP, 0} +}; +#endif + +//*** FDCAN *** + +#ifdef HAL_FDCAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_RD[] = { + {PA_11, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PB_0, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PB_5, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PB_8, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PB_12, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PC_2, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PC_4, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PD_0, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PD_12, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PD_14, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_FDCAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_TD[] = { + {PA_12, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PB_1, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PB_6, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PB_9, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PB_13, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PC_3, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {PC_5, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PD_1, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PD_13, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN1)}, + {PD_15, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF3_FDCAN2)}, + {NC, NP, 0} +}; +#endif + +//*** No ETHERNET *** + +//*** No QUADSPI *** + +//*** USB *** + +#if defined(HAL_PCD_MODULE_ENABLED) || defined(HAL_HCD_MODULE_ENABLED) +WEAK const PinMap PinMap_USB_DRD_FS[] = { + {PA_4, USB_DRD_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_USB)}, // USB_NOE + {PA_11, USB_DRD_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_DM + {PA_12, USB_DRD_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_DP + {PA_13, USB_DRD_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_USB)}, // USB_NOE + {PA_15, USB_DRD_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_USB)}, // USB_NOE + {PC_9, USB_DRD_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_USB)}, // USB_NOE + {NC, NP, 0} +}; +#endif + +//*** No SD *** + +#endif /* !CUSTOM_PERIPHERAL_PINS */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1VE/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_G0B1VE/PinNamesVar.h new file mode 100644 index 000000000000..7d35869fe7dd --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1VE/PinNamesVar.h @@ -0,0 +1,91 @@ +/* Remap pin name */ +PA_9_R = PA_9 | PREMAP, +PA_10_R = PA_10 | PREMAP, + +/* Alternate pin name */ +PA_1_ALT1 = PA_1 | ALT1, +PA_2_ALT1 = PA_2 | ALT1, +PA_3_ALT1 = PA_3 | ALT1, +PA_4_ALT1 = PA_4 | ALT1, +PA_6_ALT1 = PA_6 | ALT1, +PA_6_ALT2 = PA_6 | ALT2, +PA_7_ALT1 = PA_7 | ALT1, +PA_7_ALT2 = PA_7 | ALT2, +PA_7_ALT3 = PA_7 | ALT3, +PA_9_ALT1 = PA_9 | ALT1, +PA_9_R_ALT1 = PA_9_R | ALT1, +PA_10_ALT1 = PA_10 | ALT1, +PA_10_R_ALT1 = PA_10_R | ALT1, +PA_14_ALT1 = PA_14 | ALT1, +PA_15_ALT1 = PA_15 | ALT1, +PB_0_ALT1 = PB_0 | ALT1, +PB_1_ALT1 = PB_1 | ALT1, +PB_1_ALT2 = PB_1 | ALT2, +PB_3_ALT1 = PB_3 | ALT1, +PB_4_ALT1 = PB_4 | ALT1, +PB_5_ALT1 = PB_5 | ALT1, +PB_6_ALT1 = PB_6 | ALT1, +PB_6_ALT2 = PB_6 | ALT2, +PB_7_ALT1 = PB_7 | ALT1, +PB_8_ALT1 = PB_8 | ALT1, +PB_9_ALT1 = PB_9 | ALT1, +PB_13_ALT1 = PB_13 | ALT1, +PB_14_ALT1 = PB_14 | ALT1, +PB_15_ALT1 = PB_15 | ALT1, +PB_15_ALT2 = PB_15 | ALT2, +PC_0_ALT1 = PC_0 | ALT1, +PC_1_ALT1 = PC_1 | ALT1, +PC_4_ALT1 = PC_4 | ALT1, +PC_5_ALT1 = PC_5 | ALT1, +PC_6_ALT1 = PC_6 | ALT1, +PC_7_ALT1 = PC_7 | ALT1, +PC_8_ALT1 = PC_8 | ALT1, +PC_9_ALT1 = PC_9 | ALT1, +PC_10_ALT1 = PC_10 | ALT1, +PC_11_ALT1 = PC_11 | ALT1, +PD_4_ALT1 = PD_4 | ALT1, +PF_7_ALT1 = PF_7 | ALT1, + +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 + SYS_WKUP1 = PA_0, +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = PC_13, +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = PE_6, +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = PA_2, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = PC_5, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = PB_5, +#endif +#ifdef PWR_WAKEUP_PIN7 + SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 + SYS_WKUP8 = NC, +#endif + +/* USB */ +#ifdef USBCON + USB_DM = PA_11, + USB_DP = PA_12, + #ifdef USB_NOE_PA_4 + USB_NOE = PA_4, + #endif + #ifdef USB_NOE_PA_13 + USB_NOE = PA_13, + #endif + #ifdef USB_NOE_PA_15 + USB_NOE = PA_15, + #endif + #ifdef USB_NOE_PC_9 + USB_NOE = PC_9, + #endif +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1VE/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_G0B1VE/ldscript.ld new file mode 100644 index 000000000000..db07355fb744 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1VE/ldscript.ld @@ -0,0 +1,177 @@ +/** + ****************************************************************************** + * @file LinkerScript.ld + * @author Auto-generated by STM32CubeIDE + * @brief Linker script for STM32G0B1VETx Device from STM32G0 series + * 512Kbytes FLASH + * 144Kbytes 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_G0B1VE/variant_MARLIN_STM32G0B1VE.cpp b/buildroot/share/PlatformIO/variants/MARLIN_G0B1VE/variant_MARLIN_STM32G0B1VE.cpp new file mode 100644 index 000000000000..8bf88aed49bf --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1VE/variant_MARLIN_STM32G0B1VE.cpp @@ -0,0 +1,213 @@ +/* + ******************************************************************************* + * 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(STM32G0B1xx) +#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/A10 + PB_3, // D19 + PB_4, // D20 + PB_5, // D21 + PB_6, // D22 + PB_7, // D23 + PB_8, // D24 + PB_9, // D25 + PB_10, // D26/A11 + PB_11, // D27/A12 + PB_12, // D28/A13 + PB_13, // D29 + PB_14, // D30 + PB_15, // D31 + PC_0, // D32 + PC_1, // D33 + PC_2, // D34 + PC_3, // D35 + PC_4, // D36/A14 + PC_5, // D37/A15 + 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 + PA_9_R, // D94 + PA_10_R // D95 +}; + +// 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 + 18, // A10, PB2 + 26, // A11, PB10 + 27, // A12, PB11 + 28, // A13, PB12 + 36, // A14, PC4 + 37 // A15, PC5 +}; + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief System Clock Configuration + * The system Clock is configured as follows : + * System Clock source = PLL (HSE) + * SYSCLK(Hz) = 64000000 + * HCLK(Hz) = 64000000 + * AHB Prescaler = 1 + * APB1 Prescaler = 1 + * PLL_M = 1 + * PLL_N = 24 + * PLL_R = 3 + * PLL_P = 2 + * PLL_Q = 4 + * USB(Hz) = 48000000 (PLLQ) + * @param None + * @retval None + */ +WEAK void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; + + // Reset clock registers (in case bootloader has changed them) + SystemInit(); + + /** Configure the main internal regulator output voltage + */ + HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1); + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. + */ + 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 = RCC_PLLM_DIV1; + RCC_OscInitStruct.PLL.PLLN = 24; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV4; + RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV3; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Initializes the CPU, AHB and APB buses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) + { + Error_Handler(); + } + /** Initializes the peripherals clocks + */ + PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; + PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) + { + Error_Handler(); + } +} + +#ifdef __cplusplus +} +#endif +#endif /* STM32G0B1xx */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1VE/variant_MARLIN_STM32G0B1VE.h b/buildroot/share/PlatformIO/variants/MARLIN_G0B1VE/variant_MARLIN_STM32G0B1VE.h new file mode 100644 index 000000000000..e6f2251db059 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1VE/variant_MARLIN_STM32G0B1VE.h @@ -0,0 +1,258 @@ +/* + ******************************************************************************* + * 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 PIN_A10 +#define PB3 19 +#define PB4 20 +#define PB5 21 +#define PB6 22 +#define PB7 23 +#define PB8 24 +#define PB9 25 +#define PB10 PIN_A11 +#define PB11 PIN_A12 +#define PB12 PIN_A13 +#define PB13 29 +#define PB14 30 +#define PB15 31 +#define PC0 32 +#define PC1 33 +#define PC2 34 +#define PC3 35 +#define PC4 PIN_A14 +#define PC5 PIN_A15 +#define PC6 38 +#define PC7 39 +#define PC8 40 +#define PC9 41 +#define PC10 42 +#define PC11 43 +#define PC12 44 +#define PC13 45 +#define PC14 46 +#define PC15 47 +#define PD0 48 +#define PD1 49 +#define PD2 50 +#define PD3 51 +#define PD4 52 +#define PD5 53 +#define PD6 54 +#define PD7 55 +#define PD8 56 +#define PD9 57 +#define PD10 58 +#define PD11 59 +#define PD12 60 +#define PD13 61 +#define PD14 62 +#define PD15 63 +#define PE0 64 +#define PE1 65 +#define PE2 66 +#define PE3 67 +#define PE4 68 +#define PE5 69 +#define PE6 70 +#define PE7 71 +#define PE8 72 +#define PE9 73 +#define PE10 74 +#define PE11 75 +#define PE12 76 +#define PE13 77 +#define PE14 78 +#define PE15 79 +#define PF0 80 +#define PF1 81 +#define PF2 82 +#define PF3 83 +#define PF4 84 +#define PF5 85 +#define PF6 86 +#define PF7 87 +#define PF8 88 +#define PF9 89 +#define PF10 90 +#define PF11 91 +#define PF12 92 +#define PF13 93 +#define PA9_R 94 +#define PA10_R 95 + +// Alternate pins number +#define PA1_ALT1 (PA1 | ALT1) +#define PA2_ALT1 (PA2 | ALT1) +#define PA3_ALT1 (PA3 | ALT1) +#define PA4_ALT1 (PA4 | ALT1) +#define PA6_ALT1 (PA6 | ALT1) +#define PA6_ALT2 (PA6 | ALT2) +#define PA7_ALT1 (PA7 | ALT1) +#define PA7_ALT2 (PA7 | ALT2) +#define PA7_ALT3 (PA7 | ALT3) +#define PA9_ALT1 (PA9 | ALT1) +#define PA9_R_ALT1 (PA9_R | ALT1) +#define PA10_ALT1 (PA10 | ALT1) +#define PA10_R_ALT1 (PA10_R | ALT1) +#define PA14_ALT1 (PA14 | ALT1) +#define PA15_ALT1 (PA15 | ALT1) +#define PB0_ALT1 (PB0 | ALT1) +#define PB1_ALT1 (PB1 | ALT1) +#define PB1_ALT2 (PB1 | ALT2) +#define PB3_ALT1 (PB3 | ALT1) +#define PB4_ALT1 (PB4 | ALT1) +#define PB5_ALT1 (PB5 | ALT1) +#define PB6_ALT1 (PB6 | ALT1) +#define PB6_ALT2 (PB6 | ALT2) +#define PB7_ALT1 (PB7 | ALT1) +#define PB8_ALT1 (PB8 | ALT1) +#define PB9_ALT1 (PB9 | ALT1) +#define PB13_ALT1 (PB13 | ALT1) +#define PB14_ALT1 (PB14 | ALT1) +#define PB15_ALT1 (PB15 | ALT1) +#define PB15_ALT2 (PB15 | ALT2) +#define PC0_ALT1 (PC0 | ALT1) +#define PC1_ALT1 (PC1 | ALT1) +#define PC4_ALT1 (PC4 | ALT1) +#define PC5_ALT1 (PC5 | ALT1) +#define PC6_ALT1 (PC6 | ALT1) +#define PC7_ALT1 (PC7 | ALT1) +#define PC8_ALT1 (PC8 | ALT1) +#define PC9_ALT1 (PC9 | ALT1) +#define PC10_ALT1 (PC10 | ALT1) +#define PC11_ALT1 (PC11 | ALT1) +#define PD4_ALT1 (PD4 | ALT1) +#define PF7_ALT1 (PF7 | ALT1) + +#define NUM_DIGITAL_PINS 96 +#define NUM_REMAP_PINS 2 +#define NUM_ANALOG_INPUTS 16 + +// 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 PB0 +#endif +#ifndef PIN_SPI_SS3 + #define PIN_SPI_SS3 PD9 +#endif +#ifndef PIN_SPI_MOSI + #define PIN_SPI_MOSI PA2 +#endif +#ifndef PIN_SPI_MISO + #define PIN_SPI_MISO PA6 +#endif +#ifndef PIN_SPI_SCK + #define PIN_SPI_SCK PA1 +#endif + +// I2C definitions +#ifndef PIN_WIRE_SDA + #define PIN_WIRE_SDA PA6 +#endif +#ifndef PIN_WIRE_SCL + #define PIN_WIRE_SCL PA7 +#endif + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE + #define TIMER_TONE TIM6 +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM7 +#endif + +// UART Definitions +#ifndef SERIAL_UART_INSTANCE + #define SERIAL_UART_INSTANCE 4 +#endif + +// Default pin used for generic 'Serial' instance +// Mandatory for Firmata +#ifndef PIN_SERIAL_RX + #define PIN_SERIAL_RX PA1 +#endif +#ifndef PIN_SERIAL_TX + #define PIN_SERIAL_TX PA0 +#endif + +// Extra HAL modules +#if !defined(HAL_DAC_MODULE_DISABLED) + #define HAL_DAC_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/buildroot/share/PlatformIO/variants/MARLIN_H723Vx/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_H723Vx/PeripheralPins.c new file mode 100644 index 000000000000..e484edd1ad44 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_H723Vx/PeripheralPins.c @@ -0,0 +1,590 @@ +/* + ******************************************************************************* + * 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 + * + ******************************************************************************* + */ +/* + * Automatically generated from STM32H723VEHx.xml, STM32H723VETx.xml + * STM32H723VGHx.xml, STM32H723VGTx.xml + * STM32H730VBHx.xml, STM32H730VBTx.xml + * STM32H733VGHx.xml, STM32H733VGTx.xml + * CubeMX DB release 6.0.60 + */ +#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, 16, 0)}, // ADC1_INP16 + {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 17, 0)}, // ADC1_INP17 + {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_INP14 + {PA_2_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_INP14 + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_INP15 + {PA_3_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_INP15 + {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)}, // ADC1_INP18 + {PA_4_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)}, // ADC2_INP18 + {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 19, 0)}, // ADC1_INP19 + {PA_5_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 19, 0)}, // ADC2_INP19 + {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_INP3 + {PA_6_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_INP3 + {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_INP7 + {PA_7_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_INP7 + {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_INP9 + {PB_0_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_INP9 + {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_INP5 + {PB_1_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_INP5 + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_INP10 + {PC_0_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_INP10 + {PC_0_ALT2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_INP10 + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_INP11 + {PC_1_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_INP11 + {PC_1_ALT2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_INP11 + {PC_2_C, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_INP0 + {PC_3_C, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_INP1 + {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_INP4 + {PC_4_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_INP4 + {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_INP8 + {PC_5_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_INP8 + {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)}, // DAC1_OUT1 + {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC1_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_7_ALT1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_9_ALT1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, + {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)}, + {PC_9_ALT1, I2C5, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C5)}, + {PC_10, I2C5, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C5)}, + {PD_13, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C4)}, + {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)}, + {PA_8_ALT1, I2C5, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C5)}, + {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_6_ALT1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_8_ALT1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, + {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {PC_11, I2C5, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C5)}, + {PD_12, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C4)}, + {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_1_ALT2, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 1)}, // TIM15_CH1N + {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, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 0)}, // TIM15_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, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 2, 0)}, // TIM15_CH2 + {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PA_5_ALT1, 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_ALT1, 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_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PA_7_ALT2, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + {PA_7_ALT3, 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 + {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_0_ALT2, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + {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_1_ALT2, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + {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_6_ALT1, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 1)}, // TIM16_CH1N + {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + {PB_7_ALT1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 1)}, // TIM17_CH1N + {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + {PB_8_ALT1, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 0)}, // TIM16_CH1 + {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PB_9_ALT1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 0)}, // TIM17_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_ALT1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + {PB_14_ALT2, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_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_ALT1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + {PB_15_ALT2, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_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_ALT1, 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_ALT1, 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_ALT1, 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_ALT1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 + {PC_12, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM15, 1, 0)}, // TIM15_CH1 + {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PE_4, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 1)}, // TIM15_CH1N + {PE_5, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 0)}, // TIM15_CH1 + {PE_6, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 2, 0)}, // TIM15_CH2 + {PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + {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 + {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 + +//*** UART *** + +#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, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, + {PA_9_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PA_12, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_UART4)}, + {PA_15, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, + {PB_4, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, + {PB_6, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)}, + {PB_6_ALT1, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, + {PB_6_ALT2, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_9, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PB_13, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, + {PB_14, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, + {PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + {PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PC_10_ALT1, 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_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {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)}, + {PD_15, UART9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART9)}, + {PE_1, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, + {PE_3, USART10, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_USART10)}, + {PE_8, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +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_8, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, + {PA_10, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, + {PA_10_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PA_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_UART4)}, + {PB_3, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, + {PB_5, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, + {PB_7, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)}, + {PB_7_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_8, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PB_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, + {PB_15, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, + {PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + {PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PC_11_ALT1, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PD_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {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)}, + {PD_14, UART9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART9)}, + {PE_0, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, + {PE_2, USART10, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART10)}, + {PE_7, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + {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, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, + {PA_12_ALT1, 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, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PB_14_ALT1, 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_AF8_UART5)}, + {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)}, + {PD_13, UART9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART9)}, + {PD_15, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, + {PE_9, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + {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, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, + {PA_11_ALT1, 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)}, + {PB_15, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PC_9, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {PD_0, UART9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART9)}, + {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)}, + {PD_14, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, + {PE_10, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + {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)}, + {PA_7_ALT1, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + {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_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + {PB_5_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + {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_AF5_SPI2)}, + {PC_3_C, 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)}, + {PD_6, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)}, + {PD_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PE_6, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {PE_14, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {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)}, + {PA_6_ALT1, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + {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_4_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_2_C, 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)}, + {PE_5, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {PE_13, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {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)}, + {PA_5_ALT1, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + {PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PA_12, 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_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_3_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + {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)}, + {PC_12, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, + {PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PE_2, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {PE_12, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SSEL[] = { + {PA_0, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, + {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_4_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + {PA_11, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {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)}, + {PA_15_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI6)}, + {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)}, + {PE_4, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {PE_11, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {NC, NP, 0} +}; +#endif + +//*** FDCAN *** + +#ifdef HAL_FDCAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_RD[] = { + {PA_11, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, + {PB_5, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, + {PB_8, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, + {PB_12, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, + {PD_0, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, + {PD_12, FDCAN3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_FDCAN3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_FDCAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_TD[] = { + {PA_12, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, + {PB_6, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, + {PB_9, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, + {PB_13, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, + {PD_1, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, + {PD_13, FDCAN3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_FDCAN3)}, + {NC, NP, 0} +}; +#endif + +//*** ETHERNET *** + +#if defined(HAL_ETH_MODULE_ENABLED) || defined(HAL_ETH_LEGACY_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 + {PA_1_ALT1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // 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 + {PA_7_ALT1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RX_DV + {PA_9, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_ER + {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_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_ER + {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_C, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD2 + {PC_3_C, 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 + {NC, NP, 0} +}; +#endif + +//*** OCTOSPI *** + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_DATA0[] = { + {PA_2, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO0 + {PB_1, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO0 + {PB_12, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO0 + {PC_3_C, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO0 + {PC_9, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO0 + {PD_11, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO0 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_DATA1[] = { + {PB_0, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO1 + {PC_10, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO1 + {PD_12, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO1 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_DATA2[] = { + {PA_3, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO2 + {PA_7, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO2 + {PB_13, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO2 + {PC_2_C, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO2 + {PE_2, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO2 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_DATA3[] = { + {PA_1, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO3 + {PA_6, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO3 + {PD_13, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO3 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_DATA4[] = { + {PC_1, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO4 + {PD_4, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO4 + {PE_7, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO4 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_DATA5[] = { + {PC_2_C, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO5 + {PD_5, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO5 + {PE_8, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO5 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_DATA6[] = { + {PC_3_C, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO6 + {PD_6, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO6 + {PE_9, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO6 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_DATA7[] = { + {PD_7, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO7 + {PE_10, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO7 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_SCLK[] = { + {PA_3, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OCTOSPIM_P1)}, // OCTOSPIM_P1_CLK + {PB_2, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_CLK + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_SSEL[] = { + {PB_6, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_NCS + {PB_10, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_NCS + {PC_11, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_NCS + {PE_11, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_OCTOSPIM_P1)}, // OCTOSPIM_P1_NCS + {NC, NP, 0} +}; +#endif + +//*** USB *** + +#if defined(HAL_PCD_MODULE_ENABLED) || defined(HAL_HCD_MODULE_ENABLED) +WEAK const PinMap PinMap_USB_OTG_HS[] = { +#ifdef USE_USB_HS_IN_FS + {PA_8, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_SOF + {PA_9, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS + {PA_10, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ID + {PA_11, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF_NONE)}, // USB_OTG_HS_DM + {PA_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF_NONE)}, // USB_OTG_HS_DP +#else + {PA_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_D0 + {PA_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_CK + {PB_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_D1 + {PB_1, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_D2 + {PB_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_D7 + {PB_10, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_D3 + {PB_11, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_D4 + {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_D5 + {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_D6 + {PC_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_STP + {PC_2_C, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_DIR + {PC_3_C, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_NXT +#endif /* USE_USB_HS_IN_FS */ + {NC, NP, 0} +}; +#endif + +//*** SD *** + +#ifdef HAL_SD_MODULE_ENABLED +WEAK const PinMap PinMap_SD[] = { + {PA_0, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_SDMMC2)}, // SDMMC2_CMD + {PB_3, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDMMC2)}, // SDMMC2_D2 + {PB_4, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDMMC2)}, // SDMMC2_D3 + {PB_8, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF7_SDMMC1)}, // SDMMC1_CKIN + {PB_8_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D4 + {PB_8_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDMMC2)}, // SDMMC2_D4 + {PB_9, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF7_SDMMC1)}, // SDMMC1_CDIR + {PB_9_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D5 + {PB_9_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDMMC2)}, // SDMMC2_D5 + {PB_13, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D0 + {PB_14, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDMMC2)}, // SDMMC2_D0 + {PB_15, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDMMC2)}, // SDMMC2_D1 + {PC_1, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_SDMMC2)}, // SDMMC2_CK + {PC_4, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_SDMMC2)}, // SDMMC2_CKIN + {PC_6, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF8_SDMMC1)}, // SDMMC1_D0DIR + {PC_6_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D6 + {PC_6_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDMMC2)}, // SDMMC2_D6 + {PC_7, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF8_SDMMC1)}, // SDMMC1_D123DIR + {PC_7_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D7 + {PC_7_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDMMC2)}, // SDMMC2_D7 + {PC_8, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D0 + {PC_9, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D1 + {PC_10, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D2 + {PC_11, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D3 + {PC_12, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDMMC1)}, // SDMMC1_CK + {PD_2, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDMMC1)}, // SDMMC1_CMD + {PD_6, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF11_SDMMC2)}, // SDMMC2_CK + {PD_7, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF11_SDMMC2)}, // SDMMC2_CMD + {NC, NP, 0} +}; +#endif + +#endif /* !CUSTOM_PERIPHERAL_PINS */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H723Vx/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_H723Vx/PinNamesVar.h new file mode 100644 index 000000000000..3bd0ed8fcd64 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_H723Vx/PinNamesVar.h @@ -0,0 +1,108 @@ +/* Dual pad pin name */ +PC_2_C = PC_2 | PDUAL, +PC_3_C = PC_3 | PDUAL, + +/* Alternate pin name */ +PA_0_ALT1 = PA_0 | ALT1, +PA_1_ALT1 = PA_1 | ALT1, +PA_1_ALT2 = PA_1 | ALT2, +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_4_ALT2 = PA_4 | ALT2, +PA_5_ALT1 = PA_5 | ALT1, +PA_6_ALT1 = PA_6 | ALT1, +PA_7_ALT1 = PA_7 | ALT1, +PA_7_ALT2 = PA_7 | ALT2, +PA_7_ALT3 = PA_7 | ALT3, +PA_8_ALT1 = PA_8 | ALT1, +PA_9_ALT1 = PA_9 | ALT1, +PA_10_ALT1 = PA_10 | ALT1, +PA_11_ALT1 = PA_11 | ALT1, +PA_12_ALT1 = PA_12 | ALT1, +PA_15_ALT1 = PA_15 | ALT1, +PA_15_ALT2 = PA_15 | ALT2, +PB_0_ALT1 = PB_0 | ALT1, +PB_0_ALT2 = PB_0 | ALT2, +PB_1_ALT1 = PB_1 | ALT1, +PB_1_ALT2 = PB_1 | ALT2, +PB_3_ALT1 = PB_3 | ALT1, +PB_3_ALT2 = PB_3 | ALT2, +PB_4_ALT1 = PB_4 | ALT1, +PB_4_ALT2 = PB_4 | ALT2, +PB_5_ALT1 = PB_5 | ALT1, +PB_5_ALT2 = PB_5 | ALT2, +PB_6_ALT1 = PB_6 | ALT1, +PB_6_ALT2 = PB_6 | ALT2, +PB_7_ALT1 = PB_7 | ALT1, +PB_8_ALT1 = PB_8 | ALT1, +PB_8_ALT2 = PB_8 | ALT2, +PB_9_ALT1 = PB_9 | ALT1, +PB_9_ALT2 = PB_9 | ALT2, +PB_14_ALT1 = PB_14 | ALT1, +PB_14_ALT2 = PB_14 | ALT2, +PB_15_ALT1 = PB_15 | ALT1, +PB_15_ALT2 = PB_15 | ALT2, +PC_0_ALT1 = PC_0 | ALT1, +PC_0_ALT2 = PC_0 | ALT2, +PC_1_ALT1 = PC_1 | ALT1, +PC_1_ALT2 = PC_1 | ALT2, +PC_4_ALT1 = PC_4 | ALT1, +PC_5_ALT1 = PC_5 | ALT1, +PC_6_ALT1 = PC_6 | ALT1, +PC_6_ALT2 = PC_6 | ALT2, +PC_7_ALT1 = PC_7 | ALT1, +PC_7_ALT2 = PC_7 | ALT2, +PC_8_ALT1 = PC_8 | ALT1, +PC_9_ALT1 = PC_9 | ALT1, +PC_10_ALT1 = PC_10 | ALT1, +PC_11_ALT1 = PC_11 | ALT1, + +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 + SYS_WKUP1 = PA_0, +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = PA_2, +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = PC_13, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = PC_1, +#endif +#ifdef PWR_WAKEUP_PIN7 + SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 + SYS_WKUP8 = NC, +#endif + +/* USB */ +#ifdef USBCON + USB_OTG_HS_DM = PA_11, + USB_OTG_HS_DP = PA_12, + USB_OTG_HS_ID = PA_10, + USB_OTG_HS_SOF = PA_8, + USB_OTG_HS_ULPI_CK = PA_5, + USB_OTG_HS_ULPI_D0 = PA_3, + USB_OTG_HS_ULPI_D1 = PB_0, + USB_OTG_HS_ULPI_D2 = PB_1, + USB_OTG_HS_ULPI_D3 = PB_10, + USB_OTG_HS_ULPI_D4 = PB_11, + USB_OTG_HS_ULPI_D5 = PB_12, + USB_OTG_HS_ULPI_D6 = PB_13, + USB_OTG_HS_ULPI_D7 = PB_5, + USB_OTG_HS_ULPI_DIR = PC_2_C, + USB_OTG_HS_ULPI_NXT = PC_3_C, + USB_OTG_HS_ULPI_STP = PC_0, + USB_OTG_HS_VBUS = PA_9, +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H723Vx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_H723Vx/ldscript.ld new file mode 100644 index 000000000000..63228610336b --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_H723Vx/ldscript.ld @@ -0,0 +1,174 @@ +/* +****************************************************************************** +** +** File : LinkerScript.ld +** +** Author : STM32CubeIDE +** +** Abstract : Linker script for STM32H7 series +** 512Kbytes FLASH and 560Kbytes 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) 2022 STMicroelectronics. +** All rights reserved. +** +** This software is licensed under terms that can be found in the LICENSE file +** in the root directory of this software component. +** If no LICENSE file comes with this software, it is provided AS-IS. +** +**************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = ORIGIN(RAM_D1) + LENGTH(RAM_D1); /* 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 +{ + ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K + DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K + FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET + RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 320K + RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K + RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K +} + +/* 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 */ + *(.RamFunc) /* .RamFunc sections */ + *(.RamFunc*) /* .RamFunc* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM_D1 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_D1 + + /* 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_D1 + + /* 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_H723Vx/variant_MARLIN_STM32H723VX.cpp b/buildroot/share/PlatformIO/variants/MARLIN_H723Vx/variant_MARLIN_STM32H723VX.cpp new file mode 100644 index 000000000000..bfeb0f9abc62 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_H723Vx/variant_MARLIN_STM32H723VX.cpp @@ -0,0 +1,273 @@ +/* + ******************************************************************************* + * 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 + * + ******************************************************************************* + */ +#ifdef STM32H723xx +#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_11, // D27 + PB_12, // D28 + PB_13, // D29 + PB_14, // D30 + PB_15, // D31 + PC_0, // D32/A10 + PC_1, // D33/A11 + PC_4, // D34/A12 + PC_5, // D35/A13 + PC_6, // D36 + PC_7, // D37 + PC_8, // D38 + PC_9, // D39 + PC_10, // D40 + PC_11, // D41 + PC_12, // D42 + PC_13, // D43 + PC_14, // D44 + PC_15, // D45 + PD_0, // D46 + PD_1, // D47 + PD_2, // D48 + PD_3, // D49 + PD_4, // D50 + PD_5, // D51 + PD_6, // D52 + PD_7, // D53 + PD_8, // D54 + PD_9, // D55 + PD_10, // D56 + PD_11, // D57 + PD_12, // D58 + PD_13, // D59 + PD_14, // D60 + PD_15, // D61 + PE_0, // D62 + PE_1, // D63 + PE_2, // D64 + PE_3, // D65 + PE_4, // D66 + PE_5, // D67 + PE_6, // D68 + PE_7, // D69 + PE_8, // D70 + PE_9, // D71 + PE_10, // D72 + PE_11, // D73 + PE_12, // D74 + PE_13, // D75 + PE_14, // D76 + PE_15, // D77 + PH_0, // D78 + PH_1, // D79 + PC_2_C, // D80/A14 + PC_3_C // D81/A15 +}; + +// 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, PC4 + 35, // A13, PC5 + 80, // A14, PC2_C + 81 // A15, PC3_C +}; + +void MPU_Config(void) +{ + MPU_Region_InitTypeDef MPU_InitStruct = {0}; + + /* Disables the MPU */ + HAL_MPU_Disable(); + + /** Initializes and configures the Region and the memory to be protected + */ + MPU_InitStruct.Enable = MPU_REGION_ENABLE; + MPU_InitStruct.Number = MPU_REGION_NUMBER0; + MPU_InitStruct.BaseAddress = 0x0; + MPU_InitStruct.Size = MPU_REGION_SIZE_4GB; + MPU_InitStruct.SubRegionDisable = 0x87; + MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0; + MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS; + MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE; + MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE; + MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE; + MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE; + + HAL_MPU_ConfigRegion(&MPU_InitStruct); + /* Enables the MPU */ + HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); + +} + +/* + * @brief System Clock Configuration + * @param None + * @retval None + */ +WEAK void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {}; + + MPU_Config(); + + /** Supply configuration update enable + */ + HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); + /** Configure the main internal regulator output voltage + */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0); + + while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; // 48Mhz for USB + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 5; // 25Mhz / 5 = 5Mhz + RCC_OscInitStruct.PLL.PLLN = 110; // 25Mhz / 5 * 110 = 550Mhz + RCC_OscInitStruct.PLL.PLLP = 1; // 550Mhz / 1 = 550Mhz + RCC_OscInitStruct.PLL.PLLQ = 10; // 550Mhz / 10 = 55Mhz + RCC_OscInitStruct.PLL.PLLR = 10; // unused + RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2; + RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE; + RCC_OscInitStruct.PLL.PLLFRACN = 0; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Initializes the CPU, AHB and APB buses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2 + |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2; + RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2; + RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) + { + Error_Handler(); + } + + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB + | RCC_PERIPHCLK_SDMMC | RCC_PERIPHCLK_ADC + | RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_USART16 + | RCC_PERIPHCLK_USART234578 | RCC_PERIPHCLK_I2C123 + | RCC_PERIPHCLK_I2C4 | RCC_PERIPHCLK_SPI123 + | RCC_PERIPHCLK_SPI45 | RCC_PERIPHCLK_SPI6; + + /* HSI48 used for USB 48 Mhz */ + /* PLL1 qclk also used for FMC, SDMMC, RNG, SAI */ + /* PLL2 pclk is needed for adc max 80 Mhz (p,q,r same) */ + /* PLL2 pclk also used for LP timers 2,3,4,5, SPI 1,2,3 */ + /* PLL2 qclk is needed for uart, can, spi4,5,6 80 Mhz */ + /* PLL3 r clk is needed for i2c 80 Mhz (p,q,r same) */ + PeriphClkInitStruct.PLL2.PLL2M = 15; // M DIV 15 vco 25 / 15 ~ 1.667 Mhz + PeriphClkInitStruct.PLL2.PLL2N = 96; // N MUL 96 + PeriphClkInitStruct.PLL2.PLL2P = 2; // P div 2 + PeriphClkInitStruct.PLL2.PLL2Q = 2; // Q div 2 + PeriphClkInitStruct.PLL2.PLL2R = 2; // R div 2 + // RCC_PLL1VCIRANGE_0 Clock range frequency between 1 and 2 MHz + PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_0; + PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOMEDIUM; + PeriphClkInitStruct.PLL2.PLL2FRACN = 0; + PeriphClkInitStruct.PLL3.PLL3M = 15; // M DIV 15 vco 25 / 15 ~ 1.667 Mhz + PeriphClkInitStruct.PLL3.PLL3N = 96; // N MUL 96 + PeriphClkInitStruct.PLL3.PLL3P = 2; // P div 2 + PeriphClkInitStruct.PLL3.PLL3Q = 2; // Q div 2 + PeriphClkInitStruct.PLL3.PLL3R = 2; // R div 2 + // RCC_PLL1VCIRANGE_0 Clock range frequency between 1 and 2 MHz + PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_0; + PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOMEDIUM; + PeriphClkInitStruct.PLL3.PLL3FRACN = 0; + // ADC from PLL2 pclk + PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2; + // USB from HSI48 + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; + // SDMMC from PLL1 qclk + PeriphClkInitStruct.SdmmcClockSelection = 0; + //PeriphClkInitStruct.SdmmcClockSelection = RCC_SDMMCCLKSOURCE_PLL; + // LPUART from PLL2 qclk + PeriphClkInitStruct.Lpuart1ClockSelection = 0; + //PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PLL2; + // USART from PLL2 qclk + PeriphClkInitStruct.Usart16ClockSelection = RCC_USART16CLKSOURCE_PLL2; + // USART from PLL2 qclk + PeriphClkInitStruct.Usart234578ClockSelection = 0; + //PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_PLL2; + // I2C123 from PLL3 rclk + PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_PLL3; + // I2C4 from PLL3 rclk + PeriphClkInitStruct.I2c4ClockSelection = 0; + //PeriphClkInitStruct.I2c4ClockSelection = RCC_I2C4CLKSOURCE_PLL3; + // SPI123 from PLL2 pclk + PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL2; + // SPI45 from PLL2 qclk + PeriphClkInitStruct.Spi45ClockSelection = 0; + //PeriphClkInitStruct.Spi45ClockSelection = RCC_SPI45CLKSOURCE_PLL2; + // SPI6 from PLL2 qclk + PeriphClkInitStruct.Spi6ClockSelection = 0; + //PeriphClkInitStruct.Spi6ClockSelection = RCC_SPI6CLKSOURCE_PLL2; + + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { + Error_Handler(); + } +} + +#endif /* ARDUINO_GENERIC_* */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H723Vx/variant_MARLIN_STM32H723VX.h b/buildroot/share/PlatformIO/variants/MARLIN_H723Vx/variant_MARLIN_STM32H723VX.h new file mode 100644 index 000000000000..8b67905680a9 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_H723Vx/variant_MARLIN_STM32H723VX.h @@ -0,0 +1,269 @@ +/* + ******************************************************************************* + * 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 + * + ******************************************************************************* + */ +#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 PB11 27 +#define PB12 28 +#define PB13 29 +#define PB14 30 +#define PB15 31 +#define PC0 PIN_A10 +#define PC1 PIN_A11 +#define PC4 PIN_A12 +#define PC5 PIN_A13 +#define PC6 36 +#define PC7 37 +#define PC8 38 +#define PC9 39 +#define PC10 40 +#define PC11 41 +#define PC12 42 +#define PC13 43 +#define PC14 44 +#define PC15 45 +#define PD0 46 +#define PD1 47 +#define PD2 48 +#define PD3 49 +#define PD4 50 +#define PD5 51 +#define PD6 52 +#define PD7 53 +#define PD8 54 +#define PD9 55 +#define PD10 56 +#define PD11 57 +#define PD12 58 +#define PD13 59 +#define PD14 60 +#define PD15 61 +#define PE0 62 +#define PE1 63 +#define PE2 64 +#define PE3 65 +#define PE4 66 +#define PE5 67 +#define PE6 68 +#define PE7 69 +#define PE8 70 +#define PE9 71 +#define PE10 72 +#define PE11 73 +#define PE12 74 +#define PE13 75 +#define PE14 76 +#define PE15 77 +#define PH0 78 +#define PH1 79 +#define PC2_C PIN_A14 +#define PC3_C PIN_A15 +#define PC2 PC2_C +#define PC3 PC3_C + +// Alternate pins number +#define PA0_ALT1 (PA0 | ALT1) +#define PA1_ALT1 (PA1 | ALT1) +#define PA1_ALT2 (PA1 | ALT2) +#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 PA4_ALT2 (PA4 | ALT2) +#define PA5_ALT1 (PA5 | ALT1) +#define PA6_ALT1 (PA6 | ALT1) +#define PA7_ALT1 (PA7 | ALT1) +#define PA7_ALT2 (PA7 | ALT2) +#define PA7_ALT3 (PA7 | ALT3) +#define PA8_ALT1 (PA8 | ALT1) +#define PA9_ALT1 (PA9 | ALT1) +#define PA10_ALT1 (PA10 | ALT1) +#define PA11_ALT1 (PA11 | ALT1) +#define PA12_ALT1 (PA12 | ALT1) +#define PA15_ALT1 (PA15 | ALT1) +#define PA15_ALT2 (PA15 | ALT2) +#define PB0_ALT1 (PB0 | ALT1) +#define PB0_ALT2 (PB0 | ALT2) +#define PB1_ALT1 (PB1 | ALT1) +#define PB1_ALT2 (PB1 | ALT2) +#define PB3_ALT1 (PB3 | ALT1) +#define PB3_ALT2 (PB3 | ALT2) +#define PB4_ALT1 (PB4 | ALT1) +#define PB4_ALT2 (PB4 | ALT2) +#define PB5_ALT1 (PB5 | ALT1) +#define PB5_ALT2 (PB5 | ALT2) +#define PB6_ALT1 (PB6 | ALT1) +#define PB6_ALT2 (PB6 | ALT2) +#define PB7_ALT1 (PB7 | ALT1) +#define PB8_ALT1 (PB8 | ALT1) +#define PB8_ALT2 (PB8 | ALT2) +#define PB9_ALT1 (PB9 | ALT1) +#define PB9_ALT2 (PB9 | ALT2) +#define PB14_ALT1 (PB14 | ALT1) +#define PB14_ALT2 (PB14 | ALT2) +#define PB15_ALT1 (PB15 | ALT1) +#define PB15_ALT2 (PB15 | ALT2) +#define PC0_ALT1 (PC0 | ALT1) +#define PC0_ALT2 (PC0 | ALT2) +#define PC1_ALT1 (PC1 | ALT1) +#define PC1_ALT2 (PC1 | ALT2) +#define PC4_ALT1 (PC4 | ALT1) +#define PC5_ALT1 (PC5 | ALT1) +#define PC6_ALT1 (PC6 | ALT1) +#define PC6_ALT2 (PC6 | ALT2) +#define PC7_ALT1 (PC7 | ALT1) +#define PC7_ALT2 (PC7 | ALT2) +#define PC8_ALT1 (PC8 | ALT1) +#define PC9_ALT1 (PC9 | ALT1) +#define PC10_ALT1 (PC10 | ALT1) +#define PC11_ALT1 (PC11 | ALT1) + +#define NUM_DIGITAL_PINS 82 +#define NUM_DUALPAD_PINS 2 +#define NUM_ANALOG_INPUTS 16 + +// 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 PB7 +#endif +#ifndef PIN_WIRE_SCL + #define PIN_WIRE_SCL PB6 +#endif + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE + #define TIMER_TONE TIM6 +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM7 +#endif + +// UART Definitions +#ifndef SERIAL_UART_INSTANCE + #define SERIAL_UART_INSTANCE 4 +#endif + +// Default pin used for generic 'Serial' instance +// Mandatory for Firmata +#ifndef PIN_SERIAL_RX + #define PIN_SERIAL_RX PA1 +#endif +#ifndef PIN_SERIAL_TX + #define PIN_SERIAL_TX PA0 +#endif + +// Extra HAL modules +#if !defined(HAL_DAC_MODULE_DISABLED) + #define HAL_DAC_MODULE_ENABLED +#endif +#if !defined(HAL_ETH_MODULE_DISABLED) + #define HAL_ETH_MODULE_ENABLED +#endif +#if !defined(HAL_OSPI_MODULE_DISABLED) + #define HAL_OSPI_MODULE_ENABLED +#endif +#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/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/PeripheralPins.c new file mode 100644 index 000000000000..70048173e787 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/PeripheralPins.c @@ -0,0 +1,688 @@ +/* + ******************************************************************************* + * 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 STM32H723ZETx.xml, STM32H723ZGTx.xml + * STM32H733ZGTx.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, 16, 0)}, // ADC1_INP16 + {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 17, 0)}, // ADC1_INP17 + {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_INP14 + {PA_2_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_INP14 + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_INP15 + {PA_3_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_INP15 + {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)}, // ADC1_INP18 + {PA_4_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 18, 0)}, // ADC2_INP18 + {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 19, 0)}, // ADC1_INP19 + {PA_5_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 19, 0)}, // ADC2_INP19 + {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_INP3 + {PA_6_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_INP3 + {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_INP7 + {PA_7_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_INP7 + {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_INP9 + {PB_0_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_INP9 + {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_INP5 + {PB_1_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_INP5 + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_INP10 + {PC_0_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_INP10 + {PC_0_ALT2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_INP10 + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_INP11 + {PC_1_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_INP11 + {PC_1_ALT2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_INP11 + {PC_2_C, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_INP0 + {PC_3_C, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_INP1 + {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_INP4 + {PC_4_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_INP4 + {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_INP8 + {PC_5_ALT1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_INP8 + {PF_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC3_INP5 + {PF_4, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC3_INP9 + {PF_5, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC3_INP4 + {PF_6, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC3_INP8 + {PF_7, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_INP3 + {PF_8, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC3_INP7 + {PF_9, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_INP2 + {PF_10, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC3_INP6 + {PF_11, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_INP2 + {PF_12, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_INP6 + {PF_13, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_INP2 + {PF_14, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_INP6 + {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)}, // DAC1_OUT1 + {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC1_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_7_ALT1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_9_ALT1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, + {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)}, + {PC_9_ALT1, I2C5, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C5)}, + {PC_10, I2C5, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C5)}, + {PD_13, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C4)}, + {PF_0, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {PF_0_ALT1, I2C5, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C5)}, + {PF_15, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C4)}, + {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)}, + {PA_8_ALT1, I2C5, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C5)}, + {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_6_ALT1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_8_ALT1, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C4)}, + {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {PC_11, I2C5, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C5)}, + {PD_12, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C4)}, + {PF_1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {PF_1_ALT1, I2C5, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C5)}, + {PF_14, I2C4, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C4)}, + {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_1_ALT2, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 1)}, // TIM15_CH1N + {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, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 0)}, // TIM15_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, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 2, 0)}, // TIM15_CH2 + {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PA_5_ALT1, 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_ALT1, 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_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PA_7_ALT2, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + {PA_7_ALT3, 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 + {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_0_ALT2, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + {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_1_ALT2, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + {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_6_ALT1, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 1)}, // TIM16_CH1N + {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + {PB_7_ALT1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 1)}, // TIM17_CH1N + {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + {PB_8_ALT1, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 0)}, // TIM16_CH1 + {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PB_9_ALT1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 0)}, // TIM17_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_ALT1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + {PB_14_ALT2, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_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_ALT1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + {PB_15_ALT2, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_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_ALT1, 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_ALT1, 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_ALT1, 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_ALT1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 + {PC_12, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM15, 1, 0)}, // TIM15_CH1 + {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PE_4, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 1)}, // TIM15_CH1N + {PE_5, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 1, 0)}, // TIM15_CH1 + {PE_6, TIM15, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM15, 2, 0)}, // TIM15_CH2 + {PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + {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 + {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 + {PF_0, TIM23, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF13_TIM23, 1, 0)}, // TIM23_CH1 + {PF_1, TIM23, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF13_TIM23, 2, 0)}, // TIM23_CH2 + {PF_2, TIM23, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF13_TIM23, 3, 0)}, // TIM23_CH3 + {PF_3, TIM23, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF13_TIM23, 4, 0)}, // TIM23_CH4 + {PF_6, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 0)}, // TIM16_CH1 + {PF_6_ALT1, TIM23, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF13_TIM23, 1, 0)}, // TIM23_CH1 + {PF_7, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 0)}, // TIM17_CH1 + {PF_7_ALT1, TIM23, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF13_TIM23, 2, 0)}, // TIM23_CH2 + {PF_8, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + {PF_8_ALT1, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM16, 1, 1)}, // TIM16_CH1N + {PF_8_ALT2, TIM23, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF13_TIM23, 3, 0)}, // TIM23_CH3 + {PF_9, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 + {PF_9_ALT1, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM17, 1, 1)}, // TIM17_CH1N + {PF_9_ALT2, TIM23, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF13_TIM23, 4, 0)}, // TIM23_CH4 + {PF_11, TIM24, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM24, 1, 0)}, // TIM24_CH1 + {PF_12, TIM24, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM24, 2, 0)}, // TIM24_CH2 + {PF_13, TIM24, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM24, 3, 0)}, // TIM24_CH3 + {PF_14, TIM24, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_TIM24, 4, 0)}, // TIM24_CH4 + {PG_12, TIM23, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF13_TIM23, 1, 0)}, // TIM23_CH1 + {PG_13, TIM23, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF13_TIM23, 2, 0)}, // TIM23_CH2 + {PG_14, TIM23, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF13_TIM23, 3, 0)}, // TIM23_CH3 + {NC, NP, 0} +}; +#endif + +//*** UART *** + +#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, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, + {PA_9_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PA_12, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_UART4)}, + {PA_15, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, + {PB_4, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, + {PB_6, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)}, + {PB_6_ALT1, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, + {PB_6_ALT2, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_9, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PB_13, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, + {PB_14, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, + {PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + {PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PC_10_ALT1, 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_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {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)}, + {PD_15, UART9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART9)}, + {PE_1, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, + {PE_3, USART10, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_USART10)}, + {PE_8, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + {PF_7, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + {PG_1, UART9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART9)}, + {PG_12, USART10, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART10)}, + {PG_14, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +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_8, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, + {PA_10, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, + {PA_10_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PA_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_UART4)}, + {PB_3, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART7)}, + {PB_5, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, + {PB_7, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART)}, + {PB_7_ALT1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_8, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PB_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF14_UART5)}, + {PB_15, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, + {PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + {PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PC_11_ALT1, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {PD_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {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)}, + {PD_14, UART9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART9)}, + {PE_0, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, + {PE_2, USART10, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART10)}, + {PE_7, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + {PF_6, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + {PG_0, UART9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART9)}, + {PG_9, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + {PG_11, USART10, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART10)}, + {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, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, + {PA_12_ALT1, 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, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PB_14_ALT1, 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_AF8_UART5)}, + {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)}, + {PD_13, UART9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART9)}, + {PD_15, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, + {PE_9, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + {PF_8, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + {PG_8, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + {PG_12, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + {PG_14, USART10, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART10)}, + {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, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_LPUART)}, + {PA_11_ALT1, 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)}, + {PB_15, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PC_9, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {PD_0, UART9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_UART9)}, + {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)}, + {PD_14, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, + {PE_10, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + {PF_9, UART7, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART7)}, + {PG_13, USART10, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART10)}, + {PG_13_ALT1, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART6)}, + {PG_15, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_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)}, + {PA_7_ALT1, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + {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_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + {PB_5_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + {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_AF5_SPI2)}, + {PC_3_C, 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)}, + {PD_6, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)}, + {PD_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PE_6, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {PE_14, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {PF_9, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, + {PF_11, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, + {PG_14, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, + {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)}, + {PA_6_ALT1, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + {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_4_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_2_C, 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)}, + {PE_5, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {PE_13, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {PF_8, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, + {PG_9, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PG_12, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, + {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)}, + {PA_5_ALT1, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + {PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PA_12, 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_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_3_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + {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)}, + {PC_12, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, + {PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PE_2, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {PE_12, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {PF_7, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, + {PG_11, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PG_13, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SSEL[] = { + {PA_0, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, + {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_4_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_SPI6)}, + {PA_11, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {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)}, + {PA_15_ALT2, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI6)}, + {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)}, + {PE_4, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {PE_11, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, + {PF_6, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI5)}, + {PG_8, SPI6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)}, + {PG_10, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {NC, NP, 0} +}; +#endif + +//*** FDCAN *** + +#ifdef HAL_FDCAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_RD[] = { + {PA_11, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, + {PB_5, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, + {PB_8, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, + {PB_12, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, + {PD_0, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, + {PD_12, FDCAN3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_FDCAN3)}, + {PF_6, FDCAN3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_FDCAN3)}, + {PG_10, FDCAN3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_FDCAN3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_FDCAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_TD[] = { + {PA_12, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, + {PB_6, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, + {PB_9, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, + {PB_13, FDCAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN2)}, + {PD_1, FDCAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_FDCAN1)}, + {PD_13, FDCAN3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_FDCAN3)}, + {PF_7, FDCAN3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_FDCAN3)}, + {PG_9, FDCAN3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_FDCAN3)}, + {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 + {PA_1_ALT1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // 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 + {PA_7_ALT1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RX_DV + {PA_9, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_ER + {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_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_ER + {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_C, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD2 + {PC_3_C, 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_12, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD1 + {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 + +//*** OCTOSPI *** + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_DATA0[] = { + {PA_2, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO0 + {PB_1, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO0 + {PB_12, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO0 + {PC_3_C, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO0 + {PC_9, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO0 + {PD_11, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO0 + {PF_0, OCTOSPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P2)}, // OCTOSPIM_P2_IO0 + {PF_8, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO0 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_DATA1[] = { + {PB_0, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO1 + {PC_10, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO1 + {PD_12, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO1 + {PF_1, OCTOSPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P2)}, // OCTOSPIM_P2_IO1 + {PF_9, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO1 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_DATA2[] = { + {PA_3, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO2 + {PA_7, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO2 + {PB_13, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO2 + {PC_2_C, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO2 + {PE_2, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO2 + {PF_2, OCTOSPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P2)}, // OCTOSPIM_P2_IO2 + {PF_7, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO2 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_DATA3[] = { + {PA_1, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO3 + {PA_6, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO3 + {PD_13, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO3 + {PF_3, OCTOSPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P2)}, // OCTOSPIM_P2_IO3 + {PF_6, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO3 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_DATA4[] = { + {PC_1, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO4 + {PD_4, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO4 + {PE_7, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO4 + {PG_0, OCTOSPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P2)}, // OCTOSPIM_P2_IO4 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_DATA5[] = { + {PC_2_C, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO5 + {PD_5, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO5 + {PE_8, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO5 + {PG_1, OCTOSPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P2)}, // OCTOSPIM_P2_IO5 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_DATA6[] = { + {PC_3_C, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO6 + {PD_6, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO6 + {PE_9, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO6 + {PG_9, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO6 + {PG_10, OCTOSPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_OCTOSPIM_P2)}, // OCTOSPIM_P2_IO6 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_DATA7[] = { + {PD_7, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO7 + {PE_10, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO7 + {PG_11, OCTOSPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P2)}, // OCTOSPIM_P2_IO7 + {PG_14, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_IO7 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_SCLK[] = { + {PA_3, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OCTOSPIM_P1)}, // OCTOSPIM_P1_CLK + {PB_2, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_CLK + {PF_4, OCTOSPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P2)}, // OCTOSPIM_P2_CLK + {PF_10, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_CLK + {NC, NP, 0} +}; +#endif + +#ifdef HAL_OSPI_MODULE_ENABLED +WEAK const PinMap PinMap_OCTOSPI_SSEL[] = { + {PB_6, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_NCS + {PB_10, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_NCS + {PC_11, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_OCTOSPIM_P1)}, // OCTOSPIM_P1_NCS + {PE_11, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_OCTOSPIM_P1)}, // OCTOSPIM_P1_NCS + {PG_6, OCTOSPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OCTOSPIM_P1)}, // OCTOSPIM_P1_NCS + {PG_12, OCTOSPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_OCTOSPIM_P2)}, // OCTOSPIM_P2_NCS + {NC, NP, 0} +}; +#endif + +//*** USB *** + +#if defined(HAL_PCD_MODULE_ENABLED) || defined(HAL_HCD_MODULE_ENABLED) +WEAK const PinMap PinMap_USB_OTG_HS[] = { +#ifdef USE_USB_HS_IN_FS + {PA_8, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_SOF + {PA_9, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS + {PA_10, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ID + {PA_11, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF_NONE)}, // USB_OTG_HS_DM + {PA_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF_NONE)}, // USB_OTG_HS_DP +#else + {PA_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_D0 + {PA_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_CK + {PB_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_D1 + {PB_1, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_D2 + {PB_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_D7 + {PB_10, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_D3 + {PB_11, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_D4 + {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_D5 + {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_D6 + {PC_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_STP + {PC_2_C, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_DIR + {PC_3_C, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_HS)}, // USB_OTG_HS_ULPI_NXT +#endif /* USE_USB_HS_IN_FS */ + {NC, NP, 0} +}; +#endif + +//*** SD *** + +#ifdef HAL_SD_MODULE_ENABLED +WEAK const PinMap PinMap_SD[] = { + {PA_0, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_SDMMC2)}, // SDMMC2_CMD + {PB_3, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDMMC2)}, // SDMMC2_D2 + {PB_4, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDMMC2)}, // SDMMC2_D3 + {PB_8, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF7_SDMMC1)}, // SDMMC1_CKIN + {PB_8_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D4 + {PB_8_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDMMC2)}, // SDMMC2_D4 + {PB_9, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF7_SDMMC1)}, // SDMMC1_CDIR + {PB_9_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D5 + {PB_9_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDMMC2)}, // SDMMC2_D5 + {PB_13, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D0 + {PB_14, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDMMC2)}, // SDMMC2_D0 + {PB_15, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDMMC2)}, // SDMMC2_D1 + {PC_1, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_SDMMC2)}, // SDMMC2_CK + {PC_4, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_SDMMC2)}, // SDMMC2_CKIN + {PC_6, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF8_SDMMC1)}, // SDMMC1_D0DIR + {PC_6_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D6 + {PC_6_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDMMC2)}, // SDMMC2_D6 + {PC_7, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF8_SDMMC1)}, // SDMMC1_D123DIR + {PC_7_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D7 + {PC_7_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDMMC2)}, // SDMMC2_D7 + {PC_8, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D0 + {PC_9, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D1 + {PC_10, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D2 + {PC_11, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDMMC1)}, // SDMMC1_D3 + {PC_12, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDMMC1)}, // SDMMC1_CK + {PD_2, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDMMC1)}, // SDMMC1_CMD + {PD_6, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF11_SDMMC2)}, // SDMMC2_CK + {PD_7, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF11_SDMMC2)}, // SDMMC2_CMD + {PG_9, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_SDMMC2)}, // SDMMC2_D0 + {PG_10, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_SDMMC2)}, // SDMMC2_D1 + {PG_11, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDMMC2)}, // SDMMC2_D2 + {PG_12, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDMMC2)}, // SDMMC2_D3 + {PG_13, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDMMC2)}, // SDMMC2_D6 + {PG_14, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDMMC2)}, // SDMMC2_D7 + {NC, NP, 0} +}; +#endif + +#endif /* !CUSTOM_PERIPHERAL_PINS */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/PinNamesVar.h new file mode 100644 index 000000000000..ad9d80a62518 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/PinNamesVar.h @@ -0,0 +1,117 @@ +/* Dual pad pin name */ +PC_2_C = PC_2 | PDUAL, +PC_3_C = PC_3 | PDUAL, + +/* Alternate pin name */ +PA_0_ALT1 = PA_0 | ALT1, +PA_1_ALT1 = PA_1 | ALT1, +PA_1_ALT2 = PA_1 | ALT2, +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_4_ALT2 = PA_4 | ALT2, +PA_5_ALT1 = PA_5 | ALT1, +PA_6_ALT1 = PA_6 | ALT1, +PA_7_ALT1 = PA_7 | ALT1, +PA_7_ALT2 = PA_7 | ALT2, +PA_7_ALT3 = PA_7 | ALT3, +PA_8_ALT1 = PA_8 | ALT1, +PA_9_ALT1 = PA_9 | ALT1, +PA_10_ALT1 = PA_10 | ALT1, +PA_11_ALT1 = PA_11 | ALT1, +PA_12_ALT1 = PA_12 | ALT1, +PA_15_ALT1 = PA_15 | ALT1, +PA_15_ALT2 = PA_15 | ALT2, +PB_0_ALT1 = PB_0 | ALT1, +PB_0_ALT2 = PB_0 | ALT2, +PB_1_ALT1 = PB_1 | ALT1, +PB_1_ALT2 = PB_1 | ALT2, +PB_3_ALT1 = PB_3 | ALT1, +PB_3_ALT2 = PB_3 | ALT2, +PB_4_ALT1 = PB_4 | ALT1, +PB_4_ALT2 = PB_4 | ALT2, +PB_5_ALT1 = PB_5 | ALT1, +PB_5_ALT2 = PB_5 | ALT2, +PB_6_ALT1 = PB_6 | ALT1, +PB_6_ALT2 = PB_6 | ALT2, +PB_7_ALT1 = PB_7 | ALT1, +PB_8_ALT1 = PB_8 | ALT1, +PB_8_ALT2 = PB_8 | ALT2, +PB_9_ALT1 = PB_9 | ALT1, +PB_9_ALT2 = PB_9 | ALT2, +PB_14_ALT1 = PB_14 | ALT1, +PB_14_ALT2 = PB_14 | ALT2, +PB_15_ALT1 = PB_15 | ALT1, +PB_15_ALT2 = PB_15 | ALT2, +PC_0_ALT1 = PC_0 | ALT1, +PC_0_ALT2 = PC_0 | ALT2, +PC_1_ALT1 = PC_1 | ALT1, +PC_1_ALT2 = PC_1 | ALT2, +PC_4_ALT1 = PC_4 | ALT1, +PC_5_ALT1 = PC_5 | ALT1, +PC_6_ALT1 = PC_6 | ALT1, +PC_6_ALT2 = PC_6 | ALT2, +PC_7_ALT1 = PC_7 | ALT1, +PC_7_ALT2 = PC_7 | ALT2, +PC_8_ALT1 = PC_8 | ALT1, +PC_9_ALT1 = PC_9 | ALT1, +PC_10_ALT1 = PC_10 | ALT1, +PC_11_ALT1 = PC_11 | ALT1, +PF_0_ALT1 = PF_0 | ALT1, +PF_1_ALT1 = PF_1 | ALT1, +PF_6_ALT1 = PF_6 | ALT1, +PF_7_ALT1 = PF_7 | ALT1, +PF_8_ALT1 = PF_8 | ALT1, +PF_8_ALT2 = PF_8 | ALT2, +PF_9_ALT1 = PF_9 | ALT1, +PF_9_ALT2 = PF_9 | ALT2, +PG_13_ALT1 = PG_13 | ALT1, + +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 + SYS_WKUP1 = PA_0, +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = PA_2, +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = PC_13, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = PC_1, +#endif +#ifdef PWR_WAKEUP_PIN7 + SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 + SYS_WKUP8 = NC, +#endif + +/* USB */ +#ifdef USBCON + USB_OTG_HS_DM = PA_11, + USB_OTG_HS_DP = PA_12, + USB_OTG_HS_ID = PA_10, + USB_OTG_HS_SOF = PA_8, + USB_OTG_HS_ULPI_CK = PA_5, + USB_OTG_HS_ULPI_D0 = PA_3, + USB_OTG_HS_ULPI_D1 = PB_0, + USB_OTG_HS_ULPI_D2 = PB_1, + USB_OTG_HS_ULPI_D3 = PB_10, + USB_OTG_HS_ULPI_D4 = PB_11, + USB_OTG_HS_ULPI_D5 = PB_12, + USB_OTG_HS_ULPI_D6 = PB_13, + USB_OTG_HS_ULPI_D7 = PB_5, + USB_OTG_HS_ULPI_DIR = PC_2_C, + USB_OTG_HS_ULPI_NXT = PC_3_C, + USB_OTG_HS_ULPI_STP = PC_0, + USB_OTG_HS_VBUS = PA_9, +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/ldscript.ld new file mode 100644 index 000000000000..63228610336b --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/ldscript.ld @@ -0,0 +1,174 @@ +/* +****************************************************************************** +** +** File : LinkerScript.ld +** +** Author : STM32CubeIDE +** +** Abstract : Linker script for STM32H7 series +** 512Kbytes FLASH and 560Kbytes 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) 2022 STMicroelectronics. +** All rights reserved. +** +** This software is licensed under terms that can be found in the LICENSE file +** in the root directory of this software component. +** If no LICENSE file comes with this software, it is provided AS-IS. +** +**************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = ORIGIN(RAM_D1) + LENGTH(RAM_D1); /* 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 +{ + ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K + DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K + FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET + RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 320K + RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K + RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K +} + +/* 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 */ + *(.RamFunc) /* .RamFunc sections */ + *(.RamFunc*) /* .RamFunc* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM_D1 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_D1 + + /* 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_D1 + + /* 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_H723Zx/variant_MARLIN_STM32H723ZX.cpp b/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/variant_MARLIN_STM32H723ZX.cpp new file mode 100644 index 000000000000..4506cf5ce6b5 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/variant_MARLIN_STM32H723ZX.cpp @@ -0,0 +1,317 @@ +/* + ******************************************************************************* + * 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(STM32H723xx) +#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_11, // D27 + PB_12, // D28 + PB_13, // D29 + PB_14, // D30 + PB_15, // D31 + PC_0, // D32/A10 + PC_1, // D33/A11 + PC_4, // D34/A12 + PC_5, // D35/A13 + PC_6, // D36 + PC_7, // D37 + PC_8, // D38 + PC_9, // D39 + PC_10, // D40 + PC_11, // D41 + PC_12, // D42 + PC_13, // D43 + PC_14, // D44 + PC_15, // D45 + PD_0, // D46 + PD_1, // D47 + PD_2, // D48 + PD_3, // D49 + PD_4, // D50 + PD_5, // D51 + PD_6, // D52 + PD_7, // D53 + PD_8, // D54 + PD_9, // D55 + PD_10, // D56 + PD_11, // D57 + PD_12, // D58 + PD_13, // D59 + PD_14, // D60 + PD_15, // D61 + PE_0, // D62 + PE_1, // D63 + PE_2, // D64 + PE_3, // D65 + PE_4, // D66 + PE_5, // D67 + PE_6, // D68 + PE_7, // D69 + PE_8, // D70 + PE_9, // D71 + PE_10, // D72 + PE_11, // D73 + PE_12, // D74 + PE_13, // D75 + PE_14, // D76 + PE_15, // D77 + PF_0, // D78 + PF_1, // D79 + PF_2, // D80 + PF_3, // D81/A14 + PF_4, // D82/A15 + PF_5, // D83/A16 + PF_6, // D84/A17 + PF_7, // D85/A18 + PF_8, // D86/A19 + PF_9, // D87/A20 + PF_10, // D88/A21 + PF_11, // D89/A22 + PF_12, // D90/A23 + PF_13, // D91/A24 + PF_14, // D92/A25 + PF_15, // D93 + PG_0, // D94 + PG_1, // D95 + PG_2, // D96 + PG_3, // D97 + PG_4, // D98 + PG_5, // D99 + PG_6, // D100 + PG_7, // D101 + PG_8, // D102 + PG_9, // D103 + PG_10, // D104 + PG_11, // D105 + PG_12, // D106 + PG_13, // D107 + PG_14, // D108 + PG_15, // D109 + PH_0, // D110 + PH_1, // D111 + PC_2_C, // D112/A26 + PC_3_C // D113/A27 +}; + +// 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, PC4 + 35, // A13, PC5 + 81, // A14, PF3 + 82, // A15, PF4 + 83, // A16, PF5 + 84, // A17, PF6 + 85, // A18, PF7 + 86, // A19, PF8 + 87, // A20, PF9 + 88, // A21, PF10 + 89, // A22, PF11 + 90, // A23, PF12 + 91, // A24, PF13 + 92, // A25, PF14 + 112, // A26, PC2_C + 113 // A27, PC3_C +}; + +void MPU_Config(void) +{ + MPU_Region_InitTypeDef MPU_InitStruct = {0}; + + /* Disables the MPU */ + HAL_MPU_Disable(); + + /** Initializes and configures the Region and the memory to be protected + */ + MPU_InitStruct.Enable = MPU_REGION_ENABLE; + MPU_InitStruct.Number = MPU_REGION_NUMBER0; + MPU_InitStruct.BaseAddress = 0x0; + MPU_InitStruct.Size = MPU_REGION_SIZE_4GB; + MPU_InitStruct.SubRegionDisable = 0x87; + MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0; + MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS; + MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE; + MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE; + MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE; + MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE; + + HAL_MPU_ConfigRegion(&MPU_InitStruct); + /* Enables the MPU */ + HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); + +} + +/* + * @brief System Clock Configuration + * @param None + * @retval None + */ +WEAK void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {}; + + MPU_Config(); + + /** Supply configuration update enable + */ + HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); + /** Configure the main internal regulator output voltage + */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0); + + while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; // 48Mhz for USB + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 5; // 25Mhz / 5 = 5Mhz + RCC_OscInitStruct.PLL.PLLN = 110; // 25Mhz / 5 * 110 = 550Mhz + RCC_OscInitStruct.PLL.PLLP = 1; // 550Mhz / 1 = 550Mhz + RCC_OscInitStruct.PLL.PLLQ = 10; // 550Mhz / 10 = 55Mhz + RCC_OscInitStruct.PLL.PLLR = 10; // unused + RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2; + RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE; + RCC_OscInitStruct.PLL.PLLFRACN = 0; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + Error_Handler(); + } + /** Initializes the CPU, AHB and APB buses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2 + |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2; + RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2; + RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) + { + Error_Handler(); + } + + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB + | RCC_PERIPHCLK_SDMMC | RCC_PERIPHCLK_ADC + | RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_USART16 + | RCC_PERIPHCLK_USART234578 | RCC_PERIPHCLK_I2C123 + | RCC_PERIPHCLK_I2C4 | RCC_PERIPHCLK_SPI123 + | RCC_PERIPHCLK_SPI45 | RCC_PERIPHCLK_SPI6; + + /* HSI48 used for USB 48 Mhz */ + /* PLL1 qclk also used for FMC, SDMMC, RNG, SAI */ + /* PLL2 pclk is needed for adc max 80 Mhz (p,q,r same) */ + /* PLL2 pclk also used for LP timers 2,3,4,5, SPI 1,2,3 */ + /* PLL2 qclk is needed for uart, can, spi4,5,6 80 Mhz */ + /* PLL3 r clk is needed for i2c 80 Mhz (p,q,r same) */ + PeriphClkInitStruct.PLL2.PLL2M = 15; // M DIV 15 vco 25 / 15 ~ 1.667 Mhz + PeriphClkInitStruct.PLL2.PLL2N = 96; // N MUL 96 + PeriphClkInitStruct.PLL2.PLL2P = 2; // P div 2 + PeriphClkInitStruct.PLL2.PLL2Q = 2; // Q div 2 + PeriphClkInitStruct.PLL2.PLL2R = 2; // R div 2 + // RCC_PLL1VCIRANGE_0 Clock range frequency between 1 and 2 MHz + PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_0; + PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOMEDIUM; + PeriphClkInitStruct.PLL2.PLL2FRACN = 0; + PeriphClkInitStruct.PLL3.PLL3M = 15; // M DIV 15 vco 25 / 15 ~ 1.667 Mhz + PeriphClkInitStruct.PLL3.PLL3N = 96; // N MUL 96 + PeriphClkInitStruct.PLL3.PLL3P = 2; // P div 2 + PeriphClkInitStruct.PLL3.PLL3Q = 2; // Q div 2 + PeriphClkInitStruct.PLL3.PLL3R = 2; // R div 2 + // RCC_PLL1VCIRANGE_0 Clock range frequency between 1 and 2 MHz + PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_0; + PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOMEDIUM; + PeriphClkInitStruct.PLL3.PLL3FRACN = 0; + // ADC from PLL2 pclk + PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_PLL2; + // USB from HSI48 + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; + // SDMMC from PLL1 qclk + PeriphClkInitStruct.SdmmcClockSelection = 0; + //PeriphClkInitStruct.SdmmcClockSelection = RCC_SDMMCCLKSOURCE_PLL; + // LPUART from PLL2 qclk + PeriphClkInitStruct.Lpuart1ClockSelection = 0; + //PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PLL2; + // USART from PLL2 qclk + PeriphClkInitStruct.Usart16ClockSelection = RCC_USART16CLKSOURCE_PLL2; + // USART from PLL2 qclk + PeriphClkInitStruct.Usart234578ClockSelection = 0; + //PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_PLL2; + // I2C123 from PLL3 rclk + PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_PLL3; + // I2C4 from PLL3 rclk + PeriphClkInitStruct.I2c4ClockSelection = 0; + //PeriphClkInitStruct.I2c4ClockSelection = RCC_I2C4CLKSOURCE_PLL3; + // SPI123 from PLL2 pclk + PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL2; + // SPI45 from PLL2 qclk + PeriphClkInitStruct.Spi45ClockSelection = 0; + //PeriphClkInitStruct.Spi45ClockSelection = RCC_SPI45CLKSOURCE_PLL2; + // SPI6 from PLL2 qclk + PeriphClkInitStruct.Spi6ClockSelection = 0; + //PeriphClkInitStruct.Spi6ClockSelection = RCC_SPI6CLKSOURCE_PLL2; + + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { + Error_Handler(); + } +} + +#endif /* ARDUINO_GENERIC_* */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/variant_MARLIN_STM32H723ZX.h b/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/variant_MARLIN_STM32H723ZX.h new file mode 100644 index 000000000000..d443f5c1fd3d --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/variant_MARLIN_STM32H723ZX.h @@ -0,0 +1,308 @@ +/* + ******************************************************************************* + * 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 PB11 27 +#define PB12 28 +#define PB13 29 +#define PB14 30 +#define PB15 31 +#define PC0 PIN_A10 +#define PC1 PIN_A11 +#define PC4 PIN_A12 +#define PC5 PIN_A13 +#define PC6 36 +#define PC7 37 +#define PC8 38 +#define PC9 39 +#define PC10 40 +#define PC11 41 +#define PC12 42 +#define PC13 43 +#define PC14 44 +#define PC15 45 +#define PD0 46 +#define PD1 47 +#define PD2 48 +#define PD3 49 +#define PD4 50 +#define PD5 51 +#define PD6 52 +#define PD7 53 +#define PD8 54 +#define PD9 55 +#define PD10 56 +#define PD11 57 +#define PD12 58 +#define PD13 59 +#define PD14 60 +#define PD15 61 +#define PE0 62 +#define PE1 63 +#define PE2 64 +#define PE3 65 +#define PE4 66 +#define PE5 67 +#define PE6 68 +#define PE7 69 +#define PE8 70 +#define PE9 71 +#define PE10 72 +#define PE11 73 +#define PE12 74 +#define PE13 75 +#define PE14 76 +#define PE15 77 +#define PF0 78 +#define PF1 79 +#define PF2 80 +#define PF3 PIN_A14 +#define PF4 PIN_A15 +#define PF5 PIN_A16 +#define PF6 PIN_A17 +#define PF7 PIN_A18 +#define PF8 PIN_A19 +#define PF9 PIN_A20 +#define PF10 PIN_A21 +#define PF11 PIN_A22 +#define PF12 PIN_A23 +#define PF13 PIN_A24 +#define PF14 PIN_A25 +#define PF15 93 +#define PG0 94 +#define PG1 95 +#define PG2 96 +#define PG3 97 +#define PG4 98 +#define PG5 99 +#define PG6 100 +#define PG7 101 +#define PG8 102 +#define PG9 103 +#define PG10 104 +#define PG11 105 +#define PG12 106 +#define PG13 107 +#define PG14 108 +#define PG15 109 +#define PH0 110 +#define PH1 111 +#define PC2_C PIN_A26 +#define PC3_C PIN_A27 + +// Alternate pins number +#define PA0_ALT1 (PA0 | ALT1) +#define PA1_ALT1 (PA1 | ALT1) +#define PA1_ALT2 (PA1 | ALT2) +#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 PA4_ALT2 (PA4 | ALT2) +#define PA5_ALT1 (PA5 | ALT1) +#define PA6_ALT1 (PA6 | ALT1) +#define PA7_ALT1 (PA7 | ALT1) +#define PA7_ALT2 (PA7 | ALT2) +#define PA7_ALT3 (PA7 | ALT3) +#define PA8_ALT1 (PA8 | ALT1) +#define PA9_ALT1 (PA9 | ALT1) +#define PA10_ALT1 (PA10 | ALT1) +#define PA11_ALT1 (PA11 | ALT1) +#define PA12_ALT1 (PA12 | ALT1) +#define PA15_ALT1 (PA15 | ALT1) +#define PA15_ALT2 (PA15 | ALT2) +#define PB0_ALT1 (PB0 | ALT1) +#define PB0_ALT2 (PB0 | ALT2) +#define PB1_ALT1 (PB1 | ALT1) +#define PB1_ALT2 (PB1 | ALT2) +#define PB3_ALT1 (PB3 | ALT1) +#define PB3_ALT2 (PB3 | ALT2) +#define PB4_ALT1 (PB4 | ALT1) +#define PB4_ALT2 (PB4 | ALT2) +#define PB5_ALT1 (PB5 | ALT1) +#define PB5_ALT2 (PB5 | ALT2) +#define PB6_ALT1 (PB6 | ALT1) +#define PB6_ALT2 (PB6 | ALT2) +#define PB7_ALT1 (PB7 | ALT1) +#define PB8_ALT1 (PB8 | ALT1) +#define PB8_ALT2 (PB8 | ALT2) +#define PB9_ALT1 (PB9 | ALT1) +#define PB9_ALT2 (PB9 | ALT2) +#define PB14_ALT1 (PB14 | ALT1) +#define PB14_ALT2 (PB14 | ALT2) +#define PB15_ALT1 (PB15 | ALT1) +#define PB15_ALT2 (PB15 | ALT2) +#define PC0_ALT1 (PC0 | ALT1) +#define PC0_ALT2 (PC0 | ALT2) +#define PC1_ALT1 (PC1 | ALT1) +#define PC1_ALT2 (PC1 | ALT2) +#define PC4_ALT1 (PC4 | ALT1) +#define PC5_ALT1 (PC5 | ALT1) +#define PC6_ALT1 (PC6 | ALT1) +#define PC6_ALT2 (PC6 | ALT2) +#define PC7_ALT1 (PC7 | ALT1) +#define PC7_ALT2 (PC7 | ALT2) +#define PC8_ALT1 (PC8 | ALT1) +#define PC9_ALT1 (PC9 | ALT1) +#define PC10_ALT1 (PC10 | ALT1) +#define PC11_ALT1 (PC11 | ALT1) +#define PF0_ALT1 (PF0 | ALT1) +#define PF1_ALT1 (PF1 | ALT1) +#define PF6_ALT1 (PF6 | ALT1) +#define PF7_ALT1 (PF7 | ALT1) +#define PF8_ALT1 (PF8 | ALT1) +#define PF8_ALT2 (PF8 | ALT2) +#define PF9_ALT1 (PF9 | ALT1) +#define PF9_ALT2 (PF9 | ALT2) +#define PG13_ALT1 (PG13 | ALT1) + +#define NUM_DIGITAL_PINS 114 +#define NUM_DUALPAD_PINS 2 +#define NUM_ANALOG_INPUTS 28 + +// 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 PG10 +#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 PB7 +#endif +#ifndef PIN_WIRE_SCL + #define PIN_WIRE_SCL PB6 +#endif + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE + #define TIMER_TONE TIM6 +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM7 +#endif + +// UART Definitions +#ifndef SERIAL_UART_INSTANCE + #define SERIAL_UART_INSTANCE 4 +#endif + +// Default pin used for generic 'Serial' instance +// Mandatory for Firmata +#ifndef PIN_SERIAL_RX + #define PIN_SERIAL_RX PA1 +#endif +#ifndef PIN_SERIAL_TX + #define PIN_SERIAL_TX PA0 +#endif + +// Extra HAL modules +#if !defined(HAL_DAC_MODULE_DISABLED) + #define HAL_DAC_MODULE_ENABLED +#endif +#if !defined(HAL_ETH_MODULE_DISABLED) + #define HAL_ETH_MODULE_ENABLED +#endif +#if !defined(HAL_OSPI_MODULE_DISABLED) + #define HAL_OSPI_MODULE_ENABLED +#endif +#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/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/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_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_LERDGE/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_LERDGE/variant.h index e7bc7c0bc1db..e71bb1c5c8dd 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_LERDGE/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_LERDGE/variant.h @@ -218,6 +218,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MEGA_EXTENDED/pins_arduino.h b/buildroot/share/PlatformIO/variants/MARLIN_MEGA_EXTENDED/pins_arduino.h index 1129f8edae10..f6bc62d57bc9 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_MEGA_EXTENDED/pins_arduino.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_MEGA_EXTENDED/pins_arduino.h @@ -118,324 +118,324 @@ static const uint8_t A15 = PIN_A15; #ifdef ARDUINO_MAIN const uint16_t PROGMEM port_to_mode_PGM[] = { - NOT_A_PORT, - (uint16_t) &DDRA, - (uint16_t) &DDRB, - (uint16_t) &DDRC, - (uint16_t) &DDRD, - (uint16_t) &DDRE, - (uint16_t) &DDRF, - (uint16_t) &DDRG, - (uint16_t) &DDRH, - NOT_A_PORT, - (uint16_t) &DDRJ, - (uint16_t) &DDRK, - (uint16_t) &DDRL, + NOT_A_PORT, + (uint16_t) &DDRA, + (uint16_t) &DDRB, + (uint16_t) &DDRC, + (uint16_t) &DDRD, + (uint16_t) &DDRE, + (uint16_t) &DDRF, + (uint16_t) &DDRG, + (uint16_t) &DDRH, + NOT_A_PORT, + (uint16_t) &DDRJ, + (uint16_t) &DDRK, + (uint16_t) &DDRL, }; const uint16_t PROGMEM port_to_output_PGM[] = { - NOT_A_PORT, - (uint16_t) &PORTA, - (uint16_t) &PORTB, - (uint16_t) &PORTC, - (uint16_t) &PORTD, - (uint16_t) &PORTE, - (uint16_t) &PORTF, - (uint16_t) &PORTG, - (uint16_t) &PORTH, - NOT_A_PORT, - (uint16_t) &PORTJ, - (uint16_t) &PORTK, - (uint16_t) &PORTL, + NOT_A_PORT, + (uint16_t) &PORTA, + (uint16_t) &PORTB, + (uint16_t) &PORTC, + (uint16_t) &PORTD, + (uint16_t) &PORTE, + (uint16_t) &PORTF, + (uint16_t) &PORTG, + (uint16_t) &PORTH, + NOT_A_PORT, + (uint16_t) &PORTJ, + (uint16_t) &PORTK, + (uint16_t) &PORTL, }; const uint16_t PROGMEM port_to_input_PGM[] = { - NOT_A_PIN, - (uint16_t) &PINA, - (uint16_t) &PINB, - (uint16_t) &PINC, - (uint16_t) &PIND, - (uint16_t) &PINE, - (uint16_t) &PINF, - (uint16_t) &PING, - (uint16_t) &PINH, - NOT_A_PIN, - (uint16_t) &PINJ, - (uint16_t) &PINK, - (uint16_t) &PINL, + NOT_A_PIN, + (uint16_t) &PINA, + (uint16_t) &PINB, + (uint16_t) &PINC, + (uint16_t) &PIND, + (uint16_t) &PINE, + (uint16_t) &PINF, + (uint16_t) &PING, + (uint16_t) &PINH, + NOT_A_PIN, + (uint16_t) &PINJ, + (uint16_t) &PINK, + (uint16_t) &PINL, }; const uint8_t PROGMEM digital_pin_to_port_PGM[] = { - // PORTLIST - // ------------------------------------------- - PE , // PE 0 ** 0 ** USART0_RX - PE , // PE 1 ** 1 ** USART0_TX - PE , // PE 4 ** 2 ** PWM2 - PE , // PE 5 ** 3 ** PWM3 - PG , // PG 5 ** 4 ** PWM4 - PE , // PE 3 ** 5 ** PWM5 - PH , // PH 3 ** 6 ** PWM6 - PH , // PH 4 ** 7 ** PWM7 - PH , // PH 5 ** 8 ** PWM8 - PH , // PH 6 ** 9 ** PWM9 - PB , // PB 4 ** 10 ** PWM10 - PB , // PB 5 ** 11 ** PWM11 - PB , // PB 6 ** 12 ** PWM12 - PB , // PB 7 ** 13 ** PWM13 - PJ , // PJ 1 ** 14 ** USART3_TX - PJ , // PJ 0 ** 15 ** USART3_RX - PH , // PH 1 ** 16 ** USART2_TX - PH , // PH 0 ** 17 ** USART2_RX - PD , // PD 3 ** 18 ** USART1_TX - PD , // PD 2 ** 19 ** USART1_RX - PD , // PD 1 ** 20 ** I2C_SDA - PD , // PD 0 ** 21 ** I2C_SCL - PA , // PA 0 ** 22 ** D22 - PA , // PA 1 ** 23 ** D23 - PA , // PA 2 ** 24 ** D24 - PA , // PA 3 ** 25 ** D25 - PA , // PA 4 ** 26 ** D26 - PA , // PA 5 ** 27 ** D27 - PA , // PA 6 ** 28 ** D28 - PA , // PA 7 ** 29 ** D29 - PC , // PC 7 ** 30 ** D30 - PC , // PC 6 ** 31 ** D31 - PC , // PC 5 ** 32 ** D32 - PC , // PC 4 ** 33 ** D33 - PC , // PC 3 ** 34 ** D34 - PC , // PC 2 ** 35 ** D35 - PC , // PC 1 ** 36 ** D36 - PC , // PC 0 ** 37 ** D37 - PD , // PD 7 ** 38 ** D38 - PG , // PG 2 ** 39 ** D39 - PG , // PG 1 ** 40 ** D40 - PG , // PG 0 ** 41 ** D41 - PL , // PL 7 ** 42 ** D42 - PL , // PL 6 ** 43 ** D43 - PL , // PL 5 ** 44 ** D44 - PL , // PL 4 ** 45 ** D45 - PL , // PL 3 ** 46 ** D46 - PL , // PL 2 ** 47 ** D47 - PL , // PL 1 ** 48 ** D48 - PL , // PL 0 ** 49 ** D49 - PB , // PB 3 ** 50 ** SPI_MISO - PB , // PB 2 ** 51 ** SPI_MOSI - PB , // PB 1 ** 52 ** SPI_SCK - PB , // PB 0 ** 53 ** SPI_SS - PF , // PF 0 ** 54 ** A0 - PF , // PF 1 ** 55 ** A1 - PF , // PF 2 ** 56 ** A2 - PF , // PF 3 ** 57 ** A3 - PF , // PF 4 ** 58 ** A4 - PF , // PF 5 ** 59 ** A5 - PF , // PF 6 ** 60 ** A6 - PF , // PF 7 ** 61 ** A7 - PK , // PK 0 ** 62 ** A8 - PK , // PK 1 ** 63 ** A9 - PK , // PK 2 ** 64 ** A10 - PK , // PK 3 ** 65 ** A11 - PK , // PK 4 ** 66 ** A12 - PK , // PK 5 ** 67 ** A13 - PK , // PK 6 ** 68 ** A14 - PK , // PK 7 ** 69 ** A15 - PG , // PG 4 ** 70 ** D70 - PG , // PG 3 ** 71 ** D71 - PJ , // PJ 2 ** 72 ** D72 - PJ , // PJ 3 ** 73 ** D73 - PJ , // PJ 7 ** 74 ** D74 - PJ , // PJ 4 ** 75 ** D75 - PJ , // PJ 5 ** 76 ** D76 - PJ , // PJ 6 ** 77 ** D77 - PE , // PE 2 ** 78 ** D78 - PE , // PE 6 ** 79 ** D79 - PE , // PE 7 ** 80 ** D80 - PD , // PD 4 ** 81 ** D81 - PD , // PD 5 ** 82 ** D82 - PD , // PD 6 ** 83 ** D83 - PH , // PH 2 ** 84 ** D84 - PH , // PH 7 ** 85 ** D85 + // PORTLIST + // ------------------------------------------- + PE , // PE 0 ** 0 ** USART0_RX + PE , // PE 1 ** 1 ** USART0_TX + PE , // PE 4 ** 2 ** PWM2 + PE , // PE 5 ** 3 ** PWM3 + PG , // PG 5 ** 4 ** PWM4 + PE , // PE 3 ** 5 ** PWM5 + PH , // PH 3 ** 6 ** PWM6 + PH , // PH 4 ** 7 ** PWM7 + PH , // PH 5 ** 8 ** PWM8 + PH , // PH 6 ** 9 ** PWM9 + PB , // PB 4 ** 10 ** PWM10 + PB , // PB 5 ** 11 ** PWM11 + PB , // PB 6 ** 12 ** PWM12 + PB , // PB 7 ** 13 ** PWM13 + PJ , // PJ 1 ** 14 ** USART3_TX + PJ , // PJ 0 ** 15 ** USART3_RX + PH , // PH 1 ** 16 ** USART2_TX + PH , // PH 0 ** 17 ** USART2_RX + PD , // PD 3 ** 18 ** USART1_TX + PD , // PD 2 ** 19 ** USART1_RX + PD , // PD 1 ** 20 ** I2C_SDA + PD , // PD 0 ** 21 ** I2C_SCL + PA , // PA 0 ** 22 ** D22 + PA , // PA 1 ** 23 ** D23 + PA , // PA 2 ** 24 ** D24 + PA , // PA 3 ** 25 ** D25 + PA , // PA 4 ** 26 ** D26 + PA , // PA 5 ** 27 ** D27 + PA , // PA 6 ** 28 ** D28 + PA , // PA 7 ** 29 ** D29 + PC , // PC 7 ** 30 ** D30 + PC , // PC 6 ** 31 ** D31 + PC , // PC 5 ** 32 ** D32 + PC , // PC 4 ** 33 ** D33 + PC , // PC 3 ** 34 ** D34 + PC , // PC 2 ** 35 ** D35 + PC , // PC 1 ** 36 ** D36 + PC , // PC 0 ** 37 ** D37 + PD , // PD 7 ** 38 ** D38 + PG , // PG 2 ** 39 ** D39 + PG , // PG 1 ** 40 ** D40 + PG , // PG 0 ** 41 ** D41 + PL , // PL 7 ** 42 ** D42 + PL , // PL 6 ** 43 ** D43 + PL , // PL 5 ** 44 ** D44 + PL , // PL 4 ** 45 ** D45 + PL , // PL 3 ** 46 ** D46 + PL , // PL 2 ** 47 ** D47 + PL , // PL 1 ** 48 ** D48 + PL , // PL 0 ** 49 ** D49 + PB , // PB 3 ** 50 ** SPI_MISO + PB , // PB 2 ** 51 ** SPI_MOSI + PB , // PB 1 ** 52 ** SPI_SCK + PB , // PB 0 ** 53 ** SPI_SS + PF , // PF 0 ** 54 ** A0 + PF , // PF 1 ** 55 ** A1 + PF , // PF 2 ** 56 ** A2 + PF , // PF 3 ** 57 ** A3 + PF , // PF 4 ** 58 ** A4 + PF , // PF 5 ** 59 ** A5 + PF , // PF 6 ** 60 ** A6 + PF , // PF 7 ** 61 ** A7 + PK , // PK 0 ** 62 ** A8 + PK , // PK 1 ** 63 ** A9 + PK , // PK 2 ** 64 ** A10 + PK , // PK 3 ** 65 ** A11 + PK , // PK 4 ** 66 ** A12 + PK , // PK 5 ** 67 ** A13 + PK , // PK 6 ** 68 ** A14 + PK , // PK 7 ** 69 ** A15 + PG , // PG 4 ** 70 ** D70 + PG , // PG 3 ** 71 ** D71 + PJ , // PJ 2 ** 72 ** D72 + PJ , // PJ 3 ** 73 ** D73 + PJ , // PJ 7 ** 74 ** D74 + PJ , // PJ 4 ** 75 ** D75 + PJ , // PJ 5 ** 76 ** D76 + PJ , // PJ 6 ** 77 ** D77 + PE , // PE 2 ** 78 ** D78 + PE , // PE 6 ** 79 ** D79 + PE , // PE 7 ** 80 ** D80 + PD , // PD 4 ** 81 ** D81 + PD , // PD 5 ** 82 ** D82 + PD , // PD 6 ** 83 ** D83 + PH , // PH 2 ** 84 ** D84 + PH , // PH 7 ** 85 ** D85 }; const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = { - // PIN IN PORT - // ------------------------------------------- - _BV( 0 ) , // PE 0 ** 0 ** USART0_RX - _BV( 1 ) , // PE 1 ** 1 ** USART0_TX - _BV( 4 ) , // PE 4 ** 2 ** PWM2 - _BV( 5 ) , // PE 5 ** 3 ** PWM3 - _BV( 5 ) , // PG 5 ** 4 ** PWM4 - _BV( 3 ) , // PE 3 ** 5 ** PWM5 - _BV( 3 ) , // PH 3 ** 6 ** PWM6 - _BV( 4 ) , // PH 4 ** 7 ** PWM7 - _BV( 5 ) , // PH 5 ** 8 ** PWM8 - _BV( 6 ) , // PH 6 ** 9 ** PWM9 - _BV( 4 ) , // PB 4 ** 10 ** PWM10 - _BV( 5 ) , // PB 5 ** 11 ** PWM11 - _BV( 6 ) , // PB 6 ** 12 ** PWM12 - _BV( 7 ) , // PB 7 ** 13 ** PWM13 - _BV( 1 ) , // PJ 1 ** 14 ** USART3_TX - _BV( 0 ) , // PJ 0 ** 15 ** USART3_RX - _BV( 1 ) , // PH 1 ** 16 ** USART2_TX - _BV( 0 ) , // PH 0 ** 17 ** USART2_RX - _BV( 3 ) , // PD 3 ** 18 ** USART1_TX - _BV( 2 ) , // PD 2 ** 19 ** USART1_RX - _BV( 1 ) , // PD 1 ** 20 ** I2C_SDA - _BV( 0 ) , // PD 0 ** 21 ** I2C_SCL - _BV( 0 ) , // PA 0 ** 22 ** D22 - _BV( 1 ) , // PA 1 ** 23 ** D23 - _BV( 2 ) , // PA 2 ** 24 ** D24 - _BV( 3 ) , // PA 3 ** 25 ** D25 - _BV( 4 ) , // PA 4 ** 26 ** D26 - _BV( 5 ) , // PA 5 ** 27 ** D27 - _BV( 6 ) , // PA 6 ** 28 ** D28 - _BV( 7 ) , // PA 7 ** 29 ** D29 - _BV( 7 ) , // PC 7 ** 30 ** D30 - _BV( 6 ) , // PC 6 ** 31 ** D31 - _BV( 5 ) , // PC 5 ** 32 ** D32 - _BV( 4 ) , // PC 4 ** 33 ** D33 - _BV( 3 ) , // PC 3 ** 34 ** D34 - _BV( 2 ) , // PC 2 ** 35 ** D35 - _BV( 1 ) , // PC 1 ** 36 ** D36 - _BV( 0 ) , // PC 0 ** 37 ** D37 - _BV( 7 ) , // PD 7 ** 38 ** D38 - _BV( 2 ) , // PG 2 ** 39 ** D39 - _BV( 1 ) , // PG 1 ** 40 ** D40 - _BV( 0 ) , // PG 0 ** 41 ** D41 - _BV( 7 ) , // PL 7 ** 42 ** D42 - _BV( 6 ) , // PL 6 ** 43 ** D43 - _BV( 5 ) , // PL 5 ** 44 ** D44 - _BV( 4 ) , // PL 4 ** 45 ** D45 - _BV( 3 ) , // PL 3 ** 46 ** D46 - _BV( 2 ) , // PL 2 ** 47 ** D47 - _BV( 1 ) , // PL 1 ** 48 ** D48 - _BV( 0 ) , // PL 0 ** 49 ** D49 - _BV( 3 ) , // PB 3 ** 50 ** SPI_MISO - _BV( 2 ) , // PB 2 ** 51 ** SPI_MOSI - _BV( 1 ) , // PB 1 ** 52 ** SPI_SCK - _BV( 0 ) , // PB 0 ** 53 ** SPI_SS - _BV( 0 ) , // PF 0 ** 54 ** A0 - _BV( 1 ) , // PF 1 ** 55 ** A1 - _BV( 2 ) , // PF 2 ** 56 ** A2 - _BV( 3 ) , // PF 3 ** 57 ** A3 - _BV( 4 ) , // PF 4 ** 58 ** A4 - _BV( 5 ) , // PF 5 ** 59 ** A5 - _BV( 6 ) , // PF 6 ** 60 ** A6 - _BV( 7 ) , // PF 7 ** 61 ** A7 - _BV( 0 ) , // PK 0 ** 62 ** A8 - _BV( 1 ) , // PK 1 ** 63 ** A9 - _BV( 2 ) , // PK 2 ** 64 ** A10 - _BV( 3 ) , // PK 3 ** 65 ** A11 - _BV( 4 ) , // PK 4 ** 66 ** A12 - _BV( 5 ) , // PK 5 ** 67 ** A13 - _BV( 6 ) , // PK 6 ** 68 ** A14 - _BV( 7 ) , // PK 7 ** 69 ** A15 - _BV( 4 ) , // PG 4 ** 70 ** D70 - _BV( 3 ) , // PG 3 ** 71 ** D71 - _BV( 2 ) , // PJ 2 ** 72 ** D72 - _BV( 3 ) , // PJ 3 ** 73 ** D73 - _BV( 7 ) , // PJ 7 ** 74 ** D74 - _BV( 4 ) , // PJ 4 ** 75 ** D75 - _BV( 5 ) , // PJ 5 ** 76 ** D76 - _BV( 6 ) , // PJ 6 ** 77 ** D77 - _BV( 2 ) , // PE 2 ** 78 ** D78 - _BV( 6 ) , // PE 6 ** 79 ** D79 - _BV( 7 ) , // PE 7 ** 80 ** D80 - _BV( 4 ) , // PD 4 ** 81 ** D81 - _BV( 5 ) , // PD 5 ** 82 ** D82 - _BV( 6 ) , // PD 6 ** 83 ** D83 - _BV( 2 ) , // PH 2 ** 84 ** D84 - _BV( 7 ) , // PH 7 ** 85 ** D85 + // PIN IN PORT + // ------------------------------------------- + _BV( 0 ) , // PE 0 ** 0 ** USART0_RX + _BV( 1 ) , // PE 1 ** 1 ** USART0_TX + _BV( 4 ) , // PE 4 ** 2 ** PWM2 + _BV( 5 ) , // PE 5 ** 3 ** PWM3 + _BV( 5 ) , // PG 5 ** 4 ** PWM4 + _BV( 3 ) , // PE 3 ** 5 ** PWM5 + _BV( 3 ) , // PH 3 ** 6 ** PWM6 + _BV( 4 ) , // PH 4 ** 7 ** PWM7 + _BV( 5 ) , // PH 5 ** 8 ** PWM8 + _BV( 6 ) , // PH 6 ** 9 ** PWM9 + _BV( 4 ) , // PB 4 ** 10 ** PWM10 + _BV( 5 ) , // PB 5 ** 11 ** PWM11 + _BV( 6 ) , // PB 6 ** 12 ** PWM12 + _BV( 7 ) , // PB 7 ** 13 ** PWM13 + _BV( 1 ) , // PJ 1 ** 14 ** USART3_TX + _BV( 0 ) , // PJ 0 ** 15 ** USART3_RX + _BV( 1 ) , // PH 1 ** 16 ** USART2_TX + _BV( 0 ) , // PH 0 ** 17 ** USART2_RX + _BV( 3 ) , // PD 3 ** 18 ** USART1_TX + _BV( 2 ) , // PD 2 ** 19 ** USART1_RX + _BV( 1 ) , // PD 1 ** 20 ** I2C_SDA + _BV( 0 ) , // PD 0 ** 21 ** I2C_SCL + _BV( 0 ) , // PA 0 ** 22 ** D22 + _BV( 1 ) , // PA 1 ** 23 ** D23 + _BV( 2 ) , // PA 2 ** 24 ** D24 + _BV( 3 ) , // PA 3 ** 25 ** D25 + _BV( 4 ) , // PA 4 ** 26 ** D26 + _BV( 5 ) , // PA 5 ** 27 ** D27 + _BV( 6 ) , // PA 6 ** 28 ** D28 + _BV( 7 ) , // PA 7 ** 29 ** D29 + _BV( 7 ) , // PC 7 ** 30 ** D30 + _BV( 6 ) , // PC 6 ** 31 ** D31 + _BV( 5 ) , // PC 5 ** 32 ** D32 + _BV( 4 ) , // PC 4 ** 33 ** D33 + _BV( 3 ) , // PC 3 ** 34 ** D34 + _BV( 2 ) , // PC 2 ** 35 ** D35 + _BV( 1 ) , // PC 1 ** 36 ** D36 + _BV( 0 ) , // PC 0 ** 37 ** D37 + _BV( 7 ) , // PD 7 ** 38 ** D38 + _BV( 2 ) , // PG 2 ** 39 ** D39 + _BV( 1 ) , // PG 1 ** 40 ** D40 + _BV( 0 ) , // PG 0 ** 41 ** D41 + _BV( 7 ) , // PL 7 ** 42 ** D42 + _BV( 6 ) , // PL 6 ** 43 ** D43 + _BV( 5 ) , // PL 5 ** 44 ** D44 + _BV( 4 ) , // PL 4 ** 45 ** D45 + _BV( 3 ) , // PL 3 ** 46 ** D46 + _BV( 2 ) , // PL 2 ** 47 ** D47 + _BV( 1 ) , // PL 1 ** 48 ** D48 + _BV( 0 ) , // PL 0 ** 49 ** D49 + _BV( 3 ) , // PB 3 ** 50 ** SPI_MISO + _BV( 2 ) , // PB 2 ** 51 ** SPI_MOSI + _BV( 1 ) , // PB 1 ** 52 ** SPI_SCK + _BV( 0 ) , // PB 0 ** 53 ** SPI_SS + _BV( 0 ) , // PF 0 ** 54 ** A0 + _BV( 1 ) , // PF 1 ** 55 ** A1 + _BV( 2 ) , // PF 2 ** 56 ** A2 + _BV( 3 ) , // PF 3 ** 57 ** A3 + _BV( 4 ) , // PF 4 ** 58 ** A4 + _BV( 5 ) , // PF 5 ** 59 ** A5 + _BV( 6 ) , // PF 6 ** 60 ** A6 + _BV( 7 ) , // PF 7 ** 61 ** A7 + _BV( 0 ) , // PK 0 ** 62 ** A8 + _BV( 1 ) , // PK 1 ** 63 ** A9 + _BV( 2 ) , // PK 2 ** 64 ** A10 + _BV( 3 ) , // PK 3 ** 65 ** A11 + _BV( 4 ) , // PK 4 ** 66 ** A12 + _BV( 5 ) , // PK 5 ** 67 ** A13 + _BV( 6 ) , // PK 6 ** 68 ** A14 + _BV( 7 ) , // PK 7 ** 69 ** A15 + _BV( 4 ) , // PG 4 ** 70 ** D70 + _BV( 3 ) , // PG 3 ** 71 ** D71 + _BV( 2 ) , // PJ 2 ** 72 ** D72 + _BV( 3 ) , // PJ 3 ** 73 ** D73 + _BV( 7 ) , // PJ 7 ** 74 ** D74 + _BV( 4 ) , // PJ 4 ** 75 ** D75 + _BV( 5 ) , // PJ 5 ** 76 ** D76 + _BV( 6 ) , // PJ 6 ** 77 ** D77 + _BV( 2 ) , // PE 2 ** 78 ** D78 + _BV( 6 ) , // PE 6 ** 79 ** D79 + _BV( 7 ) , // PE 7 ** 80 ** D80 + _BV( 4 ) , // PD 4 ** 81 ** D81 + _BV( 5 ) , // PD 5 ** 82 ** D82 + _BV( 6 ) , // PD 6 ** 83 ** D83 + _BV( 2 ) , // PH 2 ** 84 ** D84 + _BV( 7 ) , // PH 7 ** 85 ** D85 }; const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { - // TIMERS - // ------------------------------------------- - NOT_ON_TIMER , // PE 0 ** 0 ** USART0_RX - NOT_ON_TIMER , // PE 1 ** 1 ** USART0_TX - TIMER3B , // PE 4 ** 2 ** PWM2 - TIMER3C , // PE 5 ** 3 ** PWM3 - TIMER0B , // PG 5 ** 4 ** PWM4 - TIMER3A , // PE 3 ** 5 ** PWM5 - TIMER4A , // PH 3 ** 6 ** PWM6 - TIMER4B , // PH 4 ** 7 ** PWM7 - TIMER4C , // PH 5 ** 8 ** PWM8 - TIMER2B , // PH 6 ** 9 ** PWM9 - TIMER2A , // PB 4 ** 10 ** PWM10 - TIMER1A , // PB 5 ** 11 ** PWM11 - TIMER1B , // PB 6 ** 12 ** PWM12 - TIMER0A , // PB 7 ** 13 ** PWM13 - NOT_ON_TIMER , // PJ 1 ** 14 ** USART3_TX - NOT_ON_TIMER , // PJ 0 ** 15 ** USART3_RX - NOT_ON_TIMER , // PH 1 ** 16 ** USART2_TX - NOT_ON_TIMER , // PH 0 ** 17 ** USART2_RX - NOT_ON_TIMER , // PD 3 ** 18 ** USART1_TX - NOT_ON_TIMER , // PD 2 ** 19 ** USART1_RX - NOT_ON_TIMER , // PD 1 ** 20 ** I2C_SDA - NOT_ON_TIMER , // PD 0 ** 21 ** I2C_SCL - NOT_ON_TIMER , // PA 0 ** 22 ** D22 - NOT_ON_TIMER , // PA 1 ** 23 ** D23 - NOT_ON_TIMER , // PA 2 ** 24 ** D24 - NOT_ON_TIMER , // PA 3 ** 25 ** D25 - NOT_ON_TIMER , // PA 4 ** 26 ** D26 - NOT_ON_TIMER , // PA 5 ** 27 ** D27 - NOT_ON_TIMER , // PA 6 ** 28 ** D28 - NOT_ON_TIMER , // PA 7 ** 29 ** D29 - NOT_ON_TIMER , // PC 7 ** 30 ** D30 - NOT_ON_TIMER , // PC 6 ** 31 ** D31 - NOT_ON_TIMER , // PC 5 ** 32 ** D32 - NOT_ON_TIMER , // PC 4 ** 33 ** D33 - NOT_ON_TIMER , // PC 3 ** 34 ** D34 - NOT_ON_TIMER , // PC 2 ** 35 ** D35 - NOT_ON_TIMER , // PC 1 ** 36 ** D36 - NOT_ON_TIMER , // PC 0 ** 37 ** D37 - NOT_ON_TIMER , // PD 7 ** 38 ** D38 - NOT_ON_TIMER , // PG 2 ** 39 ** D39 - NOT_ON_TIMER , // PG 1 ** 40 ** D40 - NOT_ON_TIMER , // PG 0 ** 41 ** D41 - NOT_ON_TIMER , // PL 7 ** 42 ** D42 - NOT_ON_TIMER , // PL 6 ** 43 ** D43 - TIMER5C , // PL 5 ** 44 ** D44 - TIMER5B , // PL 4 ** 45 ** D45 - TIMER5A , // PL 3 ** 46 ** D46 - NOT_ON_TIMER , // PL 2 ** 47 ** D47 - NOT_ON_TIMER , // PL 1 ** 48 ** D48 - NOT_ON_TIMER , // PL 0 ** 49 ** D49 - NOT_ON_TIMER , // PB 3 ** 50 ** SPI_MISO - NOT_ON_TIMER , // PB 2 ** 51 ** SPI_MOSI - NOT_ON_TIMER , // PB 1 ** 52 ** SPI_SCK - NOT_ON_TIMER , // PB 0 ** 53 ** SPI_SS - NOT_ON_TIMER , // PF 0 ** 54 ** A0 - NOT_ON_TIMER , // PF 1 ** 55 ** A1 - NOT_ON_TIMER , // PF 2 ** 56 ** A2 - NOT_ON_TIMER , // PF 3 ** 57 ** A3 - NOT_ON_TIMER , // PF 4 ** 58 ** A4 - NOT_ON_TIMER , // PF 5 ** 59 ** A5 - NOT_ON_TIMER , // PF 6 ** 60 ** A6 - NOT_ON_TIMER , // PF 7 ** 61 ** A7 - NOT_ON_TIMER , // PK 0 ** 62 ** A8 - NOT_ON_TIMER , // PK 1 ** 63 ** A9 - NOT_ON_TIMER , // PK 2 ** 64 ** A10 - NOT_ON_TIMER , // PK 3 ** 65 ** A11 - NOT_ON_TIMER , // PK 4 ** 66 ** A12 - NOT_ON_TIMER , // PK 5 ** 67 ** A13 - NOT_ON_TIMER , // PK 6 ** 68 ** A14 - NOT_ON_TIMER , // PK 7 ** 69 ** A15 - NOT_ON_TIMER , // PG 4 ** 70 ** D70 - NOT_ON_TIMER , // PG 3 ** 71 ** D71 - NOT_ON_TIMER , // PJ 2 ** 72 ** D72 - NOT_ON_TIMER , // PJ 3 ** 73 ** D73 - NOT_ON_TIMER , // PJ 7 ** 74 ** D74 - NOT_ON_TIMER , // PJ 4 ** 75 ** D75 - NOT_ON_TIMER , // PJ 5 ** 76 ** D76 - NOT_ON_TIMER , // PJ 6 ** 77 ** D77 - NOT_ON_TIMER , // PE 2 ** 78 ** D78 - NOT_ON_TIMER , // PE 6 ** 79 ** D79 - NOT_ON_TIMER , // PE 7 ** 80 ** D80 - NOT_ON_TIMER , // PD 4 ** 81 ** D81 - NOT_ON_TIMER , // PD 5 ** 82 ** D82 - NOT_ON_TIMER , // PD 6 ** 83 ** D83 - NOT_ON_TIMER , // PH 2 ** 84 ** D84 - NOT_ON_TIMER , // PH 7 ** 85 ** D85 + // TIMERS + // ------------------------------------------- + NOT_ON_TIMER , // PE 0 ** 0 ** USART0_RX + NOT_ON_TIMER , // PE 1 ** 1 ** USART0_TX + TIMER3B , // PE 4 ** 2 ** PWM2 + TIMER3C , // PE 5 ** 3 ** PWM3 + TIMER0B , // PG 5 ** 4 ** PWM4 + TIMER3A , // PE 3 ** 5 ** PWM5 + TIMER4A , // PH 3 ** 6 ** PWM6 + TIMER4B , // PH 4 ** 7 ** PWM7 + TIMER4C , // PH 5 ** 8 ** PWM8 + TIMER2B , // PH 6 ** 9 ** PWM9 + TIMER2A , // PB 4 ** 10 ** PWM10 + TIMER1A , // PB 5 ** 11 ** PWM11 + TIMER1B , // PB 6 ** 12 ** PWM12 + TIMER0A , // PB 7 ** 13 ** PWM13 + NOT_ON_TIMER , // PJ 1 ** 14 ** USART3_TX + NOT_ON_TIMER , // PJ 0 ** 15 ** USART3_RX + NOT_ON_TIMER , // PH 1 ** 16 ** USART2_TX + NOT_ON_TIMER , // PH 0 ** 17 ** USART2_RX + NOT_ON_TIMER , // PD 3 ** 18 ** USART1_TX + NOT_ON_TIMER , // PD 2 ** 19 ** USART1_RX + NOT_ON_TIMER , // PD 1 ** 20 ** I2C_SDA + NOT_ON_TIMER , // PD 0 ** 21 ** I2C_SCL + NOT_ON_TIMER , // PA 0 ** 22 ** D22 + NOT_ON_TIMER , // PA 1 ** 23 ** D23 + NOT_ON_TIMER , // PA 2 ** 24 ** D24 + NOT_ON_TIMER , // PA 3 ** 25 ** D25 + NOT_ON_TIMER , // PA 4 ** 26 ** D26 + NOT_ON_TIMER , // PA 5 ** 27 ** D27 + NOT_ON_TIMER , // PA 6 ** 28 ** D28 + NOT_ON_TIMER , // PA 7 ** 29 ** D29 + NOT_ON_TIMER , // PC 7 ** 30 ** D30 + NOT_ON_TIMER , // PC 6 ** 31 ** D31 + NOT_ON_TIMER , // PC 5 ** 32 ** D32 + NOT_ON_TIMER , // PC 4 ** 33 ** D33 + NOT_ON_TIMER , // PC 3 ** 34 ** D34 + NOT_ON_TIMER , // PC 2 ** 35 ** D35 + NOT_ON_TIMER , // PC 1 ** 36 ** D36 + NOT_ON_TIMER , // PC 0 ** 37 ** D37 + NOT_ON_TIMER , // PD 7 ** 38 ** D38 + NOT_ON_TIMER , // PG 2 ** 39 ** D39 + NOT_ON_TIMER , // PG 1 ** 40 ** D40 + NOT_ON_TIMER , // PG 0 ** 41 ** D41 + NOT_ON_TIMER , // PL 7 ** 42 ** D42 + NOT_ON_TIMER , // PL 6 ** 43 ** D43 + TIMER5C , // PL 5 ** 44 ** D44 + TIMER5B , // PL 4 ** 45 ** D45 + TIMER5A , // PL 3 ** 46 ** D46 + NOT_ON_TIMER , // PL 2 ** 47 ** D47 + NOT_ON_TIMER , // PL 1 ** 48 ** D48 + NOT_ON_TIMER , // PL 0 ** 49 ** D49 + NOT_ON_TIMER , // PB 3 ** 50 ** SPI_MISO + NOT_ON_TIMER , // PB 2 ** 51 ** SPI_MOSI + NOT_ON_TIMER , // PB 1 ** 52 ** SPI_SCK + NOT_ON_TIMER , // PB 0 ** 53 ** SPI_SS + NOT_ON_TIMER , // PF 0 ** 54 ** A0 + NOT_ON_TIMER , // PF 1 ** 55 ** A1 + NOT_ON_TIMER , // PF 2 ** 56 ** A2 + NOT_ON_TIMER , // PF 3 ** 57 ** A3 + NOT_ON_TIMER , // PF 4 ** 58 ** A4 + NOT_ON_TIMER , // PF 5 ** 59 ** A5 + NOT_ON_TIMER , // PF 6 ** 60 ** A6 + NOT_ON_TIMER , // PF 7 ** 61 ** A7 + NOT_ON_TIMER , // PK 0 ** 62 ** A8 + NOT_ON_TIMER , // PK 1 ** 63 ** A9 + NOT_ON_TIMER , // PK 2 ** 64 ** A10 + NOT_ON_TIMER , // PK 3 ** 65 ** A11 + NOT_ON_TIMER , // PK 4 ** 66 ** A12 + NOT_ON_TIMER , // PK 5 ** 67 ** A13 + NOT_ON_TIMER , // PK 6 ** 68 ** A14 + NOT_ON_TIMER , // PK 7 ** 69 ** A15 + NOT_ON_TIMER , // PG 4 ** 70 ** D70 + NOT_ON_TIMER , // PG 3 ** 71 ** D71 + NOT_ON_TIMER , // PJ 2 ** 72 ** D72 + NOT_ON_TIMER , // PJ 3 ** 73 ** D73 + NOT_ON_TIMER , // PJ 7 ** 74 ** D74 + NOT_ON_TIMER , // PJ 4 ** 75 ** D75 + NOT_ON_TIMER , // PJ 5 ** 76 ** D76 + NOT_ON_TIMER , // PJ 6 ** 77 ** D77 + NOT_ON_TIMER , // PE 2 ** 78 ** D78 + NOT_ON_TIMER , // PE 6 ** 79 ** D79 + NOT_ON_TIMER , // PE 7 ** 80 ** D80 + NOT_ON_TIMER , // PD 4 ** 81 ** D81 + NOT_ON_TIMER , // PD 5 ** 82 ** D82 + NOT_ON_TIMER , // PD 6 ** 83 ** D83 + NOT_ON_TIMER , // PH 2 ** 84 ** D84 + NOT_ON_TIMER , // PH 7 ** 85 ** D85 }; #endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_ROBIN2/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_MKS_ROBIN2/PeripheralPins.c new file mode 100644 index 000000000000..63763e9db7bd --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_ROBIN2/PeripheralPins.c @@ -0,0 +1,437 @@ +/* + ******************************************************************************* + * 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 "Arduino.h" +#include "PeripheralPins.h" + +/* ===== + * Note: Commented lines are alternative possibilities which are not used by default. + * If you change them, you should know what you're doing first. + * ===== + */ + +//*** 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 + + #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio, 24 ADC + {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 + #endif + {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 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +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)}, + #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio + {PF_0, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + #endif + {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)}, + #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio + {PF_1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + #endif + {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 + //{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 + //{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 + //{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_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, 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 + //{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 + {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {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 + {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 + {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 + #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio + {PF_6, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + {PF_7, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + {PF_8, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + {PF_9, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 + #endif + {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)}, + {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)}, + #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio + {PG_14, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + #endif + {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)}, + {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)}, + #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio + {PG_9, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + #endif + {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)}, + {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)}, + #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio + {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)}, + #endif + {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_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)}, + #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio + {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)}, + #endif + {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_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} +}; +#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)}, + {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} +}; +#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_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)}, + {PD_0, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + {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)}, + {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 +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 + #if STM32F4X_PIN_NUM >= 144 //144 pins mcu, 114 gpio + {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 + #endif + {NC, NP, 0} +}; +#endif + +//*** No QUADSPI *** + +//*** 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, 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 + +#ifdef HAL_PCD_MODULE_ENABLED +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_MKS_ROBIN2/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_MKS_ROBIN2/PinNamesVar.h new file mode 100644 index 000000000000..24248859373b --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_ROBIN2/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_MKS_ROBIN2/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_MKS_ROBIN2/hal_conf_custom.h new file mode 100644 index 000000000000..3640bd1616a5 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_ROBIN2/hal_conf_custom.h @@ -0,0 +1,481 @@ +/** + ****************************************************************************** + * @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 +/* #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 +//#define HAL_PCD_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). + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) +#define HSE_STARTUP_TIMEOUT ((uint32_t)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). + */ +#if !defined (HSI_VALUE) +#define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) +#define LSI_VALUE ((uint32_t)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. + */ +#if !defined (LSE_VALUE) +#define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined (LSE_STARTUP_TIMEOUT) +#define LSE_STARTUP_TIMEOUT ((uint32_t)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. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) +#define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency 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 ((uint32_t)3300U) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< 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 ((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 ((uint32_t)0x000000FFU) +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU) + +#define PHY_READ_TO ((uint32_t)0x0000FFFFU) +#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU) + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< 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 +*/ + +#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****/ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_ROBIN2/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_MKS_ROBIN2/ldscript.ld new file mode 100644 index 000000000000..e83d35496a80 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_ROBIN2/ldscript.ld @@ -0,0 +1,206 @@ +/* +***************************************************************************** +** + +** 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 = 0x800C000, LENGTH = 512K-48K +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 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); + 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_MKS_ROBIN2/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_MKS_ROBIN2/variant.cpp new file mode 100644 index 000000000000..cfc7f0affd66 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_ROBIN2/variant.cpp @@ -0,0 +1,228 @@ +/* + ******************************************************************************* + * 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 "variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#include "pins_arduino.h" + + +// Pin number +// This array allows to wrap Arduino pin number(Dx or x) +// to STM32 PinName (PX_n) +const PinName digitalPin[] = { + PC_13, //D0 + PC_14, //D1 - OSC32_IN + PC_15, //D2 - OSC32_OUT + PH_0, //D3 - OSC_IN + PH_1, //D4 - OSC_OUT + PB_2, //D21 - BOOT1 + PB_10, //D22 - 1:SPI2_SCK / I2C2_SCL / USART3_TX / TIM2_CH3 + PB_11, //D23 - 1:I2C2_SDA / USART3_RX / TIM2_CH4 + PB_12, //D24 - 1:SPI2_NSS / OTG_HS_ID + PB_13, //D25 - 1:SPI2_SCK 2:OTG_HS_VBUS + PB_14, //D26 - 1:SPI2_MISO / TIM12_CH1 / OTG_HS_DM + PB_15, //D27 - SPI2_MOSI / TIM12_CH2 / OTG_HS_DP + PC_6, //D28 - 1:TIM8_CH1 / SDIO_D6 / USART6_TX / TIM3_CH1 + PC_7, //D29 - 1:TIM8_CH2 / SDIO_D7 / USART6_RX / TIM3_CH2 + PC_8, //D30 - 1:TIM8_CH3 / SDIO_D0 / TIM3_CH3 + PC_9, //D31 - 1:TIM8_CH4 / SDIO_D1 / TIM3_CH4 + PA_8, //D32 - 1:TIM1_CH1 / I2C3_SCL / OTG_FS_SOF + PA_9, //D33 - 1:USART1_TX / TIM1_CH2 2:OTG_FS_VBUS + PA_10, //34 - 1:USART1_RX / TIM1_CH3 / OTG_FS_ID + PA_11, //D35 - 1:TIM1_CH4 / OTG_FS_DM + PA_12, //D36 - 1:OTG_FS_DP + PA_13, //D37 - 0:JTMS-SWDIO + PA_14, //D38 - 0:JTCK-SWCLK + PA_15, //D39 - 0:JTDI 1:SPI3_NSS / SPI1_NSS + PC_10, //D40 - 1:UART4_TX / SPI3_SCK / SDIO_D2 / USART3_TX + PC_11, //D41 - 1:UART4_RX / SPI3_MISO / SDIO_D3 / USART3_RX + PC_12, //D42 - 1:UART5_TX / SPI3_MOSI / SDIO_CK + PD_2, //D43 - 1:UART5_RX / SDIO_CMD + PB_3, //D44 - 0:JTDO 1:SPI3_SCK / TIM2_CH2 / SPI1_SCK + PB_4, //D45 - 0:NJTRST 1:SPI3_MISO / TIM3_CH1 / SPI1_MISO + PB_5, //D45 - 1:TIM3_CH2 / SPI1_MOSI / SPI3_MOSI + PB_6, //D47 - 1:I2C1_SCL / TIM4_CH1 / USART1_TX + PB_7, //D48 - 1:I2C1_SDA / TIM4_CH2 / USART1_RX + PB_8, //D49 - 1:I2C1_SCL / TIM4_CH3 / SDIO_D4 / TIM10_CH1 + PB_9, //D50 - 1:I2C1_SDA / TIM4_CH4 / SDIO_D5 / TIM11_CH1 / SPI2_NSS + PE_2, //D51 - 1:FSMC_A23 + PE_3, //D52 - 1:FSMC_A19 + PE_4, //D53 - 1:FSMC_A20 + PE_5, //D54 - 1:FSMC_A21 + PE_6, //D55 - 1:FSMC_A22 + PE_7, //D56 - 1:FSMC_D4 + PE_8, //D57 - 1:FSMC_D5 + PE_9, //D58 - 1:FSMC_D6 / TIM1_CH1 + PE_10, //D59 - 1:FSMC_D7 + PE_11, //D60 - 1:FSMC_D8 / TIM1_CH2 + PE_12, //D61 - 1:FSMC_D9 + PE_13, //D62 - 1:FSMC_D10 / TIM1_CH3 + PE_14, //D63 - 1:FSMC_D11 / TIM1_CH4 + PE_15, //D64 - 1:FSMC_D12 + PD_8, //D65 - 1:FSMC_D13 / USART3_TX + PD_9, //D66 - 1:FSMC_D14 / USART3_RX + PD_10, //D67 - 1:FSMC_D15 + PD_11, //D68 - 1:FSMC_A16 + PD_12, //D69 - 1:FSMC_A17 / TIM4_CH1 + PD_13, //D70 - 1:FSMC_A18 / TIM4_CH2 + PD_14, //D71 - 1:FSMC_D0 / TIM4_CH3 + PD_15, //D72 - 1:FSMC_D1 / TIM4_CH4 + PD_0, //D73 - 1:FSMC_D2 + PD_1, //D74 - 1:FSMC_D3 + PD_3, //D75 - 1:FSMC_CLK + PD_4, //D76 - 1:FSMC_NOE + PD_5, //D77 - 1:USART2_TX + PD_6, //D78 - 1:USART2_RX + PD_7, //D79 + PE_0, //D80 + PE_1, //D81 + PF_0, //D82 - 1:FSMC_A0 / I2C2_SDA + PF_1, //D83 - 1:FSMC_A1 / I2C2_SCL + PF_2, //D84 - 1:FSMC_A2 + PF_11, //D93 + PF_12, //D94 - 1:FSMC_A6 + PF_13, //D95 - 1:FSMC_A7 + PF_14, //D96 - 1:FSMC_A8 + PF_15, //D97 - 1:FSMC_A9 + PG_0, //D98 - 1:FSMC_A10 + PG_1, //D99 - 1:FSMC_A11 + PG_2, //D100 - 1:FSMC_A12 + PG_3, //D101 - 1:FSMC_A13 + PG_4, //D102 - 1:FSMC_A14 + PG_5, //D103 - 1:FSMC_A15 + PG_6, //D104 + PG_7, //D105 + PG_8, //D106 + PG_9, //D107 - 1:USART6_RX + PG_10, //D108 - 1:FSMC_NE3 + PG_11, //D109 + PG_12, //D110 - 1:FSMC_NE4 + PG_13, //D111 - 1:FSMC_A24 + PG_14, //D112 - 1:FSMC_A25 / USART6_TX + PG_15, //D113 + PA_0, //D140/A0 = D9 - 1:UART4_TX / TIM5_CH1 2:ADC123_IN0 + PA_1, //D141/A1 = D10 - 1:UART4_RX / TIM5_CH2 / TIM2_CH2 2:ADC123_IN1 + PA_2, //D142/A2 = D11 - 1:USART2_TX /TIM5_CH3 / TIM9_CH1 / TIM2_CH3 2:ADC123_IN2 + PA_3, //D143/A3 = D12 - 1:USART2_RX /TIM5_CH4 / TIM9_CH2 / TIM2_CH4 2:ADC123_IN3 + PA_4, //D144/A4 = D13 - NOT FT 1:SPI1_NSS / SPI3_NSS / USART2_CK 2:ADC12_IN4 / DAC_OUT1 + PA_5, //D145/A5 = D14 - NOT FT 1:SPI1_SCK 2:ADC12_IN5 / DAC_OUT2 + PA_6, //D146/A6 = D15 - 1:SPI1_MISO / TIM13_CH1 / TIM3_CH1 2:ADC12_IN6 + PA_7, //D147/A7 = D16 - 1:SPI1_MOSI / TIM14_CH1 / TIM3_CH2 2:ADC12_IN7 + PB_0, //D148/A8 = D19 - 1:TIM3_CH3 2:ADC12_IN8 + PB_1, //D149/A9 = D20 - 1:TIM3_CH4 2:ADC12_IN9 + PC_0, //D150/A10 = D5 - 1: 2:ADC123_IN10 + PC_1, //D151/A11 = D6 - 1: 2:ADC123_IN11 + PC_2, //D152/A12 = D7 - 1:SPI2_MISO 2:ADC123_IN12 + PC_3, //D153/A13 = D8 - 1:SPI2_MOSI 2:ADC123_IN13 + PC_4, //D154/A14 = D17 - 1: 2:ADC12_IN14 + PC_5, //D155/A15 = D18 - 1: 2:ADC12_IN15 + PF_3, //D156/A16 = D85 - 1:FSMC_A3 2:ADC3_IN9 + PF_4, //D157/A17 = D86 - 1:FSMC_A4 2:ADC3_IN14 + PF_5, //D158/A18 = D87 - 1:FSMC_A5 2:ADC3_IN15 + PF_6, //D159/A19 = D88 - 1:TIM10_CH1 2:ADC3_IN4 + PF_7, //D160/A20 = D89 - 1:TIM11_CH1 2:ADC3_IN5 + PF_8, //D161/A21 = D90 - 1:TIM13_CH1 2:ADC3_IN6 + PF_9, //D162/A22 = D91 - 1;TIM14_CH1 2:ADC3_IN7 + PF_10, //D163/A23 = D92 - 2:ADC3_IN8 +}; + +#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__); + } + + /**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); +} + +#ifdef __cplusplus +} +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_ROBIN2/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_MKS_ROBIN2/variant.h new file mode 100644 index 000000000000..51c29357986c --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_ROBIN2/variant.h @@ -0,0 +1,242 @@ + +/* + ******************************************************************************* + * 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. + ******************************************************************************* + */ + +#ifndef _VARIANT_ARDUINO_STM32_ +#define _VARIANT_ARDUINO_STM32_ + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ +// #include "PeripheralPins.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ +//extern const PinName digitalPin[]; + + #define PC13 0 + #define PC14 1 //OSC32_IN + #define PC15 2 //OSC32_OUT + #define PH0 3 //OSC_IN + #define PH1 4 //OSC_OUT + #define PB2 5 //BOOT1 + #define PB10 6 //1:SPI2_SCK / I2C2_SCL / USART3_TX / TIM2_CH3 + #define PB11 7 //1:I2C2_SDA / USART3_RX / TIM2_CH4 + #define PB12 8 //1:SPI2_NSS / OTG_HS_ID + #define PB13 9 //1:SPI2_SCK 2:OTG_HS_VBUS + #define PB14 10 //1:SPI2_MISO / TIM12_CH1 / OTG_HS_DM + #define PB15 11 //SPI2_MOSI / TIM12_CH2 / OTG_HS_DP + #define PC6 12 //1:TIM8_CH1 / SDIO_D6 / USART6_TX / TIM3_CH1 + #define PC7 13 //1:TIM8_CH2 / SDIO_D7 / USART6_RX / TIM3_CH2 + #define PC8 14 //1:TIM8_CH3 / SDIO_D0 / TIM3_CH3 + #define PC9 15 //1:TIM8_CH4 / SDIO_D1 / TIM3_CH4 + #define PA8 16 //1:TIM1_CH1 / I2C3_SCL / OTG_FS_SOF + #define PA9 17 //1:USART1_TX / TIM1_CH2 2:OTG_FS_VBUS + #define PA10 18 //1:USART1_RX / TIM1_CH3 / OTG_FS_ID + #define PA11 19 //1:TIM1_CH4 / OTG_FS_DM + #define PA12 20 //1:OTG_FS_DP + #define PA13 21 //0:JTMS-SWDIO + #define PA14 22 //0:JTCK-SWCLK + #define PA15 23 //0:JTDI 1:SPI3_NSS / SPI1_NSS + #define PC10 24 //1:UART4_TX / SPI3_SCK / SDIO_D2 / USART3_TX + #define PC11 25 //1:UART4_RX / SPI3_MISO / SDIO_D3 / USART3_RX + #define PC12 26 //1:UART5_TX / SPI3_MOSI / SDIO_CK + #define PD2 27 //1:UART5_RX / SDIO_CMD + #define PB3 28 //0:JTDO 1:SPI3_SCK / TIM2_CH2 / SPI1_SCK + #define PB4 29 //0:NJTRST 1:SPI3_MISO / TIM3_CH1 / SPI1_MISO + #define PB5 30 //1:TIM3_CH2 / SPI1_MOSI / SPI3_MOSI + #define PB6 31 //1:I2C1_SCL / TIM4_CH1 / USART1_TX + #define PB7 32 //1:I2C1_SDA / TIM4_CH2 / USART1_RX + #define PB8 33 //1:I2C1_SCL / TIM4_CH3 / SDIO_D4 / TIM10_CH1 + #define PB9 34 //1:I2C1_SDA / TIM4_CH4 / SDIO_D5 / TIM11_CH1 / SPI2_NSS + #define PE2 35 //1:FSMC_A23 + #define PE3 36 //1:FSMC_A19 + #define PE4 37 //1:FSMC_A20 + #define PE5 38 //1:FSMC_A21 + #define PE6 39 //1:FSMC_A22 + #define PE7 40 //1:FSMC_D4 + #define PE8 41 //1:FSMC_D5 + #define PE9 42 //1:FSMC_D6 / TIM1_CH1 + #define PE10 43 //1:FSMC_D7 + #define PE11 44 //1:FSMC_D8 / TIM1_CH2 + #define PE12 45 //1:FSMC_D9 + #define PE13 46 //1:FSMC_D10 / TIM1_CH3 + #define PE14 47 //1:FSMC_D11 / TIM1_CH4 + #define PE15 48 //1:FSMC_D12 + #define PD8 49 //1:FSMC_D13 / USART3_TX + #define PD9 50 //1:FSMC_D14 / USART3_RX + #define PD10 51 //1:FSMC_D15 + #define PD11 52 //1:FSMC_A16 + #define PD12 53 //1:FSMC_A17 / TIM4_CH1 + #define PD13 54 //1:FSMC_A18 / TIM4_CH2 + #define PD14 55 //1:FSMC_D0 / TIM4_CH3 + #define PD15 56 //1:FSMC_D1 / TIM4_CH4 + #define PD0 57 //1:FSMC_D2 + #define PD1 58 //1:FSMC_D3 + #define PD3 59 //1:FSMC_CLK + #define PD4 60 //1:FSMC_NOE + #define PD5 61 //1:USART2_TX + #define PD6 62 //1:USART2_RX + #define PD7 63 + #define PE0 64 + #define PE1 65 + #define PF0 66 //1:FSMC_A0 / I2C2_SDA + #define PF1 67 //1:FSMC_A1 / I2C2_SCL + #define PF2 68 //1:FSMC_A2 + #define PF11 69 + #define PF12 70 //1:FSMC_A6 + #define PF13 71 //1:FSMC_A7 + #define PF14 72 //1:FSMC_A8 + #define PF15 73 //1:FSMC_A9 + #define PG0 74 //1:FSMC_A10 + #define PG1 75 //1:FSMC_A11 + #define PG2 76 //1:FSMC_A12 + #define PG3 77 //1:FSMC_A13 + #define PG4 78 //1:FSMC_A14 + #define PG5 79 //1:FSMC_A15 + #define PG6 80 + #define PG7 81 + #define PG8 82 + #define PG9 83 //1:USART6_RX + #define PG10 84 //1:FSMC_NE3 + #define PG11 85 + #define PG12 86 //1:FSMC_NE4 + #define PG13 87 //1:FSMC_A24 + #define PG14 88 //1:FSMC_A25 / USART6_TX + #define PG15 89 + #define PA0 90 //1:UART4_TX / TIM5_CH1 2:ADC123_IN0 + #define PA1 91 //1:UART4_RX / TIM5_CH2 / TIM2_CH2 2:ADC123_IN1 + #define PA2 92 //1:USART2_TX /TIM5_CH3 / TIM9_CH1 / TIM2_CH3 2:ADC123_IN2 + #define PA3 93 //1:USART2_RX /TIM5_CH4 / TIM9_CH2 / TIM2_CH4 2:ADC123_IN3 + #define PA4 94 //NOT FT 1:SPI1_NSS / SPI3_NSS / USART2_CK 2:ADC12_IN4 / DAC_OUT1 + #define PA5 95 //NOT FT 1:SPI1_SCK 2:ADC12_IN5 / DAC_OUT2 + #define PA6 96 //1:SPI1_MISO / TIM13_CH1 / TIM3_CH1 2:ADC12_IN6 + #define PA7 97 //1:SPI1_MOSI / TIM14_CH1 / TIM3_CH2 2:ADC12_IN7 + #define PB0 98 //1:TIM3_CH3 2:ADC12_IN8 + #define PB1 99 //1:TIM3_CH4 2:ADC12_IN9 + #define PC0 100 //1: 2:ADC123_IN10 + #define PC1 101 //1: 2:ADC123_IN11 + #define PC2 102 //1:SPI2_MISO 2:ADC123_IN12 + #define PC3 103 //1:SPI2_MOSI 2:ADC123_IN13 + #define PC4 104 //1: 2:ADC12_IN14 + #define PC5 105 //1: 2:ADC12_IN15 + #define PF3 106 //1:FSMC_A3 2:ADC3_IN9 + #define PF4 107 //1:FSMC_A4 2:ADC3_IN14 + #define PF5 108 //1:FSMC_A5 2:ADC3_IN15 + #define PF6 109 //1:TIM10_CH1 2:ADC3_IN4 + #define PF7 110 //1:TIM11_CH1 2:ADC3_IN5 + #define PF8 111 //1:TIM13_CH1 2:ADC3_IN6 + #define PF9 112 //1;TIM14_CH1 2:ADC3_IN7 + #define PF10 113 //2:ADC3_IN8 + +// 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 24 +#define NUM_ANALOG_FIRST 90 + +// Below ADC, DAC and PWM definitions already done in the core +// Could be redefined here if needed +// ADC resolution is 12bits +//#define ADC_RESOLUTION 12 +//#define DACC_RESOLUTION 12 + +// PWM resolution +#define PWM_RESOLUTION 8 +#define PWM_FREQUENCY 20000 +#define PWM_MAX_DUTY_CYCLE 255 + +// 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_MOSI PB15 +#define PIN_SPI_MISO PB14 +#define PIN_SPI_SCK PB13 +#define PIN_SPI_SS PB12 + +// I2C Definitions +#define PIN_WIRE_SDA PB7 +#define PIN_WIRE_SCL PB6 + +// Timer Definitions +//Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c +#define TIMER_TONE TIM6 + +// Do not use basic timer: OC is required +#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work + +// UART Definitions +// Define here Serial instance number to map on Serial generic name +#define SERIAL_UART_INSTANCE 3 //ex: 2 for Serial2 (USART2) +// 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 PB11//PA10 +#define PIN_SERIAL_TX PB10//PA9 + +#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 +#endif + +#endif /* _VARIANT_ARDUINO_STM32_ */ 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..11f5cc5afc4f --- /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..2ca9df2efcdf --- /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****/ 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..df1ed1581a39 --- /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..0b6e6142bae9 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.h @@ -0,0 +1,197 @@ +/* + ******************************************************************************* + * 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/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PeripheralPins.c deleted file mode 100644 index d3d754b689ee..000000000000 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/PeripheralPins.c +++ /dev/null @@ -1,260 +0,0 @@ - -/* - ******************************************************************************* - * Copyright (c) 2019, 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 STM32F401V(D-E)Tx.xml - */ -#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[] = { - {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} -}; - -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 - -//*** 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_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, 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, 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, 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, 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_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 - {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 - {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 - {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 - {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 - {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 - //{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 - //{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_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)}, - {PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - {NC, NP, 0} -}; - -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)}, - {PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - {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)}, - {PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - {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)}, - {PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, - {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)}, - //{PD_6, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - //{PE_6, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - //{PE_14, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - {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)}, - //{PE_5, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - //{PE_13, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - {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)}, - //{PD_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, - //{PE_2, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - //{PE_12, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - {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)}, - //{PE_4, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - //{PE_11, SPI4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI4)}, - {NC, NP, 0} -}; -#endif - -//*** No CAN *** - -//*** No ETHERNET *** - -//*** 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} -}; -#endif - -//*** No USB_OTG_HS *** -//*** 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 diff --git a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.cpp deleted file mode 100644 index 4ecbff0ecc5c..000000000000 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/* - ******************************************************************************* - * 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 - -#ifdef ARDUINO_STEVAL -// Pin number -// This array allows to wrap Arduino pin number(Dx or x) -// to STM32 PinName (PX_n) -const PinName digitalPin[] = { - PA_9, // TX - PA_10, // RX - - // WIFI - PD_3, // CTS - PD_4, // RTS - PD_5, // TX - PD_6, // RX - PB_5, // WIFI_WAKEUP - PE_11, // WIFI_RESET - PE_12, // WIFI_BOOT - - // STATUS_LED - PE_1, //STATUS_LED - - // SPI USER - PB_12, // SPI_CS - PB_15, // SPI_MOSI - PB_14, // SPI_MISO - PB_13, // SPI_SCK - - // I2C USER - PB_7, // SDA - PB_6, // SCL - - // SPI - PA_4, // SPI_CS - PA_5, // SPI_SCK - PA_6, // SPI_MISO - PA_7, // SPI_MOSI - - // JTAG - PA_13, // JTAG_TMS/SWDIO - PA_14, // JTAG_TCK/SWCLK - PB_3, // JTAG_TDO/SWO - - // SDCARD - PC_8, // SDIO_D0 - PC_9, // SDIO_D1 - PA_15, // SD_CARD_DETECT - PC_10, // SDIO_D2 - PC_11, // SDIO_D3 - PC_12, // SDIO_CK - PD_2, // SDIO_CMD - - // OTG - PA_11, // OTG_DM - PA_12, // OTG_DP - - // IR/PROBE - PD_1, // IR_OUT - PC_1, // IR_ON - - // USER_PINS - PD_7, // USER3 - PB_9, // USER1 - PE_0, // USER2 - PB_4, // USER4 - - // USERKET - PE_7, // USER_BUTTON - - // ENDSTOPS - PD_8, // X_STOP - PD_9, // Y_STOP - PD_10, // Z_STOP - PD_11, // U_STOP - PA_8, // V_STOP - PD_0, // W_STOP - - // HEATERS - PD_13, // BED_HEAT_2 - PD_14, // BED_HEAT_1 - PD_15, // BED_HEAT_3 - PC_7, // E1_HEAT_PWM - PB_0, // E2_HEAT_PWM - PB_1, // E3_HEAT_PWM - - // THERMISTOR - PC_2, // BED_THERMISTOR_1 - PC_3, // BED_THERMISTOR_2 - PA_3, // BED_THERMISTOR_3 - PA_0, // E1_THERMISTOR - PA_1, // E2_THERMISTOR - PA_2, // E3_THERMISTOR - - // FANS - PC_4, // E1_FAN - PC_5, // E2_FAN - PE_8, // E3_FAN - - // X_MOTOR - PE_13, // X_RESET - PE_14, // X_PWM - PE_15, // X_DIR - - // Y_MOTOR - PE_10, // Y_RESET - PB_10, // Y_PWM - PE_9, // Y_DIR - - // Z_MOTOR - PC_15, // Z_RESET - PC_6, // Z_PWM - PC_0, // Z_DIR - - // E1_MOTOR - PC_14, // E1_RESET - PC_13, // E1_DIR - PD_12, // E1_PWM - - // E2_MOTOR - PE_4, // E2_RESET - PE_5, // E2_PWM - PE_6, // E2_DIR - - // E3_MOTOR - PE_3, // E3_RESET - PE_2, // E3_DIR - PB_8 // E3_PWM -}; -#endif - -#ifdef __cplusplus -} -#endif - -// ---------------------------------------------------------------------------- - -#ifdef __cplusplus -extern "C" { -#endif -/** - * @brief System Clock Configuration - * The system Clock is configured as follow : - * System Clock source = PLL (HSI) - * SYSCLK(Hz) = 84000000 - * HCLK(Hz) = 84000000 - * AHB Prescaler = 1 - * APB1 Prescaler = 2 - * APB2 Prescaler = 1 - * HSI Frequency(Hz) = 16000000 - * PLL_M = 16 - * PLL_N = 336 - * PLL_P = 4 - * PLL_Q = 7 - * VDD(V) = 3.3 - * Main regulator output voltage = Scale2 mode - * Flash Latency(WS) = 2 - * @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_SCALE2); - - /* 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 = 15; - RCC_OscInitStruct.PLL.PLLN = 144; - RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; - RCC_OscInitStruct.PLL.PLLQ = 5; - if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { - Error_Handler(); - } - /* 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_DIV2; - RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; - - if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) { - Error_Handler(); - } -} - -#ifdef __cplusplus -} -#endif - - -// PA_0 54 // E1_THERMISTOR -// PA_1 55 // E2_THERMISTOR -// PA_2 56 // E3_THERMISTOR -// PA_3 53 // BED_THERMISTOR_3 -// PA_4 16 // SPI_CS -// PA_5 17 // SPI_SCK -// PA_6 18 // SPI_MISO -// PA_7 19 // SPI_MOSI -// PA_8 43 // V_STOP -// PA_9 0 //TX -// PA_10 1 //RX -// PA_11 30 //OTG_DM -// PA_12 31 //OTG_DP -// PA_13 20 // JTAG_TMS/SWDIO -// PA_14 21 // JTAG_TCK/SWCLK -// PA_15 25 // SD_CARD_DETECT -// PB_0 49 // E2_HEAT_PWM -// PB_1 50 // E3_HEAT_PWM -// PB_3 22 // JTAG_TDO/SWO -// PB_4 37 // USER4 -// PB_5 6 // WIFI_WAKEUP -// PB_6 15 // SCL -// PB_7 14 // SDA -// PB_8 77 // E3_PWM -// PB_9 35 // USER1 -// PB_10 64 // Y_PWM -// PB_12 10 // SPI_CS -// PB_13 13 // SPI_SCK -// PB_14 12 // SPI_MISO -// PB_15 11 // SPI_MOSI -// PC_0 68 // Z_DIR -// PC_1 33 //IR_ON -// PC_2 51 // BED_THERMISTOR_1 -// PC_3 52 // BED_THERMISTOR_2 -// PC_4 57 // E1_FAN -// PC_5 58 // E2_FAN -// PC_6 67 // Z_PWM -// PC_7 48 // E1_HEAT_PWM -// PC_8 23 // SDIO_D0 -// PC_9 24 // SDIO_D1 -// PC_10 26 // SDIO_D2 -// PC_11 27 // SDIO_D3 -// PC_12 28 // SDIO_CK -// PC_13 70 // E1_DIR -// PC_14 69 // E1_RESET -// PC_15 66 // Z_RESET -// PD_0 44 // W_STOP -// PD_1 32 //IR_OUT -// PD_2 29 // SDIO_CMD -// PD_3 2 // CTS -// PD_4 3 // RTS -// PD_5 4 // TX -// PD_6 5 // RX -// PD_7 34 // USER3 -// PD_8 39 // X_STOP -// PD_9 40 // Y_STOP -// PD_10 41 // Z_STOP -// PD_11 42 // U_STOP -// PD_12 71 // E1_PWM -// PD_13 45 // BED_HEAT_2 -// PD_14 46 // BED_HEAT_1 -// PD_15 47 // BED_HEAT_3 -// PE_0 36 // USER2 -// PE_1 9 // STATUS_LED -// PE_2 76 // E3_DIR -// PE_3 75 // E3_RESET -// PE_4 72 // E2_RESET -// PE_5 73 // E2_PWM -// PE_6 74 // E2_DIR -// PE_7 38 // USER_BUTTON -// PE_8 59 // E3_FAN -// PE_9 65 // Y_DIR -// PE_10 63 // Y_RESET -// PE_11 7 // WIFI_RESET -// PE_12 8 // WIFI_BOOT -// PE_13 60 // X_RESET -// PE_14 61 // X_PWM -// PE_15 62 // X_DIR diff --git a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.h deleted file mode 100644 index df7295ab17e8..000000000000 --- a/buildroot/share/PlatformIO/variants/MARLIN_STEVAL_F401VE/variant.h +++ /dev/null @@ -1,327 +0,0 @@ -/* - ******************************************************************************* - * 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. - ******************************************************************************* - */ - -#ifndef _VARIANT_ARDUINO_STM32_ -#define _VARIANT_ARDUINO_STM32_ -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -/*---------------------------------------------------------------------------- - * Pins - *----------------------------------------------------------------------------*/ -#ifdef ARDUINO_STEVAL - - -/*---------------------------------------------------------------------------- - * Pins - *----------------------------------------------------------------------------*/ -// USART1_MAIN -#define PA9 0 //TX -#define PA10 1 //RX - -// WIFI (USART2) -#define PD3 2 // CTS -#define PD4 3 // RTS -#define PD5 4 // TX -#define PD6 5 // RX -#define PB5 6 // WIFI_WAKEUP -#define PE11 7 // WIFI_RESET -#define PE12 8 // WIFI_BOOT - -// STATUS_LED -#define PE1 9 // STATUS_LED - -// SPI USER -#define PB12 10 // SPI_CS -#define PB15 11 // SPI_MOSI -#define PB14 12 // SPI_MISO -#define PB13 13 // SPI_SCK - -// I2C USER -#define PB7 14 // SDA -#define PB6 15 // SCL - -// SPI -#define PA4 16 // SPI_CS -#define PA5 17 // SPI_SCK -#define PA6 18 // SPI_MISO -#define PA7 19 // SPI_MOSI - -// JTAG -#define PA13 20 // JTAG_TMS/SWDIO -#define PA14 21 // JTAG_TCK/SWCLK -#define PB3 22 // JTAG_TDO/SWO - -// SDCARD -#define PC8 23 // SDIO_D0 -#define PC9 24 // SDIO_D1 -#define PA15 25 // SD_CARD_DETECT -#define PC10 26 // SDIO_D2 -#define PC11 27 // SDIO_D3 -#define PC12 28 // SDIO_CK -#define PD2 29 // SDIO_CMD - -// OTG -#define PA11 30 //OTG_DM -#define PA12 31 //OTG_DP - -// IR/PROBE -#define PD1 32 //IR_OUT -#define PC1 33 //IR_ON - -// USER_PINS -#define PD7 34 // USER3 -#define PB9 35 // USER1 -#define PE0 36 // USER2 -#define PB4 37 // USER4 - -// USERKET -#define PE7 38 // USER_BUTTON - -// ENDSTOPS -#define PD8 39 // X_STOP -#define PD9 40 // Y_STOP -#define PD10 41 // Z_STOP -#define PD11 42 // U_STOP -#define PA8 43 // V_STOP -#define PD0 44 // W_STOP - -// HEATERS -#define PD13 45 // BED_HEAT_2 -#define PD14 46 // BED_HEAT_1 -#define PD15 47 // BED_HEAT_3 -#define PC7 48 // E1_HEAT_PWM -#define PB0 49 // E2_HEAT_PWM -#define PB1 50 // E3_HEAT_PWM - -// THERMISTOR -#define PC2 51 // BED_THERMISTOR_1 -#define PC3 52 // BED_THERMISTOR_2 -#define PA3 53 // BED_THERMISTOR_3 -#define PA0 54 // E1_THERMISTOR -#define PA1 55 // E2_THERMISTOR -#define PA2 56 // E3_THERMISTOR - -// FANS -#define PC4 57 // E1_FAN -#define PC5 58 // E2_FAN -#define PE8 59 // E3_FAN - -// X_MOTOR -#define PE13 60 // X_RESET -#define PE14 61 // X_PWM -#define PE15 62 // X_DIR - -// Y_MOTOR -#define PE10 63 // Y_RESET -#define PB10 64 // Y_PWM -#define PE9 65 // Y_DIR - -// Z_MOTOR -#define PC15 66 // Z_RESET -#define PC6 67 // Z_PWM -#define PC0 68 // Z_DIR - -// E1_MOTOR -#define PC14 69 // E1_RESET -#define PC13 70 // E1_DIR -#define PD12 71 // E1_PWM - -// E2_MOTOR -#define PE4 72 // E2_RESET -#define PE5 73 // E2_PWM -#define PE6 74 // E2_DIR - -// E3_MOTOR -#define PE3 75 // E3_RESET -#define PE2 76 // E3_DIR -#define PB8 77 // E3_PWM - -// This must be a literal -#define NUM_DIGITAL_PINS 78 -// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS -#define NUM_ANALOG_INPUTS 6 -#define NUM_ANALOG_FIRST 51 - -// On-board LED pin number -#define LED_BUILTIN PE1 -#define LED_GREEN LED_BUILTIN - -// On-board user button -#define USER_BTN PE7 - -// UART Definitions -#define SERIAL_UART_INSTANCE 1 // Connected to ST-Link -//#define SERIAL_UART_INSTANCE 2 // Connected to WIFI - -// Default pin used for 'Serial' instance (ex: ST-Link) -// Mandatory for Firmata -#if SERIAL_UART_INSTANCE == 1 // ST-Link & J23 - #define PIN_SERIAL_RX PA10 - #define PIN_SERIAL_TX PA9 -#elif SERIAL_UART_INSTANCE == 2 // WIFI interface - #define PIN_SERIAL2_RX PD6 - #define PIN_SERIAL2_TX PD5 -#else - #error "Invalid setting for SERIAL_UART_INSTANCE." -#endif - -// Timer Definitions -#define TIMER_SERVO TIM4 // TIMER_SERVO must be defined in this file -#define TIMER_TONE TIM5 // TIMER_TONE must be defined in this file - -/* SD detect signal */ -/* - * By default, R67 is not provided, so SD card detect is not used. - * Note: SD CD (pin 16 of expansion connector J23) can be connected - * to GND in order to be able to use SD_DETECT_PIN - */ -/*#define SD_DETECT_PIN PA15*/ - -/* HAL configuration */ -#define HSE_VALUE 25000000U - -/* Extra HAL modules */ -#define HAL_SD_MODULE_ENABLED - -#endif - -#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 -#endif - -#endif // _VARIANT_ARDUINO_STM32_ - -// PA0 54 // E1_THERMISTOR -// PA1 55 // E2_THERMISTOR -// PA2 56 // E3_THERMISTOR -// PA3 53 // BED_THERMISTOR_3 -// PA4 16 // SPI_CS -// PA5 17 // SPI_SCK -// PA6 18 // SPI_MISO -// PA7 19 // SPI_MOSI -// PA8 43 // V_STOP -// PA9 0 //TX -// PA10 1 //RX -// PA11 30 //OTG_DM -// PA12 31 //OTG_DP -// PA13 20 // JTAG_TMS/SWDIO -// PA14 21 // JTAG_TCK/SWCLK -// PA15 25 // SD_CARD_DETECT -// PB0 49 // E2_HEAT_PWM -// PB1 50 // E3_HEAT_PWM -// PB3 22 // JTAG_TDO/SWO -// PB4 37 // USER4 -// PB5 6 // WIFI_WAKEUP -// PB6 15 // SCL -// PB7 14 // SDA -// PB8 77 // E3_PWM -// PB9 35 // USER1 -// PB10 64 // Y_PWM -// PB12 10 // SPI_CS -// PB13 13 // SPI_SCK -// PB14 12 // SPI_MISO -// PB15 11 // SPI_MOSI -// PC0 68 // Z_DIR -// PC1 33 //IR_ON -// PC2 51 // BED_THERMISTOR_1 -// PC3 52 // BED_THERMISTOR_2 -// PC4 57 // E1_FAN -// PC5 58 // E2_FAN -// PC6 67 // Z_PWM -// PC7 48 // E1_HEAT_PWM -// PC8 23 // SDIO_D0 -// PC9 24 // SDIO_D1 -// PC10 26 // SDIO_D2 -// PC11 27 // SDIO_D3 -// PC12 28 // SDIO_CK -// PC13 70 // E1_DIR -// PC14 69 // E1_RESET -// PC15 66 // Z_RESET -// PD0 44 // W_STOP -// PD1 32 //IR_OUT -// PD2 29 // SDIO_CMD -// PD3 2 // CTS -// PD4 3 // RTS -// PD5 4 // TX -// PD6 5 // RX -// PD7 34 // USER3 -// PD8 39 // X_STOP -// PD9 40 // Y_STOP -// PD10 41 // Z_STOP -// PD11 42 // U_STOP -// PD12 71 // E1_PWM -// PD13 45 // BED_HEAT_2 -// PD14 46 // BED_HEAT_1 -// PD15 47 // BED_HEAT_3 -// PE0 36 // USER2 -// PE1 9 // STATUS_LED -// PE2 76 // E3_DIR -// PE3 75 // E3_RESET -// PE4 72 // E2_RESET -// PE5 73 // E2_PWM -// PE6 74 // E2_DIR -// PE7 38 // USER_BUTTON -// PE8 59 // E3_FAN -// PE9 65 // Y_DIR -// PE10 63 // Y_RESET -// PE11 7 // WIFI_RESET -// PE12 8 // WIFI_BOOT -// PE13 60 // X_RESET -// PE14 61 // X_PWM -// PE15 62 // X_DIR 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..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 @@ -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_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: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/variant.h index 30c3d953494f..5232a1eaf2e4 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/variant.h @@ -121,6 +121,7 @@ extern "C" { #ifdef __cplusplus } // extern "C" #endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ 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/board/board.h b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board/board.h index a1e33467434a..80261d30274d 100644 --- a/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board/board.h +++ b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board/board.h @@ -63,7 +63,6 @@ * SPI3 is unusable due to pin 43 (PB4) and NRST tie-together :(, but * leave the definitions so as not to clutter things up. This is only * OK since RET6 Ed. is specifically advertised as a beta board. */ -#define BOARD_NR_SPI 3 #define BOARD_SPI1_NSS_PIN PA4 #define BOARD_SPI1_SCK_PIN PA5 #define BOARD_SPI1_MISO_PIN PA6 @@ -79,7 +78,6 @@ #define BOARD_SPI3_MISO_PIN PB4 #define BOARD_SPI3_MOSI_PIN PB5 - /* GPIO A to E = 5 * 16 - BOOT1 not used = 79*/ #define BOARD_NR_GPIO_PINS 112 /* Note: NOT 19. The missing one is D38 a.k.a. BOARD_BUTTON_PIN, which 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/board/board.h b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/board/board.h index da9ffd893f87..6ffa2447460d 100644 --- a/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/board/board.h +++ b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/board/board.h @@ -63,26 +63,21 @@ * SPI3 is unusable due to pin 43 (PB4) and NRST tie-together :(, but * leave the definitions so as not to clutter things up. This is only * OK since RET6 Ed. is specifically advertised as a beta board. */ -#define BOARD_NR_SPI 3 #define BOARD_SPI1_NSS_PIN PA4 #define BOARD_SPI1_SCK_PIN PA5 #define BOARD_SPI1_MISO_PIN PA6 #define BOARD_SPI1_MOSI_PIN PA7 - - #define BOARD_SPI2_NSS_PIN PB12 #define BOARD_SPI2_SCK_PIN PB13 #define BOARD_SPI2_MISO_PIN PB14 #define BOARD_SPI2_MOSI_PIN PB15 - #define BOARD_SPI3_NSS_PIN PA15 #define BOARD_SPI3_SCK_PIN PB3 #define BOARD_SPI3_MISO_PIN PB4 #define BOARD_SPI3_MOSI_PIN PB5 - /* GPIO A to E = 5 * 16 - BOOT1 not used = 79*/ #define BOARD_NR_GPIO_PINS 51 /* Note: NOT 19. The missing one is D38 a.k.a. BOARD_BUTTON_PIN, which 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 diff --git a/buildroot/share/cmake/CMakeLists.txt b/buildroot/share/cmake/CMakeLists.txt index 9d3f24f990aa..1ed9091e01d6 100644 --- a/buildroot/share/cmake/CMakeLists.txt +++ b/buildroot/share/cmake/CMakeLists.txt @@ -25,7 +25,7 @@ set(SCRIPT_BRANCH 1.0.2) #Set to wanted marlin-cmake release tag or branch if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake) file(DOWNLOAD https://github.com/tohara/marlin-cmake/archive/${SCRIPT_BRANCH}.tar.gz - ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake-src.tar.gz SHOW_PROGRESS) + ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake-src.tar.gz SHOW_PROGRESS) execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xvf ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake-src.tar.gz WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) @@ -36,7 +36,7 @@ if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake) endif() if(WIN32 AND NOT EXISTS ${CMAKE_BINARY_DIR}/make.exe) - file(COPY ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/resources/make.exe DESTINATION ${CMAKE_BINARY_DIR}/) + file(COPY ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/resources/make.exe DESTINATION ${CMAKE_BINARY_DIR}/) endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/modules) @@ -105,9 +105,9 @@ set(${PROJECT_NAME}_SRCS "${SOURCES};../../../Marlin/Marlin.ino") # cmake .. -DUPLOAD_PORT=/dev/ttyACM0 # #====================================================================# if(UPLOAD_PORT) - set(${PROJECT_NAME}_PORT ${UPLOAD_PORT}) + set(${PROJECT_NAME}_PORT ${UPLOAD_PORT}) else() - set(${PROJECT_NAME}_PORT /dev/ttyACM0) + set(${PROJECT_NAME}_PORT /dev/ttyACM0) endif() #====================================================================# diff --git a/buildroot/share/dwin/bin/DWIN_ICO.py b/buildroot/share/dwin/bin/DWIN_ICO.py index 8ac680c61e7c..3ddc734022ee 100644 --- a/buildroot/share/dwin/bin/DWIN_ICO.py +++ b/buildroot/share/dwin/bin/DWIN_ICO.py @@ -144,7 +144,7 @@ def createFile(self, iconDir, filename): # process each file: try: index = int(dirEntry.name[0:3]) - if (index < 0) or (index > 255): + if not (0 <= index <= 255): print('...Ignoring invalid index on', dirEntry.path) continue #dirEntry.path is iconDir/name diff --git a/buildroot/share/dwin/bin/README.md b/buildroot/share/dwin/bin/README.md index 9d513bc0c8f5..a00d679bf8e1 100644 --- a/buildroot/share/dwin/bin/README.md +++ b/buildroot/share/dwin/bin/README.md @@ -4,7 +4,7 @@ Tools for processing `.ICO` files used by DWIN displays. ## Introduction -The DWIN LCDs that come with the Creality Ender 3 v2 and other 3D printers contain image and container files stored on them which are used to draw various the UI elements. +The DWIN LCDs that come with the Creality Ender-3 v2 and other 3D printers contain image and container files stored on them which are used to draw various the UI elements. Standard `.JPG` files can be installed for things like the boot screen, and `.ICO` files can contain several images within a structured file format. @@ -42,15 +42,15 @@ These tools must be run from a terminal with access to an installed Python 3 and Pillow is most easily installed with pip: - python3 -m pip install pillow + python3 -m pip install pillow ## Examples These tools process an `.ICO` file that you specify. The safest method is to create a folder and copy your `.ICO` file there. For example: - $ mkdir hackicons - $ cp 9.ICO hackicons - $ cd hackicons + $ mkdir hackicons + $ cp 9.ICO hackicons + $ cd hackicons The following explanations will refer back to this layout. @@ -64,19 +64,19 @@ If you want to edit the individual icons stored in an ICO file (or add more imag In this example we're extracting the constituent JPEG files from `9.ICO` and storing them in a folder named `icons`. As each file is extracted the script reports its index number, byte offset, size, dimensions, and filename: - $ cd buildroot/share/dwin - $ ./bin/splitIco.py 9.ICO icons-9 - Splitting 9.ICO into dir icons - Splitting Entry Data... - 00: offset: 0x001000 len: 0x10a2 width: 130 height: 17 - Wrote 4258 bytes to icons/000-ICON_LOGO.jpg - 01: offset: 0x0020a2 len: 0x0eac width: 110 height: 100 - Wrote 3756 bytes to icons/001-ICON_Print_0.jpg - 02: offset: 0x002f4e len: 0x0eaa width: 110 height: 100 - Wrote 3754 bytes to icons/002-ICON_Print_1.jpg - ... - 91: offset: 0x0345fc len: 0x0d89 width: 110 height: 100 - Wrote 3465 bytes to icons/091-ICON_Info_1.jpg + $ cd buildroot/share/dwin + $ ./bin/splitIco.py 9.ICO icons-9 + Splitting 9.ICO into dir icons + Splitting Entry Data... + 00: offset: 0x001000 len: 0x10a2 width: 130 height: 17 + Wrote 4258 bytes to icons/000-ICON_LOGO.jpg + 01: offset: 0x0020a2 len: 0x0eac width: 110 height: 100 + Wrote 3756 bytes to icons/001-ICON_Print_0.jpg + 02: offset: 0x002f4e len: 0x0eaa width: 110 height: 100 + Wrote 3754 bytes to icons/002-ICON_Print_1.jpg + ... + 91: offset: 0x0345fc len: 0x0d89 width: 110 height: 100 + Wrote 3465 bytes to icons/091-ICON_Info_1.jpg Once the individual JPEG files have been saved they can be edited using common graphics applications like Photoshop. JPEG files are inherently lossy and will usually contain ugly artifacts, so cleanup may be needed before they are re-exported. Keep the limits of bank size in mind when exporting images and try to find the best balance between compressed size and image quality. @@ -84,9 +84,9 @@ Once the individual JPEG files have been saved they can be edited using common g After editing images you'll create a new `9.ICO` archive with `makeIco.py` like so: - $ cd buildroot/share/dwin - $ ./bin/makeIco.py icons-3 3.ICO - Making .ico file '3.ICO' from contents of 'icons-3' - Scanning icon directory icons-3 - ...Scanned 16 icon files - Scanning done. 16 icons included. + $ cd buildroot/share/dwin + $ ./bin/makeIco.py icons-3 3.ICO + Making .ico file '3.ICO' from contents of 'icons-3' + Scanning icon directory icons-3 + ...Scanned 16 icon files + Scanning done. 16 icons included. 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/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 diff --git a/buildroot/share/fonts/bdf2u8g/Makefile b/buildroot/share/fonts/bdf2u8g/Makefile new file mode 100644 index 000000000000..cb00c7bb7425 --- /dev/null +++ b/buildroot/share/fonts/bdf2u8g/Makefile @@ -0,0 +1,15 @@ +CFLAGS = -g -Wall +#CFLAGS = -O4 -Wall + +SRC = bdf2u8g.c + +OBJ = $(SRC:.c=.o) + +bdf2u8g: $(OBJ) + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o bdf2u8g.exe + +clean: + -rm $(OBJ) bdf2u8g.exe + +test: + ./bdf2u8g.exe -f 2 ../bdf/9x18.bdf u8g_aafont_9x18 u8g_aafont_9x18.c diff --git a/buildroot/share/fonts/bdf2u8g/bdf2u8g.c b/buildroot/share/fonts/bdf2u8g/bdf2u8g.c new file mode 100644 index 000000000000..0421bbd87fb9 --- /dev/null +++ b/buildroot/share/fonts/bdf2u8g/bdf2u8g.c @@ -0,0 +1,1214 @@ +/* + general font collections + http://www.smashingmagazine.com/2007/11/08/40-excellent-freefonts-for-professional-design/ + http://techmagazine.ws/most-popular-free-quality-fonts/ + http://openfontlibrary.org/ + bitmap font collections + http://www.orgdot.com/aliasfonts/ (includes links) + http://www.04.jp.org/ + http://www.miniml.com + http://www.fontspace.com/010bus + + http://en.wikipedia.org/wiki/Unicode_typeface + da könnten auch ein paar fonts dabei sein, die die m2tklib sonderzeichen beinhalten: + Caslon Roman http://en.wikipedia.org/wiki/Caslon_Roman + Charis Sil http://en.wikipedia.org/wiki/Charis_SIL + DejaVu Sans http://en.wikipedia.org/wiki/DejaVu_fonts + Doulos http://en.wikipedia.org/wiki/Doulos_SIL + Free Serif http://en.wikipedia.org/wiki/FreeSerif http://ftp.gnu.org/gnu/freefont/ + --> keine box, aber es gibt pfeile/invertierte pfeile und kreise für m2tklib + Gentium Plus ???? http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=Gentium_download#02b091ae + --> keine graphic + GNU Unifont http://en.wikipedia.org/wiki/GNU_Unifont, http://unifoundry.com/unifont.html + + Titus cyberbit Basic http://en.wikipedia.org/wiki/TITUS_Cyberbit_Basic + + fonts + Gentium + http://openfontlibrary.org/font/gentium + license: OFL + Old-Standard + http://openfontlibrary.org/font/old-standard + license: OFL + Hanuman + http://openfontlibrary.org/font/hanumanb + license: OFL + FreeUniversal + http://openfontlibrary.org/font/freeuniversal + license: OFL + FriendShip-Code <--- nicht so sicher... + http://openfontlibrary.org/font/friendship-code + license: CC-BY-SA + LinuxLibertine + http://de.wikipedia.org/wiki/Linux_Libertine + http://sourceforge.net/projects/linuxlibertine/files/linuxlibertine/5.1.3-2/ + license: OFL + DidactGothic + source: http://openfontlibrary.org/ + judson + source: http://openfontlibrary.org/ + unicons + source: http://openfontlibrary.org/ + license: OFL + suggested pt: 26, 30 + org_V01, fixed_V0 + source: http://www.orgdot.com/aliasfonts/ + license: open source, individual, cite required + suggested pt: 8 + 04b_03b.zip 04b_03.zip 04b_09.zip 04b_11.zip 04b_19.zip 04b_21.zip 04b_25.zip 04b_30.zip + source: http://www.04.jp.org/ + license: "Freeware: You may use them as you like" + 7px4bus + source: http://www.fontspace.com/010bus + license: Licensed as: Freeware, Commercial use allowed! + suggested 7pt + 8pxbus + source: http://www.fontspace.com/010bus + license: Licensed as: Freeware, Commercial use allowed! + suggested 8pt + +*/ + +/* + only supports metric set "0" + assume DWIDTH second arg to be 0 for all glyphs + assumes that (0,0) of the BBX is placed on the base line + assumes ISO10646 encoding of the BDF file + + font information + offset + 0 font format + 1 FONTBOUNDINGBOX width unsigned + 2 FONTBOUNDINGBOX height unsigned + 3 FONTBOUNDINGBOX x-offset signed + 4 FONTBOUNDINGBOX y-offset signed + 5 capital A height unsigned + 6 start 'A' + 8 start 'a' + 10 encoding start + 11 encoding end + 12 descent 'g' negative: below baseline + 13 font max ascent + 14 font min decent negative: below baseline + 15 xascent (ascent of "(") + 16 xdescent (descent of ")") + +format 0 + glyph information + offset + 0 BBX width unsigned + 1 BBX height unsigned + 2 data size unsigned (BBX width + 7)/8 * BBX height + 3 DWIDTH signed + 4 BBX xoffset signed + 5 BBX yoffset signed + +format 1 + 0 BBX xoffset signed --> upper 4 Bit + 0 BBX yoffset signed --> lower 4 Bit + 1 BBX width unsigned --> upper 4 Bit + 1 BBX height unsigned --> lower 4 Bit + 2 data size unsigned -(BBX width + 7)/8 * BBX height --> lower 4 Bit + 2 DWIDTH signed --> upper 4 Bit + byte 0 == 255 indicates empty glyph + +format 2 + like format 0, but 4 gray levels for the glyph (4 pixel per byte in the glyph data) + + The glyph bitmap size is defined by BBX width and BBX height + number of bytes in the bitmap data (BBX width + 7)/8 * BBX height (format 0 and 1) + + draw_text(x,y,str) + get_text_frame(x,y,str, &x1, &y1, &width, &height) + frame( x1, y1, width, height) + underline( x1, y-1, width ) + + size of the surrounding bbox + + width = - xoffset(c1) + DWIDTH(c1) + DWIDTH(c2) + ... + DWIDTH(cn-1) + width(cn) + xoffset(cn) + height = FONTBOUNDINGBOX height + x1 = x + xoffset(c1) + y1 = y + yoffset(c1) + +ISO-8859-1 was incorporated as the first 256 code points of ISO/IEC 10646 and Unicode. + +*/ + +#include +#include +#include +#include + +#define BDF2U8G_COMPACT_OUTPUT +#define BDF2U8G_VERSION "1.01" +//#define VERBOSE + +/*=== forward declaration ===*/ +void bdf_aa_ClearDoShow(void); +void bdf_aa_Do(void); + +/*=== result data ===*/ +#define DATA_BUF_SIZE (1024 * 64) +unsigned char data_buf[DATA_BUF_SIZE]; +int data_pos = 0; + +void data_Init(void) { + data_pos = 0; +} + +void data_Put(unsigned char c) { + data_buf[data_pos] = c; + data_pos++; +} + +void data_Write(FILE *out_fp, const char *indent) { + int i; + int bytes_per_line = 16; + for (i = 0; i < data_pos; i++) { + fprintf(out_fp, "0x%02X", data_buf[i]); + if (i + 1 != data_pos) + fprintf(out_fp, ","); + if ((i + 1) % bytes_per_line == 0) + fprintf(out_fp, "\n%s", indent); + } +} + +/*=== low level parser ===*/ +#define P_BUF_SIZE (1024 * 4) +int p_current_char; +const char *p_line; +char p_buf[P_BUF_SIZE]; + +/* put next char into p_current_char */ +static int p_next_char(void) { + p_current_char = *p_line; + if (p_current_char == '\0') + return 0; + p_line++; + return 1; +} + +int p_first_char(const char *line) { + p_line = line; + return p_next_char(); +} + +void p_err(const char *msg) { +} + +int p_skip_space(void) { + for (;;) { + if (p_current_char == 0 || p_current_char > 32) + break; + if (p_next_char() == 0) + return 0; + } + return 1; +} + +/* put identifier into p_buf */ +int p_get_identifier(void) { + int i = 0; + if (p_current_char == '\0') + return p_err("unexpected EOF (expected identifier)"), 0; + for (;;) { + if (p_current_char <= 32) + break; + p_buf[i++] = p_current_char; + if (p_next_char() == 0) + break; + } + p_buf[i++] = '\0'; + p_skip_space(); + return 1; +} + +/* put identifier into p_buf */ +int p_get_identifier_with_blank(void) { + int i = 0; + for (;;) { + if (p_current_char < 32) + break; + p_buf[i++] = p_current_char; + if (p_next_char() == 0) + break; + } + p_buf[i++] = '\0'; + p_skip_space(); + return 1; +} + +int p_get_string(void) { + int i = 0; + if (p_current_char == '\0') + return 0; + if (p_current_char != '\"') + return p_err("\" expected"), 0; + if (p_next_char() == 0) + return p_err("unexpected EOF (\")"), 0; + for (;;) { + if (p_current_char == '\\') { + if (p_next_char() == 0) + return p_err("unexpected EOF (\\)"), 0; + } + else if (p_current_char == '\"') { + p_next_char(); + break; + } + p_buf[i++] = p_current_char; + if (p_next_char() == 0) + return p_err("unexpected EOF (\")"), 0; + } + p_buf[i] = '\0'; + return 1; +} + +int p_get_any(void) { + if (p_current_char == '\"') + return p_get_string(); + return p_get_identifier(); +} + +int p_get_val(void) { + p_get_any(); + return atoi(p_buf); +} + +int p_get_hex(void) { + int value = 0; + if (p_current_char >= '0' && p_current_char <= '9') + value = p_current_char - '0'; + else if (p_current_char >= 'a' && p_current_char <= 'f') + value = p_current_char - 'a' + 10; + else if (p_current_char >= 'A' && p_current_char <= 'F') + value = p_current_char - 'A' + 10; + p_next_char(); + return value; +} + +int p_get_hex_byte(void) { + int v; + v = p_get_hex(); + v *= 16; + v += p_get_hex(); + return v; +} + +/*=== encoding mapping ===*/ +/* the internal u8g index number (0..255) is mapped to the unicode number */ +/* for the conversion we need the reverse search */ +/* 0 is special and means not found */ +int map_u8g_to_unicode[256]; + +int map_UnicodeToU8G(int unicode) { + int i; + for (i = 0; i < 256; i++) + if (map_u8g_to_unicode[i] == unicode) + return i; + return 0; +} + +void map_Init(void) { + int i; + map_u8g_to_unicode[0] = 0; + for (i = 0; i < 256; i++) map_u8g_to_unicode[i] = i; +} + +void map_UpperLowerPage(int lower_page, int upper_page, int shift, int upper_shift) { + int i; + int encoding; + int tmp[256]; + // map_u8g_to_unicode[0] = 0; + for (i = 0; i < 128; i++) { + encoding = i + lower_page * 128; + map_u8g_to_unicode[i] = encoding; + } + + for (i = 128; i < 256; i++) { + encoding = i - 128 + upper_page * 128; + if (i + upper_shift < 256) + map_u8g_to_unicode[i + upper_shift] = encoding; + } + + for (i = 0; i < 256; i++) tmp[i] = map_u8g_to_unicode[i]; + + for (i = 0; i < shift; i++) map_u8g_to_unicode[i] = -1; + + for (i = shift; i < 256; i++) map_u8g_to_unicode[i] = tmp[(i + 256 - shift) % 256]; + /* + printf("map_u8g_to_unicode[ 32 ] = %d\n", map_u8g_to_unicode[ 32 ]); + printf("map_u8g_to_unicode[ 33 ] = %d\n", map_u8g_to_unicode[ 33 ]); + */ +} + +/*=== store bdf file positions ===*/ + +long bdf_last_line_start_pos; +long bdf_encoding_pos[256]; + +void bdf_InitFilePos(void) { + int i; + for (i = 0; i < 256; i++) bdf_encoding_pos[i] = 0; +} + +void bdf_SetFilePos(FILE *fp, int encoding) { + if (encoding < 0) + return; + if (bdf_encoding_pos[encoding] == 0L) + return; + fseek(fp, bdf_encoding_pos[encoding], SEEK_SET); + // fprintf(stderr, "setting file for encoding %d to pos %ld\n", encoding, bdf_encoding_pos[encoding]); +} + +int bdf_IsEncodingAvailable(int encoding) { + if (bdf_encoding_pos[encoding] == 0L) + // printf("encoding %d not availabe\n", encoding); + return 0; + return 1; +} + +void bdf_StoreFilePos(int encoding, long pos) { + // if ( encoding == 33 ) + // printf("encoding %d at pos %ld\n", encoding, pos); + if (bdf_encoding_pos[encoding] != 0L) + return; + bdf_encoding_pos[encoding] = pos; +} + +/*=== bdf file read ===*/ + +int bdf_font_format = 0; + +#define BDF_STATE_FONT_DATA 0 +#define BDF_STATE_ENCODING 1 + +int bdf_state = BDF_STATE_FONT_DATA; +int bdf_requested_encoding = 0; + +#define BDF_LINE_MAX (1024 * 4) +#define BDF_LINE_STATE_KEYWORDS 0 +#define BDF_LINE_STATE_BITMAP 1 +#define BDF_MAX_HEIGHT 200 +#define BDF_AA_OFFSET 1 + +char bdf_copyright[BDF_LINE_MAX]; +char bdf_font[BDF_LINE_MAX]; +unsigned char bdf_bitmap_line[BDF_MAX_HEIGHT][20]; +unsigned char bdf_aa_bitmap_line[BDF_MAX_HEIGHT + 2 * BDF_AA_OFFSET][(20 + 2 * BDF_AA_OFFSET) * 8]; + +int bdf_line_state = BDF_LINE_STATE_KEYWORDS; +int bdf_line_bm_line = 0; + +int bdf_font_size; /* point font size */ + +int bdf_font_width; /* FONTBOUNDINGBOX arg 1 */ +int bdf_font_height; /* FONTBOUNDINGBOX arg 2 */ +int bdf_font_x; /* FONTBOUNDINGBOX arg 3 */ +int bdf_font_y; /* FONTBOUNDINGBOX arg 4 */ + +int bdf_capital_A_height; +int bdf_capital_1_height; +int bdf_lower_g_descent; + +int bdf_char_width; /* BBX arg 1 */ +int bdf_char_max_width; +int bdf_char_height; /* BBX arg 2 */ +int bdf_char_ascent; /* defined as BBX arg 2 + BBX arg 4 */ +int bdf_char_xascent; +int bdf_char_xdescent; +int bdf_char_max_ascent; +int bdf_char_max_height; +int bdf_char_x; /* BBX arg 3 */ +int bdf_char_max_x; +int bdf_char_min_x; +int bdf_char_y; /* BBX arg 4 */ +int bdf_char_max_y; +int bdf_char_min_y; + +int bdf_delta_x_default = -1; +int bdf_delta_x = -1; /* DWIDTH arg 1 */ +int bdf_delta_max_x; +int bdf_delta_min_x; +int bdf_delta_y; /* DWIDTH arg 2 */ +int bdf_delta_max_y; +int bdf_delta_min_y; + +int bdf_glyph_data_len; +int bdf_glyph_data_max_len; + +int bdf_encoding; + +int bdf_encoding_65_pos; +int bdf_encoding_97_pos; +int bdf_is_encoding_successfully_done; + +char bdf_info[32000 * 2]; + +int bdf_is_put_glyph_completed = 0; /* indicator, when the glyph has been processed */ + +void bdf_ResetMax(void) { + bdf_char_max_width = 0; + bdf_char_max_height = 0; + bdf_char_max_x = 0; + bdf_char_max_y = 0; + bdf_delta_max_x = 0; + bdf_delta_max_y = 0; + bdf_char_min_x = 0; + bdf_char_min_y = 0; + bdf_delta_min_x = 0; + bdf_delta_min_y = 0; + bdf_glyph_data_max_len = 0; + bdf_char_max_ascent = 0; + bdf_char_xascent = 0; + bdf_char_xdescent = 0; +} + +void bdf_UpdateMax(void) { + if (bdf_char_max_width < bdf_char_width) + bdf_char_max_width = bdf_char_width; + if (bdf_char_max_height < bdf_char_height) + bdf_char_max_height = bdf_char_height; + + if (bdf_char_max_x < bdf_char_x) + bdf_char_max_x = bdf_char_x; + + if (bdf_char_max_y < bdf_char_y) + bdf_char_max_y = bdf_char_y; + + if (bdf_delta_max_x < bdf_delta_x) + bdf_delta_max_x = bdf_delta_x; + if (bdf_delta_max_y < bdf_delta_y) + bdf_delta_max_y = bdf_delta_y; + + if (bdf_char_min_x > bdf_char_x) + bdf_char_min_x = bdf_char_x; + + if (bdf_char_min_y > bdf_char_y) + bdf_char_min_y = bdf_char_y; + + if (bdf_delta_min_x > bdf_delta_x) + bdf_delta_min_x = bdf_delta_x; + if (bdf_delta_min_y > bdf_delta_y) + bdf_delta_min_y = bdf_delta_y; + + if (bdf_glyph_data_max_len < bdf_glyph_data_len) + bdf_glyph_data_max_len = bdf_glyph_data_len; + + if (bdf_char_max_ascent < bdf_char_ascent) + bdf_char_max_ascent = bdf_char_ascent; +} + +void bdf_ShowGlyph(void) { + #ifdef VERBOSE + int x, y, byte, bit; + int gx, gy; + char *p; + gy = bdf_char_height - 1 + bdf_char_y; + printf("bbx %d %d %d %d encoding %d\n", bdf_char_width, bdf_char_height, bdf_char_x, bdf_char_y, bdf_encoding); + for (y = 0; y < bdf_line_bm_line; y++) { + printf("%02d ", gy); + gx = bdf_char_x; + for (x = 0; x < bdf_char_width; x++) { + byte = x >> 3; + bit = 7 - (x & 7); + if ((bdf_bitmap_line[y][byte] & (1 << bit)) == 0) + p = " ."; + else + p = " *"; + if (gy == 0 && gx == 0) + p = " o"; + printf("%s", p); + gx++; + } + printf(" "); + for (x = 0; x < ((bdf_char_width + 7) / 8); x++) printf( "%02X", bdf_bitmap_line[y][x]); + gy--; + printf("\n"); + } + #else + printf("bbx %d %d %d %d encoding %d\n", bdf_char_width, bdf_char_height, bdf_char_x, bdf_char_y, bdf_encoding); + fflush(stdout); + #endif +} + +void bdf_ClearGlyphBuffer(void) { + int x, y; + for (y = 0; y < BDF_MAX_HEIGHT; y++) + for (x = 0; x < 20; x++) bdf_bitmap_line[y][x] = 0; +} + +void bdf_PutGlyph(void) { + int len; + int y, x; + + if (bdf_state == BDF_STATE_ENCODING) { + //if (bdf_char_width == 0 && bdf_char_height == 0) bdf_char_y = 0; + + bdf_char_ascent = bdf_char_height + bdf_char_y; + //printf("h:%d w:%d ascent: %d\n", bdf_char_height, bdf_char_width, bdf_char_ascent); + + if (bdf_encoding == 'A') + bdf_capital_A_height = bdf_char_height; + if (bdf_encoding == '1') + bdf_capital_1_height = bdf_char_height; + + if (bdf_encoding == 'g') + bdf_lower_g_descent = bdf_char_y; + + if (bdf_char_xascent < bdf_capital_A_height) + bdf_char_xascent = bdf_capital_A_height; + if (bdf_char_xascent < bdf_capital_1_height) + bdf_char_xascent = bdf_capital_1_height; + if (bdf_encoding == '(') + if (bdf_char_xascent < bdf_char_ascent) + bdf_char_xascent = bdf_char_ascent; + if (bdf_encoding == '[') + if (bdf_char_xascent < bdf_char_ascent) + bdf_char_xascent = bdf_char_ascent; + + if (bdf_char_xdescent > bdf_lower_g_descent) + bdf_char_xdescent = bdf_lower_g_descent; + if (bdf_encoding == '(') + if (bdf_char_xdescent > bdf_char_y) + bdf_char_xdescent = bdf_char_y; + if (bdf_encoding == '[') + if (bdf_char_xdescent > bdf_char_y) + bdf_char_xdescent = bdf_char_y; + + if (bdf_requested_encoding != bdf_encoding) + return; + + assert( bdf_line_bm_line == bdf_char_height); + + bdf_ShowGlyph(); + #ifdef VERBOSE + bdf_aa_ClearDoShow(); + #endif + + bdf_UpdateMax(); + + if (bdf_font_format <= 1) + len = (bdf_char_width + 7) / 8 * bdf_char_height; + else + len = (bdf_char_width + 2 * BDF_AA_OFFSET + 3) / 4 * (bdf_char_height + 2 * BDF_AA_OFFSET); + if (len > 255) { + fprintf(stderr, "Glyph with encoding %d is too large (%d > 255)\n", bdf_encoding, len); + exit(1); + } + + bdf_glyph_data_len = len; + + /* + format 0 and format 2 + glyph information + offset + 0 BBX width unsigned + 1 BBX height unsigned + 2 data size unsigned (BBX width + 7)/8 * BBX height + 3 DWIDTH signed + 4 BBX xoffset signed + 5 BBX yoffset signed + */ + + if (bdf_font_format == 0) { + data_Put(bdf_char_width); + data_Put(bdf_char_height); + data_Put(bdf_glyph_data_len); + data_Put(bdf_delta_x); + data_Put(bdf_char_x); + data_Put(bdf_char_y); + // data_Put(bdf_encoding); + bdf_is_encoding_successfully_done = 1; + } + else if (bdf_font_format == 2) { + data_Put(bdf_char_width + 2 * BDF_AA_OFFSET); + data_Put(bdf_char_height + 2 * BDF_AA_OFFSET); + data_Put(bdf_glyph_data_len); + data_Put(bdf_delta_x); + data_Put(bdf_char_x - BDF_AA_OFFSET); + data_Put(bdf_char_y - BDF_AA_OFFSET); + // data_Put(bdf_encoding); + bdf_is_encoding_successfully_done = 1; + } + else { + /** + * format 1 + * 0 BBX xoffset signed --> upper 4 Bit + * 0 BBX yoffset signed --> lower 4 Bit + * 1 BBX width unsigned --> upper 4 Bit + * 1 BBX height unsigned --> lower 4 Bit + * 2 data size unsigned -(BBX width + 7)/8 * BBX height --> lower 4 Bit + * 2 DWIDTH signed --> upper 4 Bit + * byte 0 == 255 indicates empty glyph + */ + if (bdf_glyph_data_len < 0 || bdf_glyph_data_len > 15) { + fprintf(stderr, "Glyph with encoding %d does not fit for format 1 (data len = %d)\n", bdf_encoding, bdf_glyph_data_len); + exit(1); + } + if (bdf_delta_x < 0 || bdf_delta_x > 15) { + fprintf(stderr, "Glyph with encoding %d does not fit for format 1 (DWIDTH = %d)\n", bdf_encoding, bdf_delta_x); + exit(1); + } + if (bdf_char_x < 0 || bdf_char_x > 15) { + fprintf(stderr, "Glyph with encoding %d does not fit for format 1 (x-off = %d)\n", bdf_encoding, bdf_char_x); + exit(1); + } + if (bdf_char_y < -2 || bdf_char_y > 13) { + fprintf(stderr, "Glyph with encoding %d does not fit for format 1 (y-off = %d [%d..%d])\n", bdf_encoding, bdf_char_y, bdf_char_min_y, bdf_char_max_y); + exit(1); + } + if (bdf_char_width < 0 || bdf_char_width > 15) { + fprintf(stderr, "Glyph with encoding %d does not fit for format 1 (width = %d)\n", bdf_encoding, bdf_char_width); + exit(1); + } + if (bdf_char_height < 0 || bdf_char_height > 15) { + fprintf(stderr, "Glyph with encoding %d does not fit for format 1 (height = %d)\n", bdf_encoding, bdf_char_height); + exit(1); + } + // data_Put(bdf_encoding); + if (((bdf_char_x << 4) | (bdf_char_y + 2)) == 255) { + fprintf(stderr, "Glyph with encoding %d does not fit for format 1 (skip mark generated)\n", bdf_encoding); + exit(1); + } + data_Put((bdf_char_x << 4) | (bdf_char_y + 2)); + data_Put((bdf_char_width << 4) | bdf_char_height ); + data_Put((bdf_delta_x << 4) | bdf_glyph_data_len ); + bdf_is_encoding_successfully_done = 1; + } + + sprintf(bdf_info + strlen(bdf_info), "/* encoding %d %c, bbx %d %d %d %d asc %d dx %d*/\n", + bdf_encoding, + bdf_encoding > 32 && bdf_encoding <= 'z' ? bdf_encoding : ' ', + bdf_char_width, + bdf_char_height, + bdf_char_x, + bdf_char_y, + bdf_char_ascent, + bdf_delta_x); + + if (bdf_font_format <= 1) { + for (y = 0; y < bdf_char_height; y++) + for (x = 0; x < ((bdf_char_width + 7) / 8); x++) { + data_Put(bdf_bitmap_line[y][x]); + len--; + } + assert( len == 0 ); + bdf_is_put_glyph_completed = 1; + } + else { /* format == 2 */ + int b, cnt; + bdf_aa_Do(); + for (y = 0; y < bdf_char_height + 2 * BDF_AA_OFFSET; y++) { + b = 0; + cnt = 0; + for (x = 0; x < bdf_char_width + 2 * BDF_AA_OFFSET; x++) { + b <<= 2; + b |= bdf_aa_bitmap_line[y][x] & 3; + cnt++; + if (cnt == 4) { + data_Put(b); + b = 0; + cnt = 0; + len--; + } + } + + if (cnt != 0) { + b <<= 2 * (4 - cnt); + data_Put(b); + b = 0; + cnt = 0; + len--; + } + } + assert( len == 0 ); + } + } +} + +/*=========================================================================*/ +/* Glyph Clipping */ + +int bdf_IsColZero(int x) { + int y, byte, bit; + for (y = 0; y < bdf_char_height; y++) { + byte = x >> 3; + bit = 7 - (x & 7); + if ((bdf_bitmap_line[y][byte] & (1 << bit)) != 0) + return 0; + } + return 1; +} + +int bdf_IsRowZero(int y) { + int x, byte, bit; + for (x = 0; x < bdf_char_width; x++) { + byte = x >> 3; + bit = 7 - (x & 7); + if ((bdf_bitmap_line[y][byte] & (1 << bit)) != 0) + return 0; + } + return 1; +} + +void bdf_DeleteFirstCol(void) { + int m = (bdf_char_width + 7) / 8; + int x, y; + for (y = 0; y < bdf_char_height; y++) + for (x = 0; x < m; x++) { + bdf_bitmap_line[y][x] <<= 1; + bdf_bitmap_line[y][x] |= bdf_bitmap_line[y][x + 1] >> 7; + } +} + +void bdf_DeleteFirstRow(void) { + int m = (bdf_char_width + 7) / 8; + int x, y; + for (y = 0; y + 1 < bdf_char_height; y++) + for (x = 0; x < m; x++) + bdf_bitmap_line[y][x] = bdf_bitmap_line[y + 1][x]; +} + +void bdf_ReduceGlyph(void) { + while (bdf_char_width > 0) { + if (bdf_IsColZero(bdf_char_width - 1) == 0) + break; + bdf_char_width--; + } + + while (bdf_char_height > 0) { + if (bdf_IsRowZero(bdf_char_height - 1) == 0) + break; + bdf_line_bm_line--; + bdf_char_height--; + bdf_char_y++; + } + + while (bdf_IsColZero(0) != 0 && bdf_char_width > 0) { + bdf_DeleteFirstCol(); + bdf_char_x++; + bdf_char_width--; + } + + while (bdf_char_height > 0) { + if (bdf_IsRowZero(0) == 0) + break; + bdf_DeleteFirstRow(); + bdf_line_bm_line--; + bdf_char_height--; + } +} + +/*=========================================================================*/ +/* Anti Aliasing / Graylevel Glyph */ + +int bdf_GetXYVal(int x, int y) { + int byte, bit; + + if (x < 0) return 0; + if (y < 0) return 0; + if (x >= bdf_char_width) return 0; + if (y >= bdf_char_height) return 0; + + byte = x >> 3; + bit = 7 - (x & 7); + if ((bdf_bitmap_line[y][byte] & (1 << bit)) != 0) return 1; + return 0; +} + +void bdf_aa_Clear(void) { + int x, y; + for (y = 0; y < BDF_MAX_HEIGHT + 2 * BDF_AA_OFFSET; y++) + for (x = 0; x < (20 + 2 * BDF_AA_OFFSET) * 8; x++) + bdf_aa_bitmap_line[y][x] = 0; +} + +void bdf_aa_SetXYVal(int x, int y, int val) { + bdf_aa_bitmap_line[y][x] = val; +} + +int bdf_aa_matrix[9] = { + 1, 3, 1, + 3, 4, 3, + 1, 3, 1 +}; +int bdf_aa_sum = 20; +int bdf_aa_gray_levels = 4; + +void bdf_aa_Do(void) { + int x, y, val, sx, sy, sum, gray; + bdf_aa_Clear(); + for (y = 0; y < bdf_char_height + 2 * BDF_AA_OFFSET; y++) + for (x = 0; x < bdf_char_width + 2 * BDF_AA_OFFSET; x++) { + if (bdf_GetXYVal(x - BDF_AA_OFFSET, y - BDF_AA_OFFSET) == 0) { + sum = 0; + for (sy = -BDF_AA_OFFSET; sy <= BDF_AA_OFFSET; sy++) + for (sx = -BDF_AA_OFFSET; sx <= BDF_AA_OFFSET; sx++) { + val = bdf_GetXYVal(x + sx - BDF_AA_OFFSET, y + sy - BDF_AA_OFFSET); + val *= bdf_aa_matrix[(sy + BDF_AA_OFFSET) * (2 * BDF_AA_OFFSET + 1) + sx + BDF_AA_OFFSET]; + sum += val; + } + if (sum <= 5) + gray = 0; + else + gray = (sum * (bdf_aa_gray_levels - 1) + (bdf_aa_sum / 2)) / bdf_aa_sum; + if (gray >= bdf_aa_gray_levels) + gray = bdf_aa_gray_levels - 1; + } + else { + gray = bdf_aa_gray_levels - 1; + } + bdf_aa_SetXYVal(x, y, gray); + } +} + +void bdf_aa_Show(void) { + int x, y; + if (bdf_font_format == 2) { + for (y = 0; y < bdf_char_height + 2 * BDF_AA_OFFSET; y++) { + for (x = 0; x < bdf_char_width + 2 * BDF_AA_OFFSET; x++) + switch (bdf_aa_bitmap_line[y][x]) { + case 0: printf("."); break; + case 1: printf("-"); break; + case 2: printf("+"); break; + case 3: printf("#"); break; + } + printf("\n"); + } + } +} + +void bdf_aa_ClearDoShow(void) { + bdf_aa_Do(); + bdf_aa_Show(); +} + +/*=========================================================================*/ +/* Parser */ + +void bdf_ReadLine(const char *s) { + /* + if ( bdf_line_state == BDF_LINE_STATE_BITMAP && bdf_requested_encoding != bdf_encoding && *s != 'E' ) + return; + */ + + if (p_first_char(s) == 0) return; + if (p_skip_space() == 0) return; + + if (bdf_line_state == BDF_LINE_STATE_KEYWORDS) { + p_get_identifier(); + if (strcmp(p_buf, "COPYRIGHT") == 0) { + p_get_any(); + strcpy(bdf_copyright, p_buf); + } + else if (strcmp(p_buf, "FONT") == 0) { + /* p_get_any(); */ + p_get_identifier_with_blank(); + strcpy(bdf_font, p_buf); + } + else if (strcmp(p_buf, "SIZE") == 0) { + bdf_font_size = p_get_val(); + } + else if (strcmp(p_buf, "ENCODING") == 0) { + bdf_encoding = map_UnicodeToU8G(p_get_val()); + bdf_StoreFilePos(bdf_encoding, bdf_last_line_start_pos); + } + else if (strcmp(p_buf, "DWIDTH") == 0) { + bdf_delta_x = p_get_val(); + bdf_delta_y = p_get_val(); + } + else if (strcmp(p_buf, "FONTBOUNDINGBOX") == 0) { + bdf_font_width = p_get_val(); + bdf_font_height = p_get_val(); + bdf_font_x = p_get_val(); + bdf_font_y = p_get_val(); + } + else if (strcmp(p_buf, "BBX") == 0) { + bdf_char_width = p_get_val(); + bdf_char_height = p_get_val(); + bdf_char_x = p_get_val(); + bdf_char_y = p_get_val(); + bdf_char_ascent = bdf_char_height + bdf_char_y; + // printf("h:%d w:%d ascent: %d\n", bdf_char_height, bdf_char_width, bdf_char_ascent); + } + else if (strcmp(p_buf, "CHARS") == 0) { + if (bdf_delta_x < 0) + bdf_delta_x = 0; + if (bdf_delta_x_default < 0) + bdf_delta_x_default = bdf_delta_x; + } + else if (strcmp(p_buf, "STARTCHAR") == 0) { + if (bdf_delta_x_default < 0) + bdf_delta_x_default = 0; + bdf_delta_x = bdf_delta_x_default; + } + else if (strcmp(p_buf, "BITMAP") == 0) { + bdf_line_state = BDF_LINE_STATE_BITMAP; + bdf_line_bm_line = 0; + } + } + else if (bdf_line_state == BDF_LINE_STATE_BITMAP) { + if (strncmp(s, "ENDCHAR", 7) == 0) { + bdf_ReduceGlyph(); + bdf_PutGlyph(); + bdf_line_state = BDF_LINE_STATE_KEYWORDS; + bdf_line_bm_line = 0; + } + else if (bdf_requested_encoding == bdf_encoding) { + int i = 0; + for (;;) { + if (p_current_char < '0') break; + bdf_bitmap_line[bdf_line_bm_line][i] = p_get_hex_byte(); + i++; + } + bdf_line_bm_line++; + assert(bdf_line_bm_line < BDF_MAX_HEIGHT); + } + } +} + +int bdf_ReadFP(FILE *fp) { + static char bdf_line[BDF_LINE_MAX]; + bdf_is_put_glyph_completed = 0; + for (;;) { + bdf_last_line_start_pos = ftell(fp); + if (fgets(bdf_line, BDF_LINE_MAX - 1, fp) == NULL) + break; + bdf_ReadLine(bdf_line); + if (bdf_is_put_glyph_completed != 0) + break; + } + return 1; +} + +int bdf_ReadFile(const char *filename, int encoding) { + int r; + FILE *fp; + fp = fopen(filename, "rb"); + if (fp != NULL) { + bdf_SetFilePos(fp, encoding); + r = bdf_ReadFP(fp); + fclose(fp); + return r; + } + return 0; /* open error */ +} + +void bdf_GenerateFontData(const char *filename, int begin, int end) { + bdf_state = BDF_STATE_FONT_DATA; + bdf_ReadFile(filename, -1); + /** + * font information + * + * offset + * 0 font format + * 1 FONTBOUNDINGBOX width unsigned + * 2 FONTBOUNDINGBOX height unsigned + * 3 FONTBOUNDINGBOX x-offset signed + * 4 FONTBOUNDINGBOX y-offset signed + * 5 Capital A Height unsigned + * 6 position of encoding 65 'A' high byte first + * 8 position of encoding 97 'a' high byte first + */ + data_Put(bdf_font_format); + data_Put(bdf_font_width); + data_Put(bdf_font_height); + data_Put(bdf_font_x); + data_Put(bdf_font_y); + data_Put(bdf_capital_A_height > 0 ? bdf_capital_A_height : bdf_capital_1_height); + data_Put(0); + data_Put(0); + data_Put(0); + data_Put(0); + data_Put(begin); + data_Put(end); /* will be overwritten later */ + data_Put(0); /* lower g descent */ + data_Put(0); /* max ascent */ + data_Put(0); /* min y = descent */ + data_Put(0); /* x ascent */ + data_Put(0); /* x descent */ +} + +void bdf_GenerateGlyph(const char *filename, int encoding) { + bdf_ClearGlyphBuffer(); + bdf_requested_encoding = encoding; + bdf_state = BDF_STATE_ENCODING; + bdf_ReadFile(filename, encoding); +} + +void bdf_Generate(const char *filename, int begin, int end) { + int i; + int last_valid_encoding; + + bdf_encoding_65_pos = 0; + bdf_encoding_97_pos = 0; + + bdf_InitFilePos(); + bdf_ResetMax(); + bdf_info[0] = '\0'; + bdf_font[0] = '\0'; + bdf_copyright[0] = '\0'; + + bdf_GenerateFontData(filename, begin, end); + for (i = begin; i <= end; i++) { + + if (i == 65) bdf_encoding_65_pos = data_pos; + if (i == 97) bdf_encoding_97_pos = data_pos; + + bdf_is_encoding_successfully_done = 0; + if (bdf_IsEncodingAvailable(i)) + bdf_GenerateGlyph(filename, i); + if (bdf_is_encoding_successfully_done == 0) + data_Put(255); /* no char encoding */ + if (bdf_is_encoding_successfully_done != 0) + last_valid_encoding = i; + } + /* data_Put(255); obsolete, not required any more for format 0 */ /* encoding 255, end of font data (format 0) */ + + data_buf[5] = bdf_capital_A_height > 0 ? bdf_capital_A_height : bdf_capital_1_height; + + data_buf[6] = (bdf_encoding_65_pos >> 8); + data_buf[7] = (bdf_encoding_65_pos & 255); + data_buf[8] = (bdf_encoding_97_pos >> 8); + data_buf[9] = (bdf_encoding_97_pos & 255); + + data_buf[12] = bdf_lower_g_descent; + data_buf[13] = bdf_char_max_ascent; + data_buf[14] = bdf_char_min_y; + data_buf[15] = bdf_char_xascent; + data_buf[16] = bdf_char_xdescent; + + if (0) data_buf[11] = last_valid_encoding; + +} + +void bdf_WriteC(const char *outname, const char *fontname) { + int capital_ascent; + FILE *out_fp; + out_fp = fopen(outname, "wb"); + assert( out_fp != NULL ); + + capital_ascent = bdf_capital_A_height > 0 ? bdf_capital_A_height : bdf_capital_1_height; + + fprintf(out_fp, "/*\n"); + fprintf(out_fp, " Fontname: %s\n", bdf_font); + fprintf(out_fp, " Copyright: %s\n", bdf_copyright); + fprintf(out_fp, " Capital A Height: %d, '1' Height: %d\n", bdf_capital_A_height, bdf_capital_1_height); + fprintf(out_fp, " Calculated Max Values w=%2d h=%2d x=%2d y=%2d dx=%2d dy=%2d ascent=%2d len=%2d\n", + bdf_char_max_width, bdf_char_max_height, bdf_char_max_x, bdf_char_max_y, bdf_delta_max_x, bdf_delta_max_y, + bdf_char_max_ascent, bdf_glyph_data_max_len); + fprintf(out_fp, " Font Bounding box w=%2d h=%2d x=%2d y=%2d\n", + bdf_font_width, bdf_font_height, bdf_font_x, bdf_font_y); + fprintf(out_fp, " Calculated Min Values x=%2d y=%2d dx=%2d dy=%2d\n", + bdf_char_min_x, bdf_char_min_y, bdf_delta_min_x, bdf_delta_min_y); + + fprintf(out_fp, " Pure Font ascent =%2d descent=%2d\n", capital_ascent, bdf_lower_g_descent); + fprintf(out_fp, " X Font ascent =%2d descent=%2d\n", bdf_char_xascent, bdf_char_xdescent); + fprintf(out_fp, " Max Font ascent =%2d descent=%2d\n", bdf_char_max_ascent, bdf_char_min_y); + + fprintf(out_fp, "*/\n"); + fprintf(out_fp, "const u8g_fntpgm_uint8_t %s[%d] U8G_FONT_SECTION(\"%s\") = {\n", fontname, data_pos, fontname); + fprintf(out_fp, " "); + data_Write(out_fp, " "); + fprintf(out_fp, "};\n"); + #ifndef BDF2U8G_COMPACT_OUTPUT + fprintf(out_fp, "%s\n", bdf_info); + #endif + + fclose(out_fp); +} + +int ga_argc; +char **ga_argv; + +void ga_remove_arg(void) { + if (ga_argc == 0) return; + ga_argc--; + ga_argv++; +} + +int ga_is_arg(char opt) { + if (ga_argc == 0) return 0; + if (ga_argv[0] == NULL) return 0; + if (ga_argv[0][0] != '-') return 0; + if (ga_argv[0][1] != opt) return 0; + ga_remove_arg(); + return 1; +} + +int main(int argc, char **argv) { + int lower_page = 0; + int upper_page = 1; + int mapping_shift = 0; + int upper_mapping_shift = 0; + int begin = 32; + int end = 255; + + if (argc < 4) { + printf("bdf to u8glib font format converter v" BDF2U8G_VERSION "\n"); + printf("%s [-l page] [-u page] [-s shift] [-S upper-shift] [-b begin] [-e end] [-f format] fontfile fontname outputfile\n", argv[0]); + return 1; + } + + ga_argc = argc; + ga_argv = argv; + ga_remove_arg(); /* remove program name */ + + for (;;) { + if (ga_is_arg('l')) { + lower_page = atoi(ga_argv[0]); + ga_remove_arg(); + } + else if (ga_is_arg('u')) { + upper_page = atoi(ga_argv[0]); + ga_remove_arg(); + } + else if (ga_is_arg('s')) { + mapping_shift = atoi(ga_argv[0]); + ga_remove_arg(); + } + else if (ga_is_arg('S')) { + upper_mapping_shift = atoi(ga_argv[0]); + ga_remove_arg(); + } + else if (ga_is_arg('b')) { + begin = atoi(ga_argv[0]); + ga_remove_arg(); + } + else if (ga_is_arg('e')) { + end = atoi(ga_argv[0]); + ga_remove_arg(); + } + else if (ga_is_arg('f')) { + bdf_font_format = atoi(ga_argv[0]); + ga_remove_arg(); + } + else { + break; + } + } + + printf("encoding range %d..%d\n", begin, end); + + data_Init(); + map_Init(); + map_UpperLowerPage(lower_page, upper_page, mapping_shift, upper_mapping_shift); + + /* + puts(bdf_font); + puts(bdf_copyright); + if (ga_argc < 3) { + printf("from page %d to page %d\n", lower_page, upper_page); + return 1; + } + */ + + bdf_Generate(ga_argv[0], begin, end); + bdf_WriteC(ga_argv[2], ga_argv[1]); + + printf("input file '%s'\n", ga_argv[0]); + printf("u8g font name '%s'\n", ga_argv[1]); + printf("output file '%s'\n", ga_argv[2]); + + return 0; +} diff --git a/buildroot/share/fonts/genallfont.sh b/buildroot/share/fonts/genallfont.sh index ebb99b273fdc..cc92d17d2c42 100755 --- a/buildroot/share/fonts/genallfont.sh +++ b/buildroot/share/fonts/genallfont.sh @@ -24,18 +24,8 @@ my_getpath() { echo -n "${DN}" [[ -z "$FN" ]] || echo -n "/${FN}" } -#DN_EXEC=`echo "$0" | ${EXEC_AWK} -F/ '{b=$1; for (i=2; i < NF; i ++) {b=b "/" $(i)}; print b}'` -DN_EXEC=$(dirname $(my_getpath "$0") ) - -EXEC_WXGGEN="${DN_EXEC}/uxggenpages.sh" -# -# Locate the bdf2u8g command -# -EXEC_BDF2U8G=`which bdf2u8g` -[ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G="${DN_EXEC}/bdf2u8g" -[ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G="${PWD}/bdf2u8g" -[ -x "${EXEC_BDF2U8G}" ] || { EOL=$'\n' ; echo "ERR: Can't find bdf2u8g!${EOL}See uxggenpages.md for bdf2u8g build instructions." >&2 ; exit 1; } +DN_EXEC=$(dirname $(my_getpath "$0") ) # # Get language arguments @@ -55,9 +45,19 @@ OLDWD=`pwd` [[ -f "Configuration.h" ]] || { echo -n "cd to the 'Marlin' folder to run " ; basename $0 ; exit 1; } # -# Compile the 'genpages' command in-place +# Compile the 'genpages.exe' and 'bdf2u8g.exe' commands in-place # -(cd ${DN_EXEC}; cc -o genpages genpages.c getline.c) +if [[ ! -x "${DN_EXEC}/genpages/genpages.exe" ]]; then + echo "Building genpages.exe..." + ( cd ${DN_EXEC}/genpages ; cc -o genpages.exe genpages.c getline.c ) + [[ -x "${DN_EXEC}/genpages/genpages.exe" ]] || { echo "Build of genpages.exe failed" ; exit 1 ; } +fi + +if [[ ! -x "${DN_EXEC}/bdf2u8g/bdf2u8g.exe" ]]; then + echo "Building bdf2u8g.exe..." + ( cd ${DN_EXEC}/bdf2u8g ; make ) + [[ -x "${DN_EXEC}/bdf2u8g/bdf2u8g.exe" ]] || { echo "Build of bdf2u8g.exe failed" ; exit 1 ; } +fi # # By default loop through all languages @@ -67,21 +67,21 @@ LANGS_DEFAULT="an bg ca cz da de el el_CY en es eu fi fr gl hr hu it jp_kana ko_ # # Generate data for language list MARLIN_LANGS or all if not provided # -for LANG in ${LANG_ARG:=$LANGS_DEFAULT} ; do - echo "Generating Marlin language data for '${LANG}'" >&2 - case "$LANG" in +for ALANG in ${LANG_ARG:=$LANGS_DEFAULT} ; do + echo "Generating Marlin language data for '${ALANG}'" >&2 + case "$ALANG" in zh_* ) FONTFILE="wenquanyi_12pt" ;; ko_* ) FONTFILE="${DN_EXEC}/NanumGothic.bdf" ;; * ) FONTFILE="${DN_EXEC}/marlin-6x12-3.bdf" ;; esac - DN_WORK=`mktemp -d` + DN_WORK=$(mktemp -d) cp Configuration.h ${DN_WORK}/ - cp src/lcd/language/language_${LANG}.h ${DN_WORK}/ + cp src/lcd/language/language_${ALANG}.h ${DN_WORK}/ cd "${DN_WORK}" - ${EXEC_WXGGEN} "${FONTFILE}" + ${DN_EXEC}/uxggenpages.sh "${FONTFILE}" $ALANG sed -i fontutf8-data.h -e 's|fonts//|fonts/|g' -e 's|fonts//|fonts/|g' -e 's|[/0-9a-zA-Z_\-]*buildroot/share/fonts|buildroot/share/fonts|' 2>/dev/null cd - >/dev/null - mv ${DN_WORK}/fontutf8-data.h src/lcd/dogm/fontdata/langdata_${LANG}.h + mv ${DN_WORK}/fontutf8-data.h src/lcd/dogm/fontdata/langdata_${ALANG}.h rm -rf ${DN_WORK} done @@ -89,9 +89,10 @@ done # Generate default ASCII font (char range 0-255): # Marlin/src/lcd/dogm/fontdata/fontdata_ISO10646_1.h # +EXEC_BDF2U8G="${DN_EXEC}/bdf2u8g/bdf2u8g.exe" #if [ "${MARLIN_LANGS}" == "${LANGS_DEFAULT}" ]; then if [ 1 = 1 ]; then - DN_WORK=`mktemp -d` + DN_WORK=$(mktemp -d) cd ${DN_WORK} ${EXEC_BDF2U8G} -b 1 -e 127 ${FN_FONT} ISO10646_1_5x7 tmp1.h >/dev/null ${EXEC_BDF2U8G} -b 1 -e 255 ${FN_FONT} ISO10646_1_5x7 tmp2.h >/dev/null @@ -103,7 +104,7 @@ if [ 1 = 1 ]; then cat <src/lcd/dogm/fontdata/fontdata_ISO10646_1.h /** * Marlin 3D Printer Firmware - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm @@ -139,6 +140,4 @@ EOF fi -(cd ${DN_EXEC}; rm genpages) - cd "$OLDWD" diff --git a/buildroot/share/fonts/genpages.c b/buildroot/share/fonts/genpages/genpages.c similarity index 99% rename from buildroot/share/fonts/genpages.c rename to buildroot/share/fonts/genpages/genpages.c index 8009e553fa68..dea5b05c5c80 100644 --- a/buildroot/share/fonts/genpages.c +++ b/buildroot/share/fonts/genpages/genpages.c @@ -66,7 +66,7 @@ wchar_t get_val_utf82uni(uint8_t *pstart) { */ uint8_t* get_utf8_value(uint8_t *pstart, wchar_t *pval) { uint32_t val = 0; - const uint8_t *p = pstart; + uint8_t *p = pstart; /*size_t maxlen = strlen(pstart);*/ assert(NULL != pstart); diff --git a/buildroot/share/fonts/getline.c b/buildroot/share/fonts/genpages/getline.c similarity index 100% rename from buildroot/share/fonts/getline.c rename to buildroot/share/fonts/genpages/getline.c diff --git a/buildroot/share/fonts/getline.h b/buildroot/share/fonts/genpages/getline.h similarity index 100% rename from buildroot/share/fonts/getline.h rename to buildroot/share/fonts/genpages/getline.h diff --git a/buildroot/share/fonts/get-bdf2u8g.sh b/buildroot/share/fonts/get-bdf2u8g.sh deleted file mode 100755 index 5851bf93e3a4..000000000000 --- a/buildroot/share/fonts/get-bdf2u8g.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash - -##################################################################### -# get-bdf2u8g.sh for Marlin -# -# This script downloads, patches, and builds bdf2u8g -# License: CC-SA -# -# Execute from within buildroot/share/fonts -# -##################################################################### - -HERE=$(pwd) - -for CMD in curl unzip patch make; do - which $CMD >/dev/null || { echo "'$CMD' is required for this script." ; exit 1 ; } -done - -[[ $HERE =~ 'buildroot/share/fonts'$ ]] || { echo "Change to buildroot/share/fonts to run $(basename $0)" ; exit 1; } - -# Download u8glib -curl -LJO https://github.com/olikraus/u8glib/archive/master.zip -unzip u8glib-master.zip >/dev/null 2>&1 - -# Patch and build bdf2u8g -cd u8glib-master/tools/font/bdf2u8g -patch -p0 <../../../../u8glib-bdf2u8g.patch bdf2u8g.c >/dev/null 2>&1 -make >/dev/null 2>&1 -mv bdf2u8g ../../../../ - -# Clean up -cd - -rm -rf u8glib-master* - -cd "$HERE" diff --git a/buildroot/share/fonts/make_lang_na.sh b/buildroot/share/fonts/make_lang_na.sh new file mode 100755 index 000000000000..d7453e282093 --- /dev/null +++ b/buildroot/share/fonts/make_lang_na.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# +# make_lang_na.sh +# +# Create non-accented language files given a list of accented language files. +# + +which gsed >/dev/null || { echo "gsed is required for this script." ; exit 1 ; } +which perl >/dev/null || { echo "perl is required for this script." ; exit 1 ; } + +# +# Get language arguments +# +[ $# ] || { echo "One or more language codes (such as 'fr') must be supplied." ; exit 1 ; } + +LANG_ARG="$@" + +# +# Change to working directory 'Marlin' +# +OLDWD=`pwd` +[[ $(basename "$OLDWD") != 'Marlin' && -d "Marlin" ]] && cd Marlin +[[ -f "Configuration.h" ]] || { echo -n "cd to the 'Marlin' folder to run " ; basename $0 ; exit 1; } + +# +# Generate a non-accented language file +# +for ALANG in $LANG_ARG ; do + echo "Generating a non-accented language for '${ALANG}'" >&2 + OUTFILE=src/lcd/language/language_${ALANG}_na.h + cp src/lcd/language/language_${ALANG}.h $OUTFILE + perl -pi -e 's/\s*#define DISPLAY_CHARSET_.+\n*//g' $OUTFILE + perl -pi -e 's/\s*constexpr .+ CHARSIZE.+\n*//g' $OUTFILE + perl -pi -e "s/namespace Language_${ALANG}/#define DISPLAY_CHARSET_ISO10646_1\n#define NOT_EXTENDED_ISO10646_1_5X7\n\nnamespace Language_${ALANG}_na/" $OUTFILE + gsed -i 'y/āáǎàâäēéěèêīíǐìïîōóǒòöôūúǔùǖǘǚǜüûĀÁǍÀĒÉĚÈÊĪÍǏÌÎŌÓǑÒÔŪÚǓÙǕǗǙǛÜÛÇçÑñ/aaaaaaeeeeeiiiiiioooooouuuuuuuuuuAAAAEEEEEIIIIIOOOOOUUUUUUUUUUCcNn/' $OUTFILE + perl -pi -e 's/ß/ss/g' $OUTFILE +done + +cd "$OLDWD" diff --git a/buildroot/share/fonts/u8glib-bdf2u8g.patch b/buildroot/share/fonts/u8glib-bdf2u8g.patch deleted file mode 100644 index 1201e99800e8..000000000000 --- a/buildroot/share/fonts/u8glib-bdf2u8g.patch +++ /dev/null @@ -1,32 +0,0 @@ -178c178 -< fprintf(out_fp, "%d", data_buf[i]); ---- -> fprintf(out_fp, "0x%02x", data_buf[i]); -180c180 -< fprintf(out_fp, "%3d", data_buf[i]); ---- -> fprintf(out_fp, "0x%02x", data_buf[i]); -487c487,488 -< int bdf_delta_x; /* DWIDTH arg 1 */ ---- -> int bdf_delta_x_default = -1; -> int bdf_delta_x = -1; /* DWIDTH arg 1 */ -1097a1099,1114 -> else if ( strcmp(p_buf, "CHARS") == 0 ) -> { -> if (bdf_delta_x < 0) { -> bdf_delta_x = 0; -> } -> if (bdf_delta_x_default < 0) { -> bdf_delta_x_default = bdf_delta_x; -> } -> } -> else if ( strcmp(p_buf, "STARTCHAR") == 0 ) -> { -> if (bdf_delta_x_default < 0) { -> bdf_delta_x_default = 0; -> } -> bdf_delta_x = bdf_delta_x_default; -> } -1293d1309 -< fprintf(out_fp, "#include \"u8g.h\"\n"); diff --git a/buildroot/share/fonts/uxggenpages.sh b/buildroot/share/fonts/uxggenpages.sh index 047d3ae661b9..2d39297b8f30 100755 --- a/buildroot/share/fonts/uxggenpages.sh +++ b/buildroot/share/fonts/uxggenpages.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash ##################################################################### -# genpages.sh for u8g +# uxggenpages.sh for u8g # # This script will generate u8g c files for specified fonts # # Copyright 2015-2018 Yunhui Fu -# License: GPL/BSD +# License: BSD ##################################################################### my_getpath() { @@ -31,16 +31,11 @@ DN_EXEC=$(dirname $(my_getpath "$0") ) ##################################################################### -EXEC_GENPAGES=${DN_EXEC}/genpages -[ -x "${EXEC_GENPAGES}" ] || EXEC_GENPAGES="$(my_getpath ${DN_EXEC}/../../../genpages)" -[ -x "${EXEC_GENPAGES}" ] || EXEC_GENPAGES=$(which genpages) +EXEC_GENPAGES=${DN_EXEC}/genpages/genpages.exe [ -x "${EXEC_GENPAGES}" ] || { echo "Error: genpages not found!" ; exit 1; } -#echo "EXEC_GENPAGES=${EXEC_GENPAGES}" -EXEC_BDF2U8G=${DN_EXEC}/bdf2u8g -[ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G="${DN_EXEC}/../../../bdf2u8g" -[ -x "${EXEC_BDF2U8G}" ] || EXEC_BDF2U8G=$(which bdf2u8g) -[ -x "${EXEC_BDF2U8G}" ] || { echo "Error: bdf2u8g not found!" ; echo "Please compile u8glib/tools/font/bdf2u8g/bdf2u8g and link to it from here!"; exit 1; } +EXEC_BDF2U8G=${DN_EXEC}/bdf2u8g/bdf2u8g.exe +[ -x "${EXEC_BDF2U8G}" ] || { echo "Error: bdf2u8g not found!" ; exit 1; } DN_CUR=$(pwd) DN_DATA=$(pwd)/datatmp @@ -56,6 +51,7 @@ FN_FONT_BASE="marlin-6x12-3" #FN_FONT_BASE=wenquanyi_9pt FN_FONT="${1:-}" +LANG="$2" DN_FONT0=`dirname ${FN_FONT}` DN_FONT="$(my_getpath ${DN_FONT0})" FN_FONT="$(my_getpath "${DN_FONT}")/"`basename ${FN_FONT}` @@ -151,14 +147,14 @@ grep -Hrn _UxGT . | grep '"' \ ${EXEC_BDF2U8G} -u ${PAGE} -b ${BEGIN} -e ${END} ${FN_FONT} fontpage_${PAGE}_${BEGIN}_${END} ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h > /dev/null 2>&1 ; fi ; \ grep -A 10000000000 u8g_fntpgm_uint8_t ${DN_DATA}/fontpage_${PAGE}_${BEGIN}_${END}.h >> tmpa ; \ - echo " FONTDATA_ITEM(${PAGE}, ${BEGIN}, ${END}, fontpage_${PAGE}_${BEGIN}_${END}), // '${UTF8BEGIN}' -- '${UTF8END}'" >> tmpb ;\ + echo " FONTDATA_ITEM(${PAGE}, ${BEGIN}, ${END}, fontpage_${PAGE}_${BEGIN}_${END}), // '${UTF8BEGIN}' -- '${UTF8END}'" >> tmpb ;\ done TMPA=$(cat tmpa) TMPB=$(cat tmpb) EOL=$'\n' -[[ ! "$TMPA" == "" ]] && TMPA="$EOL$TMPA$EOL" +[[ ! "$TMPA" == "" ]] && TMPA="$TMPA$EOL$EOL" [[ ! "$TMPB" == "" ]] && TMPB="$EOL$TMPB$EOL" rm -f tmpa tmpb "proc.awk" @@ -169,8 +165,9 @@ cat <fontutf8-data.h * Contents will be REPLACED by future processing! * Use genallfont.sh to generate font data for updated languages. */ -#include -$TMPA -#define FONTDATA_ITEM(page, begin, end, data) { page, begin, end, COUNT(data), data } -static const uxg_fontinfo_t g_fontinfo[] PROGMEM = {$TMPB}; +#pragma once + +#include "langdata.h" + +${TMPA}static const uxg_fontinfo_t g_fontinfo_${LANG}[] PROGMEM = {${TMPB}}; EOF diff --git a/buildroot/share/git/firstpush b/buildroot/share/git/firstpush index 9a68fc5afde8..db025f6c52cf 100755 --- a/buildroot/share/git/firstpush +++ b/buildroot/share/git/firstpush @@ -16,7 +16,7 @@ BRANCH=${INFO[5]} git push --set-upstream origin HEAD:$BRANCH -OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }') +OPEN=$( which gnome-open xdg-open open | head -n1 ) URL="https://github.com/$FORK/$REPO/commits/$BRANCH" if [ -z "$OPEN" ]; then diff --git a/buildroot/share/git/mfadd b/buildroot/share/git/mfadd index 30be1ec0f748..d6fc07bde08e 100755 --- a/buildroot/share/git/mfadd +++ b/buildroot/share/git/mfadd @@ -29,7 +29,7 @@ REPO=${INFO[2]} set -e -echo "Adding and fetching $USER..." +echo "Adding and fetching $USER/$REPO..." git remote add "$USER" "git@github.com:$USER/$REPO.git" >/dev/null 2>&1 || echo "Remote exists." git fetch "$USER" diff --git a/buildroot/share/git/mfconfig b/buildroot/share/git/mfconfig index 1dd47a427b7d..852885944621 100755 --- a/buildroot/share/git/mfconfig +++ b/buildroot/share/git/mfconfig @@ -52,7 +52,7 @@ if [[ $ACTION == "manual" ]]; then git checkout $IMPORT || exit # Reset from the latest complete state - #git reset --hard bugfix-2.0.x + #git reset --hard bugfix-2.1.x cp "$MARLINREPO/Marlin/"Configuration*.h "$CDEF/" #git add . && git commit -m "Changes from Marlin ($(date '+%Y-%m-%d %H:%M'))." @@ -110,53 +110,15 @@ if [[ $ACTION == "init" ]]; then ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Commit for comparison" >/dev/null # Init Cartesian/SCARA/TPARA configurations to default - echo "- Initializing Cartesian/SCARA/TPARA configs to default state..." + echo "- Initializing configs to default state..." - find "$CEXA" -name $BC ! -path */delta/* -print0 \ + find "$CEXA" -name $BC -print0 \ | while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done - find "$CEXA" -name $AC ! -path */delta/* -print0 \ + find "$CEXA" -name $AC -print0 \ | while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done # DEBUG: Commit the reset for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset Cartesian/SCARA/TPARA configs..." >/dev/null - - # Create base Delta configurations - cp "$CDEF"/* "$CEXA/delta/generic" - - # DEBUG: Commit the reset for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset Generic Delta..." >/dev/null - - cp -R "$TEMP/$CEXA/delta/generic"/Conf* "$CEXA/delta/generic" - - # DEBUG: Commit Generic Delta changes for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Apply Generic Delta..." >/dev/null - - # Reset all Delta configs to the generic version - find "$CEXA/delta" -name $BC ! -path */generic/* -print0 \ - | while read -d $'\0' F ; do cp "$CEXA/delta/generic/$BC" "$F" ; done - find "$CEXA/delta" -name $AC ! -path */generic/* -print0 \ - | while read -d $'\0' F ; do cp "$CEXA/delta/generic/$AC" "$F" ; done - - # DEBUG: Commit the Delta reset for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset Delta configs..." >/dev/null - - # Reset all SCARA configs to the default cartesian - find "$CEXA/SCARA" -name $BC \ - | while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done - find "$CEXA/SCARA" -name $AC \ - | while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done - - # DEBUG: Commit the SCARA reset for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset SCARA..." >/dev/null - - # Reset all TPARA configs to the default cartesian - find "$CEXA/TPARA" -name $BC \ - | while read -d $'\0' F ; do cp "$CDEF/$BC" "$F" ; done - find "$CEXA/TPARA" -name $AC \ - | while read -d $'\0' F ; do cp "$CDEF/$AC" "$F" ; done - - # DEBUG: Commit the TPARA reset for review - ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset TPARA..." >/dev/null + ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset configs..." >/dev/null # Update the %VERSION% in the README.md file VERS=$( echo $EXPORT | $SED 's/release-//' ) @@ -178,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 @@ -187,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/git/mfdoc b/buildroot/share/git/mfdoc index ce214190164f..29f0ec6873f4 100755 --- a/buildroot/share/git/mfdoc +++ b/buildroot/share/git/mfdoc @@ -17,7 +17,7 @@ BRANCH=${INFO[5]} opensite() { URL="http://127.0.0.1:4000/" - OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }') + OPEN=$( which gnome-open xdg-open open | head -n1 ) if [ -z "$OPEN" ]; then echo "Can't find a tool to open the URL:" echo $URL diff --git a/buildroot/share/git/mffp b/buildroot/share/git/mffp index ab4dd4c0b771..6fe52d47e5a3 100755 --- a/buildroot/share/git/mffp +++ b/buildroot/share/git/mffp @@ -3,7 +3,7 @@ # mffp [1|2] [ref] # # Push the given commit (or HEAD) upstream immediately. -# By default: `git push upstream HEAD:bugfix-2.0.x` +# By default: `git push upstream HEAD:bugfix-2.1.x` # usage() { echo "usage: `basename $0` [1|2] [ref]" 1>&2 ; } diff --git a/buildroot/share/git/mfinfo b/buildroot/share/git/mfinfo index 0c2113d92293..c74e48650cbc 100755 --- a/buildroot/share/git/mfinfo +++ b/buildroot/share/git/mfinfo @@ -7,13 +7,13 @@ # - Remote (upstream) Org name (MarlinFirmware) # - Remote (origin) Org name (your Github username) # - Repo Name (Marlin, MarlinDocumentation) -# - PR Target branch (e.g., bugfix-2.0.x) +# - PR Target branch (e.g., bugfix-2.1.x) # - Branch Arg (the branch argument or current branch) # - Current Branch # # Example output # > mfinfo -q ongoing -# MarlinFirmware john.doe Marlin bugfix-2.0.x ongoing bugfix-2.0.x -q +# MarlinFirmware john.doe Marlin bugfix-2.1.x ongoing bugfix-2.1.x -q # CURR=$(git branch 2>/dev/null | grep ^* | sed 's/\* //g') @@ -55,8 +55,8 @@ while [[ $# -gt 0 ]]; do done case "$REPO" in - Marlin ) TARG=bugfix-2.0.x ; ((INDEX == 1)) && TARG=bugfix-1.1.x ; [[ $BRANCH =~ ^[12]$ ]] && USAGE=1 ;; - Configurations ) TARG=import-2.0.x ;; + Marlin ) TARG=bugfix-2.1.x ; ((INDEX == 1)) && TARG=bugfix-1.1.x ; [[ $BRANCH =~ ^[12]$ ]] && USAGE=1 ;; + Configurations ) TARG=import-2.1.x ;; MarlinDocumentation ) TARG=master ;; AutoBuildMarlin ) TARG=master ;; esac diff --git a/buildroot/share/git/mfpr b/buildroot/share/git/mfpr index 230bd2886cf4..c5eb4522c799 100755 --- a/buildroot/share/git/mfpr +++ b/buildroot/share/git/mfpr @@ -23,7 +23,7 @@ OLDBRANCH=${INFO[5]} # See if it's been pushed yet if [ -z "$(git branch -vv | grep ^\* | grep \\[origin)" ]; then firstpush; fi -OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }') +OPEN=$( which gnome-open xdg-open open | head -n1 ) URL="https://github.com/$ORG/$REPO/compare/$TARG...$FORK:$BRANCH?expand=1" if [ -z "$OPEN" ]; then diff --git a/buildroot/share/git/mfprep b/buildroot/share/git/mfprep index 6a8850286153..75776cbba310 100755 --- a/buildroot/share/git/mfprep +++ b/buildroot/share/git/mfprep @@ -2,11 +2,11 @@ # # mfprep tag1 [tag2] # -# Find commits in bugfix-2.0.x that are not yet in 2.0.x. +# Find commits in bugfix-2.1.x that are not yet in 2.1.x. # # Specify a version tag to start from, and optional version tag to end at. -# For bugfix-2.0.x the tag will be prefixed by bf- to distinguish it from the version tag, -# so at every release be sure to create a bf- tag and publish it to origin. +# For bugfix-2.1.x the tag will be prefixed by dev- to distinguish it from the version tag, +# so at every release be sure to create a dev- tag and publish it to origin. # SED=$(which gsed sed | head -n1) @@ -22,12 +22,12 @@ DEST=2.1.x # Validate that the required tags exist -MTAG=`git tag | grep -e "^bf-$TAG1\$"` -[[ -n "$MTAG" ]] || { echo "Can't find tag bf-$TAG1" ; exit 1 ; } +MTAG=`git tag | grep -e "^dev-$TAG1\$"` +[[ -n "$MTAG" ]] || { echo "Can't find tag dev-$TAG1" ; exit 1 ; } MTAG=`git tag | grep -e "^$TAG1\$"` [[ -n "$MTAG" ]] || { echo "Can't find tag $TAG1" ; exit 1 ; } -# Generate log of recent commits for bugfix-2.0.x and DEST +# Generate log of recent commits for bugfix-2.1.x and DEST TMPDIR=`mktemp -d` LOGB="$TMPDIR/log-bf.txt" @@ -35,11 +35,11 @@ LOG2="$TMPDIR/log-2x.txt" TMPF="$TMPDIR/tmp.txt" SCRF="$TMPDIR/update-$DEST.sh" -git checkout bugfix-2.0.x -git log --pretty="[%h] %s" bf-$TAG1..$TAG2 | grep -v '\[cron\]' | $SED '1!G;h;$!d' >"$LOGB" +git checkout bugfix-2.1.x +git log --pretty="[%h] %s" dev-$TAG1..$TAG2 | grep -v '\[cron\]' | $SED '1!G;h;$!d' >"$LOGB" git checkout $DEST -git log --pretty="[%h] %s" $TAG1..$TAG2 | $SED '1!G;h;$!d' >"$LOG2" || { echo "Can't find tag bf-$TAG1" ; exit 1 ; } +git log --pretty="[%h] %s" $TAG1..$TAG2 | $SED '1!G;h;$!d' >"$LOG2" || { echo "Can't find tag dev-$TAG1" ; exit 1 ; } # Go through commit text from DEST removing all matches from the bugfix log diff --git a/buildroot/share/git/mfpub b/buildroot/share/git/mfpub index 6a912e5515b0..6ffe627b925a 100755 --- a/buildroot/share/git/mfpub +++ b/buildroot/share/git/mfpub @@ -45,7 +45,7 @@ git clean -d -f opensite() { URL="$1" - OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }') + OPEN=$( which gnome-open xdg-open open | head -n1 ) if [ -z "$OPEN" ]; then echo "Can't find a tool to open the URL:" echo $URL diff --git a/buildroot/share/scripts/MarlinBinaryProtocol.py b/buildroot/share/scripts/MarlinBinaryProtocol.py index 4887ad991978..ecf9df35e2f5 100644 --- a/buildroot/share/scripts/MarlinBinaryProtocol.py +++ b/buildroot/share/scripts/MarlinBinaryProtocol.py @@ -376,11 +376,13 @@ def close(self): token, data = self.await_response(1000) if token == 'PFT:success': print("File closed") - return + return True elif token == 'PFT:ioerror': print("Client storage device IO error") + return False elif token == 'PFT:invalid': print("No open file") + return False def abort(self): self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.ABORT); @@ -417,12 +419,23 @@ def copy(self, filename, dest_filename, compression, dummy): self.write(data[start:end]) kibs = (( (i+1) * block_size) / 1024) / (millis() + 1 - start_time) * 1000 if (i / blocks) >= dump_pctg: - print("\r{0:2.2f}% {1:4.2f}KiB/s {2} Errors: {3}".format((i / blocks) * 100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression_support else "", self.protocol.errors), end='') + print("\r{0:2.0f}% {1:4.2f}KiB/s {2} Errors: {3}".format((i / blocks) * 100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression_support else "", self.protocol.errors), end='') dump_pctg += 0.1 - print("\r{0:2.2f}% {1:4.2f}KiB/s {2} Errors: {3}".format(100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression_support else "", self.protocol.errors)) # no one likes transfers finishing at 99.8% - - self.close() + if self.protocol.errors > 0: + # Dump last status (errors may not be visible) + print("\r{0:2.0f}% {1:4.2f}KiB/s {2} Errors: {3} - Aborting...".format((i / blocks) * 100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression_support else "", self.protocol.errors), end='') + print("") # New line to break the transfer speed line + self.close() + print("Transfer aborted due to protocol errors") + #raise Exception("Transfer aborted due to protocol errors") + return False; + print("\r{0:2.0f}% {1:4.2f}KiB/s {2} Errors: {3}".format(100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression_support else "", self.protocol.errors)) # no one likes transfers finishing at 99.8% + + if not self.close(): + print("Transfer failed") + return False print("Transfer complete") + return True class EchoProtocol(object): diff --git a/buildroot/share/scripts/config-labels.py b/buildroot/share/scripts/config-labels.py deleted file mode 100755 index 700604e45284..000000000000 --- a/buildroot/share/scripts/config-labels.py +++ /dev/null @@ -1,200 +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/