diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml deleted file mode 100644 index 0e6028a31df7..000000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ /dev/null @@ -1,169 +0,0 @@ -name: 🪲 Report a bug -description: Create a bug report to help improve Marlin Firmware -title: "[BUG] (bug summary)" -body: - - type: markdown - attributes: - value: > - Do you want to ask a question? Are you looking for support? Please use one of the [support links](https://github.com/MarlinFirmware/Marlin/issues/new/choose). - - - type: markdown - attributes: - value: | - **Thank you for reporting a bug in Marlin Firmware!** - - ## Before Reporting a Bug - - - Read and understand Marlin's [Code of Conduct](https://github.com/MarlinFirmware/Marlin/blob/master/.github/code_of_conduct.md). You are expected to comply with it, including treating everyone with respect. - - - Test with the [`bugfix-2.0.x` branch](https://github.com/MarlinFirmware/Marlin/archive/bugfix-2.0.x.zip) to see whether the issue still exists. - - ## Instructions - - Please follow the instructions below. Failure to do so may result in your issue being closed. See [Contributing to Marlin](https://github.com/MarlinFirmware/Marlin/blob/2.0.x/.github/contributing.md) for additional guidelines. - - 1. Provide a good title starting with [BUG]. - 2. Fill out all sections of this bug report form. - 3. Always attach configuration files so we can build and test your setup. - - - type: dropdown - attributes: - label: Did you test the latest `bugfix-2.0.x` code? - description: >- - Always try the latest code to make sure the issue you are reporting is not already fixed. To download - the latest code just [click this link](https://github.com/MarlinFirmware/Marlin/archive/bugfix-2.0.x.zip). - options: - - Yes, and the problem still exists. - - No, but I will test it now! - validations: - required: true - - - type: markdown - attributes: - value: | - # Bug Details - - - type: textarea - attributes: - label: Bug Description - description: >- - Describe the bug in this section. Tell us what you were trying to do and what - happened that you did not expect. Provide a clear and concise description of the - problem and include as many details as possible. - placeholder: | - Marlin doesn't work. - validations: - required: true - - - type: input - attributes: - label: Bug Timeline - description: Is this a new bug or an old issue? When did it first start? - - - type: textarea - attributes: - label: Expected behavior - description: >- - What did you expect to happen? - placeholder: I expected it to move left. - - - type: textarea - attributes: - label: Actual behavior - description: What actually happened instead? - placeholder: It moved right instead of left. - - - type: textarea - attributes: - label: Steps to Reproduce - description: >- - Please describe the steps needed to reproduce the issue. - placeholder: | - 1. [First Step] ... - 2. [Second Step] ... - 3. [and so on] ... - - - type: markdown - attributes: - value: | - # Your Setup - - - type: input - attributes: - label: Version of Marlin Firmware - description: "See the About Menu on the LCD or the output of `M115`. NOTE: For older releases we only patch critical bugs." - validations: - required: true - - - type: input - attributes: - label: Printer model - description: Creality Ender 3, Prusa mini, or Kossel Delta? - - - type: input - attributes: - label: Electronics - description: Stock electronics, upgrade board, or something else? - - - type: input - attributes: - label: Add-ons - description: Please list any hardware add-ons that could be involved. - - - type: dropdown - attributes: - label: Bed Leveling - description: What kind of bed leveling compensation are you using? - options: - - UBL Bilinear mesh - - ABL Bilinear mesh - - ABL Linear grid - - ABL 3-point - - MBL Manual Bed Leveling - - No Bed Leveling - - - type: dropdown - attributes: - label: Your Slicer - description: Do you use Slic3r, Prusa Slicer, Simplify3D, IdeaMaker...? - options: - - Slic3r - - Simplify3D - - Prusa Slicer - - IdeaMaker - - Cura - - Other (explain below) - - - type: dropdown - attributes: - label: Host Software - description: Do you use OctoPrint, Repetier Host, Pronterface...? - options: - - SD Card (headless) - - Repetier Host - - OctoPrint - - Pronterface - - Cura - - Same as my slicer - - Other (explain below) - - - type: markdown - attributes: - value: >- - ## Other things to include - - Please also be sure to include these items to help with troubleshooting: - - * **A ZIP file** containing your `Configuration.h` and `Configuration_adv.h`. - (Please don't paste lengthy configuration text here.) - * **Log output** from the host. (`M111 S247` for maximum logging.) - * **Images or videos** demonstrating the problem, if it helps to make it clear. - * **A G-Code file** that exposes the problem, if not affecting _all_ G-code. - - If you've made any other modifications to the firmware, please describe them in detail in the space provided. - - When pasting formatted text into the box below don't forget to put ` ``` ` (on its own line) before and after to make it readable. - - - type: textarea - attributes: - label: Additional information & file uploads diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index 3f5d6fe5517d..000000000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,20 +0,0 @@ -blank_issues_enabled: false -contact_links: - - name: 📖 Marlin Documentation - url: http://marlinfw.org/ - about: Lots of documentation on installing and using Marlin. - - name: 👤 MarlinFirmware Facebook group - url: https://www.facebook.com/groups/1049718498464482 - about: Please ask and answer questions here. - - name: 🕹 Marlin on Discord - url: https://discord.gg/n5NJ59y - about: Join the Discord server for support and discussion. - - name: 🔗 Marlin Discussion Forum - url: http://forums.reprap.org/list.php?415 - about: A searchable web forum hosted by RepRap dot org. - - name: 📺 Marlin Videos on YouTube - url: https://www.youtube.com/results?search_query=marlin+firmware - about: Tutorials and more from Marlin users all around the world. Great for new users! - - name: 💸 Want to donate? - url: https://www.thinkyhead.com/donate-to-marlin - about: Please take a look at the various options to support Marlin Firmware's development financially! diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml deleted file mode 100644 index df1938ccd84a..000000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: ✨ Request a feature -description: Request a new Marlin Firmware feature -title: "[FR] (feature summary)" -labels: 'T: Feature Request' -body: - - type: markdown - attributes: - value: > - Do you want to ask a question? Are you looking for support? Please use one of the [support links](https://github.com/MarlinFirmware/Marlin/issues/new/choose). - - - type: markdown - attributes: - value: > - **Thank you for requesting a new Marlin Firmware feature!** - - ## Before Requesting a Feature - - - Read and understand Marlin's [Code of Conduct](https://github.com/MarlinFirmware/Marlin/blob/master/.github/code_of_conduct.md). You are expected to comply with it, including treating everyone with respect. - - - Check the latest [`bugfix-2.0.x` branch](https://github.com/MarlinFirmware/Marlin/archive/bugfix-2.0.x.zip) to see if the feature already exists. - - - Before you proceed with your request, please consider if it is necessary to make it into a firmware feature, or if it may be better suited for a slicer or host feature. - - - type: textarea - attributes: - label: Is your feature request related to a problem? Please describe. - description: A clear description of the problem (e.g., "I need X but Marlin can't do it [...]"). - - - type: textarea - attributes: - label: Are you looking for hardware support? - description: Tell us the printer, board, or peripheral that needs support. - - - type: textarea - attributes: - label: Describe the feature you want - description: A clear description of the feature and how you think it should work. - validations: - required: true - - - type: textarea - attributes: - label: Additional context - description: Add any other context or screenshots about the feature request here. diff --git a/.github/contributing.md b/.github/contributing.md index 6bc7b5a00514..24b9dbdf8d0d 100644 --- a/.github/contributing.md +++ b/.github/contributing.md @@ -50,13 +50,13 @@ If chat is more your speed, you can join the MarlinFirmware Discord server: This section guides you through submitting a Bug Report for Marlin. Following these guidelines helps maintainers and the community understand your report, reproduce the behavior, and find related reports. -Before creating a Bug Report, please test the "nightly" development branch, as you might find out that you don't need to create one. When you are creating a Bug Report, please [include as many details as possible](#how-do-i-submit-a-good-bug-report). Fill out [the required template](issue_template.md), the information it asks for helps us resolve issues faster. +Before creating a Bug Report, please test the "nightly" development branch, as you might find out that you don't need to create one. When you are creating a Bug Report, please [include as many details as possible](#how-do-i-submit-a-good-bug-report). Fill out [the required template](ISSUE_TEMPLATE/bug_report.yml), the information it asks for helps us resolve issues faster. > **Note:** Regressions can happen. If you find a **Closed** issue that seems like your issue, go ahead and open a new issue and include a link to the original issue in the body of your new one. All you need to create a link is the issue number, preceded by #. For example, #8888. #### How Do I Submit A (Good) Bug Report? -Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/). Use the New Issue button to create an issue and provide the following information by filling in [the template](issue_template.md). +Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/). Use the New Issue button to create an issue and provide the following information by filling in [the template](ISSUE_TEMPLATE/bug_report.yml). Explain the problem and include additional details to help maintainers reproduce the problem: @@ -88,12 +88,12 @@ Include details about your configuration and environment: This section guides you through submitting a suggestion for Marlin, including completely new features and minor improvements to existing functionality. Following these guidelines helps maintainers and the community understand your suggestion and find related suggestions. -Before creating a suggestion, please check [this list](#before-submitting-a-suggestion) as you might find out that you don't need to create one. When you are creating an enhancement suggestion, please [include as many details as possible](#how-do-i-submit-a-good-enhancement-suggestion). Fill in [the template](issue_template.md), including the steps that you imagine you would take if the feature you're requesting existed. +Before creating a suggestion, please check [this list](https://github.com/MarlinFirmware/Marlin/issues?q=is%3Aopen+is%3Aissue+label%3A%22T%3A+Feature+Request%22) as you might find out that you don't need to create one. When you are creating an enhancement suggestion, please [include as many details as possible](#how-do-i-submit-a-good-feature-request). Fill in [the template](ISSUE_TEMPLATE/feature_request.yml), including the steps that you imagine you would take if the feature you're requesting existed. #### Before Submitting a Feature Request * **Check the [Marlin website](https://marlinfw.org/)** for tips — you might discover that the feature is already included. Most importantly, check if you're using [the latest version of Marlin](https://github.com/MarlinFirmware/Marlin/releases) and if you can get the desired behavior by changing [Marlin's config settings](https://marlinfw.org/docs/configuration/configuration.html). -* **Perform a [cursory search](https://github.com/MarlinFirmware/Marlin/issues?q=is%3Aissue)** to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one. +* **Perform a [cursory search](https://github.com/MarlinFirmware/Marlin/issues?q=is%3Aopen+is%3Aissue+label%3A%22T%3A+Feature+Request%22)** to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one. #### How Do I Submit A (Good) Feature Request? @@ -116,7 +116,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-1.1.x` and/or `bugfix-2.0.x`) and never to release branches (e.g., `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.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. * Fill in [the required template](pull_request_template.md). * Don't include issue numbers in the PR title. diff --git a/.github/issue_template.md b/.github/issue_template.md deleted file mode 100644 index 6cb34b8f588a..000000000000 --- a/.github/issue_template.md +++ /dev/null @@ -1,35 +0,0 @@ - - -### Description - - - -### Steps to Reproduce - - - -1. [First Step] -2. [Second Step] -3. [and so on...] - -**Expected behavior:** [What you expect to happen] - -**Actual behavior:** [What actually happens] - -#### Additional Information - -* Include a ZIP file containing your `Configuration.h` and `Configuration_adv.h` files. -* Provide pictures or links to videos that clearly demonstrate the issue. -* See [How Can I Contribute](#how-can-i-contribute) for additional guidelines. diff --git a/.github/lock.yml b/.github/lock.yml deleted file mode 100644 index c5ceff66b0a7..000000000000 --- a/.github/lock.yml +++ /dev/null @@ -1,40 +0,0 @@ -# -# Configuration for Lock Threads - https://github.com/dessant/lock-threads-app -# - -# Number of days of inactivity before a closed issue or pull request is locked -daysUntilLock: 60 - -# Skip issues and pull requests created before a given timestamp. Timestamp must -# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable -skipCreatedBefore: false - -# Issues and pull requests with these labels will be ignored. Set to `[]` to disable -exemptLabels: [ 'no-locking' ] - -# Label to add before locking, such as `outdated`. Set to `false` to disable -lockLabel: false - -# Comment to post before locking. Set to `false` to disable -lockComment: > - This thread has been automatically locked since there has not been - any recent activity after it was closed. Please open a new issue for - related bugs. - -# Assign `resolved` as the reason for locking. Set to `false` to disable -setLockReason: true - -# Limit to only `issues` or `pulls` -# only: issues - -# Optionally, specify configuration settings just for `issues` or `pulls` -# issues: -# exemptLabels: -# - help-wanted -# lockLabel: outdated - -# pulls: -# daysUntilLock: 30 - -# Repository to extend settings from -# _extends: repo diff --git a/.github/workflows/bump-date.yml b/.github/workflows/bump-date.yml deleted file mode 100644 index a1942777d1ae..000000000000 --- a/.github/workflows/bump-date.yml +++ /dev/null @@ -1,36 +0,0 @@ -# -# bump-date.yml -# Bump the distribution date once per day -# - -name: Bump Distribution Date - -on: - schedule: - - cron: '0 0 * * *' - -jobs: - bump_date: - name: Bump Distribution Date - if: github.repository == 'MarlinFirmware/Marlin' - - runs-on: ubuntu-latest - - steps: - - - name: Check out bugfix-2.0.x - uses: actions/checkout@v2 - with: - ref: bugfix-2.0.x - - - name: Bump Distribution Date - run: | - # Inline Bump Script - DIST=$( date +"%Y-%m-%d" ) - eval "sed -E -i 's/(#define +STRING_DISTRIBUTION_DATE) .*$/\1 \"$DIST\"/g' Marlin/src/inc/Version.h" && \ - eval "sed -E -i 's/(#define +STRING_DISTRIBUTION_DATE) .*$/\1 \"$DIST\"/g' Marlin/Version.h" && \ - git config user.name "${GITHUB_ACTOR}" && \ - git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" && \ - git add . && \ - git commit -m "[cron] Bump distribution date ($DIST)" && \ - git push diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml deleted file mode 100644 index 93a110f270d3..000000000000 --- a/.github/workflows/check-pr.yml +++ /dev/null @@ -1,33 +0,0 @@ -# -# check-pr.yml -# Close PRs directed at release branches -# - -name: PR Bad Target - -on: - pull_request_target: - types: [opened] - branches: - - 1.0.x - - 1.1.x - - 2.0.x - -jobs: - bad_target: - name: PR Bad Target - if: github.repository == 'MarlinFirmware/Marlin' - - runs-on: ubuntu-latest - - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: > - Thanks for your contribution! Unfortunately we can't accept PRs directed at release branches. We make patches to the bugfix branches and only later do we push them out as releases. - - Please redo this PR starting with the `bugfix-2.0.x` branch and be careful to target `bugfix-2.0.x` when resubmitting the PR. - - It may help to set your fork's default branch to `bugfix-2.0.x`. - - See [this page](http://marlinfw.org/docs/development/getting_started_pull_requests.html) for full instructions. diff --git a/.github/workflows/clean-closed.yml b/.github/workflows/clean-closed.yml deleted file mode 100644 index befec4498f25..000000000000 --- a/.github/workflows/clean-closed.yml +++ /dev/null @@ -1,39 +0,0 @@ -# -# clean-closed.yml -# Remove obsolete labels when an Issue or PR is closed -# - -name: Clean Closed - -on: - pull_request: - types: [closed] - issues: - types: [closed] - -jobs: - remove_label: - runs-on: ubuntu-latest - - strategy: - matrix: - label: - - "S: Don't Merge" - - "S: Hold for 2.1" - - "S: Please Merge" - - "S: Please Test" - - "help wanted" - - "Needs: Discussion" - - "Needs: Documentation" - - "Needs: More Data" - - "Needs: Patch" - - "Needs: Testing" - - "Needs: Work" - - steps: - - uses: actions/checkout@v2 - - name: Remove Labels - uses: actions-ecosystem/action-remove-labels@v1 - with: - github_token: ${{ github.token }} - labels: ${{ matrix.label }} diff --git a/.github/workflows/close-stale.yml b/.github/workflows/close-stale.yml deleted file mode 100644 index f017907d2934..000000000000 --- a/.github/workflows/close-stale.yml +++ /dev/null @@ -1,28 +0,0 @@ -# -# close-stale.yml -# Close open issues after a period of inactivity -# - -name: Close Stale Issues - -on: - schedule: - - cron: "22 1 * * *" - -jobs: - stale: - name: Close Stale Issues - if: github.repository == 'MarlinFirmware/Marlin' - - runs-on: ubuntu-latest - - steps: - - uses: actions/stale@v3 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: 'This issue has had no activity in the last 60 days. Please add a reply if you want to keep this issue active, otherwise it will be automatically closed within 10 days.' - days-before-stale: 60 - days-before-close: 10 - stale-issue-label: 'stale-closing-soon' - exempt-all-assignees: true - exempt-issue-labels: 'Bug: Confirmed !,T: Feature Request,Needs: Discussion,Needs: Documentation,Needs: More Data,Needs: Patch,Needs: Work,Needs: Testing,help wanted,no-locking' diff --git a/.github/workflows/lock-closed.yml b/.github/workflows/lock-closed.yml deleted file mode 100644 index 81145688288b..000000000000 --- a/.github/workflows/lock-closed.yml +++ /dev/null @@ -1,32 +0,0 @@ -# -# lock-closed.yml -# Lock closed issues after a period of inactivity -# - -name: Lock Closed Issues - -on: - schedule: - - cron: '0 1/13 * * *' - -jobs: - lock: - name: Lock Closed Issues - if: github.repository == 'MarlinFirmware/Marlin' - - runs-on: ubuntu-latest - - steps: - - uses: dessant/lock-threads@v2 - with: - github-token: ${{ github.token }} - process-only: 'issues' - issue-lock-inactive-days: '60' - issue-exclude-created-before: '2017-07-01T00:00:00Z' - issue-exclude-labels: 'no-locking' - issue-lock-labels: '' - issue-lock-comment: > - This issue has been automatically locked since there - has not been any recent activity after it was closed. - Please open a new issue for related bugs. - issue-lock-reason: '' diff --git a/.github/workflows/test-builds.yml b/.github/workflows/test-builds.yml deleted file mode 100644 index f5ce466d9051..000000000000 --- a/.github/workflows/test-builds.yml +++ /dev/null @@ -1,145 +0,0 @@ -# -# test-builds.yml -# Do test builds to catch compile errors -# - -name: CI - -on: - pull_request: - branches: - - bugfix-2.0.x - paths-ignore: - - config/** - - data/** - - docs/** - - '**/*.md' - push: - branches: - - bugfix-2.0.x - paths-ignore: - - config/** - - data/** - - docs/** - - '**/*.md' - -jobs: - test_builds: - name: Run All Tests - if: github.repository == 'MarlinFirmware/Marlin' - - runs-on: ubuntu-latest - - strategy: - matrix: - test-platform: - # Base Environments - - - DUE - - DUE_archim - - esp32 - - linux_native - - mega2560 - - at90usb1286_dfu - - teensy31 - - teensy35 - - teensy41 - - SAMD51_grandcentral_m4 - - # Extended AVR Environments - - - FYSETC_F6 - - mega1280 - - rambo - - sanguino1284p - - sanguino644p - - # STM32F1 (Maple) Environments - - #- STM32F103RC_btt_maple - - STM32F103RC_btt_USB_maple - - STM32F103RC_fysetc_maple - - STM32F103RC_meeb - - jgaurora_a5s_a1_maple - - STM32F103VE_longer_maple - #- mks_robin_maple - - mks_robin_lite_maple - - mks_robin_pro_maple - #- mks_robin_nano35_maple - #- STM32F103RET6_creality_maple - - STM32F103VE_ZM3E4V2_USB_maple - - # STM32 (ST) Environments - - - STM32F103RC_btt - #- STM32F103RC_btt_USB - - STM32F103RE_btt - - STM32F103RE_btt_USB - - STM32F103RET6_creality - - STM32F103VE_longer - - STM32F407VE_black - - STM32F401VE_STEVAL - - BIGTREE_BTT002 - - BIGTREE_SKR_PRO - - BIGTREE_GTR_V1_0 - - mks_robin - - ARMED - - FYSETC_S6 - - STM32F070CB_malyan - - STM32F070RB_malyan - - malyan_M300 - - FLYF407ZG - - rumba32 - - LERDGEX - - LERDGEK - - mks_robin_nano35 - - NUCLEO_F767ZI - - REMRAM_V1 - - BTT_SKR_SE_BX - - chitu_f103 - - Index_Mobo_Rev03 - - # Put lengthy tests last - - - LPC1768 - - LPC1769 - - # Non-working environment tests - #- at90usb1286_cdc - #- STM32F103CB_malyan - #- STM32F103RE - #- mks_robin_mini - - steps: - - - name: Check out the PR - uses: actions/checkout@v2 - - - name: Cache pip - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Cache PlatformIO - uses: actions/cache@v2 - with: - path: ~/.platformio - key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} - - - name: Select Python 3.7 - uses: actions/setup-python@v2 - with: - python-version: '3.7' # Version range or exact version of a Python version to use, using semvers version range syntax. - architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified - - - name: Install PlatformIO - run: | - pip install -U https://github.com/platformio/platformio-core/archive/develop.zip - platformio update - - - name: Run ${{ matrix.test-platform }} Tests - run: | - make tests-single-ci TEST_TARGET=${{ matrix.test-platform }} diff --git a/.github/workflows/unlock-reopened.yml b/.github/workflows/unlock-reopened.yml deleted file mode 100644 index 614ef3fab297..000000000000 --- a/.github/workflows/unlock-reopened.yml +++ /dev/null @@ -1,22 +0,0 @@ -# -# unlock-reopened.yml -# Unlock an issue whenever it is re-opened -# - -name: "Unlock reopened issue" - -on: - issues: - types: [reopened] - -jobs: - unlock: - name: Unlock Reopened - if: github.repository == 'MarlinFirmware/Marlin' - - runs-on: ubuntu-latest - - steps: - - uses: OSDKDev/unlock-issues@v1.1 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.gitignore b/.gitignore index 72fd117bd234..0b852d767325 100755 --- a/.gitignore +++ b/.gitignore @@ -41,7 +41,6 @@ applet/ *.rej *.bak *.idea -*.s *.i *.ii *.swp @@ -141,11 +140,8 @@ __vm/ vc-fileutils.settings # Visual Studio Code -.vscode -.vscode/.browse.c_cpp.db* -.vscode/c_cpp_properties.json -.vscode/launch.json -.vscode/*.db +.vscode/* +!.vscode/extensions.json #Simulation imgui.ini diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000000..f495d14f53e8 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,11 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "marlinfirmware.auto-build", + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index f0fc4dd7d608..c3b176d245ab 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -35,7 +35,7 @@ * * Advanced settings can be found in Configuration_adv.h */ -#define CONFIGURATION_H_VERSION 02000903 +#define CONFIGURATION_H_VERSION 02000904 //=========================================================================== //============================= Getting Started ============================= @@ -150,20 +150,40 @@ //#define MACHINE_UUID "00000000-0000-0000-0000-000000000000" /** - * Define the number of coordinated linear axes. - * See https://github.com/DerAndere1/Marlin/wiki - * Each linear axis gets its own stepper control and endstop: + * Stepper Drivers * - * Steppers: *_STEP_PIN, *_ENABLE_PIN, *_DIR_PIN, *_ENABLE_ON - * Endstops: *_STOP_PIN, USE_*MIN_PLUG, USE_*MAX_PLUG - * Axes: *_MIN_POS, *_MAX_POS, INVERT_*_DIR - * Planner: DEFAULT_AXIS_STEPS_PER_UNIT, DEFAULT_MAX_FEEDRATE - * DEFAULT_MAX_ACCELERATION, AXIS_RELATIVE_MODES, - * MICROSTEP_MODES, MANUAL_FEEDRATE + * These settings allow Marlin to tune stepper driver timing and enable advanced options for + * stepper drivers that support them. You may also override timing options in Configuration_adv.h. * - * :[3, 4, 5, 6] + * 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, + * 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'] */ -//#define LINEAR_AXES 3 +#define X_DRIVER_TYPE A4988 +#define Y_DRIVER_TYPE A4988 +#define Z_DRIVER_TYPE A4988 +//#define X2_DRIVER_TYPE A4988 +//#define Y2_DRIVER_TYPE A4988 +//#define Z2_DRIVER_TYPE A4988 +//#define Z3_DRIVER_TYPE A4988 +//#define Z4_DRIVER_TYPE A4988 +//#define I_DRIVER_TYPE A4988 +//#define J_DRIVER_TYPE A4988 +//#define K_DRIVER_TYPE A4988 +#define E0_DRIVER_TYPE A4988 +//#define E1_DRIVER_TYPE A4988 +//#define E2_DRIVER_TYPE A4988 +//#define E3_DRIVER_TYPE A4988 +//#define E4_DRIVER_TYPE A4988 +//#define E5_DRIVER_TYPE A4988 +//#define E6_DRIVER_TYPE A4988 +//#define E7_DRIVER_TYPE A4988 /** * Axis codes for additional axes: @@ -178,14 +198,16 @@ * Regardless of the settings, firmware-internal axis IDs are * I (AXIS4), J (AXIS5), K (AXIS6). */ -#if LINEAR_AXES >= 4 +#ifdef I_DRIVER_TYPE #define AXIS4_NAME 'A' // :['A', 'B', 'C', 'U', 'V', 'W'] #endif -#if LINEAR_AXES >= 5 - #define AXIS5_NAME 'B' // :['A', 'B', 'C', 'U', 'V', 'W'] +#ifdef J_DRIVER_TYPE + #define AXIS5_NAME 'B' // :['B', 'C', 'U', 'V', 'W'] + #define AXIS5_ROTATES #endif -#if LINEAR_AXES >= 6 - #define AXIS6_NAME 'C' // :['A', 'B', 'C', 'U', 'V', 'W'] +#ifdef K_DRIVER_TYPE + #define AXIS6_NAME 'C' // :['C', 'U', 'V', 'W'] + #define AXIS6_ROTATES #endif // @section extruder @@ -371,8 +393,12 @@ //#define PS_OFF_SOUND // Beep 1s when power off #define PSU_ACTIVE_STATE LOW // Set 'LOW' for ATX, 'HIGH' for X-Box - //#define PSU_DEFAULT_OFF // Keep power off until enabled directly with M80 - //#define PSU_POWERUP_DELAY 250 // (ms) Delay for the PSU to warm up to full power + //#define PSU_DEFAULT_OFF // Keep power off until enabled directly with M80 + //#define PSU_POWERUP_DELAY 250 // (ms) Delay for the PSU to warm up to full power + //#define LED_POWEROFF_TIMEOUT 10000 // (ms) Turn off LEDs after power-off, with this amount of delay + + //#define POWER_OFF_TIMER // Enable M81 D to power off after a delay + //#define POWER_OFF_WAIT_FOR_COOLDOWN // Enable M81 S to power off only after cooldown //#define PSU_POWERUP_GCODE "M355 S1" // G-code to run after power-on (e.g., case light on) //#define PSU_POWEROFF_GCODE "M355 S0" // G-code to run before power-off (e.g., case light off) @@ -384,12 +410,14 @@ #define AUTO_POWER_CONTROLLERFAN #define AUTO_POWER_CHAMBER_FAN #define AUTO_POWER_COOLER_FAN - //#define AUTO_POWER_E_TEMP 50 // (°C) Turn on PSU if any extruder is over this temperature - //#define AUTO_POWER_CHAMBER_TEMP 30 // (°C) Turn on PSU if the chamber is over this temperature - //#define AUTO_POWER_COOLER_TEMP 26 // (°C) Turn on PSU if the cooler is over this temperature #define POWER_TIMEOUT 30 // (s) Turn off power if the machine is idle for this duration //#define POWER_OFF_DELAY 60 // (s) Delay of poweroff after M81 command. Useful to let fans run for extra time. #endif + #if EITHER(AUTO_POWER_CONTROL, POWER_OFF_WAIT_FOR_COOLDOWN) + //#define AUTO_POWER_E_TEMP 50 // (°C) PSU on if any extruder is over this temperature + //#define AUTO_POWER_CHAMBER_TEMP 30 // (°C) PSU on if the chamber is over this temperature + //#define AUTO_POWER_COOLER_TEMP 26 // (°C) PSU on if the cooler is over this temperature + #endif #endif //=========================================================================== @@ -431,6 +459,9 @@ * 5 : 100kΩ ATC Semitec 104GT-2/104NT-4-R025H42G - Used in ParCan, J-Head, and E3D, SliceEngineering 300°C * 501 : 100kΩ Zonestar - Tronxy X3A * 502 : 100kΩ Zonestar - used by hot bed in Zonestar Průša P802M + * 503 : 100kΩ Zonestar (Z8XM2) Heated Bed thermistor + * 504 : 100kΩ Zonestar P802QR2 (Part# QWG-104F-B3950) Hotend Thermistor + * 505 : 100kΩ Zonestar P802QR2 (Part# QWG-104F-3950) Bed Thermistor * 512 : 100kΩ RPW-Ultra hotend * 6 : 100kΩ EPCOS - Not as accurate as table #1 (created using a fluke thermocouple) * 7 : 100kΩ Honeywell 135-104LAG-J01 @@ -450,6 +481,7 @@ * 61 : 100kΩ Formbot/Vivedino 350°C Thermistor - beta 3950 * 66 : 4.7MΩ Dyze Design High Temperature Thermistor * 67 : 500kΩ SliceEngineering 450°C Thermistor + * 68 : PT100 amplifier board from Dyze Design * 70 : 100kΩ bq Hephestos 2 * 75 : 100kΩ Generic Silicon Heat Pad with NTC100K MGB18-104F39050L32 * 2000 : 100kΩ Ultimachine Rambo TDK NTCG104LH104KT1 NTC100K motherboard Thermistor @@ -579,19 +611,19 @@ //=========================================================================== //============================= PID Settings ================================ //=========================================================================== -// PID Tuning Guide here: https://reprap.org/wiki/PID_Tuning -// Comment the following line to disable PID and enable bang-bang. -#define PIDTEMP +// 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 +//#define MPCTEMP // ** EXPERIMENTAL ** + #define BANG_MAX 255 // Limits current to nozzle while in bang-bang mode; 255=full current #define PID_MAX BANG_MAX // Limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current #define PID_K1 0.95 // Smoothing factor within any PID loop #if ENABLED(PIDTEMP) - //#define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM) - //#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM) //#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders) - // Set/get with gcode: M301 E[extruder number, 0-2] + // Set/get with G-code: M301 E[extruder number, 0-2] #if ENABLED(PID_PARAMS_PER_HOTEND) // Specify up to one value per hotend here, according to your setup. @@ -604,7 +636,49 @@ #define DEFAULT_Ki 1.08 #define DEFAULT_Kd 114.00 #endif -#endif // PIDTEMP +#endif + +/** + * Model Predictive Control for hotend + * + * 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. + */ +#if ENABLED(MPCTEMP) + //#define MPC_EDIT_MENU // Add MPC editing to the "Advanced Settings" menu. (~1300 bytes of flash) + //#define MPC_AUTOTUNE_MENU // Add MPC auto-tuning to the "Advanced Settings" menu. (~350 bytes of flash) + + #define MPC_MAX BANG_MAX // (0..255) Current to nozzle while MPC is active. + #define MPC_HEATER_POWER { 40.0f } // (W) Heat cartridge powers. + + #define MPC_INCLUDE_FAN // Model the fan speed? + + // Measured physical constants from M306 + #define MPC_BLOCK_HEAT_CAPACITY { 16.7f } // (J/K) Heat block heat capacities. + #define MPC_SENSOR_RESPONSIVENESS { 0.22f } // (K/s per ∆K) Rate of change of sensor temperature from heat block. + #define MPC_AMBIENT_XFER_COEFF { 0.068f } // (W/K) Heat transfer coefficients from heat block to room air with fan off. + #if ENABLED(MPC_INCLUDE_FAN) + #define MPC_AMBIENT_XFER_COEFF_FAN255 { 0.097f } // (W/K) Heat transfer coefficients from heat block to room air with fan on full. + #endif + + // For one fan and multiple hotends MPC needs to know how to apply the fan cooling effect. + #if ENABLED(MPC_INCLUDE_FAN) + //#define MPC_FAN_0_ALL_HOTENDS + //#define MPC_FAN_0_ACTIVE_HOTEND + #endif + + #define FILAMENT_HEAT_CAPACITY_PERMM { 5.6e-3f } // 0.0056 J/K/mm for 1.75mm PLA (0.0149 J/K/mm for 2.85mm PLA). + //#define FILAMENT_HEAT_CAPACITY_PERMM { 3.6e-3f } // 0.0036 J/K/mm for 1.75mm PETG (0.0094 J/K/mm for 2.85mm PETG). + + // Advanced options + #define MPC_SMOOTHING_FACTOR 0.5f // (0.0...1.0) Noisy temperature sensors may need a lower value for stabilization. + #define MPC_MIN_AMBIENT_CHANGE 1.0f // (K/s) Modeled ambient temperature rate of change, when correcting model inaccuracies. + #define MPC_STEADYSTATE 0.5f // (K/s) Temperature change rate for steady state logic to be enforced. + + #define MPC_TUNING_POS { X_CENTER, Y_CENTER, 1.0f } // (mm) M306 Autotuning position, ideally bed center at first layer height. + #define MPC_TUNING_END_Z 10.0f // (mm) M306 Autotuning final Z position. +#endif //=========================================================================== //====================== PID > Bed Temperature Control ====================== @@ -698,6 +772,9 @@ //#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 // is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max. + + //#define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of flash) + //#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of flash) #endif // @section extruder @@ -843,44 +920,6 @@ #define K_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop. #define Z_MIN_PROBE_ENDSTOP_INVERTING false // Set to true to invert the logic of the probe. -/** - * Stepper Drivers - * - * These settings allow Marlin to tune stepper driver timing and enable advanced options for - * stepper drivers that support them. You may also override timing options in Configuration_adv.h. - * - * A4988 is assumed for unspecified drivers. - * - * 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, - * 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'] - */ -#define X_DRIVER_TYPE A4988 -#define Y_DRIVER_TYPE A4988 -#define Z_DRIVER_TYPE A4988 -//#define X2_DRIVER_TYPE A4988 -//#define Y2_DRIVER_TYPE A4988 -//#define Z2_DRIVER_TYPE A4988 -//#define Z3_DRIVER_TYPE A4988 -//#define Z4_DRIVER_TYPE A4988 -//#define I_DRIVER_TYPE A4988 -//#define J_DRIVER_TYPE A4988 -//#define K_DRIVER_TYPE A4988 -#define E0_DRIVER_TYPE A4988 -//#define E1_DRIVER_TYPE A4988 -//#define E2_DRIVER_TYPE A4988 -//#define E3_DRIVER_TYPE A4988 -//#define E4_DRIVER_TYPE A4988 -//#define E5_DRIVER_TYPE A4988 -//#define E6_DRIVER_TYPE A4988 -//#define E7_DRIVER_TYPE A4988 - // Enable this feature if all enabled endstop pins are interrupt-capable. // This will remove the need to poll the interrupt pins, saving many CPU cycles. //#define ENDSTOP_INTERRUPTS_FEATURE @@ -1089,6 +1128,17 @@ */ //#define BLTOUCH +/** + * MagLev V4 probe by MDD + * + * This probe is deployed and activated by powering a built-in electromagnet. + */ +//#define MAGLEV4 +#if ENABLED(MAGLEV4) + //#define MAGLEV_TRIGGER_PIN 11 // Set to the connected digital output + #define MAGLEV_TRIGGER_DELAY 15 // Changing this risks overheating the coil +#endif + /** * Touch-MI Probe by hotends.fr * @@ -1685,18 +1735,18 @@ #endif // Add a menu item to move between bed corners for manual bed adjustment -//#define LEVEL_BED_CORNERS - -#if ENABLED(LEVEL_BED_CORNERS) - #define LEVEL_CORNERS_INSET_LFRB { 30, 30, 30, 30 } // (mm) Left, Front, Right, Back insets - #define LEVEL_CORNERS_HEIGHT 0.0 // (mm) Z height of nozzle at leveling points - #define LEVEL_CORNERS_Z_HOP 4.0 // (mm) Z height of nozzle between leveling points - //#define LEVEL_CENTER_TOO // Move to the center after the last corner - //#define LEVEL_CORNERS_USE_PROBE - #if ENABLED(LEVEL_CORNERS_USE_PROBE) - #define LEVEL_CORNERS_PROBE_TOLERANCE 0.1 - #define LEVEL_CORNERS_VERIFY_RAISED // After adjustment triggers the probe, re-probe to verify - //#define LEVEL_CORNERS_AUDIO_FEEDBACK +//#define LCD_BED_TRAMMING + +#if ENABLED(LCD_BED_TRAMMING) + #define BED_TRAMMING_INSET_LFRB { 30, 30, 30, 30 } // (mm) Left, Front, Right, Back insets + #define BED_TRAMMING_HEIGHT 0.0 // (mm) Z height of nozzle at leveling points + #define BED_TRAMMING_Z_HOP 4.0 // (mm) Z height of nozzle between leveling points + //#define BED_TRAMMING_INCLUDE_CENTER // Move to the center after the last corner + //#define BED_TRAMMING_USE_PROBE + #if ENABLED(BED_TRAMMING_USE_PROBE) + #define BED_TRAMMING_PROBE_TOLERANCE 0.1 // (mm) + #define BED_TRAMMING_VERIFY_RAISED // After adjustment triggers the probe, re-probe to verify + //#define BED_TRAMMING_AUDIO_FEEDBACK #endif /** @@ -1716,7 +1766,7 @@ * | 1 2 | | 1 4 | | 1 2 | | 2 | * LF --------- RF LF --------- RF LF --------- RF LF --------- RF */ - #define LEVEL_CORNERS_LEVELING_ORDER { LF, RF, RB, LB } + #define BED_TRAMMING_LEVELING_ORDER { LF, RF, RB, LB } #endif /** @@ -1832,7 +1882,7 @@ * M502 - Revert settings to "factory" defaults. (Follow with M500 to init the EEPROM.) */ //#define EEPROM_SETTINGS // Persistent storage with M500 and M501 -//#define DISABLE_M503 // Saves ~2700 bytes of PROGMEM. Disable for release! +//#define DISABLE_M503 // Saves ~2700 bytes of flash. Disable for release! #define EEPROM_CHITCHAT // Give feedback on EEPROM commands. Disable to save PROGMEM. #define EEPROM_BOOT_SILENT // Keep M503 quiet and only give errors during first load #if ENABLED(EEPROM_SETTINGS) @@ -1863,7 +1913,7 @@ // @section temperature // -// Preheat Constants - Up to 5 are supported without changes +// Preheat Constants - Up to 6 are supported without changes // #define PREHEAT_1_LABEL "PLA" #define PREHEAT_1_TEMP_HOTEND 180 @@ -1893,8 +1943,7 @@ #if ENABLED(NOZZLE_PARK_FEATURE) // Specify a park position as { X, Y, Z_raise } #define NOZZLE_PARK_POINT { (X_MIN_POS + 10), (Y_MAX_POS - 10), 20 } - //#define NOZZLE_PARK_X_ONLY // X move only is required to park - //#define NOZZLE_PARK_Y_ONLY // Y move only is required to park + #define NOZZLE_PARK_MOVE 0 // Park motion: 0 = XY Move, 1 = X Only, 2 = Y Only, 3 = X before Y, 4 = Y before X #define NOZZLE_PARK_Z_RAISE_MIN 2 // (mm) Always raise Z by at least this distance #define NOZZLE_PARK_XY_FEEDRATE 100 // (mm/s) X and Y axes feedrate (also used for delta Z axis) #define NOZZLE_PARK_Z_FEEDRATE 5 // (mm/s) Z axis feedrate (not used for delta printers) @@ -2564,38 +2613,38 @@ //========================== Extensible UI Displays =========================== //============================================================================= -// -// DGUS Touch Display with DWIN OS. (Choose one.) -// ORIGIN : https://www.aliexpress.com/item/32993409517.html -// FYSETC : https://www.aliexpress.com/item/32961471929.html -// MKS : https://www.aliexpress.com/item/1005002008179262.html -// -// Flash display with DGUS Displays for Marlin: -// - Format the SD card to FAT32 with an allocation size of 4kb. -// - Download files as specified for your type of display. -// - Plug the microSD card into the back of the display. -// - Boot the display and wait for the update to complete. -// -// ORIGIN (Marlin DWIN_SET) -// - Download https://github.com/coldtobi/Marlin_DGUS_Resources -// - Copy the downloaded DWIN_SET folder to the SD card. -// -// FYSETC (Supplier default) -// - Download https://github.com/FYSETC/FYSTLCD-2.0 -// - Copy the downloaded SCREEN folder to the SD card. -// -// HIPRECY (Supplier default) -// - Download https://github.com/HiPrecy/Touch-Lcd-LEO -// - Copy the downloaded DWIN_SET folder to the SD card. -// -// MKS (MKS-H43) (Supplier default) -// - Download https://github.com/makerbase-mks/MKS-H43 -// - Copy the downloaded DWIN_SET folder to the SD card. -// -// RELOADED (T5UID1) -// - Download https://github.com/Desuuuu/DGUS-reloaded/releases -// - Copy the downloaded DWIN_SET folder to the SD card. -// +/** + * DGUS Touch Display with DWIN OS. (Choose one.) + * ORIGIN : https://www.aliexpress.com/item/32993409517.html + * FYSETC : https://www.aliexpress.com/item/32961471929.html + * MKS : https://www.aliexpress.com/item/1005002008179262.html + * + * Flash display with DGUS Displays for Marlin: + * - Format the SD card to FAT32 with an allocation size of 4kb. + * - Download files as specified for your type of display. + * - Plug the microSD card into the back of the display. + * - Boot the display and wait for the update to complete. + * + * ORIGIN (Marlin DWIN_SET) + * - Download https://github.com/coldtobi/Marlin_DGUS_Resources + * - Copy the downloaded DWIN_SET folder to the SD card. + * + * FYSETC (Supplier default) + * - Download https://github.com/FYSETC/FYSTLCD-2.0 + * - Copy the downloaded SCREEN folder to the SD card. + * + * HIPRECY (Supplier default) + * - Download https://github.com/HiPrecy/Touch-Lcd-LEO + * - Copy the downloaded DWIN_SET folder to the SD card. + * + * MKS (MKS-H43) (Supplier default) + * - Download https://github.com/makerbase-mks/MKS-H43 + * - Copy the downloaded DWIN_SET folder to the SD card. + * + * RELOADED (T5UID1) + * - Download https://github.com/Desuuuu/DGUS-reloaded/releases + * - Copy the downloaded DWIN_SET folder to the SD card. + */ //#define DGUS_LCD_UI_ORIGIN //#define DGUS_LCD_UI_FYSETC //#define DGUS_LCD_UI_HIPRECY @@ -2609,9 +2658,6 @@ // Touch-screen LCD for Malyan M200/M300 printers // //#define MALYAN_LCD -#if ENABLED(MALYAN_LCD) - #define LCD_SERIAL_PORT 1 // Default is 1 for Malyan M200 -#endif // // Touch UI for FTDI EVE (FT800/FT810) displays @@ -2625,7 +2671,6 @@ //#define ANYCUBIC_LCD_I3MEGA //#define ANYCUBIC_LCD_CHIRON #if EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON) - #define LCD_SERIAL_PORT 3 // Default is 3 for Anycubic //#define ANYCUBIC_LCD_DEBUG #endif @@ -2633,9 +2678,6 @@ // 320x240 Nextion 2.8" serial TFT Resistive Touch Screen NX3224T028 // //#define NEXTION_TFT -#if ENABLED(NEXTION_TFT) - #define LCD_SERIAL_PORT 1 // Default is 1 for Nextion -#endif // // Third-party or vendor-customized controller interfaces. @@ -2787,7 +2829,7 @@ // Ender-3 v2 OEM display. A DWIN display with Rotary Encoder. // //#define DWIN_CREALITY_LCD // Creality UI -//#define DWIN_CREALITY_LCD_ENHANCED // Enhanced UI +//#define DWIN_LCD_PROUI // Pro UI by MRiscoC //#define DWIN_CREALITY_LCD_JYERSUI // Jyers UI by Jacob Myers //#define DWIN_MARLINUI_PORTRAIT // MarlinUI (portrait orientation) //#define DWIN_MARLINUI_LANDSCAPE // MarlinUI (landscape orientation) @@ -2800,7 +2842,7 @@ #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 // (secs) Turn off the TFT backlight if set (5mn) + //#define TOUCH_IDLE_SLEEP 300 // (s) Turn off the TFT backlight if set (5mn) #define TOUCH_SCREEN_CALIBRATION @@ -2910,30 +2952,31 @@ // Support for Adafruit NeoPixel LED driver //#define NEOPIXEL_LED #if ENABLED(NEOPIXEL_LED) - #define NEOPIXEL_TYPE NEO_GRBW // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h) - //#define NEOPIXEL_PIN 4 // LED driving pin - //#define NEOPIXEL2_TYPE NEOPIXEL_TYPE - //#define NEOPIXEL2_PIN 5 - #define NEOPIXEL_PIXELS 30 // Number of LEDs in the strip. (Longest strip when NEOPIXEL2_SEPARATE is disabled.) - #define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once. - #define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255) - //#define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup + #define NEOPIXEL_TYPE NEO_GRBW // NEO_GRBW, NEO_RGBW, NEO_GRB, NEO_RBG, etc. + // See https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.h + //#define NEOPIXEL_PIN 4 // LED driving pin + //#define NEOPIXEL2_TYPE NEOPIXEL_TYPE + //#define NEOPIXEL2_PIN 5 + #define NEOPIXEL_PIXELS 30 // Number of LEDs in the strip. (Longest strip when NEOPIXEL2_SEPARATE is disabled.) + #define NEOPIXEL_IS_SEQUENTIAL // Sequential display for temperature change - LED by LED. Disable to change all LEDs at once. + #define NEOPIXEL_BRIGHTNESS 127 // Initial brightness (0-255) + //#define NEOPIXEL_STARTUP_TEST // Cycle through colors at startup // Support for second Adafruit NeoPixel LED driver controlled with M150 S1 ... //#define NEOPIXEL2_SEPARATE #if ENABLED(NEOPIXEL2_SEPARATE) - #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 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 #else - //#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel + //#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel #endif // Use some of the NeoPixel LEDs for static (background) lighting - //#define NEOPIXEL_BKGD_INDEX_FIRST 0 // Index of the first background LED - //#define NEOPIXEL_BKGD_INDEX_LAST 5 // Index of the last background LED + //#define NEOPIXEL_BKGD_INDEX_FIRST 0 // Index of the first background LED + //#define NEOPIXEL_BKGD_INDEX_LAST 5 // Index of the last background LED //#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 } // R, G, B, W - //#define NEOPIXEL_BKGD_ALWAYS_ON // Keep the backlight on when other NeoPixels are off + //#define NEOPIXEL_BKGD_ALWAYS_ON // Keep the backlight on when other NeoPixels are off #endif /** diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 2410d8b9033f..d25355d8a6ba 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -30,7 +30,7 @@ * * Basic settings can be found in Configuration.h */ -#define CONFIGURATION_ADV_H_VERSION 02000903 +#define CONFIGURATION_ADV_H_VERSION 02000904 //=========================================================================== //============================= Thermal Settings ============================ @@ -138,24 +138,21 @@ #endif /** - * Configuration options for MAX Thermocouples (-2, -3, -5). - * FORCE_HW_SPI: Ignore SCK/MOSI/MISO pins and just use the CS pin & default SPI bus. - * MAX31865_WIRES: Set the number of wires for the probe connected to a MAX31865 board, 2-4. Default: 2 - * MAX31865_50HZ: Enable 50Hz filter instead of the default 60Hz. - * MAX31865_USE_READ_ERROR_DETECTION: Detects random read errors from value spikes (a 20°C difference in less than 1sec) - * MAX31865_USE_AUTO_MODE: Faster and more frequent reads than 1-shot, but bias voltage always on, slightly affecting RTD temperature. - * MAX31865_MIN_SAMPLING_TIME_MSEC: in 1-shot mode, the minimum time between subsequent reads. This reduces the effect of bias voltage by leaving the sensor unpowered for longer intervals. - * MAX31865_WIRE_OHMS: In 2-wire configurations, manually set the wire resistance for more accurate readings + * Thermocouple Options — for MAX6675 (-2), MAX31855 (-3), and MAX31865 (-5). */ -//#define TEMP_SENSOR_FORCE_HW_SPI -//#define MAX31865_SENSOR_WIRES_0 2 +//#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_50HZ_FILTER -//#define MAX31865_USE_READ_ERROR_DETECTION -//#define MAX31865_USE_AUTO_MODE -//#define MAX31865_MIN_SAMPLING_TIME_MSEC 100 -//#define MAX31865_WIRE_OHMS_0 0.0f -//#define MAX31865_WIRE_OHMS_1 0.0f + +//#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. + +//#define MAX31865_USE_AUTO_MODE // Read faster and more often than 1-shot; bias voltage always on; slight effect on RTD temperature. +//#define MAX31865_MIN_SAMPLING_TIME_MSEC 100 // (ms) 1-shot: minimum read interval. Reduces bias voltage effects by leaving sensor unpowered for longer intervals. +//#define MAX31865_IGNORE_INITIAL_FAULTY_READS 10 // Ignore some read faults (keeping the temperature reading) to work around a possible issue (#23439). + +//#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 /** * Hephestos 2 24V heated bed upgrade kit. @@ -252,20 +249,6 @@ #endif #endif -// -// Laser Coolant Flow Meter -// -//#define LASER_COOLANT_FLOW_METER -#if ENABLED(LASER_COOLANT_FLOW_METER) - #define FLOWMETER_PIN 20 // Requires an external interrupt-enabled pin (e.g., RAMPS 2,3,18,19,20,21) - #define FLOWMETER_PPL 5880 // (pulses/liter) Flow meter pulses-per-liter on the input pin - #define FLOWMETER_INTERVAL 1000 // (ms) Flow rate calculation interval in milliseconds - #define FLOWMETER_SAFETY // Prevent running the laser without the minimum flow rate set below - #if ENABLED(FLOWMETER_SAFETY) - #define FLOWMETER_MIN_LITERS_PER_MINUTE 1.5 // (liters/min) Minimum flow required when enabled - #endif -#endif - /** * Thermal Protection provides additional protection to your printer from damage * and fire. Marlin always includes safe min and max temperature ranges which @@ -349,6 +332,14 @@ #define WATCH_COOLER_TEMP_INCREASE 3 // Degrees Celsius #endif +#if ANY(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_BED, THERMAL_PROTECTION_CHAMBER, THERMAL_PROTECTION_COOLER) + /** + * Thermal Protection Variance Monitor - EXPERIMENTAL. + * Kill the machine on a stuck temperature sensor. Disable if you get false positives. + */ + //#define THERMAL_PROTECTION_VARIANCE_MONITOR // Detect a sensor malfunction preventing temperature updates +#endif + #if ENABLED(PIDTEMP) // Add an experimental additional term to the heater power, proportional to the extrusion speed. // A well-chosen Kc value should add just enough power to melt the increased material volume. @@ -567,8 +558,8 @@ * * USE_OCR2A_AS_TOP [undefined by default] * Boards that use TIMER2 for PWM have limitations resulting in only a few possible frequencies on TIMER2: - * 16MHz MCUs: [62.5KHz, 31.4KHz (default), 7.8KHz, 3.92KHz, 1.95KHz, 977Hz, 488Hz, 244Hz, 60Hz, 122Hz, 30Hz] - * 20MHz MCUs: [78.1KHz, 39.2KHz (default), 9.77KHz, 4.9KHz, 2.44KHz, 1.22KHz, 610Hz, 305Hz, 153Hz, 76Hz, 38Hz] + * 16MHz MCUs: [62.5kHz, 31.4kHz (default), 7.8kHz, 3.92kHz, 1.95kHz, 977Hz, 488Hz, 244Hz, 60Hz, 122Hz, 30Hz] + * 20MHz MCUs: [78.1kHz, 39.2kHz (default), 9.77kHz, 4.9kHz, 2.44kHz, 1.22kHz, 610Hz, 305Hz, 153Hz, 76Hz, 38Hz] * A greater range can be achieved by enabling USE_OCR2A_AS_TOP. But note that this option blocks the use of * PWM on pin OC2A. Only use this option if you don't need PWM on 0C2A. (Check your schematic.) * USE_OCR2A_AS_TOP sacrifices duty cycle control resolution to achieve this broader range of frequencies. @@ -615,7 +606,6 @@ #define E7_AUTO_FAN_PIN -1 #define CHAMBER_AUTO_FAN_PIN -1 #define COOLER_AUTO_FAN_PIN -1 -#define COOLER_FAN_PIN -1 #define EXTRUDER_AUTO_FAN_TEMPERATURE 50 #define EXTRUDER_AUTO_FAN_SPEED 255 // 255 == full speed @@ -709,73 +699,6 @@ //#define CLOSED_LOOP_MOVE_COMPLETE_PIN -1 #endif -/** - * Dual Steppers / Dual Endstops - * - * This section will allow you to use extra E drivers to drive a second motor for X, Y, or Z axes. - * - * For example, set X_DUAL_STEPPER_DRIVERS setting to use a second motor. If the motors need to - * spin in opposite directions set INVERT_X2_VS_X_DIR. If the second motor needs its own endstop - * set X_DUAL_ENDSTOPS. This can adjust for "racking." Use X2_USE_ENDSTOP to set the endstop plug - * that should be used for the second endstop. Extra endstops will appear in the output of 'M119'. - * - * Use X_DUAL_ENDSTOP_ADJUSTMENT to adjust for mechanical imperfection. After homing both motors - * this offset is applied to the X2 motor. To find the offset home the X axis, and measure the error - * in X2. Dual endstop offsets can be set at runtime with 'M666 X Y Z'. - */ - -//#define X_DUAL_STEPPER_DRIVERS -#if ENABLED(X_DUAL_STEPPER_DRIVERS) - //#define INVERT_X2_VS_X_DIR // Enable if X2 direction signal is opposite to X - //#define X_DUAL_ENDSTOPS - #if ENABLED(X_DUAL_ENDSTOPS) - #define X2_USE_ENDSTOP _XMAX_ - #define X2_ENDSTOP_ADJUSTMENT 0 - #endif -#endif - -//#define Y_DUAL_STEPPER_DRIVERS -#if ENABLED(Y_DUAL_STEPPER_DRIVERS) - //#define INVERT_Y2_VS_Y_DIR // Enable if Y2 direction signal is opposite to Y - //#define Y_DUAL_ENDSTOPS - #if ENABLED(Y_DUAL_ENDSTOPS) - #define Y2_USE_ENDSTOP _YMAX_ - #define Y2_ENDSTOP_ADJUSTMENT 0 - #endif -#endif - -// -// For Z set the number of stepper drivers -// -#define NUM_Z_STEPPER_DRIVERS 1 // (1-4) Z options change based on how many - -#if NUM_Z_STEPPER_DRIVERS > 1 - // Enable if Z motor direction signals are the opposite of Z1 - //#define INVERT_Z2_VS_Z_DIR - //#define INVERT_Z3_VS_Z_DIR - //#define INVERT_Z4_VS_Z_DIR - - //#define Z_MULTI_ENDSTOPS - #if ENABLED(Z_MULTI_ENDSTOPS) - #define Z2_USE_ENDSTOP _XMAX_ - #define Z2_ENDSTOP_ADJUSTMENT 0 - #if NUM_Z_STEPPER_DRIVERS >= 3 - #define Z3_USE_ENDSTOP _YMAX_ - #define Z3_ENDSTOP_ADJUSTMENT 0 - #endif - #if NUM_Z_STEPPER_DRIVERS >= 4 - #define Z4_USE_ENDSTOP _ZMAX_ - #define Z4_ENDSTOP_ADJUSTMENT 0 - #endif - #endif -#endif - -// Drive the E axis with two synchronized steppers -//#define E_DUAL_STEPPER_DRIVERS -#if ENABLED(E_DUAL_STEPPER_DRIVERS) - //#define INVERT_E1_VS_E0_DIR // Enable if the E motors need opposite DIR states -#endif - /** * Dual X Carriage * @@ -806,18 +729,17 @@ */ //#define DUAL_X_CARRIAGE #if ENABLED(DUAL_X_CARRIAGE) - #define X1_MIN_POS X_MIN_POS // Set to X_MIN_POS - #define X1_MAX_POS X_BED_SIZE // Set a maximum so the first X-carriage can't hit the parked second X-carriage - #define X2_MIN_POS 80 // Set a minimum to ensure the second X-carriage can't hit the parked first X-carriage - #define X2_MAX_POS 353 // Set this to the distance between toolheads when both heads are homed - #define X2_HOME_DIR 1 // Set to 1. The second X-carriage always homes to the maximum endstop position - #define X2_HOME_POS X2_MAX_POS // Default X2 home position. Set to X2_MAX_POS. - // However: In this mode the HOTEND_OFFSET_X value for the second extruder provides a software - // override for X2_HOME_POS. This also allow recalibration of the distance between the two endstops - // without modifying the firmware (through the "M218 T1 X???" command). - // Remember: you should set the second extruder x-offset to 0 in your slicer. - - // This is the default power-up mode which can be later using M605. + #define X1_MIN_POS X_MIN_POS // Set to X_MIN_POS + #define X1_MAX_POS X_BED_SIZE // A max coordinate so the X1 carriage can't hit the parked X2 carriage + #define X2_MIN_POS 80 // A min coordinate so the X2 carriage can't hit the parked X1 carriage + #define X2_MAX_POS 353 // The max position of the X2 carriage, typically also the home position + #define X2_HOME_DIR 1 // Set to 1. The X2 carriage always homes to the max endstop position + #define X2_HOME_POS X2_MAX_POS // Default X2 home position. Set to X2_MAX_POS. + // NOTE: For Dual X Carriage use M218 T1 Xn to override the X2_HOME_POS. + // This allows recalibration of endstops distance without a rebuild. + // Remember to set the second extruder's X-offset to 0 in your slicer. + + // This is the default power-up mode which can be changed later using M605 S. #define DEFAULT_DUAL_X_CARRIAGE_MODE DXC_AUTO_PARK_MODE // Default x offset in duplication mode (typically set to half print bed width) @@ -827,6 +749,77 @@ //#define EVENT_GCODE_IDEX_AFTER_MODECHANGE "G28X" #endif +/** + * Multi-Stepper / Multi-Endstop + * + * When X2_DRIVER_TYPE is defined, this indicates that the X and X2 motors work in tandem. + * The following explanations for X also apply to Y and Z multi-stepper setups. + * Endstop offsets may be changed by 'M666 X Y Z' and stored to EEPROM. + * + * - Enable INVERT_X2_VS_X_DIR if the X2 motor requires an opposite DIR signal from X. + * + * - Enable X_DUAL_ENDSTOPS if the second motor has its own endstop, with adjustable offset. + * + * - Extra endstops are included in the output of 'M119'. + * + * - Set X_DUAL_ENDSTOP_ADJUSTMENT to the known error in the X2 endstop. + * Applied to the X2 motor on 'G28' / 'G28 X'. + * Get the offset by homing X and measuring the error. + * Also set with 'M666 X' and stored to EEPROM with 'M500'. + * + * - Use X2_USE_ENDSTOP to set the endstop plug by name. (_XMIN_, _XMAX_, _YMIN_, _YMAX_, _ZMIN_, _ZMAX_) + */ +#if HAS_X2_STEPPER && DISABLED(DUAL_X_CARRIAGE) + //#define INVERT_X2_VS_X_DIR // X2 direction signal is the opposite of X + //#define X_DUAL_ENDSTOPS // X2 has its own endstop + #if ENABLED(X_DUAL_ENDSTOPS) + #define X2_USE_ENDSTOP _XMAX_ // X2 endstop board plug. Don't forget to enable USE_*_PLUG. + #define X2_ENDSTOP_ADJUSTMENT 0 // X2 offset relative to X endstop + #endif +#endif + +#if HAS_DUAL_Y_STEPPERS + //#define INVERT_Y2_VS_Y_DIR // Y2 direction signal is the opposite of Y + //#define Y_DUAL_ENDSTOPS // Y2 has its own endstop + #if ENABLED(Y_DUAL_ENDSTOPS) + #define Y2_USE_ENDSTOP _YMAX_ // Y2 endstop board plug. Don't forget to enable USE_*_PLUG. + #define Y2_ENDSTOP_ADJUSTMENT 0 // Y2 offset relative to Y endstop + #endif +#endif + +// +// Multi-Z steppers +// +#ifdef Z2_DRIVER_TYPE + //#define INVERT_Z2_VS_Z_DIR // Z2 direction signal is the opposite of Z + + //#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 + #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 + #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 + #endif + #endif +#endif + +// Drive the E axis with two synchronized steppers +//#define E_DUAL_STEPPER_DRIVERS +#if ENABLED(E_DUAL_STEPPER_DRIVERS) + //#define INVERT_E1_VS_E0_DIR // E direction signals are opposites +#endif + // Activate a solenoid on the active extruder with M380. Disable all with M381. // Define SOL0_PIN, SOL1_PIN, etc., for each extruder that has a solenoid. //#define EXT_SOLENOID @@ -958,15 +951,17 @@ //#define Z_STEPPERS_ORIENTATION 0 #endif - // Provide Z stepper positions for more rapid convergence in bed alignment. - // Requires triple stepper drivers (i.e., set NUM_Z_STEPPER_DRIVERS to 3) - //#define Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - // Define Stepper XY positions for Z1, Z2, Z3 corresponding to - // the Z screw positions in the bed carriage. - // Define one position per Z stepper in stepper driver order. - #define Z_STEPPER_ALIGN_STEPPER_XY { { 210.7, 102.5 }, { 152.6, 220.0 }, { 94.5, 102.5 } } - #else + /** + * Z Stepper positions for more rapid convergence in bed alignment. + * Requires 3 or 4 Z steppers. + * + * Define Stepper XY positions for Z1, Z2, Z3... corresponding to the screw + * positions in the bed carriage, with one position per Z stepper in stepper + * driver order. + */ + //#define Z_STEPPER_ALIGN_STEPPER_XY { { 210.7, 102.5 }, { 152.6, 220.0 }, { 94.5, 102.5 } } + + #ifndef Z_STEPPER_ALIGN_STEPPER_XY // Amplification factor. Used to scale the correction step up or down in case // the stepper (spindle) position is farther out than the test point. #define Z_STEPPER_ALIGN_AMP 1.0 // Use a value > 1.0 NOTE: This may cause instability! @@ -1253,7 +1248,7 @@ // @section lcd -#if ANY(HAS_LCD_MENU, EXTENSIBLE_UI, HAS_DWIN_E3V2) +#if HAS_MANUAL_MOVE_MENU #define MANUAL_FEEDRATE { 50*60, 50*60, 4*60, 2*60 } // (mm/min) Feedrates for manual moves along X, Y, Z, E from panel #define FINE_MANUAL_MOVE 0.025 // (mm) Smallest manual move (< 0.1mm) applying to Z on most machines #if IS_ULTIPANEL @@ -1276,37 +1271,41 @@ #define FEEDRATE_CHANGE_BEEP_FREQUENCY 440 #endif -#if HAS_LCD_MENU +// +// LCD Backlight Timeout +// +//#define LCD_BACKLIGHT_TIMEOUT 30 // (s) 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 + #if ENABLED(PROBE_OFFSET_WIZARD) + /** + * Enable to init the Probe Z-Offset when starting the Wizard. + * Use a height slightly above the estimated nozzle-to-probe Z offset. + * For example, with an offset of -5, consider a starting height of -4. + */ + //#define PROBE_OFFSET_WIZARD_START_Z -4.0 + + // Set a convenient position to do the calibration (probing point and nozzle/bed-distance) + //#define PROBE_OFFSET_WIZARD_XY_POS { X_CENTER, Y_CENTER } + #endif +#endif + +#if HAS_MARLINUI_MENU - // Add Probe Z Offset calibration to the Z Probe Offsets menu #if HAS_BED_PROBE - //#define PROBE_OFFSET_WIZARD - #if ENABLED(PROBE_OFFSET_WIZARD) - // - // Enable to init the Probe Z-Offset when starting the Wizard. - // Use a height slightly above the estimated nozzle-to-probe Z offset. - // For example, with an offset of -5, consider a starting height of -4. - // - //#define PROBE_OFFSET_WIZARD_START_Z -4.0 - - // Set a convenient position to do the calibration (probing point and nozzle/bed-distance) - //#define PROBE_OFFSET_WIZARD_XY_POS { X_CENTER, Y_CENTER } - #endif - - #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - // Add a calibration procedure in the Probe Offsets menu - // to compensate for twist in the X-axis. - //#define X_AXIS_TWIST_COMPENSATION - #if ENABLED(X_AXIS_TWIST_COMPENSATION) - /** - * Enable to init the Probe Z-Offset when starting the Wizard. - * Use a height slightly above the estimated nozzle-to-probe Z offset. - * For example, with an offset of -5, consider a starting height of -4. - */ - #define XATC_START_Z 0.0 - #define XATC_MAX_POINTS 3 // Number of points to probe in the wizard - #define XATC_Y_POSITION Y_CENTER // (mm) Y position to probe - #endif + // Add calibration in the Probe Offsets menu to compensate for X-axis twist. + //#define X_AXIS_TWIST_COMPENSATION + #if ENABLED(X_AXIS_TWIST_COMPENSATION) + /** + * Enable to init the Probe Z-Offset when starting the Wizard. + * Use a height slightly above the estimated nozzle-to-probe Z offset. + * For example, with an offset of -5, consider a starting height of -4. + */ + #define XATC_START_Z 0.0 + #define XATC_MAX_POINTS 3 // Number of points to probe in the wizard + #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 #endif @@ -1319,6 +1318,42 @@ // BACK menu items keep the highlight at the top //#define TURBO_BACK_MENU_ITEM + // Insert a menu for preheating at the top level to allow for quick access + //#define PREHEAT_SHORTCUT_MENU_ITEM + +#endif // HAS_MARLINUI_MENU + +#if ANY(HAS_DISPLAY, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) + //#define SOUND_MENU_ITEM // Add a mute option to the LCD menu + #define SOUND_ON_DEFAULT // Buzzer/speaker default enabled state +#endif + +#if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI) + // The timeout to return to the status screen from sub-menus + //#define LCD_TIMEOUT_TO_STATUS 15000 // (ms) + + #if ENABLED(SHOW_BOOTSCREEN) + #define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s) + #if EITHER(HAS_MARLINUI_U8GLIB, TFT_COLOR_UI) + #define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving lots of flash) + #endif + #endif + + // Scroll a longer status message into view + //#define STATUS_MESSAGE_SCROLLING + + // Apply a timeout to low-priority status messages + //#define STATUS_MESSAGE_TIMEOUT_SEC 30 // (seconds) + + // 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 + /** * LED Control Menu * Add LED Control to the LCD menu @@ -1345,37 +1380,6 @@ #endif #endif - // Insert a menu for preheating at the top level to allow for quick access - //#define PREHEAT_SHORTCUT_MENU_ITEM - -#endif // HAS_LCD_MENU - -#if ANY(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI) - //#define SOUND_MENU_ITEM // Add a mute option to the LCD menu -#endif - -#if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED) - // The timeout (in ms) to return to the status screen from sub-menus - //#define LCD_TIMEOUT_TO_STATUS 15000 - - #if ENABLED(SHOW_BOOTSCREEN) - #define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s) - #if EITHER(HAS_MARLINUI_U8GLIB, TFT_COLOR_UI) - #define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving lots of flash) - #endif - #endif - - // Scroll a longer status message into view - //#define STATUS_MESSAGE_SCROLLING - - // 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 #endif // LCD Print Progress options @@ -1522,33 +1526,23 @@ // LCD's font must contain the characters. Check your selected LCD language. //#define UTF_FILENAME_SUPPORT - // This allows hosts to request long names for files and folders with M33 - //#define LONG_FILENAME_HOST_SUPPORT + //#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 - // Enable this option to scroll long filenames in the SD card menu - //#define SCROLL_LONG_FILENAMES + //#define SCROLL_LONG_FILENAMES // Scroll long filenames in the SD card menu - // Leave the heaters on after Stop Print (not recommended!) - //#define SD_ABORT_NO_COOLDOWN + //#define SD_ABORT_NO_COOLDOWN // Leave the heaters on after Stop Print (not recommended!) /** - * This option allows you to abort SD printing when any endstop is triggered. - * This feature must be enabled with "M540 S1" or from the LCD menu. - * To have any effect, endstops must be enabled during SD printing. + * Abort SD printing when any endstop is triggered. + * This feature is enabled with 'M540 S1' or from the LCD menu. + * Endstops must be activated for this option to work. */ //#define SD_ABORT_ON_ENDSTOP_HIT - /** - * This option makes it easier to print the same SD Card file again. - * On print completion the LCD Menu will open with the file selected. - * You can just click to start the print, or navigate elsewhere. - */ - //#define SD_REPRINT_LAST_SELECTED_FILE + //#define SD_REPRINT_LAST_SELECTED_FILE // On print completion open the LCD Menu and select the same file - /** - * Auto-report SdCard status with M27 S - */ - //#define AUTO_REPORT_SD_STATUS + //#define AUTO_REPORT_SD_STATUS // Auto-report media status with 'M27 S' /** * Support for USB thumb drives using an Arduino USB Host Shield or @@ -1617,6 +1611,11 @@ // Add an optimized binary file transfer mode, initiated with 'M28 B1' //#define BINARY_FILE_TRANSFER + #if ENABLED(BINARY_FILE_TRANSFER) + // Include extra facilities (e.g., 'M20 F') supporting firmware upload via BINARY_FILE_TRANSFER + //#define CUSTOM_FIRMWARE_UPLOAD + #endif + /** * Set this option to one of the following (or the board's defaults apply): * @@ -1631,7 +1630,10 @@ // Enable if SD detect is rendered useless (e.g., by using an SD extender) //#define NO_SD_DETECT - // Multiple volume support - EXPERIMENTAL. + /** + * Multiple volume support - EXPERIMENTAL. + * Adds 'M21 Pm' / 'M21 S' / 'M21 U' to mount SD Card / USB Drive. + */ //#define MULTI_VOLUME #if ENABLED(MULTI_VOLUME) #define VOLUME_SD_ONBOARD @@ -1665,14 +1667,25 @@ //#define XYZ_NO_FRAME #define XYZ_HOLLOW_FRAME - // A bigger font is available for edit items. Costs 3120 bytes of PROGMEM. + // A bigger font is available for edit items. Costs 3120 bytes of flash. // Western only. Not available for Cyrillic, Kana, Turkish, Greek, or Chinese. //#define USE_BIG_EDIT_FONT - // A smaller font may be used on the Info Screen. Costs 2434 bytes of PROGMEM. + // A smaller font may be used on the Info Screen. Costs 2434 bytes of flash. // Western only. Not available for Cyrillic, Kana, Turkish, Greek, or Chinese. //#define USE_SMALL_INFOFONT + /** + * Graphical Display Sleep + * + * The U8G library provides sleep / wake functions for SH1106, SSD1306, + * SSD1309, and some other DOGM displays. + * Enable this option to save energy and prevent OLED pixel burn-in. + * 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 + /** * ST7920-based LCDs can emulate a 16 x 4 character display using * the ST7920 character-generator for very fast screen updates. @@ -1714,7 +1727,7 @@ //#define STATUS_ALT_FAN_BITMAP // Use the alternative fan bitmap //#define STATUS_FAN_FRAMES 3 // :[0,1,2,3,4] Number of fan animation frames //#define STATUS_HEAT_PERCENT // Show heating in a progress bar - //#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~3260 (or ~940) bytes of PROGMEM. + //#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~3260 (or ~940) bytes of flash. // Frivolous Game Options //#define MARLIN_BRICKOUT @@ -1739,7 +1752,6 @@ // Additional options for DGUS / DWIN displays // #if HAS_DGUS_LCD - #define LCD_SERIAL_PORT 3 #define LCD_BAUDRATE 115200 #define DGUS_RX_BUFFER_SIZE 128 @@ -2260,7 +2272,7 @@ #define BUFSIZE 4 // Transmission to Host Buffer Size -// To save 386 bytes of PROGMEM (and TX_BUFFER_SIZE+3 bytes of RAM) set to 0. +// To save 386 bytes of flash (and TX_BUFFER_SIZE+3 bytes of RAM) set to 0. // To buffer a simple "ok" you need 4 bytes. // For ADVANCED_OK (M105) you need 32 bytes. // For debug-echo: 128 bytes for the optimal speed. @@ -2342,6 +2354,15 @@ // For serial echo, the number of digits after the decimal point //#define SERIAL_FLOAT_PRECISION 4 +/** + * Set the number of proportional font spaces required to fill up a typical character space. + * This can help to better align the output of commands like `G29 O` Mesh Output. + * + * For clients that use a fixed-width font (like OctoPrint), leave this set to 1.0. + * Otherwise, adjust according to your client and font. + */ +#define PROPORTIONAL_FONT_RATIO 1.0 + // @section extras /** @@ -2402,7 +2423,7 @@ /** * Extra G-code to run while executing tool-change commands. Can be used to use an additional - * stepper motor (I axis, see option LINEAR_AXES in Configuration.h) to drive the tool-changer. + * stepper motor (e.g., I axis in Configuration.h) to drive the tool-changer. */ //#define EVENT_GCODE_TOOLCHANGE_T0 "G28 A\nG1 A0" // Extra G-code to run while executing tool-change command T0 //#define EVENT_GCODE_TOOLCHANGE_T1 "G1 A10" // Extra G-code to run while executing tool-change command T1 @@ -2422,7 +2443,7 @@ #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) // Load / Unload #define TOOLCHANGE_FS_LENGTH 12 // (mm) Load / Unload length - #define TOOLCHANGE_FS_EXTRA_RESUME_LENGTH 0 // (mm) Extra length for better restart, fine tune by LCD/Gcode) + #define TOOLCHANGE_FS_EXTRA_RESUME_LENGTH 0 // (mm) Extra length for better restart. Adjust with LCD or M217 B. #define TOOLCHANGE_FS_RETRACT_SPEED (50*60) // (mm/min) (Unloading) #define TOOLCHANGE_FS_UNRETRACT_SPEED (25*60) // (mm/min) (On SINGLENOZZLE or Bowden loading must be slowed down) @@ -2436,12 +2457,16 @@ #define TOOLCHANGE_FS_FAN_SPEED 255 // 0-255 #define TOOLCHANGE_FS_FAN_TIME 10 // (seconds) - // Swap uninitialized extruder with TOOLCHANGE_FS_PRIME_SPEED for all lengths (recover + prime) - // (May break filament if not retracted beforehand.) - //#define TOOLCHANGE_FS_INIT_BEFORE_SWAP + // Use TOOLCHANGE_FS_PRIME_SPEED feedrate the first time each extruder is primed + //#define TOOLCHANGE_FS_SLOW_FIRST_PRIME - // Prime on the first T0 (If other, TOOLCHANGE_FS_INIT_BEFORE_SWAP applied) - // Enable it (M217 V[0/1]) before printing, to avoid unwanted priming on host connect + /** + * Prime T0 the first time T0 is sent to the printer: + * [ Power-On -> T0 { Activate & Prime T0 } -> T1 { Retract T0, Activate & Prime T1 } ] + * If disabled, no priming on T0 until switching back to T0 from another extruder: + * [ Power-On -> T0 { T0 Activated } -> T1 { Activate & Prime T1 } -> T0 { Retract T1, Activate & Prime T0 } ] + * Enable with M217 V1 before printing to avoid unwanted priming on host connect. + */ //#define TOOLCHANGE_FS_PRIME_FIRST_USED /** @@ -2975,6 +3000,9 @@ //#define CHOPPER_TIMING_Z2 CHOPPER_TIMING_Z //#define CHOPPER_TIMING_Z3 CHOPPER_TIMING_Z //#define CHOPPER_TIMING_Z4 CHOPPER_TIMING_Z + //#define CHOPPER_TIMING_I CHOPPER_TIMING + //#define CHOPPER_TIMING_J CHOPPER_TIMING + //#define CHOPPER_TIMING_K CHOPPER_TIMING //#define CHOPPER_TIMING_E CHOPPER_TIMING // For Extruders (override below) //#define CHOPPER_TIMING_E1 CHOPPER_TIMING_E //#define CHOPPER_TIMING_E2 CHOPPER_TIMING_E @@ -3212,7 +3240,7 @@ #define Z4_SLEW_RATE 1 #endif - #if AXIS_DRIVER_TYPE_I(L6470) + #if AXIS_IS_L64XX(I) #define I_MICROSTEPS 128 #define I_OVERCURRENT 2000 #define I_STALLCURRENT 1500 @@ -3221,7 +3249,7 @@ #define I_SLEW_RATE 1 #endif - #if AXIS_DRIVER_TYPE_J(L6470) + #if AXIS_IS_L64XX(J) #define J_MICROSTEPS 128 #define J_OVERCURRENT 2000 #define J_STALLCURRENT 1500 @@ -3230,7 +3258,7 @@ #define J_SLEW_RATE 1 #endif - #if AXIS_DRIVER_TYPE_K(L6470) + #if AXIS_IS_L64XX(K) #define K_MICROSTEPS 128 #define K_OVERCURRENT 2000 #define K_STALLCURRENT 1500 @@ -3433,7 +3461,7 @@ * You'll need to select a pin for the ON/OFF function and optionally choose a 0-5V * hardware PWM pin for the speed control and a pin for the rotation direction. * - * See https://marlinfw.org/docs/configuration/laser_spindle.html for more config details. + * See https://marlinfw.org/docs/configuration/2.0.9/laser_spindle.html for more config details. */ //#define SPINDLE_FEATURE //#define LASER_FEATURE @@ -3443,7 +3471,7 @@ #define SPINDLE_LASER_USE_PWM // Enable if your controller supports setting the speed/power #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 and LPC) + #define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR, ESP32, and LPC) #endif //#define AIR_EVACUATION // Cutter Vacuum / Laser Blower motor control with G-codes M10-M11 @@ -3520,6 +3548,16 @@ #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 + /** + * Laser Safety Timeout + * + * The laser should be turned off when there is no movement for a period of time. + * Consider material flammability, cut rate, and G-code order when setting this + * value. Too low and it could turn off during a very slow move; too high and + * the material could ignite. + */ + #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) @@ -3604,6 +3642,20 @@ #define I2C_AMMETER_SHUNT_RESISTOR 0.1 // (Ohms) Calibration shunt resistor value #endif + // + // Laser Coolant Flow Meter + // + //#define LASER_COOLANT_FLOW_METER + #if ENABLED(LASER_COOLANT_FLOW_METER) + #define FLOWMETER_PIN 20 // Requires an external interrupt-enabled pin (e.g., RAMPS 2,3,18,19,20,21) + #define FLOWMETER_PPL 5880 // (pulses/liter) Flow meter pulses-per-liter on the input pin + #define FLOWMETER_INTERVAL 1000 // (ms) Flow rate calculation interval in milliseconds + #define FLOWMETER_SAFETY // Prevent running the laser without the minimum flow rate set below + #if ENABLED(FLOWMETER_SAFETY) + #define FLOWMETER_MIN_LITERS_PER_MINUTE 1.5 // (liters/min) Minimum flow required when enabled + #endif + #endif + #endif #endif // SPINDLE_FEATURE || LASER_FEATURE @@ -3717,6 +3769,9 @@ * Auto-report temperatures with M155 S */ #define AUTO_REPORT_TEMPERATURES +#if ENABLED(AUTO_REPORT_TEMPERATURES) && TEMP_SENSOR_REDUNDANT + //#define AUTO_REPORT_REDUNDANT // Include the "R" sensor in the auto-report +#endif /** * Auto-report position with M154 S @@ -3782,15 +3837,6 @@ //#define REPORT_FAN_CHANGE // Report the new fan speed when changed by M106 (and others) -/** - * Set the number of proportional font spaces required to fill up a typical character space. - * This can help to better align the output of commands like `G29 O` Mesh Output. - * - * For clients that use a fixed-width font (like OctoPrint), leave this set to 1.0. - * Otherwise, adjust according to your client and font. - */ -#define PROPORTIONAL_FONT_RATIO 1.0 - /** * Spend 28 bytes of SRAM to optimize the G-code parser */ @@ -3954,10 +4000,13 @@ */ //#define HOST_ACTION_COMMANDS #if ENABLED(HOST_ACTION_COMMANDS) - //#define HOST_PAUSE_M76 - //#define HOST_PROMPT_SUPPORT - //#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start - //#define HOST_SHUTDOWN_MENU_ITEM // Add a menu item that tells the host to shut down + //#define HOST_PAUSE_M76 // Tell the host to pause in response to M76 + //#define HOST_PROMPT_SUPPORT // Initiate host prompts to get user feedback + #if ENABLED(HOST_PROMPT_SUPPORT) + //#define HOST_STATUS_NOTIFICATIONS // Send some status messages to the host as notifications + #endif + //#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start + //#define HOST_SHUTDOWN_MENU_ITEM // Add a menu item that tells the host to shut down #endif /** @@ -4092,12 +4141,12 @@ /** * Instant freeze / unfreeze functionality - * Specified pin has pullup and connecting to ground will instantly pause motion. * Potentially useful for emergency stop that allows being resumed. */ //#define FREEZE_FEATURE #if ENABLED(FREEZE_FEATURE) //#define FREEZE_PIN 41 // Override the default (KILL) pin here + #define FREEZE_STATE LOW // State of pin indicating freeze #endif /** diff --git a/Marlin/Makefile b/Marlin/Makefile index eee1403b537c..417c979f8857 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -132,7 +132,7 @@ CC_MIN:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_MINOR__ | cut -f3 -d\ ) CC_PATCHLEVEL:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_PATCHLEVEL__ | cut -f3 -d\ ) CC_VER:=$(shell echo $$(( $(CC_MAJ) * 10000 + $(CC_MIN) * 100 + $(CC_PATCHLEVEL) ))) ifeq ($(shell test $(CC_VER) -lt 40901 && echo 1),1) - @echo This version of GCC is likely broken. Enabling relocation workaround. + $(warning This GCC version $(CC_VER) is likely broken. Enabling relocation workaround.) RELOC_WORKAROUND = 1 endif @@ -512,7 +512,7 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1324) else ifeq ($(HARDWARE_MOTHERBOARD),1325) # Intamsys 4.0 (Funmat HT) else ifeq ($(HARDWARE_MOTHERBOARD),1326) -# Malyan M180 Mainboard Version 2 (no display function, direct gcode only) +# Malyan M180 Mainboard Version 2 (no display function, direct G-code only) else ifeq ($(HARDWARE_MOTHERBOARD),1327) # Geeetech GT2560 Rev B for A20(M/T/D) else ifeq ($(HARDWARE_MOTHERBOARD),1328) diff --git a/Marlin/Version.h b/Marlin/Version.h index 40136a36847d..68d56f6e7ecf 100644 --- a/Marlin/Version.h +++ b/Marlin/Version.h @@ -28,7 +28,7 @@ /** * Marlin release version identifier */ -//#define SHORT_BUILD_VERSION "2.0.9.3" +//#define SHORT_BUILD_VERSION "2.0.9.4" /** * 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 "2021-12-25" +//#define STRING_DISTRIBUTION_DATE "2022-06-04" /** * Defines a generic printer name to be output to the LCD after booting Marlin. diff --git a/Marlin/src/HAL/AVR/HAL.cpp b/Marlin/src/HAL/AVR/HAL.cpp index d7bf2a6f6fbb..5382eb36a2bd 100644 --- a/Marlin/src/HAL/AVR/HAL.cpp +++ b/Marlin/src/HAL/AVR/HAL.cpp @@ -23,6 +23,7 @@ #include "../../inc/MarlinConfig.h" #include "HAL.h" +#include #ifdef USBCON DefaultSerial1 MSerial0(false, Serial); @@ -36,7 +37,7 @@ // ------------------------ // Don't initialize/override variable (which would happen in .init4) -uint8_t reset_reason __attribute__((section(".noinit"))); +uint8_t MarlinHAL::reset_reason __attribute__((section(".noinit"))); // ------------------------ // Public functions @@ -45,22 +46,22 @@ uint8_t reset_reason __attribute__((section(".noinit"))); __attribute__((naked)) // Don't output function pro- and epilogue __attribute__((used)) // Output the function, even if "not used" __attribute__((section(".init3"))) // Put in an early user definable section -void HAL_save_reset_reason() { +void save_reset_reason() { #if ENABLED(OPTIBOOT_RESET_REASON) __asm__ __volatile__( A("STS %0, r2") - : "=m"(reset_reason) + : "=m"(hal.reset_reason) ); #else - reset_reason = MCUSR; + hal.reset_reason = MCUSR; #endif // Clear within 16ms since WDRF bit enables a 16ms watchdog timer -> Boot loop - MCUSR = 0; + hal.clear_reset_source(); wdt_disable(); } -void HAL_init() { +void MarlinHAL::init() { // Init Servo Pins #define INIT_SERVO(N) OUT_WRITE(SERVO##N##_PIN, LOW) #if HAS_SERVO_0 @@ -75,9 +76,11 @@ void HAL_init() { #if HAS_SERVO_3 INIT_SERVO(3); #endif + + init_pwm_timers(); // Init user timers to default frequency - 1000HZ } -void HAL_reboot() { +void MarlinHAL::reboot() { #if ENABLED(USE_WATCHDOG) while (1) { /* run out the watchdog */ } #else @@ -86,6 +89,62 @@ void HAL_reboot() { #endif } +// ------------------------ +// Watchdog Timer +// ------------------------ + +#if ENABLED(USE_WATCHDOG) + + #include + #include "../../MarlinCore.h" + + // Initialize watchdog with 8s timeout, if possible. Otherwise, make it 4s. + void MarlinHAL::watchdog_init() { + #if ENABLED(WATCHDOG_DURATION_8S) && defined(WDTO_8S) + #define WDTO_NS WDTO_8S + #else + #define WDTO_NS WDTO_4S + #endif + #if ENABLED(WATCHDOG_RESET_MANUAL) + // Enable the watchdog timer, but only for the interrupt. + // Take care, as this requires the correct order of operation, with interrupts disabled. + // See the datasheet of any AVR chip for details. + wdt_reset(); + cli(); + _WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE); + _WD_CONTROL_REG = _BV(WDIE) | (WDTO_NS & 0x07) | ((WDTO_NS & 0x08) << 2); // WDTO_NS directly does not work. bit 0-2 are consecutive in the register but the highest value bit is at bit 5 + // So worked for up to WDTO_2S + sei(); + wdt_reset(); + #else + wdt_enable(WDTO_NS); // The function handles the upper bit correct. + #endif + //delay(10000); // test it! + } + + //=========================================================================== + //=================================== ISR =================================== + //=========================================================================== + + // Watchdog timer interrupt, called if main program blocks >4sec and manual reset is enabled. + #if ENABLED(WATCHDOG_RESET_MANUAL) + ISR(WDT_vect) { + sei(); // With the interrupt driven serial we need to allow interrupts. + SERIAL_ERROR_MSG(STR_WATCHDOG_FIRED); + minkill(); // interrupt-safe final kill and infinite loop + } + #endif + + // Reset watchdog. MUST be called at least every 4 seconds after the + // first watchdog_init or AVR will go into emergency procedures. + void MarlinHAL::watchdog_refresh() { wdt_reset(); } + +#endif // USE_WATCHDOG + +// ------------------------ +// Free Memory Accessor +// ------------------------ + #if ENABLED(SDSUPPORT) #include "../../sd/SdFatUtil.h" @@ -93,20 +152,20 @@ void HAL_reboot() { #else // !SDSUPPORT -extern "C" { - extern char __bss_end; - extern char __heap_start; - extern void* __brkval; - - int freeMemory() { - int free_memory; - if ((int)__brkval == 0) - free_memory = ((int)&free_memory) - ((int)&__bss_end); - else - free_memory = ((int)&free_memory) - ((int)__brkval); - return free_memory; + extern "C" { + extern char __bss_end; + extern char __heap_start; + extern void* __brkval; + + int freeMemory() { + int free_memory; + if ((int)__brkval == 0) + free_memory = ((int)&free_memory) - ((int)&__bss_end); + else + free_memory = ((int)&free_memory) - ((int)__brkval); + return free_memory; + } } -} #endif // !SDSUPPORT diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index 2217f239d64e..7185142175dc 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -22,13 +22,11 @@ #include "../shared/Marduino.h" #include "../shared/HAL_SPI.h" #include "fastio.h" -#include "watchdog.h" #include "math.h" #ifdef USBCON #include #else - #define HardwareSerial_h // Hack to prevent HardwareSerial.h header inclusion #include "MarlinSerial.h" #endif @@ -74,9 +72,9 @@ #define CRITICAL_SECTION_START() unsigned char _sreg = SREG; cli() #define CRITICAL_SECTION_END() SREG = _sreg #endif -#define ISRS_ENABLED() TEST(SREG, SREG_I) -#define ENABLE_ISRS() sei() -#define DISABLE_ISRS() cli() + +#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment +#define PWM_FREQUENCY 1000 // Default PWM frequency when set_pwm_duty() is called without set_pwm_frequency() // ------------------------ // Types @@ -84,16 +82,15 @@ typedef int8_t pin_t; -#define SHARED_SERVOS HAS_SERVOS -#define HAL_SERVO_LIB Servo +#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +class Servo; +typedef Servo hal_servo_t; // ------------------------ -// Public Variables +// Serial ports // ------------------------ -extern uint8_t reset_reason; - -// Serial ports #ifdef USBCON #include "../../core/serial_hook.h" typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1; @@ -142,20 +139,31 @@ extern uint8_t reset_reason; #endif #endif -// ------------------------ -// Public functions -// ------------------------ +// +// ADC +// +#define HAL_ADC_VREF 5.0 +#define HAL_ADC_RESOLUTION 10 -void HAL_init(); +// +// 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) -//void cli(); +#define HAL_SENSITIVE_PINS 0, 1, -//void _delay_ms(const int delay); +#ifdef __AVR_AT90USB1286__ + #define JTAG_DISABLE() do{ MCUCR = 0x80; MCUCR = 0x80; }while(0) +#endif -inline void HAL_clear_reset_source() { } -inline uint8_t HAL_get_reset_source() { return reset_reason; } +// AVR compatibility +#define strtof strtod -void HAL_reboot(); +// ------------------------ +// Free Memory Accessor +// ------------------------ #pragma GCC diagnostic push #if GCC_VERSION <= 50000 @@ -166,63 +174,100 @@ extern "C" int freeMemory(); #pragma GCC diagnostic pop -// ADC -#ifdef DIDR2 - #define HAL_ANALOG_SELECT(ind) do{ if (ind < 8) SBI(DIDR0, ind); else SBI(DIDR2, ind & 0x07); }while(0) -#else - #define HAL_ANALOG_SELECT(ind) SBI(DIDR0, ind); -#endif +// ------------------------ +// MarlinHAL Class +// ------------------------ -inline void HAL_adc_init() { - ADCSRA = _BV(ADEN) | _BV(ADSC) | _BV(ADIF) | 0x07; - DIDR0 = 0; - #ifdef DIDR2 - DIDR2 = 0; - #endif -} +class MarlinHAL { +public: -#define SET_ADMUX_ADCSRA(ch) ADMUX = _BV(REFS0) | (ch & 0x07); SBI(ADCSRA, ADSC) -#ifdef MUX5 - #define HAL_START_ADC(ch) if (ch > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(ch) -#else - #define HAL_START_ADC(ch) ADCSRB = 0; SET_ADMUX_ADCSRA(ch) -#endif + // Earliest possible init, before setup() + MarlinHAL() {} -#define HAL_ADC_VREF 5.0 -#define HAL_ADC_RESOLUTION 10 -#define HAL_READ_ADC() ADC -#define HAL_ADC_READY() !TEST(ADCSRA, ADSC) + // Watchdog + static void watchdog_init() IF_DISABLED(USE_WATCHDOG, {}); + static void watchdog_refresh() IF_DISABLED(USE_WATCHDOG, {}); -#define GET_PIN_MAP_PIN(index) index -#define GET_PIN_MAP_INDEX(pin) pin -#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + static void init(); // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 -#define HAL_SENSITIVE_PINS 0, 1, + // Interrupts + static bool isr_state() { return TEST(SREG, SREG_I); } + static void isr_on() { sei(); } + static void isr_off() { cli(); } -#ifdef __AVR_AT90USB1286__ - #define JTAG_DISABLE() do{ MCUCR = 0x80; MCUCR = 0x80; }while(0) -#endif + static void delay_ms(const int ms) { _delay_ms(ms); } -// AVR compatibility -#define strtof strtod + // Tasks, called from idle() + static void idletask() {} -#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment + // Reset + static uint8_t reset_reason; + static uint8_t get_reset_source() { return reset_reason; } + static void clear_reset_source() { MCUSR = 0; } -/** - * set_pwm_frequency - * Sets the frequency of the timer corresponding to the provided pin - * as close as possible to the provided desired frequency. Internally - * calculates the required waveform generation mode, prescaler and - * resolution values required and sets the timer registers accordingly. - * NOTE that the frequency is applied to all pins on the timer (Ex OC3A, OC3B and OC3B) - * NOTE that there are limitations, particularly if using TIMER2. (see Configuration_adv.h -> FAST FAN PWM Settings) - */ -void set_pwm_frequency(const pin_t pin, int f_desired); + // Free SRAM + static int freeMemory() { return ::freeMemory(); } -/** - * set_pwm_duty - * Set the PWM duty cycle of the provided pin to the provided value - * Optionally allows inverting the duty cycle [default = false] - * Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255] - */ -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); + // + // ADC Methods + // + + // Called by Temperature::init once at startup + static void adc_init() { + ADCSRA = _BV(ADEN) | _BV(ADSC) | _BV(ADIF) | 0x07; + DIDR0 = 0; + #ifdef DIDR2 + DIDR2 = 0; + #endif + } + + // Called by Temperature::init for each sensor at startup + static void adc_enable(const uint8_t ch) { + #ifdef DIDR2 + if (ch > 7) { SBI(DIDR2, ch & 0x07); return; } + #endif + SBI(DIDR0, ch); + } + + // Begin ADC sampling on the given channel. Called from Temperature::isr! + static void adc_start(const uint8_t ch) { + #ifdef MUX5 + ADCSRB = ch > 7 ? _BV(MUX5) : 0; + #else + ADCSRB = 0; + #endif + ADMUX = _BV(REFS0) | (ch & 0x07); + SBI(ADCSRA, ADSC); + } + + // Is the ADC ready for reading? + static bool adc_ready() { return !TEST(ADCSRA, ADSC); } + + // The current value of the ADC register + static __typeof__(ADC) adc_value() { return ADC; } + + /** + * init_pwm_timers + * Set the default frequency for timers 2-5 to 1000HZ + */ + static void init_pwm_timers(); + + /** + * Set the PWM duty cycle for the pin to the given value. + * Optionally invert the duty cycle [default = false] + * Optionally 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 v_size=255, const bool invert=false); + + /** + * Set the frequency of the timer for the given pin as close as + * possible to the provided desired frequency. Internally calculate + * the required waveform generation mode, prescaler, and resolution + * values and set timer registers accordingly. + * NOTE that the frequency is applied to all pins on the timer (Ex OC3A, OC3B and OC3B) + * NOTE that there are limitations, particularly if using TIMER2. (see Configuration_adv.h -> FAST_PWM_FAN Settings) + */ + static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired); +}; diff --git a/Marlin/src/HAL/AVR/HAL_SPI.cpp b/Marlin/src/HAL/AVR/HAL_SPI.cpp index 8784bb07b30e..dc98f2f79e71 100644 --- a/Marlin/src/HAL/AVR/HAL_SPI.cpp +++ b/Marlin/src/HAL/AVR/HAL_SPI.cpp @@ -35,22 +35,20 @@ void spiBegin() { #if PIN_EXISTS(SD_SS) - OUT_WRITE(SD_SS_PIN, HIGH); + // Do not init HIGH for boards with pin 4 used as Fans or Heaters or otherwise, not likely to have multiple SPI devices anyway. + #if defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__) + // SS must be in output mode even it is not chip select + SET_OUTPUT(SD_SS_PIN); + #else + // set SS high - may be chip select for another SPI device + OUT_WRITE(SD_SS_PIN, HIGH); + #endif #endif SET_OUTPUT(SD_SCK_PIN); SET_INPUT(SD_MISO_PIN); SET_OUTPUT(SD_MOSI_PIN); - #if DISABLED(SOFTWARE_SPI) - // SS must be in output mode even it is not chip select - //SET_OUTPUT(SD_SS_PIN); - // set SS high - may be chip select for another SPI device - //#if SET_SPI_SS_HIGH - //WRITE(SD_SS_PIN, HIGH); - //#endif - // set a default rate - spiInit(1); - #endif + IF_DISABLED(SOFTWARE_SPI, spiInit(SPI_HALF_SPEED)); } #if NONE(SOFTWARE_SPI, FORCE_SOFT_SPI) diff --git a/Marlin/src/HAL/AVR/MarlinSerial.cpp b/Marlin/src/HAL/AVR/MarlinSerial.cpp index cd8bf5e6903b..986462437c8f 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.cpp +++ b/Marlin/src/HAL/AVR/MarlinSerial.cpp @@ -486,7 +486,7 @@ void MarlinSerial::write(const uint8_t c) { const uint8_t i = (tx_buffer.head + 1) & (Cfg::TX_SIZE - 1); // If global interrupts are disabled (as the result of being called from an ISR)... - if (!ISRS_ENABLED()) { + if (!hal.isr_state()) { // Make room by polling if it is possible to transmit, and do so! while (i == tx_buffer.tail) { @@ -534,7 +534,7 @@ void MarlinSerial::flushTX() { if (!_written) return; // If global interrupts are disabled (as the result of being called from an ISR)... - if (!ISRS_ENABLED()) { + if (!hal.isr_state()) { // Wait until everything was transmitted - We must do polling, as interrupts are disabled while (tx_buffer.head != tx_buffer.tail || !B_TXC) { diff --git a/Marlin/src/HAL/AVR/MarlinSerial.h b/Marlin/src/HAL/AVR/MarlinSerial.h index 0565c7b9db9e..7eb76000d66e 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.h +++ b/Marlin/src/HAL/AVR/MarlinSerial.h @@ -191,13 +191,13 @@ rx_framing_errors; static ring_buffer_pos_t rx_max_enqueued; - static FORCE_INLINE ring_buffer_pos_t atomic_read_rx_head(); + FORCE_INLINE static ring_buffer_pos_t atomic_read_rx_head(); static volatile bool rx_tail_value_not_stable; static volatile uint16_t rx_tail_value_backup; - static FORCE_INLINE void atomic_set_rx_tail(ring_buffer_pos_t value); - static FORCE_INLINE ring_buffer_pos_t atomic_read_rx_tail(); + FORCE_INLINE static void atomic_set_rx_tail(ring_buffer_pos_t value); + FORCE_INLINE static ring_buffer_pos_t atomic_read_rx_tail(); public: FORCE_INLINE static void store_rxd_char(); @@ -217,7 +217,7 @@ #endif enum { HasEmergencyParser = Cfg::EMERGENCYPARSER }; - static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; } + static bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; } FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; } FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; } diff --git a/Marlin/src/HAL/AVR/Servo.cpp b/Marlin/src/HAL/AVR/Servo.cpp index 526352b77339..6dc1e2fb0732 100644 --- a/Marlin/src/HAL/AVR/Servo.cpp +++ b/Marlin/src/HAL/AVR/Servo.cpp @@ -66,7 +66,7 @@ static volatile int8_t Channel[_Nbr_16timers]; // counter for the s /************ static functions common to all instances ***********************/ -static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t* TCNTn, volatile uint16_t* OCRnA) { +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 { diff --git a/Marlin/src/HAL/AVR/endstop_interrupts.h b/Marlin/src/HAL/AVR/endstop_interrupts.h index 50f29c3356ce..0ce8574c53d9 100644 --- a/Marlin/src/HAL/AVR/endstop_interrupts.h +++ b/Marlin/src/HAL/AVR/endstop_interrupts.h @@ -301,5 +301,6 @@ void setup_endstop_interrupts() { pciSetup(Z_MIN_PROBE_PIN); #endif #endif + // If we arrive here without raising an assertion, each pin has either an EXT-interrupt or a PCI. } diff --git a/Marlin/src/HAL/AVR/fast_pwm.cpp b/Marlin/src/HAL/AVR/fast_pwm.cpp index 804e5fad3070..0a384172c32a 100644 --- a/Marlin/src/HAL/AVR/fast_pwm.cpp +++ b/Marlin/src/HAL/AVR/fast_pwm.cpp @@ -21,10 +21,7 @@ */ #ifdef __AVR__ -#include "../../inc/MarlinConfigPre.h" -#include "HAL.h" - -#if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM +#include "../../inc/MarlinConfig.h" struct Timer { volatile uint8_t* TCCRnQ[3]; // max 3 TCCR registers per timer @@ -32,229 +29,194 @@ struct Timer { volatile uint16_t* ICRn; // max 1 ICR register per timer uint8_t n; // the timer number [0->5] uint8_t q; // the timer output [0->2] (A->C) + bool isPWM; // True if pin is a "hardware timer" + bool isProtected; // True if timer is protected }; +// Macros for the Timer structure +#define _SET_WGMnQ(T, V) do{ \ + *(T.TCCRnQ)[0] = (*(T.TCCRnQ)[0] & ~(0x3 << 0)) | (( int(V) & 0x3) << 0); \ + *(T.TCCRnQ)[1] = (*(T.TCCRnQ)[1] & ~(0x3 << 3)) | (((int(V) >> 2) & 0x3) << 3); \ + }while(0) + +// Set TCCR CS bits +#define _SET_CSn(T, V) (*(T.TCCRnQ)[1] = (*(T.TCCRnQ[1]) & ~(0x7 << 0)) | ((int(V) & 0x7) << 0)) + +// Set TCCR COM bits +#define _SET_COMnQ(T, Q, V) (*(T.TCCRnQ)[0] = (*(T.TCCRnQ)[0] & ~(0x3 << (6-2*(Q)))) | (int(V) << (6-2*(Q)))) + +// Set OCRnQ register +#define _SET_OCRnQ(T, Q, V) (*(T.OCRnQ)[Q] = int(V) & 0xFFFF) + +// Set ICRn register (one per timer) +#define _SET_ICRn(T, V) (*(T.ICRn) = int(V) & 0xFFFF) + /** - * get_pwm_timer - * Get the timer information and register of the provided pin. - * Return a Timer struct containing this information. - * Used by set_pwm_frequency, set_pwm_duty + * Return a Timer struct describing a pin's timer. */ -Timer get_pwm_timer(const pin_t pin) { +const Timer get_pwm_timer(const pin_t pin) { + uint8_t q = 0; + switch (digitalPinToTimer(pin)) { - // Protect reserved timers (TIMER0 & TIMER1) #ifdef TCCR0A - #if !AVR_AT90USB1286_FAMILY - case TIMER0A: - #endif - case TIMER0B: + IF_DISABLED(AVR_AT90USB1286_FAMILY, case TIMER0A:) #endif #ifdef TCCR1A case TIMER1A: case TIMER1B: #endif - break; - #if HAS_TCCR2 || defined(TCCR2A) - #if HAS_TCCR2 - case TIMER2: { - Timer timer = { - /*TCCRnQ*/ { &TCCR2, nullptr, nullptr }, - /*OCRnQ*/ { (uint16_t*)&OCR2, nullptr, nullptr }, - /*ICRn*/ nullptr, - /*n, q*/ 2, 0 - }; - } - #elif defined(TCCR2A) - #if ENABLED(USE_OCR2A_AS_TOP) - case TIMER2A: break; // protect TIMER2A - case TIMER2B: { - Timer timer = { - /*TCCRnQ*/ { &TCCR2A, &TCCR2B, nullptr }, - /*OCRnQ*/ { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, nullptr }, - /*ICRn*/ nullptr, - /*n, q*/ 2, 1 - }; - return timer; - } - #else - case TIMER2B: ++q; - case TIMER2A: { - Timer timer = { - /*TCCRnQ*/ { &TCCR2A, &TCCR2B, nullptr }, - /*OCRnQ*/ { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, nullptr }, - /*ICRn*/ nullptr, - 2, q - }; - return timer; - } - #endif - #endif + + break; // Protect reserved timers (TIMER0 & TIMER1) + + #ifdef TCCR0A + case TIMER0B: // Protected timer, but allow setting the duty cycle on OCR0B for pin D4 only + return Timer({ { &TCCR0A, nullptr, nullptr }, { (uint16_t*)&OCR0A, (uint16_t*)&OCR0B, nullptr }, nullptr, 0, 1, true, true }); + #endif + + #if HAS_TCCR2 + case TIMER2: + return Timer({ { &TCCR2, nullptr, nullptr }, { (uint16_t*)&OCR2, nullptr, nullptr }, nullptr, 2, 0, true, false }); + #elif ENABLED(USE_OCR2A_AS_TOP) + case TIMER2A: break; // Protect TIMER2A since its OCR is used by TIMER2B + case TIMER2B: + return Timer({ { &TCCR2A, &TCCR2B, nullptr }, { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, nullptr }, nullptr, 2, 1, true, false }); + #elif defined(TCCR2A) + case TIMER2B: ++q; case TIMER2A: + return Timer({ { &TCCR2A, &TCCR2B, nullptr }, { (uint16_t*)&OCR2A, (uint16_t*)&OCR2B, nullptr }, nullptr, 2, q, true, false }); #endif + #ifdef OCR3C - case TIMER3C: ++q; - case TIMER3B: ++q; - case TIMER3A: { - Timer timer = { - /*TCCRnQ*/ { &TCCR3A, &TCCR3B, &TCCR3C }, - /*OCRnQ*/ { &OCR3A, &OCR3B, &OCR3C }, - /*ICRn*/ &ICR3, - /*n, q*/ 3, q - }; - return timer; - } + case TIMER3C: ++q; case TIMER3B: ++q; case TIMER3A: + return Timer({ { &TCCR3A, &TCCR3B, &TCCR3C }, { &OCR3A, &OCR3B, &OCR3C }, &ICR3, 3, q, true, false }); #elif defined(OCR3B) - case TIMER3B: ++q; - case TIMER3A: { - Timer timer = { - /*TCCRnQ*/ { &TCCR3A, &TCCR3B, nullptr }, - /*OCRnQ*/ { &OCR3A, &OCR3B, nullptr }, - /*ICRn*/ &ICR3, - /*n, q*/ 3, q - }; - return timer; - } + case TIMER3B: ++q; case TIMER3A: + return Timer({ { &TCCR3A, &TCCR3B, nullptr }, { &OCR3A, &OCR3B, nullptr }, &ICR3, 3, q, true, false }); #endif + #ifdef TCCR4A - case TIMER4C: ++q; - case TIMER4B: ++q; - case TIMER4A: { - Timer timer = { - /*TCCRnQ*/ { &TCCR4A, &TCCR4B, &TCCR4C }, - /*OCRnQ*/ { &OCR4A, &OCR4B, &OCR4C }, - /*ICRn*/ &ICR4, - /*n, q*/ 4, q - }; - return timer; - } + case TIMER4C: ++q; case TIMER4B: ++q; case TIMER4A: + return Timer({ { &TCCR4A, &TCCR4B, &TCCR4C }, { &OCR4A, &OCR4B, &OCR4C }, &ICR4, 4, q, true, false }); #endif + #ifdef TCCR5A - case TIMER5C: ++q; - case TIMER5B: ++q; - case TIMER5A: { - Timer timer = { - /*TCCRnQ*/ { &TCCR5A, &TCCR5B, &TCCR5C }, - /*OCRnQ*/ { &OCR5A, &OCR5B, &OCR5C }, - /*ICRn*/ &ICR5, - /*n, q*/ 5, q - }; - return timer; - } + case TIMER5C: ++q; case TIMER5B: ++q; case TIMER5A: + return Timer({ { &TCCR5A, &TCCR5B, &TCCR5C }, { &OCR5A, &OCR5B, &OCR5C }, &ICR5, 5, q, true, false }); #endif } - Timer timer = { - /*TCCRnQ*/ { nullptr, nullptr, nullptr }, - /*OCRnQ*/ { nullptr, nullptr, nullptr }, - /*ICRn*/ nullptr, - 0, 0 - }; - return timer; + + return Timer(); } -void set_pwm_frequency(const pin_t pin, int f_desired) { - Timer timer = get_pwm_timer(pin); - if (timer.n == 0) return; // Don't proceed if protected timer or not recognized - uint16_t size; - if (timer.n == 2) size = 255; else size = 65535; +void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t 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; - uint16_t res = 255; // resolution (TOP value) - uint8_t j = 0; // prescaler index - uint8_t wgm = 1; // waveform generation mode + uint16_t res = 0xFF; // resolution (TOP value) + uint8_t j = CS_NONE; // prescaler index + uint8_t wgm = WGM_PWM_PC_8; // waveform generation mode // Calculating the prescaler and resolution to use to achieve closest frequency if (f_desired != 0) { - int f = (F_CPU) / (2 * 1024 * size) + 1; // Initialize frequency as lowest (non-zero) achievable - uint16_t prescaler[] = { 0, 1, 8, /*TIMER2 ONLY*/32, 64, /*TIMER2 ONLY*/128, 256, 1024 }; - - // loop over prescaler values - LOOP_S_L_N(i, 1, 8) { - uint16_t res_temp_fast = 255, res_temp_phase_correct = 255; - if (timer.n == 2) { - // No resolution calculation for TIMER2 unless enabled USE_OCR2A_AS_TOP - #if ENABLED(USE_OCR2A_AS_TOP) - const uint16_t rtf = (F_CPU) / (prescaler[i] * f_desired); - res_temp_fast = rtf - 1; - res_temp_phase_correct = rtf / 2; + 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) + + LOOP_L_N(i, COUNT(prescaler)) { // Loop through all prescaler values + const uint16_t p = prescaler[i]; + 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; + #else + res_fast_temp = res_pc_temp = maxtop; #endif } else { - // Skip TIMER2 specific prescalers when not TIMER2 - if (i == 3 || i == 5) continue; - const uint16_t rtf = (F_CPU) / (prescaler[i] * f_desired); - res_temp_fast = rtf - 1; - res_temp_phase_correct = rtf / 2; + if (p == 32 || p == 128) continue; // Skip TIMER2 specific prescalers when not TIMER2 + const uint16_t rft = (F_CPU) / (p * f_desired); + res_fast_temp = rft - 1; + res_pc_temp = rft / 2; } - LIMIT(res_temp_fast, 1U, size); - LIMIT(res_temp_phase_correct, 1U, size); + LIMIT(res_fast_temp, 1U, maxtop); + LIMIT(res_pc_temp, 1U, maxtop); + // Calculate frequencies of test prescaler and resolution values - const int f_temp_fast = (F_CPU) / (prescaler[i] * (1 + res_temp_fast)), - f_temp_phase_correct = (F_CPU) / (2 * prescaler[i] * res_temp_phase_correct), - f_diff = ABS(f - f_desired), - f_fast_diff = ABS(f_temp_fast - f_desired), - f_phase_diff = ABS(f_temp_phase_correct - f_desired); + const uint32_t f_diff = _MAX(f, f_desired) - _MIN(f, f_desired), + f_fast_temp = (F_CPU) / (p * (1 + res_fast_temp)), + f_fast_diff = _MAX(f_fast_temp, f_desired) - _MIN(f_fast_temp, f_desired), + f_pc_temp = (F_CPU) / (2 * p * res_pc_temp), + f_pc_diff = _MAX(f_pc_temp, f_desired) - _MIN(f_pc_temp, f_desired); - // If FAST values are closest to desired f - if (f_fast_diff < f_diff && f_fast_diff <= f_phase_diff) { - // Remember this combination - f = f_temp_fast; - res = res_temp_fast; - j = i; + 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 - if (timer.n == 2) - wgm = TERN(USE_OCR2A_AS_TOP, WGM2_FAST_PWM_OCR2A, WGM2_FAST_PWM); - else - wgm = WGM_FAST_PWM_ICRn; + 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; } - // If PHASE CORRECT values are closes to desired f - else if (f_phase_diff < f_diff) { - f = f_temp_phase_correct; - res = res_temp_phase_correct; - j = i; + else if (f_pc_diff < f_diff) { // PHASE CORRECT values are closes to desired f // Set the Wave Generation Mode to PWM PHASE CORRECT - if (timer.n == 2) - wgm = TERN(USE_OCR2A_AS_TOP, WGM2_PWM_PC_OCR2A, WGM2_FAST_PWM); - else - wgm = WGM_PWM_PC_ICRn; + 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; } } } - _SET_WGMnQ(timer.TCCRnQ, wgm); - _SET_CSn(timer.TCCRnQ, j); - if (timer.n == 2) { - TERN_(USE_OCR2A_AS_TOP, _SET_OCRnQ(timer.OCRnQ, 0, res)); // Set OCR2A value (TOP) = res + _SET_WGMnQ(timer, wgm); + _SET_CSn(timer, j); + + if (is_timer2) { + TERN_(USE_OCR2A_AS_TOP, _SET_OCRnQ(timer, 0, res)); // Set OCR2A value (TOP) = res } else - _SET_ICRn(timer.ICRn, res); // Set ICRn value (TOP) = res + _SET_ICRn(timer, res); // Set ICRn value (TOP) = res } -#endif // NEEDS_HARDWARE_PWM - -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { - #if NEEDS_HARDWARE_PWM - - // If v is 0 or v_size (max), digitalWrite to LOW or HIGH. - // Note that digitalWrite also disables pwm output for us (sets COM bit to 0) - if (v == 0) - digitalWrite(pin, invert); - else if (v == v_size) - digitalWrite(pin, !invert); - else { - Timer timer = get_pwm_timer(pin); - if (timer.n == 0) return; // Don't proceed if protected timer or not recognized - // Set compare output mode to CLEAR -> SET or SET -> CLEAR (if inverted) - _SET_COMnQ(timer.TCCRnQ, timer.q TERN_(HAS_TCCR2, + (timer.q == 2)), COM_CLEAR_SET + invert); // COM20 is on bit 4 of TCCR2, so +1 for q==2 - const uint16_t top = timer.n == 2 ? TERN(USE_OCR2A_AS_TOP, *timer.OCRnQ[0], 255) : *timer.ICRn; - _SET_OCRnQ(timer.OCRnQ, timer.q, uint16_t(uint32_t(v) * top / v_size)); // Scale 8/16-bit v to top value +void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { + // If v is 0 or v_size (max), digitalWrite to LOW or HIGH. + // Note that digitalWrite also disables PWM output for us (sets COM bit to 0) + if (v == 0) + digitalWrite(pin, invert); + else if (v == v_size) + digitalWrite(pin, !invert); + else { + const Timer timer = get_pwm_timer(pin); + if (timer.isPWM) { + if (timer.n == 0) { + _SET_COMnQ(timer, timer.q, COM_CLEAR_SET); // Only allow a TIMER0B select... + _SET_OCRnQ(timer, timer.q, v); // ...and OCR0B duty update. For output pin D4 no frequency changes are permitted. + } + else if (!timer.isProtected) { + const uint16_t top = timer.n == 2 ? TERN(USE_OCR2A_AS_TOP, *timer.OCRnQ[0], 255) : *timer.ICRn; + _SET_COMnQ(timer, SUM_TERN(HAS_TCCR2, timer.q, timer.q == 2), COM_CLEAR_SET + invert); // COM20 is on bit 4 of TCCR2, so +1 for q==2 + _SET_OCRnQ(timer, timer.q, uint16_t(uint32_t(v) * top / v_size)); // Scale 8/16-bit v to top value + } } + else + digitalWrite(pin, v < v_size / 2 ? LOW : HIGH); + } +} - #else - - analogWrite(pin, v); - UNUSED(v_size); - UNUSED(invert); +void MarlinHAL::init_pwm_timers() { + // Init some timer frequencies to a default 1KHz + const pin_t pwm_pin[] = { + #ifdef __AVR_ATmega2560__ + 10, 5, 6, 46 + #elif defined(__AVR_ATmega1280__) + 12, 31 + #elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega1284__) + 15, 6 + #elif defined(__AVR_AT90USB1286__) || defined(__AVR_mega64) || defined(__AVR_mega128) + 16, 24 + #endif + }; - #endif + LOOP_L_N(i, COUNT(pwm_pin)) + set_pwm_frequency(pwm_pin[i], 1000); } #endif // __AVR__ diff --git a/Marlin/src/HAL/AVR/fastio.cpp b/Marlin/src/HAL/AVR/fastio.cpp index 8af3ef805efa..5c6ef1891512 100644 --- a/Marlin/src/HAL/AVR/fastio.cpp +++ b/Marlin/src/HAL/AVR/fastio.cpp @@ -245,7 +245,7 @@ uint16_t set_pwm_frequency_hz(const_float_t hz, const float dca, const float dcb float count = 0; if (hz > 0 && (dca || dcb || dcc)) { count = float(F_CPU) / hz; // 1x prescaler, TOP for 16MHz base freq. - uint16_t prescaler; // Range of 30.5Hz (65535) 64.5KHz (>31) + uint16_t prescaler; // Range of 30.5Hz (65535) 64.5kHz (>31) if (count >= 255. * 256.) { prescaler = 1024; SET_CS(5, PRESCALER_1024); } else if (count >= 255. * 64.) { prescaler = 256; SET_CS(5, PRESCALER_256); } @@ -257,7 +257,7 @@ uint16_t set_pwm_frequency_hz(const_float_t hz, const float dca, const float dcb const float pwm_top = round(count); // Get the rounded count ICR5 = (uint16_t)pwm_top - 1; // Subtract 1 for TOP - OCR5A = pwm_top * ABS(dca); // Update and scale DCs + OCR5A = pwm_top * ABS(dca); // Update and scale DCs OCR5B = pwm_top * ABS(dcb); OCR5C = pwm_top * ABS(dcc); _SET_COM(5, A, dca ? (dca < 0 ? COM_SET_CLEAR : COM_CLEAR_SET) : COM_NORMAL); // Set compare modes @@ -277,7 +277,7 @@ uint16_t set_pwm_frequency_hz(const_float_t hz, const float dca, const float dcb // Restore the default for Timer 5 SET_WGM(5, PWM_PC_8); // PWM 8-bit (Phase Correct) SET_COMS(5, NORMAL, NORMAL, NORMAL); // Do nothing - SET_CS(5, PRESCALER_64); // 16MHz / 64 = 250KHz + SET_CS(5, PRESCALER_64); // 16MHz / 64 = 250kHz OCR5A = OCR5B = OCR5C = 0; } return round(count); diff --git a/Marlin/src/HAL/AVR/fastio.h b/Marlin/src/HAL/AVR/fastio.h index db6e598b8670..51d3b311ee9d 100644 --- a/Marlin/src/HAL/AVR/fastio.h +++ b/Marlin/src/HAL/AVR/fastio.h @@ -118,7 +118,7 @@ */ // Waveform Generation Modes -enum WaveGenMode : char { +enum WaveGenMode : uint8_t { WGM_NORMAL, // 0 WGM_PWM_PC_8, // 1 WGM_PWM_PC_9, // 2 @@ -138,19 +138,19 @@ enum WaveGenMode : char { }; // Wavefore Generation Modes (Timer 2 only) -enum WaveGenMode2 : char { - WGM2_NORMAL, // 0 - WGM2_PWM_PC, // 1 - WGM2_CTC_OCR2A, // 2 - WGM2_FAST_PWM, // 3 - WGM2_reserved_1, // 4 - WGM2_PWM_PC_OCR2A, // 5 - WGM2_reserved_2, // 6 - WGM2_FAST_PWM_OCR2A, // 7 +enum WaveGenMode2 : uint8_t { + WGM2_NORMAL, // 0 + WGM2_PWM_PC, // 1 + WGM2_CTC_OCR2A, // 2 + WGM2_FAST_PWM, // 3 + WGM2_reserved_1, // 4 + WGM2_PWM_PC_OCR2A, // 5 + WGM2_reserved_2, // 6 + WGM2_FAST_PWM_OCR2A, // 7 }; // Compare Modes -enum CompareMode : char { +enum CompareMode : uint8_t { COM_NORMAL, // 0 COM_TOGGLE, // 1 Non-PWM: OCnx ... Both PWM (WGM 9,11,14,15): OCnA only ... else NORMAL COM_CLEAR_SET, // 2 Non-PWM: OCnx ... Fast PWM: OCnx/Bottom ... PF-FC: OCnx Up/Down @@ -158,7 +158,7 @@ enum CompareMode : char { }; // Clock Sources -enum ClockSource : char { +enum ClockSource : uint8_t { CS_NONE, // 0 CS_PRESCALER_1, // 1 CS_PRESCALER_8, // 2 @@ -170,7 +170,7 @@ enum ClockSource : char { }; // Clock Sources (Timer 2 only) -enum ClockSource2 : char { +enum ClockSource2 : uint8_t { CS2_NONE, // 0 CS2_PRESCALER_1, // 1 CS2_PRESCALER_8, // 2 @@ -203,11 +203,6 @@ enum ClockSource2 : char { TCCR##T##B = (TCCR##T##B & ~(0x3 << WGM##T##2)) | (((int(V) >> 2) & 0x3) << WGM##T##2); \ }while(0) #define SET_WGM(T,V) _SET_WGM(T,WGM_##V) -// Runtime (see set_pwm_frequency): -#define _SET_WGMnQ(TCCRnQ, V) do{ \ - *(TCCRnQ)[0] = (*(TCCRnQ)[0] & ~(0x3 << 0)) | (( int(V) & 0x3) << 0); \ - *(TCCRnQ)[1] = (*(TCCRnQ)[1] & ~(0x3 << 3)) | (((int(V) >> 2) & 0x3) << 3); \ - }while(0) // Set Clock Select bits // Ex: SET_CS3(PRESCALER_64); @@ -235,8 +230,6 @@ enum ClockSource2 : char { #define SET_CS4(V) _SET_CS4(CS_##V) #define SET_CS5(V) _SET_CS5(CS_##V) #define SET_CS(T,V) SET_CS##T(V) -// Runtime (see set_pwm_frequency) -#define _SET_CSn(TCCRnQ, V) (*(TCCRnQ)[1] = (*(TCCRnQ[1]) & ~(0x7 << 0)) | ((int(V) & 0x7) << 0)) // Set Compare Mode bits // Ex: SET_COMS(4,CLEAR_SET,CLEAR_SET,CLEAR_SET); @@ -246,16 +239,6 @@ enum ClockSource2 : char { #define SET_COMB(T,V) SET_COM(T,B,V) #define SET_COMC(T,V) SET_COM(T,C,V) #define SET_COMS(T,V1,V2,V3) do{ SET_COMA(T,V1); SET_COMB(T,V2); SET_COMC(T,V3); }while(0) -// Runtime (see set_pwm_duty) -#define _SET_COMnQ(TCCRnQ, Q, V) (*(TCCRnQ)[0] = (*(TCCRnQ)[0] & ~(0x3 << (6-2*(Q)))) | (int(V) << (6-2*(Q)))) - -// Set OCRnQ register -// Runtime (see set_pwm_duty): -#define _SET_OCRnQ(OCRnQ, Q, V) (*(OCRnQ)[Q] = int(V) & 0xFFFF) - -// Set ICRn register (one per timer) -// Runtime (see set_pwm_frequency) -#define _SET_ICRn(ICRn, V) (*(ICRn) = int(V) & 0xFFFF) // Set Noise Canceler bit // Ex: SET_ICNC(2,1) diff --git a/Marlin/src/HAL/AVR/inc/SanityCheck.h b/Marlin/src/HAL/AVR/inc/SanityCheck.h index 2f80d1fee165..1c1d8d441351 100644 --- a/Marlin/src/HAL/AVR/inc/SanityCheck.h +++ b/Marlin/src/HAL/AVR/inc/SanityCheck.h @@ -25,11 +25,43 @@ * Test AVR-specific configuration values for errors at compile-time. */ +/** + * Check for common serial pin conflicts + */ +#define CHECK_SERIAL_PIN(N) ( \ + X_STOP_PIN == N || Y_STOP_PIN == N || Z_STOP_PIN == N \ + || X_MIN_PIN == N || Y_MIN_PIN == N || Z_MIN_PIN == N \ + || X_MAX_PIN == N || Y_MAX_PIN == N || Z_MAX_PIN == N \ + || 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 \ +) +#if CONF_SERIAL_IS(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." +#endif +#if CONF_SERIAL_IS(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)) + #error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board." +#endif +#undef CHECK_SERIAL_PIN + /** * Checks for FAST PWM */ #if ALL(FAST_PWM_FAN, USE_OCR2A_AS_TOP, HAS_TCCR2) - #error "USE_OCR2A_AS_TOP does not apply to devices with a single output TIMER2" + #error "USE_OCR2A_AS_TOP does not apply to devices with a single output TIMER2." +#endif + +/** + * Checks for SOFT PWM + */ +#if HAS_FAN0 && FAN_PIN == 9 && DISABLED(FAN_SOFT_PWM) && ENABLED(SPEAKER) + #error "FAN_PIN 9 Hardware PWM uses Timer 2 which conflicts with Arduino AVR Tone Timer (for SPEAKER)." + #error "Disable SPEAKER or enable FAN_SOFT_PWM." #endif /** @@ -42,7 +74,7 @@ #elif NUM_SERVOS > 0 && defined(_useTimer3) && (WITHIN(SPINDLE_LASER_PWM_PIN, 2, 3) || SPINDLE_LASER_PWM_PIN == 5) #error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by the servo system." #endif -#elif defined(SPINDLE_LASER_FREQUENCY) +#elif SPINDLE_LASER_FREQUENCY #error "SPINDLE_LASER_FREQUENCY requires SPINDLE_LASER_USE_PWM." #endif @@ -63,3 +95,7 @@ #if ENABLED(POSTMORTEM_DEBUGGING) #error "POSTMORTEM_DEBUGGING is not supported on AVR boards." #endif + +#if USING_PULLDOWNS + #error "PULLDOWN pin mode is not available on AVR boards." +#endif diff --git a/Marlin/src/HAL/AVR/math.h b/Marlin/src/HAL/AVR/math.h index 7ede4accc09e..7dd1018ff199 100644 --- a/Marlin/src/HAL/AVR/math.h +++ b/Marlin/src/HAL/AVR/math.h @@ -35,7 +35,7 @@ // C B A is longIn1 // D C B A is longIn2 // -static FORCE_INLINE uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2) { +FORCE_INLINE static uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2) { uint8_t tmp1; uint8_t tmp2; uint16_t intRes; @@ -89,7 +89,7 @@ static FORCE_INLINE uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2 // uses: // r26 to store 0 // r27 to store the byte 1 of the 24 bit result -static FORCE_INLINE uint16_t MultiU16X8toH16(uint8_t charIn1, uint16_t intIn2) { +FORCE_INLINE static uint16_t MultiU16X8toH16(uint8_t charIn1, uint16_t intIn2) { uint8_t tmp; uint16_t intRes; __asm__ __volatile__ ( diff --git a/Marlin/src/HAL/AVR/pinsDebug.h b/Marlin/src/HAL/AVR/pinsDebug.h index 0f564df987f3..dab4e4471524 100644 --- a/Marlin/src/HAL/AVR/pinsDebug.h +++ b/Marlin/src/HAL/AVR/pinsDebug.h @@ -74,7 +74,7 @@ #define MULTI_NAME_PAD 26 // space needed to be pretty if not first name assigned to a pin void PRINT_ARRAY_NAME(uint8_t x) { - char *name_mem_pointer = (char*)pgm_read_ptr(&pin_array[x].name); + PGM_P const name_mem_pointer = (PGM_P)pgm_read_ptr(&pin_array[x].name); LOOP_L_N(y, MAX_NAME_LENGTH) { char temp_char = pgm_read_byte(name_mem_pointer + y); if (temp_char != 0) diff --git a/Marlin/src/HAL/AVR/timers.h b/Marlin/src/HAL/AVR/timers.h index 36b04eae0d1f..33c3880b6b99 100644 --- a/Marlin/src/HAL/AVR/timers.h +++ b/Marlin/src/HAL/AVR/timers.h @@ -58,9 +58,9 @@ typedef uint16_t hal_timer_t; #define DISABLE_STEPPER_DRIVER_INTERRUPT() CBI(TIMSK1, OCIE1A) #define STEPPER_ISR_ENABLED() TEST(TIMSK1, OCIE1A) -#define ENABLE_TEMPERATURE_INTERRUPT() SBI(TIMSK0, OCIE0B) -#define DISABLE_TEMPERATURE_INTERRUPT() CBI(TIMSK0, OCIE0B) -#define TEMPERATURE_ISR_ENABLED() TEST(TIMSK0, OCIE0B) +#define ENABLE_TEMPERATURE_INTERRUPT() SBI(TIMSK0, OCIE0A) +#define DISABLE_TEMPERATURE_INTERRUPT() CBI(TIMSK0, OCIE0A) +#define TEMPERATURE_ISR_ENABLED() TEST(TIMSK0, OCIE0A) FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) { switch (timer_num) { @@ -87,7 +87,7 @@ FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) { case MF_TIMER_TEMP: // Use timer0 for temperature measurement // Interleave temperature interrupt with millies interrupt - OCR0B = 128; + OCR0A = 128; break; } } @@ -109,12 +109,12 @@ FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) { * (otherwise, characters will be lost due to UART overflow). * Then: Stepper, Endstops, Temperature, and -finally- all others. */ -#define HAL_timer_isr_prologue(T) -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_prologue(T) NOOP +#define HAL_timer_isr_epilogue(T) NOOP -/* 18 cycles maximum latency */ #ifndef HAL_STEP_TIMER_ISR +/* 18 cycles maximum latency */ #define HAL_STEP_TIMER_ISR() \ extern "C" void TIMER1_COMPA_vect() __attribute__ ((signal, naked, used, externally_visible)); \ extern "C" void TIMER1_COMPA_vect_bottom() asm ("TIMER1_COMPA_vect_bottom") __attribute__ ((used, externally_visible, noinline)); \ @@ -180,7 +180,7 @@ void TIMER1_COMPA_vect() { \ : \ : [timsk0] "i" ((uint16_t)&TIMSK0), \ [timsk1] "i" ((uint16_t)&TIMSK1), \ - [msk0] "M" ((uint8_t)(1<. - * - */ -#ifdef __AVR__ - -#include "../../inc/MarlinConfig.h" - -#if ENABLED(USE_WATCHDOG) - -#include "watchdog.h" - -#include "../../MarlinCore.h" - -// Initialize watchdog with 8s timeout, if possible. Otherwise, make it 4s. -void watchdog_init() { - #if ENABLED(WATCHDOG_DURATION_8S) && defined(WDTO_8S) - #define WDTO_NS WDTO_8S - #else - #define WDTO_NS WDTO_4S - #endif - #if ENABLED(WATCHDOG_RESET_MANUAL) - // Enable the watchdog timer, but only for the interrupt. - // Take care, as this requires the correct order of operation, with interrupts disabled. - // See the datasheet of any AVR chip for details. - wdt_reset(); - cli(); - _WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE); - _WD_CONTROL_REG = _BV(WDIE) | (WDTO_NS & 0x07) | ((WDTO_NS & 0x08) << 2); // WDTO_NS directly does not work. bit 0-2 are consecutive in the register but the highest value bit is at bit 5 - // So worked for up to WDTO_2S - sei(); - wdt_reset(); - #else - wdt_enable(WDTO_NS); // The function handles the upper bit correct. - #endif - //delay(10000); // test it! -} - -//=========================================================================== -//=================================== ISR =================================== -//=========================================================================== - -// Watchdog timer interrupt, called if main program blocks >4sec and manual reset is enabled. -#if ENABLED(WATCHDOG_RESET_MANUAL) - ISR(WDT_vect) { - sei(); // With the interrupt driven serial we need to allow interrupts. - SERIAL_ERROR_MSG(STR_WATCHDOG_FIRED); - minkill(); // interrupt-safe final kill and infinite loop - } -#endif - -#endif // USE_WATCHDOG -#endif // __AVR__ diff --git a/Marlin/src/HAL/DUE/HAL.cpp b/Marlin/src/HAL/DUE/HAL.cpp index a3985652e71d..4353f1649732 100644 --- a/Marlin/src/HAL/DUE/HAL.cpp +++ b/Marlin/src/HAL/DUE/HAL.cpp @@ -25,7 +25,7 @@ #ifdef ARDUINO_ARCH_SAM #include "../../inc/MarlinConfig.h" -#include "HAL.h" +#include "../../MarlinCore.h" #include #include "usb/usb_task.h" @@ -34,39 +34,33 @@ // Public Variables // ------------------------ -uint16_t HAL_adc_result; +uint16_t MarlinHAL::adc_result; // ------------------------ // Public functions // ------------------------ -TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial()); +#if ENABLED(POSTMORTEM_DEBUGGING) + extern void install_min_serial(); +#endif -// HAL initialization task -void HAL_init() { - // Initialize the USB stack +void MarlinHAL::init() { #if ENABLED(SDSUPPORT) OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up #endif - usb_task_init(); + usb_task_init(); // Initialize the USB stack TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the min serial handler } -// HAL idle task -void HAL_idletask() { - // Perform USB stack housekeeping - usb_task_idle(); +void MarlinHAL::init_board() { + #ifdef BOARD_INIT + BOARD_INIT(); + #endif } -// Disable interrupts -void cli() { noInterrupts(); } - -// Enable interrupts -void sei() { interrupts(); } +void MarlinHAL::idletask() { usb_task_idle(); } // Perform USB stack housekeeping -void HAL_clear_reset_source() { } - -uint8_t HAL_get_reset_source() { +uint8_t MarlinHAL::get_reset_source() { switch ((RSTC->RSTC_SR >> 8) & 0x07) { case 0: return RST_POWER_ON; case 1: return RST_BACKUP; @@ -77,13 +71,105 @@ uint8_t HAL_get_reset_source() { } } -void HAL_reboot() { rstc_start_software_reset(RSTC); } +void MarlinHAL::reboot() { rstc_start_software_reset(RSTC); } + +// ------------------------ +// Watchdog Timer +// ------------------------ + +#if ENABLED(USE_WATCHDOG) + + // Initialize watchdog - On SAM3X, Watchdog was already configured + // and enabled or disabled at startup, so no need to reconfigure it + // here. + void MarlinHAL::watchdog_init() { WDT_Restart(WDT); } // Reset watchdog to start clean + + // Reset watchdog. MUST be called at least every 4 seconds after the + // first watchdog_init or AVR will go into emergency procedures. + void MarlinHAL::watchdog_refresh() { watchdogReset(); } + +#endif + +// Override Arduino runtime to either config or disable the watchdog +// +// We need to configure the watchdog as soon as possible in the boot +// process, because watchdog initialization at hardware reset on SAM3X8E +// is unreliable, and there is risk of unintended resets if we delay +// that initialization to a later time. +void watchdogSetup() { + + #if ENABLED(USE_WATCHDOG) + + // 4 seconds timeout + uint32_t timeout = TERN(WATCHDOG_DURATION_8S, 8000, 4000); + + // Calculate timeout value in WDT counter ticks: This assumes + // the slow clock is running at 32.768 kHz watchdog + // frequency is therefore 32768 / 128 = 256 Hz + timeout = (timeout << 8) / 1000; + if (timeout == 0) + timeout = 1; + else if (timeout > 0xFFF) + timeout = 0xFFF; + + // We want to enable the watchdog with the specified timeout + uint32_t value = + WDT_MR_WDV(timeout) | // With the specified timeout + WDT_MR_WDD(timeout) | // and no invalid write window + #if !(SAMV70 || SAMV71 || SAME70 || SAMS70) + WDT_MR_WDRPROC | // WDT fault resets processor only - We want + // to keep PIO controller state + #endif + WDT_MR_WDDBGHLT | // WDT stops in debug state. + WDT_MR_WDIDLEHLT; // WDT stops in idle state. + + #if ENABLED(WATCHDOG_RESET_MANUAL) + // We enable the watchdog timer, but only for the interrupt. + + // Configure WDT to only trigger an interrupt + value |= WDT_MR_WDFIEN; // Enable WDT fault interrupt. -void _delay_ms(const int delay_ms) { - // Todo: port for Due? - delay(delay_ms); + // Disable WDT interrupt (just in case, to avoid triggering it!) + NVIC_DisableIRQ(WDT_IRQn); + + // 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(); + + // Initialize WDT with the given parameters + WDT_Enable(WDT, value); + + // Configure and enable WDT interrupt. + NVIC_ClearPendingIRQ(WDT_IRQn); + NVIC_SetPriority(WDT_IRQn, 0); // Use highest priority, so we detect all kinds of lockups + NVIC_EnableIRQ(WDT_IRQn); + + #else + + // a WDT fault triggers a reset + value |= WDT_MR_WDRSTEN; + + // Initialize WDT with the given parameters + WDT_Enable(WDT, value); + + #endif + + // Reset the watchdog + WDT_Restart(WDT); + + #else + + // Make sure to completely disable the Watchdog + WDT_Disable(WDT); + + #endif } +// ------------------------ +// Free Memory Accessor +// ------------------------ + extern "C" { extern unsigned int _ebss; // end of bss section } @@ -95,18 +181,9 @@ int freeMemory() { } // ------------------------ -// ADC +// Serial Ports // ------------------------ -void HAL_adc_start_conversion(const uint8_t ch) { - HAL_adc_result = analogRead(ch); -} - -uint16_t HAL_adc_get_result() { - // nop - return HAL_adc_result; -} - // Forward the default serial ports #if USING_HW_SERIAL0 DefaultSerial1 MSerial0(false, Serial); diff --git a/Marlin/src/HAL/DUE/HAL.h b/Marlin/src/HAL/DUE/HAL.h index 96ab5d9808ac..4d3f4823a517 100644 --- a/Marlin/src/HAL/DUE/HAL.h +++ b/Marlin/src/HAL/DUE/HAL.h @@ -32,12 +32,15 @@ #include "../shared/math_32bit.h" #include "../shared/HAL_SPI.h" #include "fastio.h" -#include "watchdog.h" #include #include "../../core/serial_hook.h" +// ------------------------ +// Serial ports +// ------------------------ + typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1; typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2; typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3; @@ -97,60 +100,38 @@ extern DefaultSerial4 MSerial3; #include "MarlinSerial.h" #include "MarlinSerialUSB.h" -// On AVR this is in math.h? -#define square(x) ((x)*(x)) +// ------------------------ +// Types +// ------------------------ typedef int8_t pin_t; -#define SHARED_SERVOS HAS_SERVOS -#define HAL_SERVO_LIB Servo +#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +class Servo; +typedef Servo hal_servo_t; // // Interrupts // -#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_PRIMASK()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() - -void cli(); // Disable interrupts -void sei(); // Enable interrupts +#define sei() interrupts() +#define cli() noInterrupts() -void HAL_clear_reset_source(); // clear reset reason -uint8_t HAL_get_reset_source(); // get reset reason - -void HAL_reboot(); +#define CRITICAL_SECTION_START() const bool _irqon = hal.isr_state(); hal.isr_off() +#define CRITICAL_SECTION_END() if (_irqon) hal.isr_on() // // ADC // -extern uint16_t HAL_adc_result; // result of last ADC conversion +#define HAL_ADC_VREF 3.3 +#define HAL_ADC_RESOLUTION 10 #ifndef analogInputToDigitalPin #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) #endif -#define HAL_ANALOG_SELECT(ch) - -inline void HAL_adc_init() {}//todo - -#define HAL_ADC_VREF 3.3 -#define HAL_ADC_RESOLUTION 10 -#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch) -#define HAL_READ_ADC() HAL_adc_result -#define HAL_ADC_READY() true - -void HAL_adc_start_conversion(const uint8_t ch); -uint16_t HAL_adc_get_result(); - -// -// PWM // -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } - -// -// Pin Map +// Pin Mapping for M42, M43, M226 // #define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_INDEX(pin) pin @@ -159,27 +140,18 @@ inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, // // Tone // -void toneInit(); void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0); void noTone(const pin_t _pin); -// Enable hooks into idle and setup for HAL -#define HAL_IDLETASK 1 -void HAL_idletask(); -void HAL_init(); - -// -// Utility functions -// -void _delay_ms(const int delay); +// ------------------------ +// Class Utilities +// ------------------------ #pragma GCC diagnostic push #if GCC_VERSION <= 50000 #pragma GCC diagnostic ignored "-Wunused-function" #endif -int freeMemory(); - #pragma GCC diagnostic pop #ifdef __cplusplus @@ -189,3 +161,73 @@ char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s #ifdef __cplusplus } #endif + +// Return free RAM between end of heap (or end bss) and whatever is current +int freeMemory(); + +// ------------------------ +// 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 + + // Interrupts + static bool isr_state() { return !__get_PRIMASK(); } + static void isr_on() { __enable_irq(); } + static void isr_off() { __disable_irq(); } + + 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 channel. Called from Temperature::isr! + static void adc_start(const uint8_t ch) { adc_result = analogRead(ch); } + + // 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 inverting the duty cycle in this HAL. + * No changing the maximum size of the provided value to enable finer PWM duty control in this HAL. + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } + +}; diff --git a/Marlin/src/HAL/DUE/HAL_SPI.cpp b/Marlin/src/HAL/DUE/HAL_SPI.cpp index c5e8f2433d7d..7e3fe0135645 100644 --- a/Marlin/src/HAL/DUE/HAL_SPI.cpp +++ b/Marlin/src/HAL/DUE/HAL_SPI.cpp @@ -31,8 +31,6 @@ /** * HAL for Arduino Due and compatible (SAM3X8E) - * - * For ARDUINO_ARCH_SAM */ #ifdef ARDUINO_ARCH_SAM diff --git a/Marlin/src/HAL/DUE/MarlinSerial.cpp b/Marlin/src/HAL/DUE/MarlinSerial.cpp index fe62ff5607d5..638f7a100722 100644 --- a/Marlin/src/HAL/DUE/MarlinSerial.cpp +++ b/Marlin/src/HAL/DUE/MarlinSerial.cpp @@ -406,7 +406,7 @@ size_t MarlinSerial::write(const uint8_t c) { const uint8_t i = (tx_buffer.head + 1) & (Cfg::TX_SIZE - 1); // If global interrupts are disabled (as the result of being called from an ISR)... - if (!ISRS_ENABLED()) { + if (!hal.isr_state()) { // Make room by polling if it is possible to transmit, and do so! while (i == tx_buffer.tail) { @@ -454,7 +454,7 @@ void MarlinSerial::flushTX() { if (!_written) return; // If global interrupts are disabled (as the result of being called from an ISR)... - if (!ISRS_ENABLED()) { + if (!hal.isr_state()) { // Wait until everything was transmitted - We must do polling, as interrupts are disabled while (tx_buffer.head != tx_buffer.tail || !(HWUART->UART_SR & UART_SR_TXEMPTY)) { diff --git a/Marlin/src/HAL/DUE/MarlinSerial.h b/Marlin/src/HAL/DUE/MarlinSerial.h index 4a62e2834f7f..5a61bffee0da 100644 --- a/Marlin/src/HAL/DUE/MarlinSerial.h +++ b/Marlin/src/HAL/DUE/MarlinSerial.h @@ -118,7 +118,7 @@ class MarlinSerial { static size_t write(const uint8_t c); static void flushTX(); - static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; } + static bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; } FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; } FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; } diff --git a/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp b/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp index 67c597da80c4..8de2dc7924a0 100644 --- a/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp +++ b/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp @@ -41,7 +41,7 @@ extern "C" { int udi_cdc_getc(); bool udi_cdc_is_tx_ready(); int udi_cdc_putc(int value); -}; +} // Pending character static int pending_char = -1; diff --git a/Marlin/src/HAL/DUE/HAL_MinSerial.cpp b/Marlin/src/HAL/DUE/MinSerial.cpp similarity index 98% rename from Marlin/src/HAL/DUE/HAL_MinSerial.cpp rename to Marlin/src/HAL/DUE/MinSerial.cpp index 93c4ed67d63c..e5b3dbfe6f36 100644 --- a/Marlin/src/HAL/DUE/HAL_MinSerial.cpp +++ b/Marlin/src/HAL/DUE/MinSerial.cpp @@ -25,7 +25,7 @@ #if ENABLED(POSTMORTEM_DEBUGGING) -#include "../shared/HAL_MinSerial.h" +#include "../shared/MinSerial.h" #include diff --git a/Marlin/src/HAL/DUE/Servo.cpp b/Marlin/src/HAL/DUE/Servo.cpp index 5524aa9cef47..72a7d649ef04 100644 --- a/Marlin/src/HAL/DUE/Servo.cpp +++ b/Marlin/src/HAL/DUE/Servo.cpp @@ -52,7 +52,7 @@ static volatile int8_t Channel[_Nbr_16timers]; // counter for the s // ------------------------ /// Interrupt handler for the TC0 channel 1. // ------------------------ -void Servo_Handler(timer16_Sequence_t timer, Tc *pTc, uint8_t channel); +void Servo_Handler(const timer16_Sequence_t, Tc*, const uint8_t); #ifdef _useTimer1 void HANDLER_FOR_TIMER1() { Servo_Handler(_timer1, TC_FOR_TIMER1, CHANNEL_FOR_TIMER1); } @@ -70,7 +70,7 @@ void Servo_Handler(timer16_Sequence_t timer, Tc *pTc, uint8_t channel); void HANDLER_FOR_TIMER5() { Servo_Handler(_timer5, TC_FOR_TIMER5, CHANNEL_FOR_TIMER5); } #endif -void Servo_Handler(timer16_Sequence_t timer, Tc *tc, uint8_t channel) { +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) @@ -113,26 +113,21 @@ static void _initISR(Tc *tc, uint32_t channel, uint32_t id, IRQn_Type irqn) { TC_Start(tc, channel); } -void initISR(timer16_Sequence_t timer) { +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); + 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); + 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); + 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); + 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); + if (timer == _timer5) _initISR(TC_FOR_TIMER5, CHANNEL_FOR_TIMER5, ID_TC_FOR_TIMER5, IRQn_FOR_TIMER5); #endif } diff --git a/Marlin/src/HAL/DUE/Tone.cpp b/Marlin/src/HAL/DUE/Tone.cpp index 1ac81faaf0e1..4bc8142aba27 100644 --- a/Marlin/src/HAL/DUE/Tone.cpp +++ b/Marlin/src/HAL/DUE/Tone.cpp @@ -35,7 +35,7 @@ static pin_t tone_pin; volatile static int32_t toggles; -void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration) { +void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration/*=0*/) { tone_pin = _pin; toggles = 2 * frequency * duration / 1000; HAL_timer_start(MF_TIMER_TONE, 2 * frequency); diff --git a/Marlin/src/HAL/DUE/eeprom_flash.cpp b/Marlin/src/HAL/DUE/eeprom_flash.cpp index 7ce4a84df531..607764155b0a 100644 --- a/Marlin/src/HAL/DUE/eeprom_flash.cpp +++ b/Marlin/src/HAL/DUE/eeprom_flash.cpp @@ -199,8 +199,7 @@ static bool ee_PageWrite(uint16_t page, const void *data) { for (i = 0; i > 2; i++) pageContents[i] = (((uint32_t*)data)[i]) | (~(pageContents[i] ^ ((uint32_t*)data)[i])); - DEBUG_ECHO_START(); - DEBUG_ECHOLNPGM("EEPROM PageWrite ", page); + DEBUG_ECHO_MSG("EEPROM PageWrite ", page); DEBUG_ECHOLNPGM(" in FLASH address ", (uint32_t)addrflash); DEBUG_ECHOLNPGM(" base address ", (uint32_t)getFlashStorage(0)); DEBUG_FLUSH(); @@ -245,8 +244,7 @@ static bool ee_PageWrite(uint16_t page, const void *data) { // Reenable interrupts __enable_irq(); - DEBUG_ECHO_START(); - DEBUG_ECHOLNPGM("EEPROM Unlock failure for page ", page); + DEBUG_ECHO_MSG("EEPROM Unlock failure for page ", page); return false; } @@ -270,8 +268,7 @@ static bool ee_PageWrite(uint16_t page, const void *data) { // Reenable interrupts __enable_irq(); - DEBUG_ECHO_START(); - DEBUG_ECHOLNPGM("EEPROM Write failure for page ", page); + DEBUG_ECHO_MSG("EEPROM Write failure for page ", page); return false; } @@ -286,8 +283,7 @@ static bool ee_PageWrite(uint16_t page, const void *data) { if (memcmp(getFlashStorage(page),data,PageSize)) { #ifdef EE_EMU_DEBUG - DEBUG_ECHO_START(); - DEBUG_ECHOLNPGM("EEPROM Verify Write failure for page ", page); + DEBUG_ECHO_MSG("EEPROM Verify Write failure for page ", page); ee_Dump( page, (uint32_t *)addrflash); ee_Dump(-page, data); @@ -325,8 +321,7 @@ static bool ee_PageErase(uint16_t page) { uint16_t i; uint32_t addrflash = uint32_t(getFlashStorage(page)); - DEBUG_ECHO_START(); - DEBUG_ECHOLNPGM("EEPROM PageErase ", page); + DEBUG_ECHO_MSG("EEPROM PageErase ", page); DEBUG_ECHOLNPGM(" in FLASH address ", (uint32_t)addrflash); DEBUG_ECHOLNPGM(" base address ", (uint32_t)getFlashStorage(0)); DEBUG_FLUSH(); @@ -370,8 +365,7 @@ static bool ee_PageErase(uint16_t page) { // Reenable interrupts __enable_irq(); - DEBUG_ECHO_START(); - DEBUG_ECHOLNPGM("EEPROM Unlock failure for page ",page); + DEBUG_ECHO_MSG("EEPROM Unlock failure for page ",page); return false; } @@ -394,8 +388,7 @@ static bool ee_PageErase(uint16_t page) { // Reenable interrupts __enable_irq(); - DEBUG_ECHO_START(); - DEBUG_ECHOLNPGM("EEPROM Erase failure for page ",page); + DEBUG_ECHO_MSG("EEPROM Erase failure for page ",page); return false; } @@ -410,8 +403,7 @@ static bool ee_PageErase(uint16_t page) { uint32_t * aligned_src = (uint32_t *) addrflash; for (i = 0; i < PageSize >> 2; i++) { if (*aligned_src++ != 0xFFFFFFFF) { - DEBUG_ECHO_START(); - DEBUG_ECHOLNPGM("EEPROM Verify Erase failure for page ",page); + DEBUG_ECHO_MSG("EEPROM Verify Erase failure for page ",page); ee_Dump(page, (uint32_t *)addrflash); return false; } @@ -921,8 +913,7 @@ static void ee_Init() { // If all groups seem to be used, default to first group if (curGroup >= GroupCount) curGroup = 0; - DEBUG_ECHO_START(); - DEBUG_ECHOLNPGM("EEPROM Current Group: ",curGroup); + DEBUG_ECHO_MSG("EEPROM Current Group: ",curGroup); DEBUG_FLUSH(); // Now, validate that all the other group pages are empty @@ -931,8 +922,7 @@ static void ee_Init() { for (int page = 0; page < PagesPerGroup; page++) { if (!ee_IsPageClean(grp * PagesPerGroup + page)) { - DEBUG_ECHO_START(); - DEBUG_ECHOLNPGM("EEPROM Page ", page, " not clean on group ", grp); + DEBUG_ECHO_MSG("EEPROM Page ", page, " not clean on group ", grp); DEBUG_FLUSH(); ee_PageErase(grp * PagesPerGroup + page); } @@ -948,15 +938,13 @@ static void ee_Init() { } } - DEBUG_ECHO_START(); - DEBUG_ECHOLNPGM("EEPROM Active page: ", curPage); + DEBUG_ECHO_MSG("EEPROM Active page: ", curPage); DEBUG_FLUSH(); // Make sure the pages following the first clean one are also clean for (int page = curPage + 1; page < PagesPerGroup; page++) { if (!ee_IsPageClean(curGroup * PagesPerGroup + page)) { - DEBUG_ECHO_START(); - DEBUG_ECHOLNPGM("EEPROM Page ", page, " not clean on active group ", curGroup); + DEBUG_ECHO_MSG("EEPROM Page ", page, " not clean on active group ", curGroup); DEBUG_FLUSH(); ee_Dump(curGroup * PagesPerGroup + page, getFlashStorage(curGroup * PagesPerGroup + page)); ee_PageErase(curGroup * PagesPerGroup + page); diff --git a/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp b/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp index d9fbabce2148..800915ff692b 100644 --- a/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp +++ b/Marlin/src/HAL/DUE/fastio/G2_PWM.cpp @@ -25,7 +25,7 @@ * is NOT used to directly toggle pins. The ISR writes to the pin assigned to * that interrupt. * - * All PWMs use the same repetition rate. The G2 needs about 10KHz min in order to + * All PWMs use the same repetition rate. The G2 needs about 10kHz min in order to * not have obvious ripple on the Vref signals. * * The data structures are setup to minimize the computation done by the ISR which diff --git a/Marlin/src/HAL/DUE/inc/SanityCheck.h b/Marlin/src/HAL/DUE/inc/SanityCheck.h index 87b09cf29257..13484f7029d1 100644 --- a/Marlin/src/HAL/DUE/inc/SanityCheck.h +++ b/Marlin/src/HAL/DUE/inc/SanityCheck.h @@ -25,6 +25,30 @@ * Test Arduino Due specific configuration values for errors at compile-time. */ +/** + * Check for common serial pin conflicts + */ +#define CHECK_SERIAL_PIN(N) ( \ + X_STOP_PIN == N || Y_STOP_PIN == N || Z_STOP_PIN == N \ + || X_MIN_PIN == N || Y_MIN_PIN == N || Z_MIN_PIN == N \ + || X_MAX_PIN == N || Y_MAX_PIN == N || Z_MAX_PIN == N \ + || 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 \ +) +#if CONF_SERIAL_IS(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." +#endif +#if CONF_SERIAL_IS(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)) + #error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board." +#endif +#undef CHECK_SERIAL_PIN + /** * HARDWARE VS. SOFTWARE SPI COMPATIBILITY * @@ -59,3 +83,7 @@ #if HAS_TMC_SW_SERIAL #error "TMC220x Software Serial is not supported on the DUE platform." #endif + +#if USING_PULLDOWNS + #error "PULLDOWN pin mode is not available on DUE boards." +#endif diff --git a/Marlin/src/HAL/DUE/pinsDebug.h b/Marlin/src/HAL/DUE/pinsDebug.h index f01c53c8ce06..df1ba415e918 100644 --- a/Marlin/src/HAL/DUE/pinsDebug.h +++ b/Marlin/src/HAL/DUE/pinsDebug.h @@ -53,7 +53,7 @@ * The net result is that both the g_pinStatus[pin] array and the PIO_OSR register * needs to be looked at when determining if a pin is an input or an output. * - * b) Due has only pins 6, 7, 8 & 9 enabled for PWMs. FYI - they run at 1KHz + * b) Due has only pins 6, 7, 8 & 9 enabled for PWMs. FYI - they run at 1kHz * * c) NUM_DIGITAL_PINS does not include the analog pins * @@ -86,7 +86,6 @@ bool GET_PINMODE(int8_t pin) { // 1: output, 0: input || pwm_status(pin)); } - void pwm_details(int32_t pin) { if (pwm_status(pin)) { uint32_t chan = g_APinDescription[pin].ulPWMChannel; diff --git a/Marlin/src/HAL/DUE/timers.h b/Marlin/src/HAL/DUE/timers.h index e2932ff36f91..bcfd07e268c5 100644 --- a/Marlin/src/HAL/DUE/timers.h +++ b/Marlin/src/HAL/DUE/timers.h @@ -125,4 +125,4 @@ FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) { pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_SR; } -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp b/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp index 3dcbbaecd28f..34cc256b30ff 100644 --- a/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp +++ b/Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp @@ -10,7 +10,7 @@ #include "../../../sd/cardreader.h" extern "C" { -#include "sd_mmc_spi_mem.h" + #include "sd_mmc_spi_mem.h" } #define SD_MMC_BLOCK_SIZE 512 diff --git a/Marlin/src/HAL/DUE/watchdog.cpp b/Marlin/src/HAL/DUE/watchdog.cpp deleted file mode 100644 index e144db8291e3..000000000000 --- a/Marlin/src/HAL/DUE/watchdog.cpp +++ /dev/null @@ -1,114 +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 . - * - */ -#ifdef ARDUINO_ARCH_SAM - -#include "../../inc/MarlinConfig.h" -#include "../../MarlinCore.h" -#include "watchdog.h" - -// Override Arduino runtime to either config or disable the watchdog -// -// We need to configure the watchdog as soon as possible in the boot -// process, because watchdog initialization at hardware reset on SAM3X8E -// is unreliable, and there is risk of unintended resets if we delay -// that initialization to a later time. -void watchdogSetup() { - - #if ENABLED(USE_WATCHDOG) - - // 4 seconds timeout - uint32_t timeout = TERN(WATCHDOG_DURATION_8S, 8000, 4000); - - // Calculate timeout value in WDT counter ticks: This assumes - // the slow clock is running at 32.768 kHz watchdog - // frequency is therefore 32768 / 128 = 256 Hz - timeout = (timeout << 8) / 1000; - if (timeout == 0) - timeout = 1; - else if (timeout > 0xFFF) - timeout = 0xFFF; - - // We want to enable the watchdog with the specified timeout - uint32_t value = - WDT_MR_WDV(timeout) | // With the specified timeout - WDT_MR_WDD(timeout) | // and no invalid write window - #if !(SAMV70 || SAMV71 || SAME70 || SAMS70) - WDT_MR_WDRPROC | // WDT fault resets processor only - We want - // to keep PIO controller state - #endif - WDT_MR_WDDBGHLT | // WDT stops in debug state. - WDT_MR_WDIDLEHLT; // WDT stops in idle state. - - #if ENABLED(WATCHDOG_RESET_MANUAL) - // We enable the watchdog timer, but only for the interrupt. - - // Configure WDT to only trigger an interrupt - value |= WDT_MR_WDFIEN; // Enable WDT fault interrupt. - - // Disable WDT interrupt (just in case, to avoid triggering it!) - NVIC_DisableIRQ(WDT_IRQn); - - // 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(); - - // Initialize WDT with the given parameters - WDT_Enable(WDT, value); - - // Configure and enable WDT interrupt. - NVIC_ClearPendingIRQ(WDT_IRQn); - NVIC_SetPriority(WDT_IRQn, 0); // Use highest priority, so we detect all kinds of lockups - NVIC_EnableIRQ(WDT_IRQn); - - #else - - // a WDT fault triggers a reset - value |= WDT_MR_WDRSTEN; - - // Initialize WDT with the given parameters - WDT_Enable(WDT, value); - - #endif - - // Reset the watchdog - WDT_Restart(WDT); - - #else - - // Make sure to completely disable the Watchdog - WDT_Disable(WDT); - - #endif -} - -#if ENABLED(USE_WATCHDOG) - // Initialize watchdog - On SAM3X, Watchdog was already configured - // and enabled or disabled at startup, so no need to reconfigure it - // here. - void watchdog_init() { - // Reset watchdog to start clean - WDT_Restart(WDT); - } -#endif // USE_WATCHDOG - -#endif diff --git a/Marlin/src/HAL/DUE/watchdog.h b/Marlin/src/HAL/DUE/watchdog.h deleted file mode 100644 index 5725a10007a7..000000000000 --- a/Marlin/src/HAL/DUE/watchdog.h +++ /dev/null @@ -1,33 +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 - -// Arduino Due core now has watchdog support - -#include "HAL.h" - -// Initialize watchdog with a 4 second interrupt time -void watchdog_init(); - -// Reset watchdog. MUST be called at least every 4 seconds after the -// first watchdog_init or AVR will go into emergency procedures. -inline void HAL_watchdog_refresh() { watchdogReset(); } diff --git a/Marlin/src/HAL/ESP32/HAL.cpp b/Marlin/src/HAL/ESP32/HAL.cpp index 810e386894ec..65af39786eeb 100644 --- a/Marlin/src/HAL/ESP32/HAL.cpp +++ b/Marlin/src/HAL/ESP32/HAL.cpp @@ -52,7 +52,7 @@ // Externs // ------------------------ -portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED; +portMUX_TYPE MarlinHAL::spinlock = portMUX_INITIALIZER_UNLOCKED; // ------------------------ // Local defines @@ -64,7 +64,7 @@ portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED; // Public Variables // ------------------------ -uint16_t HAL_adc_result; +uint16_t MarlinHAL::adc_result; // ------------------------ // Private Variables @@ -73,9 +73,16 @@ uint16_t HAL_adc_result; esp_adc_cal_characteristics_t characteristics[ADC_ATTEN_MAX]; adc_atten_t attenuations[ADC1_CHANNEL_MAX] = {}; uint32_t thresholds[ADC_ATTEN_MAX]; -volatile int numPWMUsed = 0, - pwmPins[MAX_PWM_PINS], - pwmValues[MAX_PWM_PINS]; + +volatile int numPWMUsed = 0; +volatile struct { pin_t pin; int value; } pwmState[MAX_PWM_PINS]; + +pin_t chan_pin[CHANNEL_MAX_NUM + 1] = { 0 }; // PWM capable IOpins - not 0 or >33 on ESP32 + +struct { + uint32_t freq; // ledcReadFreq doesn't work if a duty hasn't been set yet! + uint16_t res; +} pwmInfo[(CHANNEL_MAX_NUM + 1) / 2]; // ------------------------ // Public functions @@ -95,20 +102,22 @@ volatile int numPWMUsed = 0, #endif #if ENABLED(USE_ESP32_EXIO) + HardwareSerial YSerial2(2); void Write_EXIO(uint8_t IO, uint8_t v) { - if (ISRS_ENABLED()) { - DISABLE_ISRS(); + if (hal.isr_state()) { + hal.isr_off(); YSerial2.write(0x80 | (((char)v) << 5) | (IO - 100)); - ENABLE_ISRS(); + hal.isr_on(); } else YSerial2.write(0x80 | (((char)v) << 5) | (IO - 100)); } + #endif -void HAL_init_board() { +void MarlinHAL::init_board() { #if ENABLED(USE_ESP32_TASK_WDT) esp_task_wdt_init(10, true); #endif @@ -154,27 +163,51 @@ void HAL_init_board() { #endif } -void HAL_idletask() { +void MarlinHAL::idletask() { #if BOTH(WIFISUPPORT, OTASUPPORT) OTA_handle(); #endif TERN_(ESP3D_WIFISUPPORT, esp3dlib.idletask()); } -void HAL_clear_reset_source() { } - -uint8_t HAL_get_reset_source() { return rtc_get_reset_reason(1); } +uint8_t MarlinHAL::get_reset_source() { return rtc_get_reset_reason(1); } -void HAL_reboot() { ESP.restart(); } +void MarlinHAL::reboot() { ESP.restart(); } void _delay_ms(int delay_ms) { delay(delay_ms); } // return free memory between end of heap (or end bss) and whatever is current -int freeMemory() { return ESP.getFreeHeap(); } +int MarlinHAL::freeMemory() { return ESP.getFreeHeap(); } + +// ------------------------ +// Watchdog Timer +// ------------------------ + +#if ENABLED(USE_WATCHDOG) + + #define WDT_TIMEOUT_US TERN(WATCHDOG_DURATION_8S, 8000000, 4000000) // 4 or 8 second timeout + + extern "C" { + esp_err_t esp_task_wdt_reset(); + } + + void watchdogSetup() { + // do whatever. don't remove this function. + } + + void MarlinHAL::watchdog_init() { + // TODO + } + + // Reset watchdog. + void MarlinHAL::watchdog_refresh() { esp_task_wdt_reset(); } + +#endif // ------------------------ // ADC // ------------------------ + #define ADC1_CHANNEL(pin) ADC1_GPIO ## pin ## _CHANNEL adc1_channel_t get_channel(int pin) { @@ -196,22 +229,24 @@ void adc1_set_attenuation(adc1_channel_t chan, adc_atten_t atten) { } } -void HAL_adc_init() { +void MarlinHAL::adc_init() { // Configure ADC adc1_config_width(ADC_WIDTH_12Bit); // Configure channels only if used as (re-)configuring a pin for ADC that is used elsewhere might have adverse effects - TERN_(HAS_TEMP_ADC_0, adc1_set_attenuation(get_channel(TEMP_0_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_ADC_1, adc1_set_attenuation(get_channel(TEMP_1_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_ADC_2, adc1_set_attenuation(get_channel(TEMP_2_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_ADC_3, adc1_set_attenuation(get_channel(TEMP_3_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_ADC_4, adc1_set_attenuation(get_channel(TEMP_4_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_ADC_5, adc1_set_attenuation(get_channel(TEMP_5_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_ADC_6, adc2_set_attenuation(get_channel(TEMP_6_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_ADC_7, adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db)); - TERN_(HAS_HEATED_BED, adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_CHAMBER, adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db)); - TERN_(HAS_TEMP_COOLER, adc1_set_attenuation(get_channel(TEMP_COOLER_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_ADC_0, adc1_set_attenuation(get_channel(TEMP_0_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_ADC_1, adc1_set_attenuation(get_channel(TEMP_1_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_ADC_2, adc1_set_attenuation(get_channel(TEMP_2_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_ADC_3, adc1_set_attenuation(get_channel(TEMP_3_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_ADC_4, adc1_set_attenuation(get_channel(TEMP_4_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_ADC_5, adc1_set_attenuation(get_channel(TEMP_5_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_ADC_6, adc2_set_attenuation(get_channel(TEMP_6_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_ADC_7, adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db)); + TERN_(HAS_HEATED_BED, adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_CHAMBER, adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_PROBE, adc1_set_attenuation(get_channel(TEMP_PROBE_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_COOLER, adc1_set_attenuation(get_channel(TEMP_COOLER_PIN), ADC_ATTEN_11db)); + TERN_(HAS_TEMP_BOARD, adc1_set_attenuation(get_channel(TEMP_BOARD_PIN), ADC_ATTEN_11db)); TERN_(FILAMENT_WIDTH_SENSOR, adc1_set_attenuation(get_channel(FILWIDTH_PIN), ADC_ATTEN_11db)); // Note that adc2 is shared with the WiFi module, which has higher priority, so the conversion may fail. @@ -226,11 +261,16 @@ void HAL_adc_init() { } } -void HAL_adc_start_conversion(const uint8_t adc_pin) { - const adc1_channel_t chan = get_channel(adc_pin); +#ifndef ADC_REFERENCE_VOLTAGE + #define ADC_REFERENCE_VOLTAGE 3.3 +#endif + +void MarlinHAL::adc_start(const pin_t pin) { + const adc1_channel_t chan = get_channel(pin); uint32_t mv; esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv); - HAL_adc_result = mv * 1023.0 / 3300.0; + + adc_result = mv * isr_float_t(1023) / isr_float_t(ADC_REFERENCE_VOLTAGE) / isr_float_t(1000); // Change the attenuation level based on the new reading adc_atten_t atten; @@ -247,25 +287,81 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) { adc1_set_attenuation(chan, atten); } -void analogWrite(pin_t pin, int value) { - // Use ledc hardware for internal pins - if (pin < 34) { - static int cnt_channel = 1, pin_to_channel[40] = { 0 }; - if (pin_to_channel[pin] == 0) { - ledcAttachPin(pin, cnt_channel); - ledcSetup(cnt_channel, 490, 8); - ledcWrite(cnt_channel, value); - pin_to_channel[pin] = cnt_channel++; +// ------------------------ +// PWM +// ------------------------ + +int8_t channel_for_pin(const uint8_t pin) { + for (int i = 0; i <= CHANNEL_MAX_NUM; i++) + if (chan_pin[i] == pin) return i; + return -1; +} + +// get PWM channel for pin - if none then attach a new one +// return -1 if fail or invalid pin#, channel # (0-15) if success +int8_t get_pwm_channel(const pin_t pin, const uint32_t freq, const uint16_t res) { + if (!WITHIN(pin, 1, MAX_PWM_IOPIN)) return -1; // Not a hardware PWM pin! + int8_t cid = channel_for_pin(pin); + if (cid >= 0) return cid; + + // Find an empty adjacent channel (same timer & freq/res) + for (int i = 0; i <= CHANNEL_MAX_NUM; i++) { + if (chan_pin[i] == 0) { + if (chan_pin[i ^ 0x1] != 0) { + if (pwmInfo[i / 2].freq == freq && pwmInfo[i / 2].res == res) { + chan_pin[i] = pin; // Allocate PWM to this channel + ledcAttachPin(pin, i); + return i; + } + } + else if (cid == -1) // Pair of empty channels? + cid = i & 0xFE; // Save lower channel number } - ledcWrite(pin_to_channel[pin], value); + } + // not attached, is an empty timer slot avail? + if (cid >= 0) { + chan_pin[cid] = pin; + pwmInfo[cid / 2].freq = freq; + pwmInfo[cid / 2].res = res; + ledcSetup(cid, freq, res); + ledcAttachPin(pin, cid); + } + return cid; // -1 if no channel avail +} + +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*/) { + 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); + ledcWrite(cid, duty); + } +} + +int8_t MarlinHAL::set_pwm_frequency(const pin_t pin, const uint32_t f_desired) { + const int8_t cid = channel_for_pin(pin); + if (cid >= 0) { + if (f_desired == ledcReadFreq(cid)) return cid; // no freq change + ledcDetachPin(chan_pin[cid]); + chan_pin[cid] = 0; // remove old freq channel + } + return get_pwm_channel(pin, f_desired, PWM_RESOLUTION); // try for new one +} + +// use hardware PWM if avail, if not then ISR +void analogWrite(const pin_t pin, const uint16_t value, const uint32_t freq/*=PWM_FREQUENCY*/, const uint16_t res/*=8*/) { // always 8 bit resolution! + // Use ledc hardware for internal pins + const int8_t cid = get_pwm_channel(pin, freq, res); + if (cid >= 0) { + ledcWrite(cid, value); // set duty value return; } + // not a hardware PWM pin OR no PWM channels available int idx = -1; // Search Pin for (int i = 0; i < numPWMUsed; ++i) - if (pwmPins[i] == pin) { idx = i; break; } + if (pwmState[i].pin == pin) { idx = i; break; } // not found ? if (idx < 0) { @@ -274,7 +370,7 @@ void analogWrite(pin_t pin, int value) { // Take new slot for pin idx = numPWMUsed; - pwmPins[idx] = pin; + pwmState[idx].pin = pin; // Start timer on first use if (idx == 0) HAL_timer_start(MF_TIMER_PWM, PWM_TIMER_FREQUENCY); @@ -282,7 +378,7 @@ void analogWrite(pin_t pin, int value) { } // Use 7bit internal value - add 1 to have 100% high at 255 - pwmValues[idx] = (value + 1) / 2; + pwmState[idx].value = (value + 1) / 2; } // Handle PWM timer interrupt @@ -293,9 +389,9 @@ HAL_PWM_TIMER_ISR() { for (int i = 0; i < numPWMUsed; ++i) { if (count == 0) // Start of interval - WRITE(pwmPins[i], pwmValues[i] ? HIGH : LOW); - else if (pwmValues[i] == count) // End of duration - WRITE(pwmPins[i], LOW); + digitalWrite(pwmState[i].pin, pwmState[i].value ? HIGH : LOW); + else if (pwmState[i].value == count) // End of duration + digitalWrite(pwmState[i].pin, LOW); } // 128 for 7 Bit resolution diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h index 8473e3c4e469..a07303d4891f 100644 --- a/Marlin/src/HAL/ESP32/HAL.h +++ b/Marlin/src/HAL/ESP32/HAL.h @@ -32,7 +32,6 @@ #include "../shared/HAL_SPI.h" #include "fastio.h" -#include "watchdog.h" #include "i2s.h" #if ENABLED(WIFISUPPORT) @@ -49,8 +48,6 @@ // Defines // ------------------------ -extern portMUX_TYPE spinlock; - #define MYSERIAL1 flushableSerial #if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT) @@ -65,24 +62,22 @@ extern portMUX_TYPE spinlock; #define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock) #define CRITICAL_SECTION_END() portEXIT_CRITICAL(&spinlock) -#define ISRS_ENABLED() (spinlock.owner == portMUX_FREE_VAL) -#define ENABLE_ISRS() if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock) -#define DISABLE_ISRS() portENTER_CRITICAL(&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 // ------------------------ // Types // ------------------------ +typedef double isr_float_t; // FPU ops are used for single-precision, so use double for ISRs. typedef int16_t pin_t; -#define HAL_SERVO_LIB Servo - -// ------------------------ -// Public Variables -// ------------------------ - -/** result of last ADC conversion */ -extern uint16_t HAL_adc_result; +class Servo; +typedef Servo hal_servo_t; // ------------------------ // Public functions @@ -91,59 +86,18 @@ extern uint16_t HAL_adc_result; // // Tone // -void toneInit(); void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0); void noTone(const pin_t _pin); +int8_t get_pwm_channel(const pin_t pin, const uint32_t freq, const uint16_t res); +void analogWrite(const pin_t pin, const uint16_t value, const uint32_t freq=PWM_FREQUENCY, const uint16_t res=8); -// clear reset reason -void HAL_clear_reset_source(); - -// reset reason -uint8_t HAL_get_reset_source(); - -void HAL_reboot(); - -void _delay_ms(int delay); - -#pragma GCC diagnostic push -#if GCC_VERSION <= 50000 - #pragma GCC diagnostic ignored "-Wunused-function" -#endif - -int freeMemory(); - -#pragma GCC diagnostic pop - -void analogWrite(pin_t pin, int value); - -// ADC -#define HAL_ANALOG_SELECT(pin) - -void HAL_adc_init(); - -#define HAL_ADC_VREF 3.3 -#define HAL_ADC_RESOLUTION 10 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_result -#define HAL_ADC_READY() true - -void HAL_adc_start_conversion(const uint8_t adc_pin); - -// PWM -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } - -// Pin Map +// +// 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) -// Enable hooks into idle and setup for HAL -#define HAL_IDLETASK 1 -#define BOARD_INIT() HAL_init_board(); -void HAL_idletask(); -inline void HAL_init() {} -void HAL_init_board(); - #if ENABLED(USE_ESP32_EXIO) void Write_EXIO(uint8_t IO, uint8_t v); #endif @@ -188,3 +142,94 @@ FORCE_INLINE static void DELAY_CYCLES(uint32_t x) { } } + +// ------------------------ +// Class Utilities +// ------------------------ + +#pragma GCC diagnostic push +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif + +int freeMemory(); + +#pragma GCC diagnostic pop + +void _delay_ms(const int ms); + +// ------------------------ +// MarlinHAL Class +// ------------------------ + +#define HAL_ADC_VREF 3.3 +#define HAL_ADC_RESOLUTION 10 + +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 + + // Interrupts + static portMUX_TYPE spinlock; + static bool isr_state() { return spinlock.owner == portMUX_FREE_VAL; } + static void isr_on() { if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock); } + static void isr_off() { portENTER_CRITICAL(&spinlock); } + + static void delay_ms(const int ms) { _delay_ms(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(); + + // + // 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 pin_t pin) {} + + // 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; } + + /** + * If not already allocated, allocate a hardware PWM channel + * to the pin and set the duty cycle.. + * Optionally invert the duty cycle [default = false] + * Optionally 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 v_size=255, const bool invert=false); + + /** + * Allocate and set the frequency of a hardware PWM pin + * Returns -1 if no pin available. + */ + static int8_t set_pwm_frequency(const pin_t pin, const uint32_t f_desired); + +}; diff --git a/Marlin/src/HAL/ESP32/Servo.cpp b/Marlin/src/HAL/ESP32/Servo.cpp index fcf58485819e..ca3950d07f75 100644 --- a/Marlin/src/HAL/ESP32/Servo.cpp +++ b/Marlin/src/HAL/ESP32/Servo.cpp @@ -31,20 +31,18 @@ // so we only allocate servo channels up high to avoid side effects with regards to analogWrite (fans, leds, laser pwm etc.) int Servo::channel_next_free = 12; -Servo::Servo() { - channel = channel_next_free++; -} +Servo::Servo() {} int8_t Servo::attach(const int inPin) { - if (channel >= CHANNEL_MAX_NUM) return -1; if (inPin > 0) pin = inPin; - - ledcSetup(channel, 50, 16); // channel X, 50 Hz, 16-bit depth - ledcAttachPin(pin, channel); - return true; + channel = get_pwm_channel(pin, 50u, 16u); + return channel; // -1 if no PWM avail. } -void Servo::detach() { ledcDetachPin(pin); } +// leave channel connected to servo - set duty to zero +void Servo::detach() { + if (channel >= 0) ledcWrite(channel, 0); +} int Servo::read() { return degrees; } @@ -52,7 +50,7 @@ void Servo::write(int inDegrees) { degrees = constrain(inDegrees, MIN_ANGLE, MAX_ANGLE); int us = map(degrees, MIN_ANGLE, MAX_ANGLE, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH); int duty = map(us, 0, TAU_USEC, 0, MAX_COMPARE); - ledcWrite(channel, duty); + if (channel >= 0) ledcWrite(channel, duty); // don't save duty for servos! } void Servo::move(const int value) { diff --git a/Marlin/src/HAL/ESP32/Servo.h b/Marlin/src/HAL/ESP32/Servo.h index 8542092d66ea..1dbb416a8317 100644 --- a/Marlin/src/HAL/ESP32/Servo.h +++ b/Marlin/src/HAL/ESP32/Servo.h @@ -30,8 +30,7 @@ class Servo { MAX_PULSE_WIDTH = 2400, // Longest pulse sent to a servo TAU_MSEC = 20, TAU_USEC = (TAU_MSEC * 1000), - MAX_COMPARE = _BV(16) - 1, // 65535 - CHANNEL_MAX_NUM = 16; + MAX_COMPARE = _BV(16) - 1; // 65535 public: Servo(); diff --git a/Marlin/src/HAL/ESP32/Tone.cpp b/Marlin/src/HAL/ESP32/Tone.cpp index 9c16cdde800a..839c612b6a87 100644 --- a/Marlin/src/HAL/ESP32/Tone.cpp +++ b/Marlin/src/HAL/ESP32/Tone.cpp @@ -35,7 +35,7 @@ static pin_t tone_pin; volatile static int32_t toggles; -void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration) { +void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration/*=0*/) { tone_pin = _pin; toggles = 2 * frequency * duration / 1000; HAL_timer_start(MF_TIMER_TONE, 2 * frequency); diff --git a/Marlin/src/HAL/ESP32/inc/SanityCheck.h b/Marlin/src/HAL/ESP32/inc/SanityCheck.h index 8bbc68d8715b..04d70ec14f0b 100644 --- a/Marlin/src/HAL/ESP32/inc/SanityCheck.h +++ b/Marlin/src/HAL/ESP32/inc/SanityCheck.h @@ -25,8 +25,8 @@ #error "EMERGENCY_PARSER is not yet implemented for ESP32. 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 ESP32." +#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." #endif #if HAS_TMC_SW_SERIAL @@ -40,3 +40,11 @@ #if ENABLED(POSTMORTEM_DEBUGGING) #error "POSTMORTEM_DEBUGGING is not yet supported on ESP32." #endif + +#if MB(MKS_TINYBEE) && ENABLED(FAST_PWM_FAN) + #error "FAST_PWM_FAN is not available on TinyBee." +#endif + +#if USING_PULLDOWNS + #error "PULLDOWN pin mode is not available on ESP32 boards." +#endif diff --git a/Marlin/src/HAL/ESP32/timers.cpp b/Marlin/src/HAL/ESP32/timers.cpp index df0065f45396..c37ad2430cb2 100644 --- a/Marlin/src/HAL/ESP32/timers.cpp +++ b/Marlin/src/HAL/ESP32/timers.cpp @@ -81,7 +81,7 @@ void IRAM_ATTR timer_isr(void *para) { * @param timer_num timer number to initialize * @param frequency frequency of the timer */ -void HAL_timer_start(const uint8_t timer_num, uint32_t frequency) { +void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { const tTimerConfig timer = timer_config[timer_num]; timer_config_t config; diff --git a/Marlin/src/HAL/ESP32/timers.h b/Marlin/src/HAL/ESP32/timers.h index 266169848daf..aa4e1551f066 100644 --- a/Marlin/src/HAL/ESP32/timers.h +++ b/Marlin/src/HAL/ESP32/timers.h @@ -127,7 +127,7 @@ extern const tTimerConfig timer_config[]; // Public functions // ------------------------ -void HAL_timer_start (const uint8_t timer_num, uint32_t frequency); +void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency); void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t count); hal_timer_t HAL_timer_get_compare(const uint8_t timer_num); hal_timer_t HAL_timer_get_count(const uint8_t timer_num); @@ -136,5 +136,5 @@ 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); -#define HAL_timer_isr_prologue(T) -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_prologue(T) NOOP +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp b/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp new file mode 100644 index 000000000000..a445035b2b43 --- /dev/null +++ b/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp @@ -0,0 +1,94 @@ +/** + * 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 + * + * Copypaste of SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * 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 . + * + */ +#ifdef ARDUINO_ARCH_ESP32 + +#include "../../inc/MarlinConfig.h" + +#if EITHER(MKS_MINI_12864, FYSETC_MINI_12864_2_1) + +#include +#include "../shared/HAL_SPI.h" +#include "HAL.h" +#include "SPI.h" + +static SPISettings spiConfig; + + +#ifndef LCD_SPI_SPEED + #ifdef SD_SPI_SPEED + #define LCD_SPI_SPEED SD_SPI_SPEED // Assume SPI speed shared with SD + #else + #define LCD_SPI_SPEED SPI_FULL_SPEED // Use full speed if SD speed is not supplied + #endif +#endif + +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 (msgInitCount) { + if (msg == U8G_COM_MSG_INIT) msgInitCount--; + if (msgInitCount) return -1; + } + + switch (msg) { + case U8G_COM_MSG_STOP: break; + + case U8G_COM_MSG_INIT: + OUT_WRITE(DOGLCD_CS, HIGH); + OUT_WRITE(DOGLCD_A0, HIGH); + OUT_WRITE(LCD_RESET_PIN, HIGH); + u8g_Delay(5); + spiBegin(); + spiInit(LCD_SPI_SPEED); + break; + + case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */ + WRITE(DOGLCD_A0, arg_val ? HIGH : LOW); + break; + + case U8G_COM_MSG_CHIP_SELECT: /* arg_val == 0 means HIGH level of U8G_PI_CS */ + WRITE(DOGLCD_CS, arg_val ? LOW : HIGH); + break; + + case U8G_COM_MSG_RESET: + WRITE(LCD_RESET_PIN, arg_val); + break; + + case U8G_COM_MSG_WRITE_BYTE: + spiSend((uint8_t)arg_val); + break; + + case U8G_COM_MSG_WRITE_SEQ: + uint8_t *ptr = (uint8_t*) arg_ptr; + while (arg_val > 0) { + spiSend(*ptr++); + arg_val--; + } + break; + } + return 1; +} + +#endif // EITHER(MKS_MINI_12864, FYSETC_MINI_12864_2_1) + +#endif // ARDUINO_ARCH_ESP32 diff --git a/Marlin/src/HAL/ESP32/watchdog.cpp b/Marlin/src/HAL/ESP32/watchdog.cpp deleted file mode 100644 index 5ec03c46079b..000000000000 --- a/Marlin/src/HAL/ESP32/watchdog.cpp +++ /dev/null @@ -1,42 +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 . - * - */ -#ifdef ARDUINO_ARCH_ESP32 - -#include "../../inc/MarlinConfig.h" - -#if ENABLED(USE_WATCHDOG) - -#define WDT_TIMEOUT_US TERN(WATCHDOG_DURATION_8S, 8000000, 4000000) // 4 or 8 second timeout - -#include "watchdog.h" - -void watchdogSetup() { - // do whatever. don't remove this function. -} - -void watchdog_init() { - // TODO -} - -#endif // USE_WATCHDOG - -#endif // ARDUINO_ARCH_ESP32 diff --git a/Marlin/src/HAL/HAL.h b/Marlin/src/HAL/HAL.h index 0cd836af2b68..518657801905 100644 --- a/Marlin/src/HAL/HAL.h +++ b/Marlin/src/HAL/HAL.h @@ -28,6 +28,7 @@ #endif #include HAL_PATH(.,HAL.h) +extern MarlinHAL hal; #define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION) @@ -44,7 +45,3 @@ #ifndef PGMSTR #define PGMSTR(NAM,STR) const char NAM[] = STR #endif - -inline void watchdog_refresh() { - TERN_(USE_WATCHDOG, HAL_watchdog_refresh()); -} diff --git a/Marlin/src/HAL/LINUX/HAL.cpp b/Marlin/src/HAL/LINUX/HAL.cpp index 0b679170ef17..db43f42eaafd 100644 --- a/Marlin/src/HAL/LINUX/HAL.cpp +++ b/Marlin/src/HAL/LINUX/HAL.cpp @@ -24,6 +24,10 @@ #include "../../inc/MarlinConfig.h" #include "../shared/Delay.h" +// ------------------------ +// Serial ports +// ------------------------ + MSerialT usb_serial(TERN0(EMERGENCY_PARSER, true)); // U8glib required functions @@ -37,42 +41,21 @@ extern "C" { //************************// // return free heap space -int freeMemory() { - return 0; -} +int freeMemory() { return 0; } // ------------------------ // ADC // ------------------------ -void HAL_adc_init() { - -} - -void HAL_adc_enable_channel(const uint8_t ch) { - -} - -uint8_t active_ch = 0; -void HAL_adc_start_conversion(const uint8_t ch) { - active_ch = ch; -} - -bool HAL_adc_finished() { - return true; -} +uint8_t MarlinHAL::active_ch = 0; -uint16_t HAL_adc_get_result() { - pin_t pin = analogInputToDigitalPin(active_ch); +uint16_t MarlinHAL::adc_value() { + const pin_t pin = analogInputToDigitalPin(active_ch); if (!VALID_PIN(pin)) return 0; - uint16_t data = ((Gpio::get(pin) >> 2) & 0x3FF); + const uint16_t data = ((Gpio::get(pin) >> 2) & 0x3FF); return data; // return 10bit value as Marlin expects } -void HAL_pwm_init() { - -} - -void HAL_reboot() { /* Reset the application state and GPIO */ } +void MarlinHAL::reboot() { /* Reset the application state and GPIO */ } #endif // __PLAT_LINUX__ diff --git a/Marlin/src/HAL/LINUX/HAL.h b/Marlin/src/HAL/LINUX/HAL.h index d7d3a92b73b9..22c3e521f086 100644 --- a/Marlin/src/HAL/LINUX/HAL.h +++ b/Marlin/src/HAL/LINUX/HAL.h @@ -21,25 +21,42 @@ */ #pragma once -#define CPU_32_BIT +#include "../../inc/MarlinConfigPre.h" -#define F_CPU 100000000UL -#define SystemCoreClock F_CPU #include #include #include - #undef min #undef max - #include -void _printf (const char *format, ...); +#include "hardware/Clock.h" +#include "../shared/Marduino.h" +#include "../shared/math_32bit.h" +#include "../shared/HAL_SPI.h" +#include "fastio.h" +#include "serial.h" + +// ------------------------ +// Defines +// ------------------------ + +#define CPU_32_BIT +#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +#define F_CPU 100000000UL +#define SystemCoreClock F_CPU + +#define DELAY_CYCLES(x) Clock::delayCycles(x) + +#define CPU_ST7920_DELAY_1 600 +#define CPU_ST7920_DELAY_2 750 +#define CPU_ST7920_DELAY_3 750 + +void _printf(const char *format, ...); void _putc(uint8_t c); uint8_t _getc(); -//extern "C" volatile uint32_t _millis; - //arduino: Print.h #define DEC 10 #define HEX 16 @@ -49,36 +66,27 @@ uint8_t _getc(); #define B01 1 #define B10 2 -#include "hardware/Clock.h" - -#include "../shared/Marduino.h" -#include "../shared/math_32bit.h" -#include "../shared/HAL_SPI.h" -#include "fastio.h" -#include "watchdog.h" -#include "serial.h" - -#define SHARED_SERVOS HAS_SERVOS +// ------------------------ +// Serial ports +// ------------------------ extern MSerialT usb_serial; #define MYSERIAL1 usb_serial -#define CPU_ST7920_DELAY_1 600 -#define CPU_ST7920_DELAY_2 750 -#define CPU_ST7920_DELAY_3 750 - // // Interrupts // #define CRITICAL_SECTION_START() #define CRITICAL_SECTION_END() -#define ISRS_ENABLED() -#define ENABLE_ISRS() -#define DISABLE_ISRS() -inline void HAL_init() {} +// ADC +#define HAL_ADC_VREF 5.0 +#define HAL_ADC_RESOLUTION 10 + +// ------------------------ +// Class Utilities +// ------------------------ -// Utility functions #pragma GCC diagnostic push #if GCC_VERSION <= 50000 #pragma GCC diagnostic ignored "-Wunused-function" @@ -88,29 +96,70 @@ int freeMemory(); #pragma GCC diagnostic pop -// ADC -#define HAL_ADC_VREF 5.0 -#define HAL_ADC_RESOLUTION 10 -#define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch) -#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() true +// ------------------------ +// MarlinHAL Class +// ------------------------ + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + // 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() + static void reboot(); // Reset the application state and GPIO + + // Interrupts + static bool isr_state() { return true; } + static void isr_on() {} + static void isr_off() {} + + static void delay_ms(const int ms) { _delay_ms(ms); } + + // Tasks, called from idle() + static void idletask() {} + + // Reset + static constexpr uint8_t reset_reason = RST_POWER_ON; + static uint8_t get_reset_source() { return reset_reason; } + static void clear_reset_source() {} + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static uint8_t active_ch; + + // 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) {} -void HAL_adc_init(); -void HAL_adc_enable_channel(const uint8_t ch); -void HAL_adc_start_conversion(const uint8_t ch); -uint16_t HAL_adc_get_result(); + // Begin ADC sampling on the given channel + static void adc_start(const uint8_t ch) { active_ch = ch; } -// PWM -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + // Is the ADC ready for reading? + static bool adc_ready() { return true; } -// Reset source -inline void HAL_clear_reset_source(void) {} -inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; } + // The current value of the ADC register + static uint16_t adc_value(); -void HAL_reboot(); // Reset the application state and GPIO + /** + * Set the PWM duty cycle for the pin to the given value. + * No option to change the resolution or invert the duty cycle. + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { + analogWrite(pin, v); + } -/* ---------------- Delay in cycles */ -FORCE_INLINE static void DELAY_CYCLES(uint64_t x) { - Clock::delayCycles(x); -} + static void set_pwm_frequency(const pin_t, int) {} +}; diff --git a/Marlin/src/HAL/LINUX/arduino.cpp b/Marlin/src/HAL/LINUX/arduino.cpp index 4b56d02a389c..075b4ccde2f4 100644 --- a/Marlin/src/HAL/LINUX/arduino.cpp +++ b/Marlin/src/HAL/LINUX/arduino.cpp @@ -31,9 +31,7 @@ void cli() { } // Disable void sei() { } // Enable // Time functions -void _delay_ms(const int delay_ms) { - delay(delay_ms); -} +void _delay_ms(const int ms) { delay(ms); } uint32_t millis() { return (uint32_t)Clock::millis(); diff --git a/Marlin/src/HAL/LINUX/include/Arduino.h b/Marlin/src/HAL/LINUX/include/Arduino.h index d4086e259a2f..f05aaed88083 100644 --- a/Marlin/src/HAL/LINUX/include/Arduino.h +++ b/Marlin/src/HAL/LINUX/include/Arduino.h @@ -59,10 +59,9 @@ typedef uint8_t byte; #endif #define sq(v) ((v) * (v)) -#define square(v) sq(v) #define constrain(value, arg_min, arg_max) ((value) < (arg_min) ? (arg_min) :((value) > (arg_max) ? (arg_max) : (value))) -//Interrupts +// Interrupts void cli(); // Disable void sei(); // Enable void attachInterrupt(uint32_t pin, void (*callback)(), uint32_t mode); @@ -74,8 +73,8 @@ extern "C" { } // Time functions -extern "C" void delay(const int milis); -void _delay_ms(const int delay); +extern "C" void delay(const int ms); +void _delay_ms(const int ms); void delayMicroseconds(unsigned long); uint32_t millis(); diff --git a/Marlin/src/HAL/LINUX/timers.h b/Marlin/src/HAL/LINUX/timers.h index a98ceb6f391d..2d2a95774c1b 100644 --- a/Marlin/src/HAL/LINUX/timers.h +++ b/Marlin/src/HAL/LINUX/timers.h @@ -92,5 +92,5 @@ 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); -#define HAL_timer_isr_prologue(T) -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_prologue(T) NOOP +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/LINUX/watchdog.cpp b/Marlin/src/HAL/LINUX/watchdog.cpp deleted file mode 100644 index 84202e48b6c5..000000000000 --- a/Marlin/src/HAL/LINUX/watchdog.cpp +++ /dev/null @@ -1,37 +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 . - * - */ -#ifdef __PLAT_LINUX__ - -#include "../../inc/MarlinConfig.h" - -#if ENABLED(USE_WATCHDOG) - -#include "watchdog.h" - -#define WDT_TIMEOUT_US TERN(WATCHDOG_DURATION_8S, 8000000, 4000000) // 4 or 8 second timeout - -void watchdog_init() {} -void HAL_watchdog_refresh() {} - -#endif - -#endif // __PLAT_LINUX__ diff --git a/Marlin/src/HAL/LPC1768/HAL.cpp b/Marlin/src/HAL/LPC1768/HAL.cpp index cee9cfc5f744..9ff3a6ba598f 100644 --- a/Marlin/src/HAL/LPC1768/HAL.cpp +++ b/Marlin/src/HAL/LPC1768/HAL.cpp @@ -25,13 +25,9 @@ #include "../shared/Delay.h" #include "../../../gcode/parser.h" -#if ENABLED(USE_WATCHDOG) - #include "watchdog.h" -#endif - DefaultSerial1 USBSerial(false, UsbSerial); -uint32_t HAL_adc_reading = 0; +uint32_t MarlinHAL::adc_result = 0; // U8glib required functions extern "C" { @@ -41,8 +37,6 @@ extern "C" { void u8g_Delay(uint16_t val) { delay(val); } } -//************************// - // return free heap space int freeMemory() { char stack_end; @@ -54,33 +48,77 @@ int freeMemory() { return result; } -// scan command line for code -// return index into pin map array if found and the pin is valid. -// return dval if not found or not a valid pin. -int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) { - const uint16_t val = (uint16_t)parser.intval(code, -1), port = val / 100, pin = val % 100; - const int16_t ind = (port < ((NUM_DIGITAL_PINS) >> 5) && pin < 32) ? ((port << 5) | pin) : -2; - return ind > -1 ? ind : dval; +void MarlinHAL::reboot() { NVIC_SystemReset(); } + +uint8_t MarlinHAL::get_reset_source() { + #if ENABLED(USE_WATCHDOG) + if (watchdog_timed_out()) return RST_WATCHDOG; + #endif + return RST_POWER_ON; } +void MarlinHAL::clear_reset_source() { watchdog_clear_timeout_flag(); } + void flashFirmware(const int16_t) { delay(500); // Give OS time to disconnect USB_Connect(false); // USB clear connection delay(1000); // Give OS time to notice - HAL_reboot(); + hal.reboot(); } -void HAL_clear_reset_source(void) { - TERN_(USE_WATCHDOG, watchdog_clear_timeout_flag()); -} +#if ENABLED(USE_WATCHDOG) -uint8_t HAL_get_reset_source(void) { - #if ENABLED(USE_WATCHDOG) - if (watchdog_timed_out()) return RST_WATCHDOG; - #endif - return RST_POWER_ON; -} + #include + + #define WDT_TIMEOUT_US TERN(WATCHDOG_DURATION_8S, 8000000, 4000000) // 4 or 8 second timeout + + void MarlinHAL::watchdog_init() { + #if ENABLED(WATCHDOG_RESET_MANUAL) + // We enable the watchdog timer, but only for the interrupt. + + // Configure WDT to only trigger an interrupt + // Disable WDT interrupt (just in case, to avoid triggering it!) + NVIC_DisableIRQ(WDT_IRQn); + + // 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(); + + // Configure WDT to only trigger an interrupt + // Initialize WDT with the given parameters + WDT_Init(WDT_CLKSRC_IRC, WDT_MODE_INT_ONLY); + + // Configure and enable WDT interrupt. + NVIC_ClearPendingIRQ(WDT_IRQn); + NVIC_SetPriority(WDT_IRQn, 0); // Use highest priority, so we detect all kinds of lockups + NVIC_EnableIRQ(WDT_IRQn); + #else + WDT_Init(WDT_CLKSRC_IRC, WDT_MODE_RESET); + #endif + WDT_Start(WDT_TIMEOUT_US); + } + + void MarlinHAL::watchdog_refresh() { + WDT_Feed(); + #if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED) + TOGGLE(LED_PIN); // heartbeat indicator + #endif + } -void HAL_reboot() { NVIC_SystemReset(); } + // Timeout state + bool MarlinHAL::watchdog_timed_out() { return TEST(WDT_ReadTimeOutFlag(), 0); } + void MarlinHAL::watchdog_clear_timeout_flag() { WDT_ClrTimeOutFlag(); } + +#endif // USE_WATCHDOG + +// For M42/M43, scan command line for pin code +// return index into pin map array if found and the pin is valid. +// return dval if not found or not a valid pin. +int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) { + const uint16_t val = (uint16_t)parser.intval(code, -1), port = val / 100, pin = val % 100; + const int16_t ind = (port < ((NUM_DIGITAL_PINS) >> 5) && pin < 32) ? ((port << 5) | pin) : -2; + return ind > -1 ? ind : dval; +} #endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/LPC1768/HAL.h b/Marlin/src/HAL/LPC1768/HAL.h index 348ea6b21a04..b0eeb983b445 100644 --- a/Marlin/src/HAL/LPC1768/HAL.h +++ b/Marlin/src/HAL/LPC1768/HAL.h @@ -28,8 +28,6 @@ #define CPU_32_BIT -void HAL_init(); - #include #include #include @@ -40,19 +38,15 @@ extern "C" volatile uint32_t _millis; #include "../shared/math_32bit.h" #include "../shared/HAL_SPI.h" #include "fastio.h" -#include "watchdog.h" #include "MarlinSerial.h" #include #include #include -// -// Default graphical display delays -// -#define CPU_ST7920_DELAY_1 600 -#define CPU_ST7920_DELAY_2 750 -#define CPU_ST7920_DELAY_3 750 +// ------------------------ +// Serial ports +// ------------------------ typedef ForwardSerial1Class< decltype(UsbSerial) > DefaultSerial1; extern DefaultSerial1 USBSerial; @@ -114,26 +108,12 @@ extern DefaultSerial1 USBSerial; // // Interrupts // -#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_PRIMASK()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() - -// -// Utility functions -// -#pragma GCC diagnostic push -#if GCC_VERSION <= 50000 - #pragma GCC diagnostic ignored "-Wunused-function" -#endif -int freeMemory(); - -#pragma GCC diagnostic pop +#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() // -// ADC API +// ADC // #define ADC_MEDIAN_FILTER_SIZE (23) // Higher values increase step delay (phase shift), @@ -152,20 +132,9 @@ int freeMemory(); #define HAL_ADC_RESOLUTION 12 // 15 bit maximum, raw temperature is stored as int16_t #define HAL_ADC_FILTERED // Disable oversampling done in Marlin as ADC values already filtered in HAL -using FilteredADC = LPC176x::ADC; -extern uint32_t HAL_adc_reading; -[[gnu::always_inline]] inline void HAL_adc_start_conversion(const pin_t pin) { - HAL_adc_reading = FilteredADC::read(pin) >> (16 - HAL_ADC_RESOLUTION); // returns 16bit value, reduce to required bits -} -[[gnu::always_inline]] inline uint16_t HAL_adc_get_result() { - return HAL_adc_reading; -} - -#define HAL_adc_init() -#define HAL_ANALOG_SELECT(pin) FilteredADC::enable_channel(pin) -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() (true) +// +// Pin Mapping for M42, M43, M226 +// // Test whether the pin is valid constexpr bool VALID_PIN(const pin_t pin) { @@ -192,32 +161,107 @@ int16_t PARSED_PIN_INDEX(const char code, const int16_t dval); // P0.6 thru P0.9 are for the onboard SD card #define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09, -#define HAL_IDLETASK 1 -void HAL_idletask(); +// ------------------------ +// Defines +// ------------------------ #define PLATFORM_M997_SUPPORT void flashFirmware(const int16_t); #define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment -/** - * set_pwm_frequency - * Set the frequency of the timer corresponding to the provided pin - * All Hardware PWM pins run at the same frequency and all - * Software PWM pins run at the same frequency - */ -void set_pwm_frequency(const pin_t pin, int f_desired); +// Default graphical display delays +#define CPU_ST7920_DELAY_1 600 +#define CPU_ST7920_DELAY_2 750 +#define CPU_ST7920_DELAY_3 750 -/** - * set_pwm_duty - * Set the PWM duty cycle of the provided pin to the provided value - * Optionally allows inverting the duty cycle [default = false] - * Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255] - */ -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); +// ------------------------ +// Free Memory Accessor +// ------------------------ + +#pragma GCC diagnostic push +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif + +int freeMemory(); + +#pragma GCC diagnostic pop + +// ------------------------ +// MarlinHAL Class +// ------------------------ + +class MarlinHAL { +public: + + // Earliest possible init, before setup() + MarlinHAL() {} + + 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() { __enable_irq(); } + static void isr_off() { __disable_irq(); } + + static void delay_ms(const int ms) { _delay_ms(ms); } + + // Watchdog + static void watchdog_init() IF_DISABLED(USE_WATCHDOG, {}); + static void watchdog_refresh() IF_DISABLED(USE_WATCHDOG, {}); + static bool watchdog_timed_out() IF_DISABLED(USE_WATCHDOG, { return false; }); + static void watchdog_clear_timeout_flag() IF_DISABLED(USE_WATCHDOG, {}); + + // 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 + // + + using FilteredADC = LPC176x::ADC; + + // 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 pin_t pin) { + FilteredADC::enable_channel(pin); + } + + // Begin ADC sampling on the given pin. Called from Temperature::isr! + static uint32_t adc_result; + static void adc_start(const pin_t pin) { + adc_result = FilteredADC::read(pin) >> (16 - HAL_ADC_RESOLUTION); // returns 16bit value, reduce to required bits + } + + // 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 uint16_t(adc_result); } -// Reset source -void HAL_clear_reset_source(void); -uint8_t HAL_get_reset_source(void); + /** + * Set the PWM duty cycle for the pin to the given value. + * Optionally invert the duty cycle [default = false] + * Optionally 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 v_size=255, const bool invert=false); -void HAL_reboot(); + /** + * Set the frequency of the timer corresponding to the provided pin + * All Hardware PWM pins will run at the same frequency and + * All Software PWM pins will run at the same frequency + */ + static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired); +}; diff --git a/Marlin/src/HAL/LPC1768/HAL_MinSerial.cpp b/Marlin/src/HAL/LPC1768/MinSerial.cpp similarity index 97% rename from Marlin/src/HAL/LPC1768/HAL_MinSerial.cpp rename to Marlin/src/HAL/LPC1768/MinSerial.cpp index 57065c49ac83..7a1c038c0b0b 100644 --- a/Marlin/src/HAL/LPC1768/HAL_MinSerial.cpp +++ b/Marlin/src/HAL/LPC1768/MinSerial.cpp @@ -26,7 +26,7 @@ #if ENABLED(POSTMORTEM_DEBUGGING) -#include "../shared/HAL_MinSerial.h" +#include "../shared/MinSerial.h" #include static void TX(char c) { _DBC(c); } diff --git a/Marlin/src/HAL/LPC1768/Servo.h b/Marlin/src/HAL/LPC1768/Servo.h index eb12fd20f4d8..f02f503a67da 100644 --- a/Marlin/src/HAL/LPC1768/Servo.h +++ b/Marlin/src/HAL/LPC1768/Servo.h @@ -65,4 +65,5 @@ class libServo: public Servo { } }; -#define HAL_SERVO_LIB libServo +class libServo; +typedef libServo hal_servo_t; diff --git a/Marlin/src/HAL/LPC1768/eeprom_wired.cpp b/Marlin/src/HAL/LPC1768/eeprom_wired.cpp index f9286a74ac88..1bbc39d4a242 100644 --- a/Marlin/src/HAL/LPC1768/eeprom_wired.cpp +++ b/Marlin/src/HAL/LPC1768/eeprom_wired.cpp @@ -34,7 +34,7 @@ #include "../shared/eeprom_api.h" #ifndef MARLIN_EEPROM_SIZE - #define MARLIN_EEPROM_SIZE 0x8000 // 32KB‬ + #define MARLIN_EEPROM_SIZE 0x8000 // 32K #endif size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; } diff --git a/Marlin/src/HAL/LPC1768/fast_pwm.cpp b/Marlin/src/HAL/LPC1768/fast_pwm.cpp index eae0e36b0b0e..6d2b1a9002c1 100644 --- a/Marlin/src/HAL/LPC1768/fast_pwm.cpp +++ b/Marlin/src/HAL/LPC1768/fast_pwm.cpp @@ -21,21 +21,17 @@ */ #ifdef TARGET_LPC1768 -#include "../../inc/MarlinConfigPre.h" +#include "../../inc/MarlinConfig.h" #include -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { +void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { if (!LPC176x::pin_is_valid(pin)) return; if (LPC176x::pwm_attach_pin(pin)) LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size); // map 1-254 onto PWM range } -#if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM - - void set_pwm_frequency(const pin_t pin, int f_desired) { - LPC176x::pwm_set_frequency(pin, f_desired); - } - -#endif +void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { + LPC176x::pwm_set_frequency(pin, f_desired); +} #endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h index 3ea054589ec3..8265d58a6e8f 100644 --- a/Marlin/src/HAL/LPC1768/inc/SanityCheck.h +++ b/Marlin/src/HAL/LPC1768/inc/SanityCheck.h @@ -113,7 +113,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o #define _IS_RX1_1 IS_RX1 #if IS_TX1(TMC_SW_SCK) #error "Serial port pins (1) conflict with other pins!" - #elif HAS_WIRED_LCD + #elif HAS_ROTARY_ENCODER #if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1) #error "Serial port pins (1) conflict with Encoder Buttons!" #elif ANY_TX(1, SD_SCK_PIN, LCD_PINS_D4, DOGLCD_SCK, LCD_RESET_PIN, LCD_PINS_RS, SHIFT_CLK_PIN) \ diff --git a/Marlin/src/HAL/LPC1768/include/SPI.h b/Marlin/src/HAL/LPC1768/include/SPI.h index ecd91f6a3b73..24f4759315bd 100644 --- a/Marlin/src/HAL/LPC1768/include/SPI.h +++ b/Marlin/src/HAL/LPC1768/include/SPI.h @@ -77,7 +77,7 @@ class SPISettings { //uint32_t spiRate() const { return spi_speed; } - static inline uint32_t spiRate2Clock(uint32_t spiRate) { + static uint32_t spiRate2Clock(uint32_t spiRate) { uint32_t Marlin_speed[7]; // CPSR is always 2 Marlin_speed[0] = 8333333; //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED Marlin_speed[1] = 4166667; //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED diff --git a/Marlin/src/HAL/LPC1768/include/digipot_mcp4451_I2C_routines.c b/Marlin/src/HAL/LPC1768/include/digipot_mcp4451_I2C_routines.c index f442ab71c0bd..c489c16e5ef6 100644 --- a/Marlin/src/HAL/LPC1768/include/digipot_mcp4451_I2C_routines.c +++ b/Marlin/src/HAL/LPC1768/include/digipot_mcp4451_I2C_routines.c @@ -29,7 +29,7 @@ #include "../../../inc/MarlinConfigPre.h" -#if MB(MKS_SBASE) +#if ENABLED(DIGIPOT_MCP4451) && MB(MKS_SBASE) #ifdef __cplusplus extern "C" { @@ -37,35 +37,6 @@ #include "digipot_mcp4451_I2C_routines.h" -// These two routines are exact copies of the lpc17xx_i2c.c routines. Couldn't link to -// to the lpc17xx_i2c.c routines so had to copy them into this file & rename them. - -static uint32_t _I2C_Start(LPC_I2C_TypeDef *I2Cx) { - // Reset STA, STO, SI - I2Cx->I2CONCLR = I2C_I2CONCLR_SIC|I2C_I2CONCLR_STOC|I2C_I2CONCLR_STAC; - - // Enter to Master Transmitter mode - I2Cx->I2CONSET = I2C_I2CONSET_STA; - - // Wait for complete - while (!(I2Cx->I2CONSET & I2C_I2CONSET_SI)); - I2Cx->I2CONCLR = I2C_I2CONCLR_STAC; - return (I2Cx->I2STAT & I2C_STAT_CODE_BITMASK); -} - -static void _I2C_Stop(LPC_I2C_TypeDef *I2Cx) { - // Make sure start bit is not active - if (I2Cx->I2CONSET & I2C_I2CONSET_STA) - I2Cx->I2CONCLR = I2C_I2CONCLR_STAC; - - I2Cx->I2CONSET = I2C_I2CONSET_STO|I2C_I2CONSET_AA; - I2Cx->I2CONCLR = I2C_I2CONCLR_SIC; -} - -I2C_M_SETUP_Type transferMCfg; - -#define I2C_status (LPC_I2C1->I2STAT & I2C_STAT_CODE_BITMASK) - uint8_t digipot_mcp4451_start(uint8_t sla) { // send slave address and write bit // Sometimes TX data ACK or NAK status is returned. That mean the start state didn't // happen which means only the value of the slave address was send. Keep looping until @@ -102,5 +73,5 @@ uint8_t digipot_mcp4451_send_byte(uint8_t data) { } #endif -#endif // MB(MKS_SBASE) +#endif // DIGIPOT_MCP4451 && MKS_SBASE #endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/LPC1768/include/i2c_util.c b/Marlin/src/HAL/LPC1768/include/i2c_util.c index e52fb7c4de92..4e24f23236ea 100644 --- a/Marlin/src/HAL/LPC1768/include/i2c_util.c +++ b/Marlin/src/HAL/LPC1768/include/i2c_util.c @@ -63,6 +63,32 @@ void configure_i2c(const uint8_t clock_option) { I2C_Cmd(I2CDEV_M, I2C_MASTER_MODE, ENABLE); } +////////////////////////////////////////////////////////////////////////////////////// +// These two routines are exact copies of the lpc17xx_i2c.c routines. Couldn't link to +// to the lpc17xx_i2c.c routines so had to copy them into this file & rename them. + +uint32_t _I2C_Start(LPC_I2C_TypeDef *I2Cx) { + // Reset STA, STO, SI + I2Cx->I2CONCLR = I2C_I2CONCLR_SIC|I2C_I2CONCLR_STOC|I2C_I2CONCLR_STAC; + + // Enter to Master Transmitter mode + I2Cx->I2CONSET = I2C_I2CONSET_STA; + + // Wait for complete + while (!(I2Cx->I2CONSET & I2C_I2CONSET_SI)); + I2Cx->I2CONCLR = I2C_I2CONCLR_STAC; + return (I2Cx->I2STAT & I2C_STAT_CODE_BITMASK); +} + +void _I2C_Stop(LPC_I2C_TypeDef *I2Cx) { + /* Make sure start bit is not active */ + if (I2Cx->I2CONSET & I2C_I2CONSET_STA) + I2Cx->I2CONCLR = I2C_I2CONCLR_STAC; + + I2Cx->I2CONSET = I2C_I2CONSET_STO|I2C_I2CONSET_AA; + I2Cx->I2CONCLR = I2C_I2CONCLR_SIC; +} + #ifdef __cplusplus } #endif diff --git a/Marlin/src/HAL/LPC1768/include/i2c_util.h b/Marlin/src/HAL/LPC1768/include/i2c_util.h index a57f68a4071f..1f1c19f2798b 100644 --- a/Marlin/src/HAL/LPC1768/include/i2c_util.h +++ b/Marlin/src/HAL/LPC1768/include/i2c_util.h @@ -51,6 +51,11 @@ void configure_i2c(const uint8_t clock_option); +uint32_t _I2C_Start(LPC_I2C_TypeDef *I2Cx); +void _I2C_Stop(LPC_I2C_TypeDef *I2Cx); + +#define I2C_status (LPC_I2C1->I2STAT & I2C_STAT_CODE_BITMASK) + #ifdef __cplusplus } #endif diff --git a/Marlin/src/HAL/LPC1768/main.cpp b/Marlin/src/HAL/LPC1768/main.cpp index ef0dc42c78ca..419c99793fb8 100644 --- a/Marlin/src/HAL/LPC1768/main.cpp +++ b/Marlin/src/HAL/LPC1768/main.cpp @@ -48,7 +48,7 @@ void SysTick_Callback() { disk_timerproc(); } TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial()); -void HAL_init() { +void MarlinHAL::init() { // Init LEDs #if PIN_EXISTS(LED) @@ -130,7 +130,7 @@ void HAL_init() { const millis_t usb_timeout = millis() + 2000; while (!USB_Configuration && PENDING(millis(), usb_timeout)) { delay(50); - HAL_idletask(); + idletask(); #if PIN_EXISTS(LED) TOGGLE(LED_PIN); // Flash quickly during USB initialization #endif @@ -142,7 +142,7 @@ void HAL_init() { } // HAL idle task -void HAL_idletask() { +void MarlinHAL::idletask() { #if HAS_SHARED_MEDIA // If Marlin is using the SD card we need to lock it to prevent access from // a PC via USB. diff --git a/Marlin/src/HAL/LPC1768/tft/xpt2046.h b/Marlin/src/HAL/LPC1768/tft/xpt2046.h index aba0799e445f..7c456cf00e1b 100644 --- a/Marlin/src/HAL/LPC1768/tft/xpt2046.h +++ b/Marlin/src/HAL/LPC1768/tft/xpt2046.h @@ -65,8 +65,8 @@ class XPT2046 { static uint16_t getRawData(const XPTCoordinate coordinate); static bool isTouched(); - static inline void DataTransferBegin() { WRITE(TOUCH_CS_PIN, LOW); }; - static inline void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); }; + static void DataTransferBegin() { WRITE(TOUCH_CS_PIN, LOW); }; + static void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); }; #if ENABLED(TOUCH_BUTTONS_HW_SPI) static uint16_t HardwareIO(uint16_t data); #endif diff --git a/Marlin/src/HAL/LPC1768/timers.h b/Marlin/src/HAL/LPC1768/timers.h index 78e856db2857..c6d7bc632e2e 100644 --- a/Marlin/src/HAL/LPC1768/timers.h +++ b/Marlin/src/HAL/LPC1768/timers.h @@ -170,4 +170,4 @@ FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) { } } -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/LPC1768/u8g/LCD_I2C_routines.cpp b/Marlin/src/HAL/LPC1768/u8g/LCD_I2C_routines.cpp index a48a820dc433..e714c3c16da1 100644 --- a/Marlin/src/HAL/LPC1768/u8g/LCD_I2C_routines.cpp +++ b/Marlin/src/HAL/LPC1768/u8g/LCD_I2C_routines.cpp @@ -36,40 +36,7 @@ extern int millis(); ////////////////////////////////////////////////////////////////////////////////////// -// These two routines are exact copies of the lpc17xx_i2c.c routines. Couldn't link to -// to the lpc17xx_i2c.c routines so had to copy them into this file & rename them. - -static uint32_t _I2C_Start(LPC_I2C_TypeDef *I2Cx) { - // Reset STA, STO, SI - I2Cx->I2CONCLR = I2C_I2CONCLR_SIC|I2C_I2CONCLR_STOC|I2C_I2CONCLR_STAC; - - // Enter to Master Transmitter mode - I2Cx->I2CONSET = I2C_I2CONSET_STA; - - // Wait for complete - while (!(I2Cx->I2CONSET & I2C_I2CONSET_SI)); - I2Cx->I2CONCLR = I2C_I2CONCLR_STAC; - return (I2Cx->I2STAT & I2C_STAT_CODE_BITMASK); -} - -static void _I2C_Stop (LPC_I2C_TypeDef *I2Cx) { - /* Make sure start bit is not active */ - if (I2Cx->I2CONSET & I2C_I2CONSET_STA) - I2Cx->I2CONCLR = I2C_I2CONCLR_STAC; - - I2Cx->I2CONSET = I2C_I2CONSET_STO|I2C_I2CONSET_AA; - I2Cx->I2CONCLR = I2C_I2CONCLR_SIC; -} - -////////////////////////////////////////////////////////////////////////////////////// - -#define I2CDEV_S_ADDR 0x78 // from SSD1306 //actual address is 0x3C - shift left 1 with LSB set to 0 to indicate write - -#define BUFFER_SIZE 0x1 // only do single byte transfers with LCDs - -I2C_M_SETUP_Type transferMCfg; - -#define I2C_status (LPC_I2C1->I2STAT & I2C_STAT_CODE_BITMASK) +#define I2CDEV_S_ADDR 0x78 // From SSD1306 (actual address is 0x3C - shift left 1 with LSB set to 0 to indicate write) // Send slave address and write bit uint8_t u8g_i2c_start(const uint8_t sla) { @@ -115,7 +82,6 @@ uint8_t u8g_i2c_send_byte(uint8_t data) { void u8g_i2c_stop() { } - #ifdef __cplusplus } #endif diff --git a/Marlin/src/HAL/LPC1768/watchdog.cpp b/Marlin/src/HAL/LPC1768/watchdog.cpp deleted file mode 100644 index f23ccf5b512d..000000000000 --- a/Marlin/src/HAL/LPC1768/watchdog.cpp +++ /dev/null @@ -1,72 +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 . - * - */ -#ifdef TARGET_LPC1768 - -#include "../../inc/MarlinConfig.h" - -#if ENABLED(USE_WATCHDOG) - -#include -#include "watchdog.h" - -#define WDT_TIMEOUT_US TERN(WATCHDOG_DURATION_8S, 8000000, 4000000) // 4 or 8 second timeout - -void watchdog_init() { - #if ENABLED(WATCHDOG_RESET_MANUAL) - // We enable the watchdog timer, but only for the interrupt. - - // Configure WDT to only trigger an interrupt - // Disable WDT interrupt (just in case, to avoid triggering it!) - NVIC_DisableIRQ(WDT_IRQn); - - // 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(); - - // Configure WDT to only trigger an interrupt - // Initialize WDT with the given parameters - WDT_Init(WDT_CLKSRC_IRC, WDT_MODE_INT_ONLY); - - // Configure and enable WDT interrupt. - NVIC_ClearPendingIRQ(WDT_IRQn); - NVIC_SetPriority(WDT_IRQn, 0); // Use highest priority, so we detect all kinds of lockups - NVIC_EnableIRQ(WDT_IRQn); - #else - WDT_Init(WDT_CLKSRC_IRC, WDT_MODE_RESET); - #endif - WDT_Start(WDT_TIMEOUT_US); -} - -void HAL_watchdog_refresh() { - WDT_Feed(); - #if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED) - TOGGLE(LED_PIN); // heartbeat indicator - #endif -} - -// Timeout state -bool watchdog_timed_out() { return TEST(WDT_ReadTimeOutFlag(), 0); } -void watchdog_clear_timeout_flag() { WDT_ClrTimeOutFlag(); } - -#endif // USE_WATCHDOG -#endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/LPC1768/watchdog.h b/Marlin/src/HAL/LPC1768/watchdog.h deleted file mode 100644 index c843f0ed5571..000000000000 --- a/Marlin/src/HAL/LPC1768/watchdog.h +++ /dev/null @@ -1,28 +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 - -void watchdog_init(); -void HAL_watchdog_refresh(); - -bool watchdog_timed_out(); -void watchdog_clear_timeout_flag(); diff --git a/Marlin/src/HAL/NATIVE_SIM/HAL.h b/Marlin/src/HAL/NATIVE_SIM/HAL.h index 436b4b4daa26..66203611447f 100644 --- a/Marlin/src/HAL/NATIVE_SIM/HAL.h +++ b/Marlin/src/HAL/NATIVE_SIM/HAL.h @@ -21,18 +21,10 @@ */ #pragma once -#define CPU_32_BIT -#define HAL_IDLETASK -void HAL_idletask(); - -#define F_CPU 100000000 -#define SystemCoreClock F_CPU #include #include - #undef min #undef max - #include #include "pinmapping.h" @@ -40,8 +32,6 @@ void _printf (const char *format, ...); void _putc(uint8_t c); uint8_t _getc(); -//extern "C" volatile uint32_t _millis; - //arduino: Print.h #define DEC 10 #define HEX 16 @@ -55,10 +45,25 @@ uint8_t _getc(); #include "../shared/math_32bit.h" #include "../shared/HAL_SPI.h" #include "fastio.h" -#include "watchdog.h" #include "serial.h" -#define SHARED_SERVOS HAS_SERVOS +// ------------------------ +// Defines +// ------------------------ + +#define CPU_32_BIT +#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +#define F_CPU 100000000 +#define SystemCoreClock F_CPU + +#define CPU_ST7920_DELAY_1 600 +#define CPU_ST7920_DELAY_2 750 +#define CPU_ST7920_DELAY_3 750 + +// ------------------------ +// Serial ports +// ------------------------ extern MSerialT serial_stream_0; extern MSerialT serial_stream_1; @@ -98,49 +103,19 @@ extern MSerialT serial_stream_3; #endif #endif - -#define CPU_ST7920_DELAY_1 600 -#define CPU_ST7920_DELAY_2 750 -#define CPU_ST7920_DELAY_3 750 - -// +// ------------------------ // Interrupts -// +// ------------------------ + #define CRITICAL_SECTION_START() #define CRITICAL_SECTION_END() -#define ISRS_ENABLED() -#define ENABLE_ISRS() -#define DISABLE_ISRS() - -inline void HAL_init() {} - -// Utility functions -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-function" -int freeMemory(); -#pragma GCC diagnostic pop +// ------------------------ // ADC +// ------------------------ + #define HAL_ADC_VREF 5.0 #define HAL_ADC_RESOLUTION 10 -#define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch) -#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() true - -void HAL_adc_init(); -void HAL_adc_enable_channel(const uint8_t ch); -void HAL_adc_start_conversion(const uint8_t ch); -uint16_t HAL_adc_get_result(); - -// PWM -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } - -// Reset source -inline void HAL_clear_reset_source(void) {} -inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; } - -void HAL_reboot(); /* ---------------- Delay in cycles */ @@ -159,29 +134,22 @@ constexpr inline std::size_t strlen_constexpr(const char* str) { // https://github.com/gcc-mirror/gcc/blob/5c7634a0e5f202935aa6c11b6ea953b8bf80a00a/libstdc%2B%2B-v3/include/bits/char_traits.h#L329 if (str != nullptr) { std::size_t i = 0; - while (str[i] != '\0') { - ++i; - } - + while (str[i] != '\0') ++i; return i; } - return 0; } constexpr inline int strncmp_constexpr(const char* lhs, const char* rhs, std::size_t count) { // https://github.com/gcc-mirror/gcc/blob/13b9cbfc32fe3ac4c81c4dd9c42d141c8fb95db4/libstdc%2B%2B-v3/include/bits/char_traits.h#L655 - if (lhs == nullptr || rhs == nullptr) { + if (lhs == nullptr || rhs == nullptr) return rhs != nullptr ? -1 : 1; - } - for (std::size_t i = 0; i < count; ++i) { - if (lhs[i] != rhs[i]) { + for (std::size_t i = 0; i < count; ++i) + if (lhs[i] != rhs[i]) return lhs[i] < rhs[i] ? -1 : 1; - } else if (lhs[i] == '\0') { + else if (lhs[i] == '\0') return 0; - } - } return 0; } @@ -193,14 +161,11 @@ constexpr inline const char* strstr_constexpr(const char* str, const char* targe do { char sc = {}; do { - if ((sc = *str++) == '\0') { - return nullptr; - } + if ((sc = *str++) == '\0') return nullptr; } while (sc != c); } while (strncmp_constexpr(str, target, len) != 0); --str; } - return str; } @@ -211,12 +176,91 @@ constexpr inline char* strstr_constexpr(char* str, const char* target) { do { char sc = {}; do { - if ((sc = *str++) == '\0') { - return nullptr; - } + if ((sc = *str++) == '\0') return nullptr; } while (sc != c); } while (strncmp_constexpr(str, target, len) != 0); --str; } return str; } + +// ------------------------ +// Free Memory Accessor +// ------------------------ + +#pragma GCC diagnostic push +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif + +int freeMemory(); + +#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 true; } + static void isr_on() {} + static void isr_off() {} + + static void delay_ms(const int ms) { _delay_ms(ms); } + + // Tasks, called from idle() + static void idletask(); + + // Reset + static constexpr uint8_t reset_reason = RST_POWER_ON; + static uint8_t get_reset_source() { return reset_reason; } + static void clear_reset_source() {} + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static uint8_t active_ch; + + // 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 channel. Called from Temperature::isr! + static void adc_start(const uint8_t ch); + + // Is the ADC ready for reading? + static bool adc_ready(); + + // The current value of the ADC register + static uint16_t adc_value(); + + /** + * 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); + } + +}; diff --git a/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h b/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h index 9ef1816c7b16..b131853643a8 100644 --- a/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h +++ b/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h @@ -62,8 +62,8 @@ class XPT2046 { static uint16_t getRawData(const XPTCoordinate coordinate); static bool isTouched(); - static inline void DataTransferBegin(); - static inline void DataTransferEnd(); + static void DataTransferBegin(); + static void DataTransferEnd(); #if ENABLED(TOUCH_BUTTONS_HW_SPI) static uint16_t HardwareIO(uint16_t data); #endif diff --git a/Marlin/src/HAL/NATIVE_SIM/timers.h b/Marlin/src/HAL/NATIVE_SIM/timers.h index cedfdb62d631..be38d583b686 100644 --- a/Marlin/src/HAL/NATIVE_SIM/timers.h +++ b/Marlin/src/HAL/NATIVE_SIM/timers.h @@ -87,5 +87,5 @@ 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); -#define HAL_timer_isr_prologue(T) -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_prologue(T) NOOP +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_pin_routines.cpp b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_pin_routines.cpp index 3b5acc1656cd..91b7e0f67f76 100644 --- a/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_pin_routines.cpp +++ b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_pin_routines.cpp @@ -38,13 +38,13 @@ #ifdef __cplusplus extern "C" { #endif -void u8g_SetPinOutput(uint8_t internal_pin_number){SET_DIR_OUTPUT(internal_pin_number);} -void u8g_SetPinInput(uint8_t internal_pin_number){SET_DIR_INPUT(internal_pin_number);} -void u8g_SetPinLevel(uint8_t pin, uint8_t pin_status){WRITE_PIN(pin, pin_status);} -uint8_t u8g_GetPinLevel(uint8_t pin){return READ_PIN(pin);} -void usleep(uint64_t microsec){ -assert(false); // why we here? -} + +void u8g_SetPinOutput(uint8_t internal_pin_number) { SET_DIR_OUTPUT(internal_pin_number); } +void u8g_SetPinInput(uint8_t internal_pin_number) { SET_DIR_INPUT(internal_pin_number); } +void u8g_SetPinLevel(uint8_t pin, uint8_t pin_status) { WRITE_PIN(pin, pin_status); } +uint8_t u8g_GetPinLevel(uint8_t pin) { return READ_PIN(pin); } +void usleep(uint64_t microsec) { assert(false); /* why we here? */ } + #ifdef __cplusplus } #endif diff --git a/Marlin/src/HAL/SAMD51/HAL.cpp b/Marlin/src/HAL/SAMD51/HAL.cpp index 8baad31bc751..bd1c98bfa1d9 100644 --- a/Marlin/src/HAL/SAMD51/HAL.cpp +++ b/Marlin/src/HAL/SAMD51/HAL.cpp @@ -42,10 +42,6 @@ #endif #endif -// ------------------------ -// Local defines -// ------------------------ - #define GET_TEMP_0_ADC() TERN(HAS_TEMP_ADC_0, PIN_TO_ADC(TEMP_0_PIN), -1) #define GET_TEMP_1_ADC() TERN(HAS_TEMP_ADC_1, PIN_TO_ADC(TEMP_1_PIN), -1) #define GET_TEMP_2_ADC() TERN(HAS_TEMP_ADC_2, PIN_TO_ADC(TEMP_2_PIN), -1) @@ -54,22 +50,28 @@ #define GET_TEMP_5_ADC() TERN(HAS_TEMP_ADC_5, PIN_TO_ADC(TEMP_5_PIN), -1) #define GET_TEMP_6_ADC() TERN(HAS_TEMP_ADC_6, PIN_TO_ADC(TEMP_6_PIN), -1) #define GET_TEMP_7_ADC() TERN(HAS_TEMP_ADC_7, PIN_TO_ADC(TEMP_7_PIN), -1) -#define GET_PROBE_ADC() TERN(HAS_TEMP_PROBE, PIN_TO_ADC(TEMP_PROBE_PIN), -1) #define GET_BED_ADC() TERN(HAS_TEMP_ADC_BED, PIN_TO_ADC(TEMP_BED_PIN), -1) #define GET_CHAMBER_ADC() TERN(HAS_TEMP_ADC_CHAMBER, PIN_TO_ADC(TEMP_CHAMBER_PIN), -1) +#define GET_PROBE_ADC() TERN(HAS_TEMP_ADC_PROBE, PIN_TO_ADC(TEMP_PROBE_PIN), -1) #define GET_COOLER_ADC() TERN(HAS_TEMP_ADC_COOLER, PIN_TO_ADC(TEMP_COOLER_PIN), -1) +#define GET_BOARD_ADC() TERN(HAS_TEMP_ADC_BOARD, PIN_TO_ADC(TEMP_BOARD_PIN), -1) #define GET_FILAMENT_WIDTH_ADC() TERN(FILAMENT_WIDTH_SENSOR, PIN_TO_ADC(FILWIDTH_PIN), -1) #define GET_BUTTONS_ADC() TERN(HAS_ADC_BUTTONS, PIN_TO_ADC(ADC_KEYPAD_PIN), -1) +#define GET_JOY_ADC_X() TERN(HAS_JOY_ADC_X, PIN_TO_ADC(JOY_X_PIN), -1) +#define GET_JOY_ADC_Y() TERN(HAS_JOY_ADC_Y, PIN_TO_ADC(JOY_Y_PIN), -1) +#define GET_JOY_ADC_Z() TERN(HAS_JOY_ADC_Z, PIN_TO_ADC(JOY_Z_PIN), -1) #define IS_ADC_REQUIRED(n) ( \ GET_TEMP_0_ADC() == n || GET_TEMP_1_ADC() == n || GET_TEMP_2_ADC() == n || GET_TEMP_3_ADC() == n \ || GET_TEMP_4_ADC() == n || GET_TEMP_5_ADC() == n || GET_TEMP_6_ADC() == n || GET_TEMP_7_ADC() == n \ - || GET_PROBE_ADC() == n \ - || GET_BED_ADC() == n \ - || GET_CHAMBER_ADC() == n \ - || GET_COOLER_ADC() == n \ + || GET_BED_ADC() == n \ + || GET_CHAMBER_ADC() == n \ + || GET_PROBE_ADC() == n \ + || GET_COOLER_ADC() == n \ + || GET_BOARD_ADC() == n \ || GET_FILAMENT_WIDTH_ADC() == n \ - || GET_BUTTONS_ADC() == n \ + || GET_BUTTONS_ADC() == n \ + || GET_JOY_ADC_X() == n || GET_JOY_ADC_Y() == n || GET_JOY_ADC_Z() == n \ ) #if IS_ADC_REQUIRED(0) @@ -89,6 +91,152 @@ #define DMA_IS_REQUIRED 1 #endif +enum ADCIndex { + #if GET_TEMP_0_ADC() == 0 + TEMP_0, + #endif + #if GET_TEMP_1_ADC() == 0 + TEMP_1, + #endif + #if GET_TEMP_2_ADC() == 0 + TEMP_2, + #endif + #if GET_TEMP_3_ADC() == 0 + TEMP_3, + #endif + #if GET_TEMP_4_ADC() == 0 + TEMP_4, + #endif + #if GET_TEMP_5_ADC() == 0 + TEMP_5, + #endif + #if GET_TEMP_6_ADC() == 0 + TEMP_6, + #endif + #if GET_TEMP_7_ADC() == 0 + TEMP_7, + #endif + #if GET_BED_ADC() == 0 + TEMP_BED, + #endif + #if GET_CHAMBER_ADC() == 0 + TEMP_CHAMBER, + #endif + #if GET_PROBE_ADC() == 0 + TEMP_PROBE, + #endif + #if GET_COOLER_ADC() == 0 + TEMP_COOLER, + #endif + #if GET_BOARD_ADC() == 0 + TEMP_BOARD, + #endif + #if GET_FILAMENT_WIDTH_ADC() == 0 + FILWIDTH, + #endif + #if GET_BUTTONS_ADC() == 0 + ADC_KEY, + #endif + #if GET_JOY_ADC_X() == 0 + JOY_X, + #endif + #if GET_JOY_ADC_Y() == 0 + JOY_Y, + #endif + #if GET_JOY_ADC_Z() == 0 + JOY_Z, + #endif + #if GET_TEMP_0_ADC() == 1 + TEMP_0, + #endif + #if GET_TEMP_1_ADC() == 1 + TEMP_1, + #endif + #if GET_TEMP_2_ADC() == 1 + TEMP_2, + #endif + #if GET_TEMP_3_ADC() == 1 + TEMP_3, + #endif + #if GET_TEMP_4_ADC() == 1 + TEMP_4, + #endif + #if GET_TEMP_5_ADC() == 1 + TEMP_5, + #endif + #if GET_TEMP_6_ADC() == 1 + TEMP_6, + #endif + #if GET_TEMP_7_ADC() == 1 + TEMP_7, + #endif + #if GET_BED_ADC() == 1 + TEMP_BED, + #endif + #if GET_CHAMBER_ADC() == 1 + TEMP_CHAMBER, + #endif + #if GET_PROBE_ADC() == 1 + TEMP_PROBE, + #endif + #if GET_COOLER_ADC() == 1 + TEMP_COOLER, + #endif + #if GET_BOARD_ADC() == 1 + TEMP_BOARD, + #endif + #if GET_FILAMENT_WIDTH_ADC() == 1 + FILWIDTH, + #endif + #if GET_BUTTONS_ADC() == 1 + ADC_KEY, + #endif + #if GET_JOY_ADC_X() == 1 + JOY_X, + #endif + #if GET_JOY_ADC_Y() == 1 + JOY_Y, + #endif + #if GET_JOY_ADC_Z() == 1 + JOY_Z, + #endif + ADC_COUNT +}; + +#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() { + // The low-power oscillator used by the WDT runs at 32,768 Hz with + // a 1:32 prescale, thus 1024 Hz, though probably not super precise. + + // Setup WDT clocks + MCLK->APBAMASK.bit.OSC32KCTRL_ = true; + MCLK->APBAMASK.bit.WDT_ = true; + OSC32KCTRL->OSCULP32K.bit.EN1K = true; // Enable out 1K (this is what WDT uses) + + WDT->CTRLA.bit.ENABLE = false; // Disable watchdog for config + SYNC(WDT->SYNCBUSY.bit.ENABLE); + + WDT->INTENCLR.reg = WDT_INTENCLR_EW; // Disable early warning interrupt + WDT->CONFIG.reg = WDT_TIMEOUT_REG; // Set a 4s or 8s period for chip reset + + hal.watchdog_refresh(); + + WDT->CTRLA.reg = WDT_CTRLA_ENABLE; // Start watchdog now in normal mode + SYNC(WDT->SYNCBUSY.bit.ENABLE); + } + + // 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() { + SYNC(WDT->SYNCBUSY.bit.CLEAR); // Test first if previous is 'ongoing' to save time waiting for command execution + WDT->CLEAR.reg = WDT_CLEAR_CLEAR_KEY; + } + +#endif + // ------------------------ // Types // ------------------------ @@ -106,12 +254,10 @@ // Private Variables // ------------------------ -uint16_t HAL_adc_result; - #if ADC_IS_REQUIRED // Pins used by ADC inputs. Order must be ADC0 inputs first then ADC1 - const uint8_t adc_pins[] = { + static constexpr uint8_t adc_pins[ADC_COUNT] = { // ADC0 pins #if GET_TEMP_0_ADC() == 0 TEMP_0_PIN, @@ -137,24 +283,36 @@ uint16_t HAL_adc_result; #if GET_TEMP_7_ADC() == 0 TEMP_7_PIN, #endif - #if GET_PROBE_ADC() == 0 - TEMP_PROBE_PIN, - #endif #if GET_BED_ADC() == 0 TEMP_BED_PIN, #endif #if GET_CHAMBER_ADC() == 0 TEMP_CHAMBER_PIN, #endif + #if GET_PROBE_ADC() == 0 + TEMP_PROBE_PIN, + #endif #if GET_COOLER_ADC() == 0 TEMP_COOLER_PIN, #endif + #if GET_BOARD_ADC() == 0 + TEMP_BOARD_PIN, + #endif #if GET_FILAMENT_WIDTH_ADC() == 0 FILWIDTH_PIN, #endif #if GET_BUTTONS_ADC() == 0 ADC_KEYPAD_PIN, #endif + #if GET_JOY_ADC_X() == 0 + JOY_X_PIN, + #endif + #if GET_JOY_ADC_Y() == 0 + JOY_Y_PIN, + #endif + #if GET_JOY_ADC_Z() == 0 + JOY_Z_PIN, + #endif // ADC1 pins #if GET_TEMP_0_ADC() == 1 TEMP_0_PIN, @@ -180,33 +338,44 @@ uint16_t HAL_adc_result; #if GET_TEMP_7_ADC() == 1 TEMP_7_PIN, #endif - #if GET_PROBE_ADC() == 1 - TEMP_PROBE_PIN, - #endif #if GET_BED_ADC() == 1 TEMP_BED_PIN, #endif #if GET_CHAMBER_ADC() == 1 TEMP_CHAMBER_PIN, #endif + #if GET_PROBE_ADC() == 1 + TEMP_PROBE_PIN, + #endif #if GET_COOLER_ADC() == 1 TEMP_COOLER_PIN, #endif + #if GET_BOARD_ADC() == 1 + TEMP_BOARD_PIN, + #endif #if GET_FILAMENT_WIDTH_ADC() == 1 FILWIDTH_PIN, #endif #if GET_BUTTONS_ADC() == 1 ADC_KEYPAD_PIN, #endif + #if GET_JOY_ADC_X() == 1 + JOY_X_PIN, + #endif + #if GET_JOY_ADC_Y() == 1 + JOY_Y_PIN, + #endif + #if GET_JOY_ADC_Z() == 1 + JOY_Z_PIN, + #endif }; - uint16_t HAL_adc_results[COUNT(adc_pins)]; + static uint16_t adc_results[ADC_COUNT]; #if ADC0_IS_REQUIRED - Adafruit_ZeroDMA adc0DMAProgram, - adc0DMARead; + Adafruit_ZeroDMA adc0DMAProgram, adc0DMARead; - const HAL_DMA_DAC_Registers adc0_dma_regs_list[] = { + static constexpr HAL_DMA_DAC_Registers adc0_dma_regs_list[ADC_COUNT] = { #if GET_TEMP_0_ADC() == 0 { PIN_TO_INPUTCTRL(TEMP_0_PIN) }, #endif @@ -231,34 +400,45 @@ uint16_t HAL_adc_result; #if GET_TEMP_7_ADC() == 0 { PIN_TO_INPUTCTRL(TEMP_7_PIN) }, #endif - #if GET_PROBE_ADC() == 0 - { PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) }, - #endif #if GET_BED_ADC() == 0 { PIN_TO_INPUTCTRL(TEMP_BED_PIN) }, #endif #if GET_CHAMBER_ADC() == 0 { PIN_TO_INPUTCTRL(TEMP_CHAMBER_PIN) }, #endif + #if GET_PROBE_ADC() == 0 + { PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) }, + #endif #if GET_COOLER_ADC() == 0 { PIN_TO_INPUTCTRL(TEMP_COOLER_PIN) }, #endif + #if GET_BOARD_ADC() == 0 + { PIN_TO_INPUTCTRL(TEMP_BOARD_PIN) }, + #endif #if GET_FILAMENT_WIDTH_ADC() == 0 { PIN_TO_INPUTCTRL(FILWIDTH_PIN) }, #endif #if GET_BUTTONS_ADC() == 0 { PIN_TO_INPUTCTRL(ADC_KEYPAD_PIN) }, #endif + #if GET_JOY_ADC_X() == 0 + { PIN_TO_INPUTCTRL(JOY_X_PIN) }, + #endif + #if GET_JOY_ADC_Y() == 0 + { PIN_TO_INPUTCTRL(JOY_Y_PIN) }, + #endif + #if GET_JOY_ADC_Z() == 0 + { PIN_TO_INPUTCTRL(JOY_Z_PIN) }, + #endif }; #define ADC0_AINCOUNT COUNT(adc0_dma_regs_list) #endif // ADC0_IS_REQUIRED #if ADC1_IS_REQUIRED - Adafruit_ZeroDMA adc1DMAProgram, - adc1DMARead; + Adafruit_ZeroDMA adc1DMAProgram, adc1DMARead; - const HAL_DMA_DAC_Registers adc1_dma_regs_list[] = { + static constexpr HAL_DMA_DAC_Registers adc1_dma_regs_list[ADC_COUNT] = { #if GET_TEMP_0_ADC() == 1 { PIN_TO_INPUTCTRL(TEMP_0_PIN) }, #endif @@ -283,24 +463,36 @@ uint16_t HAL_adc_result; #if GET_TEMP_7_ADC() == 1 { PIN_TO_INPUTCTRL(TEMP_7_PIN) }, #endif - #if GET_PROBE_ADC() == 1 - { PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) }, - #endif #if GET_BED_ADC() == 1 { PIN_TO_INPUTCTRL(TEMP_BED_PIN) }, #endif #if GET_CHAMBER_ADC() == 1 { PIN_TO_INPUTCTRL(TEMP_CHAMBER_PIN) }, #endif + #if GET_PROBE_ADC() == 1 + { PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) }, + #endif #if GET_COOLER_ADC() == 1 { PIN_TO_INPUTCTRL(TEMP_COOLER_PIN) }, #endif + #if GET_BOARD_ADC() == 1 + { PIN_TO_INPUTCTRL(TEMP_BOARD_PIN) }, + #endif #if GET_FILAMENT_WIDTH_ADC() == 1 { PIN_TO_INPUTCTRL(FILWIDTH_PIN) }, #endif #if GET_BUTTONS_ADC() == 1 { PIN_TO_INPUTCTRL(ADC_KEYPAD_PIN) }, #endif + #if GET_JOY_ADC_X() == 1 + { PIN_TO_INPUTCTRL(JOY_X_PIN) }, + #endif + #if GET_JOY_ADC_Y() == 1 + { PIN_TO_INPUTCTRL(JOY_Y_PIN) }, + #endif + #if GET_JOY_ADC_Z() == 1 + { PIN_TO_INPUTCTRL(JOY_Z_PIN) }, + #endif }; #define ADC1_AINCOUNT COUNT(adc1_dma_regs_list) @@ -312,9 +504,10 @@ uint16_t HAL_adc_result; // Private functions // ------------------------ -#if DMA_IS_REQUIRED +void MarlinHAL::dma_init() { + + #if DMA_IS_REQUIRED - void dma_init() { DmacDescriptor *descriptor; #if ADC0_IS_REQUIRED @@ -343,7 +536,7 @@ uint16_t HAL_adc_result; if (adc0DMARead.allocate() == DMA_STATUS_OK) { adc0DMARead.addDescriptor( (void *)&ADC0->RESULT.reg, // SRC - &HAL_adc_results, // DEST + &adc_results, // DEST ADC0_AINCOUNT, // CNT DMA_BEAT_SIZE_HWORD, false, // SRCINC @@ -380,7 +573,7 @@ uint16_t HAL_adc_result; if (adc1DMARead.allocate() == DMA_STATUS_OK) { adc1DMARead.addDescriptor( (void *)&ADC1->RESULT.reg, // SRC - &HAL_adc_results[ADC0_AINCOUNT], // DEST + &adc_results[ADC0_AINCOUNT], // DEST ADC1_AINCOUNT, // CNT DMA_BEAT_SIZE_HWORD, false, // SRCINC @@ -393,36 +586,28 @@ uint16_t HAL_adc_result; #endif DMAC->PRICTRL0.bit.RRLVLEN0 = true; // Activate round robin for DMA channels required by ADCs - } -#endif // DMA_IS_REQUIRED + #endif // DMA_IS_REQUIRED +} // ------------------------ // Public functions // ------------------------ // HAL initialization task -void HAL_init() { +void MarlinHAL::init() { TERN_(DMA_IS_REQUIRED, dma_init()); #if ENABLED(SDSUPPORT) - #if SD_CONNECTION_IS(ONBOARD) && PIN_EXISTS(SD_DETECT) + #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 } -// HAL idle task -/* -void HAL_idletask() { -} -*/ - -void HAL_clear_reset_source() { } - #pragma push_macro("WDT") #undef WDT // Required to be able to use '.bit.WDT'. Compiler wrongly replace struct field with WDT define -uint8_t HAL_get_reset_source() { +uint8_t MarlinHAL::get_reset_source() { RSTC_RCAUSE_Type resetCause; resetCause.reg = REG_RSTC_RCAUSE; @@ -436,7 +621,7 @@ uint8_t HAL_get_reset_source() { } #pragma pop_macro("WDT") -void HAL_reboot() { NVIC_SystemReset(); } +void MarlinHAL::reboot() { NVIC_SystemReset(); } extern "C" { void * _sbrk(int incr); @@ -454,9 +639,11 @@ int freeMemory() { // ADC // ------------------------ -void HAL_adc_init() { +uint16_t MarlinHAL::adc_result; + +void MarlinHAL::adc_init() { #if ADC_IS_REQUIRED - memset(HAL_adc_results, 0xFF, sizeof(HAL_adc_results)); // Fill result with invalid values + memset(adc_results, 0xFF, sizeof(adc_results)); // Fill result with invalid values LOOP_L_N(pi, COUNT(adc_pins)) pinPeripheral(adc_pins[pi], PIO_ANALOG); @@ -491,17 +678,13 @@ void HAL_adc_init() { #endif // ADC_IS_REQUIRED } -void HAL_adc_start_conversion(const uint8_t adc_pin) { +void MarlinHAL::adc_start(const pin_t pin) { #if ADC_IS_REQUIRED - LOOP_L_N(pi, COUNT(adc_pins)) { - if (adc_pin == adc_pins[pi]) { - HAL_adc_result = HAL_adc_results[pi]; - return; - } - } + LOOP_L_N(pi, COUNT(adc_pins)) + if (pin == adc_pins[pi]) { adc_result = adc_results[pi]; return; } #endif - HAL_adc_result = 0xFFFF; + adc_result = 0xFFFF; } #endif // __SAMD51__ diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index c262752a8d66..79ba8021f4fd 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -26,7 +26,6 @@ #include "../shared/math_32bit.h" #include "../shared/HAL_SPI.h" #include "fastio.h" -#include "watchdog.h" #ifdef ADAFRUIT_GRAND_CENTRAL_M4 #include "MarlinSerial_AGCM4.h" @@ -89,51 +88,30 @@ typedef int8_t pin_t; -#define SHARED_SERVOS HAS_SERVOS -#define HAL_SERVO_LIB Servo +#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp + +class Servo; +typedef Servo hal_servo_t; // // Interrupts // -#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_PRIMASK()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() - -#define cli() __disable_irq() // Disable interrupts -#define sei() __enable_irq() // Enable interrupts - -void HAL_clear_reset_source(); // clear reset reason -uint8_t HAL_get_reset_source(); // get reset reason +#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() -void HAL_reboot(); +#define cli() __disable_irq() // Disable interrupts +#define sei() __enable_irq() // Enable interrupts // // ADC // -extern uint16_t HAL_adc_result; // Most recent ADC conversion - -#define HAL_ANALOG_SELECT(pin) - -void HAL_adc_init(); //#define HAL_ADC_FILTERED // Disable Marlin's oversampling. The HAL filters ADC values. #define HAL_ADC_VREF 3.3 #define HAL_ADC_RESOLUTION 10 // ... 12 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_result -#define HAL_ADC_READY() true -void HAL_adc_start_conversion(const uint8_t adc_pin); - -// -// PWM // -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } - -// -// Pin Map +// Pin Mapping for M42, M43, M226 // #define GET_PIN_MAP_PIN(index) index #define GET_PIN_MAP_INDEX(pin) pin @@ -142,35 +120,97 @@ inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, // // Tone // -void toneInit(); void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0); void noTone(const pin_t _pin); -// Enable hooks into idle and setup for HAL -void HAL_init(); -/* -#define HAL_IDLETASK 1 -void HAL_idletask(); -*/ - -// -// Utility functions -// -FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } +// ------------------------ +// Class Utilities +// ------------------------ #pragma GCC diagnostic push #if GCC_VERSION <= 50000 #pragma GCC diagnostic ignored "-Wunused-function" #endif -int freeMemory(); - -#pragma GCC diagnostic pop - #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/SAMD51/Servo.cpp b/Marlin/src/HAL/SAMD51/Servo.cpp index 23ab21c615c4..04461653f94f 100644 --- a/Marlin/src/HAL/SAMD51/Servo.cpp +++ b/Marlin/src/HAL/SAMD51/Servo.cpp @@ -124,7 +124,7 @@ HAL_SERVO_TIMER_ISR() { } } -void initISR(timer16_Sequence_t timer) { +void initISR(const timer16_Sequence_t timer) { Tc * const tc = timer_config[SERVO_TC].pTc; const uint8_t tcChannel = TIMER_TCCHANNEL(timer); @@ -201,7 +201,7 @@ void initISR(timer16_Sequence_t timer) { } } -void finISR(timer16_Sequence_t timer) { +void finISR(const timer16_Sequence_t timer) { Tc * const tc = timer_config[SERVO_TC].pTc; const uint8_t tcChannel = TIMER_TCCHANNEL(timer); diff --git a/Marlin/src/HAL/SAMD51/timers.cpp b/Marlin/src/HAL/SAMD51/timers.cpp index ce13dd231ecd..1ad0e360736a 100644 --- a/Marlin/src/HAL/SAMD51/timers.cpp +++ b/Marlin/src/HAL/SAMD51/timers.cpp @@ -79,7 +79,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { rtc->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP0; // RTC clock setup - OSC32KCTRL->RTCCTRL.reg = OSC32KCTRL_RTCCTRL_RTCSEL_XOSC32K; // External 32.768KHz oscillator + OSC32KCTRL->RTCCTRL.reg = OSC32KCTRL_RTCCTRL_RTCSEL_XOSC32K; // External 32.768kHz oscillator // Stop timer, just in case, to be able to reconfigure it rtc->MODE0.CTRLA.bit.ENABLE = false; diff --git a/Marlin/src/HAL/SAMD51/watchdog.cpp b/Marlin/src/HAL/SAMD51/watchdog.cpp deleted file mode 100644 index 9de451836aeb..000000000000 --- a/Marlin/src/HAL/SAMD51/watchdog.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) - * - * 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 . - * - */ -#ifdef __SAMD51__ - -#include "../../inc/MarlinConfig.h" - -#if ENABLED(USE_WATCHDOG) - -#include "watchdog.h" - -#define WDT_TIMEOUT_REG TERN(WATCHDOG_DURATION_8S, WDT_CONFIG_PER_CYC8192, WDT_CONFIG_PER_CYC4096) // 4 or 8 second timeout - -void watchdog_init() { - // The low-power oscillator used by the WDT runs at 32,768 Hz with - // a 1:32 prescale, thus 1024 Hz, though probably not super precise. - - // Setup WDT clocks - MCLK->APBAMASK.bit.OSC32KCTRL_ = true; - MCLK->APBAMASK.bit.WDT_ = true; - OSC32KCTRL->OSCULP32K.bit.EN1K = true; // Enable out 1K (this is what WDT uses) - - WDT->CTRLA.bit.ENABLE = false; // Disable watchdog for config - SYNC(WDT->SYNCBUSY.bit.ENABLE); - - WDT->INTENCLR.reg = WDT_INTENCLR_EW; // Disable early warning interrupt - WDT->CONFIG.reg = WDT_TIMEOUT_REG; // Set a 4s or 8s period for chip reset - - HAL_watchdog_refresh(); - - WDT->CTRLA.reg = WDT_CTRLA_ENABLE; // Start watchdog now in normal mode - SYNC(WDT->SYNCBUSY.bit.ENABLE); -} - -#endif // USE_WATCHDOG - -#endif // __SAMD51__ diff --git a/Marlin/src/HAL/SAMD51/watchdog.h b/Marlin/src/HAL/SAMD51/watchdog.h deleted file mode 100644 index 2cd4788229b0..000000000000 --- a/Marlin/src/HAL/SAMD51/watchdog.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Marlin 3D Printer Firmware - * - * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) - * - * 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 - -// Initialize watchdog with a 4 second interrupt time -void watchdog_init(); - -// Reset watchdog. MUST be called at least every 4 seconds after the -// first watchdog_init or SAMD will go into emergency procedures. -inline void HAL_watchdog_refresh() { - SYNC(WDT->SYNCBUSY.bit.CLEAR); // Test first if previous is 'ongoing' to save time waiting for command execution - WDT->CLEAR.reg = WDT_CLEAR_CLEAR_KEY; -} diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index 0920a72ec1bc..aff52f597f4d 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -24,14 +24,13 @@ #ifdef HAL_STM32 -#include "HAL.h" -#include "usb_serial.h" - #include "../../inc/MarlinConfig.h" #include "../shared/Delay.h" +#include "usb_serial.h" + #ifdef USBCON - DefaultSerial1 MSerial0(false, SerialUSB); + DefaultSerial1 MSerialUSB(false, SerialUSB); #endif #if ENABLED(SRAM_EEPROM_EMULATION) @@ -53,16 +52,18 @@ // Public Variables // ------------------------ -uint16_t HAL_adc_result; +uint16_t MarlinHAL::adc_result; // ------------------------ // Public functions // ------------------------ -TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial()); +#if ENABLED(POSTMORTEM_DEBUGGING) + extern void install_min_serial(); +#endif // HAL initialization task -void HAL_init() { +void MarlinHAL::init() { // Ensure F_CPU is a constant expression. // If the compiler breaks here, it means that delay code that should compute at compile time will not work. // So better safe than sorry here. @@ -87,7 +88,7 @@ void HAL_init() { SetTimerInterruptPriorities(); - #if ENABLED(EMERGENCY_PARSER) && USBD_USE_CDC + #if ENABLED(EMERGENCY_PARSER) && (USBD_USE_CDC || USBD_USE_CDC_MSC) USB_Hook_init(); #endif @@ -103,7 +104,7 @@ void HAL_init() { } // HAL idle task -void HAL_idletask() { +void MarlinHAL::idletask() { #if HAS_SHARED_MEDIA // Stm32duino currently doesn't have a "loop/idle" method CDC_resume_receive(); @@ -111,9 +112,9 @@ void HAL_idletask() { #endif } -void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); } +void MarlinHAL::reboot() { NVIC_SystemReset(); } -uint8_t HAL_get_reset_source() { +uint8_t MarlinHAL::get_reset_source() { return #ifdef RCC_FLAG_IWDGRST // Some sources may not exist... RESET != __HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) ? RST_WATCHDOG : @@ -137,24 +138,37 @@ uint8_t HAL_get_reset_source() { ; } -void HAL_reboot() { NVIC_SystemReset(); } +void MarlinHAL::clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); } + +// ------------------------ +// Watchdog Timer +// ------------------------ + +#if ENABLED(USE_WATCHDOG) + + #define WDT_TIMEOUT_US TERN(WATCHDOG_DURATION_8S, 8000000, 4000000) // 4 or 8 second timeout -void _delay_ms(const int delay_ms) { delay(delay_ms); } + #include + + void MarlinHAL::watchdog_init() { + IF_DISABLED(DISABLE_WATCHDOG_INIT, IWatchdog.begin(WDT_TIMEOUT_US)); + } + + void MarlinHAL::watchdog_refresh() { + IWatchdog.reload(); + #if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED) + TOGGLE(LED_PIN); // heartbeat indicator + #endif + } + +#endif extern "C" { extern unsigned int _ebss; // end of bss section } -// ------------------------ -// ADC -// ------------------------ - -// TODO: Make sure this doesn't cause any delay -void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRead(adc_pin); } -uint16_t HAL_adc_get_result() { return HAL_adc_result; } - // Reset the system to initiate a firmware flash -WEAK void flashFirmware(const int16_t) { HAL_reboot(); } +WEAK void flashFirmware(const int16_t) { hal.reboot(); } // Maple Compatibility volatile uint32_t systick_uptime_millis = 0; diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index adaf14223f32..3e85aca293d2 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -30,7 +30,6 @@ #include "../shared/HAL_SPI.h" #include "fastio.h" #include "Servo.h" -#include "watchdog.h" #include "MarlinSerial.h" #include "../../inc/MarlinConfigPre.h" @@ -44,64 +43,74 @@ #define CPU_ST7920_DELAY_2 40 #define CPU_ST7920_DELAY_3 340 -// -// Serial Ports -// +// ------------------------ +// Serial ports +// ------------------------ #ifdef USBCON #include #include "../../core/serial_hook.h" typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1; - extern DefaultSerial1 MSerial0; + extern DefaultSerial1 MSerialUSB; #endif #define _MSERIAL(X) MSerial##X #define MSERIAL(X) _MSERIAL(X) -#if SERIAL_PORT == -1 - #define MYSERIAL1 MSerial0 -#elif WITHIN(SERIAL_PORT, 1, 6) +#if WITHIN(SERIAL_PORT, 1, 6) #define MYSERIAL1 MSERIAL(SERIAL_PORT) +#elif !defined(USBCON) + #error "SERIAL_PORT must be from 1 to 6." +#elif SERIAL_PORT == -1 + #define MYSERIAL1 MSerialUSB #else - #error "SERIAL_PORT must be from 1 to 6. You can also use -1 if the board supports Native USB." + #error "SERIAL_PORT must be from 1 to 6, or -1 for Native USB." #endif #ifdef SERIAL_PORT_2 - #if SERIAL_PORT_2 == -1 - #define MYSERIAL2 MSerial0 - #elif WITHIN(SERIAL_PORT_2, 1, 6) + #if WITHIN(SERIAL_PORT_2, 1, 6) #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) + #elif !defined(USBCON) + #error "SERIAL_PORT must be from 1 to 6." + #elif SERIAL_PORT_2 == -1 + #define MYSERIAL2 MSerialUSB #else - #error "SERIAL_PORT_2 must be from 1 to 6. You can also use -1 if the board supports Native USB." + #error "SERIAL_PORT_2 must be from 1 to 6, or -1 for Native USB." #endif #endif #ifdef SERIAL_PORT_3 - #if SERIAL_PORT_3 == -1 - #define MYSERIAL3 MSerial0 - #elif WITHIN(SERIAL_PORT_3, 1, 6) + #if WITHIN(SERIAL_PORT_3, 1, 6) #define MYSERIAL3 MSERIAL(SERIAL_PORT_3) + #elif !defined(USBCON) + #error "SERIAL_PORT must be from 1 to 6." + #elif SERIAL_PORT_3 == -1 + #define MYSERIAL3 MSerialUSB #else - #error "SERIAL_PORT_3 must be from 1 to 6. You can also use -1 if the board supports Native USB." + #error "SERIAL_PORT_3 must be from 1 to 6, or -1 for Native USB." #endif #endif #ifdef MMU2_SERIAL_PORT - #if MMU2_SERIAL_PORT == -1 - #define MMU2_SERIAL MSerial0 - #elif WITHIN(MMU2_SERIAL_PORT, 1, 6) + #if WITHIN(MMU2_SERIAL_PORT, 1, 6) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT) + #elif !defined(USBCON) + #error "SERIAL_PORT must be from 1 to 6." + #elif MMU2_SERIAL_PORT == -1 + #define MMU2_SERIAL MSerialUSB #else - #error "MMU2_SERIAL_PORT must be from 1 to 6. You can also use -1 if the board supports Native USB." + #error "MMU2_SERIAL_PORT must be from 1 to 6, or -1 for Native USB." #endif #endif #ifdef LCD_SERIAL_PORT - #if LCD_SERIAL_PORT == -1 - #define LCD_SERIAL MSerial0 - #elif WITHIN(LCD_SERIAL_PORT, 1, 6) + #if WITHIN(LCD_SERIAL_PORT, 1, 6) #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) + #elif !defined(USBCON) + #error "SERIAL_PORT must be from 1 to 6." + #elif LCD_SERIAL_PORT == -1 + #define LCD_SERIAL MSerialUSB #else - #error "LCD_SERIAL_PORT must be from 1 to 6. You can also use -1 if the board supports Native USB." + #error "LCD_SERIAL_PORT must be from 1 to 6, or -1 for Native USB." #endif #if HAS_DGUS_LCD #define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite() @@ -115,64 +124,81 @@ #define analogInputToDigitalPin(p) (p) #endif -#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_PRIMASK()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() +// +// Interrupts +// +#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() #define cli() __disable_irq() #define sei() __enable_irq() -// On AVR this is in math.h? -#define square(x) ((x)*(x)) - // ------------------------ // Types // ------------------------ +typedef double isr_float_t; // FPU ops are used for single-precision, so use double for ISRs. + #ifdef STM32G0B1xx typedef int32_t pin_t; #else typedef int16_t pin_t; #endif -#define HAL_SERVO_LIB libServo +class libServo; +typedef libServo hal_servo_t; #define PAUSE_SERVO_OUTPUT() libServo::pause_all_servos() #define RESUME_SERVO_OUTPUT() libServo::resume_all_servos() // ------------------------ -// Public Variables +// ADC // ------------------------ -// result of last ADC conversion -extern uint16_t HAL_adc_result; +#ifdef ADC_RESOLUTION + #define HAL_ADC_RESOLUTION ADC_RESOLUTION +#else + #define HAL_ADC_RESOLUTION 12 +#endif -// ------------------------ -// Public functions -// ------------------------ +#define HAL_ADC_VREF 3.3 -// Memory related -#define __bss_end __bss_end__ +// +// 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) + +#ifdef STM32F1xx + #define JTAG_DISABLE() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_JTAGDISABLE) + #define JTAGSWD_DISABLE() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_DISABLE) + #define JTAGSWD_RESET() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_RESET); // Reset: FULL SWD+JTAG +#endif -// Enable hooks into setup for HAL -void HAL_init(); -#define HAL_IDLETASK 1 -void HAL_idletask(); +#define PLATFORM_M997_SUPPORT +void flashFirmware(const int16_t); + +// Maple Compatibility +typedef void (*systickCallback_t)(void); +void systick_attach_callback(systickCallback_t cb); +void HAL_SYSTICK_Callback(); -// Clear reset reason -void HAL_clear_reset_source(); +extern volatile uint32_t systick_uptime_millis; -// Reset reason -uint8_t HAL_get_reset_source(); +#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment -void HAL_reboot(); +// ------------------------ +// Class Utilities +// ------------------------ -void _delay_ms(const int delay); +// Memory related +#define __bss_end __bss_end__ extern "C" char* _sbrk(int incr); #pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-function" +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif static inline int freeMemory() { volatile char top; @@ -181,62 +207,75 @@ static inline int freeMemory() { #pragma GCC diagnostic pop -// -// ADC -// +// ------------------------ +// MarlinHAL Class +// ------------------------ -#define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT) +class MarlinHAL { +public: -#ifdef ADC_RESOLUTION - #define HAL_ADC_RESOLUTION ADC_RESOLUTION -#else - #define HAL_ADC_RESOLUTION 12 -#endif + // Earliest possible init, before setup() + MarlinHAL() {} -#define HAL_ADC_VREF 3.3 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_result -#define HAL_ADC_READY() true + // Watchdog + static void watchdog_init() IF_DISABLED(USE_WATCHDOG, {}); + static void watchdog_refresh() IF_DISABLED(USE_WATCHDOG, {}); -inline void HAL_adc_init() { analogReadResolution(HAL_ADC_RESOLUTION); } + static void init(); // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 -void HAL_adc_start_conversion(const uint8_t adc_pin); + // Interrupts + static bool isr_state() { return !__get_PRIMASK(); } + static void isr_on() { sei(); } + static void isr_off() { cli(); } -uint16_t HAL_adc_get_result(); + static void delay_ms(const int ms) { delay(ms); } -#define GET_PIN_MAP_PIN(index) index -#define GET_PIN_MAP_INDEX(pin) pin -#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + // Tasks, called from idle() + static void idletask(); -#ifdef STM32F1xx - #define JTAG_DISABLE() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_JTAGDISABLE) - #define JTAGSWD_DISABLE() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_DISABLE) - #define JTAGSWD_RESET() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_RESET); // Reset: FULL SWD+JTAG -#endif + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source(); -#define PLATFORM_M997_SUPPORT -void flashFirmware(const int16_t); + // Free SRAM + static int freeMemory() { return ::freeMemory(); } -// Maple Compatibility -typedef void (*systickCallback_t)(void); -void systick_attach_callback(systickCallback_t cb); -void HAL_SYSTICK_Callback(); + // + // ADC Methods + // -extern volatile uint32_t systick_uptime_millis; + static uint16_t adc_result; -#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment + // Called by Temperature::init once at startup + static void adc_init() { + analogReadResolution(HAL_ADC_RESOLUTION); + } -/** - * set_pwm_frequency - * Set the frequency of the timer corresponding to the provided pin - * All Timer PWM pins run at the same frequency - */ -void set_pwm_frequency(const pin_t pin, int f_desired); + // Called by Temperature::init for each sensor at startup + static void adc_enable(const pin_t pin) { pinMode(pin, INPUT); } -/** - * set_pwm_duty - * Set the PWM duty cycle of the provided pin to the provided value - * Optionally allows inverting the duty cycle [default = false] - * Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255] - */ -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); + // Begin ADC sampling on the given pin. Called from Temperature::isr! + static void adc_start(const pin_t pin) { adc_result = analogRead(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. + * Optionally invert the duty cycle [default = false] + * Optionally change the maximum size 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 v_size=255, const bool invert=false); + + /** + * Set the frequency of the timer for the given pin. + * All Timer PWM pins run at the same frequency. + */ + static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired); + +}; diff --git a/Marlin/src/HAL/STM32/HAL_SPI.cpp b/Marlin/src/HAL/STM32/HAL_SPI.cpp index 8ee476164785..40d320d5e822 100644 --- a/Marlin/src/HAL/STM32/HAL_SPI.cpp +++ b/Marlin/src/HAL/STM32/HAL_SPI.cpp @@ -102,9 +102,9 @@ static SPISettings spiConfig; // Soft SPI receive byte uint8_t spiRec() { - DISABLE_ISRS(); // No interrupts during byte receive + hal.isr_off(); // No interrupts during byte receive const uint8_t data = HAL_SPI_STM32_SpiTransfer_Mode_3(0xFF); - ENABLE_ISRS(); // Enable interrupts + hal.isr_on(); // Enable interrupts return data; } @@ -116,9 +116,9 @@ static SPISettings spiConfig; // Soft SPI send byte void spiSend(uint8_t data) { - DISABLE_ISRS(); // No interrupts during byte send + hal.isr_off(); // No interrupts during byte send HAL_SPI_STM32_SpiTransfer_Mode_3(data); // Don't care what is received - ENABLE_ISRS(); // Enable interrupts + hal.isr_on(); // Enable interrupts } // Soft SPI send block diff --git a/Marlin/src/HAL/STM32/HAL_MinSerial.cpp b/Marlin/src/HAL/STM32/MinSerial.cpp similarity index 97% rename from Marlin/src/HAL/STM32/HAL_MinSerial.cpp rename to Marlin/src/HAL/STM32/MinSerial.cpp index b6e86b72daa9..b0fcff20c172 100644 --- a/Marlin/src/HAL/STM32/HAL_MinSerial.cpp +++ b/Marlin/src/HAL/STM32/MinSerial.cpp @@ -28,8 +28,7 @@ #if ENABLED(POSTMORTEM_DEBUGGING) -#include "../shared/HAL_MinSerial.h" -#include "watchdog.h" +#include "../shared/MinSerial.h" /* Instruction Synchronization Barrier */ #define isb() __asm__ __volatile__ ("isb" : : : "memory") @@ -120,7 +119,7 @@ static void TX(char c) { #if WITHIN(SERIAL_PORT, 1, 6) constexpr uint32_t usart_sr_txe = _BV(7); while (!(regs->SR & usart_sr_txe)) { - TERN_(USE_WATCHDOG, HAL_watchdog_refresh()); + hal.watchdog_refresh(); sw_barrier(); } regs->DR = c; diff --git a/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp b/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp deleted file mode 100644 index 54e1820c78e6..000000000000 --- a/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp +++ /dev/null @@ -1,326 +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 "../platforms.h" - -#ifdef HAL_STM32 - -#include "../../inc/MarlinConfig.h" - -#if ENABLED(SDIO_SUPPORT) - -#include -#include - -// use local drivers -#if defined(STM32F103xE) || defined(STM32F103xG) - #include - #include -#elif defined(STM32F4xx) - #include - #include - #include - #include -#elif defined(STM32F7xx) - #include - #include - #include - #include -#else - #error "SDIO only supported with STM32F103xE, STM32F103xG, STM32F4xx, or STM32F7xx." -#endif - -// Fixed -#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 - -SD_HandleTypeDef hsd; // create SDIO structure -// 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; - -/* - 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 board seems to have stable SDIO with BusWide 1bit and ClockDiv 8 i.e. 4.8MHz SDIO clock frequency - Additional testing is required as there are clearly some 4bit initialization problems -*/ - -#ifndef USBD_OK - #define USBD_OK 0 -#endif - -// Target Clock, configurable. Default is 18MHz, from STM32F1 -#ifndef SDIO_CLOCK - #define SDIO_CLOCK 18000000 // 18 MHz -#endif - -// SDIO retries, configurable. Default is 3, from STM32F1 -#ifndef SDIO_READ_RETRIES - #define SDIO_READ_RETRIES 3 -#endif - -// SDIO Max Clock (naming from STM Manual, don't change) -#define SDIOCLK 48000000 - -static uint32_t clock_to_divider(uint32_t clk) { - // 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; -} - -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); -} - -void SD_LowLevel_Init(void) { - uint32_t tempreg; - - __HAL_RCC_GPIOC_CLK_ENABLE(); //enable GPIO clocks - __HAL_RCC_GPIOD_CLK_ENABLE(); //enable GPIO clocks - - 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 - #if defined(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.Priority = DMA_PRIORITY_LOW; - __HAL_LINKDMA(&hsd, hdmarx, hdma_sdio); - __HAL_LINKDMA(&hsd, hdmatx, hdma_sdio); - - #if defined(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 - tempreg |= SDIO_CLKCR_CLKEN; // Clock enabled - tempreg |= 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; -} - -void HAL_SD_MspInit(SD_HandleTypeDef *hsd) { // application specific init - UNUSED(hsd); // Prevent unused argument(s) compilation warning - __HAL_RCC_SDIO_CLK_ENABLE(); // turn on SDIO clock -} - -bool SDIO_Init() { - uint8_t retryCnt = SDIO_READ_RETRIES; - - bool status; - hsd.Instance = SDIO; - hsd.State = HAL_SD_STATE_RESET; - - SD_LowLevel_Init(); - - uint8_t retry_Cnt = retryCnt; - for (;;) { - TERN_(USE_WATCHDOG, 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(); - - #if PINS_EXIST(SDIO_D1, SDIO_D2, SDIO_D3) // go to 4 bit wide mode if pins are defined - retry_Cnt = retryCnt; - for (;;) { - TERN_(USE_WATCHDOG, 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 (;;) { - TERN_(USE_WATCHDOG, 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; -} - -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; - - TERN_(USE_WATCHDOG, 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() + 500; - // 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_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() + 500; - while (HAL_SD_GetCardState(&hsd) != HAL_SD_CARD_TRANSFER) if (ELAPSED(millis(), timeout)) return false; - - return true; -} - -bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) { - uint8_t retries = SDIO_READ_RETRIES; - while (retries--) if (SDIO_ReadWriteBlock_DMA(block, nullptr, dst)) return true; - return false; -} - -bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) { - uint8_t retries = SDIO_READ_RETRIES; - while (retries--) if (SDIO_ReadWriteBlock_DMA(block, src, nullptr)) return true; - return false; -} - -bool SDIO_IsReady() { - return hsd.State == HAL_SD_STATE_READY; -} - -uint32_t SDIO_GetCardSize() { - return (uint32_t)(hsd.SdCard.BlockNbr) * (hsd.SdCard.BlockSize); -} - -#if defined(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 - -extern "C" void SDIO_IRQHandler(void) { HAL_SD_IRQHandler(&hsd); } -extern "C" void DMA_IRQ_HANDLER(void) { HAL_DMA_IRQHandler(&hdma_sdio); } - -#endif // SDIO_SUPPORT -#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/eeprom_flash.cpp b/Marlin/src/HAL/STM32/eeprom_flash.cpp index 252b057362c9..7c8cc8dd21e1 100644 --- a/Marlin/src/HAL/STM32/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32/eeprom_flash.cpp @@ -174,9 +174,9 @@ bool PersistentStore::access_finish() { UNLOCK_FLASH(); TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT()); - DISABLE_ISRS(); + hal.isr_off(); status = HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError); - ENABLE_ISRS(); + hal.isr_on(); TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT()); if (status != HAL_OK) { DEBUG_ECHOLNPGM("HAL_FLASHEx_Erase=", status); @@ -229,9 +229,9 @@ bool PersistentStore::access_finish() { // output. Servo output still glitches with interrupts disabled, but recovers after the // erase. TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT()); - DISABLE_ISRS(); + hal.isr_off(); eeprom_buffer_flush(); - ENABLE_ISRS(); + hal.isr_on(); TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT()); eeprom_data_written = false; diff --git a/Marlin/src/HAL/STM32/fast_pwm.cpp b/Marlin/src/HAL/STM32/fast_pwm.cpp index b1bea5ce20eb..a0d8ecc612c2 100644 --- a/Marlin/src/HAL/STM32/fast_pwm.cpp +++ b/Marlin/src/HAL/STM32/fast_pwm.cpp @@ -29,34 +29,39 @@ // Array to support sticky frequency sets per timer static uint16_t timer_freq[TIMER_NUM]; -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { - if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer - const PinName pin_name = digitalPinToPinName(pin); - TIM_TypeDef * const Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM); +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)) { + const PinName pin_name = digitalPinToPinName(pin); + TIM_TypeDef * const Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM); - const timer_index_t index = get_timer_index(Instance); - const bool needs_freq = (HardwareTimer_Handle[index] == nullptr); - if (needs_freq) // A new instance must be set to the default frequency of PWM_FREQUENCY - HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM)); + const timer_index_t index = get_timer_index(Instance); + const bool needs_freq = (HardwareTimer_Handle[index] == nullptr); + if (needs_freq) // A new instance must be set to the default frequency of PWM_FREQUENCY + HardwareTimer_Handle[index]->__this = new HardwareTimer((TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM)); - HardwareTimer * const HT = (HardwareTimer *)(HardwareTimer_Handle[index]->__this); - const uint32_t channel = STM_PIN_CHANNEL(pinmap_function(pin_name, PinMap_PWM)); - const TimerModes_t previousMode = HT->getMode(channel); - if (previousMode != TIMER_OUTPUT_COMPARE_PWM1) - HT->setMode(channel, TIMER_OUTPUT_COMPARE_PWM1, pin); + HardwareTimer * const HT = (HardwareTimer *)(HardwareTimer_Handle[index]->__this); + const uint32_t channel = STM_PIN_CHANNEL(pinmap_function(pin_name, PinMap_PWM)); + const TimerModes_t previousMode = HT->getMode(channel); + if (previousMode != TIMER_OUTPUT_COMPARE_PWM1) + HT->setMode(channel, TIMER_OUTPUT_COMPARE_PWM1, pin); - if (needs_freq && timer_freq[index] == 0) // If the timer is unconfigured and no freq is set then default PWM_FREQUENCY - set_pwm_frequency(pin_name, PWM_FREQUENCY); // Set the frequency and save the value to the assigned index no. + if (needs_freq && timer_freq[index] == 0) // If the timer is unconfigured and no freq is set then default PWM_FREQUENCY + set_pwm_frequency(pin_name, PWM_FREQUENCY); // Set the frequency and save the value to the assigned index no. - // Note the resolution is sticky here, the input can be upto 16 bits and that would require RESOLUTION_16B_COMPARE_FORMAT (16) - // If such a need were to manifest then we would need to calc the resolution based on the v_size parameter and add code for it. - const uint16_t value = invert ? v_size - v : v; - HT->setCaptureCompare(channel, value, RESOLUTION_8B_COMPARE_FORMAT); // Sets the duty, the calc is done in the library :) - pinmap_pinout(pin_name, PinMap_PWM); // Make sure the pin output state is set. - if (previousMode != TIMER_OUTPUT_COMPARE_PWM1) HT->resume(); + // Note the resolution is sticky here, the input can be upto 16 bits and that would require RESOLUTION_16B_COMPARE_FORMAT (16) + // If such a need were to manifest then we would need to calc the resolution based on the v_size parameter and add code for it. + HT->setCaptureCompare(channel, duty, RESOLUTION_8B_COMPARE_FORMAT); // Set the duty, the calc is done in the library :) + pinmap_pinout(pin_name, PinMap_PWM); // Make sure the pin output state is set. + if (previousMode != TIMER_OUTPUT_COMPARE_PWM1) HT->resume(); + } + else { + pinMode(pin, OUTPUT); + digitalWrite(pin, duty < v_size / 2 ? LOW : HIGH); + } } -void set_pwm_frequency(const pin_t pin, int f_desired) { +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 const PinName pin_name = digitalPinToPinName(pin); TIM_TypeDef * const Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM); // Get HAL timer instance diff --git a/Marlin/src/HAL/STM32/msc_sd.cpp b/Marlin/src/HAL/STM32/msc_sd.cpp index 4f85af0d446a..a40bec9d644d 100644 --- a/Marlin/src/HAL/STM32/msc_sd.cpp +++ b/Marlin/src/HAL/STM32/msc_sd.cpp @@ -57,7 +57,7 @@ class Sd2CardUSBMscHandler : public USBMscHandler { auto sd2card = diskIODriver(); // single block if (blkLen == 1) { - watchdog_refresh(); + hal.watchdog_refresh(); sd2card->writeBlock(blkAddr, pBuf); return true; } @@ -65,7 +65,7 @@ class Sd2CardUSBMscHandler : public USBMscHandler { // multi block optimization sd2card->writeStart(blkAddr, blkLen); while (blkLen--) { - watchdog_refresh(); + hal.watchdog_refresh(); sd2card->writeData(pBuf); pBuf += BLOCK_SIZE; } @@ -77,7 +77,7 @@ class Sd2CardUSBMscHandler : public USBMscHandler { auto sd2card = diskIODriver(); // single block if (blkLen == 1) { - watchdog_refresh(); + hal.watchdog_refresh(); sd2card->readBlock(blkAddr, pBuf); return true; } @@ -85,7 +85,7 @@ class Sd2CardUSBMscHandler : public USBMscHandler { // multi block optimization sd2card->readStart(blkAddr); while (blkLen--) { - watchdog_refresh(); + hal.watchdog_refresh(); sd2card->readData(pBuf); pBuf += BLOCK_SIZE; } diff --git a/Marlin/src/HAL/STM32/pinsDebug.h b/Marlin/src/HAL/STM32/pinsDebug.h index 73d850fc4313..55c64c868192 100644 --- a/Marlin/src/HAL/STM32/pinsDebug.h +++ b/Marlin/src/HAL/STM32/pinsDebug.h @@ -79,7 +79,6 @@ // make a list of the Arduino pin numbers in the Port/Pin order // -#define _PIN_ADD_2(NAME_ALPHA, ARDUINO_NUM) { {NAME_ALPHA}, ARDUINO_NUM }, #define _PIN_ADD(NAME_ALPHA, ARDUINO_NUM) { NAME_ALPHA, ARDUINO_NUM }, #define PIN_ADD(NAME) _PIN_ADD(#NAME, NAME) @@ -108,14 +107,17 @@ const XrefInfo pin_xref[] PROGMEM = { /** * Translation of routines & variables used by pinsDebug.h */ -#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS + +#if PA0 >= 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 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) #define PRINT_PORT(ANUM) port_print(ANUM) #define DIGITAL_PIN_TO_ANALOG_PIN(ANUM) -1 // will report analog pin number in the print port routine -#define GET_PIN_MAP_PIN_M43(Index) pin_xref[Index].Ard_num // x is a variable used to search pin_array #define GET_ARRAY_IS_DIGITAL(x) ((bool) pin_array[x].is_digital) @@ -123,6 +125,11 @@ const XrefInfo pin_xref[] PROGMEM = { #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 MULTI_NAME_PAD 33 // space needed to be pretty if not first name assigned to a pin +// +// Pin Mapping for M43 +// +#define GET_PIN_MAP_PIN_M43(Index) pin_xref[Index].Ard_num + #ifndef M43_NEVER_TOUCH #define _M43_NEVER_TOUCH(Index) (Index >= 9 && Index <= 12) // SERIAL/USB pins: PA9(TX) PA10(RX) PA11(USB_DM) PA12(USB_DP) #ifdef KILL_PIN @@ -160,17 +167,20 @@ bool GET_PINMODE(const pin_t Ard_num) { return pin_mode == MODE_PIN_OUTPUT || pin_mode == MODE_PIN_ALT; // assume all alt definitions are PWM } -int8_t digital_pin_to_analog_pin(pin_t Ard_num) { - Ard_num -= NUM_ANALOG_FIRST; - return (Ard_num >= 0 && Ard_num < NUM_ANALOG_INPUTS) ? Ard_num : -1; +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)) + return Ard_num - NUM_ANALOG_FIRST; + + const uint32_t ind = digitalPinToAnalogInput(Ard_num); + return (ind < NUM_ANALOG_INPUTS) ? ind : -1; } bool IS_ANALOG(const pin_t Ard_num) { return get_pin_mode(Ard_num) == MODE_PIN_ANALOG; } -bool is_digital(const pin_t x) { - const uint8_t pin_mode = get_pin_mode(pin_array[x].pin); +bool is_digital(const pin_t Ard_num) { + const uint8_t pin_mode = get_pin_mode(pin_array[Ard_num].pin); return pin_mode == MODE_PIN_INPUT || pin_mode == MODE_PIN_OUTPUT; } @@ -196,10 +206,15 @@ void port_print(const pin_t Ard_num) { SERIAL_ECHO_SP(7); // Print number to be used with M42 - sprintf_P(buffer, PSTR(" M42 P%d "), Ard_num); - SERIAL_ECHO(buffer); - if (Ard_num < 10) SERIAL_CHAR(' '); - if (Ard_num < 100) SERIAL_CHAR(' '); + int calc_p = Ard_num % (NUM_DIGITAL_PINS + 1); + if (Ard_num > NUM_DIGITAL_PINS && calc_p > 7) calc_p += 8; + SERIAL_ECHOPGM(" M42 P", calc_p); + SERIAL_CHAR(' '); + if (calc_p < 100) { + SERIAL_CHAR(' '); + if (calc_p < 10) + SERIAL_CHAR(' '); + } } bool pwm_status(const pin_t Ard_num) { @@ -221,19 +236,19 @@ void pwm_details(const pin_t Ard_num) { case 'D' : alt_all = GPIOD->AFR[ind]; break; #ifdef PE_0 case 'E' : alt_all = GPIOE->AFR[ind]; break; - #elif defined (PF_0) + #elif defined(PF_0) case 'F' : alt_all = GPIOF->AFR[ind]; break; - #elif defined (PG_0) + #elif defined(PG_0) case 'G' : alt_all = GPIOG->AFR[ind]; break; - #elif defined (PH_0) + #elif defined(PH_0) case 'H' : alt_all = GPIOH->AFR[ind]; break; - #elif defined (PI_0) + #elif defined(PI_0) case 'I' : alt_all = GPIOI->AFR[ind]; break; - #elif defined (PJ_0) + #elif defined(PJ_0) case 'J' : alt_all = GPIOJ->AFR[ind]; break; - #elif defined (PK_0) + #elif defined(PK_0) case 'K' : alt_all = GPIOK->AFR[ind]; break; - #elif defined (PL_0) + #elif defined(PL_0) case 'L' : alt_all = GPIOL->AFR[ind]; break; #endif } diff --git a/Marlin/src/HAL/STM32/sdio.cpp b/Marlin/src/HAL/STM32/sdio.cpp new file mode 100644 index 000000000000..e958d8c3bc48 --- /dev/null +++ b/Marlin/src/HAL/STM32/sdio.cpp @@ -0,0 +1,268 @@ +/** + * 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 "../platforms.h" + +#ifdef HAL_STM32 + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(SDIO_SUPPORT) + +#include "sdio.h" + +#include +#include + +// use local drivers +#if defined(STM32F103xE) || defined(STM32F103xG) + #include +#elif defined(STM32F4xx) + #include +#elif defined(STM32F7xx) + #include +#elif defined(STM32H7xx) + #include +#else + #error "SDIO only supported with STM32F103xE, STM32F103xG, STM32F4xx, STM32F7xx, or STM32H7xx." +#endif + +// Target Clock, configurable. Default is 18MHz, from STM32F1 +#ifndef SDIO_CLOCK + #define SDIO_CLOCK 18000000 // 18 MHz +#endif + +#define SD_TIMEOUT 1000 // ms + +// SDIO Max Clock (naming from STM Manual, don't change) +#define SDIOCLK 48000000 + +#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); + } + + extern "C" void DMA2_Stream6_IRQHandler(void) { + HAL_DMA_IRQHandler(&hdma_sdio_tx); + } +#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; + +extern "C" void SDIO_IRQHandler(void) { + HAL_SD_IRQHandler(&hsd); +} + +void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsdio) { + waitingTxCplt = 0; +} + +void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsdio) { + waitingRxCplt = 0; +} + +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); + #endif + + __HAL_RCC_SDIO_CLK_ENABLE(); + HAL_NVIC_EnableIRQ(SDIO_IRQn); + + // 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; + 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); + #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 +} + +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 +} + +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 +} + +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); + } + #endif + + return (sd_state == HAL_OK) ? true : false; +} + +bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) { + 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; +} + +bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) { + uint32_t timeout = HAL_GetTick() + SD_TIMEOUT; + + 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; + + return true; +} + +bool SDIO_IsReady() { + return hsd.State == HAL_SD_STATE_READY; +} + +uint32_t SDIO_GetCardSize() { + return (uint32_t)(hsd.SdCard.BlockNbr) * (hsd.SdCard.BlockSize); +} + +#endif // SDIO_SUPPORT +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/NATIVE_SIM/watchdog.h b/Marlin/src/HAL/STM32/sdio.h similarity index 84% rename from Marlin/src/HAL/NATIVE_SIM/watchdog.h rename to Marlin/src/HAL/STM32/sdio.h index 4e404c3887da..cf5539c3c76d 100644 --- a/Marlin/src/HAL/NATIVE_SIM/watchdog.h +++ b/Marlin/src/HAL/STM32/sdio.h @@ -21,7 +21,9 @@ */ #pragma once -#define WDT_TIMEOUT 4000000 // 4 second timeout - -void watchdog_init(); -void HAL_watchdog_refresh(); +#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/HAL/STM32/tft/tft_spi.cpp b/Marlin/src/HAL/STM32/tft/tft_spi.cpp index 4ad35cee8ba3..2e18c8a64c06 100644 --- a/Marlin/src/HAL/STM32/tft/tft_spi.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_spi.cpp @@ -242,5 +242,29 @@ void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Coun Abort(); } +#if ENABLED(USE_SPI_DMA_TC) + + void TFT_SPI::TransmitDMA_IT(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count) { + + DMAtx.Init.MemInc = MemoryIncrease; + HAL_DMA_Init(&DMAtx); + + if (TFT_MISO_PIN == TFT_MOSI_PIN) + SPI_1LINE_TX(&SPIx); + + DataTransferBegin(); + + HAL_NVIC_SetPriority(DMA2_Stream3_IRQn, 5, 0); + HAL_NVIC_EnableIRQ(DMA2_Stream3_IRQn); + HAL_DMA_Start_IT(&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 + } + + extern "C" void DMA2_Stream3_IRQHandler(void) { HAL_DMA_IRQHandler(&TFT_SPI::DMAtx); } + +#endif + #endif // HAS_SPI_TFT #endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/tft/tft_spi.h b/Marlin/src/HAL/STM32/tft/tft_spi.h index 667b5f366b7e..de051e229459 100644 --- a/Marlin/src/HAL/STM32/tft/tft_spi.h +++ b/Marlin/src/HAL/STM32/tft/tft_spi.h @@ -36,20 +36,25 @@ #define LCD_READ_ID4 0xD3 // Read display identification information (0xD3 on ILI9341) #endif -#define DATASIZE_8BIT SPI_DATASIZE_8BIT -#define DATASIZE_16BIT SPI_DATASIZE_16BIT -#define TFT_IO_DRIVER TFT_SPI +#define DATASIZE_8BIT SPI_DATASIZE_8BIT +#define DATASIZE_16BIT SPI_DATASIZE_16BIT +#define TFT_IO_DRIVER TFT_SPI 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 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(); @@ -63,6 +68,11 @@ class TFT_SPI { 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); } + + #if ENABLED(USE_SPI_DMA_TC) + static void WriteSequenceIT(uint16_t *Data, uint16_t Count) { TransmitDMA_IT(DMA_MINC_ENABLE, Data, Count); } + #endif + static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); } static void WriteMultiple(uint16_t Color, uint32_t Count) { static uint16_t Data; Data = Color; diff --git a/Marlin/src/HAL/STM32/tft/xpt2046.h b/Marlin/src/HAL/STM32/tft/xpt2046.h index 2cff3e29d05b..71de6b00251b 100644 --- a/Marlin/src/HAL/STM32/tft/xpt2046.h +++ b/Marlin/src/HAL/STM32/tft/xpt2046.h @@ -69,8 +69,8 @@ class XPT2046 { static uint16_t getRawData(const XPTCoordinate coordinate); static bool isTouched(); - static inline void DataTransferBegin() { if (SPIx.Instance) { HAL_SPI_Init(&SPIx); } WRITE(TOUCH_CS_PIN, LOW); }; - static inline void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); }; + static void DataTransferBegin() { if (SPIx.Instance) { HAL_SPI_Init(&SPIx); } WRITE(TOUCH_CS_PIN, LOW); }; + static void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); }; static uint16_t HardwareIO(uint16_t data); static uint16_t SoftwareIO(uint16_t data); static uint16_t IO(uint16_t data = 0) { return SPIx.Instance ? HardwareIO(data) : SoftwareIO(data); } diff --git a/Marlin/src/HAL/STM32/timers.cpp b/Marlin/src/HAL/STM32/timers.cpp index fe27ca101677..e68b59c46fee 100644 --- a/Marlin/src/HAL/STM32/timers.cpp +++ b/Marlin/src/HAL/STM32/timers.cpp @@ -74,10 +74,10 @@ #define MCU_STEP_TIMER 4 #define MCU_TEMP_TIMER 2 #elif defined(STM32F401xC) || defined(STM32F401xE) - #define MCU_STEP_TIMER 9 + #define MCU_STEP_TIMER 9 // STM32F401 has no TIM6, TIM7, or TIM8 #define MCU_TEMP_TIMER 10 #elif defined(STM32F4xx) || defined(STM32F7xx) || defined(STM32H7xx) - #define MCU_STEP_TIMER 6 // STM32F401 has no TIM6, TIM7, or TIM8 + #define MCU_STEP_TIMER 6 #define MCU_TEMP_TIMER 14 // TIM7 is consumed by Software Serial if used. #endif @@ -303,16 +303,16 @@ enum TimerPurpose { TP_SERIAL, TP_TONE, TP_SERVO, TP_STEP, TP_TEMP }; // This cannot yet account for timers used for PWM output, such as for fans. static constexpr struct { TimerPurpose p; int t; } timers_in_use[] = { #if HAS_TMC_SW_SERIAL - {TP_SERIAL, get_timer_num_from_base_address(timer_serial[0])}, // Set in variant.h, or as a define in platformio.h if not present in variant.h + { TP_SERIAL, get_timer_num_from_base_address(timer_serial[0]) }, // Set in variant.h, or as a define in platformio.h if not present in variant.h #endif #if ENABLED(SPEAKER) - {TP_TONE, get_timer_num_from_base_address(timer_tone[0])}, // Set in variant.h, or as a define in platformio.h if not present in variant.h + { TP_TONE, get_timer_num_from_base_address(timer_tone[0]) }, // Set in variant.h, or as a define in platformio.h if not present in variant.h #endif #if HAS_SERVOS - {TP_SERVO, get_timer_num_from_base_address(timer_servo[0])}, // Set in variant.h, or as a define in platformio.h if not present in variant.h + { TP_SERVO, get_timer_num_from_base_address(timer_servo[0]) }, // Set in variant.h, or as a define in platformio.h if not present in variant.h #endif - {TP_STEP, STEP_TIMER}, - {TP_TEMP, TEMP_TIMER}, + { TP_STEP, STEP_TIMER }, + { TP_TEMP, TEMP_TIMER }, }; static constexpr bool verify_no_timer_conflicts() { diff --git a/Marlin/src/HAL/STM32/timers.h b/Marlin/src/HAL/STM32/timers.h index aad543229e16..6828998198af 100644 --- a/Marlin/src/HAL/STM32/timers.h +++ b/Marlin/src/HAL/STM32/timers.h @@ -116,5 +116,5 @@ FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const ha } } -#define HAL_timer_isr_prologue(T) -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_prologue(T) NOOP +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/STM32/usb_serial.cpp b/Marlin/src/HAL/STM32/usb_serial.cpp index b607275db5bb..0b2372f3a79d 100644 --- a/Marlin/src/HAL/STM32/usb_serial.cpp +++ b/Marlin/src/HAL/STM32/usb_serial.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if ENABLED(EMERGENCY_PARSER) && USBD_USE_CDC +#if ENABLED(EMERGENCY_PARSER) && (USBD_USE_CDC || USBD_USE_CDC_MSC) #include "usb_serial.h" #include "../../feature/e_parser.h" diff --git a/Marlin/src/HAL/STM32/watchdog.cpp b/Marlin/src/HAL/STM32/watchdog.cpp deleted file mode 100644 index 1eccdec4985d..000000000000 --- a/Marlin/src/HAL/STM32/watchdog.cpp +++ /dev/null @@ -1,52 +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 "../platforms.h" - -#ifdef HAL_STM32 - -#include "../../inc/MarlinConfigPre.h" - -#if ENABLED(USE_WATCHDOG) - -#define WDT_TIMEOUT_US TERN(WATCHDOG_DURATION_8S, 8000000, 4000000) // 4 or 8 second timeout - -#include "../../inc/MarlinConfig.h" - -#include "watchdog.h" -#include - -void watchdog_init() { - #if DISABLED(DISABLE_WATCHDOG_INIT) - IWatchdog.begin(WDT_TIMEOUT_US); - #endif -} - -void HAL_watchdog_refresh() { - IWatchdog.reload(); - #if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED) - TOGGLE(LED_PIN); // heartbeat indicator - #endif -} - -#endif // USE_WATCHDOG -#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp index f29b30536146..4d3140001e82 100644 --- a/Marlin/src/HAL/STM32F1/HAL.cpp +++ b/Marlin/src/HAL/STM32F1/HAL.cpp @@ -79,10 +79,11 @@ #define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ // ------------------------ -// Public Variables +// Serial ports // ------------------------ #if defined(SERIAL_USB) && !HAS_SD_HOST_DRIVE + USBSerial SerialUSB; DefaultSerial1 MSerial0(true, SerialUSB); @@ -112,148 +113,78 @@ #endif #endif -uint16_t HAL_adc_result; +// ------------------------ +// Watchdog Timer +// ------------------------ + +#if ENABLED(USE_WATCHDOG) + + #include + + void watchdogSetup() { + // do whatever. don't remove this function. + } + + /** + * The watchdog clock is 40Khz. So for a 4s or 8s interval use a /256 preescaler and 625 or 1250 reload value (counts down to 0). + */ + #define STM32F1_WD_RELOAD TERN(WATCHDOG_DURATION_8S, 1250, 625) // 4 or 8 second timeout + + /** + * @brief Initialize the independent hardware watchdog. + * + * @return No return + * + * @details The watchdog clock is 40Khz. So for a 4s or 8s interval use a /256 preescaler and 625 or 1250 reload value (counts down to 0). + */ + void MarlinHAL::watchdog_init() { + #if DISABLED(DISABLE_WATCHDOG_INIT) + iwdg_init(IWDG_PRE_256, STM32F1_WD_RELOAD); + #endif + } + + // Reset watchdog. MUST be called every 4 or 8 seconds after the + // first watchdog_init or the STM32F1 will reset. + void MarlinHAL::watchdog_refresh() { + #if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED) + TOGGLE(LED_PIN); // heartbeat indicator + #endif + iwdg_feed(); + } + +#endif // USE_WATCHDOG // ------------------------ -// Private Variables +// ADC // ------------------------ -STM32ADC adc(ADC1); -const uint8_t adc_pins[] = { - #if HAS_TEMP_ADC_0 - TEMP_0_PIN, - #endif - #if HAS_TEMP_ADC_PROBE - TEMP_PROBE_PIN, - #endif - #if HAS_HEATED_BED - TEMP_BED_PIN, - #endif - #if HAS_TEMP_CHAMBER - TEMP_CHAMBER_PIN, - #endif - #if HAS_TEMP_COOLER - TEMP_COOLER_PIN, - #endif - #if HAS_TEMP_ADC_1 - TEMP_1_PIN, - #endif - #if HAS_TEMP_ADC_2 - TEMP_2_PIN, - #endif - #if HAS_TEMP_ADC_3 - TEMP_3_PIN, - #endif - #if HAS_TEMP_ADC_4 - TEMP_4_PIN, - #endif - #if HAS_TEMP_ADC_5 - TEMP_5_PIN, - #endif - #if HAS_TEMP_ADC_6 - TEMP_6_PIN, - #endif - #if HAS_TEMP_ADC_7 - TEMP_7_PIN, - #endif - #if ENABLED(FILAMENT_WIDTH_SENSOR) - FILWIDTH_PIN, - #endif - #if HAS_ADC_BUTTONS - ADC_KEYPAD_PIN, - #endif - #if HAS_JOY_ADC_X - JOY_X_PIN, - #endif - #if HAS_JOY_ADC_Y - JOY_Y_PIN, - #endif - #if HAS_JOY_ADC_Z - JOY_Z_PIN, - #endif - #if ENABLED(POWER_MONITOR_CURRENT) - POWER_MONITOR_CURRENT_PIN, - #endif - #if ENABLED(POWER_MONITOR_VOLTAGE) - POWER_MONITOR_VOLTAGE_PIN, - #endif -}; +// Watch out for recursion here! Our pin_t is signed, so pass through to Arduino -> analogRead(uint8_t) -enum TempPinIndex : char { - #if HAS_TEMP_ADC_0 - TEMP_0, - #endif - #if HAS_TEMP_ADC_PROBE - TEMP_PROBE, - #endif - #if HAS_HEATED_BED - TEMP_BED, - #endif - #if HAS_TEMP_CHAMBER - TEMP_CHAMBER, - #endif - #if HAS_TEMP_COOLER - TEMP_COOLER_PIN, - #endif - #if HAS_TEMP_ADC_1 - TEMP_1, - #endif - #if HAS_TEMP_ADC_2 - TEMP_2, - #endif - #if HAS_TEMP_ADC_3 - TEMP_3, - #endif - #if HAS_TEMP_ADC_4 - TEMP_4, - #endif - #if HAS_TEMP_ADC_5 - TEMP_5, - #endif - #if HAS_TEMP_ADC_6 - TEMP_6, - #endif - #if HAS_TEMP_ADC_7 - TEMP_7, - #endif - #if ENABLED(FILAMENT_WIDTH_SENSOR) - FILWIDTH, - #endif - #if HAS_ADC_BUTTONS - ADC_KEY, - #endif - #if HAS_JOY_ADC_X - JOY_X, - #endif - #if HAS_JOY_ADC_Y - JOY_Y, - #endif - #if HAS_JOY_ADC_Z - JOY_Z, - #endif - #if ENABLED(POWER_MONITOR_CURRENT) - POWERMON_CURRENT, - #endif - #if ENABLED(POWER_MONITOR_VOLTAGE) - POWERMON_VOLTS, - #endif - ADC_PIN_COUNT -}; +uint16_t analogRead(const pin_t pin) { + const bool is_analog = _GET_MODE(pin) == GPIO_INPUT_ANALOG; + return is_analog ? analogRead(uint8_t(pin)) : 0; +} + +// Wrapper to maple unprotected analogWrite +void analogWrite(const pin_t pin, int pwm_val8) { + if (PWM_PIN(pin)) analogWrite(uint8_t(pin), pwm_val8); +} -uint16_t HAL_adc_results[ADC_PIN_COUNT]; +uint16_t MarlinHAL::adc_result; // ------------------------ // Private functions // ------------------------ + static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) { uint32_t reg_value; - uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07); /* only values 0..7 are used */ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07); // only values 0..7 are used - reg_value = SCB->AIRCR; /* read old register configuration */ - reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk); /* clear bits to change */ + reg_value = SCB->AIRCR; // read old register configuration + reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk); // clear bits to change reg_value = (reg_value | ((uint32_t)0x5FA << SCB_AIRCR_VECTKEY_Pos) | - (PriorityGroupTmp << 8)); /* Insert write key & priority group */ + (PriorityGroupTmp << 8)); // Insert write key & priority group SCB->AIRCR = reg_value; } @@ -261,6 +192,8 @@ static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) { // Public functions // ------------------------ +void flashFirmware(const int16_t) { hal.reboot(); } + // // Leave PA11/PA12 intact if USBSerial is not used // @@ -280,7 +213,11 @@ static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) { TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial()); -void HAL_init() { +// ------------------------ +// MarlinHAL class +// ------------------------ + +void MarlinHAL::init() { NVIC_SetPriorityGrouping(0x3); #if PIN_EXISTS(LED) OUT_WRITE(LED_PIN, LOW); @@ -299,7 +236,7 @@ void HAL_init() { } // HAL idle task -void HAL_idletask() { +void MarlinHAL::idletask() { #if HAS_SHARED_MEDIA // If Marlin is using the SD card we need to lock it to prevent access from // a PC via USB. @@ -314,14 +251,11 @@ void HAL_idletask() { #endif } -void HAL_clear_reset_source() { } +void MarlinHAL::reboot() { nvic_sys_reset(); } -/** - * TODO: Check this and change or remove. - */ -uint8_t HAL_get_reset_source() { return RST_POWER_ON; } - -void _delay_ms(const int delay_ms) { delay(delay_ms); } +// ------------------------ +// Free Memory Accessor +// ------------------------ extern "C" { extern unsigned int _ebss; // end of bss section @@ -358,102 +292,96 @@ extern "C" { // ------------------------ // ADC // ------------------------ + +enum ADCIndex : uint8_t { + OPTITEM(HAS_TEMP_ADC_0, TEMP_0) + OPTITEM(HAS_TEMP_ADC_1, TEMP_1) + OPTITEM(HAS_TEMP_ADC_2, TEMP_2) + OPTITEM(HAS_TEMP_ADC_3, TEMP_3) + OPTITEM(HAS_TEMP_ADC_4, TEMP_4) + OPTITEM(HAS_TEMP_ADC_5, TEMP_5) + OPTITEM(HAS_TEMP_ADC_6, TEMP_6) + OPTITEM(HAS_TEMP_ADC_7, TEMP_7) + OPTITEM(HAS_HEATED_BED, TEMP_BED) + OPTITEM(HAS_TEMP_CHAMBER, TEMP_CHAMBER) + OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE) + OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER) + OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD) + OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH) + OPTITEM(HAS_ADC_BUTTONS, ADC_KEY) + OPTITEM(HAS_JOY_ADC_X, JOY_X) + OPTITEM(HAS_JOY_ADC_Y, JOY_Y) + OPTITEM(HAS_JOY_ADC_Z, JOY_Z) + OPTITEM(POWER_MONITOR_CURRENT, POWERMON_CURRENT) + OPTITEM(POWER_MONITOR_VOLTAGE, POWERMON_VOLTS) + ADC_COUNT +}; + +static uint16_t adc_results[ADC_COUNT]; + // Init the AD in continuous capture mode -void HAL_adc_init() { +void MarlinHAL::adc_init() { + static const uint8_t adc_pins[] = { + OPTITEM(HAS_TEMP_ADC_0, TEMP_0_PIN) + OPTITEM(HAS_TEMP_ADC_1, TEMP_1_PIN) + OPTITEM(HAS_TEMP_ADC_2, TEMP_2_PIN) + OPTITEM(HAS_TEMP_ADC_3, TEMP_3_PIN) + OPTITEM(HAS_TEMP_ADC_4, TEMP_4_PIN) + OPTITEM(HAS_TEMP_ADC_5, TEMP_5_PIN) + OPTITEM(HAS_TEMP_ADC_6, TEMP_6_PIN) + OPTITEM(HAS_TEMP_ADC_7, TEMP_7_PIN) + OPTITEM(HAS_HEATED_BED, TEMP_BED_PIN) + OPTITEM(HAS_TEMP_CHAMBER, TEMP_CHAMBER_PIN) + OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE_PIN) + OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER_PIN) + OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD_PIN) + OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH_PIN) + OPTITEM(HAS_ADC_BUTTONS, ADC_KEYPAD_PIN) + OPTITEM(HAS_JOY_ADC_X, JOY_X_PIN) + OPTITEM(HAS_JOY_ADC_Y, JOY_Y_PIN) + OPTITEM(HAS_JOY_ADC_Z, JOY_Z_PIN) + OPTITEM(POWER_MONITOR_CURRENT, POWER_MONITOR_CURRENT_PIN) + OPTITEM(POWER_MONITOR_VOLTAGE, POWER_MONITOR_VOLTAGE_PIN) + }; + static STM32ADC adc(ADC1); // configure the ADC adc.calibrate(); - #if F_CPU > 72000000 - adc.setSampleRate(ADC_SMPR_71_5); // 71.5 ADC cycles - #else - adc.setSampleRate(ADC_SMPR_41_5); // 41.5 ADC cycles - #endif - adc.setPins((uint8_t *)adc_pins, ADC_PIN_COUNT); - adc.setDMA(HAL_adc_results, (uint16_t)ADC_PIN_COUNT, (uint32_t)(DMA_MINC_MODE | DMA_CIRC_MODE), nullptr); + adc.setSampleRate((F_CPU > 72000000) ? ADC_SMPR_71_5 : ADC_SMPR_41_5); // 71.5 or 41.5 ADC cycles + adc.setPins((uint8_t *)adc_pins, ADC_COUNT); + adc.setDMA(adc_results, uint16_t(ADC_COUNT), uint32_t(DMA_MINC_MODE | DMA_CIRC_MODE), nullptr); adc.setScanMode(); adc.setContinuous(); adc.startConversion(); } -void HAL_adc_start_conversion(const uint8_t adc_pin) { - //TEMP_PINS pin_index; - TempPinIndex pin_index; - switch (adc_pin) { +void MarlinHAL::adc_start(const pin_t pin) { + #define __TCASE(N,I) case N: pin_index = I; break; + #define _TCASE(C,N,I) TERN_(C, __TCASE(N, I)) + ADCIndex pin_index; + switch (pin) { default: return; - #if HAS_TEMP_ADC_0 - case TEMP_0_PIN: pin_index = TEMP_0; break; - #endif - #if HAS_TEMP_ADC_PROBE - case TEMP_PROBE_PIN: pin_index = TEMP_PROBE; break; - #endif - #if HAS_HEATED_BED - case TEMP_BED_PIN: pin_index = TEMP_BED; break; - #endif - #if HAS_TEMP_CHAMBER - case TEMP_CHAMBER_PIN: pin_index = TEMP_CHAMBER; break; - #endif - #if HAS_TEMP_COOLER - case TEMP_COOLER_PIN: pin_index = TEMP_COOLER; break; - #endif - #if HAS_TEMP_ADC_1 - case TEMP_1_PIN: pin_index = TEMP_1; break; - #endif - #if HAS_TEMP_ADC_2 - case TEMP_2_PIN: pin_index = TEMP_2; break; - #endif - #if HAS_TEMP_ADC_3 - case TEMP_3_PIN: pin_index = TEMP_3; break; - #endif - #if HAS_TEMP_ADC_4 - case TEMP_4_PIN: pin_index = TEMP_4; break; - #endif - #if HAS_TEMP_ADC_5 - case TEMP_5_PIN: pin_index = TEMP_5; break; - #endif - #if HAS_TEMP_ADC_6 - case TEMP_6_PIN: pin_index = TEMP_6; break; - #endif - #if HAS_TEMP_ADC_7 - case TEMP_7_PIN: pin_index = TEMP_7; break; - #endif - #if HAS_JOY_ADC_X - case JOY_X_PIN: pin_index = JOY_X; break; - #endif - #if HAS_JOY_ADC_Y - case JOY_Y_PIN: pin_index = JOY_Y; break; - #endif - #if HAS_JOY_ADC_Z - case JOY_Z_PIN: pin_index = JOY_Z; break; - #endif - #if ENABLED(FILAMENT_WIDTH_SENSOR) - case FILWIDTH_PIN: pin_index = FILWIDTH; break; - #endif - #if HAS_ADC_BUTTONS - case ADC_KEYPAD_PIN: pin_index = ADC_KEY; break; - #endif - #if ENABLED(POWER_MONITOR_CURRENT) - case POWER_MONITOR_CURRENT_PIN: pin_index = POWERMON_CURRENT; break; - #endif - #if ENABLED(POWER_MONITOR_VOLTAGE) - case POWER_MONITOR_VOLTAGE_PIN: pin_index = POWERMON_VOLTS; break; - #endif + _TCASE(HAS_TEMP_ADC_0, TEMP_0_PIN, TEMP_0) + _TCASE(HAS_TEMP_ADC_1, TEMP_1_PIN, TEMP_1) + _TCASE(HAS_TEMP_ADC_2, TEMP_2_PIN, TEMP_2) + _TCASE(HAS_TEMP_ADC_3, TEMP_3_PIN, TEMP_3) + _TCASE(HAS_TEMP_ADC_4, TEMP_4_PIN, TEMP_4) + _TCASE(HAS_TEMP_ADC_5, TEMP_5_PIN, TEMP_5) + _TCASE(HAS_TEMP_ADC_6, TEMP_6_PIN, TEMP_6) + _TCASE(HAS_TEMP_ADC_7, TEMP_7_PIN, TEMP_7) + _TCASE(HAS_HEATED_BED, TEMP_BED_PIN, TEMP_BED) + _TCASE(HAS_TEMP_CHAMBER, TEMP_CHAMBER_PIN, TEMP_CHAMBER) + _TCASE(HAS_TEMP_ADC_PROBE, TEMP_PROBE_PIN, TEMP_PROBE) + _TCASE(HAS_TEMP_COOLER, TEMP_COOLER_PIN, TEMP_COOLER) + _TCASE(HAS_TEMP_BOARD, TEMP_BOARD_PIN, TEMP_BOARD) + _TCASE(HAS_JOY_ADC_X, JOY_X_PIN, JOY_X) + _TCASE(HAS_JOY_ADC_Y, JOY_Y_PIN, JOY_Y) + _TCASE(HAS_JOY_ADC_Z, JOY_Z_PIN, JOY_Z) + _TCASE(FILAMENT_WIDTH_SENSOR, FILWIDTH_PIN, FILWIDTH) + _TCASE(HAS_ADC_BUTTONS, ADC_KEYPAD_PIN, ADC_KEY) + _TCASE(POWER_MONITOR_CURRENT, POWER_MONITOR_CURRENT_PIN, POWERMON_CURRENT) + _TCASE(POWER_MONITOR_VOLTAGE, POWER_MONITOR_VOLTAGE_PIN, POWERMON_VOLTS) } - HAL_adc_result = HAL_adc_results[(int)pin_index] >> (12 - HAL_ADC_RESOLUTION); // shift out unused bits -} - -uint16_t HAL_adc_get_result() { return HAL_adc_result; } - -uint16_t analogRead(pin_t pin) { - const bool is_analog = _GET_MODE(pin) == GPIO_INPUT_ANALOG; - return is_analog ? analogRead(uint8_t(pin)) : 0; + adc_result = (adc_results[(int)pin_index] & 0xFFF) >> (12 - HAL_ADC_RESOLUTION); // shift out unused bits } -// Wrapper to maple unprotected analogWrite -void analogWrite(pin_t pin, int pwm_val8) { - if (PWM_PIN(pin)) analogWrite(uint8_t(pin), pwm_val8); -} - -void HAL_reboot() { nvic_sys_reset(); } - -void flashFirmware(const int16_t) { HAL_reboot(); } - #endif // __STM32F1__ diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index 153cfe8ac89e..b14b5f7e7926 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -34,7 +34,6 @@ #include "../shared/HAL_SPI.h" #include "fastio.h" -#include "watchdog.h" #include #include @@ -66,6 +65,10 @@ #endif #endif +// ------------------------ +// Serial ports +// ------------------------ + #ifdef SERIAL_USB typedef ForwardSerial1Class< USBSerial > DefaultSerial1; extern DefaultSerial1 MSerial0; @@ -141,11 +144,6 @@ #endif #endif -// Set interrupt grouping for this MCU -void HAL_init(); -#define HAL_IDLETASK 1 -void HAL_idletask(); - /** * TODO: review this to return 1 for pins that are not analog input */ @@ -158,15 +156,7 @@ void HAL_idletask(); #define NO_COMPILE_TIME_PWM #endif -#define CRITICAL_SECTION_START() uint32_t primask = __get_primask(); (void)__iCliRetVal() -#define CRITICAL_SECTION_END() if (!primask) (void)__iSeiRetVal() -#define ISRS_ENABLED() (!__get_primask()) -#define ENABLE_ISRS() ((void)__iSeiRetVal()) -#define DISABLE_ISRS() ((void)__iCliRetVal()) - -// On AVR this is in math.h? -#define square(x) ((x)*(x)) - +// Reset Reason #define RST_POWER_ON 1 #define RST_EXTERNAL 2 #define RST_BROWN_OUT 4 @@ -182,46 +172,63 @@ void HAL_idletask(); typedef int8_t pin_t; // ------------------------ -// Public Variables +// Interrupts // ------------------------ -// Result of last ADC conversion -extern uint16_t HAL_adc_result; +#define CRITICAL_SECTION_START() const bool irqon = !__get_primask(); (void)__iCliRetVal() +#define CRITICAL_SECTION_END() if (!irqon) (void)__iSeiRetVal() +#define cli() noInterrupts() +#define sei() interrupts() // ------------------------ -// Public functions +// ADC // ------------------------ -// Disable interrupts -#define cli() noInterrupts() +#ifdef ADC_RESOLUTION + #define HAL_ADC_RESOLUTION ADC_RESOLUTION +#else + #define HAL_ADC_RESOLUTION 12 +#endif -// Enable interrupts -#define sei() interrupts() +#define HAL_ADC_VREF 3.3 -// Memory related -#define __bss_end __bss_end__ +uint16_t analogRead(const pin_t pin); // need hal.adc_enable() first +void analogWrite(const pin_t pin, int pwm_val8); // PWM only! mul by 257 in maple!? -// Clear reset reason -void HAL_clear_reset_source(); +// +// 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) -// Reset reason -uint8_t HAL_get_reset_source(); +#define JTAG_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY) +#define JTAGSWD_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_NONE) -void HAL_reboot(); +#define PLATFORM_M997_SUPPORT +void flashFirmware(const int16_t); -void _delay_ms(const int delay); +#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment +#ifndef PWM_FREQUENCY + #define PWM_FREQUENCY 1000 // Default PWM Frequency +#endif -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-function" +// ------------------------ +// Class Utilities +// ------------------------ -/* -extern "C" { - int freeMemory(); -} -*/ +// Memory related +#define __bss_end __bss_end__ + +void _delay_ms(const int ms); extern "C" char* _sbrk(int incr); +#pragma GCC diagnostic push +#if GCC_VERSION <= 50000 + #pragma GCC diagnostic ignored "-Wunused-function" +#endif + static inline int freeMemory() { volatile char top; return &top - _sbrk(0); @@ -229,58 +236,74 @@ static inline int freeMemory() { #pragma GCC diagnostic pop -// -// ADC -// +// ------------------------ +// MarlinHAL Class +// ------------------------ -#define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT_ANALOG); +class MarlinHAL { +public: -void HAL_adc_init(); + // Earliest possible init, before setup() + MarlinHAL() {} -#ifdef ADC_RESOLUTION - #define HAL_ADC_RESOLUTION ADC_RESOLUTION -#else - #define HAL_ADC_RESOLUTION 12 -#endif + // Watchdog + static void watchdog_init() IF_DISABLED(USE_WATCHDOG, {}); + static void watchdog_refresh() IF_DISABLED(USE_WATCHDOG, {}); -#define HAL_ADC_VREF 3.3 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_result -#define HAL_ADC_READY() true + static void init(); // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 -void HAL_adc_start_conversion(const uint8_t adc_pin); -uint16_t HAL_adc_get_result(); + // Interrupts + static bool isr_state() { return !__get_primask(); } + static void isr_on() { ((void)__iSeiRetVal()); } + static void isr_off() { ((void)__iCliRetVal()); } -uint16_t analogRead(pin_t pin); // need HAL_ANALOG_SELECT() first -void analogWrite(pin_t pin, int pwm_val8); // PWM only! mul by 257 in maple!? + static void delay_ms(const int ms) { delay(ms); } -#define GET_PIN_MAP_PIN(index) index -#define GET_PIN_MAP_INDEX(pin) pin -#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + // Tasks, called from idle() + static void idletask(); -#define JTAG_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY) -#define JTAGSWD_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_NONE) + // Reset + static uint8_t get_reset_source() { return RST_POWER_ON; } + static void clear_reset_source() {} -#define PLATFORM_M997_SUPPORT -void flashFirmware(const int16_t); + // Free SRAM + static int freeMemory() { return ::freeMemory(); } -#ifndef PWM_FREQUENCY - #define PWM_FREQUENCY 1000 // Default PWM Frequency -#endif -#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment + // + // ADC Methods + // -/** - * set_pwm_frequency - * Set the frequency of the timer corresponding to the provided pin - * All Timer PWM pins run at the same frequency - */ -void set_pwm_frequency(const pin_t pin, int f_desired); + static uint16_t adc_result; -/** - * set_pwm_duty - * Set the PWM duty cycle of the provided pin to the provided value - * Optionally allows inverting the duty cycle [default = false] - * Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255] - * The timer must be pre-configured with set_pwm_frequency() if the default frequency is not desired. - */ -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false); + // 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 pin_t pin) { pinMode(pin, INPUT_ANALOG); } + + // 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. + * Optionally invert the duty cycle [default = false] + * Optionally change the maximum size of the provided value to enable finer PWM duty control [default = 255] + * The timer must be pre-configured with set_pwm_frequency() if the default frequency is not desired. + */ + static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false); + + /** + * Set the frequency of the timer for the given pin. + * All Timer PWM pins run at the same frequency. + */ + static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired); + +}; diff --git a/Marlin/src/HAL/STM32F1/HAL_MinSerial.cpp b/Marlin/src/HAL/STM32F1/MinSerial.cpp similarity index 97% rename from Marlin/src/HAL/STM32F1/HAL_MinSerial.cpp rename to Marlin/src/HAL/STM32F1/MinSerial.cpp index 0fc3d014d484..6cf68d8d8f45 100644 --- a/Marlin/src/HAL/STM32F1/HAL_MinSerial.cpp +++ b/Marlin/src/HAL/STM32F1/MinSerial.cpp @@ -26,8 +26,7 @@ #if ENABLED(POSTMORTEM_DEBUGGING) -#include "../shared/HAL_MinSerial.h" -#include "watchdog.h" +#include "../shared/MinSerial.h" #include #include @@ -82,7 +81,7 @@ static void TX(char c) { #if WITHIN(SERIAL_PORT, 1, 6) struct usart_dev* dev = MYSERIAL1.c_dev(); while (!(dev->regs->SR & USART_SR_TXE)) { - TERN_(USE_WATCHDOG, HAL_watchdog_refresh()); + hal.watchdog_refresh(); sw_barrier(); } dev->regs->DR = c; diff --git a/Marlin/src/HAL/STM32F1/SPI.cpp b/Marlin/src/HAL/STM32F1/SPI.cpp index 8bfa3d236a7c..1ce2c7d3fd5d 100644 --- a/Marlin/src/HAL/STM32F1/SPI.cpp +++ b/Marlin/src/HAL/STM32F1/SPI.cpp @@ -91,6 +91,14 @@ static const spi_pins board_spi_pins[] __FLASH__ = { static void *_spi3_this; #endif +/** + * @brief Wait until TXE (tx empty) flag is set and BSY (busy) flag unset. + */ +static inline void waitSpiTxEnd(spi_dev *spi_d) { + while (spi_is_tx_empty(spi_d) == 0) { /* nada */ } // wait until TXE=1 + while (spi_is_busy(spi_d) != 0) { /* nada */ } // wait until BSY=0 +} + /** * Constructor */ diff --git a/Marlin/src/HAL/STM32F1/SPI.h b/Marlin/src/HAL/STM32F1/SPI.h index 2467432e0718..13f4d5ed6cfe 100644 --- a/Marlin/src/HAL/STM32F1/SPI.h +++ b/Marlin/src/HAL/STM32F1/SPI.h @@ -414,12 +414,4 @@ class SPIClass { */ }; -/** - * @brief Wait until TXE (tx empty) flag is set and BSY (busy) flag unset. - */ -static inline void waitSpiTxEnd(spi_dev *spi_d) { - while (spi_is_tx_empty(spi_d) == 0) { /* nada */ } // wait until TXE=1 - while (spi_is_busy(spi_d) != 0) { /* nada */ } // wait until BSY=0 -} - extern SPIClass SPI; diff --git a/Marlin/src/HAL/STM32F1/Servo.cpp b/Marlin/src/HAL/STM32F1/Servo.cpp index 8dc1ef7b6a5b..47ffb631cf8f 100644 --- a/Marlin/src/HAL/STM32F1/Servo.cpp +++ b/Marlin/src/HAL/STM32F1/Servo.cpp @@ -147,17 +147,17 @@ void libServo::move(const int32_t value) { uint16_t SR = timer_get_status(tdev); if (SR & TIMER_SR_CC1IF) { // channel 1 off #ifdef SERVO0_PWM_OD - OUT_WRITE_OD(SERVO0_PIN, 1); // off + OUT_WRITE_OD(SERVO0_PIN, HIGH); // off #else - OUT_WRITE(SERVO0_PIN, 0); + OUT_WRITE(SERVO0_PIN, LOW); #endif timer_reset_status_bit(tdev, TIMER_SR_CC1IF_BIT); } if (SR & TIMER_SR_CC2IF) { // channel 2 resume #ifdef SERVO0_PWM_OD - OUT_WRITE_OD(SERVO0_PIN, 0); // on + OUT_WRITE_OD(SERVO0_PIN, LOW); // on #else - OUT_WRITE(SERVO0_PIN, 1); + OUT_WRITE(SERVO0_PIN, HIGH); #endif timer_reset_status_bit(tdev, TIMER_SR_CC2IF_BIT); } @@ -167,9 +167,9 @@ void libServo::move(const int32_t value) { timer_dev *tdev = HAL_get_timer_dev(MF_TIMER_SERVO0); if (!tdev) return false; #ifdef SERVO0_PWM_OD - OUT_WRITE_OD(inPin, 1); + OUT_WRITE_OD(inPin, HIGH); #else - OUT_WRITE(inPin, 0); + OUT_WRITE(inPin, LOW); #endif timer_pause(tdev); @@ -200,9 +200,9 @@ void libServo::move(const int32_t value) { timer_disable_irq(tdev, 1); timer_disable_irq(tdev, 2); #ifdef SERVO0_PWM_OD - OUT_WRITE_OD(pin, 1); // off + OUT_WRITE_OD(pin, HIGH); // off #else - OUT_WRITE(pin, 0); + OUT_WRITE(pin, LOW); #endif } } diff --git a/Marlin/src/HAL/STM32F1/Servo.h b/Marlin/src/HAL/STM32F1/Servo.h index b6143de81d62..745a1c93f07d 100644 --- a/Marlin/src/HAL/STM32F1/Servo.h +++ b/Marlin/src/HAL/STM32F1/Servo.h @@ -35,7 +35,8 @@ #define SERVO_DEFAULT_MIN_ANGLE 0 #define SERVO_DEFAULT_MAX_ANGLE 180 -#define HAL_SERVO_LIB libServo +class libServo; +typedef libServo hal_servo_t; class libServo { public: diff --git a/Marlin/src/HAL/STM32F1/fast_pwm.cpp b/Marlin/src/HAL/STM32F1/fast_pwm.cpp index 98d56bc5e931..297804a3ac42 100644 --- a/Marlin/src/HAL/STM32F1/fast_pwm.cpp +++ b/Marlin/src/HAL/STM32F1/fast_pwm.cpp @@ -21,11 +21,9 @@ */ #ifdef __STM32F1__ -#include "../../inc/MarlinConfigPre.h" +#include "../../inc/MarlinConfig.h" #include -#include "HAL.h" -#include "timers.h" #define NR_TIMERS TERN(STM32_XL_DENSITY, 14, 8) // Maple timers, 14 for STM32_XL_DENSITY (F/G chips), 8 for HIGH density (C D E) @@ -38,20 +36,23 @@ inline uint8_t timer_and_index_for_pin(const pin_t pin, timer_dev **timer_ptr) { return 0; } -void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) { - if (!PWM_PIN(pin)) return; - - timer_dev *timer; UNUSED(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; +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; - timer_set_compare(timer, channel, duty); - timer_set_mode(timer, channel, TIMER_PWM); // PWM Output Mode + if (PWM_PIN(pin)) { + timer_dev *timer; UNUSED(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; + timer_set_compare(timer, channel, duty); + timer_set_mode(timer, channel, TIMER_PWM); // PWM Output Mode + } + else { + pinMode(pin, OUTPUT); + digitalWrite(pin, duty < v_size / 2 ? LOW : HIGH); + } } -void set_pwm_frequency(const pin_t pin, int f_desired) { +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); diff --git a/Marlin/src/HAL/STM32F1/onboard_sd.cpp b/Marlin/src/HAL/STM32F1/onboard_sd.cpp index 582ee3853d00..a3d8dcb2d57e 100644 --- a/Marlin/src/HAL/STM32F1/onboard_sd.cpp +++ b/Marlin/src/HAL/STM32F1/onboard_sd.cpp @@ -38,8 +38,13 @@ #define SPI_CLOCK_MAX SPI_BAUD_PCLK_DIV_2 #endif -#define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) // Set OnboardSPI cs low -#define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) // Set OnboardSPI cs high +#if PIN_EXISTS(ONBOARD_SD_CS) && ONBOARD_SD_CS_PIN != SD_SS_PIN + #define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) // Set OnboardSPI cs low + #define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) // Set OnboardSPI cs high +#else + #define CS_LOW() + #define CS_HIGH() +#endif #define FCLK_FAST() ONBOARD_SD_SPI.setClockDivider(SPI_CLOCK_MAX) #define FCLK_SLOW() ONBOARD_SD_SPI.setClockDivider(SPI_BAUD_PCLK_DIV_256) diff --git a/Marlin/src/HAL/STM32F1/pinsDebug.h b/Marlin/src/HAL/STM32F1/pinsDebug.h index 27f4b6732bfb..7828479658a9 100644 --- a/Marlin/src/HAL/STM32F1/pinsDebug.h +++ b/Marlin/src/HAL/STM32F1/pinsDebug.h @@ -54,11 +54,11 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS]; #define M43_NEVER_TOUCH(Q) (Q >= 9 && Q <= 12) // SERIAL/USB pins PA9(TX) PA10(RX) #endif -static inline int8_t get_pin_mode(pin_t pin) { +static int8_t get_pin_mode(pin_t pin) { return VALID_PIN(pin) ? _GET_MODE(pin) : -1; } -static inline pin_t DIGITAL_PIN_TO_ANALOG_PIN(pin_t pin) { +static pin_t DIGITAL_PIN_TO_ANALOG_PIN(pin_t pin) { if (!VALID_PIN(pin)) return -1; int8_t adc_channel = int8_t(PIN_MAP[pin].adc_channel); #ifdef NUM_ANALOG_INPUTS @@ -67,7 +67,7 @@ static inline pin_t DIGITAL_PIN_TO_ANALOG_PIN(pin_t pin) { return pin_t(adc_channel); } -static inline bool IS_ANALOG(pin_t pin) { +static bool IS_ANALOG(pin_t pin) { if (!VALID_PIN(pin)) return false; if (PIN_MAP[pin].adc_channel != ADCx) { #ifdef NUM_ANALOG_INPUTS @@ -78,11 +78,11 @@ static inline bool IS_ANALOG(pin_t pin) { return false; } -static inline bool GET_PINMODE(const pin_t pin) { +static bool GET_PINMODE(const pin_t pin) { return VALID_PIN(pin) && !IS_INPUT(pin); } -static inline bool GET_ARRAY_IS_DIGITAL(const int16_t array_pin) { +static bool GET_ARRAY_IS_DIGITAL(const int16_t array_pin) { const pin_t pin = GET_ARRAY_PIN(array_pin); return (!IS_ANALOG(pin) #ifdef NUM_ANALOG_INPUTS @@ -93,7 +93,7 @@ static inline bool GET_ARRAY_IS_DIGITAL(const int16_t array_pin) { #include "../../inc/MarlinConfig.h" // Allow pins/pins.h to set density -static inline void pwm_details(const pin_t pin) { +static void pwm_details(const pin_t pin) { if (PWM_PIN(pin)) { timer_dev * const tdev = PIN_MAP[pin].timer_device; const uint8_t channel = PIN_MAP[pin].timer_channel; @@ -113,7 +113,7 @@ static inline void pwm_details(const pin_t pin) { } } -static inline void print_port(pin_t pin) { +static void print_port(pin_t pin) { const char port = 'A' + char(pin >> 4); // pin div 16 const int16_t gbit = PIN_MAP[pin].gpio_bit; char buffer[8]; diff --git a/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp b/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp index 9bf6bbb32bc7..f447cec81107 100644 --- a/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp +++ b/Marlin/src/HAL/STM32F1/tft/tft_spi.cpp @@ -30,7 +30,7 @@ SPIClass TFT_SPI::SPIx(1); void TFT_SPI::Init() { #if PIN_EXISTS(TFT_RESET) - OUT_WRITE(TFT_RST_PIN, HIGH); + OUT_WRITE(TFT_RESET_PIN, HIGH); delay(100); #endif diff --git a/Marlin/src/HAL/STM32F1/tft/xpt2046.h b/Marlin/src/HAL/STM32F1/tft/xpt2046.h index aba0799e445f..7c456cf00e1b 100644 --- a/Marlin/src/HAL/STM32F1/tft/xpt2046.h +++ b/Marlin/src/HAL/STM32F1/tft/xpt2046.h @@ -65,8 +65,8 @@ class XPT2046 { static uint16_t getRawData(const XPTCoordinate coordinate); static bool isTouched(); - static inline void DataTransferBegin() { WRITE(TOUCH_CS_PIN, LOW); }; - static inline void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); }; + static void DataTransferBegin() { WRITE(TOUCH_CS_PIN, LOW); }; + static void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); }; #if ENABLED(TOUCH_BUTTONS_HW_SPI) static uint16_t HardwareIO(uint16_t data); #endif diff --git a/Marlin/src/HAL/STM32F1/timers.h b/Marlin/src/HAL/STM32F1/timers.h index f9ab6d13d374..0cd807fc8479 100644 --- a/Marlin/src/HAL/STM32F1/timers.h +++ b/Marlin/src/HAL/STM32F1/timers.h @@ -188,7 +188,7 @@ FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) { } } -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_epilogue(T) NOOP // No command is available in framework to turn off ARPE bit, which is turned on by default in libmaple. // Needed here to reset ARPE=0 for stepper timer diff --git a/Marlin/src/HAL/STM32F1/watchdog.cpp b/Marlin/src/HAL/STM32F1/watchdog.cpp deleted file mode 100644 index b812a4fa6403..000000000000 --- a/Marlin/src/HAL/STM32F1/watchdog.cpp +++ /dev/null @@ -1,66 +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 . - * - */ - -/** - * HAL for stm32duino.com based on Libmaple and compatible (STM32F1) - */ - -#ifdef __STM32F1__ - -#include "../../inc/MarlinConfig.h" - -#if ENABLED(USE_WATCHDOG) - -#include -#include "watchdog.h" - -/** - * The watchdog clock is 40Khz. So for a 4s or 8s interval use a /256 preescaler and 625 or 1250 reload value (counts down to 0). - */ -#define STM32F1_WD_RELOAD TERN(WATCHDOG_DURATION_8S, 1250, 625) // 4 or 8 second timeout - -void HAL_watchdog_refresh() { - #if DISABLED(PINS_DEBUGGING) && PIN_EXISTS(LED) - TOGGLE(LED_PIN); // heartbeat indicator - #endif - iwdg_feed(); -} - -void watchdogSetup() { - // do whatever. don't remove this function. -} - -/** - * @brief Initialized the independent hardware watchdog. - * - * @return No return - * - * @details The watchdog clock is 40Khz. So for a 4s or 8s interval use a /256 preescaler and 625 or 1250 reload value (counts down to 0). - */ -void watchdog_init() { - #if DISABLED(DISABLE_WATCHDOG_INIT) - iwdg_init(IWDG_PRE_256, STM32F1_WD_RELOAD); - #endif -} - -#endif // USE_WATCHDOG -#endif // __STM32F1__ diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.cpp b/Marlin/src/HAL/TEENSY31_32/HAL.cpp index f08cf799e9e8..2892368967e4 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.cpp +++ b/Marlin/src/HAL/TEENSY31_32/HAL.cpp @@ -31,6 +31,10 @@ #include +// ------------------------ +// Serial ports +// ------------------------ + #define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X) #define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X) #if WITHIN(SERIAL_PORT, 0, 3) @@ -40,33 +44,13 @@ #endif USBSerialType USBSerial(false, SerialUSB); -uint16_t HAL_adc_result; - -static const uint8_t pin2sc1a[] = { - 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 0, 19, 3, 31, // 0-13, we treat them as A0-A13 - 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 (A0-A9) - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, // 24-33 - 0+64, 19+64, 3+64, 31+64, // 34-37 (A10-A13) - 26, 22, 23, 27, 29, 30 // 38-43: temp. sensor, VREF_OUT, A14, bandgap, VREFH, VREFL. A14 isn't connected to anything in Teensy 3.0. -}; - -/* - // disable interrupts - void cli() { noInterrupts(); } - - // enable interrupts - void sei() { interrupts(); } -*/ +// ------------------------ +// MarlinHAL Class +// ------------------------ -void HAL_adc_init() { - analog_init(); - while (ADC0_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish - NVIC_ENABLE_IRQ(IRQ_FTM1); -} +void MarlinHAL::reboot() { _reboot_Teensyduino_(); } -void HAL_clear_reset_source() { } - -uint8_t HAL_get_reset_source() { +uint8_t MarlinHAL::get_reset_source() { switch (RCM_SRS0) { case 128: return RST_POWER_ON; break; case 64: return RST_EXTERNAL; break; @@ -78,7 +62,54 @@ uint8_t HAL_get_reset_source() { return 0; } -void HAL_reboot() { _reboot_Teensyduino_(); } +// ------------------------ +// Watchdog Timer +// ------------------------ + +#if ENABLED(USE_WATCHDOG) + + #define WDT_TIMEOUT_MS TERN(WATCHDOG_DURATION_8S, 8000, 4000) // 4 or 8 second timeout + + void MarlinHAL::watchdog_init() { + WDOG_TOVALH = 0; + WDOG_TOVALL = WDT_TIMEOUT_MS; + WDOG_STCTRLH = WDOG_STCTRLH_WDOGEN; + } + + void MarlinHAL::watchdog_refresh() { + // Watchdog refresh sequence + WDOG_REFRESH = 0xA602; + WDOG_REFRESH = 0xB480; + } + +#endif + +// ------------------------ +// ADC +// ------------------------ + +void MarlinHAL::adc_init() { + analog_init(); + while (ADC0_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish + NVIC_ENABLE_IRQ(IRQ_FTM1); +} + +void MarlinHAL::adc_start(const pin_t pin) { + static const uint8_t pin2sc1a[] = { + 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 0, 19, 3, 31, // 0-13, we treat them as A0-A13 + 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 (A0-A9) + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, // 24-33 + 0+64, 19+64, 3+64, 31+64, // 34-37 (A10-A13) + 26, 22, 23, 27, 29, 30 // 38-43: temp. sensor, VREF_OUT, A14, bandgap, VREFH, VREFL. A14 isn't connected to anything in Teensy 3.0. + }; + ADC0_SC1A = pin2sc1a[pin]; +} + +uint16_t MarlinHAL::adc_value() { return ADC0_RA; } + +// ------------------------ +// Free Memory Accessor +// ------------------------ extern "C" { extern char __bss_end; @@ -95,8 +126,4 @@ extern "C" { } } -void HAL_adc_start_conversion(const uint8_t adc_pin) { ADC0_SC1A = pin2sc1a[adc_pin]; } - -uint16_t HAL_adc_get_result() { return ADC0_RA; } - #endif // __MK20DX256__ diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.h b/Marlin/src/HAL/TEENSY31_32/HAL.h index 61d8b34604c5..a7aa9f0da211 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/TEENSY31_32/HAL.h @@ -32,16 +32,12 @@ #include "../shared/HAL_SPI.h" #include "fastio.h" -#include "watchdog.h" #include -#define CPU_ST7920_DELAY_1 600 -#define CPU_ST7920_DELAY_2 750 -#define CPU_ST7920_DELAY_3 750 - -//#undef MOTHERBOARD -//#define MOTHERBOARD BOARD_TEENSY31_32 +// ------------------------ +// Defines +// ------------------------ #define IS_32BIT_TEENSY 1 #define IS_TEENSY_31_32 1 @@ -49,6 +45,14 @@ #define IS_TEENSY32 1 #endif +#define CPU_ST7920_DELAY_1 600 +#define CPU_ST7920_DELAY_2 750 +#define CPU_ST7920_DELAY_3 750 + +// ------------------------ +// Serial ports +// ------------------------ + #include "../../core/serial_hook.h" #define Serial0 Serial @@ -72,31 +76,44 @@ extern USBSerialType USBSerial; #error "The required SERIAL_PORT must be from 0 to 3, or -1 for Native USB." #endif -#define HAL_SERVO_LIB libServo +// ------------------------ +// Types +// ------------------------ + +class libServo; +typedef libServo hal_servo_t; typedef int8_t pin_t; -#ifndef analogInputToDigitalPin - #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) -#endif +// ------------------------ +// Interrupts +// ------------------------ -#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_PRIMASK()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() +uint32_t __get_PRIMASK(void); // CMSIS +#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() -inline void HAL_init() {} +// ------------------------ +// ADC +// ------------------------ -// Clear the reset reason -void HAL_clear_reset_source(); +#ifndef analogInputToDigitalPin + #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) +#endif -// Get the reason for the reset -uint8_t HAL_get_reset_source(); +#define HAL_ADC_VREF 3.3 +#define HAL_ADC_RESOLUTION 10 -void HAL_reboot(); +// +// 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) -FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } +// ------------------------ +// Class Utilities +// ------------------------ #pragma GCC diagnostic push #if GCC_VERSION <= 50000 @@ -107,27 +124,67 @@ extern "C" int freeMemory(); #pragma GCC diagnostic pop -// ADC +// ------------------------ +// MarlinHAL Class +// ------------------------ -void HAL_adc_init(); +class MarlinHAL { +public: -#define HAL_ADC_VREF 3.3 -#define HAL_ADC_RESOLUTION 10 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() true + // Earliest possible init, before setup() + MarlinHAL() {} -#define HAL_ANALOG_SELECT(pin) + // Watchdog + static void watchdog_init() IF_DISABLED(USE_WATCHDOG, {}); + static void watchdog_refresh() IF_DISABLED(USE_WATCHDOG, {}); -void HAL_adc_start_conversion(const uint8_t adc_pin); -uint16_t HAL_adc_get_result(); + static void init() {} // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 -// PWM + // Interrupts + static bool isr_state() { return !__get_PRIMASK(); } + static void isr_on() { __enable_irq(); } + static void isr_off() { __disable_irq(); } -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + static void delay_ms(const int ms) { delay(ms); } -// Pin Map + // Tasks, called from idle() + static void idletask() {} -#define GET_PIN_MAP_PIN(index) index -#define GET_PIN_MAP_INDEX(pin) pin -#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source() {} + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + // 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 pin_t ch) {} + + // Begin ADC sampling on the given channel. Called from Temperature::isr! + static void adc_start(const pin_t ch); + + // Is the ADC ready for reading? + static bool adc_ready() { return true; } + + // The current value of the ADC register + static uint16_t adc_value(); + + /** + * 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); + } + +}; diff --git a/Marlin/src/HAL/TEENSY31_32/inc/SanityCheck.h b/Marlin/src/HAL/TEENSY31_32/inc/SanityCheck.h index 1efa76b1e9df..dbce187673c9 100644 --- a/Marlin/src/HAL/TEENSY31_32/inc/SanityCheck.h +++ b/Marlin/src/HAL/TEENSY31_32/inc/SanityCheck.h @@ -40,3 +40,7 @@ #if ENABLED(POSTMORTEM_DEBUGGING) #error "POSTMORTEM_DEBUGGING is not yet supported on Teensy 3.1/3.2." #endif + +#if USING_PULLDOWNS + #error "PULLDOWN pin mode is not available on Teensy 3.1/3.2 boards." +#endif diff --git a/Marlin/src/HAL/TEENSY31_32/timers.h b/Marlin/src/HAL/TEENSY31_32/timers.h index 3b073d63ab29..9fcbb6f232c9 100644 --- a/Marlin/src/HAL/TEENSY31_32/timers.h +++ b/Marlin/src/HAL/TEENSY31_32/timers.h @@ -110,4 +110,4 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num); bool HAL_timer_interrupt_enabled(const uint8_t timer_num); void HAL_timer_isr_prologue(const uint8_t timer_num); -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/TEENSY31_32/watchdog.cpp b/Marlin/src/HAL/TEENSY31_32/watchdog.cpp deleted file mode 100644 index 5e21236129db..000000000000 --- a/Marlin/src/HAL/TEENSY31_32/watchdog.cpp +++ /dev/null @@ -1,40 +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 . - * - */ -#ifdef __MK20DX256__ - -#include "../../inc/MarlinConfig.h" - -#if ENABLED(USE_WATCHDOG) - -#include "watchdog.h" - -#define WDT_TIMEOUT_MS TERN(WATCHDOG_DURATION_8S, 8000, 4000) // 4 or 8 second timeout - -void watchdog_init() { - WDOG_TOVALH = 0; - WDOG_TOVALL = WDT_TIMEOUT_MS; - WDOG_STCTRLH = WDOG_STCTRLH_WDOGEN; -} - -#endif // USE_WATCHDOG - -#endif // __MK20DX256__ diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.cpp b/Marlin/src/HAL/TEENSY35_36/HAL.cpp index 046c00b56ed5..bc02ac1c4524 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.cpp +++ b/Marlin/src/HAL/TEENSY35_36/HAL.cpp @@ -31,6 +31,10 @@ #include +// ------------------------ +// Serial ports +// ------------------------ + #define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X) #define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X) #if WITHIN(SERIAL_PORT, 0, 3) @@ -39,42 +43,13 @@ USBSerialType USBSerial(false, SerialUSB); -uint16_t HAL_adc_result, HAL_adc_select; - -static const uint8_t pin2sc1a[] = { - 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 3, 19+128, 14+128, 15+128, // 0-13 -> A0-A13 - 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 are A0-A9 - 255, 255, 255, 255, 255, 255, 255, // 24-30 are digital only - 14+128, 15+128, 17, 18, 4+128, 5+128, 6+128, 7+128, 17+128, // 31-39 are A12-A20 - 255, 255, 255, 255, 255, 255, 255, 255, 255, // 40-48 are digital only - 10+128, 11+128, // 49-50 are A23-A24 - 255, 255, 255, 255, 255, 255, 255, // 51-57 are digital only - 255, 255, 255, 255, 255, 255, // 58-63 (sd card pins) are digital only - 3, 19+128, // 64-65 are A10-A11 - 23, 23+128,// 66-67 are A21-A22 (DAC pins) - 1, 1+128, // 68-69 are A25-A26 (unused USB host port on Teensy 3.5) - 26, // 70 is Temperature Sensor - 18+128 // 71 is Vref -}; - -/* - // disable interrupts - void cli() { noInterrupts(); } - - // enable interrupts - void sei() { interrupts(); } -*/ - -void HAL_adc_init() { - analog_init(); - while (ADC0_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish - while (ADC1_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish - NVIC_ENABLE_IRQ(IRQ_FTM1); -} +// ------------------------ +// MarlinHAL Class +// ------------------------ -void HAL_clear_reset_source() { } +void MarlinHAL::reboot() { _reboot_Teensyduino_(); } -uint8_t HAL_get_reset_source() { +uint8_t MarlinHAL::get_reset_source() { switch (RCM_SRS0) { case 128: return RST_POWER_ON; break; case 64: return RST_EXTERNAL; break; @@ -86,45 +61,96 @@ uint8_t HAL_get_reset_source() { return 0; } -void HAL_reboot() { _reboot_Teensyduino_(); } +// ------------------------ +// Watchdog Timer +// ------------------------ -extern "C" { - extern char __bss_end; - extern char __heap_start; - extern void* __brkval; +#if ENABLED(USE_WATCHDOG) - int freeMemory() { - int free_memory; - if ((int)__brkval == 0) - free_memory = ((int)&free_memory) - ((int)&__bss_end); - else - free_memory = ((int)&free_memory) - ((int)__brkval); - return free_memory; + #define WDT_TIMEOUT_MS TERN(WATCHDOG_DURATION_8S, 8000, 4000) // 4 or 8 second timeout + + void MarlinHAL::watchdog_init() { + WDOG_TOVALH = 0; + WDOG_TOVALL = WDT_TIMEOUT_MS; + WDOG_STCTRLH = WDOG_STCTRLH_WDOGEN; } + + void MarlinHAL::watchdog_refresh() { + // Watchdog refresh sequence + WDOG_REFRESH = 0xA602; + WDOG_REFRESH = 0xB480; + } + +#endif + +// ------------------------ +// ADC +// ------------------------ + +int8_t MarlinHAL::adc_select; + +void MarlinHAL::adc_init() { + analog_init(); + while (ADC0_SC3 & ADC_SC3_CAL) { /* Wait for calibration to finish */ } + while (ADC1_SC3 & ADC_SC3_CAL) { /* Wait for calibration to finish */ } + NVIC_ENABLE_IRQ(IRQ_FTM1); } -void HAL_adc_start_conversion(const uint8_t adc_pin) { +void MarlinHAL::adc_start(const pin_t adc_pin) { + static const uint8_t pin2sc1a[] = { + 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 3, 19+128, 14+128, 15+128, // 0-13 -> A0-A13 + 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 are A0-A9 + 255, 255, 255, 255, 255, 255, 255, // 24-30 are digital only + 14+128, 15+128, 17, 18, 4+128, 5+128, 6+128, 7+128, 17+128, // 31-39 are A12-A20 + 255, 255, 255, 255, 255, 255, 255, 255, 255, // 40-48 are digital only + 10+128, 11+128, // 49-50 are A23-A24 + 255, 255, 255, 255, 255, 255, 255, // 51-57 are digital only + 255, 255, 255, 255, 255, 255, // 58-63 (sd card pins) are digital only + 3, 19+128, // 64-65 are A10-A11 + 23, 23+128,// 66-67 are A21-A22 (DAC pins) + 1, 1+128, // 68-69 are A25-A26 (unused USB host port on Teensy 3.5) + 26, // 70 is Temperature Sensor + 18+128 // 71 is Vref + }; const uint16_t pin = pin2sc1a[adc_pin]; if (pin == 0xFF) { - // Digital only - HAL_adc_select = -1; + adc_select = -1; // Digital only } else if (pin & 0x80) { - HAL_adc_select = 1; + adc_select = 1; ADC1_SC1A = pin & 0x7F; } else { - HAL_adc_select = 0; + adc_select = 0; ADC0_SC1A = pin; } } -uint16_t HAL_adc_get_result() { - switch (HAL_adc_select) { +uint16_t MarlinHAL::adc_value() { + switch (adc_select) { case 0: return ADC0_RA; case 1: return ADC1_RA; } return 0; } +// ------------------------ +// Free Memory Accessor +// ------------------------ + +extern "C" { + extern char __bss_end; + extern char __heap_start; + extern void* __brkval; + + int freeMemory() { + int free_memory; + if ((int)__brkval == 0) + free_memory = ((int)&free_memory) - ((int)&__bss_end); + else + free_memory = ((int)&free_memory) - ((int)__brkval); + return free_memory; + } +} + #endif // __MK64FX512__ || __MK66FX1M0__ diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.h b/Marlin/src/HAL/TEENSY35_36/HAL.h index 892eb2d3c5b8..2a192e47189d 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/TEENSY35_36/HAL.h @@ -32,15 +32,10 @@ #include "../shared/HAL_SPI.h" #include "fastio.h" -#include "watchdog.h" #include #include -#define CPU_ST7920_DELAY_1 600 -#define CPU_ST7920_DELAY_2 750 -#define CPU_ST7920_DELAY_3 750 - // ------------------------ // Defines // ------------------------ @@ -53,6 +48,17 @@ #define IS_TEENSY35 1 #endif +#define CPU_ST7920_DELAY_1 600 +#define CPU_ST7920_DELAY_2 750 +#define CPU_ST7920_DELAY_3 750 + +#undef sq +#define sq(x) ((x)*(x)) + +// ------------------------ +// Serial ports +// ------------------------ + #include "../../core/serial_hook.h" #define Serial0 Serial @@ -76,34 +82,43 @@ extern USBSerialType USBSerial; #error "SERIAL_PORT must be from 0 to 3, or -1 for Native USB." #endif -#define HAL_SERVO_LIB libServo +// ------------------------ +// Types +// ------------------------ -typedef int8_t pin_t; +class libServo; +typedef libServo hal_servo_t; -#ifndef analogInputToDigitalPin - #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) -#endif +typedef int8_t pin_t; -#define CRITICAL_SECTION_START() uint32_t primask = __get_primask(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_primask()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() +// ------------------------ +// Interrupts +// ------------------------ -#undef sq -#define sq(x) ((x)*(x)) +#define CRITICAL_SECTION_START() const bool irqon = !__get_primask(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() -inline void HAL_init() {} +// ------------------------ +// ADC +// ------------------------ -// Clear reset reason -void HAL_clear_reset_source(); +#ifndef analogInputToDigitalPin + #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) +#endif -// Reset reason -uint8_t HAL_get_reset_source(); +#define HAL_ADC_VREF 3.3 +#define HAL_ADC_RESOLUTION 10 -void HAL_reboot(); +// +// 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) -FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } +// ------------------------ +// Free Memory Accessor +// ------------------------ #pragma GCC diagnostic push #if GCC_VERSION <= 50000 @@ -114,27 +129,69 @@ extern "C" int freeMemory(); #pragma GCC diagnostic pop -// ADC +// ------------------------ +// MarlinHAL Class +// ------------------------ -void HAL_adc_init(); +class MarlinHAL { +public: -#define HAL_ADC_VREF 3.3 -#define HAL_ADC_RESOLUTION 10 -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() true + // Earliest possible init, before setup() + MarlinHAL() {} -#define HAL_ANALOG_SELECT(pin) + // Watchdog + static void watchdog_init() IF_DISABLED(USE_WATCHDOG, {}); + static void watchdog_refresh() IF_DISABLED(USE_WATCHDOG, {}); -void HAL_adc_start_conversion(const uint8_t adc_pin); -uint16_t HAL_adc_get_result(); + static void init() {} // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 -// PWM + // Interrupts + static bool isr_state() { return true; } + static void isr_on() { __enable_irq(); } + static void isr_off() { __disable_irq(); } -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + static void delay_ms(const int ms) { delay(ms); } -// Pin Map + // Tasks, called from idle() + static void idletask() {} -#define GET_PIN_MAP_PIN(index) index -#define GET_PIN_MAP_INDEX(pin) pin -#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source() {} + + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static int8_t adc_select; + + // 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 pin_t) {} + + // 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(); + + /** + * 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); + } + +}; diff --git a/Marlin/src/HAL/TEENSY35_36/inc/SanityCheck.h b/Marlin/src/HAL/TEENSY35_36/inc/SanityCheck.h index eef2850550eb..330870737184 100644 --- a/Marlin/src/HAL/TEENSY35_36/inc/SanityCheck.h +++ b/Marlin/src/HAL/TEENSY35_36/inc/SanityCheck.h @@ -40,3 +40,7 @@ #if ENABLED(POSTMORTEM_DEBUGGING) #error "POSTMORTEM_DEBUGGING is not yet supported on Teensy 3.5/3.6." #endif + +#if USING_PULLDOWNS + #error "PULLDOWN pin mode is not available on Teensy 3.5/3.6 boards." +#endif diff --git a/Marlin/src/HAL/TEENSY35_36/timers.h b/Marlin/src/HAL/TEENSY35_36/timers.h index 6c342bbe0d25..8af79d73928e 100644 --- a/Marlin/src/HAL/TEENSY35_36/timers.h +++ b/Marlin/src/HAL/TEENSY35_36/timers.h @@ -109,4 +109,4 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num); bool HAL_timer_interrupt_enabled(const uint8_t timer_num); void HAL_timer_isr_prologue(const uint8_t timer_num); -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/TEENSY35_36/watchdog.cpp b/Marlin/src/HAL/TEENSY35_36/watchdog.cpp deleted file mode 100644 index 3825e2792869..000000000000 --- a/Marlin/src/HAL/TEENSY35_36/watchdog.cpp +++ /dev/null @@ -1,40 +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 . - * - */ -#if defined(__MK64FX512__) || defined(__MK66FX1M0__) - -#include "../../inc/MarlinConfig.h" - -#if ENABLED(USE_WATCHDOG) - -#include "watchdog.h" - -#define WDT_TIMEOUT_MS TERN(WATCHDOG_DURATION_8S, 8000, 4000) // 4 or 8 second timeout - -void watchdog_init() { - WDOG_TOVALH = 0; - WDOG_TOVALL = WDT_TIMEOUT_MS; - WDOG_STCTRLH = WDOG_STCTRLH_WDOGEN; -} - -#endif // USE_WATCHDOG - -#endif // __MK64FX512__ || __MK66FX1M0__ diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.cpp b/Marlin/src/HAL/TEENSY40_41/HAL.cpp index 270bee0dc9d4..1d02ab8575c3 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.cpp +++ b/Marlin/src/HAL/TEENSY40_41/HAL.cpp @@ -33,6 +33,10 @@ #include "timers.h" #include +// ------------------------ +// Serial ports +// ------------------------ + #define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X) #define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X) #if WITHIN(SERIAL_PORT, 0, 3) @@ -40,75 +44,23 @@ #endif USBSerialType USBSerial(false, SerialUSB); -uint16_t HAL_adc_result, HAL_adc_select; - -static const uint8_t pin2sc1a[] = { - 0x07, // 0/A0 AD_B1_02 - 0x08, // 1/A1 AD_B1_03 - 0x0C, // 2/A2 AD_B1_07 - 0x0B, // 3/A3 AD_B1_06 - 0x06, // 4/A4 AD_B1_01 - 0x05, // 5/A5 AD_B1_00 - 0x0F, // 6/A6 AD_B1_10 - 0x00, // 7/A7 AD_B1_11 - 0x0D, // 8/A8 AD_B1_08 - 0x0E, // 9/A9 AD_B1_09 - 0x01, // 24/A10 AD_B0_12 - 0x02, // 25/A11 AD_B0_13 - 0x83, // 26/A12 AD_B1_14 - only on ADC2, 3 - 0x84, // 27/A13 AD_B1_15 - only on ADC2, 4 - 0x07, // 14/A0 AD_B1_02 - 0x08, // 15/A1 AD_B1_03 - 0x0C, // 16/A2 AD_B1_07 - 0x0B, // 17/A3 AD_B1_06 - 0x06, // 18/A4 AD_B1_01 - 0x05, // 19/A5 AD_B1_00 - 0x0F, // 20/A6 AD_B1_10 - 0x00, // 21/A7 AD_B1_11 - 0x0D, // 22/A8 AD_B1_08 - 0x0E, // 23/A9 AD_B1_09 - 0x01, // 24/A10 AD_B0_12 - 0x02, // 25/A11 AD_B0_13 - 0x83, // 26/A12 AD_B1_14 - only on ADC2, 3 - 0x84, // 27/A13 AD_B1_15 - only on ADC2, 4 - #ifdef ARDUINO_TEENSY41 - 0xFF, // 28 - 0xFF, // 29 - 0xFF, // 30 - 0xFF, // 31 - 0xFF, // 32 - 0xFF, // 33 - 0xFF, // 34 - 0xFF, // 35 - 0xFF, // 36 - 0xFF, // 37 - 0x81, // 38/A14 AD_B1_12 - only on ADC2, 1 - 0x82, // 39/A15 AD_B1_13 - only on ADC2, 2 - 0x09, // 40/A16 AD_B1_04 - 0x0A, // 41/A17 AD_B1_05 - #endif -}; - -/* -// disable interrupts -void cli() { noInterrupts(); } - -// enable interrupts -void sei() { interrupts(); } -*/ - -void HAL_adc_init() { - analog_init(); - while (ADC1_GC & ADC_GC_CAL) ; - while (ADC2_GC & ADC_GC_CAL) ; -} +// ------------------------ +// FastIO +// ------------------------ -void HAL_clear_reset_source() { - uint32_t reset_source = SRC_SRSR; - SRC_SRSR = reset_source; +bool is_output(pin_t pin) { + const struct digital_pin_bitband_and_config_table_struct *p; + p = digital_pin_to_info_PGM + pin; + return (*(p->reg + 1) & p->mask); } -uint8_t HAL_get_reset_source() { +// ------------------------ +// MarlinHAL Class +// ------------------------ + +void MarlinHAL::reboot() { _reboot_Teensyduino_(); } + +uint8_t MarlinHAL::get_reset_source() { switch (SRC_SRSR & 0xFF) { case 1: return RST_POWER_ON; break; case 2: return RST_SOFTWARE; break; @@ -121,57 +73,138 @@ uint8_t HAL_get_reset_source() { return 0; } -void HAL_reboot() { _reboot_Teensyduino_(); } +void MarlinHAL::clear_reset_source() { + uint32_t reset_source = SRC_SRSR; + SRC_SRSR = reset_source; +} -#define __bss_end _ebss +// ------------------------ +// Watchdog Timer +// ------------------------ -extern "C" { - extern char __bss_end; - extern char __heap_start; - extern void* __brkval; +#if ENABLED(USE_WATCHDOG) - // Doesn't work on Teensy 4.x - uint32_t freeMemory() { - uint32_t free_memory; - if ((uint32_t)__brkval == 0) - free_memory = ((uint32_t)&free_memory) - ((uint32_t)&__bss_end); - else - free_memory = ((uint32_t)&free_memory) - ((uint32_t)__brkval); - return free_memory; + #define WDT_TIMEOUT TERN(WATCHDOG_DURATION_8S, 8, 4) // 4 or 8 second timeout + + constexpr uint8_t timeoutval = (WDT_TIMEOUT - 0.5f) / 0.5f; + + void MarlinHAL::watchdog_init() { + CCM_CCGR3 |= CCM_CCGR3_WDOG1(3); // enable WDOG1 clocks + WDOG1_WMCR = 0; // disable power down PDE + WDOG1_WCR |= WDOG_WCR_SRS | WDOG_WCR_WT(timeoutval); + WDOG1_WCR |= WDOG_WCR_WDE | WDOG_WCR_WDT | WDOG_WCR_SRE; } + + void MarlinHAL::watchdog_refresh() { + // Watchdog refresh sequence + WDOG1_WSR = 0x5555; + WDOG1_WSR = 0xAAAA; + } + +#endif + +// ------------------------ +// ADC +// ------------------------ + +int8_t MarlinHAL::adc_select; + +void MarlinHAL::adc_init() { + analog_init(); + while (ADC1_GC & ADC_GC_CAL) { /* wait */ } + while (ADC2_GC & ADC_GC_CAL) { /* wait */ } } -void HAL_adc_start_conversion(const uint8_t adc_pin) { +void MarlinHAL::adc_start(const pin_t adc_pin) { + static const uint8_t pin2sc1a[] = { + 0x07, // 0/A0 AD_B1_02 + 0x08, // 1/A1 AD_B1_03 + 0x0C, // 2/A2 AD_B1_07 + 0x0B, // 3/A3 AD_B1_06 + 0x06, // 4/A4 AD_B1_01 + 0x05, // 5/A5 AD_B1_00 + 0x0F, // 6/A6 AD_B1_10 + 0x00, // 7/A7 AD_B1_11 + 0x0D, // 8/A8 AD_B1_08 + 0x0E, // 9/A9 AD_B1_09 + 0x01, // 24/A10 AD_B0_12 + 0x02, // 25/A11 AD_B0_13 + 0x83, // 26/A12 AD_B1_14 - only on ADC2, 3 + 0x84, // 27/A13 AD_B1_15 - only on ADC2, 4 + 0x07, // 14/A0 AD_B1_02 + 0x08, // 15/A1 AD_B1_03 + 0x0C, // 16/A2 AD_B1_07 + 0x0B, // 17/A3 AD_B1_06 + 0x06, // 18/A4 AD_B1_01 + 0x05, // 19/A5 AD_B1_00 + 0x0F, // 20/A6 AD_B1_10 + 0x00, // 21/A7 AD_B1_11 + 0x0D, // 22/A8 AD_B1_08 + 0x0E, // 23/A9 AD_B1_09 + 0x01, // 24/A10 AD_B0_12 + 0x02, // 25/A11 AD_B0_13 + 0x83, // 26/A12 AD_B1_14 - only on ADC2, 3 + 0x84, // 27/A13 AD_B1_15 - only on ADC2, 4 + #ifdef ARDUINO_TEENSY41 + 0xFF, // 28 + 0xFF, // 29 + 0xFF, // 30 + 0xFF, // 31 + 0xFF, // 32 + 0xFF, // 33 + 0xFF, // 34 + 0xFF, // 35 + 0xFF, // 36 + 0xFF, // 37 + 0x81, // 38/A14 AD_B1_12 - only on ADC2, 1 + 0x82, // 39/A15 AD_B1_13 - only on ADC2, 2 + 0x09, // 40/A16 AD_B1_04 + 0x0A, // 41/A17 AD_B1_05 + #endif + }; const uint16_t pin = pin2sc1a[adc_pin]; if (pin == 0xFF) { - HAL_adc_select = -1; // Digital only + adc_select = -1; // Digital only } else if (pin & 0x80) { - HAL_adc_select = 1; + adc_select = 1; ADC2_HC0 = pin & 0x7F; } else { - HAL_adc_select = 0; + adc_select = 0; ADC1_HC0 = pin; } } -uint16_t HAL_adc_get_result() { - switch (HAL_adc_select) { +uint16_t MarlinHAL::adc_value() { + switch (adc_select) { case 0: - while (!(ADC1_HS & ADC_HS_COCO0)) ; // wait + while (!(ADC1_HS & ADC_HS_COCO0)) { /* wait */ } return ADC1_R0; case 1: - while (!(ADC2_HS & ADC_HS_COCO0)) ; // wait + while (!(ADC2_HS & ADC_HS_COCO0)) { /* wait */ } return ADC2_R0; } return 0; } -bool is_output(pin_t pin) { - const struct digital_pin_bitband_and_config_table_struct *p; - p = digital_pin_to_info_PGM + pin; - return (*(p->reg + 1) & p->mask); +// ------------------------ +// Free Memory Accessor +// ------------------------ + +#define __bss_end _ebss + +extern "C" { + extern char __bss_end; + extern char __heap_start; + extern void* __brkval; + + // Doesn't work on Teensy 4.x + uint32_t freeMemory() { + uint32_t free_memory; + free_memory = ((uint32_t)&free_memory) - (((uint32_t)__brkval) ?: ((uint32_t)&__bss_end)); + return free_memory; + } } #endif // __IMXRT1062__ diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.h b/Marlin/src/HAL/TEENSY40_41/HAL.h index 2b730768a802..c54a2e8a0b64 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.h +++ b/Marlin/src/HAL/TEENSY40_41/HAL.h @@ -32,7 +32,6 @@ #include "../shared/HAL_SPI.h" #include "fastio.h" -#include "watchdog.h" #include #include @@ -41,10 +40,6 @@ #include "../../feature/ethernet.h" #endif -#define CPU_ST7920_DELAY_1 600 -#define CPU_ST7920_DELAY_2 750 -#define CPU_ST7920_DELAY_3 750 - // ------------------------ // Defines // ------------------------ @@ -55,7 +50,23 @@ #define IS_TEENSY41 1 #endif +#define CPU_ST7920_DELAY_1 600 +#define CPU_ST7920_DELAY_2 750 +#define CPU_ST7920_DELAY_3 750 + +#undef sq +#define sq(x) ((x)*(x)) + +// Don't place string constants in PROGMEM +#undef PSTR +#define PSTR(str) ({static const char *data = (str); &data[0];}) + +// ------------------------ +// Serial ports +// ------------------------ + #include "../../core/serial_hook.h" + #define Serial0 Serial #define _DECLARE_SERIAL(X) \ typedef ForwardSerial1Class DefaultSerial##X; \ @@ -89,41 +100,47 @@ extern USBSerialType USBSerial; #endif #endif -#define HAL_SERVO_LIB libServo +// ------------------------ +// Types +// ------------------------ -typedef int8_t pin_t; +class libServo; +typedef libServo hal_servo_t; -#ifndef analogInputToDigitalPin - #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) -#endif +typedef int8_t pin_t; -#define CRITICAL_SECTION_START() uint32_t primask = __get_primask(); __disable_irq() -#define CRITICAL_SECTION_END() if (!primask) __enable_irq() -#define ISRS_ENABLED() (!__get_primask()) -#define ENABLE_ISRS() __enable_irq() -#define DISABLE_ISRS() __disable_irq() +// ------------------------ +// Interrupts +// ------------------------ -#undef sq -#define sq(x) ((x)*(x)) +#define CRITICAL_SECTION_START() const bool irqon = !__get_primask(); __disable_irq() +#define CRITICAL_SECTION_END() if (irqon) __enable_irq() -// Don't place string constants in PROGMEM -#undef PSTR -#define PSTR(str) ({static const char *data = (str); &data[0];}) +// ------------------------ +// ADC +// ------------------------ -// Enable hooks into idle and setup for HAL -#define HAL_IDLETASK 1 -FORCE_INLINE void HAL_idletask() {} -FORCE_INLINE void HAL_init() {} +#ifndef analogInputToDigitalPin + #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1) +#endif -// Clear reset reason -void HAL_clear_reset_source(); +#define HAL_ADC_VREF 3.3 +#define HAL_ADC_RESOLUTION 10 +#define HAL_ADC_FILTERED // turn off ADC oversampling -// Reset reason -uint8_t HAL_get_reset_source(); +// +// 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) -void HAL_reboot(); +// FastIO +bool is_output(pin_t pin); -FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); } +// ------------------------ +// Free Memory Accessor +// ------------------------ #pragma GCC diagnostic push #if GCC_VERSION <= 50000 @@ -134,30 +151,69 @@ extern "C" uint32_t freeMemory(); #pragma GCC diagnostic pop -// ADC +// ------------------------ +// MarlinHAL Class +// ------------------------ -void HAL_adc_init(); +class MarlinHAL { +public: -#define HAL_ADC_VREF 3.3 -#define HAL_ADC_RESOLUTION 10 -#define HAL_ADC_FILTERED // turn off ADC oversampling -#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) -#define HAL_READ_ADC() HAL_adc_get_result() -#define HAL_ADC_READY() true + // Earliest possible init, before setup() + MarlinHAL() {} -#define HAL_ANALOG_SELECT(pin) + // Watchdog + static void watchdog_init() IF_DISABLED(USE_WATCHDOG, {}); + static void watchdog_refresh() IF_DISABLED(USE_WATCHDOG, {}); -void HAL_adc_start_conversion(const uint8_t adc_pin); -uint16_t HAL_adc_get_result(); + static void init() {} // Called early in setup() + static void init_board() {} // Called less early in setup() + static void reboot(); // Restart the firmware from 0x0 -// PWM + // Interrupts + static bool isr_state() { return !__get_primask(); } + static void isr_on() { __enable_irq(); } + static void isr_off() { __disable_irq(); } -inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); } + static void delay_ms(const int ms) { delay(ms); } -// Pin Map + // Tasks, called from idle() + static void idletask() {} -#define GET_PIN_MAP_PIN(index) index -#define GET_PIN_MAP_INDEX(pin) pin -#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval) + // Reset + static uint8_t get_reset_source(); + static void clear_reset_source(); -bool is_output(pin_t pin); + // Free SRAM + static int freeMemory() { return ::freeMemory(); } + + // + // ADC Methods + // + + static int8_t adc_select; + + // 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 pin_t pin) {} + + // 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(); + + /** + * 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); + } + +}; diff --git a/Marlin/src/HAL/TEENSY40_41/timers.h b/Marlin/src/HAL/TEENSY40_41/timers.h index 81cf67f7bc08..77fe0953d3bd 100644 --- a/Marlin/src/HAL/TEENSY40_41/timers.h +++ b/Marlin/src/HAL/TEENSY40_41/timers.h @@ -114,4 +114,4 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num); void HAL_timer_isr_prologue(const uint8_t timer_num); //void HAL_timer_isr_epilogue(const uint8_t timer_num) {} -#define HAL_timer_isr_epilogue(T) +#define HAL_timer_isr_epilogue(T) NOOP diff --git a/Marlin/src/HAL/TEENSY40_41/watchdog.cpp b/Marlin/src/HAL/TEENSY40_41/watchdog.cpp deleted file mode 100644 index dd7c0aa92f09..000000000000 --- a/Marlin/src/HAL/TEENSY40_41/watchdog.cpp +++ /dev/null @@ -1,52 +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 . - * - */ -#ifdef __IMXRT1062__ - -/** - * HAL Watchdog for Teensy 4.0 (IMXRT1062DVL6A) / 4.1 (IMXRT1062DVJ6A) - */ - -#include "../../inc/MarlinConfig.h" - -#if ENABLED(USE_WATCHDOG) - -#include "watchdog.h" - -#define WDT_TIMEOUT TERN(WATCHDOG_DURATION_8S, 8, 4) // 4 or 8 second timeout - -constexpr uint8_t timeoutval = (WDT_TIMEOUT - 0.5f) / 0.5f; - -void watchdog_init() { - CCM_CCGR3 |= CCM_CCGR3_WDOG1(3); // enable WDOG1 clocks - WDOG1_WMCR = 0; // disable power down PDE - WDOG1_WCR |= WDOG_WCR_SRS | WDOG_WCR_WT(timeoutval); - WDOG1_WCR |= WDOG_WCR_WDE | WDOG_WCR_WDT | WDOG_WCR_SRE; -} - -void HAL_watchdog_refresh() { - // Watchdog refresh sequence - WDOG1_WSR = 0x5555; - WDOG1_WSR = 0xAAAA; -} - -#endif // USE_WATCHDOG -#endif // __IMXRT1062__ diff --git a/Marlin/src/HAL/shared/Delay.h b/Marlin/src/HAL/shared/Delay.h index df07881f01d9..a6795a78eaf4 100644 --- a/Marlin/src/HAL/shared/Delay.h +++ b/Marlin/src/HAL/shared/Delay.h @@ -166,6 +166,8 @@ void calibrate_delay_loop(); // Delay in microseconds #define DELAY_US(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL)) + #define DELAY_CYCLES_VAR DELAY_CYCLES + #elif defined(ESP32) || defined(__PLAT_LINUX__) || defined(__PLAT_NATIVE_SIM__) // DELAY_CYCLES specified inside platform diff --git a/Marlin/src/HAL/TEENSY35_36/watchdog.h b/Marlin/src/HAL/shared/HAL.cpp similarity index 75% rename from Marlin/src/HAL/TEENSY35_36/watchdog.h rename to Marlin/src/HAL/shared/HAL.cpp index 981b1f0bd20b..4d92aedd9a1f 100644 --- a/Marlin/src/HAL/TEENSY35_36/watchdog.h +++ b/Marlin/src/HAL/shared/HAL.cpp @@ -1,6 +1,6 @@ /** * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 @@ -19,12 +19,18 @@ * along with this program. If not, see . * */ -#pragma once -void watchdog_init(); +/** + * HAL/shared/HAL.cpp + */ + +#include "../../inc/MarlinConfig.h" + +MarlinHAL hal; + +#if ENABLED(SOFT_RESET_VIA_SERIAL) + + // Global for use by e_parser.h + void HAL_reboot() { hal.reboot(); } -inline void HAL_watchdog_refresh() { - // Watchdog refresh sequence - WDOG_REFRESH = 0xA602; - WDOG_REFRESH = 0xB480; -} +#endif diff --git a/Marlin/src/HAL/shared/HAL_spi_L6470.cpp b/Marlin/src/HAL/shared/HAL_spi_L6470.cpp index bd85dbe7bd7e..5d4ce89b2748 100644 --- a/Marlin/src/HAL/shared/HAL_spi_L6470.cpp +++ b/Marlin/src/HAL/shared/HAL_spi_L6470.cpp @@ -92,9 +92,9 @@ 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); - DISABLE_ISRS(); // Disable interrupts during SPI transfer (can't allow partial command to chips) + 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); - ENABLE_ISRS(); // Enable interrupts + hal.isr_on(); // Enable interrupts extDigitalWrite(ss_pin, HIGH); return data_out; @@ -107,9 +107,9 @@ uint8_t L64XX_Marlin::transfer_chain(uint8_t data, int16_t ss_pin, uint8_t chain extDigitalWrite(ss_pin, LOW); for (uint8_t i = L64XX::chain[0]; !L64xxManager.spi_abort && i >= 1; i--) { // Send data unless aborted - DISABLE_ISRS(); // Disable interrupts during SPI transfer (can't allow partial command to chips) + 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)); - ENABLE_ISRS(); // Enable interrupts + hal.isr_on(); // Enable interrupts if (i == chain_position) data_out = temp; } diff --git a/Marlin/src/HAL/shared/HAL_MinSerial.cpp b/Marlin/src/HAL/shared/MinSerial.cpp similarity index 97% rename from Marlin/src/HAL/shared/HAL_MinSerial.cpp rename to Marlin/src/HAL/shared/MinSerial.cpp index 9dda5fdf8c67..2e718d83dc12 100644 --- a/Marlin/src/HAL/shared/HAL_MinSerial.cpp +++ b/Marlin/src/HAL/shared/MinSerial.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#include "HAL_MinSerial.h" +#include "MinSerial.h" #if ENABLED(POSTMORTEM_DEBUGGING) diff --git a/Marlin/src/HAL/shared/HAL_MinSerial.h b/Marlin/src/HAL/shared/MinSerial.h similarity index 100% rename from Marlin/src/HAL/shared/HAL_MinSerial.h rename to Marlin/src/HAL/shared/MinSerial.h diff --git a/Marlin/src/HAL/shared/backtrace/backtrace.cpp b/Marlin/src/HAL/shared/backtrace/backtrace.cpp index ad88de8385ac..33e8e65154a0 100644 --- a/Marlin/src/HAL/shared/backtrace/backtrace.cpp +++ b/Marlin/src/HAL/shared/backtrace/backtrace.cpp @@ -25,7 +25,7 @@ #include "unwinder.h" #include "unwmemaccess.h" -#include "../HAL_MinSerial.h" +#include "../MinSerial.h" #include // Dump a backtrace entry diff --git a/Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp b/Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp index a106ed2b05e5..e54661c77071 100644 --- a/Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp +++ b/Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp @@ -54,7 +54,7 @@ #include "exception_hook.h" #include "../backtrace/backtrace.h" -#include "../HAL_MinSerial.h" +#include "../MinSerial.h" #define HW_REG(X) (*((volatile unsigned long *)(X))) @@ -221,7 +221,7 @@ bool resume_from_fault() { // So we'll just need to refresh the watchdog for a while and then stop for the system to reboot uint32_t last = start; while (PENDING(last, end)) { - watchdog_refresh(); + hal.watchdog_refresh(); while (millis() == last) { /* nada */ } last = millis(); MinSerial::TX('.'); diff --git a/Marlin/src/HAL/shared/eeprom_api.h b/Marlin/src/HAL/shared/eeprom_api.h index 1f38639930dc..cd744f82dc79 100644 --- a/Marlin/src/HAL/shared/eeprom_api.h +++ b/Marlin/src/HAL/shared/eeprom_api.h @@ -49,7 +49,7 @@ class PersistentStore { // Write one or more bytes of data // Return 'true' on write error - static inline bool write_data(const int pos, const uint8_t *value, const size_t size=sizeof(uint8_t)) { + static bool write_data(const int pos, const uint8_t *value, const size_t size=sizeof(uint8_t)) { int data_pos = pos; uint16_t crc = 0; return write_data(data_pos, value, size, &crc); @@ -57,11 +57,11 @@ class PersistentStore { // Write a single byte of data // Return 'true' on write error - static inline bool write_data(const int pos, const uint8_t value) { return write_data(pos, &value); } + static bool write_data(const int pos, const uint8_t value) { return write_data(pos, &value); } // Read one or more bytes of data // Return 'true' on read error - static inline bool read_data(const int pos, uint8_t *value, const size_t size=1) { + static bool read_data(const int pos, uint8_t *value, const size_t size=1) { int data_pos = pos; uint16_t crc = 0; return read_data(data_pos, value, size, &crc); diff --git a/Marlin/src/HAL/shared/math_32bit.h b/Marlin/src/HAL/shared/math_32bit.h index 87e9e6406ee4..1fb233e3e896 100644 --- a/Marlin/src/HAL/shared/math_32bit.h +++ b/Marlin/src/HAL/shared/math_32bit.h @@ -26,6 +26,6 @@ /** * Math helper functions for 32 bit CPUs */ -static FORCE_INLINE uint32_t MultiU32X24toH32(uint32_t longIn1, uint32_t longIn2) { +FORCE_INLINE static uint32_t MultiU32X24toH32(uint32_t longIn1, uint32_t longIn2) { return ((uint64_t)longIn1 * longIn2 + 0x00800000) >> 24; } diff --git a/Marlin/src/HAL/shared/servo.cpp b/Marlin/src/HAL/shared/servo.cpp index cfec6f301737..b838800de654 100644 --- a/Marlin/src/HAL/shared/servo.cpp +++ b/Marlin/src/HAL/shared/servo.cpp @@ -65,7 +65,7 @@ uint8_t ServoCount = 0; // the total number of attached /************ static functions common to all instances ***********************/ -static boolean isTimerActive(timer16_Sequence_t timer) { +static bool anyTimerChannelActive(const timer16_Sequence_t timer) { // returns true if any servo is active on this timer LOOP_L_N(channel, SERVOS_PER_TIMER) { if (SERVO(timer, channel).Pin.isActive) @@ -101,17 +101,18 @@ int8_t Servo::attach(const int inPin, const int inMin, const int inMax) { max = (MAX_PULSE_WIDTH - inMax) / 4; // initialize the timer if it has not already been initialized - timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex); - if (!isTimerActive(timer)) initISR(timer); - servo_info[servoIndex].Pin.isActive = true; // this must be set after the check for isTimerActive + const timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex); + if (!anyTimerChannelActive(timer)) initISR(timer); + servo_info[servoIndex].Pin.isActive = true; // this must be set after the check for anyTimerChannelActive return servoIndex; } void Servo::detach() { servo_info[servoIndex].Pin.isActive = false; - timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex); - if (!isTimerActive(timer)) finISR(timer); + const timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex); + if (!anyTimerChannelActive(timer)) finISR(timer); + //pinMode(servo_info[servoIndex].Pin.nbr, INPUT); // set servo pin to input } void Servo::write(int value) { diff --git a/Marlin/src/HAL/shared/servo_private.h b/Marlin/src/HAL/shared/servo_private.h index d85d8da8ba43..021e0cb81d01 100644 --- a/Marlin/src/HAL/shared/servo_private.h +++ b/Marlin/src/HAL/shared/servo_private.h @@ -70,10 +70,10 @@ #define ticksToUs(_ticks) (unsigned(_ticks) * (SERVO_TIMER_PRESCALER) / clockCyclesPerMicrosecond()) // convenience macros -#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / (SERVOS_PER_TIMER))) // returns the timer controlling this servo -#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % (SERVOS_PER_TIMER)) // returns the index of the servo on this timer -#define SERVO_INDEX(_timer,_channel) ((_timer*(SERVOS_PER_TIMER)) + _channel) // macro to access servo index by timer and channel -#define SERVO(_timer,_channel) (servo_info[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel +#define SERVO_INDEX_TO_TIMER(_servo_nbr) timer16_Sequence_t(_servo_nbr / (SERVOS_PER_TIMER)) // the timer controlling this servo +#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % (SERVOS_PER_TIMER)) // the index of the servo on this timer +#define SERVO_INDEX(_timer,_channel) ((_timer*(SERVOS_PER_TIMER)) + _channel) // servo index by timer and channel +#define SERVO(_timer,_channel) servo_info[SERVO_INDEX(_timer,_channel)] // servo class by timer and channel // Types @@ -94,5 +94,5 @@ extern ServoInfo_t servo_info[MAX_SERVOS]; // Public functions -extern void initISR(timer16_Sequence_t timer); -extern void finISR(timer16_Sequence_t timer); +extern void initISR(const timer16_Sequence_t timer); +extern void finISR(const timer16_Sequence_t timer); diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 5132d07e8711..7f1aabc43b28 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -74,8 +74,8 @@ #include "lcd/e3v2/common/encoder.h" #if ENABLED(DWIN_CREALITY_LCD) #include "lcd/e3v2/creality/dwin.h" - #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "lcd/e3v2/enhanced/dwin.h" + #elif ENABLED(DWIN_LCD_PROUI) + #include "lcd/e3v2/proui/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "lcd/e3v2/jyersui/dwin.h" #endif @@ -97,7 +97,7 @@ #include "feature/host_actions.h" #endif -#if USE_BEEPER +#if HAS_BEEPER #include "libs/buzzer.h" #endif @@ -145,7 +145,7 @@ #include "feature/encoder_i2c.h" #endif -#if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF) +#if (HAS_TRINAMIC_CONFIG || HAS_TMC_SPI) && DISABLED(PSU_DEFAULT_OFF) #include "feature/tmc_util.h" #endif @@ -271,6 +271,7 @@ bool wait_for_heatup = true; while (wait_for_user && !(ms && ELAPSED(millis(), ms))) idle(TERN_(ADVANCED_PAUSE_FEATURE, no_sleep)); wait_for_user = false; + while (ui.button_pressed()) safe_delay(50); } #endif @@ -320,6 +321,10 @@ bool pin_is_protected(const pin_t pin) { #pragma GCC diagnostic pop +bool printer_busy() { + return planner.movesplanned() || printingIsActive(); +} + /** * A Print Job exists when the timer is running or SD is printing */ @@ -412,38 +417,41 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { if (do_reset_timeout) gcode.reset_stepper_timeout(ms); if (gcode.stepper_max_timed_out(ms)) { - SERIAL_ERROR_MSG(STR_KILL_INACTIVE_TIME, parser.command_ptr); + SERIAL_ERROR_START(); + SERIAL_ECHOPGM(STR_KILL_PRE); + SERIAL_ECHOLNPGM(STR_KILL_INACTIVE_TIME, parser.command_ptr); kill(); } + const bool has_blocks = planner.has_blocks_queued(); // Any moves in the planner? + if (has_blocks) gcode.reset_stepper_timeout(ms); // Reset timeout for M18/M84, M85 max 'kill', and laser. + // M18 / M84 : Handle steppers inactive time timeout - if (gcode.stepper_inactive_time) { + #if HAS_DISABLE_INACTIVE_AXIS + if (gcode.stepper_inactive_time) { - static bool already_shutdown_steppers; // = false + static bool already_shutdown_steppers; // = false - // Any moves in the planner? Resets both the M18/M84 - // activity timeout and the M85 max 'kill' timeout - if (planner.has_blocks_queued()) - gcode.reset_stepper_timeout(ms); - else if (!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 - - // Individual axes will be disabled if configured - TERN_(DISABLE_INACTIVE_X, stepper.disable_axis(X_AXIS)); - TERN_(DISABLE_INACTIVE_Y, stepper.disable_axis(Y_AXIS)); - TERN_(DISABLE_INACTIVE_Z, stepper.disable_axis(Z_AXIS)); - TERN_(DISABLE_INACTIVE_I, stepper.disable_axis(I_AXIS)); - TERN_(DISABLE_INACTIVE_J, stepper.disable_axis(J_AXIS)); - TERN_(DISABLE_INACTIVE_K, stepper.disable_axis(K_AXIS)); - TERN_(DISABLE_INACTIVE_E, stepper.disable_e_steppers()); - - TERN_(AUTO_BED_LEVELING_UBL, ubl.steppers_were_disabled()); + 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 + + // Individual axes will be disabled if configured + TERN_(DISABLE_INACTIVE_X, stepper.disable_axis(X_AXIS)); + TERN_(DISABLE_INACTIVE_Y, stepper.disable_axis(Y_AXIS)); + TERN_(DISABLE_INACTIVE_Z, stepper.disable_axis(Z_AXIS)); + TERN_(DISABLE_INACTIVE_I, stepper.disable_axis(I_AXIS)); + TERN_(DISABLE_INACTIVE_J, stepper.disable_axis(J_AXIS)); + TERN_(DISABLE_INACTIVE_K, stepper.disable_axis(K_AXIS)); + TERN_(DISABLE_INACTIVE_E, stepper.disable_e_steppers()); + + TERN_(AUTO_BED_LEVELING_UBL, bedlevel.steppers_were_disabled()); + } } + else + already_shutdown_steppers = false; } - else - already_shutdown_steppers = false; - } + #endif #if ENABLED(PHOTO_GCODE) && PIN_EXISTS(CHDK) // Check if CHDK should be set to LOW (after M240 set it HIGH) @@ -470,13 +478,15 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { // KILL the machine // ---------------------------------------------------------------- if (killCount >= KILL_DELAY) { - SERIAL_ERROR_MSG(STR_KILL_BUTTON); + SERIAL_ERROR_START(); + SERIAL_ECHOPGM(STR_KILL_PRE); + SERIAL_ECHOLNPGM(STR_KILL_BUTTON); kill(); } #endif #if HAS_FREEZE_PIN - Stepper::frozen = !READ(FREEZE_PIN); + stepper.frozen = READ(FREEZE_PIN) == FREEZE_STATE; #endif #if HAS_HOME @@ -506,7 +516,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { next_cub_ms_##N = ms + CUB_DEBOUNCE_DELAY_##N; \ CODE; \ queue.inject(F(BUTTON##N##_GCODE)); \ - TERN_(HAS_LCD_MENU, ui.quick_feedback()); \ + TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); \ } \ } \ }while(0) @@ -790,7 +800,7 @@ void idle(bool no_stepper_sleep/*=false*/) { #endif // Run HAL idle tasks - TERN_(HAL_IDLETASK, HAL_idletask()); + hal.idletask(); // Check network connection TERN_(HAS_ETHERNET, ethernet.check()); @@ -819,10 +829,10 @@ void idle(bool no_stepper_sleep/*=false*/) { TERN_(PRINTCOUNTER, print_job_timer.tick()); // Update the Beeper queue - TERN_(USE_BEEPER, buzzer.tick()); + TERN_(HAS_BEEPER, buzzer.tick()); // Handle UI input / draw events - TERN(HAS_DWIN_E3V2_BASIC, DWIN_Update(), ui.update()); + TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update()); // Run i2c Position Encoders #if ENABLED(I2C_POSITION_ENCODERS) @@ -878,7 +888,7 @@ void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullp // Echo the LCD message to serial for extra context if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNF(lcd_error); } - #if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED) + #if HAS_DISPLAY ui.kill_screen(lcd_error ?: GET_TEXT_F(MSG_KILLED), lcd_component ?: FPSTR(NUL_STR)); #else UNUSED(lcd_error); UNUSED(lcd_component); @@ -922,18 +932,18 @@ void minkill(const bool steppers_off/*=false*/) { // Wait for both KILL and ENC to be released while (TERN0(HAS_KILL, kill_state()) || TERN0(SOFT_RESET_ON_KILL, ui.button_pressed())) - watchdog_refresh(); + hal.watchdog_refresh(); // Wait for either KILL or ENC to be pressed again while (TERN1(HAS_KILL, !kill_state()) && TERN1(SOFT_RESET_ON_KILL, !ui.button_pressed())) - watchdog_refresh(); + hal.watchdog_refresh(); // Reboot the board - HAL_reboot(); + hal.reboot(); #else - for (;;) watchdog_refresh(); // Wait for RESET button or power-cycle + for (;;) hal.watchdog_refresh(); // Wait for RESET button or power-cycle #endif } @@ -1041,7 +1051,7 @@ inline void tmc_standby_setup() { * • L64XX Stepper Drivers (SPI) * • Stepper Driver Reset: DISABLE * • TMC Stepper Drivers (SPI) - * • Run BOARD_INIT if defined + * • Run hal.init_board() for additional pins setup * • ESP WiFi * - Get the Reset Reason and report it * - Print startup messages and diagnostics @@ -1119,8 +1129,8 @@ void setup() { tmc_standby_setup(); // TMC Low Power Standby pins must be set early or they're not usable // Check startup - does nothing if bootloader sets MCUSR to 0 - const byte mcu = HAL_get_reset_source(); - HAL_clear_reset_source(); + const byte mcu = hal.get_reset_source(); + hal.clear_reset_source(); #if ENABLED(MARLIN_DEV_MODE) auto log_current_ms = [&](PGM_P const msg) { @@ -1166,9 +1176,13 @@ void setup() { #endif #endif - #if HAS_FREEZE_PIN + #if ENABLED(FREEZE_FEATURE) SETUP_LOG("FREEZE_PIN"); - SET_INPUT_PULLUP(FREEZE_PIN); + #if FREEZE_STATE + SET_INPUT_PULLDOWN(FREEZE_PIN); + #else + SET_INPUT_PULLUP(FREEZE_PIN); + #endif #endif #if HAS_SUICIDE @@ -1181,23 +1195,20 @@ void setup() { JTAGSWD_RESET(); #endif - #if EITHER(DISABLE_DEBUG, DISABLE_JTAG) + // Disable any hardware debug to free up pins for IO + #if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE) delay(10); - // Disable any hardware debug to free up pins for IO - #if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE) - SETUP_LOG("JTAGSWD_DISABLE"); - JTAGSWD_DISABLE(); - #elif defined(JTAG_DISABLE) - SETUP_LOG("JTAG_DISABLE"); - JTAG_DISABLE(); - #else - #error "DISABLE_(DEBUG|JTAG) is not supported for the selected MCU/Board." - #endif + SETUP_LOG("JTAGSWD_DISABLE"); + JTAGSWD_DISABLE(); + #elif ENABLED(DISABLE_JTAG) && defined(JTAG_DISABLE) + delay(10); + SETUP_LOG("JTAG_DISABLE"); + JTAG_DISABLE(); #endif TERN_(DYNAMIC_VECTORTABLE, hook_cpu_exceptions()); // If supported, install Marlin exception handlers at runtime - SETUP_RUN(HAL_init()); + 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)) @@ -1219,6 +1230,17 @@ void setup() { SETUP_RUN(tmc_serial_begin()); #endif + #if HAS_TMC_SPI + #if DISABLED(TMC_USE_SW_SPI) + SETUP_RUN(SPI.begin()); + #endif + 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(); @@ -1228,34 +1250,20 @@ void setup() { SETUP_RUN(recovery.setup()); #endif - #if HAS_L64XX - SETUP_RUN(L64xxManager.init()); // Set up SPI, init drivers - #endif - #if HAS_STEPPER_RESET SETUP_RUN(disableStepperDrivers()); #endif - #if HAS_TMC_SPI - #if DISABLED(TMC_USE_SW_SPI) - SETUP_RUN(SPI.begin()); - #endif - SETUP_RUN(tmc_init_cs_pins()); - #endif - - #ifdef BOARD_INIT - SETUP_LOG("BOARD_INIT"); - BOARD_INIT(); - #endif + SETUP_RUN(hal.init_board()); SETUP_RUN(esp_wifi_init()); // Report Reset Reason - if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP); - if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET); + if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP); + if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET); if (mcu & RST_BROWN_OUT) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET); - if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET); - if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET); + if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET); + if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET); // Identify myself as Marlin x.x.x SERIAL_ECHOLNPGM("Marlin " SHORT_BUILD_VERSION); @@ -1266,13 +1274,13 @@ void setup() { ); #endif SERIAL_ECHO_MSG(" Compiled: " __DATE__); - SERIAL_ECHO_MSG(STR_FREE_MEMORY, freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE)); + SERIAL_ECHO_MSG(STR_FREE_MEMORY, hal.freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE)); // Some HAL need precise delay adjustment calibrate_delay_loop(); // Init buzzer pin(s) - #if USE_BEEPER + #if HAS_BEEPER SETUP_RUN(buzzer.init()); #endif @@ -1294,16 +1302,7 @@ void setup() { // UI must be initialized before EEPROM // (because EEPROM code calls the UI). - #if HAS_DWIN_E3V2_BASIC - SETUP_RUN(DWIN_Startup()); - #else - SETUP_RUN(ui.init()); - #if BOTH(HAS_WIRED_LCD, SHOW_BOOTSCREEN) - SETUP_RUN(ui.show_bootscreen()); - const millis_t bootscreen_ms = millis(); - #endif - SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.) - #endif + SETUP_RUN(ui.init()); #if PIN_EXISTS(SAFE_POWER) #if HAS_DRIVER_SAFE_POWER_PROTECT @@ -1314,10 +1313,6 @@ void setup() { #endif #endif - #if ENABLED(PROBE_TARE) - SETUP_RUN(probe.tare_init()); - #endif - #if BOTH(SDSUPPORT, SDCARD_EEPROM_EMULATION) SETUP_RUN(card.mount()); // Mount media with settings before first_load #endif @@ -1325,6 +1320,15 @@ void setup() { SETUP_RUN(settings.first_load()); // Load data from EEPROM if available (or use defaults) // This also updates variables in the planner, elsewhere + #if BOTH(HAS_WIRED_LCD, SHOW_BOOTSCREEN) + SETUP_RUN(ui.show_bootscreen()); + const millis_t bootscreen_ms = millis(); + #endif + + #if ENABLED(PROBE_TARE) + SETUP_RUN(probe.tare_init()); + #endif + #if HAS_ETHERNET SETUP_RUN(ethernet.init()); #endif @@ -1343,6 +1347,10 @@ void setup() { SETUP_RUN(endstops.init()); // Init endstops and pullups + #if ENABLED(DELTA) && !HAS_SOFTWARE_ENDSTOPS + SETUP_RUN(refresh_delta_clip_start_height()); // Init safe delta height without soft endstops + #endif + SETUP_RUN(stepper.init()); // Init stepper. This enables interrupts! #if HAS_SERVOS @@ -1502,6 +1510,10 @@ void setup() { SETUP_RUN(bltouch.init(/*set_voltage=*/true)); #endif + #if ENABLED(MAGLEV4) + OUT_WRITE(MAGLEV_TRIGGER_PIN, LOW); + #endif + #if ENABLED(I2C_POSITION_ENCODERS) SETUP_RUN(I2CPEM.init()); #endif @@ -1538,7 +1550,7 @@ void setup() { #endif #if ENABLED(USE_WATCHDOG) - SETUP_RUN(watchdog_init()); // Reinit watchdog after HAL_get_reset_source call + SETUP_RUN(hal.watchdog_init()); // Reinit watchdog after hal.get_reset_source call #endif #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER) @@ -1554,10 +1566,6 @@ void setup() { SETUP_RUN(hostui.prompt_end()); #endif - #if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF) - SETUP_RUN(test_tmc_connection()); - #endif - #if HAS_DRIVER_SAFE_POWER_PROTECT SETUP_RUN(stepper_driver_backward_report()); #endif @@ -1573,11 +1581,7 @@ void setup() { #endif #if HAS_DWIN_E3V2_BASIC - SETUP_LOG("E3V2 Init"); - Encoder_Configuration(); - HMI_Init(); - HMI_SetLanguageCache(); - HMI_StartFrame(true); + SETUP_RUN(DWIN_InitScreen()); #endif #if HAS_SERVICE_INTERVALS && !HAS_DWIN_E3V2_BASIC @@ -1611,7 +1615,7 @@ void setup() { SETUP_RUN(password.lock_machine()); // Will not proceed until correct password provided #endif - #if BOTH(HAS_LCD_MENU, TOUCH_SCREEN_CALIBRATION) && EITHER(TFT_CLASSIC_UI, TFT_COLOR_UI) + #if BOTH(HAS_MARLINUI_MENU, TOUCH_SCREEN_CALIBRATION) && EITHER(TFT_CLASSIC_UI, TFT_COLOR_UI) SETUP_RUN(ui.check_touch_calibration()); #endif @@ -1619,6 +1623,10 @@ void setup() { SETUP_RUN(easythreed_ui.init()); #endif + #if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF) + SETUP_RUN(test_tmc_connection()); + #endif + marlin_state = MF_RUNNING; SETUP_LOG("setup() completed."); @@ -1648,6 +1656,10 @@ void loop() { queue.advance(); + #if EITHER(POWER_OFF_TIMER, POWER_OFF_WAIT_FOR_COOLDOWN) + powerManager.checkAutoPowerOff(); + #endif + endstops.event_handler(); TERN_(HAS_TFT_LVGL_UI, printer_state_polling()); diff --git a/Marlin/src/MarlinCore.h b/Marlin/src/MarlinCore.h index 7063c7e2de38..f80405a302ee 100644 --- a/Marlin/src/MarlinCore.h +++ b/Marlin/src/MarlinCore.h @@ -61,6 +61,8 @@ bool printJobOngoing(); bool printingIsPaused(); void startOrResumeJob(); +bool printer_busy(); + extern bool wait_for_heatup; #if HAS_RESUME_CONTINUE diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index aee9b3c49287..ef750056d6fc 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -115,6 +115,8 @@ #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 // // RAMBo and derivatives @@ -159,9 +161,10 @@ #define BOARD_PICA_REVB 1324 // PICA Shield (original version) #define BOARD_PICA 1325 // PICA Shield (rev C or later) #define BOARD_INTAMSYS40 1326 // Intamsys 4.0 (Funmat HT) -#define BOARD_MALYAN_M180 1327 // Malyan M180 Mainboard Version 2 (no display function, direct gcode only) +#define BOARD_MALYAN_M180 1327 // Malyan M180 Mainboard Version 2 (no display function, direct G-code only) #define BOARD_GT2560_V4_A20 1328 // Geeetech GT2560 Rev B for A20(M/T/D) #define BOARD_PROTONEER_CNC_SHIELD_V3 1329 // Mega controller & Protoneer CNC Shield V3.00 +#define BOARD_WEEDO_62A 1330 // WEEDO 62A board (TINA2, Monoprice Cadet, etc.) // // ATmega1281, ATmega2561 @@ -225,33 +228,33 @@ #define BOARD_RAMPS_14_RE_ARM_EFF 2002 // Re-ARM with RAMPS 1.4 (Power outputs: Hotend, Fan0, Fan1) #define BOARD_RAMPS_14_RE_ARM_EEF 2003 // Re-ARM with RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Fan) #define BOARD_RAMPS_14_RE_ARM_SF 2004 // Re-ARM with RAMPS 1.4 (Power outputs: Spindle, Controller Fan) -#define BOARD_MKS_SBASE 2005 // MKS-Sbase (Power outputs: Hotend0, Hotend1, Bed, Fan) +#define BOARD_MKS_SBASE 2005 // MKS-Sbase #define BOARD_AZSMZ_MINI 2006 // AZSMZ Mini -#define BOARD_BIQU_BQ111_A4 2007 // BIQU BQ111-A4 (Power outputs: Hotend, Fan, Bed) -#define BOARD_SELENA_COMPACT 2008 // Selena Compact (Power outputs: Hotend0, Hotend1, Bed0, Bed1, Fan0, Fan1) -#define BOARD_BIQU_B300_V1_0 2009 // BIQU B300_V1.0 (Power outputs: Hotend0, Fan, Bed, SPI Driver) -#define BOARD_MKS_SGEN_L 2010 // MKS-SGen-L (Power outputs: Hotend0, Hotend1, Bed, Fan) +#define BOARD_BIQU_BQ111_A4 2007 // BIQU BQ111-A4 +#define BOARD_SELENA_COMPACT 2008 // Selena Compact +#define BOARD_BIQU_B300_V1_0 2009 // BIQU B300_V1.0 +#define BOARD_MKS_SGEN_L 2010 // MKS-SGen-L #define BOARD_GMARSH_X6_REV1 2011 // GMARSH X6, revision 1 prototype -#define BOARD_BTT_SKR_V1_1 2012 // BigTreeTech SKR v1.1 (Power outputs: Hotend0, Hotend1, Fan, Bed) -#define BOARD_BTT_SKR_V1_3 2013 // BigTreeTech SKR v1.3 (Power outputs: Hotend0, Hotend1, Fan, Bed) -#define BOARD_BTT_SKR_V1_4 2014 // BigTreeTech SKR v1.4 (Power outputs: Hotend0, Hotend1, Fan, Bed) +#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 // // LPC1769 ARM Cortex M3 // -#define BOARD_MKS_SGEN 2500 // MKS-SGen (Power outputs: Hotend0, Hotend1, Bed, Fan) -#define BOARD_AZTEEG_X5_GT 2501 // Azteeg X5 GT (Power outputs: Hotend0, Hotend1, Bed, Fan) -#define BOARD_AZTEEG_X5_MINI 2502 // Azteeg X5 Mini (Power outputs: Hotend0, Bed, Fan) -#define BOARD_AZTEEG_X5_MINI_WIFI 2503 // Azteeg X5 Mini Wifi (Power outputs: Hotend0, Bed, Fan) +#define BOARD_MKS_SGEN 2500 // MKS-SGen +#define BOARD_AZTEEG_X5_GT 2501 // Azteeg X5 GT +#define BOARD_AZTEEG_X5_MINI 2502 // Azteeg X5 Mini +#define BOARD_AZTEEG_X5_MINI_WIFI 2503 // Azteeg X5 Mini Wifi #define BOARD_COHESION3D_REMIX 2504 // Cohesion3D ReMix #define BOARD_COHESION3D_MINI 2505 // Cohesion3D Mini #define BOARD_SMOOTHIEBOARD 2506 // Smoothieboard #define BOARD_TH3D_EZBOARD 2507 // TH3D EZBoard v1.0 -#define BOARD_BTT_SKR_V1_4_TURBO 2508 // BigTreeTech SKR v1.4 TURBO (Power outputs: Hotend0, Hotend1, Fan, Bed) -#define BOARD_MKS_SGEN_L_V2 2509 // MKS SGEN_L V2 (Power outputs: Hotend0, Hotend1, Bed, Fan) -#define BOARD_BTT_SKR_E3_TURBO 2510 // BigTreeTech SKR E3 Turbo (Power outputs: Hotend0, Hotend1, Bed, Fan0, Fan1) -#define BOARD_FLY_CDY 2511 // FLYmaker FLY CDY (Power outputs: Hotend0, Hotend1, Hotend2, Bed, Fan0, Fan1, Fan2) +#define BOARD_BTT_SKR_V1_4_TURBO 2508 // BigTreeTech SKR v1.4 TURBO +#define BOARD_MKS_SGEN_L_V2 2509 // MKS SGEN_L V2 +#define BOARD_BTT_SKR_E3_TURBO 2510 // BigTreeTech SKR E3 Turbo +#define BOARD_FLY_CDY 2511 // FLYmaker FLY CDY // // SAM3X8E ARM Cortex M3 @@ -277,8 +280,8 @@ #define BOARD_RAMPS4DUE_EFF 3017 // RAMPS4DUE (Power outputs: Hotend, Fan0, Fan1) #define BOARD_RAMPS4DUE_EEF 3018 // RAMPS4DUE (Power outputs: Hotend0, Hotend1, Fan) #define BOARD_RAMPS4DUE_SF 3019 // RAMPS4DUE (Power outputs: Spindle, Controller Fan) -#define BOARD_RURAMPS4D_11 3020 // RuRAMPS4Duo v1.1 (Power outputs: Hotend0, Hotend1, Hotend2, Fan0, Fan1, Bed) -#define BOARD_RURAMPS4D_13 3021 // RuRAMPS4Duo v1.3 (Power outputs: Hotend0, Hotend1, Hotend2, Fan0, Fan1, Bed) +#define BOARD_RURAMPS4D_11 3020 // RuRAMPS4Duo v1.1 +#define BOARD_RURAMPS4D_13 3021 // RuRAMPS4Duo v1.3 #define BOARD_ULTRATRONICS_PRO 3022 // ReprapWorld Ultratronics Pro V1.0 #define BOARD_ARCHIM1 3023 // UltiMachine Archim1 (with DRV8825 drivers) #define BOARD_ARCHIM2 3024 // UltiMachine Archim2 (with TMC2130 drivers) @@ -290,7 +293,7 @@ // SAM3X8C ARM Cortex M3 // -#define BOARD_PRINTRBOARD_G2 3100 // PRINTRBOARD G2 +#define BOARD_PRINTRBOARD_G2 3100 // Printrboard G2 #define BOARD_ADSK 3101 // Arduino DUE Shield Kit (ADSK) // @@ -300,26 +303,26 @@ #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 // STM32C8T6 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 // STM32F103VET6 controller -#define BOARD_GTM32_MINI 4006 // STM32F103VET6 controller -#define BOARD_GTM32_MINI_A30 4007 // STM32F103VET6 controller -#define BOARD_GTM32_REV_B 4008 // STM32F103VET6 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 (STM32F103RET6) -#define BOARD_MKS_ROBIN 4011 // MKS Robin (STM32F103ZET6) -#define BOARD_MKS_ROBIN_MINI 4012 // MKS Robin Mini (STM32F103VET6) -#define BOARD_MKS_ROBIN_NANO 4013 // MKS Robin Nano (STM32F103VET6) -#define BOARD_MKS_ROBIN_NANO_V2 4014 // MKS Robin Nano V2 (STM32F103VET6) -#define BOARD_MKS_ROBIN_LITE 4015 // MKS Robin Lite/Lite2 (STM32F103RCT6) -#define BOARD_MKS_ROBIN_LITE3 4016 // MKS Robin Lite3 (STM32F103RCT6) -#define BOARD_MKS_ROBIN_PRO 4017 // MKS Robin Pro (STM32F103ZET6) -#define BOARD_MKS_ROBIN_E3 4018 // MKS Robin E3 (STM32F103RCT6) -#define BOARD_MKS_ROBIN_E3_V1_1 4019 // MKS Robin E3 V1.1 (STM32F103RCT6) -#define BOARD_MKS_ROBIN_E3D 4020 // MKS Robin E3D (STM32F103RCT6) -#define BOARD_MKS_ROBIN_E3D_V1_1 4021 // MKS Robin E3D V1.1 (STM32F103RCT6) -#define BOARD_MKS_ROBIN_E3P 4022 // MKS Robin E3p (STM32F103VET6) +#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) @@ -328,37 +331,41 @@ #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 (STM32F103ZET6) +#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) / STM32F103VET6 +#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 (STM32F103RE) -#define BOARD_CREALITY_V423 4041 // Creality v4.2.3 (STM32F103RE) -#define BOARD_CREALITY_V427 4042 // Creality v4.2.7 (STM32F103RE) -#define BOARD_CREALITY_V4210 4043 // Creality v4.2.10 (STM32F103RE) as found in the CR-30 -#define BOARD_CREALITY_V431 4044 // Creality v4.3.1 (STM32F103RE) -#define BOARD_CREALITY_V431_A 4045 // Creality v4.3.1a (STM32F103RE) -#define BOARD_CREALITY_V431_B 4046 // Creality v4.3.1b (STM32F103RE) -#define BOARD_CREALITY_V431_C 4047 // Creality v4.3.1c (STM32F103RE) -#define BOARD_CREALITY_V431_D 4048 // Creality v4.3.1d (STM32F103RE) -#define BOARD_CREALITY_V452 4049 // Creality v4.5.2 (STM32F103RE) -#define BOARD_CREALITY_V453 4050 // Creality v4.5.3 (STM32F103RE) -#define BOARD_CREALITY_V24S1 4051 // Creality v2.4.S1 (STM32F103RE) v101 as found in the Ender 7 -#define BOARD_TRIGORILLA_PRO 4052 // Trigorilla Pro (STM32F103ZET6) -#define BOARD_FLY_MINI 4053 // FLYmaker FLY MINI (STM32F103RCT6) -#define BOARD_FLSUN_HISPEED 4054 // FLSUN HiSpeedV1 (STM32F103VET6) -#define BOARD_BEAST 4055 // STM32F103RET6 Libmaple-based controller -#define BOARD_MINGDA_MPX_ARM_MINI 4056 // STM32F103ZET6 Mingda MD-16 -#define BOARD_GTM32_PRO_VD 4057 // STM32F103VET6 controller -#define BOARD_ZONESTAR_ZM3E2 4058 // Zonestar ZM3E2 (STM32F103RCT6) -#define BOARD_ZONESTAR_ZM3E4 4059 // Zonestar ZM3E4 V1 (STM32F103VCT6) -#define BOARD_ZONESTAR_ZM3E4V2 4060 // Zonestar ZM3E4 V2 (STM32F103VCT6) -#define BOARD_ERYONE_ERY32_MINI 4061 // Eryone Ery32 mini (STM32F103VET6) +#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) // // ARM Cortex-M4F @@ -372,44 +379,46 @@ // #define BOARD_ARMED 4200 // Arm'ed STM32F4-based controller -#define BOARD_RUMBA32_V1_0 4201 // RUMBA32 STM32F446VET6 based controller from Aus3D -#define BOARD_RUMBA32_V1_1 4202 // RUMBA32 STM32F446VET6 based controller from Aus3D -#define BOARD_RUMBA32_MKS 4203 // RUMBA32 STM32F446VET6 based controller from Makerbase -#define BOARD_RUMBA32_BTT 4204 // RUMBA32 STM32F446VET6 based controller from BIGTREETECH +#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 (STM32F407ZGT6) -#define BOARD_BTT_SKR_PRO_V1_2 4209 // BigTreeTech SKR Pro v1.2 (STM32F407ZGT6) -#define BOARD_BTT_BTT002_V1_0 4210 // BigTreeTech BTT002 v1.0 (STM32F407VGT6) -#define BOARD_BTT_E3_RRF 4211 // BigTreeTech E3 RRF (STM32F407VGT6) -#define BOARD_BTT_SKR_V2_0_REV_A 4212 // BigTreeTech SKR v2.0 Rev A (STM32F407VGT6) -#define BOARD_BTT_SKR_V2_0_REV_B 4213 // BigTreeTech SKR v2.0 Rev B (STM32F407VGT6/STM32F429VGT6) +#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 (STM32F446ZET6) -#define BOARD_BTT_OCTOPUS_V1_1 4216 // BigTreeTech Octopus v1.1 (STM32F446ZET6) -#define BOARD_BTT_OCTOPUS_PRO_V1_0 4217 // BigTreeTech Octopus Pro v1.0 (STM32F446ZET6/STM32F429ZGT6) +#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 (STM32F446VET6) -#define BOARD_FYSETC_S6 4222 // FYSETC S6 (STM32F446VET6) -#define BOARD_FYSETC_S6_V2_0 4223 // FYSETC S6 v2.0 (STM32F446VET6) -#define BOARD_FYSETC_SPIDER 4224 // FYSETC Spider (STM32F446VET6) +#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_MONSTER8 4229 // MKS Monster8 (STM32F407VGT6) -#define BOARD_ANET_ET4 4230 // ANET ET4 V1.x (STM32F407VGT6) -#define BOARD_ANET_ET4P 4231 // ANET ET4P V1.x (STM32F407VGT6) -#define BOARD_FYSETC_CHEETAH_V20 4232 // FYSETC Cheetah V2.0 -#define BOARD_TH3D_EZBOARD_V2 4233 // TH3D EZBoard v2.0 -#define BOARD_INDEX_REV03 4234 // Index PnP Controller REV03 (STM32F407VET6/VGT6) -#define BOARD_MKS_ROBIN_NANO_V1_3_F4 4235 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VET6) -#define BOARD_MKS_EAGLE 4236 // MKS Eagle (STM32F407VET6) -#define BOARD_ARTILLERY_RUBY 4237 // Artillery Ruby (STM32F401RCT6) -#define BOARD_FYSETC_SPIDER_V2_2 4238 // FYSETC Spider V2.2 (STM32F446VET6) +#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 @@ -420,6 +429,8 @@ #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) // // Espressif ESP32 WiFi @@ -434,12 +445,15 @@ #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) // // SAMD51 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 // // Custom board diff --git a/Marlin/src/core/drivers.h b/Marlin/src/core/drivers.h index 0a76410274bb..f6a8f0f126ac 100644 --- a/Marlin/src/core/drivers.h +++ b/Marlin/src/core/drivers.h @@ -64,11 +64,11 @@ #define AXIS_DRIVER_TYPE_J(T) _AXIS_DRIVER_TYPE(J,T) #define AXIS_DRIVER_TYPE_K(T) _AXIS_DRIVER_TYPE(K,T) -#define AXIS_DRIVER_TYPE_X2(T) (EITHER(X_DUAL_STEPPER_DRIVERS, DUAL_X_CARRIAGE) && _AXIS_DRIVER_TYPE(X2,T)) -#define AXIS_DRIVER_TYPE_Y2(T) (ENABLED(Y_DUAL_STEPPER_DRIVERS) && _AXIS_DRIVER_TYPE(Y2,T)) -#define AXIS_DRIVER_TYPE_Z2(T) (NUM_Z_STEPPER_DRIVERS >= 2 && _AXIS_DRIVER_TYPE(Z2,T)) -#define AXIS_DRIVER_TYPE_Z3(T) (NUM_Z_STEPPER_DRIVERS >= 3 && _AXIS_DRIVER_TYPE(Z3,T)) -#define AXIS_DRIVER_TYPE_Z4(T) (NUM_Z_STEPPER_DRIVERS >= 4 && _AXIS_DRIVER_TYPE(Z4,T)) +#define AXIS_DRIVER_TYPE_X2(T) (HAS_X2_STEPPER && _AXIS_DRIVER_TYPE(X2,T)) +#define AXIS_DRIVER_TYPE_Y2(T) (HAS_DUAL_Y_STEPPERS && _AXIS_DRIVER_TYPE(Y2,T)) +#define AXIS_DRIVER_TYPE_Z2(T) (NUM_Z_STEPPERS >= 2 && _AXIS_DRIVER_TYPE(Z2,T)) +#define AXIS_DRIVER_TYPE_Z3(T) (NUM_Z_STEPPERS >= 3 && _AXIS_DRIVER_TYPE(Z3,T)) +#define AXIS_DRIVER_TYPE_Z4(T) (NUM_Z_STEPPERS >= 4 && _AXIS_DRIVER_TYPE(Z4,T)) #define AXIS_DRIVER_TYPE_E(N,T) (E_STEPPERS > N && _AXIS_DRIVER_TYPE(E##N,T)) #define AXIS_DRIVER_TYPE_E0(T) AXIS_DRIVER_TYPE_E(0,T) @@ -128,7 +128,7 @@ // 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) \ - || AXIS_DRIVER_TYPE(A,TMC2660) \ + || AXIS_DRIVER_TYPE(A,TMC26X) || AXIS_DRIVER_TYPE(A,TMC2660) \ || AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) ) #define AXIS_HAS_UART(A) ( AXIS_DRIVER_TYPE(A,TMC2208) || AXIS_DRIVER_TYPE(A,TMC2209) ) @@ -200,4 +200,4 @@ #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)) +#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 0a6870af26bf..fe89a3536f1b 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -105,6 +105,7 @@ #define STR_ENQUEUEING "enqueueing \"" #define STR_POWERUP "PowerUp" +#define STR_POWEROFF "PowerOff" #define STR_EXTERNAL_RESET " External Reset" #define STR_BROWNOUT_RESET " Brown out Reset" #define STR_WATCHDOG_RESET " Watchdog Reset" @@ -198,16 +199,20 @@ #define STR_FILAMENT_CHANGE_INSERT_M108 "Insert filament and send M108" #define STR_FILAMENT_CHANGE_WAIT_M108 "Send M108 to resume" -#define STR_STOP_BLTOUCH "!! STOP called because of BLTouch error - restart with M999" -#define STR_STOP_UNHOMED "!! STOP called because of unhomed error - restart with M999" -#define STR_KILL_INACTIVE_TIME "!! KILL caused by too much inactive time - current command: " -#define STR_KILL_BUTTON "!! KILL caused by KILL button/pin" +#define STR_STOP_PRE "!! STOP called because of " +#define STR_STOP_POST " error - restart with M999" +#define STR_STOP_BLTOUCH "BLTouch" +#define STR_STOP_UNHOMED "unhomed" +#define STR_KILL_PRE "!! KILL caused by " +#define STR_KILL_INACTIVE_TIME "too much inactive time - current command: " +#define STR_KILL_BUTTON "KILL button/pin" // temperature.cpp strings -#define STR_PID_AUTOTUNE_START "PID Autotune start" -#define STR_PID_BAD_HEATER_ID "PID Autotune failed! Bad heater id" -#define STR_PID_TEMP_TOO_HIGH "PID Autotune failed! Temperature too high" -#define STR_PID_TIMEOUT "PID Autotune failed! timeout" +#define STR_PID_AUTOTUNE "PID Autotune" +#define STR_PID_AUTOTUNE_START " start" +#define STR_PID_BAD_HEATER_ID " failed! Bad heater id" +#define STR_PID_TEMP_TOO_HIGH " failed! Temperature too high" +#define STR_PID_TIMEOUT " failed! timeout" #define STR_BIAS " bias: " #define STR_D_COLON " d: " #define STR_T_MIN " min: " @@ -218,7 +223,7 @@ #define STR_KP " Kp: " #define STR_KI " Ki: " #define STR_KD " Kd: " -#define STR_PID_AUTOTUNE_FINISHED "PID Autotune finished! Put the last Kp, Ki and Kd constants from below into Configuration.h" +#define STR_PID_AUTOTUNE_FINISHED " finished! Put the last Kp, Ki and Kd constants from below into Configuration.h" #define STR_PID_DEBUG " PID_DEBUG " #define STR_PID_DEBUG_INPUT ": Input " #define STR_PID_DEBUG_OUTPUT " Output " @@ -227,6 +232,14 @@ #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 +#define STR_MPC_AUTOTUNE_INTERRUPTED " interrupted!" +#define STR_MPC_AUTOTUNE_FINISHED " finished! Put the constants below into Configuration.h" +#define STR_MPC_COOLING_TO_AMBIENT "Cooling to ambient" +#define STR_MPC_HEATING_PAST_200 "Heating to over 200C" +#define STR_MPC_MEASURING_AMBIENT "Measuring ambient heatloss at " +#define STR_MPC_TEMPERATURE_ERROR "Temperature error" #define STR_HEATER_BED "bed" #define STR_HEATER_CHAMBER "chamber" @@ -240,6 +253,7 @@ #define STR_REDUNDANCY "Heater switched off. Temperature difference between temp sensors is too high !" #define STR_T_HEATING_FAILED "Heating failed" #define STR_T_THERMAL_RUNAWAY "Thermal Runaway" +#define STR_T_MALFUNCTION "Thermal Malfunction" #define STR_T_MAXTEMP "MAXTEMP triggered" #define STR_T_MINTEMP "MINTEMP triggered" #define STR_ERR_PROBING_FAILED "Probing Failed" @@ -253,7 +267,7 @@ #define STR_DEBUG_ERRORS "ERRORS" #define STR_DEBUG_DRYRUN "DRYRUN" #define STR_DEBUG_COMMUNICATION "COMMUNICATION" -#define STR_DEBUG_LEVELING "LEVELING" +#define STR_DEBUG_DETAIL "DETAIL" #define STR_PRINTER_LOCKED "Printer locked! (Unlock with M511 or LCD)" #define STR_WRONG_PASSWORD "Incorrect Password" @@ -301,10 +315,12 @@ #define STR_MATERIAL_HEATUP "Material heatup parameters" #define STR_LCD_CONTRAST "LCD Contrast" #define STR_LCD_BRIGHTNESS "LCD Brightness" +#define STR_DISPLAY_SLEEP "Display Sleep" #define STR_UI_LANGUAGE "UI Language" #define STR_Z_PROBE_OFFSET "Z-Probe Offset" #define STR_TEMPERATURE_UNITS "Temperature Units" #define STR_USER_THERMISTORS "User thermistors" +#define STR_DELAYED_POWEROFF "Delayed poweroff" // // Endstop Names used by Endstops::report_states @@ -340,9 +356,6 @@ #define STR_X "X" #define STR_Y "Y" #define STR_Z "Z" -#define STR_I AXIS4_STR -#define STR_J AXIS5_STR -#define STR_K AXIS6_STR #define STR_E "E" #if IS_KINEMATIC #define STR_A "A" @@ -359,115 +372,89 @@ #define STR_Z3 "Z3" #define STR_Z4 "Z4" -#define LCD_STR_A STR_A -#define LCD_STR_B STR_B -#define LCD_STR_C STR_C -#define LCD_STR_I STR_I -#define LCD_STR_J STR_J -#define LCD_STR_K STR_K -#define LCD_STR_E STR_E - // Extra Axis and Endstop Names -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #if AXIS4_NAME == 'A' - #define AXIS4_STR "A" + #define STR_I "A" #define STR_I_MIN "a_min" #define STR_I_MAX "a_max" #elif AXIS4_NAME == 'B' - #define AXIS4_STR "B" + #define STR_I "B" #define STR_I_MIN "b_min" #define STR_I_MAX "b_max" #elif AXIS4_NAME == 'C' - #define AXIS4_STR "C" + #define STR_I "C" #define STR_I_MIN "c_min" #define STR_I_MAX "c_max" #elif AXIS4_NAME == 'U' - #define AXIS4_STR "U" + #define STR_I "U" #define STR_I_MIN "u_min" #define STR_I_MAX "u_max" #elif AXIS4_NAME == 'V' - #define AXIS4_STR "V" + #define STR_I "V" #define STR_I_MIN "v_min" #define STR_I_MAX "v_max" #elif AXIS4_NAME == 'W' - #define AXIS4_STR "W" + #define STR_I "W" #define STR_I_MIN "w_min" #define STR_I_MAX "w_max" #else - #define AXIS4_STR "A" - #define STR_I_MIN "a_min" - #define STR_I_MAX "a_max" + #error "AXIS4_NAME can only be one of 'A', 'B', 'C', 'U', 'V', or 'W'." #endif #else - #define AXIS4_STR "" + #define STR_I "" #endif -#if LINEAR_AXES >= 5 - #if AXIS5_NAME == 'A' - #define AXIS5_STR "A" - #define STR_J_MIN "a_min" - #define STR_J_MAX "a_max" - #elif AXIS5_NAME == 'B' - #define AXIS5_STR "B" +#if HAS_J_AXIS + #if AXIS5_NAME == 'B' + #define STR_J "B" #define STR_J_MIN "b_min" #define STR_J_MAX "b_max" #elif AXIS5_NAME == 'C' - #define AXIS5_STR "C" + #define STR_J "C" #define STR_J_MIN "c_min" #define STR_J_MAX "c_max" #elif AXIS5_NAME == 'U' - #define AXIS5_STR "U" + #define STR_J "U" #define STR_J_MIN "u_min" #define STR_J_MAX "u_max" #elif AXIS5_NAME == 'V' - #define AXIS5_STR "V" + #define STR_J "V" #define STR_J_MIN "v_min" #define STR_J_MAX "v_max" #elif AXIS5_NAME == 'W' - #define AXIS5_STR "W" + #define STR_J "W" #define STR_J_MIN "w_min" #define STR_J_MAX "w_max" #else - #define AXIS5_STR "B" - #define STR_J_MIN "b_min" - #define STR_J_MAX "b_max" + #error "AXIS5_NAME can only be one of 'B', 'C', 'U', 'V', or 'W'." #endif #else - #define AXIS5_STR "" + #define STR_J "" #endif -#if LINEAR_AXES >= 6 - #if AXIS6_NAME == 'A' - #define AXIS6_STR "A" - #define STR_K_MIN "a_min" - #define STR_K_MAX "a_max" - #elif AXIS6_NAME == 'B' - #define AXIS6_STR "B" - #define STR_K_MIN "b_min" - #define STR_K_MAX "b_max" - #elif AXIS6_NAME == 'C' - #define AXIS6_STR "C" +#if HAS_K_AXIS + #if AXIS6_NAME == 'C' + #define STR_K "C" #define STR_K_MIN "c_min" #define STR_K_MAX "c_max" #elif AXIS6_NAME == 'U' - #define AXIS6_STR "U" + #define STR_K "U" #define STR_K_MIN "u_min" #define STR_K_MAX "u_max" #elif AXIS6_NAME == 'V' - #define AXIS6_STR "V" + #define STR_K "V" #define STR_K_MIN "v_min" #define STR_K_MAX "v_max" #elif AXIS6_NAME == 'W' - #define AXIS6_STR "W" + #define STR_K "W" #define STR_K_MIN "w_min" #define STR_K_MAX "w_max" #else - #define AXIS6_STR "C" - #define STR_K_MIN "c_min" - #define STR_K_MAX "c_max" + #error "AXIS6_NAME can only be one of 'C', 'U', 'V', or 'W'." #endif #else - #define AXIS6_STR "" + #define STR_K "" #endif #if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL) @@ -518,34 +505,34 @@ */ #if ENABLED(NUMBER_TOOLS_FROM_0) #define LCD_FIRST_TOOL 0 - #define LCD_STR_N0 "0" - #define LCD_STR_N1 "1" - #define LCD_STR_N2 "2" - #define LCD_STR_N3 "3" - #define LCD_STR_N4 "4" - #define LCD_STR_N5 "5" - #define LCD_STR_N6 "6" - #define LCD_STR_N7 "7" + #define STR_N0 "0" + #define STR_N1 "1" + #define STR_N2 "2" + #define STR_N3 "3" + #define STR_N4 "4" + #define STR_N5 "5" + #define STR_N6 "6" + #define STR_N7 "7" #else #define LCD_FIRST_TOOL 1 - #define LCD_STR_N0 "1" - #define LCD_STR_N1 "2" - #define LCD_STR_N2 "3" - #define LCD_STR_N3 "4" - #define LCD_STR_N4 "5" - #define LCD_STR_N5 "6" - #define LCD_STR_N6 "7" - #define LCD_STR_N7 "8" + #define STR_N0 "1" + #define STR_N1 "2" + #define STR_N2 "3" + #define STR_N3 "4" + #define STR_N4 "5" + #define STR_N5 "6" + #define STR_N6 "7" + #define STR_N7 "8" #endif -#define LCD_STR_E0 "E" LCD_STR_N0 -#define LCD_STR_E1 "E" LCD_STR_N1 -#define LCD_STR_E2 "E" LCD_STR_N2 -#define LCD_STR_E3 "E" LCD_STR_N3 -#define LCD_STR_E4 "E" LCD_STR_N4 -#define LCD_STR_E5 "E" LCD_STR_N5 -#define LCD_STR_E6 "E" LCD_STR_N6 -#define LCD_STR_E7 "E" LCD_STR_N7 +#define STR_E0 STR_E STR_N0 +#define STR_E1 STR_E STR_N1 +#define STR_E2 STR_E STR_N2 +#define STR_E3 STR_E STR_N3 +#define STR_E4 STR_E STR_N4 +#define STR_E5 STR_E STR_N5 +#define STR_E6 STR_E STR_N6 +#define STR_E7 STR_E STR_N7 // Include localized LCD Menu Messages diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 62675d131972..648307656e64 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -70,11 +70,11 @@ #define FORCE_INLINE __attribute__((always_inline)) inline #define NO_INLINE __attribute__((noinline)) #define _UNUSED __attribute__((unused)) -#define _O0 __attribute__((optimize("O0"))) -#define _Os __attribute__((optimize("Os"))) -#define _O1 __attribute__((optimize("O1"))) -#define _O2 __attribute__((optimize("O2"))) -#define _O3 __attribute__((optimize("O3"))) +#define __O0 __attribute__((optimize("O0"))) +#define __Os __attribute__((optimize("Os"))) +#define __O1 __attribute__((optimize("O1"))) +#define __O2 __attribute__((optimize("O2"))) +#define __O3 __attribute__((optimize("O3"))) #define IS_CONSTEXPR(...) __builtin_constant_p(__VA_ARGS__) // Only valid solution with C++14. Should use std::is_constant_evaluated() in C++20 instead @@ -131,13 +131,13 @@ #ifdef __cplusplus // C++11 solution that is standards compliant. - template static inline constexpr void NOLESS(V& v, const N n) { + template static constexpr void NOLESS(V& v, const N n) { if (n > v) v = n; } - template static inline constexpr void NOMORE(V& v, const N n) { + template static constexpr void NOMORE(V& v, const N n) { if (n < v) v = n; } - template static inline constexpr void LIMIT(V& v, const N1 n1, const N2 n2) { + template static constexpr void LIMIT(V& v, const N1 n1, const N2 n2) { if (n1 > v) v = n1; else if (n2 < v) v = n2; } @@ -235,6 +235,8 @@ #define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1' #define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B. +#define _OPTITEM(A...) A, +#define OPTITEM(O,A...) TERN_(O,DEFER4(_OPTITEM)(A)) #define _OPTARG(A...) , A #define OPTARG(O,A...) TERN_(O,DEFER4(_OPTARG)(A)) #define _OPTCODE(A) A; @@ -276,7 +278,7 @@ #define NUMERIC_SIGNED(a) (NUMERIC(a) || (a) == '-' || (a) == '+') #define DECIMAL_SIGNED(a) (DECIMAL(a) || (a) == '-' || (a) == '+') #define COUNT(a) (sizeof(a)/sizeof(*a)) -#define ZERO(a) memset(a,0,sizeof(a)) +#define ZERO(a) memset((void*)a,0,sizeof(a)) #define COPY(a,b) do{ \ static_assert(sizeof(a[0]) == sizeof(b[0]), "COPY: '" STRINGIFY(a) "' and '" STRINGIFY(b) "' types (sizes) don't match!"); \ memcpy(&a[0],&b[0],_MIN(sizeof(a),sizeof(b))); \ @@ -366,7 +368,7 @@ #undef ABS #ifdef __cplusplus - template static inline constexpr const T ABS(const T v) { return v >= 0 ? v : -v; } + template static constexpr const T ABS(const T v) { return v >= 0 ? v : -v; } #else #define ABS(a) ({__typeof__(a) _a = (a); _a >= 0 ? _a : -_a;}) #endif @@ -409,14 +411,14 @@ extern "C++" { // C++11 solution that is standards compliant. Return type is deduced automatically - template static inline constexpr auto _MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) { + template static constexpr auto _MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) { return lhs < rhs ? lhs : rhs; } - template static inline constexpr auto _MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) { + template static constexpr auto _MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) { return lhs > rhs ? lhs : rhs; } - template static inline constexpr const T _MIN(T V, Ts... Vs) { return _MIN(V, _MIN(Vs...)); } - template static inline constexpr const T _MAX(T V, Ts... Vs) { return _MAX(V, _MAX(Vs...)); } + template static constexpr const T _MIN(T V, Ts... Vs) { return _MIN(V, _MIN(Vs...)); } + template static constexpr const T _MAX(T V, Ts... Vs) { return _MAX(V, _MAX(Vs...)); } } diff --git a/Marlin/src/core/multi_language.h b/Marlin/src/core/multi_language.h index 2106f946ac73..05a713e435de 100644 --- a/Marlin/src/core/multi_language.h +++ b/Marlin/src/core/multi_language.h @@ -45,6 +45,7 @@ typedef const char Language_Str[]; // Set unused languages equal to each other so the // compiler can optimize away the conditionals. +#define LCD_LANGUAGE_1 LCD_LANGUAGE #ifndef LCD_LANGUAGE_2 #define LCD_LANGUAGE_2 LCD_LANGUAGE #endif @@ -80,6 +81,9 @@ typedef const char Language_Str[]; #endif #define GET_TEXT_F(MSG) FPSTR(GET_TEXT(MSG)) +#define GET_EN_TEXT(MSG) GET_LANG(en)::MSG +#define GET_EN_TEXT_F(MSG) FPSTR(GET_EN_TEXT(MSG)) + #define GET_LANGUAGE_NAME(INDEX) GET_LANG(LCD_LANGUAGE_##INDEX)::LANGUAGE #define LANG_CHARSIZE GET_TEXT(CHARSIZE) #define USE_WIDE_GLYPH (LANG_CHARSIZE > 2) diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 9cd862df702c..562cddbaa07a 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -36,10 +36,10 @@ PGMSTR(X_LBL, "X:"); PGMSTR(Y_LBL, "Y:"); PGMSTR(Z_LBL, "Z:"); PGMST PGMSTR(SP_A_STR, " A"); PGMSTR(SP_B_STR, " B"); PGMSTR(SP_C_STR, " C"); PGMSTR(SP_X_STR, " X"); PGMSTR(SP_Y_STR, " Y"); PGMSTR(SP_Z_STR, " Z"); PGMSTR(SP_E_STR, " E"); PGMSTR(SP_X_LBL, " X:"); PGMSTR(SP_Y_LBL, " Y:"); PGMSTR(SP_Z_LBL, " Z:"); PGMSTR(SP_E_LBL, " E:"); -PGMSTR(I_STR, AXIS4_STR); PGMSTR(J_STR, AXIS5_STR); PGMSTR(K_STR, AXIS6_STR); -PGMSTR(I_LBL, AXIS4_STR ":"); PGMSTR(J_LBL, AXIS5_STR ":"); PGMSTR(K_LBL, AXIS6_STR ":"); -PGMSTR(SP_I_STR, " " AXIS4_STR); PGMSTR(SP_J_STR, " " AXIS5_STR); PGMSTR(SP_K_STR, " " AXIS6_STR); -PGMSTR(SP_I_LBL, " " AXIS4_STR ":"); PGMSTR(SP_J_LBL, " " AXIS5_STR ":"); PGMSTR(SP_K_LBL, " " AXIS6_STR ":"); +PGMSTR(I_STR, STR_I); PGMSTR(J_STR, STR_J); PGMSTR(K_STR, STR_K); +PGMSTR(I_LBL, STR_I ":"); PGMSTR(J_LBL, STR_J ":"); PGMSTR(K_LBL, STR_K ":"); +PGMSTR(SP_I_STR, " " STR_I); PGMSTR(SP_J_STR, " " STR_J); PGMSTR(SP_K_STR, " " STR_K); +PGMSTR(SP_I_LBL, " " STR_I ":"); PGMSTR(SP_J_LBL, " " STR_J ":"); PGMSTR(SP_K_LBL, " " STR_K ":"); // Hook Meatpack if it's enabled on the first leaf #if ENABLED(MEATPACK_ON_SERIAL_PORT_1) @@ -78,6 +78,14 @@ void serial_error_start() { static PGMSTR(errormagic, "Error:"); serial_print_P( void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); } +void serial_offset(const_float_t v, const uint8_t sp/*=0*/) { + if (v == 0 && sp == 1) + SERIAL_CHAR(' '); + else if (v > 0 || (v == 0 && sp == 2)) + SERIAL_CHAR('+'); + 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); diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index aee4d4d43db8..98e82b6d7281 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -345,6 +345,7 @@ void serialprint_onoff(const bool onoff); void serialprintln_onoff(const bool onoff); void serialprint_truefalse(const bool tf); void serial_spaces(uint8_t count); +void serial_offset(const_float_t v, const uint8_t sp=0); // For v==0 draw space (sp==1) or plus (sp==2) void print_bin(const uint16_t val); void print_pos(LINEAR_AXIS_ARGS(const_float_t), FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr); diff --git a/Marlin/src/core/serial_hook.h b/Marlin/src/core/serial_hook.h index 2019b389e497..3972279452ef 100644 --- a/Marlin/src/core/serial_hook.h +++ b/Marlin/src/core/serial_hook.h @@ -37,7 +37,7 @@ class SerialMask { inline constexpr bool enabled(const SerialMask PortMask) const { return mask & PortMask.mask; } inline constexpr SerialMask combine(const SerialMask other) const { return SerialMask(mask | other.mask); } inline constexpr SerialMask operator<< (const int offset) const { return SerialMask(mask << offset); } - static inline SerialMask from(const serial_index_t index) { + static SerialMask from(const serial_index_t index) { if (index.valid()) return SerialMask(_BV(index.index)); return SerialMask(0); // A invalid index mean no output } @@ -298,7 +298,7 @@ struct MultiSerial : public SerialBase< MultiSerial< REPEAT(NUM_SERIAL, _S_NAME) // Build the actual serial object depending on current configuration #define Serial1Class TERN(SERIAL_RUNTIME_HOOK, RuntimeSerial, BaseSerial) #define ForwardSerial1Class TERN(SERIAL_RUNTIME_HOOK, RuntimeSerial, ForwardSerial) -#ifdef HAS_MULTI_SERIAL +#if HAS_MULTI_SERIAL #define Serial2Class ConditionalSerial #if NUM_SERIAL >= 3 #define Serial3Class ConditionalSerial diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 9a5b64c22e86..855502458bbb 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -52,7 +52,7 @@ struct IF { typedef L type; }; #define LOGICAL_AXIS_ELEM(O) LOGICAL_AXIS_LIST(O.e, O.x, O.y, O.z, O.i, O.j, O.k) #define LOGICAL_AXIS_DECL(T,V) LOGICAL_AXIS_LIST(T e=V, T x=V, T y=V, T z=V, T i=V, T j=V, T k=V) -#define LOGICAL_AXES_STRING LOGICAL_AXIS_GANG("E", "X", "Y", "Z", AXIS4_STR, AXIS5_STR, AXIS6_STR) +#define LOGICAL_AXES_STRING LOGICAL_AXIS_GANG("E", "X", "Y", "Z", STR_I, STR_J, STR_K) #if HAS_EXTRUDERS #define LIST_ITEM_E(N) , N @@ -64,6 +64,61 @@ struct IF { typedef L type; }; #define GANG_ITEM_E(N) #endif +#define AXIS_COLLISION(L) (AXIS4_NAME == L || AXIS5_NAME == L || AXIS6_NAME == L) + +// General Flags for some number of states +template +struct Flags { + typedef typename IF<(N>8), uint16_t, uint8_t>::type bits_t; + typedef struct { bool b0:1, b1:1, b2:1, b3:1, b4:1, b5:1, b6:1, b7:1; } N8; + typedef struct { bool b0:1, b1:1, b2:1, b3:1, b4:1, b5:1, b6:1, b7:1, b8:1, b9:1, b10:1, b11:1, b12:1, b13:1, b14:1, b15:1; } N16; + union { + bits_t b; + typename IF<(N>8), N16, N8>::type flag; + }; + void reset() { b = 0; } + void set(const int n, const bool onoff) { onoff ? set(n) : clear(n); } + void set(const int n) { b |= (bits_t)_BV(n); } + void clear(const int n) { b &= ~(bits_t)_BV(n); } + bool test(const int n) const { return TEST(b, n); } + bool operator[](const int n) { return test(n); } + const bool operator[](const int n) const { return test(n); } + const int size() const { return sizeof(b); } +}; + +// Specialization for a single bool flag +template<> +struct Flags<1> { + bool b; + void reset() { b = false; } + void set(const int n, const bool onoff) { onoff ? set(n) : clear(n); } + 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; } + const bool operator[](const int) const { return b; } + const int size() const { return sizeof(b); } +}; + +typedef Flags<8> flags_8_t; +typedef Flags<16> flags_16_t; + +// Flags for some axis states, with per-axis aliases xyzijkuvwe +typedef struct AxisFlags { + union { + struct Flags flags; + struct { bool LOGICAL_AXIS_LIST(e:1, x:1, y:1, z:1, i:1, j:1, k:1, u:1, v:1, w:1); }; + }; + void reset() { flags.reset(); } + void set(const int n) { flags.set(n); } + void set(const int n, const bool onoff) { flags.set(n, onoff); } + void clear(const int n) { flags.clear(n); } + bool test(const int n) const { return flags.test(n); } + bool operator[](const int n) { return flags[n]; } + const bool operator[](const int n) const { return flags[n]; } + const int size() const { return sizeof(flags); } +} axis_flags_t; + // // Enumerated axis indices // @@ -96,10 +151,10 @@ enum AxisEnum : uint8_t { // A, B, and C are for DELTA, SCARA, etc. , A_AXIS = X_AXIS - #if LINEAR_AXES >= 2 + #if HAS_Y_AXIS , B_AXIS = Y_AXIS #endif - #if LINEAR_AXES >= 3 + #if HAS_Z_AXIS , C_AXIS = Z_AXIS #endif @@ -116,6 +171,7 @@ typedef IF<(NUM_AXIS_ENUMS > 8), uint16_t, uint8_t>::type axis_bits_t; #define LOOP_LINEAR_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, LINEAR_AXES) #define LOOP_LOGICAL_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, LOGICAL_AXES) #define LOOP_DISTINCT_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, DISTINCT_AXES) +#define LOOP_DISTINCT_E(VAR) LOOP_L_N(VAR, DISTINCT_E) // // feedRate_t is just a humble float @@ -126,6 +182,7 @@ typedef float feedRate_t; // celsius_t is the native unit of temperature. Signed to handle a disconnected thermistor value (-14). // For more resolition (e.g., for a chocolate printer) this may later be changed to Celsius x 100 // +typedef uint16_t raw_adc_t; typedef int16_t celsius_t; typedef float celsius_float_t; @@ -406,13 +463,13 @@ struct XYZval { FI void set(const T (&arr)[DISTINCT_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5]); } #endif #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; } #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS FI void set(const T px, const T py, const T pz, const T pi, const T pj) { x = px; y = py; z = pz; i = pi; j = pj; } #endif @@ -534,28 +591,30 @@ struct XYZEval { // Reset all to 0 FI void reset() { LOGICAL_AXIS_GANG(e =, x =, y =, z =, i =, j =, k =) 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; } + #if HAS_I_AXIS + FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } + #endif + #if HAS_J_AXIS + FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; } + #endif + #if HAS_K_AXIS + FI void set(const T px, const T py, const T pz, const T pi, const T pj) { x = px; y = py; z = pz; i = pi; j = pj; } + #endif // 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 XYZval pxyz) { set(LINEAR_AXIS_ELEM(pxyz)); } + FI void set(const XYval pxy) { x = pxy.x; y = pxy.y; } + FI void set(const XYZval pxyz) { set(LINEAR_AXIS_ELEM(pxyz)); } #if HAS_Z_AXIS FI void set(LINEAR_AXIS_ARGS(const T)) { LINEAR_AXIS_CODE(a = x, b = y, c = z, u = i, v = j, w = k); } #endif + FI void set(const XYval pxy, const T pz) { set(pxy); TERN_(HAS_Z_AXIS, z = pz); } #if LOGICAL_AXES > LINEAR_AXES - FI void set(const XYval pxy, const T pe) { set(pxy); e = pe; } + 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, u = i, v = j, w = k); } #endif - #if LINEAR_AXES >= 4 - FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } - #endif - #if LINEAR_AXES >= 5 - FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; } - #endif - #if LINEAR_AXES >= 6 - FI void set(const T px, const T py, const T pz, const T pi, const T pj) { x = px; y = py; z = pz; i = pi; j = pj; } - #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)); } diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index cc3b1ace2fdb..7d33c25c3c43 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -74,7 +74,8 @@ void safe_delay(millis_t ms) { TERN_(Z_PROBE_SLED, "Z_PROBE_SLED") TERN_(Z_PROBE_ALLEN_KEY, "Z_PROBE_ALLEN_KEY") TERN_(SOLENOID_PROBE, "SOLENOID_PROBE") - TERN(PROBE_SELECTED, "", "NONE") + TERN_(MAGLEV4, "MAGLEV4") + IF_DISABLED(PROBE_SELECTED, "NONE") ); #if HAS_BED_PROBE @@ -125,19 +126,16 @@ void safe_delay(millis_t ms) { #if ABL_PLANAR SERIAL_ECHOPGM("ABL Adjustment"); LOOP_LINEAR_AXES(a) { - const float v = planner.get_axis_position_mm(AxisEnum(a)) - current_position[a]; SERIAL_CHAR(' ', AXIS_CHAR(a)); - if (v > 0) SERIAL_CHAR('+'); - SERIAL_DECIMAL(v); + serial_offset(planner.get_axis_position_mm(AxisEnum(a)) - current_position[a]); } #else #if ENABLED(AUTO_BED_LEVELING_UBL) SERIAL_ECHOPGM("UBL Adjustment Z"); - const float rz = ubl.get_z_correction(current_position); #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) SERIAL_ECHOPGM("ABL Adjustment Z"); - const float rz = bilinear_z_offset(current_position); #endif + const float rz = bedlevel.get_z_correction(current_position); SERIAL_ECHO(ftostr43sign(rz, '+')); #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) if (planner.z_fade_height) { @@ -157,11 +155,13 @@ void safe_delay(millis_t ms) { SERIAL_ECHOPGM("Mesh Bed Leveling"); if (planner.leveling_active) { SERIAL_ECHOLNPGM(" (enabled)"); - SERIAL_ECHOPGM("MBL Adjustment Z", ftostr43sign(mbl.get_z(current_position), '+')); + const float z_offset = bedlevel.get_z_offset(), + z_correction = bedlevel.get_z_correction(current_position); + SERIAL_ECHOPGM("MBL Adjustment Z", ftostr43sign(z_offset + z_correction, '+')); #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) if (planner.z_fade_height) { SERIAL_ECHOPGM(" (", ftostr43sign( - mbl.get_z(current_position, planner.fade_scaling_factor_for_z(current_position.z)), '+' + z_offset + z_correction * planner.fade_scaling_factor_for_z(current_position.z), '+' )); SERIAL_CHAR(')'); } diff --git a/Marlin/src/feature/adc/adc_mcp3426.cpp b/Marlin/src/feature/adc/adc_mcp3426.cpp index aaddf46821b0..49bb67ef6d5c 100644 --- a/Marlin/src/feature/adc/adc_mcp3426.cpp +++ b/Marlin/src/feature/adc/adc_mcp3426.cpp @@ -34,7 +34,7 @@ #include "adc_mcp3426.h" // Read the ADC value from MCP342X on a specific channel -int16_t MCP3426::ReadValue(uint8_t channel, uint8_t gain) { +int16_t MCP3426::ReadValue(uint8_t channel, uint8_t gain, uint8_t address) { Error = false; #if PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM) @@ -44,7 +44,7 @@ int16_t MCP3426::ReadValue(uint8_t channel, uint8_t gain) { Wire.begin(); // No address joins the BUS as the master - Wire.beginTransmission(I2C_ADDRESS(MCP342X_ADC_I2C_ADDRESS)); + Wire.beginTransmission(I2C_ADDRESS(address)); // Continuous Conversion Mode, 16 bit, Channel 1, Gain x4 // 26 = 0b00011000 @@ -75,7 +75,7 @@ int16_t MCP3426::ReadValue(uint8_t channel, uint8_t gain) { uint8_t buffer[len] = {}; do { - Wire.requestFrom(I2C_ADDRESS(MCP342X_ADC_I2C_ADDRESS), len); + Wire.requestFrom(I2C_ADDRESS(address), len); if (Wire.available() != len) { Error = true; return 0; diff --git a/Marlin/src/feature/adc/adc_mcp3426.h b/Marlin/src/feature/adc/adc_mcp3426.h index 35458716b975..af48593369e1 100644 --- a/Marlin/src/feature/adc/adc_mcp3426.h +++ b/Marlin/src/feature/adc/adc_mcp3426.h @@ -29,12 +29,9 @@ #include #include -// Address of MCP342X chip -#define MCP342X_ADC_I2C_ADDRESS 104 - class MCP3426 { public: - int16_t ReadValue(uint8_t channel, uint8_t gain); + int16_t ReadValue(uint8_t channel, uint8_t gain, uint8_t address); bool Error; }; diff --git a/Marlin/src/feature/babystep.h b/Marlin/src/feature/babystep.h index f8037678ca16..5693afb4fc5b 100644 --- a/Marlin/src/feature/babystep.h +++ b/Marlin/src/feature/babystep.h @@ -54,7 +54,7 @@ class Babystep { #if ENABLED(BABYSTEP_DISPLAY_TOTAL) static int16_t axis_total[BS_TOTAL_IND(Z_AXIS) + 1]; // Total babysteps since G28 - static inline void reset_total(const AxisEnum axis) { + static void reset_total(const AxisEnum axis) { if (TERN1(BABYSTEP_XY, axis == Z_AXIS)) axis_total[BS_TOTAL_IND(axis)] = 0; } @@ -63,7 +63,7 @@ class Babystep { static void add_steps(const AxisEnum axis, const int16_t distance); static void add_mm(const AxisEnum axis, const_float_t mm); - static inline bool has_steps() { + static bool has_steps() { return steps[BS_AXIS_IND(X_AXIS)] || steps[BS_AXIS_IND(Y_AXIS)] || steps[BS_AXIS_IND(Z_AXIS)]; } @@ -71,7 +71,7 @@ class Babystep { // Called by the Temperature or Stepper ISR to // apply accumulated babysteps to the axes. // - static inline void task() { + static void task() { LOOP_LE_N(i, BS_AXIS_IND(Z_AXIS)) step_axis(BS_AXIS(i)); } diff --git a/Marlin/src/feature/backlash.cpp b/Marlin/src/feature/backlash.cpp index 24c0f2ca0c15..84382cf85680 100644 --- a/Marlin/src/feature/backlash.cpp +++ b/Marlin/src/feature/backlash.cpp @@ -29,6 +29,9 @@ #include "../module/motion.h" #include "../module/planner.h" +axis_bits_t Backlash::last_direction_bits; +xyz_long_t Backlash::residual_error{0}; + #ifdef BACKLASH_DISTANCE_MM #if ENABLED(BACKLASH_GCODE) xyz_float_t Backlash::distance_mm = BACKLASH_DISTANCE_MM; @@ -38,7 +41,7 @@ #endif #if ENABLED(BACKLASH_GCODE) - uint8_t Backlash::correction = (BACKLASH_CORRECTION) * 0xFF; + uint8_t Backlash::correction = (BACKLASH_CORRECTION) * all_on; #ifdef BACKLASH_SMOOTHING_MM float Backlash::smoothing_mm = BACKLASH_SMOOTHING_MM; #endif @@ -61,7 +64,6 @@ Backlash backlash; */ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const axis_bits_t dm, block_t * const block) { - static axis_bits_t last_direction_bits; axis_bits_t changed_dir = last_direction_bits ^ dm; // Ignore direction change unless steps are taken in that direction #if DISABLED(CORE_BACKLASH) || EITHER(MARKFORGED_XY, MARKFORGED_YX) @@ -83,7 +85,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const #endif last_direction_bits ^= changed_dir; - if (correction == 0) return; + if (!correction && !residual_error) return; #ifdef BACKLASH_SMOOTHING_MM // The segment proportion is a value greater than 0.0 indicating how much residual_error @@ -91,39 +93,28 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const // smoothing distance. Since the computation of this proportion involves a floating point // division, defer computation until needed. float segment_proportion = 0; - - // Residual error carried forward across multiple segments, so correction can be applied - // to segments where there is no direction change. - static xyz_long_t residual_error{0}; - #else - // No direction change, no correction. - if (!changed_dir) return; - // No leftover residual error from segment to segment - xyz_long_t residual_error{0}; #endif - const float f_corr = float(correction) / 255.0f; + const float f_corr = float(correction) / all_on; LOOP_LINEAR_AXES(axis) { if (distance_mm[axis]) { - const bool reversing = TEST(dm,axis); + const bool reverse = TEST(dm, axis); // When an axis changes direction, add axis backlash to the residual error if (TEST(changed_dir, axis)) - residual_error[axis] += (reversing ? -f_corr : f_corr) * distance_mm[axis] * planner.settings.axis_steps_per_mm[axis]; + residual_error[axis] += (reverse ? -f_corr : f_corr) * distance_mm[axis] * planner.settings.axis_steps_per_mm[axis]; // Decide how much of the residual error to correct in this segment int32_t error_correction = residual_error[axis]; + if (reverse != (error_correction < 0)) + error_correction = 0; // Don't take up any backlash in this segment, as it would subtract steps + #ifdef BACKLASH_SMOOTHING_MM if (error_correction && smoothing_mm != 0) { - // Take up a portion of the residual_error in this segment, but only when - // the current segment travels in the same direction as the correction - if (reversing == (error_correction < 0)) { - if (segment_proportion == 0) segment_proportion = _MIN(1.0f, block->millimeters / smoothing_mm); - error_correction = CEIL(segment_proportion * error_correction); - } - else - error_correction = 0; // Don't take up any backlash in this segment, as it would subtract steps + // Take up a portion of the residual_error in this segment + if (segment_proportion == 0) segment_proportion = _MIN(1.0f, block->millimeters / smoothing_mm); + error_correction = CEIL(segment_proportion * error_correction); } #endif @@ -153,6 +144,52 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const } } +int32_t Backlash::get_applied_steps(const AxisEnum axis) { + if (axis >= LINEAR_AXES) return 0; + + const bool reverse = TEST(last_direction_bits, axis); + + const int32_t residual_error_axis = residual_error[axis]; + + // At startup it is assumed the last move was forwards. So the applied + // steps will always be a non-positive number. + + if (!reverse) return -residual_error_axis; + + const float f_corr = float(correction) / all_on; + const int32_t full_error_axis = -f_corr * distance_mm[axis] * planner.settings.axis_steps_per_mm[axis]; + return full_error_axis - residual_error_axis; +} + +class Backlash::StepAdjuster { + xyz_long_t applied_steps; +public: + StepAdjuster() { + LOOP_LINEAR_AXES(axis) applied_steps[axis] = backlash.get_applied_steps((AxisEnum)axis); + } + ~StepAdjuster() { + // after backlash compensation parameter changes, ensure applied step count does not change + LOOP_LINEAR_AXES(axis) residual_error[axis] += backlash.get_applied_steps((AxisEnum)axis) - applied_steps[axis]; + } +}; + +void Backlash::set_correction_uint8(const uint8_t v) { + StepAdjuster adjuster; + correction = v; +} + +void Backlash::set_distance_mm(const AxisEnum axis, const float v) { + StepAdjuster adjuster; + distance_mm[axis] = v; +} + +#ifdef BACKLASH_SMOOTHING_MM + void Backlash::set_smoothing_mm(const float v) { + StepAdjuster adjuster; + smoothing_mm = v; + } +#endif + #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) #include "../module/probe.h" diff --git a/Marlin/src/feature/backlash.h b/Marlin/src/feature/backlash.h index 4d4e2940382c..0bace526e53f 100644 --- a/Marlin/src/feature/backlash.h +++ b/Marlin/src/feature/backlash.h @@ -24,21 +24,22 @@ #include "../inc/MarlinConfigPre.h" #include "../module/planner.h" -constexpr uint8_t all_on = 0xFF, all_off = 0x00; - class Backlash { public: + static constexpr uint8_t all_on = 0xFF, all_off = 0x00; + +private: + static axis_bits_t last_direction_bits; + static xyz_long_t residual_error; + #if ENABLED(BACKLASH_GCODE) - static xyz_float_t distance_mm; static uint8_t correction; + static xyz_float_t distance_mm; #ifdef BACKLASH_SMOOTHING_MM static float smoothing_mm; #endif - - static inline void set_correction(const_float_t v) { correction = _MAX(0, _MIN(1.0, v)) * all_on; } - static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; } #else - static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF; + static constexpr uint8_t correction = (BACKLASH_CORRECTION) * all_on; static const xyz_float_t distance_mm; #ifdef BACKLASH_SMOOTHING_MM static constexpr float smoothing_mm = BACKLASH_SMOOTHING_MM; @@ -46,14 +47,14 @@ class Backlash { #endif #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) - private: - static xyz_float_t measured_mm; - static xyz_uint8_t measured_count; - public: - static void measure_with_probe(); + static xyz_float_t measured_mm; + static xyz_uint8_t measured_count; #endif - static inline float get_measurement(const AxisEnum a) { + class StepAdjuster; + +public: + static float get_measurement(const AxisEnum a) { UNUSED(a); // Return the measurement averaged over all readings return TERN(MEASURE_BACKLASH_WHEN_PROBING @@ -62,16 +63,34 @@ class Backlash { ); } - static inline bool has_measurement(const AxisEnum a) { + static bool has_measurement(const AxisEnum a) { UNUSED(a); return TERN0(MEASURE_BACKLASH_WHEN_PROBING, measured_count[a] > 0); } - static inline bool has_any_measurement() { + static bool has_any_measurement() { return has_measurement(X_AXIS) || has_measurement(Y_AXIS) || has_measurement(Z_AXIS); } - void add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const axis_bits_t dm, block_t * const block); + static void add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const axis_bits_t dm, block_t * const block); + static int32_t get_applied_steps(const AxisEnum axis); + + #if ENABLED(BACKLASH_GCODE) + static void set_correction_uint8(const uint8_t v); + static uint8_t get_correction_uint8() { return correction; } + static void set_correction(const float v) { set_correction_uint8(_MAX(0, _MIN(1.0, v)) * all_on + 0.5f); } + static float get_correction() { return float(get_correction_uint8()) / all_on; } + static void set_distance_mm(const AxisEnum axis, const float v); + static float get_distance_mm(const AxisEnum axis) {return distance_mm[axis];} + #ifdef BACKLASH_SMOOTHING_MM + static void set_smoothing_mm(const float v); + static float get_smoothing_mm() {return smoothing_mm;} + #endif + #endif + + #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) + static void measure_with_probe(); + #endif }; extern Backlash backlash; diff --git a/Marlin/src/feature/bedlevel/abl/abl.h b/Marlin/src/feature/bedlevel/abl/abl.h deleted file mode 100644 index 3d54c55695e8..000000000000 --- a/Marlin/src/feature/bedlevel/abl/abl.h +++ /dev/null @@ -1,45 +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/MarlinConfigPre.h" - -extern xy_pos_t bilinear_grid_spacing, bilinear_start; -extern xy_float_t bilinear_grid_factor; -extern bed_mesh_t z_values; -float bilinear_z_offset(const xy_pos_t &raw); - -void extrapolate_unprobed_bed_level(); -void print_bilinear_leveling_grid(); -void refresh_bed_level(); -#if ENABLED(ABL_BILINEAR_SUBDIVISION) - void print_bilinear_leveling_grid_virt(); - void bed_level_virt_interpolate(); -#endif - -#if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES) - void bilinear_line_to_destination(const_feedRate_t scaled_fr_mm_s, uint16_t x_splits=0xFFFF, uint16_t y_splits=0xFFFF); -#endif - -#define _GET_MESH_X(I) float(bilinear_start.x + (I) * bilinear_grid_spacing.x) -#define _GET_MESH_Y(J) float(bilinear_start.y + (J) * bilinear_grid_spacing.y) -#define Z_VALUES_ARR z_values diff --git a/Marlin/src/feature/bedlevel/abl/abl.cpp b/Marlin/src/feature/bedlevel/abl/bbl.cpp similarity index 78% rename from Marlin/src/feature/bedlevel/abl/abl.cpp rename to Marlin/src/feature/bedlevel/abl/bbl.cpp index ece748198195..be0e862cc16a 100644 --- a/Marlin/src/feature/bedlevel/abl/abl.cpp +++ b/Marlin/src/feature/bedlevel/abl/bbl.cpp @@ -35,14 +35,19 @@ #include "../../../lcd/extui/ui_api.h" #endif -xy_pos_t bilinear_grid_spacing, bilinear_start; -xy_float_t bilinear_grid_factor; -bed_mesh_t z_values; +LevelingBilinear bedlevel; + +xy_pos_t LevelingBilinear::grid_spacing, + LevelingBilinear::grid_start; +xy_float_t LevelingBilinear::grid_factor; +bed_mesh_t LevelingBilinear::z_values; +xy_pos_t LevelingBilinear::cached_rel; +xy_int8_t LevelingBilinear::cached_g; /** * Extrapolate a single point from its neighbors */ -static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) { +void LevelingBilinear::extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) { if (!isnan(z_values[x][y])) return; if (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM("Extrapolate ["); @@ -92,11 +97,26 @@ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t #endif #endif +void LevelingBilinear::reset() { + grid_start.reset(); + grid_spacing.reset(); + GRID_LOOP(x, y) { + z_values[x][y] = NAN; + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, 0)); + } +} + +void LevelingBilinear::set_grid(const xy_pos_t& _grid_spacing, const xy_pos_t& _grid_start) { + grid_spacing = _grid_spacing; + grid_start = _grid_start; + grid_factor = grid_spacing.reciprocal(); +} + /** * Fill in the unprobed points (corners of circular print surface) * using linear extrapolation, away from the center. */ -void extrapolate_unprobed_bed_level() { +void LevelingBilinear::extrapolate_unprobed_bed_level() { #ifdef HALF_IN_X constexpr uint8_t ctrx2 = 0, xend = GRID_MAX_POINTS_X - 1; #else @@ -131,35 +151,31 @@ void extrapolate_unprobed_bed_level() { #endif extrapolate_one_point(x2, y2, -1, -1); // right-above - - } - } -void print_bilinear_leveling_grid() { +void LevelingBilinear::print_leveling_grid(const bed_mesh_t* _z_values /*= NULL*/) { + // print internal grid(s) or just the one passed as a parameter SERIAL_ECHOLNPGM("Bilinear Leveling Grid:"); - print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 3, - [](const uint8_t ix, const uint8_t iy) { return z_values[ix][iy]; } - ); + print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 3, _z_values ? *_z_values[0] : z_values[0]); + + #if ENABLED(ABL_BILINEAR_SUBDIVISION) + if (!_z_values) { + SERIAL_ECHOLNPGM("Subdivided with CATMULL ROM Leveling Grid:"); + print_2d_array(ABL_GRID_POINTS_VIRT_X, ABL_GRID_POINTS_VIRT_Y, 5, z_values_virt[0]); + } + #endif } #if ENABLED(ABL_BILINEAR_SUBDIVISION) - #define ABL_GRID_POINTS_VIRT_X GRID_MAX_CELLS_X * (BILINEAR_SUBDIVISIONS) + 1 - #define ABL_GRID_POINTS_VIRT_Y GRID_MAX_CELLS_Y * (BILINEAR_SUBDIVISIONS) + 1 #define ABL_TEMP_POINTS_X (GRID_MAX_POINTS_X + 2) #define ABL_TEMP_POINTS_Y (GRID_MAX_POINTS_Y + 2) - float z_values_virt[ABL_GRID_POINTS_VIRT_X][ABL_GRID_POINTS_VIRT_Y]; - xy_pos_t bilinear_grid_spacing_virt; - xy_float_t bilinear_grid_factor_virt; - - void print_bilinear_leveling_grid_virt() { - SERIAL_ECHOLNPGM("Subdivided with CATMULL ROM Leveling Grid:"); - print_2d_array(ABL_GRID_POINTS_VIRT_X, ABL_GRID_POINTS_VIRT_Y, 5, - [](const uint8_t ix, const uint8_t iy) { return z_values_virt[ix][iy]; } - ); - } + float LevelingBilinear::z_values_virt[ABL_GRID_POINTS_VIRT_X][ABL_GRID_POINTS_VIRT_Y]; + xy_pos_t LevelingBilinear::grid_spacing_virt; + xy_float_t LevelingBilinear::grid_factor_virt; #define LINEAR_EXTRAPOLATION(E, I) ((E) * 2 - (I)) - float bed_level_virt_coord(const uint8_t x, const uint8_t y) { + float LevelingBilinear::bed_level_virt_coord(const uint8_t x, const uint8_t y) { uint8_t ep = 0, ip = 1; if (x > (GRID_MAX_POINTS_X) + 1 || y > (GRID_MAX_POINTS_Y) + 1) { // The requested point requires extrapolating two points beyond the mesh. @@ -204,7 +220,7 @@ void print_bilinear_leveling_grid() { return z_values[x - 1][y - 1]; } - static float bed_level_virt_cmr(const float p[4], const uint8_t i, const float t) { + float LevelingBilinear::bed_level_virt_cmr(const float p[4], const uint8_t i, const float t) { return ( p[i-1] * -t * sq(1 - t) + p[i] * (2 - 5 * sq(t) + 3 * t * sq(t)) @@ -213,7 +229,7 @@ void print_bilinear_leveling_grid() { ) * 0.5f; } - static float bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty) { + float LevelingBilinear::bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty) { float row[4], column[4]; LOOP_L_N(i, 4) { LOOP_L_N(j, 4) { @@ -224,9 +240,9 @@ void print_bilinear_leveling_grid() { return bed_level_virt_cmr(row, 1, tx); } - void bed_level_virt_interpolate() { - bilinear_grid_spacing_virt = bilinear_grid_spacing / (BILINEAR_SUBDIVISIONS); - bilinear_grid_factor_virt = bilinear_grid_spacing_virt.reciprocal(); + void LevelingBilinear::bed_level_virt_interpolate() { + grid_spacing_virt = grid_spacing / (BILINEAR_SUBDIVISIONS); + grid_factor_virt = grid_spacing_virt.reciprocal(); LOOP_L_N(y, GRID_MAX_POINTS_Y) LOOP_L_N(x, GRID_MAX_POINTS_X) LOOP_L_N(ty, BILINEAR_SUBDIVISIONS) @@ -242,40 +258,42 @@ void print_bilinear_leveling_grid() { ); } } + #endif // ABL_BILINEAR_SUBDIVISION // Refresh after other values have been updated -void refresh_bed_level() { - bilinear_grid_factor = bilinear_grid_spacing.reciprocal(); +void LevelingBilinear::refresh_bed_level() { TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate()); + cached_rel.x = cached_rel.y = -999.999; + cached_g.x = cached_g.y = -99; } #if ENABLED(ABL_BILINEAR_SUBDIVISION) - #define ABL_BG_SPACING(A) bilinear_grid_spacing_virt.A - #define ABL_BG_FACTOR(A) bilinear_grid_factor_virt.A + #define ABL_BG_SPACING(A) grid_spacing_virt.A + #define ABL_BG_FACTOR(A) grid_factor_virt.A #define ABL_BG_POINTS_X ABL_GRID_POINTS_VIRT_X #define ABL_BG_POINTS_Y ABL_GRID_POINTS_VIRT_Y #define ABL_BG_GRID(X,Y) z_values_virt[X][Y] #else - #define ABL_BG_SPACING(A) bilinear_grid_spacing.A - #define ABL_BG_FACTOR(A) bilinear_grid_factor.A + #define ABL_BG_SPACING(A) grid_spacing.A + #define ABL_BG_FACTOR(A) grid_factor.A #define ABL_BG_POINTS_X GRID_MAX_POINTS_X #define ABL_BG_POINTS_Y GRID_MAX_POINTS_Y #define ABL_BG_GRID(X,Y) z_values[X][Y] #endif // Get the Z adjustment for non-linear bed leveling -float bilinear_z_offset(const xy_pos_t &raw) { +float LevelingBilinear::get_z_correction(const xy_pos_t &raw) { static float z1, d2, z3, d4, L, D; - static xy_pos_t prev { -999.999, -999.999 }, ratio; + static xy_pos_t ratio; // Whole units for the grid line indices. Constrained within bounds. - static xy_int8_t thisg, nextg, lastg { -99, -99 }; + static xy_int8_t thisg, nextg; // XY relative to the probed area - xy_pos_t rel = raw - bilinear_start.asFloat(); + xy_pos_t rel = raw - grid_start.asFloat(); #if ENABLED(EXTRAPOLATE_BEYOND_GRID) #define FAR_EDGE_OR_BOX 2 // Keep using the last grid box @@ -283,8 +301,8 @@ float bilinear_z_offset(const xy_pos_t &raw) { #define FAR_EDGE_OR_BOX 1 // Just use the grid far edge #endif - if (prev.x != rel.x) { - prev.x = rel.x; + if (cached_rel.x != rel.x) { + cached_rel.x = rel.x; ratio.x = rel.x * ABL_BG_FACTOR(x); const float gx = constrain(FLOOR(ratio.x), 0, ABL_BG_POINTS_X - (FAR_EDGE_OR_BOX)); ratio.x -= gx; // Subtract whole to get the ratio within the grid box @@ -298,10 +316,10 @@ float bilinear_z_offset(const xy_pos_t &raw) { nextg.x = _MIN(thisg.x + 1, ABL_BG_POINTS_X - 1); } - if (prev.y != rel.y || lastg.x != thisg.x) { + if (cached_rel.y != rel.y || cached_g.x != thisg.x) { - if (prev.y != rel.y) { - prev.y = rel.y; + if (cached_rel.y != rel.y) { + cached_rel.y = rel.y; ratio.y = rel.y * ABL_BG_FACTOR(y); const float gy = constrain(FLOOR(ratio.y), 0, ABL_BG_POINTS_Y - (FAR_EDGE_OR_BOX)); ratio.y -= gy; @@ -315,8 +333,8 @@ float bilinear_z_offset(const xy_pos_t &raw) { nextg.y = _MIN(thisg.y + 1, ABL_BG_POINTS_Y - 1); } - if (lastg != thisg) { - lastg = thisg; + if (cached_g != thisg) { + cached_g = thisg; // Z at the box corners z1 = ABL_BG_GRID(thisg.x, thisg.y); // left-front d2 = ABL_BG_GRID(thisg.x, nextg.y) - z1; // left-back (delta) @@ -336,8 +354,8 @@ float bilinear_z_offset(const xy_pos_t &raw) { /* static float last_offset = 0; if (ABS(last_offset - offset) > 0.2) { - SERIAL_ECHOLNPGM("Sudden Shift at x=", rel.x, " / ", bilinear_grid_spacing.x, " -> thisg.x=", thisg.x); - SERIAL_ECHOLNPGM(" y=", rel.y, " / ", bilinear_grid_spacing.y, " -> thisg.y=", thisg.y); + SERIAL_ECHOLNPGM("Sudden Shift at x=", rel.x, " / ", grid_spacing.x, " -> thisg.x=", thisg.x); + SERIAL_ECHOLNPGM(" y=", rel.y, " / ", grid_spacing.y, " -> thisg.y=", thisg.y); SERIAL_ECHOLNPGM(" ratio.x=", ratio.x, " ratio.y=", ratio.y); SERIAL_ECHOLNPGM(" z1=", z1, " z2=", z2, " z3=", z3, " z4=", z4); SERIAL_ECHOLNPGM(" L=", L, " R=", R, " offset=", offset); @@ -350,13 +368,13 @@ float bilinear_z_offset(const xy_pos_t &raw) { #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES) - #define CELL_INDEX(A,V) ((V - bilinear_start.A) * ABL_BG_FACTOR(A)) + #define CELL_INDEX(A,V) ((V - grid_start.A) * ABL_BG_FACTOR(A)) /** * Prepare a bilinear-leveled linear move on Cartesian, * splitting the move where it crosses grid borders. */ - void bilinear_line_to_destination(const_feedRate_t scaled_fr_mm_s, uint16_t x_splits, uint16_t y_splits) { + void LevelingBilinear::line_to_destination(const_feedRate_t scaled_fr_mm_s, uint16_t x_splits, uint16_t y_splits) { // Get current and destination cells for this line xy_int_t c1 { CELL_INDEX(x, current_position.x), CELL_INDEX(y, current_position.y) }, c2 { CELL_INDEX(x, destination.x), CELL_INDEX(y, destination.y) }; @@ -384,7 +402,7 @@ float bilinear_z_offset(const xy_pos_t &raw) { // Split on the X grid line CBI(x_splits, gc.x); end = destination; - destination.x = bilinear_start.x + ABL_BG_SPACING(x) * gc.x; + destination.x = grid_start.x + ABL_BG_SPACING(x) * gc.x; normalized_dist = (destination.x - current_position.x) / (end.x - current_position.x); destination.y = LINE_SEGMENT_END(y); } @@ -393,7 +411,7 @@ float bilinear_z_offset(const xy_pos_t &raw) { // Split on the Y grid line CBI(y_splits, gc.y); end = destination; - destination.y = bilinear_start.y + ABL_BG_SPACING(y) * gc.y; + destination.y = grid_start.y + ABL_BG_SPACING(y) * gc.y; normalized_dist = (destination.y - current_position.y) / (end.y - current_position.y); destination.x = LINE_SEGMENT_END(x); } @@ -409,11 +427,11 @@ float bilinear_z_offset(const xy_pos_t &raw) { destination.e = LINE_SEGMENT_END(e); // Do the split and look for more borders - bilinear_line_to_destination(scaled_fr_mm_s, x_splits, y_splits); + line_to_destination(scaled_fr_mm_s, x_splits, y_splits); // Restore destination from stack destination = end; - bilinear_line_to_destination(scaled_fr_mm_s, x_splits, y_splits); + line_to_destination(scaled_fr_mm_s, x_splits, y_splits); } #endif // IS_CARTESIAN && !SEGMENT_LEVELED_MOVES diff --git a/Marlin/src/feature/bedlevel/abl/bbl.h b/Marlin/src/feature/bedlevel/abl/bbl.h new file mode 100644 index 000000000000..c2be4fee821c --- /dev/null +++ b/Marlin/src/feature/bedlevel/abl/bbl.h @@ -0,0 +1,70 @@ +/** + * 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/MarlinConfigPre.h" + +class LevelingBilinear { +public: + static bed_mesh_t z_values; + static xy_pos_t grid_spacing, grid_start; + +private: + static xy_float_t grid_factor; + static xy_pos_t cached_rel; + static xy_int8_t cached_g; + + static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir); + + #if ENABLED(ABL_BILINEAR_SUBDIVISION) + #define ABL_GRID_POINTS_VIRT_X (GRID_MAX_CELLS_X * (BILINEAR_SUBDIVISIONS) + 1) + #define ABL_GRID_POINTS_VIRT_Y (GRID_MAX_CELLS_Y * (BILINEAR_SUBDIVISIONS) + 1) + + static float z_values_virt[ABL_GRID_POINTS_VIRT_X][ABL_GRID_POINTS_VIRT_Y]; + static xy_pos_t grid_spacing_virt; + static xy_float_t grid_factor_virt; + + static float bed_level_virt_coord(const uint8_t x, const uint8_t y); + static float bed_level_virt_cmr(const float p[4], const uint8_t i, const float t); + static float bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const_float_t tx, const_float_t ty); + static void bed_level_virt_interpolate(); + #endif + +public: + static void reset(); + static void set_grid(const xy_pos_t& _grid_spacing, const xy_pos_t& _grid_start); + static void extrapolate_unprobed_bed_level(); + static void print_leveling_grid(const bed_mesh_t* _z_values = NULL); + static void refresh_bed_level(); + static bool has_mesh() { return !!grid_spacing.x; } + static bool mesh_is_valid() { return has_mesh(); } + static float get_mesh_x(const uint8_t i) { return grid_start.x + i * grid_spacing.x; } + static float get_mesh_y(const uint8_t j) { return grid_start.y + j * grid_spacing.y; } + static float get_z_correction(const xy_pos_t &raw); + static constexpr float get_z_offset() { return 0.0f; } + + #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES) + static void line_to_destination(const_feedRate_t scaled_fr_mm_s, uint16_t x_splits=0xFFFF, uint16_t y_splits=0xFFFF); + #endif +}; + +extern LevelingBilinear bedlevel; diff --git a/Marlin/src/feature/bedlevel/bedlevel.cpp b/Marlin/src/feature/bedlevel/bedlevel.cpp index 8e03632de44d..1ca9696a3a30 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.cpp +++ b/Marlin/src/feature/bedlevel/bedlevel.cpp @@ -47,14 +47,11 @@ #endif bool leveling_is_valid() { - return TERN1(MESH_BED_LEVELING, mbl.has_mesh()) - && TERN1(AUTO_BED_LEVELING_BILINEAR, !!bilinear_grid_spacing.x) - && TERN1(AUTO_BED_LEVELING_UBL, ubl.mesh_is_valid()); + return TERN1(HAS_MESH, bedlevel.mesh_is_valid()); } /** - * Turn bed leveling on or off, fixing the current - * position as-needed. + * Turn bed leveling on or off, correcting the current position. * * Disable: Current position = physical position * Enable: Current position = "unleveled" physical position @@ -65,30 +62,25 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) { if (can_change && enable != planner.leveling_active) { + auto _report_leveling = []{ + if (DEBUGGING(LEVELING)) { + if (planner.leveling_active) + DEBUG_POS("Leveling ON", current_position); + else + DEBUG_POS("Leveling OFF", current_position); + } + }; + + _report_leveling(); planner.synchronize(); - #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - // Force bilinear_z_offset to re-calculate next time - const xyz_pos_t reset { -9999.999, -9999.999, 0 }; - (void)bilinear_z_offset(reset); - #endif - - if (planner.leveling_active) { // leveling from on to off - if (DEBUGGING(LEVELING)) DEBUG_POS("Leveling ON", current_position); - // change unleveled current_position to physical current_position without moving steppers. - planner.apply_leveling(current_position); - planner.leveling_active = false; // disable only AFTER calling apply_leveling - if (DEBUGGING(LEVELING)) DEBUG_POS("...Now OFF", current_position); - } - else { // leveling from off to on - if (DEBUGGING(LEVELING)) DEBUG_POS("Leveling OFF", current_position); - planner.leveling_active = true; // enable BEFORE calling unapply_leveling, otherwise ignored - // change physical current_position to unleveled current_position without moving steppers. - planner.unapply_leveling(current_position); - if (DEBUGGING(LEVELING)) DEBUG_POS("...Now ON", current_position); - } + // 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 sync_plan_position(); + _report_leveling(); } } @@ -122,23 +114,9 @@ TemporaryBedLevelingState::TemporaryBedLevelingState(const bool enable) : saved( */ void reset_bed_level() { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("reset_bed_level"); - #if ENABLED(AUTO_BED_LEVELING_UBL) - ubl.reset(); - #else - set_bed_leveling_enabled(false); - #if ENABLED(MESH_BED_LEVELING) - mbl.reset(); - #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) - bilinear_start.reset(); - bilinear_grid_spacing.reset(); - GRID_LOOP(x, y) { - z_values[x][y] = NAN; - TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, 0)); - } - #elif ABL_PLANAR - planner.bed_level_matrix.set_to_identity(); - #endif - #endif + IF_DISABLED(AUTO_BED_LEVELING_UBL, set_bed_leveling_enabled(false)); + TERN_(HAS_MESH, bedlevel.reset()); + TERN_(ABL_PLANAR, planner.bed_level_matrix.set_to_identity()); } #if EITHER(AUTO_BED_LEVELING_BILINEAR, MESH_BED_LEVELING) @@ -156,7 +134,7 @@ void reset_bed_level() { /** * Print calibration results for plotting or manual frame adjustment. */ - void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, element_2d_fn fn) { + void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, const float *values) { #ifndef SCAD_MESH_OUTPUT LOOP_L_N(x, sx) { serial_spaces(precision + (x < 10 ? 3 : 2)); @@ -176,7 +154,7 @@ void reset_bed_level() { #endif LOOP_L_N(x, sx) { SERIAL_CHAR(' '); - const float offset = fn(x, y); + const float offset = values[x * sx + y]; if (!isnan(offset)) { if (offset >= 0) SERIAL_CHAR('+'); SERIAL_ECHO_F(offset, int(precision)); diff --git a/Marlin/src/feature/bedlevel/bedlevel.h b/Marlin/src/feature/bedlevel/bedlevel.h index c623c99b5c52..aeafec10d6ab 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.h +++ b/Marlin/src/feature/bedlevel/bedlevel.h @@ -62,19 +62,13 @@ class TemporaryBedLevelingState { typedef float bed_mesh_t[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - #include "abl/abl.h" - #if ENABLED(X_AXIS_TWIST_COMPENSATION) - #include "abl/x_twist.h" - #endif + #include "abl/bbl.h" #elif ENABLED(AUTO_BED_LEVELING_UBL) #include "ubl/ubl.h" #elif ENABLED(MESH_BED_LEVELING) #include "mbl/mesh_bed_leveling.h" #endif - #define Z_VALUES(X,Y) Z_VALUES_ARR[X][Y] - #define _GET_MESH_POS(M) { _GET_MESH_X(M.a), _GET_MESH_Y(M.b) } - #if EITHER(AUTO_BED_LEVELING_BILINEAR, MESH_BED_LEVELING) #include @@ -84,7 +78,7 @@ class TemporaryBedLevelingState { /** * Print calibration results for plotting or manual frame adjustment. */ - void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, element_2d_fn fn); + void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, const float *values); #endif @@ -95,7 +89,7 @@ class TemporaryBedLevelingState { bool valid() const { return pos.x >= 0 && pos.y >= 0; } #if ENABLED(AUTO_BED_LEVELING_UBL) xy_pos_t meshpos() { - return { ubl.mesh_index_to_xpos(pos.x), ubl.mesh_index_to_ypos(pos.y) }; + return { bedlevel.get_mesh_x(pos.x), bedlevel.get_mesh_y(pos.y) }; } #endif operator xy_int8_t&() { return pos; } diff --git a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp index 51cf28f89005..193cbbf7654a 100644 --- a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp +++ b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.cpp @@ -32,7 +32,7 @@ #include "../../../lcd/extui/ui_api.h" #endif - mesh_bed_leveling mbl; + mesh_bed_leveling bedlevel; float mesh_bed_leveling::z_offset, mesh_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y], @@ -125,9 +125,7 @@ void mesh_bed_leveling::report_mesh() { SERIAL_ECHOPAIR_F(STRINGIFY(GRID_MAX_POINTS_X) "x" STRINGIFY(GRID_MAX_POINTS_Y) " mesh. Z offset: ", z_offset, 5); SERIAL_ECHOLNPGM("\nMeasured points:"); - print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 5, - [](const uint8_t ix, const uint8_t iy) { return z_values[ix][iy]; } - ); + print_2d_array(GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y, 5, z_values[0]); } #endif // MESH_BED_LEVELING diff --git a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h index cc5469577189..1a8e693e8180 100644 --- a/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h +++ b/Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h @@ -34,9 +34,6 @@ enum MeshLevelingState : char { #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 _GET_MESH_X(I) mbl.index_to_xpos[I] -#define _GET_MESH_Y(J) mbl.index_to_ypos[J] -#define Z_VALUES_ARR mbl.z_values class mesh_bed_leveling { public: @@ -56,9 +53,11 @@ class mesh_bed_leveling { return false; } + static bool mesh_is_valid() { return has_mesh(); } + static void set_z(const int8_t px, const int8_t py, const_float_t z) { z_values[px][py] = z; } - static inline void zigzag(const int8_t index, int8_t &px, int8_t &py) { + static void zigzag(const int8_t index, int8_t &px, int8_t &py) { px = index % (GRID_MAX_POINTS_X); py = index / (GRID_MAX_POINTS_X); if (py & 1) px = (GRID_MAX_POINTS_X) - 1 - px; // Zig zag @@ -70,6 +69,9 @@ class mesh_bed_leveling { set_z(px, py, z); } + static float get_mesh_x(const uint8_t i) { return index_to_xpos[i]; } + static float get_mesh_y(const uint8_t i) { return index_to_ypos[i]; } + static int8_t cell_index_x(const_float_t x) { int8_t cx = (x - (MESH_MIN_X)) * RECIPROCAL(MESH_X_DIST); return constrain(cx, 0, GRID_MAX_CELLS_X - 1); @@ -78,10 +80,10 @@ class mesh_bed_leveling { int8_t cy = (y - (MESH_MIN_Y)) * RECIPROCAL(MESH_Y_DIST); return constrain(cy, 0, GRID_MAX_CELLS_Y - 1); } - static inline xy_int8_t cell_indexes(const_float_t x, const_float_t y) { + static xy_int8_t cell_indexes(const_float_t x, const_float_t y) { return { cell_index_x(x), cell_index_y(y) }; } - static inline xy_int8_t cell_indexes(const xy_pos_t &xy) { return cell_indexes(xy.x, xy.y); } + static xy_int8_t cell_indexes(const xy_pos_t &xy) { return cell_indexes(xy.x, xy.y); } static int8_t probe_index_x(const_float_t x) { int8_t px = (x - (MESH_MIN_X) + 0.5f * (MESH_X_DIST)) * RECIPROCAL(MESH_X_DIST); @@ -91,10 +93,10 @@ class mesh_bed_leveling { int8_t py = (y - (MESH_MIN_Y) + 0.5f * (MESH_Y_DIST)) * RECIPROCAL(MESH_Y_DIST); return WITHIN(py, 0, (GRID_MAX_POINTS_Y) - 1) ? py : -1; } - static inline xy_int8_t probe_indexes(const_float_t x, const_float_t y) { + static xy_int8_t probe_indexes(const_float_t x, const_float_t y) { return { probe_index_x(x), probe_index_y(y) }; } - static inline xy_int8_t probe_indexes(const xy_pos_t &xy) { return probe_indexes(xy.x, xy.y); } + static xy_int8_t probe_indexes(const xy_pos_t &xy) { return probe_indexes(xy.x, xy.y); } static float calc_z0(const_float_t a0, const_float_t a1, const_float_t z1, const_float_t a2, const_float_t z2) { const float delta_z = (z2 - z1) / (a2 - a1), @@ -102,12 +104,9 @@ class mesh_bed_leveling { return z1 + delta_a * delta_z; } - static float get_z(const xy_pos_t &pos - OPTARG(ENABLE_LEVELING_FADE_HEIGHT, const_float_t factor=1.0f) - ) { - #if DISABLED(ENABLE_LEVELING_FADE_HEIGHT) - constexpr float factor = 1.0f; - #endif + static float get_z_offset() { return z_offset; } + + 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], @@ -115,7 +114,7 @@ class mesh_bed_leveling { 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); - return z_offset + zf * factor; + return zf; } #if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES) @@ -123,4 +122,4 @@ class mesh_bed_leveling { #endif }; -extern mesh_bed_leveling mbl; +extern mesh_bed_leveling bedlevel; diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 964f1123fe42..2aa50be34d26 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -26,7 +26,7 @@ #include "../bedlevel.h" -unified_bed_leveling ubl; +unified_bed_leveling bedlevel; #include "../../../MarlinCore.h" #include "../../../gcode/gcode.h" @@ -213,8 +213,8 @@ void unified_bed_leveling::display_map(const uint8_t map_type) { else if (isnan(f)) SERIAL_ECHOF(human ? F(" . ") : F("NAN")); else if (human || csv) { - if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Display sign also for positive numbers (' ' for 0) - SERIAL_ECHO_F(f, 3); // Positive: 5 digits, Negative: 6 digits + if (human && f >= 0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Display sign also for positive numbers (' ' for 0) + SERIAL_DECIMAL(f); // Positive: 5 digits, Negative: 6 digits } if (csv && i < (GRID_MAX_POINTS_X) - 1) SERIAL_CHAR('\t'); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h index ffabadd990b3..a7103d6e18c4 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.h +++ b/Marlin/src/feature/bedlevel/ubl/ubl.h @@ -70,20 +70,19 @@ class unified_bed_leveling { static void move_z_with_encoder(const_float_t multiplier); static float measure_point_with_encoder(); static float measure_business_card_thickness(); - static void manually_probe_remaining_mesh(const xy_pos_t&, const_float_t , const_float_t , const bool) _O0; - static void fine_tune_mesh(const xy_pos_t &pos, const bool do_ubl_mesh_map) _O0; + static void manually_probe_remaining_mesh(const xy_pos_t&, const_float_t , const_float_t , const bool) __O0; + static void fine_tune_mesh(const xy_pos_t &pos, const bool do_ubl_mesh_map) __O0; #endif - static bool G29_parse_parameters() _O0; + static bool G29_parse_parameters() __O0; static void shift_mesh_height(); - static void probe_entire_mesh(const xy_pos_t &near, const bool do_ubl_mesh_map, const bool stow_probe, const bool do_furthest) _O0; + static void probe_entire_mesh(const xy_pos_t &near, const bool do_ubl_mesh_map, const bool stow_probe, const bool do_furthest) __O0; static void tilt_mesh_based_on_3pts(const_float_t z1, const_float_t z2, const_float_t z3); static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map); static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir); - static inline bool smart_fill_one(const xy_uint8_t &pos, const xy_uint8_t &dir) { + static bool smart_fill_one(const xy_uint8_t &pos, const xy_uint8_t &dir) { return smart_fill_one(pos.x, pos.y, dir.x, dir.y); } - static void smart_fill_mesh(); #if ENABLED(UBL_DEVEL_DEBUGGING) static void g29_what_command(); @@ -98,17 +97,18 @@ class unified_bed_leveling { static void report_state(); static void save_ubl_active_state_and_disable(); static void restore_ubl_active_state_and_leave(); - static void display_map(const uint8_t) _O0; - static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const xy_pos_t&, const bool=false, MeshFlags *done_flags=nullptr) _O0; - static mesh_index_pair find_furthest_invalid_mesh_point() _O0; + static void display_map(const uint8_t) __O0; + static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const xy_pos_t&, const bool=false, MeshFlags *done_flags=nullptr) __O0; + static mesh_index_pair find_furthest_invalid_mesh_point() __O0; static void reset(); static void invalidate(); static void set_all_mesh_points_to_value(const_float_t value); static void adjust_mesh_to_mean(const bool cflag, const_float_t value); static bool sanity_check(); + static void smart_fill_mesh(); - static void G29() _O0; // O0 for no optimization - static void smart_fill_wlsf(const_float_t ) _O2; // O2 gives smaller code than Os on A2560 + static void G29() __O0; // O0 for no optimization + static void smart_fill_wlsf(const_float_t ) __O2; // O2 gives smaller code than Os on A2560 static int8_t storage_slot; @@ -120,11 +120,11 @@ class unified_bed_leveling { static const float _mesh_index_to_xpos[GRID_MAX_POINTS_X], _mesh_index_to_ypos[GRID_MAX_POINTS_Y]; - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU static bool lcd_map_control; static void steppers_were_disabled(); #else - static inline void steppers_were_disabled() {} + static void steppers_were_disabled() {} #endif static volatile int16_t encoder_diff; // Volatile because buttons may change it at interrupt time @@ -157,10 +157,10 @@ class unified_bed_leveling { return constrain(cell_index_y_raw(y), 0, GRID_MAX_CELLS_Y - 1); } - static inline xy_int8_t cell_indexes(const_float_t x, const_float_t y) { + static xy_int8_t cell_indexes(const_float_t x, const_float_t y) { return { cell_index_x(x), cell_index_y(y) }; } - static inline xy_int8_t cell_indexes(const xy_pos_t &xy) { return cell_indexes(xy.x, xy.y); } + static xy_int8_t cell_indexes(const xy_pos_t &xy) { return cell_indexes(xy.x, xy.y); } static int8_t closest_x_index(const_float_t x) { const int8_t px = (x - (MESH_MIN_X) + (MESH_X_DIST) * 0.5) * RECIPROCAL(MESH_X_DIST); @@ -170,7 +170,7 @@ class unified_bed_leveling { const int8_t py = (y - (MESH_MIN_Y) + (MESH_Y_DIST) * 0.5) * RECIPROCAL(MESH_Y_DIST); return WITHIN(py, 0, (GRID_MAX_POINTS_Y) - 1) ? py : -1; } - static inline xy_int8_t closest_indexes(const xy_pos_t &xy) { + static xy_int8_t closest_indexes(const xy_pos_t &xy) { return { closest_x_index(xy.x), closest_y_index(xy.y) }; } @@ -203,7 +203,7 @@ class unified_bed_leveling { * z_correction_for_x_on_horizontal_mesh_line is an optimization for * the case where the printer is making a vertical line that only crosses horizontal mesh lines. */ - static inline float z_correction_for_x_on_horizontal_mesh_line(const_float_t rx0, const int x1_i, const int yi) { + static float z_correction_for_x_on_horizontal_mesh_line(const_float_t rx0, const int x1_i, const int yi) { if (!WITHIN(x1_i, 0, (GRID_MAX_POINTS_X) - 1) || !WITHIN(yi, 0, (GRID_MAX_POINTS_Y) - 1)) { if (DEBUGGING(LEVELING)) { @@ -215,7 +215,7 @@ class unified_bed_leveling { return _UBL_OUTER_Z_RAISE; } - const float xratio = (rx0 - mesh_index_to_xpos(x1_i)) * RECIPROCAL(MESH_X_DIST), + const float xratio = (rx0 - get_mesh_x(x1_i)) * RECIPROCAL(MESH_X_DIST), z1 = z_values[x1_i][yi]; return z1 + xratio * (z_values[_MIN(x1_i, (GRID_MAX_POINTS_X) - 2) + 1][yi] - z1); // Don't allow x1_i+1 to be past the end of the array @@ -226,7 +226,7 @@ class unified_bed_leveling { // // See comments above for z_correction_for_x_on_horizontal_mesh_line // - static inline float z_correction_for_y_on_vertical_mesh_line(const_float_t ry0, const int xi, const int y1_i) { + static float z_correction_for_y_on_vertical_mesh_line(const_float_t ry0, const int xi, const int y1_i) { if (!WITHIN(xi, 0, (GRID_MAX_POINTS_X) - 1) || !WITHIN(y1_i, 0, (GRID_MAX_POINTS_Y) - 1)) { if (DEBUGGING(LEVELING)) { @@ -238,7 +238,7 @@ class unified_bed_leveling { return _UBL_OUTER_Z_RAISE; } - const float yratio = (ry0 - mesh_index_to_ypos(y1_i)) * RECIPROCAL(MESH_Y_DIST), + const float yratio = (ry0 - get_mesh_y(y1_i)) * RECIPROCAL(MESH_Y_DIST), z1 = z_values[xi][y1_i]; return z1 + yratio * (z_values[xi][_MIN(y1_i, (GRID_MAX_POINTS_Y) - 2) + 1] - z1); // Don't allow y1_i+1 to be past the end of the array @@ -264,16 +264,17 @@ 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; - const float z1 = calc_z0(rx0, mesh_index_to_xpos(cx), z_values[cx][cy], mesh_index_to_xpos(cx + 1), z_values[mx][cy]); - const float z2 = calc_z0(rx0, mesh_index_to_xpos(cx), z_values[cx][my], mesh_index_to_xpos(cx + 1), z_values[mx][my]); - float z0 = calc_z0(ry0, mesh_index_to_ypos(cy), z1, mesh_index_to_ypos(cy + 1), z2); + 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]), + 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); - if (isnan(z0)) { // if part of the Mesh is undefined, it will show up as NAN - z0 = 0.0; // in ubl.z_values[][] and propagate through the - // calculations. If our correction is NAN, we throw it out - // because part of the Mesh is undefined and we don't have the - // information we need to complete the height correction. + if (isnan(z0)) { // If part of the Mesh is undefined, it will show up as NAN + z0 = 0.0; // in z_values[][] and propagate through the calculations. + // If our correction is NAN, we throw it out because part of + // the Mesh is undefined and we don't have the information + // needed to complete the height correction. if (DEBUGGING(MESH_ADJUST)) DEBUG_ECHOLNPGM("??? Yikes! NAN in "); } @@ -285,12 +286,14 @@ class unified_bed_leveling { return z0; } - static inline float get_z_correction(const xy_pos_t &pos) { return get_z_correction(pos.x, pos.y); } + static float get_z_correction(const xy_pos_t &pos) { return get_z_correction(pos.x, pos.y); } - static inline float mesh_index_to_xpos(const uint8_t i) { + static constexpr float get_z_offset() { return 0.0f; } + + static float get_mesh_x(const uint8_t i) { return i < (GRID_MAX_POINTS_X) ? pgm_read_float(&_mesh_index_to_xpos[i]) : MESH_MIN_X + i * (MESH_X_DIST); } - static inline float mesh_index_to_ypos(const uint8_t i) { + static float get_mesh_y(const uint8_t i) { return i < (GRID_MAX_POINTS_Y) ? pgm_read_float(&_mesh_index_to_ypos[i]) : MESH_MIN_Y + i * (MESH_Y_DIST); } @@ -300,18 +303,14 @@ class unified_bed_leveling { static void line_to_destination_cartesian(const_feedRate_t scaled_fr_mm_s, const uint8_t e); #endif - static inline bool mesh_is_valid() { + static bool mesh_is_valid() { GRID_LOOP(x, y) if (isnan(z_values[x][y])) return false; return true; } }; // class unified_bed_leveling -extern unified_bed_leveling ubl; - -#define _GET_MESH_X(I) ubl.mesh_index_to_xpos(I) -#define _GET_MESH_Y(J) ubl.mesh_index_to_ypos(J) -#define Z_VALUES_ARR ubl.z_values +extern unified_bed_leveling bedlevel; // Prevent debugging propagating to other files #include "../../../core/debug_out.h" diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index df83923fef0a..eed9f61ebbcf 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -57,7 +57,7 @@ #define UBL_G29_P31 -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU bool unified_bed_leveling::lcd_map_control = false; @@ -316,7 +316,7 @@ void unified_bed_leveling::G29() { planner.synchronize(); // Send 'N' to force homing before G29 (internal only) if (axes_should_home() || parser.seen_test('N')) gcode.home_all_axes(); - TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0)); + TERN_(HAS_MULTI_HOTEND, if (active_extruder != 0) tool_change(0, true)); } // Invalidate one or more nearby mesh points, possibly all. @@ -367,13 +367,13 @@ void unified_bed_leveling::G29() { case 1: LOOP_L_N(x, GRID_MAX_POINTS_X) { // Create a diagonal line several Mesh cells thick that is raised + const uint8_t x2 = x + (x < (GRID_MAX_POINTS_Y) - 1 ? 1 : -1); z_values[x][x] += 9.999f; - z_values[x][x + (x < (GRID_MAX_POINTS_Y) - 1) ? 1 : -1] += 9.999f; // We want the altered line several mesh points thick + 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, (x + (x < (GRID_MAX_POINTS_Y) - 1) ? 1 : -1), z_values[x][x + (x < (GRID_MAX_POINTS_Y) - 1) ? 1 : -1]); + ExtUI::onMeshUpdate(x, (x2), z_values[x][x2]); #endif - } break; @@ -443,7 +443,7 @@ void unified_bed_leveling::G29() { #endif // HAS_BED_PROBE case 2: { - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU // // Manually Probe Mesh in areas that can't be reached by the probe // @@ -555,7 +555,7 @@ void unified_bed_leveling::G29() { } case 4: // Fine Tune (i.e., Edit) the Mesh - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU fine_tune_mesh(param.XY_pos, parser.seen_test('T')); #else SERIAL_ECHOLNPGM("?P4 is only available when an LCD is present."); @@ -646,7 +646,7 @@ void unified_bed_leveling::G29() { LEAVE: - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU ui.reset_alert_level(); ui.quick_feedback(); ui.reset_status(); @@ -663,7 +663,7 @@ void unified_bed_leveling::G29() { UNUSED(probe_deployed); #endif - TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index)); + TERN_(HAS_MULTI_HOTEND, if (old_tool_index != 0) tool_change(old_tool_index)); return; } @@ -725,7 +725,9 @@ void unified_bed_leveling::shift_mesh_height() { void unified_bed_leveling::probe_entire_mesh(const xy_pos_t &nearby, const bool do_ubl_mesh_map, const bool stow_probe, const bool do_furthest) { probe.deploy(); // Deploy before ui.capture() to allow for PAUSE_BEFORE_DEPLOY_STOW - TERN_(HAS_LCD_MENU, ui.capture()); + TERN_(HAS_MARLINUI_MENU, ui.capture()); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart()); + TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart()); save_ubl_active_state_and_disable(); // No bed level correction so only raw data is obtained uint8_t count = GRID_MAX_POINTS; @@ -739,7 +741,7 @@ void unified_bed_leveling::shift_mesh_height() { SERIAL_ECHOLNPGM("Probing mesh point ", point_num, "/", GRID_MAX_POINTS, "."); TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_POINT), point_num, int(GRID_MAX_POINTS))); - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU if (ui.button_pressed()) { ui.quick_feedback(false); // Preserve button state for click-and-hold SERIAL_ECHOLNPGM("\nMesh only partially populated.\n"); @@ -747,6 +749,7 @@ void unified_bed_leveling::shift_mesh_height() { ui.quick_feedback(); ui.release(); probe.stow(); // Release UI before stow to allow for PAUSE_BEFORE_DEPLOY_STOW + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); return restore_ubl_active_state_and_leave(); } #endif @@ -774,9 +777,9 @@ void unified_bed_leveling::shift_mesh_height() { TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::G29_FINISH)); // Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW - TERN_(HAS_LCD_MENU, ui.release()); + TERN_(HAS_MARLINUI_MENU, ui.release()); probe.stow(); - TERN_(HAS_LCD_MENU, ui.capture()); + TERN_(HAS_MARLINUI_MENU, ui.capture()); probe.move_z_after_probing(); @@ -786,12 +789,15 @@ void unified_bed_leveling::shift_mesh_height() { constrain(nearby.x - probe.offset_xy.x, MESH_MIN_X, MESH_MAX_X), constrain(nearby.y - probe.offset_xy.y, MESH_MIN_Y, MESH_MAX_Y) ); + + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); + TERN_(DWIN_LCD_PROUI, DWIN_LevelingDone()); } #endif // HAS_BED_PROBE void set_message_with_feedback(FSTR_P const fstr) { - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU ui.set_status(fstr); ui.quick_feedback(); #else @@ -799,7 +805,7 @@ void set_message_with_feedback(FSTR_P const fstr) { #endif } -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU typedef void (*clickFunc_t)(); @@ -885,6 +891,7 @@ void set_message_with_feedback(FSTR_P const fstr) { */ void unified_bed_leveling::manually_probe_remaining_mesh(const xy_pos_t &pos, const_float_t z_clearance, const_float_t thick, const bool do_ubl_mesh_map) { ui.capture(); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart()); save_ubl_active_state_and_disable(); // No bed level correction so only raw data is obtained do_blocking_move_to_xy_z(current_position, z_clearance); @@ -898,11 +905,7 @@ void set_message_with_feedback(FSTR_P const fstr) { // It doesn't matter if the probe can't reach the NAN location. This is a manual probe. if (!location.valid()) continue; - const xyz_pos_t ppos = { - mesh_index_to_xpos(lpos.x), - mesh_index_to_ypos(lpos.y), - z_clearance - }; + const xyz_pos_t ppos = { get_mesh_x(lpos.x), get_mesh_y(lpos.y), z_clearance }; if (!position_is_reachable(ppos)) break; // SHOULD NOT OCCUR (find_closest_mesh_point only returns reachable points) @@ -948,6 +951,8 @@ void set_message_with_feedback(FSTR_P const fstr) { restore_ubl_active_state_and_leave(); do_blocking_move_to_xy_z(pos, Z_CLEARANCE_DEPLOY_PROBE); + + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); } /** @@ -995,11 +1000,7 @@ void set_message_with_feedback(FSTR_P const fstr) { done_flags.mark(lpos); // Mark this location as 'adjusted' so a new // location is used on the next loop - const xyz_pos_t raw = { - mesh_index_to_xpos(lpos.x), - mesh_index_to_ypos(lpos.y), - Z_CLEARANCE_BETWEEN_PROBES - }; + const xyz_pos_t raw = { get_mesh_x(lpos.x), get_mesh_y(lpos.y), Z_CLEARANCE_BETWEEN_PROBES }; if (!position_is_reachable(raw)) break; // SHOULD NOT OCCUR (find_closest_mesh_point_of_type only returns reachable) @@ -1070,7 +1071,7 @@ void set_message_with_feedback(FSTR_P const fstr) { ui.return_to_status(); } -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU /** * Parse and validate most G29 parameters, store for use by G29 functions. @@ -1210,7 +1211,7 @@ void unified_bed_leveling::save_ubl_active_state_and_disable() { } void unified_bed_leveling::restore_ubl_active_state_and_leave() { - TERN_(HAS_LCD_MENU, ui.release()); + TERN_(HAS_MARLINUI_MENU, ui.release()); #if ENABLED(UBL_DEVEL_DEBUGGING) if (--ubl_state_recursion_chk) { SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times."); @@ -1219,6 +1220,7 @@ void unified_bed_leveling::restore_ubl_active_state_and_leave() { } #endif set_bed_leveling_enabled(ubl_state_at_invocation); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); } mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() { @@ -1231,7 +1233,7 @@ mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() { if (!isnan(z_values[i][j])) continue; // Skip valid mesh points // Skip unreachable points - if (!probe.can_reach(mesh_index_to_xpos(i), mesh_index_to_ypos(j))) + if (!probe.can_reach(get_mesh_x(i), get_mesh_y(j))) continue; found_a_NAN = true; @@ -1283,11 +1285,11 @@ mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() { static bool test_func(uint8_t i, uint8_t j, void *data) { find_closest_t *d = (find_closest_t*)data; - if ( d->type == CLOSEST || d->type == (isnan(ubl.z_values[i][j]) ? INVALID : REAL) + if ( d->type == CLOSEST || d->type == (isnan(bedlevel.z_values[i][j]) ? INVALID : REAL) || (d->type == SET_IN_BITMAP && !d->done_flags->marked(i, j)) ) { // Found a Mesh Point of the specified type! - const xy_pos_t mpos = { ubl.mesh_index_to_xpos(i), ubl.mesh_index_to_ypos(j) }; + const xy_pos_t mpos = { bedlevel.get_mesh_x(i), bedlevel.get_mesh_y(j) }; // If using the probe as the reference there are some unreachable locations. // Also for round beds, there are grid points outside the bed the nozzle can't reach. @@ -1331,7 +1333,7 @@ mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const Mesh || (type == SET_IN_BITMAP && !done_flags->marked(i, j)) ) { // Found a Mesh Point of the specified type! - const xy_pos_t mpos = { mesh_index_to_xpos(i), mesh_index_to_ypos(j) }; + const xy_pos_t mpos = { get_mesh_x(i), get_mesh_y(j) }; // If using the probe as the reference there are some unreachable locations. // Also for round beds, there are grid points outside the bed the nozzle can't reach. @@ -1387,10 +1389,10 @@ typedef struct { uint8_t sx, ex, sy, ey; bool yfirst; } smart_fill_info; void unified_bed_leveling::smart_fill_mesh() { static const smart_fill_info - info0 PROGMEM = { 0, GRID_MAX_POINTS_X, 0, GRID_MAX_POINTS_Y - 2, false }, // Bottom of the mesh looking up - info1 PROGMEM = { 0, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y - 1, 0, false }, // Top of the mesh looking down - info2 PROGMEM = { 0, GRID_MAX_POINTS_X - 2, 0, GRID_MAX_POINTS_Y, true }, // Left side of the mesh looking right - info3 PROGMEM = { GRID_MAX_POINTS_X - 1, 0, 0, GRID_MAX_POINTS_Y, true }; // Right side of the mesh looking left + info0 PROGMEM = { 0, GRID_MAX_POINTS_X, 0, (GRID_MAX_POINTS_Y) - 2, false }, // Bottom of the mesh looking up + info1 PROGMEM = { 0, GRID_MAX_POINTS_X, (GRID_MAX_POINTS_Y) - 1, 0, false }, // Top of the mesh looking down + info2 PROGMEM = { 0, (GRID_MAX_POINTS_X) - 2, 0, GRID_MAX_POINTS_Y, true }, // Left side of the mesh looking right + info3 PROGMEM = { (GRID_MAX_POINTS_X) - 1, 0, 0, GRID_MAX_POINTS_Y, true }; // Right side of the mesh looking left static const smart_fill_info * const info[] PROGMEM = { &info0, &info1, &info2, &info3 }; LOOP_L_N(i, COUNT(info)) { @@ -1579,9 +1581,7 @@ void unified_bed_leveling::smart_fill_mesh() { matrix_3x3 rotation = matrix_3x3::create_look_at(vector_3(lsf_results.A, lsf_results.B, 1)); GRID_LOOP(i, j) { - float mx = mesh_index_to_xpos(i), - my = mesh_index_to_ypos(j), - mz = z_values[i][j]; + float mx = get_mesh_x(i), my = get_mesh_y(j), mz = z_values[i][j]; if (DEBUGGING(LEVELING)) { DEBUG_ECHOPAIR_F("before rotation = [", mx, 7); @@ -1678,18 +1678,18 @@ void unified_bed_leveling::smart_fill_mesh() { xy_pos_t ppos; LOOP_L_N(ix, GRID_MAX_POINTS_X) { - ppos.x = mesh_index_to_xpos(ix); + ppos.x = get_mesh_x(ix); LOOP_L_N(iy, GRID_MAX_POINTS_Y) { - ppos.y = mesh_index_to_ypos(iy); + ppos.y = get_mesh_y(iy); if (isnan(z_values[ix][iy])) { // undefined mesh point at (ppos.x,ppos.y), compute weighted LSF from original valid mesh points. incremental_LSF_reset(&lsf_results); xy_pos_t rpos; LOOP_L_N(jx, GRID_MAX_POINTS_X) { - rpos.x = mesh_index_to_xpos(jx); + rpos.x = get_mesh_x(jx); LOOP_L_N(jy, GRID_MAX_POINTS_Y) { if (TEST(bitmap[jx], jy)) { - rpos.y = mesh_index_to_ypos(jy); + rpos.y = get_mesh_y(jy); const float rz = z_values[jx][jy], w = 1.0f + weight_scaled / (rpos - ppos).magnitude(); incremental_WLSF(&lsf_results, rpos, rz, w); @@ -1748,7 +1748,7 @@ void unified_bed_leveling::smart_fill_mesh() { SERIAL_ECHOPGM("X-Axis Mesh Points at: "); LOOP_L_N(i, GRID_MAX_POINTS_X) { - SERIAL_ECHO_F(LOGICAL_X_POSITION(mesh_index_to_xpos(i)), 3); + SERIAL_ECHO_F(LOGICAL_X_POSITION(get_mesh_x(i)), 3); SERIAL_ECHOPGM(" "); serial_delay(25); } @@ -1756,7 +1756,7 @@ void unified_bed_leveling::smart_fill_mesh() { SERIAL_ECHOPGM("Y-Axis Mesh Points at: "); LOOP_L_N(i, GRID_MAX_POINTS_Y) { - SERIAL_ECHO_F(LOGICAL_Y_POSITION(mesh_index_to_ypos(i)), 3); + SERIAL_ECHO_F(LOGICAL_Y_POSITION(get_mesh_y(i)), 3); SERIAL_ECHOPGM(" "); serial_delay(25); } diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp index f7e98c9fa77d..e6eec0de63fd 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp @@ -76,8 +76,8 @@ #endif // The distance is always MESH_X_DIST so multiply by the constant reciprocal. - const float xratio = (end.x - mesh_index_to_xpos(iend.x)) * RECIPROCAL(MESH_X_DIST), - yratio = (end.y - mesh_index_to_ypos(iend.y)) * RECIPROCAL(MESH_Y_DIST), + const float xratio = (end.x - get_mesh_x(iend.x)) * RECIPROCAL(MESH_X_DIST), + yratio = (end.y - get_mesh_y(iend.y)) * RECIPROCAL(MESH_Y_DIST), z1 = z_values[iend.x][iend.y ] + xratio * (z_values[iend.x + 1][iend.y ] - z_values[iend.x][iend.y ]), z2 = z_values[iend.x][iend.y + 1] + xratio * (z_values[iend.x + 1][iend.y + 1] - z_values[iend.x][iend.y + 1]); @@ -139,7 +139,7 @@ icell.y += ineg.y; // Line going down? Just go to the bottom. while (icell.y != iend.y + ineg.y) { icell.y += iadd.y; - const float next_mesh_line_y = mesh_index_to_ypos(icell.y); + const float next_mesh_line_y = get_mesh_y(icell.y); /** * Skip the calculations for an infinite slope. @@ -155,7 +155,7 @@ // Replace NAN corrections with 0.0 to prevent NAN propagation. if (isnan(z0)) z0 = 0.0; - dest.y = mesh_index_to_ypos(icell.y); + dest.y = get_mesh_y(icell.y); /** * Without this check, it's possible to generate a zero length move, as in the case where @@ -196,7 +196,7 @@ while (icell.x != iend.x + ineg.x) { icell.x += iadd.x; - dest.x = mesh_index_to_xpos(icell.x); + dest.x = get_mesh_x(icell.x); dest.y = ratio * dest.x + c; // Calculate Y at the next X mesh line float z0 = z_correction_for_y_on_vertical_mesh_line(dest.y, icell.x, icell.y) @@ -245,8 +245,8 @@ while (cnt) { - const float next_mesh_line_x = mesh_index_to_xpos(icell.x + iadd.x), - next_mesh_line_y = mesh_index_to_ypos(icell.y + iadd.y); + const float next_mesh_line_x = get_mesh_x(icell.x + iadd.x), + next_mesh_line_y = get_mesh_y(icell.y + iadd.y); dest.y = ratio * next_mesh_line_x + c; // Calculate Y at the next X mesh line dest.x = (next_mesh_line_y - c) / ratio; // Calculate X at the next Y mesh line @@ -340,7 +340,7 @@ * Returns true if did NOT move, false if moved (requires current_position update). */ - bool _O2 unified_bed_leveling::line_to_destination_segmented(const_feedRate_t scaled_fr_mm_s) { + bool __O2 unified_bed_leveling::line_to_destination_segmented(const_feedRate_t scaled_fr_mm_s) { if (!position_is_reachable(destination)) // fail if moving outside reachable boundary return true; // did not move, so current_position still accurate @@ -423,7 +423,7 @@ if (isnan(z_x0y1)) z_x0y1 = 0; // in order to avoid isnan tests per cell, if (isnan(z_x1y1)) z_x1y1 = 0; // thus guessing zero for undefined points - const xy_pos_t pos = { mesh_index_to_xpos(icell.x), mesh_index_to_ypos(icell.y) }; + const xy_pos_t pos = { get_mesh_x(icell.x), get_mesh_y(icell.y) }; xy_pos_t cell = raw - pos; const float z_xmy0 = (z_x1y0 - z_x0y0) * RECIPROCAL(MESH_X_DIST), // z slope per x along y0 (lower left to lower right) @@ -450,10 +450,7 @@ if (--segments == 0) raw = destination; // if this is last segment, use destination for exact const float z_cxcy = (z_cxy0 + z_cxym * cell.y) // interpolated mesh z height along cell.x at cell.y - #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - * fade_scaling_factor // apply fade factor to interpolated mesh height - #endif - ; + 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) ); diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index b1cc30bee0d9..10d3131aedcb 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -45,7 +45,7 @@ void stop(); bool BLTouch::command(const BLTCommand cmd, const millis_t &ms) { if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("BLTouch Command :", cmd); - MOVE_SERVO(Z_PROBE_SERVO_NR, cmd); + servo[Z_PROBE_SERVO_NR].move(cmd); safe_delay(_MAX(ms, (uint32_t)BLTOUCH_DELAY)); // BLTOUCH_DELAY is also the *minimum* delay return triggered(); } @@ -111,11 +111,8 @@ bool BLTouch::deploy_proc() { // Last attempt to DEPLOY if (_deploy_query_alarm()) { // The deploy might have failed or the probe is actually triggered (nozzle too low?) again - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("BLTouch Recovery Failed"); - - SERIAL_ERROR_MSG(STR_STOP_BLTOUCH); // Tell the user something is wrong, needs action - stop(); // but it's not too bad, no need to kill, allow restart - + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("BLTouch Deploy Failed"); + probe.probe_error_stop(); // Something is wrong, needs action, but not too bad, allow restart return true; // Tell our caller we goofed in case he cares to know } } @@ -153,12 +150,8 @@ bool BLTouch::stow_proc() { // But one more STOW will catch that // Last attempt to STOW if (_stow_query_alarm()) { // so if there is now STILL an ALARM condition: - - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("BLTouch Recovery Failed"); - - SERIAL_ERROR_MSG(STR_STOP_BLTOUCH); // Tell the user something is wrong, needs action - stop(); // but it's not too bad, no need to kill, allow restart - + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("BLTouch Stow Failed"); + probe.probe_error_stop(); // Something is wrong, needs action, but not too bad, allow restart return true; // Tell our caller we goofed in case he cares to know } } diff --git a/Marlin/src/feature/bltouch.h b/Marlin/src/feature/bltouch.h index ae3ab6630036..fa857bb96ab6 100644 --- a/Marlin/src/feature/bltouch.h +++ b/Marlin/src/feature/bltouch.h @@ -76,7 +76,7 @@ class BLTouch { static constexpr bool high_speed_mode = false; #endif - static inline float z_extra_clearance() { return high_speed_mode ? 7 : 0; } + static float z_extra_clearance() { return high_speed_mode ? 7 : 0; } // DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing static bool deploy() { return deploy_proc(); } diff --git a/Marlin/src/feature/cancel_object.h b/Marlin/src/feature/cancel_object.h index 1d2d77f20334..62548a371937 100644 --- a/Marlin/src/feature/cancel_object.h +++ b/Marlin/src/feature/cancel_object.h @@ -32,10 +32,10 @@ class CancelObject { static void cancel_object(const int8_t obj); static void uncancel_object(const int8_t obj); static void report(); - static inline bool is_canceled(const int8_t obj) { return TEST(canceled, obj); } - static inline void clear_active_object() { set_active_object(-1); } - static inline void cancel_active_object() { cancel_object(active_object); } - static inline void reset() { canceled = 0x0000; object_count = 0; clear_active_object(); } + static bool is_canceled(const int8_t obj) { return TEST(canceled, obj); } + static void clear_active_object() { set_active_object(-1); } + static void cancel_active_object() { cancel_object(active_object); } + static void reset() { canceled = 0x0000; object_count = 0; clear_active_object(); } }; extern CancelObject cancelable; diff --git a/Marlin/src/feature/caselight.cpp b/Marlin/src/feature/caselight.cpp index 59832fd6edd7..eb580a6d6269 100644 --- a/Marlin/src/feature/caselight.cpp +++ b/Marlin/src/feature/caselight.cpp @@ -64,12 +64,22 @@ void CaseLight::update(const bool sflag) { #endif #if CASE_LIGHT_IS_COLOR_LED - leds.set_color(LEDColor(color.r, color.g, color.b OPTARG(HAS_WHITE_LED, color.w) OPTARG(NEOPIXEL_LED, n10ct))); + #if ENABLED(CASE_LIGHT_USE_NEOPIXEL) + if (on) + // Use current color of (NeoPixel) leds and new brightness level + leds.set_color(LEDColor(leds.color.r, leds.color.g, leds.color.b OPTARG(HAS_WHITE_LED, leds.color.w) OPTARG(NEOPIXEL_LED, n10ct))); + else + // Switch off leds + leds.set_off(); + #else + // Use CaseLight color (CASE_LIGHT_DEFAULT_COLOR) and new brightness level + leds.set_color(LEDColor(color.r, color.g, color.b OPTARG(HAS_WHITE_LED, color.w) OPTARG(NEOPIXEL_LED, n10ct))); + #endif #else // !CASE_LIGHT_IS_COLOR_LED #if CASELIGHT_USES_BRIGHTNESS if (pin_is_pwm()) - set_pwm_duty(pin_t(CASE_LIGHT_PIN), ( + hal.set_pwm_duty(pin_t(CASE_LIGHT_PIN), ( #if CASE_LIGHT_MAX_PWM == 255 n10ct #else diff --git a/Marlin/src/feature/caselight.h b/Marlin/src/feature/caselight.h index b2e82f9b838f..17e1222acbfa 100644 --- a/Marlin/src/feature/caselight.h +++ b/Marlin/src/feature/caselight.h @@ -27,10 +27,6 @@ #include "leds/leds.h" // for LEDColor #endif -#if NONE(CASE_LIGHT_NO_BRIGHTNESS, CASE_LIGHT_IS_COLOR_LED) || ENABLED(CASE_LIGHT_USE_NEOPIXEL) - #define CASELIGHT_USES_BRIGHTNESS 1 -#endif - class CaseLight { public: static bool on; @@ -49,8 +45,8 @@ class CaseLight { } static void update(const bool sflag); - static inline void update_brightness() { update(false); } - static inline void update_enabled() { update(true); } + static void update_brightness() { update(false); } + static void update_enabled() { update(true); } #if ENABLED(CASE_LIGHT_IS_COLOR_LED) private: diff --git a/Marlin/src/feature/controllerfan.cpp b/Marlin/src/feature/controllerfan.cpp index 59ba665e1114..f42bf52ae40a 100644 --- a/Marlin/src/feature/controllerfan.cpp +++ b/Marlin/src/feature/controllerfan.cpp @@ -76,7 +76,7 @@ void ControllerFan::update() { thermalManager.soft_pwm_controller_speed = speed; #else if (PWM_PIN(CONTROLLER_FAN_PIN)) - set_pwm_duty(pin_t(CONTROLLER_FAN_PIN), speed); + hal.set_pwm_duty(pin_t(CONTROLLER_FAN_PIN), speed); else WRITE(CONTROLLER_FAN_PIN, speed > 0); #endif diff --git a/Marlin/src/feature/controllerfan.h b/Marlin/src/feature/controllerfan.h index 55f2d5cfc7aa..55eb2359b067 100644 --- a/Marlin/src/feature/controllerfan.h +++ b/Marlin/src/feature/controllerfan.h @@ -60,9 +60,9 @@ class ControllerFan { #else static const controllerFan_settings_t &settings; #endif - static inline bool state() { return speed > 0; } - static inline void init() { reset(); } - static inline void reset() { TERN_(CONTROLLER_FAN_EDITABLE, settings = controllerFan_defaults); } + static bool state() { return speed > 0; } + static void init() { reset(); } + static void reset() { TERN_(CONTROLLER_FAN_EDITABLE, settings = controllerFan_defaults); } static void setup(); static void update(); }; diff --git a/Marlin/src/feature/dac/stepper_dac.cpp b/Marlin/src/feature/dac/stepper_dac.cpp index ff730e93c62c..119a85959982 100644 --- a/Marlin/src/feature/dac/stepper_dac.cpp +++ b/Marlin/src/feature/dac/stepper_dac.cpp @@ -29,7 +29,6 @@ #if HAS_MOTOR_CURRENT_DAC #include "stepper_dac.h" -#include "../../MarlinCore.h" // for SP_X_LBL... bool dac_present = false; constexpr xyze_uint8_t dac_order = DAC_STEPPER_ORDER; diff --git a/Marlin/src/feature/digipot/digipot_mcp4018.cpp b/Marlin/src/feature/digipot/digipot_mcp4018.cpp index 37853ff428bc..3f2ecbfcdc0b 100644 --- a/Marlin/src/feature/digipot/digipot_mcp4018.cpp +++ b/Marlin/src/feature/digipot/digipot_mcp4018.cpp @@ -31,9 +31,13 @@ // Settings for the I2C based DIGIPOT (MCP4018) based on WT150 -#define DIGIPOT_A4988_Rsx 0.250 -#define DIGIPOT_A4988_Vrefmax 1.666 -#define DIGIPOT_MCP4018_MAX_VALUE 127 +#ifndef DIGIPOT_A4988_Rsx + #define DIGIPOT_A4988_Rsx 0.250 +#endif +#ifndef DIGIPOT_A4988_Vrefmax + #define DIGIPOT_A4988_Vrefmax 1.666 +#endif +#define DIGIPOT_MCP4018_MAX_VALUE 127 #define DIGIPOT_A4988_Itripmax(Vref) ((Vref) / (8.0 * DIGIPOT_A4988_Rsx)) diff --git a/Marlin/src/feature/direct_stepping.cpp b/Marlin/src/feature/direct_stepping.cpp index b8ef04fcd908..052e79de41e5 100644 --- a/Marlin/src/feature/direct_stepping.cpp +++ b/Marlin/src/feature/direct_stepping.cpp @@ -52,13 +52,13 @@ namespace DirectStepping { volatile bool SerialPageManager::fatal_error; template - volatile PageState SerialPageManager::page_states[Cfg::NUM_PAGES]; + volatile PageState SerialPageManager::page_states[Cfg::PAGE_COUNT]; template volatile bool SerialPageManager::page_states_dirty; template - uint8_t SerialPageManager::pages[Cfg::NUM_PAGES][Cfg::PAGE_SIZE]; + uint8_t SerialPageManager::pages[Cfg::PAGE_COUNT][Cfg::PAGE_SIZE]; template uint8_t SerialPageManager::checksum; @@ -74,7 +74,7 @@ namespace DirectStepping { template void SerialPageManager::init() { - for (int i = 0 ; i < Cfg::NUM_PAGES ; i++) + for (int i = 0 ; i < Cfg::PAGE_COUNT ; i++) page_states[i] = PageState::FREE; fatal_error = false; @@ -183,10 +183,10 @@ namespace DirectStepping { SERIAL_CHAR(Cfg::CONTROL_CHAR); constexpr int state_bits = 2; - constexpr int n_bytes = Cfg::NUM_PAGES >> state_bits; + constexpr int n_bytes = Cfg::PAGE_COUNT >> state_bits; volatile uint8_t bits_b[n_bytes] = { 0 }; - for (page_idx_t i = 0 ; i < Cfg::NUM_PAGES ; i++) { + for (page_idx_t i = 0 ; i < Cfg::PAGE_COUNT ; i++) { bits_b[i >> state_bits] |= page_states[i] << ((i * state_bits) & 0x7); } diff --git a/Marlin/src/feature/direct_stepping.h b/Marlin/src/feature/direct_stepping.h index b3007731cdb2..962310281edb 100644 --- a/Marlin/src/feature/direct_stepping.h +++ b/Marlin/src/feature/direct_stepping.h @@ -68,10 +68,10 @@ namespace DirectStepping { static State state; static volatile bool fatal_error; - static volatile PageState page_states[Cfg::NUM_PAGES]; + static volatile PageState page_states[Cfg::PAGE_COUNT]; static volatile bool page_states_dirty; - static uint8_t pages[Cfg::NUM_PAGES][Cfg::PAGE_SIZE]; + static uint8_t pages[Cfg::PAGE_COUNT][Cfg::PAGE_SIZE]; static uint8_t checksum; static write_byte_idx_t write_byte_idx; static page_idx_t write_page_idx; @@ -87,8 +87,8 @@ namespace DirectStepping { struct config_t { static constexpr char CONTROL_CHAR = '!'; - static constexpr int NUM_PAGES = num_pages; - static constexpr int NUM_AXES = num_axes; + static constexpr int PAGE_COUNT = num_pages; + static constexpr int AXIS_COUNT = num_axes; static constexpr int BITS_SEGMENT = bits_segment; static constexpr int DIRECTIONAL = dir ? 1 : 0; static constexpr int SEGMENTS = segments; @@ -96,10 +96,10 @@ namespace DirectStepping { static constexpr int NUM_SEGMENTS = _BV(BITS_SEGMENT); static constexpr int SEGMENT_STEPS = _BV(BITS_SEGMENT - DIRECTIONAL) - 1; static constexpr int TOTAL_STEPS = SEGMENT_STEPS * SEGMENTS; - static constexpr int PAGE_SIZE = (NUM_AXES * BITS_SEGMENT * SEGMENTS) / 8; + static constexpr int PAGE_SIZE = (AXIS_COUNT * BITS_SEGMENT * SEGMENTS) / 8; typedef typename TypeSelector<(PAGE_SIZE>256), uint16_t, uint8_t>::type write_byte_idx_t; - typedef typename TypeSelector<(NUM_PAGES>256), uint16_t, uint8_t>::type page_idx_t; + typedef typename TypeSelector<(PAGE_COUNT>256), uint16_t, uint8_t>::type page_idx_t; }; template diff --git a/Marlin/src/feature/e_parser.h b/Marlin/src/feature/e_parser.h index 1dee0cf7550c..fda1ba144bc4 100644 --- a/Marlin/src/feature/e_parser.h +++ b/Marlin/src/feature/e_parser.h @@ -41,7 +41,9 @@ extern bool wait_for_user, wait_for_heatup; void quickresume_stepper(); #endif -void HAL_reboot(); +#if ENABLED(SOFT_RESET_VIA_SERIAL) + void HAL_reboot(); +#endif class EmergencyParser { diff --git a/Marlin/src/feature/easythreed_ui.cpp b/Marlin/src/feature/easythreed_ui.cpp index 9f8af039478c..b15daffc09be 100644 --- a/Marlin/src/feature/easythreed_ui.cpp +++ b/Marlin/src/feature/easythreed_ui.cpp @@ -194,11 +194,11 @@ void EasythreedUI::printButton() { print_key_flag = PF_START; return; // Bail out } - card.ls(); // List all files to serial output - const uint16_t filecnt = card.countFilesInWorkDir(); // Count printable files in cwd - if (filecnt == 0) return; // None are printable? - card.selectFileByIndex(filecnt); // Select the last file according to current sort options - card.openAndPrintFile(card.filename); // Start printing it + card.ls(); // List all files to serial output + const uint16_t filecnt = card.countFilesInWorkDir(); // Count printable files in cwd + if (filecnt == 0) return; // None are printable? + card.selectFileByIndex(filecnt); // Select the last file according to current sort options + card.openAndPrintFile(card.filename); // Start printing it break; } case PF_PAUSE: { // Pause printing (not currently firing) diff --git a/Marlin/src/feature/encoder_i2c.cpp b/Marlin/src/feature/encoder_i2c.cpp index 87e611f86c23..fa14c9ac715d 100644 --- a/Marlin/src/feature/encoder_i2c.cpp +++ b/Marlin/src/feature/encoder_i2c.cpp @@ -489,7 +489,7 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_stepper_ticks(I2CPE_ENC_1_TICKS_REV); #endif #ifdef I2CPE_ENC_1_INVERT - encoders[i].set_inverted(I2CPE_ENC_1_INVERT); + encoders[i].set_inverted(ENABLED(I2CPE_ENC_1_INVERT)); #endif #ifdef I2CPE_ENC_1_EC_METHOD encoders[i].set_ec_method(I2CPE_ENC_1_EC_METHOD); @@ -518,7 +518,7 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_stepper_ticks(I2CPE_ENC_2_TICKS_REV); #endif #ifdef I2CPE_ENC_2_INVERT - encoders[i].set_inverted(I2CPE_ENC_2_INVERT); + encoders[i].set_inverted(ENABLED(I2CPE_ENC_2_INVERT)); #endif #ifdef I2CPE_ENC_2_EC_METHOD encoders[i].set_ec_method(I2CPE_ENC_2_EC_METHOD); @@ -547,7 +547,7 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_stepper_ticks(I2CPE_ENC_3_TICKS_REV); #endif #ifdef I2CPE_ENC_3_INVERT - encoders[i].set_inverted(I2CPE_ENC_3_INVERT); + encoders[i].set_inverted(ENABLED(I2CPE_ENC_3_INVERT)); #endif #ifdef I2CPE_ENC_3_EC_METHOD encoders[i].set_ec_method(I2CPE_ENC_3_EC_METHOD); @@ -576,7 +576,7 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_stepper_ticks(I2CPE_ENC_4_TICKS_REV); #endif #ifdef I2CPE_ENC_4_INVERT - encoders[i].set_inverted(I2CPE_ENC_4_INVERT); + encoders[i].set_inverted(ENABLED(I2CPE_ENC_4_INVERT)); #endif #ifdef I2CPE_ENC_4_EC_METHOD encoders[i].set_ec_method(I2CPE_ENC_4_EC_METHOD); @@ -605,7 +605,7 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_stepper_ticks(I2CPE_ENC_5_TICKS_REV); #endif #ifdef I2CPE_ENC_5_INVERT - encoders[i].set_inverted(I2CPE_ENC_5_INVERT); + encoders[i].set_inverted(ENABLED(I2CPE_ENC_5_INVERT)); #endif #ifdef I2CPE_ENC_5_EC_METHOD encoders[i].set_ec_method(I2CPE_ENC_5_EC_METHOD); @@ -634,7 +634,7 @@ void I2CPositionEncodersMgr::init() { encoders[i].set_stepper_ticks(I2CPE_ENC_6_TICKS_REV); #endif #ifdef I2CPE_ENC_6_INVERT - encoders[i].set_inverted(I2CPE_ENC_6_INVERT); + encoders[i].set_inverted(ENABLED(I2CPE_ENC_6_INVERT)); #endif #ifdef I2CPE_ENC_6_EC_METHOD encoders[i].set_ec_method(I2CPE_ENC_6_EC_METHOD); @@ -756,7 +756,7 @@ int8_t I2CPositionEncodersMgr::parse() { if (!parser.has_value()) { SERIAL_ECHOLNPGM("?A seen, but no address specified! [30-200]"); return I2CPE_PARSE_ERR; - }; + } I2CPE_addr = parser.value_byte(); if (!WITHIN(I2CPE_addr, 30, 200)) { // reserve the first 30 and last 55 @@ -775,7 +775,7 @@ int8_t I2CPositionEncodersMgr::parse() { if (!parser.has_value()) { SERIAL_ECHOLNPGM("?I seen, but no index specified! [0-", I2CPE_ENCODER_CNT - 1, "]"); return I2CPE_PARSE_ERR; - }; + } I2CPE_idx = parser.value_byte(); if (I2CPE_idx >= I2CPE_ENCODER_CNT) { @@ -791,7 +791,7 @@ int8_t I2CPositionEncodersMgr::parse() { I2CPE_anyaxis = parser.seen_axis(); return I2CPE_PARSE_OK; -}; +} /** * M860: Report the position(s) of position encoder module(s). @@ -934,7 +934,7 @@ void I2CPositionEncodersMgr::M864() { if (!parser.has_value()) { SERIAL_ECHOLNPGM("?S seen, but no address specified! [30-200]"); return; - }; + } newAddress = parser.value_byte(); if (!WITHIN(newAddress, 30, 200)) { diff --git a/Marlin/src/feature/fancheck.cpp b/Marlin/src/feature/fancheck.cpp index 1b47fadecc31..126b79b0a409 100644 --- a/Marlin/src/feature/fancheck.cpp +++ b/Marlin/src/feature/fancheck.cpp @@ -34,7 +34,7 @@ #if HAS_AUTO_FAN && EXTRUDER_AUTO_FAN_SPEED != 255 && DISABLED(FOURWIRES_FANS) bool FanCheck::measuring = false; #endif -bool FanCheck::tacho_state[TACHO_COUNT]; +Flags FanCheck::tacho_state; uint16_t FanCheck::edge_counter[TACHO_COUNT]; uint8_t FanCheck::rps[TACHO_COUNT]; FanCheck::TachoError FanCheck::error = FanCheck::TachoError::NONE; @@ -103,7 +103,7 @@ void FanCheck::update_tachometers() { if (status != tacho_state[f]) { if (measuring) ++edge_counter[f]; - tacho_state[f] = status; + tacho_state.set(f, status); } } } diff --git a/Marlin/src/feature/fancheck.h b/Marlin/src/feature/fancheck.h index 6e8038b498e7..b13a34fb19eb 100644 --- a/Marlin/src/feature/fancheck.h +++ b/Marlin/src/feature/fancheck.h @@ -51,12 +51,12 @@ class FanCheck { #else static constexpr bool measuring = true; #endif - static bool tacho_state[TACHO_COUNT]; + static Flags tacho_state; static uint16_t edge_counter[TACHO_COUNT]; static uint8_t rps[TACHO_COUNT]; static TachoError error; - static inline void report_speed_error(uint8_t fan); + static void report_speed_error(uint8_t fan); public: @@ -67,11 +67,11 @@ class FanCheck { static void compute_speed(uint16_t elapsedTime); static void print_fan_states(); #if HAS_PWMFANCHECK - static inline void toggle_measuring() { measuring = !measuring; } - static inline bool is_measuring() { return measuring; } + static void toggle_measuring() { measuring = !measuring; } + static bool is_measuring() { return measuring; } #endif - static inline void check_deferred_error() { + static void check_deferred_error() { if (error == TachoError::DETECTED) { error = TachoError::REPORTED; TERN(PARK_HEAD_ON_PAUSE, queue.inject(F("M125")), kill(GET_TEXT_F(MSG_FAN_SPEED_FAULT))); diff --git a/Marlin/src/feature/filwidth.h b/Marlin/src/feature/filwidth.h index e63d3d719ffb..9eb1e77762ff 100644 --- a/Marlin/src/feature/filwidth.h +++ b/Marlin/src/feature/filwidth.h @@ -41,9 +41,9 @@ class FilamentWidthSensor { FilamentWidthSensor() { init(); } static void init(); - static inline void enable(const bool ena) { enabled = ena; } + static void enable(const bool ena) { enabled = ena; } - static inline void set_delay_cm(const uint8_t cm) { + static void set_delay_cm(const uint8_t cm) { meas_delay_cm = _MIN(cm, MAX_MEASUREMENT_DELAY); } @@ -67,18 +67,18 @@ class FilamentWidthSensor { } // Convert raw measurement to mm - static inline float raw_to_mm(const uint16_t v) { return v * 5.0f * RECIPROCAL(float(MAX_RAW_THERMISTOR_VALUE)); } - static inline float raw_to_mm() { return raw_to_mm(raw); } + static float raw_to_mm(const uint16_t v) { return v * float(ADC_VREF) * RECIPROCAL(float(MAX_RAW_THERMISTOR_VALUE)); } + static float raw_to_mm() { return raw_to_mm(raw); } // A scaled reading is ready // Divide to get to 0-16384 range since we used 1/128 IIR filter approach - static inline void reading_ready() { raw = accum >> 10; } + static void reading_ready() { raw = accum >> 10; } // Update mm from the raw measurement - static inline void update_measured_mm() { measured_mm = raw_to_mm(); } + static void update_measured_mm() { measured_mm = raw_to_mm(); } // Update ring buffer used to delay filament measurements - static inline void advance_e(const_float_t e_move) { + static void advance_e(const_float_t e_move) { // Increment counters with the E distance e_count += e_move; @@ -106,7 +106,7 @@ class FilamentWidthSensor { } // Dynamically set the volumetric multiplier based on the delayed width measurement. - static inline void update_volumetric() { + static void update_volumetric() { if (enabled) { int8_t read_index = index_r - meas_delay_cm; if (read_index < 0) read_index += MMD_CM; // Loop around buffer if needed diff --git a/Marlin/src/feature/fwretract.cpp b/Marlin/src/feature/fwretract.cpp index 4077d8d1c209..172c97accdda 100644 --- a/Marlin/src/feature/fwretract.cpp +++ b/Marlin/src/feature/fwretract.cpp @@ -45,7 +45,7 @@ FWRetract fwretract; // Single instance - this calls the constructor // private: #if HAS_MULTI_EXTRUDER - bool FWRetract::retracted_swap[EXTRUDERS]; // Which extruders are swap-retracted + Flags FWRetract::retracted_swap; // Which extruders are swap-retracted #endif // public: @@ -56,7 +56,7 @@ fwretract_settings_t FWRetract::settings; // M207 S F Z W, M208 S F bool FWRetract::autoretract_enabled; // M209 S - Autoretract switch #endif -bool FWRetract::retracted[EXTRUDERS]; // Which extruders are currently retracted +Flags FWRetract::retracted; // Which extruders are currently retracted float FWRetract::current_retract[EXTRUDERS], // Retract value used by planner FWRetract::current_hop; @@ -73,10 +73,10 @@ void FWRetract::reset() { settings.swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP; current_hop = 0.0; - LOOP_L_N(i, EXTRUDERS) { - retracted[i] = false; - E_TERN_(retracted_swap[i] = false); - current_retract[i] = 0.0; + retracted.reset(); + EXTRUDER_LOOP() { + E_TERN_(retracted_swap.clear(e)); + current_retract[e] = 0.0; } } @@ -111,10 +111,10 @@ void FWRetract::retract(const bool retracting E_OPTARG(bool swapping/*=false*/)) " swapping ", swapping, " active extruder ", active_extruder ); - LOOP_L_N(i, EXTRUDERS) { - SERIAL_ECHOLNPGM("retracted[", i, "] ", AS_DIGIT(retracted[i])); + EXTRUDER_LOOP() { + SERIAL_ECHOLNPGM("retracted[", e, "] ", AS_DIGIT(retracted[e])); #if HAS_MULTI_EXTRUDER - SERIAL_ECHOLNPGM("retracted_swap[", i, "] ", AS_DIGIT(retracted_swap[i])); + SERIAL_ECHOLNPGM("retracted_swap[", e, "] ", AS_DIGIT(retracted_swap[e])); #endif } SERIAL_ECHOLNPGM("current_position.z ", current_position.z); @@ -173,21 +173,21 @@ void FWRetract::retract(const bool retracting E_OPTARG(bool swapping/*=false*/)) TERN_(RETRACT_SYNC_MIXING, mixer.T(old_mixing_tool)); // Restore original mixing tool - retracted[active_extruder] = retracting; // Active extruder now retracted / recovered + retracted.set(active_extruder, retracting); // Active extruder now retracted / recovered // If swap retract/recover update the retracted_swap flag too #if HAS_MULTI_EXTRUDER - if (swapping) retracted_swap[active_extruder] = retracting; + if (swapping) retracted_swap.set(active_extruder, retracting); #endif /* // debugging SERIAL_ECHOLNPGM("retracting ", AS_DIGIT(retracting)); SERIAL_ECHOLNPGM("swapping ", AS_DIGIT(swapping)); SERIAL_ECHOLNPGM("active_extruder ", active_extruder); - LOOP_L_N(i, EXTRUDERS) { - SERIAL_ECHOLNPGM("retracted[", i, "] ", AS_DIGIT(retracted[i])); + EXTRUDER_LOOP() { + SERIAL_ECHOLNPGM("retracted[", e, "] ", AS_DIGIT(retracted[e])); #if HAS_MULTI_EXTRUDER - SERIAL_ECHOLNPGM("retracted_swap[", i, "] ", AS_DIGIT(retracted_swap[i])); + SERIAL_ECHOLNPGM("retracted_swap[", e, "] ", AS_DIGIT(retracted_swap[e])); #endif } SERIAL_ECHOLNPGM("current_position.z ", current_position.z); diff --git a/Marlin/src/feature/fwretract.h b/Marlin/src/feature/fwretract.h index d6d0432e3aa7..db2a62c8d410 100644 --- a/Marlin/src/feature/fwretract.h +++ b/Marlin/src/feature/fwretract.h @@ -43,7 +43,7 @@ typedef struct { class FWRetract { private: #if HAS_MULTI_EXTRUDER - static bool retracted_swap[EXTRUDERS]; // Which extruders are swap-retracted + static Flags retracted_swap; // Which extruders are swap-retracted #endif public: @@ -55,7 +55,7 @@ class FWRetract { static constexpr bool autoretract_enabled = false; #endif - static bool retracted[EXTRUDERS]; // Which extruders are currently retracted + static Flags retracted; // Which extruders are currently retracted static float current_retract[EXTRUDERS], // Retract value used by planner current_hop; // Hop value used by planner @@ -63,9 +63,7 @@ class FWRetract { static void reset(); - static void refresh_autoretract() { - LOOP_L_N(i, EXTRUDERS) retracted[i] = false; - } + static void refresh_autoretract() { retracted.reset(); } static void enable_autoretract(const bool enable) { #if ENABLED(FWRETRACT_AUTORETRACT) diff --git a/Marlin/src/feature/host_actions.cpp b/Marlin/src/feature/host_actions.cpp index be7b055b55f7..c03a6bc5976e 100644 --- a/Marlin/src/feature/host_actions.cpp +++ b/Marlin/src/feature/host_actions.cpp @@ -39,10 +39,7 @@ HostUI hostui; -flag_t HostUI::flag; - void HostUI::action(FSTR_P const fstr, const bool eol) { - if (!flag.bits) return; PORT_REDIRECT(SerialMask::All); SERIAL_ECHOPGM("//action:"); SERIAL_ECHOF(fstr); @@ -96,21 +93,18 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { #endif void HostUI::notify(const char * const cstr) { - if (!flag.bits) return; PORT_REDIRECT(SerialMask::All); action(F("notification "), false); SERIAL_ECHOLN(cstr); } void HostUI::notify_P(PGM_P const pstr) { - if (!flag.bits) return; PORT_REDIRECT(SerialMask::All); action(F("notification "), false); SERIAL_ECHOLNPGM_P(pstr); } void HostUI::prompt(FSTR_P const ptype, const bool eol/*=true*/) { - if (!flag.bits) return; PORT_REDIRECT(SerialMask::All); action(F("prompt_"), false); SERIAL_ECHOF(ptype); @@ -118,7 +112,6 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { } void HostUI::prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char/*='\0'*/) { - if (!flag.bits) return; prompt(ptype, false); PORT_REDIRECT(SerialMask::All); SERIAL_CHAR(' '); @@ -127,7 +120,6 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { SERIAL_EOL(); } void HostUI::prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char/*='\0'*/) { - if (!flag.bits) return; prompt_end(); host_prompt_reason = reason; prompt_plus(F("begin"), fstr, extra_char); diff --git a/Marlin/src/feature/host_actions.h b/Marlin/src/feature/host_actions.h index 45379afc29ec..41d66b82ec9b 100644 --- a/Marlin/src/feature/host_actions.h +++ b/Marlin/src/feature/host_actions.h @@ -24,11 +24,6 @@ #include "../inc/MarlinConfigPre.h" #include "../HAL/shared/Marduino.h" -typedef union { - uint8_t bits; - struct { bool info:1, errors:1, debug:1; }; -} flag_t; - #if ENABLED(HOST_PROMPT_SUPPORT) enum PromptReason : uint8_t { @@ -45,9 +40,6 @@ typedef union { class HostUI { public: - static flag_t flag; - HostUI() { flag.bits = 0xFF; } - static void action(FSTR_P const fstr, const bool eol=true); #ifdef ACTION_ON_KILL @@ -97,7 +89,7 @@ class HostUI { static void handle_response(const uint8_t response); static void notify_P(PGM_P const message); - static inline void notify(FSTR_P const fmsg) { notify_P(FTOP(fmsg)); } + static void notify(FSTR_P const fmsg) { notify_P(FTOP(fmsg)); } static void notify(const char * const message); static void prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char='\0'); @@ -105,7 +97,7 @@ class HostUI { static void prompt_end(); 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, FSTR_P const pstr, const char extra_char, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr); - static inline void prompt_open(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr) { + static void prompt_open(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr) { if (host_prompt_reason == PROMPT_NOT_DEFINED) prompt_do(reason, pstr, btn1, btn2); } diff --git a/Marlin/src/feature/joystick.cpp b/Marlin/src/feature/joystick.cpp index 7f91c1549b9e..c68a2b8df90a 100644 --- a/Marlin/src/feature/joystick.cpp +++ b/Marlin/src/feature/joystick.cpp @@ -68,13 +68,13 @@ Joystick joystick; void Joystick::report() { SERIAL_ECHOPGM("Joystick"); #if HAS_JOY_ADC_X - SERIAL_ECHOPGM_P(SP_X_STR, JOY_X(x.raw)); + SERIAL_ECHOPGM_P(SP_X_STR, JOY_X(x.getraw())); #endif #if HAS_JOY_ADC_Y - SERIAL_ECHOPGM_P(SP_Y_STR, JOY_Y(y.raw)); + SERIAL_ECHOPGM_P(SP_Y_STR, JOY_Y(y.getraw())); #endif #if HAS_JOY_ADC_Z - SERIAL_ECHOPGM_P(SP_Z_STR, JOY_Z(z.raw)); + SERIAL_ECHOPGM_P(SP_Z_STR, JOY_Z(z.getraw())); #endif #if HAS_JOY_ADC_EN SERIAL_ECHO_TERNARY(READ(JOY_EN_PIN), " EN=", "HIGH (dis", "LOW (en", "abled)"); @@ -91,29 +91,29 @@ Joystick joystick; if (READ(JOY_EN_PIN)) return; #endif - auto _normalize_joy = [](float &axis_jog, const int16_t raw, const int16_t (&joy_limits)[4]) { + auto _normalize_joy = [](float &axis_jog, const raw_adc_t raw, const raw_adc_t (&joy_limits)[4]) { if (WITHIN(raw, joy_limits[0], joy_limits[3])) { // within limits, check deadzone if (raw > joy_limits[2]) axis_jog = (raw - joy_limits[2]) / float(joy_limits[3] - joy_limits[2]); else if (raw < joy_limits[1]) - axis_jog = (raw - joy_limits[1]) / float(joy_limits[1] - joy_limits[0]); // negative value + axis_jog = int16_t(raw - joy_limits[1]) / float(joy_limits[1] - joy_limits[0]); // negative value // Map normal to jog value via quadratic relationship axis_jog = SIGN(axis_jog) * sq(axis_jog); } }; #if HAS_JOY_ADC_X - static constexpr int16_t joy_x_limits[4] = JOY_X_LIMITS; - _normalize_joy(norm_jog.x, JOY_X(x.raw), joy_x_limits); + static constexpr raw_adc_t joy_x_limits[4] = JOY_X_LIMITS; + _normalize_joy(norm_jog.x, JOY_X(x.getraw()), joy_x_limits); #endif #if HAS_JOY_ADC_Y - static constexpr int16_t joy_y_limits[4] = JOY_Y_LIMITS; - _normalize_joy(norm_jog.y, JOY_Y(y.raw), joy_y_limits); + static constexpr raw_adc_t joy_y_limits[4] = JOY_Y_LIMITS; + _normalize_joy(norm_jog.y, JOY_Y(y.getraw()), joy_y_limits); #endif #if HAS_JOY_ADC_Z - static constexpr int16_t joy_z_limits[4] = JOY_Z_LIMITS; - _normalize_joy(norm_jog.z, JOY_Z(z.raw), joy_z_limits); + static constexpr raw_adc_t joy_z_limits[4] = JOY_Z_LIMITS; + _normalize_joy(norm_jog.z, JOY_Z(z.getraw()), joy_z_limits); #endif } diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index 17d790b8cc9a..2a53a7c884e6 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -42,7 +42,7 @@ #include "pca9533.h" #endif -#if ENABLED(CASE_LIGHT_USE_RGB_LED) +#if EITHER(CASE_LIGHT_USE_RGB_LED, CASE_LIGHT_USE_NEOPIXEL) #include "../../feature/caselight.h" #endif @@ -95,6 +95,10 @@ void LEDLights::set_color(const LEDColor &incol #endif #endif + #if BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) + // Update brightness only if caselight is ON or switching leds off + if (caselight.on || incol.is_off()) + #endif neo.set_brightness(incol.i); #if ENABLED(NEOPIXEL_IS_SEQUENTIAL) @@ -106,6 +110,10 @@ void LEDLights::set_color(const LEDColor &incol } #endif + #if BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) + // Update color only if caselight is ON or switching leds off + if (caselight.on || incol.is_off()) + #endif neo.set_color(neocolor); #endif @@ -121,11 +129,11 @@ void LEDLights::set_color(const LEDColor &incol // This variant uses 3-4 separate pins for the RGB(W) components. // If the pins can do PWM then their intensity will be set. - #define _UPDATE_RGBW(C,c) do { \ - if (PWM_PIN(RGB_LED_##C##_PIN)) \ - set_pwm_duty(pin_t(RGB_LED_##C##_PIN), c); \ - else \ - WRITE(RGB_LED_##C##_PIN, c ? HIGH : LOW); \ + #define _UPDATE_RGBW(C,c) do { \ + if (PWM_PIN(RGB_LED_##C##_PIN)) \ + hal.set_pwm_duty(pin_t(RGB_LED_##C##_PIN), c); \ + else \ + WRITE(RGB_LED_##C##_PIN, c ? HIGH : LOW); \ }while(0) #define UPDATE_RGBW(C,c) _UPDATE_RGBW(C, TERN1(CASE_LIGHT_USE_RGB_LED, caselight.on) ? incol.c : 0) UPDATE_RGBW(R,r); UPDATE_RGBW(G,g); UPDATE_RGBW(B,b); @@ -150,7 +158,7 @@ void LEDLights::set_color(const LEDColor &incol void LEDLights::toggle() { if (lights_on) set_off(); else update(); } #endif -#ifdef LED_BACKLIGHT_TIMEOUT +#if LED_POWEROFF_TIMEOUT > 0 millis_t LEDLights::led_off_time; // = 0 diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 74964b51a8e4..8649dd014fbf 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -54,6 +54,8 @@ typedef struct LEDColor { OPTARG(NEOPIXEL_LED, i(NEOPIXEL_BRIGHTNESS)) {} + LEDColor(const LEDColor&) = default; + LEDColor(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w=0) OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS)) : r(r), g(g), b(b) OPTARG(HAS_WHITE_LED, w(w)) OPTARG(NEOPIXEL_LED, i(i)) {} @@ -68,11 +70,6 @@ typedef struct LEDColor { return *this; } - LEDColor& operator=(const LEDColor &right) { - if (this != &right) memcpy(this, &right, sizeof(LEDColor)); - return *this; - } - bool operator==(const LEDColor &right) { if (this == &right) return true; return 0 == memcmp(this, &right, sizeof(LEDColor)); @@ -118,7 +115,7 @@ class LEDLights { OPTARG(NEOPIXEL_IS_SEQUENTIAL, bool isSequence=false) ); - static inline void set_color(uint8_t r, uint8_t g, uint8_t b + static void set_color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w=0) OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS) OPTARG(NEOPIXEL_IS_SEQUENTIAL, bool isSequence=false) @@ -126,23 +123,23 @@ class LEDLights { set_color(LEDColor(r, g, b OPTARG(HAS_WHITE_LED, w) OPTARG(NEOPIXEL_LED, i)) OPTARG(NEOPIXEL_IS_SEQUENTIAL, isSequence)); } - static inline void set_off() { set_color(LEDColorOff()); } - static inline void set_green() { set_color(LEDColorGreen()); } - static inline void set_white() { set_color(LEDColorWhite()); } + static void set_off() { set_color(LEDColorOff()); } + static void set_green() { set_color(LEDColorGreen()); } + static void set_white() { set_color(LEDColorWhite()); } #if ENABLED(LED_COLOR_PRESETS) static const LEDColor defaultLEDColor; - static inline void set_default() { set_color(defaultLEDColor); } - static inline void set_red() { set_color(LEDColorRed()); } - static inline void set_orange() { set_color(LEDColorOrange()); } - static inline void set_yellow() { set_color(LEDColorYellow()); } - static inline void set_blue() { set_color(LEDColorBlue()); } - static inline void set_indigo() { set_color(LEDColorIndigo()); } - static inline void set_violet() { set_color(LEDColorViolet()); } + static void set_default() { set_color(defaultLEDColor); } + static void set_red() { set_color(LEDColorRed()); } + static void set_orange() { set_color(LEDColorOrange()); } + static void set_yellow() { set_color(LEDColorYellow()); } + static void set_blue() { set_color(LEDColorBlue()); } + static void set_indigo() { set_color(LEDColorIndigo()); } + static void set_violet() { set_color(LEDColorViolet()); } #endif #if ENABLED(PRINTER_EVENT_LEDS) - static inline LEDColor get_color() { return lights_on ? color : LEDColorOff(); } + static LEDColor get_color() { return lights_on ? color : LEDColorOff(); } #endif #if ANY(LED_CONTROL_MENU, PRINTER_EVENT_LEDS, CASE_LIGHT_IS_COLOR_LED) @@ -154,15 +151,15 @@ class LEDLights { static void toggle(); // swap "off" with color #endif #if EITHER(LED_CONTROL_MENU, CASE_LIGHT_USE_RGB_LED) - static inline void update() { set_color(color); } + static void update() { set_color(color); } #endif - #ifdef LED_BACKLIGHT_TIMEOUT + #if LED_POWEROFF_TIMEOUT > 0 private: static millis_t led_off_time; public: - static inline void reset_timeout(const millis_t &ms) { - led_off_time = ms + LED_BACKLIGHT_TIMEOUT; + static void reset_timeout(const millis_t &ms) { + led_off_time = ms + LED_POWEROFF_TIMEOUT; if (!lights_on) update(); } static void update_timeout(const bool power_on); @@ -181,7 +178,7 @@ extern LEDLights leds; static void set_color(const LEDColor &color); - static inline void set_color(uint8_t r, uint8_t g, uint8_t b + static void set_color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w=0) OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS) ) { @@ -191,26 +188,26 @@ extern LEDLights leds; )); } - static inline void set_off() { set_color(LEDColorOff()); } - static inline void set_green() { set_color(LEDColorGreen()); } - static inline void set_white() { set_color(LEDColorWhite()); } + static void set_off() { set_color(LEDColorOff()); } + static void set_green() { set_color(LEDColorGreen()); } + static void set_white() { set_color(LEDColorWhite()); } #if ENABLED(NEO2_COLOR_PRESETS) static const LEDColor defaultLEDColor; - static inline void set_default() { set_color(defaultLEDColor); } - static inline void set_red() { set_color(LEDColorRed()); } - static inline void set_orange() { set_color(LEDColorOrange()); } - static inline void set_yellow() { set_color(LEDColorYellow()); } - static inline void set_blue() { set_color(LEDColorBlue()); } - static inline void set_indigo() { set_color(LEDColorIndigo()); } - static inline void set_violet() { set_color(LEDColorViolet()); } + static void set_default() { set_color(defaultLEDColor); } + static void set_red() { set_color(LEDColorRed()); } + static void set_orange() { set_color(LEDColorOrange()); } + static void set_yellow() { set_color(LEDColorYellow()); } + static void set_blue() { set_color(LEDColorBlue()); } + static void set_indigo() { set_color(LEDColorIndigo()); } + static void set_violet() { set_color(LEDColorViolet()); } #endif #if ENABLED(NEOPIXEL2_SEPARATE) static LEDColor color; // last non-off color static bool lights_on; // the last set color was "on" static void toggle(); // swap "off" with color - static inline void update() { set_color(color); } + static void update() { set_color(color); } #endif }; diff --git a/Marlin/src/feature/leds/neopixel.cpp b/Marlin/src/feature/leds/neopixel.cpp index 3569cb180d53..4f104234f15c 100644 --- a/Marlin/src/feature/leds/neopixel.cpp +++ b/Marlin/src/feature/leds/neopixel.cpp @@ -44,14 +44,14 @@ Adafruit_NeoPixel Marlin_NeoPixel::adaneo1(NEOPIXEL_PIXELS, NEOPIXEL_PIN, NEOPIX #ifdef NEOPIXEL_BKGD_INDEX_FIRST - void Marlin_NeoPixel::set_background_color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) { - for (int background_led = NEOPIXEL_BKGD_INDEX_FIRST; background_led <= NEOPIXEL_BKGD_INDEX_LAST; background_led++) + void Marlin_NeoPixel::set_background_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w) { + for (int background_led = NEOPIXEL_BKGD_INDEX_FIRST; background_led <= NEOPIXEL_BKGD_INDEX_LAST; background_led++) set_pixel_color(background_led, adaneo1.Color(r, g, b, w)); } void Marlin_NeoPixel::reset_background_color() { constexpr uint8_t background_color[4] = NEOPIXEL_BKGD_COLOR; - set_background_color(background_color[0], background_color[1], background_color[2], background_color[3]); + set_background_color(background_color); } #endif @@ -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), - (0, 0, 0, 0)) + (255, 255, 255, 255)) ); } diff --git a/Marlin/src/feature/leds/neopixel.h b/Marlin/src/feature/leds/neopixel.h index 814ae9c8d839..d71aa25770fc 100644 --- a/Marlin/src/feature/leds/neopixel.h +++ b/Marlin/src/feature/leds/neopixel.h @@ -25,8 +25,6 @@ * NeoPixel support */ -#define MAX_NEOPIXELS 127 - #ifndef _NEOPIXEL_INCLUDE_ #error "Always include 'leds.h' and not 'neopixel.h' directly." #endif @@ -68,7 +66,7 @@ // Types // ------------------------ -typedef IF<(MAX_NEOPIXELS > 127), int16_t, int8_t>::type pixel_index_t; +typedef IF<(TERN0(NEOPIXEL_LED, NEOPIXEL_PIXELS > 127)), int16_t, int8_t>::type pixel_index_t; // ------------------------ // Classes @@ -90,16 +88,17 @@ class Marlin_NeoPixel { static void set_color(const uint32_t c); #ifdef NEOPIXEL_BKGD_INDEX_FIRST - static void set_background_color(uint8_t r, uint8_t g, uint8_t b, uint8_t w); + static void set_background_color(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t w); + static void set_background_color(const uint8_t (&rgbw)[4]) { set_background_color(rgbw[0], rgbw[1], rgbw[2], rgbw[3]); } static void reset_background_color(); #endif - static inline void begin() { + static void begin() { adaneo1.begin(); TERN_(CONJOINED_NEOPIXEL, adaneo2.begin()); } - static inline void set_pixel_color(const uint16_t n, const uint32_t c) { + static void set_pixel_color(const uint16_t n, const uint32_t c) { #if ENABLED(NEOPIXEL2_INSERIES) if (n >= NEOPIXEL_PIXELS) adaneo2.setPixelColor(n - (NEOPIXEL_PIXELS), c); else adaneo1.setPixelColor(n, c); @@ -109,12 +108,12 @@ class Marlin_NeoPixel { #endif } - static inline void set_brightness(const uint8_t b) { + static void set_brightness(const uint8_t b) { adaneo1.setBrightness(b); TERN_(CONJOINED_NEOPIXEL, adaneo2.setBrightness(b)); } - static inline void show() { + static void show() { // Some platforms cannot maintain PWM output when NeoPixel disables interrupts for long durations. TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT()); adaneo1.show(); @@ -130,11 +129,11 @@ class Marlin_NeoPixel { } // Accessors - static inline uint16_t pixels() { return adaneo1.numPixels() * TERN1(NEOPIXEL2_INSERIES, 2); } + static uint16_t pixels() { return adaneo1.numPixels() * TERN1(NEOPIXEL2_INSERIES, 2); } - static inline uint8_t brightness() { return adaneo1.getBrightness(); } + static uint8_t brightness() { return adaneo1.getBrightness(); } - static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w)) { + static uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w)) { return adaneo1.Color(r, g, b OPTARG(HAS_WHITE_LED, w)); } }; @@ -165,18 +164,18 @@ extern Marlin_NeoPixel neo; static void set_color(const uint32_t c); - static inline void begin() { adaneo.begin(); } - static inline void set_pixel_color(const uint16_t n, const uint32_t c) { adaneo.setPixelColor(n, c); } - static inline void set_brightness(const uint8_t b) { adaneo.setBrightness(b); } - static inline void show() { + static void begin() { adaneo.begin(); } + static void set_pixel_color(const uint16_t n, const uint32_t c) { adaneo.setPixelColor(n, c); } + static void set_brightness(const uint8_t b) { adaneo.setBrightness(b); } + static void show() { adaneo.show(); adaneo.setPin(NEOPIXEL2_PIN); } // Accessors - static inline uint16_t pixels() { return adaneo.numPixels();} - static inline uint8_t brightness() { return adaneo.getBrightness(); } - static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED2, uint8_t w)) { + static uint16_t pixels() { return adaneo.numPixels();} + 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/printer_event_leds.h b/Marlin/src/feature/leds/printer_event_leds.h index b2201433d821..2a4342e8f55c 100644 --- a/Marlin/src/feature/leds/printer_event_leds.h +++ b/Marlin/src/feature/leds/printer_event_leds.h @@ -36,32 +36,32 @@ class PrinterEventLEDs { static bool leds_off_after_print; #endif - static inline void set_done() { TERN(LED_COLOR_PRESETS, leds.set_default(), leds.set_off()); } + static void set_done() { TERN(LED_COLOR_PRESETS, leds.set_default(), leds.set_off()); } public: #if HAS_TEMP_HOTEND - static inline LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); } + static LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); } static void onHotendHeating(const celsius_t start, const celsius_t current, const celsius_t target); #endif #if HAS_HEATED_BED - static inline LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); } + static LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); } static void onBedHeating(const celsius_t start, const celsius_t current, const celsius_t target); #endif #if HAS_HEATED_CHAMBER - static inline LEDColor onChamberHeatingStart() { old_intensity = 127; return leds.get_color(); } + static LEDColor onChamberHeatingStart() { old_intensity = 127; return leds.get_color(); } static void onChamberHeating(const celsius_t start, const celsius_t current, const celsius_t target); #endif #if HAS_TEMP_HOTEND || HAS_HEATED_BED || HAS_HEATED_CHAMBER - static inline void onHeatingDone() { leds.set_white(); } - static inline void onPidTuningDone(LEDColor c) { leds.set_color(c); } + static void onHeatingDone() { leds.set_white(); } + static void onPidTuningDone(LEDColor c) { leds.set_color(c); } #endif #if ENABLED(SDSUPPORT) - static inline void onPrintCompleted() { + static void onPrintCompleted() { leds.set_green(); #if HAS_LEDS_OFF_FLAG leds_off_after_print = true; @@ -71,7 +71,7 @@ class PrinterEventLEDs { #endif } - static inline void onResumeAfterWait() { + static void onResumeAfterWait() { #if HAS_LEDS_OFF_FLAG if (leds_off_after_print) { set_done(); diff --git a/Marlin/src/feature/max7219.h b/Marlin/src/feature/max7219.h index c25fef173060..809bda6d4b35 100644 --- a/Marlin/src/feature/max7219.h +++ b/Marlin/src/feature/max7219.h @@ -88,13 +88,13 @@ class Max7219 { static void send(const uint8_t reg, const uint8_t data); // Refresh all units - static inline void refresh() { for (uint8_t i = 0; i < 8; i++) refresh_line(i); } + static void refresh() { for (uint8_t i = 0; i < 8; i++) refresh_line(i); } // Suspend / resume updates to the LED unit // Use these methods to speed up multiple changes // or to apply updates from interrupt context. - static inline void suspend() { suspended++; } - static inline void resume() { suspended--; suspended |= 0x80; } + static void suspend() { suspended++; } + static void resume() { suspended--; suspended |= 0x80; } // Update a single native line on all units static void refresh_line(const uint8_t line); diff --git a/Marlin/src/feature/meatpack.cpp b/Marlin/src/feature/meatpack.cpp index b2899243b2fb..07ff41e5be22 100644 --- a/Marlin/src/feature/meatpack.cpp +++ b/Marlin/src/feature/meatpack.cpp @@ -26,7 +26,7 @@ * Algorithm & Implementation: Scott Mudge - mail@scottmudge.com * Date: Dec. 2020 * - * Character Frequencies from ~30 MB of comment-stripped gcode: + * Character Frequencies from ~30 MB of comment-stripped G-code: * '1' -> 4451136 '4' -> 1353273 '\n' -> 1087683 '-' -> 90242 * '0' -> 4253577 '9' -> 1352147 'G' -> 1075806 'Z' -> 34109 * ' ' -> 3053297 '3' -> 1262929 'X' -> 975742 'M' -> 11879 diff --git a/Marlin/src/feature/meatpack.h b/Marlin/src/feature/meatpack.h index a56e65b6cc30..98a535e5923f 100644 --- a/Marlin/src/feature/meatpack.h +++ b/Marlin/src/feature/meatpack.h @@ -29,7 +29,7 @@ * Specifically optimized for 3D printing G-Code, this is a zero-cost data compression method * which packs ~180-190% more data into the same amount of bytes going to the CNC controller. * As a majority of G-Code can be represented by a restricted alphabet, I performed histogram - * analysis on a wide variety of 3D printing gcode samples, and found ~93% of all gcode could + * analysis on a wide variety of 3D printing G-code samples, and found ~93% of all G-code could * be represented by the same 15-character alphabet. * * This allowed me to design a system of packing 2 8-bit characters into a single byte, assuming @@ -38,7 +38,7 @@ * * Combined with some logic to allow commingling of full-width characters outside of this 15- * character alphabet (at the cost of an extra 8-bits per full-width character), and by stripping - * out unnecessary comments, the end result is gcode which is roughly half the original size. + * out unnecessary comments, the end result is G-code which is roughly half the original size. * * Why did I do this? I noticed micro-stuttering and other data-bottleneck issues while printing * objects with high curvature, especially at high speeds. There is also the issue of the limited diff --git a/Marlin/src/feature/mixing.cpp b/Marlin/src/feature/mixing.cpp index 9ebc90127f43..b1a069e3205e 100644 --- a/Marlin/src/feature/mixing.cpp +++ b/Marlin/src/feature/mixing.cpp @@ -63,7 +63,7 @@ void Mixer::normalize(const uint8_t tool_index) { #ifdef MIXER_NORMALIZER_DEBUG SERIAL_ECHOPGM("Mixer: Old relation : [ "); MIXER_STEPPER_LOOP(i) { - SERIAL_ECHO_F(collector[i] / csum, 3); + SERIAL_DECIMAL(collector[i] / csum); SERIAL_CHAR(' '); } SERIAL_ECHOLNPGM("]"); diff --git a/Marlin/src/feature/mixing.h b/Marlin/src/feature/mixing.h index f700c7b65b7d..85d52d69c8f3 100644 --- a/Marlin/src/feature/mixing.h +++ b/Marlin/src/feature/mixing.h @@ -126,7 +126,7 @@ class Mixer { static mixer_perc_t mix[MIXING_STEPPERS]; // Scratch array for the Mix in proportion to 100 - static inline void copy_mix_to_color(mixer_comp_t (&tcolor)[MIXING_STEPPERS]) { + static void copy_mix_to_color(mixer_comp_t (&tcolor)[MIXING_STEPPERS]) { // Scale each component to the largest one in terms of COLOR_A_MASK // So the largest component will be COLOR_A_MASK and the other will be in proportion to it const float scale = (COLOR_A_MASK) * RECIPROCAL(_MAX( @@ -145,7 +145,7 @@ class Mixer { #endif } - static inline void update_mix_from_vtool(const uint8_t j=selected_vtool) { + 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; @@ -165,7 +165,7 @@ class Mixer { #if HAS_DUAL_MIXING // Update the virtual tool from an edited mix - static inline void update_vtool_from_mix() { + static void update_vtool_from_mix() { copy_mix_to_color(color[selected_vtool]); TERN_(GRADIENT_MIX, refresh_gradient()); // MIXER_STEPPER_LOOP(i) collector[i] = mix[i]; @@ -182,7 +182,7 @@ class Mixer { // Update the current mix from the gradient for a given Z static void update_gradient_for_z(const_float_t z); static void update_gradient_for_planner_z(); - static inline void gradient_control(const_float_t z) { + static void gradient_control(const_float_t z) { if (gradient.enabled) { if (z >= gradient.end_z) T(gradient.end_vtool); @@ -191,7 +191,7 @@ class Mixer { } } - static inline void update_mix_from_gradient() { + static void update_mix_from_gradient() { float ctot = 0; MIXER_STEPPER_LOOP(i) ctot += gradient.color[i]; MIXER_STEPPER_LOOP(i) mix[i] = (mixer_perc_t)CEIL(100.0f * gradient.color[i] / ctot); diff --git a/Marlin/src/feature/mmu/mmu2-serial-protocol.md b/Marlin/src/feature/mmu/mmu2-serial-protocol.md index 7ff0901742af..93135e406f36 100644 --- a/Marlin/src/feature/mmu/mmu2-serial-protocol.md +++ b/Marlin/src/feature/mmu/mmu2-serial-protocol.md @@ -51,7 +51,7 @@ When done, the MMU sends - MMU => 'ok\n' -We don't wait for a response here but immediately continue with the next gcode which should +We don't wait for a response here but immediately continue with the next G-code which should be one or more extruder moves to feed the filament into the hotend. diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 2813337c635b..a4718b53d9d8 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -143,6 +143,11 @@ uint8_t MMU2::get_current_tool() { #define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE) #endif +void mmu2_attn_buzz(const bool two=false) { + BUZZ(200, 404); + if (two) { BUZZ(10, 0); BUZZ(200, 404); } +} + void MMU2::mmu_loop() { switch (state) { @@ -525,7 +530,7 @@ static void mmu2_not_responding() { while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); load_filament_to_nozzle(index); #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -544,7 +549,7 @@ static void mmu2_not_responding() { active_extruder = 0; } #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -613,7 +618,7 @@ static void mmu2_not_responding() { while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); load_filament_to_nozzle(index); #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -633,7 +638,7 @@ static void mmu2_not_responding() { extruder = index; active_extruder = 0; #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -707,7 +712,7 @@ static void mmu2_not_responding() { while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); load_filament_to_nozzle(index); #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -726,7 +731,7 @@ static void mmu2_not_responding() { extruder = index; active_extruder = 0; #else - BUZZ(400, 40); + ERR_BUZZ(); #endif } break; @@ -811,25 +816,26 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) { if (turn_off_nozzle && resume_hotend_temp) { thermalManager.setTargetHotend(resume_hotend_temp, active_extruder); LCD_MESSAGE(MSG_HEATING); - BUZZ(200, 40); + ERR_BUZZ(); while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(1000); } - if (move_axes && all_axes_homed()) { - LCD_MESSAGE(MSG_MMU2_RESUMING); - BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404); + LCD_MESSAGE(MSG_MMU2_RESUMING); + mmu2_attn_buzz(true); + + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + if (move_axes && all_axes_homed()) { // Move XY to starting position, then Z do_blocking_move_to_xy(resume_position, feedRate_t(NOZZLE_PARK_XY_FEEDRATE)); // Move Z_AXIS to saved position do_blocking_move_to_z(resume_position.z, feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); } - else { - BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404); - LCD_MESSAGE(MSG_MMU2_RESUMING); - } + + #pragma GCC diagnostic pop } } } @@ -898,7 +904,7 @@ void MMU2::load_filament(const uint8_t index) { command(MMU_CMD_L0 + index); manage_response(false, false); - BUZZ(200, 404); + mmu2_attn_buzz(); } /** @@ -909,7 +915,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) { if (!_enabled) return false; if (thermalManager.tooColdToExtrude(active_extruder)) { - BUZZ(200, 404); + mmu2_attn_buzz(); LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); return false; } @@ -924,7 +930,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) { extruder = index; active_extruder = 0; load_to_nozzle(); - BUZZ(200, 404); + mmu2_attn_buzz(); } return success; } @@ -933,7 +939,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) { * Load filament to nozzle of multimaterial printer * * This function is used only after T? (user select filament) and M600 (change filament). - * It is not used after T0 .. T4 command (select filament), in such case, gcode is responsible for loading + * It is not used after T0 .. T4 command (select filament), in such case, G-code is responsible for loading * filament to nozzle. */ void MMU2::load_to_nozzle() { @@ -945,7 +951,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { if (!_enabled) return false; if (thermalManager.tooColdToExtrude(active_extruder)) { - BUZZ(200, 404); + mmu2_attn_buzz(); LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); return false; } @@ -961,12 +967,11 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { if (recover) { LCD_MESSAGE(MSG_MMU2_EJECT_RECOVER); - BUZZ(200, 404); + 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_(HAS_RESUME_CONTINUE, wait_for_user_response()); - BUZZ(200, 404); - BUZZ(200, 404); + mmu2_attn_buzz(true); command(MMU_CMD_R0); manage_response(false, false); @@ -979,7 +984,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) { set_runout_valid(false); - BUZZ(200, 404); + mmu2_attn_buzz(); stepper.disable_extruder(); @@ -994,7 +999,7 @@ bool MMU2::unload() { if (!_enabled) return false; if (thermalManager.tooColdToExtrude(active_extruder)) { - BUZZ(200, 404); + mmu2_attn_buzz(); LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); return false; } @@ -1005,7 +1010,7 @@ bool MMU2::unload() { command(MMU_CMD_U0); manage_response(false, true); - BUZZ(200, 404); + mmu2_attn_buzz(); // no active tool extruder = MMU2_NO_TOOL; @@ -1026,8 +1031,7 @@ void MMU2::execute_extruder_sequence(const E_Step * sequence, int steps) { const float es = pgm_read_float(&(step->extrude)); const feedRate_t fr_mm_m = pgm_read_float(&(step->feedRate)); - DEBUG_ECHO_START(); - DEBUG_ECHOLNPGM("E step ", es, "/", fr_mm_m); + DEBUG_ECHO_MSG("E step ", es, "/", fr_mm_m); current_position.e += es; line_to_current_position(MMM_TO_MMS(fr_mm_m)); diff --git a/Marlin/src/feature/mmu/mmu2.h b/Marlin/src/feature/mmu/mmu2.h index 9574e2217f82..7d3d9ec4df38 100644 --- a/Marlin/src/feature/mmu/mmu2.h +++ b/Marlin/src/feature/mmu/mmu2.h @@ -43,7 +43,7 @@ class MMU2 { static void init(); static void reset(); - static inline bool enabled() { return _enabled; } + static bool enabled() { return _enabled; } static void mmu_loop(); static void tool_change(const uint8_t index); static void tool_change(const char *special); @@ -57,10 +57,10 @@ class MMU2 { static bool eject_filament(const uint8_t index, const bool recover); private: - static inline bool rx_str(FSTR_P fstr); - static inline void tx_str(FSTR_P fstr); - static inline void tx_printf(FSTR_P ffmt, const int argument); - static inline void tx_printf(FSTR_P ffmt, const int argument1, const int argument2); + static bool rx_str(FSTR_P fstr); + static void tx_str(FSTR_P fstr); + static void tx_printf(FSTR_P ffmt, const int argument); + static void tx_printf(FSTR_P ffmt, const int argument1, const int argument2); static void clear_rx_buffer(); static bool rx_ok(); @@ -99,7 +99,7 @@ class MMU2 { static millis_t prev_request, prev_P0_request; static char rx_buffer[MMU_RX_SIZE], tx_buffer[MMU_TX_SIZE]; - static inline void set_runout_valid(const bool valid) { + static void set_runout_valid(const bool valid) { finda_runout_valid = valid; #if HAS_FILAMENT_SENSOR if (valid) runout.reset(); diff --git a/Marlin/src/feature/password/password.cpp b/Marlin/src/feature/password/password.cpp index 4e841c243cf0..1d376cc586cd 100644 --- a/Marlin/src/feature/password/password.cpp +++ b/Marlin/src/feature/password/password.cpp @@ -40,7 +40,7 @@ uint32_t Password::value, Password::value_entry; // void Password::lock_machine() { is_locked = true; - TERN_(HAS_LCD_MENU, authenticate_user(ui.status_screen, screen_password_entry)); + TERN_(HAS_MARLINUI_MENU, authenticate_user(ui.status_screen, screen_password_entry)); } // @@ -55,7 +55,7 @@ void Password::authentication_check() { is_locked = true; SERIAL_ECHOLNPGM(STR_WRONG_PASSWORD); } - TERN_(HAS_LCD_MENU, authentication_done()); + TERN_(HAS_MARLINUI_MENU, authentication_done()); } #endif // PASSWORD_FEATURE diff --git a/Marlin/src/feature/password/password.h b/Marlin/src/feature/password/password.h index 829d222e20b9..208765b21225 100644 --- a/Marlin/src/feature/password/password.h +++ b/Marlin/src/feature/password/password.h @@ -33,7 +33,7 @@ class Password { static void lock_machine(); static void authentication_check(); - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU static void access_menu_password(); static void authentication_done(); static void media_gatekeeper(); diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 191c0e4b08ef..ac5852f91a1a 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -39,6 +39,10 @@ #include "../module/printcounter.h" #include "../module/temperature.h" +#if ENABLED(AUTO_BED_LEVELING_UBL) + #include "bedlevel/bedlevel.h" +#endif + #if ENABLED(FWRETRACT) #include "fwretract.h" #endif @@ -53,8 +57,8 @@ #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../lcd/e3v2/proui/dwin.h" #endif #include "../lcd/marlinui.h" @@ -97,7 +101,7 @@ fil_change_settings_t fc_settings[EXTRUDERS]; #if HAS_BUZZER static void impatient_beep(const int8_t max_beep_count, const bool restart=false) { - if (TERN0(HAS_LCD_MENU, pause_mode == PAUSE_MODE_PAUSE_PRINT)) return; + if (TERN0(HAS_MARLINUI_MENU, pause_mode == PAUSE_MODE_PAUSE_PRINT)) return; static millis_t next_buzz = 0; static int8_t runout_beep = 0; @@ -277,7 +281,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load // Show "Purge More" / "Resume" menu and wait for reply KEEPALIVE_STATE(PAUSED_FOR_USER); wait_for_user = false; - #if EITHER(HAS_LCD_MENU, DWIN_CREALITY_LCD_ENHANCED) + #if EITHER(HAS_MARLINUI_MENU, DWIN_LCD_PROUI) ui.pause_show_message(PAUSE_MESSAGE_OPTION); // Also sets PAUSE_RESPONSE_WAIT_FOR #else pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; @@ -403,6 +407,7 @@ 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; @@ -440,7 +445,15 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool // Initial retract before move to filament change position if (retract && thermalManager.hotEnoughToExtrude(active_extruder)) { DEBUG_ECHOLNPGM("... retract:", retract); + + #if ENABLED(AUTO_BED_LEVELING_UBL) + const bool leveling_was_enabled = planner.leveling_active; // save leveling state + set_bed_leveling_enabled(false); // turn off leveling + #endif + unscaled_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE); + + TERN_(AUTO_BED_LEVELING_UBL, set_bed_leveling_enabled(leveling_was_enabled)); // restore leveling } // If axes don't need to home then the nozzle can park @@ -537,7 +550,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(GET_TEXT_F(MSG_REHEATING))); - TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_REHEATING)); + TERN_(DWIN_LCD_PROUI, LCD_MESSAGE(MSG_REHEATING)); // Re-enable the heaters if they timed out HOTEND_LOOP() thermalManager.reset_hotend_idle_timer(e); @@ -555,7 +568,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep 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_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_REHEATDONE)); + TERN_(DWIN_LCD_PROUI, LCD_MESSAGE(MSG_REHEATDONE)); IF_DISABLED(PAUSE_REHEAT_FAST_RESUME, wait_for_user = true); @@ -640,9 +653,16 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_ prepare_internal_move_to_destination(NOZZLE_PARK_Z_FEEDRATE); } + #if ENABLED(AUTO_BED_LEVELING_UBL) + const bool leveling_was_enabled = planner.leveling_active; // save leveling state + set_bed_leveling_enabled(false); // turn off leveling + #endif + // Unretract unscaled_e_move(PAUSE_PARK_RETRACT_LENGTH, feedRate_t(PAUSE_PARK_RETRACT_FEEDRATE)); + TERN_(AUTO_BED_LEVELING_UBL, set_bed_leveling_enabled(leveling_was_enabled)); // restore leveling + // Intelligent resuming #if ENABLED(FWRETRACT) // If retracted before goto pause @@ -652,8 +672,9 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_ // If resume_position is negative if (resume_position.e < 0) unscaled_e_move(resume_position.e, feedRate_t(PAUSE_PARK_RETRACT_FEEDRATE)); - #if ADVANCED_PAUSE_RESUME_PRIME != 0 - unscaled_e_move(ADVANCED_PAUSE_RESUME_PRIME, feedRate_t(ADVANCED_PAUSE_PURGE_FEEDRATE)); + #ifdef ADVANCED_PAUSE_RESUME_PRIME + if (ADVANCED_PAUSE_RESUME_PRIME != 0) + unscaled_e_move(ADVANCED_PAUSE_RESUME_PRIME, feedRate_t(ADVANCED_PAUSE_PURGE_FEEDRATE)); #endif // Now all extrusion positions are resumed and ready to be confirmed @@ -690,9 +711,9 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_ TERN_(HAS_FILAMENT_SENSOR, runout.reset()); - TERN_(HAS_STATUS_MESSAGE, ui.reset_status()); - TERN_(HAS_LCD_MENU, ui.return_to_status()); - TERN_(DWIN_CREALITY_LCD_ENHANCED, HMI_ReturnScreen()); + TERN(DWIN_LCD_PROUI, DWIN_Print_Resume(), ui.reset_status()); + TERN_(HAS_MARLINUI_MENU, ui.return_to_status()); + TERN_(DWIN_LCD_PROUI, HMI_ReturnScreen()); } #endif // ADVANCED_PAUSE_FEATURE diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index fabe35b989c7..c2ed169aa809 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -24,10 +24,14 @@ * power.cpp - power control */ -#include "../inc/MarlinConfig.h" +#include "../inc/MarlinConfigPre.h" + +#if EITHER(PSU_CONTROL, AUTO_POWER_CONTROL) #include "power.h" +#include "../module/planner.h" #include "../module/stepper.h" +#include "../module/temperature.h" #include "../MarlinCore.h" #if ENABLED(PS_OFF_SOUND) @@ -38,8 +42,6 @@ #include "../gcode/gcode.h" #endif -#if EITHER(PSU_CONTROL, AUTO_POWER_CONTROL) - Power powerManager; bool Power::psu_on; @@ -75,6 +77,10 @@ void Power::power_on() { if (psu_on) return; + #if EITHER(POWER_OFF_TIMER, POWER_OFF_WAIT_FOR_COOLDOWN) + cancelAutoPowerOff(); + #endif + OUT_WRITE(PS_ON_PIN, PSU_ACTIVE_STATE); psu_on = true; safe_delay(PSU_POWERUP_DELAY); @@ -89,9 +95,12 @@ void Power::power_on() { /** * Power off if the power is currently on. * Processes any PSU_POWEROFF_GCODE and makes a PS_OFF_SOUND if enabled. - * */ void Power::power_off() { + SERIAL_ECHOLNPGM(STR_POWEROFF); + + TERN_(HAS_SUICIDE, suicide()); + if (!psu_on) return; #ifdef PSU_POWEROFF_GCODE @@ -104,8 +113,57 @@ void Power::power_off() { OUT_WRITE(PS_ON_PIN, !PSU_ACTIVE_STATE); psu_on = false; + + #if EITHER(POWER_OFF_TIMER, POWER_OFF_WAIT_FOR_COOLDOWN) + cancelAutoPowerOff(); + #endif } +#if EITHER(AUTO_POWER_CONTROL, POWER_OFF_WAIT_FOR_COOLDOWN) + + bool Power::is_cooling_needed() { + #if HAS_HOTEND && AUTO_POWER_E_TEMP + HOTEND_LOOP() if (thermalManager.degHotend(e) >= (AUTO_POWER_E_TEMP)) return true; + #endif + + #if HAS_HEATED_CHAMBER && AUTO_POWER_CHAMBER_TEMP + if (thermalManager.degChamber() >= (AUTO_POWER_CHAMBER_TEMP)) return true; + #endif + + #if HAS_COOLER && AUTO_POWER_COOLER_TEMP + if (thermalManager.degCooler() >= (AUTO_POWER_COOLER_TEMP)) return true; + #endif + + return false; + } + +#endif + +#if EITHER(POWER_OFF_TIMER, POWER_OFF_WAIT_FOR_COOLDOWN) + + #if ENABLED(POWER_OFF_TIMER) + millis_t Power::power_off_time = 0; + void Power::setPowerOffTimer(const millis_t delay_ms) { power_off_time = millis() + delay_ms; } + #endif + + #if ENABLED(POWER_OFF_WAIT_FOR_COOLDOWN) + bool Power::power_off_on_cooldown = false; + void Power::setPowerOffOnCooldown(const bool ena) { power_off_on_cooldown = ena; } + #endif + + void Power::cancelAutoPowerOff() { + TERN_(POWER_OFF_TIMER, power_off_time = 0); + TERN_(POWER_OFF_WAIT_FOR_COOLDOWN, power_off_on_cooldown = false); + } + + void Power::checkAutoPowerOff() { + if (TERN1(POWER_OFF_TIMER, !power_off_time) && TERN1(POWER_OFF_WAIT_FOR_COOLDOWN, !power_off_on_cooldown)) return; + if (TERN0(POWER_OFF_WAIT_FOR_COOLDOWN, power_off_on_cooldown && is_cooling_needed())) return; + if (TERN0(POWER_OFF_TIMER, power_off_time && PENDING(millis(), power_off_time))) return; + power_off(); + } + +#endif // POWER_OFF_TIMER || POWER_OFF_WAIT_FOR_COOLDOWN #if ENABLED(AUTO_POWER_CONTROL) @@ -149,19 +207,7 @@ void Power::power_off() { if (TERN0(HAS_HEATED_BED, thermalManager.degTargetBed() > 0 || thermalManager.temp_bed.soft_pwm_amount > 0)) return true; - #if HAS_HOTEND && AUTO_POWER_E_TEMP - HOTEND_LOOP() if (thermalManager.degHotend(e) >= (AUTO_POWER_E_TEMP)) return true; - #endif - - #if HAS_HEATED_CHAMBER && AUTO_POWER_CHAMBER_TEMP - if (thermalManager.degChamber() >= (AUTO_POWER_CHAMBER_TEMP)) return true; - #endif - - #if HAS_COOLER && AUTO_POWER_COOLER_TEMP - if (thermalManager.degCooler() >= (AUTO_POWER_COOLER_TEMP)) return true; - #endif - - return false; + return is_cooling_needed(); } /** @@ -193,7 +239,6 @@ void Power::power_off() { /** * Power off with a delay. Power off is triggered by check() after the delay. - * */ void Power::power_off_soon() { lastPowerOn = millis() - SEC_TO_MS(POWER_TIMEOUT) + SEC_TO_MS(POWER_OFF_DELAY); diff --git a/Marlin/src/feature/power.h b/Marlin/src/feature/power.h index 7f5a97e6df83..839366ca602b 100644 --- a/Marlin/src/feature/power.h +++ b/Marlin/src/feature/power.h @@ -25,7 +25,7 @@ * power.h - power control */ -#if ENABLED(AUTO_POWER_CONTROL) +#if EITHER(AUTO_POWER_CONTROL, POWER_OFF_TIMER) #include "../core/millis_t.h" #endif @@ -37,20 +37,36 @@ class Power { static void power_on(); static void power_off(); - #if ENABLED(AUTO_POWER_CONTROL) && POWER_OFF_DELAY > 0 - static void power_off_soon(); - #else - static inline void power_off_soon() { power_off(); } - #endif + #if EITHER(POWER_OFF_TIMER, POWER_OFF_WAIT_FOR_COOLDOWN) + #if ENABLED(POWER_OFF_TIMER) + static millis_t power_off_time; + static void setPowerOffTimer(const millis_t delay_ms); + #endif + #if ENABLED(POWER_OFF_WAIT_FOR_COOLDOWN) + static bool power_off_on_cooldown; + static void setPowerOffOnCooldown(const bool ena); + #endif + static void cancelAutoPowerOff(); + static void checkAutoPowerOff(); + #endif - #if ENABLED(AUTO_POWER_CONTROL) - static void check(const bool pause); + #if ENABLED(AUTO_POWER_CONTROL) && POWER_OFF_DELAY > 0 + static void power_off_soon(); + #else + static void power_off_soon() { power_off(); } + #endif - private: - static millis_t lastPowerOn; - static bool is_power_needed(); + #if ENABLED(AUTO_POWER_CONTROL) + static void check(const bool pause); - #endif + private: + static millis_t lastPowerOn; + static bool is_power_needed(); + static bool is_cooling_needed(); + #elif ENABLED(POWER_OFF_WAIT_FOR_COOLDOWN) + private: + static bool is_cooling_needed(); + #endif }; extern Power powerManager; diff --git a/Marlin/src/feature/power_monitor.cpp b/Marlin/src/feature/power_monitor.cpp index 1937a54102a8..504f1ea48e3b 100644 --- a/Marlin/src/feature/power_monitor.cpp +++ b/Marlin/src/feature/power_monitor.cpp @@ -26,7 +26,7 @@ #include "power_monitor.h" -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "../lcd/marlinui.h" #include "../lcd/lcdprint.h" #endif diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 723ec1903bc8..944f2ee63c84 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -54,6 +54,10 @@ uint32_t PrintJobRecovery::cmd_sdpos, // = 0 #include "../module/temperature.h" #include "../core/serial.h" +#if HOMING_Z_WITH_PROBE + #include "../module/probe.h" +#endif + #if ENABLED(FWRETRACT) #include "fwretract.h" #endif @@ -104,13 +108,18 @@ void PrintJobRecovery::changed() { * * If a saved state exists send 'M1000 S' to initiate job recovery. */ -void PrintJobRecovery::check() { +bool PrintJobRecovery::check() { //if (!card.isMounted()) card.mount(); + bool success = false; if (card.isMounted()) { load(); - if (!valid()) return cancel(); - queue.inject(F("M1000S")); + success = valid(); + if (!success) + cancel(); + else + queue.inject(F("M1000S")); } + return success; } /** @@ -178,7 +187,8 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW info.valid_foot = info.valid_head; // Machine state - info.current_position = current_position; + // info.sdpos and info.current_position are pre-filled from the Stepper ISR + info.feedrate = uint16_t(MMS_TO_MMM(feedrate_mm_s)); info.zraise = zraise; info.flag.raised = raised; // Was Z raised before power-off? @@ -191,7 +201,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW #if DISABLED(NO_VOLUMETRICS) info.flag.volumetric_enabled = parser.volumetric_enabled; #if HAS_MULTI_EXTRUDER - for (int8_t e = 0; e < EXTRUDERS; e++) info.filament_size[e] = planner.filament_size[e]; + EXTRUDER_LOOP() info.filament_size[e] = planner.filament_size[e]; #else if (parser.volumetric_enabled) info.filament_size[0] = planner.filament_size[active_extruder]; #endif @@ -265,6 +275,10 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW #endif +#endif // POWER_LOSS_PIN + +#if PIN_EXISTS(POWER_LOSS) || ENABLED(DEBUG_POWER_LOSS_RECOVERY) + /** * An outage was detected by a sensor pin. * - If not SD printing, let the machine turn off on its own with no "KILL" screen @@ -273,7 +287,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW * - If backup power is available Retract E and Raise Z * - Go to the KILL screen */ - void PrintJobRecovery::_outage() { + void PrintJobRecovery::_outage(TERN_(DEBUG_POWER_LOSS_RECOVERY, const bool simulated/*=false*/)) { #if ENABLED(BACKUP_POWER_SUPPLY) static bool lock = false; if (lock) return; // No re-entrance from idle() during retract_and_lift() @@ -301,10 +315,16 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW retract_and_lift(zraise); #endif - kill(GET_TEXT_F(MSG_OUTAGE_RECOVERY)); + if (TERN0(DEBUG_POWER_LOSS_RECOVERY, simulated)) { + card.fileHasFinished(); + current_position.reset(); + sync_plan_position(); + } + else + kill(GET_TEXT_F(MSG_OUTAGE_RECOVERY)); } -#endif +#endif // POWER_LOSS_PIN || DEBUG_POWER_LOSS_RECOVERY /** * Save the recovery info the recovery file @@ -390,14 +410,12 @@ void PrintJobRecovery::resume() { #if ENABLED(POWER_LOSS_RECOVER_ZHOME) && defined(POWER_LOSS_ZHOME_POS) #define HOMING_Z_DOWN 1 - #else - #define HOME_XY_ONLY 1 #endif float z_now = info.flag.raised ? z_raised : z_print; - // Reset E to 0 and set Z to the real position - #if HOME_XY_ONLY + #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); #endif @@ -409,15 +427,15 @@ void PrintJobRecovery::resume() { gcode.process_subcommands_now(cmd); } - // Home XY with no Z raise, and also home Z here if Z isn't homing down below. - gcode.process_subcommands_now(F("G28R0" TERN_(HOME_XY_ONLY, "XY"))); // No raise during G28 + // Home XY with no Z raise + gcode.process_subcommands_now(F("G28R0XY")); // No raise during G28 #endif #if HOMING_Z_DOWN // Move to a safe XY position and home Z while avoiding the print. - constexpr xy_pos_t p = POWER_LOSS_ZHOME_POS; - sprintf_P(cmd, PSTR("G1X%sY%sF1000\nG28Z"), dtostrf(p.x, 1, 3, str_1), dtostrf(p.y, 1, 3, str_2)); + 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); #endif @@ -431,7 +449,7 @@ void PrintJobRecovery::resume() { sprintf_P(cmd, PSTR("M420S%cZ%s"), '0' + (char)info.flag.leveling, dtostrf(info.fade, 1, 1, str_1)); gcode.process_subcommands_now(cmd); - #if HOME_XY_ONLY + #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); @@ -448,7 +466,7 @@ void PrintJobRecovery::resume() { // Recover volumetric extrusion state #if DISABLED(NO_VOLUMETRICS) #if HAS_MULTI_EXTRUDER - for (int8_t e = 0; e < EXTRUDERS; e++) { + EXTRUDER_LOOP() { sprintf_P(cmd, PSTR("M200T%iD%s"), e, dtostrf(info.filament_size[e], 1, 3, str_1)); gcode.process_subcommands_now(cmd); } @@ -498,10 +516,10 @@ void PrintJobRecovery::resume() { // Restore retract and hop state from an active `G10` command #if ENABLED(FWRETRACT) - LOOP_L_N(e, EXTRUDERS) { + EXTRUDER_LOOP() { if (info.retract[e] != 0.0) { fwretract.current_retract[e] = info.retract[e]; - fwretract.retracted[e] = true; + fwretract.retracted.set(e); } } fwretract.current_hop = info.retract_hop; @@ -513,12 +531,12 @@ 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("G1E" STRINGIFY(POWER_LOSS_RETRACT_LEN) "F3000")); + gcode.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("G1 E%d F3000"), (POWER_LOSS_PURGE_LEN) + (POWER_LOSS_RETRACT_LEN)); + sprintf_P(cmd, PSTR("G1F3000E%d"), (POWER_LOSS_PURGE_LEN) + (POWER_LOSS_RETRACT_LEN)); gcode.process_subcommands_now(cmd); #endif @@ -621,7 +639,7 @@ void PrintJobRecovery::resume() { #if DISABLED(NO_VOLUMETRICS) DEBUG_ECHOPGM("filament_size:"); - LOOP_L_N(i, EXTRUDERS) DEBUG_ECHOLNPGM(" ", info.filament_size[i]); + EXTRUDER_LOOP() DEBUG_ECHOLNPGM(" ", info.filament_size[e]); DEBUG_EOL(); #endif @@ -653,7 +671,7 @@ void PrintJobRecovery::resume() { #if ENABLED(FWRETRACT) DEBUG_ECHOPGM("retract: "); - for (int8_t e = 0; e < EXTRUDERS; e++) { + EXTRUDER_LOOP() { DEBUG_ECHO(info.retract[e]); if (e < EXTRUDERS - 1) DEBUG_CHAR(','); } diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index 76cb398af2a1..33d9dc007c0d 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -152,7 +152,7 @@ class PrintJobRecovery { static void init(); static void prepare(); - static inline void setup() { + static void setup() { #if PIN_EXISTS(POWER_LOSS) #if ENABLED(POWER_LOSS_PULLUP) SET_INPUT_PULLUP(POWER_LOSS_PIN); @@ -165,28 +165,28 @@ class PrintJobRecovery { } // Track each command's file offsets - static inline uint32_t command_sdpos() { return sdpos[queue_index_r]; } - static inline void commit_sdpos(const uint8_t index_w) { sdpos[index_w] = cmd_sdpos; } + static uint32_t command_sdpos() { return sdpos[queue_index_r]; } + static void commit_sdpos(const uint8_t index_w) { sdpos[index_w] = cmd_sdpos; } static bool enabled; static void enable(const bool onoff); static void changed(); - static inline bool exists() { return card.jobRecoverFileExists(); } - static inline void open(const bool read) { card.openJobRecoveryFile(read); } - static inline void close() { file.close(); } + static bool exists() { return card.jobRecoverFileExists(); } + static void open(const bool read) { card.openJobRecoveryFile(read); } + static void close() { file.close(); } - static void check(); + static bool check(); static void resume(); static void purge(); - static inline void cancel() { purge(); IF_DISABLED(NO_SD_AUTOSTART, card.autofile_begin()); } + static void cancel() { purge(); } static void load(); static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE), const float zraise=POWER_LOSS_ZRAISE, const bool raised=false); #if PIN_EXISTS(POWER_LOSS) - static inline void outage() { + static void outage() { static constexpr uint8_t OUTAGE_THRESHOLD = 3; static uint8_t outage_counter = 0; if (enabled && READ(POWER_LOSS_PIN) == POWER_LOSS_STATE) { @@ -199,14 +199,14 @@ class PrintJobRecovery { #endif // The referenced file exists - static inline bool interrupted_file_exists() { return card.fileExists(info.sd_filename); } + static bool interrupted_file_exists() { return card.fileExists(info.sd_filename); } - static inline bool valid() { return info.valid() && interrupted_file_exists(); } + static bool valid() { return info.valid() && interrupted_file_exists(); } #if ENABLED(DEBUG_POWER_LOSS_RECOVERY) static void debug(FSTR_P const prefix); #else - static inline void debug(FSTR_P const) {} + static void debug(FSTR_P const) {} #endif private: @@ -216,9 +216,9 @@ class PrintJobRecovery { static void retract_and_lift(const_float_t zraise); #endif - #if PIN_EXISTS(POWER_LOSS) + #if PIN_EXISTS(POWER_LOSS) || ENABLED(DEBUG_POWER_LOSS_RECOVERY) friend class GcodeSuite; - static void _outage(); + static void _outage(TERN_(DEBUG_POWER_LOSS_RECOVERY, const bool simulated=false)); #endif }; diff --git a/Marlin/src/feature/probe_temp_comp.cpp b/Marlin/src/feature/probe_temp_comp.cpp index 9a975d6763fa..b5f636e698c9 100644 --- a/Marlin/src/feature/probe_temp_comp.cpp +++ b/Marlin/src/feature/probe_temp_comp.cpp @@ -28,6 +28,7 @@ #include "probe_temp_comp.h" #include +#include "../module/temperature.h" ProbeTempComp ptc; @@ -62,6 +63,7 @@ constexpr temp_calib_t ProbeTempComp::cali_info[TSI_COUNT]; uint8_t ProbeTempComp::calib_idx; // = 0 float ProbeTempComp::init_measurement; // = 0.0 +bool ProbeTempComp::enabled = true; void ProbeTempComp::reset() { TERN_(PTC_PROBE, LOOP_L_N(i, PTC_PROBE_COUNT) z_offsets_probe[i] = z_offsets_probe_default[i]); @@ -169,6 +171,13 @@ bool ProbeTempComp::finish_calibration(const TempSensorID tsi) { return true; } +void ProbeTempComp::apply_compensation(float &meas_z) { + if (!enabled) return; + TERN_(PTC_BED, compensate_measurement(TSI_BED, thermalManager.degBed(), meas_z)); + TERN_(PTC_PROBE, compensate_measurement(TSI_PROBE, thermalManager.degProbe(), meas_z)); + TERN_(PTC_HOTEND, compensate_measurement(TSI_EXT, thermalManager.degHotend(0), meas_z)); +} + void ProbeTempComp::compensate_measurement(const TempSensorID tsi, const celsius_t temp, float &meas_z) { const uint8_t measurements = cali_info[tsi].measurements; const celsius_t start_temp = cali_info[tsi].start_temp, diff --git a/Marlin/src/feature/probe_temp_comp.h b/Marlin/src/feature/probe_temp_comp.h index 4579f2187cd4..42348db68473 100644 --- a/Marlin/src/feature/probe_temp_comp.h +++ b/Marlin/src/feature/probe_temp_comp.h @@ -74,11 +74,10 @@ class ProbeTempComp { static int16_t z_offsets_hotend[PTC_HOTEND_COUNT]; // (µm) #endif - static inline void reset_index() { calib_idx = 0; }; - static inline uint8_t get_index() { return calib_idx; } + static void reset_index() { calib_idx = 0; }; + static uint8_t get_index() { return calib_idx; } static void reset(); - static void clear_offsets(const TempSensorID tsi); - static inline void clear_all_offsets() { + static void clear_all_offsets() { TERN_(PTC_PROBE, clear_offsets(TSI_PROBE)); TERN_(PTC_BED, clear_offsets(TSI_BED)); TERN_(PTC_HOTEND, clear_offsets(TSI_EXT)); @@ -88,10 +87,16 @@ class ProbeTempComp { static void prepare_new_calibration(const_float_t init_meas_z); static void push_back_new_measurement(const TempSensorID tsi, const_float_t meas_z); static bool finish_calibration(const TempSensorID tsi); - static void compensate_measurement(const TempSensorID tsi, const celsius_t temp, float &meas_z); + static void set_enabled(const bool ena) { enabled = ena; } + + // Apply all temperature compensation adjustments + static void apply_compensation(float &meas_z); private: static uint8_t calib_idx; + static bool enabled; + + static void clear_offsets(const TempSensorID tsi); /** * Base value. Temperature compensation values will be deltas @@ -104,6 +109,8 @@ class ProbeTempComp { * to allow generating values of higher temperatures. */ static bool linear_regression(const TempSensorID tsi, float &k, float &d); + + static void compensate_measurement(const TempSensorID tsi, const celsius_t temp, float &meas_z); }; extern ProbeTempComp ptc; diff --git a/Marlin/src/feature/repeat.h b/Marlin/src/feature/repeat.h index 0f4d9425b768..fc11e4a9e2cf 100644 --- a/Marlin/src/feature/repeat.h +++ b/Marlin/src/feature/repeat.h @@ -38,8 +38,8 @@ class Repeat { static repeat_marker_t marker[MAX_REPEAT_NESTING]; static uint8_t index; public: - static inline void reset() { index = 0; } - static inline bool is_active() { + static void reset() { index = 0; } + static bool is_active() { LOOP_L_N(i, index) if (marker[i].counter) return true; return false; } diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index 9317e3489a83..98b6bd051061 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -68,8 +68,8 @@ bool FilamentMonitorBase::enabled = true, #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../lcd/e3v2/proui/dwin.h" #endif void event_filament_runout(const uint8_t extruder) { @@ -88,7 +88,7 @@ void event_filament_runout(const uint8_t extruder) { #endif TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getTool(extruder))); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_FilamentRunout(extruder)); + TERN_(DWIN_LCD_PROUI, DWIN_FilamentRunout(extruder)); #if ANY(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS, MULTI_FILAMENT_SENSOR) const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, extruder); diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 8065e515559f..e74d857a79ed 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -83,30 +83,30 @@ class TFilamentMonitor : public FilamentMonitorBase { static sensor_t sensor; public: - static inline void setup() { + static void setup() { sensor.setup(); reset(); } - static inline void reset() { + static void reset() { filament_ran_out = false; response.reset(); } // Call this method when filament is present, // so the response can reset its counter. - static inline void filament_present(const uint8_t extruder) { + static void filament_present(const uint8_t extruder) { response.filament_present(extruder); } #if HAS_FILAMENT_RUNOUT_DISTANCE - static inline float& runout_distance() { return response.runout_distance_mm; } - static inline void set_runout_distance(const_float_t mm) { response.runout_distance_mm = mm; } + static float& runout_distance() { return response.runout_distance_mm; } + static void set_runout_distance(const_float_t mm) { response.runout_distance_mm = mm; } #endif // Handle a block completion. RunoutResponseDelayed uses this to // add up the length of filament moved while the filament is out. - static inline void block_completed(const block_t * const b) { + static void block_completed(const block_t * const b) { if (enabled) { response.block_completed(b); sensor.block_completed(b); @@ -114,7 +114,7 @@ class TFilamentMonitor : public FilamentMonitorBase { } // Give the response a chance to update its counter. - static inline void run() { + static void run() { if (enabled && !filament_ran_out && (printingIsActive() || did_pause_print)) { TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, cli()); // Prevent RunoutResponseDelayed::block_completed from accumulating here response.run(); @@ -168,12 +168,12 @@ class FilamentSensorBase { * Called by FilamentSensorSwitch::run when filament is detected. * Called by FilamentSensorEncoder::block_completed when motion is detected. */ - static inline void filament_present(const uint8_t extruder) { + static void filament_present(const uint8_t extruder) { runout.filament_present(extruder); // ...which calls response.filament_present(extruder) } public: - static inline void setup() { + static void setup() { #define _INIT_RUNOUT_PIN(P,S,U,D) do{ if (ENABLED(U)) SET_INPUT_PULLUP(P); else if (ENABLED(D)) SET_INPUT_PULLDOWN(P); else SET_INPUT(P); }while(0) #define INIT_RUNOUT_PIN(N) _INIT_RUNOUT_PIN(FIL_RUNOUT##N##_PIN, FIL_RUNOUT##N##_STATE, FIL_RUNOUT##N##_PULLUP, FIL_RUNOUT##N##_PULLDOWN) #if NUM_RUNOUT_SENSORS >= 1 @@ -205,14 +205,14 @@ class FilamentSensorBase { } // Return a bitmask of runout pin states - static inline uint8_t poll_runout_pins() { + static uint8_t poll_runout_pins() { #define _OR_RUNOUT(N) | (READ(FIL_RUNOUT##N##_PIN) ? _BV((N) - 1) : 0) return (0 REPEAT_1(NUM_RUNOUT_SENSORS, _OR_RUNOUT)); #undef _OR_RUNOUT } // Return a bitmask of runout flag states (1 bits always indicates runout) - static inline uint8_t poll_runout_states() { + static uint8_t poll_runout_states() { return poll_runout_pins() ^ uint8_t(0 #if NUM_RUNOUT_SENSORS >= 1 | (FIL_RUNOUT1_STATE ? 0 : _BV(1 - 1)) @@ -254,7 +254,7 @@ class FilamentSensorBase { private: static uint8_t motion_detected; - static inline void poll_motion_sensor() { + static void poll_motion_sensor() { static uint8_t old_state; const uint8_t new_state = poll_runout_pins(), change = old_state ^ new_state; @@ -273,7 +273,7 @@ class FilamentSensorBase { } public: - static inline void block_completed(const block_t * const b) { + static void block_completed(const block_t * const b) { // If the sensor wheel has moved since the last call to // this method reset the runout counter for the extruder. if (TEST(motion_detected, b->extruder)) @@ -283,7 +283,7 @@ class FilamentSensorBase { motion_detected = 0; } - static inline void run() { poll_motion_sensor(); } + static void run() { poll_motion_sensor(); } }; #else @@ -294,7 +294,7 @@ class FilamentSensorBase { */ class FilamentSensorSwitch : public FilamentSensorBase { private: - static inline bool poll_runout_state(const uint8_t extruder) { + static bool poll_runout_state(const uint8_t extruder) { const uint8_t runout_states = poll_runout_states(); #if MULTI_FILAMENT_SENSOR if ( !TERN0(DUAL_X_CARRIAGE, idex_is_duplicating()) @@ -307,9 +307,9 @@ class FilamentSensorBase { } public: - static inline void block_completed(const block_t * const) {} + static void block_completed(const block_t * const) {} - static inline void run() { + static void run() { LOOP_L_N(s, NUM_RUNOUT_SENSORS) { const bool out = poll_runout_state(s); if (!out) filament_present(s); @@ -341,11 +341,11 @@ class FilamentSensorBase { public: static float runout_distance_mm; - static inline void reset() { + static void reset() { LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i); } - static inline void run() { + static void run() { #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) static millis_t t = 0; const millis_t ms = millis(); @@ -358,17 +358,17 @@ class FilamentSensorBase { #endif } - static inline uint8_t has_run_out() { + static uint8_t has_run_out() { uint8_t runout_flags = 0; LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_mm_countdown[i] < 0) SBI(runout_flags, i); return runout_flags; } - static inline void filament_present(const uint8_t extruder) { + static void filament_present(const uint8_t extruder) { runout_mm_countdown[extruder] = runout_distance_mm; } - static inline void block_completed(const block_t * const b) { + static void block_completed(const block_t * const b) { if (b->steps.x || b->steps.y || b->steps.z || did_pause_print) { // Allow pause purge move to re-trigger runout state // Only trigger on extrusion with XYZ movement to allow filament change and retract/recover. const uint8_t e = b->extruder; @@ -389,23 +389,23 @@ class FilamentSensorBase { static int8_t runout_count[NUM_RUNOUT_SENSORS]; public: - static inline void reset() { + static void reset() { LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i); } - static inline void run() { + static void run() { LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_count[i] >= 0) runout_count[i]--; } - static inline uint8_t has_run_out() { + static uint8_t has_run_out() { uint8_t runout_flags = 0; LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_count[i] < 0) SBI(runout_flags, i); return runout_flags; } - static inline void block_completed(const block_t * const) { } + static void block_completed(const block_t * const) { } - static inline void filament_present(const uint8_t extruder) { + static void filament_present(const uint8_t extruder) { runout_count[extruder] = runout_threshold; } }; diff --git a/Marlin/src/feature/solenoid.cpp b/Marlin/src/feature/solenoid.cpp index b6795d1a1ef8..861e44ed05de 100644 --- a/Marlin/src/feature/solenoid.cpp +++ b/Marlin/src/feature/solenoid.cpp @@ -27,31 +27,25 @@ #include "solenoid.h" #include "../module/motion.h" // for active_extruder - -// PARKING_EXTRUDER options alter the default behavior of solenoids, this ensures compliance of M380-381 - -#if ENABLED(PARKING_EXTRUDER) - #include "../module/tool_change.h" -#endif +#include "../module/tool_change.h" // Used primarily with MANUAL_SOLENOID_CONTROL -static void set_solenoid(const uint8_t num, const bool active) { - const uint8_t value = active ? PE_MAGNET_ON_STATE : !PE_MAGNET_ON_STATE; - #define _SOL_CASE(N) case N: TERN_(HAS_SOLENOID_##N, OUT_WRITE(SOL##N##_PIN, value)); break; +static void set_solenoid(const uint8_t num, const uint8_t state) { + #define _SOL_CASE(N) case N: TERN_(HAS_SOLENOID_##N, OUT_WRITE(SOL##N##_PIN, state)); break; switch (num) { REPEAT(8, _SOL_CASE) default: SERIAL_ECHO_MSG(STR_INVALID_SOLENOID); break; } #if ENABLED(PARKING_EXTRUDER) - if (!active && active_extruder == num) // If active extruder's solenoid is disabled, carriage is considered parked + if (state == LOW && active_extruder == num) // If active extruder's solenoid is disabled, carriage is considered parked parking_extruder_set_parked(true); #endif } -void enable_solenoid(const uint8_t num) { set_solenoid(num, true); } -void disable_solenoid(const uint8_t num) { set_solenoid(num, false); } -void enable_solenoid_on_active_extruder() { } +// PARKING_EXTRUDER options alter the default behavior of solenoids to ensure compliance of M380-381 +void enable_solenoid(const uint8_t num) { set_solenoid(num, TERN1(PARKING_EXTRUDER, PE_MAGNET_ON_STATE)); } +void disable_solenoid(const uint8_t num) { set_solenoid(num, TERN0(PARKING_EXTRUDER, !PE_MAGNET_ON_STATE)); } void disable_all_solenoids() { #define _SOL_DISABLE(N) TERN_(HAS_SOLENOID_##N, disable_solenoid(N)); diff --git a/Marlin/src/feature/solenoid.h b/Marlin/src/feature/solenoid.h index 2ba4983fb000..3131aeb868d4 100644 --- a/Marlin/src/feature/solenoid.h +++ b/Marlin/src/feature/solenoid.h @@ -21,7 +21,6 @@ */ #pragma once -void enable_solenoid_on_active_extruder(); void disable_all_solenoids(); void enable_solenoid(const uint8_t num); void disable_solenoid(const uint8_t num); diff --git a/Marlin/src/feature/spindle_laser.cpp b/Marlin/src/feature/spindle_laser.cpp index cde2b47d90aa..4f8f4d49dc2f 100644 --- a/Marlin/src/feature/spindle_laser.cpp +++ b/Marlin/src/feature/spindle_laser.cpp @@ -39,7 +39,8 @@ #endif SpindleLaser cutter; -uint8_t SpindleLaser::power; +uint8_t SpindleLaser::power, + 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. #endif @@ -57,7 +58,7 @@ cutter_power_t SpindleLaser::menuPower, // Power s */ void SpindleLaser::init() { #if ENABLED(SPINDLE_SERVO) - MOVE_SERVO(SPINDLE_SERVO_NR, SPINDLE_SERVO_MIN); + servo[SPINDLE_SERVO_NR].move(SPINDLE_SERVO_MIN); #else OUT_WRITE(SPINDLE_LASER_ENA_PIN, !SPINDLE_LASER_ACTIVE_STATE); // Init spindle to off #endif @@ -66,10 +67,10 @@ void SpindleLaser::init() { #endif #if ENABLED(SPINDLE_LASER_USE_PWM) SET_PWM(SPINDLE_LASER_PWM_PIN); - set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_PWM_OFF); // Set to lowest speed + 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) && defined(SPINDLE_LASER_FREQUENCY) - set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY); + #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) @@ -78,9 +79,7 @@ void SpindleLaser::init() { #if ENABLED(AIR_ASSIST) OUT_WRITE(AIR_ASSIST_PIN, !AIR_ASSIST_ACTIVE); // Init Air Assist OFF #endif - #if ENABLED(I2C_AMMETER) - ammeter.init(); // Init I2C Ammeter - #endif + TERN_(I2C_AMMETER, ammeter.init()); // Init I2C Ammeter } #if ENABLED(SPINDLE_LASER_USE_PWM) @@ -90,10 +89,10 @@ void SpindleLaser::init() { * @param ocr Power value */ void SpindleLaser::_set_ocr(const uint8_t ocr) { - #if NEEDS_HARDWARE_PWM && SPINDLE_LASER_FREQUENCY - set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), TERN(MARLIN_DEV_MODE, frequency, SPINDLE_LASER_FREQUENCY)); + #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)); #endif - set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); + hal.set_pwm_duty(pin_t(SPINDLE_LASER_PWM_PIN), ocr ^ SPINDLE_LASER_PWM_OFF); } void SpindleLaser::set_ocr(const uint8_t ocr) { @@ -115,7 +114,6 @@ void SpindleLaser::init() { * @param opwr Power value. Range 0 to MAX. When 0 disable spindle/laser. */ void SpindleLaser::apply_power(const uint8_t opwr) { - static uint8_t last_power_applied = 0; if (opwr == last_power_applied) return; last_power_applied = opwr; power = opwr; @@ -133,7 +131,7 @@ void SpindleLaser::apply_power(const uint8_t opwr) { isReady = false; } #elif ENABLED(SPINDLE_SERVO) - MOVE_SERVO(SPINDLE_SERVO_NR, power); + servo[SPINDLE_SERVO_NR].move(power); #else WRITE(SPINDLE_LASER_ENA_PIN, enabled() ? SPINDLE_LASER_ACTIVE_STATE : !SPINDLE_LASER_ACTIVE_STATE); isReady = true; @@ -161,8 +159,8 @@ void SpindleLaser::apply_power(const uint8_t opwr) { #if ENABLED(AIR_ASSIST) // Enable / disable air assist - void SpindleLaser::air_assist_enable() { WRITE(AIR_ASSIST_PIN, AIR_ASSIST_PIN); } // Turn ON - void SpindleLaser::air_assist_disable() { WRITE(AIR_ASSIST_PIN, !AIR_ASSIST_PIN); } // Turn OFF + void SpindleLaser::air_assist_enable() { WRITE(AIR_ASSIST_PIN, AIR_ASSIST_ACTIVE); } // Turn ON + void SpindleLaser::air_assist_disable() { WRITE(AIR_ASSIST_PIN, !AIR_ASSIST_ACTIVE); } // Turn OFF void SpindleLaser::air_assist_toggle() { TOGGLE(AIR_ASSIST_PIN); } // Toggle state #endif diff --git a/Marlin/src/feature/spindle_laser.h b/Marlin/src/feature/spindle_laser.h index 95d60ae48674..a9dc7794c4e9 100644 --- a/Marlin/src/feature/spindle_laser.h +++ b/Marlin/src/feature/spindle_laser.h @@ -30,7 +30,7 @@ #include "spindle_laser_types.h" -#if USE_BEEPER +#if HAS_BEEPER #include "../libs/buzzer.h" #endif @@ -91,7 +91,8 @@ class SpindleLaser { #endif static bool isReady; // Ready to apply power setting from the UI to OCR - static uint8_t power; + 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 @@ -103,12 +104,12 @@ class SpindleLaser { static void init(); #if ENABLED(MARLIN_DEV_MODE) - static inline void refresh_frequency() { set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency); } + static void refresh_frequency() { hal.set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency); } #endif // Modifying this function should update everywhere - static inline bool enabled(const cutter_power_t opwr) { return opwr > 0; } - static inline bool enabled() { return enabled(power); } + static bool enabled(const cutter_power_t opwr) { return opwr > 0; } + static bool enabled() { return enabled(power); } static void apply_power(const uint8_t inpow); @@ -124,13 +125,13 @@ class SpindleLaser { public: static void set_ocr(const uint8_t ocr); - static inline void ocr_set_power(const uint8_t ocr) { power = ocr; set_ocr(ocr); } + static void ocr_set_power(const uint8_t ocr) { power = ocr; set_ocr(ocr); } static void ocr_off(); /** * Update output for power->OCR translation */ - static inline uint8_t upower_to_ocr(const cutter_power_t upwr) { + static uint8_t upower_to_ocr(const cutter_power_t upwr) { return uint8_t( #if CUTTER_UNIT_IS(PWM255) upwr @@ -145,11 +146,11 @@ class SpindleLaser { /** * Correct power to configured range */ - static inline cutter_power_t power_to_range(const cutter_power_t pwr) { + static cutter_power_t power_to_range(const cutter_power_t pwr) { return power_to_range(pwr, _CUTTER_POWER(CUTTER_POWER_UNIT)); } - static inline cutter_power_t power_to_range(const cutter_power_t pwr, const uint8_t pwrUnit) { + 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); @@ -188,7 +189,7 @@ class SpindleLaser { * Enable/Disable spindle/laser * @param enable true = enable; false = disable */ - static inline void set_enabled(const bool enable) { + static void set_enabled(const bool enable) { uint8_t value = 0; if (enable) { #if ENABLED(SPINDLE_LASER_USE_PWM) @@ -203,14 +204,14 @@ class SpindleLaser { set_power(value); } - static inline void disable() { isReady = false; set_enabled(false); } + static void disable() { isReady = false; set_enabled(false); } /** * Wait for spindle to spin up or spin down * * @param on true = state to on; false = state to off. */ - static inline void power_delay(const bool on) { + static void power_delay(const bool on) { #if DISABLED(LASER_POWER_INLINE) safe_delay(on ? SPINDLE_LASER_POWERUP_DELAY : SPINDLE_LASER_POWERDOWN_DELAY); #endif @@ -220,7 +221,7 @@ class SpindleLaser { static void set_reverse(const bool reverse); static bool is_reverse() { return READ(SPINDLE_DIR_PIN) == SPINDLE_INVERT_DIR; } #else - static inline void set_reverse(const bool) {} + static void set_reverse(const bool) {} static bool is_reverse() { return false; } #endif @@ -228,7 +229,7 @@ class SpindleLaser { 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 inline bool air_evac_state() { // Get current state + static bool air_evac_state() { // Get current state return (READ(AIR_EVACUATION_PIN) == AIR_EVACUATION_ACTIVE); } #endif @@ -237,13 +238,13 @@ class SpindleLaser { 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 inline bool air_assist_state() { // Get current state + static bool air_assist_state() { // Get current state return (READ(AIR_ASSIST_PIN) == AIR_ASSIST_ACTIVE); } #endif - #if HAS_LCD_MENU - static inline void enable_with_dir(const bool reverse) { + #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) @@ -259,7 +260,7 @@ class SpindleLaser { FORCE_INLINE static void enable_same_dir() { enable_with_dir(is_reverse()); } #if ENABLED(SPINDLE_LASER_USE_PWM) - static inline void update_from_mpower() { + static void update_from_mpower() { if (isReady) power = upower_to_ocr(menuPower); unitPower = menuPower; } @@ -271,15 +272,15 @@ class SpindleLaser { * Also fires with any PWM power that was previous set * If not set defaults to 80% power */ - static inline void test_fire_pulse() { - TERN_(USE_BEEPER, buzzer.tone(30, 3000)); + 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 } #endif - #endif // HAS_LCD_MENU + #endif // HAS_MARLINUI_MENU #if ENABLED(LASER_POWER_INLINE) /** @@ -288,7 +289,7 @@ class SpindleLaser { */ // Force disengage planner power control - static inline void inline_disable() { + static void inline_disable() { isReady = false; unitPower = 0; planner.laser_inline.status.isPlanned = false; @@ -297,7 +298,7 @@ class SpindleLaser { } // Inline modes of all other functions; all enable planner inline power control - static inline void set_inline_enabled(const bool enable) { + static void set_inline_enabled(const bool enable) { if (enable) inline_power(255); else { @@ -326,10 +327,10 @@ class SpindleLaser { #endif } - static inline void inline_direction(const bool) { /* never */ } + static void inline_direction(const bool) { /* never */ } #if ENABLED(SPINDLE_LASER_USE_PWM) - static inline void inline_ocr_power(const uint8_t ocrpwr) { + static void inline_ocr_power(const uint8_t ocrpwr) { isReady = ocrpwr > 0; planner.laser_inline.status.isEnabled = ocrpwr > 0; planner.laser_inline.power = ocrpwr; @@ -337,7 +338,7 @@ class SpindleLaser { #endif #endif // LASER_POWER_INLINE - static inline void kill() { + static void kill() { TERN_(LASER_POWER_INLINE, inline_disable()); disable(); } diff --git a/Marlin/src/feature/tmc_util.cpp b/Marlin/src/feature/tmc_util.cpp index 82c10e6e8ec2..c69772bebcaf 100644 --- a/Marlin/src/feature/tmc_util.cpp +++ b/Marlin/src/feature/tmc_util.cpp @@ -40,7 +40,7 @@ #endif #endif -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "../module/stepper.h" #endif @@ -421,12 +421,10 @@ if (monitor_tmc_driver(stepperI, need_update_error_counters, need_debug_reporting)) step_current_down(stepperI); #endif - #if AXIS_IS_TMC(J) if (monitor_tmc_driver(stepperJ, need_update_error_counters, need_debug_reporting)) step_current_down(stepperJ); #endif - #if AXIS_IS_TMC(K) if (monitor_tmc_driver(stepperK, need_update_error_counters, need_debug_reporting)) step_current_down(stepperK); @@ -472,12 +470,8 @@ void tmc_set_report_interval(const uint16_t update_interval) { if ((report_tmc_status_interval = update_interval)) SERIAL_ECHOLNPGM("axis:pwm_scale" - #if HAS_STEALTHCHOP - "/curr_scale" - #endif - #if HAS_STALLGUARD - "/mech_load" - #endif + TERN_(HAS_STEALTHCHOP, "/curr_scale") + TERN_(HAS_STALLGUARD, "/mech_load") "|flags|warncount" ); } @@ -1184,69 +1178,6 @@ #endif // USE_SENSORLESS -#if HAS_TMC_SPI - #define SET_CS_PIN(st) OUT_WRITE(st##_CS_PIN, HIGH) - void tmc_init_cs_pins() { - #if AXIS_HAS_SPI(X) - SET_CS_PIN(X); - #endif - #if AXIS_HAS_SPI(Y) - SET_CS_PIN(Y); - #endif - #if AXIS_HAS_SPI(Z) - SET_CS_PIN(Z); - #endif - #if AXIS_HAS_SPI(X2) - SET_CS_PIN(X2); - #endif - #if AXIS_HAS_SPI(Y2) - SET_CS_PIN(Y2); - #endif - #if AXIS_HAS_SPI(Z2) - SET_CS_PIN(Z2); - #endif - #if AXIS_HAS_SPI(Z3) - SET_CS_PIN(Z3); - #endif - #if AXIS_HAS_SPI(Z4) - SET_CS_PIN(Z4); - #endif - #if AXIS_HAS_SPI(I) - SET_CS_PIN(I); - #endif - #if AXIS_HAS_SPI(J) - SET_CS_PIN(J); - #endif - #if AXIS_HAS_SPI(K) - SET_CS_PIN(K); - #endif - #if AXIS_HAS_SPI(E0) - SET_CS_PIN(E0); - #endif - #if AXIS_HAS_SPI(E1) - SET_CS_PIN(E1); - #endif - #if AXIS_HAS_SPI(E2) - SET_CS_PIN(E2); - #endif - #if AXIS_HAS_SPI(E3) - SET_CS_PIN(E3); - #endif - #if AXIS_HAS_SPI(E4) - SET_CS_PIN(E4); - #endif - #if AXIS_HAS_SPI(E5) - SET_CS_PIN(E5); - #endif - #if AXIS_HAS_SPI(E6) - SET_CS_PIN(E6); - #endif - #if AXIS_HAS_SPI(E7) - SET_CS_PIN(E7); - #endif - } -#endif // HAS_TMC_SPI - template static bool test_connection(TMC &st) { SERIAL_ECHOPGM("Testing "); @@ -1345,3 +1276,66 @@ void test_tmc_connection(LOGICAL_AXIS_ARGS(const bool)) { } #endif // HAS_TRINAMIC_CONFIG + +#if HAS_TMC_SPI + #define SET_CS_PIN(st) OUT_WRITE(st##_CS_PIN, HIGH) + void tmc_init_cs_pins() { + #if AXIS_HAS_SPI(X) + SET_CS_PIN(X); + #endif + #if AXIS_HAS_SPI(Y) + SET_CS_PIN(Y); + #endif + #if AXIS_HAS_SPI(Z) + SET_CS_PIN(Z); + #endif + #if AXIS_HAS_SPI(X2) + SET_CS_PIN(X2); + #endif + #if AXIS_HAS_SPI(Y2) + SET_CS_PIN(Y2); + #endif + #if AXIS_HAS_SPI(Z2) + SET_CS_PIN(Z2); + #endif + #if AXIS_HAS_SPI(Z3) + SET_CS_PIN(Z3); + #endif + #if AXIS_HAS_SPI(Z4) + SET_CS_PIN(Z4); + #endif + #if AXIS_HAS_SPI(I) + SET_CS_PIN(I); + #endif + #if AXIS_HAS_SPI(J) + SET_CS_PIN(J); + #endif + #if AXIS_HAS_SPI(K) + SET_CS_PIN(K); + #endif + #if AXIS_HAS_SPI(E0) + SET_CS_PIN(E0); + #endif + #if AXIS_HAS_SPI(E1) + SET_CS_PIN(E1); + #endif + #if AXIS_HAS_SPI(E2) + SET_CS_PIN(E2); + #endif + #if AXIS_HAS_SPI(E3) + SET_CS_PIN(E3); + #endif + #if AXIS_HAS_SPI(E4) + SET_CS_PIN(E4); + #endif + #if AXIS_HAS_SPI(E5) + SET_CS_PIN(E5); + #endif + #if AXIS_HAS_SPI(E6) + SET_CS_PIN(E6); + #endif + #if AXIS_HAS_SPI(E7) + SET_CS_PIN(E7); + #endif + } +#endif // HAS_TMC_SPI diff --git a/Marlin/src/feature/tmc_util.h b/Marlin/src/feature/tmc_util.h index 1f7d5cf1a543..fc333b09dd99 100644 --- a/Marlin/src/feature/tmc_util.h +++ b/Marlin/src/feature/tmc_util.h @@ -45,6 +45,12 @@ constexpr uint16_t _tmc_thrs(const uint16_t msteps, const uint32_t thrs, const u return 12650000UL * msteps / (256 * thrs * spmm); } +typedef struct { + uint8_t toff; + int8_t hend; + uint8_t hstrt; +} chopper_timing_t; + template class TMCStorage { protected: @@ -58,13 +64,13 @@ class TMCStorage { uint8_t otpw_count = 0, error_count = 0; bool flag_otpw = false; - inline bool getOTPW() { return flag_otpw; } - inline void clear_otpw() { flag_otpw = 0; } + bool getOTPW() { return flag_otpw; } + void clear_otpw() { flag_otpw = 0; } #endif - inline uint16_t getMilliamps() { return val_mA; } + uint16_t getMilliamps() { return val_mA; } - inline void printLabel() { + void printLabel() { SERIAL_CHAR(AXIS_LETTER); if (DRIVER_ID > '0') SERIAL_CHAR(DRIVER_ID); } @@ -91,55 +97,61 @@ class TMCMarlin : public TMC, public TMCStorage { TMCMarlin(const uint16_t CS, const float RS, const uint16_t pinMOSI, const uint16_t pinMISO, const uint16_t pinSCK, const uint8_t axis_chain_index) : TMC(CS, RS, pinMOSI, pinMISO, pinSCK, axis_chain_index) {} - inline uint16_t rms_current() { return TMC::rms_current(); } - inline void rms_current(uint16_t mA) { + uint16_t rms_current() { return TMC::rms_current(); } + void rms_current(uint16_t mA) { this->val_mA = mA; TMC::rms_current(mA); } - inline void rms_current(const uint16_t mA, const float mult) { + void rms_current(const uint16_t mA, const float mult) { this->val_mA = mA; TMC::rms_current(mA, mult); } - inline uint16_t get_microstep_counter() { return TMC::MSCNT(); } + uint16_t get_microstep_counter() { return TMC::MSCNT(); } #if HAS_STEALTHCHOP - inline bool get_stealthChop() { return this->en_pwm_mode(); } - inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } - inline void refresh_stepping_mode() { this->en_pwm_mode(this->stored.stealthChop_enabled); } - inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); } - inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); } + bool get_stealthChop() { return this->en_pwm_mode(); } + bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } + void refresh_stepping_mode() { this->en_pwm_mode(this->stored.stealthChop_enabled); } + void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); } + bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); } #endif + void set_chopper_times(const chopper_timing_t &ct) { + TMC::toff(ct.toff); + TMC::hysteresis_end(ct.hend); + TMC::hysteresis_start(ct.hstrt); + } + #if ENABLED(HYBRID_THRESHOLD) uint32_t get_pwm_thrs() { return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); } void set_pwm_thrs(const uint32_t thrs) { TMC::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); - TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs); + TERN_(HAS_MARLINUI_MENU, this->stored.hybrid_thrs = thrs); } #endif #if USE_SENSORLESS - inline int16_t homing_threshold() { return TMC::sgt(); } + int16_t homing_threshold() { return TMC::sgt(); } void homing_threshold(int16_t sgt_val) { sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max); TMC::sgt(sgt_val); - TERN_(HAS_LCD_MENU, this->stored.homing_thrs = sgt_val); + TERN_(HAS_MARLINUI_MENU, this->stored.homing_thrs = sgt_val); } #if ENABLED(SPI_ENDSTOPS) bool test_stall_status(); #endif #endif - #if HAS_LCD_MENU - inline void refresh_stepper_current() { rms_current(this->val_mA); } + #if HAS_MARLINUI_MENU + void refresh_stepper_current() { rms_current(this->val_mA); } #if ENABLED(HYBRID_THRESHOLD) - inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } + void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } #endif #if USE_SENSORLESS - inline void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); } + void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); } #endif #endif @@ -161,39 +173,45 @@ class TMCMarlin : public TMC220 {} uint16_t rms_current() { return TMC2208Stepper::rms_current(); } - inline void rms_current(const uint16_t mA) { + void rms_current(const uint16_t mA) { this->val_mA = mA; TMC2208Stepper::rms_current(mA); } - inline void rms_current(const uint16_t mA, const float mult) { + void rms_current(const uint16_t mA, const float mult) { this->val_mA = mA; TMC2208Stepper::rms_current(mA, mult); } - inline uint16_t get_microstep_counter() { return TMC2208Stepper::MSCNT(); } + uint16_t get_microstep_counter() { return TMC2208Stepper::MSCNT(); } #if HAS_STEALTHCHOP - inline bool get_stealthChop() { return !this->en_spreadCycle(); } - inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } - inline void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); } - inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); } - inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); } + bool get_stealthChop() { return !this->en_spreadCycle(); } + bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } + void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); } + void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); } + bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); } #endif + void set_chopper_times(const chopper_timing_t &ct) { + TMC2208Stepper::toff(ct.toff); + TMC2208Stepper::hysteresis_end(ct.hend); + TMC2208Stepper::hysteresis_start(ct.hstrt); + } + #if ENABLED(HYBRID_THRESHOLD) uint32_t get_pwm_thrs() { return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); } void set_pwm_thrs(const uint32_t thrs) { TMC2208Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); - TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs); + TERN_(HAS_MARLINUI_MENU, this->stored.hybrid_thrs = thrs); } #endif - #if HAS_LCD_MENU - inline void refresh_stepper_current() { rms_current(this->val_mA); } + #if HAS_MARLINUI_MENU + void refresh_stepper_current() { rms_current(this->val_mA); } #if ENABLED(HYBRID_THRESHOLD) - inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } + void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } #endif #endif }; @@ -209,50 +227,56 @@ class TMCMarlin : public TMC220 {} uint8_t get_address() { return slave_address; } uint16_t rms_current() { return TMC2209Stepper::rms_current(); } - inline void rms_current(const uint16_t mA) { + void rms_current(const uint16_t mA) { this->val_mA = mA; TMC2209Stepper::rms_current(mA); } - inline void rms_current(const uint16_t mA, const float mult) { + void rms_current(const uint16_t mA, const float mult) { this->val_mA = mA; TMC2209Stepper::rms_current(mA, mult); } - inline uint16_t get_microstep_counter() { return TMC2209Stepper::MSCNT(); } + uint16_t get_microstep_counter() { return TMC2209Stepper::MSCNT(); } #if HAS_STEALTHCHOP - inline bool get_stealthChop() { return !this->en_spreadCycle(); } - inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } - inline void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); } - inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); } - inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); } + bool get_stealthChop() { return !this->en_spreadCycle(); } + bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } + void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); } + void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); } + bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); } #endif + void set_chopper_times(const chopper_timing_t &ct) { + TMC2209Stepper::toff(ct.toff); + TMC2209Stepper::hysteresis_end(ct.hend); + TMC2209Stepper::hysteresis_start(ct.hstrt); + } + #if ENABLED(HYBRID_THRESHOLD) uint32_t get_pwm_thrs() { return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); } void set_pwm_thrs(const uint32_t thrs) { TMC2209Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); - TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs); + TERN_(HAS_MARLINUI_MENU, this->stored.hybrid_thrs = thrs); } #endif #if USE_SENSORLESS - inline int16_t homing_threshold() { return TMC2209Stepper::SGTHRS(); } + int16_t homing_threshold() { return TMC2209Stepper::SGTHRS(); } void homing_threshold(int16_t sgt_val) { sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max); TMC2209Stepper::SGTHRS(sgt_val); - TERN_(HAS_LCD_MENU, this->stored.homing_thrs = sgt_val); + TERN_(HAS_MARLINUI_MENU, this->stored.homing_thrs = sgt_val); } #endif - #if HAS_LCD_MENU - inline void refresh_stepper_current() { rms_current(this->val_mA); } + #if HAS_MARLINUI_MENU + void refresh_stepper_current() { rms_current(this->val_mA); } #if ENABLED(HYBRID_THRESHOLD) - inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } + void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } #endif #if USE_SENSORLESS - inline void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); } + void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); } #endif #endif @@ -269,27 +293,33 @@ class TMCMarlin : public TMC266 TMCMarlin(const uint16_t CS, const float RS, const uint16_t pinMOSI, const uint16_t pinMISO, const uint16_t pinSCK, const uint8_t) : TMC2660Stepper(CS, RS, pinMOSI, pinMISO, pinSCK) {} - inline uint16_t rms_current() { return TMC2660Stepper::rms_current(); } - inline void rms_current(const uint16_t mA) { + uint16_t rms_current() { return TMC2660Stepper::rms_current(); } + void rms_current(const uint16_t mA) { this->val_mA = mA; TMC2660Stepper::rms_current(mA); } - inline uint16_t get_microstep_counter() { return TMC2660Stepper::mstep(); } + uint16_t get_microstep_counter() { return TMC2660Stepper::mstep(); } + + void set_chopper_times(const chopper_timing_t &ct) { + TMC2660Stepper::toff(ct.toff); + TMC2660Stepper::hysteresis_end(ct.hend); + TMC2660Stepper::hysteresis_start(ct.hstrt); + } #if USE_SENSORLESS - inline int16_t homing_threshold() { return TMC2660Stepper::sgt(); } + int16_t homing_threshold() { return TMC2660Stepper::sgt(); } void homing_threshold(int16_t sgt_val) { sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max); TMC2660Stepper::sgt(sgt_val); - TERN_(HAS_LCD_MENU, this->stored.homing_thrs = sgt_val); + TERN_(HAS_MARLINUI_MENU, this->stored.homing_thrs = sgt_val); } #endif - #if HAS_LCD_MENU - inline void refresh_stepper_current() { rms_current(this->val_mA); } + #if HAS_MARLINUI_MENU + void refresh_stepper_current() { rms_current(this->val_mA); } #if USE_SENSORLESS - inline void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); } + void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); } #endif #endif @@ -297,43 +327,6 @@ class TMCMarlin : public TMC266 sgt_max = 63; }; -template -void tmc_print_current(TMC &st) { - st.printLabel(); - SERIAL_ECHOLNPGM(" driver current: ", st.getMilliamps()); -} - -#if ENABLED(MONITOR_DRIVER_STATUS) - template - void tmc_report_otpw(TMC &st) { - st.printLabel(); - SERIAL_ECHOPGM(" temperature prewarn triggered: "); - serialprint_truefalse(st.getOTPW()); - SERIAL_EOL(); - } - template - void tmc_clear_otpw(TMC &st) { - st.clear_otpw(); - st.printLabel(); - SERIAL_ECHOLNPGM(" prewarn flag cleared"); - } -#endif -#if ENABLED(HYBRID_THRESHOLD) - template - void tmc_print_pwmthrs(TMC &st) { - st.printLabel(); - SERIAL_ECHOLNPGM(" stealthChop max speed: ", st.get_pwm_thrs()); - } -#endif -#if USE_SENSORLESS - template - void tmc_print_sgt(TMC &st) { - st.printLabel(); - SERIAL_ECHOPGM(" homing sensitivity: "); - SERIAL_PRINTLN(st.homing_threshold(), PrintBase::Dec); - } -#endif - void monitor_tmc_drivers(); void test_tmc_connection(LOGICAL_AXIS_DECL(const bool, true)); @@ -389,8 +382,8 @@ void test_tmc_connection(LOGICAL_AXIS_DECL(const bool, true)); #endif // USE_SENSORLESS +#endif // HAS_TRINAMIC_CONFIG + #if HAS_TMC_SPI void tmc_init_cs_pins(); #endif - -#endif // HAS_TRINAMIC_CONFIG diff --git a/Marlin/src/feature/twibus.h b/Marlin/src/feature/twibus.h index d2c7270303c7..806e2a147a7d 100644 --- a/Marlin/src/feature/twibus.h +++ b/Marlin/src/feature/twibus.h @@ -244,11 +244,11 @@ class TWIBus { static void debug(FSTR_P const func, char c); static void debug(FSTR_P const func, char adr[]); #else - static inline void debug(FSTR_P const, uint32_t) {} - static inline void debug(FSTR_P const, char) {} - static inline void debug(FSTR_P const, char[]) {} + static void debug(FSTR_P const, uint32_t) {} + static void debug(FSTR_P const, char) {} + static void debug(FSTR_P const, char[]) {} #endif - static inline void debug(FSTR_P const func, uint8_t v) { debug(func, (uint32_t)v); } + static void debug(FSTR_P const func, uint8_t v) { debug(func, (uint32_t)v); } }; extern TWIBus i2c; diff --git a/Marlin/src/feature/bedlevel/abl/x_twist.cpp b/Marlin/src/feature/x_twist.cpp similarity index 64% rename from Marlin/src/feature/bedlevel/abl/x_twist.cpp rename to Marlin/src/feature/x_twist.cpp index c4a62c35953f..b5ad25cba87d 100644 --- a/Marlin/src/feature/bedlevel/abl/x_twist.cpp +++ b/Marlin/src/feature/x_twist.cpp @@ -19,29 +19,36 @@ * along with this program. If not, see . * */ -#include "../../../inc/MarlinConfig.h" +#include "../inc/MarlinConfig.h" #if ENABLED(X_AXIS_TWIST_COMPENSATION) -#include "../bedlevel.h" +#include "x_twist.h" +#include "../module/probe.h" XATC xatc; +bool XATC::enabled; float XATC::spacing, XATC::start; -xatc_points_t XATC::z_values; +xatc_array_t XATC::z_offset; // Initialized by settings.load() + +void XATC::reset() { + constexpr float xzo[] = XATC_Z_OFFSETS; + static_assert(COUNT(xzo) == XATC_MAX_POINTS, "XATC_Z_OFFSETS is the wrong size."); + COPY(z_offset, xzo); + start = probe.min_x(); + spacing = (probe.max_x() - start) / (XATC_MAX_POINTS - 1); + enabled = true; +} void XATC::print_points() { SERIAL_ECHOLNPGM(" X-Twist Correction:"); LOOP_L_N(x, XATC_MAX_POINTS) { SERIAL_CHAR(' '); - if (!isnan(z_values[x])) { - if (z_values[x] >= 0) SERIAL_CHAR('+'); - SERIAL_ECHO_F(z_values[x], 3); - } - else { - LOOP_L_N(i, 6) - SERIAL_CHAR(i ? '=' : ' '); - } + if (!isnan(z_offset[x])) + serial_offset(z_offset[x]); + else + LOOP_L_N(i, 6) SERIAL_CHAR(i ? '=' : ' '); } SERIAL_EOL(); } @@ -49,11 +56,12 @@ void XATC::print_points() { float lerp(const_float_t t, const_float_t a, const_float_t b) { return a + t * (b - a); } float XATC::compensation(const xy_pos_t &raw) { + if (!enabled) return 0; + if (NEAR_ZERO(spacing)) return 0; float t = (raw.x - start) / spacing; - int i = FLOOR(t); - LIMIT(i, 0, XATC_MAX_POINTS - 2); + const int i = constrain(FLOOR(t), 0, XATC_MAX_POINTS - 2); t -= i; - return lerp(t, z_values[i], z_values[i + 1]); + return lerp(t, z_offset[i], z_offset[i + 1]); } #endif // X_AXIS_TWIST_COMPENSATION diff --git a/Marlin/src/feature/bedlevel/abl/x_twist.h b/Marlin/src/feature/x_twist.h similarity index 82% rename from Marlin/src/feature/bedlevel/abl/x_twist.h rename to Marlin/src/feature/x_twist.h index bbad9e73efac..6a2ff279013a 100644 --- a/Marlin/src/feature/bedlevel/abl/x_twist.h +++ b/Marlin/src/feature/x_twist.h @@ -21,15 +21,18 @@ */ #pragma once -#include "../../../inc/MarlinConfigPre.h" +#include "../inc/MarlinConfigPre.h" -typedef float xatc_points_t[XATC_MAX_POINTS]; +typedef float xatc_array_t[XATC_MAX_POINTS]; class XATC { + static bool enabled; public: static float spacing, start; - static xatc_points_t z_values; + static xatc_array_t z_offset; + static void reset(); + static void set_enabled(const bool ena) { enabled = ena; } static float compensation(const xy_pos_t &raw); static void print_points(); }; diff --git a/Marlin/src/feature/z_stepper_align.cpp b/Marlin/src/feature/z_stepper_align.cpp index 1b4eb4474903..9dba21d8219d 100644 --- a/Marlin/src/feature/z_stepper_align.cpp +++ b/Marlin/src/feature/z_stepper_align.cpp @@ -33,35 +33,35 @@ ZStepperAlign z_stepper_align; -xy_pos_t ZStepperAlign::xy[NUM_Z_STEPPER_DRIVERS]; +xy_pos_t ZStepperAlign::xy[NUM_Z_STEPPERS]; -#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - xy_pos_t ZStepperAlign::stepper_xy[NUM_Z_STEPPER_DRIVERS]; +#if HAS_Z_STEPPER_ALIGN_STEPPER_XY + xy_pos_t ZStepperAlign::stepper_xy[NUM_Z_STEPPERS]; #endif void ZStepperAlign::reset_to_default() { #ifdef Z_STEPPER_ALIGN_XY constexpr xy_pos_t xy_init[] = Z_STEPPER_ALIGN_XY; - static_assert(COUNT(xy_init) == NUM_Z_STEPPER_DRIVERS, + static_assert(COUNT(xy_init) == NUM_Z_STEPPERS, "Z_STEPPER_ALIGN_XY requires " - #if NUM_Z_STEPPER_DRIVERS == 4 + #if NUM_Z_STEPPERS == 4 "four {X,Y} entries (Z, Z2, Z3, and Z4)." - #elif NUM_Z_STEPPER_DRIVERS == 3 + #elif NUM_Z_STEPPERS == 3 "three {X,Y} entries (Z, Z2, and Z3)." #else "two {X,Y} entries (Z and Z2)." #endif ); - #define VALIDATE_ALIGN_POINT(N) static_assert(N >= NUM_Z_STEPPER_DRIVERS || Probe::build_time::can_reach(xy_init[N]), \ + #define VALIDATE_ALIGN_POINT(N) static_assert(N >= NUM_Z_STEPPERS || Probe::build_time::can_reach(xy_init[N]), \ "Z_STEPPER_ALIGN_XY point " STRINGIFY(N) " is not reachable with the default NOZZLE_TO_PROBE offset and PROBING_MARGIN.") VALIDATE_ALIGN_POINT(0); VALIDATE_ALIGN_POINT(1); VALIDATE_ALIGN_POINT(2); VALIDATE_ALIGN_POINT(3); #else // !Z_STEPPER_ALIGN_XY const xy_pos_t xy_init[] = { - #if NUM_Z_STEPPER_DRIVERS >= 3 // First probe point... + #if NUM_Z_STEPPERS >= 3 // First probe point... #if !Z_STEPPERS_ORIENTATION { probe.min_x(), probe.min_y() }, // SW #elif Z_STEPPERS_ORIENTATION == 1 @@ -73,7 +73,7 @@ void ZStepperAlign::reset_to_default() { #else #error "Z_STEPPERS_ORIENTATION must be from 0 to 3 (first point SW, NW, NE, SE)." #endif - #if NUM_Z_STEPPER_DRIVERS == 4 // 3 more points... + #if NUM_Z_STEPPERS == 4 // 3 more points... #if !Z_STEPPERS_ORIENTATION { probe.min_x(), probe.max_y() }, { probe.max_x(), probe.max_y() }, { probe.max_x(), probe.min_y() } // SW #elif Z_STEPPERS_ORIENTATION == 1 @@ -103,14 +103,14 @@ void ZStepperAlign::reset_to_default() { COPY(xy, xy_init); - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY constexpr xy_pos_t stepper_xy_init[] = Z_STEPPER_ALIGN_STEPPER_XY; static_assert( - COUNT(stepper_xy_init) == NUM_Z_STEPPER_DRIVERS, + COUNT(stepper_xy_init) == NUM_Z_STEPPERS, "Z_STEPPER_ALIGN_STEPPER_XY requires " - #if NUM_Z_STEPPER_DRIVERS == 4 + #if NUM_Z_STEPPERS == 4 "four {X,Y} entries (Z, Z2, Z3, and Z4)." - #elif NUM_Z_STEPPER_DRIVERS == 3 + #elif NUM_Z_STEPPERS == 3 "three {X,Y} entries (Z, Z2, and Z3)." #endif ); diff --git a/Marlin/src/feature/z_stepper_align.h b/Marlin/src/feature/z_stepper_align.h index e1b235b52cb3..f3f9abb845b9 100644 --- a/Marlin/src/feature/z_stepper_align.h +++ b/Marlin/src/feature/z_stepper_align.h @@ -29,10 +29,10 @@ class ZStepperAlign { public: - static xy_pos_t xy[NUM_Z_STEPPER_DRIVERS]; + static xy_pos_t xy[NUM_Z_STEPPERS]; - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - static xy_pos_t stepper_xy[NUM_Z_STEPPER_DRIVERS]; + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY + static xy_pos_t stepper_xy[NUM_Z_STEPPERS]; #endif static void reset_to_default(); diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index 728771d5809d..21fa08fc107a 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -71,8 +71,8 @@ * pliers while holding the LCD Click wheel in a depressed state. If you do not have * an LCD, you must specify a value if you use P. * - * Q # Multiplier Retraction Multiplier. Normally not needed. Retraction defaults to 1.0mm and - * un-retraction is at 1.2mm These numbers will be scaled by the specified amount + * Q # Multiplier Retraction Multiplier. (Normally not needed.) During G26 retraction will use the length + * specified by this parameter (1mm by default). Recover will be 1.2x the retract distance. * * R # Repeat Prints the number of patterns given as a parameter, starting at the current location. * If a parameter isn't given, every point will be printed unless G26 is interrupted. @@ -156,7 +156,7 @@ constexpr float g26_e_axis_feedrate = 0.025; static MeshFlags circle_flags; float g26_random_deviation = 0.0; -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU /** * If the LCD is clicked, cancel, wait for release, return true @@ -164,7 +164,7 @@ 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_LCD_MENU, ui.quick_feedback()); + TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); ui.wait_for_release(); return true; } @@ -293,10 +293,10 @@ typedef struct { if (circle_flags.marked(p1.x, p1.y) && circle_flags.marked(p2.x, p2.y)) { xyz_pos_t s, e; - s.x = _GET_MESH_X(p1.x) + (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)) * dx; - e.x = _GET_MESH_X(p2.x) - (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)) * dx; - s.y = _GET_MESH_Y(p1.y) + (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)) * dy; - e.y = _GET_MESH_Y(p2.y) - (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)) * dy; + s.x = bedlevel.get_mesh_x(p1.x) + (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)) * dx; + e.x = bedlevel.get_mesh_x(p2.x) - (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)) * dx; + s.y = bedlevel.get_mesh_y(p1.y) + (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)) * dy; + e.y = bedlevel.get_mesh_y(p2.y) - (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)) * dy; s.z = e.z = layer_height; #if HAS_ENDSTOPS @@ -325,7 +325,7 @@ typedef struct { #if HAS_WIRED_LCD ui.set_status(GET_TEXT_F(MSG_G26_HEATING_BED), 99); ui.quick_feedback(); - TERN_(HAS_LCD_MENU, ui.capture()); + TERN_(HAS_MARLINUI_MENU, ui.capture()); #endif thermalManager.setTargetBed(bed_temp); @@ -365,7 +365,7 @@ typedef struct { bool prime_nozzle() { const feedRate_t fr_slow_e = planner.settings.max_feedrate_mm_s[E_AXIS] / 15.0f; - #if HAS_LCD_MENU && !HAS_TOUCH_BUTTONS // ui.button_pressed issue with touchscreen + #if HAS_MARLINUI_MENU && !HAS_TOUCH_BUTTONS // ui.button_pressed issue with touchscreen #if ENABLED(PREVENT_LENGTHY_EXTRUDE) float Total_Prime = 0.0; #endif @@ -448,7 +448,7 @@ typedef struct { GRID_LOOP(i, j) { if (!circle_flags.marked(i, j)) { // We found a circle that needs to be printed - const xy_pos_t m = { _GET_MESH_X(i), _GET_MESH_Y(j) }; + const xy_pos_t m = { bedlevel.get_mesh_x(i), bedlevel.get_mesh_y(j) }; // Get the distance to this intersection float f = (pos - m).magnitude(); @@ -579,7 +579,7 @@ void GcodeSuite::G26() { if (parser.seen('P')) { if (!parser.has_value()) { - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU g26.prime_flag = -1; #else SERIAL_ECHOLNPGM("?Prime length must be specified when not using an LCD."); @@ -638,7 +638,7 @@ void GcodeSuite::G26() { // Get repeat from 'R', otherwise do one full circuit int16_t g26_repeats; - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU g26_repeats = parser.intval('R', GRID_MAX_POINTS + 1); #else if (parser.seen('R')) @@ -699,7 +699,7 @@ void GcodeSuite::G26() { move_to(destination, 0.0); move_to(destination, g26.ooze_amount); - TERN_(HAS_LCD_MENU, ui.capture()); + TERN_(HAS_MARLINUI_MENU, ui.capture()); #if DISABLED(ARC_SUPPORT) @@ -729,7 +729,7 @@ void GcodeSuite::G26() { if (location.valid()) { TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location.pos, ExtUI::G26_POINT_START)); - const xy_pos_t circle = _GET_MESH_POS(location.pos); + const xy_pos_t circle = { bedlevel.get_mesh_x(location.pos.a), bedlevel.get_mesh_y(location.pos.b) }; // If this mesh location is outside the printable radius, skip it. if (!position_is_reachable(circle)) continue; @@ -738,8 +738,8 @@ void GcodeSuite::G26() { // which is always drawn counter-clockwise. const xy_int8_t st = location; const bool f = st.y == 0, - r = st.x >= GRID_MAX_POINTS_X - 1, - b = st.y >= GRID_MAX_POINTS_Y - 1; + r = st.x >= (GRID_MAX_POINTS_X) - 1, + b = st.y >= (GRID_MAX_POINTS_Y) - 1; #if ENABLED(ARC_SUPPORT) @@ -795,7 +795,7 @@ void GcodeSuite::G26() { destination = current_position; } - if (TERN0(HAS_LCD_MENU, user_canceled())) goto LEAVE; // Check if the user wants to stop the Mesh Validation + if (TERN0(HAS_MARLINUI_MENU, user_canceled())) goto LEAVE; // Check if the user wants to stop the Mesh Validation #else // !ARC_SUPPORT @@ -819,7 +819,7 @@ void GcodeSuite::G26() { for (int8_t ind = start_ind; ind <= end_ind; ind++) { - if (TERN0(HAS_LCD_MENU, user_canceled())) goto LEAVE; // Check if the user wants to stop the Mesh Validation + if (TERN0(HAS_MARLINUI_MENU, user_canceled())) goto LEAVE; // Check if the user wants to stop the Mesh Validation xyz_float_t p = { circle.x + _COS(ind ), circle.y + _SIN(ind ), g26.layer_height }, q = { circle.x + _COS(ind + 1), circle.y + _SIN(ind + 1), g26.layer_height }; @@ -846,7 +846,7 @@ void GcodeSuite::G26() { g26.connect_neighbor_with_line(location.pos, 0, 1); planner.synchronize(); TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location.pos, ExtUI::G26_POINT_FINISH)); - if (TERN0(HAS_LCD_MENU, user_canceled())) goto LEAVE; + if (TERN0(HAS_MARLINUI_MENU, user_canceled())) goto LEAVE; } SERIAL_FLUSH(); // Prevent host M105 buffer overrun. @@ -866,7 +866,7 @@ void GcodeSuite::G26() { planner.calculate_volumetric_multipliers(); #endif - TERN_(HAS_LCD_MENU, ui.release()); // Give back control of the LCD + TERN_(HAS_MARLINUI_MENU, ui.release()); // Give back control of the LCD if (!g26.keep_heaters_on) { TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(0)); diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 8cabb923825a..dd828bf0c873 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -106,7 +106,9 @@ void GcodeSuite::G35() { // In BLTOUCH HS mode, the probe travels in a deployed state. // Users of G35 might have a badly misaligned bed, so raise Z by the // length of the deployed pin (BLTOUCH stroke < 7mm) - do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES + TERN0(BLTOUCH, bltouch.z_extra_clearance())); + + // Unsure if this is even required. The probe seems to lift correctly after probe done. + do_blocking_move_to_z(SUM_TERN(BLTOUCH, Z_CLEARANCE_BETWEEN_PROBES, bltouch.z_extra_clearance())); const float z_probed_height = probe.probe_at_point(tramming_points[i], PROBE_PT_RAISE, 0, true); if (isnan(z_probed_height)) { @@ -153,7 +155,7 @@ void GcodeSuite::G35() { // Restore the active tool after homing #if HAS_MULTI_HOTEND - tool_change(old_tool_index, DISABLED(PARKING_EXTRUDER)); // Fetch previous toolhead if not PARKING_EXTRUDER + if (old_tool_index != 0) tool_change(old_tool_index, DISABLED(PARKING_EXTRUDER)); // Fetch previous toolhead if not PARKING_EXTRUDER #endif #if BOTH(HAS_LEVELING, RESTORE_LEVELING_AFTER_G35) diff --git a/Marlin/src/gcode/bedlevel/G42.cpp b/Marlin/src/gcode/bedlevel/G42.cpp index a2896ed6c705..cb5ed9740604 100644 --- a/Marlin/src/gcode/bedlevel/G42.cpp +++ b/Marlin/src/gcode/bedlevel/G42.cpp @@ -48,8 +48,8 @@ void GcodeSuite::G42() { // Move to current_position, as modified by I, J, P parameters destination = current_position; - if (hasI) destination.x = _GET_MESH_X(ix); - if (hasJ) destination.y = _GET_MESH_Y(iy); + if (hasI) destination.x = bedlevel.get_mesh_x(ix); + if (hasJ) destination.y = bedlevel.get_mesh_y(iy); #if HAS_PROBE_XY_OFFSET if (parser.boolval('P')) { diff --git a/Marlin/src/gcode/bedlevel/M420.cpp b/Marlin/src/gcode/bedlevel/M420.cpp index 3c23e85a1dfb..277f95b9ffe1 100644 --- a/Marlin/src/gcode/bedlevel/M420.cpp +++ b/Marlin/src/gcode/bedlevel/M420.cpp @@ -67,14 +67,17 @@ void GcodeSuite::M420() { const float x_min = probe.min_x(), x_max = probe.max_x(), y_min = probe.min_y(), y_max = probe.max_y(); #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - bilinear_start.set(x_min, y_min); - bilinear_grid_spacing.set((x_max - x_min) / (GRID_MAX_CELLS_X), - (y_max - y_min) / (GRID_MAX_CELLS_Y)); + xy_pos_t start, spacing; + start.set(x_min, y_min); + spacing.set((x_max - x_min) / (GRID_MAX_CELLS_X), + (y_max - y_min) / (GRID_MAX_CELLS_Y)); + bedlevel.set_grid(spacing, start); #endif GRID_LOOP(x, y) { - Z_VALUES(x, y) = 0.001 * random(-200, 200); - TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y))); + bedlevel.z_values[x][y] = 0.001 * random(-200, 200); + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, bedlevel.z_values[x][y])); } + TERN_(AUTO_BED_LEVELING_BILINEAR, bedlevel.refresh_bed_level()); SERIAL_ECHOPGM("Simulated " STRINGIFY(GRID_MAX_POINTS_X) "x" STRINGIFY(GRID_MAX_POINTS_Y) " mesh "); SERIAL_ECHOPGM(" (", x_min); SERIAL_CHAR(','); SERIAL_ECHO(y_min); @@ -98,7 +101,7 @@ void GcodeSuite::M420() { set_bed_leveling_enabled(false); #if ENABLED(EEPROM_SETTINGS) - const int8_t storage_slot = parser.has_value() ? parser.value_int() : ubl.storage_slot; + const int8_t storage_slot = parser.has_value() ? parser.value_int() : bedlevel.storage_slot; const int16_t a = settings.calc_num_meshes(); if (!a) { @@ -113,7 +116,7 @@ void GcodeSuite::M420() { } settings.load_mesh(storage_slot); - ubl.storage_slot = storage_slot; + bedlevel.storage_slot = storage_slot; #else @@ -125,10 +128,10 @@ void GcodeSuite::M420() { // L or V display the map info if (parser.seen("LV")) { - ubl.display_map(parser.byteval('T')); + bedlevel.display_map(parser.byteval('T')); SERIAL_ECHOPGM("Mesh is "); - if (!ubl.mesh_is_valid()) SERIAL_ECHOPGM("in"); - SERIAL_ECHOLNPGM("valid\nStorage slot: ", ubl.storage_slot); + if (!bedlevel.mesh_is_valid()) SERIAL_ECHOPGM("in"); + SERIAL_ECHOLNPGM("valid\nStorage slot: ", bedlevel.storage_slot); } #endif // AUTO_BED_LEVELING_UBL @@ -145,7 +148,7 @@ void GcodeSuite::M420() { #if ENABLED(AUTO_BED_LEVELING_UBL) set_bed_leveling_enabled(false); - ubl.adjust_mesh_to_mean(true, cval); + bedlevel.adjust_mesh_to_mean(true, cval); #else @@ -153,7 +156,7 @@ void GcodeSuite::M420() { // Get the sum and average of all mesh values float mesh_sum = 0; - GRID_LOOP(x, y) mesh_sum += Z_VALUES(x, y); + GRID_LOOP(x, y) mesh_sum += bedlevel.z_values[x][y]; const float zmean = mesh_sum / float(GRID_MAX_POINTS); #else // midrange @@ -161,7 +164,7 @@ void GcodeSuite::M420() { // Find the low and high mesh values. float lo_val = 100, hi_val = -100; GRID_LOOP(x, y) { - const float z = Z_VALUES(x, y); + const float z = bedlevel.z_values[x][y]; NOMORE(lo_val, z); NOLESS(hi_val, z); } @@ -175,10 +178,10 @@ void GcodeSuite::M420() { set_bed_leveling_enabled(false); // Subtract the mean from all values GRID_LOOP(x, y) { - Z_VALUES(x, y) -= zmean; - TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y))); + bedlevel.z_values[x][y] -= zmean; + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, bedlevel.z_values[x][y])); } - TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate()); + TERN_(AUTO_BED_LEVELING_BILINEAR, bedlevel.refresh_bed_level()); } #endif @@ -199,11 +202,10 @@ void GcodeSuite::M420() { #else if (leveling_is_valid()) { #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - print_bilinear_leveling_grid(); - TERN_(ABL_BILINEAR_SUBDIVISION, print_bilinear_leveling_grid_virt()); + bedlevel.print_leveling_grid(); #elif ENABLED(MESH_BED_LEVELING) SERIAL_ECHOLNPGM("Mesh Bed Level data:"); - mbl.report_mesh(); + bedlevel.report_mesh(); #endif } #endif diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 6765ec86a6ec..0d247e47673c 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -36,15 +36,6 @@ #include "../../../module/probe.h" #include "../../queue.h" -#if HAS_PTC - #include "../../../feature/probe_temp_comp.h" - #include "../../../module/temperature.h" -#endif - -#if HAS_STATUS_MESSAGE - #include "../../../lcd/marlinui.h" -#endif - #if ENABLED(AUTO_BED_LEVELING_LINEAR) #include "../../../libs/least_squares_fit.h" #endif @@ -53,21 +44,22 @@ #include "../../../libs/vector_3.h" #endif -#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) -#include "../../../core/debug_out.h" - +#include "../../../lcd/marlinui.h" #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD) #include "../../../lcd/e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../../../lcd/e3v2/proui/dwin.h" #endif #if HAS_MULTI_HOTEND #include "../../../module/tool_change.h" #endif +#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) +#include "../../../core/debug_out.h" + #if ABL_USES_GRID #if ENABLED(PROBE_Y_FIRST) #define PR_OUTER_VAR abl.meshCount.x @@ -82,7 +74,20 @@ #endif #endif -#define G29_RETURN(b) return TERN_(G29_RETRY_AND_RECOVER, b) +static void pre_g29_return(const bool retry, const bool did) { + if (!retry) { + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE, false)); + } + if (did) { + TERN_(HAS_DWIN_E3V2_BASIC, DWIN_LevelingDone()); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); + } +} + +#define G29_RETURN(retry, did) do{ \ + pre_g29_return(TERN0(G29_RETRY_AND_RECOVER, retry), did); \ + return TERN_(G29_RETRY_AND_RECOVER, retry); \ +}while(0) // For manual probing values persist over multiple G29 class G29_State { @@ -93,6 +98,10 @@ class G29_State { bool dryrun, reenable; + #if HAS_MULTI_HOTEND + uint8_t tool_index; + #endif + #if EITHER(PROBE_MANUALLY, AUTO_BED_LEVELING_LINEAR) int abl_probe_index; #endif @@ -123,6 +132,7 @@ class G29_State { #if ENABLED(AUTO_BED_LEVELING_BILINEAR) float Z_offset; + bed_mesh_t z_values; #endif #if ENABLED(AUTO_BED_LEVELING_LINEAR) @@ -219,27 +229,31 @@ class G29_State { G29_TYPE GcodeSuite::G29() { DEBUG_SECTION(log_G29, "G29", DEBUGGING(LEVELING)); + // Leveling state is persistent when done manually with multiple G29 commands TERN_(PROBE_MANUALLY, static) G29_State abl; - TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE)); - + // Keep powered steppers from timing out reset_stepper_timeout(); + // Q = Query leveling and G29 state const bool seenQ = EITHER(DEBUG_LEVELING_FEATURE, PROBE_MANUALLY) && parser.seen_test('Q'); // G29 Q is also available if debugging #if ENABLED(DEBUG_LEVELING_FEATURE) if (seenQ || DEBUGGING(LEVELING)) log_machine_info(); - if (DISABLED(PROBE_MANUALLY) && seenQ) G29_RETURN(false); + if (DISABLED(PROBE_MANUALLY) && seenQ) G29_RETURN(false, false); #endif + // A = Abort manual probing + // C = Generate fake probe points (DEBUG_LEVELING_FEATURE) const bool seenA = TERN0(PROBE_MANUALLY, parser.seen_test('A')), no_action = seenA || seenQ, faux = ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY) ? parser.boolval('C') : no_action; - if (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed + // O = Don't level if leveling is already active + if (!no_action && planner.leveling_active && parser.boolval('O')) { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Auto-level not needed, skip"); - G29_RETURN(false); + G29_RETURN(false, false); } // Send 'N' to force homing before G29 (internal only) @@ -247,23 +261,31 @@ G29_TYPE GcodeSuite::G29() { process_subcommands_now(TERN(CAN_SET_LEVELING_AFTER_G28, F("G28L0"), FPSTR(G28_STR))); // Don't allow auto-leveling without homing first - if (homing_needed_error()) G29_RETURN(false); + if (homing_needed_error()) G29_RETURN(false, false); + // 3-point leveling gets points from the probe class #if ENABLED(AUTO_BED_LEVELING_3POINT) vector_3 points[3]; probe.get_three_points(points); #endif + // Storage for ABL Linear results #if ENABLED(AUTO_BED_LEVELING_LINEAR) struct linear_fit_data lsf_results; #endif + // Set and report "probing" state to host + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE, false)); + /** * On the initial G29 fetch command parameters. */ if (!g29_in_progress) { - TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0)); + #if HAS_MULTI_HOTEND + abl.tool_index = active_extruder; + if (active_extruder != 0) tool_change(0, true); + #endif #if EITHER(PROBE_MANUALLY, AUTO_BED_LEVELING_LINEAR) abl.abl_probe_index = -1; @@ -277,35 +299,43 @@ G29_TYPE GcodeSuite::G29() { if (seen_w) { if (!leveling_is_valid()) { SERIAL_ERROR_MSG("No bilinear grid"); - G29_RETURN(false); + G29_RETURN(false, false); } const float rz = parser.seenval('Z') ? RAW_Z_POSITION(parser.value_linear_units()) : current_position.z; if (!WITHIN(rz, -10, 10)) { SERIAL_ERROR_MSG("Bad Z value"); - G29_RETURN(false); + G29_RETURN(false, false); } const float rx = RAW_X_POSITION(parser.linearval('X', NAN)), ry = RAW_Y_POSITION(parser.linearval('Y', NAN)); int8_t i = parser.byteval('I', -1), j = parser.byteval('J', -1); + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + if (!isnan(rx) && !isnan(ry)) { // Get nearest i / j from rx / ry - i = (rx - bilinear_start.x + 0.5 * abl.gridSpacing.x) / abl.gridSpacing.x; - j = (ry - bilinear_start.y + 0.5 * abl.gridSpacing.y) / abl.gridSpacing.y; + i = (rx - bedlevel.grid_start.x) / bedlevel.grid_spacing.x + 0.5f; + j = (ry - bedlevel.grid_start.y) / bedlevel.grid_spacing.y + 0.5f; LIMIT(i, 0, (GRID_MAX_POINTS_X) - 1); LIMIT(j, 0, (GRID_MAX_POINTS_Y) - 1); } + + #pragma GCC diagnostic pop + if (WITHIN(i, 0, (GRID_MAX_POINTS_X) - 1) && WITHIN(j, 0, (GRID_MAX_POINTS_Y) - 1)) { set_bed_leveling_enabled(false); - z_values[i][j] = rz; - TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate()); + bedlevel.z_values[i][j] = rz; + bedlevel.refresh_bed_level(); TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(i, j, rz)); - set_bed_leveling_enabled(abl.reenable); - if (abl.reenable) report_current_position(); + if (abl.reenable) { + set_bed_leveling_enabled(true); + report_current_position(); + } } - G29_RETURN(false); + G29_RETURN(false, false); } // parser.seen_test('W') #else @@ -317,13 +347,13 @@ G29_TYPE GcodeSuite::G29() { // Jettison bed leveling data if (!seen_w && parser.seen_test('J')) { reset_bed_level(); - G29_RETURN(false); + G29_RETURN(false, false); } abl.verbose_level = parser.intval('V'); if (!WITHIN(abl.verbose_level, 0, 4)) { SERIAL_ECHOLNPGM("?(V)erbose level implausible (0-4)."); - G29_RETURN(false); + G29_RETURN(false, false); } abl.dryrun = parser.boolval('D') || TERN0(PROBE_MANUALLY, no_action); @@ -344,11 +374,11 @@ G29_TYPE GcodeSuite::G29() { if (!WITHIN(abl.grid_points.x, 2, GRID_MAX_POINTS_X)) { SERIAL_ECHOLNPGM("?Probe points (X) implausible (2-" STRINGIFY(GRID_MAX_POINTS_X) ")."); - G29_RETURN(false); + G29_RETURN(false, false); } if (!WITHIN(abl.grid_points.y, 2, GRID_MAX_POINTS_Y)) { SERIAL_ECHOLNPGM("?Probe points (Y) implausible (2-" STRINGIFY(GRID_MAX_POINTS_Y) ")."); - G29_RETURN(false); + G29_RETURN(false, false); } abl.abl_points = abl.grid_points.x * abl.grid_points.y; @@ -383,7 +413,7 @@ G29_TYPE GcodeSuite::G29() { " F", abl.probe_position_lf.y, " B", abl.probe_position_rb.y); } SERIAL_ECHOLNPGM("? (L,R,F,B) out of bounds."); - G29_RETURN(false); + G29_RETURN(false, false); } // Probe at the points of a lattice grid @@ -404,15 +434,22 @@ G29_TYPE GcodeSuite::G29() { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> 3-point Leveling"); points[0].z = points[1].z = points[2].z = 0; // Probe at 3 arbitrary points #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) - TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart()); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_MeshLevelingStart()); + TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart()); #endif + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart()); + if (!faux) { remember_feedrate_scaling_off(); #if ENABLED(PREHEAT_BEFORE_LEVELING) - if (!abl.dryrun) probe.preheat_for_probing(LEVELING_NOZZLE_TEMP, LEVELING_BED_TEMP); + if (!abl.dryrun) probe.preheat_for_probing(LEVELING_NOZZLE_TEMP, + #if BOTH(DWIN_LCD_PROUI, HAS_HEATED_BED) + HMI_data.BedLevT + #else + LEVELING_BED_TEMP + #endif + ); #endif } @@ -421,29 +458,29 @@ G29_TYPE GcodeSuite::G29() { if (!no_action) set_bed_leveling_enabled(false); // Deploy certain probes before starting probing - #if HAS_BED_PROBE - if (ENABLED(BLTOUCH)) - do_z_clearance(Z_CLEARANCE_DEPLOY_PROBE); - else if (probe.deploy()) { + #if ENABLED(BLTOUCH) + do_z_clearance(Z_CLEARANCE_DEPLOY_PROBE); + #elif HAS_BED_PROBE + if (probe.deploy()) { // (returns true on deploy failure) set_bed_leveling_enabled(abl.reenable); - G29_RETURN(false); + G29_RETURN(false, true); } #endif #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - if (TERN1(PROBE_MANUALLY, !no_action) - && (abl.gridSpacing != bilinear_grid_spacing || abl.probe_position_lf != bilinear_start) + if (!abl.dryrun + && (abl.gridSpacing != bedlevel.grid_spacing || abl.probe_position_lf != bedlevel.grid_start) ) { // Reset grid to 0.0 or "not probed". (Also disables ABL) reset_bed_level(); - // Initialize a grid with the given dimensions - bilinear_grid_spacing = abl.gridSpacing; - bilinear_start = abl.probe_position_lf; - // Can't re-enable (on error) until the new grid is written abl.reenable = false; } + + // Pre-populate local Z values from the stored mesh + TERN_(IS_KINEMATIC, COPY(abl.z_values, bedlevel.z_values)); + #endif // AUTO_BED_LEVELING_BILINEAR } // !g29_in_progress @@ -475,7 +512,8 @@ G29_TYPE GcodeSuite::G29() { SERIAL_ECHOLNPGM("idle"); } - if (no_action) G29_RETURN(false); + // For 'A' or 'Q' exit with success state + if (no_action) G29_RETURN(false, true); if (abl.abl_probe_index == 0) { // For the initial G29 S2 save software endstop state @@ -510,7 +548,7 @@ G29_TYPE GcodeSuite::G29() { #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) const float newz = abl.measured_z + abl.Z_offset; - z_values[abl.meshCount.x][abl.meshCount.y] = newz; + abl.z_values[abl.meshCount.x][abl.meshCount.y] = newz; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(abl.meshCount, newz)); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM_P(PSTR("Save X"), abl.meshCount.x, SP_Y_STR, abl.meshCount.y, SP_Z_STR, abl.measured_z + abl.Z_offset); @@ -550,7 +588,7 @@ G29_TYPE GcodeSuite::G29() { // Disable software endstops to allow manual adjustment // If G29 is not completed, they will not be re-enabled SET_SOFT_ENDSTOP_LOOSE(true); - G29_RETURN(false); + G29_RETURN(false, true); } else { // Leveling done! Fall through to G29 finishing code below @@ -568,7 +606,7 @@ G29_TYPE GcodeSuite::G29() { // Disable software endstops to allow manual adjustment // If G29 is not completed, they will not be re-enabled SET_SOFT_ENDSTOP_LOOSE(true); - G29_RETURN(false); + G29_RETURN(false, true); } else { @@ -600,8 +638,6 @@ G29_TYPE GcodeSuite::G29() { bool zig = PR_OUTER_SIZE & 1; // Always end at RIGHT and BACK_PROBE_BED_POSITION - abl.measured_z = 0; - // Outer loop is X with PROBE_Y_FIRST enabled // Outer loop is Y with PROBE_Y_FIRST disabled for (PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_SIZE && !isnan(abl.measured_z); PR_OUTER_VAR++) { @@ -645,10 +681,6 @@ G29_TYPE GcodeSuite::G29() { break; // Breaks out of both loops } - TERN_(PTC_BED, ptc.compensate_measurement(TSI_BED, thermalManager.degBed(), abl.measured_z)); - TERN_(PTC_PROBE, ptc.compensate_measurement(TSI_PROBE, thermalManager.degProbe(), abl.measured_z)); - TERN_(PTC_HOTEND, ptc.compensate_measurement(TSI_EXT, thermalManager.degHotend(0), abl.measured_z)); - #if ENABLED(AUTO_BED_LEVELING_LINEAR) abl.mean += abl.measured_z; @@ -662,12 +694,12 @@ G29_TYPE GcodeSuite::G29() { #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) const float z = abl.measured_z + abl.Z_offset; - z_values[abl.meshCount.x][abl.meshCount.y] = z PLUS_TERN0(X_AXIS_TWIST_COMPENSATION, xatc.compensation(abl.probePos)); + abl.z_values[abl.meshCount.x][abl.meshCount.y] = z; TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(abl.meshCount, z)); #endif - abl.reenable = false; + abl.reenable = false; // Don't re-enable after modifying the mesh idle_no_sleep(); } // inner @@ -733,12 +765,16 @@ G29_TYPE GcodeSuite::G29() { if (!isnan(abl.measured_z)) { #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - if (!abl.dryrun) extrapolate_unprobed_bed_level(); - print_bilinear_leveling_grid(); - - refresh_bed_level(); + if (abl.dryrun) + bedlevel.print_leveling_grid(&abl.z_values); + else { + bedlevel.set_grid(abl.gridSpacing, abl.probe_position_lf); + COPY(bedlevel.z_values, abl.z_values); + TERN_(IS_KINEMATIC, bedlevel.extrapolate_unprobed_bed_level()); + bedlevel.refresh_bed_level(); - TERN_(ABL_BILINEAR_SUBDIVISION, print_bilinear_leveling_grid_virt()); + bedlevel.print_leveling_grid(); + } #elif ENABLED(AUTO_BED_LEVELING_LINEAR) @@ -848,33 +884,28 @@ G29_TYPE GcodeSuite::G29() { current_position = converted; if (DEBUGGING(LEVELING)) DEBUG_POS("G29 corrected XYZ", current_position); + + abl.reenable = true; } - #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) + // Auto Bed Leveling is complete! Enable if possible. + if (abl.reenable) { + planner.leveling_active = true; + sync_plan_position(); + } - if (!abl.dryrun) { - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("G29 uncorrected Z:", current_position.z); + #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) - // Unapply the offset because it is going to be immediately applied - // and cause compensation movement in Z - const float fade_scaling_factor = TERN(ENABLE_LEVELING_FADE_HEIGHT, planner.fade_scaling_factor_for_z(current_position.z), 1); - current_position.z -= fade_scaling_factor * bilinear_z_offset(current_position); + // Auto Bed Leveling is complete! Enable if possible. + if (!abl.dryrun || abl.reenable) set_bed_leveling_enabled(true); - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM(" corrected Z:", current_position.z); - } - - #endif // ABL_PLANAR + #endif - // Auto Bed Leveling is complete! Enable if possible. - planner.leveling_active = !abl.dryrun || abl.reenable; } // !isnan(abl.measured_z) // Restore state after probing if (!faux) restore_feedrate_and_scaling(); - // Sync the planner from the current_position - if (planner.leveling_active) sync_plan_position(); - TERN_(HAS_BED_PROBE, probe.move_z_after_probing()); #ifdef Z_PROBE_END_SCRIPT @@ -883,14 +914,11 @@ G29_TYPE GcodeSuite::G29() { process_subcommands_now(F(Z_PROBE_END_SCRIPT)); #endif - TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedLeveling()); + TERN_(HAS_MULTI_HOTEND, if (abl.tool_index != 0) tool_change(abl.tool_index)); report_current_position(); - TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); - - G29_RETURN(isnan(abl.measured_z)); - + G29_RETURN(isnan(abl.measured_z), true); } #endif // HAS_ABL_NOT_UBL diff --git a/Marlin/src/gcode/bedlevel/abl/M421.cpp b/Marlin/src/gcode/bedlevel/abl/M421.cpp index 182dc32515b6..3272ea1bd227 100644 --- a/Marlin/src/gcode/bedlevel/abl/M421.cpp +++ b/Marlin/src/gcode/bedlevel/abl/M421.cpp @@ -58,11 +58,11 @@ void GcodeSuite::M421() { sy = iy >= 0 ? iy : 0, ey = iy >= 0 ? iy : GRID_MAX_POINTS_Y - 1; LOOP_S_LE_N(x, sx, ex) { LOOP_S_LE_N(y, sy, ey) { - z_values[x][y] = zval + (hasQ ? z_values[x][y] : 0); - TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y])); + bedlevel.z_values[x][y] = zval + (hasQ ? bedlevel.z_values[x][y] : 0); + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, bedlevel.z_values[x][y])); } } - TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate()); + bedlevel.refresh_bed_level(); } else SERIAL_ERROR_MSG(STR_ERR_MESH_XY); diff --git a/Marlin/src/gcode/bedlevel/mbl/G29.cpp b/Marlin/src/gcode/bedlevel/mbl/G29.cpp index eec89f73acff..10b044b056aa 100644 --- a/Marlin/src/gcode/bedlevel/mbl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/G29.cpp @@ -40,8 +40,8 @@ #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../../../lcd/e3v2/proui/dwin.h" #endif #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) @@ -75,8 +75,6 @@ void GcodeSuite::G29() { } #endif - TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE)); - static int mbl_probe_index = -1; MeshLevelingState state = (MeshLevelingState)parser.byteval('S', (int8_t)MeshReport); @@ -85,6 +83,8 @@ void GcodeSuite::G29() { return; } + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE)); + int8_t ix, iy; ix = iy = 0; @@ -93,18 +93,19 @@ void GcodeSuite::G29() { SERIAL_ECHOPGM("Mesh Bed Leveling "); if (leveling_is_valid()) { serialprintln_onoff(planner.leveling_active); - mbl.report_mesh(); + bedlevel.report_mesh(); } else SERIAL_ECHOLNPGM("has no data."); break; case MeshStart: - mbl.reset(); + bedlevel.reset(); mbl_probe_index = 0; if (!ui.wait_for_move) { queue.inject(parser.seen_test('N') ? F("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : F("G29S2")); - TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart()); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart()); + TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart()); return; } state = MeshNext; @@ -117,16 +118,19 @@ void GcodeSuite::G29() { // For each G29 S2... if (mbl_probe_index == 0) { // Move close to the bed before the first point - do_blocking_move_to_z(0.4f + do_blocking_move_to_z( #ifdef MANUAL_PROBE_START_Z - + (MANUAL_PROBE_START_Z) - 0.4f + MANUAL_PROBE_START_Z + #else + 0.4f #endif ); } else { // Save Z for the previous mesh position - mbl.set_zigzag_z(mbl_probe_index - 1, current_position.z); + bedlevel.set_zigzag_z(mbl_probe_index - 1, current_position.z); TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, current_position.z)); + TERN_(DWIN_LCD_PROUI, DWIN_MeshUpdate(_MIN(mbl_probe_index, GRID_MAX_POINTS), int(GRID_MAX_POINTS), current_position.z)); SET_SOFT_ENDSTOP_LOOSE(false); } // If there's another point to sample, move there with optional lift. @@ -134,8 +138,8 @@ void GcodeSuite::G29() { // Disable software endstops to allow manual adjustment // If G29 is left hanging without completion they won't be re-enabled! SET_SOFT_ENDSTOP_LOOSE(true); - mbl.zigzag(mbl_probe_index++, ix, iy); - _manual_goto_xy({ mbl.index_to_xpos[ix], mbl.index_to_ypos[iy] }); + bedlevel.zigzag(mbl_probe_index++, ix, iy); + _manual_goto_xy({ bedlevel.index_to_xpos[ix], bedlevel.index_to_ypos[iy] }); } else { // Move to the after probing position @@ -153,8 +157,7 @@ void GcodeSuite::G29() { mbl_probe_index = -1; SERIAL_ECHOLNPGM("Mesh probing done."); TERN_(HAS_STATUS_MESSAGE, LCD_MESSAGE(MSG_MESH_DONE)); - BUZZ(100, 659); - BUZZ(100, 698); + OKAY_BUZZ(); home_all_axes(); set_bed_leveling_enabled(true); @@ -166,6 +169,7 @@ void GcodeSuite::G29() { #endif TERN_(LCD_BED_LEVELING, ui.wait_for_move = false); + TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); } break; @@ -191,9 +195,9 @@ void GcodeSuite::G29() { return echo_not_entered('J'); if (parser.seenval('Z')) { - mbl.z_values[ix][iy] = parser.value_linear_units(); - TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, mbl.z_values[ix][iy])); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_MeshUpdate(ix, iy, mbl.z_values[ix][iy])); + bedlevel.z_values[ix][iy] = parser.value_linear_units(); + TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, bedlevel.z_values[ix][iy])); + TERN_(DWIN_LCD_PROUI, DWIN_MeshUpdate(ix, iy, bedlevel.z_values[ix][iy])); } else return echo_not_entered('Z'); @@ -201,7 +205,7 @@ void GcodeSuite::G29() { case MeshSetZOffset: if (parser.seenval('Z')) - mbl.z_offset = parser.value_linear_units(); + bedlevel.z_offset = parser.value_linear_units(); else return echo_not_entered('Z'); break; diff --git a/Marlin/src/gcode/bedlevel/mbl/M421.cpp b/Marlin/src/gcode/bedlevel/mbl/M421.cpp index 1368ab0bef98..e23683d55f34 100644 --- a/Marlin/src/gcode/bedlevel/mbl/M421.cpp +++ b/Marlin/src/gcode/bedlevel/mbl/M421.cpp @@ -43,9 +43,9 @@ */ void GcodeSuite::M421() { const bool hasX = parser.seen('X'), hasI = parser.seen('I'); - const int8_t ix = hasI ? parser.value_int() : hasX ? mbl.probe_index_x(RAW_X_POSITION(parser.value_linear_units())) : -1; + const int8_t ix = hasI ? parser.value_int() : hasX ? bedlevel.probe_index_x(RAW_X_POSITION(parser.value_linear_units())) : -1; const bool hasY = parser.seen('Y'), hasJ = parser.seen('J'); - const int8_t iy = hasJ ? parser.value_int() : hasY ? mbl.probe_index_y(RAW_Y_POSITION(parser.value_linear_units())) : -1; + const int8_t iy = hasJ ? parser.value_int() : hasY ? bedlevel.probe_index_y(RAW_Y_POSITION(parser.value_linear_units())) : -1; const bool hasZ = parser.seen('Z'), hasQ = !hasZ && parser.seen('Q'); if (int(hasI && hasJ) + int(hasX && hasY) != 1 || !(hasZ || hasQ)) @@ -53,7 +53,7 @@ void GcodeSuite::M421() { else if (ix < 0 || iy < 0) SERIAL_ERROR_MSG(STR_ERR_MESH_XY); else - mbl.set_z(ix, iy, parser.value_linear_units() + (hasQ ? mbl.z_values[ix][iy] : 0)); + bedlevel.set_z(ix, iy, parser.value_linear_units() + (hasQ ? bedlevel.z_values[ix][iy] : 0)); } #endif // MESH_BED_LEVELING diff --git a/Marlin/src/gcode/bedlevel/ubl/G29.cpp b/Marlin/src/gcode/bedlevel/ubl/G29.cpp index 932503d72b97..90deab3d2e3e 100644 --- a/Marlin/src/gcode/bedlevel/ubl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/ubl/G29.cpp @@ -39,7 +39,7 @@ void GcodeSuite::G29() { TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_PROBE)); - ubl.G29(); + bedlevel.G29(); TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); } diff --git a/Marlin/src/gcode/bedlevel/ubl/M421.cpp b/Marlin/src/gcode/bedlevel/ubl/M421.cpp index e6f0ef1f8907..ff74f4c6f744 100644 --- a/Marlin/src/gcode/bedlevel/ubl/M421.cpp +++ b/Marlin/src/gcode/bedlevel/ubl/M421.cpp @@ -33,8 +33,8 @@ #if ENABLED(EXTENSIBLE_UI) #include "../../../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../../../lcd/e3v2/proui/dwin.h" #endif /** @@ -56,7 +56,7 @@ void GcodeSuite::M421() { hasZ = parser.seen('Z'), hasQ = !hasZ && parser.seen('Q'); - if (hasC) ij = ubl.find_closest_mesh_point_of_type(CLOSEST, current_position); + if (hasC) ij = bedlevel.find_closest_mesh_point_of_type(CLOSEST, current_position); // Test for bad parameter combinations if (int(hasC) + int(hasI && hasJ) != 1 || !(hasZ || hasQ || hasN)) @@ -66,10 +66,10 @@ void GcodeSuite::M421() { else if (!WITHIN(ij.x, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(ij.y, 0, GRID_MAX_POINTS_Y - 1)) SERIAL_ERROR_MSG(STR_ERR_MESH_XY); else { - float &zval = ubl.z_values[ij.x][ij.y]; // Altering this Mesh Point + float &zval = bedlevel.z_values[ij.x][ij.y]; // Altering this Mesh Point zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0); // N=NAN, Z=NEWVAL, or Q=ADDVAL TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval)); // Ping ExtUI in case it's showing the mesh - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_MeshUpdate(ij.x, ij.y, zval)); + TERN_(DWIN_LCD_PROUI, DWIN_MeshUpdate(ij.x, ij.y, zval)); } } diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 8743c0d8951c..b2096ace7e51 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -51,8 +51,8 @@ #include "../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD) #include "../../lcd/e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin.h" #endif #if HAS_L64XX // set L6470 absolute position registers to counts @@ -76,40 +76,33 @@ const int x_axis_home_dir = TOOL_X_HOME_DIR(active_extruder); - const float mlx = max_length(X_AXIS), - mly = max_length(Y_AXIS), - mlratio = mlx > mly ? mly / mlx : mlx / mly, - fr_mm_s = _MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)) * SQRT(sq(mlratio) + 1.0); + // Use a higher diagonal feedrate so axes move at homing speed + const float minfr = _MIN(homing_feedrate(X_AXIS), homing_feedrate(Y_AXIS)), + fr_mm_s = HYPOT(minfr, minfr); #if ENABLED(SENSORLESS_HOMING) sensorless_t stealth_states { - LINEAR_AXIS_LIST(tmc_enable_stallguard(stepperX), tmc_enable_stallguard(stepperY), false, false, false, false) - , false - #if AXIS_HAS_STALLGUARD(X2) - || tmc_enable_stallguard(stepperX2) - #endif - , false - #if AXIS_HAS_STALLGUARD(Y2) - || tmc_enable_stallguard(stepperY2) - #endif + LINEAR_AXIS_LIST( + TERN0(X_SENSORLESS, tmc_enable_stallguard(stepperX)), + TERN0(Y_SENSORLESS, tmc_enable_stallguard(stepperY)), + false, false, false, false + ) + , TERN0(X2_SENSORLESS, tmc_enable_stallguard(stepperX2)) + , TERN0(Y2_SENSORLESS, tmc_enable_stallguard(stepperY2)) }; #endif - do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * Y_HOME_DIR, fr_mm_s); + do_blocking_move_to_xy(1.5 * max_length(X_AXIS) * x_axis_home_dir, 1.5 * max_length(Y_AXIS) * Y_HOME_DIR, fr_mm_s); endstops.validate_homing_move(); current_position.set(0.0, 0.0); #if ENABLED(SENSORLESS_HOMING) && DISABLED(ENDSTOPS_ALWAYS_ON_DEFAULT) - tmc_disable_stallguard(stepperX, stealth_states.x); - tmc_disable_stallguard(stepperY, stealth_states.y); - #if AXIS_HAS_STALLGUARD(X2) - tmc_disable_stallguard(stepperX2, stealth_states.x2); - #endif - #if AXIS_HAS_STALLGUARD(Y2) - tmc_disable_stallguard(stepperY2, stealth_states.y2); - #endif + TERN_(X_SENSORLESS, tmc_disable_stallguard(stepperX, stealth_states.x)); + TERN_(X2_SENSORLESS, tmc_disable_stallguard(stepperX2, stealth_states.x2)); + TERN_(Y_SENSORLESS, tmc_disable_stallguard(stepperY, stealth_states.y)); + TERN_(Y2_SENSORLESS, tmc_disable_stallguard(stepperY2, stealth_states.y2)); #endif } @@ -214,8 +207,6 @@ void GcodeSuite::G28() { TERN_(LASER_MOVE_G28_OFF, cutter.set_inline_enabled(false)); // turn off laser - TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_HOMING)); - #if ENABLED(DUAL_X_CARRIAGE) bool IDEX_saved_duplication_state = extruder_duplication_enabled; DualXMode IDEX_saved_mode = dual_x_carriage_mode; @@ -237,7 +228,12 @@ void GcodeSuite::G28() { return; } - TERN_(HAS_DWIN_E3V2_BASIC, DWIN_StartHoming()); + #if ENABLED(FULL_REPORT_TO_HOST_FEATURE) + const M_StateEnum old_grblstate = M_State_grbl; + set_and_report_grblstate(M_HOMING); + #endif + + TERN_(HAS_DWIN_E3V2_BASIC, DWIN_HomingStart()); TERN_(EXTENSIBLE_UI, ExtUI::onHomingStart()); planner.synchronize(); // Wait for planner moves to finish! @@ -262,7 +258,7 @@ void GcodeSuite::G28() { reset_stepper_timeout(); #define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT) - #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2) || HAS_CURRENT_HOME(I) || HAS_CURRENT_HOME(J) || HAS_CURRENT_HOME(K) || (ENABLED(DELTA) && HAS_CURRENT_HOME(Z)) + #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2) || (ENABLED(DELTA) && HAS_CURRENT_HOME(Z)) || HAS_CURRENT_HOME(I) || HAS_CURRENT_HOME(J) || HAS_CURRENT_HOME(K) #define HAS_HOMING_CURRENT 1 #endif @@ -273,42 +269,60 @@ void GcodeSuite::G28() { #if HAS_CURRENT_HOME(X) const int16_t tmc_save_current_X = stepperX.getMilliamps(); stepperX.rms_current(X_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F("X"), tmc_save_current_X, X_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_X), tmc_save_current_X, X_CURRENT_HOME); #endif #if HAS_CURRENT_HOME(X2) const int16_t tmc_save_current_X2 = stepperX2.getMilliamps(); stepperX2.rms_current(X2_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F("X2"), tmc_save_current_X2, X2_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_X2), tmc_save_current_X2, X2_CURRENT_HOME); #endif #if HAS_CURRENT_HOME(Y) const int16_t tmc_save_current_Y = stepperY.getMilliamps(); stepperY.rms_current(Y_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F("Y"), tmc_save_current_Y, Y_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_Y), tmc_save_current_Y, Y_CURRENT_HOME); #endif #if HAS_CURRENT_HOME(Y2) const int16_t tmc_save_current_Y2 = stepperY2.getMilliamps(); stepperY2.rms_current(Y2_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F("Y2"), tmc_save_current_Y2, Y2_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_Y2), tmc_save_current_Y2, Y2_CURRENT_HOME); #endif #if HAS_CURRENT_HOME(I) const int16_t tmc_save_current_I = stepperI.getMilliamps(); stepperI.rms_current(I_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F(AXIS4_STR), tmc_save_current_I, I_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_I), tmc_save_current_I, I_CURRENT_HOME); #endif #if HAS_CURRENT_HOME(J) const int16_t tmc_save_current_J = stepperJ.getMilliamps(); stepperJ.rms_current(J_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F(AXIS5_STR), tmc_save_current_J, J_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_J), tmc_save_current_J, J_CURRENT_HOME); #endif #if HAS_CURRENT_HOME(K) const int16_t tmc_save_current_K = stepperK.getMilliamps(); stepperK.rms_current(K_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F(AXIS6_STR), tmc_save_current_K, K_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_K), tmc_save_current_K, K_CURRENT_HOME); #endif #if HAS_CURRENT_HOME(Z) && ENABLED(DELTA) const int16_t tmc_save_current_Z = stepperZ.getMilliamps(); stepperZ.rms_current(Z_CURRENT_HOME); - if (DEBUGGING(LEVELING)) debug_current(F("Z"), tmc_save_current_Z, Z_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_Z), tmc_save_current_Z, Z_CURRENT_HOME); + #endif + #if HAS_CURRENT_HOME(I) + const int16_t tmc_save_current_I = stepperI.getMilliamps(); + stepperI.rms_current(I_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_I), tmc_save_current_I, I_CURRENT_HOME); + #endif + #if HAS_CURRENT_HOME(J) + const int16_t tmc_save_current_J = stepperJ.getMilliamps(); + stepperJ.rms_current(J_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_J), tmc_save_current_J, J_CURRENT_HOME); + #endif + #if HAS_CURRENT_HOME(K) + const int16_t tmc_save_current_K = stepperK.getMilliamps(); + stepperK.rms_current(K_CURRENT_HOME); + if (DEBUGGING(LEVELING)) debug_current(F(STR_K), tmc_save_current_K, K_CURRENT_HOME); + #endif + #if SENSORLESS_STALLGUARD_DELAY + safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle #endif #endif @@ -361,7 +375,7 @@ void GcodeSuite::G28() { homeX = needX || parser.seen_test('X'), homeY = needY || parser.seen_test('Y'), homeZZ = homeZ, - homeI = needI || parser.seen_test(AXIS4_NAME), homeJ = needJ || parser.seen_test(AXIS5_NAME), homeK = needK || parser.seen_test(AXIS6_NAME), + homeI = needI || parser.seen_test(AXIS4_NAME), homeJ = needJ || parser.seen_test(AXIS5_NAME), homeK = needK || parser.seen_test(AXIS6_NAME) ), home_all = LINEAR_AXIS_GANG( // Home-all if all or none are flagged homeX == homeX, && homeY == homeX, && homeZ == homeX, @@ -380,9 +394,10 @@ void GcodeSuite::G28() { TERN_(HOME_Z_FIRST, if (doZ) homeaxis(Z_AXIS)); - const float z_homing_height = parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT; + const bool seenR = parser.seenval('R'); + const float z_homing_height = seenR ? parser.value_linear_units() : Z_HOMING_HEIGHT; - if (z_homing_height && (LINEAR_AXIS_GANG(doX, || doY, || TERN0(Z_SAFE_HOMING, doZ), || doI, || doJ, || doK))) { + if (z_homing_height && (seenR || LINEAR_AXIS_GANG(doX, || doY, || TERN0(Z_SAFE_HOMING, doZ), || doI, || doJ, || doK))) { // 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); do_z_clearance(z_homing_height); @@ -436,20 +451,18 @@ void GcodeSuite::G28() { stepper.set_separate_multi_axis(false); #endif - TERN(Z_SAFE_HOMING, home_z_safely(), homeaxis(Z_AXIS)); + #if ENABLED(Z_SAFE_HOMING) + if (TERN1(POWER_LOSS_RECOVERY, !parser.seen_test('H'))) home_z_safely(); else homeaxis(Z_AXIS); + #else + homeaxis(Z_AXIS); + #endif probe.move_z_after_homing(); } #endif - #if LINEAR_AXES >= 4 - if (doI) homeaxis(I_AXIS); - #endif - #if LINEAR_AXES >= 5 - if (doJ) homeaxis(J_AXIS); - #endif - #if LINEAR_AXES >= 6 - if (doK) homeaxis(K_AXIS); - #endif + TERN_(HAS_I_AXIS, if (doI) homeaxis(I_AXIS)); + TERN_(HAS_J_AXIS, if (doJ) homeaxis(J_AXIS)); + TERN_(HAS_K_AXIS, if (doK) homeaxis(K_AXIS)); sync_plan_position(); @@ -532,19 +545,22 @@ void GcodeSuite::G28() { #if HAS_CURRENT_HOME(K) stepperK.rms_current(tmc_save_current_K); #endif + #if SENSORLESS_STALLGUARD_DELAY + safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle + #endif #endif // HAS_HOMING_CURRENT ui.refresh(); - TERN_(HAS_DWIN_E3V2_BASIC, DWIN_CompletedHoming()); - TERN_(EXTENSIBLE_UI, ExtUI::onHomingComplete()); + TERN_(HAS_DWIN_E3V2_BASIC, DWIN_HomingDone()); + TERN_(EXTENSIBLE_UI, ExtUI::onHomingDone()); report_current_position(); if (ENABLED(NANODLP_Z_SYNC) && (doZ || ENABLED(NANODLP_ALL_AXIS))) SERIAL_ECHOLNPGM(STR_Z_MOVE_COMP); - TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); + TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(old_grblstate)); #if HAS_L64XX // Set L6470 absolute position registers to counts diff --git a/Marlin/src/gcode/calibrate/G33.cpp b/Marlin/src/gcode/calibrate/G33.cpp index a4b9aec01b67..05da2f94571d 100644 --- a/Marlin/src/gcode/calibrate/G33.cpp +++ b/Marlin/src/gcode/calibrate/G33.cpp @@ -71,9 +71,9 @@ float lcd_probe_pt(const xy_pos_t &xy); void ac_home() { endstops.enable(true); - TERN_(HAS_DELTA_SENSORLESS_PROBING, probe.set_homing_current(true)); + TERN_(SENSORLESS_HOMING, endstops.set_homing_current(true)); home_delta(); - TERN_(HAS_DELTA_SENSORLESS_PROBING, probe.set_homing_current(false)); + TERN_(SENSORLESS_HOMING, endstops.set_homing_current(false)); endstops.not_homing(); } @@ -98,8 +98,7 @@ void ac_cleanup(TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index)) { void print_signed_float(FSTR_P const prefix, const_float_t f) { SERIAL_ECHOPGM(" "); SERIAL_ECHOF(prefix, AS_CHAR(':')); - if (f >= 0) SERIAL_CHAR('+'); - SERIAL_ECHO_F(f, 2); + serial_offset(f); } /** @@ -391,6 +390,8 @@ static float auto_tune_a(const float dcr) { * X Don't activate stallguard on X. * Y Don't activate stallguard on Y. * Z Don't activate stallguard on Z. + * + * S Save offset_sensorless_adj */ void GcodeSuite::G33() { @@ -412,7 +413,8 @@ void GcodeSuite::G33() { dcr -= probe_at_offset ? _MAX(total_offset, PROBING_MARGIN) : total_offset; #endif NOMORE(dcr, DELTA_PRINTABLE_RADIUS); - if (parser.seenval('R')) dcr -= _MAX(parser.value_float(),0); + if (parser.seenval('R')) dcr -= _MAX(parser.value_float(), 0.0f); + TERN_(HAS_DELTA_SENSORLESS_PROBING, dcr *= sensorless_radius_factor); const float calibration_precision = parser.floatval('C', 0.0f); if (calibration_precision < 0) { @@ -435,9 +437,8 @@ void GcodeSuite::G33() { const bool stow_after_each = parser.seen_test('E'); #if HAS_DELTA_SENSORLESS_PROBING - probe.test_sensitivity.x = !parser.seen_test('X'); - TERN_(HAS_Y_AXIS, probe.test_sensitivity.y = !parser.seen_test('Y')); - TERN_(HAS_Z_AXIS, probe.test_sensitivity.z = !parser.seen_test('Z')); + probe.test_sensitivity.set(!parser.seen_test('X'), !parser.seen_test('Y'), !parser.seen_test('Z')); + const bool do_save_offset_adj = parser.seen_test('S'); #endif const bool _0p_calibration = probe_points == 0, @@ -476,6 +477,25 @@ void GcodeSuite::G33() { if (!_0p_calibration) ac_home(); + #if HAS_DELTA_SENSORLESS_PROBING + if (verbose_level > 0 && do_save_offset_adj) { + offset_sensorless_adj.reset(); + + auto caltower = [&](Probe::sense_bool_t s){ + float z_at_pt[NPP + 1]; + LOOP_CAL_ALL(rad) z_at_pt[rad] = 0.0f; + probe.test_sensitivity = s; + if (probe_calibration_points(z_at_pt, 1, dcr, false, false, probe_at_offset)) + probe.set_offset_sensorless_adj(z_at_pt[CEN]); + }; + caltower({ true, false, false }); // A + caltower({ false, true, false }); // B + caltower({ false, false, true }); // C + + probe.test_sensitivity = { true, true, true }; // reset to all + } + #endif + do { // start iterations float z_at_pt[NPP + 1] = { 0.0f }; @@ -599,8 +619,17 @@ void GcodeSuite::G33() { // print report - if (verbose_level == 3 || verbose_level == 0) + if (verbose_level == 3 || verbose_level == 0) { print_calibration_results(z_at_pt, _tower_results, _opposite_results); + #if HAS_DELTA_SENSORLESS_PROBING + if (verbose_level == 0 && probe_points == 1) { + if (do_save_offset_adj) + probe.set_offset_sensorless_adj(z_at_pt[CEN]); + else + probe.refresh_largest_sensorless_adj(); + } + #endif + } if (verbose_level != 0) { // !dry run if ((zero_std_dev >= test_precision && iterations > force_iterations) || zero_std_dev <= calibration_precision) { // end iterations @@ -661,6 +690,9 @@ void GcodeSuite::G33() { ac_cleanup(TERN_(HAS_MULTI_HOTEND, old_tool_index)); TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE)); + #if HAS_DELTA_SENSORLESS_PROBING + probe.test_sensitivity = { true, true, true }; + #endif } #endif // DELTA_AUTO_CALIBRATION diff --git a/Marlin/src/gcode/calibrate/G34.cpp b/Marlin/src/gcode/calibrate/G34.cpp index 98a0bdef8898..84b910212344 100644 --- a/Marlin/src/gcode/calibrate/G34.cpp +++ b/Marlin/src/gcode/calibrate/G34.cpp @@ -91,7 +91,7 @@ void GcodeSuite::G34() { digipot_i2c.set_current(Z_AXIS, target_current) #elif HAS_TRINAMIC_CONFIG const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT); - static uint16_t previous_current_arr[NUM_Z_STEPPER_DRIVERS]; + static uint16_t previous_current_arr[NUM_Z_STEPPERS]; #if AXIS_IS_TMC(Z) previous_current_arr[0] = stepperZ.getMilliamps(); stepperZ.rms_current(target_current); @@ -114,10 +114,6 @@ void GcodeSuite::G34() { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Final Z Move"); do_blocking_move_to_z(zgrind, MMM_TO_MMS(GANTRY_CALIBRATION_FEEDRATE)); - // Back off end plate, back to normal motion range - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Backoff"); - do_blocking_move_to_z(zpounce, MMM_TO_MMS(GANTRY_CALIBRATION_FEEDRATE)); - #if _REDUCE_CURRENT // Reset current to original values if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Restore Current"); @@ -146,6 +142,10 @@ void GcodeSuite::G34() { #endif #endif + // Back off end plate, back to normal motion range + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Backoff"); + do_blocking_move_to_z(zpounce, MMM_TO_MMS(GANTRY_CALIBRATION_FEEDRATE)); + #ifdef GANTRY_CALIBRATION_COMMANDS_POST if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Running Post Commands"); process_subcommands_now(F(GANTRY_CALIBRATION_COMMANDS_POST)); diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 328a40dbb46a..d68207885d39 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -41,7 +41,7 @@ #include "../../module/tool_change.h" #endif -#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) +#if HAS_Z_STEPPER_ALIGN_STEPPER_XY #include "../../libs/least_squares_fit.h" #endif @@ -52,9 +52,9 @@ #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #include "../../core/debug_out.h" -#if NUM_Z_STEPPER_DRIVERS >= 3 +#if NUM_Z_STEPPERS >= 3 #define TRIPLE_Z 1 - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 #define QUAD_Z 1 #endif #endif @@ -122,7 +122,7 @@ void GcodeSuite::G34() { break; } - const float z_auto_align_amplification = TERN(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, Z_STEPPER_ALIGN_AMP, parser.floatval('A', Z_STEPPER_ALIGN_AMP)); + const float z_auto_align_amplification = TERN(HAS_Z_STEPPER_ALIGN_STEPPER_XY, Z_STEPPER_ALIGN_AMP, parser.floatval('A', Z_STEPPER_ALIGN_AMP)); if (!WITHIN(ABS(z_auto_align_amplification), 0.5f, 2.0f)) { SERIAL_ECHOLNPGM("?(A)mplification out of bounds (0.5-2.0)."); break; @@ -179,16 +179,16 @@ void GcodeSuite::G34() { // Now, the Z origin lies below the build plate. That allows to probe deeper, before run_z_probe throws an error. // This hack is un-done at the end of G34 - either by re-homing, or by using the probed heights of the last iteration. - #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - float last_z_align_move[NUM_Z_STEPPER_DRIVERS] = ARRAY_N_1(NUM_Z_STEPPER_DRIVERS, 10000.0f); + #if !HAS_Z_STEPPER_ALIGN_STEPPER_XY + float last_z_align_move[NUM_Z_STEPPERS] = ARRAY_N_1(NUM_Z_STEPPERS, 10000.0f); #else float last_z_align_level_indicator = 10000.0f; #endif - float z_measured[NUM_Z_STEPPER_DRIVERS] = { 0 }, + float z_measured[NUM_Z_STEPPERS] = { 0 }, z_maxdiff = 0.0f, amplification = z_auto_align_amplification; - #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if !HAS_Z_STEPPER_ALIGN_STEPPER_XY bool adjustment_reverse = false; #endif @@ -217,9 +217,9 @@ void GcodeSuite::G34() { float z_measured_max = -100000.0f; // Probe all positions (one per Z-Stepper) - LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) { + LOOP_L_N(i, NUM_Z_STEPPERS) { // iteration odd/even --> downward / upward stepper sequence - const uint8_t iprobe = (iteration & 1) ? NUM_Z_STEPPER_DRIVERS - 1 - i : i; + const uint8_t iprobe = (iteration & 1) ? NUM_Z_STEPPERS - 1 - i : i; // Safe clearance even on an incline if ((iteration == 0 || i > 0) && z_probe > current_position.z) do_blocking_move_to_z(z_probe); @@ -256,7 +256,7 @@ void GcodeSuite::G34() { z_maxdiff = z_measured_max - z_measured_min; z_probe = Z_BASIC_CLEARANCE + z_measured_max + z_maxdiff; - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY // Replace the initial values in z_measured with calculated heights at // each stepper position. This allows the adjustment algorithm to be // shared between both possible probing mechanisms. @@ -270,20 +270,20 @@ void GcodeSuite::G34() { // This allows the actual adjustment logic to be shared by both algorithms. linear_fit_data lfd; incremental_LSF_reset(&lfd); - LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) { + LOOP_L_N(i, NUM_Z_STEPPERS) { SERIAL_ECHOLNPGM("PROBEPT_", i, ": ", z_measured[i]); incremental_LSF(&lfd, z_stepper_align.xy[i], z_measured[i]); } finish_incremental_LSF(&lfd); z_measured_min = 100000.0f; - LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) { + LOOP_L_N(i, NUM_Z_STEPPERS) { z_measured[i] = -(lfd.A * z_stepper_align.stepper_xy[i].x + lfd.B * z_stepper_align.stepper_xy[i].y + lfd.D); z_measured_min = _MIN(z_measured_min, z_measured[i]); } SERIAL_ECHOLNPGM( - LIST_N(DOUBLE(NUM_Z_STEPPER_DRIVERS), + LIST_N(DOUBLE(NUM_Z_STEPPERS), "Calculated Z1=", z_measured[0], " Z2=", z_measured[1], " Z3=", z_measured[2], @@ -307,7 +307,7 @@ void GcodeSuite::G34() { #if HAS_STATUS_MESSAGE char fstr1[10]; - char msg[6 + (6 + 5) * NUM_Z_STEPPER_DRIVERS + 1] + char msg[6 + (6 + 5) * NUM_Z_STEPPERS + 1] #if TRIPLE_Z , fstr2[10], fstr3[10] #if QUAD_Z @@ -338,19 +338,19 @@ void GcodeSuite::G34() { return false; }; - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY // Check if the applied corrections go in the correct direction. // Calculate the sum of the absolute deviations from the mean of the probe measurements. // Compare to the last iteration to ensure it's getting better. // Calculate mean value as a reference float z_measured_mean = 0.0f; - LOOP_L_N(zstepper, NUM_Z_STEPPER_DRIVERS) z_measured_mean += z_measured[zstepper]; - z_measured_mean /= NUM_Z_STEPPER_DRIVERS; + LOOP_L_N(zstepper, NUM_Z_STEPPERS) z_measured_mean += z_measured[zstepper]; + z_measured_mean /= NUM_Z_STEPPERS; // Calculate the sum of the absolute deviations from the mean value float z_align_level_indicator = 0.0f; - LOOP_L_N(zstepper, NUM_Z_STEPPER_DRIVERS) + LOOP_L_N(zstepper, NUM_Z_STEPPERS) z_align_level_indicator += ABS(z_measured[zstepper] - z_measured_mean); // If it's getting worse, stop and throw an error @@ -365,12 +365,12 @@ void GcodeSuite::G34() { bool success_break = true; // Correct the individual stepper offsets - LOOP_L_N(zstepper, NUM_Z_STEPPER_DRIVERS) { + LOOP_L_N(zstepper, NUM_Z_STEPPERS) { // Calculate current stepper move float z_align_move = z_measured[zstepper] - z_measured_min; const float z_align_abs = ABS(z_align_move); - #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if !HAS_Z_STEPPER_ALIGN_STEPPER_XY // Optimize one iteration's correction based on the first measurements if (z_align_abs) amplification = (iteration == 1) ? _MIN(last_z_align_move[zstepper] / z_align_abs, 2.0f) : z_auto_align_amplification; @@ -394,7 +394,7 @@ void GcodeSuite::G34() { // Lock all steppers except one stepper.set_all_z_lock(true, zstepper); - #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if !HAS_Z_STEPPER_ALIGN_STEPPER_XY // Decreasing accuracy was detected so move was inverted. // Will match reversed Z steppers on dual steppers. Triple will need more work to map. if (adjustment_reverse) { @@ -467,7 +467,7 @@ void GcodeSuite::G34() { * * S : Index of the probe point to set * - * With Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS: + * With Z_STEPPER_ALIGN_STEPPER_XY: * W : Index of the Z stepper position to set * The W and S parameters may not be combined. * @@ -486,42 +486,43 @@ void GcodeSuite::M422() { return; } - const bool is_probe_point = parser.seen('S'); + const bool is_probe_point = parser.seen_test('S'); - if (TERN0(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, is_probe_point && parser.seen('W'))) { + if (TERN0(HAS_Z_STEPPER_ALIGN_STEPPER_XY, is_probe_point && parser.seen_test('W'))) { SERIAL_ECHOLNPGM("?(S) and (W) may not be combined."); return; } - xy_pos_t *pos_dest = ( - TERN_(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, !is_probe_point ? z_stepper_align.stepper_xy :) + xy_pos_t * const pos_dest = ( + TERN_(HAS_Z_STEPPER_ALIGN_STEPPER_XY, !is_probe_point ? z_stepper_align.stepper_xy :) z_stepper_align.xy ); - if (!is_probe_point && TERN1(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, !parser.seen('W'))) { - SERIAL_ECHOLNPGM("?(S)" TERN_(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, " or (W)") " is required."); + if (!is_probe_point && TERN1(HAS_Z_STEPPER_ALIGN_STEPPER_XY, !parser.seen_test('W'))) { + SERIAL_ECHOLNPGM("?(S)" TERN_(HAS_Z_STEPPER_ALIGN_STEPPER_XY, " or (W)") " is required."); return; } // Get the Probe Position Index or Z Stepper Index - int8_t position_index; - if (is_probe_point) { - position_index = parser.intval('S') - 1; - if (!WITHIN(position_index, 0, int8_t(NUM_Z_STEPPER_DRIVERS) - 1)) { - SERIAL_ECHOLNPGM("?(S) Probe-position index invalid."); - return; - } - } + int8_t position_index = 1; + FSTR_P err_string = F("?(S) Probe-position"); + if (is_probe_point) + position_index = parser.intval('S'); else { - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - position_index = parser.intval('W') - 1; - if (!WITHIN(position_index, 0, NUM_Z_STEPPER_DRIVERS - 1)) { - SERIAL_ECHOLNPGM("?(W) Z-stepper index invalid."); - return; - } + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY + err_string = F("?(W) Z-stepper"); + position_index = parser.intval('W'); #endif } + if (!WITHIN(position_index, 1, NUM_Z_STEPPERS)) { + SERIAL_ECHOF(err_string); + SERIAL_ECHOLNPGM(" index invalid (1.." STRINGIFY(NUM_Z_STEPPERS) ")."); + return; + } + + --position_index; + const xy_pos_t pos = { parser.floatval('X', pos_dest[position_index].x), parser.floatval('Y', pos_dest[position_index].y) @@ -543,7 +544,7 @@ void GcodeSuite::M422() { void GcodeSuite::M422_report(const bool forReplay/*=true*/) { report_heading(forReplay, F(STR_Z_AUTO_ALIGN)); - LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) { + LOOP_L_N(i, NUM_Z_STEPPERS) { report_echo_start(forReplay); SERIAL_ECHOLNPGM_P( PSTR(" M422 S"), i + 1, @@ -551,8 +552,8 @@ void GcodeSuite::M422_report(const bool forReplay/*=true*/) { SP_Y_STR, z_stepper_align.xy[i].y ); } - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) { + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY + LOOP_L_N(i, NUM_Z_STEPPERS) { report_echo_start(forReplay); SERIAL_ECHOLNPGM_P( PSTR(" M422 W"), i + 1, diff --git a/Marlin/src/gcode/calibrate/G425.cpp b/Marlin/src/gcode/calibrate/G425.cpp index 88c906f4937a..a2dec64bc3a8 100644 --- a/Marlin/src/gcode/calibrate/G425.cpp +++ b/Marlin/src/gcode/calibrate/G425.cpp @@ -73,16 +73,16 @@ #if BOTH(CALIBRATION_MEASURE_LEFT, CALIBRATION_MEASURE_RIGHT) #define HAS_X_CENTER 1 #endif -#if HAS_Y_AXIS && BOTH(CALIBRATION_MEASURE_FRONT, CALIBRATION_MEASURE_BACK) +#if ALL(HAS_Y_AXIS, CALIBRATION_MEASURE_FRONT, CALIBRATION_MEASURE_BACK) #define HAS_Y_CENTER 1 #endif -#if LINEAR_AXES >= 4 && BOTH(CALIBRATION_MEASURE_IMIN, CALIBRATION_MEASURE_IMAX) +#if ALL(HAS_I_AXIS, CALIBRATION_MEASURE_IMIN, CALIBRATION_MEASURE_IMAX) #define HAS_I_CENTER 1 #endif -#if LINEAR_AXES >= 5 && BOTH(CALIBRATION_MEASURE_JMIN, CALIBRATION_MEASURE_JMAX) +#if ALL(HAS_J_AXIS, CALIBRATION_MEASURE_JMIN, CALIBRATION_MEASURE_JMAX) #define HAS_J_CENTER 1 #endif -#if LINEAR_AXES >= 6 && BOTH(CALIBRATION_MEASURE_KMIN, CALIBRATION_MEASURE_KMAX) +#if ALL(HAS_K_AXIS, CALIBRATION_MEASURE_KMIN, CALIBRATION_MEASURE_KMAX) #define HAS_K_CENTER 1 #endif @@ -105,13 +105,27 @@ struct measurements_t { }; #if ENABLED(BACKLASH_GCODE) - #define TEMPORARY_BACKLASH_CORRECTION(value) REMEMBER(tbst, backlash.correction, value) + class restorer_correction { + const uint8_t val_; + public: + restorer_correction(const uint8_t temp_val) : val_(backlash.get_correction_uint8()) { backlash.set_correction_uint8(temp_val); } + ~restorer_correction() { backlash.set_correction_uint8(val_); } + }; + + #define TEMPORARY_BACKLASH_CORRECTION(value) restorer_correction restorer_tbst(value) #else #define TEMPORARY_BACKLASH_CORRECTION(value) #endif #if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM) - #define TEMPORARY_BACKLASH_SMOOTHING(value) REMEMBER(tbsm, backlash.smoothing_mm, value) + class restorer_smoothing { + const float val_; + public: + restorer_smoothing(const float temp_val) : val_(backlash.get_smoothing_mm()) { backlash.set_smoothing_mm(temp_val); } + ~restorer_smoothing() { backlash.set_smoothing_mm(val_); } + }; + + #define TEMPORARY_BACKLASH_SMOOTHING(value) restorer_smoothing restorer_tbsm(value) #else #define TEMPORARY_BACKLASH_SMOOTHING(value) #endif @@ -241,14 +255,15 @@ inline void probe_side(measurements_t &m, const float uncertainty, const side_t park_above_object(m, uncertainty); + #define _ACASE(N,A,B) case A: dir = -1; case B: axis = N##_AXIS; break + #define _PCASE(N) _ACASE(N, N##MINIMUM, N##MAXIMUM) + switch (side) { #if AXIS_CAN_CALIBRATE(X) - case RIGHT: dir = -1; - case LEFT: axis = X_AXIS; break; + _ACASE(X, RIGHT, LEFT); #endif - #if LINEAR_AXES >= 2 && AXIS_CAN_CALIBRATE(Y) - case BACK: dir = -1; - case FRONT: axis = Y_AXIS; break; + #if HAS_Y_AXIS && AXIS_CAN_CALIBRATE(Y) + _ACASE(Y, BACK, FRONT); #endif #if HAS_Z_AXIS && AXIS_CAN_CALIBRATE(Z) case TOP: { @@ -258,17 +273,14 @@ inline void probe_side(measurements_t &m, const float uncertainty, const side_t return; } #endif - #if LINEAR_AXES >= 4 && AXIS_CAN_CALIBRATE(I) - case IMINIMUM: dir = -1; - case IMAXIMUM: axis = I_AXIS; break; + #if HAS_I_AXIS && AXIS_CAN_CALIBRATE(I) + _PCASE(I); #endif - #if LINEAR_AXES >= 5 && AXIS_CAN_CALIBRATE(J) - case JMINIMUM: dir = -1; - case JMAXIMUM: axis = J_AXIS; break; + #if HAS_J_AXIS && AXIS_CAN_CALIBRATE(J) + _PCASE(J); #endif - #if LINEAR_AXES >= 6 && AXIS_CAN_CALIBRATE(K) - case KMINIMUM: dir = -1; - case KMAXIMUM: axis = K_AXIS; break; + #if HAS_K_AXIS && AXIS_CAN_CALIBRATE(K) + _PCASE(K); #endif default: return; } @@ -370,7 +382,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { SERIAL_ECHOLNPGM(" Back: ", m.obj_side[BACK]); #endif #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS #if ENABLED(CALIBRATION_MEASURE_IMIN) SERIAL_ECHOLNPGM(" " STR_I_MIN ": ", m.obj_side[IMINIMUM]); #endif @@ -378,7 +390,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { SERIAL_ECHOLNPGM(" " STR_I_MAX ": ", m.obj_side[IMAXIMUM]); #endif #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS #if ENABLED(CALIBRATION_MEASURE_JMIN) SERIAL_ECHOLNPGM(" " STR_J_MIN ": ", m.obj_side[JMINIMUM]); #endif @@ -386,7 +398,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { SERIAL_ECHOLNPGM(" " STR_J_MAX ": ", m.obj_side[JMAXIMUM]); #endif #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS #if ENABLED(CALIBRATION_MEASURE_KMIN) SERIAL_ECHOLNPGM(" " STR_K_MIN ": ", m.obj_side[KMINIMUM]); #endif @@ -439,7 +451,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { #if HAS_Z_AXIS && AXIS_CAN_CALIBRATE(Z) SERIAL_ECHOLNPGM(" Top: ", m.backlash[TOP]); #endif - #if LINEAR_AXES >= 4 && AXIS_CAN_CALIBRATE(I) + #if HAS_I_AXIS && AXIS_CAN_CALIBRATE(I) #if ENABLED(CALIBRATION_MEASURE_IMIN) SERIAL_ECHOLNPGM(" " STR_I_MIN ": ", m.backlash[IMINIMUM]); #endif @@ -447,7 +459,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { SERIAL_ECHOLNPGM(" " STR_I_MAX ": ", m.backlash[IMAXIMUM]); #endif #endif - #if LINEAR_AXES >= 5 && AXIS_CAN_CALIBRATE(J) + #if HAS_J_AXIS && AXIS_CAN_CALIBRATE(J) #if ENABLED(CALIBRATION_MEASURE_JMIN) SERIAL_ECHOLNPGM(" " STR_J_MIN ": ", m.backlash[JMINIMUM]); #endif @@ -455,7 +467,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) { SERIAL_ECHOLNPGM(" " STR_J_MAX ": ", m.backlash[JMAXIMUM]); #endif #endif - #if LINEAR_AXES >= 6 && AXIS_CAN_CALIBRATE(K) + #if HAS_K_AXIS && AXIS_CAN_CALIBRATE(K) #if ENABLED(CALIBRATION_MEASURE_KMIN) SERIAL_ECHOLNPGM(" " STR_K_MIN ": ", m.backlash[KMINIMUM]); #endif @@ -526,7 +538,7 @@ inline void calibrate_backlash(measurements_t &m, const float uncertainty) { { // New scope for TEMPORARY_BACKLASH_CORRECTION - TEMPORARY_BACKLASH_CORRECTION(all_off); + TEMPORARY_BACKLASH_CORRECTION(backlash.all_off); TEMPORARY_BACKLASH_SMOOTHING(0.0f); probe_sides(m, uncertainty); @@ -534,45 +546,45 @@ inline void calibrate_backlash(measurements_t &m, const float uncertainty) { #if ENABLED(BACKLASH_GCODE) #if HAS_X_CENTER - backlash.distance_mm.x = (m.backlash[LEFT] + m.backlash[RIGHT]) / 2; + backlash.set_distance_mm(X_AXIS, (m.backlash[LEFT] + m.backlash[RIGHT]) / 2); #elif ENABLED(CALIBRATION_MEASURE_LEFT) - backlash.distance_mm.x = m.backlash[LEFT]; + backlash.set_distance_mm(X_AXIS, m.backlash[LEFT]); #elif ENABLED(CALIBRATION_MEASURE_RIGHT) - backlash.distance_mm.x = m.backlash[RIGHT]; + backlash.set_distance_mm(X_AXIS, m.backlash[RIGHT]); #endif #if HAS_Y_CENTER - backlash.distance_mm.y = (m.backlash[FRONT] + m.backlash[BACK]) / 2; + backlash.set_distance_mm(Y_AXIS, (m.backlash[FRONT] + m.backlash[BACK]) / 2); #elif ENABLED(CALIBRATION_MEASURE_FRONT) - backlash.distance_mm.y = m.backlash[FRONT]; + backlash.set_distance_mm(Y_AXIS, m.backlash[FRONT]); #elif ENABLED(CALIBRATION_MEASURE_BACK) - backlash.distance_mm.y = m.backlash[BACK]; + backlash.set_distance_mm(Y_AXIS, m.backlash[BACK]); #endif - TERN_(HAS_Z_AXIS, if (AXIS_CAN_CALIBRATE(Z)) backlash.distance_mm.z = m.backlash[TOP]); + TERN_(HAS_Z_AXIS, if (AXIS_CAN_CALIBRATE(Z)) backlash.set_distance_mm(Z_AXIS, m.backlash[TOP])); #if HAS_I_CENTER - backlash.distance_mm.i = (m.backlash[IMINIMUM] + m.backlash[IMAXIMUM]) / 2; + backlash.set_distance_mm(I_AXIS, (m.backlash[IMINIMUM] + m.backlash[IMAXIMUM]) / 2); #elif ENABLED(CALIBRATION_MEASURE_IMIN) - backlash.distance_mm.i = m.backlash[IMINIMUM]; + backlash.set_distance_mm(I_AXIS, m.backlash[IMINIMUM]); #elif ENABLED(CALIBRATION_MEASURE_IMAX) - backlash.distance_mm.i = m.backlash[IMAXIMUM]; + backlash.set_distance_mm(I_AXIS, m.backlash[IMAXIMUM]); #endif #if HAS_J_CENTER - backlash.distance_mm.j = (m.backlash[JMINIMUM] + m.backlash[JMAXIMUM]) / 2; + backlash.set_distance_mm(J_AXIS, (m.backlash[JMINIMUM] + m.backlash[JMAXIMUM]) / 2); #elif ENABLED(CALIBRATION_MEASURE_JMIN) - backlash.distance_mm.j = m.backlash[JMINIMUM]; + backlash.set_distance_mm(J_AXIS, m.backlash[JMINIMUM]); #elif ENABLED(CALIBRATION_MEASURE_JMAX) - backlash.distance_mm.j = m.backlash[JMAXIMUM]; + backlash.set_distance_mm(J_AXIS, m.backlash[JMAXIMUM]); #endif #if HAS_K_CENTER - backlash.distance_mm.k = (m.backlash[KMINIMUM] + m.backlash[KMAXIMUM]) / 2; + backlash.set_distance_mm(K_AXIS, (m.backlash[KMINIMUM] + m.backlash[KMAXIMUM]) / 2); #elif ENABLED(CALIBRATION_MEASURE_KMIN) - backlash.distance_mm.k = m.backlash[KMINIMUM]; + backlash.set_distance_mm(K_AXIS, m.backlash[KMINIMUM]); #elif ENABLED(CALIBRATION_MEASURE_KMAX) - backlash.distance_mm.k = m.backlash[KMAXIMUM]; + backlash.set_distance_mm(K_AXIS, m.backlash[KMAXIMUM]); #endif #endif // BACKLASH_GCODE @@ -583,7 +595,7 @@ inline void calibrate_backlash(measurements_t &m, const float uncertainty) { // allowed directions to take up any backlash { // New scope for TEMPORARY_BACKLASH_CORRECTION - TEMPORARY_BACKLASH_CORRECTION(all_on); + TEMPORARY_BACKLASH_CORRECTION(backlash.all_on); TEMPORARY_BACKLASH_SMOOTHING(0.0f); const xyz_float_t move = LINEAR_AXIS_ARRAY( AXIS_CAN_CALIBRATE(X) * 3, AXIS_CAN_CALIBRATE(Y) * 3, AXIS_CAN_CALIBRATE(Z) * 3, @@ -613,7 +625,7 @@ inline void update_measurements(measurements_t &m, const AxisEnum axis) { * - Call calibrate_backlash() beforehand for best accuracy */ inline void calibrate_toolhead(measurements_t &m, const float uncertainty, const uint8_t extruder) { - TEMPORARY_BACKLASH_CORRECTION(all_on); + TEMPORARY_BACKLASH_CORRECTION(backlash.all_on); TEMPORARY_BACKLASH_SMOOTHING(0.0f); TERN(HAS_MULTI_HOTEND, set_nozzle(m, extruder), UNUSED(extruder)); @@ -650,7 +662,7 @@ inline void calibrate_toolhead(measurements_t &m, const float uncertainty, const * uncertainty in - How far away from the object to begin probing */ inline void calibrate_all_toolheads(measurements_t &m, const float uncertainty) { - TEMPORARY_BACKLASH_CORRECTION(all_on); + TEMPORARY_BACKLASH_CORRECTION(backlash.all_on); TEMPORARY_BACKLASH_SMOOTHING(0.0f); HOTEND_LOOP() calibrate_toolhead(m, uncertainty, e); @@ -666,7 +678,7 @@ inline void calibrate_all_toolheads(measurements_t &m, const float uncertainty) * 1) For each nozzle, touch top and sides of object to determine object position and * nozzle offsets. Do a fast but rough search over a wider area. * 2) With the first nozzle, touch top and sides of object to determine backlash values - * for all axis (if BACKLASH_GCODE is enabled) + * for all axes (if BACKLASH_GCODE is enabled) * 3) For each nozzle, touch top and sides of object slowly to determine precise * position of object. Adjust coordinate system and nozzle offsets so probed object * location corresponds to known object location with a high degree of precision. @@ -676,7 +688,7 @@ inline void calibrate_all() { TERN_(HAS_HOTEND_OFFSET, reset_hotend_offsets()); - TEMPORARY_BACKLASH_CORRECTION(all_on); + TEMPORARY_BACKLASH_CORRECTION(backlash.all_on); TEMPORARY_BACKLASH_SMOOTHING(0.0f); // Do a fast and rough calibration of the toolheads diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index 21bb2c759006..c484d4f1b770 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -82,13 +82,13 @@ * - `P` - Run probe temperature calibration. */ -static void say_waiting_for() { SERIAL_ECHOPGM("Waiting for "); } -static void say_waiting_for_probe_heating() { say_waiting_for(); SERIAL_ECHOLNPGM("probe heating."); } -static void say_successfully_calibrated() { SERIAL_ECHOPGM("Successfully calibrated"); } -static void say_failed_to_calibrate() { SERIAL_ECHOPGM("!Failed to calibrate"); } - #if BOTH(PTC_PROBE, PTC_BED) + static void say_waiting_for() { SERIAL_ECHOPGM("Waiting for "); } + static void say_waiting_for_probe_heating() { say_waiting_for(); SERIAL_ECHOLNPGM("probe heating."); } + static void say_successfully_calibrated() { SERIAL_ECHOPGM("Successfully calibrated"); } + static void say_failed_to_calibrate() { SERIAL_ECHOPGM("!Failed to calibrate"); } + void GcodeSuite::G76() { auto report_temps = [](millis_t &ntr, millis_t timeout=0) { idle_no_sleep(); @@ -109,7 +109,9 @@ static void say_failed_to_calibrate() { SERIAL_ECHOPGM("!Failed to calibra auto g76_probe = [](const TempSensorID sid, celsius_t &targ, const xy_pos_t &nozpos) { do_z_clearance(5.0); // Raise nozzle before probing + ptc.set_enabled(false); const float measured_z = probe.probe_at_point(nozpos, PROBE_PT_STOW, 0, false); // verbose=0, probe_relative=false + ptc.set_enabled(true); if (isnan(measured_z)) SERIAL_ECHOLNPGM("!Received NAN. Aborting."); else { diff --git a/Marlin/src/gcode/calibrate/M425.cpp b/Marlin/src/gcode/calibrate/M425.cpp index 190af0f71bbe..6b1f56fcf658 100644 --- a/Marlin/src/gcode/calibrate/M425.cpp +++ b/Marlin/src/gcode/calibrate/M425.cpp @@ -55,7 +55,7 @@ void GcodeSuite::M425() { case Z_AXIS: return AXIS_CAN_CALIBRATE(Z), case I_AXIS: return AXIS_CAN_CALIBRATE(I), case J_AXIS: return AXIS_CAN_CALIBRATE(J), - case K_AXIS: return AXIS_CAN_CALIBRATE(K), + case K_AXIS: return AXIS_CAN_CALIBRATE(K) ); } }; @@ -63,7 +63,7 @@ void GcodeSuite::M425() { LOOP_LINEAR_AXES(a) { if (axis_can_calibrate(a) && parser.seen(AXIS_CHAR(a))) { planner.synchronize(); - backlash.distance_mm[a] = parser.has_value() ? parser.value_linear_units() : backlash.get_measurement(AxisEnum(a)); + backlash.set_distance_mm(AxisEnum(a), parser.has_value() ? parser.value_linear_units() : backlash.get_measurement(AxisEnum(a))); noArgs = false; } } @@ -77,25 +77,25 @@ void GcodeSuite::M425() { #ifdef BACKLASH_SMOOTHING_MM if (parser.seen('S')) { planner.synchronize(); - backlash.smoothing_mm = parser.value_linear_units(); + backlash.set_smoothing_mm(parser.value_linear_units()); noArgs = false; } #endif if (noArgs) { SERIAL_ECHOPGM("Backlash Correction "); - if (!backlash.correction) SERIAL_ECHOPGM("in"); + if (!backlash.get_correction_uint8()) SERIAL_ECHOPGM("in"); SERIAL_ECHOLNPGM("active:"); SERIAL_ECHOLNPGM(" Correction Amount/Fade-out: F", backlash.get_correction(), " (F1.0 = full, F0.0 = none)"); SERIAL_ECHOPGM(" Backlash Distance (mm): "); LOOP_LINEAR_AXES(a) if (axis_can_calibrate(a)) { SERIAL_CHAR(' ', AXIS_CHAR(a)); - SERIAL_ECHO(backlash.distance_mm[a]); + SERIAL_ECHO(backlash.get_distance_mm(AxisEnum(a))); SERIAL_EOL(); } #ifdef BACKLASH_SMOOTHING_MM - SERIAL_ECHOLNPGM(" Smoothing (mm): S", backlash.smoothing_mm); + SERIAL_ECHOLNPGM(" Smoothing (mm): S", backlash.get_smoothing_mm()); #endif #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) @@ -118,15 +118,15 @@ void GcodeSuite::M425_report(const bool forReplay/*=true*/) { SERIAL_ECHOLNPGM_P( PSTR(" M425 F"), backlash.get_correction() #ifdef BACKLASH_SMOOTHING_MM - , PSTR(" S"), LINEAR_UNIT(backlash.smoothing_mm) + , PSTR(" S"), LINEAR_UNIT(backlash.get_smoothing_mm()) #endif , LIST_N(DOUBLE(LINEAR_AXES), - SP_X_STR, LINEAR_UNIT(backlash.distance_mm.x), - SP_Y_STR, LINEAR_UNIT(backlash.distance_mm.y), - SP_Z_STR, LINEAR_UNIT(backlash.distance_mm.z), - SP_I_STR, LINEAR_UNIT(backlash.distance_mm.i), - SP_J_STR, LINEAR_UNIT(backlash.distance_mm.j), - SP_K_STR, LINEAR_UNIT(backlash.distance_mm.k) + SP_X_STR, LINEAR_UNIT(backlash.get_distance_mm(X_AXIS)), + SP_Y_STR, LINEAR_UNIT(backlash.get_distance_mm(Y_AXIS)), + SP_Z_STR, LINEAR_UNIT(backlash.get_distance_mm(Z_AXIS)), + SP_I_STR, LINEAR_UNIT(backlash.get_distance_mm(I_AXIS)), + SP_J_STR, LINEAR_UNIT(backlash.get_distance_mm(J_AXIS)), + SP_K_STR, LINEAR_UNIT(backlash.get_distance_mm(K_AXIS)) ) ); } diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 913ffe30d478..8b6ea0bf1fae 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -35,11 +35,15 @@ #include "../../module/planner.h" #endif +#if HAS_PTC + #include "../../feature/probe_temp_comp.h" +#endif + /** * M48: Z probe repeatability measurement function. * * Usage: - * M48 + * M48 * P = Number of sampled points (4-50, default 10) * X = Sample X position * Y = Sample Y position @@ -47,6 +51,7 @@ * E = Engage Z probe for each reading * L = Number of legs of movement before probe * S = Schizoid (Or Star if you prefer) + * C = Enable probe temperature compensation (0 or 1, default 1) * * This function requires the machine to be homed before invocation. */ @@ -107,6 +112,8 @@ void GcodeSuite::M48() { set_bed_leveling_enabled(false); #endif + TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool())); + // Work with reasonable feedrates remember_feedrate_scaling_off(); @@ -269,6 +276,9 @@ void GcodeSuite::M48() { // Re-enable bed level correction if it had been on TERN_(HAS_LEVELING, set_bed_leveling_enabled(was_enabled)); + // Re-enable probe temperature correction + TERN_(HAS_PTC, ptc.set_enabled(true)); + report_current_position(); } diff --git a/Marlin/src/gcode/calibrate/M666.cpp b/Marlin/src/gcode/calibrate/M666.cpp index 15f8baf109eb..aa8ba26bb6b2 100644 --- a/Marlin/src/gcode/calibrate/M666.cpp +++ b/Marlin/src/gcode/calibrate/M666.cpp @@ -93,12 +93,12 @@ #if ENABLED(Z_MULTI_ENDSTOPS) if (parser.seenval('Z')) { const float z_adj = parser.value_linear_units(); - #if NUM_Z_STEPPER_DRIVERS == 2 + #if NUM_Z_STEPPERS == 2 endstops.z2_endstop_adj = z_adj; #else const int ind = parser.intval('S'); #define _SET_ZADJ(N) if (!ind || ind == N) endstops.z##N##_endstop_adj = z_adj; - REPEAT_S(2, INCREMENT(NUM_Z_STEPPER_DRIVERS), _SET_ZADJ) + REPEAT_S(2, INCREMENT(NUM_Z_STEPPERS), _SET_ZADJ) #endif } #endif @@ -114,11 +114,11 @@ SERIAL_ECHOLNPGM_P(SP_Y_STR, LINEAR_UNIT(endstops.y2_endstop_adj)); #endif #if ENABLED(Z_MULTI_ENDSTOPS) - #if NUM_Z_STEPPER_DRIVERS >= 3 + #if NUM_Z_STEPPERS >= 3 SERIAL_ECHOPGM(" S2 Z", LINEAR_UNIT(endstops.z3_endstop_adj)); report_echo_start(forReplay); SERIAL_ECHOPGM(" M666 S3 Z", LINEAR_UNIT(endstops.z3_endstop_adj)); - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 report_echo_start(forReplay); SERIAL_ECHOPGM(" M666 S4 Z", LINEAR_UNIT(endstops.z4_endstop_adj)); #endif diff --git a/Marlin/src/gcode/calibrate/M852.cpp b/Marlin/src/gcode/calibrate/M852.cpp index b24a449652a3..6c661dcd61d9 100644 --- a/Marlin/src/gcode/calibrate/M852.cpp +++ b/Marlin/src/gcode/calibrate/M852.cpp @@ -93,7 +93,7 @@ void GcodeSuite::M852() { void GcodeSuite::M852_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_SKEW_FACTOR)); - SERIAL_ECHOPAIR_F(" M851 I", planner.skew_factor.xy, 6); + SERIAL_ECHOPAIR_F(" M852 I", planner.skew_factor.xy, 6); #if ENABLED(SKEW_CORRECTION_FOR_Z) SERIAL_ECHOPAIR_F(" J", planner.skew_factor.xz, 6); SERIAL_ECHOPAIR_F(" K", planner.skew_factor.yz, 6); diff --git a/Marlin/src/gcode/config/M200-M205.cpp b/Marlin/src/gcode/config/M200-M205.cpp index 7b7ce5e10d7f..08b50b968029 100644 --- a/Marlin/src/gcode/config/M200-M205.cpp +++ b/Marlin/src/gcode/config/M200-M205.cpp @@ -93,12 +93,12 @@ } #else SERIAL_ECHOLNPGM(" M200 S", parser.volumetric_enabled); - LOOP_L_N(i, EXTRUDERS) { + EXTRUDER_LOOP() { report_echo_start(forReplay); SERIAL_ECHOLNPGM( - " M200 T", i, " D", LINEAR_UNIT(planner.filament_size[i]) + " M200 T", e, " D", LINEAR_UNIT(planner.filament_size[e]) #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) - , " L", LINEAR_UNIT(planner.volumetric_extruder_limit[i]) + , " L", LINEAR_UNIT(planner.volumetric_extruder_limit[e]) #endif ); } @@ -108,12 +108,21 @@ #endif // !NO_VOLUMETRICS /** - * M201: Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000) + * M201: Set max acceleration in units/s^2 for print moves. * - * With multiple extruders use T to specify which one. + * X : Max Acceleration for X + * Y : Max Acceleration for Y + * Z : Max Acceleration for Z + * ... : etc + * E : Max Acceleration for Extruder + * T : Extruder index to set + * + * With XY_FREQUENCY_LIMIT: + * F : Frequency limit for XY...IJKUVW + * S : Speed factor percentage. */ void GcodeSuite::M201() { - if (!parser.seen("T" LOGICAL_AXES_STRING)) + if (!parser.seen("T" LOGICAL_AXES_STRING TERN_(XY_FREQUENCY_LIMIT, "FS"))) return M201_report(); const int8_t target_extruder = get_target_extruder_from_command(); @@ -121,7 +130,7 @@ void GcodeSuite::M201() { #ifdef XY_FREQUENCY_LIMIT if (parser.seenval('F')) planner.set_frequency_limit(parser.value_byte()); - if (parser.seenval('G')) planner.xy_freq_min_speed_factor = constrain(parser.value_float(), 1, 100) / 100; + if (parser.seenval('S')) planner.xy_freq_min_speed_factor = constrain(parser.value_float(), 1, 100) / 100; #endif LOOP_LOGICAL_AXES(i) { @@ -194,7 +203,7 @@ void GcodeSuite::M203_report(const bool forReplay/*=true*/) { ); #if ENABLED(DISTINCT_E_FACTORS) LOOP_L_N(i, E_STEPPERS) { - SERIAL_ECHO_START(); + if (!forReplay) SERIAL_ECHO_START(); SERIAL_ECHOLNPGM_P( PSTR(" M203 T"), i , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_feedrate_mm_s[E_AXIS_N(i)]) @@ -253,7 +262,7 @@ void GcodeSuite::M205() { 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 - #if HAS_CLASSIC_JERK && (AXIS4_NAME == 'J' || AXIS5_NAME == 'J' || AXIS6_NAME == 'J') + #if HAS_CLASSIC_JERK && AXIS_COLLISION('J') #error "Can't set_max_jerk for 'J' axis because 'J' is used for Junction Deviation." #endif if (parser.seenval('J')) { @@ -288,8 +297,13 @@ void GcodeSuite::M205_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F( "Advanced (B S T" TERN_(HAS_JUNCTION_DEVIATION, " J") - TERN_(HAS_CLASSIC_JERK, " X Y Z") - TERN_(HAS_CLASSIC_E_JERK, " E") + #if HAS_CLASSIC_JERK + LINEAR_AXIS_GANG( + " X", " Y", " Z", + " " STR_I "", " " STR_J "", " " STR_K "" + ) + #endif + TERN_(HAS_CLASSIC_E_JERK, " E") ")" )); SERIAL_ECHOLNPGM_P( diff --git a/Marlin/src/gcode/config/M217.cpp b/Marlin/src/gcode/config/M217.cpp index 7576272a48b6..74932a64f8fe 100644 --- a/Marlin/src/gcode/config/M217.cpp +++ b/Marlin/src/gcode/config/M217.cpp @@ -34,25 +34,28 @@ #include "../../MarlinCore.h" // for SP_X_STR, etc. /** - * M217 - Set SINGLENOZZLE toolchange parameters + * M217 - Set toolchange parameters * * // Tool change command * Q Prime active tool and exit * * // Tool change settings - * S[linear] Swap length - * B[linear] Extra Swap length - * E[linear] Prime length - * P[linear/m] Prime speed - * R[linear/m] Retract speed - * U[linear/m] UnRetract 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) - * Z[linear] Z Raise - * F[linear] Fan Speed 0-255 - * G[linear/s] Fan time + * 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 + * R[linear/min] Retract speed + * U[linear/min] UnRetract 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) + * I[linear] Park I (Requires TOOLCHANGE_PARK and LINEAR_AXES >= 4) + * J[linear] Park J (Requires TOOLCHANGE_PARK and LINEAR_AXES >= 5) + * K[linear] Park K (Requires TOOLCHANGE_PARK and LINEAR_AXES >= 6) + * Z[linear] Z Raise + * F[speed] Fan Speed 0-255 + * D[seconds] Fan time * * Tool migration settings * A[0|1] Enable auto-migration on runout @@ -76,8 +79,8 @@ void GcodeSuite::M217() { 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 - if (parser.seenval('F')) { const int16_t v = parser.value_linear_units(); toolchange_settings.fan_speed = constrain(v, 0, 255); } - if (parser.seenval('G')) { const int16_t v = parser.value_linear_units(); toolchange_settings.fan_time = constrain(v, 1, 30); } + if (parser.seenval('F')) { const uint16_t v = parser.value_ushort(); toolchange_settings.fan_speed = constrain(v, 0, 255); } + if (parser.seenval('D')) { const uint16_t v = parser.value_ushort(); toolchange_settings.fan_time = constrain(v, 1, 30); } #endif #endif @@ -88,10 +91,23 @@ void GcodeSuite::M217() { #if ENABLED(TOOLCHANGE_PARK) if (parser.seenval('W')) { toolchange_settings.enable_park = parser.value_linear_units(); } if (parser.seenval('X')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.x = constrain(v, X_MIN_POS, X_MAX_POS); } - if (parser.seenval('Y')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.y = constrain(v, Y_MIN_POS, Y_MAX_POS); } + #if HAS_Y_AXIS + if (parser.seenval('Y')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.y = constrain(v, Y_MIN_POS, Y_MAX_POS); } + #endif + #if HAS_I_AXIS + if (parser.seenval('I')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.i = constrain(v, I_MIN_POS, I_MAX_POS); } + #endif + #if HAS_J_AXIS + if (parser.seenval('J')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.j = constrain(v, J_MIN_POS, J_MAX_POS); } + #endif + #if HAS_K_AXIS + if (parser.seenval('K')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.k = constrain(v, K_MIN_POS, K_MAX_POS); } + #endif #endif - if (parser.seenval('Z')) { toolchange_settings.z_raise = parser.value_linear_units(); } + #if HAS_Z_AXIS + if (parser.seenval('Z')) { toolchange_settings.z_raise = parser.value_linear_units(); } + #endif #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) migration.target = 0; // 0 = disabled @@ -143,7 +159,7 @@ void GcodeSuite::M217_report(const bool forReplay/*=true*/) { SERIAL_ECHOPGM(" R", LINEAR_UNIT(toolchange_settings.retract_speed), " U", LINEAR_UNIT(toolchange_settings.unretract_speed), " F", toolchange_settings.fan_speed, - " G", toolchange_settings.fan_time); + " D", toolchange_settings.fan_time); #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) SERIAL_ECHOPGM(" A", migration.automode); @@ -151,9 +167,24 @@ void GcodeSuite::M217_report(const bool forReplay/*=true*/) { #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)); - SERIAL_ECHOPGM_P(SP_Y_STR, LINEAR_UNIT(toolchange_settings.change_point.y)); + SERIAL_ECHOPGM_P( + SP_X_STR, LINEAR_UNIT(toolchange_settings.change_point.x) + #if HAS_Y_AXIS + , SP_Y_STR, LINEAR_UNIT(toolchange_settings.change_point.y) + #endif + #if HAS_I_AXIS + , SP_I_STR, LINEAR_UNIT(toolchange_settings.change_point.i) + #endif + #if HAS_J_AXIS + , SP_J_STR, LINEAR_UNIT(toolchange_settings.change_point.j) + #endif + #if HAS_K_AXIS + , SP_K_STR, LINEAR_UNIT(toolchange_settings.change_point.k) + #endif + ); + } #endif #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED) diff --git a/Marlin/src/gcode/config/M302.cpp b/Marlin/src/gcode/config/M302.cpp index e271dcd469ee..9f4d569d7b2e 100644 --- a/Marlin/src/gcode/config/M302.cpp +++ b/Marlin/src/gcode/config/M302.cpp @@ -27,6 +27,10 @@ #include "../gcode.h" #include "../../module/temperature.h" +#if ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin_defines.h" +#endif + /** * M302: Allow cold extrudes, or set the minimum extrude temperature * @@ -47,6 +51,7 @@ void GcodeSuite::M302() { if (seen_S) { thermalManager.extrude_min_temp = parser.value_celsius(); thermalManager.allow_cold_extrude = (thermalManager.extrude_min_temp == 0); + TERN_(DWIN_LCD_PROUI, HMI_data.ExtMinT = thermalManager.extrude_min_temp); } if (parser.seen('P')) diff --git a/Marlin/src/gcode/config/M43.cpp b/Marlin/src/gcode/config/M43.cpp index 097aa142f03f..688b94c9bf39 100644 --- a/Marlin/src/gcode/config/M43.cpp +++ b/Marlin/src/gcode/config/M43.cpp @@ -69,7 +69,7 @@ inline void toggle_pins() { SERIAL_EOL(); } else { - watchdog_refresh(); + hal.watchdog_refresh(); report_pin_state_extended(pin, ignore_protection, true, F("Pulsing ")); #ifdef __STM32F1__ const auto prior_mode = _GET_MODE(i); @@ -98,10 +98,10 @@ inline void toggle_pins() { { pinMode(pin, OUTPUT); for (int16_t j = 0; j < repeat; j++) { - watchdog_refresh(); extDigitalWrite(pin, 0); safe_delay(wait); - watchdog_refresh(); extDigitalWrite(pin, 1); safe_delay(wait); - watchdog_refresh(); extDigitalWrite(pin, 0); safe_delay(wait); - watchdog_refresh(); + hal.watchdog_refresh(); extDigitalWrite(pin, 0); safe_delay(wait); + hal.watchdog_refresh(); extDigitalWrite(pin, 1); safe_delay(wait); + hal.watchdog_refresh(); extDigitalWrite(pin, 0); safe_delay(wait); + hal.watchdog_refresh(); } } #ifdef __STM32F1__ @@ -198,10 +198,10 @@ inline void servo_probe_test() { uint8_t i = 0; SERIAL_ECHOLNPGM(". Deploy & stow 4 times"); do { - MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][0]); // Deploy + servo[probe_index].move(servo_angles[Z_PROBE_SERVO_NR][0]); // Deploy safe_delay(500); deploy_state = READ(PROBE_TEST_PIN); - MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][1]); // Stow + servo[probe_index].move(servo_angles[Z_PROBE_SERVO_NR][1]); // Stow safe_delay(500); stow_state = READ(PROBE_TEST_PIN); } while (++i < 4); @@ -226,7 +226,7 @@ inline void servo_probe_test() { } // Ask the user for a trigger event and measure the pulse width. - MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][0]); // Deploy + servo[probe_index].move(servo_angles[Z_PROBE_SERVO_NR][0]); // Deploy safe_delay(500); SERIAL_ECHOLNPGM("** Please trigger probe within 30 sec **"); uint16_t probe_counter = 0; @@ -256,7 +256,7 @@ inline void servo_probe_test() { } else SERIAL_ECHOLNPGM("FAIL: Noise detected - please re-run test"); - MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][1]); // Stow + servo[probe_index].move(servo_angles[Z_PROBE_SERVO_NR][1]); // Stow return; } } @@ -313,7 +313,7 @@ void GcodeSuite::M43() { // 'P' Get the range of pins to test or watch uint8_t first_pin = PARSED_PIN_INDEX('P', 0), - last_pin = parser.seenval('P') ? first_pin : NUMBER_PINS_TOTAL - 1; + last_pin = parser.seenval('P') ? first_pin : TERN(HAS_HIGH_ANALOG_PINS, NUM_DIGITAL_PINS, NUMBER_PINS_TOTAL) - 1; if (first_pin > last_pin) return; @@ -333,12 +333,12 @@ void GcodeSuite::M43() { if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue; pinMode(pin, INPUT_PULLUP); delay(1); - /* - if (IS_ANALOG(pin)) - pin_state[pin - first_pin] = analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin)); // int16_t pin_state[...] - else - //*/ - pin_state[i - first_pin] = extDigitalRead(pin); + /* + if (IS_ANALOG(pin)) + pin_state[pin - first_pin] = analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin)); // int16_t pin_state[...] + else + //*/ + pin_state[i - first_pin] = extDigitalRead(pin); } #if HAS_RESUME_CONTINUE diff --git a/Marlin/src/gcode/config/M672.cpp b/Marlin/src/gcode/config/M672.cpp index af74230516e1..257b49471f61 100644 --- a/Marlin/src/gcode/config/M672.cpp +++ b/Marlin/src/gcode/config/M672.cpp @@ -53,7 +53,7 @@ // b7 b6 b5 b4 ~b4 ... hi bits, NOT last bit // b3 b2 b1 b0 ~b0 ... lo bits, NOT last bit // -void M672_send(uint8_t b) { // bit rate requirement: 1KHz +/- 30% +void M672_send(uint8_t b) { // bit rate requirement: 1kHz +/- 30% LOOP_L_N(bits, 14) { switch (bits) { default: { OUT_WRITE(SMART_EFFECTOR_MOD_PIN, !!(b & 0x80)); b <<= 1; break; } // send bit, shift next into place diff --git a/Marlin/src/gcode/config/M92.cpp b/Marlin/src/gcode/config/M92.cpp index 54fe698f97b2..8f527919fd83 100644 --- a/Marlin/src/gcode/config/M92.cpp +++ b/Marlin/src/gcode/config/M92.cpp @@ -24,7 +24,7 @@ #include "../../module/planner.h" /** - * M92: Set axis steps-per-unit for one or more axes, X, Y, Z, and E. + * M92: Set axis steps-per-unit for one or more axes, X, Y, Z, [I, [J, [K]]] and E. * (Follows the same syntax as G92) * * With multiple extruders use T to specify which one. diff --git a/Marlin/src/gcode/control/M111.cpp b/Marlin/src/gcode/control/M111.cpp index 08c39b762ea4..d6aeb774108b 100644 --- a/Marlin/src/gcode/control/M111.cpp +++ b/Marlin/src/gcode/control/M111.cpp @@ -34,12 +34,12 @@ void GcodeSuite::M111() { static PGMSTR(str_debug_8, STR_DEBUG_DRYRUN); static PGMSTR(str_debug_16, STR_DEBUG_COMMUNICATION); #if ENABLED(DEBUG_LEVELING_FEATURE) - static PGMSTR(str_debug_lvl, STR_DEBUG_LEVELING); + static PGMSTR(str_debug_detail, STR_DEBUG_DETAIL); #endif static PGM_P const debug_strings[] PROGMEM = { str_debug_1, str_debug_2, str_debug_4, str_debug_8, str_debug_16, - TERN_(DEBUG_LEVELING_FEATURE, str_debug_lvl) + TERN_(DEBUG_LEVELING_FEATURE, str_debug_detail) }; SERIAL_ECHO_START(); diff --git a/Marlin/src/gcode/control/M17_M18_M84.cpp b/Marlin/src/gcode/control/M17_M18_M84.cpp index 4683786f1fd0..ac3a602687a9 100644 --- a/Marlin/src/gcode/control/M17_M18_M84.cpp +++ b/Marlin/src/gcode/control/M17_M18_M84.cpp @@ -33,8 +33,8 @@ #include "../../core/debug_out.h" #include "../../libs/hex_print.h" -inline axis_flags_t selected_axis_bits() { - axis_flags_t selected{0}; +inline stepper_flags_t selected_axis_bits() { + stepper_flags_t selected{0}; #if HAS_EXTRUDERS if (parser.seen('E')) { if (E_TERN0(parser.has_value())) { @@ -58,7 +58,7 @@ inline axis_flags_t selected_axis_bits() { } // Enable specified axes and warn about other affected axes -void do_enable(const axis_flags_t to_enable) { +void do_enable(const stepper_flags_t to_enable) { const ena_mask_t was_enabled = stepper.axis_enabled.bits, shall_enable = to_enable.bits & ~was_enabled; @@ -77,7 +77,7 @@ void do_enable(const axis_flags_t to_enable) { } } #if HAS_EXTRUDERS - LOOP_L_N(e, EXTRUDERS) { + EXTRUDER_LOOP() { const uint8_t a = INDEX_OF_AXIS(E_AXIS, e); if (TEST(shall_enable, a)) { stepper.ENABLE_EXTRUDER(e); @@ -141,7 +141,7 @@ void GcodeSuite::M17() { } } -void try_to_disable(const axis_flags_t to_disable) { +void try_to_disable(const stepper_flags_t to_disable) { ena_mask_t still_enabled = to_disable.bits & stepper.axis_enabled.bits; DEBUG_ECHOLNPGM("Enabled: ", hex_word(stepper.axis_enabled.bits), " To Disable: ", hex_word(to_disable.bits), " | ", hex_word(still_enabled)); @@ -161,7 +161,7 @@ void try_to_disable(const axis_flags_t to_disable) { DEBUG_ECHOLNPGM(" ... still_enabled=", hex_word(still_enabled)); } #if HAS_EXTRUDERS - LOOP_L_N(e, EXTRUDERS) { + EXTRUDER_LOOP() { const uint8_t a = INDEX_OF_AXIS(E_AXIS, e); if (TEST(to_disable.bits, a)) { DEBUG_ECHOPGM("Try to disable E", AS_DIGIT(e), " (", a, ") with overlap ", hex_word(enable_overlap[a]), " ... "); @@ -194,7 +194,7 @@ void try_to_disable(const axis_flags_t to_disable) { } } #if HAS_EXTRUDERS - LOOP_L_N(e, EXTRUDERS) { + EXTRUDER_LOOP() { const uint8_t a = INDEX_OF_AXIS(E_AXIS, e); if (TEST(still_enabled, a)) { SERIAL_CHAR('E', '0' + e); @@ -213,7 +213,16 @@ void try_to_disable(const axis_flags_t to_disable) { void GcodeSuite::M18_M84() { if (parser.seenval('S')) { reset_stepper_timeout(); - stepper_inactive_time = parser.value_millis_from_seconds(); + #if HAS_DISABLE_INACTIVE_AXIS + const millis_t ms = parser.value_millis_from_seconds(); + #if LASER_SAFETY_TIMEOUT_MS > 0 + if (ms && ms <= LASER_SAFETY_TIMEOUT_MS) { + SERIAL_ECHO_MSG("M18 timeout must be > ", MS_TO_SEC(LASER_SAFETY_TIMEOUT_MS + 999), " s for laser safety."); + return; + } + #endif + stepper_inactive_time = ms; + #endif } else { if (parser.seen_axis()) { @@ -242,6 +251,6 @@ void GcodeSuite::M18_M84() { else planner.finish_and_disable(); - TERN_(AUTO_BED_LEVELING_UBL, ubl.steppers_were_disabled()); + TERN_(AUTO_BED_LEVELING_UBL, bedlevel.steppers_were_disabled()); } } diff --git a/Marlin/src/gcode/control/M280.cpp b/Marlin/src/gcode/control/M280.cpp index 2a8e73eafbf2..930542999ee2 100644 --- a/Marlin/src/gcode/control/M280.cpp +++ b/Marlin/src/gcode/control/M280.cpp @@ -56,14 +56,14 @@ void GcodeSuite::M280() { while (PENDING(now, end)) { safe_delay(50); now = _MIN(millis(), end); - MOVE_SERVO(servo_index, LROUND(aold + (anew - aold) * (float(now - start) / t))); + servo[servo_index].move(LROUND(aold + (anew - aold) * (float(now - start) / t))); } } #endif // POLARGRAPH - MOVE_SERVO(servo_index, anew); + servo[servo_index].move(anew); } else - DETACH_SERVO(servo_index); + servo[servo_index].detach(); } else SERIAL_ECHO_MSG(" Servo ", servo_index, ": ", servo[servo_index].read()); diff --git a/Marlin/src/gcode/control/M282.cpp b/Marlin/src/gcode/control/M282.cpp index e6f5ce7dccc3..3ac5ac9f5bfc 100644 --- a/Marlin/src/gcode/control/M282.cpp +++ b/Marlin/src/gcode/control/M282.cpp @@ -36,7 +36,7 @@ void GcodeSuite::M282() { const int servo_index = parser.value_int(); if (WITHIN(servo_index, 0, NUM_SERVOS - 1)) - DETACH_SERVO(servo_index); + servo[servo_index].detach(); else SERIAL_ECHO_MSG("Servo ", servo_index, " out of range"); diff --git a/Marlin/src/gcode/control/M3-M5.cpp b/Marlin/src/gcode/control/M3-M5.cpp index ddbbc4ab6835..a619b1b76208 100644 --- a/Marlin/src/gcode/control/M3-M5.cpp +++ b/Marlin/src/gcode/control/M3-M5.cpp @@ -43,7 +43,7 @@ * * If no PWM pin is defined then M3/M4 just turns it on. * - * At least 12.8KHz (50Hz * 256) is needed for Spindle PWM. + * At least 12.8kHz (50Hz * 256) is needed for Spindle PWM. * Hardware PWM is required on AVR. ISRs are too slow. * * NOTE: WGM for timers 3, 4, and 5 must be either Mode 1 or Mode 5. @@ -66,6 +66,10 @@ * PWM duty cycle goes from 0 (off) to 255 (always on). */ void GcodeSuite::M3_M4(const bool is_M4) { + #if LASER_SAFETY_TIMEOUT_MS > 0 + 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')) { diff --git a/Marlin/src/gcode/control/M380_M381.cpp b/Marlin/src/gcode/control/M380_M381.cpp index 3f5b25246543..6bcec891e281 100644 --- a/Marlin/src/gcode/control/M380_M381.cpp +++ b/Marlin/src/gcode/control/M380_M381.cpp @@ -37,7 +37,7 @@ void GcodeSuite::M380() { #if ENABLED(MANUAL_SOLENOID_CONTROL) enable_solenoid(parser.intval('S', active_extruder)); #else - enable_solenoid_on_active_extruder(); + enable_solenoid(active_extruder); #endif } diff --git a/Marlin/src/gcode/control/M42.cpp b/Marlin/src/gcode/control/M42.cpp index 77c0ccc49b0f..1b3a29d10056 100644 --- a/Marlin/src/gcode/control/M42.cpp +++ b/Marlin/src/gcode/control/M42.cpp @@ -52,7 +52,7 @@ void protected_pin_err() { * S Pin status from 0 - 255 * I Flag to ignore Marlin's pin protection * - * M Pin mode: 0=INPUT 1=OUTPUT 2=INPUT_PULLUP 3=INPUT_PULLDOWN + * T Pin mode: 0=INPUT 1=OUTPUT 2=INPUT_PULLUP 3=INPUT_PULLDOWN */ void GcodeSuite::M42() { const int pin_index = PARSED_PIN_INDEX('P', GET_PIN_MAP_INDEX(LED_PIN)); @@ -63,7 +63,7 @@ void GcodeSuite::M42() { if (!parser.boolval('I') && pin_is_protected(pin)) return protected_pin_err(); bool avoidWrite = false; - if (parser.seenval('M')) { + if (parser.seenval('T')) { switch (parser.value_byte()) { case 0: pinMode(pin, INPUT); avoidWrite = true; break; case 1: pinMode(pin, OUTPUT); break; @@ -126,10 +126,10 @@ void GcodeSuite::M42() { extDigitalWrite(pin, pin_status); #ifdef ARDUINO_ARCH_STM32 - // A simple I/O will be set to 0 by set_pwm_duty() + // A simple I/O will be set to 0 by hal.set_pwm_duty() if (pin_status <= 1 && !PWM_PIN(pin)) return; #endif - set_pwm_duty(pin, pin_status); + hal.set_pwm_duty(pin, pin_status); } #endif // DIRECT_PIN_CONTROL diff --git a/Marlin/src/gcode/control/M80_M81.cpp b/Marlin/src/gcode/control/M80_M81.cpp index b8be9daa4015..90b25e7ed34d 100644 --- a/Marlin/src/gcode/control/M80_M81.cpp +++ b/Marlin/src/gcode/control/M80_M81.cpp @@ -63,7 +63,7 @@ OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_STATE); #endif - TERN_(HAS_LCD_MENU, ui.reset_status()); + TERN_(HAS_MARLINUI_MENU, ui.reset_status()); } #endif // PSU_CONTROL @@ -79,20 +79,42 @@ void GcodeSuite::M81() { print_job_timer.stop(); - #if HAS_FAN - #if ENABLED(PROBING_FANS_OFF) - thermalManager.fans_paused = false; - ZERO(thermalManager.saved_fan_speed); - #endif + #if BOTH(HAS_FAN, PROBING_FANS_OFF) + thermalManager.fans_paused = false; + ZERO(thermalManager.saved_fan_speed); #endif safe_delay(1000); // Wait 1 second before switching off + LCD_MESSAGE_F(MACHINE_NAME " " STR_OFF "."); + + bool delayed_power_off = false; + + #if ENABLED(POWER_OFF_TIMER) + if (parser.seenval('D')) { + uint16_t delay = parser.value_ushort(); + if (delay > 1) { // skip already observed 1s delay + delayed_power_off = true; + powerManager.setPowerOffTimer(SEC_TO_MS(delay - 1)); + } + } + #endif + + #if ENABLED(POWER_OFF_WAIT_FOR_COOLDOWN) + if (parser.boolval('S')) { + delayed_power_off = true; + powerManager.setPowerOffOnCooldown(true); + } + #endif + + if (delayed_power_off) { + SERIAL_ECHOLNPGM(STR_DELAYED_POWEROFF); + return; + } + #if HAS_SUICIDE suicide(); #elif ENABLED(PSU_CONTROL) powerManager.power_off_soon(); #endif - - LCD_MESSAGE_F(MACHINE_NAME " " STR_OFF "."); } diff --git a/Marlin/src/gcode/control/M85.cpp b/Marlin/src/gcode/control/M85.cpp index 9c8c02c59aa0..ee868349ed75 100644 --- a/Marlin/src/gcode/control/M85.cpp +++ b/Marlin/src/gcode/control/M85.cpp @@ -29,7 +29,14 @@ void GcodeSuite::M85() { if (parser.seen('S')) { reset_stepper_timeout(); - max_inactive_time = parser.value_millis_from_seconds(); + const millis_t ms = parser.value_millis_from_seconds(); + #if LASER_SAFETY_TIMEOUT_MS > 0 + if (ms && ms <= LASER_SAFETY_TIMEOUT_MS) { + SERIAL_ECHO_MSG("M85 timeout must be > ", MS_TO_SEC(LASER_SAFETY_TIMEOUT_MS + 999), " s for laser safety."); + return; + } + #endif + max_inactive_time = ms; } } diff --git a/Marlin/src/gcode/control/M997.cpp b/Marlin/src/gcode/control/M997.cpp index 73d795bcefc8..74ed8b0d073e 100644 --- a/Marlin/src/gcode/control/M997.cpp +++ b/Marlin/src/gcode/control/M997.cpp @@ -24,8 +24,8 @@ #if ENABLED(PLATFORM_M997_SUPPORT) -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" +#if ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin.h" #endif /** @@ -33,7 +33,7 @@ */ void GcodeSuite::M997() { - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_RebootScreen()); + TERN_(DWIN_LCD_PROUI, DWIN_RebootScreen()); flashFirmware(parser.intval('S')); diff --git a/Marlin/src/gcode/eeprom/M500-M504.cpp b/Marlin/src/gcode/eeprom/M500-M504.cpp index a1f295ebde06..412d0033558f 100644 --- a/Marlin/src/gcode/eeprom/M500-M504.cpp +++ b/Marlin/src/gcode/eeprom/M500-M504.cpp @@ -56,6 +56,8 @@ void GcodeSuite::M502() { /** * M503: print settings currently in memory * + * S : Include / exclude header comments in the output. (Default: S1) + * * With CONFIGURATION_EMBEDDING: * C : Save the full Marlin configuration to SD Card as "mc.zip" */ diff --git a/Marlin/src/gcode/feature/L6470/M906.cpp b/Marlin/src/gcode/feature/L6470/M906.cpp index d058ce5501ae..f55405b798ad 100644 --- a/Marlin/src/gcode/feature/L6470/M906.cpp +++ b/Marlin/src/gcode/feature/L6470/M906.cpp @@ -24,6 +24,10 @@ #if HAS_L64XX +#if AXIS_COLLISION('I') + #error "M906 parameter collision with axis name." +#endif + #include "../../gcode.h" #include "../../../libs/L64XX/L64XX_Marlin.h" #include "../../../module/stepper/indirection.h" @@ -202,12 +206,11 @@ void L64XX_report_current(L64XX &motor, const L64XX_axis_t axis) { * On L6474 this sets the TVAL register (same address). * * I - select which driver(s) to change on multi-driver axis - * 0 - (default) all drivers on the axis or E0 - * 1 - monitor only X, Y, Z or E1 - * 2 - monitor only X2, Y2, Z2 or E2 - * 3 - monitor only Z3 or E3 - * 4 - monitor only Z4 or E4 - * 5 - monitor only E5 + * (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, Exxx - axis to change (optional) * L6474 - current in mA (4A max) * All others - 0-255 @@ -227,8 +230,10 @@ void GcodeSuite::M906() { uint8_t report_current = true; - #if HAS_L64XX - const uint8_t index = parser.byteval('I'); + #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_codes[i])) { @@ -241,73 +246,72 @@ void GcodeSuite::M906() { } switch (i) { - case X_AXIS: - #if AXIS_IS_L64XX(X) - if (index == 0) L6470_SET_KVAL_HOLD(X); - #endif - #if AXIS_IS_L64XX(X2) - if (index == 1) L6470_SET_KVAL_HOLD(X2); - #endif - break; - - #if HAS_Y_AXIS + #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) L6470_SET_KVAL_HOLD(Y); + if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(Y); #endif #if AXIS_IS_L64XX(Y2) - if (index == 1) L6470_SET_KVAL_HOLD(Y2); + if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(Y2); #endif break; #endif - #if HAS_Z_AXIS + #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) L6470_SET_KVAL_HOLD(Z); + if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(Z); #endif #if AXIS_IS_L64XX(Z2) - if (index == 1) L6470_SET_KVAL_HOLD(Z2); + if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(Z2); #endif #if AXIS_IS_L64XX(Z3) - if (index == 2) L6470_SET_KVAL_HOLD(Z3); + if (index < 0 || index == 2) L6470_SET_KVAL_HOLD(Z3); #endif - #if AXIS_DRIVER_TYPE_Z4(L6470) - if (index == 3) L6470_SET_KVAL_HOLD(Z4); + #if AXIS_IS_L64XX(Z4) + if (index < 0 || index == 3) L6470_SET_KVAL_HOLD(Z4); #endif break; #endif - #if E_STEPPERS + #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 target_e_stepper = get_target_e_stepper_from_command(0); - if (target_e_stepper < 0) return; - switch (target_e_stepper) { - #if AXIS_IS_L64XX(E0) - case 0: L6470_SET_KVAL_HOLD(E0); break; - #endif - #if AXIS_IS_L64XX(E1) - case 1: L6470_SET_KVAL_HOLD(E1); break; - #endif - #if AXIS_IS_L64XX(E2) - case 2: L6470_SET_KVAL_HOLD(E2); break; - #endif - #if AXIS_IS_L64XX(E3) - case 3: L6470_SET_KVAL_HOLD(E3); break; - #endif - #if AXIS_IS_L64XX(E4) - case 4: L6470_SET_KVAL_HOLD(E4); break; - #endif - #if AXIS_IS_L64XX(E5) - case 5: L6470_SET_KVAL_HOLD(E5); break; - #endif - #if AXIS_IS_L64XX(E6) - case 6: L6470_SET_KVAL_HOLD(E6); break; - #endif - #if AXIS_IS_L64XX(E7) - case 7: L6470_SET_KVAL_HOLD(E7); break; - #endif - } + 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 } diff --git a/Marlin/src/gcode/feature/L6470/M916-918.cpp b/Marlin/src/gcode/feature/L6470/M916-M918.cpp similarity index 99% rename from Marlin/src/gcode/feature/L6470/M916-918.cpp rename to Marlin/src/gcode/feature/L6470/M916-M918.cpp index 8d614603eda0..9e1f1b98da34 100644 --- a/Marlin/src/gcode/feature/L6470/M916-918.cpp +++ b/Marlin/src/gcode/feature/L6470/M916-M918.cpp @@ -309,7 +309,6 @@ void GcodeSuite::M917() { } DEBUG_ECHOLNPGM("."); reset_stepper_timeout(); // keep steppers powered - watchdog_refresh(); safe_delay(5000); status_composite_temp = 0; for (j = 0; j < driver_count; j++) { diff --git a/Marlin/src/gcode/feature/adc/M3426.cpp b/Marlin/src/gcode/feature/adc/M3426.cpp index 8205fa01f2bd..2820c8b88093 100644 --- a/Marlin/src/gcode/feature/adc/M3426.cpp +++ b/Marlin/src/gcode/feature/adc/M3426.cpp @@ -28,6 +28,8 @@ #include "../../../feature/adc/adc_mcp3426.h" +#define MCP3426_BASE_ADDR (0b1101 << 3) + /** * M3426: Read 16 bit (signed) value from I2C MCP3426 ADC device * @@ -36,12 +38,15 @@ * M3426 I 0 or 1, invert reply */ void GcodeSuite::M3426() { - uint8_t channel = parser.byteval('C', 1), // Select the channel 1 or 2 - gain = parser.byteval('G', 1); - const bool inverted = parser.byteval('I') == 1; + uint8_t channel = parser.byteval('C', 1), // Channel 1 or 2 + gain = parser.byteval('G', 1), // Gain 1, 2, 4, or 8 + address = parser.byteval('A', 3); // Address 0-7 (or 104-111) + const bool inverted = parser.boolval('I'); + + if (address <= 7) address += MCP3426_BASE_ADDR; - if (channel <= 2 && (gain == 1 || gain == 2 || gain == 4 || gain == 8)) { - int16_t result = mcp3426.ReadValue(channel, gain); + if (WITHIN(channel, 1, 2) && (gain == 1 || gain == 2 || gain == 4 || gain == 8) && WITHIN(address, MCP3426_BASE_ADDR, MCP3426_BASE_ADDR + 7)) { + int16_t result = mcp3426.ReadValue(channel, gain, address); if (mcp3426.Error == false) { if (inverted) { diff --git a/Marlin/src/gcode/feature/advance/M900.cpp b/Marlin/src/gcode/feature/advance/M900.cpp index 054ea3617f9b..8b59e88fb114 100644 --- a/Marlin/src/gcode/feature/advance/M900.cpp +++ b/Marlin/src/gcode/feature/advance/M900.cpp @@ -117,10 +117,10 @@ void GcodeSuite::M900() { #if EXTRUDERS < 2 SERIAL_ECHOLNPGM("Advance S", new_slot, " K", kref, "(S", !new_slot, " K", lref, ")"); #else - LOOP_L_N(i, EXTRUDERS) { - const bool slot = TEST(lin_adv_slot, i); - SERIAL_ECHOLNPGM("Advance T", i, " S", slot, " K", planner.extruder_advance_K[i], - "(S", !slot, " K", other_extruder_advance_K[i], ")"); + EXTRUDER_LOOP() { + const bool slot = TEST(lin_adv_slot, e); + SERIAL_ECHOLNPGM("Advance T", e, " S", slot, " K", planner.extruder_advance_K[e], + "(S", !slot, " K", other_extruder_advance_K[e], ")"); SERIAL_EOL(); } #endif @@ -132,9 +132,9 @@ void GcodeSuite::M900() { SERIAL_ECHOLNPGM("Advance K=", planner.extruder_advance_K[0]); #else SERIAL_ECHOPGM("Advance K"); - LOOP_L_N(i, EXTRUDERS) { - SERIAL_CHAR(' ', '0' + i, ':'); - SERIAL_DECIMAL(planner.extruder_advance_K[i]); + EXTRUDER_LOOP() { + SERIAL_CHAR(' ', '0' + e, ':'); + SERIAL_DECIMAL(planner.extruder_advance_K[e]); } SERIAL_EOL(); #endif @@ -150,9 +150,9 @@ void GcodeSuite::M900_report(const bool forReplay/*=true*/) { report_echo_start(forReplay); SERIAL_ECHOLNPGM(" M900 K", planner.extruder_advance_K[0]); #else - LOOP_L_N(i, EXTRUDERS) { + EXTRUDER_LOOP() { report_echo_start(forReplay); - SERIAL_ECHOLNPGM(" M900 T", i, " K", planner.extruder_advance_K[i]); + SERIAL_ECHOLNPGM(" M900 T", e, " K", planner.extruder_advance_K[e]); } #endif } diff --git a/Marlin/src/gcode/feature/clean/G12.cpp b/Marlin/src/gcode/feature/clean/G12.cpp index a0b87b1abc9e..999a9b10bd85 100644 --- a/Marlin/src/gcode/feature/clean/G12.cpp +++ b/Marlin/src/gcode/feature/clean/G12.cpp @@ -46,7 +46,8 @@ */ void GcodeSuite::G12() { // Don't allow nozzle cleaning without homing first - if (homing_needed_error()) return; + if (homing_needed_error(linear_bits & ~TERN0(NOZZLE_CLEAN_NO_Z, Z_AXIS) & ~TERN0(NOZZLE_CLEAN_NO_Y, Y_AXIS))) + return; #ifdef WIPE_SEQUENCE_COMMANDS if (!parser.seen_any()) { diff --git a/Marlin/src/gcode/feature/digipot/M907-M910.cpp b/Marlin/src/gcode/feature/digipot/M907-M910.cpp index 757cffd47383..95adde3ea532 100644 --- a/Marlin/src/gcode/feature/digipot/M907-M910.cpp +++ b/Marlin/src/gcode/feature/digipot/M907-M910.cpp @@ -39,7 +39,9 @@ #endif /** - * M907: Set digital trimpot motor current using axis codes X, Y, Z, E, B, S + * M907: Set digital trimpot motor current using axis codes X [Y] [Z] [E] + * B - Special case for 4th (E) axis + * S - Special case to set first 3 axes */ void GcodeSuite::M907() { #if HAS_MOTOR_CURRENT_SPI @@ -75,7 +77,7 @@ void GcodeSuite::M907() { if (parser.seenval('E')) stepper.set_digipot_current(2, parser.value_int()); #endif - #endif + #endif // HAS_MOTOR_CURRENT_PWM #if HAS_MOTOR_CURRENT_I2C // this one uses actual amps in floating point diff --git a/Marlin/src/gcode/feature/leds/M150.cpp b/Marlin/src/gcode/feature/leds/M150.cpp index f01c220d0131..95e7367b6e23 100644 --- a/Marlin/src/gcode/feature/leds/M150.cpp +++ b/Marlin/src/gcode/feature/leds/M150.cpp @@ -38,7 +38,7 @@ * I Set the NeoPixel index to affect. Default: All * * With NEOPIXEL2_SEPARATE: - * S The NeoPixel strip to set. Default is index 0. + * S The NeoPixel strip to set. Default: All. * * Examples: * diff --git a/Marlin/src/gcode/feature/pause/G60.cpp b/Marlin/src/gcode/feature/pause/G60.cpp index 4c7190091cfc..01b7d31e3e50 100644 --- a/Marlin/src/gcode/feature/pause/G60.cpp +++ b/Marlin/src/gcode/feature/pause/G60.cpp @@ -47,13 +47,16 @@ void GcodeSuite::G60() { SBI(saved_slots[slot >> 3], slot & 0x07); #if ENABLED(SAVED_POSITIONS_DEBUG) - DEBUG_ECHOPGM(STR_SAVED_POS " S", slot); + { + DEBUG_ECHOPGM(STR_SAVED_POS " S", slot, " :"); const xyze_pos_t &pos = stored_position[slot]; - DEBUG_ECHOLNPAIR_F_P( - LIST_N(DOUBLE(LOGICAL_AXES), SP_E_STR, pos.e, - PSTR(" : X"), pos.x, SP_Y_STR, pos.y, SP_Z_STR, pos.z, - SP_I_STR, pos.i, SP_J_STR, pos.j, SP_K_STR, pos.k) + DEBUG_ECHOLNPGM_P( + LIST_N(DOUBLE(LINEAR_AXES), PSTR(" : X"), pos.x, SP_Y_STR, pos.y, SP_Z_STR, pos.z, SP_I_STR, pos.i, SP_J_STR, pos.j, SP_K_STR, pos.k) + #if HAS_EXTRUDERS + , SP_E_LBL, pos.e + #endif ); + } #endif } diff --git a/Marlin/src/gcode/feature/pause/G61.cpp b/Marlin/src/gcode/feature/pause/G61.cpp index f3e5a2ab387a..e0e1983a2574 100644 --- a/Marlin/src/gcode/feature/pause/G61.cpp +++ b/Marlin/src/gcode/feature/pause/G61.cpp @@ -41,7 +41,7 @@ * * If XYZE are not given, default restore uses the smart blocking move. */ -void GcodeSuite::G61(void) { +void GcodeSuite::G61() { const uint8_t slot = parser.byteval('S'); @@ -68,7 +68,7 @@ void GcodeSuite::G61(void) { SYNC_E(stored_position[slot].e); } else { - if (parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", AXIS4_STR, AXIS5_STR, AXIS6_STR))) { + if (parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", STR_I, STR_J, STR_K))) { DEBUG_ECHOPGM(STR_RESTORING_POS " S", slot); LOOP_LINEAR_AXES(i) { destination[i] = parser.seen(AXIS_CHAR(i)) diff --git a/Marlin/src/gcode/feature/pause/M125.cpp b/Marlin/src/gcode/feature/pause/M125.cpp index bc31e1225d86..940e1b369bc6 100644 --- a/Marlin/src/gcode/feature/pause/M125.cpp +++ b/Marlin/src/gcode/feature/pause/M125.cpp @@ -49,6 +49,9 @@ * L = Override retract Length * X = Override park position X * Y = Override park position Y + * A = Override park position A (requires AXIS*_NAME 'A') + * B = Override park position B (requires AXIS*_NAME 'B') + * C = Override park position C (requires AXIS*_NAME 'C') * Z = Override Z raise * * With an LCD menu: @@ -60,9 +63,15 @@ void GcodeSuite::M125() { xyz_pos_t park_point = NOZZLE_PARK_POINT; - // Move XY axes to filament change position or given position - if (parser.seenval('X')) park_point.x = RAW_X_POSITION(parser.linearval('X')); - if (parser.seenval('Y')) park_point.y = RAW_X_POSITION(parser.linearval('Y')); + // Move to filament change position or given position + LINEAR_AXIS_CODE( + 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_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)) + ); // Lift Z axis if (parser.seenval('Z')) park_point.z = parser.linearval('Z'); @@ -76,7 +85,7 @@ void GcodeSuite::M125() { ui.pause_show_message(PAUSE_MESSAGE_PARKING, PAUSE_MODE_PAUSE_PRINT); // If possible, show an LCD prompt with the 'P' flag - const bool show_lcd = TERN0(HAS_LCD_MENU, parser.boolval('P')); + const bool show_lcd = TERN0(HAS_MARLINUI_MENU, parser.boolval('P')); if (pause_print(retract, park_point, show_lcd, 0)) { if (ENABLED(EXTENSIBLE_UI) || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT) || !sd_printing || show_lcd) { diff --git a/Marlin/src/gcode/feature/pause/M600.cpp b/Marlin/src/gcode/feature/pause/M600.cpp index 665967ca564d..9ba54ac448c5 100644 --- a/Marlin/src/gcode/feature/pause/M600.cpp +++ b/Marlin/src/gcode/feature/pause/M600.cpp @@ -34,7 +34,7 @@ #include "../../../module/tool_change.h" #endif -#if ENABLED(HAS_PRUSA_MMU2) +#if HAS_PRUSA_MMU2 #include "../../../feature/mmu/mmu2.h" #if ENABLED(MMU2_MENUS) #include "../../../lcd/menu/menu_mmu2.h" @@ -67,13 +67,13 @@ void GcodeSuite::M600() { #if ENABLED(MIXING_EXTRUDER) - const int8_t target_e_stepper = get_target_e_stepper_from_command(); - if (target_e_stepper < 0) return; + const int8_t eindex = get_target_e_stepper_from_command(); + if (eindex < 0) return; const uint8_t old_mixing_tool = mixer.get_current_vtool(); mixer.T(MIXER_DIRECT_SET_TOOL); - MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(target_e_stepper) ? 1.0 : 0.0); + MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(eindex) ? 1.0 : 0.0); mixer.normalize(); const int8_t target_extruder = active_extruder; @@ -101,10 +101,8 @@ void GcodeSuite::M600() { if (standardM600) ui.pause_show_message(PAUSE_MESSAGE_CHANGING, PAUSE_MODE_PAUSE_PRINT, target_extruder); - #if ENABLED(HOME_BEFORE_FILAMENT_CHANGE) - // If needed, home before parking for filament change - home_if_needed(true); - #endif + // If needed, home before parking for filament change + TERN_(HOME_BEFORE_FILAMENT_CHANGE, home_if_needed(true)); #if HAS_MULTI_EXTRUDER // Change toolhead if specified @@ -118,12 +116,15 @@ void GcodeSuite::M600() { xyz_pos_t park_point NOZZLE_PARK_POINT; - // Lift Z axis - if (parser.seenval('Z')) park_point.z = parser.linearval('Z'); - // Move XY axes to filament change position or given position - if (parser.seenval('X')) park_point.x = parser.linearval('X'); - if (parser.seenval('Y')) park_point.y = parser.linearval('Y'); + LINEAR_AXIS_CODE( + if (parser.seenval('X')) park_point.x = parser.linearval('X'), + if (parser.seenval('Y')) park_point.y = parser.linearval('Y'), + if (parser.seenval('Z')) park_point.z = parser.linearval('Z'), // Lift Z axis + if (parser.seenval(AXIS4_NAME)) park_point.i = parser.linearval(AXIS4_NAME), + if (parser.seenval(AXIS5_NAME)) park_point.j = parser.linearval(AXIS5_NAME), + if (parser.seenval(AXIS6_NAME)) park_point.k = parser.linearval(AXIS6_NAME) + ); #if HAS_HOTEND_OFFSET && NONE(DUAL_X_CARRIAGE, DELTA) park_point += hotend_offset[active_extruder]; diff --git a/Marlin/src/gcode/feature/pause/M603.cpp b/Marlin/src/gcode/feature/pause/M603.cpp index 6689749cfb4c..10d14012f890 100644 --- a/Marlin/src/gcode/feature/pause/M603.cpp +++ b/Marlin/src/gcode/feature/pause/M603.cpp @@ -72,7 +72,7 @@ void GcodeSuite::M603_report(const bool forReplay/*=true*/) { SERIAL_ECHOPGM(" M603 L", LINEAR_UNIT(fc_settings[0].load_length), " U", LINEAR_UNIT(fc_settings[0].unload_length), " ;"); say_units(); #else - LOOP_L_N(e, EXTRUDERS) { + EXTRUDER_LOOP() { report_echo_start(forReplay); SERIAL_ECHOPGM(" M603 T", e, " L", LINEAR_UNIT(fc_settings[e].load_length), " U", LINEAR_UNIT(fc_settings[e].unload_length), " ;"); say_units(); diff --git a/Marlin/src/gcode/feature/pause/M701_M702.cpp b/Marlin/src/gcode/feature/pause/M701_M702.cpp index 21e389a5f201..135b3d384ec0 100644 --- a/Marlin/src/gcode/feature/pause/M701_M702.cpp +++ b/Marlin/src/gcode/feature/pause/M701_M702.cpp @@ -60,13 +60,13 @@ void GcodeSuite::M701() { if (TERN0(NO_MOTION_BEFORE_HOMING, axes_should_home())) park_point.z = 0; #if ENABLED(MIXING_EXTRUDER) - const int8_t target_e_stepper = get_target_e_stepper_from_command(); - if (target_e_stepper < 0) return; + const int8_t eindex = get_target_e_stepper_from_command(); + if (eindex < 0) return; const uint8_t old_mixing_tool = mixer.get_current_vtool(); mixer.T(MIXER_DIRECT_SET_TOOL); - MIXER_STEPPER_LOOP(i) mixer.set_collector(i, (i == (uint8_t)target_e_stepper) ? 1.0 : 0.0); + MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(eindex) ? 1.0 : 0.0); mixer.normalize(); const int8_t target_extruder = active_extruder; @@ -165,10 +165,10 @@ void GcodeSuite::M702() { #endif if (seenT) { - const int8_t target_e_stepper = get_target_e_stepper_from_command(); - if (target_e_stepper < 0) return; + const int8_t eindex = get_target_e_stepper_from_command(); + if (eindex < 0) return; mixer.T(MIXER_DIRECT_SET_TOOL); - MIXER_STEPPER_LOOP(i) mixer.set_collector(i, (i == (uint8_t)target_e_stepper) ? 1.0 : 0.0); + MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(eindex) ? 1.0 : 0.0); mixer.normalize(); } diff --git a/Marlin/src/gcode/feature/power_monitor/M430.cpp b/Marlin/src/gcode/feature/power_monitor/M430.cpp index 642a75d0612a..0f3bb4091421 100644 --- a/Marlin/src/gcode/feature/power_monitor/M430.cpp +++ b/Marlin/src/gcode/feature/power_monitor/M430.cpp @@ -53,9 +53,7 @@ void GcodeSuite::M430() { SERIAL_ECHOLNPGM( #if ENABLED(POWER_MONITOR_CURRENT) "Current: ", power_monitor.getAmps(), "A" - #if ENABLED(POWER_MONITOR_VOLTAGE) - " " - #endif + TERN_(POWER_MONITOR_VOLTAGE, " ") #endif #if ENABLED(POWER_MONITOR_VOLTAGE) "Voltage: ", power_monitor.getVolts(), "V" diff --git a/Marlin/src/gcode/feature/powerloss/M1000.cpp b/Marlin/src/gcode/feature/powerloss/M1000.cpp index c086ca842c1d..1629a154bce3 100644 --- a/Marlin/src/gcode/feature/powerloss/M1000.cpp +++ b/Marlin/src/gcode/feature/powerloss/M1000.cpp @@ -33,8 +33,8 @@ #include "../../../lcd/extui/ui_api.h" #elif ENABLED(DWIN_CREALITY_LCD) #include "../../../lcd/e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../../../lcd/e3v2/proui/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "../../../lcd/e3v2/jyersui/dwin.h" // Temporary fix until it can be better implemented #endif @@ -54,7 +54,7 @@ inline void plr_error(FSTR_P const prefix) { #endif } -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU void lcd_power_loss_recovery_cancel(); #endif @@ -67,7 +67,7 @@ void GcodeSuite::M1000() { if (recovery.valid()) { if (parser.seen_test('S')) { - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU ui.goto_screen(menu_job_recovery); #elif HAS_DWIN_E3V2_BASIC recovery.dwin_flag = true; @@ -80,7 +80,7 @@ void GcodeSuite::M1000() { #endif } else if (parser.seen_test('C')) { - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU lcd_power_loss_recovery_cancel(); #else recovery.cancel(); diff --git a/Marlin/src/gcode/feature/powerloss/M413.cpp b/Marlin/src/gcode/feature/powerloss/M413.cpp index 0ccbfe6341ad..f6d82b0ad944 100644 --- a/Marlin/src/gcode/feature/powerloss/M413.cpp +++ b/Marlin/src/gcode/feature/powerloss/M413.cpp @@ -48,9 +48,8 @@ void GcodeSuite::M413() { if (parser.seen_test('W')) recovery.save(true); if (parser.seen_test('P')) recovery.purge(); if (parser.seen_test('D')) recovery.debug(F("M413")); - #if PIN_EXISTS(POWER_LOSS) - if (parser.seen_test('O')) recovery._outage(); - #endif + if (parser.seen_test('O')) recovery._outage(true); + if (parser.seen_test('C')) (void)recovery.check(); if (parser.seen_test('E')) SERIAL_ECHOF(recovery.exists() ? F("PLR Exists\n") : F("No PLR\n")); if (parser.seen_test('V')) SERIAL_ECHOF(recovery.valid() ? F("Valid\n") : F("Invalid\n")); #endif diff --git a/Marlin/src/gcode/feature/trinamic/M569.cpp b/Marlin/src/gcode/feature/trinamic/M569.cpp index cb33d46d2528..7bfedf8c7210 100644 --- a/Marlin/src/gcode/feature/trinamic/M569.cpp +++ b/Marlin/src/gcode/feature/trinamic/M569.cpp @@ -24,6 +24,10 @@ #if HAS_STEALTHCHOP +#if AXIS_COLLISION('I') + #error "M569 parameter collision with axis name." +#endif + #include "../../gcode.h" #include "../../../feature/tmc_util.h" #include "../../../module/stepper/indirection.h" @@ -40,35 +44,35 @@ void tmc_set_stealthChop(TMC &st, const bool enable) { st.refresh_stepping_mode(); } -static void set_stealth_status(const bool enable, const int8_t target_e_stepper) { +static void set_stealth_status(const bool enable, const int8_t eindex) { #define TMC_SET_STEALTH(Q) tmc_set_stealthChop(stepper##Q, enable) - #if X_HAS_STEALTHCHOP || Y_HAS_STEALTHCHOP || Z_HAS_STEALTHCHOP \ - || I_HAS_STEALTHCHOP || J_HAS_STEALTHCHOP || K_HAS_STEALTHCHOP \ - || X2_HAS_STEALTHCHOP || Y2_HAS_STEALTHCHOP || Z2_HAS_STEALTHCHOP || Z3_HAS_STEALTHCHOP || Z4_HAS_STEALTHCHOP - const uint8_t index = parser.byteval('I'); + #if X2_HAS_STEALTHCHOP || Y2_HAS_STEALTHCHOP || Z2_HAS_STEALTHCHOP || Z3_HAS_STEALTHCHOP || Z4_HAS_STEALTHCHOP + const int8_t index = parser.byteval('I', -1); + #else + constexpr int8_t index = -1; #endif LOOP_LOGICAL_AXES(i) if (parser.seen(axis_codes[i])) { switch (i) { case X_AXIS: - TERN_(X_HAS_STEALTHCHOP, if (index == 0) TMC_SET_STEALTH(X)); - TERN_(X2_HAS_STEALTHCHOP, if (index == 1) TMC_SET_STEALTH(X2)); + TERN_(X_HAS_STEALTHCHOP, if (index < 0 || index == 0) TMC_SET_STEALTH(X)); + TERN_(X2_HAS_STEALTHCHOP, if (index < 0 || index == 1) TMC_SET_STEALTH(X2)); break; #if HAS_Y_AXIS case Y_AXIS: - TERN_(Y_HAS_STEALTHCHOP, if (index == 0) TMC_SET_STEALTH(Y)); - TERN_(Y2_HAS_STEALTHCHOP, if (index == 1) TMC_SET_STEALTH(Y2)); + TERN_(Y_HAS_STEALTHCHOP, if (index < 0 || index == 0) TMC_SET_STEALTH(Y)); + TERN_(Y2_HAS_STEALTHCHOP, if (index < 0 || index == 1) TMC_SET_STEALTH(Y2)); break; #endif #if HAS_Z_AXIS case Z_AXIS: - TERN_(Z_HAS_STEALTHCHOP, if (index == 0) TMC_SET_STEALTH(Z)); - TERN_(Z2_HAS_STEALTHCHOP, if (index == 1) TMC_SET_STEALTH(Z2)); - TERN_(Z3_HAS_STEALTHCHOP, if (index == 2) TMC_SET_STEALTH(Z3)); - TERN_(Z4_HAS_STEALTHCHOP, if (index == 3) TMC_SET_STEALTH(Z4)); + TERN_(Z_HAS_STEALTHCHOP, if (index < 0 || index == 0) TMC_SET_STEALTH(Z)); + TERN_(Z2_HAS_STEALTHCHOP, if (index < 0 || index == 1) TMC_SET_STEALTH(Z2)); + TERN_(Z3_HAS_STEALTHCHOP, if (index < 0 || index == 2) TMC_SET_STEALTH(Z3)); + TERN_(Z4_HAS_STEALTHCHOP, if (index < 0 || index == 3) TMC_SET_STEALTH(Z4)); break; #endif @@ -84,17 +88,14 @@ static void set_stealth_status(const bool enable, const int8_t target_e_stepper) #if E_STEPPERS case E_AXIS: { - if (target_e_stepper < 0) return; - switch (target_e_stepper) { - TERN_(E0_HAS_STEALTHCHOP, case 0: TMC_SET_STEALTH(E0); break;) - TERN_(E1_HAS_STEALTHCHOP, case 1: TMC_SET_STEALTH(E1); break;) - TERN_(E2_HAS_STEALTHCHOP, case 2: TMC_SET_STEALTH(E2); break;) - TERN_(E3_HAS_STEALTHCHOP, case 3: TMC_SET_STEALTH(E3); break;) - TERN_(E4_HAS_STEALTHCHOP, case 4: TMC_SET_STEALTH(E4); break;) - TERN_(E5_HAS_STEALTHCHOP, case 5: TMC_SET_STEALTH(E5); break;) - TERN_(E6_HAS_STEALTHCHOP, case 6: TMC_SET_STEALTH(E6); break;) - TERN_(E7_HAS_STEALTHCHOP, case 7: TMC_SET_STEALTH(E7); break;) - } + TERN_(E0_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 0) TMC_SET_STEALTH(E0)); + TERN_(E1_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 1) TMC_SET_STEALTH(E1)); + TERN_(E2_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 2) TMC_SET_STEALTH(E2)); + TERN_(E3_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 3) TMC_SET_STEALTH(E3)); + TERN_(E4_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 4) TMC_SET_STEALTH(E4)); + TERN_(E5_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 5) TMC_SET_STEALTH(E5)); + TERN_(E6_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 6) TMC_SET_STEALTH(E6)); + TERN_(E7_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 7) TMC_SET_STEALTH(E7)); } break; #endif } @@ -133,7 +134,7 @@ static void say_stealth_status() { */ void GcodeSuite::M569() { if (parser.seen('S')) - set_stealth_status(parser.value_bool(), get_target_e_stepper_from_command(0)); + set_stealth_status(parser.value_bool(), get_target_e_stepper_from_command(-2)); else say_stealth_status(); } diff --git a/Marlin/src/gcode/feature/trinamic/M906.cpp b/Marlin/src/gcode/feature/trinamic/M906.cpp index f28718c831ba..c85d0be8a19a 100644 --- a/Marlin/src/gcode/feature/trinamic/M906.cpp +++ b/Marlin/src/gcode/feature/trinamic/M906.cpp @@ -28,6 +28,12 @@ #include "../../../feature/tmc_util.h" #include "../../../module/stepper/indirection.h" +template +static void tmc_print_current(TMC &st) { + st.printLabel(); + SERIAL_ECHOLNPGM(" driver current: ", st.getMilliamps()); +} + /** * M906: Set motor current in milliamps. * @@ -35,6 +41,9 @@ * X[current] - Set mA current for X driver(s) * Y[current] - Set mA current for Y driver(s) * Z[current] - Set mA current for Z driver(s) + * A[current] - Set mA current for A driver(s) (Requires AXIS*_NAME 'A') + * B[current] - Set mA current for B driver(s) (Requires AXIS*_NAME 'B') + * C[current] - Set mA current for C driver(s) (Requires AXIS*_NAME 'C') * E[current] - Set mA current for E driver(s) * * I[index] - Axis sub-index (Omit or 0 for X, Y, Z; 1 for X2, Y2, Z2; 2 for Z3; 3 for Z4.) @@ -48,46 +57,50 @@ void GcodeSuite::M906() { bool report = true; - #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) || AXIS_IS_TMC(I) || AXIS_IS_TMC(J) || AXIS_IS_TMC(K) - const uint8_t index = parser.byteval('I'); + #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) + const int8_t index = parser.byteval('I', -1); + #elif AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) + constexpr int8_t index = -1; #endif LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(axis_codes[i])) { report = false; switch (i) { - case X_AXIS: - #if AXIS_IS_TMC(X) - if (index == 0) TMC_SET_CURRENT(X); - #endif - #if AXIS_IS_TMC(X2) - if (index == 1) TMC_SET_CURRENT(X2); - #endif - break; + #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) + case X_AXIS: + #if AXIS_IS_TMC(X) + if (index < 0 || index == 0) TMC_SET_CURRENT(X); + #endif + #if AXIS_IS_TMC(X2) + if (index < 0 || index == 1) TMC_SET_CURRENT(X2); + #endif + break; + #endif - #if HAS_Y_AXIS + #if AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2) case Y_AXIS: #if AXIS_IS_TMC(Y) - if (index == 0) TMC_SET_CURRENT(Y); + if (index < 0 || index == 0) TMC_SET_CURRENT(Y); #endif #if AXIS_IS_TMC(Y2) - if (index == 1) TMC_SET_CURRENT(Y2); + if (index < 0 || index == 1) TMC_SET_CURRENT(Y2); #endif break; #endif - #if HAS_Z_AXIS + #if AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) case Z_AXIS: #if AXIS_IS_TMC(Z) - if (index == 0) TMC_SET_CURRENT(Z); + if (index < 0 || index == 0) TMC_SET_CURRENT(Z); #endif #if AXIS_IS_TMC(Z2) - if (index == 1) TMC_SET_CURRENT(Z2); + if (index < 0 || index == 1) TMC_SET_CURRENT(Z2); #endif #if AXIS_IS_TMC(Z3) - if (index == 2) TMC_SET_CURRENT(Z3); + if (index < 0 || index == 2) TMC_SET_CURRENT(Z3); #endif #if AXIS_IS_TMC(Z4) - if (index == 3) TMC_SET_CURRENT(Z4); + if (index < 0 || index == 3) TMC_SET_CURRENT(Z4); #endif break; #endif @@ -102,36 +115,33 @@ void GcodeSuite::M906() { case K_AXIS: TMC_SET_CURRENT(K); break; #endif - #if E_STEPPERS + #if AXIS_IS_TMC(E0) || AXIS_IS_TMC(E1) || AXIS_IS_TMC(E2) || AXIS_IS_TMC(E3) || AXIS_IS_TMC(E4) || AXIS_IS_TMC(E5) || AXIS_IS_TMC(E6) || AXIS_IS_TMC(E7) case E_AXIS: { - const int8_t target_e_stepper = get_target_e_stepper_from_command(0); - if (target_e_stepper < 0) return; - switch (target_e_stepper) { - #if AXIS_IS_TMC(E0) - case 0: TMC_SET_CURRENT(E0); break; - #endif - #if AXIS_IS_TMC(E1) - case 1: TMC_SET_CURRENT(E1); break; - #endif - #if AXIS_IS_TMC(E2) - case 2: TMC_SET_CURRENT(E2); break; - #endif - #if AXIS_IS_TMC(E3) - case 3: TMC_SET_CURRENT(E3); break; - #endif - #if AXIS_IS_TMC(E4) - case 4: TMC_SET_CURRENT(E4); break; - #endif - #if AXIS_IS_TMC(E5) - case 5: TMC_SET_CURRENT(E5); break; - #endif - #if AXIS_IS_TMC(E6) - case 6: TMC_SET_CURRENT(E6); break; - #endif - #if AXIS_IS_TMC(E7) - case 7: TMC_SET_CURRENT(E7); break; - #endif - } + const int8_t eindex = get_target_e_stepper_from_command(-2); + #if AXIS_IS_TMC(E0) + if (eindex < 0 || eindex == 0) TMC_SET_CURRENT(E0); + #endif + #if AXIS_IS_TMC(E1) + if (eindex < 0 || eindex == 1) TMC_SET_CURRENT(E1); + #endif + #if AXIS_IS_TMC(E2) + if (eindex < 0 || eindex == 2) TMC_SET_CURRENT(E2); + #endif + #if AXIS_IS_TMC(E3) + if (eindex < 0 || eindex == 3) TMC_SET_CURRENT(E3); + #endif + #if AXIS_IS_TMC(E4) + if (eindex < 0 || eindex == 4) TMC_SET_CURRENT(E4); + #endif + #if AXIS_IS_TMC(E5) + if (eindex < 0 || eindex == 5) TMC_SET_CURRENT(E5); + #endif + #if AXIS_IS_TMC(E6) + if (eindex < 0 || eindex == 6) TMC_SET_CURRENT(E6); + #endif + #if AXIS_IS_TMC(E7) + if (eindex < 0 || eindex == 7) TMC_SET_CURRENT(E7); + #endif } break; #endif } diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp index 3f83558fd428..987c20b157bf 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp @@ -38,19 +38,19 @@ #if M91x_USE(X) || M91x_USE(X2) #define M91x_SOME_X 1 #endif - #if LINEAR_AXES >= 2 && (M91x_USE(Y) || M91x_USE(Y2)) + #if HAS_Y_AXIS && (M91x_USE(Y) || M91x_USE(Y2)) #define M91x_SOME_Y 1 #endif #if HAS_Z_AXIS && (M91x_USE(Z) || M91x_USE(Z2) || M91x_USE(Z3) || M91x_USE(Z4)) #define M91x_SOME_Z 1 #endif - #if LINEAR_AXES >= 4 && M91x_USE(I) + #if HAS_I_AXIS && M91x_USE(I) #define M91x_USE_I 1 #endif - #if LINEAR_AXES >= 5 && M91x_USE(J) + #if HAS_J_AXIS && M91x_USE(J) #define M91x_USE_J 1 #endif - #if LINEAR_AXES >= 6 && M91x_USE(K) + #if HAS_K_AXIS && M91x_USE(K) #define M91x_USE_K 1 #endif @@ -62,6 +62,21 @@ #error "MONITOR_DRIVER_STATUS requires at least one TMC2130, 2160, 2208, 2209, 2660, 5130, or 5160." #endif + template + static void tmc_report_otpw(TMC &st) { + st.printLabel(); + SERIAL_ECHOPGM(" temperature prewarn triggered: "); + serialprint_truefalse(st.getOTPW()); + SERIAL_EOL(); + } + + template + static void tmc_clear_otpw(TMC &st) { + st.clear_otpw(); + st.printLabel(); + SERIAL_ECHOLNPGM(" prewarn flag cleared"); + } + /** * M911: Report TMC stepper driver overtemperature pre-warn flag * This flag is held by the library, persisting until cleared by M912 @@ -223,11 +238,17 @@ #endif // MONITOR_DRIVER_STATUS -/** - * M913: Set HYBRID_THRESHOLD speed. - */ #if ENABLED(HYBRID_THRESHOLD) + template + static void tmc_print_pwmthrs(TMC &st) { + st.printLabel(); + SERIAL_ECHOLNPGM(" stealthChop max speed: ", st.get_pwm_thrs()); + } + + /** + * M913: Set HYBRID_THRESHOLD speed. + */ void GcodeSuite::M913() { #define TMC_SAY_PWMTHRS(A,Q) tmc_print_pwmthrs(stepper##Q) #define TMC_SET_PWMTHRS(A,Q) stepper##Q.set_pwm_thrs(value) @@ -235,20 +256,36 @@ #define TMC_SET_PWMTHRS_E(E) stepperE##E.set_pwm_thrs(value) bool report = true; - #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) || AXIS_IS_TMC(I) || AXIS_IS_TMC(J) || AXIS_IS_TMC(K) + #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) const uint8_t index = parser.byteval('I'); + #elif AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) + constexpr uint8_t index = 0; #endif LOOP_LOGICAL_AXES(i) if (int32_t value = parser.longval(axis_codes[i])) { report = false; switch (i) { - 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)); - break; - 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)); - break; + #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)); + 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)); + break; + #endif + + #if Z_HAS_STEALTHCHOP || Z2_HAS_STEALTHCHOP || Z3_HAS_STEALTHCHOP || Z4_HAS_STEALTHCHOP + case Z_AXIS: + TERN_(Z_HAS_STEALTHCHOP, if (index < 2) TMC_SET_PWMTHRS(Z,Z)); + TERN_(Z2_HAS_STEALTHCHOP, if (!index || index == 2) TMC_SET_PWMTHRS(Z,Z2)); + TERN_(Z3_HAS_STEALTHCHOP, if (!index || index == 3) TMC_SET_PWMTHRS(Z,Z3)); + TERN_(Z4_HAS_STEALTHCHOP, if (!index || index == 4) TMC_SET_PWMTHRS(Z,Z4)); + break; + #endif #if I_HAS_STEALTHCHOP case I_AXIS: TMC_SET_PWMTHRS(I,I); break; @@ -260,26 +297,17 @@ case K_AXIS: TMC_SET_PWMTHRS(K,K); break; #endif - case Z_AXIS: - TERN_(Z_HAS_STEALTHCHOP, if (index < 2) TMC_SET_PWMTHRS(Z,Z)); - TERN_(Z2_HAS_STEALTHCHOP, if (index == 0 || index == 2) TMC_SET_PWMTHRS(Z,Z2)); - TERN_(Z3_HAS_STEALTHCHOP, if (index == 0 || index == 3) TMC_SET_PWMTHRS(Z,Z3)); - TERN_(Z4_HAS_STEALTHCHOP, if (index == 0 || index == 4) TMC_SET_PWMTHRS(Z,Z4)); - break; - #if E_STEPPERS + #if E0_HAS_STEALTHCHOP || E1_HAS_STEALTHCHOP || E2_HAS_STEALTHCHOP || E3_HAS_STEALTHCHOP || E4_HAS_STEALTHCHOP || E5_HAS_STEALTHCHOP || E6_HAS_STEALTHCHOP || E7_HAS_STEALTHCHOP case E_AXIS: { - const int8_t target_e_stepper = get_target_e_stepper_from_command(0); - if (target_e_stepper < 0) return; - switch (target_e_stepper) { - TERN_(E0_HAS_STEALTHCHOP, case 0: TMC_SET_PWMTHRS_E(0); break;) - TERN_(E1_HAS_STEALTHCHOP, case 1: TMC_SET_PWMTHRS_E(1); break;) - TERN_(E2_HAS_STEALTHCHOP, case 2: TMC_SET_PWMTHRS_E(2); break;) - TERN_(E3_HAS_STEALTHCHOP, case 3: TMC_SET_PWMTHRS_E(3); break;) - TERN_(E4_HAS_STEALTHCHOP, case 4: TMC_SET_PWMTHRS_E(4); break;) - TERN_(E5_HAS_STEALTHCHOP, case 5: TMC_SET_PWMTHRS_E(5); break;) - TERN_(E6_HAS_STEALTHCHOP, case 6: TMC_SET_PWMTHRS_E(6); break;) - TERN_(E7_HAS_STEALTHCHOP, case 7: TMC_SET_PWMTHRS_E(7); break;) - } + const int8_t eindex = get_target_e_stepper_from_command(-2); + TERN_(E0_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 0) TMC_SET_PWMTHRS_E(0)); + TERN_(E1_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 1) TMC_SET_PWMTHRS_E(1)); + TERN_(E2_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 2) TMC_SET_PWMTHRS_E(2)); + TERN_(E3_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 3) TMC_SET_PWMTHRS_E(3)); + TERN_(E4_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 4) TMC_SET_PWMTHRS_E(4)); + TERN_(E5_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 5) TMC_SET_PWMTHRS_E(5)); + TERN_(E6_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 6) TMC_SET_PWMTHRS_E(6)); + TERN_(E7_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 7) TMC_SET_PWMTHRS_E(7)); } break; #endif // E_STEPPERS } @@ -334,7 +362,7 @@ #if X2_HAS_STEALTHCHOP || Y2_HAS_STEALTHCHOP || Z2_HAS_STEALTHCHOP say_M913(forReplay); - SERIAL_ECHOPGM(" I1"); + SERIAL_ECHOPGM(" I2"); #if X2_HAS_STEALTHCHOP SERIAL_ECHOPGM_P(SP_X_STR, stepperX2.get_pwm_thrs()); #endif @@ -349,12 +377,12 @@ #if Z3_HAS_STEALTHCHOP say_M913(forReplay); - SERIAL_ECHOLNPGM(" I2 Z", stepperZ3.get_pwm_thrs()); + SERIAL_ECHOLNPGM(" I3 Z", stepperZ3.get_pwm_thrs()); #endif #if Z4_HAS_STEALTHCHOP say_M913(forReplay); - SERIAL_ECHOLNPGM(" I3 Z", stepperZ4.get_pwm_thrs()); + SERIAL_ECHOLNPGM(" I4 Z", stepperZ4.get_pwm_thrs()); #endif #if I_HAS_STEALTHCHOP @@ -407,11 +435,18 @@ #endif // HYBRID_THRESHOLD -/** - * M914: Set StallGuard sensitivity. - */ #if USE_SENSORLESS + template + static void tmc_print_sgt(TMC &st) { + st.printLabel(); + SERIAL_ECHOPGM(" homing sensitivity: "); + SERIAL_PRINTLN(st.homing_threshold(), PrintBase::Dec); + } + + /** + * M914: Set StallGuard sensitivity. + */ void GcodeSuite::M914() { bool report = true; @@ -422,92 +457,48 @@ switch (i) { #if X_SENSORLESS case X_AXIS: - #if AXIS_HAS_STALLGUARD(X) - if (index < 2) stepperX.homing_threshold(value); - #endif - #if AXIS_HAS_STALLGUARD(X2) - if (!(index & 1)) stepperX2.homing_threshold(value); - #endif + if (index < 2) stepperX.homing_threshold(value); + TERN_(X2_SENSORLESS, if (!(index & 1)) stepperX2.homing_threshold(value)); break; #endif #if Y_SENSORLESS case Y_AXIS: - #if AXIS_HAS_STALLGUARD(Y) - if (index < 2) stepperY.homing_threshold(value); - #endif - #if AXIS_HAS_STALLGUARD(Y2) - if (!(index & 1)) stepperY2.homing_threshold(value); - #endif + if (index < 2) stepperY.homing_threshold(value); + TERN_(Y2_SENSORLESS, if (!(index & 1)) stepperY2.homing_threshold(value)); break; #endif #if Z_SENSORLESS case Z_AXIS: - #if AXIS_HAS_STALLGUARD(Z) - if (index < 2) stepperZ.homing_threshold(value); - #endif - #if AXIS_HAS_STALLGUARD(Z2) - if (index == 0 || index == 2) stepperZ2.homing_threshold(value); - #endif - #if AXIS_HAS_STALLGUARD(Z3) - if (index == 0 || index == 3) stepperZ3.homing_threshold(value); - #endif - #if AXIS_HAS_STALLGUARD(Z4) - if (index == 0 || index == 4) stepperZ4.homing_threshold(value); - #endif + if (index < 2) stepperZ.homing_threshold(value); + TERN_(Z2_SENSORLESS, if (!index || index == 2) stepperZ2.homing_threshold(value)); + TERN_(Z3_SENSORLESS, if (!index || index == 3) stepperZ3.homing_threshold(value)); + TERN_(Z4_SENSORLESS, if (!index || index == 4) stepperZ4.homing_threshold(value)); break; #endif - #if I_SENSORLESS && AXIS_HAS_STALLGUARD(I) + #if I_SENSORLESS case I_AXIS: stepperI.homing_threshold(value); break; #endif - #if J_SENSORLESS && AXIS_HAS_STALLGUARD(J) + #if J_SENSORLESS case J_AXIS: stepperJ.homing_threshold(value); break; #endif - #if K_SENSORLESS && AXIS_HAS_STALLGUARD(K) + #if K_SENSORLESS case K_AXIS: stepperK.homing_threshold(value); break; #endif } } if (report) { - #if X_SENSORLESS - #if AXIS_HAS_STALLGUARD(X) - tmc_print_sgt(stepperX); - #endif - #if AXIS_HAS_STALLGUARD(X2) - tmc_print_sgt(stepperX2); - #endif - #endif - #if Y_SENSORLESS - #if AXIS_HAS_STALLGUARD(Y) - tmc_print_sgt(stepperY); - #endif - #if AXIS_HAS_STALLGUARD(Y2) - tmc_print_sgt(stepperY2); - #endif - #endif - #if Z_SENSORLESS - #if AXIS_HAS_STALLGUARD(Z) - tmc_print_sgt(stepperZ); - #endif - #if AXIS_HAS_STALLGUARD(Z2) - tmc_print_sgt(stepperZ2); - #endif - #if AXIS_HAS_STALLGUARD(Z3) - tmc_print_sgt(stepperZ3); - #endif - #if AXIS_HAS_STALLGUARD(Z4) - tmc_print_sgt(stepperZ4); - #endif - #endif - #if I_SENSORLESS && AXIS_HAS_STALLGUARD(I) - tmc_print_sgt(stepperI); - #endif - #if J_SENSORLESS && AXIS_HAS_STALLGUARD(J) - tmc_print_sgt(stepperJ); - #endif - #if K_SENSORLESS && AXIS_HAS_STALLGUARD(K) - tmc_print_sgt(stepperK); - #endif + TERN_(X_SENSORLESS, tmc_print_sgt(stepperX)); + TERN_(X2_SENSORLESS, tmc_print_sgt(stepperX2)); + TERN_(Y_SENSORLESS, tmc_print_sgt(stepperY)); + TERN_(Y2_SENSORLESS, tmc_print_sgt(stepperY2)); + TERN_(Z_SENSORLESS, tmc_print_sgt(stepperZ)); + TERN_(Z2_SENSORLESS, tmc_print_sgt(stepperZ2)); + TERN_(Z3_SENSORLESS, tmc_print_sgt(stepperZ3)); + TERN_(Z4_SENSORLESS, tmc_print_sgt(stepperZ4)); + TERN_(I_SENSORLESS, tmc_print_sgt(stepperI)); + TERN_(J_SENSORLESS, tmc_print_sgt(stepperJ)); + TERN_(K_SENSORLESS, tmc_print_sgt(stepperK)); } } @@ -535,7 +526,7 @@ #if X2_SENSORLESS || Y2_SENSORLESS || Z2_SENSORLESS say_M914(forReplay); - SERIAL_ECHOPGM(" I1"); + SERIAL_ECHOPGM(" I2"); #if X2_SENSORLESS SERIAL_ECHOPGM_P(SP_X_STR, stepperX2.homing_threshold()); #endif @@ -550,12 +541,12 @@ #if Z3_SENSORLESS say_M914(forReplay); - SERIAL_ECHOLNPGM(" I2 Z", stepperZ3.homing_threshold()); + SERIAL_ECHOLNPGM(" I3 Z", stepperZ3.homing_threshold()); #endif #if Z4_SENSORLESS say_M914(forReplay); - SERIAL_ECHOLNPGM(" I3 Z", stepperZ4.homing_threshold()); + SERIAL_ECHOLNPGM(" I4 Z", stepperZ4.homing_threshold()); #endif #if I_SENSORLESS diff --git a/Marlin/src/gcode/feature/trinamic/M919.cpp b/Marlin/src/gcode/feature/trinamic/M919.cpp new file mode 100644 index 000000000000..d4ba4f74eaa1 --- /dev/null +++ b/Marlin/src/gcode/feature/trinamic/M919.cpp @@ -0,0 +1,266 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 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_TRINAMIC_CONFIG + +#if AXIS_COLLISION('I') + #error "M919 parameter collision with axis name." +#endif + +#include "../../gcode.h" +#include "../../../feature/tmc_util.h" +#include "../../../module/stepper/indirection.h" + +#define DEBUG_OUT ENABLED(MARLIN_DEV_MODE) +#include "../../../core/debug_out.h" + +template +static void tmc_print_chopper_time(TMC &st) { + st.printLabel(); + SERIAL_ECHOLNPGM(" chopper .toff: ", st.toff(), + " .hend: ", st.hysteresis_end(), + " .hstrt: ", st.hysteresis_start()); +} + +/** + * M919: Set TMC stepper driver chopper times + * + * Parameters: + * XYZ...E - Selected axes + * I[index] - Axis sub-index (Omit for all XYZ steppers, 1 for X2, Y2, Z2; 2 for Z3; 3 for Z4) + * T[index] - Extruder index (Zero-based. Omit for all extruders.) + * O - time-off [ 1..15] + * P - hysteresis_end [-3..12] + * S - hysteresis_start [ 1...8] + * + * With no parameters report chopper times for all axes + */ +void GcodeSuite::M919() { + bool err = false; + + int8_t toff = int8_t(parser.intval('O', -127)); + if (toff != -127) { + if (WITHIN(toff, 1, 15)) + DEBUG_ECHOLNPGM(".toff: ", toff); + else { + SERIAL_ECHOLNPGM("?O out of range (1..15)"); + err = true; + } + } + + int8_t hend = int8_t(parser.intval('P', -127)); + if (hend != -127) { + if (WITHIN(hend, -3, 12)) + DEBUG_ECHOLNPGM(".hend: ", hend); + else { + SERIAL_ECHOLNPGM("?P out of range (-3..12)"); + err = true; + } + } + + int8_t hstrt = int8_t(parser.intval('S', -127)); + if (hstrt != -127) { + if (WITHIN(hstrt, 1, 8)) + DEBUG_ECHOLNPGM(".hstrt: ", hstrt); + else { + SERIAL_ECHOLNPGM("?S out of range (1..8)"); + err = true; + } + } + + if (err) return; + + #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) + const int8_t index = parser.byteval('I'); + #elif AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) + constexpr int8_t index = -1; + #endif + + auto make_chopper_timing = [](chopper_timing_t bct, const int8_t toff, const int8_t hend, const int8_t hstrt) { + chopper_timing_t uct = bct; + if (toff != -127) uct.toff = toff; + if (hend != -127) uct.hend = hend; + if (hstrt != -127) uct.hstrt = hstrt; + return uct; + }; + + #define TMC_SET_CHOPPER_TIME(Q) stepper##Q.set_chopper_times(make_chopper_timing(CHOPPER_TIMING_##Q, toff, hend, hstrt)) + + #if AXIS_IS_TMC(E0) || AXIS_IS_TMC(E1) || AXIS_IS_TMC(E2) || AXIS_IS_TMC(E3) || AXIS_IS_TMC(E4) || AXIS_IS_TMC(E5) || AXIS_IS_TMC(E6) || AXIS_IS_TMC(E7) + #define HAS_E_CHOPPER 1 + int8_t eindex = -1; + #endif + bool report = true; + LOOP_LOGICAL_AXES(i) if (parser.seen_test(axis_codes[i])) { + report = false; + + // Get the chopper timing for the specified axis and index + switch (i) { + default: // A specified axis isn't Trinamic + SERIAL_ECHOLNPGM("?Axis ", AS_CHAR(axis_codes[i]), " has no TMC drivers."); + break; + + #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) + case X_AXIS: + #if AXIS_IS_TMC(X) + if (index <= 0) TMC_SET_CHOPPER_TIME(X); + #endif + #if AXIS_IS_TMC(X2) + if (index < 0 || index == 1) TMC_SET_CHOPPER_TIME(X2); + #endif + break; + #endif + + #if AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2) + case Y_AXIS: + #if AXIS_IS_TMC(Y) + if (index <= 0) TMC_SET_CHOPPER_TIME(Y); + #endif + #if AXIS_IS_TMC(Y2) + if (index < 0 || index == 1) TMC_SET_CHOPPER_TIME(Y2); + #endif + break; + #endif + + #if AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) + case Z_AXIS: + #if AXIS_IS_TMC(Z) + if (index <= 0) TMC_SET_CHOPPER_TIME(Z); + #endif + #if AXIS_IS_TMC(Z2) + if (index < 0 || index == 1) TMC_SET_CHOPPER_TIME(Z2); + #endif + #if AXIS_IS_TMC(Z3) + if (index < 0 || index == 2) TMC_SET_CHOPPER_TIME(Z3); + #endif + #if AXIS_IS_TMC(Z4) + if (index < 0 || index == 3) TMC_SET_CHOPPER_TIME(Z4); + #endif + break; + #endif + + #if AXIS_IS_TMC(I) + case I_AXIS: TMC_SET_CHOPPER_TIME(I); break; + #endif + #if AXIS_IS_TMC(J) + case J_AXIS: TMC_SET_CHOPPER_TIME(J); break; + #endif + #if AXIS_IS_TMC(K) + case K_AXIS: TMC_SET_CHOPPER_TIME(K); break; + #endif + + #if HAS_E_CHOPPER + case E_AXIS: { + #if AXIS_IS_TMC(E0) + if (eindex <= 0) TMC_SET_CHOPPER_TIME(E0); + #endif + #if AXIS_IS_TMC(E1) + if (eindex < 0 || eindex == 1) TMC_SET_CHOPPER_TIME(E1); + #endif + #if AXIS_IS_TMC(E2) + if (eindex < 0 || eindex == 2) TMC_SET_CHOPPER_TIME(E2); + #endif + #if AXIS_IS_TMC(E3) + if (eindex < 0 || eindex == 3) TMC_SET_CHOPPER_TIME(E3); + #endif + #if AXIS_IS_TMC(E4) + if (eindex < 0 || eindex == 4) TMC_SET_CHOPPER_TIME(E4); + #endif + #if AXIS_IS_TMC(E5) + if (eindex < 0 || eindex == 5) TMC_SET_CHOPPER_TIME(E5); + #endif + #if AXIS_IS_TMC(E6) + if (eindex < 0 || eindex == 6) TMC_SET_CHOPPER_TIME(E6); + #endif + #if AXIS_IS_TMC(E7) + if (eindex < 0 || eindex == 7) TMC_SET_CHOPPER_TIME(E7); + #endif + } break; + #endif + } + } + + if (report) { + #define TMC_SAY_CHOPPER_TIME(Q) tmc_print_chopper_time(stepper##Q) + #if AXIS_IS_TMC(X) + TMC_SAY_CHOPPER_TIME(X); + #endif + #if AXIS_IS_TMC(X2) + TMC_SAY_CHOPPER_TIME(X2); + #endif + #if AXIS_IS_TMC(Y) + TMC_SAY_CHOPPER_TIME(Y); + #endif + #if AXIS_IS_TMC(Y2) + TMC_SAY_CHOPPER_TIME(Y2); + #endif + #if AXIS_IS_TMC(Z) + TMC_SAY_CHOPPER_TIME(Z); + #endif + #if AXIS_IS_TMC(Z2) + TMC_SAY_CHOPPER_TIME(Z2); + #endif + #if AXIS_IS_TMC(Z3) + TMC_SAY_CHOPPER_TIME(Z3); + #endif + #if AXIS_IS_TMC(Z4) + TMC_SAY_CHOPPER_TIME(Z4); + #endif + #if AXIS_IS_TMC(I) + TMC_SAY_CHOPPER_TIME(I); + #endif + #if AXIS_IS_TMC(J) + TMC_SAY_CHOPPER_TIME(J); + #endif + #if AXIS_IS_TMC(K) + TMC_SAY_CHOPPER_TIME(K); + #endif + #if AXIS_IS_TMC(E0) + TMC_SAY_CHOPPER_TIME(E0); + #endif + #if AXIS_IS_TMC(E1) + TMC_SAY_CHOPPER_TIME(E1); + #endif + #if AXIS_IS_TMC(E2) + TMC_SAY_CHOPPER_TIME(E2); + #endif + #if AXIS_IS_TMC(E3) + TMC_SAY_CHOPPER_TIME(E3); + #endif + #if AXIS_IS_TMC(E4) + TMC_SAY_CHOPPER_TIME(E4); + #endif + #if AXIS_IS_TMC(E5) + TMC_SAY_CHOPPER_TIME(E5); + #endif + #if AXIS_IS_TMC(E6) + TMC_SAY_CHOPPER_TIME(E6); + #endif + #if AXIS_IS_TMC(E7) + TMC_SAY_CHOPPER_TIME(E7); + #endif + } +} + +#endif // HAS_TRINAMIC_CONFIG diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index c05ac5494d5a..f6e6dda5f87f 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -21,7 +21,7 @@ */ /** - * gcode.cpp - Temporary container for all gcode handlers + * gcode.cpp - Temporary container for all G-code handlers * Most will migrate to classes, by feature. */ @@ -73,8 +73,11 @@ GcodeSuite gcode; // Inactivity shutdown millis_t GcodeSuite::previous_move_ms = 0, - GcodeSuite::max_inactive_time = 0, - GcodeSuite::stepper_inactive_time = SEC_TO_MS(DEFAULT_STEPPER_DEACTIVE_TIME); + GcodeSuite::max_inactive_time = 0; + +#if HAS_DISABLE_INACTIVE_AXIS + millis_t GcodeSuite::stepper_inactive_time = SEC_TO_MS(DEFAULT_STEPPER_DEACTIVE_TIME); +#endif // Relative motion mode for each logical axis static constexpr xyze_bool_t ar_init = AXIS_RELATIVE_MODES; @@ -148,6 +151,7 @@ int8_t GcodeSuite::get_target_extruder_from_command() { int8_t GcodeSuite::get_target_e_stepper_from_command(const int8_t dval/*=-1*/) { const int8_t e = parser.intval('T', dval); if (WITHIN(e, 0, E_STEPPERS - 1)) return e; + if (dval == -2) return dval; SERIAL_ECHO_START(); SERIAL_CHAR('M'); SERIAL_ECHO(parser.codenum); @@ -159,7 +163,7 @@ int8_t GcodeSuite::get_target_e_stepper_from_command(const int8_t dval/*=-1*/) { } /** - * Set XYZIJKE destination and feedrate from the current GCode command + * Set XYZ...E destination and feedrate from the current GCode command * * - Set destination from included axis codes * - Set to current for missing axis codes @@ -206,7 +210,7 @@ void GcodeSuite::get_destination_from_command() { if (parser.floatval('F') > 0) feedrate_mm_s = parser.value_feedrate(); - #if ENABLED(PRINTCOUNTER) + #if BOTH(PRINTCOUNTER, HAS_EXTRUDERS) if (!DEBUGGING(DRYRUN) && !skip_move) print_job_timer.incFilamentUsed(destination.e - current_position.e); #endif @@ -786,6 +790,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 305: M305(); break; // M305: Set user thermistor parameters #endif + #if ENABLED(MPCTEMP) + case 306: M306(); break; // M306: MPC autotune + #endif + #if ENABLED(REPETIER_GCODE_M360) case 360: M360(); break; // M360: Firmware settings #endif @@ -970,6 +978,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { #if USE_SENSORLESS case 914: M914(); break; // M914: Set StallGuard sensitivity. #endif + case 919: M919(); break; // M919: Set stepper Chopper Times #endif #if HAS_L64XX diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index bbfb31a3fece..509c6e219db8 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -91,7 +91,7 @@ * *** Print from Media (SDSUPPORT) *** * M20 - List SD card. (Requires SDSUPPORT) - * M21 - Init SD card. (Requires SDSUPPORT) + * M21 - Init SD card. (Requires SDSUPPORT) With MULTI_VOLUME select a drive with `M21 Pn` / 'M21 S' / 'M21 U'. * M22 - Release SD card. (Requires SDSUPPORT) * M23 - Select SD file: "M23 /path/file.gco". (Requires SDSUPPORT) * M24 - Start/resume SD print. (Requires SDSUPPORT) @@ -110,7 +110,7 @@ * M33 - Get the longname version of a path. (Requires LONG_FILENAME_HOST_SUPPORT) * M34 - Set SD Card sorting options. (Requires SDCARD_SORT_ALPHA) * - * M42 - Change pin status via gcode: M42 P S. LED pin assumed if P is omitted. (Requires DIRECT_PIN_CONTROL) + * M42 - Change pin status via G-code: M42 P S. LED pin assumed if P is omitted. (Requires DIRECT_PIN_CONTROL) * M43 - Display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins (Requires PINS_DEBUGGING) * M48 - Measure Z Probe repeatability: M48 P X Y V E L S. (Requires Z_MIN_PROBE_REPEATABILITY_TEST) * @@ -202,6 +202,7 @@ * M226 - Wait until a pin is in a given state: "M226 P S" (Requires DIRECT_PIN_CONTROL) * M240 - Trigger a camera to take a photograph. (Requires PHOTO_GCODE) * M250 - Set LCD contrast: "M250 C" (0-63). (Requires LCD support) + * M255 - Set LCD sleep time: "M255 S" (0-99). (Requires an LCD with brightness or sleep/wake) * M256 - Set LCD brightness: "M256 B" (0-255). (Requires an LCD with brightness control) * M260 - i2c Send Data (Requires EXPERIMENTAL_I2CBUS) * M261 - i2c Request Data (Requires EXPERIMENTAL_I2CBUS) @@ -215,12 +216,13 @@ * M303 - PID relay autotune S sets the target temperature. Default 150C. (Requires PIDTEMP) * M304 - Set bed PID parameters P I and D. (Requires PIDTEMPBED) * M305 - Set user thermistor parameters R T and P. (Requires TEMP_SENSOR_x 1000) + * M306 - MPC autotune. (Requires MPCTEMP) * M309 - Set chamber PID parameters P I and D. (Requires PIDTEMPCHAMBER) * M350 - Set microstepping mode. (Requires digital microstepping pins.) * M351 - Toggle MS1 MS2 pins directly. (Requires digital microstepping pins.) * M355 - Set Case Light on/off and set brightness. (Requires CASE_LIGHT_PIN) - * M380 - Activate solenoid on active extruder. (Requires EXT_SOLENOID) - * M381 - Disable all solenoids. (Requires EXT_SOLENOID) + * M380 - Activate solenoid on active tool (Requires EXT_SOLENOID) or the tool specified by 'S' (Requires MANUAL_SOLENOID_CONTROL). + * M381 - Disable solenoids on all tools (Requires EXT_SOLENOID) or the tool specified by 'S' (Requires MANUAL_SOLENOID_CONTROL). * M400 - Finish all moves. * M401 - Deploy and activate Z probe. (Requires a probe) * M402 - Deactivate and stow Z probe. (Requires a probe) @@ -284,7 +286,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 X, Y, Z, E. 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 or L6470) * 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) @@ -296,6 +298,7 @@ * 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) * M7219 - Control Max7219 Matrix LEDs. (Requires MAX7219_GCODE) @@ -349,7 +352,7 @@ class GcodeSuite { static axis_bits_t axis_relative; - static inline bool axis_is_relative(const AxisEnum a) { + static bool axis_is_relative(const AxisEnum a) { #if HAS_EXTRUDERS if (a == E_AXIS) { if (TEST(axis_relative, E_MODE_REL)) return true; @@ -358,7 +361,7 @@ class GcodeSuite { #endif return TEST(axis_relative, a); } - static inline void set_relative_mode(const bool rel) { + static void set_relative_mode(const bool rel) { axis_relative = rel ? (0 LOGICAL_AXIS_GANG( | _BV(REL_E), | _BV(REL_X), | _BV(REL_Y), | _BV(REL_Z), @@ -366,11 +369,11 @@ class GcodeSuite { )) : 0; } #if HAS_EXTRUDERS - static inline void set_e_relative() { + static void set_e_relative() { CBI(axis_relative, E_MODE_ABS); SBI(axis_relative, E_MODE_REL); } - static inline void set_e_absolute() { + static void set_e_absolute() { CBI(axis_relative, E_MODE_REL); SBI(axis_relative, E_MODE_ABS); } @@ -392,18 +395,24 @@ class GcodeSuite { static bool select_coordinate_system(const int8_t _new); #endif - static millis_t previous_move_ms, max_inactive_time, stepper_inactive_time; - FORCE_INLINE static void reset_stepper_timeout(const millis_t ms=millis()) { previous_move_ms = ms; } + static millis_t previous_move_ms, max_inactive_time; FORCE_INLINE static bool stepper_max_timed_out(const millis_t ms=millis()) { return max_inactive_time && ELAPSED(ms, previous_move_ms + max_inactive_time); } - FORCE_INLINE static bool stepper_inactive_timeout(const millis_t ms=millis()) { - return ELAPSED(ms, previous_move_ms + stepper_inactive_time); - } + FORCE_INLINE static void reset_stepper_timeout(const millis_t ms=millis()) { previous_move_ms = ms; } + + #if HAS_DISABLE_INACTIVE_AXIS + static millis_t stepper_inactive_time; + FORCE_INLINE static bool stepper_inactive_timeout(const millis_t ms=millis()) { + return ELAPSED(ms, previous_move_ms + stepper_inactive_time); + } + #else + static bool stepper_inactive_timeout(const millis_t) { return false; } + #endif static void report_echo_start(const bool forReplay); static void report_heading(const bool forReplay, FSTR_P const fstr, const bool eol=true); - static inline void report_heading_etc(const bool forReplay, FSTR_P const fstr, const bool eol=true) { + static void report_heading_etc(const bool forReplay, FSTR_P const fstr, const bool eol=true) { report_heading(forReplay, fstr, eol); report_echo_start(forReplay); } @@ -420,20 +429,20 @@ class GcodeSuite { static void process_subcommands_now(FSTR_P fgcode); static void process_subcommands_now(char * gcode); - static inline void home_all_axes(const bool keep_leveling=false) { + static void home_all_axes(const bool keep_leveling=false) { process_subcommands_now(keep_leveling ? FPSTR(G28_STR) : TERN(CAN_SET_LEVELING_AFTER_G28, F("G28L0"), FPSTR(G28_STR))); } #if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE) static bool autoreport_paused; - static inline bool set_autoreport_paused(const bool p) { + static bool set_autoreport_paused(const bool p) { const bool was = autoreport_paused; autoreport_paused = p; return was; } #else static constexpr bool autoreport_paused = false; - static inline bool set_autoreport_paused(const bool) { return false; } + static bool set_autoreport_paused(const bool) { return false; } #endif #if ENABLED(HOST_KEEPALIVE_FEATURE) @@ -453,7 +462,7 @@ class GcodeSuite { static uint8_t host_keepalive_interval; static void host_keepalive(); - static inline bool host_keepalive_is_paused() { return busy_state >= PAUSED_FOR_USER; } + static bool host_keepalive_is_paused() { return busy_state >= PAUSED_FOR_USER; } #define KEEPALIVE_STATE(N) REMEMBER(_KA_, gcode.busy_state, gcode.N) #else @@ -876,6 +885,11 @@ class GcodeSuite { static void M250_report(const bool forReplay=true); #endif + #if HAS_DISPLAY_SLEEP + static void M255(); + static void M255_report(const bool forReplay=true); + #endif + #if HAS_LCD_BRIGHTNESS static void M256(); static void M256_report(const bool forReplay=true); @@ -927,6 +941,11 @@ class GcodeSuite { static void M305(); #endif + #if ENABLED(MPCTEMP) + static void M306(); + static void M306_report(const bool forReplay=true); + #endif + #if ENABLED(PIDTEMPCHAMBER) static void M309(); static void M309_report(const bool forReplay=true); @@ -1140,6 +1159,7 @@ class GcodeSuite { static void M914(); static void M914_report(const bool forReplay=true); #endif + static void M919(); #endif #if HAS_L64XX @@ -1193,6 +1213,11 @@ class GcodeSuite { static void M1000(); #endif + #if ENABLED(X_AXIS_TWIST_COMPENSATION) + static void M423(); + static void M423_report(const bool forReplay=true); + #endif + #if ENABLED(SDSUPPORT) static void M1001(); #endif diff --git a/Marlin/src/gcode/gcode_d.cpp b/Marlin/src/gcode/gcode_d.cpp index 204455e65ec6..2ebe38bbcf19 100644 --- a/Marlin/src/gcode/gcode_d.cpp +++ b/Marlin/src/gcode/gcode_d.cpp @@ -38,7 +38,7 @@ #include "../sd/cardreader.h" #include "../MarlinCore.h" // for kill -extern void dump_delay_accuracy_check(); +void dump_delay_accuracy_check(); /** * Dn: G-code for development and testing @@ -54,7 +54,7 @@ void GcodeSuite::D(const int16_t dcode) { for (;;) { /* loop forever (watchdog reset) */ } case 0: - HAL_reboot(); + hal.reboot(); break; case 10: @@ -74,7 +74,7 @@ void GcodeSuite::D(const int16_t dcode) { settings.reset(); settings.save(); #endif - HAL_reboot(); + hal.reboot(); } break; case 2: { // D2 Read / Write SRAM @@ -189,12 +189,12 @@ void GcodeSuite::D(const int16_t dcode) { SERIAL_ECHOLNPGM("(USE_WATCHDOG " TERN(USE_WATCHDOG, "ENABLED", "DISABLED") ")"); thermalManager.disable_all_heaters(); delay(1000); // Allow time to print - DISABLE_ISRS(); + hal.isr_off(); // Use a low-level delay that does not rely on interrupts to function // Do not spin forever, to avoid thermal risks if heaters are enabled and // watchdog does not work. for (int i = 10000; i--;) DELAY_US(1000UL); - ENABLE_ISRS(); + hal.isr_on(); SERIAL_ECHOLNPGM("FAILURE: Watchdog did not trigger board reset."); } break; @@ -214,7 +214,7 @@ void GcodeSuite::D(const int16_t dcode) { c = 1024 * 4; while (c--) { - TERN_(USE_WATCHDOG, watchdog_refresh()); + hal.watchdog_refresh(); card.write(buf, COUNT(buf)); } SERIAL_ECHOLNPGM(" done"); @@ -231,7 +231,7 @@ void GcodeSuite::D(const int16_t dcode) { __attribute__((aligned(sizeof(size_t)))) uint8_t buf[512]; uint16_t c = 1024 * 4; while (c--) { - TERN_(USE_WATCHDOG, watchdog_refresh()); + hal.watchdog_refresh(); card.read(buf, COUNT(buf)); bool error = false; for (uint16_t i = 0; i < COUNT(buf); i++) { diff --git a/Marlin/src/gcode/geometry/G92.cpp b/Marlin/src/gcode/geometry/G92.cpp index 990236c0e878..4fc882f6ecf3 100644 --- a/Marlin/src/gcode/geometry/G92.cpp +++ b/Marlin/src/gcode/geometry/G92.cpp @@ -29,7 +29,7 @@ #endif /** - * G92: Set the Current Position to the given X Y Z E values. + * G92: Set the Current Position to the given X [Y [Z [A [B [C [E]]]]]] values. * * Behind the scenes the G92 command may modify the Current Position * or the Position Shift depending on settings and sub-commands. @@ -37,14 +37,14 @@ * Since E has no Workspace Offset, it is always set directly. * * Without Workspace Offsets (e.g., with NO_WORKSPACE_OFFSETS): - * G92 : Set NATIVE Current Position to the given X Y Z E. + * G92 : Set NATIVE Current Position to the given X [Y [Z [A [B [C [E]]]]]]. * * Using Workspace Offsets (default Marlin behavior): - * G92 : Modify Workspace Offsets so the reported position shows the given X Y Z E. + * G92 : Modify Workspace Offsets so the reported position shows the given X [Y [Z [A [B [C [E]]]]]]. * G92.1 : Zero XYZ Workspace Offsets (so the reported position = the native position). * * With POWER_LOSS_RECOVERY: - * G92.9 : Set NATIVE Current Position to the given X Y Z E. + * G92.9 : Set NATIVE Current Position to the given X [Y [Z [A [B [C [E]]]]]]. */ void GcodeSuite::G92() { @@ -93,7 +93,7 @@ void GcodeSuite::G92() { v = TERN0(HAS_EXTRUDERS, i == E_AXIS) ? l : LOGICAL_TO_NATIVE(l, i), // Axis position in NATIVE space (applying the existing offset) d = v - current_position[i]; // How much is the current axis position altered by? if (!NEAR_ZERO(d)) { - #if HAS_POSITION_SHIFT && !IS_SCARA // When using workspaces... + #if HAS_POSITION_SHIFT && NONE(IS_SCARA, POLARGRAPH) // When using workspaces... if (TERN1(HAS_EXTRUDERS, i != E_AXIS)) { position_shift[i] += d; // ...most axes offset the workspace... update_workspace_offset((AxisEnum)i); diff --git a/Marlin/src/gcode/geometry/M206_M428.cpp b/Marlin/src/gcode/geometry/M206_M428.cpp index 131dbecf3343..b32d72996940 100644 --- a/Marlin/src/gcode/geometry/M206_M428.cpp +++ b/Marlin/src/gcode/geometry/M206_M428.cpp @@ -92,7 +92,7 @@ void GcodeSuite::M428() { if (!WITHIN(diff[i], -20, 20)) { SERIAL_ERROR_MSG(STR_ERR_M428_TOO_FAR); LCD_ALERTMESSAGE_F("Err: Too far!"); - BUZZ(200, 40); + ERR_BUZZ(); return; } } @@ -100,8 +100,7 @@ void GcodeSuite::M428() { LOOP_LINEAR_AXES(i) set_home_offset((AxisEnum)i, diff[i]); report_current_position(); LCD_MESSAGE(MSG_HOME_OFFSETS_APPLIED); - BUZZ(100, 659); - BUZZ(100, 698); + OKAY_BUZZ(); } #endif // HAS_M206_COMMAND diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index 08943ed5f299..36731c23da16 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -142,6 +142,11 @@ void GcodeSuite::M115() { // SDCARD (M20, M23, M24, etc.) cap_line(F("SDCARD"), ENABLED(SDSUPPORT)); + // MULTI_VOLUME (M21 S/M21 U) + #if ENABLED(SDSUPPORT) + cap_line(F("MULTI_VOLUME"), ENABLED(MULTI_VOLUME)); + #endif + // REPEAT (M808) cap_line(F("REPEAT"), ENABLED(GCODE_REPEAT_MARKERS)); @@ -154,6 +159,12 @@ void GcodeSuite::M115() { // LONG_FILENAME_HOST_SUPPORT (M33) cap_line(F("LONG_FILENAME"), ENABLED(LONG_FILENAME_HOST_SUPPORT)); + // LONG_FILENAME_WRITE_SUPPORT (M23, M28, M30...) + cap_line(F("LFN_WRITE"), ENABLED(LONG_FILENAME_WRITE_SUPPORT)); + + // CUSTOM_FIRMWARE_UPLOAD (M20 F) + cap_line(F("CUSTOM_FIRMWARE_UPLOAD"), ENABLED(CUSTOM_FIRMWARE_UPLOAD)); + // EXTENDED_M20 (M20 L) cap_line(F("EXTENDED_M20"), ENABLED(LONG_FILENAME_HOST_SUPPORT)); @@ -179,7 +190,7 @@ void GcodeSuite::M115() { cap_line(F("MEATPACK"), SERIAL_IMPL.has_feature(port, SerialFeature::MeatPack)); // CONFIG_EXPORT - cap_line(F("CONFIG_EXPORT"), ENABLED(CONFIG_EMBED_AND_SAVE_TO_SD)); + cap_line(F("CONFIG_EXPORT"), ENABLED(CONFIGURATION_EMBEDDING)); // Machine Geometry #if ENABLED(M115_GEOMETRY_REPORT) diff --git a/Marlin/src/gcode/host/M16.cpp b/Marlin/src/gcode/host/M16.cpp index 03e734daaa8b..07b0c5ef573d 100644 --- a/Marlin/src/gcode/host/M16.cpp +++ b/Marlin/src/gcode/host/M16.cpp @@ -26,6 +26,7 @@ #include "../gcode.h" #include "../../MarlinCore.h" +#include "../../lcd/marlinui.h" /** * M16: Expected Printer Check @@ -37,4 +38,4 @@ void GcodeSuite::M16() { } -#endif +#endif // EXPECTED_PRINTER_CHECK diff --git a/Marlin/src/gcode/host/M360.cpp b/Marlin/src/gcode/host/M360.cpp index 1feb57996adb..b3a95a35aaec 100644 --- a/Marlin/src/gcode/host/M360.cpp +++ b/Marlin/src/gcode/host/M360.cpp @@ -180,7 +180,7 @@ void GcodeSuite::M360() { // config_line(F("NumExtruder"), EXTRUDERS); #if HAS_EXTRUDERS - LOOP_L_N(e, EXTRUDERS) { + EXTRUDER_LOOP() { config_line_e(e, JERK_STR, TERN(HAS_LINEAR_E_JERK, planner.max_e_jerk[E_INDEX_N(e)], TERN(HAS_CLASSIC_JERK, planner.max_jerk.e, DEFAULT_EJERK))); config_line_e(e, F("MaxSpeed"), planner.settings.max_feedrate_mm_s[E_AXIS_N(e)]); config_line_e(e, F("Acceleration"), planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(e)]); diff --git a/Marlin/src/gcode/host/M876.cpp b/Marlin/src/gcode/host/M876.cpp index 49994f44e605..c2a519d0ac60 100644 --- a/Marlin/src/gcode/host/M876.cpp +++ b/Marlin/src/gcode/host/M876.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfig.h" -#if ENABLED(HOST_PROMPT_SUPPORT) && DISABLED(EMERGENCY_PARSER) +#if HAS_GCODE_M876 #include "../../feature/host_actions.h" #include "../gcode.h" @@ -37,4 +37,4 @@ void GcodeSuite::M876() { } -#endif // HOST_PROMPT_SUPPORT && !EMERGENCY_PARSER +#endif // HAS_GCODE_M876 diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index 6e3b84c020f0..af03fcb0b1a1 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -31,12 +31,13 @@ #include "../../module/planner.h" // for synchronize() #include "../../MarlinCore.h" // for wait_for_user_response() -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "../../lcd/marlinui.h" #elif ENABLED(EXTENSIBLE_UI) #include "../../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin_popup.h" + #include "../../lcd/e3v2/proui/dwin.h" #endif #if ENABLED(HOST_PROMPT_SUPPORT) @@ -54,7 +55,7 @@ void GcodeSuite::M0_M1() { planner.synchronize(); - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU if (parser.string_arg) ui.set_status(parser.string_arg, true); @@ -70,7 +71,7 @@ void GcodeSuite::M0_M1() { ExtUI::onUserConfirmRequired(parser.string_arg); // String in an SRAM buffer else ExtUI::onUserConfirmRequired(GET_TEXT_F(MSG_USERWAIT)); - #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #elif ENABLED(DWIN_LCD_PROUI) if (parser.string_arg) DWIN_Popup_Confirm(ICON_BLTouch, parser.string_arg, GET_TEXT_F(MSG_USERWAIT)); else @@ -88,7 +89,7 @@ void GcodeSuite::M0_M1() { TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(ms)); - TERN_(HAS_LCD_MENU, ui.reset_status()); + TERN_(HAS_MARLINUI_MENU, ui.reset_status()); } #endif // HAS_RESUME_CONTINUE diff --git a/Marlin/src/gcode/lcd/M117.cpp b/Marlin/src/gcode/lcd/M117.cpp index f26694bd6463..86023e12e3b4 100644 --- a/Marlin/src/gcode/lcd/M117.cpp +++ b/Marlin/src/gcode/lcd/M117.cpp @@ -33,7 +33,7 @@ void GcodeSuite::M117() { if (parser.string_arg && parser.string_arg[0]) - ui.set_status(parser.string_arg); + ui.set_status(parser.string_arg, true); else ui.reset_status(); diff --git a/Marlin/src/gcode/lcd/M250.cpp b/Marlin/src/gcode/lcd/M250.cpp index 25e423278883..58b6dac872a3 100644 --- a/Marlin/src/gcode/lcd/M250.cpp +++ b/Marlin/src/gcode/lcd/M250.cpp @@ -31,7 +31,7 @@ * M250: Read and optionally set the LCD contrast */ void GcodeSuite::M250() { - if (parser.seenval('C')) + if (LCD_CONTRAST_MIN < LCD_CONTRAST_MAX && parser.seenval('C')) ui.set_contrast(parser.value_byte()); else M250_report(); diff --git a/Marlin/src/gcode/lcd/M255.cpp b/Marlin/src/gcode/lcd/M255.cpp new file mode 100644 index 000000000000..cfdf27b8a1fc --- /dev/null +++ b/Marlin/src/gcode/lcd/M255.cpp @@ -0,0 +1,58 @@ +/** + * 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_GCODE_M255 + +#include "../gcode.h" +#include "../../lcd/marlinui.h" + +/** + * M255: Set the LCD sleep timeout (in minutes) + * S - Period of inactivity required for display / backlight sleep + */ +void GcodeSuite::M255() { + if (parser.seenval('S')) { + #if HAS_DISPLAY_SLEEP + const int m = parser.value_int(); + ui.sleep_timeout_minutes = constrain(m, SLEEP_TIMEOUT_MIN, 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); + #endif + } + else + M255_report(); +} + +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 + ); +} + +#endif // HAS_GCODE_M255 diff --git a/Marlin/src/gcode/lcd/M73.cpp b/Marlin/src/gcode/lcd/M73.cpp index b7a9b3459e52..a86eee4d9967 100644 --- a/Marlin/src/gcode/lcd/M73.cpp +++ b/Marlin/src/gcode/lcd/M73.cpp @@ -28,8 +28,8 @@ #include "../../lcd/marlinui.h" #include "../../sd/cardreader.h" -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" +#if ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin.h" #endif /** @@ -40,9 +40,9 @@ */ void GcodeSuite::M73() { - #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(DWIN_LCD_PROUI) - DWIN_Progress_Update(); + DWIN_M73(); #else diff --git a/Marlin/src/gcode/motion/G0_G1.cpp b/Marlin/src/gcode/motion/G0_G1.cpp index cc6979b74c12..493fd00da187 100644 --- a/Marlin/src/gcode/motion/G0_G1.cpp +++ b/Marlin/src/gcode/motion/G0_G1.cpp @@ -89,7 +89,7 @@ void GcodeSuite::G0_G1(TERN_(HAS_FAST_MOVES, const bool fast_move/*=false*/)) { if (MIN_AUTORETRACT <= MAX_AUTORETRACT) { // When M209 Autoretract is enabled, convert E-only moves to firmware retract/recover moves if (fwretract.autoretract_enabled && parser.seen_test('E') - && !parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", AXIS4_STR, AXIS5_STR, AXIS6_STR)) + && !parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", STR_I, STR_J, STR_K)) ) { const float echange = destination.e - current_position.e; // Is this a retract or recover move? diff --git a/Marlin/src/gcode/motion/G5.cpp b/Marlin/src/gcode/motion/G5.cpp index 2c98fae84522..316a59b6506c 100644 --- a/Marlin/src/gcode/motion/G5.cpp +++ b/Marlin/src/gcode/motion/G5.cpp @@ -24,6 +24,10 @@ #if ENABLED(BEZIER_CURVE_SUPPORT) +#if AXIS_COLLISION('I') || AXIS_COLLISION('J') + #error "G5 parameter collision with axis name." +#endif + #include "../../module/motion.h" #include "../../module/planner_bezier.h" diff --git a/Marlin/src/gcode/motion/M290.cpp b/Marlin/src/gcode/motion/M290.cpp index 747ddd64de19..ac5cd7f27e88 100644 --- a/Marlin/src/gcode/motion/M290.cpp +++ b/Marlin/src/gcode/motion/M290.cpp @@ -87,7 +87,7 @@ void GcodeSuite::M290() { } #endif - if (!parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", AXIS4_STR, AXIS5_STR, AXIS6_STR)) || parser.seen('R')) { + if (!parser.seen(LINEAR_AXIS_GANG("X", "Y", "Z", STR_I, STR_J, STR_K)) || parser.seen('R')) { SERIAL_ECHO_START(); #if ENABLED(BABYSTEP_ZPROBE_OFFSET) @@ -111,7 +111,7 @@ void GcodeSuite::M290() { #endif #if ENABLED(MESH_BED_LEVELING) - SERIAL_ECHOLNPGM("MBL Adjust Z", mbl.z_offset); + SERIAL_ECHOLNPGM("MBL Adjust Z", bedlevel.z_offset); #endif #if ENABLED(BABYSTEP_DISPLAY_TOTAL) diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index 83fda5483608..a32999f2d2cb 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -45,7 +45,7 @@ /** * GCode parser * - * - Parse a single gcode line for its letter, code, subcode, and parameters + * - Parse a single G-code line for its letter, code, subcode, and parameters * - FASTER_GCODE_PARSER: * - Flags existing params (1 bit each) * - Stores value offsets (1 byte each) @@ -126,7 +126,7 @@ class GCodeParser { } // Set the flag and pointer for a parameter - static inline void set(const char c, char * const ptr) { + static void set(const char c, char * const ptr) { const uint8_t ind = LETTER_BIT(c); if (ind >= COUNT(param)) return; // Only A-Z SBI32(codebits, ind); // parameter exists @@ -142,7 +142,7 @@ class GCodeParser { // Code seen bit was set. If not found, value_ptr is unchanged. // This allows "if (seen('A')||seen('B'))" to use the last-found value. - static inline bool seen(const char c) { + static bool seen(const char c) { const uint8_t ind = LETTER_BIT(c); if (ind >= COUNT(param)) return false; // Only A-Z const bool b = TEST32(codebits, ind); @@ -183,7 +183,7 @@ class GCodeParser { } #endif - static inline bool seen_any() { return !!codebits; } + static bool seen_any() { return !!codebits; } FORCE_INLINE static bool seen_test(const char c) { return TEST32(codebits, LETTER_BIT(c)); } @@ -204,19 +204,19 @@ class GCodeParser { // Code is found in the string. If not found, value_ptr is unchanged. // This allows "if (seen('A')||seen('B'))" to use the last-found value. - static inline bool seen(const char c) { + static bool seen(const char c) { char *p = strgchr(command_args, c); const bool b = !!p; if (b) value_ptr = valid_number(&p[1]) ? &p[1] : nullptr; return b; } - static inline bool seen_any() { return *command_args == '\0'; } + static bool seen_any() { return *command_args == '\0'; } FORCE_INLINE static bool seen_test(const char c) { return (bool)strgchr(command_args, c); } // At least one of a list of code letters was seen - static inline bool seen(const char * const str) { + static bool seen(const char * const str) { for (uint8_t i = 0; const char c = str[i]; i++) if (seen_test(c)) return true; return false; @@ -225,7 +225,7 @@ class GCodeParser { #endif // !FASTER_GCODE_PARSER // Seen any axis parameter - static inline bool seen_axis() { return seen(LOGICAL_AXES_STRING); } + static bool seen_axis() { return seen(LOGICAL_AXES_STRING); } #if ENABLED(GCODE_QUOTED_STRINGS) static char* unescape_string(char* &src); @@ -243,19 +243,19 @@ class GCodeParser { #endif // Test whether the parsed command matches the input - static inline bool is_command(const char ltr, const uint16_t num) { return command_letter == ltr && codenum == num; } + static bool is_command(const char ltr, const uint16_t num) { return command_letter == ltr && codenum == num; } // The code value pointer was set FORCE_INLINE static bool has_value() { return !!value_ptr; } // Seen a parameter with a value - static inline bool seenval(const char c) { return seen(c) && has_value(); } + static bool seenval(const char c) { return seen(c) && has_value(); } // The value as a string - static inline char* value_string() { return value_ptr; } + static char* value_string() { return value_ptr; } // Float removes 'E' to prevent scientific notation interpretation - static inline float value_float() { + static float value_float() { if (value_ptr) { char *e = value_ptr; for (;;) { @@ -275,31 +275,31 @@ class GCodeParser { } // Code value as a long or ulong - static inline int32_t value_long() { return value_ptr ? strtol(value_ptr, nullptr, 10) : 0L; } - static inline uint32_t value_ulong() { return value_ptr ? strtoul(value_ptr, nullptr, 10) : 0UL; } + static int32_t value_long() { return value_ptr ? strtol(value_ptr, nullptr, 10) : 0L; } + static uint32_t value_ulong() { return value_ptr ? strtoul(value_ptr, nullptr, 10) : 0UL; } // Code value for use as time - static inline millis_t value_millis() { return value_ulong(); } - static inline millis_t value_millis_from_seconds() { return (millis_t)SEC_TO_MS(value_float()); } + static millis_t value_millis() { return value_ulong(); } + static millis_t value_millis_from_seconds() { return (millis_t)SEC_TO_MS(value_float()); } // Reduce to fewer bits - static inline int16_t value_int() { return (int16_t)value_long(); } - static inline uint16_t value_ushort() { return (uint16_t)value_long(); } - static inline uint8_t value_byte() { return (uint8_t)constrain(value_long(), 0, 255); } + static int16_t value_int() { return (int16_t)value_long(); } + static uint16_t value_ushort() { return (uint16_t)value_long(); } + static uint8_t value_byte() { return (uint8_t)constrain(value_long(), 0, 255); } // Bool is true with no value or non-zero - static inline bool value_bool() { return !has_value() || !!value_byte(); } + static bool value_bool() { return !has_value() || !!value_byte(); } // Units modes: Inches, Fahrenheit, Kelvin #if ENABLED(INCH_MODE_SUPPORT) - static inline float mm_to_linear_unit(const_float_t mm) { return mm / linear_unit_factor; } - static inline float mm_to_volumetric_unit(const_float_t mm) { return mm / (volumetric_enabled ? volumetric_unit_factor : linear_unit_factor); } + static float mm_to_linear_unit(const_float_t mm) { return mm / linear_unit_factor; } + static float mm_to_volumetric_unit(const_float_t mm) { return mm / (volumetric_enabled ? volumetric_unit_factor : linear_unit_factor); } // Init linear units by constructor GCodeParser() { set_input_linear_units(LINEARUNIT_MM); } - static inline void set_input_linear_units(const LinearUnit units) { + static void set_input_linear_units(const LinearUnit units) { switch (units) { default: case LINEARUNIT_MM: linear_unit_factor = 1.0f; break; @@ -308,7 +308,7 @@ class GCodeParser { volumetric_unit_factor = POW(linear_unit_factor, 3); } - static inline float axis_unit_factor(const AxisEnum axis) { + static float axis_unit_factor(const AxisEnum axis) { return ( #if HAS_EXTRUDERS axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor @@ -318,46 +318,46 @@ class GCodeParser { ); } - static inline float linear_value_to_mm(const_float_t v) { return v * linear_unit_factor; } - static inline float axis_value_to_mm(const AxisEnum axis, const float v) { return v * axis_unit_factor(axis); } - static inline float per_axis_value(const AxisEnum axis, const float v) { return v / axis_unit_factor(axis); } + static float linear_value_to_mm(const_float_t v) { return v * linear_unit_factor; } + static float axis_value_to_mm(const AxisEnum axis, const float v) { return v * axis_unit_factor(axis); } + static float per_axis_value(const AxisEnum axis, const float v) { return v / axis_unit_factor(axis); } #else - static inline float mm_to_linear_unit(const_float_t mm) { return mm; } - static inline float mm_to_volumetric_unit(const_float_t mm) { return mm; } + static float mm_to_linear_unit(const_float_t mm) { return mm; } + static float mm_to_volumetric_unit(const_float_t mm) { return mm; } - static inline float linear_value_to_mm(const_float_t v) { return v; } - static inline float axis_value_to_mm(const AxisEnum, const float v) { return v; } - static inline float per_axis_value(const AxisEnum, const float v) { return v; } + static float linear_value_to_mm(const_float_t v) { return v; } + static float axis_value_to_mm(const AxisEnum, const float v) { return v; } + static float per_axis_value(const AxisEnum, const float v) { return v; } #endif - static inline bool using_inch_units() { return mm_to_linear_unit(1.0f) != 1.0f; } + static bool using_inch_units() { return mm_to_linear_unit(1.0f) != 1.0f; } #define IN_TO_MM(I) ((I) * 25.4f) #define MM_TO_IN(M) ((M) / 25.4f) #define LINEAR_UNIT(V) parser.mm_to_linear_unit(V) #define VOLUMETRIC_UNIT(V) parser.mm_to_volumetric_unit(V) - static inline float value_linear_units() { return linear_value_to_mm(value_float()); } - static inline float value_axis_units(const AxisEnum axis) { return axis_value_to_mm(axis, value_float()); } - static inline float value_per_axis_units(const AxisEnum axis) { return per_axis_value(axis, value_float()); } + static float value_linear_units() { return linear_value_to_mm(value_float()); } + static float value_axis_units(const AxisEnum axis) { return axis_value_to_mm(axis, value_float()); } + static float value_per_axis_units(const AxisEnum axis) { return per_axis_value(axis, value_float()); } #if ENABLED(TEMPERATURE_UNITS_SUPPORT) - static inline void set_input_temp_units(const TempUnit units) { input_temp_units = units; } + static void set_input_temp_units(const TempUnit units) { input_temp_units = units; } - static inline char temp_units_code() { + static char temp_units_code() { return input_temp_units == TEMPUNIT_K ? 'K' : input_temp_units == TEMPUNIT_F ? 'F' : 'C'; } - static inline FSTR_P temp_units_name() { + static FSTR_P temp_units_name() { return input_temp_units == TEMPUNIT_K ? F("Kelvin") : input_temp_units == TEMPUNIT_F ? F("Fahrenheit") : F("Celsius"); } - #if HAS_LCD_MENU && DISABLED(DISABLE_M503) + #if HAS_MARLINUI_MENU && DISABLED(DISABLE_M503) - static inline float to_temp_units(celsius_t c) { + static float to_temp_units(celsius_t c) { switch (input_temp_units) { default: case TEMPUNIT_C: return c; @@ -366,9 +366,9 @@ class GCodeParser { } } - #endif // HAS_LCD_MENU && !DISABLE_M503 + #endif // HAS_MARLINUI_MENU && !DISABLE_M503 - static inline celsius_t value_celsius() { + static celsius_t value_celsius() { float f = value_float(); switch (input_temp_units) { default: @@ -379,7 +379,7 @@ class GCodeParser { return LROUND(f); } - static inline celsius_t value_celsius_diff() { + static celsius_t value_celsius_diff() { float f = value_float(); switch (input_temp_units) { default: @@ -392,35 +392,35 @@ class GCodeParser { #else // !TEMPERATURE_UNITS_SUPPORT - static inline float to_temp_units(int16_t c) { return (float)c; } + static float to_temp_units(int16_t c) { return (float)c; } - static inline celsius_t value_celsius() { return value_int(); } - static inline celsius_t value_celsius_diff() { return value_int(); } + static celsius_t value_celsius() { return value_int(); } + static celsius_t value_celsius_diff() { return value_int(); } #endif // !TEMPERATURE_UNITS_SUPPORT - static inline feedRate_t value_feedrate() { return MMM_TO_MMS(value_linear_units()); } + static feedRate_t value_feedrate() { return MMM_TO_MMS(value_linear_units()); } void unknown_command_warning(); // Provide simple value accessors with default option - static inline char* stringval(const char c, char * const dval=nullptr) { return seenval(c) ? value_string() : dval; } - static inline float floatval(const char c, const float dval=0.0) { return seenval(c) ? value_float() : dval; } - static inline bool boolval(const char c, const bool dval=false) { return seenval(c) ? value_bool() : (seen(c) ? true : dval); } - static inline uint8_t byteval(const char c, const uint8_t dval=0) { return seenval(c) ? value_byte() : dval; } - static inline int16_t intval(const char c, const int16_t dval=0) { return seenval(c) ? value_int() : dval; } - static inline uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort() : dval; } - static inline int32_t longval(const char c, const int32_t dval=0) { return seenval(c) ? value_long() : dval; } - static inline uint32_t ulongval(const char c, const uint32_t dval=0) { return seenval(c) ? value_ulong() : dval; } - static inline float linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; } - static inline float axisunitsval(const char c, const AxisEnum a, const float dval=0) + static char* stringval(const char c, char * const dval=nullptr) { return seenval(c) ? value_string() : dval; } + static float floatval(const char c, const float dval=0.0) { return seenval(c) ? value_float() : dval; } + static bool boolval(const char c, const bool dval=false) { return seenval(c) ? value_bool() : (seen(c) ? true : dval); } + static uint8_t byteval(const char c, const uint8_t dval=0) { return seenval(c) ? value_byte() : dval; } + static int16_t intval(const char c, const int16_t dval=0) { return seenval(c) ? value_int() : dval; } + static uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort() : dval; } + static int32_t longval(const char c, const int32_t dval=0) { return seenval(c) ? value_long() : dval; } + static uint32_t ulongval(const char c, const uint32_t dval=0) { return seenval(c) ? value_ulong() : dval; } + static float linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; } + static float axisunitsval(const char c, const AxisEnum a, const float dval=0) { return seenval(c) ? value_axis_units(a) : dval; } - static inline celsius_t celsiusval(const char c, const celsius_t dval=0) { return seenval(c) ? value_celsius() : dval; } - static inline feedRate_t feedrateval(const char c, const feedRate_t dval=0) { return seenval(c) ? value_feedrate() : dval; } + static celsius_t celsiusval(const char c, const celsius_t dval=0) { return seenval(c) ? value_celsius() : dval; } + static feedRate_t feedrateval(const char c, const feedRate_t dval=0) { return seenval(c) ? value_feedrate() : dval; } #if ENABLED(MARLIN_DEV_MODE) - static inline uint8_t* hex_adr_val(const char c, uint8_t * const dval=nullptr) { + static uint8_t* hex_adr_val(const char c, uint8_t * const dval=nullptr) { if (!seen(c) || *value_ptr != 'x') return dval; uint8_t *out = nullptr; for (char *vp = value_ptr + 1; HEXCHR(*vp) >= 0; vp++) @@ -428,7 +428,7 @@ class GCodeParser { return out; } - static inline uint16_t hex_val(const char c, uint16_t const dval=0) { + static uint16_t hex_val(const char c, uint16_t const dval=0) { if (!seen(c) || *value_ptr != 'x') return dval; uint16_t out = 0; for (char *vp = value_ptr + 1; HEXCHR(*vp) >= 0; vp++) diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index f4152c76e9e5..a16853bdf894 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -29,6 +29,14 @@ #include "../../module/probe.h" #include "../../feature/bedlevel/bedlevel.h" +#if HAS_PTC + #include "../../feature/probe_temp_comp.h" +#endif + +#if ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/marlinui.h" +#endif + /** * G30: Do a single Z probe at the current XY * @@ -37,23 +45,45 @@ * X Probe X position (default current X) * Y Probe Y position (default current Y) * E Engage the probe for each probe (default 1) + * C Enable probe temperature compensation (0 or 1, default 1) */ 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)) return; + 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; + } // 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); - if (!isnan(measured_z)) + 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 + } restore_feedrate_and_scaling(); diff --git a/Marlin/src/gcode/probe/M401_M402.cpp b/Marlin/src/gcode/probe/M401_M402.cpp index 7cbae76f4b88..33895749193f 100644 --- a/Marlin/src/gcode/probe/M401_M402.cpp +++ b/Marlin/src/gcode/probe/M401_M402.cpp @@ -36,12 +36,18 @@ * M401: Deploy and activate the Z probe * * With BLTOUCH_HS_MODE: + * H Report the current BLTouch HS mode state and exit * S Set High Speed (HS) Mode and exit without deploy */ void GcodeSuite::M401() { - if (parser.seen('S')) { + const bool seenH = parser.seen_test('H'), + seenS = parser.seen('S'); + if (seenH || seenS) { #ifdef BLTOUCH_HS_MODE - bltouch.high_speed_mode = parser.value_bool(); + if (seenS) bltouch.high_speed_mode = parser.value_bool(); + SERIAL_ECHO_START(); + SERIAL_ECHOPGM("BLTouch HS mode "); + serialprintln_onoff(bltouch.high_speed_mode); #endif } else { diff --git a/Marlin/src/gcode/probe/M423.cpp b/Marlin/src/gcode/probe/M423.cpp new file mode 100644 index 000000000000..fde5aaaf87c9 --- /dev/null +++ b/Marlin/src/gcode/probe/M423.cpp @@ -0,0 +1,99 @@ +/** + * 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 . + * + */ + +/** + * M423.cpp - X-Axis Twist Compensation + */ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(X_AXIS_TWIST_COMPENSATION) + +#include "../gcode.h" +#include "../../feature/x_twist.h" +#include "../../module/probe.h" + +/** + * M423: Set a Z offset for X-Twist (added to the mesh on future G29). + * M423 [R] [A] [I] [X Z] + * + * R - Reset the twist compensation data + * A - Set the X twist starting X position + * E - Set the X twist ending X position + * I - Set the X twist X-spacing directly + * X - Index of a Z value in the list + * Z - A Z value to set + */ +void GcodeSuite::M423() { + + bool do_report = true; + float new_spacing = 0; + + if (parser.seen_test('R')) { + do_report = false; + xatc.reset(); + } + if (parser.seenval('A')) { + do_report = false; + xatc.start = parser.value_float(); + new_spacing = (probe.max_x() - xatc.start) / (XATC_MAX_POINTS - 1); + } + if (parser.seenval('E')) { + do_report = false; + new_spacing = (parser.value_float() - xatc.start) / (XATC_MAX_POINTS - 1); + } + else if (parser.seenval('I')) { + do_report = false; + new_spacing = parser.value_float(); + } + + if (new_spacing) xatc.spacing = new_spacing; + + if (parser.seenval('X')) { + do_report = false; + const int8_t x = parser.value_int(); + if (!WITHIN(x, 0, XATC_MAX_POINTS - 1)) + SERIAL_ECHOLNPGM("?(X) out of range (0..", XATC_MAX_POINTS - 1, ")."); + else { + if (parser.seenval('Z')) + xatc.z_offset[x] = parser.value_linear_units(); + else + SERIAL_ECHOLNPGM("?(Z) required."); + } + } + + if (do_report) M423_report(); + +} + +void GcodeSuite::M423_report(const bool forReplay/*=true*/) { + report_heading(forReplay, F("X-Twist Correction")); + SERIAL_ECHOLNPGM(" M423 A", xatc.start, " I", xatc.spacing); + LOOP_L_N(x, XATC_MAX_POINTS) { + const float z = xatc.z_offset[x]; + SERIAL_ECHOPGM(" M423 X", x, " Z"); + serial_offset(isnan(z) ? 0 : z); + SERIAL_EOL(); + } +} + +#endif // X_AXIS_TWIST_COMPENSATION diff --git a/Marlin/src/gcode/probe/M951.cpp b/Marlin/src/gcode/probe/M951.cpp index c6a9cfbe206c..7a06400e3336 100644 --- a/Marlin/src/gcode/probe/M951.cpp +++ b/Marlin/src/gcode/probe/M951.cpp @@ -32,13 +32,13 @@ mpe_settings_t mpe_settings; inline void mpe_settings_report() { SERIAL_ECHO_MSG("Magnetic Parking Extruder"); - SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("L: Left parking :", mpe_settings.parking_xpos[0]); - SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("R: Right parking :", mpe_settings.parking_xpos[1]); - SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("I: Grab Offset :", mpe_settings.grab_distance); - SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("J: Normal speed :", long(MMS_TO_MMM(mpe_settings.slow_feedrate))); - SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("H: High speed :", long(MMS_TO_MMM(mpe_settings.fast_feedrate))); - SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("D: Distance trav.:", mpe_settings.travel_distance); - SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("C: Compenstion :", mpe_settings.compensation_factor); + SERIAL_ECHO_MSG("L: Left parking :", mpe_settings.parking_xpos[0]); + SERIAL_ECHO_MSG("R: Right parking :", mpe_settings.parking_xpos[1]); + SERIAL_ECHO_MSG("I: Grab Offset :", mpe_settings.grab_distance); + SERIAL_ECHO_MSG("J: Normal speed :", long(MMS_TO_MMM(mpe_settings.slow_feedrate))); + SERIAL_ECHO_MSG("H: High speed :", long(MMS_TO_MMM(mpe_settings.fast_feedrate))); + SERIAL_ECHO_MSG("D: Distance trav.:", mpe_settings.travel_distance); + SERIAL_ECHO_MSG("C: Compenstion :", mpe_settings.compensation_factor); } void mpe_settings_init() { diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index cc52a3bb9e80..2250cd3b7452 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -522,7 +522,7 @@ void GCodeQueue::get_serial_commands() { #if DISABLED(EMERGENCY_PARSER) // Process critical commands early if (command[0] == 'M') switch (command[3]) { - case '8': if (command[2] == '0' && command[1] == '1') { wait_for_heatup = false; TERN_(HAS_LCD_MENU, wait_for_user = false); } break; + case '8': if (command[2] == '0' && command[1] == '1') { wait_for_heatup = false; TERN_(HAS_MARLINUI_MENU, wait_for_user = false); } break; case '2': if (command[2] == '1' && command[1] == '1') kill(FPSTR(M112_KILL_STR), nullptr, true); break; case '0': if (command[1] == '4' && command[2] == '1') quickstop_stepper(); break; } diff --git a/Marlin/src/gcode/queue.h b/Marlin/src/gcode/queue.h index 82e2a7a0e4da..1a2baaa6bbc4 100644 --- a/Marlin/src/gcode/queue.h +++ b/Marlin/src/gcode/queue.h @@ -126,14 +126,14 @@ class GCodeQueue { * Don't inject comments or use leading spaces! * Aborts the current PROGMEM queue so only use for one or two commands. */ - static inline void inject_P(PGM_P const pgcode) { injected_commands_P = pgcode; } - static inline void inject(FSTR_P const fgcode) { inject_P(FTOP(fgcode)); } + static void inject_P(PGM_P const pgcode) { injected_commands_P = pgcode; } + static void inject(FSTR_P const fgcode) { inject_P(FTOP(fgcode)); } /** * Enqueue command(s) to run from SRAM. Drained by process_injected_command(). * Aborts the current SRAM queue so only use for one or two commands. */ - static inline void inject(const char * const gcode) { + static void inject(const char * const gcode) { strncpy(injected_commands, gcode, sizeof(injected_commands) - 1); } @@ -158,7 +158,7 @@ class GCodeQueue { * Enqueue from program memory and return only when commands are actually enqueued */ static void enqueue_now_P(PGM_P const pcmd); - static inline void enqueue_now(FSTR_P const fcmd) { enqueue_now_P(FTOP(fcmd)); } + static void enqueue_now(FSTR_P const fcmd) { enqueue_now_P(FTOP(fcmd)); } /** * Check whether there are any commands yet to be executed @@ -192,7 +192,7 @@ class GCodeQueue { * P Planner space remaining * B Block queue space remaining */ - static inline void ok_to_send() { ring_buffer.ok_to_send(); } + static void ok_to_send() { ring_buffer.ok_to_send(); } /** * Clear the serial line and request a resend of @@ -203,7 +203,7 @@ class GCodeQueue { /** * (Re)Set the current line number for the last received command */ - static inline void set_current_line_number(long n) { serial_state[ring_buffer.command_port().index].last_N = n; } + static void set_current_line_number(long n) { serial_state[ring_buffer.command_port().index].last_N = n; } #if ENABLED(BUFFER_MONITORING) @@ -237,7 +237,7 @@ class GCodeQueue { static void auto_report_buffer_statistics(); - static inline void set_auto_report_interval(uint8_t v) { + static void set_auto_report_interval(uint8_t v) { NOMORE(v, 60); auto_buffer_report_interval = v; next_buffer_report_ms = millis() + 1000UL * v; diff --git a/Marlin/src/gcode/sd/M1001.cpp b/Marlin/src/gcode/sd/M1001.cpp index 417f3747c17f..197177882c31 100644 --- a/Marlin/src/gcode/sd/M1001.cpp +++ b/Marlin/src/gcode/sd/M1001.cpp @@ -49,8 +49,8 @@ #if ENABLED(EXTENSIBLE_UI) #include "../../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin.h" #endif #if ENABLED(HOST_ACTION_COMMANDS) @@ -98,7 +98,7 @@ void GcodeSuite::M1001() { 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_(HAS_RESUME_CONTINUE, wait_for_user_response(SEC_TO_MS(TERN(HAS_LCD_MENU, PE_LEDS_COMPLETED_TIME, 30)))); + TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(SEC_TO_MS(TERN(HAS_MARLINUI_MENU, PE_LEDS_COMPLETED_TIME, 30)))); printerEventLEDs.onResumeAfterWait(); } #endif @@ -108,8 +108,8 @@ void GcodeSuite::M1001() { process_subcommands_now(F(SD_FINISHED_RELEASECOMMAND)); #endif - TERN_(EXTENSIBLE_UI, ExtUI::onPrintFinished()); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Print_Finished()); + 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 573183833854..c640309be8c8 100644 --- a/Marlin/src/gcode/sd/M20.cpp +++ b/Marlin/src/gcode/sd/M20.cpp @@ -33,7 +33,13 @@ void GcodeSuite::M20() { if (card.flag.mounted) { SERIAL_ECHOLNPGM(STR_BEGIN_FILE_LIST); - card.ls(TERN_(LONG_FILENAME_HOST_SUPPORT, parser.boolval('L'))); + 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')) + ); SERIAL_ECHOLNPGM(STR_END_FILE_LIST); } else diff --git a/Marlin/src/gcode/sd/M21_M22.cpp b/Marlin/src/gcode/sd/M21_M22.cpp index c7f41f9c817e..aec0de27ca5c 100644 --- a/Marlin/src/gcode/sd/M21_M22.cpp +++ b/Marlin/src/gcode/sd/M21_M22.cpp @@ -29,8 +29,21 @@ /** * M21: Init SD Card + * + * With MULTI_VOLUME: + * P0 or S - Change to the SD Card and mount it + * P1 or U - Change to the USB Drive and mount it */ -void GcodeSuite::M21() { card.mount(); } +void GcodeSuite::M21() { + #if ENABLED(MULTI_VOLUME) + const int8_t vol = parser.intval('P', -1); + if (vol == 0 || parser.seen_test('S')) // "S" for SD Card + card.changeMedia(&card.media_driver_sdcard); + else if (vol == 1 || parser.seen_test('U')) // "U" for USB + card.changeMedia(&card.media_driver_usbFlash); + #endif + card.mount(); +} /** * M22: Release SD Card diff --git a/Marlin/src/gcode/sd/M524.cpp b/Marlin/src/gcode/sd/M524.cpp index e7159155655c..001a1e184263 100644 --- a/Marlin/src/gcode/sd/M524.cpp +++ b/Marlin/src/gcode/sd/M524.cpp @@ -27,15 +27,27 @@ #include "../gcode.h" #include "../../sd/cardreader.h" +#if ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin.h" +#endif + /** * M524: Abort the current SD print job (started with M24) */ void GcodeSuite::M524() { - if (IS_SD_PRINTING()) - card.abortFilePrintSoon(); - else if (card.isMounted()) - card.closefile(); + #if ENABLED(DWIN_LCD_PROUI) + + HMI_flag.abort_flag = true; // The LCD will handle it + + #else + + if (IS_SD_PRINTING()) + card.abortFilePrintSoon(); + else if (card.isMounted()) + card.closefile(); + + #endif } diff --git a/Marlin/src/gcode/stats/M31.cpp b/Marlin/src/gcode/stats/M31.cpp index 355701f6a413..1a1c13ba2f1a 100644 --- a/Marlin/src/gcode/stats/M31.cpp +++ b/Marlin/src/gcode/stats/M31.cpp @@ -33,7 +33,7 @@ void GcodeSuite::M31() { char buffer[22]; duration_t(print_job_timer.duration()).toString(buffer); - ui.set_status(buffer); + ui.set_status(buffer, ENABLED(DWIN_LCD_PROUI)); SERIAL_ECHO_MSG("Print time: ", buffer); } diff --git a/Marlin/src/gcode/stats/M75-M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp index 7d16899fd34e..0ed1e6693013 100644 --- a/Marlin/src/gcode/stats/M75-M78.cpp +++ b/Marlin/src/gcode/stats/M75-M78.cpp @@ -29,8 +29,8 @@ #include "../../MarlinCore.h" // for startOrResumeJob -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" +#if ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin.h" #endif /** @@ -38,9 +38,9 @@ */ void GcodeSuite::M75() { startOrResumeJob(); - #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) - DWIN_Print_Header(parser.string_arg && parser.string_arg[0] ? parser.string_arg : GET_TEXT(MSG_HOST_START_PRINT)); + #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 } @@ -50,6 +50,7 @@ void GcodeSuite::M75() { void GcodeSuite::M76() { print_job_timer.pause(); TERN_(HOST_PAUSE_M76, hostui.pause()); + TERN_(DWIN_LCD_PROUI, DWIN_Print_Pause()); } /** @@ -57,7 +58,7 @@ void GcodeSuite::M76() { */ void GcodeSuite::M77() { print_job_timer.stop(); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Print_Finished()); + TERN_(DWIN_LCD_PROUI, DWIN_Print_Finished()); } #if ENABLED(PRINTCOUNTER) diff --git a/Marlin/src/gcode/temp/M104_M109.cpp b/Marlin/src/gcode/temp/M104_M109.cpp index baaac0210098..331ceeb61db1 100644 --- a/Marlin/src/gcode/temp/M104_M109.cpp +++ b/Marlin/src/gcode/temp/M104_M109.cpp @@ -126,7 +126,7 @@ void GcodeSuite::M104_M109(const bool isM109) { #endif if (thermalManager.isHeatingHotend(target_extruder) || !no_wait_for_cooling) - thermalManager.set_heating_message(target_extruder); + thermalManager.set_heating_message(target_extruder, !isM109 && got_temp); } TERN_(AUTOTEMP, planner.autotemp_M104_M109()); diff --git a/Marlin/src/gcode/temp/M140_M190.cpp b/Marlin/src/gcode/temp/M140_M190.cpp index 7532defccdac..c5e3c000290c 100644 --- a/Marlin/src/gcode/temp/M140_M190.cpp +++ b/Marlin/src/gcode/temp/M140_M190.cpp @@ -82,14 +82,18 @@ void GcodeSuite::M140_M190(const bool isM190) { if (!got_temp) return; thermalManager.setTargetBed(temp); + thermalManager.isHeatingBed() ? LCD_MESSAGE(MSG_BED_HEATING) : LCD_MESSAGE(MSG_BED_COOLING); - ui.set_status(thermalManager.isHeatingBed() ? GET_TEXT_F(MSG_BED_HEATING) : GET_TEXT_F(MSG_BED_COOLING)); - - // with PRINTJOB_TIMER_AUTOSTART, M190 can start the timer, and M140 can stop it + // With PRINTJOB_TIMER_AUTOSTART, M190 can start the timer, and M140 can stop it TERN_(PRINTJOB_TIMER_AUTOSTART, thermalManager.auto_job_check_timer(isM190, !isM190)); if (isM190) thermalManager.wait_for_bed(no_wait_for_cooling); + else + ui.set_status_reset_fn([]{ + const celsius_t c = thermalManager.degTargetBed(); + return c < 30 || thermalManager.degBedNear(c); + }); } #endif // HAS_HEATED_BED diff --git a/Marlin/src/gcode/temp/M192.cpp b/Marlin/src/gcode/temp/M192.cpp index a96e2d34a4bf..04b36a548c3c 100644 --- a/Marlin/src/gcode/temp/M192.cpp +++ b/Marlin/src/gcode/temp/M192.cpp @@ -49,7 +49,7 @@ void GcodeSuite::M192() { } const celsius_t target_temp = parser.value_celsius(); - ui.set_status(thermalManager.isProbeBelowTemp(target_temp) ? GET_TEXT_F(MSG_PROBE_HEATING) : GET_TEXT_F(MSG_PROBE_COOLING)); + thermalManager.isProbeBelowTemp(target_temp) ? LCD_MESSAGE(MSG_PROBE_HEATING) : LCD_MESSAGE(MSG_PROBE_COOLING); thermalManager.wait_for_probe(target_temp, no_wait_for_cooling); } diff --git a/Marlin/src/gcode/temp/M303.cpp b/Marlin/src/gcode/temp/M303.cpp index f823aefbed97..ce362984a6ca 100644 --- a/Marlin/src/gcode/temp/M303.cpp +++ b/Marlin/src/gcode/temp/M303.cpp @@ -30,8 +30,8 @@ #if ENABLED(EXTENSIBLE_UI) #include "../../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../../lcd/e3v2/proui/dwin.h" #endif /** @@ -71,16 +71,24 @@ void GcodeSuite::M303() { case H_CHAMBER: default_temp = PREHEAT_1_TEMP_CHAMBER; break; #endif default: + SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_BAD_HEATER_ID); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_BAD_EXTRUDER_NUM)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_BAD_EXTRUDER_NUM)); return; } - const celsius_t temp = parser.celsiusval('S', default_temp); - const int c = parser.intval('C', 5); + const bool seenC = parser.seenval('C'); + const int c = seenC ? parser.value_int() : 5; + const bool seenS = parser.seenval('S'); + const celsius_t temp = seenS ? parser.value_celsius() : default_temp; const bool u = parser.boolval('U'); + #if ENABLED(DWIN_LCD_PROUI) + if (seenC) HMI_data.PidCycles = c; + if (seenS) { if (hid == H_BED) HMI_data.BedPidT = temp; else HMI_data.HotendPidT = temp; } + #endif + #if DISABLED(BUSY_WHILE_HEATING) KEEPALIVE_STATE(NOT_BUSY); #endif diff --git a/Marlin/src/gcode/temp/M306.cpp b/Marlin/src/gcode/temp/M306.cpp new file mode 100644 index 000000000000..4286b2017e22 --- /dev/null +++ b/Marlin/src/gcode/temp/M306.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 . + * + */ + +#include "../../inc/MarlinConfig.h" + +#if ENABLED(MPCTEMP) + +#include "../gcode.h" +#include "../../module/temperature.h" + +/** + * M306: MPC settings and autotune + * + * T Autotune the active extruder. + * + * A Ambient heat transfer coefficient (no fan). + * C Block heat capacity. + * E Extruder number to set. (Default: E0) + * F Ambient heat transfer coefficient (fan on full). + * H Filament heat capacity per mm. + * P Heater power. + * R Sensor responsiveness (= transfer coefficient / heat capcity). + */ + +void GcodeSuite::M306() { + if (parser.seen_test('T')) { thermalManager.MPC_autotune(); return; } + + if (parser.seen("ACFPRH")) { + const heater_id_t hid = (heater_id_t)parser.intval('E', 0); + MPC_t &constants = thermalManager.temp_hotend[hid].constants; + if (parser.seenval('P')) constants.heater_power = parser.value_float(); + if (parser.seenval('C')) constants.block_heat_capacity = parser.value_float(); + if (parser.seenval('R')) constants.sensor_responsiveness = parser.value_float(); + if (parser.seenval('A')) constants.ambient_xfer_coeff_fan0 = parser.value_float(); + #if ENABLED(MPC_INCLUDE_FAN) + if (parser.seenval('F')) constants.fan255_adjustment = parser.value_float() - constants.ambient_xfer_coeff_fan0; + #endif + if (parser.seenval('H')) constants.filament_heat_capacity_permm = parser.value_float(); + return; + } + + M306_report(true); +} + +void GcodeSuite::M306_report(const bool forReplay/*=true*/) { + report_heading(forReplay, F("Model predictive control")); + HOTEND_LOOP() { + report_echo_start(forReplay); + MPC_t& constants = thermalManager.temp_hotend[e].constants; + SERIAL_ECHOPGM(" M306 E", e); + SERIAL_ECHOPAIR_F(" P", constants.heater_power, 2); + SERIAL_ECHOPAIR_F(" C", constants.block_heat_capacity, 2); + SERIAL_ECHOPAIR_F(" R", constants.sensor_responsiveness, 4); + SERIAL_ECHOPAIR_F(" A", constants.ambient_xfer_coeff_fan0, 4); + #if ENABLED(MPC_INCLUDE_FAN) + SERIAL_ECHOPAIR_F(" F", constants.ambient_xfer_coeff_fan0 + constants.fan255_adjustment, 4); + #endif + SERIAL_ECHOPAIR_F(" M", constants.filament_heat_capacity_permm, 4); + SERIAL_EOL(); + } +} + +#endif // MPCTEMP diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 9e050101aa36..5b6313b19d70 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -41,13 +41,13 @@ * * DOGLCD : Run a Graphical LCD through U8GLib (with MarlinUI) * IS_ULTIPANEL : Define LCD_PINS_D5/6/7 for direct-connected "Ultipanel" LCDs - * IS_ULTRA_LCD : Ultra LCD, not necessarily Ultipanel. + * HAS_WIRED_LCD : Ultra LCD, not necessarily Ultipanel. * IS_RRD_SC : Common RRD Smart Controller digital interface pins * IS_RRD_FG_SC : Common RRD Full Graphical Smart Controller digital interface pins * IS_U8GLIB_ST7920 : Most common DOGM display SPI interface, supporting a "lightweight" display mode. * U8GLIB_SH1106 : SH1106 OLED with I2C interface via U8GLib * IS_U8GLIB_SSD1306 : SSD1306 OLED with I2C interface via U8GLib (U8GLIB_SSD1306) - * U8GLIB_SSD1309 : SSD1309 OLED with I2C interface via U8GLib (HAS_U8GLIB_I2C_OLED, IS_ULTRA_LCD, DOGLCD) + * U8GLIB_SSD1309 : SSD1309 OLED with I2C interface via U8GLib (HAS_U8GLIB_I2C_OLED, HAS_WIRED_LCD, DOGLCD) * IS_U8GLIB_ST7565_64128N : ST7565 128x64 LCD with SPI interface via U8GLib * IS_U8GLIB_LM6059_AF : LM6059 with Hardware SPI via U8GLib */ @@ -78,8 +78,8 @@ // This helps to implement HAS_ADC_BUTTONS menus #define REVERSE_MENU_DIRECTION - #define ENCODER_PULSES_PER_STEP 1 - #define ENCODER_STEPS_PER_MENU_ITEM 1 + #define STD_ENCODER_PULSES_PER_STEP 1 + #define STD_ENCODER_STEPS_PER_MENU_ITEM 1 #define ENCODER_FEEDRATE_DEADZONE 2 #elif ENABLED(ZONESTAR_12864LCD) @@ -97,13 +97,12 @@ #elif ENABLED(RADDS_DISPLAY) #define IS_ULTIPANEL 1 - #define ENCODER_PULSES_PER_STEP 2 + #define STD_ENCODER_PULSES_PER_STEP 2 #elif ANY(miniVIKI, VIKI2, WYH_L12864, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864) - #define IS_DOGM_12864 1 - #define DOGLCD + #define IS_DOGM_12864 1 #define IS_ULTIPANEL 1 #if ENABLED(miniVIKI) @@ -158,44 +157,19 @@ #define IS_RRD_SC 1 #define U8GLIB_SH1106 - #define LED_CONTROL_MENU - #define NEOPIXEL_LED - #undef NEOPIXEL_TYPE - #define NEOPIXEL_TYPE NEO_RGB - #if NEOPIXEL_PIXELS < 3 - #undef NEOPIXELS_PIXELS - #define NEOPIXEL_PIXELS 3 - #endif #ifndef NEOPIXEL_BRIGHTNESS #define NEOPIXEL_BRIGHTNESS 127 #endif - #if ENABLED(PSU_CONTROL) - #define LED_BACKLIGHT_TIMEOUT 10000 - #endif - #elif ANY(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1, FYSETC_GENERIC_12864_1_1) #define FYSETC_MINI_12864 #define DOGLCD #define IS_ULTIPANEL 1 #define LED_COLORS_REDUCE_GREEN - #if ENABLED(PSU_CONTROL) && EITHER(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1) - #define LED_BACKLIGHT_TIMEOUT 10000 - #endif // Require LED backlighting enabled - #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) - #define RGB_LED - #elif ENABLED(FYSETC_MINI_12864_2_1) - #define LED_CONTROL_MENU - #define NEOPIXEL_LED - #undef NEOPIXEL_TYPE - #define NEOPIXEL_TYPE NEO_RGB - #if NEOPIXEL_PIXELS < 3 - #undef NEOPIXELS_PIXELS - #define NEOPIXEL_PIXELS 3 - #endif + #if ENABLED(FYSETC_MINI_12864_2_1) #ifndef NEOPIXEL_BRIGHTNESS #define NEOPIXEL_BRIGHTNESS 127 #endif @@ -207,8 +181,11 @@ #define IS_ULTIPANEL 1 #define U8GLIB_SSD1309 #define LCD_RESET_PIN LCD_PINS_D6 // This controller need a reset pin - #define ENCODER_PULSES_PER_STEP 2 - #define ENCODER_STEPS_PER_MENU_ITEM 2 + #define STD_ENCODER_PULSES_PER_STEP 4 + #define STD_ENCODER_STEPS_PER_MENU_ITEM 1 + #ifndef PCA9632 + #define PCA9632 + #endif #elif ENABLED(MAKEBOARD_MINI_2_LINE_DISPLAY_1602) @@ -234,7 +211,7 @@ #define LCD_HEIGHT 10 // Character lines #define LCD_CONTRAST_MIN 127 #define LCD_CONTRAST_MAX 255 - #define DEFAULT_LCD_CONTRAST 250 + #define LCD_CONTRAST_DEFAULT 250 #define CONVERT_TO_EXT_ASCII // Use extended 128-255 symbols from ASCII table. // At this time present conversion only for cyrillic - bg, ru and uk languages. // First 7 ASCII symbols in panel font must be replaced with Marlin's special symbols. @@ -302,14 +279,14 @@ #define PCA9632_BUZZER #define PCA9632_BUZZER_DATA { 0x09, 0x02 } - #define ENCODER_PULSES_PER_STEP 1 // Overlord uses buttons - #define ENCODER_STEPS_PER_MENU_ITEM 1 + #define STD_ENCODER_PULSES_PER_STEP 1 // Overlord uses buttons + #define STD_ENCODER_STEPS_PER_MENU_ITEM 1 #endif // 128x64 I2C OLED LCDs - SSD1306/SSD1309/SH1106 #if ANY(U8GLIB_SSD1306, U8GLIB_SSD1309, U8GLIB_SH1106) #define HAS_U8GLIB_I2C_OLED 1 - #define IS_ULTRA_LCD 1 + #define HAS_WIRED_LCD 1 #define DOGLCD #endif @@ -465,7 +442,7 @@ #endif #if EITHER(IS_ULTIPANEL, ULTRA_LCD) - #define IS_ULTRA_LCD 1 + #define HAS_WIRED_LCD 1 #endif #if EITHER(IS_ULTIPANEL, REPRAPWORLD_KEYPAD) @@ -495,29 +472,27 @@ #endif // Aliases for LCD features -#if EITHER(DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_ENHANCED) +#if EITHER(DWIN_CREALITY_LCD, DWIN_LCD_PROUI) #define HAS_DWIN_E3V2_BASIC 1 #endif #if EITHER(HAS_DWIN_E3V2_BASIC, DWIN_CREALITY_LCD_JYERSUI) #define HAS_DWIN_E3V2 1 #endif +#if ENABLED(DWIN_LCD_PROUI) + #define DO_LIST_BIN_FILES 1 +#endif // E3V2 extras #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI #define SERIAL_CATCHALL 0 - #ifndef LCD_SERIAL_PORT - #if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_MINI_E3_V1_2, BTT_SKR_MINI_E3_V2_0, BTT_SKR_E3_TURBO) - #define LCD_SERIAL_PORT 1 - #else - #define LCD_SERIAL_PORT 3 // Creality 4.x board - #endif - #endif #define HAS_LCD_BRIGHTNESS 1 #define LCD_BRIGHTNESS_MAX 250 + #if ENABLED(DWIN_LCD_PROUI) + #define LCD_BRIGHTNESS_DEFAULT 127 + #endif #endif -#if IS_ULTRA_LCD - #define HAS_WIRED_LCD 1 +#if HAS_WIRED_LCD #if ENABLED(DOGLCD) #define HAS_MARLINUI_U8GLIB 1 #elif IS_TFTGLCD_PANEL @@ -530,16 +505,24 @@ #endif #endif -#if ANY(HAS_WIRED_LCD, EXTENSIBLE_UI, DWIN_CREALITY_LCD_JYERSUI) +#if ANY(HAS_WIRED_LCD, EXTENSIBLE_UI, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) #define HAS_DISPLAY 1 #endif -#if ANY(HAS_DISPLAY, HAS_DWIN_E3V2, GLOBAL_STATUS_MESSAGE) +#if HAS_WIRED_LCD && !HAS_GRAPHICAL_TFT && !IS_DWIN_MARLINUI + #define HAS_LCDPRINT 1 +#endif + +#if ANY(HAS_DISPLAY, HAS_DWIN_E3V2) #define HAS_STATUS_MESSAGE 1 #endif #if IS_ULTIPANEL && DISABLED(NO_LCD_MENUS) - #define HAS_LCD_MENU 1 + #define HAS_MARLINUI_MENU 1 +#endif + +#if ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, HAS_DWIN_E3V2) + #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) @@ -686,16 +669,199 @@ * Number of Linear Axes (e.g., XYZ) * All the logical axes except for the tool (E) axis */ -#ifndef LINEAR_AXES - #define LINEAR_AXES XYZ +#ifdef LINEAR_AXES + #undef LINEAR_AXES + #define LINEAR_AXES_WARNING 1 +#endif + +#ifdef K_DRIVER_TYPE + #define LINEAR_AXES 6 +#elif defined(J_DRIVER_TYPE) + #define LINEAR_AXES 5 +#elif defined(I_DRIVER_TYPE) + #define LINEAR_AXES 4 +#elif defined(Z_DRIVER_TYPE) + #define LINEAR_AXES 3 +#elif defined(Y_DRIVER_TYPE) + #define LINEAR_AXES 2 +#else + #define LINEAR_AXES 1 #endif #if LINEAR_AXES >= XY #define HAS_Y_AXIS 1 #if LINEAR_AXES >= XYZ #define HAS_Z_AXIS 1 + #ifdef Z4_DRIVER_TYPE + #define NUM_Z_STEPPERS 4 + #elif defined(Z3_DRIVER_TYPE) + #define NUM_Z_STEPPERS 3 + #elif defined(Z2_DRIVER_TYPE) + #define NUM_Z_STEPPERS 2 + #else + #define NUM_Z_STEPPERS 1 + #endif + #if LINEAR_AXES >= 4 + #define HAS_I_AXIS 1 + #if LINEAR_AXES >= 5 + #define HAS_J_AXIS 1 + #if LINEAR_AXES >= 6 + #define HAS_K_AXIS 1 + #endif + #endif + #endif #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 + #undef Y_MIN_ENDSTOP_INVERTING + #undef Y_MAX_ENDSTOP_INVERTING + #undef Y2_DRIVER_TYPE + #undef Y_ENABLE_ON + #undef DISABLE_Y + #undef INVERT_Y_DIR + #undef Y_HOME_DIR + #undef Y_MIN_POS + #undef Y_MAX_POS + #undef MANUAL_Y_HOME_POS +#endif + +#if !HAS_Z_AXIS + #undef ENDSTOPPULLUP_ZMIN + #undef ENDSTOPPULLUP_ZMAX + #undef Z_MIN_ENDSTOP_INVERTING + #undef Z_MAX_ENDSTOP_INVERTING + #undef Z2_DRIVER_TYPE + #undef Z3_DRIVER_TYPE + #undef Z4_DRIVER_TYPE + #undef Z_ENABLE_ON + #undef DISABLE_Z + #undef INVERT_Z_DIR + #undef Z_HOME_DIR + #undef Z_MIN_POS + #undef Z_MAX_POS + #undef MANUAL_Z_HOME_POS +#endif + +#if !HAS_I_AXIS + #undef ENDSTOPPULLUP_IMIN + #undef ENDSTOPPULLUP_IMAX + #undef I_MIN_ENDSTOP_INVERTING + #undef I_MAX_ENDSTOP_INVERTING + #undef I_ENABLE_ON + #undef DISABLE_I + #undef INVERT_I_DIR + #undef I_HOME_DIR + #undef I_MIN_POS + #undef I_MAX_POS + #undef MANUAL_I_HOME_POS +#endif + +#if !HAS_J_AXIS + #undef ENDSTOPPULLUP_JMIN + #undef ENDSTOPPULLUP_JMAX + #undef J_MIN_ENDSTOP_INVERTING + #undef J_MAX_ENDSTOP_INVERTING + #undef J_ENABLE_ON + #undef DISABLE_J + #undef INVERT_J_DIR + #undef J_HOME_DIR + #undef J_MIN_POS + #undef J_MAX_POS + #undef MANUAL_J_HOME_POS +#endif + +#if !HAS_K_AXIS + #undef ENDSTOPPULLUP_KMIN + #undef ENDSTOPPULLUP_KMAX + #undef K_MIN_ENDSTOP_INVERTING + #undef K_MAX_ENDSTOP_INVERTING + #undef K_ENABLE_ON + #undef DISABLE_K + #undef INVERT_K_DIR + #undef K_HOME_DIR + #undef K_MIN_POS + #undef K_MAX_POS + #undef MANUAL_K_HOME_POS +#endif + +#if !HAS_U_AXIS + #undef ENDSTOPPULLUP_UMIN + #undef ENDSTOPPULLUP_UMAX + #undef U_MIN_ENDSTOP_INVERTING + #undef U_MAX_ENDSTOP_INVERTING + #undef U_ENABLE_ON + #undef DISABLE_U + #undef INVERT_U_DIR + #undef U_HOME_DIR + #undef U_MIN_POS + #undef U_MAX_POS + #undef MANUAL_U_HOME_POS +#endif + +#if !HAS_V_AXIS + #undef ENDSTOPPULLUP_VMIN + #undef ENDSTOPPULLUP_VMAX + #undef V_MIN_ENDSTOP_INVERTING + #undef V_MAX_ENDSTOP_INVERTING + #undef V_ENABLE_ON + #undef DISABLE_V + #undef INVERT_V_DIR + #undef V_HOME_DIR + #undef V_MIN_POS + #undef V_MAX_POS + #undef MANUAL_V_HOME_POS +#endif + +#if !HAS_W_AXIS + #undef ENDSTOPPULLUP_WMIN + #undef ENDSTOPPULLUP_WMAX + #undef W_MIN_ENDSTOP_INVERTING + #undef W_MAX_ENDSTOP_INVERTING + #undef W_ENABLE_ON + #undef DISABLE_W + #undef INVERT_W_DIR + #undef W_HOME_DIR + #undef W_MIN_POS + #undef W_MAX_POS + #undef MANUAL_W_HOME_POS +#endif + +#ifdef X2_DRIVER_TYPE + #define HAS_X2_STEPPER 1 + // Dual X Carriage isn't known yet. TODO: Consider moving it to Configuration.h. +#endif +#ifdef Y2_DRIVER_TYPE + #define HAS_Y2_STEPPER 1 + #define HAS_DUAL_Y_STEPPERS 1 +#endif + /** * Number of Logical Axes (e.g., XYZE) * All the logical axes that can be commanded directly by G-code. @@ -746,6 +912,7 @@ #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 ARRAY_BY_EXTRUDERS(V...) ARRAY_N(EXTRUDERS, V) #define ARRAY_BY_EXTRUDERS1(v1) ARRAY_N_1(EXTRUDERS, v1) @@ -822,7 +989,7 @@ /** * Set a flag for any type of bed probe, including the paper-test */ -#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) +#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) #define HAS_BED_PROBE 1 #endif @@ -987,7 +1154,11 @@ #undef USE_PROBE_FOR_Z_HOMING #endif -#if Z_HOME_TO_MAX +#if ENABLED(BELTPRINTER) && !defined(HOME_Y_BEFORE_X) + #define HOME_Y_BEFORE_X +#endif + +#if Z_HOME_TO_MAX && DISABLED(Z_SAFE_HOMING) #define HOME_Z_FIRST // If homing away from BED do Z first #endif @@ -996,7 +1167,7 @@ */ #if ENABLED(AUTO_BED_LEVELING_UBL) #undef LCD_BED_LEVELING - #if ENABLED(DELTA) + #if EITHER(DELTA, SEGMENT_LEVELED_MOVES) #define UBL_SEGMENTED 1 #endif #endif @@ -1139,95 +1310,6 @@ #define HAS_ETHERNET 1 #endif -// Fallback Stepper Driver types that don't depend on Configuration_adv.h -#ifndef X_DRIVER_TYPE - #define X_DRIVER_TYPE A4988 -#endif -#ifndef X2_DRIVER_TYPE - #define X2_DRIVER_TYPE A4988 -#endif -#ifndef Y_DRIVER_TYPE - #define Y_DRIVER_TYPE A4988 -#endif -#ifndef Y2_DRIVER_TYPE - #define Y2_DRIVER_TYPE A4988 -#endif -#ifndef Z_DRIVER_TYPE - #define Z_DRIVER_TYPE A4988 -#endif -#ifndef Z2_DRIVER_TYPE - #define Z2_DRIVER_TYPE A4988 -#endif -#ifndef Z3_DRIVER_TYPE - #define Z3_DRIVER_TYPE A4988 -#endif -#ifndef Z4_DRIVER_TYPE - #define Z4_DRIVER_TYPE A4988 -#endif -#if E_STEPPERS <= 0 - #undef E0_DRIVER_TYPE -#elif !defined(E0_DRIVER_TYPE) - #define E0_DRIVER_TYPE A4988 -#endif -#if E_STEPPERS <= 1 - #undef E1_DRIVER_TYPE -#elif !defined(E1_DRIVER_TYPE) - #define E1_DRIVER_TYPE A4988 -#endif -#if E_STEPPERS <= 2 - #undef E2_DRIVER_TYPE -#elif !defined(E2_DRIVER_TYPE) - #define E2_DRIVER_TYPE A4988 -#endif -#if E_STEPPERS <= 3 - #undef E3_DRIVER_TYPE -#elif !defined(E3_DRIVER_TYPE) - #define E3_DRIVER_TYPE A4988 -#endif -#if E_STEPPERS <= 4 - #undef E4_DRIVER_TYPE -#elif !defined(E4_DRIVER_TYPE) - #define E4_DRIVER_TYPE A4988 -#endif -#if E_STEPPERS <= 5 - #undef E5_DRIVER_TYPE -#elif !defined(E5_DRIVER_TYPE) - #define E5_DRIVER_TYPE A4988 -#endif -#if E_STEPPERS <= 6 - #undef E6_DRIVER_TYPE -#elif !defined(E6_DRIVER_TYPE) - #define E6_DRIVER_TYPE A4988 -#endif -#if E_STEPPERS <= 7 - #undef E7_DRIVER_TYPE -#elif !defined(E7_DRIVER_TYPE) - #define E7_DRIVER_TYPE A4988 -#endif - -// Fallback axis inverting -#ifndef INVERT_X_DIR - #define INVERT_X_DIR false -#endif -#if HAS_Y_AXIS && !defined(INVERT_Y_DIR) - #define INVERT_Y_DIR false -#endif -#if HAS_Z_AXIS && !defined(INVERT_Z_DIR) - #define INVERT_Z_DIR false -#endif -#if LINEAR_AXES >= 4 && !defined(INVERT_I_DIR) - #define INVERT_I_DIR false -#endif -#if LINEAR_AXES >= 5 && !defined(INVERT_J_DIR) - #define INVERT_J_DIR false -#endif -#if LINEAR_AXES >= 6 && !defined(INVERT_K_DIR) - #define INVERT_K_DIR false -#endif -#if HAS_EXTRUDERS && !defined(INVERT_E_DIR) - #define INVERT_E_DIR false -#endif - /** * This setting is also used by M109 when trying to calculate * a ballpark safe margin to prevent wait-forever situation. @@ -1411,7 +1493,7 @@ #endif #endif -#if ANY(USE_XMIN_PLUG, USE_YMIN_PLUG, USE_ZMIN_PLUG, USE_XMAX_PLUG, USE_YMAX_PLUG, USE_ZMAX_PLUG) +#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) #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 9864b8715c75..0490f33eb0dd 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -23,7 +23,7 @@ /** * Conditionals_adv.h - * Defines that depend on advanced configuration. + * Conditionals set before pins.h and which depend on Configuration_adv.h. */ #ifndef AXIS_RELATIVE_MODES @@ -118,9 +118,9 @@ // Temperature sensor IDs #define HID_REDUNDANT -6 -#define HID_COOLER -5 -#define HID_PROBE -4 -#define HID_BOARD -3 +#define HID_BOARD -5 +#define HID_COOLER -4 +#define HID_PROBE -3 #define HID_CHAMBER -2 #define HID_BED -1 #define HID_E0 0 @@ -587,6 +587,10 @@ #define HAS_PRINT_PROGRESS 1 #endif +#if STATUS_MESSAGE_TIMEOUT_SEC > 0 + #define HAS_STATUS_MESSAGE_TIMEOUT 1 +#endif + #if ENABLED(SDSUPPORT) && SD_PROCEDURE_DEPTH #define HAS_MEDIA_SUBCALLS 1 #endif @@ -618,17 +622,26 @@ #if ANY(BLINKM, RGB_LED, RGBW_LED, PCA9632, PCA9533, NEOPIXEL_LED) #define HAS_COLOR_LEDS 1 +#else + #undef LED_POWEROFF_TIMEOUT #endif #if ALL(HAS_RESUME_CONTINUE, PRINTER_EVENT_LEDS, SDSUPPORT) #define HAS_LEDS_OFF_FLAG 1 #endif +#ifdef DISPLAY_SLEEP_MINUTES + #define HAS_DISPLAY_SLEEP 1 +#endif +#if HAS_DISPLAY_SLEEP || LCD_BACKLIGHT_TIMEOUT + #define HAS_GCODE_M255 1 +#endif #if EITHER(DIGIPOT_MCP4018, DIGIPOT_MCP4451) #define HAS_MOTOR_CURRENT_I2C 1 #endif #if ENABLED(Z_STEPPER_AUTO_ALIGN) - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #ifdef Z_STEPPER_ALIGN_STEPPER_XY + #define HAS_Z_STEPPER_ALIGN_STEPPER_XY 1 #undef Z_STEPPER_ALIGN_AMP #endif #ifndef Z_STEPPER_ALIGN_AMP @@ -637,33 +650,20 @@ #endif // Multiple Z steppers -#ifndef NUM_Z_STEPPER_DRIVERS - #define NUM_Z_STEPPER_DRIVERS 1 -#endif - -// Fallback Stepper Driver types that depend on Configuration_adv.h -#if EITHER(DUAL_X_CARRIAGE, X_DUAL_STEPPER_DRIVERS) - #define HAS_X2_STEPPER 1 -#else - #undef X2_DRIVER_TYPE -#endif -#if DISABLED(Y_DUAL_STEPPER_DRIVERS) - #undef Y2_DRIVER_TYPE -#endif - -#if NUM_Z_STEPPER_DRIVERS < 4 - #undef Z4_DRIVER_TYPE +#if NUM_Z_STEPPERS < 4 #undef INVERT_Z4_VS_Z_DIR - #if NUM_Z_STEPPER_DRIVERS < 3 - #undef Z3_DRIVER_TYPE + #if NUM_Z_STEPPERS < 3 #undef INVERT_Z3_VS_Z_DIR - #if NUM_Z_STEPPER_DRIVERS < 2 - #undef Z2_DRIVER_TYPE + #if NUM_Z_STEPPERS < 2 #undef INVERT_Z2_VS_Z_DIR #endif #endif #endif +#if defined(X2_DRIVER_TYPE) && DISABLED(DUAL_X_CARRIAGE) + #define HAS_DUAL_X_STEPPERS 1 +#endif + // // Spindle/Laser power display types // Defined here so sanity checks can use them @@ -677,11 +677,6 @@ #define CUTTER_UNIT_IS(V) (_CUTTER_POWER(CUTTER_POWER_UNIT) == _CUTTER_POWER(V)) #endif -// Add features that need hardware PWM here -#if ANY(FAST_PWM_FAN, SPINDLE_LASER_USE_PWM) - #define NEEDS_HARDWARE_PWM 1 -#endif - #if !defined(__AVR__) || !defined(USBCON) // Define constants and variables for buffering serial data. // Use only 0 or powers of 2 greater than 1 @@ -699,6 +694,10 @@ #undef SERIAL_XON_XOFF #endif +#if ENABLED(HOST_PROMPT_SUPPORT) && DISABLED(EMERGENCY_PARSER) + #define HAS_GCODE_M876 1 +#endif + #if ENABLED(HOST_ACTION_COMMANDS) #ifndef ACTION_ON_PAUSE #define ACTION_ON_PAUSE "pause" @@ -743,9 +742,6 @@ #endif #if EITHER(FYSETC_MINI_12864_2_1, FYSETC_242_OLED_12864) - #define LED_CONTROL_MENU - #define LED_USER_PRESET_STARTUP - #define LED_COLOR_PRESETS #ifndef LED_USER_PRESET_GREEN #define LED_USER_PRESET_GREEN 128 #endif @@ -935,7 +931,7 @@ #undef HOME_Z_FIRST #undef HOMING_Z_WITH_PROBE #undef ENABLE_LEVELING_FADE_HEIGHT - #undef NUM_Z_STEPPER_DRIVERS + #undef NUM_Z_STEPPERS #undef CNC_WORKSPACE_PLANES #if LINEAR_AXES < 2 #undef STEALTHCHOP_Y @@ -973,7 +969,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) +#if ANY(AUTO_BED_LEVELING_UBL, M100_FREE_MEMORY_WATCHER, DEBUG_GCODE_PARSER, TMC_DEBUG, MARLIN_DEV_MODE, DEBUG_CARDREADER) #define NEED_HEX_PRINT 1 #endif @@ -986,8 +982,13 @@ #endif #endif +// Flags for Case Light having a brightness property +#if ENABLED(CASE_LIGHT_ENABLE) && (NONE(CASE_LIGHT_NO_BRIGHTNESS, CASE_LIGHT_IS_COLOR_LED) || ENABLED(CASE_LIGHT_USE_NEOPIXEL)) + #define CASELIGHT_USES_BRIGHTNESS 1 +#endif + // Flag whether least_squares_fit.cpp is used -#if ANY(AUTO_BED_LEVELING_UBL, AUTO_BED_LEVELING_LINEAR, Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) +#if ANY(AUTO_BED_LEVELING_UBL, AUTO_BED_LEVELING_LINEAR, HAS_Z_STEPPER_ALIGN_STEPPER_XY) #define NEED_LSF 1 #endif @@ -998,6 +999,24 @@ #define HAS_USER_ITEM(N) 0 #endif +/** + * 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) + #define LCD_SERIAL_PORT 1 + #elif MB(CREALITY_V24S1_301, CREALITY_V24S1_301F4, CREALITY_V423) + #define LCD_SERIAL_PORT 2 // Creality Ender3S1 board + #else + #define LCD_SERIAL_PORT 3 // Creality 4.x board + #endif + #endif + #ifdef LCD_SERIAL_PORT + #define AUTO_ASSIGNED_LCD_SERIAL 1 + #endif +#endif + #if !HAS_MULTI_SERIAL #undef MEATPACK_ON_SERIAL_PORT_2 #endif @@ -1006,7 +1025,11 @@ #endif // AVR are (usually) too limited in resources to store the configuration into the binary -#if !defined(FORCE_CONFIG_EMBED) && (defined(__AVR__) || DISABLED(SDSUPPORT) || EITHER(SDCARD_READONLY, DISABLE_M503)) +#if ENABLED(CONFIGURATION_EMBEDDING) && !defined(FORCE_CONFIG_EMBED) && (defined(__AVR__) || DISABLED(SDSUPPORT) || EITHER(SDCARD_READONLY, DISABLE_M503)) #undef CONFIGURATION_EMBEDDING #define CANNOT_EMBED_CONFIGURATION defined(__AVR__) #endif + +#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 diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index a5c9d20eda9e..dd6b165328fe 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -23,7 +23,7 @@ /** * Conditionals_post.h - * Defines that depend on configuration but are not editable. + * Internal defines that depend on Configurations and Pins but are not user-editable. */ #ifdef GITHUB_ACTIONS @@ -78,13 +78,13 @@ /** * Axis lengths and center */ -#ifndef AXIS4_NAME +#if HAS_I_AXIS && !defined(AXIS4_NAME) #define AXIS4_NAME 'A' #endif -#ifndef AXIS5_NAME +#if HAS_J_AXIS && !defined(AXIS5_NAME) #define AXIS5_NAME 'B' #endif -#ifndef AXIS6_NAME +#if HAS_K_AXIS && !defined(AXIS6_NAME) #define AXIS6_NAME 'C' #endif @@ -97,13 +97,13 @@ #else #undef CONTROLLER_FAN_USE_Z_ONLY #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #define I_MAX_LENGTH (I_MAX_POS - (I_MIN_POS)) #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #define J_MAX_LENGTH (J_MAX_POS - (J_MIN_POS)) #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #define K_MAX_LENGTH (K_MAX_POS - (K_MIN_POS)) #endif @@ -114,13 +114,13 @@ #if HAS_Y_AXIS && !defined(Y_BED_SIZE) #define Y_BED_SIZE Y_MAX_LENGTH #endif -#if LINEAR_AXES >= 4 && !defined(I_BED_SIZE) +#if HAS_I_AXIS && !defined(I_BED_SIZE) #define I_BED_SIZE I_MAX_LENGTH #endif -#if LINEAR_AXES >= 5 && !defined(J_BED_SIZE) +#if HAS_J_AXIS && !defined(J_BED_SIZE) #define J_BED_SIZE J_MAX_LENGTH #endif -#if LINEAR_AXES >= 6 && !defined(K_BED_SIZE) +#if HAS_K_AXIS && !defined(K_BED_SIZE) #define K_BED_SIZE K_MAX_LENGTH #endif @@ -134,13 +134,13 @@ #if HAS_Y_AXIS #define _Y_HALF_BED ((Y_BED_SIZE) / 2) #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #define _I_HALF_IMAX ((I_BED_SIZE) / 2) #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #define _J_HALF_JMAX ((J_BED_SIZE) / 2) #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #define _K_HALF_KMAX ((K_BED_SIZE) / 2) #endif @@ -149,13 +149,13 @@ #define Y_CENTER TERN(BED_CENTER_AT_0_0, 0, _Y_HALF_BED) #define XY_CENTER { X_CENTER, Y_CENTER } #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #define I_CENTER TERN(BED_CENTER_AT_0_0, 0, _I_HALF_BED) #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #define J_CENTER TERN(BED_CENTER_AT_0_0, 0, _J_HALF_BED) #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #define K_CENTER TERN(BED_CENTER_AT_0_0, 0, _K_HALF_BED) #endif @@ -166,15 +166,15 @@ #define Y_MIN_BED (Y_CENTER - _Y_HALF_BED) #define Y_MAX_BED (Y_MIN_BED + Y_BED_SIZE) #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #define I_MINIM (I_CENTER - _I_HALF_BED_SIZE) #define I_MAXIM (I_MINIM + I_BED_SIZE) #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #define J_MINIM (J_CENTER - _J_HALF_BED_SIZE) #define J_MAXIM (J_MINIM + J_BED_SIZE) #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #define K_MINIM (K_CENTER - _K_HALF_BED_SIZE) #define K_MAXIM (K_MINIM + K_BED_SIZE) #endif @@ -205,7 +205,7 @@ * No adjustable bed on non-cartesians */ #if IS_KINEMATIC - #undef LEVEL_BED_CORNERS + #undef LCD_BED_TRAMMING #endif /** @@ -253,21 +253,21 @@ #define Z_HOME_POS TERN(Z_HOME_TO_MIN, Z_MIN_POS, Z_MAX_POS) #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #ifdef MANUAL_I_HOME_POS #define I_HOME_POS MANUAL_I_HOME_POS #else #define I_HOME_POS TERN(I_HOME_TO_MIN, I_MIN_POS, I_MAX_POS) #endif #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #ifdef MANUAL_J_HOME_POS #define J_HOME_POS MANUAL_J_HOME_POS #else #define J_HOME_POS TERN(J_HOME_TO_MIN, J_MIN_POS, J_MAX_POS) #endif #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #ifdef MANUAL_K_HOME_POS #define K_HOME_POS MANUAL_K_HOME_POS #else @@ -376,8 +376,8 @@ #elif EITHER(MKS_MINI_12864_V3, BTT_MINI_12864_V1) #define _LCD_CONTRAST_MIN 255 #define _LCD_CONTRAST_INIT 255 - #define _LCD_CONTRAST_MAX 255 #elif ENABLED(FYSETC_MINI_12864) + #define _LCD_CONTRAST_MIN 180 #define _LCD_CONTRAST_INIT 220 #elif ENABLED(ULTI_CONTROLLER) #define _LCD_CONTRAST_INIT 127 @@ -389,18 +389,12 @@ #elif ENABLED(ZONESTAR_12864OLED) #define _LCD_CONTRAST_MIN 64 #define _LCD_CONTRAST_INIT 128 - #define _LCD_CONTRAST_MAX 255 #elif IS_TFTGLCD_PANEL - #define _LCD_CONTRAST_MIN 0 #define _LCD_CONTRAST_INIT 250 - #define _LCD_CONTRAST_MAX 255 #endif #ifdef _LCD_CONTRAST_INIT #define HAS_LCD_CONTRAST 1 -#endif - -#if HAS_LCD_CONTRAST #ifndef LCD_CONTRAST_MIN #ifdef _LCD_CONTRAST_MIN #define LCD_CONTRAST_MIN _LCD_CONTRAST_MIN @@ -420,8 +414,8 @@ #define LCD_CONTRAST_MAX 63 // ST7567 6-bits contrast #endif #endif - #ifndef DEFAULT_LCD_CONTRAST - #define DEFAULT_LCD_CONTRAST LCD_CONTRAST_INIT + #ifndef LCD_CONTRAST_DEFAULT + #define LCD_CONTRAST_DEFAULT LCD_CONTRAST_INIT #endif #endif @@ -441,20 +435,28 @@ #define HAS_SHARED_MEDIA 1 #endif - // Set SD_DETECT_STATE based on hardware if not overridden - #if PIN_EXISTS(SD_DETECT) && !defined(SD_DETECT_STATE) - #if BOTH(HAS_LCD_MENU, ELB_FULL_GRAPHIC_CONTROLLER) && (SD_CONNECTION_IS(LCD) || !defined(SDCARD_CONNECTION)) - #define SD_DETECT_STATE HIGH - #else - #define SD_DETECT_STATE LOW - #endif - #endif - // Extender cable doesn't support SD_DETECT_PIN #if ENABLED(NO_SD_DETECT) #undef SD_DETECT_PIN #endif + // Not onboard or custom cable + #if SD_CONNECTION_IS(LCD) || !defined(SDCARD_CONNECTION) + #define SD_CONNECTION_TYPICAL 1 + #endif + + // Set SD_DETECT_STATE based on hardware if not overridden + #if PIN_EXISTS(SD_DETECT) + #define HAS_SD_DETECT 1 + #ifndef SD_DETECT_STATE + #if ALL(SD_CONNECTION_TYPICAL, HAS_MARLINUI_MENU, ELB_FULL_GRAPHIC_CONTROLLER) + #define SD_DETECT_STATE HIGH + #else + #define SD_DETECT_STATE LOW + #endif + #endif + #endif + #if DISABLED(USB_FLASH_DRIVE_SUPPORT) || BOTH(MULTI_VOLUME, VOLUME_SD_ONBOARD) #if ENABLED(SDIO_SUPPORT) #define NEED_SD2CARD_SDIO 1 @@ -463,10 +465,10 @@ #endif #endif -#endif + #if HAS_SD_DETECT && NONE(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT, IS_DWIN_MARLINUI, EXTENSIBLE_UI, HAS_DWIN_E3V2) + #define REINIT_NOISY_LCD 1 // Have the LCD re-init on SD insertion + #endif -#if ANY(HAS_GRAPHICAL_TFT, LCD_USE_DMA_FSMC, HAS_FSMC_GRAPHICAL_TFT, HAS_SPI_GRAPHICAL_TFT, IS_DWIN_MARLINUI) || !PIN_EXISTS(SD_DETECT) - #define NO_LCD_REINIT 1 // Suppress LCD re-initialization #endif /** @@ -507,7 +509,13 @@ #ifndef TEMP_SENSOR_REDUNDANT_MAX_DIFF #define TEMP_SENSOR_REDUNDANT_MAX_DIFF 10 #endif - #if REDUNDANT_TEMP_MATCH(SOURCE, COOLER) + #if REDUNDANT_TEMP_MATCH(SOURCE, BOARD) + #if !PIN_EXISTS(TEMP_BOARD) + #error "TEMP_SENSOR_REDUNDANT_SOURCE set to BOARD requires TEMP_BOARD_PIN." + #else + #define TEMP_REDUNDANT_PIN TEMP_BOARD_PIN + #endif + #elif REDUNDANT_TEMP_MATCH(SOURCE, COOLER) #if !PIN_EXISTS(TEMP_COOLER) #error "TEMP_SENSOR_REDUNDANT_SOURCE set to COOLER requires TEMP_COOLER_PIN." #else @@ -745,7 +753,7 @@ #define LIB_INTERNAL_MAX31865 1 #endif -#endif //HAS_MAX_TC +#endif // HAS_MAX_TC /** * X_DUAL_ENDSTOPS endstop reassignment @@ -1152,7 +1160,7 @@ #endif #endif - #if NUM_Z_STEPPER_DRIVERS >= 3 + #if NUM_Z_STEPPERS >= 3 #if Z_HOME_TO_MAX #ifndef Z3_MAX_ENDSTOP_INVERTING #if Z3_USE_ENDSTOP == _XMIN_ @@ -1284,7 +1292,7 @@ #endif #endif - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 #if Z_HOME_TO_MAX #ifndef Z4_MAX_ENDSTOP_INVERTING #if Z4_USE_ENDSTOP == _XMIN_ @@ -1575,7 +1583,7 @@ #undef DISABLE_INACTIVE_Z #endif -#if NUM_Z_STEPPER_DRIVERS >= 2 +#if NUM_Z_STEPPERS >= 2 #if PIN_EXISTS(Z2_ENABLE) || AXIS_IS_L64XX(Z2) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2)) #define HAS_Z2_ENABLE 1 #endif @@ -1590,7 +1598,7 @@ #endif #endif -#if NUM_Z_STEPPER_DRIVERS >= 3 +#if NUM_Z_STEPPERS >= 3 #if PIN_EXISTS(Z3_ENABLE) || AXIS_IS_L64XX(Z3) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z3)) #define HAS_Z3_ENABLE 1 #endif @@ -1605,7 +1613,7 @@ #endif #endif -#if NUM_Z_STEPPER_DRIVERS >= 4 +#if NUM_Z_STEPPERS >= 4 #if PIN_EXISTS(Z4_ENABLE) || AXIS_IS_L64XX(Z4) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z4)) #define HAS_Z4_ENABLE 1 #endif @@ -1620,7 +1628,7 @@ #endif #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #if PIN_EXISTS(I_ENABLE) || AXIS_IS_L64XX(I) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(I)) #define HAS_I_ENABLE 1 #endif @@ -1640,7 +1648,7 @@ #undef DISABLE_INACTIVE_I #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #if PIN_EXISTS(J_ENABLE) || AXIS_IS_L64XX(J) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(J)) #define HAS_J_ENABLE 1 #endif @@ -1660,7 +1668,7 @@ #undef DISABLE_INACTIVE_J #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #if PIN_EXISTS(K_ENABLE) || AXIS_IS_L64XX(K) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(K)) #define HAS_K_ENABLE 1 #endif @@ -1920,7 +1928,7 @@ #ifndef Y_SLAVE_ADDRESS #define Y_SLAVE_ADDRESS 0 #endif - #if ENABLED(Y_DUAL_STEPPER_DRIVERS) + #if HAS_DUAL_Y_STEPPERS #if defined(Y2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Y2) #define Y2_SENSORLESS 1 #endif @@ -1958,7 +1966,7 @@ #ifndef Z_SLAVE_ADDRESS #define Z_SLAVE_ADDRESS 0 #endif - #if NUM_Z_STEPPER_DRIVERS >= 2 + #if NUM_Z_STEPPERS >= 2 #if defined(Z2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z2) #define Z2_SENSORLESS 1 #endif @@ -1975,7 +1983,7 @@ #define Z2_SLAVE_ADDRESS 0 #endif #endif - #if NUM_Z_STEPPER_DRIVERS >= 3 + #if NUM_Z_STEPPERS >= 3 #if defined(Z3_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z3) #define Z3_SENSORLESS 1 #endif @@ -1992,7 +2000,7 @@ #define Z3_SLAVE_ADDRESS 0 #endif #endif - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 #if defined(Z4_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z4) #define Z4_SENSORLESS 1 #endif @@ -2214,6 +2222,7 @@ #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) \ || 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(X2, N) || TMC_UART_IS(Y2, N) || TMC_UART_IS(Z2, N) || TMC_UART_IS(Z3, N) || TMC_UART_IS(Z4, N) \ || TMC_UART_IS(E0, N) || TMC_UART_IS(E1, N) || TMC_UART_IS(E2, N) || TMC_UART_IS(E3, N) || TMC_UART_IS(E4, N) ) @@ -2308,8 +2317,8 @@ #define IS_X2_ENDSTOP(A,M) (ENABLED(X_DUAL_ENDSTOPS) && X2_USE_ENDSTOP == _##A##M##_) #define IS_Y2_ENDSTOP(A,M) (ENABLED(Y_DUAL_ENDSTOPS) && Y2_USE_ENDSTOP == _##A##M##_) #define IS_Z2_ENDSTOP(A,M) (ENABLED(Z_MULTI_ENDSTOPS) && Z2_USE_ENDSTOP == _##A##M##_) -#define IS_Z3_ENDSTOP(A,M) (ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 && Z3_USE_ENDSTOP == _##A##M##_) -#define IS_Z4_ENDSTOP(A,M) (ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4 && Z4_USE_ENDSTOP == _##A##M##_) +#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)) #if _HAS_STOP(X,MIN) @@ -2395,28 +2404,28 @@ // 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)) -#if HAS_ADC_TEST(0) +#if HOTENDS > 0 && HAS_ADC_TEST(0) #define HAS_TEMP_ADC_0 1 #endif -#if HAS_ADC_TEST(1) +#if HOTENDS > 1 && HAS_ADC_TEST(1) #define HAS_TEMP_ADC_1 1 #endif -#if HAS_ADC_TEST(2) +#if HOTENDS > 2 && HAS_ADC_TEST(2) #define HAS_TEMP_ADC_2 1 #endif -#if HAS_ADC_TEST(3) +#if HOTENDS > 3 && HAS_ADC_TEST(3) #define HAS_TEMP_ADC_3 1 #endif -#if HAS_ADC_TEST(4) +#if HOTENDS > 4 && HAS_ADC_TEST(4) #define HAS_TEMP_ADC_4 1 #endif -#if HAS_ADC_TEST(5) +#if HOTENDS > 5 && HAS_ADC_TEST(5) #define HAS_TEMP_ADC_5 1 #endif -#if HAS_ADC_TEST(6) +#if HOTENDS > 6 && HAS_ADC_TEST(6) #define HAS_TEMP_ADC_6 1 #endif -#if HAS_ADC_TEST(7) +#if HOTENDS > 7 && HAS_ADC_TEST(7) #define HAS_TEMP_ADC_7 1 #endif #if HAS_ADC_TEST(BED) @@ -2445,12 +2454,12 @@ #if HAS_TEMP(BED) #define HAS_TEMP_BED 1 #endif -#if HAS_TEMP(PROBE) - #define HAS_TEMP_PROBE 1 -#endif #if HAS_TEMP(CHAMBER) #define HAS_TEMP_CHAMBER 1 #endif +#if HAS_TEMP(PROBE) + #define HAS_TEMP_PROBE 1 +#endif #if HAS_TEMP(COOLER) #define HAS_TEMP_COOLER 1 #endif @@ -2549,13 +2558,13 @@ #endif // Thermal protection -#if BOTH(HAS_HEATED_BED, THERMAL_PROTECTION_BED) - #define HAS_THERMALLY_PROTECTED_BED 1 +#if !HAS_HEATED_BED + #undef THERMAL_PROTECTION_BED #endif #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0 #define WATCH_HOTENDS 1 #endif -#if HAS_THERMALLY_PROTECTED_BED && WATCH_BED_TEMP_PERIOD > 0 +#if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0 #define WATCH_BED 1 #endif #if BOTH(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER) && WATCH_CHAMBER_TEMP_PERIOD > 0 @@ -2564,10 +2573,13 @@ #if BOTH(HAS_COOLER, THERMAL_PROTECTION_COOLER) && WATCH_COOLER_TEMP_PERIOD > 0 #define WATCH_COOLER 1 #endif +#if NONE(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_CHAMBER, THERMAL_PROTECTION_BED, THERMAL_PROTECTION_COOLER) + #undef THERMAL_PROTECTION_VARIANCE_MONITOR +#endif #if (ENABLED(THERMAL_PROTECTION_HOTENDS) || !EXTRUDERS) \ && (ENABLED(THERMAL_PROTECTION_BED) || !HAS_HEATED_BED) \ && (ENABLED(THERMAL_PROTECTION_CHAMBER) || !HAS_HEATED_CHAMBER) \ - && (ENABLED(THERMAL_PROTECTION_COOLER) || !HAS_COOLER) + && (ENABLED(THERMAL_PROTECTION_COOLER) || !HAS_COOLER) #define THERMALLY_SAFE 1 #endif @@ -2820,17 +2832,9 @@ #endif // User Interface -#if ENABLED(FREEZE_FEATURE) - #if !PIN_EXISTS(FREEZE) && PIN_EXISTS(KILL) - #define FREEZE_PIN KILL_PIN - #endif - #if PIN_EXISTS(FREEZE) - #define HAS_FREEZE_PIN 1 - #endif -#else - #undef FREEZE_PIN -#endif -#if PIN_EXISTS(KILL) && TERN1(FREEZE_FEATURE, KILL_PIN != FREEZE_PIN) +#if ENABLED(FREEZE_FEATURE) && !PIN_EXISTS(FREEZE) && PIN_EXISTS(KILL) + #define FREEZE_PIN KILL_PIN +#elif PIN_EXISTS(KILL) && TERN1(FREEZE_FEATURE, KILL_PIN != FREEZE_PIN) #define HAS_KILL 1 #endif #if PIN_EXISTS(HOME) @@ -3048,7 +3052,7 @@ #define HAS_TEMPERATURE 1 #endif -#if HAS_TEMPERATURE && EITHER(HAS_LCD_MENU, HAS_DWIN_E3V2) +#if HAS_TEMPERATURE && ANY(HAS_MARLINUI_MENU, HAS_DWIN_E3V2, HAS_DGUS_LCD_CLASSIC) #ifdef PREHEAT_6_LABEL #define PREHEAT_COUNT 6 #elif defined(PREHEAT_5_LABEL) @@ -3173,7 +3177,7 @@ * Advanced Pause - Filament Change */ #if ENABLED(ADVANCED_PAUSE_FEATURE) - #if ANY(HAS_LCD_MENU, EXTENSIBLE_UI, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI) || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT) + #if ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) || BOTH(EMERGENCY_PARSER, HOST_PROMPT_SUPPORT) #define M600_PURGE_MORE_RESUMABLE 1 #endif #ifndef FILAMENT_CHANGE_SLOW_LOAD_LENGTH @@ -3305,9 +3309,9 @@ * Buzzer/Speaker */ #if PIN_EXISTS(BEEPER) - #define USE_BEEPER 1 + #define HAS_BEEPER 1 #endif -#if USE_BEEPER || ANY(LCD_USE_I2C_BUZZER, PCA9632_BUZZER) +#if ANY(HAS_BEEPER, LCD_USE_I2C_BUZZER, PCA9632_BUZZER) #define HAS_BUZZER 1 #endif @@ -3403,7 +3407,7 @@ #endif #endif -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU // LCD timeout to status screen default is 15s #ifndef LCD_TIMEOUT_TO_STATUS #define LCD_TIMEOUT_TO_STATUS 15000 @@ -3503,3 +3507,14 @@ #if PIN_EXISTS(SAFE_POWER) && DISABLED(DISABLE_DRIVER_SAFE_POWER_PROTECT) #define HAS_DRIVER_SAFE_POWER_PROTECT 1 #endif + +#if ANY(ENDSTOPPULLDOWNS, ENDSTOPPULLDOWN_ZMIN_PROBE, \ + ENDSTOPPULLDOWN_XMIN, ENDSTOPPULLDOWN_YMIN, ENDSTOPPULLDOWN_ZMIN, \ + ENDSTOPPULLDOWN_IMIN, ENDSTOPPULLDOWN_JMIN, ENDSTOPPULLDOWN_KMIN, \ + ENDSTOPPULLDOWN_XMAX, ENDSTOPPULLDOWN_YMAX, ENDSTOPPULLDOWN_ZMAX, \ + ENDSTOPPULLDOWN_IMAX, ENDSTOPPULLDOWN_JMAX, ENDSTOPPULLDOWN_KMAX, \ + POWER_LOSS_PULLDOWN, CALIBRATION_PIN_PULLDOWN, FIL_RUNOUT_PULLDOWN, \ + FIL_RUNOUT1_PULLDOWN, FIL_RUNOUT2_PULLDOWN, FIL_RUNOUT3_PULLDOWN, FIL_RUNOUT4_PULLDOWN, \ + FIL_RUNOUT5_PULLDOWN, FIL_RUNOUT6_PULLDOWN, FIL_RUNOUT7_PULLDOWN, FIL_RUNOUT8_PULLDOWN) + #define USING_PULLDOWNS 1 +#endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index c8ac48f7cff5..4e5d3a96aaea 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -371,7 +371,7 @@ #elif defined(FILAMENT_CHANGE_LOAD_LENGTH) #error "FILAMENT_CHANGE_LOAD_LENGTH is now FILAMENT_CHANGE_FAST_LOAD_LENGTH." #elif defined(LEVEL_CORNERS_INSET) - #error "LEVEL_CORNERS_INSET is now LEVEL_CORNERS_INSET_LFRB." + #error "LEVEL_CORNERS_INSET is now BED_TRAMMING_INSET_LFRB." #elif defined(BEZIER_JERK_CONTROL) #error "BEZIER_JERK_CONTROL is now S_CURVE_ACCELERATION." #elif HAS_JUNCTION_DEVIATION && defined(JUNCTION_DEVIATION_FACTOR) @@ -390,6 +390,8 @@ #error "ENDSTOP_NOISE_FILTER is now ENDSTOP_NOISE_THRESHOLD [2-7]." #elif defined(RETRACT_ZLIFT) #error "RETRACT_ZLIFT is now RETRACT_ZRAISE." +#elif defined(TOOLCHANGE_FS_INIT_BEFORE_SWAP) + #error "TOOLCHANGE_FS_INIT_BEFORE_SWAP is now TOOLCHANGE_FS_SLOW_FIRST_PRIME." #elif defined(TOOLCHANGE_PARK_ZLIFT) || defined(TOOLCHANGE_UNPARK_ZLIFT) #error "TOOLCHANGE_PARK_ZLIFT and TOOLCHANGE_UNPARK_ZLIFT are now TOOLCHANGE_ZRAISE." #elif defined(SINGLENOZZLE_TOOLCHANGE_ZRAISE) @@ -522,11 +524,11 @@ #elif defined(Z_QUAD_ENDSTOPS_ADJUSTMENT2) || defined(Z_QUAD_ENDSTOPS_ADJUSTMENT3) || defined(Z_QUAD_ENDSTOPS_ADJUSTMENT4) #error "Z_QUAD_ENDSTOPS_ADJUSTMENT[234] is now Z[234]_ENDSTOP_ADJUSTMENT." #elif defined(Z_DUAL_STEPPER_DRIVERS) - #error "Z_DUAL_STEPPER_DRIVERS is now NUM_Z_STEPPER_DRIVERS with a value of 2." + #error "Z_DUAL_STEPPER_DRIVERS is no longer needed and should be removed." #elif defined(Z_TRIPLE_STEPPER_DRIVERS) - #error "Z_TRIPLE_STEPPER_DRIVERS is now NUM_Z_STEPPER_DRIVERS with a value of 3." + #error "Z_TRIPLE_STEPPER_DRIVERS is no longer needed and should be removed." #elif defined(Z_QUAD_STEPPER_DRIVERS) - #error "Z_QUAD_STEPPER_DRIVERS is now NUM_Z_STEPPER_DRIVERS with a value of 4." + #error "Z_QUAD_STEPPER_DRIVERS is no longer needed and should be removed." #elif defined(Z_DUAL_ENDSTOPS) || defined(Z_TRIPLE_ENDSTOPS) || defined(Z_QUAD_ENDSTOPS) #error "Z_(DUAL|TRIPLE|QUAD)_ENDSTOPS is now Z_MULTI_ENDSTOPS." #elif defined(DUGS_UI_MOVE_DIS_OPTION) @@ -601,12 +603,34 @@ #error "PROBE_TEMP_COMPENSATION is now set using the PTC_PROBE, PTC_BED, PTC_HOTEND options." #elif defined(BTC_PROBE_TEMP) #error "BTC_PROBE_TEMP is now PTC_PROBE_TEMP." -#endif - -#if MB(DUE3DOM_MINI) && PIN_EXISTS(TEMP_2) && DISABLED(TEMP_SENSOR_BOARD) - #warning "Onboard temperature sensor for BOARD_DUE3DOM_MINI has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)." -#elif MB(BTT_SKR_E3_TURBO) && PIN_EXISTS(TEMP_2) && DISABLED(TEMP_SENSOR_BOARD) - #warning "Onboard temperature sensor for BOARD_BTT_SKR_E3_TURBO has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)." +#elif defined(LCD_SCREEN_ROT_90) + #error "LCD_SCREEN_ROT_90 is now LCD_SCREEN_ROTATE with a value of 90." +#elif defined(LCD_SCREEN_ROT_180) + #error "LCD_SCREEN_ROT_180 is now LCD_SCREEN_ROTATE with a value of 180." +#elif defined(LCD_SCREEN_ROT_270) + #error "LCD_SCREEN_ROT_270 is now LCD_SCREEN_ROTATE with a value of 270." +#elif defined(DEFAULT_LCD_BRIGHTNESS) + #error "DEFAULT_LCD_BRIGHTNESS is now LCD_BRIGHTNESS_DEFAULT." +#elif defined(NOZZLE_PARK_X_ONLY) + #error "NOZZLE_PARK_X_ONLY is now NOZZLE_PARK_MOVE 1." +#elif defined(NOZZLE_PARK_Y_ONLY) + #error "NOZZLE_PARK_Y_ONLY is now NOZZLE_PARK_MOVE 2." +#elif defined(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #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(X_DUAL_STEPPER_DRIVERS) + #error "X_DUAL_STEPPER_DRIVERS is no longer needed and should be removed." +#elif defined(Y_DUAL_STEPPER_DRIVERS) + #error "Y_DUAL_STEPPER_DRIVERS is no longer needed and should be removed." +#elif defined(NUM_Z_STEPPER_DRIVERS) + #error "NUM_Z_STEPPER_DRIVERS is no longer needed and should be removed." +#elif defined(LEVEL_BED_CORNERS) + #error "LEVEL_BED_CORNERS is now LCD_BED_TRAMMING." +#elif defined(LEVEL_CORNERS_INSET_LFRB) || defined(LEVEL_CORNERS_HEIGHT) || defined(LEVEL_CORNERS_Z_HOP) || defined(LEVEL_CORNERS_USE_PROBE) || defined(LEVEL_CORNERS_PROBE_TOLERANCE) || defined(LEVEL_CORNERS_VERIFY_RAISED) || defined(LEVEL_CORNERS_AUDIO_FEEDBACK) + #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 constexpr float arm[] = AXIS_RELATIVE_MODES; @@ -723,27 +747,21 @@ 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 ENABLED(X_DUAL_STEPPER_DRIVERS) - #if ENABLED(DUAL_X_CARRIAGE) - #error "DUAL_X_CARRIAGE is not compatible with X_DUAL_STEPPER_DRIVERS." - #elif !GOOD_AXIS_PINS(X) - #error "X_DUAL_STEPPER_DRIVERS requires X2 pins to be defined." - #endif +#if HAS_X2_STEPPER && !GOOD_AXIS_PINS(X) + #error "If X2_DRIVER_TYPE is defined, then X2 ENABLE/STEP/DIR pins are also needed." #endif -#if ENABLED(Y_DUAL_STEPPER_DRIVERS) && !GOOD_AXIS_PINS(Y) - #error "Y_DUAL_STEPPER_DRIVERS requires Y2 pins to be defined." +#if HAS_DUAL_Y_STEPPERS && !GOOD_AXIS_PINS(Y) + #error "If Y2_DRIVER_TYPE is defined, then Y2 ENABLE/STEP/DIR pins are also needed." #endif #if HAS_Z_AXIS - #if !WITHIN(NUM_Z_STEPPER_DRIVERS, 1, 4) - #error "NUM_Z_STEPPER_DRIVERS must be an integer from 1 to 4." - #elif NUM_Z_STEPPER_DRIVERS == 2 && !GOOD_AXIS_PINS(Z2) - #error "If NUM_Z_STEPPER_DRIVERS is 2, you must define stepper pins for Z2." - #elif NUM_Z_STEPPER_DRIVERS == 3 && !(GOOD_AXIS_PINS(Z2) && GOOD_AXIS_PINS(Z3)) - #error "If NUM_Z_STEPPER_DRIVERS is 3, you must define stepper pins for Z2 and Z3." - #elif NUM_Z_STEPPER_DRIVERS == 4 && !(GOOD_AXIS_PINS(Z2) && GOOD_AXIS_PINS(Z3) && GOOD_AXIS_PINS(Z4)) - #error "If NUM_Z_STEPPER_DRIVERS is 4, you must define stepper pins for Z2, Z3, and Z4." + #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." + #elif NUM_Z_STEPPERS >= 3 && !GOOD_AXIS_PINS(Z3) + #error "If Z3_DRIVER_TYPE is defined, then Z3 ENABLE/STEP/DIR pins are also needed." + #elif NUM_Z_STEPPERS >= 4 && !GOOD_AXIS_PINS(Z4) + #error "If Z4_DRIVER_TYPE is defined, then Z4 ENABLE/STEP/DIR pins are also needed." #endif #endif @@ -772,15 +790,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif -#if !defined(TARGET_LPC1768) && ANY( \ - ENDSTOPPULLDOWNS, \ - ENDSTOPPULLDOWN_XMAX, ENDSTOPPULLDOWN_YMAX, \ - ENDSTOPPULLDOWN_ZMAX, ENDSTOPPULLDOWN_XMIN, \ - ENDSTOPPULLDOWN_YMIN, ENDSTOPPULLDOWN_ZMIN \ - ) - #error "PULLDOWN pin mode is not available on the selected board." -#endif - #if BOTH(ENDSTOPPULLUPS, ENDSTOPPULLDOWNS) #error "Enable only one of ENDSTOPPULLUPS or ENDSTOPPULLDOWNS." #elif BOTH(FIL_RUNOUT_PULLUP, FIL_RUNOUT_PULLDOWN) @@ -791,6 +800,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "Enable only one of ENDSTOPPULLUP_Y_MAX or ENDSTOPPULLDOWN_Y_MAX." #elif BOTH(ENDSTOPPULLUP_ZMAX, ENDSTOPPULLDOWN_ZMAX) #error "Enable only one of ENDSTOPPULLUP_Z_MAX or ENDSTOPPULLDOWN_Z_MAX." +#elif BOTH(ENDSTOPPULLUP_IMAX, ENDSTOPPULLDOWN_IMAX) + #error "Enable only one of ENDSTOPPULLUP_I_MAX or ENDSTOPPULLDOWN_I_MAX." +#elif BOTH(ENDSTOPPULLUP_JMAX, ENDSTOPPULLDOWN_JMAX) + #error "Enable only one of ENDSTOPPULLUP_J_MAX or ENDSTOPPULLDOWN_J_MAX." +#elif BOTH(ENDSTOPPULLUP_KMAX, ENDSTOPPULLDOWN_KMAX) + #error "Enable only one of ENDSTOPPULLUP_K_MAX or ENDSTOPPULLDOWN_K_MAX." #elif BOTH(ENDSTOPPULLUP_XMIN, ENDSTOPPULLDOWN_XMIN) #error "Enable only one of ENDSTOPPULLUP_X_MIN or ENDSTOPPULLDOWN_X_MIN." #elif BOTH(ENDSTOPPULLUP_YMIN, ENDSTOPPULLDOWN_YMIN) @@ -824,7 +839,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "LCD_PROGRESS_BAR requires SDSUPPORT or LCD_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 + #elif HAS_MARLINUI_U8GLIB || IS_DWIN_MARLINUI #error "LCD_PROGRESS_BAR does not apply to graphical displays." #elif ENABLED(FILAMENT_LCD_DISPLAY) #error "LCD_PROGRESS_BAR and FILAMENT_LCD_DISPLAY are not fully compatible. Comment out this line to use both." @@ -832,22 +847,24 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #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_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_*, OR EXTENSIBLE_UI." + #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" #endif -#if !HAS_LCD_MENU && ENABLED(SD_REPRINT_LAST_SELECTED_FILE) +#if !HAS_MARLINUI_MENU && ENABLED(SD_REPRINT_LAST_SELECTED_FILE) #error "SD_REPRINT_LAST_SELECTED_FILE currently requires a Marlin-native LCD menu." #endif /** * Custom Boot and Status screens */ -#if ENABLED(SHOW_CUSTOM_BOOTSCREEN) && NONE(HAS_MARLINUI_U8GLIB, TOUCH_UI_FTDI_EVE) +#if ENABLED(SHOW_CUSTOM_BOOTSCREEN) && NONE(HAS_MARLINUI_U8GLIB, TOUCH_UI_FTDI_EVE, IS_DWIN_MARLINUI) #error "SHOW_CUSTOM_BOOTSCREEN requires Graphical LCD or TOUCH_UI_FTDI_EVE." +#elif ENABLED(SHOW_CUSTOM_BOOTSCREEN) && DISABLED(SHOW_BOOTSCREEN) + #error "SHOW_CUSTOM_BOOTSCREEN requires SHOW_BOOTSCREEN." #elif ENABLED(CUSTOM_STATUS_SCREEN_IMAGE) && !HAS_MARLINUI_U8GLIB #error "CUSTOM_STATUS_SCREEN_IMAGE requires a 128x64 DOGM B/W Graphical LCD." #endif @@ -862,9 +879,10 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * SD Card Settings */ -#if ALL(SDSUPPORT, ELB_FULL_GRAPHIC_CONTROLLER, HAS_LCD_MENU) && PIN_EXISTS(SD_DETECT) && SD_DETECT_STATE != HIGH && (SD_CONNECTION_IS(LCD) || !defined(SDCARD_CONNECTION)) +#if ALL(SDSUPPORT, HAS_SD_DETECT, SD_CONNECTION_TYPICAL, ELB_FULL_GRAPHIC_CONTROLLER, HAS_MARLINUI_MENU) && SD_DETECT_STATE == LOW #error "SD_DETECT_STATE must be set HIGH for SD on the ELB_FULL_GRAPHIC_CONTROLLER." #endif +#undef SD_CONNECTION_TYPICAL /** * SD File Sorting @@ -1026,8 +1044,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Instant Freeze */ -#if ENABLED(FREEZE_FEATURE) && !PIN_EXISTS(FREEZE) - #error "FREEZE_FEATURE requires a FREEZE_PIN to be defined." +#if ENABLED(FREEZE_FEATURE) && !(PIN_EXISTS(FREEZE) && defined(FREEZE_STATE)) + #error "FREEZE_FEATURE requires both FREEZE_PIN and FREEZE_STATE." #endif /** @@ -1069,9 +1087,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "PRUSA_MMU2S requires FILAMENT_RUNOUT_SENSOR. Enable it to continue." #elif ENABLED(MMU_EXTRUDER_SENSOR) && DISABLED(FILAMENT_RUNOUT_SENSOR) #error "MMU_EXTRUDER_SENSOR requires FILAMENT_RUNOUT_SENSOR. Enable it to continue." - #elif ENABLED(MMU_EXTRUDER_SENSOR) && !HAS_LCD_MENU + #elif ENABLED(MMU_EXTRUDER_SENSOR) && !HAS_MARLINUI_MENU #error "MMU_EXTRUDER_SENSOR requires an LCD supporting MarlinUI." - #elif ENABLED(MMU2_MENUS) && !HAS_LCD_MENU + #elif ENABLED(MMU2_MENUS) && !HAS_MARLINUI_MENU #error "MMU2_MENUS requires an LCD supporting MarlinUI." #elif DISABLED(ADVANCED_PAUSE_FEATURE) static_assert(nullptr == strstr(MMU2_FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with PRUSA_MMU2(S) / HAS_EXTENDABLE_MMU(S)."); @@ -1128,6 +1146,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #elif ENABLED(SINGLENOZZLE) #error "SINGLENOZZLE requires 2 or more EXTRUDERS." + #if ENABLED(PID_PARAMS_PER_HOTEND) + #error "PID_PARAMS_PER_HOTEND must be disabled when using any SINGLENOZZLE extruder." + #endif #endif @@ -1139,6 +1160,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "SWITCHING_NOZZLE and DUAL_X_CARRIAGE are incompatible." #elif ENABLED(SINGLENOZZLE) #error "SWITCHING_NOZZLE and SINGLENOZZLE are incompatible." + #elif HAS_PRUSA_MMU2 + #error "SWITCHING_NOZZLE and PRUSA_MMU2(S) are incompatible." #elif EXTRUDERS != 2 #error "SWITCHING_NOZZLE requires exactly 2 EXTRUDERS." #elif NUM_SERVOS < 1 @@ -1212,14 +1235,16 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "For MIXING_EXTRUDER set MIXING_STEPPERS > 1 instead of EXTRUDERS > 1." #elif MIXING_STEPPERS < 2 #error "You must set MIXING_STEPPERS >= 2 for a mixing extruder." - #elif ENABLED(FILAMENT_SENSOR) - #error "MIXING_EXTRUDER is incompatible with FILAMENT_SENSOR. Comment out this line to use it anyway." + #elif ENABLED(FILAMENT_WIDTH_SENSOR) + #error "MIXING_EXTRUDER is incompatible with FILAMENT_WIDTH_SENSOR. Comment out this line to use it anyway." #elif ENABLED(SWITCHING_EXTRUDER) #error "Please select either MIXING_EXTRUDER or SWITCHING_EXTRUDER, not both." #elif ENABLED(SINGLENOZZLE) #error "MIXING_EXTRUDER is incompatible with SINGLENOZZLE." #elif ENABLED(DISABLE_INACTIVE_EXTRUDER) #error "MIXING_EXTRUDER is incompatible with DISABLE_INACTIVE_EXTRUDER." + #elif HAS_FILAMENT_RUNOUT_DISTANCE + #error "MIXING_EXTRUDER is incompatible with FILAMENT_RUNOUT_DISTANCE_MM." #endif #endif @@ -1285,6 +1310,14 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif +/** + * Generic Switching Toolhead requirements + */ +#if ANY(SWITCHING_TOOLHEAD, MAGNETIC_SWITCHING_TOOLHEAD, ELECTROMAGNETIC_SWITCHING_TOOLHEAD) + constexpr float thpx[] = SWITCHING_TOOLHEAD_X_POS; + static_assert(COUNT(thpx) == EXTRUDERS, "SWITCHING_TOOLHEAD_X_POS must be an array EXTRUDERS long."); +#endif + /** * Switching Toolhead requirements */ @@ -1375,6 +1408,26 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "You must set DISPLAY_CHARSET_HD44780 to JAPANESE, WESTERN or CYRILLIC for your LCD controller." #endif +/** + * Extruder temperature control algorithm - There can be only one! + */ +#if BOTH(PIDTEMP, MPCTEMP) + #error "Only enable PIDTEMP or MPCTEMP, but not both." +#endif + +#if ENABLED(MPC_INCLUDE_FAN) + #if FAN_COUNT < 1 + #error "MPC_INCLUDE_FAN requires at least one fan." + #endif + #if FAN_COUNT < HOTENDS + #if COUNT_ENABLED(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) > 1 + #error "Enable either MPC_FAN_0_ALL_HOTENDS or MPC_FAN_0_ACTIVE_HOTEND, not both." + #elif NONE(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) + #error "MPC_INCLUDE_FAN requires MPC_FAN_0_ALL_HOTENDS or MPC_FAN_0_ACTIVE_HOTEND for one fan with multiple hotends." + #endif + #endif +#endif + /** * Bed Heating Options - PID vs Limit Switching */ @@ -1416,10 +1469,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Allow only extra axis codes that do not conflict with G-code parameter names */ -#if LINEAR_AXES >= 4 - #if AXIS4_NAME != 'A' && AXIS4_NAME != 'B' && AXIS4_NAME != 'C' && AXIS4_NAME != 'U' && AXIS4_NAME != 'V' && AXIS4_NAME != 'W' - #error "AXIS4_NAME can only be one of 'A', 'B', 'C', 'U', 'V', or 'W'." - #elif !defined(I_MIN_POS) || !defined(I_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 LINEAR_AXES >= 4." #elif !defined(I_HOME_DIR) #error "I_HOME_DIR is required with LINEAR_AXES >= 4." @@ -1427,11 +1478,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "I_ENABLE_ON is required for your I driver with LINEAR_AXES >= 4." #endif #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #if AXIS5_NAME == AXIS4_NAME #error "AXIS5_NAME must be unique." - #elif AXIS5_NAME != 'A' && AXIS5_NAME != 'B' && AXIS5_NAME != 'C' && AXIS5_NAME != 'U' && AXIS5_NAME != 'V' && AXIS5_NAME != 'W' - #error "AXIS5_NAME can only be one of 'A', 'B', 'C', 'U', 'V', or 'W'." #elif !defined(J_MIN_POS) || !defined(J_MAX_POS) #error "J_MIN_POS and J_MAX_POS are required with LINEAR_AXES >= 5." #elif !defined(J_HOME_DIR) @@ -1440,11 +1489,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "J_ENABLE_ON is required for your J driver with LINEAR_AXES >= 5." #endif #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #if AXIS6_NAME == AXIS5_NAME || AXIS6_NAME == AXIS4_NAME #error "AXIS6_NAME must be unique." - #elif AXIS6_NAME != 'A' && AXIS6_NAME != 'B' && AXIS6_NAME != 'C' && AXIS6_NAME != 'U' && AXIS6_NAME != 'V' && AXIS6_NAME != 'W' - #error "AXIS6_NAME can only be one of 'A', 'B', 'C', 'U', 'V', or 'W'." #elif !defined(K_MIN_POS) || !defined(K_MAX_POS) #error "K_MIN_POS and K_MAX_POS are required with LINEAR_AXES >= 6." #elif !defined(K_HOME_DIR) @@ -1473,9 +1520,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "You probably want to use Max Endstops for DELTA!" #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_LCD_MENU) + #elif ENABLED(DELTA_AUTO_CALIBRATION) && !(HAS_BED_PROBE || HAS_MARLINUI_MENU) #error "DELTA_AUTO_CALIBRATION requires a probe or LCD Controller." - #elif ENABLED(DELTA_CALIBRATION_MENU) && !HAS_LCD_MENU + #elif ENABLED(DELTA_CALIBRATION_MENU) && !HAS_MARLINUI_MENU #error "DELTA_CALIBRATION_MENU requires an LCD Controller." #elif ABL_USES_GRID #if ((GRID_MAX_POINTS_X) & 1) == 0 || ((GRID_MAX_POINTS_Y) & 1) == 0 @@ -1509,8 +1556,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) - #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, or Z Servo." + + 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." #endif #if HAS_BED_PROBE @@ -1564,10 +1611,14 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #else #define _IS_5V_TOLERANT(P) 1 // Assume 5V tolerance #endif - #if USES_Z_MIN_PROBE_PIN && !_IS_5V_TOLERANT(Z_MIN_PROBE_PIN) - #error "BLTOUCH_SET_5V_MODE is not compatible with the Z_MIN_PROBE_PIN." + #if USES_Z_MIN_PROBE_PIN + #if !_IS_5V_TOLERANT(Z_MIN_PROBE_PIN) + #error "BLTOUCH_SET_5V_MODE is not compatible with the Z_MIN_PROBE_PIN." + #endif #elif !_IS_5V_TOLERANT(Z_MIN_PIN) - #error "BLTOUCH_SET_5V_MODE is not compatible with the Z_MIN_PIN." + #if !MB(CHITU3D_V6) + #error "BLTOUCH_SET_5V_MODE is not compatible with the Z_MIN_PIN." + #endif #endif #undef _IS_5V_TOLERANT #undef _5V @@ -1612,13 +1663,26 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif + /** + * MagLev V4 probe requirements + */ + #if ENABLED(MAGLEV4) + #if !PIN_EXISTS(MAGLEV_TRIGGER) + #error "MAGLEV4 requires MAGLEV_TRIGGER_PIN to be defined." + #elif 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." + #endif + #endif + /** * Require pin options and pins to be defined */ #if ENABLED(SENSORLESS_PROBING) - #if ENABLED(DELTA) && !(AXIS_HAS_STALLGUARD(X) && AXIS_HAS_STALLGUARD(Y) && AXIS_HAS_STALLGUARD(Z)) + #if ENABLED(DELTA) && !(X_SENSORLESS && Y_SENSORLESS && Z_SENSORLESS) #error "SENSORLESS_PROBING requires TMC2130/2160/2209/5130/5160 drivers on X, Y, and Z." - #elif !AXIS_HAS_STALLGUARD(Z) + #elif !Z_SENSORLESS #error "SENSORLESS_PROBING requires a TMC2130/2160/2209/5130/5160 driver on Z." #endif #elif ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) @@ -1699,23 +1763,23 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Require some kind of probe for bed leveling and probe testing */ #if HAS_ABL_NOT_UBL && !PROBE_SELECTED - #error "Auto Bed Leveling requires one of these: PROBE_MANUALLY, SENSORLESS_PROBING, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, or a Z Servo." + #error "Auto Bed Leveling requires either PROBE_MANUALLY, SENSORLESS_PROBING, or a real probe." #endif #if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST) - #error "Z_MIN_PROBE_REPEATABILITY_TEST requires a probe: FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, BLTOUCH, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, or Z Servo." + #error "Z_MIN_PROBE_REPEATABILITY_TEST requires a real probe." #endif #endif -#if ENABLED(LEVEL_BED_CORNERS) - #ifndef LEVEL_CORNERS_INSET_LFRB - #error "LEVEL_BED_CORNERS requires LEVEL_CORNERS_INSET_LFRB values." - #elif ENABLED(LEVEL_CORNERS_USE_PROBE) +#if ENABLED(LCD_BED_TRAMMING) + #ifndef BED_TRAMMING_INSET_LFRB + #error "LCD_BED_TRAMMING requires BED_TRAMMING_INSET_LFRB values." + #elif ENABLED(BED_TRAMMING_USE_PROBE) #if !HAS_BED_PROBE - #error "LEVEL_CORNERS_USE_PROBE requires a real probe." + #error "BED_TRAMMING_USE_PROBE requires a real probe." #elif ENABLED(SENSORLESS_PROBING) - #error "LEVEL_CORNERS_USE_PROBE is incompatible with SENSORLESS_PROBING." + #error "BED_TRAMMING_USE_PROBE is incompatible with SENSORLESS_PROBING." #endif #endif #endif @@ -1801,7 +1865,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * LCD_BED_LEVELING requirements */ #if ENABLED(LCD_BED_LEVELING) - #if NONE(HAS_LCD_MENU, DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_ENHANCED) + #if !HAS_MARLINUI_MENU #error "LCD_BED_LEVELING is not supported by the selected LCD controller." #elif !(ENABLED(MESH_BED_LEVELING) || HAS_ABL_NOT_UBL) #error "LCD_BED_LEVELING requires MESH_BED_LEVELING or AUTO_BED_LEVELING." @@ -1995,8 +2059,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif -#if HAS_FAN0 && CONTROLLER_FAN_PIN == FAN_PIN - #error "You cannot set CONTROLLER_FAN_PIN equal to FAN_PIN." +#if HAS_FAN0 + #if CONTROLLER_FAN_PIN == FAN_PIN + #error "You cannot set CONTROLLER_FAN_PIN equal to FAN_PIN." + #elif ENABLED(FAN_SOFT_PWM_REQUIRED) && DISABLED(FAN_SOFT_PWM) + #error "FAN_SOFT_PWM is required for your board. Enable it to continue." + #endif #endif #if ENABLED(USE_CONTROLLER_FAN) @@ -2148,9 +2216,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Test Sensor & Heater pin combos. * Pins and Sensor IDs must be set for each heater */ -#if !ANY_PIN(TEMP_0, TEMP_0_CS) +#if HAS_EXTRUDERS && !ANY_PIN(TEMP_0, TEMP_0_CS) #error "TEMP_0_PIN or TEMP_0_CS_PIN not defined for this board." -#elif !HAS_HEATER_0 && EXTRUDERS +#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) #error "TEMP_SENSOR_0 MAX thermocouple requires TEMP_0_CS_PIN." @@ -2242,18 +2310,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if TEMP_SENSOR_PROBE #if !PIN_EXISTS(TEMP_PROBE) #error "TEMP_SENSOR_PROBE requires TEMP_PROBE_PIN." - #elif !HAS_TEMP_ADC_PROBE - #error "TEMP_PROBE_PIN must be an ADC pin." - #elif DISABLED(FIX_MOUNTED_PROBE) - #error "TEMP_SENSOR_PROBE shouldn't be set without FIX_MOUNTED_PROBE." - #endif -#endif - -#if TEMP_SENSOR_PROBE - #if !PIN_EXISTS(TEMP_PROBE) - #error "TEMP_SENSOR_PROBE requires TEMP_PROBE_PIN." - #elif !HAS_TEMP_ADC_PROBE - #error "TEMP_PROBE_PIN must be an ADC pin." #elif DISABLED(FIX_MOUNTED_PROBE) #error "TEMP_SENSOR_PROBE shouldn't be set without FIX_MOUNTED_PROBE." #endif @@ -2262,8 +2318,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if TEMP_SENSOR_BOARD #if !PIN_EXISTS(TEMP_BOARD) #error "TEMP_SENSOR_BOARD requires TEMP_BOARD_PIN." - #elif !HAS_TEMP_ADC_BOARD - #error "TEMP_BOARD_PIN must be an ADC pin." #elif ENABLED(THERMAL_PROTECTION_BOARD) && (!defined(BOARD_MINTEMP) || !defined(BOARD_MAXTEMP)) #error "THERMAL_PROTECTION_BOARD requires BOARD_MINTEMP and BOARD_MAXTEMP." #endif @@ -2271,6 +2325,10 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "CONTROLLER_FAN_MIN_BOARD_TEMP requires TEMP_SENSOR_BOARD." #endif +#if TEMP_SENSOR_BOARD && !PIN_EXISTS(TEMP_BOARD) + #error "TEMP_SENSOR_BOARD requires TEMP_BOARD_PIN." +#endif + #if ENABLED(LASER_COOLANT_FLOW_METER) && !(PIN_EXISTS(FLOWMETER) && ENABLED(LASER_FEATURE)) #error "LASER_COOLANT_FLOW_METER requires FLOWMETER_PIN and LASER_FEATURE." #endif @@ -2307,17 +2365,31 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif /** - * LED Control Menu + * FYSETC/MKS/BTT Mini Panel Requirements */ -#if ENABLED(LED_CONTROL_MENU) && !HAS_COLOR_LEDS - #error "LED_CONTROL_MENU requires BLINKM, RGB_LED, RGBW_LED, PCA9533, PCA9632, or NEOPIXEL_LED." +#if EITHER(FYSETC_242_OLED_12864, FYSETC_MINI_12864_2_1) + #ifndef NEO_RGB + #define NEO_RGB 123 + #define FAUX_RGB 1 + #endif + #if defined(NEOPIXEL_TYPE) && NEOPIXEL_TYPE != NEO_RGB + #error "Your FYSETC/MKS/BTT Mini Panel requires NEOPIXEL_TYPE to be NEO_RGB." + #elif defined(NEOPIXEL_PIXELS) && NEOPIXEL_PIXELS < 3 + #error "Your FYSETC/MKS/BTT Mini Panel requires NEOPIXEL_PIXELS >= 3." + #endif + #if FAUX_RGB + #undef NEO_RGB + #undef FAUX_RGB + #endif +#elif EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) && DISABLED(RGB_LED) + #error "Your FYSETC Mini Panel requires RGB_LED." #endif /** - * LED Backlight Timeout + * LED Control Menu requirements */ -#if defined(LED_BACKLIGHT_TIMEOUT) && !(ENABLED(PSU_CONTROL) && ANY(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1, FYSETC_242_OLED_12864)) - #error "LED_BACKLIGHT_TIMEOUT requires a FYSETC Mini Panel and a Power Switch." +#if ENABLED(LED_CONTROL_MENU) && !HAS_COLOR_LEDS + #error "LED_CONTROL_MENU requires BLINKM, RGB_LED, RGBW_LED, PCA9533, PCA9632, or NEOPIXEL_LED." #endif /** @@ -2395,13 +2467,13 @@ 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 LINEAR_AXES >= 4 && _AXIS_PLUG_UNUSED_TEST(I) + #if HAS_I_AXIS && _AXIS_PLUG_UNUSED_TEST(I) #error "You must enable USE_IMIN_PLUG or USE_IMAX_PLUG." #endif - #if LINEAR_AXES >= 5 && _AXIS_PLUG_UNUSED_TEST(J) + #if HAS_J_AXIS && _AXIS_PLUG_UNUSED_TEST(J) #error "You must enable USE_JMIN_PLUG or USE_JMAX_PLUG." #endif - #if LINEAR_AXES >= 6 && _AXIS_PLUG_UNUSED_TEST(K) + #if HAS_K_AXIS && _AXIS_PLUG_UNUSED_TEST(K) #error "You must enable USE_KMIN_PLUG or USE_KMAX_PLUG." #endif @@ -2415,17 +2487,17 @@ 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 LINEAR_AXES >= 4 && I_HOME_TO_MIN && DISABLED(USE_IMIN_PLUG) + #elif HAS_I_AXIS && I_HOME_TO_MIN && DISABLED(USE_IMIN_PLUG) #error "Enable USE_IMIN_PLUG when homing I to MIN." - #elif LINEAR_AXES >= 4 && I_HOME_TO_MAX && DISABLED(USE_IMAX_PLUG) + #elif HAS_I_AXIS && I_HOME_TO_MAX && DISABLED(USE_IMAX_PLUG) #error "Enable USE_IMAX_PLUG when homing I to MAX." - #elif LINEAR_AXES >= 5 && J_HOME_TO_MIN && DISABLED(USE_JMIN_PLUG) + #elif HAS_J_AXIS && J_HOME_TO_MIN && DISABLED(USE_JMIN_PLUG) #error "Enable USE_JMIN_PLUG when homing J to MIN." - #elif LINEAR_AXES >= 5 && J_HOME_TO_MAX && DISABLED(USE_JMAX_PLUG) + #elif HAS_J_AXIS && J_HOME_TO_MAX && DISABLED(USE_JMAX_PLUG) #error "Enable USE_JMAX_PLUG when homing J to MAX." - #elif LINEAR_AXES >= 6 && K_HOME_TO_MIN && DISABLED(USE_KMIN_PLUG) + #elif HAS_K_AXIS && K_HOME_TO_MIN && DISABLED(USE_KMIN_PLUG) #error "Enable USE_KMIN_PLUG when homing K to MIN." - #elif LINEAR_AXES >= 6 && K_HOME_TO_MAX && DISABLED(USE_KMAX_PLUG) + #elif HAS_K_AXIS && K_HOME_TO_MAX && DISABLED(USE_KMAX_PLUG) #error "Enable USE_KMAX_PLUG when homing K to MAX." #endif #endif @@ -2466,10 +2538,10 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "Z_MULTI_ENDSTOPS is not compatible with DELTA." #elif !Z2_USE_ENDSTOP #error "Z2_USE_ENDSTOP must be set with Z_MULTI_ENDSTOPS." - #elif !Z3_USE_ENDSTOP && NUM_Z_STEPPER_DRIVERS >= 3 - #error "Z3_USE_ENDSTOP must be set with Z_MULTI_ENDSTOPS and NUM_Z_STEPPER_DRIVERS >= 3." - #elif !Z4_USE_ENDSTOP && NUM_Z_STEPPER_DRIVERS >= 4 - #error "Z4_USE_ENDSTOP must be set with Z_MULTI_ENDSTOPS and NUM_Z_STEPPER_DRIVERS >= 4." + #elif !Z3_USE_ENDSTOP && NUM_Z_STEPPERS >= 3 + #error "Z3_USE_ENDSTOP must be set with Z_MULTI_ENDSTOPS and Z3_DRIVER_TYPE." + #elif !Z4_USE_ENDSTOP && NUM_Z_STEPPERS >= 4 + #error "Z4_USE_ENDSTOP must be set with Z_MULTI_ENDSTOPS and Z4_DRIVER_TYPE." #endif #endif @@ -2668,7 +2740,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS + COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35) \ + COUNT_ENABLED(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY, DGUS_LCD_UI_MKS, DGUS_LCD_UI_RELOADED) \ + COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY) \ - + COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \ + + COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE) \ + COUNT_ENABLED(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_GENERIC_12864_1_1) \ + COUNT_ENABLED(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004) \ + COUNT_ENABLED(MKS_12864OLED, MKS_12864OLED_SSD1306) \ @@ -2741,8 +2813,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "Please enable only one of TFT_INTERFACE_SPI or TFT_INTERFACE_SPI." #endif -#if MANY(LCD_SCREEN_ROT_0, LCD_SCREEN_ROT_90, LCD_SCREEN_ROT_180, LCD_SCREEN_ROT_270) - #error "Please enable only one LCD_SCREEN_ROT_* option: 0, 90, 180, or 270." +#if defined(LCD_SCREEN_ROTATE) && LCD_SCREEN_ROTATE != 0 && LCD_SCREEN_ROTATE != 90 && LCD_SCREEN_ROTATE != 180 && LCD_SCREEN_ROTATE != 270 + #error "LCD_SCREEN_ROTATE must be 0, 90, 180, or 270." #endif #if MANY(TFT_RES_320x240, TFT_RES_480x272, TFT_RES_480x320, TFT_RES_1024x600) @@ -2765,6 +2837,20 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "Please select only one of CHIRON_TFT_STANDARD or CHIRON_TFT_NEW." #endif +#if ENABLED(ANYCUBIC_LCD_CHIRON) + #if !defined(BEEPER_PIN) + #error "ANYCUBIC_LCD_CHIRON requires BEEPER_PIN" + #elif DISABLED(SDSUPPORT) + #error "ANYCUBIC_LCD_CHIRON requires SDSUPPORT" + #elif TEMP_SENSOR_BED == 0 + #error "ANYCUBIC_LCD_CHIRON requires heatbed (TEMP_SENSOR_BED)" + #elif NONE(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING) + #error "ANYCUBIC_LCD_CHIRON requires one of: AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL or MESH_BED_LEVELING" + #elif DISABLED(BABYSTEPPING) + #error "ANYCUBIC_LCD_CHIRON requires BABYSTEPPING" + #endif +#endif + #if EITHER(MKS_TS35_V2_0, BTT_TFT35_SPI_V1_0) && SD_CONNECTION_IS(LCD) #error "SDCARD_CONNECTION cannot be set to LCD for the enabled TFT. No available SD card reader." #endif @@ -2775,26 +2861,45 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if ENABLED(DWIN_CREALITY_LCD) #if DISABLED(SDSUPPORT) #error "DWIN_CREALITY_LCD requires SDSUPPORT to be enabled." - #elif ENABLED(PID_EDIT_MENU) - #error "DWIN_CREALITY_LCD does not support PID_EDIT_MENU." - #elif ENABLED(PID_AUTOTUNE_MENU) - #error "DWIN_CREALITY_LCD does not support PID_AUTOTUNE_MENU." - #elif ENABLED(LEVEL_BED_CORNERS) - #error "DWIN_CREALITY_LCD does not support LEVEL_BED_CORNERS." + #elif EITHER(PID_EDIT_MENU, PID_AUTOTUNE_MENU) + #error "DWIN_CREALITY_LCD does not support PID_EDIT_MENU or PID_AUTOTUNE_MENU." + #elif EITHER(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU) + #error "DWIN_CREALITY_LCD does not support MPC_EDIT_MENU or MPC_AUTOTUNE_MENU." + #elif ENABLED(LCD_BED_TRAMMING) + #error "DWIN_CREALITY_LCD does not support LCD_BED_TRAMMING." #elif BOTH(LCD_BED_LEVELING, PROBE_MANUALLY) #error "DWIN_CREALITY_LCD does not support LCD_BED_LEVELING with PROBE_MANUALLY." #endif -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#elif ENABLED(DWIN_LCD_PROUI) #if DISABLED(SDSUPPORT) - #error "DWIN_CREALITY_LCD_ENHANCED requires SDSUPPORT to be enabled." - #elif ENABLED(PID_EDIT_MENU) - #error "DWIN_CREALITY_LCD_ENHANCED does not support PID_EDIT_MENU." - #elif ENABLED(PID_AUTOTUNE_MENU) - #error "DWIN_CREALITY_LCD_ENHANCED does not support PID_AUTOTUNE_MENU." - #elif ENABLED(LEVEL_BED_CORNERS) - #error "DWIN_CREALITY_LCD_ENHANCED does not support LEVEL_BED_CORNERS." + #error "DWIN_LCD_PROUI requires SDSUPPORT to be enabled." + #elif EITHER(PID_EDIT_MENU, PID_AUTOTUNE_MENU) + #error "DWIN_LCD_PROUI does not support PID_EDIT_MENU or PID_AUTOTUNE_MENU." + #elif EITHER(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU) + #error "DWIN_LCD_PROUI does not support MPC_EDIT_MENU or MPC_AUTOTUNE_MENU." + #elif ENABLED(LCD_BED_TRAMMING) + #error "DWIN_LCD_PROUI does not support LCD_BED_TRAMMING." #elif BOTH(LCD_BED_LEVELING, PROBE_MANUALLY) - #error "DWIN_CREALITY_LCD_ENHANCED does not support LCD_BED_LEVELING with PROBE_MANUALLY." + #error "DWIN_LCD_PROUI does not support LCD_BED_LEVELING with PROBE_MANUALLY." + #endif +#endif + +#if LCD_BACKLIGHT_TIMEOUT + #if !HAS_ENCODER_ACTION + #error "LCD_BACKLIGHT_TIMEOUT requires an LCD with encoder or keypad." + #elif !PIN_EXISTS(LCD_BACKLIGHT) + #error "LCD_BACKLIGHT_TIMEOUT requires LCD_BACKLIGHT_PIN." + #endif +#endif + +/** + * 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) + #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." #endif #endif @@ -2843,18 +2948,11 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "The ANYCUBIC LCD requires LCD_SERIAL_PORT to be defined." #elif ENABLED(MALYAN_LCD) #error "MALYAN_LCD requires LCD_SERIAL_PORT to be defined." + #elif ENABLED(NEXTION_LCD) + #error "NEXTION_LCD requires LCD_SERIAL_PORT to be defined." #endif #endif -/** - * FYSETC Mini 12864 RGB backlighting required - */ -#if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) && DISABLED(RGB_LED) - #error "RGB_LED is required for FYSETC_MINI_12864 1.2 and 2.0." -#elif EITHER(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1) && DISABLED(LED_USER_PRESET_STARTUP) - #error "LED_USER_PRESET_STARTUP is required for FYSETC_MINI_12864 2.x displays." -#endif - /** * Check existing CS pins against enabled TMC SPI drivers. */ @@ -2936,11 +3034,11 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TMC2208 or TMC2209 on E6 requires E6_HARDWARE_SERIAL or E6_SERIAL_(RX|TX)_PIN." #elif INVALID_TMC_UART(E7) #error "TMC2208 or TMC2209 on E7 requires E7_HARDWARE_SERIAL or E7_SERIAL_(RX|TX)_PIN." -#elif LINEAR_AXES >= 4 && INVALID_TMC_UART(I) +#elif HAS_I_AXIS && INVALID_TMC_UART(I) #error "TMC2208 or TMC2209 on I requires I_HARDWARE_SERIAL or I_SERIAL_(RX|TX)_PIN." -#elif LINEAR_AXES >= 5 && INVALID_TMC_UART(J) +#elif HAS_J_AXIS && INVALID_TMC_UART(J) #error "TMC2208 or TMC2209 on J requires J_HARDWARE_SERIAL or J_SERIAL_(RX|TX)_PIN." -#elif LINEAR_AXES >= 6 && INVALID_TMC_UART(K) +#elif HAS_K_AXIS && INVALID_TMC_UART(K) #error "TMC2208 or TMC2209 on K requires K_HARDWARE_SERIAL or K_SERIAL_(RX|TX)_PIN." #endif #undef INVALID_TMC_UART @@ -3026,11 +3124,11 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS INVALID_TMC_MS(E6) #elif !TMC_MICROSTEP_IS_VALID(E7) INVALID_TMC_MS(E7) -#elif LINEAR_AXES >= 4 && !TMC_MICROSTEP_IS_VALID(I) +#elif HAS_I_AXIS && !TMC_MICROSTEP_IS_VALID(I) INVALID_TMC_MS(I) -#elif LINEAR_AXES >= 5 && !TMC_MICROSTEP_IS_VALID(J) +#elif HAS_J_AXIS && !TMC_MICROSTEP_IS_VALID(J) INVALID_TMC_MS(J) -#elif LINEAR_AXES >= 6 && !TMC_MICROSTEP_IS_VALID(K) +#elif HAS_K_AXIS && !TMC_MICROSTEP_IS_VALID(K) INVALID_TMC_MS(K) #endif #undef INVALID_TMC_MS @@ -3052,13 +3150,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #define X_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(X,TMC2209) #define Y_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(Y,TMC2209) #define Z_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(Z,TMC2209) - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS #define I_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(I,TMC2209) #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS #define J_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(J,TMC2209) #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS #define K_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(K,TMC2209) #endif @@ -3075,17 +3173,17 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_ZMIN (or ENDSTOPPULLUPS) when homing to Z_MIN." #elif Z_SENSORLESS && Z_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_ZMAX) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_ZMAX (or ENDSTOPPULLUPS) when homing to Z_MAX." - #elif LINEAR_AXES >= 4 && I_SENSORLESS && I_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_IMIN) + #elif ALL(HAS_I_AXIS, I_SENSORLESS, I_HOME_TO_MIN) && DISABLED(ENDSTOPPULLUP_IMIN) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_IMIN (or ENDSTOPPULLUPS) when homing to I_MIN." - #elif LINEAR_AXES >= 4 && I_SENSORLESS && I_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_IMAX) + #elif ALL(HAS_I_AXIS, I_SENSORLESS, I_HOME_TO_MAX) && DISABLED(ENDSTOPPULLUP_IMAX) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_IMAX (or ENDSTOPPULLUPS) when homing to I_MAX." - #elif LINEAR_AXES >= 5 && J_SENSORLESS && J_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_JMIN) + #elif ALL(HAS_J_AXIS, J_SENSORLESS, J_HOME_TO_MIN) && DISABLED(ENDSTOPPULLUP_JMIN) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_JMIN (or ENDSTOPPULLUPS) when homing to J_MIN." - #elif LINEAR_AXES >= 5 && J_SENSORLESS && J_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_JMAX) + #elif ALL(HAS_J_AXIS, J_SENSORLESS, J_HOME_TO_MAX) && DISABLED(ENDSTOPPULLUP_JMAX) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_JMAX (or ENDSTOPPULLUPS) when homing to J_MAX." - #elif LINEAR_AXES >= 6 && K_SENSORLESS && K_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_KMIN) + #elif ALL(HAS_K_AXIS, K_SENSORLESS, K_HOME_TO_MIN) && DISABLED(ENDSTOPPULLUP_KMIN) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_KMIN (or ENDSTOPPULLUPS) when homing to K_MIN." - #elif LINEAR_AXES >= 6 && K_SENSORLESS && K_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_KMAX) + #elif ALL(HAS_K_AXIS, K_SENSORLESS, K_HOME_TO_MAX) && DISABLED(ENDSTOPPULLUP_KMAX) #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_KMAX (or ENDSTOPPULLUPS) when homing to K_MAX." #endif #endif @@ -3131,37 +3229,37 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #else #error "SENSORLESS_HOMING requires Z_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to Z_MAX." #endif - #elif LINEAR_AXES >= 4 && I_SENSORLESS && I_HOME_TO_MIN && I_MIN_ENDSTOP_INVERTING != I_ENDSTOP_INVERTING + #elif ALL(HAS_I_AXIS, I_SENSORLESS, I_HOME_TO_MIN) && I_MIN_ENDSTOP_INVERTING != I_ENDSTOP_INVERTING #if I_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires I_MIN_ENDSTOP_INVERTING = true when homing to I_MIN." #else #error "SENSORLESS_HOMING requires I_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to I_MIN." #endif - #elif LINEAR_AXES >= 4 && I_SENSORLESS && I_HOME_TO_MAX && I_MAX_ENDSTOP_INVERTING != I_ENDSTOP_INVERTING + #elif ALL(HAS_I_AXIS, I_SENSORLESS, I_HOME_TO_MAX) && I_MAX_ENDSTOP_INVERTING != I_ENDSTOP_INVERTING #if I_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires I_MAX_ENDSTOP_INVERTING = true when homing to I_MAX." #else #error "SENSORLESS_HOMING requires I_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to I_MAX." #endif - #elif LINEAR_AXES >= 5 && J_SENSORLESS && J_HOME_TO_MIN && J_MIN_ENDSTOP_INVERTING != J_ENDSTOP_INVERTING + #elif ALL(HAS_J_AXIS, J_SENSORLESS, J_HOME_TO_MIN) && J_MIN_ENDSTOP_INVERTING != J_ENDSTOP_INVERTING #if J_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires J_MIN_ENDSTOP_INVERTING = true when homing to J_MIN." #else #error "SENSORLESS_HOMING requires J_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to J_MIN." #endif - #elif LINEAR_AXES >= 5 && J_SENSORLESS && J_HOME_TO_MAX && J_MAX_ENDSTOP_INVERTING != J_ENDSTOP_INVERTING + #elif ALL(HAS_J_AXIS, J_SENSORLESS, J_HOME_TO_MAX) && J_MAX_ENDSTOP_INVERTING != J_ENDSTOP_INVERTING #if J_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires J_MAX_ENDSTOP_INVERTING = true when homing to J_MAX." #else #error "SENSORLESS_HOMING requires J_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to J_MAX." #endif - #elif LINEAR_AXES >= 6 && K_SENSORLESS && K_HOME_TO_MIN && K_MIN_ENDSTOP_INVERTING != K_ENDSTOP_INVERTING + #elif ALL(HAS_K_AXIS, K_SENSORLESS, K_HOME_TO_MIN) && K_MIN_ENDSTOP_INVERTING != K_ENDSTOP_INVERTING #if K_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires K_MIN_ENDSTOP_INVERTING = true when homing to K_MIN." #else #error "SENSORLESS_HOMING requires K_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to K_MIN." #endif - #elif LINEAR_AXES >= 6 && K_SENSORLESS && K_HOME_TO_MAX && K_MAX_ENDSTOP_INVERTING != K_ENDSTOP_INVERTING + #elif ALL(HAS_K_AXIS, K_SENSORLESS, K_HOME_TO_MAX) && K_MAX_ENDSTOP_INVERTING != K_ENDSTOP_INVERTING #if K_ENDSTOP_INVERTING #error "SENSORLESS_HOMING requires K_MAX_ENDSTOP_INVERTING = true when homing to K_MAX." #else @@ -3285,8 +3383,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * L64XX requirement */ -#if HAS_L64XX && LINEAR_AXES >= 4 - #error "L64XX requires LINEAR_AXES 3. Homing with L64XX is not yet implemented for LINEAR_AXES > 3." +#if HAS_L64XX && HAS_I_AXIS + #error "L64XX requires LINEAR_AXES <= 3. Homing with L64XX is not yet implemented for LINEAR_AXES > 3." #endif /** @@ -3374,8 +3472,8 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "A very large BLOCK_BUFFER_SIZE is not needed and takes longer to drain the buffer on pause / cancel." #endif -#if ENABLED(LED_CONTROL_MENU) && !IS_ULTIPANEL - #error "LED_CONTROL_MENU requires an LCD controller." +#if ENABLED(LED_CONTROL_MENU) && NONE(HAS_MARLINUI_MENU, DWIN_LCD_PROUI) + #error "LED_CONTROL_MENU requires an LCD controller that implements the menu." #endif #if ENABLED(CASE_LIGHT_USE_NEOPIXEL) && DISABLED(NEOPIXEL_LED) @@ -3403,8 +3501,6 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(BACKUP_POWER_SUPPLY) && !PIN_EXISTS(POWER_LOSS) #error "BACKUP_POWER_SUPPLY requires a POWER_LOSS_PIN." - #elif BOTH(POWER_LOSS_RECOVER_ZHOME, Z_SAFE_HOMING) - #error "POWER_LOSS_RECOVER_ZHOME cannot be used with Z_SAFE_HOMING." #elif BOTH(POWER_LOSS_PULLUP, POWER_LOSS_PULLDOWN) #error "You can't enable POWER_LOSS_PULLUP and POWER_LOSS_PULLDOWN at the same time." #elif ENABLED(POWER_LOSS_RECOVER_ZHOME) && Z_HOME_TO_MAX @@ -3415,21 +3511,21 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #endif #if ENABLED(Z_STEPPER_AUTO_ALIGN) - #if NUM_Z_STEPPER_DRIVERS <= 1 - #error "Z_STEPPER_AUTO_ALIGN requires NUM_Z_STEPPER_DRIVERS greater than 1." + #if NUM_Z_STEPPERS <= 1 + #error "Z_STEPPER_AUTO_ALIGN requires more than one Z stepper." #elif !HAS_BED_PROBE #error "Z_STEPPER_AUTO_ALIGN requires a Z-bed probe." - #elif ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #elif HAS_Z_STEPPER_ALIGN_STEPPER_XY static_assert(WITHIN(Z_STEPPER_ALIGN_AMP, 0.5, 2.0), "Z_STEPPER_ALIGN_AMP must be between 0.5 and 2.0."); - #if NUM_Z_STEPPER_DRIVERS < 3 - #error "Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS requires NUM_Z_STEPPER_DRIVERS to be 3 or 4." + #if NUM_Z_STEPPERS < 3 + #error "Z_STEPPER_ALIGN_STEPPER_XY requires 3 or 4 Z steppers." #endif #endif #endif #if ENABLED(MECHANICAL_GANTRY_CALIBRATION) #if NONE(HAS_MOTOR_CURRENT_DAC, HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_DAC, HAS_TRINAMIC_CONFIG, HAS_MOTOR_CURRENT_PWM) - #error "It is highly recommended to have adjustable current drivers to prevent damage. Disable this line to continue anyway." + #error "Adjustable current drivers are highly recommended to prevent damage. Comment out this line to continue anyway." #elif !defined(GANTRY_CALIBRATION_CURRENT) #error "MECHANICAL_GANTRY_CALIBRATION Requires GANTRY_CALIBRATION_CURRENT to be set." #elif !defined(GANTRY_CALIBRATION_EXTRA_HEIGHT) @@ -3546,6 +3642,8 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "PSU_CONTROL requires PS_ON_PIN." #elif POWER_OFF_DELAY < 0 #error "POWER_OFF_DELAY must be a positive value." + #elif ENABLED(POWER_OFF_WAIT_FOR_COOLDOWN) && !(defined(AUTO_POWER_E_TEMP) || defined(AUTO_POWER_CHAMBER_TEMP) || defined(AUTO_POWER_COOLER_TEMP)) + #error "POWER_OFF_WAIT_FOR_COOLDOWN requires AUTO_POWER_E_TEMP, AUTO_POWER_CHAMBER_TEMP, and/or AUTO_POWER_COOLER_TEMP." #endif #endif @@ -3589,6 +3687,7 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #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." @@ -3656,6 +3755,11 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #endif #endif #undef _PIN_CONFLICT + + #ifdef LASER_SAFETY_TIMEOUT_MS + static_assert(LASER_SAFETY_TIMEOUT_MS < (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL, "LASER_SAFETY_TIMEOUT_MS must be less than DEFAULT_STEPPER_DEACTIVE_TIME (" STRINGIFY(DEFAULT_STEPPER_DEACTIVE_TIME) " seconds)"); + #endif + #endif #if ENABLED(COOLANT_MIST) && !PIN_EXISTS(COOLANT_MIST) @@ -3664,7 +3768,7 @@ 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) && ENABLED(PRINT_PROGRESS_SHOW_DECIMALS) +#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 @@ -3704,7 +3808,7 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); * Sanity Check for Password Feature */ #if ENABLED(PASSWORD_FEATURE) - #if NONE(HAS_LCD_MENU, PASSWORD_UNLOCK_GCODE, PASSWORD_CHANGE_GCODE) + #if NONE(HAS_MARLINUI_MENU, PASSWORD_UNLOCK_GCODE, PASSWORD_CHANGE_GCODE) #error "Without PASSWORD_UNLOCK_GCODE, PASSWORD_CHANGE_GCODE, or a supported LCD there's no way to unlock the printer or set a password." #elif DISABLED(EEPROM_SETTINGS) #warning "PASSWORD_FEATURE settings will be lost on power-off without EEPROM_SETTINGS." @@ -3760,22 +3864,15 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #if _BAD_DRIVER(Z) #error "Z_DRIVER_TYPE is not recognized." #endif -#if LINEAR_AXES >= 4 - #if _BAD_DRIVER(I) - #error "I_DRIVER_TYPE is not recognized." - #endif +#if _BAD_DRIVER(I) + #error "I_DRIVER_TYPE is not recognized." #endif -#if LINEAR_AXES >= 5 - #if _BAD_DRIVER(J) - #error "J_DRIVER_TYPE is not recognized." - #endif +#if _BAD_DRIVER(J) + #error "J_DRIVER_TYPE is not recognized." #endif -#if LINEAR_AXES >= 6 - #if _BAD_DRIVER(K) - #error "K_DRIVER_TYPE is not recognized." - #endif +#if _BAD_DRIVER(K) + #error "K_DRIVER_TYPE is not recognized." #endif - #if _BAD_DRIVER(X2) #error "X2_DRIVER_TYPE is not recognized." #endif @@ -3835,8 +3932,8 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "DGUS_LCD_UI_RELOADED requires a bed probe." #elif !HAS_MESH #error "DGUS_LCD_UI_RELOADED requires mesh leveling." - #elif DISABLED(LEVEL_BED_CORNERS) - #error "DGUS_LCD_UI_RELOADED requires LEVEL_BED_CORNERS." + #elif DISABLED(LCD_BED_TRAMMING) + #error "DGUS_LCD_UI_RELOADED requires LCD_BED_TRAMMING." #elif DISABLED(BABYSTEP_ALWAYS_AVAILABLE) #error "DGUS_LCD_UI_RELOADED requires BABYSTEP_ALWAYS_AVAILABLE." #elif DISABLED(BABYSTEP_ZPROBE_OFFSET) @@ -3850,3 +3947,10 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #undef _TEST_PWM #undef _LINEAR_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." +#elif ENABLED(DISABLE_JTAG) && !defined(JTAG_DISABLE) + #error "DISABLE_JTAG is not supported for the selected MCU/Board." +#endif diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 17755de348cf..f7d5e1774c93 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.0.9.3" + #define SHORT_BUILD_VERSION "2.0.9.4" #endif /** @@ -42,7 +42,7 @@ * version was tagged. */ #ifndef STRING_DISTRIBUTION_DATE - #define STRING_DISTRIBUTION_DATE "2021-09-03" + #define STRING_DISTRIBUTION_DATE "2022-06-04" #endif /** @@ -52,7 +52,7 @@ * to alert users to major changes. */ -#define MARLIN_HEX_VERSION 02000903 +#define MARLIN_HEX_VERSION 02000904 #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 c2fe42ae82e2..bfe6a3751818 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -35,6 +35,10 @@ #warning "WARNING! Disable MARLIN_DEV_MODE for the final build!" #endif +#if LINEAR_AXES_WARNING + #warning "Note: LINEAR_AXES is now based on the *_DRIVER_TYPE settings so you can remove LINEAR_AXES from Configuration.h." +#endif + // Safety Features #if DISABLED(USE_WATCHDOG) #warning "Safety Alert! Enable USE_WATCHDOG for the final build!" @@ -59,474 +63,488 @@ #warning "Your Configuration provides no method to acquire user feedback!" #endif -#if AUTO_ASSIGNED_X2_STEPPER - #warning "Auto-assigned X2 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs." -#endif -#if AUTO_ASSIGNED_X2_MS1 - #warning "Auto-assigned X2_MS1_PIN to an unused En_MS1_PIN." -#endif -#if AUTO_ASSIGNED_X2_MS2 - #warning "Auto-assigned X2_MS2_PIN to an unused En_MS2_PIN." +#if MB(DUE3DOM_MINI) && PIN_EXISTS(TEMP_2) && !TEMP_SENSOR_BOARD + #warning "Onboard temperature sensor for BOARD_DUE3DOM_MINI has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)." +#elif MB(BTT_SKR_E3_TURBO) && PIN_EXISTS(TEMP_2) && !TEMP_SENSOR_BOARD + #warning "Onboard temperature sensor for BOARD_BTT_SKR_E3_TURBO has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)." #endif -#if AUTO_ASSIGNED_X2_MS3 - #warning "Auto-assigned X2_MS3_PIN to an unused En_MS3_PIN." -#endif -#if AUTO_ASSIGNED_X2_CS - #warning "Auto-assigned X2_CS_PIN to an unused En_CS_PIN." -#endif -#if AUTO_ASSIGNED_X2_DIAG - #if X2_USE_ENDSTOP == _XMIN_ - #warning "Auto-assigned X2_DIAG_PIN to X_MIN_PIN." - #elif X2_USE_ENDSTOP == _XMAX_ - #warning "Auto-assigned X2_DIAG_PIN to X_MAX_PIN." - #elif X2_USE_ENDSTOP == _XSTOP_ - #warning "Auto-assigned X2_DIAG_PIN to X_STOP_PIN." - #elif X2_USE_ENDSTOP == _YMIN_ - #warning "Auto-assigned X2_DIAG_PIN to Y_MIN_PIN." - #elif X2_USE_ENDSTOP == _YMAX_ - #warning "Auto-assigned X2_DIAG_PIN to Y_MAX_PIN." - #elif X2_USE_ENDSTOP == _YSTOP_ - #warning "Auto-assigned X2_DIAG_PIN to Y_STOP_PIN." - #elif X2_USE_ENDSTOP == _ZMIN_ - #warning "Auto-assigned X2_DIAG_PIN to Z_MIN_PIN." - #elif X2_USE_ENDSTOP == _ZMAX_ - #warning "Auto-assigned X2_DIAG_PIN to Z_MAX_PIN." - #elif X2_USE_ENDSTOP == _ZSTOP_ - #warning "Auto-assigned X2_DIAG_PIN to Z_STOP_PIN." - #elif X2_USE_ENDSTOP == _XDIAG_ - #warning "Auto-assigned X2_DIAG_PIN to X_DIAG_PIN." - #elif X2_USE_ENDSTOP == _YDIAG_ - #warning "Auto-assigned X2_DIAG_PIN to Y_DIAG_PIN." - #elif X2_USE_ENDSTOP == _ZDIAG_ - #warning "Auto-assigned X2_DIAG_PIN to Z_DIAG_PIN." - #elif X2_USE_ENDSTOP == _E0DIAG_ - #warning "Auto-assigned X2_DIAG_PIN to E0_DIAG_PIN." - #elif X2_USE_ENDSTOP == _E1DIAG_ - #warning "Auto-assigned X2_DIAG_PIN to E1_DIAG_PIN." - #elif X2_USE_ENDSTOP == _E2DIAG_ - #warning "Auto-assigned X2_DIAG_PIN to E2_DIAG_PIN." - #elif X2_USE_ENDSTOP == _E3DIAG_ - #warning "Auto-assigned X2_DIAG_PIN to E3_DIAG_PIN." - #elif X2_USE_ENDSTOP == _E4DIAG_ - #warning "Auto-assigned X2_DIAG_PIN to E4_DIAG_PIN." - #elif X2_USE_ENDSTOP == _E5DIAG_ - #warning "Auto-assigned X2_DIAG_PIN to E5_DIAG_PIN." - #elif X2_USE_ENDSTOP == _E6DIAG_ - #warning "Auto-assigned X2_DIAG_PIN to E6_DIAG_PIN." - #elif X2_USE_ENDSTOP == _E7DIAG_ - #warning "Auto-assigned X2_DIAG_PIN to E7_DIAG_PIN." + +#ifndef NO_AUTO_ASSIGN_WARNING + + #if AUTO_ASSIGNED_LCD_SERIAL + #warning "Note: Auto-assigned LCD_SERIAL_PORT. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" #endif -#endif -#if AUTO_ASSIGNED_Y2_STEPPER - #warning "Auto-assigned Y2 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs." -#endif -#if AUTO_ASSIGNED_Y2_MS1 - #warning "Auto-assigned Y2_MS1_PIN to an unused En_MS1_PIN." -#endif -#if AUTO_ASSIGNED_Y2_MS2 - #warning "Auto-assigned Y2_MS2_PIN to an unused En_MS2_PIN." -#endif -#if AUTO_ASSIGNED_Y2_MS3 - #warning "Auto-assigned Y2_MS3_PIN to an unused En_MS3_PIN." -#endif -#if AUTO_ASSIGNED_Y2_CS - #warning "Auto-assigned Y2_CS_PIN to an unused En_CS_PIN." -#endif -#if AUTO_ASSIGNED_Y2_DIAG - #if Y2_USE_ENDSTOP == _XMIN_ - #warning "Auto-assigned Y2_DIAG_PIN to X_MIN_PIN." - #elif Y2_USE_ENDSTOP == _XMAX_ - #warning "Auto-assigned Y2_DIAG_PIN to X_MAX_PIN." - #elif Y2_USE_ENDSTOP == _XSTOP_ - #warning "Auto-assigned Y2_DIAG_PIN to X_STOP_PIN." - #elif Y2_USE_ENDSTOP == _YMIN_ - #warning "Auto-assigned Y2_DIAG_PIN to Y_MIN_PIN." - #elif Y2_USE_ENDSTOP == _YMAX_ - #warning "Auto-assigned Y2_DIAG_PIN to Y_MAX_PIN." - #elif Y2_USE_ENDSTOP == _YSTOP_ - #warning "Auto-assigned Y2_DIAG_PIN to Y_STOP_PIN." - #elif Y2_USE_ENDSTOP == _ZMIN_ - #warning "Auto-assigned Y2_DIAG_PIN to Z_MIN_PIN." - #elif Y2_USE_ENDSTOP == _ZMAX_ - #warning "Auto-assigned Y2_DIAG_PIN to Z_MAX_PIN." - #elif Y2_USE_ENDSTOP == _ZSTOP_ - #warning "Auto-assigned Y2_DIAG_PIN to Z_STOP_PIN." - #elif Y2_USE_ENDSTOP == _XDIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to X_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _YDIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to Y_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _ZDIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to Z_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _E0DIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to E0_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _E1DIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to E1_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _E2DIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to E2_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _E3DIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to E3_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _E4DIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to E4_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _E5DIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to E5_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _E6DIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to E6_DIAG_PIN." - #elif Y2_USE_ENDSTOP == _E7DIAG_ - #warning "Auto-assigned Y2_DIAG_PIN to E7_DIAG_PIN." + + #if AUTO_ASSIGNED_X2_STEPPER + #warning "Note: Auto-assigned X2 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" #endif -#endif -#if AUTO_ASSIGNED_Z2_STEPPER - #warning "Auto-assigned Z2 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs." -#endif -#if AUTO_ASSIGNED_Z2_MS1 - #warning "Auto-assigned Z2_MS1_PIN to an unused En_MS1_PIN." -#endif -#if AUTO_ASSIGNED_Z2_MS2 - #warning "Auto-assigned Z2_MS2_PIN to an unused En_MS2_PIN." -#endif -#if AUTO_ASSIGNED_Z2_MS3 - #warning "Auto-assigned Z2_MS3_PIN to an unused En_MS3_PIN." -#endif -#if AUTO_ASSIGNED_Z2_CS - #warning "Auto-assigned Z2_CS_PIN to an unused En_CS_PIN." -#endif -#if AUTO_ASSIGNED_Z2_DIAG - #if Z2_USE_ENDSTOP == _XMIN_ - #warning "Auto-assigned Z2_DIAG_PIN to X_MIN_PIN." - #elif Z2_USE_ENDSTOP == _XMAX_ - #warning "Auto-assigned Z2_DIAG_PIN to X_MAX_PIN." - #elif Z2_USE_ENDSTOP == _XSTOP_ - #warning "Auto-assigned Z2_DIAG_PIN to X_STOP_PIN." - #elif Z2_USE_ENDSTOP == _YMIN_ - #warning "Auto-assigned Z2_DIAG_PIN to Y_MIN_PIN." - #elif Z2_USE_ENDSTOP == _YMAX_ - #warning "Auto-assigned Z2_DIAG_PIN to Y_MAX_PIN." - #elif Z2_USE_ENDSTOP == _YSTOP_ - #warning "Auto-assigned Z2_DIAG_PIN to Y_STOP_PIN." - #elif Z2_USE_ENDSTOP == _ZMIN_ - #warning "Auto-assigned Z2_DIAG_PIN to Z_MIN_PIN." - #elif Z2_USE_ENDSTOP == _ZMAX_ - #warning "Auto-assigned Z2_DIAG_PIN to Z_MAX_PIN." - #elif Z2_USE_ENDSTOP == _ZSTOP_ - #warning "Auto-assigned Z2_DIAG_PIN to Z_STOP_PIN." - #elif Z2_USE_ENDSTOP == _XDIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to X_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _YDIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to Y_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _ZDIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to Z_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _E0DIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to E0_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _E1DIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to E1_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _E2DIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to E2_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _E3DIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to E3_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _E4DIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to E4_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _E5DIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to E5_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _E6DIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to E6_DIAG_PIN." - #elif Z2_USE_ENDSTOP == _E7DIAG_ - #warning "Auto-assigned Z2_DIAG_PIN to E7_DIAG_PIN." + #if AUTO_ASSIGNED_X2_MS1 + #warning "Note: Auto-assigned X2_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" #endif -#endif -#if AUTO_ASSIGNED_Z3_STEPPER - #warning "Auto-assigned Z3 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs." -#endif -#if AUTO_ASSIGNED_Z3_CS - #warning "Auto-assigned Z3_CS_PIN to an unused En_CS_PIN." -#endif -#if AUTO_ASSIGNED_Z3_MS1 - #warning "Auto-assigned Z3_MS1_PIN to an unused En_MS1_PIN." -#endif -#if AUTO_ASSIGNED_Z3_MS2 - #warning "Auto-assigned Z3_MS2_PIN to an unused En_MS2_PIN." -#endif -#if AUTO_ASSIGNED_Z3_MS3 - #warning "Auto-assigned Z3_MS3_PIN to an unused En_MS3_PIN." -#endif -#if AUTO_ASSIGNED_Z3_DIAG - #if Z3_USE_ENDSTOP == _XMIN_ - #warning "Auto-assigned Z3_DIAG_PIN to X_MIN_PIN." - #elif Z3_USE_ENDSTOP == _XMAX_ - #warning "Auto-assigned Z3_DIAG_PIN to X_MAX_PIN." - #elif Z3_USE_ENDSTOP == _XSTOP_ - #warning "Auto-assigned Z3_DIAG_PIN to X_STOP_PIN." - #elif Z3_USE_ENDSTOP == _YMIN_ - #warning "Auto-assigned Z3_DIAG_PIN to Y_MIN_PIN." - #elif Z3_USE_ENDSTOP == _YMAX_ - #warning "Auto-assigned Z3_DIAG_PIN to Y_MAX_PIN." - #elif Z3_USE_ENDSTOP == _YSTOP_ - #warning "Auto-assigned Z3_DIAG_PIN to Y_STOP_PIN." - #elif Z3_USE_ENDSTOP == _ZMIN_ - #warning "Auto-assigned Z3_DIAG_PIN to Z_MIN_PIN." - #elif Z3_USE_ENDSTOP == _ZMAX_ - #warning "Auto-assigned Z3_DIAG_PIN to Z_MAX_PIN." - #elif Z3_USE_ENDSTOP == _ZSTOP_ - #warning "Auto-assigned Z3_DIAG_PIN to Z_STOP_PIN." - #elif Z3_USE_ENDSTOP == _XDIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to X_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _YDIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to Y_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _ZDIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to Z_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _E0DIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to E0_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _E1DIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to E1_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _E2DIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to E2_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _E3DIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to E3_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _E4DIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to E4_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _E5DIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to E5_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _E6DIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to E6_DIAG_PIN." - #elif Z3_USE_ENDSTOP == _E7DIAG_ - #warning "Auto-assigned Z3_DIAG_PIN to E7_DIAG_PIN." + #if AUTO_ASSIGNED_X2_MS2 + #warning "Note: Auto-assigned X2_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" #endif -#endif -#if AUTO_ASSIGNED_Z4_STEPPER - #warning "Auto-assigned Z4 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs." -#endif -#if AUTO_ASSIGNED_Z4_CS - #warning "Auto-assigned Z4_CS_PIN to an unused En_CS_PIN." -#endif -#if AUTO_ASSIGNED_Z4_MS1 - #warning "Auto-assigned Z4_MS1_PIN to an unused En_MS1_PIN." -#endif -#if AUTO_ASSIGNED_Z4_MS2 - #warning "Auto-assigned Z4_MS2_PIN to an unused En_MS2_PIN." -#endif -#if AUTO_ASSIGNED_Z4_MS3 - #warning "Auto-assigned Z4_MS3_PIN to an unused En_MS3_PIN." -#endif -#if AUTO_ASSIGNED_Z4_DIAG - #if Z4_USE_ENDSTOP == _XMIN_ - #warning "Auto-assigned Z4_DIAG_PIN to X_MIN_PIN." - #elif Z4_USE_ENDSTOP == _XMAX_ - #warning "Auto-assigned Z4_DIAG_PIN to X_MAX_PIN." - #elif Z4_USE_ENDSTOP == _XSTOP_ - #warning "Auto-assigned Z4_DIAG_PIN to X_STOP_PIN." - #elif Z4_USE_ENDSTOP == _YMIN_ - #warning "Auto-assigned Z4_DIAG_PIN to Y_MIN_PIN." - #elif Z4_USE_ENDSTOP == _YMAX_ - #warning "Auto-assigned Z4_DIAG_PIN to Y_MAX_PIN." - #elif Z4_USE_ENDSTOP == _YSTOP_ - #warning "Auto-assigned Z4_DIAG_PIN to Y_STOP_PIN." - #elif Z4_USE_ENDSTOP == _ZMIN_ - #warning "Auto-assigned Z4_DIAG_PIN to Z_MIN_PIN." - #elif Z4_USE_ENDSTOP == _ZMAX_ - #warning "Auto-assigned Z4_DIAG_PIN to Z_MAX_PIN." - #elif Z4_USE_ENDSTOP == _ZSTOP_ - #warning "Auto-assigned Z4_DIAG_PIN to Z_STOP_PIN." - #elif Z4_USE_ENDSTOP == _XDIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to X_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _YDIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to Y_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _ZDIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to Z_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _E0DIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to E0_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _E1DIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to E1_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _E2DIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to E2_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _E3DIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to E3_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _E4DIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to E4_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _E5DIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to E5_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _E6DIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to E6_DIAG_PIN." - #elif Z4_USE_ENDSTOP == _E7DIAG_ - #warning "Auto-assigned Z4_DIAG_PIN to E7_DIAG_PIN." + #if AUTO_ASSIGNED_X2_MS3 + #warning "Note: Auto-assigned X2_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" #endif -#endif -#if AUTO_ASSIGNED_I_STEPPER - #warning "Auto-assigned I STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs." -#endif -#if AUTO_ASSIGNED_I_CS - #warning "Auto-assigned I_CS_PIN to an unused En_CS_PIN." -#endif -#if AUTO_ASSIGNED_I_MS1 - #warning "Auto-assigned I_MS1_PIN to an unused En_MS1_PIN." -#endif -#if AUTO_ASSIGNED_I_MS2 - #warning "Auto-assigned I_MS2_PIN to an unused En_MS2_PIN." -#endif -#if AUTO_ASSIGNED_I_MS3 - #warning "Auto-assigned I_MS3_PIN to an unused En_MS3_PIN." -#endif -#if AUTO_ASSIGNED_I_DIAG - #if I_USE_ENDSTOP == _XMIN_ - #warning "Auto-assigned I_DIAG_PIN to X_MIN_PIN." - #elif I_USE_ENDSTOP == _XMAX_ - #warning "Auto-assigned I_DIAG_PIN to X_MAX_PIN." - #elif I_USE_ENDSTOP == _XSTOP_ - #warning "Auto-assigned I_DIAG_PIN to X_STOP_PIN." - #elif I_USE_ENDSTOP == _YMIN_ - #warning "Auto-assigned I_DIAG_PIN to Y_MIN_PIN." - #elif I_USE_ENDSTOP == _YMAX_ - #warning "Auto-assigned I_DIAG_PIN to Y_MAX_PIN." - #elif I_USE_ENDSTOP == _YSTOP_ - #warning "Auto-assigned I_DIAG_PIN to Y_STOP_PIN." - #elif I_USE_ENDSTOP == _ZMIN_ - #warning "Auto-assigned I_DIAG_PIN to Z_MIN_PIN." - #elif I_USE_ENDSTOP == _ZMAX_ - #warning "Auto-assigned I_DIAG_PIN to Z_MAX_PIN." - #elif I_USE_ENDSTOP == _ZSTOP_ - #warning "Auto-assigned I_DIAG_PIN to Z_STOP_PIN." - #elif I_USE_ENDSTOP == _XDIAG_ - #warning "Auto-assigned I_DIAG_PIN to X_DIAG_PIN." - #elif I_USE_ENDSTOP == _YDIAG_ - #warning "Auto-assigned I_DIAG_PIN to Y_DIAG_PIN." - #elif I_USE_ENDSTOP == _ZDIAG_ - #warning "Auto-assigned I_DIAG_PIN to Z_DIAG_PIN." - #elif I_USE_ENDSTOP == _E0DIAG_ - #warning "Auto-assigned I_DIAG_PIN to E0_DIAG_PIN." - #elif I_USE_ENDSTOP == _E1DIAG_ - #warning "Auto-assigned I_DIAG_PIN to E1_DIAG_PIN." - #elif I_USE_ENDSTOP == _E2DIAG_ - #warning "Auto-assigned I_DIAG_PIN to E2_DIAG_PIN." - #elif I_USE_ENDSTOP == _E3DIAG_ - #warning "Auto-assigned I_DIAG_PIN to E3_DIAG_PIN." - #elif I_USE_ENDSTOP == _E4DIAG_ - #warning "Auto-assigned I_DIAG_PIN to E4_DIAG_PIN." - #elif I_USE_ENDSTOP == _E5DIAG_ - #warning "Auto-assigned I_DIAG_PIN to E5_DIAG_PIN." - #elif I_USE_ENDSTOP == _E6DIAG_ - #warning "Auto-assigned I_DIAG_PIN to E6_DIAG_PIN." - #elif I_USE_ENDSTOP == _E7DIAG_ - #warning "Auto-assigned I_DIAG_PIN to E7_DIAG_PIN." + #if AUTO_ASSIGNED_X2_CS + #warning "Note: Auto-assigned X2_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" #endif -#endif -#if AUTO_ASSIGNED_J_STEPPER - #warning "Auto-assigned J STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs." -#endif -#if AUTO_ASSIGNED_J_CS - #warning "Auto-assigned J_CS_PIN to an unused En_CS_PIN." -#endif -#if AUTO_ASSIGNED_J_MS1 - #warning "Auto-assigned J_MS1_PIN to an unused En_MS1_PIN." -#endif -#if AUTO_ASSIGNED_J_MS2 - #warning "Auto-assigned J_MS2_PIN to an unused En_MS2_PIN." -#endif -#if AUTO_ASSIGNED_J_MS3 - #warning "Auto-assigned J_MS3_PIN to an unused En_MS3_PIN." -#endif -#if AUTO_ASSIGNED_J_DIAG - #if J_USE_ENDSTOP == _XMIN_ - #warning "Auto-assigned J_DIAG_PIN to X_MIN_PIN." - #elif J_USE_ENDSTOP == _XMAX_ - #warning "Auto-assigned J_DIAG_PIN to X_MAX_PIN." - #elif J_USE_ENDSTOP == _XSTOP_ - #warning "Auto-assigned J_DIAG_PIN to X_STOP_PIN." - #elif J_USE_ENDSTOP == _YMIN_ - #warning "Auto-assigned J_DIAG_PIN to Y_MIN_PIN." - #elif J_USE_ENDSTOP == _YMAX_ - #warning "Auto-assigned J_DIAG_PIN to Y_MAX_PIN." - #elif J_USE_ENDSTOP == _YSTOP_ - #warning "Auto-assigned J_DIAG_PIN to Y_STOP_PIN." - #elif J_USE_ENDSTOP == _ZMIN_ - #warning "Auto-assigned J_DIAG_PIN to Z_MIN_PIN." - #elif J_USE_ENDSTOP == _ZMAX_ - #warning "Auto-assigned J_DIAG_PIN to Z_MAX_PIN." - #elif J_USE_ENDSTOP == _ZSTOP_ - #warning "Auto-assigned J_DIAG_PIN to Z_STOP_PIN." - #elif J_USE_ENDSTOP == _XDIAG_ - #warning "Auto-assigned J_DIAG_PIN to X_DIAG_PIN." - #elif J_USE_ENDSTOP == _YDIAG_ - #warning "Auto-assigned J_DIAG_PIN to Y_DIAG_PIN." - #elif J_USE_ENDSTOP == _ZDIAG_ - #warning "Auto-assigned J_DIAG_PIN to Z_DIAG_PIN." - #elif J_USE_ENDSTOP == _E0DIAG_ - #warning "Auto-assigned J_DIAG_PIN to E0_DIAG_PIN." - #elif J_USE_ENDSTOP == _E1DIAG_ - #warning "Auto-assigned J_DIAG_PIN to E1_DIAG_PIN." - #elif J_USE_ENDSTOP == _E2DIAG_ - #warning "Auto-assigned J_DIAG_PIN to E2_DIAG_PIN." - #elif J_USE_ENDSTOP == _E3DIAG_ - #warning "Auto-assigned J_DIAG_PIN to E3_DIAG_PIN." - #elif J_USE_ENDSTOP == _E4DIAG_ - #warning "Auto-assigned J_DIAG_PIN to E4_DIAG_PIN." - #elif J_USE_ENDSTOP == _E5DIAG_ - #warning "Auto-assigned J_DIAG_PIN to E5_DIAG_PIN." - #elif J_USE_ENDSTOP == _E6DIAG_ - #warning "Auto-assigned J_DIAG_PIN to E6_DIAG_PIN." - #elif J_USE_ENDSTOP == _E7DIAG_ - #warning "Auto-assigned J_DIAG_PIN to E7_DIAG_PIN." + #if AUTO_ASSIGNED_X2_DIAG + #if X2_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned X2_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned X2_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _XSTOP_ + #warning "Note: Auto-assigned X2_DIAG_PIN to X_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned X2_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned X2_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _YSTOP_ + #warning "Note: Auto-assigned X2_DIAG_PIN to Y_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned X2_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned X2_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _ZSTOP_ + #warning "Note: Auto-assigned X2_DIAG_PIN to Z_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif X2_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned X2_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif #endif -#endif -#if AUTO_ASSIGNED_K_STEPPER - #warning "Auto-assigned K STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs." -#endif -#if AUTO_ASSIGNED_K_CS - #warning "Auto-assigned K_CS_PIN to an unused En_CS_PIN." -#endif -#if AUTO_ASSIGNED_K_MS1 - #warning "Auto-assigned K_MS1_PIN to an unused En_MS1_PIN." -#endif -#if AUTO_ASSIGNED_K_MS2 - #warning "Auto-assigned K_MS2_PIN to an unused En_MS2_PIN." -#endif -#if AUTO_ASSIGNED_K_MS3 - #warning "Auto-assigned K_MS3_PIN to an unused En_MS3_PIN." -#endif -#if AUTO_ASSIGNED_K_DIAG - #if K_USE_ENDSTOP == _XMIN_ - #warning "Auto-assigned K_DIAG_PIN to X_MIN_PIN." - #elif K_USE_ENDSTOP == _XMAX_ - #warning "Auto-assigned K_DIAG_PIN to X_MAX_PIN." - #elif K_USE_ENDSTOP == _XSTOP_ - #warning "Auto-assigned K_DIAG_PIN to X_STOP_PIN." - #elif K_USE_ENDSTOP == _YMIN_ - #warning "Auto-assigned K_DIAG_PIN to Y_MIN_PIN." - #elif K_USE_ENDSTOP == _YMAX_ - #warning "Auto-assigned K_DIAG_PIN to Y_MAX_PIN." - #elif K_USE_ENDSTOP == _YSTOP_ - #warning "Auto-assigned K_DIAG_PIN to Y_STOP_PIN." - #elif K_USE_ENDSTOP == _ZMIN_ - #warning "Auto-assigned K_DIAG_PIN to Z_MIN_PIN." - #elif K_USE_ENDSTOP == _ZMAX_ - #warning "Auto-assigned K_DIAG_PIN to Z_MAX_PIN." - #elif K_USE_ENDSTOP == _ZSTOP_ - #warning "Auto-assigned K_DIAG_PIN to Z_STOP_PIN." - #elif K_USE_ENDSTOP == _XDIAG_ - #warning "Auto-assigned K_DIAG_PIN to X_DIAG_PIN." - #elif K_USE_ENDSTOP == _YDIAG_ - #warning "Auto-assigned K_DIAG_PIN to Y_DIAG_PIN." - #elif K_USE_ENDSTOP == _ZDIAG_ - #warning "Auto-assigned K_DIAG_PIN to Z_DIAG_PIN." - #elif K_USE_ENDSTOP == _E0DIAG_ - #warning "Auto-assigned K_DIAG_PIN to E0_DIAG_PIN." - #elif K_USE_ENDSTOP == _E1DIAG_ - #warning "Auto-assigned K_DIAG_PIN to E1_DIAG_PIN." - #elif K_USE_ENDSTOP == _E2DIAG_ - #warning "Auto-assigned K_DIAG_PIN to E2_DIAG_PIN." - #elif K_USE_ENDSTOP == _E3DIAG_ - #warning "Auto-assigned K_DIAG_PIN to E3_DIAG_PIN." - #elif K_USE_ENDSTOP == _E4DIAG_ - #warning "Auto-assigned K_DIAG_PIN to E4_DIAG_PIN." - #elif K_USE_ENDSTOP == _E5DIAG_ - #warning "Auto-assigned K_DIAG_PIN to E5_DIAG_PIN." - #elif K_USE_ENDSTOP == _E6DIAG_ - #warning "Auto-assigned K_DIAG_PIN to E6_DIAG_PIN." - #elif K_USE_ENDSTOP == _E7DIAG_ - #warning "Auto-assigned K_DIAG_PIN to E7_DIAG_PIN." + #if AUTO_ASSIGNED_Y2_STEPPER + #warning "Note: Auto-assigned Y2 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Y2_MS1 + #warning "Note: Auto-assigned Y2_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Y2_MS2 + #warning "Note: Auto-assigned Y2_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Y2_MS3 + #warning "Note: Auto-assigned Y2_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Y2_CS + #warning "Note: Auto-assigned Y2_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Y2_DIAG + #if Y2_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _XSTOP_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to X_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _YSTOP_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to Y_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _ZSTOP_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to Z_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Y2_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned Y2_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #endif + #if AUTO_ASSIGNED_Z2_STEPPER + #warning "Note: Auto-assigned Z2 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z2_MS1 + #warning "Note: Auto-assigned Z2_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z2_MS2 + #warning "Note: Auto-assigned Z2_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z2_MS3 + #warning "Note: Auto-assigned Z2_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z2_CS + #warning "Note: Auto-assigned Z2_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z2_DIAG + #if Z2_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _XSTOP_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to X_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _YSTOP_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to Y_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _ZSTOP_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to Z_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z2_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned Z2_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #endif + #if AUTO_ASSIGNED_Z3_STEPPER + #warning "Note: Auto-assigned Z3 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z3_CS + #warning "Note: Auto-assigned Z3_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z3_MS1 + #warning "Note: Auto-assigned Z3_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z3_MS2 + #warning "Note: Auto-assigned Z3_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z3_MS3 + #warning "Note: Auto-assigned Z3_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z3_DIAG + #if Z3_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _XSTOP_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to X_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _YSTOP_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to Y_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _ZSTOP_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to Z_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z3_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned Z3_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #endif + #if AUTO_ASSIGNED_Z4_STEPPER + #warning "Note: Auto-assigned Z4 STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z4_CS + #warning "Note: Auto-assigned Z4_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z4_MS1 + #warning "Note: Auto-assigned Z4_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z4_MS2 + #warning "Note: Auto-assigned Z4_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z4_MS3 + #warning "Note: Auto-assigned Z4_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_Z4_DIAG + #if Z4_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _XSTOP_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to X_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _YSTOP_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to Y_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _ZSTOP_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to Z_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif Z4_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned Z4_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #endif + #if AUTO_ASSIGNED_I_STEPPER + #warning "Note: Auto-assigned I STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_I_CS + #warning "Note: Auto-assigned I_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_I_MS1 + #warning "Note: Auto-assigned I_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_I_MS2 + #warning "Note: Auto-assigned I_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_I_MS3 + #warning "Note: Auto-assigned I_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_I_DIAG + #if I_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned I_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned I_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _XSTOP_ + #warning "Note: Auto-assigned I_DIAG_PIN to X_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned I_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned I_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _YSTOP_ + #warning "Note: Auto-assigned I_DIAG_PIN to Y_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned I_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned I_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _ZSTOP_ + #warning "Note: Auto-assigned I_DIAG_PIN to Z_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif I_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned I_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #endif + #if AUTO_ASSIGNED_J_STEPPER + #warning "Note: Auto-assigned J STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_J_CS + #warning "Note: Auto-assigned J_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_J_MS1 + #warning "Note: Auto-assigned J_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_J_MS2 + #warning "Note: Auto-assigned J_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_J_MS3 + #warning "Note: Auto-assigned J_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_J_DIAG + #if J_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned J_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned J_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _XSTOP_ + #warning "Note: Auto-assigned J_DIAG_PIN to X_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned J_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned J_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _YSTOP_ + #warning "Note: Auto-assigned J_DIAG_PIN to Y_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned J_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned J_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _ZSTOP_ + #warning "Note: Auto-assigned J_DIAG_PIN to Z_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif J_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned J_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #endif + #if AUTO_ASSIGNED_K_STEPPER + #warning "Note: Auto-assigned K STEP/DIR/ENABLE_PINs to unused En_STEP/DIR/ENABLE_PINs. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_K_CS + #warning "Note: Auto-assigned K_CS_PIN to an unused En_CS_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_K_MS1 + #warning "Note: Auto-assigned K_MS1_PIN to an unused En_MS1_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_K_MS2 + #warning "Note: Auto-assigned K_MS2_PIN to an unused En_MS2_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_K_MS3 + #warning "Note: Auto-assigned K_MS3_PIN to an unused En_MS3_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + #if AUTO_ASSIGNED_K_DIAG + #if K_USE_ENDSTOP == _XMIN_ + #warning "Note: Auto-assigned K_DIAG_PIN to X_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _XMAX_ + #warning "Note: Auto-assigned K_DIAG_PIN to X_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _XSTOP_ + #warning "Note: Auto-assigned K_DIAG_PIN to X_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _YMIN_ + #warning "Note: Auto-assigned K_DIAG_PIN to Y_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _YMAX_ + #warning "Note: Auto-assigned K_DIAG_PIN to Y_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _YSTOP_ + #warning "Note: Auto-assigned K_DIAG_PIN to Y_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _ZMIN_ + #warning "Note: Auto-assigned K_DIAG_PIN to Z_MIN_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _ZMAX_ + #warning "Note: Auto-assigned K_DIAG_PIN to Z_MAX_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _ZSTOP_ + #warning "Note: Auto-assigned K_DIAG_PIN to Z_STOP_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _XDIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to X_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _YDIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to Y_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _ZDIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to Z_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _E0DIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to E0_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _E1DIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to E1_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _E2DIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to E2_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _E3DIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to E3_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _E4DIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to E4_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _E5DIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to E5_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _E6DIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to E6_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #elif K_USE_ENDSTOP == _E7DIAG_ + #warning "Note: Auto-assigned K_DIAG_PIN to E7_DIAG_PIN. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif #endif -#endif -#if ENABLED(CHAMBER_FAN) && !defined(CHAMBER_FAN_INDEX) - #warning "Auto-assigned CHAMBER_FAN_INDEX to the first free FAN pin." -#endif + #if ENABLED(CHAMBER_FAN) && !defined(CHAMBER_FAN_INDEX) + #warning "Note: Auto-assigned CHAMBER_FAN_INDEX to the first free FAN pin. (Define NO_AUTO_ASSIGN_WARNING to suppress this warning.)" + #endif + +#endif // !NO_AUTO_ASSIGN_WARNING #if IS_LEGACY_TFT #warning "Don't forget to update your TFT settings in Configuration.h." @@ -534,7 +552,11 @@ // 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 may have A4988 or TMC2208_STANDALONE drivers. Check your board and make sure to select the correct DRIVER_TYPE!" + #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)." +#endif + +#if PRINTCOUNTER_SYNC + #warning "To prevent step loss, motion will pause for PRINTCOUNTER auto-save." #endif #if HOMING_Z_WITH_PROBE && IS_CARTESIAN && DISABLED(Z_SAFE_HOMING) @@ -544,12 +566,53 @@ // // Warn users of potential endstop/DIAG pin conflicts to prevent homing issues when not using sensorless homing // -#if !USE_SENSORLESS && ENABLED(USES_DIAG_JUMPERS) - #warning "Motherboard DIAG jumpers must be removed when SENSORLESS_HOMING is disabled." -#elif !USE_SENSORLESS && ENABLED(USES_DIAG_PINS) - #warning "Driver DIAG pins must be physically removed unless SENSORLESS_HOMING is enabled. (See https://bit.ly/2ZPRlt0)" +#if !USE_SENSORLESS + #if ENABLED(USES_DIAG_JUMPERS) && DISABLED(DIAG_JUMPERS_REMOVED) + #warning "Motherboard DIAG jumpers must be removed when SENSORLESS_HOMING is disabled. (Define DIAG_JUMPERS_REMOVED to suppress this warning.)" + #elif ENABLED(USES_DIAG_PINS) && DISABLED(DIAG_PINS_REMOVED) + #warning "Driver DIAG pins must be physically removed unless SENSORLESS_HOMING is enabled. (See https://bit.ly/2ZPRlt0) (Define DIAG_PINS_REMOVED to suppress this warning.)" + #endif #endif #if CANNOT_EMBED_CONFIGURATION #warning "Disabled CONFIGURATION_EMBEDDING because the target usually has less flash storage. Define FORCE_CONFIG_EMBED to override." #endif + +#if HAS_LCD_CONTRAST && LCD_CONTRAST_MIN >= LCD_CONTRAST_MAX + #warning "Contrast cannot be changed when LCD_CONTRAST_MIN >= LCD_CONTRAST_MAX." +#endif + +#if PROGRESS_MSG_EXPIRE > 0 && HAS_STATUS_MESSAGE_TIMEOUT + #warning "It is recommended not to combine PROGRESS_MSG_EXPIRE with STATUS_MESSAGE_TIMEOUT_SEC." +#endif + +/** + * FYSETC/MKS/BTT Mini Panel backlighting + */ +#if EITHER(FYSETC_242_OLED_12864, FYSETC_MINI_12864_2_1) && !ALL(NEOPIXEL_LED, LED_CONTROL_MENU, LED_USER_PRESET_STARTUP, LED_COLOR_PRESETS) + #warning "Your FYSETC/MKS/BTT Mini Panel works best with NEOPIXEL_LED, LED_CONTROL_MENU, LED_USER_PRESET_STARTUP, and LED_COLOR_PRESETS." +#endif + +#if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) && DISABLED(RGB_LED) + #warning "Your FYSETC Mini Panel works best with RGB_LED." +#elif EITHER(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1) && DISABLED(LED_USER_PRESET_STARTUP) + #warning "Your FYSETC Mini Panel works best with LED_USER_PRESET_STARTUP." +#endif + +#if EITHER(FYSETC_242_OLED_12864, FYSETC_MINI_12864) && BOTH(PSU_CONTROL, HAS_COLOR_LEDS) && !LED_POWEROFF_TIMEOUT + #warning "Your FYSETC display with PSU_CONTROL works best with LED_POWEROFF_TIMEOUT." +#endif + +/** + * Maple environment + */ +#ifdef __STM32F1__ + #warning "Maple build environments are deprecated. Please use a non-Maple build environment. Report issues to the Marlin Firmware project." +#endif + +/** + * Průša MK3/S/+ fan pin reassignment + */ +#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 diff --git a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp index 31b26aa5bbcb..1e82fe403d9f 100644 --- a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp +++ b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp @@ -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(wchar_t c, pixel_len_t max_length) { +int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { // find the HD44780 internal ROM first int ret; @@ -1047,9 +1047,9 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) { * * Draw a UTF-8 string */ -static int lcd_put_u8str_max_cb(const char * utf8_str, uint8_t (*cb_read_byte)(uint8_t * str), pixel_len_t max_length) { +static int lcd_put_u8str_max_cb(const char * utf8_str, read_byte_cb_t cb_read_byte, const pixel_len_t max_length) { pixel_len_t ret = 0; - uint8_t *p = (uint8_t *)utf8_str; + 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); @@ -1059,11 +1059,11 @@ static int lcd_put_u8str_max_cb(const char * utf8_str, uint8_t (*cb_read_byte)(u return (int)ret; } -int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) { +int lcd_put_u8str_max(const char * utf8_str, const pixel_len_t max_length) { return lcd_put_u8str_max_cb(utf8_str, read_byte_ram, max_length); } -int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) { +int lcd_put_u8str_max_P(PGM_P utf8_pstr, const pixel_len_t max_length) { return lcd_put_u8str_max_cb(utf8_pstr, read_byte_rom, max_length); } diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index b450c9c10f5a..da4db8b2d419 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -121,7 +121,7 @@ static void createChar_P(const char c, const byte * const ptr) { #if ENABLED(LCD_USE_I2C_BUZZER) void MarlinUI::buzz(const long duration, const uint16_t freq) { - if (!buzzer_enabled) return; + if (!sound_on) return; lcd.buzz(duration, freq); } #endif @@ -284,7 +284,7 @@ void MarlinUI::set_custom_characters(const HD44780CharSet screen_charset/*=CHARS #endif // LCD_PROGRESS_BAR - #if BOTH(SDSUPPORT, HAS_LCD_MENU) + #if BOTH(SDSUPPORT, HAS_MARLINUI_MENU) // CHARSET_MENU const static PROGMEM byte refresh[8] = { @@ -334,7 +334,7 @@ void MarlinUI::set_custom_characters(const HD44780CharSet screen_charset/*=CHARS #endif { createChar_P(LCD_STR_UPLEVEL[0], uplevel); - #if BOTH(SDSUPPORT, HAS_LCD_MENU) + #if BOTH(SDSUPPORT, HAS_MARLINUI_MENU) // SD Card sub-menu special characters createChar_P(LCD_STR_REFRESH[0], refresh); createChar_P(LCD_STR_FOLDER[0], folder); @@ -410,7 +410,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); } // Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line void lcd_scroll(const lcd_uint_t col, const lcd_uint_t line, FSTR_P const ftxt, const uint8_t len, const int16_t time) { - uint8_t slen = utf8_strlen_P(FTOP(ftxt)); + uint8_t slen = utf8_strlen(ftxt); if (slen < len) { lcd_put_u8str_max(col, line, ftxt, len); for (; slen < len; ++slen) lcd_put_wchar(' '); @@ -437,10 +437,10 @@ void MarlinUI::clear_lcd() { lcd.clear(); } } } - static void logo_lines(PGM_P const extra) { - int16_t indent = (LCD_WIDTH - 8 - utf8_strlen_P(extra)) / 2; + 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_u8str(indent, 1, F("|Marlin|")); lcd_put_u8str_P(extra); + 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'); } @@ -468,7 +468,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); } // // Show the Marlin logo, splash line1, and splash line 2 // - logo_lines(PSTR(" " SHORT_BUILD_VERSION)); + logo_lines(F(" " SHORT_BUILD_VERSION)); CENTER_OR_SCROLL(MARLIN_WEBSITE_URL, 2000); } else { @@ -476,7 +476,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); } // Show the Marlin logo and short build version // After a delay show the website URL // - logo_lines(NUL_STR); + logo_lines(FPSTR(NUL_STR)); CENTER_OR_SCROLL(SHORT_BUILD_VERSION, 1500); CENTER_OR_SCROLL(MARLIN_WEBSITE_URL, 1500); #ifdef STRING_SPLASH_LINE3 @@ -495,12 +495,13 @@ void MarlinUI::clear_lcd() { lcd.clear(); } #endif // SHOW_BOOTSCREEN void MarlinUI::draw_kill_screen() { - lcd_put_u8str(0, 0, status_message); - lcd_uint_t y = 2; + lcd_uint_t x = 0, y = 0; + lcd_put_u8str(x, y, status_message); + y = 2; #if LCD_HEIGHT >= 4 - lcd_put_u8str(0, y++, GET_TEXT_F(MSG_HALTED)); + lcd_put_u8str(x, y++, GET_TEXT_F(MSG_HALTED)); #endif - lcd_put_u8str(0, y, GET_TEXT_F(MSG_PLEASE_RESET)); + lcd_put_u8str(x, y, GET_TEXT_F(MSG_PLEASE_RESET)); } // @@ -1051,7 +1052,7 @@ void MarlinUI::draw_status_screen() { draw_status_message(blink); } -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "../menu/menu.h" @@ -1067,33 +1068,33 @@ void MarlinUI::draw_status_screen() { #endif // ADVANCED_PAUSE_FEATURE // Draw a static item with no left-right margin required. Centered by default. - void MenuItem_static::draw(const uint8_t row, PGM_P const pstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) { + void MenuItem_static::draw(const uint8_t row, FSTR_P const fstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) { int8_t n = LCD_WIDTH; lcd_moveto(0, row); - const int8_t plen = pstr ? utf8_strlen_P(pstr) : 0, + const int8_t plen = fstr ? utf8_strlen(fstr) : 0, 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--; } } - if (plen) n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, 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(' '); } // Draw a generic menu item with pre_char (if selected) and post_char - void MenuItemBase::_draw(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char 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 : ' '); - uint8_t n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, LCD_WIDTH - 2); + uint8_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2); for (; n; --n) lcd_put_wchar(' '); lcd_put_wchar(post_char); } // Draw a menu item with a (potentially) editable value - void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, const char * const inStr, const bool pgm) { + 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] : ' '); - uint8_t n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, LCD_WIDTH - 2 - vlen); + 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(' '); @@ -1102,9 +1103,9 @@ void MarlinUI::draw_status_screen() { } // Low-level draw_edit_screen can be used to draw an edit screen from anyplace - void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) { + void MenuEditItemBase::draw_edit_screen(FSTR_P const ftpl, const char * const value/*=nullptr*/) { ui.encoder_direction_normal(); - uint8_t n = lcd_put_u8str_ind_P(0, 1, pstr, itemIndex, itemString, LCD_WIDTH - 1); + uint8_t n = lcd_put_u8str(0, 1, ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 1); if (value) { lcd_put_wchar(':'); n--; const uint8_t len = utf8_strlen(value) + 1; // Plus one for a leading space @@ -1115,17 +1116,21 @@ void MarlinUI::draw_status_screen() { } // The Select Screen presents a prompt and two "buttons" - void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) { + void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, const bool yesno, FSTR_P const pref, const char * const string/*=nullptr*/, FSTR_P const suff/*=nullptr*/) { ui.draw_select_screen_prompt(pref, string, suff); - SETCURSOR(0, LCD_HEIGHT - 1); - lcd_put_wchar(yesno ? ' ' : '['); lcd_put_u8str_P(no); lcd_put_wchar(yesno ? ' ' : ']'); - SETCURSOR_RJ(utf8_strlen_P(yes) + 2, LCD_HEIGHT - 1); - lcd_put_wchar(yesno ? '[' : ' '); lcd_put_u8str_P(yes); lcd_put_wchar(yesno ? ']' : ' '); + if (no) { + SETCURSOR(0, LCD_HEIGHT - 1); + lcd_put_wchar(yesno ? ' ' : '['); lcd_put_u8str(no); lcd_put_wchar(yesno ? ' ' : ']'); + } + if (yes) { + SETCURSOR_RJ(utf8_strlen(yes) + 2, LCD_HEIGHT - 1); + lcd_put_wchar(yesno ? '[' : ' '); lcd_put_u8str(yes); lcd_put_wchar(yesno ? ']' : ' '); + } } #if ENABLED(SDSUPPORT) - void MenuItem_sdbase::draw(const bool sel, const uint8_t row, PGM_P const, CardReader &theCard, const bool isDir) { + 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] : ' '); constexpr uint8_t maxlen = LCD_WIDTH - 2; uint8_t n = maxlen - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), maxlen); @@ -1277,9 +1282,9 @@ void MarlinUI::draw_status_screen() { * Show X and Y positions */ _XLABEL(_PLOT_X, 0); - lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(ubl.mesh_index_to_xpos(x_plot)))); + lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(bedlevel.get_mesh_x(x_plot)))); _YLABEL(_LCD_W_POS, 0); - lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(ubl.mesh_index_to_ypos(y_plot)))); + lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(bedlevel.get_mesh_y(y_plot)))); lcd_moveto(_PLOT_X, 0); @@ -1471,8 +1476,8 @@ void MarlinUI::draw_status_screen() { * Print Z values */ _ZLABEL(_LCD_W_POS, 1); - if (!isnan(ubl.z_values[x_plot][y_plot])) - lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot])); + if (!isnan(bedlevel.z_values[x_plot][y_plot])) + lcd_put_u8str(ftostr43sign(bedlevel.z_values[x_plot][y_plot])); else lcd_put_u8str(F(" -----")); @@ -1482,16 +1487,16 @@ void MarlinUI::draw_status_screen() { * Show all values at right of screen */ _XLABEL(_LCD_W_POS, 1); - lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(ubl.mesh_index_to_xpos(x_plot)))); + lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(bedlevel.get_mesh_x(x_plot)))); _YLABEL(_LCD_W_POS, 2); - lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(ubl.mesh_index_to_ypos(y_plot)))); + lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(bedlevel.get_mesh_y(y_plot)))); /** * Show the location value */ _ZLABEL(_LCD_W_POS, 3); - if (!isnan(ubl.z_values[x_plot][y_plot])) - lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot])); + if (!isnan(bedlevel.z_values[x_plot][y_plot])) + lcd_put_u8str(ftostr43sign(bedlevel.z_values[x_plot][y_plot])); else lcd_put_u8str(F(" -----")); @@ -1584,6 +1589,6 @@ void MarlinUI::draw_status_screen() { #endif // AUTO_BED_LEVELING_UBL -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU #endif // HAS_MARLINUI_HD44780 diff --git a/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp index 106ce7613892..7b15b786055c 100644 --- a/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/lcdprint_TFTGLCD.cpp @@ -45,7 +45,7 @@ #include -int lcd_glyph_height(void) { return 1; } +int lcd_glyph_height() { return 1; } typedef struct _TFTGLCD_charmap_t { wchar_t uchar; // the unicode char @@ -991,7 +991,7 @@ void lcd_put_int(const int i) { // return < 0 on error // return the advanced cols -int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) { +int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { // find the HD44780 internal ROM first int ret; @@ -1045,9 +1045,9 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) { * * Draw a UTF-8 string */ -static int lcd_put_u8str_max_cb(const char * utf8_str, uint8_t (*cb_read_byte)(uint8_t * str), pixel_len_t max_length) { +static int lcd_put_u8str_max_cb(const char * utf8_str, read_byte_cb_t cb_read_byte, const pixel_len_t max_length) { pixel_len_t ret = 0; - uint8_t *p = (uint8_t *)utf8_str; + 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); @@ -1057,11 +1057,11 @@ static int lcd_put_u8str_max_cb(const char * utf8_str, uint8_t (*cb_read_byte)(u return (int)ret; } -int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) { +int lcd_put_u8str_max(const char * utf8_str, const pixel_len_t max_length) { return lcd_put_u8str_max_cb(utf8_str, read_byte_ram, max_length); } -int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) { +int lcd_put_u8str_max_P(PGM_P utf8_pstr, const pixel_len_t max_length) { return lcd_put_u8str_max_cb(utf8_pstr, read_byte_rom, max_length); } @@ -1119,7 +1119,7 @@ int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) { return 0; } - int test_TFTGLCD_charmap_all(void) { + int test_TFTGLCD_charmap_all() { int flg_error = 0; if (test_TFTGLCD_charmap(g_TFTGLCD_charmap_device, COUNT(g_TFTGLCD_charmap_device), "g_TFTGLCD_charmap_device", 0) < 0) { flg_error = 1; diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index 420bd7cd66ae..46564bb1e6e2 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -265,7 +265,7 @@ void TFTGLCD::setContrast(uint16_t contrast) { extern volatile int8_t encoderDiff; // Read buttons and encoder states -uint8_t MarlinUI::read_slow_buttons(void) { +uint8_t MarlinUI::read_slow_buttons() { if (!PanelDetected) return 0; #if ENABLED(TFTGLCD_PANEL_SPI) uint8_t b = 0; @@ -301,7 +301,7 @@ uint8_t MarlinUI::read_slow_buttons(void) { // Duration in ms, freq in Hz void MarlinUI::buzz(const long duration, const uint16_t freq) { if (!PanelDetected) return; - if (!buzzer_enabled) return; + if (!sound_on) return; #if ENABLED(TFTGLCD_PANEL_SPI) WRITE(TFTGLCD_CS, LOW); SPI_SEND_ONE(BUZZER); @@ -380,13 +380,14 @@ void MarlinUI::clear_lcd() { void MarlinUI::_set_contrast() { lcd.setContrast(contrast); } #endif -static void center_text_P(PGM_P pstart, uint8_t y) { - uint8_t len = utf8_strlen_P(pstart); - if (len < LCD_WIDTH) - lcd.setCursor((LCD_WIDTH - len) / 2, y); - else - lcd.setCursor(0, y); - lcd_put_u8str_P(pstart); +#if !IS_TFTGLCD_PANEL + void lcd_moveto(const uint8_t col, const uint8_t row) { lcd.setCursor(col, row); } +#endif + +static void center_text(FSTR_P const fstart, const uint8_t y) { + const uint8_t len = utf8_strlen(fstart); + lcd_moveto(len < LCD_WIDTH ? (LCD_WIDTH - len) / 2 : 0, y); + lcd_put_u8str(fstart); } #if ENABLED(SHOW_BOOTSCREEN) @@ -399,11 +400,11 @@ static void center_text_P(PGM_P pstart, uint8_t y) { uint8_t indent = (LCD_WIDTH - 8) / 2; // symbols 217 (bottom right corner) and 218 (top left corner) are using for letters in some languages // and they should be moved to beginning ASCII table as special symbols - lcd.setCursor(indent, 0); lcd.write(TLC); lcd_put_u8str(F("------")); lcd.write(TRC); - lcd.setCursor(indent, 1); lcd.write(LR); lcd_put_u8str(F("Marlin")); lcd.write(LR); - lcd.setCursor(indent, 2); lcd.write(BLC); lcd_put_u8str(F("------")); lcd.write(BRC); - center_text_P(PSTR(SHORT_BUILD_VERSION), 3); - center_text_P(PSTR(MARLIN_WEBSITE_URL), 4); + lcd_moveto(indent, 0); lcd.write(TLC); lcd_put_u8str(F("------")); lcd.write(TRC); + lcd_moveto(indent, 1); lcd.write(LR); lcd_put_u8str(F("Marlin")); lcd.write(LR); + lcd_moveto(indent, 2); lcd.write(BLC); lcd_put_u8str(F("------")); lcd.write(BRC); + center_text(F(SHORT_BUILD_VERSION), 3); + center_text(F(MARLIN_WEBSITE_URL), 4); picBits = ICON_LOGO; lcd.print_screen(); } @@ -417,11 +418,11 @@ static void center_text_P(PGM_P pstart, uint8_t y) { void MarlinUI::draw_kill_screen() { if (!PanelDetected) return; lcd.clear_buffer(); - lcd.setCursor(0, 3); lcd.write(COLOR_ERROR); - lcd.setCursor((LCD_WIDTH - utf8_strlen(status_message)) / 2 + 1, 3); + lcd_moveto(0, 3); lcd.write(COLOR_ERROR); + lcd_moveto((LCD_WIDTH - utf8_strlen(status_message)) / 2 + 1, 3); lcd_put_u8str(status_message); - center_text_P(GET_TEXT(MSG_HALTED), 5); - center_text_P(GET_TEXT(MSG_PLEASE_RESET), 6); + center_text(GET_TEXT_F(MSG_HALTED), 5); + center_text(GET_TEXT_F(MSG_PLEASE_RESET), 6); lcd.print_screen(); } @@ -456,25 +457,25 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #if HOTENDS < 2 if (heater_id == H_E0) { - lcd.setCursor(2, 5); lcd.print(prefix); //HE - lcd.setCursor(1, 6); lcd.print(i16tostr3rj(t1)); - lcd.setCursor(1, 7); + lcd_moveto(2, 5); lcd.print(prefix); //HE + lcd_moveto(1, 6); lcd.print(i16tostr3rj(t1)); + lcd_moveto(1, 7); } else { - lcd.setCursor(6, 5); lcd.print(prefix); //BED - lcd.setCursor(6, 6); lcd.print(i16tostr3rj(t1)); - lcd.setCursor(6, 7); + lcd_moveto(6, 5); lcd.print(prefix); //BED + lcd_moveto(6, 6); lcd.print(i16tostr3rj(t1)); + lcd_moveto(6, 7); } #else if (heater_id > H_BED) { - lcd.setCursor(heater_id * 4, 5); lcd.print(prefix); // HE1 or HE2 or HE3 - lcd.setCursor(heater_id * 4, 6); lcd.print(i16tostr3rj(t1)); - lcd.setCursor(heater_id * 4, 7); + lcd_moveto(heater_id * 4, 5); lcd.print(prefix); // HE1 or HE2 or HE3 + lcd_moveto(heater_id * 4, 6); lcd.print(i16tostr3rj(t1)); + lcd_moveto(heater_id * 4, 7); } else { - lcd.setCursor(13, 5); lcd.print(prefix); //BED - lcd.setCursor(13, 6); lcd.print(i16tostr3rj(t1)); - lcd.setCursor(13, 7); + lcd_moveto(13, 5); lcd.print(prefix); //BED + lcd_moveto(13, 6); lcd.print(i16tostr3rj(t1)); + lcd_moveto(13, 7); } #endif // HOTENDS <= 1 @@ -515,9 +516,9 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const FORCE_INLINE void _draw_cooler_status(const bool blink) { const celsius_t t2 = thermalManager.degTargetCooler(); - lcd.setCursor(0, 5); lcd_put_u8str(F("COOL")); - lcd.setCursor(1, 6); lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegCooler())); - lcd.setCursor(1, 7); + lcd_moveto(0, 5); lcd_put_u8str(F("COOL")); + lcd_moveto(1, 6); lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegCooler())); + lcd_moveto(1, 7); #if !HEATER_IDLE_HANDLER UNUSED(blink); @@ -543,9 +544,9 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #if ENABLED(LASER_COOLANT_FLOW_METER) FORCE_INLINE void _draw_flowmeter_status() { - lcd.setCursor(5, 5); lcd_put_u8str(F("FLOW")); - lcd.setCursor(7, 6); lcd_put_wchar('L'); - lcd.setCursor(6, 7); lcd_put_u8str(ftostr11ns(cooler.flowrate)); + lcd_moveto(5, 5); lcd_put_u8str(F("FLOW")); + lcd_moveto(7, 6); lcd_put_wchar('L'); + lcd_moveto(6, 7); lcd_put_u8str(ftostr11ns(cooler.flowrate)); if (cooler.flowrate) picBits |= ICON_FAN; else picBits &= ~ICON_FAN; @@ -556,18 +557,18 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #if ENABLED(I2C_AMMETER) FORCE_INLINE void _draw_ammeter_status() { - lcd.setCursor(10, 5); lcd_put_u8str(F("ILAZ")); + lcd_moveto(10, 5); lcd_put_u8str(F("ILAZ")); ammeter.read(); - lcd.setCursor(11, 6); + lcd_moveto(11, 6); if (ammeter.current <= 0.999f) { lcd_put_u8str("mA"); - lcd.setCursor(10, 7); + lcd_moveto(10, 7); lcd_put_wchar(' '); lcd_put_u8str(ui16tostr3rj(uint16_t(ammeter.current * 1000 + 0.5f))); } else { lcd_put_u8str(" A"); - lcd.setCursor(10, 7); + lcd_moveto(10, 7); lcd_put_u8str(ftostr12ns(ammeter.current)); } @@ -580,16 +581,16 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #if HAS_CUTTER FORCE_INLINE void _draw_cutter_status() { - lcd.setCursor(15, 5); lcd_put_u8str(F("CUTT")); + lcd_moveto(15, 5); lcd_put_u8str(F("CUTT")); #if CUTTER_UNIT_IS(RPM) - lcd.setCursor(16, 6); lcd_put_u8str(F("RPM")); - lcd.setCursor(15, 7); lcd_put_u8str(ftostr31ns(float(cutter.unitPower) / 1000)); + 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'); #elif CUTTER_UNIT_IS(PERCENT) - lcd.setCursor(17, 6); lcd_put_wchar('%'); - lcd.setCursor(18, 7); lcd_put_u8str(cutter_power2str(cutter.unitPower)); + lcd_moveto(17, 6); lcd_put_wchar('%'); + lcd_moveto(18, 7); lcd_put_u8str(cutter_power2str(cutter.unitPower)); #else - lcd.setCursor(17, 7); lcd_put_u8str(cutter_power2str(cutter.unitPower)); + lcd_moveto(17, 7); lcd_put_u8str(cutter_power2str(cutter.unitPower)); #endif if (cutter.unitPower) picBits |= ICON_HOT; @@ -625,10 +626,10 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const lcd.write('%'); lcd.write(percent); } else { // For progress bar test - lcd.setCursor(LCD_WIDTH / 2 - 2, MIDDLE_Y); - lcd.print(i16tostr3rj(percent)); lcd.write('%'); + lcd_moveto(LCD_WIDTH / 2 - 2, MIDDLE_Y); + lcd.print(i16tostr3rj(percent)); lcd.write('%'); lcd.print_line(); - lcd.setCursor(0, MIDDLE_Y + 1); + lcd_moveto(0, MIDDLE_Y + 1); lcd.write('%'); lcd.write(percent); lcd.print_line(); } @@ -638,7 +639,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const void MarlinUI::draw_status_message(const bool blink) { if (!PanelDetected) return; - lcd.setCursor(0, 3); + lcd_moveto(0, 3); #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) // Alternate Status message and Filament display @@ -787,7 +788,7 @@ void MarlinUI::draw_status_screen() { // Line 1 - XYZ coordinates // - lcd.setCursor(0, 0); + lcd_moveto(0, 0); const xyz_pos_t lpos = current_position.asLogical(); _draw_axis_value(X_AXIS, ftostr4sign(lpos.x), blink); lcd.write(' '); _draw_axis_value(Y_AXIS, ftostr4sign(lpos.y), blink); lcd.write(' '); @@ -801,11 +802,11 @@ void MarlinUI::draw_status_screen() { // Line 2 - feedrate, , time // - lcd.setCursor(0, 1); + lcd_moveto(0, 1); lcd_put_u8str(F("FR")); lcd.print(i16tostr3rj(feedrate_percentage)); lcd.write('%'); #if BOTH(SDSUPPORT, HAS_PRINT_PROGRESS) - lcd.setCursor(LCD_WIDTH / 2 - 3, 1); + lcd_moveto(LCD_WIDTH / 2 - 3, 1); _draw_print_progress(); #endif @@ -813,14 +814,14 @@ void MarlinUI::draw_status_screen() { duration_t elapsed = print_job_timer.duration(); uint8_t len = elapsed.toDigital(buffer); - lcd.setCursor((LCD_WIDTH - 1) - len, 1); + lcd_moveto((LCD_WIDTH - 1) - len, 1); lcd.write(LCD_STR_CLOCK[0]); lcd.print(buffer); // // Line 3 - progressbar // - lcd.setCursor(0, 2); + lcd_moveto(0, 2); #if ENABLED(LCD_PROGRESS_BAR) draw_progress_bar(_get_progress()); #else @@ -839,7 +840,7 @@ void MarlinUI::draw_status_screen() { #if HOTENDS <= 1 || (HOTENDS <= 2 && !HAS_HEATED_BED) #if DUAL_MIXING_EXTRUDER - lcd.setCursor(0, 4); + lcd_moveto(0, 4); // Two-component mix / gradient instead of XY char mixer_messages[12]; const char *mix_label; @@ -895,9 +896,9 @@ void MarlinUI::draw_status_screen() { #else #define FANX 17 #endif - lcd.setCursor(FANX, 5); lcd_put_u8str(F("FAN")); - lcd.setCursor(FANX + 1, 6); lcd.write('%'); - lcd.setCursor(FANX, 7); + lcd_moveto(FANX, 5); lcd_put_u8str(F("FAN")); + lcd_moveto(FANX + 1, 6); lcd.write('%'); + lcd_moveto(FANX, 7); lcd.print(i16tostr3rj(per)); if (TERN0(HAS_FAN0, thermalManager.fan_speed[0]) || TERN0(HAS_FAN1, thermalManager.fan_speed[1]) || TERN0(HAS_FAN2, thermalManager.fan_speed[2])) @@ -922,7 +923,7 @@ void MarlinUI::draw_status_screen() { lcd.print_screen(); } -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "../menu/menu.h" @@ -930,7 +931,7 @@ void MarlinUI::draw_status_screen() { void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) { if (!PanelDetected) return; - lcd.setCursor((LCD_WIDTH - 14) / 2, row + 1); + lcd_moveto((LCD_WIDTH - 14) / 2, row + 1); lcd.write(LCD_STR_THERMOMETER[0]); lcd_put_u8str(F(" E")); lcd.write('1' + extruder); lcd.write(' '); lcd.print(i16tostr3rj(thermalManager.wholeDegHotend(extruder))); lcd.write(LCD_STR_DEGREE[0]); lcd.write('/'); lcd.print(i16tostr3rj(thermalManager.degTargetHotend(extruder))); lcd.write(LCD_STR_DEGREE[0]); @@ -940,58 +941,58 @@ void MarlinUI::draw_status_screen() { #endif // Draw a static item with no left-right margin required. Centered by default. - void MenuItem_static::draw(const uint8_t row, PGM_P const pstr, const uint8_t style/*=SS_DEFAULT*/, const char * const valstr/*=nullptr*/) { + void MenuItem_static::draw(const uint8_t row, FSTR_P const fstr, const uint8_t style/*=SS_DEFAULT*/, const char * const valstr/*=nullptr*/) { if (!PanelDetected) return; uint8_t n = LCD_WIDTH; - lcd.setCursor(0, row); + lcd_moveto(0, row); if ((style & SS_CENTER) && !valstr) { - int8_t pad = (LCD_WIDTH - utf8_strlen_P(pstr)) / 2; + int8_t pad = (LCD_WIDTH - utf8_strlen(fstr)) / 2; while (--pad >= 0) { lcd.write(' '); n--; } } - n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, n); + n = lcd_put_u8str(fstr, itemIndex, itemStringC, itemStringF, n); if (valstr) n -= lcd_put_u8str_max(valstr, n); for (; n; --n) lcd.write(' '); lcd.print_line(); } // Draw a generic menu item with pre_char (if selected) and post_char - void MenuItemBase::_draw(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char) { + void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char pre_char, const char post_char) { if (!PanelDetected) return; - lcd.setCursor(0, row); + lcd_moveto(0, row); lcd.write(sel ? pre_char : ' '); - uint8_t n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, LCD_WIDTH - 2); + uint8_t n = lcd_put_u8str(fstr, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2); for (; n; --n) lcd.write(' '); lcd.write(post_char); lcd.print_line(); } // Draw a menu item with a (potentially) editable value - void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, const char * const data, const bool pgm) { + void MenuEditItemBase::draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char * const inStr, const bool pgm) { if (!PanelDetected) return; - const uint8_t vlen = data ? (pgm ? utf8_strlen_P(data) : utf8_strlen(data)) : 0; - lcd.setCursor(0, row); + const uint8_t vlen = inStr ? (pgm ? utf8_strlen_P(inStr) : utf8_strlen(inStr)) : 0; + lcd_moveto(0, row); lcd.write(sel ? LCD_STR_ARROW_RIGHT[0] : ' '); - uint8_t n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, LCD_WIDTH - 2 - vlen); + uint8_t n = lcd_put_u8str(fstr, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2 - vlen); if (vlen) { lcd.write(':'); for (; n; --n) lcd.write(' '); - if (pgm) lcd_put_u8str_P(data); else lcd_put_u8str(data); + if (pgm) lcd_put_u8str_P(inStr); else lcd_put_u8str(inStr); } lcd.print_line(); } // Low-level draw_edit_screen can be used to draw an edit screen from anyplace // This line moves to the last line of the screen for UBL plot screen on the panel side - void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) { + void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const value/*=nullptr*/) { if (!PanelDetected) return; ui.encoder_direction_normal(); const uint8_t y = TERN0(AUTO_BED_LEVELING_UBL, ui.external_control) ? LCD_HEIGHT - 1 : MIDDLE_Y; - lcd.setCursor(0, y); + lcd_moveto(0, y); lcd.write(COLOR_EDIT); - lcd_put_u8str_P(pstr); + lcd_put_u8str(fstr); if (value) { lcd.write(':'); - lcd.setCursor((LCD_WIDTH - 1) - (utf8_strlen(value) + 1), y); // Right-justified, padded by spaces + lcd_moveto((LCD_WIDTH - 1) - (utf8_strlen(value) + 1), y); // Right-justified, padded by spaces lcd.write(' '); // Overwrite char if value gets shorter lcd.print(value); lcd.write(' '); @@ -1000,22 +1001,26 @@ void MarlinUI::draw_status_screen() { } // The Select Screen presents a prompt and two "buttons" - void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string, PGM_P const suff) { + void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, const bool yesno, FSTR_P const pref, const char * const string, FSTR_P const suff) { if (!PanelDetected) return; ui.draw_select_screen_prompt(pref, string, suff); - lcd.setCursor(0, MIDDLE_Y); lcd.write(COLOR_EDIT); - lcd.write(yesno ? ' ' : '['); lcd_put_u8str_P(no); lcd.write(yesno ? ' ' : ']'); - lcd.setCursor(LCD_WIDTH - utf8_strlen_P(yes) - 3, MIDDLE_Y); - lcd.write(yesno ? '[' : ' '); lcd_put_u8str_P(yes); lcd.write(yesno ? ']' : ' '); + if (no) { + lcd_moveto(0, MIDDLE_Y); + lcd.write(yesno ? ' ' : '['); lcd_put_u8str(no); lcd.write(yesno ? ' ' : ']'); + } + if (yes) { + lcd_moveto(LCD_WIDTH - utf8_strlen(yes) - 3, MIDDLE_Y); + lcd.write(yesno ? '[' : ' '); lcd_put_u8str(yes); lcd.write(yesno ? ']' : ' '); + } lcd.print_line(); } #if ENABLED(SDSUPPORT) - void MenuItem_sdbase::draw(const bool sel, const uint8_t row, PGM_P const, CardReader &theCard, const bool isDir) { + void MenuItem_sdbase::draw(const bool sel, const uint8_t row, FSTR_P const, CardReader &theCard, const bool isDir) { if (!PanelDetected) return; - lcd.setCursor(0, row); + lcd_moveto(0, row); lcd.write(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); @@ -1054,36 +1059,36 @@ void MarlinUI::draw_status_screen() { lcd.clear_buffer(); //print only top left corner. All frame with grid points will be printed by panel - lcd.setCursor(0, 0); + lcd_moveto(0, 0); *fb++ = TLC; //top left corner - marker for plot parameters *fb = (GRID_MAX_POINTS_X << 4) + GRID_MAX_POINTS_Y; //set mesh size // Print plot position - lcd.setCursor(_LCD_W_POS, 0); - *fb++ = '('; lcd.print(i16tostr3left(x_plot)); - *fb++ = ','; lcd.print(i16tostr3left(y_plot)); *fb = ')'; + lcd_moveto(_LCD_W_POS, 0); + *fb++ = '('; lcd.print(i16tostr3left(x_plot)); + *fb++ = ','; lcd.print(i16tostr3left(y_plot)); *fb = ')'; // Show all values - lcd.setCursor(_LCD_W_POS, 1); lcd_put_u8str(F("X:")); - lcd.print(ftostr52(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot])))); - lcd.setCursor(_LCD_W_POS, 2); lcd_put_u8str(F("Y:")); - lcd.print(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot])))); + lcd_moveto(_LCD_W_POS, 1); lcd_put_u8str(F("X:")); + lcd.print(ftostr52(LOGICAL_X_POSITION(pgm_read_float(&bedlevel._mesh_index_to_xpos[x_plot])))); + lcd_moveto(_LCD_W_POS, 2); lcd_put_u8str(F("Y:")); + lcd.print(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&bedlevel._mesh_index_to_ypos[y_plot])))); // Show the location value - lcd.setCursor(_LCD_W_POS, 3); lcd_put_u8str(F("Z:")); + lcd_moveto(_LCD_W_POS, 3); lcd_put_u8str(F("Z:")); - if (!isnan(ubl.z_values[x_plot][y_plot])) - lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot])); + if (!isnan(bedlevel.z_values[x_plot][y_plot])) + lcd.print(ftostr43sign(bedlevel.z_values[x_plot][y_plot])); else lcd_put_u8str(F(" -----")); - center_text_P(GET_TEXT(MSG_UBL_FINE_TUNE_MESH), 8); + center_text(GET_TEXT_F(MSG_UBL_FINE_TUNE_MESH), 8); lcd.print_screen(); } #endif // AUTO_BED_LEVELING_UBL -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU #endif // IS_TFTGLCD_PANEL diff --git a/Marlin/src/lcd/buttons.h b/Marlin/src/lcd/buttons.h index 6d028e9bc65a..2580a71d1b82 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) +#if (HAS_ENCODER_WHEEL || ANY_BUTTON(ENC, BACK, UP, DWN, LFT, RT)) && DISABLED(TOUCH_UI_FTDI_EVE) #define HAS_DIGITAL_BUTTONS 1 #endif #if !HAS_ADC_BUTTONS && (IS_RRW_KEYPAD || (HAS_WIRED_LCD && !IS_NEWPANEL)) @@ -45,36 +45,6 @@ #define ENCODER_PHASE_3 1 #endif -#if IS_RRW_KEYPAD - #define BTN_OFFSET 0 // Bit offset into buttons for shift register values - - #define BLEN_KEYPAD_F3 0 - #define BLEN_KEYPAD_F2 1 - #define BLEN_KEYPAD_F1 2 - #define BLEN_KEYPAD_DOWN 3 - #define BLEN_KEYPAD_RIGHT 4 - #define BLEN_KEYPAD_MIDDLE 5 - #define BLEN_KEYPAD_UP 6 - #define BLEN_KEYPAD_LEFT 7 - - #define EN_KEYPAD_F1 _BV(BTN_OFFSET + BLEN_KEYPAD_F1) - #define EN_KEYPAD_F2 _BV(BTN_OFFSET + BLEN_KEYPAD_F2) - #define EN_KEYPAD_F3 _BV(BTN_OFFSET + BLEN_KEYPAD_F3) - #define EN_KEYPAD_DOWN _BV(BTN_OFFSET + BLEN_KEYPAD_DOWN) - #define EN_KEYPAD_RIGHT _BV(BTN_OFFSET + BLEN_KEYPAD_RIGHT) - #define EN_KEYPAD_MIDDLE _BV(BTN_OFFSET + BLEN_KEYPAD_MIDDLE) - #define EN_KEYPAD_UP _BV(BTN_OFFSET + BLEN_KEYPAD_UP) - #define EN_KEYPAD_LEFT _BV(BTN_OFFSET + BLEN_KEYPAD_LEFT) - - #define RRK(B) (keypad_buttons & (B)) - - #ifdef EN_C - #define BUTTON_CLICK() ((buttons & EN_C) || RRK(EN_KEYPAD_MIDDLE)) - #else - #define BUTTON_CLICK() RRK(EN_KEYPAD_MIDDLE) - #endif -#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 @@ -141,7 +111,39 @@ #define B_ST _BV(BL_ST) #ifndef BUTTON_CLICK - #define BUTTON_CLICK() (buttons & (B_MI|B_ST)) + #if EN_C + #define BUTTON_CLICK() (buttons & (B_MI|B_ST)) + #endif + #endif +#endif + +#if IS_RRW_KEYPAD + #define BTN_OFFSET 0 // Bit offset into buttons for shift register values + + #define BLEN_KEYPAD_F3 0 + #define BLEN_KEYPAD_F2 1 + #define BLEN_KEYPAD_F1 2 + #define BLEN_KEYPAD_DOWN 3 + #define BLEN_KEYPAD_RIGHT 4 + #define BLEN_KEYPAD_MIDDLE 5 + #define BLEN_KEYPAD_UP 6 + #define BLEN_KEYPAD_LEFT 7 + + #define EN_KEYPAD_F1 _BV(BTN_OFFSET + BLEN_KEYPAD_F1) + #define EN_KEYPAD_F2 _BV(BTN_OFFSET + BLEN_KEYPAD_F2) + #define EN_KEYPAD_F3 _BV(BTN_OFFSET + BLEN_KEYPAD_F3) + #define EN_KEYPAD_DOWN _BV(BTN_OFFSET + BLEN_KEYPAD_DOWN) + #define EN_KEYPAD_RIGHT _BV(BTN_OFFSET + BLEN_KEYPAD_RIGHT) + #define EN_KEYPAD_MIDDLE _BV(BTN_OFFSET + BLEN_KEYPAD_MIDDLE) + #define EN_KEYPAD_UP _BV(BTN_OFFSET + BLEN_KEYPAD_UP) + #define EN_KEYPAD_LEFT _BV(BTN_OFFSET + BLEN_KEYPAD_LEFT) + + #define RRK(B) (keypad_buttons & (B)) + + #ifdef EN_C + #define BUTTON_CLICK() ((buttons & EN_C) || RRK(EN_KEYPAD_MIDDLE)) + #else + #define BUTTON_CLICK() RRK(EN_KEYPAD_MIDDLE) #endif #endif diff --git a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h index a30dd4ca17f3..e5c6524a9ec4 100644 --- a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h +++ b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h @@ -57,6 +57,11 @@ #define U8G_COM_HAL_SW_SPI_FN u8g_com_std_sw_spi_fn #define U8G_COM_HAL_HW_SPI_FN u8g_com_stm32duino_hw_spi_fn + #elif defined(ESP32) + + uint8_t u8g_eps_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); + #define U8G_COM_HAL_HW_SPI_FN u8g_eps_hw_spi_fn + #elif defined(__AVR__) uint8_t u8g_com_HAL_AVR_sw_sp_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); diff --git a/Marlin/src/lcd/dogm/dogm_Statusscreen.h b/Marlin/src/lcd/dogm/dogm_Statusscreen.h index f17dd0636516..8d0ab4efbe46 100644 --- a/Marlin/src/lcd/dogm/dogm_Statusscreen.h +++ b/Marlin/src/lcd/dogm/dogm_Statusscreen.h @@ -37,6 +37,7 @@ #undef STATUS_HEATERS_X #undef STATUS_BED_X + /** * Custom _Statusscreen.h files can define: * - A custom logo image diff --git a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp index f74a59a08c7c..f5c13798f234 100644 --- a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp +++ b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp @@ -28,7 +28,7 @@ void lcd_put_int(const int i) { u8g.print(i); } // return < 0 on error // return the advanced pixels -int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) { +int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { if (c < 256) { u8g.print((char)c); return u8g_GetFontBBXWidth(u8g.getU8g()); @@ -39,14 +39,14 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) { return ret; } -int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) { +int lcd_put_u8str_max(const char * utf8_str, const pixel_len_t max_length) { u8g_uint_t x = u8g.getPrintCol(), y = u8g.getPrintRow(), ret = uxg_DrawUtf8Str(u8g.getU8g(), x, y, utf8_str, max_length); u8g.setPrintPos(x + ret, y); return ret; } -int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) { +int lcd_put_u8str_max_P(PGM_P utf8_pstr, const pixel_len_t max_length) { u8g_uint_t x = u8g.getPrintCol(), y = u8g.getPrintRow(), ret = uxg_DrawUtf8StrP(u8g.getU8g(), x, y, utf8_pstr, max_length); u8g.setPrintPos(x + ret, y); diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index 59c74148adef..3c661a44294a 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -282,9 +282,9 @@ void MarlinUI::init_lcd() { #if PIN_EXISTS(LCD_RESET) // Perform a clean hardware reset with needed delays OUT_WRITE(LCD_RESET_PIN, LOW); - _delay_ms(5); + hal.delay_ms(5); WRITE(LCD_RESET_PIN, HIGH); - _delay_ms(5); + hal.delay_ms(5); u8g.begin(); #endif @@ -294,9 +294,13 @@ void MarlinUI::init_lcd() { TERN_(HAS_LCD_CONTRAST, refresh_contrast()); - TERN_(LCD_SCREEN_ROT_90, u8g.setRot90()); - TERN_(LCD_SCREEN_ROT_180, u8g.setRot180()); - TERN_(LCD_SCREEN_ROT_270, u8g.setRot270()); + #if LCD_SCREEN_ROTATE == 90 + u8g.setRot90(); + #elif LCD_SCREEN_ROTATE == 180 + u8g.setRot180(); + #elif LCD_SCREEN_ROTATE == 270 + u8g.setRot270(); + #endif update_language_font(); } @@ -326,18 +330,23 @@ void MarlinUI::update_language_font() { // The kill screen is displayed for unrecoverable conditions void MarlinUI::draw_kill_screen() { TERN_(LIGHTWEIGHT_UI, ST7920_Lite_Status_Screen::clear_text_buffer()); - const u8g_uint_t h4 = u8g.getHeight() / 4; + const u8g_uint_t x = 0, h4 = u8g.getHeight() / 4; u8g.firstPage(); do { set_font(FONT_MENU); - lcd_put_u8str(0, h4 * 1, status_message); - lcd_put_u8str(0, h4 * 2, GET_TEXT_F(MSG_HALTED)); - lcd_put_u8str(0, h4 * 3, GET_TEXT_F(MSG_PLEASE_RESET)); + lcd_put_u8str(x, h4 * 1, status_message); + lcd_put_u8str(x, h4 * 2, GET_TEXT_F(MSG_HALTED)); + lcd_put_u8str(x, h4 * 3, GET_TEXT_F(MSG_PLEASE_RESET)); } while (u8g.nextPage()); } 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(); } +#endif + #if HAS_LCD_BRIGHTNESS void MarlinUI::_set_brightness() { @@ -349,7 +358,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop #endif -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "../menu/menu.h" @@ -403,28 +412,28 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop } // Draw a static line of text in the same idiom as a menu item - void MenuItem_static::draw(const uint8_t row, PGM_P const pstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) { + void MenuItem_static::draw(const uint8_t row, FSTR_P const ftpl, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) { if (mark_as_selected(row, style & SS_INVERT)) { pixel_len_t n = LCD_PIXEL_WIDTH; // pixel width of string allowed - const int plen = pstr ? calculateWidth(pstr) : 0, + const int plen = ftpl ? calculateWidth(ftpl) : 0, 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(' '); } - if (plen) n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, n / (MENU_FONT_WIDTH)) * (MENU_FONT_WIDTH); + 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(' '); } } // Draw a generic menu item - void MenuItemBase::_draw(const bool sel, const uint8_t row, PGM_P const pstr, const char, const char post_char) { + 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_ind_P(pstr, itemIndex, itemString, LCD_WIDTH - 1) * (MENU_FONT_WIDTH); + 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(' '); @@ -432,27 +441,27 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop } // Draw a menu item with an editable value - void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, const char * const inStr, const bool pgm) { + void MenuEditItemBase::draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char * const inStr, const bool pgm) { if (mark_as_selected(row, sel)) { - const uint8_t vallen = (pgm ? utf8_strlen_P(inStr) : utf8_strlen((char*)inStr)), - pixelwidth = (pgm ? uxg_GetUtf8StrPixelWidthP(u8g.getU8g(), inStr) : uxg_GetUtf8StrPixelWidth(u8g.getU8g(), (char*)inStr)); + const uint8_t vallen = (pgm ? utf8_strlen_P(inStr) : utf8_strlen(inStr)), + pixelwidth = (pgm ? uxg_GetUtf8StrPixelWidthP(u8g.getU8g(), inStr) : uxg_GetUtf8StrPixelWidth(u8g.getU8g(), inStr)); const u8g_uint_t prop = USE_WIDE_GLYPH ? 2 : 1; - pixel_len_t n = lcd_put_u8str_ind_P(pstr, itemIndex, itemString, LCD_WIDTH - 2 - vallen * prop) * (MENU_FONT_WIDTH); + 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_moveto(LCD_PIXEL_WIDTH - _MAX((MENU_FONT_WIDTH) * vallen, pixelwidth + 2), row_y2); - if (pgm) lcd_put_u8str_P(inStr); else lcd_put_u8str((char*)inStr); + if (pgm) lcd_put_u8str_P(inStr); else lcd_put_u8str(inStr); } } } - void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) { + void MenuEditItemBase::draw_edit_screen(FSTR_P const ftpl, const char * const value/*=nullptr*/) { ui.encoder_direction_normal(); const u8g_uint_t prop = USE_WIDE_GLYPH ? 2 : 1; - const u8g_uint_t labellen = utf8_strlen_P(pstr), vallen = utf8_strlen(value); + const u8g_uint_t labellen = utf8_strlen(ftpl), vallen = utf8_strlen(value); bool extra_row = labellen * prop > LCD_WIDTH - 2 - vallen * prop; #if ENABLED(USE_BIG_EDIT_FONT) @@ -481,7 +490,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop // Assume the label is alpha-numeric (with a descender) bool onpage = PAGE_CONTAINS(baseline - (EDIT_FONT_ASCENT - 1), baseline + EDIT_FONT_DESCENT); - if (onpage) lcd_put_u8str_ind_P(0, baseline, pstr, itemIndex, itemString); + if (onpage) lcd_put_u8str(0, baseline, ftpl, itemIndex, itemStringC, itemStringF); // If a value is included, print a colon, then print the value right-justified if (value) { @@ -499,8 +508,8 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop TERN_(USE_BIG_EDIT_FONT, ui.set_font(FONT_MENU)); } - inline void draw_boxed_string(const u8g_uint_t x, const u8g_uint_t y, PGM_P const pstr, const bool inv) { - const u8g_uint_t len = utf8_strlen_P(pstr), + inline void draw_boxed_string(const u8g_uint_t x, const u8g_uint_t y, FSTR_P const fstr, const bool inv) { + const u8g_uint_t len = utf8_strlen(fstr), by = (y + 1) * (MENU_FONT_HEIGHT); const u8g_uint_t prop = USE_WIDE_GLYPH ? 2 : 1; const pixel_len_t bw = len * prop * (MENU_FONT_WIDTH), bx = x * prop * (MENU_FONT_WIDTH); @@ -509,19 +518,19 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop u8g.drawBox(bx / prop - 1, by - (MENU_FONT_ASCENT), bw + 2, MENU_FONT_HEIGHT); u8g.setColorIndex(0); } - lcd_put_u8str_P(bx / prop, by, pstr); + lcd_put_u8str(bx / prop, by, fstr); if (inv) u8g.setColorIndex(1); } - void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) { - ui.draw_select_screen_prompt(pref, string, suff); - draw_boxed_string(1, LCD_HEIGHT - 1, no, !yesno); - draw_boxed_string(LCD_WIDTH - (utf8_strlen_P(yes) * (USE_WIDE_GLYPH ? 2 : 1) + 1), LCD_HEIGHT - 1, yes, yesno); + void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, const bool yesno, FSTR_P const fpre, const char * const string/*=nullptr*/, FSTR_P const suff/*=nullptr*/) { + ui.draw_select_screen_prompt(fpre, string, suff); + if (no) draw_boxed_string(1, LCD_HEIGHT - 1, no, !yesno); + if (yes) draw_boxed_string(LCD_WIDTH - (utf8_strlen(yes) * (USE_WIDE_GLYPH ? 2 : 1) + 1), LCD_HEIGHT - 1, yes, yesno); } #if ENABLED(SDSUPPORT) - void MenuItem_sdbase::draw(const bool sel, const uint8_t row, PGM_P const, CardReader &theCard, const bool isDir) { + 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]); @@ -570,9 +579,9 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop u8g.setColorIndex(1); const u8g_uint_t sx = x_offset + pixels_per_x_mesh_pnt / 2; u8g_uint_t y = y_offset + pixels_per_y_mesh_pnt / 2; - for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++, y += pixels_per_y_mesh_pnt) + for (uint8_t j = 0; j < (GRID_MAX_POINTS_Y); j++, y += pixels_per_y_mesh_pnt) if (PAGE_CONTAINS(y, y)) - for (uint8_t i = 0, x = sx; i < GRID_MAX_POINTS_X; i++, x += pixels_per_x_mesh_pnt) + for (uint8_t i = 0, x = sx; i < (GRID_MAX_POINTS_X); i++, x += pixels_per_x_mesh_pnt) u8g.drawBox(x, y, 1, 1); // Fill in the Specified Mesh Point @@ -592,7 +601,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop // Show X and Y positions at top of screen u8g.setColorIndex(1); if (PAGE_UNDER(7)) { - const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) }, + const xy_pos_t pos = { bedlevel.get_mesh_x(x_plot), bedlevel.get_mesh_y(y_plot) }, lpos = pos.asLogical(); lcd_put_u8str_P(5, 7, X_LBL); lcd_put_u8str(ftostr52(lpos.x)); @@ -610,8 +619,8 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop // Show the location value lcd_put_u8str_P(74, LCD_PIXEL_HEIGHT, Z_LBL); - if (!isnan(ubl.z_values[x_plot][y_plot])) - lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot])); + if (!isnan(bedlevel.z_values[x_plot][y_plot])) + lcd_put_u8str(ftostr43sign(bedlevel.z_values[x_plot][y_plot])); else lcd_put_u8str(F(" -----")); } @@ -740,6 +749,6 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop #endif // BABYSTEP_ZPROBE_GFX_OVERLAY || MESH_EDIT_GFX_OVERLAY -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU #endif // HAS_MARLINUI_U8GLIB diff --git a/Marlin/src/lcd/dogm/status/bed.h b/Marlin/src/lcd/dogm/status/bed.h index 175a50e34188..27f5617ef703 100644 --- a/Marlin/src/lcd/dogm/status/bed.h +++ b/Marlin/src/lcd/dogm/status/bed.h @@ -42,6 +42,18 @@ B00000011,B11111111,B11111111 }; + #if HAS_LEVELING + const unsigned char status_bed_leveled_bmp[] PROGMEM = { + B11111111,B11111111,B11001110, + B01000000,B00100000,B00100100, + B00100000,B00010000,B00010000, + B00011111,B11111111,B11111000, + B00001000,B00000100,B00000100, + B00100100,B00000010,B00000010, + B01110011,B11111111,B11111111 + }; + #endif + const unsigned char status_bed_on_bmp[] PROGMEM = { B00000010,B00100010,B00000000, B00000100,B01000100,B00000000, @@ -57,6 +69,23 @@ B00000011,B11111111,B11111111 }; + #if HAS_LEVELING + const unsigned char status_bed_leveled_on_bmp[] PROGMEM = { + B00000010,B00100010,B00000000, + B00000100,B01000100,B00000000, + B00000100,B01000100,B00000000, + B00000010,B00100010,B00000000, + B00000001,B00010001,B00000000, + B11111111,B11111111,B11001110, + B01000000,B10101000,B10100100, + B00100001,B00010001,B00010000, + B00011111,B11111111,B11111000, + B00001000,B00000100,B00000100, + B00100100,B00000010,B00000010, + B01110011,B11111111,B11111111 + }; + #endif + #else #define STATUS_BED_WIDTH 21 diff --git a/Marlin/src/lcd/dogm/status/combined.h b/Marlin/src/lcd/dogm/status/combined.h index ca18f21af6d5..070fe6b027d6 100644 --- a/Marlin/src/lcd/dogm/status/combined.h +++ b/Marlin/src/lcd/dogm/status/combined.h @@ -37,6 +37,7 @@ #if HOTENDS == 0 #define STATUS_HEATERS_WIDTH 96 + #define STATUS_BED_X 74 const unsigned char status_heaters_bmp[] PROGMEM = { B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000100,B00010000,B01000000, @@ -56,6 +57,7 @@ #elif HOTENDS == 1 #define STATUS_HEATERS_WIDTH 96 + #define STATUS_BED_X 74 const unsigned char status_heaters_bmp[] PROGMEM = { B00011111,B11100000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000100,B00010000,B01000000, @@ -75,6 +77,7 @@ #elif HOTENDS == 2 #define STATUS_HEATERS_WIDTH 96 + #define STATUS_BED_X 74 const unsigned char status_heaters_bmp[] PROGMEM = { B00011111,B11100000,B00000000,B00011111,B11100000,B00000000,B00000000,B00000000,B00000000,B00000100,B00010000,B01000000, @@ -104,6 +107,7 @@ #elif HOTENDS == 3 #define STATUS_HEATERS_WIDTH 96 + #define STATUS_BED_X 74 const unsigned char status_heaters_bmp[] PROGMEM = { B00011111,B11100000,B00000000,B00011111,B11100000,B00000000,B00011111,B11100000,B00000000,B00000100,B00010000,B01000000, @@ -133,6 +137,7 @@ #else // HOTENDS > 3 #define STATUS_HEATERS_WIDTH 120 + #define STATUS_BED_X 98 const unsigned char status_heaters_bmp[] PROGMEM = { B00011111,B11100000,B00000000,B00011111,B11100000,B00000000,B00011111,B11100000,B00000000,B00011111,B11100000,B00000000,B00000100,B00010000,B01000000, @@ -161,7 +166,8 @@ #endif // HOTENDS - #define STATUS_BED_TEXT_X (STATUS_HEATERS_WIDTH - 10) + #define STATUS_BED_WIDTH 20 + #define STATUS_BED_TEXT_X (STATUS_BED_X + STATUS_BED_WIDTH / 2) #else // !HAS_HEATED_BED || HOTENDS > 3 diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 52554e5df8bd..7e5329aeef3a 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -49,6 +49,10 @@ #include "../../module/planner.h" #endif +#if HAS_LEVELING + #include "../../module/planner.h" +#endif + #if HAS_CUTTER #include "../../feature/spindle_laser.h" #endif @@ -57,7 +61,7 @@ #include "../../feature/cooler.h" #endif -#if ENABLED(I2C_AMMETER) +#if DO_DRAW_AMMETER #include "../../feature/ammeter.h" #endif @@ -602,7 +606,13 @@ void MarlinUI::draw_status_screen() { #if DO_DRAW_BED && DISABLED(STATUS_COMBINE_HEATERS) #if ANIM_BED - #define BED_BITMAP(S) ((S) ? status_bed_on_bmp : status_bed_bmp) + #if BOTH(HAS_LEVELING, STATUS_ALT_BED_BITMAP) + #define BED_BITMAP(S) ((S) \ + ? (planner.leveling_active ? status_bed_leveled_on_bmp : status_bed_on_bmp) \ + : (planner.leveling_active ? status_bed_leveled_bmp : status_bed_bmp)) + #else + #define BED_BITMAP(S) ((S) ? status_bed_on_bmp : status_bed_bmp) + #endif #else #define BED_BITMAP(S) status_bed_bmp #endif @@ -664,7 +674,7 @@ void MarlinUI::draw_status_screen() { #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, ftostr51rj(float(cutter.unitPower) / 1000)); + lcd_put_u8str(STATUS_CUTTER_TEXT_X - 2, STATUS_CUTTER_TEXT_Y, ftostr61rj(float(cutter.unitPower) / 1000)); lcd_put_wchar('K'); #else lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower)); @@ -781,7 +791,7 @@ void MarlinUI::draw_status_screen() { lcd_put_u8str(estimation_x_pos, EXTRAS_BASELINE, estimation_string); } else if (elapsed_string[0]) { - lcd_put_u8str_P(PROGRESS_BAR_X, EXTRAS_BASELINE, E_LBL); + lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, F("E:")); lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string); } 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 4a794f500007..f1bf9d032ec8 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 @@ -517,14 +517,14 @@ U8G_PB_DEV(u8g_dev_tft_320x240_upscale_from_128x64, WIDTH, HEIGHT, PAGE_HEIGHT, drawCross(x, y, TFT_MARLINBG_COLOR); } - const char *str = nullptr; + FSTR_P str = nullptr; if (calibration_stage < CALIBRATION_SUCCESS) { // handle current state switch (calibration_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; - case CALIBRATION_BOTTOM_RIGHT: str = GET_TEXT(MSG_BOTTOM_RIGHT); break; + 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; + case CALIBRATION_BOTTOM_RIGHT: str = GET_TEXT_F(MSG_BOTTOM_RIGHT); break; default: break; } @@ -534,7 +534,7 @@ U8G_PB_DEV(u8g_dev_tft_320x240_upscale_from_128x64, WIDTH, HEIGHT, PAGE_HEIGHT, } else { // end calibration - str = calibration_stage == CALIBRATION_SUCCESS ? GET_TEXT(MSG_CALIBRATION_COMPLETED) : GET_TEXT(MSG_CALIBRATION_FAILED); + str = calibration_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); diff --git a/Marlin/src/lcd/dogm/u8g_fontutf8.cpp b/Marlin/src/lcd/dogm/u8g_fontutf8.cpp index 89bdb09e1be2..8ba0e7d50a8b 100644 --- a/Marlin/src/lcd/dogm/u8g_fontutf8.cpp +++ b/Marlin/src/lcd/dogm/u8g_fontutf8.cpp @@ -104,7 +104,7 @@ static void fontgroup_drawwchar(font_group_t *group, const font_t *fnt_default, * Get the screen pixel width of a ROM UTF-8 string */ 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) { - uint8_t *p = (uint8_t*)utf8_msg; + const uint8_t *p = (uint8_t*)utf8_msg; for (;;) { wchar_t val = 0; p = get_utf8_value_cb(p, cb_read_byte, &val); diff --git a/Marlin/src/lcd/dogm/u8g_fontutf8.h b/Marlin/src/lcd/dogm/u8g_fontutf8.h index 9760ef106bd1..5933f027cc79 100644 --- a/Marlin/src/lcd/dogm/u8g_fontutf8.h +++ b/Marlin/src/lcd/dogm/u8g_fontutf8.h @@ -26,10 +26,10 @@ 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, pixel_len_t max_length); +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_DrawUtf8Str(u8g_t *pu8g, unsigned int x, unsigned int y, const char *utf8_msg, pixel_len_t max_length); -unsigned int uxg_DrawUtf8StrP(u8g_t *pu8g, unsigned int x, unsigned int y, PGM_P utf8_msg, 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); int uxg_GetUtf8StrPixelWidth(u8g_t *pu8g, const char *utf8_msg); int uxg_GetUtf8StrPixelWidthP(u8g_t *pu8g, PGM_P utf8_msg); diff --git a/Marlin/src/lcd/e3v2/common/dwin_api.cpp b/Marlin/src/lcd/e3v2/common/dwin_api.cpp index d89b22a7aa74..3f699465a9c8 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_api.cpp +++ b/Marlin/src/lcd/e3v2/common/dwin_api.cpp @@ -21,10 +21,11 @@ */ #include "../../../inc/MarlinConfigPre.h" -#if EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI) +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI #include "dwin_api.h" #include "dwin_set.h" +#include "dwin_font.h" #include "../../../inc/MarlinConfig.h" @@ -89,6 +90,40 @@ bool DWIN_Handshake() { } #endif +// Get font character width +uint8_t fontWidth(uint8_t cfont) { + switch (cfont) { + case font6x12 : return 6; + case font8x16 : return 8; + case font10x20: return 10; + case font12x24: return 12; + case font14x28: return 14; + case font16x32: return 16; + case font20x40: return 20; + case font24x48: return 24; + case font28x56: return 28; + case font32x64: return 32; + default: return 0; + } +} + +// Get font character height +uint8_t fontHeight(uint8_t cfont) { + switch (cfont) { + case font6x12 : return 12; + case font8x16 : return 16; + case font10x20: return 20; + case font12x24: return 24; + case font14x28: return 28; + case font16x32: return 32; + case font20x40: return 40; + case font24x48: return 48; + case font28x56: return 56; + case font32x64: return 64; + default: return 0; + } +} + // Set screen display direction // dir: 0=0°, 1=90°, 2=180°, 3=270° void DWIN_Frame_SetDir(uint8_t dir) { @@ -199,6 +234,9 @@ 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) + DWIN_Draw_Rectangle(1, bColor, x, y, x + (fontWidth(size) * strlen_P(string)), y + fontHeight(size)); + #endif constexpr uint8_t widthAdjust = 0; size_t i = 0; DWIN_Byte(i, 0x11); @@ -228,6 +266,7 @@ 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)); DWIN_Byte(i, 0x14); // Bit 7: bshow // Bit 6: 1 = signed; 0 = unsigned number; @@ -275,6 +314,7 @@ 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)); 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_api.h b/Marlin/src/lcd/e3v2/common/dwin_api.h index 37b1525ba34a..81724c6edf97 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_api.h +++ b/Marlin/src/lcd/e3v2/common/dwin_api.h @@ -74,7 +74,7 @@ inline void DWIN_Text(size_t &i, const char * const string, uint16_t rlimit=0xFF inline void DWIN_Text(size_t &i, FSTR_P string, uint16_t rlimit=0xFFFF) { if (!string) return; - const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, _MIN(rlimit, strlen_P((PGM_P)string))); // cast to PGM_P (const char*) measure with strlen_P. + const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, _MIN(rlimit, strlen_P(FTOP(string)))); if (len == 0) return; memcpy_P(&DWIN_SendBuf[i+1], string, len); i += len; diff --git a/Marlin/src/lcd/e3v2/common/dwin_set.h b/Marlin/src/lcd/e3v2/common/dwin_set.h index 4fedd7a5843b..7f4438695478 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_set.h +++ b/Marlin/src/lcd/e3v2/common/dwin_set.h @@ -25,7 +25,16 @@ #define Language_English 1 #define Language_Chinese 2 -#define ICON 7 // Icon set file 7.ICO +//#define USE_STOCK_DWIN_SET // Use the Creality stock DWIN_SET instead of Marlin's unified DWIN_SET by The-EG & thinkyhead +#ifdef USE_STOCK_DWIN_SET + #define ICON 9 // 9.ICO +#else + #define ICON 7 // 7.ICO +#endif + +#ifndef CORP_WEBSITE + #define CORP_WEBSITE WEBSITE_URL +#endif #define ICON_LOGO 0 #define ICON_Print_0 1 diff --git a/Marlin/src/lcd/e3v2/common/encoder.cpp b/Marlin/src/lcd/e3v2/common/encoder.cpp index edfaf60aae1e..9922b70b29df 100644 --- a/Marlin/src/lcd/e3v2/common/encoder.cpp +++ b/Marlin/src/lcd/e3v2/common/encoder.cpp @@ -51,11 +51,7 @@ ENCODER_Rate EncoderRate; // TODO: Replace with ui.quick_feedback void Encoder_tick() { #if PIN_EXISTS(BEEPER) - if (ui.buzzer_enabled) { - WRITE(BEEPER_PIN, HIGH); - delay(10); - WRITE(BEEPER_PIN, LOW); - } + if (ui.sound_on) buzzer.click(10); #endif } diff --git a/Marlin/src/lcd/e3v2/common/encoder.h b/Marlin/src/lcd/e3v2/common/encoder.h index e5d9645ed43b..3ab8c3bf422b 100644 --- a/Marlin/src/lcd/e3v2/common/encoder.h +++ b/Marlin/src/lcd/e3v2/common/encoder.h @@ -45,12 +45,32 @@ typedef enum { ENCODER_DIFF_ENTER = 3 // click } EncoderState; +#define ENCODER_WAIT_MS 20 + // Encoder initialization void Encoder_Configuration(); // Analyze encoder value and return state EncoderState Encoder_ReceiveAnalyze(); +inline EncoderState get_encoder_state() { + static millis_t Encoder_ms = 0; + const millis_t ms = millis(); + if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO; + const EncoderState state = Encoder_ReceiveAnalyze(); + if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS; + return state; +} + +template +inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) { + if (encoder_diffState == ENCODER_DIFF_CW) + valref += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + valref -= EncoderRate.encoderMoveValue; + return encoder_diffState == ENCODER_DIFF_ENTER; +} + /*********************** Encoder LED ***********************/ #if PIN_EXISTS(LCD_LED) diff --git a/Marlin/src/lcd/e3v2/creality/dwin.cpp b/Marlin/src/lcd/e3v2/creality/dwin.cpp index adf8f3771f3d..b2cb1bee30ce 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin.cpp @@ -33,7 +33,7 @@ //#define USE_STRING_HEADINGS //#define USE_STRING_TITLES -#if ENABLED(LCD_BED_LEVELING) && DISABLED(PROBE_MANUALLY) && ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT) +#if DISABLED(PROBE_MANUALLY) && ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT) #define HAS_ONESTEP_LEVELING 1 #endif @@ -91,9 +91,6 @@ #ifndef MACHINE_SIZE #define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) #endif -#ifndef CORP_WEBSITE - #define CORP_WEBSITE WEBSITE_URL -#endif #define PAUSE_HEAT @@ -474,15 +471,6 @@ void Draw_Back_First(const bool is_sel=true) { if (is_sel) Draw_Menu_Cursor(0); } -template -inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) { - if (encoder_diffState == ENCODER_DIFF_CW) - valref += EncoderRate.encoderMoveValue; - else if (encoder_diffState == ENCODER_DIFF_CCW) - valref -= EncoderRate.encoderMoveValue; - return encoder_diffState == ENCODER_DIFF_ENTER; -} - // // Draw Menus // @@ -1299,15 +1287,6 @@ void Goto_MainMenu() { TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(); } -inline EncoderState get_encoder_state() { - static millis_t Encoder_ms = 0; - const millis_t ms = millis(); - if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO; - const EncoderState state = Encoder_ReceiveAnalyze(); - if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS; - return state; -} - void HMI_Plan_Move(const feedRate_t fr_mm_s) { if (!planner.is_full()) { planner.synchronize(); @@ -1387,8 +1366,6 @@ void HMI_Move_Z() { #if HAS_ZOFFSET_ITEM - bool printer_busy() { return planner.movesplanned() || printingIsActive(); } - void HMI_Zoffset() { EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState == ENCODER_DIFF_NO) return; @@ -1754,7 +1731,7 @@ void update_variable() { if (_new_hotend_target) Draw_Stat_Int(25 + 4 * STAT_CHR_W + 6, 384, _hotendtarget); - static int16_t _flow = planner.flow_percentage[0]; + static int16_t _flow = 0; if (_flow != planner.flow_percentage[0]) { _flow = planner.flow_percentage[0]; Draw_Stat_Int(116 + 2 * STAT_CHR_W, 417, _flow); @@ -1768,7 +1745,7 @@ void update_variable() { Draw_Stat_Int(25 + 4 * STAT_CHR_W + 6, 417, _bedtarget); #endif - static int16_t _feedrate = 100; + static int16_t _feedrate = 0; if (_feedrate != feedrate_percentage) { _feedrate = feedrate_percentage; Draw_Stat_Int(116 + 2 * STAT_CHR_W, 384, _feedrate); @@ -1834,6 +1811,9 @@ void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) void HMI_SDCardInit() { card.cdroot(); } +// Initialize or re-initialize the LCD +void MarlinUI::init_lcd() { DWIN_Startup(); } + void MarlinUI::refresh() { /* Nothing to see here */ } #if HAS_LCD_BRIGHTNESS @@ -2269,6 +2249,8 @@ void HMI_SelectFile() { // thermalManager.fan_speed[i] = 255; #endif + _card_percent = 0; + _remain_time = 0; Goto_PrintProcess(); } } @@ -2746,7 +2728,7 @@ void HMI_Prepare() { EncoderRate.enabled = true; #else // Apply workspace offset, making the current position 0,0,0 - queue.inject(F("G92 X0 Y0 Z0")); + queue.inject(F("G92X0Y0Z0")); HMI_AudioFeedback(); #endif break; @@ -2760,7 +2742,10 @@ void HMI_Prepare() { #endif #if HAS_HOTEND || HAS_HEATED_BED - case PREPARE_CASE_COOL: thermalManager.cooldown(); break; + case PREPARE_CASE_COOL: + thermalManager.cooldown(); + ui.reset_status(); + break; #endif case PREPARE_CASE_LANG: @@ -3571,9 +3556,9 @@ void HMI_AdvSet() { case ADVSET_CASE_HOMEOFF: checkkey = HomeOff; select_item.reset(); - HMI_ValueStruct.Home_OffX_scaled = home_offset[X_AXIS] * 10; - HMI_ValueStruct.Home_OffY_scaled = home_offset[Y_AXIS] * 10; - HMI_ValueStruct.Home_OffZ_scaled = home_offset[Z_AXIS] * 10; + HMI_ValueStruct.Home_OffX_scaled = home_offset.x * 10; + HMI_ValueStruct.Home_OffY_scaled = home_offset.y * 10; + HMI_ValueStruct.Home_OffZ_scaled = home_offset.z * 10; Draw_HomeOff_Menu(); break; #endif @@ -3821,7 +3806,7 @@ void HMI_Tune() { EncoderRate.enabled = true; #else // Apply workspace offset, making the current position 0,0,0 - queue.inject(F("G92 X0 Y0 Z0")); + queue.inject(F("G92X0Y0Z0")); HMI_AudioFeedback(); #endif break; @@ -4081,6 +4066,13 @@ void HMI_Init() { HMI_SetLanguage(); } +void DWIN_InitScreen() { + Encoder_Configuration(); + HMI_Init(); + HMI_SetLanguageCache(); + HMI_StartFrame(true); +} + void DWIN_Update() { EachMomentUpdate(); // Status update HMI_SDCardUpdate(); // SD card update @@ -4173,10 +4165,7 @@ void EachMomentUpdate() { } #if ENABLED(POWER_LOSS_RECOVERY) else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off - static bool recovery_flag = false; - recovery.dwin_flag = false; - recovery_flag = true; auto update_selection = [&](const bool sel) { HMI_flag.select_flag = sel; @@ -4196,6 +4185,7 @@ void EachMomentUpdate() { DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, npos, 252, name); DWIN_UpdateLCD(); + bool recovery_flag = true; while (recovery_flag) { EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); if (encoder_diffState != ENCODER_DIFF_NO) { @@ -4289,7 +4279,7 @@ void DWIN_HandleScreen() { } } -void DWIN_CompletedHoming() { +void DWIN_HomingDone() { HMI_flag.home_flag = false; dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z); if (checkkey == Last_Prepare) { @@ -4305,7 +4295,7 @@ void DWIN_CompletedHoming() { } } -void DWIN_CompletedLeveling() { +void DWIN_LevelingDone() { if (checkkey == Leveling) Goto_MainMenu(); } diff --git a/Marlin/src/lcd/e3v2/creality/dwin.h b/Marlin/src/lcd/e3v2/creality/dwin.h index 3122a6fcbae1..487f309ed996 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.h +++ b/Marlin/src/lcd/e3v2/creality/dwin.h @@ -236,13 +236,14 @@ void HMI_MaxJerk(); // Maximum jerk speed submenu void HMI_Step(); // Transmission ratio void HMI_Init(); +void DWIN_InitScreen(); void DWIN_Update(); void EachMomentUpdate(); void DWIN_HandleScreen(); void DWIN_StatusChanged(const char * const cstr=nullptr); void DWIN_StatusChanged(FSTR_P const fstr); -inline void DWIN_StartHoming() { HMI_flag.home_flag = true; } +inline void DWIN_HomingStart() { HMI_flag.home_flag = true; } -void DWIN_CompletedHoming(); -void DWIN_CompletedLeveling(); +void DWIN_HomingDone(); +void DWIN_LevelingDone(); diff --git a/Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp b/Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp index fee22932d2e5..3d60e32a7908 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin_lcd.cpp @@ -49,6 +49,7 @@ void DWIN_Startup() { #if DISABLED(SHOW_BOOTSCREEN) DWIN_Frame_Clear(Color_Bg_Black); // MarlinUI handles the bootscreen so just clear here #endif + DWIN_JPG_ShowAndCache(3); DWIN_UpdateLCD(); } diff --git a/Marlin/src/lcd/e3v2/enhanced/meshviewer.cpp b/Marlin/src/lcd/e3v2/enhanced/meshviewer.cpp deleted file mode 100644 index 3824d63b2b48..000000000000 --- a/Marlin/src/lcd/e3v2/enhanced/meshviewer.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/** - * DWIN Mesh Viewer - * Author: Miguel A. Risco-Castillo - * version: 3.8.1 - * Date: 2021/11/06 - * - * This program 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 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 Lesser General Public License - * along with this program. If not, see . - * - */ - -#include "../../../inc/MarlinConfigPre.h" - -#if BOTH(DWIN_CREALITY_LCD_ENHANCED, HAS_MESH) - -#include "meshviewer.h" - -#include "../../../core/types.h" -#include "../../marlinui.h" -#include "dwin_lcd.h" -#include "dwinui.h" -#include "dwin.h" -#include "../../../feature/bedlevel/bedlevel.h" - -MeshViewerClass MeshViewer; - -void MeshViewerClass::Draw() { - const int8_t mx = 25, my = 25; // Margins - const int16_t stx = (DWIN_WIDTH - 2 * mx) / (GRID_MAX_POINTS_X - 1), // Steps - sty = (DWIN_WIDTH - 2 * my) / (GRID_MAX_POINTS_Y - 1); - const int8_t rmax = _MIN(mx - 2, stx / 2); - const int8_t rmin = 7; - int16_t zmesh[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y], maxz =-32000, minz = 32000; - #define px(xp) (mx + (xp) * stx) - #define py(yp) (30 + DWIN_WIDTH - my - (yp) * sty) - #define rm(z) ((z - minz) * (rmax - rmin) / _MAX(1, (maxz - minz)) + rmin) - #define DrawMeshValue(xp, yp, zv) DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(xp) - 12, py(yp) - 6, zv) - #define DrawMeshHLine(yp) DWIN_Draw_HLine(HMI_data.SplitLine_Color, px(0), py(yp), DWIN_WIDTH - 2 * mx) - #define DrawMeshVLine(xp) DWIN_Draw_VLine(HMI_data.SplitLine_Color, px(xp), py(GRID_MAX_POINTS_Y - 1), DWIN_WIDTH - 2 * my) - GRID_LOOP(x, y) { - const float v = Z_VALUES(x,y) * 100; - zmesh[x][y] = v; - NOLESS(maxz, v); - NOMORE(minz, v); - } - Title.ShowCaption(F("Mesh Viewer")); - DWINUI::ClearMenuArea(); - DWINUI::Draw_Icon(ICON_Continue_E, 86, 305); - DWIN_Draw_Rectangle(0, HMI_data.SplitLine_Color, px(0), py(0), px(GRID_MAX_POINTS_X - 1), py(GRID_MAX_POINTS_Y - 1)); - LOOP_S_L_N(x, 1, GRID_MAX_POINTS_X - 1) DrawMeshVLine(x); - LOOP_S_L_N(y, 1, GRID_MAX_POINTS_Y - 1) DrawMeshHLine(y); - LOOP_L_N(y, GRID_MAX_POINTS_Y) { - watchdog_refresh(); - LOOP_L_N(x, GRID_MAX_POINTS_X) { - uint16_t color = DWINUI::RainbowInt(zmesh[x][y], _MIN(-5, minz), _MAX(5, maxz)); - uint8_t radius = rm(zmesh[x][y]); - DWINUI::Draw_FillCircle(color, px(x), py(y), radius); - if (GRID_MAX_POINTS_X < 9) - DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(x) - 12, py(y) - 6, Z_VALUES(x,y)); - else { - char str_1[9]; - str_1[0] = 0; - switch (zmesh[x][y]) { - case -999 ... -100: - DWINUI::Draw_Signed_Float(font6x12, 1, 1, px(x) - 12, py(y) - 6, Z_VALUES(x,y)); - break; - case -99 ... -1: - sprintf_P(str_1, PSTR("-.%02i"), -zmesh[x][y]); - break; - case 0: - DWIN_Draw_String(false, font6x12, DWINUI::textcolor, DWINUI::backcolor, px(x) - 4, py(y) - 6, "0");; - break; - case 1 ... 99: - sprintf_P(str_1, PSTR(".%02i"), zmesh[x][y]); - break; - case 100 ... 999: - DWINUI::Draw_Signed_Float(font6x12, 1, 1, px(x) - 12, py(y) - 6, Z_VALUES(x,y)); - break; - } - if (str_1[0]) - DWIN_Draw_String(false, font6x12, DWINUI::textcolor, DWINUI::backcolor, px(x) - 12, py(y) - 6, str_1); - } - } - } - char str_1[6], str_2[6] = ""; - ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"), - dtostrf((float)minz / 100, 1, 2, str_1), - dtostrf((float)maxz / 100, 1, 2, str_2) - ); -} - -#endif // DWIN_CREALITY_LCD_ENHANCED && HAS_MESH diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index eea464dcfd17..19155fd5e55d 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -82,10 +82,6 @@ #define MACHINE_SIZE STRINGIFY(X_BED_SIZE) "x" STRINGIFY(Y_BED_SIZE) "x" STRINGIFY(Z_MAX_POS) -#ifndef CORP_WEBSITE - #define CORP_WEBSITE WEBSITE_URL - #endif - #define DWIN_FONT_MENU font8x16 #define DWIN_FONT_STAT font10x20 #define DWIN_FONT_HEAD font10x20 @@ -125,6 +121,26 @@ #define MIN_BED_TEMP 0 #endif +/** + * Custom menu items with jyersLCD + */ +#if ENABLED(CUSTOM_MENU_CONFIG) + #ifdef CONFIG_MENU_ITEM_5_DESC + #define CUSTOM_MENU_COUNT 5 + #elif defined(CONFIG_MENU_ITEM_4_DESC) + #define CUSTOM_MENU_COUNT 4 + #elif defined(CONFIG_MENU_ITEM_3_DESC) + #define CUSTOM_MENU_COUNT 3 + #elif defined(CONFIG_MENU_ITEM_2_DESC) + #define CUSTOM_MENU_COUNT 2 + #elif defined(CONFIG_MENU_ITEM_1_DESC) + #define CUSTOM_MENU_COUNT 1 + #endif + #if CUSTOM_MENU_COUNT + #define HAS_CUSTOM_MENU 1 + #endif +#endif + constexpr uint16_t TROWS = 6, MROWS = TROWS - 1, TITLE_HEIGHT = 30, MLINE = 53, @@ -211,11 +227,9 @@ CrealityDWINClass CrealityDWIN; struct linear_fit_data lsf_results; incremental_LSF_reset(&lsf_results); GRID_LOOP(x, y) { - if (!isnan(Z_VALUES_ARR[x][y])) { - xy_pos_t rpos; - rpos.x = ubl.mesh_index_to_xpos(x); - rpos.y = ubl.mesh_index_to_ypos(y); - incremental_LSF(&lsf_results, rpos, Z_VALUES_ARR[x][y]); + if (!isnan(bedlevel.z_values[x][y])) { + xy_pos_t rpos = { bedlevel.get_mesh_x(x), bedlevel.get_mesh_y(y) }; + incremental_LSF(&lsf_results, rpos, bedlevel.z_values[x][y]); } } @@ -224,13 +238,13 @@ CrealityDWINClass CrealityDWIN; return true; } - ubl.set_all_mesh_points_to_value(0); + bedlevel.set_all_mesh_points_to_value(0); matrix_3x3 rotation = matrix_3x3::create_look_at(vector_3(lsf_results.A, lsf_results.B, 1)); GRID_LOOP(i, j) { - float mx = ubl.mesh_index_to_xpos(i), - my = ubl.mesh_index_to_ypos(j), - mz = Z_VALUES_ARR[i][j]; + float mx = bedlevel.get_mesh_x(i), + my = bedlevel.get_mesh_y(j), + mz = bedlevel.z_values[i][j]; if (DEBUGGING(LEVELING)) { DEBUG_ECHOPAIR_F("before rotation = [", mx, 7); @@ -254,7 +268,7 @@ CrealityDWINClass CrealityDWIN; DEBUG_DELAY(20); } - Z_VALUES_ARR[i][j] = mz - lsf_results.D; + bedlevel.z_values[i][j] = mz - lsf_results.D; } return false; } @@ -272,7 +286,7 @@ CrealityDWINClass CrealityDWIN; void manual_move(bool zmove=false) { if (zmove) { planner.synchronize(); - current_position.z = goto_mesh_value ? Z_VALUES_ARR[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES; + current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES; planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); planner.synchronize(); } @@ -283,7 +297,7 @@ CrealityDWINClass CrealityDWIN; sprintf_P(cmd, PSTR("G42 F4000 I%i J%i"), mesh_x, mesh_y); gcode.process_subcommands_now(cmd); planner.synchronize(); - current_position.z = goto_mesh_value ? Z_VALUES_ARR[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES; + current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES; planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); planner.synchronize(); CrealityDWIN.Redraw_Menu(); @@ -293,8 +307,8 @@ CrealityDWINClass CrealityDWIN; float get_max_value() { float max = __FLT_MIN__; GRID_LOOP(x, y) { - if (!isnan(Z_VALUES_ARR[x][y]) && Z_VALUES_ARR[x][y] > max) - max = Z_VALUES_ARR[x][y]; + if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] > max) + max = bedlevel.z_values[x][y]; } return max; } @@ -302,24 +316,24 @@ CrealityDWINClass CrealityDWIN; float get_min_value() { float min = __FLT_MAX__; GRID_LOOP(x, y) { - if (!isnan(Z_VALUES_ARR[x][y]) && Z_VALUES_ARR[x][y] < min) - min = Z_VALUES_ARR[x][y]; + if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] < min) + min = bedlevel.z_values[x][y]; } 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) { 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; - const uint16_t cell_height_px = total_width_px / GRID_MAX_POINTS_Y; + const uint16_t total_width_px = DWIN_WIDTH - padding_x - padding_x, + cell_width_px = total_width_px / (GRID_MAX_POINTS_X), + cell_height_px = total_width_px / (GRID_MAX_POINTS_Y); const float v_max = abs(get_max_value()), v_min = abs(get_min_value()), range = _MAX(v_min, v_max); // Clear background from previous selection and select new square DWIN_Draw_Rectangle(1, Color_Bg_Black, _MAX(0, padding_x - gridline_width), _MAX(0, padding_y_top - gridline_width), padding_x + total_width_px, padding_y_top + total_width_px); if (selected >= 0) { - const auto selected_y = selected / GRID_MAX_POINTS_X; - const auto selected_x = selected - (GRID_MAX_POINTS_X * selected_y); + const auto selected_y = selected / (GRID_MAX_POINTS_X); + const auto selected_x = selected - (GRID_MAX_POINTS_X) * selected_y; const auto start_y_px = padding_y_top + selected_y * cell_height_px; const auto start_x_px = padding_x + selected_x * cell_width_px; DWIN_Draw_Rectangle(1, Color_White, _MAX(0, start_x_px - gridline_width), _MAX(0, start_y_px - gridline_width), start_x_px + cell_width_px, start_y_px + cell_height_px); @@ -333,11 +347,11 @@ CrealityDWINClass CrealityDWIN; const auto start_y_px = padding_y_top + (GRID_MAX_POINTS_Y - y - 1) * cell_height_px; const auto end_y_px = start_y_px + cell_height_px - 1 - gridline_width; DWIN_Draw_Rectangle(1, // RGB565 colors: http://www.barth-dev.de/online/rgb565-color-picker/ - isnan(Z_VALUES_ARR[x][y]) ? Color_Grey : ( // gray if undefined - (Z_VALUES_ARR[x][y] < 0 ? - (uint16_t)round(0x1F * -Z_VALUES_ARR[x][y] / (!viewer_asymmetric_range ? range : v_min)) << 11 : // red if mesh point value is negative - (uint16_t)round(0x3F * Z_VALUES_ARR[x][y] / (!viewer_asymmetric_range ? range : v_max)) << 5) | // green if mesh point value is positive - _MIN(0x1F, (((uint8_t)abs(Z_VALUES_ARR[x][y]) / 10) * 4))), // + blue stepping for every mm + isnan(bedlevel.z_values[x][y]) ? Color_Grey : ( // gray if undefined + (bedlevel.z_values[x][y] < 0 ? + (uint16_t)round(0x1F * -bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? range : v_min)) << 11 : // red if mesh point value is negative + (uint16_t)round(0x3F * bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? range : v_max)) << 5) | // green if mesh point value is positive + _MIN(0x1F, (((uint8_t)abs(bedlevel.z_values[x][y]) / 10) * 4))), // + blue stepping for every mm start_x_px, start_y_px, end_x_px, end_y_px ); @@ -347,14 +361,14 @@ CrealityDWINClass CrealityDWIN; // Draw value text on if (viewer_print_value) { int8_t offset_x, offset_y = cell_height_px / 2 - 6; - if (isnan(Z_VALUES_ARR[x][y])) { // undefined + if (isnan(bedlevel.z_values[x][y])) { // undefined DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X")); } else { // has value if (GRID_MAX_POINTS_X < 10) - sprintf_P(buf, PSTR("%s"), dtostrf(abs(Z_VALUES_ARR[x][y]), 1, 2, str_1)); + sprintf_P(buf, PSTR("%s"), dtostrf(abs(bedlevel.z_values[x][y]), 1, 2, str_1)); else - sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(Z_VALUES_ARR[x][y] - (int16_t)Z_VALUES_ARR[x][y]) * 100)); + sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(bedlevel.z_values[x][y] - (int16_t)bedlevel.z_values[x][y]) * 100)); offset_x = cell_width_px / 2 - 3 * (strlen(buf)) - 2; if (!(GRID_MAX_POINTS_X < 10)) DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, F(".")); @@ -421,14 +435,14 @@ 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; - uint16_t tColor = (color) ? GetColor(value, Color_White, false) : Color_White; + 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*/) { - switch (color){ + switch (color) { case Default: return original; break; @@ -962,8 +976,8 @@ void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) { static bool new_msg; static uint8_t msgscrl = 0; static char lastmsg[64]; - if (strcmp_P(lastmsg, statusmsg) != 0 || refresh) { - strcpy_P(lastmsg, statusmsg); + if (strcmp(lastmsg, statusmsg) != 0 || refresh) { + strcpy(lastmsg, statusmsg); msgscrl = 0; new_msg = true; } @@ -1016,10 +1030,62 @@ void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) { /* Menu Item Config */ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/*=true*/) { - uint8_t row = item - scrollpos; + const uint8_t row = item - scrollpos; #if HAS_LEVELING static bool level_state; #endif + + #if HAS_PREHEAT + + #define PREHEAT_BACK 0 + #define PREHEAT_SUBMENU_HOTEND (PREHEAT_BACK + ENABLED(HAS_HOTEND)) + #define PREHEAT_SUBMENU_BED (PREHEAT_SUBMENU_HOTEND + ENABLED(HAS_HEATED_BED)) + #define PREHEAT_SUBMENU_FAN (PREHEAT_SUBMENU_BED + ENABLED(HAS_FAN)) + #define PREHEAT_SUBMENU_TOTAL PREHEAT_SUBMENU_FAN + + auto preheat_submenu = [&](const int index, const uint8_t item, const uint8_t sel) { + switch (item) { + case PREHEAT_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, F("Back")); + else + Draw_Menu(TempMenu, sel); + break; + #if HAS_HOTEND + case PREHEAT_SUBMENU_HOTEND: + if (draw) { + Draw_Menu_Item(row, ICON_SetEndTemp, F("Hotend")); + Draw_Float(ui.material_preset[index].hotend_temp, row, false, 1); + } + else + Modify_Value(ui.material_preset[index].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1); + break; + #endif + #if HAS_HEATED_BED + case PREHEAT_SUBMENU_BED: + if (draw) { + Draw_Menu_Item(row, ICON_SetBedTemp, F("Bed")); + Draw_Float(ui.material_preset[index].bed_temp, row, false, 1); + } + else + Modify_Value(ui.material_preset[index].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1); + break; + #endif + #if HAS_FAN + case PREHEAT_SUBMENU_FAN: + if (draw) { + Draw_Menu_Item(row, ICON_FanSpeed, F("Fan")); + Draw_Float(ui.material_preset[index].fan_speed, row, false, 1); + } + else + Modify_Value(ui.material_preset[index].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1); + break; + #endif + } + }; + + #endif + switch (menu) { case Prepare: @@ -1032,7 +1098,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #define PREPARE_PREHEAT (PREPARE_ZOFFSET + ENABLED(HAS_PREHEAT)) #define PREPARE_COOLDOWN (PREPARE_PREHEAT + EITHER(HAS_HOTEND, HAS_HEATED_BED)) #define PREPARE_CHANGEFIL (PREPARE_COOLDOWN + ENABLED(ADVANCED_PAUSE_FEATURE)) - #define PREPARE_TOTAL PREPARE_CHANGEFIL + #define PREPARE_CUSTOM_MENU (PREPARE_CHANGEFIL + ENABLED(HAS_CUSTOM_MENU)) + #define PREPARE_TOTAL PREPARE_CUSTOM_MENU switch (item) { case PREPARE_BACK: @@ -1107,6 +1174,18 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; #endif + #if HAS_CUSTOM_MENU + case PREPARE_CUSTOM_MENU: + #ifndef CUSTOM_MENU_CONFIG_TITLE + #define CUSTOM_MENU_CONFIG_TITLE "Custom Commands" + #endif + if (draw) + Draw_Menu_Item(row, ICON_Version, F(CUSTOM_MENU_CONFIG_TITLE)); + else + Draw_Menu(MenuCustom); + break; + #endif + #if ENABLED(ADVANCED_PAUSE_FEATURE) case PREPARE_CHANGEFIL: if (draw) { @@ -1198,7 +1277,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (draw) Draw_Menu_Item(row, ICON_SetHome, F("Set Home Position")); else { - gcode.process_subcommands_now(F("G92 X0 Y0 Z0")); + gcode.process_subcommands_now(F("G92X0Y0Z0")); AudioFeedback(); } break; @@ -1588,7 +1667,6 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if HAS_PREHEAT case Preheat: { - #define PREHEAT_BACK 0 #define PREHEAT_MODE (PREHEAT_BACK + 1) #define PREHEAT_1 (PREHEAT_MODE + 1) #define PREHEAT_2 (PREHEAT_1 + (PREHEAT_COUNT >= 2)) @@ -1610,6 +1688,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ else Draw_Menu(Prepare, PREPARE_PREHEAT); break; + case PREHEAT_MODE: if (draw) { Draw_Menu_Item(row, ICON_Homing, F("Preheat Mode")); @@ -1619,50 +1698,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Modify_Option(preheatmode, preheat_modes, 2); break; - #if PREHEAT_COUNT >= 1 - case PREHEAT_1: - if (draw) - Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_1_LABEL)); - else - do_preheat(0); - break; - #endif - - #if PREHEAT_COUNT >= 2 - case PREHEAT_2: - if (draw) - Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_2_LABEL)); - else - do_preheat(1); - break; - #endif - - #if PREHEAT_COUNT >= 3 - case PREHEAT_3: - if (draw) - Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_3_LABEL)); - else - do_preheat(2); - break; - #endif - - #if PREHEAT_COUNT >= 4 - case PREHEAT_4: - if (draw) - Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_4_LABEL)); - else - do_preheat(3); - break; - #endif + #define _PREHEAT_CASE(N) \ + case PREHEAT_##N: { \ + if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_## N ##_LABEL)); \ + else do_preheat(N - 1); \ + } break; - #if PREHEAT_COUNT >= 5 - case PREHEAT_5: - if (draw) - Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_5_LABEL)); - else - do_preheat(4); - break; - #endif + REPEAT_1(PREHEAT_COUNT, _PREHEAT_CASE) } } break; #endif // HAS_PREHEAT @@ -1741,6 +1783,126 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; #endif // FILAMENT_LOAD_UNLOAD_GCODES + #if HAS_CUSTOM_MENU + + case MenuCustom: + + #define CUSTOM_MENU_BACK 0 + #define CUSTOM_MENU_1 1 + #define CUSTOM_MENU_2 2 + #define CUSTOM_MENU_3 3 + #define CUSTOM_MENU_4 4 + #define CUSTOM_MENU_5 5 + #define CUSTOM_MENU_TOTAL CUSTOM_MENU_COUNT + + switch (item) { + case CUSTOM_MENU_BACK: + if (draw) + Draw_Menu_Item(row, ICON_Back, F("Back")); + else + Draw_Menu(Prepare, PREPARE_CUSTOM_MENU); + break; + + #if CUSTOM_MENU_COUNT >= 1 + case CUSTOM_MENU_1: + if (draw) + Draw_Menu_Item(row, ICON_Info, F(CONFIG_MENU_ITEM_1_DESC)); + else { + Popup_Handler(Custom); + //queue.inject(F(CONFIG_MENU_ITEM_1_GCODE)); // Old code + gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_1_GCODE)); + planner.synchronize(); + Redraw_Menu(); + #if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK) + AudioFeedback(); + #endif + #ifdef CUSTOM_MENU_CONFIG_SCRIPT_RETURN + queue.inject(F(CUSTOM_MENU_CONFIG_SCRIPT_DONE)); + #endif + } + break; + #endif + + #if CUSTOM_MENU_COUNT >= 2 + case CUSTOM_MENU_2: + if (draw) + Draw_Menu_Item(row, ICON_Info, F(CONFIG_MENU_ITEM_2_DESC)); + else { + Popup_Handler(Custom); + gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_2_GCODE)); + planner.synchronize(); + Redraw_Menu(); + #if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK) + AudioFeedback(); + #endif + #ifdef CUSTOM_MENU_CONFIG_SCRIPT_RETURN + queue.inject(F(CUSTOM_MENU_CONFIG_SCRIPT_DONE)); + #endif + } + break; + #endif + + #if CUSTOM_MENU_COUNT >= 3 + case CUSTOM_MENU_3: + if (draw) + Draw_Menu_Item(row, ICON_Info, F(CONFIG_MENU_ITEM_3_DESC)); + else { + Popup_Handler(Custom); + gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_3_GCODE)); + planner.synchronize(); + Redraw_Menu(); + #if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK) + AudioFeedback(); + #endif + #ifdef CUSTOM_MENU_CONFIG_SCRIPT_RETURN + queue.inject(F(CUSTOM_MENU_CONFIG_SCRIPT_DONE)); + #endif + } + break; + #endif + + #if CUSTOM_MENU_COUNT >= 4 + case CUSTOM_MENU_4: + if (draw) + Draw_Menu_Item(row, ICON_Info, F(CONFIG_MENU_ITEM_4_DESC)); + else { + Popup_Handler(Custom); + gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_4_GCODE)); + planner.synchronize(); + Redraw_Menu(); + #if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK) + AudioFeedback(); + #endif + #ifdef CUSTOM_MENU_CONFIG_SCRIPT_RETURN + queue.inject(F(CUSTOM_MENU_CONFIG_SCRIPT_DONE)); + #endif + } + break; + #endif + + #if CUSTOM_MENU_COUNT >= 5 + case CUSTOM_MENU_5: + if (draw) + Draw_Menu_Item(row, ICON_Info, F(CONFIG_MENU_ITEM_5_DESC)); + else { + Popup_Handler(Custom); + gcode.process_subcommands_now(F(CONFIG_MENU_ITEM_5_GCODE)); + planner.synchronize(); + Redraw_Menu(); + #if ENABLED(CUSTOM_MENU_CONFIG_SCRIPT_AUDIBLE_FEEDBACK) + AudioFeedback(); + #endif + #ifdef CUSTOM_MENU_CONFIG_SCRIPT_RETURN + queue.inject(F(CUSTOM_MENU_CONFIG_SCRIPT_DONE)); + #endif + } + break; + #endif // Custom Menu + } + break; + + #endif // HAS_CUSTOM_MENU + case Control: #define CONTROL_BACK 0 @@ -1875,46 +2037,14 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu(PID); break; #endif - #if PREHEAT_COUNT >= 1 - case TEMP_PREHEAT1: - if (draw) - Draw_Menu_Item(row, ICON_Step, F(PREHEAT_1_LABEL), nullptr, true); - else - Draw_Menu(Preheat1); - break; - #endif - #if PREHEAT_COUNT >= 2 - case TEMP_PREHEAT2: - if (draw) - Draw_Menu_Item(row, ICON_Step, F(PREHEAT_2_LABEL), nullptr, true); - else - Draw_Menu(Preheat2); - break; - #endif - #if PREHEAT_COUNT >= 3 - case TEMP_PREHEAT3: - if (draw) - Draw_Menu_Item(row, ICON_Step, F(PREHEAT_3_LABEL), nullptr, true); - else - Draw_Menu(Preheat3); - break; - #endif - #if PREHEAT_COUNT >= 4 - case TEMP_PREHEAT4: - if (draw) - Draw_Menu_Item(row, ICON_Step, F(PREHEAT_4_LABEL), nullptr, true); - else - Draw_Menu(Preheat4); - break; - #endif - #if PREHEAT_COUNT >= 5 - case TEMP_PREHEAT5: - if (draw) - Draw_Menu_Item(row, ICON_Step, F(PREHEAT_5_LABEL), nullptr, true); - else - Draw_Menu(Preheat5); - break; - #endif + + #define _TEMP_PREHEAT_CASE(N) \ + case TEMP_PREHEAT##N: { \ + if (draw) Draw_Menu_Item(row, ICON_Step, F(PREHEAT_## N ##_LABEL), nullptr, true); \ + else Draw_Menu(Preheat##N); \ + } break; + + REPEAT_1(PREHEAT_COUNT, _TEMP_PREHEAT_CASE) } break; @@ -2099,255 +2229,10 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; #endif // HAS_HEATED_BED - #if PREHEAT_COUNT >= 1 - case Preheat1: - - #define PREHEAT1_BACK 0 - #define PREHEAT1_HOTEND (PREHEAT1_BACK + ENABLED(HAS_HOTEND)) - #define PREHEAT1_BED (PREHEAT1_HOTEND + ENABLED(HAS_HEATED_BED)) - #define PREHEAT1_FAN (PREHEAT1_BED + ENABLED(HAS_FAN)) - #define PREHEAT1_TOTAL PREHEAT1_FAN - - switch (item) { - case PREHEAT1_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); - else - Draw_Menu(TempMenu, TEMP_PREHEAT1); - break; - #if HAS_HOTEND - case PREHEAT1_HOTEND: - if (draw) { - Draw_Menu_Item(row, ICON_SetEndTemp, F("Hotend")); - Draw_Float(ui.material_preset[0].hotend_temp, row, false, 1); - } - else - Modify_Value(ui.material_preset[0].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1); - break; - #endif - #if HAS_HEATED_BED - case PREHEAT1_BED: - if (draw) { - Draw_Menu_Item(row, ICON_SetBedTemp, F("Bed")); - Draw_Float(ui.material_preset[0].bed_temp, row, false, 1); - } - else - Modify_Value(ui.material_preset[0].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1); - break; - #endif - #if HAS_FAN - case PREHEAT1_FAN: - if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, F("Fan")); - Draw_Float(ui.material_preset[0].fan_speed, row, false, 1); - } - else - Modify_Value(ui.material_preset[0].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1); - break; - #endif - } - break; - #endif // PREHEAT_COUNT >= 1 - - #if PREHEAT_COUNT >= 2 - case Preheat2: - - #define PREHEAT2_BACK 0 - #define PREHEAT2_HOTEND (PREHEAT2_BACK + ENABLED(HAS_HOTEND)) - #define PREHEAT2_BED (PREHEAT2_HOTEND + ENABLED(HAS_HEATED_BED)) - #define PREHEAT2_FAN (PREHEAT2_BED + ENABLED(HAS_FAN)) - #define PREHEAT2_TOTAL PREHEAT2_FAN - - switch (item) { - case PREHEAT2_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); - else - Draw_Menu(TempMenu, TEMP_PREHEAT2); - break; - #if HAS_HOTEND - case PREHEAT2_HOTEND: - if (draw) { - Draw_Menu_Item(row, ICON_SetEndTemp, F("Hotend")); - Draw_Float(ui.material_preset[1].hotend_temp, row, false, 1); - } - else - Modify_Value(ui.material_preset[1].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1); - break; - #endif - #if HAS_HEATED_BED - case PREHEAT2_BED: - if (draw) { - Draw_Menu_Item(row, ICON_SetBedTemp, F("Bed")); - Draw_Float(ui.material_preset[1].bed_temp, row, false, 1); - } - else - Modify_Value(ui.material_preset[1].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1); - break; - #endif - #if HAS_FAN - case PREHEAT2_FAN: - if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, F("Fan")); - Draw_Float(ui.material_preset[1].fan_speed, row, false, 1); - } - else - Modify_Value(ui.material_preset[1].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1); - break; - #endif - } - break; - #endif // PREHEAT_COUNT >= 2 - - #if PREHEAT_COUNT >= 3 - case Preheat3: - - #define PREHEAT3_BACK 0 - #define PREHEAT3_HOTEND (PREHEAT3_BACK + ENABLED(HAS_HOTEND)) - #define PREHEAT3_BED (PREHEAT3_HOTEND + ENABLED(HAS_HEATED_BED)) - #define PREHEAT3_FAN (PREHEAT3_BED + ENABLED(HAS_FAN)) - #define PREHEAT3_TOTAL PREHEAT3_FAN - - switch (item) { - case PREHEAT3_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); - else - Draw_Menu(TempMenu, TEMP_PREHEAT3); - break; - #if HAS_HOTEND - case PREHEAT3_HOTEND: - if (draw) { - Draw_Menu_Item(row, ICON_SetEndTemp, F("Hotend")); - Draw_Float(ui.material_preset[2].hotend_temp, row, false, 1); - } - else - Modify_Value(ui.material_preset[2].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1); - break; - #endif - #if HAS_HEATED_BED - case PREHEAT3_BED: - if (draw) { - Draw_Menu_Item(row, ICON_SetBedTemp, F("Bed")); - Draw_Float(ui.material_preset[2].bed_temp, row, false, 1); - } - else - Modify_Value(ui.material_preset[2].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1); - break; - #endif - #if HAS_FAN - case PREHEAT3_FAN: - if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, F("Fan")); - Draw_Float(ui.material_preset[2].fan_speed, row, false, 1); - } - else - Modify_Value(ui.material_preset[2].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1); - break; - #endif - } - break; - #endif // PREHEAT_COUNT >= 3 - - #if PREHEAT_COUNT >= 4 - case Preheat4: - - #define PREHEAT4_BACK 0 - #define PREHEAT4_HOTEND (PREHEAT4_BACK + ENABLED(HAS_HOTEND)) - #define PREHEAT4_BED (PREHEAT4_HOTEND + ENABLED(HAS_HEATED_BED)) - #define PREHEAT4_FAN (PREHEAT4_BED + ENABLED(HAS_FAN)) - #define PREHEAT4_TOTAL PREHEAT4_FAN - - switch (item) { - case PREHEAT4_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); - else - Draw_Menu(TempMenu, TEMP_PREHEAT4); - break; - #if HAS_HOTEND - case PREHEAT4_HOTEND: - if (draw) { - Draw_Menu_Item(row, ICON_SetEndTemp, F("Hotend")); - Draw_Float(ui.material_preset[3].hotend_temp, row, false, 1); - } - else - Modify_Value(ui.material_preset[3].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1); - break; - #endif - #if HAS_HEATED_BED - case PREHEAT4_BED: - if (draw) { - Draw_Menu_Item(row, ICON_SetBedTemp, F("Bed")); - Draw_Float(ui.material_preset[3].bed_temp, row, false, 1); - } - else - Modify_Value(ui.material_preset[3].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1); - break; - #endif - #if HAS_FAN - case PREHEAT4_FAN: - if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, F("Fan")); - Draw_Float(ui.material_preset[3].fan_speed, row, false, 1); - } - else - Modify_Value(ui.material_preset[3].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1); - break; - #endif - } - break; - #endif // PREHEAT_COUNT >= 4 - - #if PREHEAT_COUNT >= 5 - case Preheat5: - - #define PREHEAT5_BACK 0 - #define PREHEAT5_HOTEND (PREHEAT5_BACK + ENABLED(HAS_HOTEND)) - #define PREHEAT5_BED (PREHEAT5_HOTEND + ENABLED(HAS_HEATED_BED)) - #define PREHEAT5_FAN (PREHEAT5_BED + ENABLED(HAS_FAN)) - #define PREHEAT5_TOTAL PREHEAT5_FAN - - switch (item) { - case PREHEAT5_BACK: - if (draw) - Draw_Menu_Item(row, ICON_Back, F("Back")); - else - Draw_Menu(TempMenu, TEMP_PREHEAT5); - break; - #if HAS_HOTEND - case PREHEAT5_HOTEND: - if (draw) { - Draw_Menu_Item(row, ICON_SetEndTemp, F("Hotend")); - Draw_Float(ui.material_preset[4].hotend_temp, row, false, 1); - } - else - Modify_Value(ui.material_preset[4].hotend_temp, MIN_E_TEMP, MAX_E_TEMP, 1); - break; - #endif - #if HAS_HEATED_BED - case PREHEAT5_BED: - if (draw) { - Draw_Menu_Item(row, ICON_SetBedTemp, F("Bed")); - Draw_Float(ui.material_preset[4].bed_temp, row, false, 1); - } - else - Modify_Value(ui.material_preset[4].bed_temp, MIN_BED_TEMP, MAX_BED_TEMP, 1); - break; - #endif - #if HAS_FAN - case PREHEAT5_FAN: - if (draw) { - Draw_Menu_Item(row, ICON_FanSpeed, F("Fan")); - Draw_Float(ui.material_preset[4].fan_speed, row, false, 1); - } - else - Modify_Value(ui.material_preset[4].fan_speed, MIN_FAN_SPEED, MAX_FAN_SPEED, 1); - break; - #endif - } - break; - #endif // PREHEAT_COUNT >= 5 + #if HAS_PREHEAT + #define _PREHEAT_SUBMENU_CASE(N) case Preheat##N: preheat_submenu((N) - 1, item, TEMP_PREHEAT##N); break; + REPEAT_1(PREHEAT_COUNT, _PREHEAT_SUBMENU_CASE) + #endif case Motion: @@ -2853,11 +2738,11 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case ADVANCED_BEEPER: if (draw) { Draw_Menu_Item(row, ICON_Version, F("LCD Beeper")); - Draw_Checkbox(row, ui.buzzer_enabled); + Draw_Checkbox(row, ui.sound_on); } else { - ui.buzzer_enabled = !ui.buzzer_enabled; - Draw_Checkbox(row, ui.buzzer_enabled); + ui.sound_on = !ui.sound_on; + Draw_Checkbox(row, ui.sound_on); } break; #endif @@ -3108,7 +2993,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (draw) Draw_Menu_Item(row, ICON_Tilt, F("Autotilt Current Mesh")); else { - if (ubl.storage_slot < 0) { + if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } @@ -3135,16 +3020,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(PREHEAT_BEFORE_LEVELING) Popup_Handler(Heating); - #if HAS_HOTEND - if (thermalManager.degTargetHotend(0) < LEVELING_NOZZLE_TEMP) - thermalManager.setTargetHotend(LEVELING_NOZZLE_TEMP, 0); - #endif - #if HAS_HEATED_BED - if (thermalManager.degTargetBed() < LEVELING_BED_TEMP) - thermalManager.setTargetBed(LEVELING_BED_TEMP); - #endif - thermalManager.wait_for_hotend(0); - TERN_(HAS_HEATED_BED, thermalManager.wait_for_bed_heating()); + probe.preheat_for_probing(LEVELING_NOZZLE_TEMP, LEVELING_BED_TEMP); #endif #if HAS_BED_PROBE Popup_Handler(Level); @@ -3159,7 +3035,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_move(); Draw_Menu(UBLMesh); #endif #elif HAS_BED_PROBE @@ -3189,7 +3065,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } #endif #if ENABLED(AUTO_BED_LEVELING_UBL) - if (ubl.storage_slot < 0) { + if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } @@ -3221,10 +3097,10 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case LEVELING_VIEW: if (draw) - Draw_Menu_Item(row, ICON_Mesh, GET_TEXT(MSG_MESH_VIEW), nullptr, true); + Draw_Menu_Item(row, ICON_Mesh, GET_TEXT_F(MSG_MESH_VIEW), nullptr, true); else { #if ENABLED(AUTO_BED_LEVELING_UBL) - if (ubl.storage_slot < 0) { + if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } @@ -3242,16 +3118,16 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case LEVELING_SLOT: if (draw) { Draw_Menu_Item(row, ICON_PrintSize, F("Mesh Slot")); - Draw_Float(ubl.storage_slot, row, false, 1); + Draw_Float(bedlevel.storage_slot, row, false, 1); } else - Modify_Value(ubl.storage_slot, 0, settings.calc_num_meshes() - 1, 1); + Modify_Value(bedlevel.storage_slot, 0, settings.calc_num_meshes() - 1, 1); break; case LEVELING_LOAD: if (draw) Draw_Menu_Item(row, ICON_ReadEEPROM, F("Load Mesh")); else { - if (ubl.storage_slot < 0) { + if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } @@ -3264,7 +3140,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (draw) Draw_Menu_Item(row, ICON_WriteEEPROM, F("Save Mesh")); else { - if (ubl.storage_slot < 0) { + if (bedlevel.storage_slot < 0) { Popup_Handler(MeshSlot); break; } @@ -3294,7 +3170,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; case LEVELING_VIEW_MESH: if (draw) - Draw_Menu_Item(row, ICON_PrintSize, GET_TEXT(MSG_MESH_VIEW), nullptr, true); + Draw_Menu_Item(row, ICON_PrintSize, GET_TEXT_F(MSG_MESH_VIEW), nullptr, true); else Draw_Menu(MeshViewer); break; @@ -3373,13 +3249,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ if (draw) Draw_Menu_Item(row, ICON_Mesh, F("Zero Current Mesh")); else - ZERO(Z_VALUES_ARR); + ZERO(bedlevel.z_values); break; case LEVELING_SETTINGS_UNDEF: if (draw) Draw_Menu_Item(row, ICON_Mesh, F("Clear Current Mesh")); else - ubl.invalidate(); + bedlevel.invalidate(); break; #endif // AUTO_BED_LEVELING_UBL } @@ -3421,7 +3297,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ Draw_Menu_Item(row, ICON_Back, F("Back")); else { set_bed_leveling_enabled(level_state); - TERN_(AUTO_BED_LEVELING_BILINEAR, refresh_bed_level()); + TERN_(AUTO_BED_LEVELING_BILINEAR, bedlevel.refresh_bed_level()); Draw_Menu(Leveling, LEVELING_MANUAL); } break; @@ -3459,36 +3335,36 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case LEVELING_M_OFFSET: if (draw) { Draw_Menu_Item(row, ICON_SetZOffset, F("Point Z Offset")); - Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100); + Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100); } else { - if (isnan(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y])) - Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0; - Modify_Value(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100); + if (isnan(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y])) + bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0; + Modify_Value(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100); } break; case LEVELING_M_UP: if (draw) Draw_Menu_Item(row, ICON_Axis, F("Microstep Up")); - else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) { - Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01; + else if (bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) { + bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01; gcode.process_subcommands_now(F("M290 Z0.01")); planner.synchronize(); current_position.z += 0.01f; sync_plan_position(); - Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100); + Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100); } break; case LEVELING_M_DOWN: if (draw) Draw_Menu_Item(row, ICON_AxisD, F("Microstep Down")); - else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) { - Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01; + else if (bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) { + bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01; gcode.process_subcommands_now(F("M290 Z-0.01")); planner.synchronize(); current_position.z -= 0.01f; sync_plan_position(); - Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100); + Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100); } break; case LEVELING_M_GOTO_VALUE: @@ -3580,36 +3456,36 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case UBL_M_OFFSET: if (draw) { Draw_Menu_Item(row, ICON_SetZOffset, F("Point Z Offset")); - Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100); + Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100); } else { - if (isnan(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y])) - Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0; - Modify_Value(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100); + if (isnan(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y])) + bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0; + Modify_Value(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100); } break; case UBL_M_UP: if (draw) Draw_Menu_Item(row, ICON_Axis, F("Microstep Up")); - else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) { - Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01; + else if (bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) { + bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01; gcode.process_subcommands_now(F("M290 Z0.01")); planner.synchronize(); current_position.z += 0.01f; sync_plan_position(); - Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100); + Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100); } break; case UBL_M_DOWN: if (draw) Draw_Menu_Item(row, ICON_Axis, F("Microstep Down")); - else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) { - Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01; + else if (bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) { + bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01; gcode.process_subcommands_now(F("M290 Z-0.01")); planner.synchronize(); current_position.z -= 0.01f; sync_plan_position(); - Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100); + Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100); } break; } @@ -3693,13 +3569,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case MMESH_OLD: uint8_t mesh_x, mesh_y; // 0,0 -> 1,0 -> 2,0 -> 2,1 -> 1,1 -> 0,1 -> 0,2 -> 1,2 -> 2,2 - mesh_y = (gridpoint - 1) / GRID_MAX_POINTS_Y; - mesh_x = (gridpoint - 1) % GRID_MAX_POINTS_X; + mesh_y = (gridpoint - 1) / (GRID_MAX_POINTS_Y); + mesh_x = (gridpoint - 1) % (GRID_MAX_POINTS_X); if (mesh_y % 2 == 1) - mesh_x = GRID_MAX_POINTS_X - mesh_x - 1; + mesh_x = (GRID_MAX_POINTS_X) - mesh_x - 1; - const float currval = Z_VALUES_ARR[mesh_x][mesh_y]; + const float currval = bedlevel.z_values[mesh_x][mesh_y]; if (draw) { Draw_Menu_Item(row, ICON_Zoffset, F("Goto Mesh Value")); @@ -3859,7 +3735,9 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } break; - case PreheatHotend: + #if HAS_PREHEAT && HAS_HOTEND + + case PreheatHotend: #define PREHEATHOTEND_BACK 0 #define PREHEATHOTEND_CONTINUE (PREHEATHOTEND_BACK + 1) @@ -3922,46 +3800,16 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ } } break; - #if PREHEAT_COUNT >= 1 - case PREHEATHOTEND_1: - if (draw) - Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_1_LABEL)); - else - ui.preheat_hotend_and_fan(0); - break; - #endif - #if PREHEAT_COUNT >= 2 - case PREHEATHOTEND_2: - if (draw) - Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_2_LABEL)); - else - ui.preheat_hotend_and_fan(1); - break; - #endif - #if PREHEAT_COUNT >= 3 - case PREHEATHOTEND_3: - if (draw) - Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_3_LABEL)); - else - ui.preheat_hotend_and_fan(2); - break; - #endif - #if PREHEAT_COUNT >= 4 - case PREHEATHOTEND_4: - if (draw) - Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_4_LABEL)); - else - ui.preheat_hotend_and_fan(3); - break; - #endif - #if PREHEAT_COUNT >= 5 - case PREHEATHOTEND_5: - if (draw) - Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_5_LABEL)); - else - ui.preheat_hotend_and_fan(4); + + + #define _PREHEAT_HOTEND_CASE(N) \ + case PREHEATHOTEND_##N: \ + if (draw) Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_## N ##_LABEL)); \ + else ui.preheat_hotend_and_fan((N) - 1); \ break; - #endif + + REPEAT_1(PREHEAT_COUNT, _PREHEAT_HOTEND_CASE) + case PREHEATHOTEND_CUSTOM: if (draw) { Draw_Menu_Item(row, ICON_Temperature, F("Custom")); @@ -3972,6 +3820,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ break; } break; + + #endif // HAS_PREHEAT && HAS_HOTEND } } @@ -3991,6 +3841,14 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) { #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) case ChangeFilament: return F("Change Filament"); #endif + #if HAS_CUSTOM_MENU + case MenuCustom: + #ifdef CUSTOM_MENU_CONFIG_TITLE + return F(CUSTOM_MENU_CONFIG_TITLE); + #else + return F("Custom Commands"); + #endif + #endif case Control: return F("Control"); case TempMenu: return F("Temperature"); #if HAS_HOTEND || HAS_HEATED_BED @@ -4002,20 +3860,9 @@ FSTR_P CrealityDWINClass::Get_Menu_Title(uint8_t menu) { #if HAS_HEATED_BED case BedPID: return F("Bed PID Settings"); #endif - #if PREHEAT_COUNT >= 1 - case Preheat1: return F(PREHEAT_1_LABEL " Settings"); - #endif - #if PREHEAT_COUNT >= 2 - case Preheat2: return F(PREHEAT_2_LABEL " Settings"); - #endif - #if PREHEAT_COUNT >= 3 - case Preheat3: return F(PREHEAT_3_LABEL " Settings"); - #endif - #if PREHEAT_COUNT >= 4 - case Preheat4: return F(PREHEAT_4_LABEL " Settings"); - #endif - #if PREHEAT_COUNT >= 5 - case Preheat5: return F(PREHEAT_5_LABEL " Settings"); + #if HAS_PREHEAT + #define _PREHEAT_TITLE_CASE(N) case Preheat##N: return F(PREHEAT_## N ##_LABEL " Settings"); + REPEAT_1(PREHEAT_COUNT, _PREHEAT_TITLE_CASE) #endif case Motion: return F("Motion Settings"); case HomeOffsets: return F("Home Offsets"); @@ -4067,6 +3914,9 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) { #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) case ChangeFilament: return CHANGEFIL_TOTAL; #endif + #if HAS_CUSTOM_MENU + case MenuCustom: return CUSTOM_MENU_TOTAL; + #endif case Control: return CONTROL_TOTAL; case TempMenu: return TEMP_TOTAL; #if HAS_HOTEND || HAS_HEATED_BED @@ -4078,20 +3928,9 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) { #if HAS_HEATED_BED case BedPID: return BEDPID_TOTAL; #endif - #if PREHEAT_COUNT >= 1 - case Preheat1: return PREHEAT1_TOTAL; - #endif - #if PREHEAT_COUNT >= 2 - case Preheat2: return PREHEAT2_TOTAL; - #endif - #if PREHEAT_COUNT >= 3 - case Preheat3: return PREHEAT3_TOTAL; - #endif - #if PREHEAT_COUNT >= 4 - case Preheat4: return PREHEAT4_TOTAL; - #endif - #if PREHEAT_COUNT >= 5 - case Preheat5: return PREHEAT5_TOTAL; + #if HAS_PREHEAT + case Preheat1 ... CAT(Preheat, PREHEAT_COUNT): + return PREHEAT_SUBMENU_TOTAL; #endif case Motion: return MOTION_TOTAL; case HomeOffsets: return HOMEOFFSETS_TOTAL; @@ -4122,7 +3961,11 @@ uint8_t CrealityDWINClass::Get_Menu_Size(uint8_t menu) { case LevelManual: return LEVELING_M_TOTAL; #endif case Tune: return TUNE_TOTAL; - case PreheatHotend: return PREHEATHOTEND_TOTAL; + + #if HAS_PREHEAT && HAS_HOTEND + case PreheatHotend: return PREHEATHOTEND_TOTAL; + #endif + case ColorSettings: return COLORSETTINGS_TOTAL; } return 0; @@ -4152,6 +3995,7 @@ void CrealityDWINClass::Popup_Handler(PopupID popupid, bool option/*=false*/) { case Runout: Draw_Popup(F("Filament Runout"), F(""), F(""), Wait, ICON_BLTouch); break; case PIDWait: Draw_Popup(F("PID Autotune"), F("in process"), F("Please wait until done."), Wait, ICON_BLTouch); break; case Resuming: Draw_Popup(F("Resuming Print"), F("Please wait until done."), F(""), Wait, ICON_BLTouch); break; + case Custom: Draw_Popup(F("Running Custom GCode"), F("Please wait until done."), F(""), Wait, ICON_BLTouch); break; default: break; } } @@ -4436,14 +4280,14 @@ void CrealityDWINClass::Print_Screen_Control() { card.startOrResumeFilePrinting(); TERN_(POWER_LOSS_RECOVERY, recovery.prepare()); #else - char cmnd[20]; + char cmd[20]; #if HAS_HEATED_BED - cmnd[sprintf_P(cmnd, PSTR("M140 S%i"), pausebed)] = '\0'; - gcode.process_subcommands_now(cmnd); + sprintf_P(cmd, PSTR("M140 S%i"), pausebed); + gcode.process_subcommands_now(cmd); #endif #if HAS_EXTRUDERS - cmnd[sprintf_P(cmnd, PSTR("M109 S%i"), pausetemp)] = '\0'; - gcode.process_subcommands_now(cmnd); + sprintf_P(cmd, PSTR("M109 S%i"), pausetemp); + gcode.process_subcommands_now(cmd); #endif TERN_(HAS_FAN, thermalManager.fan_speed[0] = pausefan); planner.synchronize(); @@ -4602,7 +4446,7 @@ void CrealityDWINClass::Popup_Control() { #if ENABLED(AUTO_BED_LEVELING_UBL) case MeshSlot: - if (selection == 0) ubl.storage_slot = 0; + if (selection == 0) bedlevel.storage_slot = 0; Redraw_Menu(true, true); break; #endif @@ -4699,10 +4543,7 @@ void CrealityDWINClass::Modify_Option(uint8_t value, const char * const * option /* Main Functions */ void CrealityDWINClass::Update_Status(const char * const text) { - char header[4]; - LOOP_L_N(i, 3) header[i] = text[i]; - header[3] = '\0'; - if (strcmp_P(header, PSTR("")) == 0) { + if (strncmp_P(text, PSTR(""), 3) == 0) { LOOP_L_N(i, _MIN((size_t)LONG_FILENAME_LENGTH, strlen(text))) filename[i] = text[i + 3]; filename[_MIN((size_t)LONG_FILENAME_LENGTH - 1, strlen(text))] = '\0'; Draw_Print_Filename(true); @@ -4726,10 +4567,10 @@ void CrealityDWINClass::Start_Print(bool sd) { card.selectFileByName(fname); } #endif - strcpy_P(filename, card.longest_filename()); + strcpy(filename, card.longest_filename()); } else - strcpy_P(filename, "Host Print"); + 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)); Draw_Print_Screen(); @@ -4924,18 +4765,10 @@ void CrealityDWINClass::Screen_Update() { } void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) { - if (success) { - if (ui.buzzer_enabled) { - BUZZ(100, 659); - BUZZ( 10, 0); - BUZZ(100, 698); - } - else Update_Status("Success"); - } - else if (ui.buzzer_enabled) - BUZZ(40, 440); + if (ui.sound_on) + DONE_BUZZ(success); else - Update_Status("Failed"); + Update_Status(success ? "Success" : "Failed"); } void CrealityDWINClass::Save_Settings(char *buff) { @@ -4976,11 +4809,11 @@ void CrealityDWINClass::Reset_Settings() { eeprom_settings.coordinates_split_line = 0; TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1); corner_pos = eeprom_settings.corner_pos / 10.0f; - TERN_(SOUND_MENU_ITEM, ui.buzzer_enabled = true); + TERN_(SOUND_MENU_ITEM, ui.sound_on = ENABLED(SOUND_ON_DEFAULT)); Redraw_Screen(); } -void MarlinUI::init() { +void MarlinUI::init_lcd() { delay(800); SERIAL_ECHOPGM("\nDWIN handshake "); if (DWIN_Handshake()) SERIAL_ECHOLNPGM("ok."); else SERIAL_ECHOLNPGM("error."); @@ -4993,6 +4826,8 @@ void MarlinUI::init() { DWIN_UpdateLCD(); delay(20); } + + DWIN_JPG_ShowAndCache(3); DWIN_JPG_CacheTo1(Language_English); CrealityDWIN.Redraw_Screen(); } diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.h b/Marlin/src/lcd/e3v2/jyersui/dwin.h index 0157f673cef9..8985647cd131 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.h +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.h @@ -43,7 +43,7 @@ enum processID : uint8_t { enum PopupID : uint8_t { Pause, Stop, Resume, SaveLevel, ETemp, ConfFilChange, PurgeMore, MeshSlot, Level, Home, MoveWait, Heating, FilLoad, FilChange, TempWarn, Runout, PIDWait, Resuming, ManualProbing, - FilInsert, HeaterTime, UserInput, LevelError, InvalidMesh, UI, Complete + FilInsert, HeaterTime, UserInput, LevelError, InvalidMesh, UI, Complete, Custom }; enum menuID : uint8_t { @@ -55,16 +55,16 @@ enum menuID : uint8_t { ZOffset, Preheat, ChangeFilament, + MenuCustom, Control, TempMenu, PID, HotendPID, BedPID, - Preheat1, - Preheat2, - Preheat3, - Preheat4, - Preheat5, + #if HAS_PREHEAT + #define _PREHEAT_ID(N) Preheat##N, + REPEAT_1(PREHEAT_COUNT, _PREHEAT_ID) + #endif Motion, HomeOffsets, MaxSpeed, diff --git a/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp b/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp index ef390ac9dc04..7154270bffc6 100644 --- a/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.cpp @@ -46,6 +46,7 @@ void DWIN_Startup() { if (success) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error."); DWIN_Frame_SetDir(TERN(DWIN_MARLINUI_LANDSCAPE, 0, 1)); DWIN_Frame_Clear(Color_Bg_Black); // MarlinUI handles the bootscreen so just clear here + DWIN_JPG_ShowAndCache(3); DWIN_UpdateLCD(); } diff --git a/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.h b/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.h index 3e80a0103ee8..dc6c79bd2d0e 100644 --- a/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.h +++ b/Marlin/src/lcd/e3v2/marlinui/dwin_lcd.h @@ -64,6 +64,8 @@ #define ICON_UpArrow 14 #define ICON_DownArrow 15 #define ICON_BedLine 16 +#define ICON_BedLevelOff 17 +#define ICON_BedLevelOn 18 #include "../common/dwin_font.h" diff --git a/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp b/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp index e08d5360db53..d631cbfafc8d 100644 --- a/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp @@ -27,35 +27,35 @@ #include "dwin_string.h" //#include "../../fontutils.h" -uint8_t DWIN_String::data[]; +char DWIN_String::data[]; uint16_t DWIN_String::span; -uint8_t DWIN_String::len; +uint8_t DWIN_String::length; void DWIN_String::set() { //*data = 0x00; memset(data, 0x00, sizeof(data)); span = 0; - len = 0; + length = 0; } -uint8_t read_byte(uint8_t *byte) { return *byte; } +uint8_t read_byte(const uint8_t *byte) { return *byte; } /** * Add a string, applying substitutions for the following characters: * - * $ displays the clipped C-string given by the itemString argument + * $ displays the clipped string given by fstr or cstr * = displays '0'....'10' for indexes 0 - 10 * ~ displays '1'....'11' for indexes 0 - 10 * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) * @ displays an axis name such as XYZUVW, or E for an extruder */ -void DWIN_String::add(uint8_t *string, const int8_t index, uint8_t *itemString/*=nullptr*/) { +void DWIN_String::add(const char *tpl, const int8_t index, const char *cstr/*=nullptr*/, FSTR_P const fstr/*=nullptr*/) { wchar_t wchar; - while (*string) { - string = get_utf8_value_cb(string, read_byte, &wchar); + while (*tpl) { + tpl = get_utf8_value_cb(tpl, read_byte, &wchar); if (wchar > 255) wchar |= 0x0080; - uint8_t ch = uint8_t(wchar & 0x00FF); + const uint8_t ch = uint8_t(wchar & 0x00FF); if (ch == '=' || ch == '~' || ch == '*') { if (index >= 0) { @@ -65,10 +65,12 @@ void DWIN_String::add(uint8_t *string, const int8_t index, uint8_t *itemString/* add_character('0' + inum); } else - add(index == -2 ? GET_TEXT(MSG_CHAMBER) : GET_TEXT(MSG_BED)); + add(index == -2 ? GET_TEXT_F(MSG_CHAMBER) : GET_TEXT_F(MSG_BED)); } - else if (ch == '$' && itemString) - add(itemString); + else if (ch == '$' && fstr) + add(fstr); + else if (ch == '$' && cstr) + add(cstr); else if (ch == '@') add_character(axis_codes[index]); else @@ -77,10 +79,10 @@ void DWIN_String::add(uint8_t *string, const int8_t index, uint8_t *itemString/* eol(); } -void DWIN_String::add(uint8_t *string, uint8_t max_len) { +void DWIN_String::add(const char *cstr, uint8_t max_len/*=MAX_STRING_LENGTH*/) { wchar_t wchar; - while (*string && max_len) { - string = get_utf8_value_cb(string, read_byte, &wchar); + while (*cstr && max_len) { + cstr = get_utf8_value_cb(cstr, read_byte, &wchar); /* if (wchar > 255) wchar |= 0x0080; uint8_t ch = uint8_t(wchar & 0x00FF); @@ -92,7 +94,7 @@ void DWIN_String::add(uint8_t *string, uint8_t max_len) { eol(); } -void DWIN_String::add(wchar_t character) { +void DWIN_String::add(const wchar_t character) { int ret; size_t idx = 0; dwin_charmap_t pinval; @@ -127,18 +129,18 @@ void DWIN_String::add(wchar_t character) { if (str[1]) add_character(str[1]); } -void DWIN_String::add_character(const uint8_t character) { - if (len < MAX_STRING_LENGTH) { - data[len] = character; - len++; +void DWIN_String::add_character(const char character) { + if (length < MAX_STRING_LENGTH) { + data[length] = character; + length++; //span += glyph(character)->DWidth; } } -void DWIN_String::rtrim(const uint8_t character) { - while (len) { - if (data[len - 1] == 0x20 || data[len - 1] == character) { - len--; +void DWIN_String::rtrim(const char character) { + while (length) { + if (data[length - 1] == 0x20 || data[length - 1] == character) { + length--; //span -= glyph(data[length])->DWidth; eol(); } @@ -147,18 +149,18 @@ void DWIN_String::rtrim(const uint8_t character) { } } -void DWIN_String::ltrim(const uint8_t character) { +void DWIN_String::ltrim(const char character) { uint16_t i, j; - for (i = 0; (i < len) && (data[i] == 0x20 || data[i] == character); i++) { + for (i = 0; (i < length) && (data[i] == 0x20 || data[i] == character); i++) { //span -= glyph(data[i])->DWidth; } if (i == 0) return; - for (j = 0; i < len; data[j++] = data[i++]); - len = j; + for (j = 0; i < length; data[j++] = data[i++]); + length = j; eol(); } -void DWIN_String::trim(const uint8_t character) { +void DWIN_String::trim(const char character) { rtrim(character); ltrim(character); } diff --git a/Marlin/src/lcd/e3v2/marlinui/dwin_string.h b/Marlin/src/lcd/e3v2/marlinui/dwin_string.h index 30af387bdcba..c29777ae7b12 100644 --- a/Marlin/src/lcd/e3v2/marlinui/dwin_string.h +++ b/Marlin/src/lcd/e3v2/marlinui/dwin_string.h @@ -21,6 +21,8 @@ */ #pragma once +// TODO: Make AVR-compatible with separate ROM / RAM string methods + #include "../../fontutils.h" #include "../../marlinui.h" @@ -41,45 +43,87 @@ class DWIN_String { //static glyph_t *glyphs[256]; //static font_t *font_header; - static uint8_t data[MAX_STRING_LENGTH + 1]; + static char data[MAX_STRING_LENGTH + 1]; static uint16_t span; // in pixels - static uint8_t len; // in characters - static void add_character(const uint8_t character); - static void eol() { data[len] = 0x00; } + static void add_character(const char character); + static void eol() { data[length] = 0x00; } public: + static uint8_t length; // in characters //static void set_font(const uint8_t *font); //static void add_glyphs(const uint8_t *font); //static font_t *font() { return font_header; }; //static uint16_t font_height() { return font_header->FontAscent - font_header->FontDescent; } //static glyph_t *glyph(uint8_t character) { return glyphs[character] ?: glyphs[0x3F]; } /* Use '?' for unknown glyphs */ - //static inline glyph_t *glyph(uint8_t *character) { return glyph(*character); } + //static glyph_t *glyph(uint8_t *character) { return glyph(*character); } + /** + * @brief Set the string empty + */ static void set(); - //static void add(uint8_t character) { add_character(character); eol(); } + + //static void add(const char character) { add_character(character); eol(); } + + /** + * @brief Append a UTF-8 character + * + * @param character The UTF-8 character + */ static void add(wchar_t character); - static void add(uint8_t *string, uint8_t max_len=MAX_STRING_LENGTH); - static void add(uint8_t *string, const int8_t index, uint8_t *itemString=nullptr); - static void set(uint8_t *string) { set(); add(string); } static void set(wchar_t character) { set(); add(character); } - static void set(uint8_t *string, int8_t index, const char *itemString=nullptr) { set(); add(string, index, (uint8_t *)itemString); } - static inline void set(FSTR_P fstring) { set((uint8_t *)fstring); } - static inline void set(const char *string) { set((uint8_t *)string); } - static inline void set(const char *string, int8_t index, const char *itemString=nullptr) { set((uint8_t *)string, index, itemString); } - static inline void add(const char *string) { add((uint8_t *)string); } - - static void trim(const uint8_t character=0x20); - static void rtrim(const uint8_t character=0x20); - static void ltrim(const uint8_t character=0x20); - - static void truncate(uint8_t maxlen) { if (len > maxlen) { len = maxlen; eol(); } } - - static inline uint8_t length() { return len; } - static inline uint16_t width() { return span; } - static inline uint8_t *string() { return data; } - static uint16_t center(uint16_t width) { return span > width ? 0 : (width - span) / 2; } + + /** + * @brief Append / Set C-string + * + * @param cstr The string + * @param max_len Character limit + */ + static void add(const char *cstr, uint8_t max_len=MAX_STRING_LENGTH); + static void set(const char *cstr) { set(); add(cstr); } + + /** + * @brief Append / Set F-string + * + * @param fstr The string + * @param max_len Character limit + */ + static void add(FSTR_P const fstr, uint8_t max_len=MAX_STRING_LENGTH) { add(FTOP(fstr), max_len); } + static void set(FSTR_P const fstr) { set(FTOP(fstr)); } + + /** + * @brief Append / Set C-string with optional substitution + * + * @param tpl A string with optional substitution + * @param index An index + * @param cstr An SRAM C-string to use for $ substitution + * @param fstr A ROM F-string to use for $ substitution + */ + static void add(const char *tpl, const int8_t index, const char *cstr=nullptr, FSTR_P const fstr=nullptr); + static void set(const char *tpl, const int8_t index, const char *cstr=nullptr, FSTR_P const fstr=nullptr) { set(); add(tpl, index, cstr, fstr); } + + /** + * @brief Append / Set F-string with optional substitution + * + * @param ftpl A ROM F-string with optional substitution + * @param index An index + * @param cstr An SRAM C-string to use for $ substitution + * @param fstr A ROM F-string to use for $ substitution + */ + static void add(FSTR_P const ftpl, const int8_t index, const char *cstr=nullptr, FSTR_P const fstr=nullptr) { add(FTOP(ftpl), index, cstr, fstr); } + static void set(FSTR_P const ftpl, const int8_t index, const char *cstr=nullptr, FSTR_P const fstr=nullptr) { set(); add(ftpl, index, cstr, fstr); } + + // Common string ops + static void trim(const char character=' '); + static void rtrim(const char character=' '); + static void ltrim(const char character=' '); + static void truncate(const uint8_t maxlen) { if (length > maxlen) { length = maxlen; eol(); } } + + // Accessors + static char *string() { return data; } + static uint16_t width() { return span; } + static uint16_t center(const uint16_t width) { return span > width ? 0 : (width - span) / 2; } }; int dwin_charmap_compare(dwin_charmap_t *v1, dwin_charmap_t *v2); diff --git a/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp b/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp index 44be749d41fc..278f17fac994 100644 --- a/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/lcdprint_dwin.cpp @@ -56,20 +56,20 @@ void lcd_put_int(const int i) { } int lcd_put_dwin_string() { - DWIN_Draw_String(dwin_font.solid, dwin_font.index, dwin_font.fg, dwin_font.bg, cursor.x, cursor.y, (char*)dwin_string.string()); - lcd_advance_cursor(dwin_string.length()); - return dwin_string.length(); + 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); + return dwin_string.length; } // return < 0 on error // return the advanced cols -int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) { +int lcd_put_wchar_max(const wchar_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 - DWIN_Draw_String(dwin_font.solid, dwin_font.index, dwin_font.fg, dwin_font.bg, cursor.x, cursor.y, (char*)dwin_string.string()); - lcd_advance_cursor(dwin_string.length()); - return dwin_string.length(); + 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); + return dwin_string.length; } /** @@ -83,35 +83,34 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) { * * Draw a UTF-8 string */ -static int lcd_put_u8str_max_cb(const char * utf8_str, uint8_t (*cb_read_byte)(uint8_t * str), pixel_len_t max_length) { - uint8_t *p = (uint8_t *)utf8_str; +static int lcd_put_u8str_max_cb(const char * utf8_str, read_byte_cb_t cb_read_byte, const pixel_len_t max_length) { + const uint8_t *p = (uint8_t *)utf8_str; dwin_string.set(); - while (dwin_string.length() < max_length) { + 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); } - DWIN_Draw_String(dwin_font.solid, dwin_font.index, dwin_font.fg, dwin_font.bg, cursor.x, cursor.y, (char*)dwin_string.string()); - lcd_advance_cursor(dwin_string.length()); - return dwin_string.length(); + 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); + return dwin_string.length; } -int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) { +int lcd_put_u8str_max(const char * utf8_str, const pixel_len_t max_length) { return lcd_put_u8str_max_cb(utf8_str, read_byte_ram, max_length); } -int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) { +int lcd_put_u8str_max_P(PGM_P utf8_pstr, const pixel_len_t max_length) { return lcd_put_u8str_max_cb(utf8_pstr, read_byte_rom, max_length); } -lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const inStr/*=nullptr*/, const lcd_uint_t maxlen/*=LCD_WIDTH*/) { - dwin_string.set(); - dwin_string.add((uint8_t*)pstr, ind, (uint8_t*)inStr); +lcd_uint_t lcd_put_u8str_P(PGM_P const ptpl, const int8_t ind, const char * const cstr/*=nullptr*/, FSTR_P const fstr/*=nullptr*/, const lcd_uint_t maxlen/*=LCD_WIDTH*/) { + dwin_string.set(ptpl, ind, cstr, fstr); dwin_string.truncate(maxlen); - DWIN_Draw_String(dwin_font.solid, dwin_font.index, dwin_font.fg, dwin_font.bg, cursor.x, cursor.y, (char*)dwin_string.string()); - lcd_advance_cursor(dwin_string.length()); - return dwin_string.length(); + 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); + return dwin_string.length; } #if ENABLED(DEBUG_LCDPRINT) diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp index 126700185b04..f01a2beddf4e 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp @@ -79,16 +79,12 @@ void MarlinUI::set_font(const uint8_t font_nr) { bool MarlinUI::detected() { return true; } // Initialize or re-initialize the LCD -void MarlinUI::init_lcd() { - DWIN_Startup(); - - // Load the assets JPG (currently just the status screen 'icon') - DWIN_JPG_CacheTo1(DWIN_MarlinUI_Assets); -} +void MarlinUI::init_lcd() { DWIN_Startup(); } // This LCD should clear where it will draw anew void MarlinUI::clear_lcd() { DWIN_ICON_AnimationControl(0x0000); // disable all icon animations + DWIN_JPG_ShowAndCache(3); DWIN_Frame_Clear(Color_Bg_Black); DWIN_UpdateLCD(); @@ -98,30 +94,40 @@ void MarlinUI::clear_lcd() { #if ENABLED(SHOW_BOOTSCREEN) void MarlinUI::show_bootscreen() { - clear_lcd(); dwin_string.set(F(SHORT_BUILD_VERSION)); + #if ENABLED(SHOW_CUSTOM_BOOTSCREEN) && !defined(CUSTOM_BOOTSCREEN_TIMEOUT) + #define CUSTOM_BOOTSCREEN_TIMEOUT 3000 + #endif + #if ENABLED(DWIN_MARLINUI_PORTRAIT) #define LOGO_CENTER ((LCD_PIXEL_WIDTH) / 2) #define INFO_CENTER LOGO_CENTER #define VERSION_Y 330 - DWIN_ICON_Show(BOOT_ICON, ICON_MarlinBoot, LOGO_CENTER - 266 / 2, 15); + #else + #define LOGO_CENTER (280 / 2) + #define INFO_CENTER ((LCD_PIXEL_WIDTH) - 200 / 2) + #define VERSION_Y 84 + #endif + + DWIN_Draw_String(false, font10x20, Color_Yellow, Color_Bg_Black, INFO_CENTER - (dwin_string.length * 10) / 2, VERSION_Y, S(dwin_string.string())); + TERN_(SHOW_CUSTOM_BOOTSCREEN, safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT)); + clear_lcd(); + + DWIN_ICON_Show(BOOT_ICON, ICON_MarlinBoot, LOGO_CENTER - 266 / 2, 15); + #if ENABLED(DWIN_MARLINUI_PORTRAIT) DWIN_ICON_Show(BOOT_ICON, ICON_OpenSource, LOGO_CENTER - 174 / 2, 280); DWIN_ICON_Show(BOOT_ICON, ICON_GitHubURL, LOGO_CENTER - 180 / 2, 420); DWIN_ICON_Show(BOOT_ICON, ICON_MarlinURL, LOGO_CENTER - 100 / 2, 440); DWIN_ICON_Show(BOOT_ICON, ICON_Copyright, LOGO_CENTER - 126 / 2, 460); #else - #define LOGO_CENTER (280 / 2) - #define INFO_CENTER ((LCD_PIXEL_WIDTH) - 200 / 2) - #define VERSION_Y 84 DWIN_ICON_Show(BOOT_ICON, ICON_MarlinBoot, LOGO_CENTER - 266 / 2, 15); DWIN_ICON_Show(BOOT_ICON, ICON_OpenSource, INFO_CENTER - 174 / 2, 60); DWIN_ICON_Show(BOOT_ICON, ICON_GitHubURL, INFO_CENTER - 180 / 2, 130); DWIN_ICON_Show(BOOT_ICON, ICON_MarlinURL, INFO_CENTER - 100 / 2, 152); DWIN_ICON_Show(BOOT_ICON, ICON_Copyright, INFO_CENTER - 126 / 2, 200); #endif - - DWIN_Draw_String(false, font10x20, Color_Yellow, Color_Bg_Black, INFO_CENTER - (dwin_string.length() * 10) / 2, VERSION_Y, S(dwin_string.string())); + DWIN_Draw_String(false, font10x20, Color_Yellow, Color_Bg_Black, INFO_CENTER - (dwin_string.length * 10) / 2, VERSION_Y, S(dwin_string.string())); DWIN_UpdateLCD(); } @@ -258,7 +264,7 @@ void MarlinUI::draw_status_message(const bool blink) { void MarlinUI::_set_brightness() { DWIN_LCD_Brightness(backlight ? brightness : 0); } #endif -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "../../menu/menu.h" @@ -278,7 +284,7 @@ void MarlinUI::draw_status_message(const bool blink) { else dwin_string.add(PSTR(" ")); - lcd_moveto(LCD_WIDTH - dwin_string.length(), row); + lcd_moveto(LCD_WIDTH - dwin_string.length, row); lcd_put_dwin_string(); } @@ -305,7 +311,7 @@ void MarlinUI::draw_status_message(const bool blink) { // Draw a static line of text in the same idiom as a menu item - void MenuItem_static::draw(const uint8_t row, PGM_P const pstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) { + void MenuItem_static::draw(const uint8_t row, FSTR_P const ftpl, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) { // Call mark_as_selected to draw a bigger selection box // and draw the text without a background if (mark_as_selected(row, (bool)(style & SS_INVERT), true)) { @@ -314,15 +320,15 @@ void MarlinUI::draw_status_message(const bool blink) { dwin_font.fg = Color_White; dwin_string.set(); - const int8_t plen = pstr ? utf8_strlen_P(pstr) : 0, + const int8_t plen = ftpl ? utf8_strlen(ftpl) : 0, vlen = vstr ? utf8_strlen(vstr) : 0; if (style & SS_CENTER) { int8_t pad = (LCD_WIDTH - 1 - plen - vlen) / 2; while (--pad) dwin_string.add(' '); } - if (plen) dwin_string.add((uint8_t*)pstr, itemIndex, (uint8_t*)itemString); - if (vlen) dwin_string.add((uint8_t*)vstr); + if (plen) dwin_string.add(ftpl, itemIndex, itemStringC, itemStringF); + if (vlen) dwin_string.add(vstr); if (style & SS_CENTER) { int8_t pad = (LCD_WIDTH - 1 - plen - vlen) / 2; while (--pad) dwin_string.add(' '); @@ -334,15 +340,15 @@ void MarlinUI::draw_status_message(const bool blink) { } // Draw a generic menu item - void MenuItemBase::_draw(const bool sel, const uint8_t row, PGM_P const pstr, const char, const char post_char) { + 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)) { ui.set_font(DWIN_FONT_MENU); dwin_font.solid = false; dwin_font.fg = Color_White; - dwin_string.set(pstr, itemIndex, itemString); + dwin_string.set(ftpl, itemIndex, itemStringC, itemStringF); - pixel_len_t n = LCD_WIDTH - 1 - dwin_string.length(); + pixel_len_t n = LCD_WIDTH - 1 - dwin_string.length; while (--n > 1) dwin_string.add(' '); dwin_string.add(post_char); @@ -355,15 +361,15 @@ void MarlinUI::draw_status_message(const bool blink) { // // Draw a menu item with an editable value // - void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm) { + void MenuEditItemBase::draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char * const inStr, const bool pgm) { if (mark_as_selected(row, sel)) { ui.set_font(DWIN_FONT_MENU); dwin_font.solid = false; dwin_font.fg = Color_White; - const uint8_t vallen = (pgm ? utf8_strlen_P(data) : utf8_strlen(S(data))); + const uint8_t vallen = (pgm ? utf8_strlen_P(inStr) : utf8_strlen(S(inStr))); - dwin_string.set(pstr, itemIndex, itemString); + dwin_string.set(ftpl, itemIndex, itemStringC, itemStringF); if (vallen) dwin_string.add(':'); lcd_moveto(1, row); @@ -371,7 +377,7 @@ void MarlinUI::draw_status_message(const bool blink) { if (vallen) { dwin_font.fg = Color_Yellow; - dwin_string.set(data); + dwin_string.set(inStr); lcd_moveto(LCD_WIDTH - vallen - 1, row); lcd_put_dwin_string(); } @@ -381,13 +387,12 @@ void MarlinUI::draw_status_message(const bool blink) { // // Draw an edit screen with label and current value // - void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) { + void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char* const value/*=nullptr*/) { ui.encoder_direction_normal(); - const dwin_coord_t labellen = utf8_strlen_P(pstr), vallen = utf8_strlen(value); + const dwin_coord_t labellen = utf8_strlen(fstr), vallen = utf8_strlen(value); - dwin_string.set(); - dwin_string.add((uint8_t*)pstr, itemIndex); + dwin_string.set(FTOP(fstr), itemIndex); if (vallen) dwin_string.add(':'); // If a value is included, add a colon // Assume the label is alpha-numeric (with a descender) @@ -400,8 +405,7 @@ void MarlinUI::draw_status_message(const bool blink) { // If a value is included, print the value in larger text below the label if (vallen) { - dwin_string.set(); - dwin_string.add(value); + dwin_string.set(value); 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())); @@ -424,31 +428,31 @@ void MarlinUI::draw_status_message(const bool blink) { } } - inline void draw_boxed_string(const bool yesopt, PGM_P const pstr, const bool inv) { - const uint8_t len = utf8_strlen_P(pstr), + inline void draw_boxed_string(const bool yesopt, FSTR_P const fstr, const bool inv) { + const uint8_t len = utf8_strlen(fstr), mar = TERN(DWIN_MARLINUI_PORTRAIT, 1, 4), col = yesopt ? LCD_WIDTH - mar - len : mar, row = (LCD_HEIGHT >= 8 ? LCD_HEIGHT / 2 + 3 : LCD_HEIGHT - 1); lcd_moveto(col, row); DWIN_Draw_Box(1, inv ? Select_Color : Color_Bg_Black, cursor.x - dwin_font.width, cursor.y + 1, dwin_font.width * (len + 2), dwin_font.height + 2); - lcd_put_u8str_P(col, row, pstr); + lcd_put_u8str(col, row, fstr); } void MenuItem_confirm::draw_select_screen( - PGM_P const yes, PGM_P const no, const bool yesno, - PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/ + FSTR_P const yes, FSTR_P const no, const bool yesno, + FSTR_P const pref, const char * const string/*=nullptr*/, FSTR_P const suff/*=nullptr*/ ) { ui.set_font(DWIN_FONT_MENU); dwin_font.solid = false; dwin_font.fg = Color_White; ui.draw_select_screen_prompt(pref, string, suff); - draw_boxed_string(false, no, !yesno); - draw_boxed_string(true, yes, yesno); + if (no) draw_boxed_string(false, no, !yesno); + if (yes) draw_boxed_string(true, yes, yesno); } #if ENABLED(SDSUPPORT) - void MenuItem_sdbase::draw(const bool sel, const uint8_t row, PGM_P const, CardReader &theCard, const bool isDir) { + 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)) { dwin_string.set(); @@ -458,8 +462,8 @@ void MarlinUI::draw_status_message(const bool blink) { maxlen -= 2; } - dwin_string.add((uint8_t*)ui.scrolled_filename(theCard, maxlen, row, sel), maxlen); - uint8_t n = maxlen - dwin_string.length(); + dwin_string.add(ui.scrolled_filename(theCard, maxlen, row, sel), maxlen); + uint8_t n = maxlen - dwin_string.length; while (n > 0) { dwin_string.add(' '); --n; } lcd_moveto(1, row); lcd_put_dwin_string(); @@ -510,8 +514,8 @@ void MarlinUI::draw_status_message(const bool blink) { // Display Mesh Point Locations const dwin_coord_t sx = x_offset + pixels_per_x_mesh_pnt / 2; dwin_coord_t y = y_offset + pixels_per_y_mesh_pnt / 2; - for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++, y += pixels_per_y_mesh_pnt) - for (uint8_t i = 0, x = sx; i < GRID_MAX_POINTS_X; i++, x += pixels_per_x_mesh_pnt) + for (uint8_t j = 0; j < (GRID_MAX_POINTS_Y); j++, y += pixels_per_y_mesh_pnt) + for (uint8_t i = 0, x = sx; i < (GRID_MAX_POINTS_X); i++, x += pixels_per_x_mesh_pnt) DWIN_Draw_Point(Color_White, 1, 1, x, y); // Put Relevant Text on Display @@ -519,7 +523,7 @@ void MarlinUI::draw_status_message(const bool blink) { // Show X and Y positions at top of screen dwin_font.fg = Color_White; dwin_font.solid = true; - const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) }, + const xy_pos_t pos = { bedlevel.get_mesh_x(x_plot), bedlevel.get_mesh_y(y_plot) }, lpos = pos.asLogical(); lcd_moveto( @@ -542,19 +546,19 @@ void MarlinUI::draw_status_message(const bool blink) { dwin_string.add(i8tostr3rj(y_plot)); dwin_string.add(")"); lcd_moveto( - TERN(DWIN_MARLINUI_LANDSCAPE, ((x_offset + x_map_pixels) / MENU_FONT_WIDTH) + 2, LCD_WIDTH - dwin_string.length()), + TERN(DWIN_MARLINUI_LANDSCAPE, ((x_offset + x_map_pixels) / MENU_FONT_WIDTH) + 2, LCD_WIDTH - dwin_string.length), TERN(DWIN_MARLINUI_LANDSCAPE, LCD_HEIGHT - 2, ((y_offset + y_map_pixels) / MENU_LINE_HEIGHT) + 1) ); lcd_put_dwin_string(); // Show the location value dwin_string.set(Z_LBL); - if (!isnan(Z_VALUES_ARR[x_plot][y_plot])) - dwin_string.add(ftostr43sign(Z_VALUES_ARR[x_plot][y_plot])); + if (!isnan(bedlevel.z_values[x_plot][y_plot])) + dwin_string.add(ftostr43sign(bedlevel.z_values[x_plot][y_plot])); else dwin_string.add(PSTR(" -----")); lcd_moveto( - TERN(DWIN_MARLINUI_LANDSCAPE, ((x_offset + x_map_pixels) / MENU_FONT_WIDTH) + 2, LCD_WIDTH - dwin_string.length()), + TERN(DWIN_MARLINUI_LANDSCAPE, ((x_offset + x_map_pixels) / MENU_FONT_WIDTH) + 2, LCD_WIDTH - dwin_string.length), TERN(DWIN_MARLINUI_LANDSCAPE, LCD_HEIGHT - 1, ((y_offset + y_map_pixels) / MENU_LINE_HEIGHT) + 2) ); lcd_put_dwin_string(); @@ -586,6 +590,6 @@ void MarlinUI::draw_status_message(const bool blink) { #endif // BABYSTEP_ZPROBE_GFX_OVERLAY || MESH_EDIT_GFX_OVERLAY -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU #endif // IS_DWIN_MARLINUI diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp index 306e9044f703..810eaf361a09 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp @@ -37,6 +37,7 @@ #include "../../../module/motion.h" #include "../../../module/temperature.h" #include "../../../module/printcounter.h" +#include "../../../module/planner.h" #if ENABLED(SDSUPPORT) #include "../../../libs/duration_t.h" @@ -46,8 +47,13 @@ #include "../../../MarlinCore.h" // for printingIsActive #endif -#define STATUS_HEATERS_X 15 -#define STATUS_HEATERS_Y 56 +#if ENABLED(DWIN_MARLINUI_PORTRAIT) + #define STATUS_HEATERS_X 15 + #define STATUS_HEATERS_Y 56 +#else + #define STATUS_HEATERS_X 154 + #define STATUS_HEATERS_Y 10 +#endif #define STATUS_HEATERS_XSPACE 64 #define STATUS_FAN_WIDTH 48 #define STATUS_FAN_HEIGHT 48 @@ -61,35 +67,61 @@ // 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) { - uint8_t vallen = utf8_strlen(value); - if (!ui.did_first_redraw) { - dwin_string.set(); - dwin_string.add('X' + axis); - DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x + (vallen * 14 - 14) / 2, y + 2, S(dwin_string.string())); - } + #if ENABLED(DWIN_MARLINUI_PORTRAIT) - dwin_string.set(); - if (blink) - dwin_string.add(value); - else { - if (!TEST(axis_homed, axis)) + 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(axis_homed, axis)) while (const char c = *value++) dwin_string.add(c <= '.' ? c : '?'); + else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !TEST(axis_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(" "); + + 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 NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) - if (!TEST(axis_trusted, axis)) - dwin_string.add(TERN1(DWIN_MARLINUI_PORTRAIT, axis == Z_AXIS) ? PSTR(" ") : PSTR(" ")); - else - #endif - dwin_string.add(value); + if (!TEST(axis_homed, axis)) + while (const char c = *value++) dwin_string.add(c <= '.' ? c : '?'); + else { + #if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) + if (!TEST(axis_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 (BOTH(DWIN_MARLINUI_PORTRAIT, LCD_SHOW_E_TOTAL) && axis == X_AXIS) - dwin_string.add(" "); + // 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(" "); + + DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x + 32, y + 4, S(dwin_string.string())); - DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + 32, S(dwin_string.string())); + #endif // !DWIN_MARLINUI_PORTRAIT } #if ENABLED(LCD_SHOW_E_TOTAL) @@ -97,20 +129,36 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const FORCE_INLINE 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 - if (!ui.did_first_redraw) { - // Extra spaces so we don't have to clear the 'Y' label separately - dwin_string.set("E "); - DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x + (4 * 14 / 2) - 7, y + 2, S(dwin_string.string())); - } + #if ENABLED(DWIN_MARLINUI_PORTRAIT) - dwin_string.set(ui16tostr5rj(value / scale)); - DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + 32, S(dwin_string.string())); + if (!ui.did_first_redraw) { + // Extra spaces to erase previous value + dwin_string.set("E "); + DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x + (4 * 14 / 2) - 7, y + 2, S(dwin_string.string())); + } + + dwin_string.set(ui16tostr5rj(value / scale)); + DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + 32, S(dwin_string.string())); + + // Extra spaces to erase previous value + DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, x + (5 * 14), y + 32, S(scale == 1 ? "mm " : "cm ")); + + #else // !DWIN_MARLINUI_PORTRAIT - // Extra spaces so we don't have to clear out the Y value separately - DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, x + (5 * 14), y + 32, S(scale == 1 ? "mm " : "cm ")); + if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) { + dwin_string.set("E "); + DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x, y, S(dwin_string.string())); + } + + dwin_string.set(ui16tostr5rj(value / scale)); + DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x + 32, y + 4, S(dwin_string.string())); + + DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, x + (32 + 70), y + 4, S(scale == 1 ? "mm " : "cm ")); + + #endif // !DWIN_MARLINUI_PORTRAIT } -#endif +#endif // LCD_SHOW_E_TOTAL // // Fan Icon and Percentage @@ -126,6 +174,7 @@ FORCE_INLINE void _draw_fan_status(const uint16_t x, const uint16_t y) { 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(PSTR(" ")); DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + STATUS_FAN_HEIGHT, S(dwin_string.string())); @@ -142,52 +191,87 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x #define HOTEND_STATS 3 #elif HOTENDS > 1 #define HOTEND_STATS 2 - #elif HAS_HOTEND + #else #define HOTEND_STATS 1 #endif - static celsius_t old_temp[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500), - old_target[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500); - static bool old_on[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, false); + static celsius_t old_temp[HOTEND_STATS] = { 0 }, + old_target[HOTEND_STATS] = { 0 }; + static bool old_on[HOTEND_STATS] = { false }; #endif #if HAS_HEATED_BED - static celsius_t old_bed_temp = 500, old_bed_target = 500; + static celsius_t old_bed_temp = 0, old_bed_target = 0; static bool old_bed_on = false; + #if HAS_LEVELING + static bool old_leveling_on = false; + #endif #endif #if HAS_HOTEND && HAS_HEATED_BED + float tc, tt; + bool c_draw, t_draw, i_draw, ta; const bool isBed = heater < 0; - const float tc = (isBed ? thermalManager.degBed() : thermalManager.degHotend(heater)), - tt = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater)); - const uint8_t ta = isBed ? thermalManager.isHeatingBed() : thermalManager.isHeatingHotend(heater); - const bool c_draw = tc != (isBed ? old_bed_temp : old_temp[heater]), - t_draw = tt != (isBed ? old_bed_target : old_target[heater]), - i_draw = ta != (isBed ? old_bed_on : old_on[heater]); - if (isBed) { old_bed_temp = tc; old_bed_target = tt; old_bed_on = ta; } - else { old_temp[heater] = tc; old_target[heater] = tt; old_on[heater] = ta; } + if (isBed) { + 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; + old_bed_temp = tc; + old_bed_target = tt; + old_bed_on = ta; + } + else { + 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]; + 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); - const bool c_draw = tc != old_bed_temp, t_draw = tt != old_bed_target, i_draw = ta != old_bed_on; + 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(); - const bool c_draw = tc != old_temp[heater], t_draw = tt != old_target[heater], i_draw = ta != old_on[heater]; + 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 + // Draw target temperature, if needed if (!ui.did_first_redraw || 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())); } - if (!ui.did_first_redraw || i_draw) - DWIN_ICON_Show(ICON, (isBed ? ICON_BedOff : ICON_HotendOff) + ta, x, y + STATUS_CHR_HEIGHT + 2); + // Draw heater icon with on / off / leveled states + if (!ui.did_first_redraw || 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) { dwin_string.set(i16tostr3rj(tc + 0.5)); dwin_string.add(LCD_STR_DEGREE); @@ -220,14 +304,22 @@ void MarlinUI::draw_status_screen() { // Logo/Status Icon #define STATUS_LOGO_WIDTH 128 #define STATUS_LOGO_HEIGHT 40 - DWIN_ICON_Show(ICON, ICON_LOGO_Marlin, (LCD_PIXEL_WIDTH - (STATUS_LOGO_WIDTH)) / 2, ((STATUS_HEATERS_Y - 4) - (STATUS_LOGO_HEIGHT)) / 2); + DWIN_ICON_Show(ICON, ICON_LOGO_Marlin, + #if ENABLED(DWIN_MARLINUI_PORTRAIT) + (LCD_PIXEL_WIDTH - (STATUS_LOGO_WIDTH)) / 2, ((STATUS_HEATERS_Y - 4) - (STATUS_LOGO_HEIGHT)) / 2 + #else + 5, 42 + #endif + ); // Draw a frame around the x/y/z values - #if ENABLED(DWIN_MARLINUI_PORTRAIT) - DWIN_Draw_Rectangle(0, Select_Color, 0, 193, LCD_PIXEL_WIDTH, 260); - #else - //DWIN_Draw_Rectangle(0, Select_Color, LCD_PIXEL_WIDTH - 106, 50, LCD_PIXEL_WIDTH - 1, 230); - #endif + DWIN_Draw_Rectangle(0, Select_Color, + #if ENABLED(DWIN_MARLINUI_PORTRAIT) + 0, 193, LCD_PIXEL_WIDTH, 260 + #else + 0, 115, LCD_PIXEL_WIDTH - 1, 152 + #endif + ); } uint16_t hx = STATUS_HEATERS_X; @@ -244,33 +336,22 @@ void MarlinUI::draw_status_screen() { #endif #if HAS_FAN - // Fan display, pinned to the right side - #if ENABLED(DWIN_MARLINUI_PORTRAIT) - _draw_fan_status(LCD_PIXEL_WIDTH - STATUS_CHR_WIDTH * 4, STATUS_FAN_Y); - #else - _draw_fan_status(212, STATUS_FAN_Y); - #endif + _draw_fan_status(LCD_PIXEL_WIDTH - STATUS_CHR_WIDTH * 5, STATUS_FAN_Y); #endif // Axis values const xyz_pos_t lpos = current_position.asLogical(); const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive()); UNUSED(show_e_total); - #if ENABLED(DWIN_MARLINUI_PORTRAIT) - constexpr int16_t cpy = 195; - if (show_e_total) { - TERN_(LCD_SHOW_E_TOTAL, _draw_e_value(e_move_accumulator, 6, cpy)); - } - else { - _draw_axis_value(X_AXIS, ftostr4sign(lpos.x), blink, 6, cpy); - TERN_(HAS_Y_AXIS, _draw_axis_value(Y_AXIS, ftostr4sign(lpos.y), blink, 95, cpy)); - } - TERN_(HAS_Z_AXIS, _draw_axis_value(Z_AXIS, ftostr52sp(lpos.z), blink, 165, cpy)); - #else - constexpr int16_t cpx = LCD_PIXEL_WIDTH - 104; - _draw_axis_value(X_AXIS, ftostr52sp(lpos.x), blink, cpx, STATUS_HEATERS_Y); - TERN_(HAS_Y_AXIS, _draw_axis_value(Y_AXIS, ftostr52sp(lpos.y), blink, cpx, STATUS_HEATERS_Y + 59)); - TERN_(HAS_Z_AXIS, _draw_axis_value(Z_AXIS, ftostr52sp(lpos.z), blink, cpx, STATUS_HEATERS_Y + 118)); - #endif + + constexpr int16_t cpy = TERN(DWIN_MARLINUI_PORTRAIT, 195, 117); + if (show_e_total) { + TERN_(LCD_SHOW_E_TOTAL, _draw_e_value(e_move_accumulator, TERN(DWIN_MARLINUI_PORTRAIT, 6, 75), cpy)); + } + else { + _draw_axis_value(X_AXIS, ftostr4sign(lpos.x), blink, TERN(DWIN_MARLINUI_PORTRAIT, 6, 75), cpy); + TERN_(HAS_Y_AXIS, _draw_axis_value(Y_AXIS, ftostr4sign(lpos.y), blink, TERN(DWIN_MARLINUI_PORTRAIT, 95, 184), cpy)); + } + TERN_(HAS_Z_AXIS, _draw_axis_value(Z_AXIS, ftostr52sp(lpos.z), blink, TERN(DWIN_MARLINUI_PORTRAIT, 165, 300), cpy)); // Feedrate static uint16_t old_fp = 0; @@ -278,9 +359,9 @@ void MarlinUI::draw_status_screen() { old_fp = feedrate_percentage; _draw_feedrate_status(i16tostr3rj(feedrate_percentage), #if ENABLED(DWIN_MARLINUI_PORTRAIT) - 5, 290 + 5, 290 #else - 294, STATUS_HEATERS_Y + 14, 195 #endif ); } @@ -308,7 +389,7 @@ void MarlinUI::draw_status_screen() { time.toDigital(buffer); dwin_string.add(prefix); dwin_string.add(buffer); - DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, (LCD_PIXEL_WIDTH - ((dwin_string.length() + 1) * 14)), 290, S(dwin_string.string())); + DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, (LCD_PIXEL_WIDTH - ((dwin_string.length + 1) * 14)), 290, S(dwin_string.string())); #else @@ -317,25 +398,23 @@ void MarlinUI::draw_status_screen() { time.toDigital(buffer); dwin_string.set(" "); dwin_string.add(buffer); - DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 280, 100, S(dwin_string.string())); - - #if ENABLED(LCD_SHOW_E_TOTAL) - if (show_e_total && TERN1(SHOW_REMAINING_TIME, !blink)) { // if SHOW_REMAINING_TIME is also - const uint8_t escale = e_move_accumulator >= 100000.0f ? 10 : 1; // show cm after 99,000mm + DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 230, 170, S(dwin_string.string())); - DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 249, 135, S("E")); - dwin_string.set(ui16tostr5rj(e_move_accumulator * escale)); - DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 263, 135, S(dwin_string.string())); - DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 333, 135, S(escale==1 ? "mm" : "cm")); - } - #endif #if ENABLED(SHOW_REMAINING_TIME) - if (!show_e_total || blink) { - DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 249, 135, S(" R ")); + if (print_job_timer.isRunning()) { time = get_remaining_time(); - time.toDigital(buffer); - dwin_string.set(buffer); - DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 291, 135, S(dwin_string.string())); + DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(" R ")); + if (print_job_timer.isPaused() && blink) + dwin_string.set(" "); + else { + time.toDigital(buffer); + dwin_string.set(buffer); + } + 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()) { + dwin_string.set(" "); + DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(dwin_string.string())); } #endif #endif @@ -343,41 +422,45 @@ void MarlinUI::draw_status_screen() { // // Progress Bar // - constexpr int16_t pb_margin = 5, pb_left = pb_margin, pb_height = 60, - pb_right = LCD_PIXEL_WIDTH - TERN(DWIN_MARLINUI_PORTRAIT, 0, 107) - pb_margin, - pb_bottom = TERN(DWIN_MARLINUI_PORTRAIT, 410, 230), - pb_top = pb_bottom - pb_height, - pb_width = pb_right - pb_left; - - const progress_t progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)(); - - if (!ui.did_first_redraw) - DWIN_Draw_Rectangle(0, Select_Color, pb_left, pb_top, pb_right, pb_bottom); // Outline - - static uint16_t old_solid = 50; - const uint16_t pb_solid = (pb_width - 2) * (progress / (PROGRESS_SCALE)) * 0.01f; - const bool p_draw = !ui.did_first_redraw || old_solid != pb_solid; - - if (p_draw) { - //if (pb_solid) - DWIN_Draw_Rectangle(1, Select_Color, pb_left + 1, pb_top + 1, pb_left + pb_solid, pb_bottom - 1); // Fill the solid part - - //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) - dwin_string.set(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE)))); - dwin_string.add(PSTR("%")); - 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, - S(dwin_string.string()) - ); - #endif + #if HAS_PRINT_PROGRESS + constexpr int16_t pb_margin = 5, + pb_left = pb_margin + TERN(DWIN_MARLINUI_PORTRAIT, 0, 90), + pb_height = TERN(DWIN_MARLINUI_PORTRAIT, 60, 20), + pb_right = LCD_PIXEL_WIDTH - pb_margin, + pb_bottom = TERN(DWIN_MARLINUI_PORTRAIT, 410, 220), + pb_top = pb_bottom - pb_height, + pb_width = pb_right - pb_left; + + const progress_t progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)(); + + if (!ui.did_first_redraw) + DWIN_Draw_Rectangle(0, Select_Color, pb_left, pb_top, pb_right, pb_bottom); // Outline + + static uint16_t old_solid = 50; + const uint16_t pb_solid = (pb_width - 2) * (progress / (PROGRESS_SCALE)) * 0.01f; + const bool p_draw = !ui.did_first_redraw || old_solid != pb_solid; + + if (p_draw) { + //if (pb_solid) + DWIN_Draw_Rectangle(1, Select_Color, pb_left + 1, pb_top + 1, pb_left + pb_solid, pb_bottom - 1); // Fill the solid part + + //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) + dwin_string.set(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE)))); + dwin_string.add(PSTR("%")); + 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, + S(dwin_string.string()) + ); + #endif - old_solid = pb_solid; - } + old_solid = pb_solid; + } + #endif // HAS_PRINT_PROGRESS // // Status Message @@ -385,6 +468,7 @@ void MarlinUI::draw_status_screen() { draw_status_message(blink); ui.did_first_redraw = true; + ui.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 new file mode 100644 index 000000000000..d82d0b27e8ac --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/base64.hpp @@ -0,0 +1,208 @@ +/** + * Base64 encoder/decoder for arduino repo + * Uses common web conventions - '+' for 62, '/' for 63, '=' for padding. + * Note that invalid base64 characters are interpreted as padding. + * Author: Densaugeo + * Maintainer: Densaugeo + * Version: 1.2.1.1 + * Changed unsigned int to uint16_t for use in the professional Ender 3V2/S1 firmware + * Url: https://www.arduino.cc/reference/en/libraries/base64/ + */ + +#ifndef BASE64_H_INCLUDED +#define BASE64_H_INCLUDED + +/* binary_to_base64: + * Description: + * Converts a single byte from a binary value to the corresponding base64 character + * Parameters: + * v - Byte to convert + * Returns: + * ascii code of base64 character. If byte is >= 64, then there is not corresponding base64 character + * and 255 is returned + */ +unsigned char binary_to_base64(unsigned char v); + +/* base64_to_binary: + * Description: + * Converts a single byte from a base64 character to the corresponding binary value + * Parameters: + * c - Base64 character (as ascii code) + * Returns: + * 6-bit binary value + */ +unsigned char base64_to_binary(unsigned char c); + +/* encode_base64_length: + * Description: + * Calculates length of base64 string needed for a given number of binary bytes + * Parameters: + * input_length - Amount of binary data in bytes + * Returns: + * Number of base64 characters needed to encode input_length bytes of binary data + */ +uint16_t encode_base64_length(uint16_t input_length); + +/* decode_base64_length: + * Description: + * Calculates number of bytes of binary data in a base64 string + * Variant that does not use input_length no longer used within library, retained for API compatibility + * Parameters: + * input - Base64-encoded null-terminated string + * input_length (optional) - Number of bytes to read from input pointer + * Returns: + * Number of bytes of binary data in input + */ +uint16_t decode_base64_length(unsigned char input[]); +uint16_t decode_base64_length(unsigned char input[], uint16_t input_length); + +/* encode_base64: + * Description: + * Converts an array of bytes to a base64 null-terminated string + * Parameters: + * input - Pointer to input data + * input_length - Number of bytes to read from input pointer + * output - Pointer to output string. Null terminator will be added automatically + * Returns: + * Length of encoded string in bytes (not including null terminator) + */ +uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]); + +/* decode_base64: + * Description: + * Converts a base64 null-terminated string to an array of bytes + * Parameters: + * input - Pointer to input string + * input_length (optional) - Number of bytes to read from input pointer + * output - Pointer to output array + * Returns: + * Number of bytes in the decoded binary + */ +uint16_t decode_base64(unsigned char input[], unsigned char output[]); +uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]); + +unsigned char binary_to_base64(unsigned char v) { + // Capital letters - 'A' is ascii 65 and base64 0 + if (v < 26) return v + 'A'; + + // Lowercase letters - 'a' is ascii 97 and base64 26 + if (v < 52) return v + 71; + + // Digits - '0' is ascii 48 and base64 52 + if (v < 62) return v - 4; + + // '+' is ascii 43 and base64 62 + if (v == 62) return '+'; + + // '/' is ascii 47 and base64 63 + if (v == 63) return '/'; + + return 64; +} + +unsigned char base64_to_binary(unsigned char c) { + // Capital letters - 'A' is ascii 65 and base64 0 + if ('A' <= c && c <= 'Z') return c - 'A'; + + // Lowercase letters - 'a' is ascii 97 and base64 26 + if ('a' <= c && c <= 'z') return c - 71; + + // Digits - '0' is ascii 48 and base64 52 + if ('0' <= c && c <= '9') return c + 4; + + // '+' is ascii 43 and base64 62 + if (c == '+') return 62; + + // '/' is ascii 47 and base64 63 + if (c == '/') return 63; + + return 255; +} + +uint16_t encode_base64_length(uint16_t input_length) { + return (input_length + 2)/3*4; +} + +uint16_t decode_base64_length(unsigned char input[]) { + return decode_base64_length(input, -1); +} + +uint16_t decode_base64_length(unsigned char input[], uint16_t input_length) { + unsigned char *start = input; + + while (base64_to_binary(input[0]) < 64 && (unsigned char)(input - start) < input_length) { + ++input; + } + + input_length = input - start; + return input_length/4*3 + (input_length % 4 ? input_length % 4 - 1 : 0); +} + +uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]) { + uint16_t full_sets = input_length/3; + + // While there are still full sets of 24 bits... + for (uint16_t i = 0; i < full_sets; ++i) { + output[0] = binary_to_base64( input[0] >> 2); + output[1] = binary_to_base64((input[0] & 0x03) << 4 | input[1] >> 4); + output[2] = binary_to_base64((input[1] & 0x0F) << 2 | input[2] >> 6); + output[3] = binary_to_base64( input[2] & 0x3F); + + input += 3; + output += 4; + } + + switch(input_length % 3) { + case 0: + output[0] = '\0'; + break; + case 1: + output[0] = binary_to_base64( input[0] >> 2); + output[1] = binary_to_base64((input[0] & 0x03) << 4); + output[2] = '='; + output[3] = '='; + output[4] = '\0'; + break; + case 2: + output[0] = binary_to_base64( input[0] >> 2); + output[1] = binary_to_base64((input[0] & 0x03) << 4 | input[1] >> 4); + output[2] = binary_to_base64((input[1] & 0x0F) << 2); + output[3] = '='; + output[4] = '\0'; + break; + } + + return encode_base64_length(input_length); +} + +uint16_t decode_base64(unsigned char input[], unsigned char output[]) { + return decode_base64(input, -1, output); +} + +uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]) { + uint16_t output_length = decode_base64_length(input, input_length); + + // While there are still full sets of 24 bits... + for (uint16_t i = 2; i < output_length; i += 3) { + output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4; + output[1] = base64_to_binary(input[1]) << 4 | base64_to_binary(input[2]) >> 2; + output[2] = base64_to_binary(input[2]) << 6 | base64_to_binary(input[3]); + + input += 4; + output += 3; + } + + switch(output_length % 3) { + case 1: + output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4; + break; + case 2: + output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4; + output[1] = base64_to_binary(input[1]) << 4 | base64_to_binary(input[2]) >> 2; + break; + } + + return output_length; +} + +#endif // ifndef diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp similarity index 50% rename from Marlin/src/lcd/e3v2/enhanced/dwin.cpp rename to Marlin/src/lcd/e3v2/proui/dwin.cpp index d1a9ba7077fd..c98fd6a0e150 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -21,17 +21,19 @@ */ /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.7.1 - * Date: 2021/11/09 + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.17.2 + * Date: 2022/04/08 */ -#include "../../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfig.h" -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#if ENABLED(DWIN_LCD_PROUI) #include "dwin.h" +#include "menus.h" +#include "dwin_popup.h" #include "../../fontutils.h" #include "../../marlinui.h" @@ -62,6 +64,10 @@ #include "../../../feature/host_actions.h" #endif +#if DISABLED(PROBE_MANUALLY) && ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT) + #define HAS_ONESTEP_LEVELING 1 +#endif + #if HAS_MESH || HAS_ONESTEP_LEVELING #include "../../../feature/bedlevel/bedlevel.h" #endif @@ -70,18 +76,56 @@ #include "../../../module/probe.h" #endif -#if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) - #include "../../../feature/babystep.h" +#ifdef BLTOUCH_HS_MODE + #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 #endif #if ENABLED(POWER_LOSS_RECOVERY) #include "../../../feature/powerloss.h" #endif +#if HAS_ESDIAG + #include "endstop_diag.h" +#endif + +#if HAS_PIDPLOT + #include "plot.h" +#endif + +#if HAS_GCODE_PREVIEW + #include "gcode_preview.h" +#endif + #if HAS_MESH #include "meshviewer.h" #endif +#if ENABLED(AUTO_BED_LEVELING_UBL) + #include "ubl_tools.h" +#endif + +#if ENABLED(PRINTCOUNTER) + #include "printstats.h" +#endif + +#if ENABLED(CASE_LIGHT_MENU) + #include "../../../feature/caselight.h" +#endif + +#if ENABLED(LED_CONTROL_MENU) + #include "../../../feature/leds/leds.h" +#endif + #include #include #include @@ -92,10 +136,6 @@ #include "lockscreen.h" -#ifndef CORP_WEBSITE - #define CORP_WEBSITE WEBSITE_URL -#endif - #define PAUSE_HEAT #define MENU_CHAR_LIMIT 24 @@ -111,29 +151,26 @@ // Load and Unload limits #define MAX_LOAD_UNLOAD 500 -// Feedspeed limit (max feedspeed = DEFAULT_MAX_FEEDRATE * 2) +// Feedspeed limit (max feedspeed = MAX_FEEDRATE_EDIT_VALUES) #define MIN_MAXFEEDSPEED 1 #define MIN_MAXACCELERATION 1 #define MIN_MAXJERK 0.1 #define MIN_STEP 1 #define MAX_STEP 999.9 -// Extruder's temperature limits -#define MIN_ETEMP HEATER_0_MINTEMP -#define MAX_ETEMP (HEATER_0_MAXTEMP - HOTEND_OVERSHOOT) +// Editable temperature limits +#define MIN_ETEMP 0 +#define MAX_ETEMP (HEATER_0_MAXTEMP - (HOTEND_OVERSHOOT)) +#define MIN_BEDTEMP 0 +#define MAX_BEDTEMP BED_MAX_TARGET #define FEEDRATE_E (60) -// Minimum unit (0.1) : multiple (10) -#define UNITFDIGITS 1 -#define MINUNITMULT POW(10, UNITFDIGITS) - -#define ENCODER_WAIT_MS 20 #define DWIN_VAR_UPDATE_INTERVAL 1024 #define DWIN_SCROLL_UPDATE_INTERVAL SEC_TO_MS(2) #define DWIN_REMAIN_TIME_UPDATE_INTERVAL SEC_TO_MS(20) -#define BABY_Z_VAR TERN(HAS_BED_PROBE, probe.offset.z, dwin_zoffset) +#define BABY_Z_VAR TERN(HAS_BED_PROBE, probe.offset.z, HMI_data.ManualZOffset) // Structs HMI_value_t HMI_value; @@ -148,7 +185,7 @@ enum SelectItem : uint8_t { PAGE_PRINT = 0, PAGE_PREPARE, PAGE_CONTROL, - PAGE_INFO_LEVELING, + PAGE_ADVANCE, PAGE_COUNT, PRINT_SETUP = 0, @@ -169,14 +206,13 @@ typedef struct { select_t select_page{0}, select_file{0}, select_print{0}; uint8_t index_file = MROWS; -bool dwin_abort_flag = false; // Flag to reset feedrate, return to Home bool hash_changed = true; // Flag to know if message status was changed -constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE; -constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION; +constexpr float max_feedrate_edit_values[] = MAX_FEEDRATE_EDIT_VALUES; +constexpr float max_acceleration_edit_values[] = MAX_ACCEL_EDIT_VALUES; #if HAS_CLASSIC_JERK - constexpr float default_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK }; + constexpr float max_jerk_edit_values[] = MAX_JERK_EDIT_VALUES; #endif static uint8_t _percent_done = 0; @@ -185,29 +221,13 @@ static uint32_t _remain_time = 0; // Additional Aux Host Support static bool sdprint = false; -#if ENABLED(PAUSE_HEAT) - #if HAS_HOTEND - celsius_t resume_hotend_temp = 0; - #endif - #if HAS_HEATED_BED - celsius_t resume_bed_temp = 0; - #endif - #if HAS_FAN - uint16_t resume_fan = 0; - #endif -#endif - -#if HAS_ZOFFSET_ITEM - float dwin_zoffset = 0, last_zoffset = 0; -#endif - #if HAS_HOTEND float last_E = 0; #endif // New menu system pointers MenuClass *PrepareMenu = nullptr; -MenuClass *LevBedMenu = nullptr; +MenuClass *TrammingMenu = nullptr; MenuClass *MoveMenu = nullptr; MenuClass *ControlMenu = nullptr; MenuClass *AdvancedSettings = nullptr; @@ -236,15 +256,34 @@ MenuClass *MaxJerkMenu = nullptr; MenuClass *StepsMenu = nullptr; MenuClass *HotendPIDMenu = nullptr; MenuClass *BedPIDMenu = nullptr; -#if EITHER(HAS_BED_PROBE, BABYSTEPPING) +#if ENABLED(CASELIGHT_USES_BRIGHTNESS) + MenuClass *CaseLightMenu = nullptr; +#endif +#if ENABLED(LED_CONTROL_MENU) + MenuClass *LedControlMenu = nullptr; +#endif +#if HAS_BED_PROBE MenuClass *ZOffsetWizMenu = nullptr; #endif +#if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) + MenuClass *HomingMenu = nullptr; +#endif +#if ENABLED(FWRETRACT) + MenuClass *FWRetractMenu = nullptr; +#endif +#if HAS_MESH + MenuClass *MeshMenu = nullptr; + #if ENABLED(MESH_EDIT_MENU) + MenuClass *EditMeshMenu = nullptr; + #endif +#endif // Updatable menuitems pointers MenuItemClass *HotendTargetItem = nullptr; MenuItemClass *BedTargetItem = nullptr; MenuItemClass *FanSpeedItem = nullptr; MenuItemClass *MMeshMoveZItem = nullptr; +MenuItemClass *EditZValueItem = nullptr; #define DWIN_LANGUAGE_EEPROM_ADDRESS 0x01 // Between 0x01 and 0x63 (EEPROM_OFFSET-1) // BL24CXX::check() uses 0x00 @@ -270,13 +309,23 @@ void HMI_ToggleLanguage() { #endif } +//----------------------------------------------------------------------------- +// Main Buttons +//----------------------------------------------------------------------------- + typedef struct { uint16_t x, y[2], w, h; } text_info_t; -void ICON_Button(const bool here, const int iconid, const frame_rect_t &ico, const text_info_t (&txt)[2]) { - const bool cn = HMI_IsChinese(); - DWIN_ICON_Show(true, false, false, ICON, iconid + here, ico.x, ico.y); - if (here) DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, ico.x, ico.y, ico.x + ico.w - 1, ico.y + ico.h - 1); - DWIN_Frame_AreaCopy(1, txt[cn].x, txt[cn].y[here], txt[cn].x + txt[cn].w - 1, txt[cn].y[here] + txt[cn].h - 1, ico.x + (ico.w - txt[cn].w) / 2, (ico.y + ico.h - 28) - txt[cn].h/2); +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); + 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); + } + else { + const uint16_t x = ico.x + (ico.w - strlen_P(FTOP(caption)) * DWINUI::fontWidth()) / 2, + y = (ico.y + ico.h - 20) - DWINUI::fontHeight() / 2; + DWINUI::Draw_String(x, y, caption); + } } // @@ -284,11 +333,8 @@ void ICON_Button(const bool here, const int iconid, const frame_rect_t &ico, con // void ICON_Print() { constexpr frame_rect_t ico = { 17, 110, 110, 100 }; - constexpr text_info_t txt[2] = { - { 1, { 417, 449 }, 30, 14 }, - { 1, { 405, 447 }, 27, 15 } - }; - ICON_Button(select_page.now == PAGE_PRINT, ICON_Print_0, ico, txt); + constexpr text_info_t txt = { 1, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; + ICON_Button(select_page.now == PAGE_PRINT, ICON_Print_0, ico, txt, GET_TEXT_F(MSG_BUTTON_PRINT)); } // @@ -296,11 +342,8 @@ void ICON_Print() { // void ICON_Prepare() { constexpr frame_rect_t ico = { 145, 110, 110, 100 }; - constexpr text_info_t txt[2] = { - { 33, { 417, 449 }, 51, 14 }, - { 31, { 405, 447 }, 27, 15 } - }; - ICON_Button(select_page.now == PAGE_PREPARE, ICON_Prepare_0, ico, txt); + constexpr text_info_t txt = { 31, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; + ICON_Button(select_page.now == PAGE_PREPARE, ICON_Prepare_0, ico, txt, GET_TEXT_F(MSG_PREPARE)); } // @@ -308,35 +351,17 @@ void ICON_Prepare() { // void ICON_Control() { constexpr frame_rect_t ico = { 17, 226, 110, 100 }; - constexpr text_info_t txt[2] = { - { 85, { 417, 449 }, 46, 14 }, - { 61, { 405, 447 }, 27, 15 } - }; - ICON_Button(select_page.now == PAGE_CONTROL, ICON_Control_0, ico, txt); -} - -// -// Main Menu: "Info" -// -void ICON_StartInfo() { - constexpr frame_rect_t ico = { 145, 226, 110, 100 }; - constexpr text_info_t txt[2] = { - { 133, { 417, 449 }, 23, 14 }, - { 91, { 405, 447 }, 27, 15 } - }; - ICON_Button(select_page.now == PAGE_INFO_LEVELING, ICON_Info_0, ico, txt); + constexpr text_info_t txt = { 61, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; + ICON_Button(select_page.now == PAGE_CONTROL, ICON_Control_0, ico, txt, GET_TEXT_F(MSG_CONTROL)); } // -// Main Menu: "Level" +// Main Menu: "Advanced Settings" // -void ICON_Leveling() { +void ICON_AdvSettings() { constexpr frame_rect_t ico = { 145, 226, 110, 100 }; - constexpr text_info_t txt[2] = { - { 88, { 433, 464 }, 36, 14 }, - { 211, { 405, 447 }, 27, 15 } - }; - ICON_Button(select_page.now == PAGE_INFO_LEVELING, ICON_Leveling_0, ico, txt); + constexpr text_info_t txt = { 91, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; + ICON_Button(select_page.now == PAGE_ADVANCE, ICON_Info_0, ico, txt, GET_TEXT_F(MSG_BUTTON_ADVANCED)); } // @@ -344,11 +369,8 @@ void ICON_Leveling() { // void ICON_Tune() { constexpr frame_rect_t ico = { 8, 232, 80, 100 }; - constexpr text_info_t txt[2] = { - { 0, { 433, 464 }, 32, 14 }, - { 121, { 405, 447 }, 27, 15 } - }; - ICON_Button(select_print.now == PRINT_SETUP, ICON_Setup_0, ico, txt); + constexpr text_info_t txt = { 121, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; + ICON_Button(select_print.now == PRINT_SETUP, ICON_Setup_0, ico, txt, GET_TEXT_F(MSG_TUNE)); } // @@ -356,11 +378,8 @@ void ICON_Tune() { // void ICON_Pause() { constexpr frame_rect_t ico = { 96, 232, 80, 100 }; - constexpr text_info_t txt[2] = { - { 157, { 417, 449 }, 39, 14 }, - { 181, { 405, 447 }, 27, 15 } - }; - ICON_Button(select_print.now == PRINT_PAUSE_RESUME, ICON_Pause_0, ico, txt); + constexpr text_info_t txt = { 181, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; + ICON_Button(select_print.now == PRINT_PAUSE_RESUME, ICON_Pause_0, ico, txt, GET_TEXT_F(MSG_BUTTON_PAUSE)); } // @@ -368,11 +387,8 @@ void ICON_Pause() { // void ICON_Resume() { constexpr frame_rect_t ico = { 96, 232, 80, 100 }; - constexpr text_info_t txt[2] = { - { 33, { 433, 464 }, 53, 14 }, - { 1, { 405, 447 }, 27, 15 } - }; - ICON_Button(select_print.now == PRINT_PAUSE_RESUME, ICON_Continue_0, ico, txt); + constexpr text_info_t txt = { 1, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 15 }; + ICON_Button(select_print.now == PRINT_PAUSE_RESUME, ICON_Continue_0, ico, txt, GET_TEXT_F(MSG_BUTTON_RESUME)); } // @@ -380,20 +396,13 @@ void ICON_Resume() { // void ICON_Stop() { constexpr frame_rect_t ico = { 184, 232, 80, 100 }; - constexpr text_info_t txt[2] = { - { 196, { 417, 449 }, 29, 14 }, - { 151, { 405, 447 }, 27, 12 } - }; - ICON_Button(select_print.now == PRINT_STOP, ICON_Stop_0, ico, txt); + constexpr text_info_t txt = { 151, { 405, TERN(USE_STOCK_DWIN_SET, 446, 447) }, 27, 12 }; + ICON_Button(select_print.now == PRINT_STOP, ICON_Stop_0, ico, txt, GET_TEXT_F(MSG_BUTTON_STOP)); } -void Draw_Menu_Cursor(const int8_t line) { - DWIN_Draw_Rectangle(1, HMI_data.Cursor_color, 0, MBASE(line) - 18, 14, MBASE(line + 1) - 20); -} - -void Erase_Menu_Cursor(const int8_t line) { - DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, MBASE(line) - 18, 14, MBASE(line + 1) - 20); -} +//----------------------------------------------------------------------------- +// Drawing routines +//----------------------------------------------------------------------------- void Move_Highlight(const int8_t from, const int8_t newline) { Erase_Menu_Cursor(newline - from); @@ -402,7 +411,7 @@ void Move_Highlight(const int8_t from, const int8_t newline) { void Add_Menu_Line() { Move_Highlight(1, MROWS); - DWIN_Draw_Line(HMI_data.SplitLine_Color, 16, MBASE(MROWS + 1) - 20, 256, MBASE(MROWS + 1) - 19); + DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(MROWS + 1), 240); } void Scroll_Menu(const uint8_t dir) { @@ -421,98 +430,31 @@ void Erase_Menu_Text(const uint8_t line) { DWIN_Draw_Rectangle(1, HMI_data.Background_Color, LBLX, MBASE(line) - 14, 271, MBASE(line) + 28); } -void Draw_Menu_Line(const uint8_t line, const uint8_t icon=0, const char * const label=nullptr, bool more=false) { - if (label) DWINUI::Draw_String(LBLX, MBASE(line) - 1, (char*)label); - if (icon) DWINUI::Draw_Icon(icon, 26, MBASE(line) - 3); - if (more) DWINUI::Draw_Icon(ICON_More, 226, MBASE(line) - 3); - DWIN_Draw_Line(HMI_data.SplitLine_Color, 16, MBASE(line) + 33, 256, MBASE(line) + 33); -} - -void Draw_Chkb_Line(const uint8_t line, const bool checked) { - DWINUI::Draw_Checkbox(HMI_data.Text_Color, HMI_data.Background_Color, VALX + 16, MBASE(line) - 1, checked); -} - -void Draw_Menu_IntValue(uint16_t bcolor, const uint8_t line, uint8_t iNum, const uint16_t value=0) { - DWINUI::Draw_Int(HMI_data.Text_Color, bcolor, iNum , VALX, MBASE(line) - 1, value); -} - -// The "Back" label is always on the first line -void Draw_Back_Label() { - if (HMI_IsChinese()) - DWIN_Frame_AreaCopy(1, 129, 72, 156, 84, LBLX, MBASE(0)); - else - DWIN_Frame_AreaCopy(1, 223, 179, 254, 189, LBLX, MBASE(0)); -} - // Draw "Back" line at the top void Draw_Back_First(const bool is_sel=true) { Draw_Menu_Line(0, ICON_Back); - Draw_Back_Label(); + 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); } -inline EncoderState get_encoder_state() { - static millis_t Encoder_ms = 0; - const millis_t ms = millis(); - if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO; - const EncoderState state = Encoder_ReceiveAnalyze(); - if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS; - return state; -} - -template -inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) { - if (encoder_diffState == ENCODER_DIFF_CW) - valref += EncoderRate.encoderMoveValue; - else if (encoder_diffState == ENCODER_DIFF_CCW) - valref -= EncoderRate.encoderMoveValue; - return encoder_diffState == ENCODER_DIFF_ENTER; -} - -// -// Draw Popup Windows -// - -inline void Draw_Popup_Bkgd_60() { - DWIN_Draw_Rectangle(1, HMI_data.PopupBg_color, 14, 60, 258, 330); - DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, 14, 60, 258, 330); -} - -inline void Draw_Popup_Bkgd_105() { - DWIN_Draw_Rectangle(1, HMI_data.PopupBg_color, 14, 105, 258, 374); - DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, 14, 105, 258, 374); -} - -void Clear_Popup_Area() { - DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, 31, DWIN_WIDTH, DWIN_HEIGHT); -} - -void DWIN_Draw_Popup1(const uint8_t icon) { - DWINUI::ClearMenuArea(); - Draw_Popup_Bkgd_60(); - if (icon) DWINUI::Draw_Icon(icon, 101, 105); -} -void DWIN_Draw_Popup2(FSTR_P const fmsg2, uint8_t button) { - if (fmsg2) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 240, fmsg2); - if (button) DWINUI::Draw_Icon(button, 86, 280); -} - -void DWIN_Draw_Popup(const uint8_t icon, const char * const cmsg1, FSTR_P const fmsg2, uint8_t button) { - DWIN_Draw_Popup1(icon); - if (cmsg1) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 210, cmsg1); - DWIN_Draw_Popup2(fmsg2, button); -} - -void DWIN_Draw_Popup(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2, uint8_t button) { - DWIN_Draw_Popup1(icon); - if (fmsg1) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 210, fmsg1); - DWIN_Draw_Popup2(fmsg2, button); -} - -void DWIN_Popup_Continue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2) { - HMI_SaveProcessID(WaitResponse); - DWIN_Draw_Popup(icon, fmsg1, fmsg2, ICON_Continue_E); // Button Continue - DWIN_UpdateLCD(); +//PopUps +void Popup_window_PauseOrStop() { + if (HMI_IsChinese()) { + DWINUI::ClearMainArea(); + Draw_Popup_Bkgd(); + if (select_print.now == PRINT_PAUSE_RESUME) DWIN_Frame_AreaCopy(1, 237, 338, 269, 356, 98, 150); + else if (select_print.now == PRINT_STOP) DWIN_Frame_AreaCopy(1, 221, 320, 253, 336, 98, 150); + DWIN_Frame_AreaCopy(1, 220, 304, 264, 319, 130, 150); + DWINUI::Draw_IconWB(ICON_Confirm_C, 26, 280); + DWINUI::Draw_IconWB(ICON_Cancel_C, 146, 280); + Draw_Select_Highlight(true); + DWIN_UpdateLCD(); + } + else + DWIN_Popup_ConfirmCancel(ICON_BLTouch, select_print.now == PRINT_PAUSE_RESUME ? GET_TEXT_F(MSG_PAUSE_PRINT) : GET_TEXT_F(MSG_STOP_PRINT)); } #if HAS_HOTEND @@ -520,108 +462,51 @@ void DWIN_Popup_Continue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fm void Popup_Window_ETempTooLow() { if (HMI_IsChinese()) { HMI_SaveProcessID(WaitResponse); - DWINUI::ClearMenuArea(); - Draw_Popup_Bkgd_60(); + DWINUI::ClearMainArea(); + Draw_Popup_Bkgd(); DWINUI::Draw_Icon(ICON_TempTooLow, 102, 105); DWIN_Frame_AreaCopy(1, 103, 371, 136, 386, 69, 240); DWIN_Frame_AreaCopy(1, 170, 371, 270, 386, 102, 240); - DWINUI::Draw_Icon(ICON_Confirm_C, 86, 280); + DWINUI::Draw_IconWB(ICON_Confirm_C, 86, 280); DWIN_UpdateLCD(); } else - DWIN_Popup_Confirm(ICON_TempTooLow, F("Nozzle is too cold"), F("Preheat the hotend")); + DWIN_Popup_Confirm(ICON_TempTooLow, GET_TEXT_F(MSG_HOTEND_TOO_COLD), GET_TEXT_F(MSG_PLEASE_PREHEAT)); } #endif -void Popup_Window_Resume() { - Clear_Popup_Area(); - Draw_Popup_Bkgd_105(); - if (HMI_IsChinese()) { - DWIN_Frame_AreaCopy(1, 160, 338, 235, 354, 98, 135); - DWIN_Frame_AreaCopy(1, 103, 321, 271, 335, 52, 192); - DWINUI::Draw_Icon(ICON_Cancel_C, 26, 307); - DWINUI::Draw_Icon(ICON_Continue_C, 146, 307); - } - else { - DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 115, F("Continue Print")); - DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 192, F("It looks like the last")); - DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 212, F("file was interrupted.")); - DWINUI::Draw_Icon(ICON_Cancel_E, 26, 307); - DWINUI::Draw_Icon(ICON_Continue_E, 146, 307); - } -} - -void Draw_Select_Highlight(const bool sel) { - 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; - 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 Popup_window_PauseOrStop() { - if (HMI_IsChinese()) { - DWINUI::ClearMenuArea(); - Draw_Popup_Bkgd_60(); - if (select_print.now == PRINT_PAUSE_RESUME) DWIN_Frame_AreaCopy(1, 237, 338, 269, 356, 98, 150); - else if (select_print.now == PRINT_STOP) DWIN_Frame_AreaCopy(1, 221, 320, 253, 336, 98, 150); - DWIN_Frame_AreaCopy(1, 220, 304, 264, 319, 130, 150); - DWINUI::Draw_Icon(ICON_Confirm_C, 26, 280); - DWINUI::Draw_Icon(ICON_Cancel_C, 146, 280); - } - else { - DWIN_Draw_Popup(ICON_BLTouch, F("Please confirm"), select_print.now == PRINT_PAUSE_RESUME ? GET_TEXT_F(MSG_PAUSE_PRINT) : GET_TEXT_F(MSG_STOP_PRINT)); - DWINUI::Draw_Icon(ICON_Confirm_E, 26, 280); - DWINUI::Draw_Icon(ICON_Cancel_E, 146, 280); - } - Draw_Select_Highlight(true); - DWIN_UpdateLCD(); -} - #if HAS_HOTEND || HAS_HEATED_BED void DWIN_Popup_Temperature(const bool toohigh) { - Clear_Popup_Area(); - Draw_Popup_Bkgd_105(); - if (toohigh) { - DWINUI::Draw_Icon(ICON_TempTooHigh, 102, 165); - if (HMI_IsChinese()) { + HMI_SaveProcessID(WaitResponse); + if (HMI_IsChinese()) { + DWINUI::ClearMainArea(); + Draw_Popup_Bkgd(); + if (toohigh) { + DWINUI::Draw_Icon(ICON_TempTooHigh, 102, 165); DWIN_Frame_AreaCopy(1, 103, 371, 237, 386, 52, 285); DWIN_Frame_AreaCopy(1, 151, 389, 185, 402, 187, 285); DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); } else { - DWINUI::Draw_String(HMI_data.PopupTxt_Color, 36, 300, F("Nozzle or Bed temperature")); - DWINUI::Draw_String(HMI_data.PopupTxt_Color, 92, 300, F("is too high")); - } - } - else { - DWINUI::Draw_Icon(ICON_TempTooLow, 102, 165); - if (HMI_IsChinese()) { + DWINUI::Draw_Icon(ICON_TempTooLow, 102, 165); DWIN_Frame_AreaCopy(1, 103, 371, 270, 386, 52, 285); DWIN_Frame_AreaCopy(1, 189, 389, 271, 402, 95, 310); } - else { - DWINUI::Draw_String(HMI_data.PopupTxt_Color, 36, 300, F("Nozzle or Bed temperature")); - DWINUI::Draw_String(HMI_data.PopupTxt_Color, 92, 300, F("is too low")); - } } + 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 uint16_t color, const uint16_t bgcolor, const char *text, const bool center = true) { - DWIN_Draw_Rectangle(1, bgcolor, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); - if (text) { - if (center) DWINUI::Draw_CenteredString(color, STATUS_Y + 2, text); - else DWINUI::Draw_String(color, 0, STATUS_Y + 2, text); - } - DWIN_UpdateLCD(); +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(const char *text, const bool center = true) { - DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, text, center); + +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); } // Clear & reset status line @@ -642,17 +527,15 @@ void DWIN_CheckStatusMessage() { }; void DWIN_DrawStatusMessage() { - const uint8_t max_status_chars = DWIN_WIDTH / DWINUI::fontWidth(DWINUI::font); - #if ENABLED(STATUS_MESSAGE_SCROLLING) // Get the UTF8 character count of the string uint8_t slen = utf8_strlen(ui.status_message); // If the string fits the status line do not scroll it - if (slen <= max_status_chars) { + if (slen <= LCD_WIDTH) { if (hash_changed) { - DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, ui.status_message); + DWIN_DrawStatusLine(ui.status_message); hash_changed = false; } } @@ -665,16 +548,16 @@ void DWIN_DrawStatusMessage() { const char *stat = MarlinUI::status_and_len(rlen); DWIN_Draw_Rectangle(1, HMI_data.StatusBg_Color, 0, STATUS_Y, DWIN_WIDTH, STATUS_Y + 20); DWINUI::MoveTo(0, STATUS_Y + 2); - DWINUI::Draw_String(stat, max_status_chars); + DWINUI::Draw_String(HMI_data.StatusTxt_Color, stat, LCD_WIDTH); // If the string doesn't completely fill the line... - if (rlen < max_status_chars) { - DWINUI::Draw_Char('.'); // Always at 1+ spaces left, draw a dot - uint8_t chars = max_status_chars - rlen; // Amount of space left in characters + 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 - DWINUI::Draw_Char('.'); + DWINUI::Draw_Char(HMI_data.StatusTxt_Color, '.'); if (--chars) - DWINUI::Draw_String(ui.status_message, chars); // Print a second copy of the message + DWINUI::Draw_String(HMI_data.StatusTxt_Color, ui.status_message, chars); // Print a second copy of the message } } MarlinUI::advance_status_scroll(); @@ -683,8 +566,8 @@ void DWIN_DrawStatusMessage() { #else if (hash_changed) { - ui.status_message[max_status_chars] = 0; - DWIN_DrawStatusLine(HMI_data.StatusTxt_Color, HMI_data.StatusBg_Color, ui.status_message); + ui.status_message[LCD_WIDTH] = 0; + DWIN_DrawStatusLine(ui.status_message); hash_changed = false; } @@ -693,19 +576,17 @@ void DWIN_DrawStatusMessage() { void Draw_Print_Labels() { if (HMI_IsChinese()) { - Title.FrameCopy(30, 1, 42, 14); // "Printing" DWIN_Frame_AreaCopy(1, 0, 72, 63, 86, 41, 173); // Printing Time DWIN_Frame_AreaCopy(1, 65, 72, 128, 86, 176, 173); // Remain } else { - Title.ShowCaption(GET_TEXT(MSG_PRINTING)); - DWINUI::Draw_String( 46, 173, F("Print Time")); - DWINUI::Draw_String(181, 173, F("Remain")); + DWINUI::Draw_String( 46, 173, GET_TEXT_F(MSG_INFO_PRINT_TIME)); + DWINUI::Draw_String(181, 173, GET_TEXT_F(MSG_REMAINING_TIME)); } } void Draw_Print_ProgressBar() { - DWINUI::Draw_Icon(ICON_Bar, 15, 93); + DWIN_ICON_Show(true, false, false, ICON, 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("%")); @@ -714,47 +595,61 @@ void Draw_Print_ProgressBar() { void Draw_Print_ProgressElapsed() { char buf[10]; duration_t elapsed = print_job_timer.duration(); // print timer - sprintf_P(buf, PSTR("%02i:%02i"), (uint16_t)(elapsed.value / 3600), ((uint16_t)elapsed.value % 3600) / 60); + sprintf_P(buf, PSTR("%02i:%02i "), (uint16_t)(elapsed.value / 3600), ((uint16_t)elapsed.value % 3600) / 60); DWINUI::Draw_String(HMI_data.Text_Color, HMI_data.Background_Color, 47, 192, buf); } void Draw_Print_ProgressRemain() { char buf[10]; - sprintf_P(buf, PSTR("%02i:%02i"), (uint16_t)(_remain_time / 3600), ((uint16_t)_remain_time % 3600) / 60); + sprintf_P(buf, PSTR("%02i:%02i "), (uint16_t)(_remain_time / 3600), ((uint16_t)_remain_time % 3600) / 60); DWINUI::Draw_String(HMI_data.Text_Color, HMI_data.Background_Color, 181, 192, buf); } void ICON_ResumeOrPause() { - if (printingIsPaused() || HMI_flag.pause_flag || HMI_flag.pause_action) - ICON_Resume(); - else - ICON_Pause(); + if (checkkey == PrintProcess) printingIsPaused() ? ICON_Resume() : ICON_Pause(); } -void Draw_PrintProcess() { - DWINUI::ClearMenuArea(); - Draw_Print_Labels(); - - ICON_Tune(); - ICON_ResumeOrPause(); - ICON_Stop(); +// Update filename on print +void DWIN_Print_Header(const char *text = nullptr) { + static char headertxt[31] = ""; // Print header text + if (text) { + const int8_t size = _MIN(30U, strlen_P(text)); + LOOP_L_N(i, size) headertxt[i] = text[i]; + headertxt[size] = '\0'; + } + if (checkkey == PrintProcess || checkkey == PrintDone) { + DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, 60, DWIN_WIDTH, 60+16); + DWINUI::Draw_CenteredString(60, headertxt); + } +} +void Draw_PrintProcess() { + if (HMI_IsChinese()) + Title.FrameCopy(30, 1, 42, 14); // "Printing" + else + Title.ShowCaption(GET_TEXT_F(MSG_PRINTING)); + DWINUI::ClearMainArea(); DWIN_Print_Header(sdprint ? card.longest_filename() : nullptr); - + Draw_Print_Labels(); DWINUI::Draw_Icon(ICON_PrintTime, 15, 173); DWINUI::Draw_Icon(ICON_RemainTime, 150, 171); - Draw_Print_ProgressBar(); Draw_Print_ProgressElapsed(); Draw_Print_ProgressRemain(); - - DWIN_UpdateLCD(); + ICON_Tune(); + ICON_ResumeOrPause(); + ICON_Stop(); } void Goto_PrintProcess() { - if (checkkey == PrintProcess) return; - checkkey = PrintProcess; - Draw_PrintProcess(); + if (checkkey == PrintProcess) + ICON_ResumeOrPause(); + else { + checkkey = PrintProcess; + Draw_PrintProcess(); + TERN_(DASH_REDRAW, DWIN_RedrawDash()); + } + DWIN_UpdateLCD(); } void Draw_PrintDone() { @@ -762,42 +657,52 @@ void Draw_PrintDone() { _percent_done = 100; _remain_time = 0; - DWINUI::ClearMenuArea(); + Title.ShowCaption(GET_TEXT_F(MSG_PRINT_DONE)); + DWINUI::ClearMainArea(); DWIN_Print_Header(nullptr); - Draw_Print_Labels(); - DWINUI::Draw_Icon(ICON_PrintTime, 15, 173); - DWINUI::Draw_Icon(ICON_RemainTime, 150, 171); - Draw_Print_ProgressBar(); - Draw_Print_ProgressElapsed(); - Draw_Print_ProgressRemain(); + 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 { + Draw_Print_ProgressBar(); + Draw_Print_Labels(); + DWINUI::Draw_Icon(ICON_PrintTime, 15, 173); + DWINUI::Draw_Icon(ICON_RemainTime, 150, 171); + Draw_Print_ProgressElapsed(); + Draw_Print_ProgressRemain(); + DWINUI::Draw_Button(BTN_Continue, 86, 273); + } +} - // show print done confirm - DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, 240, DWIN_WIDTH - 1, STATUS_Y - 1); - DWINUI::Draw_Icon(HMI_IsChinese() ? ICON_Confirm_C : ICON_Confirm_E, 86, 283); +void Goto_PrintDone() { + wait_for_user = true; + if (checkkey != PrintDone) { + checkkey = PrintDone; + Draw_PrintDone(); + DWIN_UpdateLCD(); + } } void Draw_Main_Menu() { - DWINUI::ClearMenuArea(); - + DWINUI::ClearMainArea(); if (HMI_IsChinese()) Title.FrameCopy(2, 2, 26, 13); // "Home" etc else Title.ShowCaption(MACHINE_NAME); - DWINUI::Draw_Icon(ICON_LOGO, 71, 52); // CREALITY logo - + DWIN_ResetStatusLine(); ICON_Print(); ICON_Prepare(); ICON_Control(); - TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(); - DWIN_UpdateLCD(); + ICON_AdvSettings(); } void Goto_Main_Menu() { if (checkkey == MainMenu) return; checkkey = MainMenu; - ui.reset_status(true); Draw_Main_Menu(); + DWIN_UpdateLCD(); } // Draw X, Y, Z and blink if in an un-homed or un-trusted state @@ -813,11 +718,11 @@ void _update_axis_value(const AxisEnum axis, const uint16_t x, const uint16_t y, if (force || changed || draw_qmark || draw_empty) { if (blink && draw_qmark) - DWINUI::Draw_String(HMI_data.Coordinate_Color, HMI_data.Background_Color, x, y, F("--?--")); + DWINUI::Draw_String(HMI_data.Coordinate_Color, HMI_data.Background_Color, x, y, F(" - ? -")); else if (blink && draw_empty) - DWINUI::Draw_String(HMI_data.Coordinate_Color, HMI_data.Background_Color, x, y, F(" ")); + DWINUI::Draw_String(HMI_data.Coordinate_Color, HMI_data.Background_Color, x, y, F(" ")); else - DWINUI::Draw_Signed_Float(HMI_data.Coordinate_Color, HMI_data.Background_Color, 3, 1, x, y, p); + DWINUI::Draw_Signed_Float(HMI_data.Coordinate_Color, HMI_data.Background_Color, 3, 2, x, y, p); } } @@ -828,9 +733,9 @@ void _draw_xyz_position(const bool force) { if (force || blink != _blink) { _blink = blink; //SERIAL_ECHOPGM(" (blink)"); - _update_axis_value(X_AXIS, 35, 459, blink, true); - _update_axis_value(Y_AXIS, 120, 459, blink, true); - _update_axis_value(Z_AXIS, 205, 459, blink, true); + _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(); } @@ -863,16 +768,13 @@ void update_variable() { if (checkkey == Menu && (CurrentMenu == TuneMenu || CurrentMenu == TemperatureMenu)) { // Tune page temperature update #if HAS_HOTEND - if (_new_hotend_target) - HotendTargetItem->draw(CurrentMenu->line(HotendTargetItem->pos)); + if (_new_hotend_target) HotendTargetItem->redraw(); #endif #if HAS_HEATED_BED - if (_new_bed_target) - BedTargetItem->draw(CurrentMenu->line(BedTargetItem->pos)); + if (_new_bed_target) BedTargetItem->redraw(); #endif #if HAS_FAN - if (_new_fanspeed) - FanSpeedItem->draw(CurrentMenu->line(FanSpeedItem->pos)); + if (_new_fanspeed) FanSpeedItem->redraw(); #endif } @@ -914,9 +816,21 @@ void update_variable() { static float _offset = 0; if (BABY_Z_VAR != _offset) { _offset = BABY_Z_VAR; - DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 210, 417, _offset); + 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); + } + #endif + _draw_xyz_position(false); } @@ -933,14 +847,15 @@ void update_variable() { #endif void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) { - char * const name = card.longest_filename(); - size_t pos = strlen(name); // index of ending nul + size_t pos = strlen(src); // index of ending nul // For files, remove the extension // which may be .gcode, .gco, or .g if (!card.flag.filenameIsDir) while (pos && src[pos] != '.') pos--; // find last '.' (stop at 0) + if (!pos) pos = strlen(src); // pos = 0 ('.' not found) restore pos + size_t len = pos; // nul or '.' if (len > maxlen) { // Keep the name short pos = len = maxlen; // move nul down @@ -957,14 +872,6 @@ void make_name_without_ext(char *dst, char *src, size_t maxlen=MENU_CHAR_LIMIT) void HMI_SDCardInit() { card.cdroot(); } -void MarlinUI::refresh() { /* Nothing to see here */ } - -#if HAS_LCD_BRIGHTNESS - void MarlinUI::_set_brightness() { DWIN_LCD_Brightness(backlight ? brightness : 0); } -#endif - -#define ICON_Folder ICON_More - #if ENABLED(SCROLL_LONG_FILENAMES) char shift_name[LONG_FILENAME_LENGTH + 1]; @@ -1014,7 +921,8 @@ void Draw_SDItem(const uint16_t item, int16_t row=-1) { // Draw the file/folder with name aligned left char str[strlen(name) + 1]; make_name_without_ext(str, name); - Draw_Menu_Line(row, card.flag.filenameIsDir ? ICON_Folder : ICON_File, str); + const uint8_t icon = card.flag.filenameIsDir ? ICON_Folder : card.fileIsBinary() ? ICON_Binary : ICON_File; + Draw_Menu_Line(row, icon, str); } #if ENABLED(SCROLL_LONG_FILENAMES) @@ -1044,7 +952,7 @@ void Redraw_SD_List() { select_file.reset(); index_file = MROWS; - DWINUI::ClearMenuArea(); // Leave title bar unchanged + DWINUI::ClearMainArea(); // Leave title bar unchanged Draw_Back_First(); @@ -1057,7 +965,7 @@ void Redraw_SD_List() { } else { DWIN_Draw_Rectangle(1, HMI_data.AlertBg_Color, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4)); - DWINUI::Draw_CenteredString(font16x32, HMI_data.AlertTxt_Color, MBASE(3), F("No Media")); + DWINUI::Draw_CenteredString(font12x24, HMI_data.AlertTxt_Color, MBASE(3), GET_TEXT_F(MSG_MEDIA_NOT_INSERTED)); } } @@ -1083,21 +991,18 @@ void HMI_SDCardUpdate() { 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) { + if (DWIN_lcd_sd_status) { // Media inserted if (checkkey == SelectFile) Redraw_SD_List(); } - else { + else { // Media removed // clean file icon if (checkkey == SelectFile) { Redraw_SD_List(); } else if (sdprint && card.isPrinting() && printingIsActive()) { - // TODO: Move card removed abort handling - // to CardReader::manage_media. - card.abortFilePrintSoon(); wait_for_heatup = wait_for_user = false; - dwin_abort_flag = true; // Reset feedrate, return to Home + HMI_flag.abort_flag = true; // Abort print } } DWIN_UpdateLCD(); @@ -1105,10 +1010,10 @@ void HMI_SDCardUpdate() { } // -// The status area is always on-screen, except during -// full-screen modal dialogs. (TODO: Keep alive during dialogs) +// The Dashboard is always on-screen, except during +// full-screen modal dialogs. // -void Draw_Status_Area(const bool with_update) { +void DWIN_Draw_Dashboard() { DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, STATUS_Y + 21, DWIN_WIDTH, DWIN_HEIGHT - 1); @@ -1127,7 +1032,7 @@ void Draw_Status_Area(const bool with_update) { DWINUI::Draw_Icon(ICON_BedTemp, 10, 416); DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 28, 417, thermalManager.wholeDegBed()); DWINUI::Draw_String(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 25 + 3 * STAT_CHR_W + 5, 417, F("/")); - DWINUI::Draw_Int(true, true, 0, DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.degTargetBed()); + DWINUI::Draw_Int(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.degTargetBed()); #endif DWINUI::Draw_Icon(ICON_Speed, 113, 383); @@ -1139,11 +1044,11 @@ void Draw_Status_Area(const bool with_update) { 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 HAS_ZOFFSET_ITEM - DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); + #if BOTH(BABYSTEPPING, HAS_BED_PROBE) + DWINUI::Draw_Icon(planner.leveling_active ? ICON_SetZOffset : ICON_Zoffset, 187, 416); #endif - DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 210, 417, BABY_Z_VAR); + DWINUI::Draw_Signed_Float(DWIN_FONT_STAT, HMI_data.Indicator_Color, HMI_data.Background_Color, 2, 2, 204, 417, BABY_Z_VAR); DWIN_Draw_Rectangle(1, HMI_data.SplitLine_Color, 0, 449, DWIN_WIDTH, 451); @@ -1152,47 +1057,35 @@ void Draw_Status_Area(const bool with_update) { DWINUI::Draw_Icon(ICON_MaxSpeedZ, 180, 456); _draw_xyz_position(true); - if (with_update) { - DWIN_UpdateLCD(); - delay(5); - } -} - -void HMI_StartFrame(const bool with_update) { - Goto_Main_Menu(); - DWIN_DrawStatusLine(nullptr); - Draw_Status_Area(with_update); } void Draw_Info_Menu() { - DWINUI::ClearMenuArea(); + DWINUI::ClearMainArea(); Draw_Back_First(); - - DWINUI::Draw_CenteredString(122, F(MACHINE_SIZE)); - DWINUI::Draw_CenteredString(195, F(SHORT_BUILD_VERSION)); - - if (HMI_IsChinese()) { + if (HMI_IsChinese()) Title.FrameCopy(30, 17, 28, 13); // "Info" + else + Title.ShowCaption(GET_TEXT_F(MSG_INFO_SCREEN)); + if (HMI_IsChinese()) { DWIN_Frame_AreaCopy(1, 197, 149, 252, 161, 108, 102); // "Size" DWIN_Frame_AreaCopy(1, 1, 164, 56, 176, 108, 175); // "Firmware Version" DWIN_Frame_AreaCopy(1, 58, 164, 113, 176, 105, 248); // "Contact Details" + DWINUI::Draw_CenteredString(268, F(CORP_WEBSITE)); } else { - Title.ShowCaption(GET_TEXT_F(MSG_INFO_SCREEN)); - - DWIN_Frame_AreaCopy(1, 120, 150, 146, 161, 124, 102); // "Size" - DWIN_Frame_AreaCopy(1, 146, 151, 254, 161, 82, 175); // "Firmware Version" - DWIN_Frame_AreaCopy(1, 1, 164, 96, 175, 89, 248); // "Contact details" + DWINUI::Draw_CenteredString(102, F("Size")); + DWINUI::Draw_CenteredString(175, F("Firmware version")); + DWINUI::Draw_CenteredString(248, F("Build Datetime")); + DWINUI::Draw_CenteredString(268, F(STRING_DISTRIBUTION_DATE)); } - DWINUI::Draw_CenteredString(268, F(CORP_WEBSITE)); + DWINUI::Draw_CenteredString(122, F(MACHINE_SIZE)); + DWINUI::Draw_CenteredString(195, F(SHORT_BUILD_VERSION)); LOOP_L_N(i, 3) { - DWINUI::Draw_Icon(ICON_PrintSize + i, 26, 99 + i * 73); + DWINUI::Draw_Icon(ICON_PrintSize + i, ICOX, 99 + i * 73); DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MBASE(2) + i * 73, 240); } - - DWIN_UpdateLCD(); } void Draw_Print_File_Menu() { @@ -1201,6 +1094,7 @@ void Draw_Print_File_Menu() { else Title.ShowCaption(GET_TEXT_F(MSG_MEDIA_MENU)); Redraw_SD_List(); + TERN_(DASH_REDRAW, DWIN_RedrawDash()); } // Main Process @@ -1214,7 +1108,7 @@ void HMI_MainMenu() { case PAGE_PRINT: ICON_Print(); break; case PAGE_PREPARE: ICON_Print(); ICON_Prepare(); break; case PAGE_CONTROL: ICON_Prepare(); ICON_Control(); break; - case PAGE_INFO_LEVELING: ICON_Control(); TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(); break; + case PAGE_ADVANCE: ICON_Control(); ICON_AdvSettings(); break; } } } @@ -1223,8 +1117,8 @@ void HMI_MainMenu() { switch (select_page.now) { case PAGE_PRINT: ICON_Print(); ICON_Prepare(); break; case PAGE_PREPARE: ICON_Prepare(); ICON_Control(); break; - case PAGE_CONTROL: ICON_Control(); TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(); break; - case PAGE_INFO_LEVELING: TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)(); break; + case PAGE_CONTROL: ICON_Control(); ICON_AdvSettings(); break; + case PAGE_ADVANCE: ICON_AdvSettings(); break; } } } @@ -1232,21 +1126,13 @@ void HMI_MainMenu() { switch (select_page.now) { case PAGE_PRINT: checkkey = SelectFile; + card.mount(); + safe_delay(300); Draw_Print_File_Menu(); break; - case PAGE_PREPARE: Draw_Prepare_Menu(); break; - case PAGE_CONTROL: Draw_Control_Menu(); break; - - case PAGE_INFO_LEVELING: - #if HAS_ONESTEP_LEVELING - queue.inject(F("G28Z\nG29")); // Force to get the current Z home position - #else - last_checkkey = MainMenu; - Goto_InfoMenu(); - #endif - break; + case PAGE_ADVANCE: Draw_AdvancedSettings_Menu(); break; } } DWIN_UpdateLCD(); @@ -1331,7 +1217,7 @@ void HMI_SelectFile() { else if (encoder_diffState == ENCODER_DIFF_ENTER) { if (select_file.now == 0) { // Back select_page.set(PAGE_PRINT); - Goto_Main_Menu(); + return Goto_Main_Menu(); } else if (hasUpDir && select_file.now == 1) { // CD-Up SDCard_Up(); @@ -1355,16 +1241,10 @@ void HMI_SelectFile() { HMI_flag.heat_flag = true; HMI_flag.print_finish = false; - card.openAndPrintFile(card.filename); - - #if HAS_FAN - // 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; - #endif - - DWIN_Print_Started(true); + if (card.fileIsBinary()) + return DWIN_Popup_Confirm(ICON_Error, F("Please check filenames"), F("Only G-code can be printed")); + else + return Goto_ConfirmToPrint(); } } @@ -1372,6 +1252,16 @@ void HMI_SelectFile() { 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 + default: break; + } + return Goto_PrintProcess(); +} + // Printing void HMI_Printing() { EncoderState encoder_diffState = get_encoder_state(); @@ -1399,106 +1289,21 @@ void HMI_Printing() { switch (select_print.now) { case PRINT_SETUP: Draw_Tune_Menu(); break; case PRINT_PAUSE_RESUME: - if (HMI_flag.pause_flag) { - ICON_Pause(); - #if DISABLED(ADVANCED_PAUSE_FEATURE) - char cmd[40]; - cmd[0] = '\0'; - #if BOTH(HAS_HEATED_BED, PAUSE_HEAT) - if (resume_bed_temp) sprintf_P(cmd, PSTR("M190 S%i\n"), resume_bed_temp); - #endif - #if BOTH(HAS_HOTEND, PAUSE_HEAT) - if (resume_hotend_temp) sprintf_P(&cmd[strlen(cmd)], PSTR("M109 S%i\n"), resume_hotend_temp); - #endif - #if HAS_FAN - if (resume_fan) thermalManager.fan_speed[0] = resume_fan; - #endif - strcat_P(cmd, M24_STR); - queue.inject(cmd); - #endif - } - else { - HMI_flag.select_flag = true; - checkkey = PauseOrStop; - Popup_window_PauseOrStop(); + if (printingIsPaused()) { // if printer is already in pause + ui.resume_print(); + break; } - break; - + else + return Goto_Popup(Popup_window_PauseOrStop, onClick_PauseOrStop); case PRINT_STOP: - HMI_flag.select_flag = true; - checkkey = PauseOrStop; - Popup_window_PauseOrStop(); - break; - + return Goto_Popup(Popup_window_PauseOrStop, onClick_PauseOrStop); default: break; } } DWIN_UpdateLCD(); } -// Print done -void HMI_PrintDone() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_ENTER) { - dwin_abort_flag = true; // Reset feedrate, return to Home - Goto_Main_Menu(); // Return to Main menu after print done - } -} - -// Pause or Stop popup -void HMI_PauseOrStop() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - - if (encoder_diffState == ENCODER_DIFF_CW) - Draw_Select_Highlight(false); - else if (encoder_diffState == ENCODER_DIFF_CCW) - Draw_Select_Highlight(true); - else if (encoder_diffState == ENCODER_DIFF_ENTER) { - if (select_print.now == PRINT_PAUSE_RESUME) { - if (HMI_flag.select_flag) { - HMI_flag.pause_action = true; - ICON_Resume(); - queue.inject(F("M25")); - } - else { - // cancel pause - } - Goto_PrintProcess(); - } - else if (select_print.now == PRINT_STOP) { - if (HMI_flag.select_flag) { - checkkey = MainMenu; - if (HMI_flag.home_flag) planner.synchronize(); // Wait for planner moves to finish! - wait_for_heatup = wait_for_user = false; // Stop waiting for heating/user - card.abortFilePrintSoon(); // Let the main loop handle SD abort - dwin_abort_flag = true; // Reset feedrate, return to Home - #ifdef ACTION_ON_CANCEL - hostui.cancel(); - #endif - DWIN_Draw_Popup(ICON_BLTouch, F("Stopping...") , F("Please wait until done.")); - } - else - Goto_PrintProcess(); // cancel stop - } - } - DWIN_UpdateLCD(); -} - -#include "../../../libs/buzzer.h" - -void HMI_AudioFeedback(const bool success/*=true*/) { - #if HAS_BUZZER - if (success) { - BUZZ(100, 659); - BUZZ(10, 0); - BUZZ(100, 698); - } - else - BUZZ(40, 440); - #endif -} +#include "../../../libs/buzzer.h" void Draw_Main_Area() { switch (checkkey) { @@ -1506,65 +1311,74 @@ void Draw_Main_Area() { case SelectFile: Draw_Print_File_Menu(); break; case PrintProcess: Draw_PrintProcess(); break; case PrintDone: Draw_PrintDone(); break; - case Info: Draw_Info_Menu(); break; - case PauseOrStop: Popup_window_PauseOrStop(); break; - #if ENABLED(ADVANCED_PAUSE_FEATURE) - case FilamentPurge: Draw_Popup_FilamentPurge(); break; + #if HAS_ESDIAG + case ESDiagProcess: Draw_EndStopDiag(); break; #endif + case Popup: popupDraw(); break; case Locked: lockScreen.draw(); break; case Menu: case SetInt: case SetPInt: case SetIntNoDraw: case SetFloat: - case SetPFloat: CurrentMenu->draw(); break; + case SetPFloat: ReDrawMenu(); break; default: break; } } void HMI_ReturnScreen() { checkkey = last_checkkey; + wait_for_user = false; Draw_Main_Area(); - return; } -void HMI_Popup() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_ENTER) { - wait_for_user = false; - HMI_ReturnScreen(); +void HMI_WaitForUser() { + get_encoder_state(); + 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; + } } } void HMI_Init() { - HMI_SDCardInit(); - + 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) { DWINUI::Draw_Icon(ICON_Bar, 15, 260); DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 15 + t * 242 / 100, 260, 257, 280); DWIN_UpdateLCD(); delay(20); } - HMI_SetLanguage(); } -void DWIN_Update() { - EachMomentUpdate(); // Status update - HMI_SDCardUpdate(); // SD card update - DWIN_HandleScreen(); // Rotary encoder update -} - void EachMomentUpdate() { static millis_t next_var_update_ms = 0, next_rts_update_ms = 0, next_status_update_ms = 0; - const millis_t ms = millis(); + if (ELAPSED(ms, next_var_update_ms)) { next_var_update_ms = ms + DWIN_VAR_UPDATE_INTERVAL; 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()); + #endif } + #if HAS_STATUS_MESSAGE_TIMEOUT + bool did_expire = ui.status_reset_callback && (*ui.status_reset_callback)(); + did_expire |= ui.status_message_expire_ms && ELAPSED(ms, ui.status_message_expire_ms); + if (did_expire) ui.reset_status(); + #endif + if (ELAPSED(ms, next_status_update_ms)) { next_status_update_ms = ms + 500; DWIN_DrawStatusMessage(); @@ -1573,52 +1387,45 @@ void EachMomentUpdate() { if (PENDING(ms, next_rts_update_ms)) return; next_rts_update_ms = ms + DWIN_SCROLL_UPDATE_INTERVAL; - if (checkkey == PrintProcess) { + if (checkkey == PrintProcess) { // print process + + // 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 print done - if (HMI_flag.print_finish) { + if (HMI_flag.print_finish && !HMI_flag.home_flag) { HMI_flag.print_finish = false; - TERN_(POWER_LOSS_RECOVERY, recovery.cancel()); - planner.finish_and_disable(); - checkkey = PrintDone; - Draw_PrintDone(); - } - else if (HMI_flag.pause_flag != printingIsPaused()) { - // print status update - HMI_flag.pause_flag = printingIsPaused(); - ICON_ResumeOrPause(); + return DWIN_Print_Finished(); } - } - - // pause after homing - if (HMI_flag.pause_action && printingIsPaused() && !planner.has_blocks_queued()) { - HMI_flag.pause_action = false; - #if ENABLED(PAUSE_HEAT) - TERN_(HAS_HOTEND, resume_hotend_temp = sdprint ? thermalManager.degTargetHotend(0) : thermalManager.wholeDegHotend(0)); - TERN_(HAS_HEATED_BED, resume_bed_temp = sdprint ? thermalManager.degTargetBed() : thermalManager.wholeDegBed()); - TERN_(HAS_FAN, resume_fan = thermalManager.fan_speed[0]); - #endif - IF_DISABLED(ADVANCED_PAUSE_FEATURE, thermalManager.disable_all_heaters()); - IF_DISABLED(PARK_HEAD_ON_PAUSE, queue.inject(F("G1 F1200 X0 Y0"))); - } - if (checkkey == PrintProcess) { // print process + // 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(); + } + } duration_t elapsed = print_job_timer.duration(); // print timer - if (sdprint && card.isPrinting()) { + if (sdprint && card.isPrinting() && !HMI_flag.percent_flag) { uint8_t percentDone = card.percentDone(); - static uint8_t last_percentValue = 101; - if (last_percentValue != percentDone) { // print percent - last_percentValue = percentDone; - if (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) { + 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(); @@ -1634,69 +1441,63 @@ void EachMomentUpdate() { } } - else if (dwin_abort_flag && !HMI_flag.home_flag) { // Print Stop - dwin_abort_flag = false; - dwin_zoffset = BABY_Z_VAR; - select_page.set(PAGE_PRINT); - Goto_Main_Menu(); - } #if ENABLED(POWER_LOSS_RECOVERY) else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off - static bool recovery_flag = false; - - recovery.dwin_flag = false; - recovery_flag = true; - - auto update_selection = [&](const bool sel) { - HMI_flag.select_flag = sel; - const uint16_t c1 = sel ? HMI_data.PopupBg_color : HMI_data.Highlight_Color; - DWIN_Draw_Rectangle(0, c1, 25, 306, 126, 345); - DWIN_Draw_Rectangle(0, c1, 24, 305, 127, 346); - const uint16_t c2 = sel ? HMI_data.Highlight_Color : HMI_data.PopupBg_color; - DWIN_Draw_Rectangle(0, c2, 145, 306, 246, 345); - DWIN_Draw_Rectangle(0, c2, 144, 305, 247, 346); - }; - - Popup_Window_Resume(); - update_selection(true); - - // TODO: Get the name of the current file from someplace - // - //(void)recovery.interrupted_file_exists(); - SdFile *dir = nullptr; - const char * const filename = card.diveToFile(true, dir, recovery.info.sd_filename); - card.selectFileByName(filename); - DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 252, card.longest_filename()); - DWIN_UpdateLCD(); + return Goto_PowerLossRecovery(); + } + #endif // POWER_LOSS_RECOVERY - while (recovery_flag) { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (encoder_diffState == ENCODER_DIFF_ENTER) { - recovery_flag = false; - if (HMI_flag.select_flag) break; - TERN_(POWER_LOSS_RECOVERY, queue.inject(F("M1000C"))); - return HMI_StartFrame(true); - } - else - update_selection(encoder_diffState == ENCODER_DIFF_CW); - - DWIN_UpdateLCD(); - } - watchdog_refresh(); - } + DWIN_UpdateLCD(); +} +#if ENABLED(POWER_LOSS_RECOVERY) + void Popup_PowerLossRecovery() { + DWINUI::ClearMainArea(); + Draw_Popup_Bkgd(); + if (HMI_IsChinese()) { + DWIN_Frame_AreaCopy(1, 160, 338, 235, 354, 98, 115); + DWIN_Frame_AreaCopy(1, 103, 321, 271, 335, 52, 167); + DWINUI::Draw_IconWB(ICON_Cancel_C, 26, 280); + DWINUI::Draw_IconWB(ICON_Continue_C, 146, 280); + } + else { + DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 70, GET_TEXT_F(MSG_OUTAGE_RECOVERY)); + DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 147, F("It looks like the last")); + DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 167, F("file was interrupted.")); + DWINUI::Draw_Button(BTN_Cancel, 26, 280); + DWINUI::Draw_Button(BTN_Continue, 146, 280); + } + SdFile *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()); + Draw_Select_Highlight(HMI_flag.select_flag); + DWIN_UpdateLCD(); + } + + void onClick_PowerLossRecovery() { + if (HMI_flag.select_flag) { + queue.inject(F("M1000C")); + select_page.reset(); + return Goto_Main_Menu(); + } + else { select_print.set(PRINT_SETUP); queue.inject(F("M1000")); sdprint = true; - Goto_PrintProcess(); - Draw_Status_Area(true); + return Goto_PrintProcess(); } - #endif // POWER_LOSS_RECOVERY + } + + void Goto_PowerLossRecovery() { + recovery.dwin_flag = false; + LCD_MESSAGE(MSG_CONTINUE_PRINT_JOB); + Goto_Popup(Popup_PowerLossRecovery, onClick_PowerLossRecovery); + } + +#endif // POWER_LOSS_RECOVERY - DWIN_UpdateLCD(); -} void DWIN_HandleScreen() { switch (checkkey) { @@ -1708,94 +1509,149 @@ void DWIN_HandleScreen() { case SetFloat: HMI_SetFloat(); break; case SetPFloat: HMI_SetPFloat(); break; case SelectFile: HMI_SelectFile(); break; - case Homing: break; - case Leveling: break; case PrintProcess: HMI_Printing(); break; - case PrintDone: HMI_PrintDone(); break; - case PauseOrStop: HMI_PauseOrStop(); break; - case Info: HMI_Popup(); break; - case WaitResponse: HMI_Popup(); break; - #if ENABLED(ADVANCED_PAUSE_FEATURE) - case FilamentPurge: HMI_FilamentPurge(); break; - #endif - case NothingToDo: break; + case Popup: HMI_Popup(); break; + case Leveling: break; case Locked: HMI_LockScreen(); break; + case PrintDone: + TERN_(HAS_ESDIAG, case ESDiagProcess:) + case WaitResponse: HMI_WaitForUser(); break; + case Homing: + case PidProcess: + case NothingToDo: break; default: break; } } +bool IDisPopUp() { // If ID is popup... + return (checkkey == NothingToDo) + || (checkkey == WaitResponse) + || (checkkey == Homing) + || (checkkey == Leveling) + || (checkkey == PidProcess) + || TERN0(HAS_ESDIAG, (checkkey == ESDiagProcess)) + || (checkkey == Popup); +} + void HMI_SaveProcessID(const uint8_t id) { if (checkkey != id) { - if ((checkkey != NothingToDo) && - (checkkey != WaitResponse) && - (checkkey != Homing) && - (checkkey != Leveling) && - (checkkey != PauseOrStop) && - (checkkey != FilamentPurge)) last_checkkey = checkkey; // if not a popup + if (!IDisPopUp()) last_checkkey = checkkey; // if previous is not a popup + if ((id == Popup) + || TERN0(HAS_ESDIAG, (id == ESDiagProcess)) + || (id == PrintDone) + || (id == Leveling) + || (id == WaitResponse)) wait_for_user = true; checkkey = id; } } -void DWIN_StartHoming() { +void DWIN_HomingStart() { HMI_flag.home_flag = true; HMI_SaveProcessID(Homing); - Title.ShowCaption(F("Axis Homing")); - DWIN_Draw_Popup(ICON_BLTouch, F("Axis Homing"), F("Please wait until done.")); + Title.ShowCaption(GET_TEXT_F(MSG_HOMING)); + DWIN_Show_Popup(ICON_BLTouch, GET_TEXT_F(MSG_HOMING), GET_TEXT_F(MSG_PLEASE_WAIT)); } -void DWIN_CompletedHoming() { +void DWIN_HomingDone() { HMI_flag.home_flag = false; - dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z); - if (dwin_abort_flag) { - planner.finish_and_disable(); - } - HMI_ReturnScreen(); + #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(); } -void DWIN_MeshLevelingStart() { +void DWIN_LevelingStart() { #if HAS_ONESTEP_LEVELING HMI_SaveProcessID(Leveling); - Title.ShowCaption(F("Bed Leveling")); - DWIN_Draw_Popup(ICON_AutoLeveling, GET_TEXT_F(MSG_BED_LEVELING), F("Please wait until done.")); + 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)); + #if BOTH(AUTO_BED_LEVELING_UBL, PREHEAT_BEFORE_LEVELING) + #if HAS_HOTEND + if (thermalManager.degTargetHotend(0) < LEVELING_NOZZLE_TEMP) + thermalManager.setTargetHotend(LEVELING_NOZZLE_TEMP, 0); + #endif + #if HAS_HEATED_BED + if (thermalManager.degTargetBed() < HMI_data.BedLevT) + thermalManager.setTargetBed(HMI_data.BedLevT); + #endif + TERN_(HAS_HOTEND, thermalManager.wait_for_hotend(0)); + TERN_(HAS_HEATED_BED, thermalManager.wait_for_bed_heating()); + #endif #elif ENABLED(MESH_BED_LEVELING) Draw_ManualMesh_Menu(); #endif } -void DWIN_CompletedLeveling() { TERN_(HAS_MESH, DWIN_MeshViewer()); } +void DWIN_LevelingDone() { + TERN_(HAS_MESH, Goto_MeshViewer()); +} #if HAS_MESH - void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { + void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, 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), xpos, ypos, dtostrf(zval, 1, 2, str_1)); ui.set_status(msg); } #endif // PID process + +#if HAS_PIDPLOT + void DWIN_Draw_PIDPopup() { + frame_rect_t gfrm = {40, 180, DWIN_WIDTH - 80, 120}; + DWINUI::ClearMainArea(); + Draw_Popup_Bkgd(); + 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; + } + } +#endif + void DWIN_PidTuning(pidresult_t result) { + HMI_value.pidresult = result; switch (result) { case PID_BED_START: - HMI_SaveProcessID(NothingToDo); - DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for BED is running.")); + 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; case PID_EXTR_START: - HMI_SaveProcessID(NothingToDo); - DWIN_Draw_Popup(ICON_TempTooHigh, GET_TEXT_F(MSG_PID_AUTOTUNE), F("for Nozzle is running.")); + 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, F("PID Autotune failed!"), F("Bad extruder")); + 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, F("Error"), GET_TEXT_F(MSG_PID_TIMEOUT)); + 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, F("PID Autotune failed!"), F("Temperature too high")); + 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; @@ -1807,66 +1663,67 @@ void DWIN_PidTuning(pidresult_t result) { } } -// Update filename on print -void DWIN_Print_Header(const char *text = nullptr) { - static char headertxt[31] = ""; // Print header text - - if (text != nullptr) { - const int8_t size = _MIN((unsigned) 30, strlen_P(text)); - LOOP_L_N(i, size) headertxt[i] = text[i]; - headertxt[size] = '\0'; - } - if (checkkey == PrintProcess || checkkey == PrintDone) { - DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, 60, DWIN_WIDTH, 60+16); - DWINUI::Draw_CenteredString(60, headertxt); - } -} - -void Draw_Title(TitleClass* title) { - 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); -} - -void Draw_Menu(MenuClass* menu) { - DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color); - DWIN_Draw_Rectangle(1, DWINUI::backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1); - DWIN_ResetStatusLine(); -} - -// Startup routines -void DWIN_Startup() { - DWINUI::init(); - DWINUI::onCursorDraw = Draw_Menu_Cursor; - DWINUI::onCursorErase = Erase_Menu_Cursor; - DWINUI::onTitleDraw = Draw_Title; - DWINUI::onMenuDraw = Draw_Menu; - HMI_SetLanguage(); -} - // Started a Print Job void DWIN_Print_Started(const bool sd) { - sdprint = card.isPrinting() || sd; + sdprint = IS_SD_PRINTING() || sd; _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; Goto_PrintProcess(); } +// Pause a print job +void DWIN_Print_Pause() { + ICON_ResumeOrPause(); +} + +// Resume print job +void DWIN_Print_Resume() { + HMI_flag.pause_action = false; + ICON_ResumeOrPause(); + if (printJobOngoing()) { + LCD_MESSAGE(MSG_RESUME_PRINT); + Goto_PrintProcess(); + } +} + // Ended print job void DWIN_Print_Finished() { - if (checkkey == PrintProcess || printingIsActive()) { - thermalManager.cooldown(); - HMI_flag.print_finish = true; - } + if (HMI_flag.abort_flag || checkkey == PrintDone) return; + TERN_(POWER_LOSS_RECOVERY, if (card.isPrinting()) recovery.cancel()); + HMI_flag.pause_flag = false; + wait_for_heatup = false; + planner.finish_and_disable(); + thermalManager.cooldown(); + Goto_PrintDone(); +} + +// 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(); } // Progress Bar update -void DWIN_Progress_Update() { - if (parser.seenval('P')) _percent_done = parser.byteval('P'); - if (parser.seenval('R')) _remain_time = parser.ulongval('R') * 60; +void DWIN_M73() { + if (parser.seenval('P')) { + _percent_done = parser.value_byte(); + HMI_flag.percent_flag = true; + } + if (parser.seenval('R')) { + _remain_time = parser.value_ulong() * 60; + HMI_flag.remain_flag = true; + } if (checkkey == PrintProcess) { Draw_Print_ProgressBar(); Draw_Print_ProgressRemain(); @@ -1902,95 +1759,154 @@ void DWIN_SetColorDefaults() { void DWIN_SetDataDefaults() { DWIN_SetColorDefaults(); - DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_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_(PREVENT_COLD_EXTRUSION, HMI_data.ExtMinT = EXTRUDE_MINTEMP); + 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); + #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_(BAUD_RATE_GCODE, SetBaud250K()); + #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) + leds.set_default(); + ApplyLEDColor(); + #endif } -void DWIN_StoreSettings(char *buff) { - memcpy(buff, &HMI_data, _MIN(sizeof(HMI_data), eeprom_data_size)); +void DWIN_CopySettingsTo(char * const buff) { + memcpy(buff, &HMI_data, eeprom_data_size); } -void DWIN_LoadSettings(const char *buff) { - memcpy(&HMI_data, buff, _MIN(sizeof(HMI_data), eeprom_data_size)); - dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z); +void DWIN_CopySettingsFrom(const char * const buff) { + 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); + 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) + ); + leds.update(); + #endif + +} + +// Initialize or re-initialize the LCD +void MarlinUI::init_lcd() { + TERN_(DEBUG_DWIN, SERIAL_ECHOLNPGM("DWIN_Startup")); + DWINUI::init(); + DWIN_JPG_CacheTo1(Language_English); + Encoder_Configuration(); +} + +void DWIN_InitScreen() { + HMI_Init(); // draws boot screen + onCursorDraw = Draw_Menu_Cursor; + onCursorErase = Erase_Menu_Cursor; + DWINUI::onTitleDraw = Draw_Title; + onMenuDraw = Draw_Menu; + checkkey = 255; + CurrentMenu = nullptr; + PreviousMenu = nullptr; + index_file = MROWS; + hash_changed = true; + last_E = 0; + DWIN_DrawStatusLine(FSTR_P(nullptr)); + DWIN_Draw_Dashboard(); + Goto_Main_Menu(); +} + +void MarlinUI::update() { + EachMomentUpdate(); // Status update + HMI_SDCardUpdate(); // SD card update + DWIN_HandleScreen(); // Rotary encoder update } +void MarlinUI::refresh() { /* Nothing to see here */ } + +#if HAS_LCD_BRIGHTNESS + void MarlinUI::_set_brightness() { DWIN_LCD_Brightness(backlight ? brightness : 0); } +#endif + void MarlinUI::kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component) { - DWIN_Draw_Popup(ICON_BLTouch, lcd_error, lcd_component); + DWIN_Draw_Popup(ICON_BLTouch, GET_TEXT_F(MSG_PRINTER_KILLED), lcd_error); + DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 270, GET_TEXT_F(MSG_TURN_OFF)); DWIN_UpdateLCD(); } void DWIN_RebootScreen() { DWIN_Frame_Clear(Color_Bg_Black); - DWINUI::Draw_Icon(ICON_LOGO, 71, 150); // CREALITY logo - DWINUI::Draw_CenteredString(Color_White, 200, F("Please wait until reboot.")); + DWIN_JPG_ShowAndCache(0); + DWINUI::Draw_CenteredString(Color_White, 220, GET_TEXT_F(MSG_PLEASE_WAIT_REBOOT)); DWIN_UpdateLCD(); - delay(500); + safe_delay(500); +} + +void DWIN_RedrawDash() { + hash_changed = true; + DWIN_DrawStatusMessage(); + DWIN_Draw_Dashboard(); } -void DWIN_Redraw_screen() { +void DWIN_RedrawScreen() { Draw_Main_Area(); - Draw_Status_Area(false); + DWIN_RedrawDash(); } #if ENABLED(ADVANCED_PAUSE_FEATURE) - - void DWIN_Popup_Pause(FSTR_P const fmsg, uint8_t button = 0) { + void DWIN_Popup_Pause(FSTR_P const fmsg, uint8_t button /*= 0*/) { HMI_SaveProcessID(button ? WaitResponse : NothingToDo); - DWIN_Draw_Popup(ICON_BLTouch, F("Advanced Pause"), fmsg, button); - ui.reset_status(true); + DWIN_Show_Popup(ICON_BLTouch, GET_TEXT_F(MSG_ADVANCED_PAUSE), fmsg, button); } void MarlinUI::pause_show_message(const PauseMessage message, const PauseMode mode/*=PAUSE_MODE_SAME*/, const uint8_t extruder/*=active_extruder*/) { + //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; - case PAUSE_MESSAGE_CHANGING: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_INIT)); break; - case PAUSE_MESSAGE_UNLOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); break; - case PAUSE_MESSAGE_WAITING: DWIN_Popup_Pause(GET_TEXT_F(MSG_ADVANCED_PAUSE_WAITING), ICON_Continue_E); break; - case PAUSE_MESSAGE_INSERT: DWIN_Popup_Continue(ICON_BLTouch, F("Advanced Pause"), GET_TEXT_F(MSG_FILAMENT_CHANGE_INSERT)); break; + 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_LOAD: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_LOAD)); break; - case PAUSE_MESSAGE_PURGE: DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE)); break; - case PAUSE_MESSAGE_OPTION: DWIN_Popup_FilamentPurge(); 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_PURGE: + #if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE) + DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_CONT_PURGE)); + #else + DWIN_Popup_Pause(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE)); + #endif + break; + case PAUSE_MESSAGE_OPTION: Goto_FilamentPurge(); break; 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), ICON_Continue_E); break; - case PAUSE_MESSAGE_HEATING: LCD_MESSAGE(MSG_FILAMENT_CHANGE_HEATING); break; - case PAUSE_MESSAGE_STATUS: HMI_ReturnScreen(); 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 default: break; } } void Draw_Popup_FilamentPurge() { - DWIN_Draw_Popup(ICON_BLTouch, F("Advanced Pause"), F("Purge or Continue?")); - DWINUI::Draw_Icon(ICON_Confirm_E, 26, 280); - DWINUI::Draw_Icon(ICON_Continue_E, 146, 280); + DWIN_Draw_Popup(ICON_BLTouch, GET_TEXT_F(MSG_ADVANCED_PAUSE), GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE_CONTINUE)); + DWINUI::Draw_Button(BTN_Purge, 26, 280); + DWINUI::Draw_Button(BTN_Continue, 146, 280); Draw_Select_Highlight(true); - DWIN_UpdateLCD(); } - // Handle responses such as: - // - Purge More, Continue - // - General "Continue" response - void DWIN_Popup_FilamentPurge() { - HMI_SaveProcessID(FilamentPurge); - pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; - Draw_Popup_FilamentPurge(); - } - - void HMI_FilamentPurge() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_CW) - Draw_Select_Highlight(false); - else if (encoder_diffState == ENCODER_DIFF_CCW) - Draw_Select_Highlight(true); - else if (encoder_diffState == ENCODER_DIFF_ENTER) { + void onClick_FilamentPurge() { if (HMI_flag.select_flag) pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; // "Purge More" button else { @@ -1998,7 +1914,10 @@ void DWIN_Redraw_screen() { pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; // "Continue" button } } - DWIN_UpdateLCD(); + + void Goto_FilamentPurge() { + pause_menu_response = PAUSE_RESPONSE_WAIT_FOR; + Goto_Popup(Draw_Popup_FilamentPurge, onClick_FilamentPurge); } #endif // ADVANCED_PAUSE_FEATURE @@ -2006,188 +1925,185 @@ void DWIN_Redraw_screen() { #if HAS_MESH void DWIN_MeshViewer() { if (!leveling_is_valid()) - DWIN_Popup_Continue(ICON_BLTouch, F("Mesh viewer"), F("No valid mesh")); + DWIN_Popup_Continue(ICON_BLTouch, GET_TEXT_F(MSG_MESH_VIEWER), GET_TEXT_F(MSG_NO_VALID_MESH)); else { HMI_SaveProcessID(WaitResponse); MeshViewer.Draw(); } } -#endif +#endif // HAS_MESH + +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 HMI_LockScreen() { EncoderState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_NO) return; lockScreen.onEncoder(encoder_diffState); - if (lockScreen.isUnlocked()) { - if (CurrentMenu == AdvancedSettings) - Draw_AdvancedSettings_Menu(); - else - Draw_Tune_Menu(); - } + if (lockScreen.isUnlocked()) DWIN_UnLockScreen(); } -void DWIN_LockScreen(const bool flag) { - HMI_flag.lock_flag = flag; - checkkey = Locked; - lockScreen.init(); -} -// -// NEW MENU SUBSYSTEM ========================================================= -// +#if HAS_GCODE_PREVIEW -// On click functions - -// Generic onclick event without draw anything -// process: process id HMI destiny -// lo: low limit -// hi: high limit -// dp: decimal places, 0 for integers -// val: value / scaled value -// LiveUpdate: live update function when the encoder changes -// Apply: update function when the encoder is pressed -void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) { - checkkey = process; - HMI_value.MinValue = lo; - HMI_value.MaxValue = hi; - HMI_value.dp = dp; - HMI_value.Apply = Apply; - HMI_value.LiveUpdate = LiveUpdate; - HMI_value.Value = val; - EncoderRate.enabled = true; -} - -// Generic onclick event for integer values -// process: process id HMI destiny -// lo: scaled low limit -// hi: scaled high limit -// val: value -// LiveUpdate: live update function when the encoder changes -// 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, HMI_value.Value); -} - -// Generic onclick event for float values -// process: process id HMI destiny -// lo: scaled low limit -// hi: scaled high limit -// val: value -// LiveUpdate: live update function when the encoder changes -// Apply: update function when the encoder is pressed -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); -} - -// Generic onclick event for integer values -// lo: scaled low limit -// hi: scaled high limit -// val: value -// LiveUpdate: live update function when the encoder changes -// Apply: update function when the encoder is pressed -inline void SetIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) { - SetValueOnClick(SetInt, lo, hi, val, Apply, LiveUpdate); -} - -// Generic onclick event for set pointer to 16 bit uinteger values -// lo: low limit -// hi: high limit -// LiveUpdate: live update function when the encoder changes -// Apply: update function when the encoder is pressed -void SetPIntOnClick(const int32_t lo, const int32_t hi, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) { - HMI_value.P_Int = (int16_t*)static_cast(CurrentMenu->SelectedItem())->value; - const int32_t value = *HMI_value.P_Int; - SetValueOnClick(SetPInt, lo, hi, value, Apply, LiveUpdate); -} - -// Generic onclick event for float values -// process: process id HMI destiny -// lo: low limit -// hi: high limit -// dp: decimal places -// val: value -inline void SetFloatOnClick(const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) { - SetValueOnClick(SetFloat, lo, hi, dp, val, Apply, LiveUpdate); -} - -// Generic onclick event for set pointer to float values -// lo: low limit -// hi: high limit -// LiveUpdate: live update function when the encoder changes -// Apply: update function when the encoder is pressed -void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) { - HMI_value.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; - SetValueOnClick(SetPFloat, lo, hi, dp, *HMI_value.P_Float, Apply, LiveUpdate); -} + void onClick_ConfirmToPrint() { + 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(); + } + } + + void Goto_ConfirmToPrint() { + Goto_Popup(Preview_DrawFromSD, onClick_ConfirmToPrint); + } + +#else + void Goto_ConfirmToPrint() { + card.openAndPrintFile(card.filename); + DWIN_Print_Started(true); + } +#endif + +#if HAS_ESDIAG + void Draw_EndStopDiag() { + HMI_SaveProcessID(ESDiagProcess); + ESDiag.Draw(); + } +#endif + +//============================================================================= +// NEW MENU SUBSYSTEM +//============================================================================= + +// Tool functions #if ENABLED(EEPROM_SETTINGS) void WriteEeprom() { - const bool success = settings.save(); - HMI_AudioFeedback(success); + DWIN_DrawStatusLine(GET_TEXT_F(MSG_STORE_EEPROM)); + DWIN_UpdateLCD(); + DONE_BUZZ(settings.save()); } void ReadEeprom() { const bool success = settings.load(); - DWIN_Redraw_screen(); - HMI_AudioFeedback(success); + DWIN_RedrawScreen(); + DONE_BUZZ(success); } void ResetEeprom() { settings.reset(); - DWIN_Redraw_screen(); - HMI_AudioFeedback(); + DWIN_RedrawScreen(); + DONE_BUZZ(true); } + + #if HAS_MESH + void SaveMesh() { TERN(AUTO_BED_LEVELING_UBL, UBLSaveMesh(), WriteEeprom()); } + #endif #endif // Reset Printer void RebootPrinter() { - dwin_abort_flag = true; wait_for_heatup = wait_for_user = false; // Stop waiting for heating/user thermalManager.disable_all_heaters(); planner.finish_and_disable(); DWIN_RebootScreen(); - HAL_reboot(); + hal.reboot(); } -void Goto_InfoMenu(){ - checkkey = Info; +void Goto_Info_Menu() { Draw_Info_Menu(); + DWIN_UpdateLCD(); + 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 + queue.inject(F(TERN(AUTO_BED_LEVELING_UBL, "G28Z\nG29P1", "G28XYO\nG28Z\nG29"))); +} + 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() { // Apply workspace offset, making the current position 0,0,0 - queue.inject(F("G92 X0 Y0 Z0")); - HMI_AudioFeedback(); + queue.inject(F("G92X0Y0Z0")); + DONE_BUZZ(true); } #if HAS_ZOFFSET_ITEM - bool printer_busy() { return planner.movesplanned() || printingIsActive(); } + void ApplyZOffset() { TERN_(EEPROM_SETTINGS, settings.save()); } void LiveZOffset() { - last_zoffset = dwin_zoffset; - dwin_zoffset = HMI_value.Value / 100.0f; #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) - if (BABYSTEP_ALLOWED()) babystep.add_mm(Z_AXIS, dwin_zoffset - last_zoffset); + 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); #endif } - #if EITHER(HAS_BED_PROBE, BABYSTEPPING) + + #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) void SetZOffset() { + 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 + + 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"), + 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")); + #endif + ui.reset_status(); + DONE_BUZZ(true); + } + + void HomeZandDisable() { + SetMoveZto0(); + DisableMotors(); + } + +#endif // HAS_ZOFFSET_ITEM #if HAS_PREHEAT void DoPreheat0() { ui.preheat_all(0); } - void DoPreheat1() { ui.preheat_all(1); } - void DoPreheat2() { ui.preheat_all(2); } + #if PREHEAT_COUNT >= 2 + void DoPreheat1() { ui.preheat_all(1); } + #if PREHEAT_COUNT >= 3 + void DoPreheat2() { ui.preheat_all(2); } + #endif + #endif #endif void DoCoolDown() { thermalManager.cooldown(); } @@ -2199,62 +2115,41 @@ void SetLanguage() { } void LiveMove() { - *HMI_value.P_Float = HMI_value.Value / MINUNITMULT; + *MenuData.P_Float = MenuData.Value / MINUNITMULT; if (!planner.is_full()) { planner.synchronize(); planner.buffer_line(current_position, homing_feedrate(HMI_value.axis)); } } void ApplyMoveE() { - last_E = HMI_value.Value / MINUNITMULT; + last_E = MenuData.Value / MINUNITMULT; if (!planner.is_full()) { planner.synchronize(); planner.buffer_line(current_position, MMM_TO_MMS(FEEDRATE_E)); } } -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, 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); } #if HAS_HOTEND void SetMoveE() { #if ENABLED(PREVENT_COLD_EXTRUSION) - if (thermalManager.tooColdToExtrude(0)) { - Popup_Window_ETempTooLow(); - return; - } + 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); } #endif -void SetMoveZto0() { - char cmd[48] = ""; - char str_1[5] = "", str_2[5] = ""; - sprintf_P(cmd, PSTR("G28Z\nG0X%sY%sF5000\nM420S0\nG0Z0F300"), - #if ENABLED(MESH_BED_LEVELING) - dtostrf(0, 1, 1, str_1), - dtostrf(0, 1, 1, str_2) - #else - dtostrf(X_CENTER, 1, 1, str_1), - dtostrf(Y_CENTER, 1, 1, str_2) - #endif - ); - gcode.process_subcommands_now(cmd); - planner.synchronize(); - LCD_MESSAGE_F("Now adjust Z Offset"); - HMI_AudioFeedback(true); -} - void SetPID(celsius_t t, heater_id_t h) { - char cmd[48] = ""; + char cmd[53] = ""; char str_1[5] = "", str_2[5] = ""; - sprintf_P(cmd, PSTR("G28OXY\nG0Z5F300\nG0X%sY%sF5000\nM84"), + 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); - planner.synchronize(); thermalManager.PID_autotune(t, h, HMI_data.PidCycles, true); } #if HAS_HOTEND @@ -2272,36 +2167,97 @@ void SetPID(celsius_t t, heater_id_t h) { } #endif +#if ENABLED(BAUD_RATE_GCODE) + void HMI_SetBaudRate() { + if (HMI_data.Baud115K) SetBaud115K(); else SetBaud250K(); + } + void SetBaudRate() { + HMI_SetBaudRate(); + Draw_Chkb_Line(CurrentMenu->line(), HMI_data.Baud115K); + DWIN_UpdateLCD(); + } + void SetBaud115K() { queue.inject(F("M575 P0 B115200")); HMI_data.Baud115K = true; } + void SetBaud250K() { queue.inject(F("M575 P0 B250000")); HMI_data.Baud115K = false; } +#endif + #if HAS_LCD_BRIGHTNESS - void LiveBrightness() { ui.set_brightness(HMI_value.Value); } - void SetBrightness() { SetIntOnClick(LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, ui.brightness, nullptr, LiveBrightness); } + void ApplyBrightness() { ui.set_brightness(MenuData.Value); } + void LiveBrightness() { DWIN_LCD_Brightness(MenuData.Value); } + void SetBrightness() { SetIntOnClick(LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, ui.brightness, ApplyBrightness, LiveBrightness); } + void TurnOffBacklight() { HMI_SaveProcessID(WaitResponse); ui.set_brightness(0); DWIN_RedrawScreen(); } +#endif + +#if ENABLED(CASE_LIGHT_MENU) + void SetCaseLight() { + caselight.on = !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(); } + void SetCaseLightBrightness() { SetIntOnClick(0, 255, caselight.brightness, nullptr, LiveCaseLightBrightness); } + #endif +#endif + +#if ENABLED(LED_CONTROL_MENU) + #if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL) + void SetLedStatus() { + leds.toggle(); + Draw_Chkb_Line(CurrentMenu->line(), leds.lights_on); + DWIN_UpdateLCD(); + } + #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 LiveLEDColor(uint8_t *color) { *color = MenuData.Value; leds.update(); } + void LiveLEDColorR() { LiveLEDColor(&leds.color.r); } + void LiveLEDColorG() { LiveLEDColor(&leds.color.g); } + void LiveLEDColorB() { LiveLEDColor(&leds.color.b); } + void SetLEDColorR() { SetIntOnClick(0, 255, leds.color.r, ApplyLEDColor, LiveLEDColorR); } + void SetLEDColorG() { SetIntOnClick(0, 255, leds.color.g, ApplyLEDColor, LiveLEDColorG); } + void SetLEDColorB() { SetIntOnClick(0, 255, leds.color.b, ApplyLEDColor, LiveLEDColorB); } + #if HAS_WHITE_LED + void LiveLEDColorW() { LiveLEDColor(&leds.color.w); } + void SetLEDColorW() { SetIntOnClick(0, 255, leds.color.w, ApplyLEDColor, LiveLEDColorW); } + #endif + #endif #endif #if ENABLED(SOUND_MENU_ITEM) void SetEnableSound() { - ui.buzzer_enabled = !ui.buzzer_enabled; - Draw_Chkb_Line(CurrentMenu->line(), ui.buzzer_enabled); + ui.sound_on = !ui.sound_on; + Draw_Chkb_Line(CurrentMenu->line(), ui.sound_on); DWIN_UpdateLCD(); } #endif -void Goto_LockScreen() { DWIN_LockScreen(true); } - #if HAS_HOME_OFFSET - void ApplyHomeOffset() { set_home_offset(HMI_value.axis, HMI_value.Value / MINUNITMULT); } + void ApplyHomeOffset() { set_home_offset(HMI_value.axis, MenuData.Value / MINUNITMULT); } void SetHomeOffsetX() { HMI_value.axis = X_AXIS; SetPFloatOnClick(-50, 50, UNITFDIGITS, ApplyHomeOffset); } void SetHomeOffsetY() { HMI_value.axis = Y_AXIS; SetPFloatOnClick(-50, 50, UNITFDIGITS, ApplyHomeOffset); } void SetHomeOffsetZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick( -2, 2, UNITFDIGITS, ApplyHomeOffset); } #endif #if HAS_BED_PROBE - void SetProbeOffsetX() { SetPFloatOnClick(-50, 50, UNITFDIGITS); } - void SetProbeOffsetY() { SetPFloatOnClick(-50, 50, UNITFDIGITS); } + void SetProbeOffsetX() { SetPFloatOnClick(-60, 60, UNITFDIGITS); } + void SetProbeOffsetY() { SetPFloatOnClick(-60, 60, UNITFDIGITS); } void SetProbeOffsetZ() { SetPFloatOnClick(-10, 10, 2); } void ProbeTest() { LCD_MESSAGE(MSG_M48_TEST); queue.inject(F("G28O\nM48 P10")); } + void ProbeStow() { probe.stow(); } + void ProbeDeploy() { probe.deploy(); } + + #ifdef BLTOUCH_HS_MODE + void SetHSMode() { + bltouch.high_speed_mode = !bltouch.high_speed_mode; + Draw_Chkb_Line(CurrentMenu->line(), bltouch.high_speed_mode); + DWIN_UpdateLCD(); + } + #endif + #endif #if HAS_FILAMENT_SENSOR @@ -2312,7 +2268,7 @@ void Goto_LockScreen() { DWIN_LockScreen(true); } DWIN_UpdateLCD(); } #if HAS_FILAMENT_RUNOUT_DISTANCE - void ApplyRunoutDistance() { runout.set_runout_distance(HMI_value.Value / MINUNITMULT); } + void ApplyRunoutDistance() { runout.set_runout_distance(MenuData.Value / MINUNITMULT); } void SetRunoutDistance() { SetFloatOnClick(0, 999, UNITFDIGITS, runout.runout_distance(), ApplyRunoutDistance); } #endif #endif @@ -2329,20 +2285,20 @@ void Goto_LockScreen() { DWIN_LockScreen(true); } void RestoreDefaultsColors() { DWIN_SetColorDefaults(); - DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color); - DWIN_Redraw_screen(); + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); + DWIN_RedrawScreen(); } void SelColor() { - HMI_value.P_Int = (int16_t*)static_cast(CurrentMenu->SelectedItem())->value; - HMI_value.Color[0] = GetRColor(*HMI_value.P_Int); // Red - HMI_value.Color[1] = GetGColor(*HMI_value.P_Int); // Green - HMI_value.Color[2] = GetBColor(*HMI_value.P_Int); // Blue + MenuData.P_Int = (int16_t*)static_cast(CurrentMenu->SelectedItem())->value; + HMI_value.Color[0] = GetRColor(*MenuData.P_Int); // Red + HMI_value.Color[1] = GetGColor(*MenuData.P_Int); // Green + HMI_value.Color[2] = GetBColor(*MenuData.P_Int); // Blue Draw_GetColor_Menu(); } void LiveRGBColor() { - HMI_value.Color[CurrentMenu->line() - 2] = HMI_value.Value; + HMI_value.Color[CurrentMenu->line() - 2] = MenuData.Value; uint16_t color = RGB(HMI_value.Color[0], HMI_value.Color[1], HMI_value.Color[2]); DWIN_Draw_Rectangle(1, color, 20, 315, DWIN_WIDTH - 20, 335); } @@ -2352,27 +2308,28 @@ void SetRGBColor() { } void DWIN_ApplyColor() { - *HMI_value.P_Int = RGB(HMI_value.Color[0], HMI_value.Color[1], HMI_value.Color[2]); - DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color); - Draw_Status_Area(false); + *MenuData.P_Int = RGB(HMI_value.Color[0], HMI_value.Color[1], HMI_value.Color[2]); + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); Draw_SelectColors_Menu(); - LCD_MESSAGE_F("Colors applied"); + hash_changed = true; + LCD_MESSAGE(MSG_COLORS_APPLIED); + DWIN_Draw_Dashboard(); } void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); } #if HAS_HOTEND - void ApplyHotendTemp() { thermalManager.setTargetHotend(HMI_value.Value, 0); } + void ApplyHotendTemp() { thermalManager.setTargetHotend(MenuData.Value, 0); } void SetHotendTemp() { SetIntOnClick(MIN_ETEMP, MAX_ETEMP, thermalManager.degTargetHotend(0), ApplyHotendTemp); } #endif #if HAS_HEATED_BED - void ApplyBedTemp() { thermalManager.setTargetBed(HMI_value.Value); } - void SetBedTemp() { SetIntOnClick(BED_MINTEMP, BED_MAX_TARGET, thermalManager.degTargetBed(), ApplyBedTemp); } + void ApplyBedTemp() { thermalManager.setTargetBed(MenuData.Value); } + void SetBedTemp() { SetIntOnClick(MIN_BEDTEMP, MAX_BEDTEMP, thermalManager.degTargetBed(), ApplyBedTemp); } #endif #if HAS_FAN - void ApplyFanSpeed() { thermalManager.set_fan_speed(0, HMI_value.Value); } + void ApplyFanSpeed() { thermalManager.set_fan_speed(0, MenuData.Value); } void SetFanSpeed() { SetIntOnClick(0, 255, thermalManager.fan_speed[0], ApplyFanSpeed); } #endif @@ -2383,18 +2340,18 @@ void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); } queue.inject(F("M600 B2")); } - void ParkHead(){ + void ParkHead() { LCD_MESSAGE(MSG_FILAMENT_PARK_ENABLED); queue.inject(F("G28O\nG27")); } #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) - void UnloadFilament(){ + void UnloadFilament() { LCD_MESSAGE(MSG_FILAMENTUNLOAD); queue.inject(F("M702 Z20")); } - void LoadFilament(){ + void LoadFilament() { LCD_MESSAGE(MSG_FILAMENTLOAD); queue.inject(F("M701 Z20")); } @@ -2405,16 +2362,16 @@ void SetSpeed() { SetPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); } void ApplyFlow() { planner.refresh_e_factor(0); } void SetFlow() { SetPIntOnClick(MIN_PRINT_FLOW, MAX_PRINT_FLOW, ApplyFlow); } -// Leveling Bed Corners -void LevBed(uint8_t point) { +// Bed Tramming +TERN(HAS_BED_PROBE, float, void) Tram(uint8_t point) { char cmd[100] = ""; - #if HAS_ONESTEP_LEVELING + #if HAS_BED_PROBE + static bool inLev = false; + float xpos = 0, ypos = 0, zval = 0, margin = 0; char str_1[6] = "", str_2[6] = "", str_3[6] = ""; - #define fmt "X:%s, Y:%s, Z:%s" - float xpos = 0, ypos = 0, zval = 0; - float margin = PROBING_MARGIN; + if (inLev) return NAN; + margin = HMI_data.FullManualTramming ? 30 : PROBING_MARGIN; #else - #define fmt "M420S0\nG28O\nG90\nG0Z5F300\nG0X%iY%iF5000\nG0Z0F300" int16_t xpos = 0, ypos = 0; int16_t margin = 30; #endif @@ -2442,36 +2399,128 @@ void LevBed(uint8_t point) { break; } - #if HAS_ONESTEP_LEVELING - planner.synchronize(); - gcode.process_subcommands_now(F("M420S0\nG28O")); - planner.synchronize(); - zval = probe.probe_at_point(xpos, ypos, PROBE_PT_STOW); - sprintf_P(cmd, PSTR(fmt), - dtostrf(xpos, 1, 1, str_1), - dtostrf(ypos, 1, 1, str_2), - dtostrf(zval, 1, 2, str_3) - ); - ui.set_status(cmd); - #else - planner.synchronize(); - sprintf_P(cmd, PSTR(fmt), xpos, ypos); + planner.synchronize(); + + #if HAS_BED_PROBE + + if (HMI_data.FullManualTramming) { + planner.synchronize(); + sprintf_P(cmd, PSTR("M420S0\nG28O\nG90\nG0Z5F300\nG0X%sY%sF5000\nG0Z0F300"), + dtostrf(xpos, 1, 1, str_1), + dtostrf(ypos, 1, 1, str_2) + ); + queue.inject(cmd); + } + else { + LIMIT(xpos, MESH_MIN_X, MESH_MAX_X); + LIMIT(ypos, MESH_MIN_Y, MESH_MAX_Y); + probe.stow(); + gcode.process_subcommands_now(F("M420S0\nG28O")); + inLev = true; + zval = probe.probe_at_point(xpos, ypos, PROBE_PT_STOW); + if (isnan(zval)) + LCD_MESSAGE(MSG_ZPROBE_OUT); + else { + sprintf_P(cmd, PSTR("X:%s, Y:%s, Z:%s"), + dtostrf(xpos, 1, 1, str_1), + dtostrf(ypos, 1, 1, str_2), + dtostrf(zval, 1, 2, str_3) + ); + ui.set_status(cmd); + } + inLev = false; + } + return zval; + + #else // !HAS_BED_PROBE + + sprintf_P(cmd, PSTR("M420S0\nG28O\nG90\nG0Z5F300\nG0X%iY%iF5000\nG0Z0F300"), xpos, ypos); queue.inject(cmd); + #endif } -void LevBedFL() { LevBed(0); } -void LevBedFR() { LevBed(1); } -void LevBedBR() { LevBed(2); } -void LevBedBL() { LevBed(3); } -void LevBedC () { LevBed(4); } +void TramFL() { Tram(0); } +void TramFR() { Tram(1); } +void TramBR() { Tram(2); } +void TramBL() { Tram(3); } +void TramC () { Tram(4); } + +#if HAS_BED_PROBE + + void Trammingwizard() { + bed_mesh_t zval = {0}; + if (HMI_data.FullManualTramming) { + LCD_MESSAGE_F("Disable manual tramming"); + return; + } + zval[0][0] = Tram(0); + checkkey = NothingToDo; + MeshViewer.DrawMesh(zval, 2, 2); + zval[1][0] = Tram(1); + MeshViewer.DrawMesh(zval, 2, 2); + zval[1][1] = Tram(2); + MeshViewer.DrawMesh(zval, 2, 2); + zval[0][1] = Tram(3); + MeshViewer.DrawMesh(zval, 2, 2); + + DWINUI::Draw_CenteredString(140, F("Calculating average")); + DWINUI::Draw_CenteredString(160, F("and relative heights")); + safe_delay(1000); + float avg = 0.0f; + LOOP_L_N(x, 2) LOOP_L_N(y, 2) avg += zval[x][y]; + avg /= 4.0f; + LOOP_L_N(x, 2) LOOP_L_N(y, 2) zval[x][y] -= avg; + 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!")); + } + else { + uint8_t p = 0; + float max = 0; + FSTR_P plabel; + bool s = true; + LOOP_L_N(x, 2) LOOP_L_N(y, 2) { + const float d = ABS(zval[x][y]); + if (max < d) { + s = (zval[x][y] >= 0); + max = d; + p = x + 2 * y; + } + } + switch (p) { + case 0b00 : plabel = GET_TEXT_F(MSG_LEVBED_FL); break; + case 0b01 : plabel = GET_TEXT_F(MSG_LEVBED_FR); break; + case 0b10 : plabel = GET_TEXT_F(MSG_LEVBED_BL); break; + case 0b11 : plabel = GET_TEXT_F(MSG_LEVBED_BR); break; + default : plabel = F(""); break; + } + DWINUI::Draw_CenteredString(120, F("Corners not leveled")); + DWINUI::Draw_CenteredString(140, F("Knob adjustment required")); + DWINUI::Draw_CenteredString(Color_Green, 160, s ? F("Lower") : F("Raise")); + DWINUI::Draw_CenteredString(Color_Green, 180, plabel); + } + DWINUI::Draw_Button(BTN_Continue, 86, 305); + checkkey = Menu; + HMI_SaveProcessID(WaitResponse); + } + + void SetManualTramming() { + HMI_data.FullManualTramming = !HMI_data.FullManualTramming; + Draw_Chkb_Line(CurrentMenu->line(), HMI_data.FullManualTramming); + DWIN_UpdateLCD(); + } + +#endif // HAS_BED_PROBE #if ENABLED(MESH_BED_LEVELING) - void ManualMeshStart(){ + void ManualMeshStart() { LCD_MESSAGE(MSG_UBL_BUILD_MESH_MENU); - gcode.process_subcommands_now(F("G28Z\nM211S0\nG29S1")); - planner.synchronize(); + gcode.process_subcommands_now(F("G28XYO\nG28Z\nM211S0\nG29S1")); #ifdef MANUAL_PROBE_START_Z const uint8_t line = CurrentMenu->line(MMeshMoveZItem->pos); DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, 2, VALX - 2 * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(line), MANUAL_PROBE_START_Z); @@ -2479,21 +2528,20 @@ void LevBedC () { LevBed(4); } } void LiveMeshMoveZ() { - *HMI_value.P_Float = HMI_value.Value / POW(10, 2); + *MenuData.P_Float = MenuData.Value / POW(10, 2); if (!planner.is_full()) { planner.synchronize(); planner.buffer_line(current_position, homing_feedrate(Z_AXIS)); } } - void SetMMeshMoveZ() { SetPFloatOnClick(-1, 1, 2, planner.synchronize, LiveMeshMoveZ);} + void SetMMeshMoveZ() { SetPFloatOnClick(-1, 1, 2, planner.synchronize, LiveMeshMoveZ); } - void ManualMeshContinue(){ + void ManualMeshContinue() { gcode.process_subcommands_now(F("G29S2")); - planner.synchronize(); - MMeshMoveZItem->draw(CurrentMenu->line(MMeshMoveZItem->pos)); + MMeshMoveZItem->redraw(); } - void ManualMeshSave(){ + void ManualMeshSave() { LCD_MESSAGE(MSG_UBL_STORAGE_MESH_MENU); queue.inject(F("M211S1\nM500")); } @@ -2505,36 +2553,36 @@ void LevBedC () { LevBed(4); } void SetPreheatEndTemp() { SetPIntOnClick(MIN_ETEMP, MAX_ETEMP); } #endif #if HAS_HEATED_BED - void SetPreheatBedTemp() { SetPIntOnClick(BED_MINTEMP, BED_MAX_TARGET); } + void SetPreheatBedTemp() { SetPIntOnClick(MIN_BEDTEMP, MAX_BEDTEMP); } #endif #if HAS_FAN void SetPreheatFanSpeed() { SetPIntOnClick(0, 255); } #endif #endif -void ApplyMaxSpeed() { planner.set_max_feedrate(HMI_value.axis, HMI_value.Value / MINUNITMULT); } -void SetMaxSpeedX() { HMI_value.axis = X_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, default_max_feedrate[X_AXIS] * 2, UNITFDIGITS, planner.settings.max_feedrate_mm_s[X_AXIS], ApplyMaxSpeed); } -void SetMaxSpeedY() { HMI_value.axis = Y_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, default_max_feedrate[Y_AXIS] * 2, UNITFDIGITS, planner.settings.max_feedrate_mm_s[Y_AXIS], ApplyMaxSpeed); } -void SetMaxSpeedZ() { HMI_value.axis = Z_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, default_max_feedrate[Z_AXIS] * 2, UNITFDIGITS, planner.settings.max_feedrate_mm_s[Z_AXIS], ApplyMaxSpeed); } +void ApplyMaxSpeed() { planner.set_max_feedrate(HMI_value.axis, MenuData.Value / MINUNITMULT); } +void SetMaxSpeedX() { HMI_value.axis = X_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, max_feedrate_edit_values[X_AXIS], UNITFDIGITS, planner.settings.max_feedrate_mm_s[X_AXIS], ApplyMaxSpeed); } +void SetMaxSpeedY() { HMI_value.axis = Y_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, max_feedrate_edit_values[Y_AXIS], UNITFDIGITS, planner.settings.max_feedrate_mm_s[Y_AXIS], ApplyMaxSpeed); } +void SetMaxSpeedZ() { HMI_value.axis = Z_AXIS, SetFloatOnClick(MIN_MAXFEEDSPEED, max_feedrate_edit_values[Z_AXIS], UNITFDIGITS, planner.settings.max_feedrate_mm_s[Z_AXIS], ApplyMaxSpeed); } #if HAS_HOTEND - void SetMaxSpeedE() { HMI_value.axis = E_AXIS; SetFloatOnClick(MIN_MAXFEEDSPEED, default_max_feedrate[E_AXIS] * 2, UNITFDIGITS, planner.settings.max_feedrate_mm_s[E_AXIS], ApplyMaxSpeed); } + void SetMaxSpeedE() { HMI_value.axis = E_AXIS; SetFloatOnClick(MIN_MAXFEEDSPEED, max_feedrate_edit_values[E_AXIS], UNITFDIGITS, planner.settings.max_feedrate_mm_s[E_AXIS], ApplyMaxSpeed); } #endif -void ApplyMaxAccel() { planner.set_max_acceleration(HMI_value.axis, HMI_value.Value); } -void SetMaxAccelX() { HMI_value.axis = X_AXIS, SetIntOnClick(MIN_MAXACCELERATION, default_max_acceleration[X_AXIS] * 2, planner.settings.max_acceleration_mm_per_s2[X_AXIS], ApplyMaxAccel); } -void SetMaxAccelY() { HMI_value.axis = Y_AXIS, SetIntOnClick(MIN_MAXACCELERATION, default_max_acceleration[Y_AXIS] * 2, planner.settings.max_acceleration_mm_per_s2[Y_AXIS], ApplyMaxAccel); } -void SetMaxAccelZ() { HMI_value.axis = Z_AXIS, SetIntOnClick(MIN_MAXACCELERATION, default_max_acceleration[Z_AXIS] * 2, planner.settings.max_acceleration_mm_per_s2[Z_AXIS], ApplyMaxAccel); } +void ApplyMaxAccel() { planner.set_max_acceleration(HMI_value.axis, MenuData.Value); } +void SetMaxAccelX() { HMI_value.axis = X_AXIS, SetIntOnClick(MIN_MAXACCELERATION, max_acceleration_edit_values[X_AXIS], planner.settings.max_acceleration_mm_per_s2[X_AXIS], ApplyMaxAccel); } +void SetMaxAccelY() { HMI_value.axis = Y_AXIS, SetIntOnClick(MIN_MAXACCELERATION, max_acceleration_edit_values[Y_AXIS], planner.settings.max_acceleration_mm_per_s2[Y_AXIS], ApplyMaxAccel); } +void SetMaxAccelZ() { HMI_value.axis = Z_AXIS, SetIntOnClick(MIN_MAXACCELERATION, max_acceleration_edit_values[Z_AXIS], planner.settings.max_acceleration_mm_per_s2[Z_AXIS], ApplyMaxAccel); } #if HAS_HOTEND - void SetMaxAccelE() { HMI_value.axis = E_AXIS; SetIntOnClick(MIN_MAXACCELERATION, default_max_acceleration[E_AXIS] * 2, planner.settings.max_acceleration_mm_per_s2[E_AXIS], ApplyMaxAccel); } + void SetMaxAccelE() { HMI_value.axis = E_AXIS; SetIntOnClick(MIN_MAXACCELERATION, max_acceleration_edit_values[E_AXIS], planner.settings.max_acceleration_mm_per_s2[E_AXIS], ApplyMaxAccel); } #endif #if HAS_CLASSIC_JERK - void ApplyMaxJerk() { planner.set_max_jerk(HMI_value.axis, HMI_value.Value / MINUNITMULT); } - void SetMaxJerkX() { HMI_value.axis = X_AXIS, SetFloatOnClick(MIN_MAXJERK, default_max_jerk[X_AXIS] * 2, UNITFDIGITS, planner.max_jerk[X_AXIS], ApplyMaxJerk); } - void SetMaxJerkY() { HMI_value.axis = Y_AXIS, SetFloatOnClick(MIN_MAXJERK, default_max_jerk[Y_AXIS] * 2, UNITFDIGITS, planner.max_jerk[Y_AXIS], ApplyMaxJerk); } - void SetMaxJerkZ() { HMI_value.axis = Z_AXIS, SetFloatOnClick(MIN_MAXJERK, default_max_jerk[Z_AXIS] * 2, UNITFDIGITS, planner.max_jerk[Z_AXIS], ApplyMaxJerk); } + 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); } #if HAS_HOTEND - void SetMaxJerkE() { HMI_value.axis = E_AXIS; SetFloatOnClick(MIN_MAXJERK, default_max_jerk[E_AXIS] * 2, 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_AXIS], ApplyMaxJerk); } #endif #endif @@ -2546,88 +2594,42 @@ void SetStepsZ() { HMI_value.axis = Z_AXIS, SetPFloatOnClick( MIN_STEP, MAX_STEP void SetHotendPidT() { SetPIntOnClick(MIN_ETEMP, MAX_ETEMP); } #endif #if HAS_HEATED_BED - void SetBedPidT() { SetPIntOnClick(BED_MINTEMP, BED_MAX_TARGET); } + void SetBedPidT() { SetPIntOnClick(MIN_BEDTEMP, MAX_BEDTEMP); } #endif #if HAS_HOTEND || HAS_HEATED_BED void SetPidCycles() { SetPIntOnClick(3, 50); } void SetKp() { SetPFloatOnClick(0, 1000, 2); } void ApplyPIDi() { - *HMI_value.P_Float = scalePID_i(HMI_value.Value / POW(10, 2)); + *MenuData.P_Float = scalePID_i(MenuData.Value / POW(10, 2)); thermalManager.updatePID(); } void ApplyPIDd() { - *HMI_value.P_Float = scalePID_d(HMI_value.Value / POW(10, 2)); + *MenuData.P_Float = scalePID_d(MenuData.Value / POW(10, 2)); thermalManager.updatePID(); } void SetKi() { - HMI_value.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; - const float value = unscalePID_i(*HMI_value.P_Float); + MenuData.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; + const float value = unscalePID_i(*MenuData.P_Float); SetFloatOnClick(0, 1000, 2, value, ApplyPIDi); } void SetKd() { - HMI_value.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; - const float value = unscalePID_d(*HMI_value.P_Float); + MenuData.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; + const float value = unscalePID_d(*MenuData.P_Float); SetFloatOnClick(0, 1000, 2, value, ApplyPIDd); } #endif -// Menuitem Drawing functions ================================================= - -void onDrawMenuItem(MenuItemClass* menuitem, int8_t line) { - if (menuitem->icon) DWINUI::Draw_Icon(menuitem->icon, ICOX, MBASE(line) - 3); - if (menuitem->frameid) - DWIN_Frame_AreaCopy(menuitem->frameid, menuitem->frame.left, menuitem->frame.top, menuitem->frame.right, menuitem->frame.bottom, LBLX, MBASE(line)); - else if (menuitem->caption) - DWINUI::Draw_String(LBLX, MBASE(line) - 1, menuitem->caption); - DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); -} - -void onDrawSubMenu(MenuItemClass* menuitem, int8_t line) { - onDrawMenuItem(menuitem, line); - DWINUI::Draw_Icon(ICON_More, VALX + 16, MBASE(line) - 3); -} - -void onDrawIntMenu(MenuItemClass* menuitem, int8_t line, uint16_t value) { - onDrawMenuItem(menuitem, line); - Draw_Menu_IntValue(HMI_data.Background_Color, line, 4, value); -} - -void onDrawPIntMenu(MenuItemClass* menuitem, int8_t line) { - const uint16_t value = *(uint16_t*)static_cast(menuitem)->value; - onDrawIntMenu(menuitem, line, value); -} - -void onDrawPInt8Menu(MenuItemClass* menuitem, int8_t line) { - const uint8_t value = *(uint8_t*)static_cast(menuitem)->value; - onDrawIntMenu(menuitem, line, value); -} - -void onDrawPInt32Menu(MenuItemClass* menuitem, int8_t line) { - const uint32_t value = *(uint32_t*)static_cast(menuitem)->value; - onDrawIntMenu(menuitem, line, value); -} - -void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value) { - onDrawMenuItem(menuitem, line); - 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) { - 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); -} +#if ENABLED(FWRETRACT) + void Return_FWRetract_Menu() { (PreviousMenu == FilSetMenu) ? Draw_FilSet_Menu() : Draw_Tune_Menu(); } + void SetRetractLength() { SetPFloatOnClick( 0, 10, UNITFDIGITS); } + void SetRetractSpeed() { SetPFloatOnClick( 1, 90, UNITFDIGITS); } + void SetZRaise() { SetPFloatOnClick( 0, 2, 2); } + void SetRecoverSpeed() { SetPFloatOnClick( 1, 90, UNITFDIGITS); } + void SetAddRecover() { SetPFloatOnClick(-5, 5, UNITFDIGITS); } +#endif -void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line, bool checked) { - onDrawMenuItem(menuitem, line); - Draw_Chkb_Line(line, checked); -} +// Special Menuitem Drawing functions ================================================= void onDrawBack(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) menuitem->SetFrame(1, 129, 72, 156, 84); @@ -2704,7 +2706,7 @@ void onDrawAutoHome(MenuItemClass* menuitem, int8_t line) { } #if HAS_ZOFFSET_ITEM - #if EITHER(HAS_BED_PROBE, BABYSTEPPING) + #if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) void onDrawZOffset(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) menuitem->SetFrame(1, 174, 164, 223, 177); onDrawPFloat2Menu(menuitem, line); @@ -2722,10 +2724,12 @@ void onDrawAutoHome(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) menuitem->SetFrame(1, 100, 89, 151, 101); onDrawMenuItem(menuitem, line); } - void onDrawPreheat2(MenuItemClass* menuitem, int8_t line) { - if (HMI_IsChinese()) menuitem->SetFrame(1, 180, 89, 233, 100); - onDrawMenuItem(menuitem, line); - } + #if PREHEAT_COUNT > 1 + void onDrawPreheat2(MenuItemClass* menuitem, int8_t line) { + if (HMI_IsChinese()) menuitem->SetFrame(1, 180, 89, 233, 100); + onDrawMenuItem(menuitem, line); + } + #endif #endif #if HAS_PREHEAT @@ -2741,12 +2745,6 @@ void onDrawLanguage(MenuItemClass* menuitem, int8_t line) { DWINUI::Draw_String(VALX, MBASE(line), HMI_IsChinese() ? F("CN") : F("EN")); } -#if ENABLED(POWER_LOSS_RECOVERY) - void onDrawPwrLossR(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, recovery.enabled); } -#endif - -void onDrawEnableSound(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, ui.buzzer_enabled); } - void onDrawSelColorItem(MenuItemClass* menuitem, int8_t line) { const uint16_t color = *(uint16_t*)static_cast(menuitem)->value; DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, ICOX + 1, MBASE(line) - 1 + 1, ICOX + 18, MBASE(line) - 1 + 18); @@ -2838,10 +2836,12 @@ void onDrawSteps(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) menuitem->SetFrame(1, 100, 89, 178, 101); onDrawSubMenu(menuitem,line); } - void onDrawABSPreheatSubMenu(MenuItemClass* menuitem, int8_t line) { - if (HMI_IsChinese()) menuitem->SetFrame(1, 180, 89, 260, 100); - 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) { @@ -2853,7 +2853,7 @@ void onDrawSpeed(MenuItemClass* menuitem, int8_t line) { void onDrawMaxSpeedX(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 228, 147); - DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 58, MBASE(line)); // X + DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 58, MBASE(line)); // X } onDrawPFloatMenu(menuitem, line); } @@ -2861,7 +2861,7 @@ void onDrawMaxSpeedX(MenuItemClass* menuitem, int8_t line) { void onDrawMaxSpeedY(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 228, 147); - DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 58, MBASE(line)); // Y + DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 58, MBASE(line)); // Y } onDrawPFloatMenu(menuitem, line); } @@ -2869,7 +2869,7 @@ void onDrawMaxSpeedY(MenuItemClass* menuitem, int8_t line) { void onDrawMaxSpeedZ(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 228, 147); - DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 58, MBASE(line) + 3); // Z + DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 58, MBASE(line) + 3); // Z } onDrawPFloatMenu(menuitem, line); } @@ -2878,7 +2878,7 @@ void onDrawMaxSpeedZ(MenuItemClass* menuitem, int8_t line) { void onDrawMaxSpeedE(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 228, 147); - DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 58, MBASE(line)); // E + DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 58, MBASE(line)); // E } onDrawPFloatMenu(menuitem, line); } @@ -2887,7 +2887,7 @@ void onDrawMaxSpeedZ(MenuItemClass* menuitem, int8_t line) { void onDrawAcc(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); - DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line) + 1); // ...Acceleration + DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line) + 1); // ...Acceleration } onDrawSubMenu(menuitem, line); } @@ -2896,7 +2896,7 @@ void onDrawMaxAccelX(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); - DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 71, MBASE(line)); // X + DWIN_Frame_AreaCopy(1, 229, 133, 236, 147, LBLX + 71, MBASE(line)); // X } onDrawPInt32Menu(menuitem, line); } @@ -2904,8 +2904,8 @@ void onDrawMaxAccelX(MenuItemClass* menuitem, int8_t line) { void onDrawMaxAccelY(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); - DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); - DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 71, MBASE(line)); // Y + DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); + DWIN_Frame_AreaCopy(1, 1, 150, 7, 160, LBLX + 71, MBASE(line)); // Y } onDrawPInt32Menu(menuitem, line); } @@ -2913,8 +2913,8 @@ void onDrawMaxAccelY(MenuItemClass* menuitem, int8_t line) { void onDrawMaxAccelZ(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); - DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); - DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 71, MBASE(line)); // Z + DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); + DWIN_Frame_AreaCopy(1, 9, 150, 16, 160, LBLX + 71, MBASE(line)); // Z } onDrawPInt32Menu(menuitem, line); } @@ -2923,8 +2923,8 @@ void onDrawMaxAccelZ(MenuItemClass* menuitem, int8_t line) { void onDrawMaxAccelE(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); - DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); - DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 71, MBASE(line)); // E + DWIN_Frame_AreaCopy(1, 28, 149, 69, 161, LBLX + 27, MBASE(line)); + DWIN_Frame_AreaCopy(1, 18, 150, 25, 160, LBLX + 71, MBASE(line)); // E } onDrawPInt32Menu(menuitem, line); } @@ -2935,7 +2935,7 @@ void onDrawMaxAccelZ(MenuItemClass* menuitem, int8_t line) { void onDrawJerk(MenuItemClass* menuitem, int8_t line) { if (HMI_IsChinese()) { menuitem->SetFrame(1, 173, 133, 200, 147); - DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(line) + 1); // ... + DWIN_Frame_AreaCopy(1, 1, 180, 28, 192, LBLX + 27, MBASE(line) + 1); // ... DWIN_Frame_AreaCopy(1, 202, 133, 228, 147, LBLX + 54, MBASE(line)); // ...Jerk } onDrawSubMenu(menuitem, line); @@ -3019,134 +3019,9 @@ void onDrawStepsZ(MenuItemClass* menuitem, int8_t line) { } #endif -// HMI Control functions ====================================================== - -// Generic menu control using the encoder -void HMI_Menu() { - EncoderState encoder_diffState = get_encoder_state(); - if (encoder_diffState == ENCODER_DIFF_NO) return; - if (encoder_diffState == ENCODER_DIFF_ENTER) { - if (CurrentMenu != nullptr) CurrentMenu->onClick(); - } else if (CurrentMenu != nullptr) CurrentMenu->onScroll(encoder_diffState == ENCODER_DIFF_CW); -} - -// Get an integer value using the encoder without draw anything -// lo: low limit -// hi: high limit -// Return value: -// 0 : no change -// 1 : live change -// 2 : apply change -int8_t HMI_GetIntNoDraw(const int32_t lo, const int32_t hi) { - EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, HMI_value.Value)) { - EncoderRate.enabled = false; - checkkey = Menu; - return 2; - } - LIMIT(HMI_value.Value, lo, hi); - return 1; - } - return 0; -} - -// 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(); - if (encoder_diffState != ENCODER_DIFF_NO) { - if (Apply_Encoder(encoder_diffState, HMI_value.Value)) { - EncoderRate.enabled = false; - DWINUI::Draw_Int(HMI_data.Text_Color, HMI_data.Background_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, HMI_value.Value); - checkkey = Menu; - return 2; - } - LIMIT(HMI_value.Value, lo, hi); - DWINUI::Draw_Int(HMI_data.Text_Color, HMI_data.Selected_Color, 4 , VALX, MBASE(CurrentMenu->line()) - 1, HMI_value.Value); - return 1; - } - return 0; -} - -// Set an integer using the encoder -void HMI_SetInt() { - int8_t val = HMI_GetInt(HMI_value.MinValue, HMI_value.MaxValue); - switch (val) { - case 0: return; break; - case 1: if (HMI_value.LiveUpdate != nullptr) HMI_value.LiveUpdate(); break; - case 2: if (HMI_value.Apply != nullptr) HMI_value.Apply(); break; - } -} - -// Set an integer without drawing -void HMI_SetIntNoDraw() { - int8_t val = HMI_GetIntNoDraw(HMI_value.MinValue, HMI_value.MaxValue); - switch (val) { - case 0: return; break; - case 1: if (HMI_value.LiveUpdate != nullptr) HMI_value.LiveUpdate(); break; - case 2: if (HMI_value.Apply != nullptr) HMI_value.Apply(); break; - } -} - -// Set an integer pointer variable using the encoder -void HMI_SetPInt() { - int8_t val = HMI_GetInt(HMI_value.MinValue, HMI_value.MaxValue); - switch (val) { - case 0: return; - case 1: if (HMI_value.LiveUpdate != nullptr) HMI_value.LiveUpdate(); break; - case 2: *HMI_value.P_Int = HMI_value.Value; if (HMI_value.Apply != nullptr) HMI_value.Apply(); break; - } -} - -// 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, HMI_value.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()), HMI_value.Value / POW(10, dp)); - checkkey = Menu; - return 2; - } - LIMIT(HMI_value.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()), HMI_value.Value / POW(10, dp)); - return 1; - } - return 0; -} - -// Set a scaled float using the encoder -void HMI_SetFloat() { - const int8_t val = HMI_GetFloat(HMI_value.dp, HMI_value.MinValue, HMI_value.MaxValue); - switch (val) { - case 0: return; - case 1: if (HMI_value.LiveUpdate != nullptr) HMI_value.LiveUpdate(); break; - case 2: if (HMI_value.Apply != nullptr) HMI_value.Apply(); break; - } -} - -// Set a scaled float pointer variable using the encoder -void HMI_SetPFloat() { - const int8_t val = HMI_GetFloat(HMI_value.dp, HMI_value.MinValue, HMI_value.MaxValue); - switch (val) { - case 0: return; - case 1: if (HMI_value.LiveUpdate != nullptr) HMI_value.LiveUpdate(); break; - case 2: *HMI_value.P_Float = HMI_value.Value / POW(10, HMI_value.dp); if (HMI_value.Apply != nullptr) HMI_value.Apply(); break; - } -} +#if HAS_ONESTEP_LEVELING + void onDrawManualTramming(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, HMI_data.FullManualTramming); } +#endif // Menu Creation and Drawing functions ====================================================== @@ -3159,282 +3034,341 @@ void SetMenuTitle(frame_rect_t cn, const __FlashStringHelper* fstr) { void Draw_Prepare_Menu() { checkkey = Menu; - if (PrepareMenu == nullptr) PrepareMenu = new MenuClass(); + if (!PrepareMenu) PrepareMenu = new MenuClass(); if (CurrentMenu != PrepareMenu) { CurrentMenu = PrepareMenu; SetMenuTitle({133, 1, 28, 13}, GET_TEXT_F(MSG_PREPARE)); - DWINUI::MenuItemsPrepare(13); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Goto_Main_Menu); + MenuItemsPrepare(13); + BACK_ITEM(Goto_Main_Menu); #if ENABLED(ADVANCED_PAUSE_FEATURE) - ADDMENUITEM(ICON_FilMan, GET_TEXT_F(MSG_FILAMENT_MAN), onDrawSubMenu, Draw_FilamentMan_Menu); + MENU_ITEM_F(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); + #if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) + MENU_ITEM_F(ICON_Homing, MSG_HOMING, onDrawSubMenu, Draw_Homing_Menu); + #else + MENU_ITEM_F(ICON_Homing, MSG_AUTO_HOME, onDrawAutoHome, AutoHome); #endif - ADDMENUITEM(ICON_Axis, GET_TEXT_F(MSG_MOVE_AXIS), onDrawMoveSubMenu, Draw_Move_Menu); - ADDMENUITEM(ICON_LevBed, GET_TEXT_F(MSG_BED_LEVELING), onDrawSubMenu, Draw_LevBedCorners_Menu); - ADDMENUITEM(ICON_CloseMotor, GET_TEXT_F(MSG_DISABLE_STEPPERS), onDrawDisableMotors, DisableMotors); - ADDMENUITEM(ICON_Homing, GET_TEXT_F(MSG_AUTO_HOME), onDrawAutoHome, AutoHome); #if ENABLED(MESH_BED_LEVELING) - ADDMENUITEM(ICON_ManualMesh, GET_TEXT_F(MSG_MANUAL_MESH), onDrawSubMenu, Draw_ManualMesh_Menu); + 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); #endif #if HAS_ZOFFSET_ITEM - #if EITHER(HAS_BED_PROBE, BABYSTEPPING) - ADDMENUITEM(ICON_SetZOffset, GET_TEXT_F(MSG_PROBE_WIZARD), onDrawSubMenu, Draw_ZOffsetWiz_Menu); + #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 - ADDMENUITEM(ICON_SetHome, GET_TEXT_F(MSG_SET_HOME_OFFSETS), onDrawHomeOffset, SetHome); + MENU_ITEM_F(ICON_SetHome, MSG_SET_HOME_OFFSETS, onDrawHomeOffset, SetHome); #endif #endif #if HAS_PREHEAT - ADDMENUITEM(ICON_PLAPreheat, GET_TEXT_F(MSG_PREHEAT_1), onDrawPreheat1, DoPreheat0); + MENU_ITEM_F(ICON_PLAPreheat, MSG_PREHEAT_1, onDrawPreheat1, DoPreheat0); #if PREHEAT_COUNT > 1 - ADDMENUITEM(ICON_ABSPreheat, PSTR("Preheat " PREHEAT_2_LABEL), onDrawPreheat2, DoPreheat1); - #endif - #if PREHEAT_COUNT > 2 - ADDMENUITEM(ICON_CustomPreheat, GET_TEXT_F(MSG_PREHEAT_CUSTOM), onDrawMenuItem, DoPreheat2); + 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 #endif - ADDMENUITEM(ICON_Cool, GET_TEXT_F(MSG_COOLDOWN), onDrawCooldown, DoCoolDown); - ADDMENUITEM(ICON_Language, PSTR("UI Language"), onDrawLanguage, SetLanguage); + MENU_ITEM_F(ICON_Cool, MSG_COOLDOWN, onDrawCooldown, DoCoolDown); + MENU_ITEM_F(ICON_Language, MSG_UI_LANGUAGE, onDrawLanguage, SetLanguage); } + ui.reset_status(true); CurrentMenu->draw(); } -void Draw_LevBedCorners_Menu() { - DWINUI::ClearMenuArea(); +void Draw_Tramming_Menu() { checkkey = Menu; - if (LevBedMenu == nullptr) LevBedMenu = new MenuClass(); - if (CurrentMenu != LevBedMenu) { - CurrentMenu = LevBedMenu; - SetMenuTitle({0}, GET_TEXT_F(MSG_BED_TRAMMING)); // TODO: Chinese, English "Bed Tramming" JPG - DWINUI::MenuItemsPrepare(6); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Prepare_Menu); - ADDMENUITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_FL), onDrawMenuItem, LevBedFL); - ADDMENUITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_FR), onDrawMenuItem, LevBedFR); - ADDMENUITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_BR), onDrawMenuItem, LevBedBR); - ADDMENUITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_BL), onDrawMenuItem, LevBedBL); - ADDMENUITEM(ICON_Axis, GET_TEXT_F(MSG_LEVBED_C ), onDrawMenuItem, LevBedC ); + if (SetMenu(TrammingMenu, GET_TEXT_F(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); + #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 ); } - CurrentMenu->draw(); + UpdateMenu(TrammingMenu); } void Draw_Control_Menu() { checkkey = Menu; - if (ControlMenu == nullptr) ControlMenu = new MenuClass(); + if (!ControlMenu) ControlMenu = new MenuClass(); if (CurrentMenu != ControlMenu) { CurrentMenu = ControlMenu; SetMenuTitle({103, 1, 28, 14}, GET_TEXT_F(MSG_CONTROL)); - DWINUI::MenuItemsPrepare(9); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Goto_Main_Menu); - ADDMENUITEM(ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE), onDrawTempSubMenu, Draw_Temperature_Menu); - ADDMENUITEM(ICON_Motion, GET_TEXT_F(MSG_MOTION), onDrawMotionSubMenu, Draw_Motion_Menu); + MenuItemsPrepare(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); #if ENABLED(EEPROM_SETTINGS) - ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT_F(MSG_STORE_EEPROM), onDrawWriteEeprom, WriteEeprom); - ADDMENUITEM(ICON_ReadEEPROM, GET_TEXT_F(MSG_LOAD_EEPROM), onDrawReadEeprom, ReadEeprom); - ADDMENUITEM(ICON_ResumeEEPROM, GET_TEXT_F(MSG_RESTORE_DEFAULTS), onDrawResetEeprom, ResetEeprom); + 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); #endif - ADDMENUITEM(ICON_Reboot, GET_TEXT_F(MSG_RESET_PRINTER), onDrawMenuItem, RebootPrinter); - ADDMENUITEM(ICON_AdvSet, GET_TEXT_F(MSG_ADVANCED_SETTINGS), onDrawSubMenu, Draw_AdvancedSettings_Menu); - ADDMENUITEM(ICON_Info, GET_TEXT_F(MSG_INFO_SCREEN), onDrawInfoSubMenu, Goto_InfoMenu); + MENU_ITEM_F(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); + #else + MENU_ITEM_F(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); + #endif + MENU_ITEM_F(ICON_Info, MSG_INFO_SCREEN, onDrawInfoSubMenu, Goto_Info_Menu); } + ui.reset_status(true); CurrentMenu->draw(); } void Draw_AdvancedSettings_Menu() { checkkey = Menu; - if (AdvancedSettings == nullptr) AdvancedSettings = new MenuClass(); - if (CurrentMenu != AdvancedSettings) { - CurrentMenu = AdvancedSettings; - SetMenuTitle({0}, GET_TEXT_F(MSG_ADVANCED_SETTINGS)); // TODO: Chinese, English "Advanced Settings" JPG - DWINUI::MenuItemsPrepare(12); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Control_Menu); - #if HAS_HOME_OFFSET - ADDMENUITEM(ICON_HomeOffset, GET_TEXT_F(MSG_SET_HOME_OFFSETS), onDrawSubMenu, Draw_HomeOffset_Menu); + if (SetMenu(AdvancedSettings, GET_TEXT_F(MSG_ADVANCED_SETTINGS), 20)) { + BACK_ITEM(Goto_Main_Menu); + #if ENABLED(EEPROM_SETTINGS) + MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); #endif #if HAS_BED_PROBE - ADDMENUITEM(ICON_ProbeSet, GET_TEXT_F(MSG_ZPROBE_SETTINGS), onDrawSubMenu, Draw_ProbeSet_Menu); + MENU_ITEM_F(ICON_ProbeSet, MSG_ZPROBE_SETTINGS, onDrawSubMenu, Draw_ProbeSet_Menu); + #endif + #if HAS_MESH + MENU_ITEM_F(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); #endif #if HAS_HOTEND - ADDMENUITEM(ICON_PIDNozzle, F("Hotend PID Settings"), onDrawSubMenu, Draw_HotendPID_Menu); + MENU_ITEM(ICON_PIDNozzle, F(STR_HOTEND_PID " Settings"), onDrawSubMenu, Draw_HotendPID_Menu); #endif #if HAS_HEATED_BED - ADDMENUITEM(ICON_PIDbed, F("Bed PID Settings"), onDrawSubMenu, Draw_BedPID_Menu); - #endif - #if HAS_FILAMENT_SENSOR - ADDMENUITEM(ICON_FilSet, GET_TEXT_F(MSG_FILAMENT_SET), onDrawSubMenu, Draw_FilSet_Menu); + MENU_ITEM(ICON_PIDbed, F(STR_BED_PID " Settings"), onDrawSubMenu, Draw_BedPID_Menu); #endif + MENU_ITEM_F(ICON_FilSet, MSG_FILAMENT_SET, onDrawSubMenu, Draw_FilSet_Menu); #if ENABLED(POWER_LOSS_RECOVERY) - ADDMENUITEM(ICON_Pwrlossr, GET_TEXT_F(MSG_OUTAGE_RECOVERY), onDrawPwrLossR, SetPwrLossr); + EDIT_ITEM_F(ICON_Pwrlossr, MSG_OUTAGE_RECOVERY, onDrawChkbMenu, SetPwrLossr, &recovery.enabled); + #endif + #if ENABLED(BAUD_RATE_GCODE) + EDIT_ITEM(ICON_SetBaudRate, F("115K baud"), onDrawChkbMenu, SetBaudRate, &HMI_data.Baud115K); #endif #if HAS_LCD_BRIGHTNESS - ADDMENUITEM_P(ICON_Brightness, GET_TEXT_F(MSG_BRIGHTNESS), onDrawPInt8Menu, SetBrightness, &ui.brightness); + EDIT_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); + MENU_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, TurnOffBacklight); #endif - ADDMENUITEM(ICON_Scolor, F("Select Colors"), onDrawSubMenu, Draw_SelectColors_Menu); + MENU_ITEM_F(ICON_Scolor, MSG_COLORS_SELECT, onDrawSubMenu, Draw_SelectColors_Menu); #if ENABLED(SOUND_MENU_ITEM) - ADDMENUITEM(ICON_Sound, F("Enable Sound"), onDrawEnableSound, SetEnableSound); + EDIT_ITEM_F(ICON_Sound, MSG_SOUND_ENABLE, onDrawChkbMenu, SetEnableSound, &ui.sound_on); #endif - #if HAS_MESH - ADDMENUITEM(ICON_MeshViewer, GET_TEXT_F(MSG_MESH_VIEW), onDrawSubMenu, DWIN_MeshViewer); + #if HAS_ESDIAG + MENU_ITEM(ICON_ESDiag, F("End-stops diag."), onDrawSubMenu, Draw_EndStopDiag); + #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); #endif - ADDMENUITEM(ICON_Lock, F("Lock Screen"), onDrawMenuItem, Goto_LockScreen); + MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); } - CurrentMenu->draw(); + ui.reset_status(true); + UpdateMenu(AdvancedSettings); } void Draw_Move_Menu() { checkkey = Menu; - if (MoveMenu == nullptr) MoveMenu = new MenuClass(); + if (!MoveMenu) MoveMenu = new MenuClass(); if (CurrentMenu != MoveMenu) { CurrentMenu = MoveMenu; SetMenuTitle({192, 1, 42, 14}, GET_TEXT_F(MSG_MOVE_AXIS)); - DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Prepare_Menu); - ADDMENUITEM_P(ICON_MoveX, GET_TEXT_F(MSG_MOVE_X), onDrawMoveX, SetMoveX, ¤t_position.x); - ADDMENUITEM_P(ICON_MoveY, GET_TEXT_F(MSG_MOVE_Y), onDrawMoveY, SetMoveY, ¤t_position.y); - ADDMENUITEM_P(ICON_MoveZ, GET_TEXT_F(MSG_MOVE_Z), onDrawMoveZ, SetMoveZ, ¤t_position.z); + MenuItemsPrepare(5); + 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); #if HAS_HOTEND - ADDMENUITEM_P(ICON_Extruder, GET_TEXT_F(MSG_MOVE_E), onDrawMoveE, SetMoveE, ¤t_position.e); + EDIT_ITEM_F(ICON_Extruder, MSG_MOVE_E, onDrawMoveE, SetMoveE, ¤t_position.e); #endif } CurrentMenu->draw(); - if (!all_axes_trusted()) LCD_MESSAGE_F("WARNING: position is unknown"); + if (!all_axes_trusted()) LCD_MESSAGE_F("WARNING: Current position unknown. Home axes."); } #if HAS_HOME_OFFSET void Draw_HomeOffset_Menu() { checkkey = Menu; - if (HomeOffMenu == nullptr) HomeOffMenu = new MenuClass(); - if (CurrentMenu != HomeOffMenu) { - CurrentMenu = HomeOffMenu; - SetMenuTitle({0}, GET_TEXT_F(MSG_SET_HOME_OFFSETS)); // TODO: Chinese, English "Set Home Offsets" JPG - DWINUI::MenuItemsPrepare(4); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_AdvancedSettings_Menu); - ADDMENUITEM_P(ICON_HomeOffsetX, GET_TEXT_F(MSG_HOME_OFFSET_X), onDrawPFloatMenu, SetHomeOffsetX, &home_offset[X_AXIS]); - ADDMENUITEM_P(ICON_HomeOffsetY, GET_TEXT_F(MSG_HOME_OFFSET_Y), onDrawPFloatMenu, SetHomeOffsetY, &home_offset[Y_AXIS]); - ADDMENUITEM_P(ICON_HomeOffsetZ, GET_TEXT_F(MSG_HOME_OFFSET_Z), onDrawPFloatMenu, SetHomeOffsetZ, &home_offset[Z_AXIS]); + 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); } - CurrentMenu->draw(); + UpdateMenu(HomeOffMenu); } #endif #if HAS_BED_PROBE void Draw_ProbeSet_Menu() { checkkey = Menu; - if (ProbeSetMenu == nullptr) ProbeSetMenu = new MenuClass(); - if (CurrentMenu != ProbeSetMenu) { - CurrentMenu = ProbeSetMenu; - SetMenuTitle({0}, GET_TEXT_F(MSG_ZPROBE_SETTINGS)); // TODO: Chinese, English "Probe Settings" JPG - DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_AdvancedSettings_Menu); - ADDMENUITEM_P(ICON_ProbeOffsetX, GET_TEXT_F(MSG_ZPROBE_XOFFSET), onDrawPFloatMenu, SetProbeOffsetX, &probe.offset.x); - ADDMENUITEM_P(ICON_ProbeOffsetY, GET_TEXT_F(MSG_ZPROBE_YOFFSET), onDrawPFloatMenu, SetProbeOffsetY, &probe.offset.y); - ADDMENUITEM_P(ICON_ProbeOffsetZ, GET_TEXT_F(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z); - ADDMENUITEM(ICON_ProbeTest, GET_TEXT_F(MSG_M48_TEST), onDrawMenuItem, ProbeTest); + if (SetMenu(ProbeSetMenu, GET_TEXT_F(MSG_ZPROBE_SETTINGS), 8)) { + 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); + #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); } - CurrentMenu->draw(); + UpdateMenu(ProbeSetMenu); } + #endif -#if HAS_FILAMENT_SENSOR - void Draw_FilSet_Menu() { - checkkey = Menu; - if (FilSetMenu == nullptr) FilSetMenu = new MenuClass(); - if (CurrentMenu != FilSetMenu) { - CurrentMenu = FilSetMenu; - CurrentMenu->MenuTitle.SetCaption(GET_TEXT_F(MSG_FILAMENT_SET)); - DWINUI::MenuItemsPrepare(6); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, Draw_AdvancedSettings_Menu); - #if HAS_FILAMENT_SENSOR - ADDMENUITEM(ICON_Runout, GET_TEXT_F(MSG_RUNOUT_ENABLE), onDrawRunoutEnable, SetRunoutEnable); - #endif - #if HAS_FILAMENT_RUNOUT_DISTANCE - ADDMENUITEM_P(ICON_Runout, F("Runout Distance"), onDrawPFloatMenu, SetRunoutDistance, &runout.runout_distance()); - #endif - #if ENABLED(PREVENT_COLD_EXTRUSION) - ADDMENUITEM_P(ICON_ExtrudeMinT, F("Extrude Min Temp."), onDrawPIntMenu, SetExtMinT, &HMI_data.ExtMinT); - #endif - #if ENABLED(ADVANCED_PAUSE_FEATURE) - ADDMENUITEM_P(ICON_FilLoad, GET_TEXT_F(MSG_FILAMENT_LOAD), onDrawPFloatMenu, SetFilLoad, &fc_settings[0].load_length); - ADDMENUITEM_P(ICON_FilUnload, GET_TEXT_F(MSG_FILAMENT_UNLOAD), onDrawPFloatMenu, SetFilUnload, &fc_settings[0].unload_length); - #endif - } - CurrentMenu->draw(); +void Draw_FilSet_Menu() { + checkkey = Menu; + if (SetMenu(FilSetMenu, GET_TEXT_F(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); + #endif + #if HAS_FILAMENT_RUNOUT_DISTANCE + EDIT_ITEM_F(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); + #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); + #endif + #if ENABLED(FWRETRACT) + MENU_ITEM_F(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); + #endif } -#endif // HAS_FILAMENT_SENSOR + UpdateMenu(FilSetMenu); +} void Draw_SelectColors_Menu() { checkkey = Menu; - if (SelectColorMenu == nullptr) SelectColorMenu = new MenuClass(); - if (CurrentMenu != SelectColorMenu) { - CurrentMenu = SelectColorMenu; - SetMenuTitle({0}, F("Select Colors")); // TODO: Chinese, English "Select Color" JPG - DWINUI::MenuItemsPrepare(20); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_AdvancedSettings_Menu); - ADDMENUITEM(ICON_StockConfiguration, GET_TEXT_F(MSG_RESTORE_DEFAULTS), onDrawMenuItem, RestoreDefaultsColors); - ADDMENUITEM_P(0, "Screen Background", onDrawSelColorItem, SelColor, &HMI_data.Background_Color); - ADDMENUITEM_P(0, "Cursor", onDrawSelColorItem, SelColor, &HMI_data.Cursor_color); - ADDMENUITEM_P(0, "Title Background", onDrawSelColorItem, SelColor, &HMI_data.TitleBg_color); - ADDMENUITEM_P(0, "Title Text", onDrawSelColorItem, SelColor, &HMI_data.TitleTxt_color); - ADDMENUITEM_P(0, "Text", onDrawSelColorItem, SelColor, &HMI_data.Text_Color); - ADDMENUITEM_P(0, "Selected", onDrawSelColorItem, SelColor, &HMI_data.Selected_Color); - ADDMENUITEM_P(0, "Split Line", onDrawSelColorItem, SelColor, &HMI_data.SplitLine_Color); - ADDMENUITEM_P(0, "Highlight", onDrawSelColorItem, SelColor, &HMI_data.Highlight_Color); - ADDMENUITEM_P(0, "Status Background", onDrawSelColorItem, SelColor, &HMI_data.StatusBg_Color); - ADDMENUITEM_P(0, "Status Text", onDrawSelColorItem, SelColor, &HMI_data.StatusTxt_Color); - ADDMENUITEM_P(0, "Popup Background", onDrawSelColorItem, SelColor, &HMI_data.PopupBg_color); - ADDMENUITEM_P(0, "Popup Text", onDrawSelColorItem, SelColor, &HMI_data.PopupTxt_Color); - ADDMENUITEM_P(0, "Alert Background", onDrawSelColorItem, SelColor, &HMI_data.AlertBg_Color); - ADDMENUITEM_P(0, "Alert Text", onDrawSelColorItem, SelColor, &HMI_data.AlertTxt_Color); - ADDMENUITEM_P(0, "Percent Text", onDrawSelColorItem, SelColor, &HMI_data.PercentTxt_Color); - ADDMENUITEM_P(0, "Bar Fill", onDrawSelColorItem, SelColor, &HMI_data.Barfill_Color); - ADDMENUITEM_P(0, "Indicator value", onDrawSelColorItem, SelColor, &HMI_data.Indicator_Color); - ADDMENUITEM_P(0, "Coordinate value", onDrawSelColorItem, SelColor, &HMI_data.Coordinate_Color); - } - CurrentMenu->draw(); + if (SetMenu(SelectColorMenu, GET_TEXT_F(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); + } + UpdateMenu(SelectColorMenu); } void Draw_GetColor_Menu() { checkkey = Menu; - if (GetColorMenu == nullptr) GetColorMenu = new MenuClass(); - if (CurrentMenu != GetColorMenu) { - CurrentMenu = GetColorMenu; - SetMenuTitle({0}, F("Get Color")); // TODO: Chinese, English "Get Color" JPG - DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, DWIN_ApplyColor); - ADDMENUITEM(ICON_Cancel, GET_TEXT_F(MSG_BUTTON_CANCEL), onDrawMenuItem, Draw_SelectColors_Menu); - ADDMENUITEM(0, "Red", onDrawGetColorItem, SetRGBColor); - ADDMENUITEM(1, "Green", onDrawGetColorItem, SetRGBColor); - ADDMENUITEM(2, "Blue", onDrawGetColorItem, SetRGBColor); + if (SetMenu(GetColorMenu, GET_TEXT_F(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); } - CurrentMenu->draw(); - DWIN_Draw_Rectangle(1, *HMI_value.P_Int, 20, 315, DWIN_WIDTH - 20, 335); + 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); + } +#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); + #if ENABLED(HAS_WHITE_LED) + EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_WHITE, onDrawPInt8Menu, SetLedColorW, &leds.color.w); + #endif + #endif + } + UpdateMenu(LedControlMenu); + } +#endif + void Draw_Tune_Menu() { checkkey = Menu; - if (TuneMenu == nullptr) TuneMenu = new MenuClass(); + 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 - DWINUI::MenuItemsPrepare(10); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Goto_PrintProcess); - ADDMENUITEM_P(ICON_Speed, GET_TEXT_F(MSG_SPEED), onDrawSpeedItem, SetSpeed, &feedrate_percentage); + MenuItemsPrepare(16); + BACK_ITEM(Goto_PrintProcess); + EDIT_ITEM_F(ICON_Speed, MSG_SPEED, onDrawSpeedItem, SetSpeed, &feedrate_percentage); #if HAS_HOTEND - HotendTargetItem = ADDMENUITEM_P(ICON_HotendTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND), onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); + HotendTargetItem = EDIT_ITEM_F(ICON_HotendTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); #endif #if HAS_HEATED_BED - BedTargetItem = ADDMENUITEM_P(ICON_BedTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_BED), onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); + BedTargetItem = EDIT_ITEM_F(ICON_BedTemp, MSG_UBL_SET_TEMP_BED, onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); #endif #if HAS_FAN - FanSpeedItem = ADDMENUITEM_P(ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED), onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); + FanSpeedItem = EDIT_ITEM_F(ICON_FanSpeed, MSG_FAN_SPEED, onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); #endif - #if HAS_ZOFFSET_ITEM && EITHER(HAS_BED_PROBE, BABYSTEPPING) - ADDMENUITEM_P(ICON_Zoffset, GET_TEXT_F(MSG_ZPROBE_ZOFFSET), onDrawZOffset, SetZOffset, &BABY_Z_VAR); + #if HAS_ZOFFSET_ITEM && EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) + EDIT_ITEM_F(ICON_Zoffset, MSG_ZPROBE_ZOFFSET, onDrawZOffset, SetZOffset, &BABY_Z_VAR); #endif - ADDMENUITEM_P(ICON_Flow, GET_TEXT_F(MSG_FLOW), onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); + EDIT_ITEM_F(ICON_Flow, MSG_FLOW, onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); #if ENABLED(ADVANCED_PAUSE_FEATURE) - ADDMENUITEM(ICON_FilMan, GET_TEXT_F(MSG_FILAMENTCHANGE), onDrawMenuItem, ChangeFilament); + MENU_ITEM_F(ICON_FilMan, MSG_FILAMENTCHANGE, onDrawMenuItem, ChangeFilament); #endif - ADDMENUITEM(ICON_Lock, F("Lock Screen"), onDrawMenuItem, Goto_LockScreen); + #if ENABLED(FWRETRACT) + MENU_ITEM_F(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, Draw_FWRetract_Menu); + #endif + MENU_ITEM_F(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, DWIN_LockScreen); #if HAS_LCD_BRIGHTNESS - ADDMENUITEM_P(ICON_Brightness, F("LCD Brightness"), onDrawPInt8Menu, SetBrightness, &ui.brightness); + EDIT_ITEM_F(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, SetBrightness, &ui.brightness); + MENU_ITEM_F(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); + #elif ENABLED(LED_CONTROL_MENU) && DISABLED(CASE_LIGHT_USE_NEOPIXEL) + EDIT_ITEM_F(ICON_LedControl, MSG_LEDS, onDrawChkbMenu, SetLedStatus, &leds.lights_on); #endif } CurrentMenu->draw(); @@ -3442,19 +3376,19 @@ void Draw_Tune_Menu() { void Draw_Motion_Menu() { checkkey = Menu; - if (MotionMenu == nullptr) MotionMenu = new MenuClass(); + 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 - DWINUI::MenuItemsPrepare(6); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Control_Menu); - ADDMENUITEM(ICON_MaxSpeed, GET_TEXT_F(MSG_SPEED), onDrawSpeed, Draw_MaxSpeed_Menu); - ADDMENUITEM(ICON_MaxAccelerated, GET_TEXT_F(MSG_ACCELERATION), onDrawAcc, Draw_MaxAccel_Menu); + MenuItemsPrepare(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); #if HAS_CLASSIC_JERK - ADDMENUITEM(ICON_MaxJerk, GET_TEXT_F(MSG_JERK), onDrawJerk, Draw_MaxJerk_Menu); + MENU_ITEM_F(ICON_MaxJerk, MSG_JERK, onDrawJerk, Draw_MaxJerk_Menu); #endif - ADDMENUITEM(ICON_Step, GET_TEXT_F(MSG_STEPS_PER_MM), onDrawSteps, Draw_Steps_Menu); - ADDMENUITEM_P(ICON_Flow, GET_TEXT_F(MSG_FLOW), onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]); + 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]); } CurrentMenu->draw(); } @@ -3462,39 +3396,31 @@ void Draw_Motion_Menu() { #if ENABLED(ADVANCED_PAUSE_FEATURE) void Draw_FilamentMan_Menu() { checkkey = Menu; - if (FilamentMenu == nullptr) FilamentMenu = new MenuClass(); - if (CurrentMenu != FilamentMenu) { - CurrentMenu = FilamentMenu; - SetMenuTitle({0}, GET_TEXT_F(MSG_FILAMENT_MAN)); // TODO: Chinese, English "Filament Management" JPG - DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Prepare_Menu); - ADDMENUITEM(ICON_Park, GET_TEXT_F(MSG_FILAMENT_PARK_ENABLED), onDrawMenuItem, ParkHead); - ADDMENUITEM(ICON_FilMan, GET_TEXT_F(MSG_FILAMENTCHANGE), onDrawMenuItem, ChangeFilament); + if (SetMenu(FilamentMenu, GET_TEXT_F(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(FILAMENT_LOAD_UNLOAD_GCODES) - ADDMENUITEM(ICON_FilUnload, GET_TEXT_F(MSG_FILAMENTUNLOAD), onDrawMenuItem, UnloadFilament); - ADDMENUITEM(ICON_FilLoad, GET_TEXT_F(MSG_FILAMENTLOAD), onDrawMenuItem, LoadFilament); + MENU_ITEM_F(ICON_FilUnload, MSG_FILAMENTUNLOAD, onDrawMenuItem, UnloadFilament); + MENU_ITEM_F(ICON_FilLoad, MSG_FILAMENTLOAD, onDrawMenuItem, LoadFilament); #endif } - CurrentMenu->draw(); + UpdateMenu(FilamentMenu); } #endif #if ENABLED(MESH_BED_LEVELING) void Draw_ManualMesh_Menu() { checkkey = Menu; - if (ManualMesh == nullptr) ManualMesh = new MenuClass(); - if (CurrentMenu != ManualMesh) { - CurrentMenu = ManualMesh; - SetMenuTitle({0}, GET_TEXT_F(MSG_MANUAL_MESH)); // TODO: Chinese, English "Manual Mesh Leveling" JPG - DWINUI::MenuItemsPrepare(6); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Prepare_Menu); - ADDMENUITEM(ICON_ManualMesh, GET_TEXT_F(MSG_LEVEL_BED), onDrawMenuItem, ManualMeshStart); - MMeshMoveZItem = ADDMENUITEM_P(ICON_Zoffset, GET_TEXT_F(MSG_MOVE_Z), onDrawMMeshMoveZ, SetMMeshMoveZ, ¤t_position.z); - ADDMENUITEM(ICON_Axis, GET_TEXT_F(MSG_UBL_CONTINUE_MESH), onDrawMenuItem, ManualMeshContinue); - ADDMENUITEM(ICON_MeshViewer, GET_TEXT_F(MSG_MESH_VIEW), onDrawSubMenu, DWIN_MeshViewer); - ADDMENUITEM(ICON_MeshSave, GET_TEXT_F(MSG_UBL_SAVE_MESH), onDrawMenuItem, ManualMeshSave); + if (SetMenu(ManualMesh, GET_TEXT_F(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); } - CurrentMenu->draw(); + UpdateMenu(ManualMesh); } #endif @@ -3505,42 +3431,43 @@ void Draw_Motion_Menu() { if (CurrentMenu != PreheatMenu) { CurrentMenu = PreheatMenu; SetMenuTitle(cn, fstr); - DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Temperature_Menu); + MenuItemsPrepare(5); + BACK_ITEM(Draw_Temperature_Menu); #if HAS_HOTEND - ADDMENUITEM_P(ICON_SetEndTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND), onDrawSetPreheatHotend, SetPreheatEndTemp, &ui.material_preset[HMI_value.Preheat].hotend_temp); + EDIT_ITEM_F(ICON_SetEndTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawSetPreheatHotend, SetPreheatEndTemp, &ui.material_preset[HMI_value.Select].hotend_temp); #endif #if HAS_HEATED_BED - ADDMENUITEM_P(ICON_SetBedTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_BED), onDrawSetPreheatBed, SetPreheatBedTemp, &ui.material_preset[HMI_value.Preheat].bed_temp); + EDIT_ITEM_F(ICON_SetBedTemp, MSG_UBL_SET_TEMP_BED, onDrawSetPreheatBed, SetPreheatBedTemp, &ui.material_preset[HMI_value.Select].bed_temp); #endif #if HAS_FAN - ADDMENUITEM_P(ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED), onDrawSetPreheatFan, SetPreheatFanSpeed, &ui.material_preset[HMI_value.Preheat].fan_speed); + EDIT_ITEM_F(ICON_FanSpeed, MSG_FAN_SPEED, onDrawSetPreheatFan, SetPreheatFanSpeed, &ui.material_preset[HMI_value.Select].fan_speed); #endif #if ENABLED(EEPROM_SETTINGS) - ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT_F(MSG_STORE_EEPROM), onDrawWriteEeprom, WriteEeprom); + MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawWriteEeprom, WriteEeprom); #endif } CurrentMenu->draw(); } void Draw_Preheat1_Menu() { - HMI_value.Preheat = 0; - if (PreheatMenu == nullptr) PreheatMenu = new MenuClass(); + 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 } - void Draw_Preheat2_Menu() { - HMI_value.Preheat = 1; - if (PreheatMenu == nullptr) PreheatMenu = new MenuClass(); - Draw_Preheat_Menu({142, 16, 82, 14}, F(PREHEAT_2_LABEL " Preheat Settings")); // TODO: English "ABS 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 - #ifdef PREHEAT_3_LABEL + #if PREHEAT_COUNT >= 3 void Draw_Preheat3_Menu() { - HMI_value.Preheat = 2; - if (PreheatMenu == nullptr) PreheatMenu = new MenuClass(); - #define PREHEAT_3_TITLE PREHEAT_3_LABEL " Preheat Set." - Draw_Preheat_Menu({0}, F(PREHEAT_3_TITLE)); // TODO: Chinese, English "Custom Preheat Settings" JPG + 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 } #endif @@ -3548,26 +3475,28 @@ void Draw_Motion_Menu() { void Draw_Temperature_Menu() { checkkey = Menu; - if (TemperatureMenu == nullptr) TemperatureMenu = new MenuClass(); + if (!TemperatureMenu) TemperatureMenu = new MenuClass(); if (CurrentMenu != TemperatureMenu) { CurrentMenu = TemperatureMenu; SetMenuTitle({236, 2, 28, 12}, GET_TEXT_F(MSG_TEMPERATURE)); - DWINUI::MenuItemsPrepare(7); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Control_Menu); + MenuItemsPrepare(7); + BACK_ITEM(Draw_Control_Menu); #if HAS_HOTEND - HotendTargetItem = ADDMENUITEM_P(ICON_SetEndTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND), onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); + HotendTargetItem = EDIT_ITEM_F(ICON_SetEndTemp, MSG_UBL_SET_TEMP_HOTEND, onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target); #endif #if HAS_HEATED_BED - BedTargetItem = ADDMENUITEM_P(ICON_SetBedTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_BED), onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); + BedTargetItem = EDIT_ITEM_F(ICON_SetBedTemp, MSG_UBL_SET_TEMP_BED, onDrawBedTemp, SetBedTemp, &thermalManager.temp_bed.target); #endif #if HAS_FAN - FanSpeedItem = ADDMENUITEM_P(ICON_FanSpeed, GET_TEXT_F(MSG_FAN_SPEED), onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); + FanSpeedItem = EDIT_ITEM_F(ICON_FanSpeed, MSG_FAN_SPEED, onDrawFanSpeed, SetFanSpeed, &thermalManager.fan_speed[0]); #endif - #if HAS_HOTEND - ADDMENUITEM(ICON_SetPLAPreheat, F(PREHEAT_1_LABEL " Preheat Settings"), onDrawPLAPreheatSubMenu, Draw_Preheat1_Menu); - ADDMENUITEM(ICON_SetABSPreheat, F(PREHEAT_2_LABEL " Preheat Settings"), onDrawABSPreheatSubMenu, Draw_Preheat2_Menu); - #ifdef PREHEAT_3_LABEL - ADDMENUITEM(ICON_SetCustomPreheat, PREHEAT_3_TITLE, onDrawSubMenu, Draw_Preheat3_Menu); + #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 #endif } @@ -3576,17 +3505,17 @@ void Draw_Temperature_Menu() { void Draw_MaxSpeed_Menu() { checkkey = Menu; - if (MaxSpeedMenu == nullptr) MaxSpeedMenu = new MenuClass(); + if (!MaxSpeedMenu) MaxSpeedMenu = new MenuClass(); if (CurrentMenu != MaxSpeedMenu) { CurrentMenu = MaxSpeedMenu; - SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_MAXSPEED)); - DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Motion_Menu); - ADDMENUITEM_P(ICON_MaxSpeedX, GET_TEXT_F(MSG_MAXSPEED_X), onDrawMaxSpeedX, SetMaxSpeedX, &planner.settings.max_feedrate_mm_s[X_AXIS]); - ADDMENUITEM_P(ICON_MaxSpeedY, GET_TEXT_F(MSG_MAXSPEED_Y), onDrawMaxSpeedY, SetMaxSpeedY, &planner.settings.max_feedrate_mm_s[Y_AXIS]); - ADDMENUITEM_P(ICON_MaxSpeedZ, GET_TEXT_F(MSG_MAXSPEED_Z), onDrawMaxSpeedZ, SetMaxSpeedZ, &planner.settings.max_feedrate_mm_s[Z_AXIS]); + SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_MAX_SPEED)); + MenuItemsPrepare(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]); #if HAS_HOTEND - ADDMENUITEM_P(ICON_MaxSpeedE, GET_TEXT_F(MSG_MAXSPEED_E), onDrawMaxSpeedE, SetMaxSpeedE, &planner.settings.max_feedrate_mm_s[Z_AXIS]); + EDIT_ITEM_F(ICON_MaxSpeedE, MSG_VMAX_E, onDrawMaxSpeedE, SetMaxSpeedE, &planner.settings.max_feedrate_mm_s[E_AXIS]); #endif } CurrentMenu->draw(); @@ -3594,17 +3523,17 @@ void Draw_MaxSpeed_Menu() { void Draw_MaxAccel_Menu() { checkkey = Menu; - if (MaxAccelMenu == nullptr) MaxAccelMenu = new MenuClass(); + if (!MaxAccelMenu) MaxAccelMenu = new MenuClass(); if (CurrentMenu != MaxAccelMenu) { CurrentMenu = MaxAccelMenu; SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_ACCELERATION)); - DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Motion_Menu); - ADDMENUITEM_P(ICON_MaxAccX, GET_TEXT_F(MSG_AMAX_A), onDrawMaxAccelX, SetMaxAccelX, &planner.settings.max_acceleration_mm_per_s2[X_AXIS]); - ADDMENUITEM_P(ICON_MaxAccY, GET_TEXT_F(MSG_AMAX_B), onDrawMaxAccelY, SetMaxAccelY, &planner.settings.max_acceleration_mm_per_s2[Y_AXIS]); - ADDMENUITEM_P(ICON_MaxAccZ, GET_TEXT_F(MSG_AMAX_C), onDrawMaxAccelZ, SetMaxAccelZ, &planner.settings.max_acceleration_mm_per_s2[Z_AXIS]); + MenuItemsPrepare(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]); #if HAS_HOTEND - ADDMENUITEM_P(ICON_MaxAccE, GET_TEXT_F(MSG_AMAX_E), onDrawMaxAccelE, SetMaxAccelE, &planner.settings.max_acceleration_mm_per_s2[E_AXIS]); + EDIT_ITEM_F(ICON_MaxAccE, MSG_AMAX_E, onDrawMaxAccelE, SetMaxAccelE, &planner.settings.max_acceleration_mm_per_s2[E_AXIS]); #endif } CurrentMenu->draw(); @@ -3613,17 +3542,17 @@ void Draw_MaxAccel_Menu() { #if HAS_CLASSIC_JERK void Draw_MaxJerk_Menu() { checkkey = Menu; - if (MaxJerkMenu == nullptr) MaxJerkMenu = new MenuClass(); + if (!MaxJerkMenu) MaxJerkMenu = new MenuClass(); if (CurrentMenu != MaxJerkMenu) { CurrentMenu = MaxJerkMenu; SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_JERK)); - DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Motion_Menu); - ADDMENUITEM_P(ICON_MaxSpeedJerkX, GET_TEXT_F(MSG_VA_JERK), onDrawMaxJerkX, SetMaxJerkX, &planner.max_jerk[X_AXIS]); - ADDMENUITEM_P(ICON_MaxSpeedJerkY, GET_TEXT_F(MSG_VB_JERK), onDrawMaxJerkY, SetMaxJerkY, &planner.max_jerk[Y_AXIS]); - ADDMENUITEM_P(ICON_MaxSpeedJerkZ, GET_TEXT_F(MSG_VC_JERK), onDrawMaxJerkZ, SetMaxJerkZ, &planner.max_jerk[Z_AXIS]); + MenuItemsPrepare(5); + BACK_ITEM(Draw_Motion_Menu); + EDIT_ITEM_F(ICON_MaxSpeedJerkX, MSG_VA_JERK, onDrawMaxJerkX, SetMaxJerkX, &planner.max_jerk[X_AXIS]); + EDIT_ITEM_F(ICON_MaxSpeedJerkY, MSG_VB_JERK, onDrawMaxJerkY, SetMaxJerkY, &planner.max_jerk[Y_AXIS]); + EDIT_ITEM_F(ICON_MaxSpeedJerkZ, MSG_VC_JERK, onDrawMaxJerkZ, SetMaxJerkZ, &planner.max_jerk[Z_AXIS]); #if HAS_HOTEND - ADDMENUITEM_P(ICON_MaxSpeedJerkE, GET_TEXT_F(MSG_VE_JERK), onDrawMaxJerkE, SetMaxJerkE, &planner.max_jerk[E_AXIS]); + EDIT_ITEM_F(ICON_MaxSpeedJerkE, MSG_VE_JERK, onDrawMaxJerkE, SetMaxJerkE, &planner.max_jerk[E_AXIS]); #endif } CurrentMenu->draw(); @@ -3632,17 +3561,17 @@ void Draw_MaxAccel_Menu() { void Draw_Steps_Menu() { checkkey = Menu; - if (StepsMenu == nullptr) StepsMenu = new MenuClass(); + if (!StepsMenu) StepsMenu = new MenuClass(); if (CurrentMenu != StepsMenu) { CurrentMenu = StepsMenu; SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_STEPS_PER_MM)); - DWINUI::MenuItemsPrepare(5); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Motion_Menu); - ADDMENUITEM_P(ICON_StepX, GET_TEXT_F(MSG_A_STEPS), onDrawStepsX, SetStepsX, &planner.settings.axis_steps_per_mm[X_AXIS]); - ADDMENUITEM_P(ICON_StepY, GET_TEXT_F(MSG_B_STEPS), onDrawStepsY, SetStepsY, &planner.settings.axis_steps_per_mm[Y_AXIS]); - ADDMENUITEM_P(ICON_StepZ, GET_TEXT_F(MSG_C_STEPS), onDrawStepsZ, SetStepsZ, &planner.settings.axis_steps_per_mm[Z_AXIS]); + MenuItemsPrepare(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]); #if HAS_HOTEND - ADDMENUITEM_P(ICON_StepE, GET_TEXT_F(MSG_E_STEPS), onDrawStepsE, SetStepsE, &planner.settings.axis_steps_per_mm[E_AXIS]); + EDIT_ITEM_F(ICON_StepE, MSG_E_STEPS, onDrawStepsE, SetStepsE, &planner.settings.axis_steps_per_mm[E_AXIS]); #endif } CurrentMenu->draw(); @@ -3651,65 +3580,217 @@ void Draw_Steps_Menu() { #if HAS_HOTEND void Draw_HotendPID_Menu() { checkkey = Menu; - if (HotendPIDMenu == nullptr) HotendPIDMenu = new MenuClass(); - if (CurrentMenu != HotendPIDMenu) { - CurrentMenu = HotendPIDMenu; - CurrentMenu->MenuTitle.SetCaption(F("Hotend PID Settings")); - DWINUI::MenuItemsPrepare(8); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, Draw_AdvancedSettings_Menu); - ADDMENUITEM(ICON_PIDNozzle, F("Hotend PID"), onDrawMenuItem, HotendPID); - ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_hotend[0].pid.Kp); - ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KI), onDrawPIDi, SetKi, &thermalManager.temp_hotend[0].pid.Ki); - ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KD), onDrawPIDd, SetKd, &thermalManager.temp_hotend[0].pid.Kd); - ADDMENUITEM_P(ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE), onDrawPIntMenu, SetHotendPidT, &HMI_data.HotendPidT); - ADDMENUITEM_P(ICON_PIDcycles, GET_TEXT_F(MSG_PID_CYCLE), onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); + if (SetMenu(HotendPIDMenu, F(STR_HOTEND_PID " Settings"),8)) { + BACK_ITEM(Draw_AdvancedSettings_Menu); + MENU_ITEM(ICON_PIDNozzle, F(STR_HOTEND_PID), onDrawMenuItem, HotendPID); + EDIT_ITEM(ICON_PIDValue, F("Set" STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_hotend[0].pid.Kp); + 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); #if ENABLED(EEPROM_SETTINGS) - ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT_F(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom); + MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); #endif } - CurrentMenu->draw(); + UpdateMenu(HotendPIDMenu); } #endif #if HAS_HEATED_BED void Draw_BedPID_Menu() { checkkey = Menu; - if (BedPIDMenu == nullptr) BedPIDMenu = new MenuClass(); - if (CurrentMenu != BedPIDMenu) { - CurrentMenu = BedPIDMenu; - CurrentMenu->MenuTitle.SetCaption(F("Bed PID Settings")); - DWINUI::MenuItemsPrepare(8); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, Draw_AdvancedSettings_Menu); - ADDMENUITEM(ICON_PIDNozzle, F("Bed PID"), onDrawMenuItem,BedPID); - ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_bed.pid.Kp); - ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KI), onDrawPIDi, SetKi, &thermalManager.temp_bed.pid.Ki); - ADDMENUITEM_P(ICON_PIDValue, F("Set" STR_KD), onDrawPIDd, SetKd, &thermalManager.temp_bed.pid.Kd); - ADDMENUITEM_P(ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE), onDrawPIntMenu, SetBedPidT, &HMI_data.BedPidT); - ADDMENUITEM_P(ICON_PIDcycles, GET_TEXT_F(MSG_PID_CYCLE), onDrawPIntMenu, SetPidCycles, &HMI_data.PidCycles); + if (SetMenu(BedPIDMenu, F(STR_BED_PID " Settings"),8)) { + BACK_ITEM(Draw_AdvancedSettings_Menu); + MENU_ITEM(ICON_PIDNozzle, F(STR_BED_PID), onDrawMenuItem,BedPID); + EDIT_ITEM(ICON_PIDValue, F("Set" STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_bed.pid.Kp); + 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); #if ENABLED(EEPROM_SETTINGS) - ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT_F(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom); + MENU_ITEM_F(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, WriteEeprom); #endif } - CurrentMenu->draw(); + UpdateMenu(BedPIDMenu); } #endif -#if EITHER(HAS_BED_PROBE, BABYSTEPPING) +#if ENABLED(BABYSTEP_ZPROBE_OFFSET) void Draw_ZOffsetWiz_Menu() { checkkey = Menu; - if (ZOffsetWizMenu == nullptr) ZOffsetWizMenu = new MenuClass(); - if (CurrentMenu != ZOffsetWizMenu) { - CurrentMenu = ZOffsetWizMenu; - CurrentMenu->MenuTitle.SetCaption(GET_TEXT_F(MSG_PROBE_WIZARD)); - DWINUI::MenuItemsPrepare(4); - ADDMENUITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawMenuItem, Draw_Prepare_Menu); - ADDMENUITEM(ICON_Homing, GET_TEXT_F(MSG_AUTO_HOME), onDrawMenuItem, AutoHome); - ADDMENUITEM(ICON_MoveZ0, F("Move Z to Home"), onDrawMenuItem, SetMoveZto0); - ADDMENUITEM_P(ICON_Zoffset, GET_TEXT_F(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR); + if (SetMenu(ZOffsetWizMenu, GET_TEXT_F(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); } - CurrentMenu->draw(); + UpdateMenu(ZOffsetWizMenu); if (!axis_is_trusted(Z_AXIS)) LCD_MESSAGE_F("WARNING: Z position unknown, move Z to home"); } #endif -#endif // DWIN_CREALITY_LCD_ENHANCED +#if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) + void Draw_Homing_Menu() { + checkkey = Menu; + if (SetMenu(HomingMenu, GET_TEXT_F(MSG_HOMING), 5)) { + 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); + } + UpdateMenu(HomingMenu); + } +#endif + +#if ENABLED(FWRETRACT) + void Draw_FWRetract_Menu() { + checkkey = Menu; + if (SetMenu(FWRetractMenu, GET_TEXT_F(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); + } + UpdateMenu(FWRetractMenu); + } +#endif + +//============================================================================= +// Mesh Bed Leveling +//============================================================================= + +#if HAS_MESH + + void ApplyMeshFadeHeight() { set_z_fade_height(planner.z_fade_height); } + void SetMeshFadeHeight() { SetPFloatOnClick(0, 100, 1, ApplyMeshFadeHeight); } + + void SetMeshActive() { + set_bed_leveling_enabled(!planner.leveling_active); + Draw_Chkb_Line(CurrentMenu->line(), planner.leveling_active); + DWIN_UpdateLCD(); + } + + #if BOTH(HAS_HEATED_BED, PREHEAT_BEFORE_LEVELING) + void SetBedLevT() { SetPIntOnClick(MIN_BEDTEMP, MAX_BEDTEMP); } + #endif + + uint8_t mesh_x = 0; + uint8_t 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 SetEditZValue() { SetPFloatOnClick(Z_OFFSET_MIN, Z_OFFSET_MAX, 3); } + +#endif + +#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; + 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 UBLTiltMesh() { + if (bedlevel.storage_slot < 0) 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); + gcode.process_subcommands_now(buf); + } + else + gcode.process_subcommands_now(F("G28O\nG29J")); + LCD_MESSAGE(MSG_UBL_MESH_TILTED); + } + + void UBLSmartFillMesh() { + 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; + 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; + 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)) { + 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); + #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); + #if HAS_BED_PROBE + MENU_ITEM_F(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); + #endif + #if ENABLED(MESH_EDIT_MENU) + MENU_ITEM_F(ICON_UBLActive, MSG_EDIT_MESH, onDrawSubMenu, Draw_EditMesh_Menu); + #endif + MENU_ITEM_F(ICON_MeshViewer, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer); + } + UpdateMenu(MeshMenu); + } + + #if ENABLED(MESH_EDIT_MENU) + void Draw_EditMesh_Menu() { + checkkey = Menu; + if (SetMenu(EditMeshMenu, GET_TEXT_F(MSG_EDIT_MESH), 4)) { + mesh_x = 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]); + } + UpdateMenu(EditMeshMenu); + } + #endif + +#endif // HAS_MESH + +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin.h b/Marlin/src/lcd/e3v2/proui/dwin.h similarity index 50% rename from Marlin/src/lcd/e3v2/enhanced/dwin.h rename to Marlin/src/lcd/e3v2/proui/dwin.h index 05b81c101992..f4e550295ea5 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin.h +++ b/Marlin/src/lcd/e3v2/proui/dwin.h @@ -22,30 +22,18 @@ #pragma once /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.7.1 - * Date: 2021/11/09 + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.17.2 + * Date: 2022/04/08 */ -#include "../../../inc/MarlinConfigPre.h" +#include "dwin_defines.h" #include "dwinui.h" #include "../common/encoder.h" #include "../../../libs/BL24CXX.h" -#if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT) && DISABLED(PROBE_MANUALLY) - #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 - -static constexpr size_t eeprom_data_size = 64; +#include "../../../inc/MarlinConfig.h" enum processID : uint8_t { // Process ID @@ -58,17 +46,16 @@ enum processID : uint8_t { SetPFloat, SelectFile, PrintProcess, - PrintDone, - Info, - - // Popup Windows - Homing, + Popup, Leveling, - PauseOrStop, - FilamentPurge, - WaitResponse, Locked, - NothingToDo, + Reboot, + PrintDone, + ESDiagProcess, + WaitResponse, + Homing, + PidProcess, + NothingToDo }; enum pidresult_t : uint8_t { @@ -85,145 +72,166 @@ enum pidresult_t : uint8_t { typedef struct { int8_t Color[3]; // Color components - int8_t Preheat = 0; // Material Select 0: PLA, 1: ABS, 2: Custom + pidresult_t pidresult = PID_DONE; + uint8_t Select = 0; // Auxiliary selector variable AxisEnum axis = X_AXIS; // Axis Select - int32_t MaxValue = 0; // Auxiliar max integer/scaled float value - int32_t MinValue = 0; // Auxiliar min integer/scaled float value - int8_t dp = 0; // Auxiliar decimal places - int32_t Value = 0; // Auxiliar integer / scaled float value - int16_t *P_Int = nullptr; // Auxiliar pointer to 16 bit integer variable - float *P_Float = nullptr; // Auxiliar pointer to float variable - void (*Apply)() = nullptr; // Auxiliar apply function - void (*LiveUpdate)() = nullptr; // Auxiliar live update function } HMI_value_t; -typedef struct { - 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; - #if HAS_PREHEAT - #ifdef PREHEAT_1_TEMP_HOTEND - int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND; - int16_t PidCycles = 10; - #endif - #ifdef PREHEAT_1_TEMP_BED - int16_t BedPidT = PREHEAT_1_TEMP_BED; - #endif - #endif - #if ENABLED(PREVENT_COLD_EXTRUSION) - int16_t ExtMinT = EXTRUDE_MINTEMP; - #endif -} HMI_data_t; - typedef struct { uint8_t language; + 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 - bool lock_flag:1; // 0: lock called from AdvSet 1: lock called from Tune } HMI_flag_t; extern HMI_value_t HMI_value; extern HMI_flag_t HMI_flag; -extern HMI_data_t HMI_data; extern uint8_t checkkey; extern millis_t dwin_heat_time; -// SD Card -void HMI_SDCardInit(); -void HMI_SDCardUpdate(); +// Popups +#if HAS_HOTEND || HAS_HEATED_BED + void DWIN_Popup_Temperature(const bool toohigh); +#endif +#if ENABLED(POWER_LOSS_RECOVERY) + void Popup_PowerLossRecovery(); +#endif + +// Tool Functions +#if ENABLED(EEPROM_SETTINGS) + void WriteEeprom(); + void ReadEeprom(); + void ResetEeprom(); + #if HAS_MESH + void SaveMesh(); + #endif +#endif +void RebootPrinter(); +void DisableMotors(); +void AutoLev(); +void AutoHome(); +#if HAS_PREHEAT + void DoPreheat0(); + void DoPreheat1(); + void DoPreheat2(); +#endif +void DoCoolDown(); +#if HAS_HOTEND + void HotendPID(); +#endif +#if HAS_HEATED_BED + void BedPID(); +#endif +#if ENABLED(BAUD_RATE_GCODE) + void HMI_SetBaudRate(); + void SetBaud115K(); + void SetBaud250K(); +#endif +#if HAS_LCD_BRIGHTNESS + void TurnOffBacklight(); +#endif +void ApplyExtMinT(); +void ParkHead(); +#if HAS_ONESTEP_LEVELING + void Trammingwizard(); +#endif +#if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) + void ApplyLEDColor(); +#endif +#if ENABLED(AUTO_BED_LEVELING_UBL) + void UBLTiltMesh(); + bool UBLValidMesh(); + void UBLSaveMesh(); + void UBLLoadMesh(); +#endif // Other void Goto_PrintProcess(); void Goto_Main_Menu(); -void Goto_InfoMenu(); -void Draw_Select_Highlight(const bool sel); -void Draw_Status_Area(const bool with_update); // Status Area -void Draw_Main_Area(); // Redraw main area; -void DWIN_Redraw_screen(); // Redraw all screen elements -void HMI_StartFrame(const bool with_update); // Prepare the menu view +void Goto_Info_Menu(); +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_RedrawDash(); // Redraw Dash and Status line +void DWIN_RedrawScreen(); // Redraw all screen elements void HMI_MainMenu(); // Main process screen void HMI_SelectFile(); // File page void HMI_Printing(); // Print page void HMI_ReturnScreen(); // Return to previous screen before popups -void ApplyExtMinT(); -void HMI_SetLanguageCache(); // Set the languaje image cache - -void HMI_Init(); -void HMI_Popup(); +void HMI_WaitForUser(); void HMI_SaveProcessID(const uint8_t id); -void HMI_AudioFeedback(const bool success=true); +void HMI_SDCardInit(); +void HMI_SDCardUpdate(); void EachMomentUpdate(); void update_variable(); +void DWIN_InitScreen(); void DWIN_HandleScreen(); -void DWIN_Update(); void DWIN_CheckStatusMessage(); -void DWIN_StartHoming(); -void DWIN_CompletedHoming(); +void DWIN_HomingStart(); +void DWIN_HomingDone(); #if HAS_MESH - void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const float zval); + void DWIN_MeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval); #endif -void DWIN_MeshLevelingStart(); -void DWIN_CompletedLeveling(); +void DWIN_LevelingStart(); +void DWIN_LevelingDone(); void DWIN_PidTuning(pidresult_t result); -void DWIN_Print_Started(const bool sd = false); +void DWIN_Print_Started(const bool sd=false); +void DWIN_Print_Pause(); +void DWIN_Print_Resume(); void DWIN_Print_Finished(); +void DWIN_Print_Aborted(); #if HAS_FILAMENT_SENSOR void DWIN_FilamentRunout(const uint8_t extruder); #endif -void DWIN_Progress_Update(); +void DWIN_M73(); void DWIN_Print_Header(const char *text); void DWIN_SetColorDefaults(); -void DWIN_StoreSettings(char *buff); -void DWIN_LoadSettings(const char *buff); +void DWIN_ApplyColor(); +void DWIN_CopySettingsTo(char * const buff); +void DWIN_CopySettingsFrom(const char * const buff); void DWIN_SetDataDefaults(); void DWIN_RebootScreen(); #if ENABLED(ADVANCED_PAUSE_FEATURE) + void DWIN_Popup_Pause(FSTR_P const fmsg, uint8_t button=0); void Draw_Popup_FilamentPurge(); - void DWIN_Popup_FilamentPurge(); + void Goto_FilamentPurge(); void HMI_FilamentPurge(); #endif // Utility and extensions +void DWIN_LockScreen(); +void DWIN_UnLockScreen(); void HMI_LockScreen(); -void DWIN_LockScreen(const bool flag = true); #if HAS_MESH void DWIN_MeshViewer(); #endif - -// HMI user control functions -void HMI_Menu(); -void HMI_SetInt(); -void HMI_SetPInt(); -void HMI_SetIntNoDraw(); -void HMI_SetFloat(); -void HMI_SetPFloat(); +#if HAS_GCODE_PREVIEW + void HMI_ConfirmToPrint(); +#endif +#if HAS_ESDIAG + void Draw_EndStopDiag(); +#endif +#if ENABLED(PRINTCOUNTER) + void Draw_PrintStats(); +#endif // Menu drawing functions void Draw_Control_Menu(); void Draw_AdvancedSettings_Menu(); void Draw_Prepare_Menu(); void Draw_Move_Menu(); -void Draw_LevBedCorners_Menu(); +void Draw_Tramming_Menu(); #if HAS_HOME_OFFSET void Draw_HomeOffset_Menu(); #endif @@ -233,8 +241,18 @@ void Draw_LevBedCorners_Menu(); #if HAS_FILAMENT_SENSOR void Draw_FilSet_Menu(); #endif +#if ENABLED(NOZZLE_PARK_FEATURE) + void Draw_ParkPos_Menu(); +#endif +void Draw_PhySet_Menu(); void Draw_SelectColors_Menu(); void Draw_GetColor_Menu(); +#if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS) + void Draw_CaseLight_Menu(); +#endif +#if ENABLED(LED_CONTROL_MENU) + void Draw_LedControl_Menu(); +#endif void Draw_Tune_Menu(); void Draw_Motion_Menu(); #if ENABLED(ADVANCED_PAUSE_FEATURE) @@ -262,23 +280,15 @@ void Draw_Steps_Menu(); #if EITHER(HAS_BED_PROBE, BABYSTEPPING) void Draw_ZOffsetWiz_Menu(); #endif - -// Popup windows - -void DWIN_Draw_Popup(const uint8_t icon, const char * const cmsg1, FSTR_P const fmsg2, uint8_t button=0); -void DWIN_Draw_Popup(const uint8_t icon, FSTR_P const fmsg1=nullptr, FSTR_P const fmsg2=nullptr, uint8_t button=0); - -template -void DWIN_Popup_Confirm(const uint8_t icon, T amsg1, U amsg2) { - HMI_SaveProcessID(WaitResponse); - DWIN_Draw_Popup(icon, amsg1, amsg2, ICON_Confirm_E); // Button Confirm - DWIN_UpdateLCD(); -} - -#if HAS_HOTEND || HAS_HEATED_BED - void DWIN_Popup_Temperature(const bool toohigh); +#if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) + void Draw_Homing_Menu(); #endif -#if HAS_HOTEND - void Popup_Window_ETempTooLow(); +#if ENABLED(FWRETRACT) + void Draw_FWRetract_Menu(); +#endif +#if HAS_MESH + void Draw_MeshSet_Menu(); + #if ENABLED(MESH_EDIT_MENU) + void Draw_EditMesh_Menu(); + #endif #endif -void Popup_Window_Resume(); diff --git a/Marlin/src/lcd/e3v2/proui/dwin_defines.h b/Marlin/src/lcd/e3v2/proui/dwin_defines.h new file mode 100644 index 000000000000..cb7b2f8160df --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/dwin_defines.h @@ -0,0 +1,159 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 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 + +/** + * DWIN general defines and data structs for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.11.2 + * Date: 2022/02/28 + */ + +//#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 + +#if DISABLED(LIMITED_MAX_FR_EDITING) + #error "LIMITED_MAX_FR_EDITING is required with ProUI." +#endif +#if DISABLED(LIMITED_MAX_ACCEL_EDITING) + #error "LIMITED_MAX_ACCEL_EDITING is required with ProUI." +#endif +#if ENABLED(CLASSIC_JERK) && DISABLED(LIMITED_JERK_EDITING) + #error "LIMITED_JERK_EDITING is required with ProUI." +#endif +#if DISABLED(FILAMENT_RUNOUT_SENSOR) + #error "FILAMENT_RUNOUT_SENSOR is required with ProUI." +#endif +#if DISABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) + #error "INDIVIDUAL_AXIS_HOMING_SUBMENU is required with ProUI." +#endif +#if DISABLED(LCD_SET_PROGRESS_MANUALLY) + #error "LCD_SET_PROGRESS_MANUALLY is required with ProUI." +#endif +#if DISABLED(STATUS_MESSAGE_SCROLLING) + #error "STATUS_MESSAGE_SCROLLING is required with ProUI." +#endif +#if DISABLED(BAUD_RATE_GCODE) + #error "BAUD_RATE_GCODE is required with ProUI." +#endif +#if DISABLED(SOUND_MENU_ITEM) + #error "SOUND_MENU_ITEM is required with ProUI." +#endif +#if DISABLED(PRINTCOUNTER) + #error "PRINTCOUNTER is required with ProUI." +#endif + +#include "../common/dwin_color.h" +#if ENABLED(LED_CONTROL_MENU) + #include "../../../feature/leds/leds.h" +#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_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_PopupTxt_Color Popup_Text_Color +#define Def_AlertBg_Color Color_Bg_Red +#define Def_AlertTxt_Color Color_Yellow +#define Def_PercentTxt_Color Percent_Color +#define Def_Barfill_Color BarFill_Color +#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 +#endif +#if ENABLED(CASELIGHT_USES_BRIGHTNESS) + #define Def_CaseLight_Brightness 255 +#endif + +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/enhanced/dwin_lcd.cpp b/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp similarity index 95% rename from Marlin/src/lcd/e3v2/enhanced/dwin_lcd.cpp rename to Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp index 681b318a15e0..6cdafc8a935f 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin_lcd.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin_lcd.cpp @@ -21,15 +21,15 @@ */ /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.7.1 - * Date: 2021/11/09 + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.10.1 + * Date: 2022/03/06 */ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#if ENABLED(DWIN_LCD_PROUI) #include "../../../inc/MarlinConfig.h" @@ -147,7 +147,7 @@ void DWIN_SRAMToPic(uint8_t picID) { //--------------------------Test area ------------------------- -//void DWIN_ReadSRAM(uint16_t addr, uint8_t length, const char * const data) { +//void DWIN_ReadSRAM(uint16_t addr, const uint8_t length, const char * const data) { // size_t i = 0; // DWIN_Byte(i, 0x32); // DWIN_Byte(i, 0x5A); // 0x5A Read from SRAM - 0xA5 Read from Flash @@ -157,4 +157,4 @@ void DWIN_SRAMToPic(uint8_t picID) { // DWIN_Send(i); //} -#endif // DWIN_CREALITY_LCD_ENHANCED +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/enhanced/dwin_lcd.h b/Marlin/src/lcd/e3v2/proui/dwin_lcd.h similarity index 96% rename from Marlin/src/lcd/e3v2/enhanced/dwin_lcd.h rename to Marlin/src/lcd/e3v2/proui/dwin_lcd.h index 43cb098b9138..6e0a254db4ee 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwin_lcd.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_lcd.h @@ -22,10 +22,10 @@ #pragma once /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.7.1 - * Date: 2021/11/09 + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.10.1 + * Date: 2022/03/06 */ #include "../common/dwin_api.h" diff --git a/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp new file mode 100644 index 000000000000..59b6c0d328ae --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp @@ -0,0 +1,95 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 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 . + * + */ + +/** + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.11.1 + * Date: 2022/02/28 + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(DWIN_LCD_PROUI) + +#include "dwin.h" +#include "dwinui.h" +#include "dwin_popup.h" + +#include "../../../MarlinCore.h" // for wait_for_user + +popupDrawFunc_t popupDraw = nullptr; +popupClickFunc_t popupClick = nullptr; +popupChangeFunc_t popupChange = nullptr; + +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; + 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); + DWIN_Draw_Rectangle(0, c2, 144, ypos - 2, 247, ypos + 39); +} + +void DWIN_Popup_Continue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2) { + HMI_SaveProcessID(WaitResponse); + DWIN_Draw_Popup(icon, fmsg1, fmsg2, BTN_Continue); // Button Continue + DWIN_UpdateLCD(); +} + +void DWIN_Popup_ConfirmCancel(const uint8_t icon, FSTR_P const fmsg2) { + DWIN_Draw_Popup(ICON_BLTouch, F("Please confirm"), fmsg2); + DWINUI::Draw_Button(BTN_Confirm, 26, 280); + DWINUI::Draw_Button(BTN_Cancel, 146, 280); + Draw_Select_Highlight(HMI_flag.select_flag); + DWIN_UpdateLCD(); +} + +void Goto_Popup(const popupDrawFunc_t fnDraw, const popupClickFunc_t fnClick/*=nullptr*/, const popupChangeFunc_t fnChange/*=nullptr*/) { + popupDraw = fnDraw; + popupClick = fnClick; + popupChange = fnChange; + HMI_SaveProcessID(Popup); + HMI_flag.select_flag = false; + popupDraw(); +} + +void HMI_Popup() { + if (!wait_for_user) { + if (popupClick) popupClick(); + return; + } + else { + EncoderState encoder_diffState = get_encoder_state(); + if (encoder_diffState == ENCODER_DIFF_CW || encoder_diffState == ENCODER_DIFF_CCW) { + const bool change = encoder_diffState != ENCODER_DIFF_CW; + if (popupChange) popupChange(change); else Draw_Select_Highlight(change, HighlightYPos); + DWIN_UpdateLCD(); + } + } +} + +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/dwin_popup.h b/Marlin/src/lcd/e3v2/proui/dwin_popup.h new file mode 100644 index 000000000000..b4503ea7866b --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.h @@ -0,0 +1,73 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 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 + +/** + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.11.1 + * Date: 2022/02/28 + */ + +#include "dwinui.h" +#include "dwin.h" + +typedef void (*popupDrawFunc_t)(); +typedef void (*popupClickFunc_t)(); +typedef void (*popupChangeFunc_t)(const bool state); +extern popupDrawFunc_t popupDraw; + +void Draw_Select_Highlight(const bool sel, const uint16_t ypos); +inline void Draw_Select_Highlight(const bool sel) { Draw_Select_Highlight(sel, 280); }; +void DWIN_Popup_Continue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2); +void DWIN_Popup_ConfirmCancel(const uint8_t icon, FSTR_P const fmsg2); +void Goto_Popup(const popupDrawFunc_t fnDraw, const popupClickFunc_t fnClick=nullptr, const popupChangeFunc_t fnChange=nullptr); +void HMI_Popup(); + +inline void Draw_Popup_Bkgd() { + DWIN_Draw_Rectangle(1, HMI_data.PopupBg_color, 14, 60, 258, 330); + DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, 14, 60, 258, 330); +} + +template +void DWIN_Draw_Popup(const uint8_t icon, T amsg1=nullptr, U amsg2=nullptr, uint8_t button=0) { + DWINUI::ClearMainArea(); + Draw_Popup_Bkgd(); + if (icon) DWINUI::Draw_Icon(icon, 101, 105); + if (amsg1) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 210, amsg1); + if (amsg2) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 240, amsg2); + if (button) DWINUI::Draw_Button(button, 86, 280); +} + +template +void DWIN_Show_Popup(const uint8_t icon, T amsg1=nullptr, U amsg2=nullptr, uint8_t button=0) { + DWIN_Draw_Popup(icon, amsg1, amsg2, button); + DWIN_UpdateLCD(); +} + +template +void DWIN_Popup_Confirm(const uint8_t icon, T amsg1, U amsg2) { + HMI_SaveProcessID(WaitResponse); + DWIN_Draw_Popup(icon, amsg1, amsg2, BTN_Confirm); // Button Confirm + DWIN_UpdateLCD(); +} + diff --git a/Marlin/src/lcd/e3v2/enhanced/dwinui.cpp b/Marlin/src/lcd/e3v2/proui/dwinui.cpp similarity index 57% rename from Marlin/src/lcd/e3v2/enhanced/dwinui.cpp rename to Marlin/src/lcd/e3v2/proui/dwinui.cpp index 52b7c3b5213f..ecb4754a0f35 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwinui.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwinui.cpp @@ -21,53 +21,47 @@ */ /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.7.1 - * Date: 2021/11/09 + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.17.1 + * Date: 2022/04/12 */ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#if ENABLED(DWIN_LCD_PROUI) #include "../../../inc/MarlinConfig.h" #include "dwin_lcd.h" #include "dwinui.h" +#include "dwin_defines.h" //#define DEBUG_OUT 1 #include "../../../core/debug_out.h" -int8_t MenuItemTotal = 0; -int8_t MenuItemCount = 0; -MenuItemClass** MenuItems = nullptr; -MenuClass *CurrentMenu = nullptr; -MenuClass *PreviousMenu = nullptr; - 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; +FSTR_P const DWINUI::Author = F(STRING_CONFIG_H_AUTHOR); -void (*DWINUI::onCursorErase)(const int8_t line)=nullptr; -void (*DWINUI::onCursorDraw)(const int8_t line)=nullptr; -void (*DWINUI::onTitleDraw)(TitleClass* title)=nullptr; -void (*DWINUI::onMenuDraw)(MenuClass* menu)=nullptr; +void (*DWINUI::onTitleDraw)(TitleClass* title) = nullptr; void DWINUI::init() { - DEBUG_ECHOPGM("\r\nDWIN handshake "); - delay(750); // Delay here or init later in the boot process - const bool success = DWIN_Handshake(); - if (success) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error."); + 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); - TERN(SHOW_BOOTSCREEN,,DWIN_Frame_Clear(Color_Bg_Black)); - DWIN_UpdateLCD(); - cursor.x = 0; - cursor.y = 0; + cursor.reset(); pencolor = Color_White; textcolor = Def_Text_Color; backcolor = Def_Background_Color; + buttoncolor = Def_Button_Color; font = font8x16; } @@ -121,9 +115,10 @@ uint16_t DWINUI::RowToY(uint8_t row) { } // Set text/number color -void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor) { +void DWINUI::SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor) { textcolor = fgcolor; backcolor = bgcolor; + buttoncolor = alcolor; } void DWINUI::SetTextColor(uint16_t fgcolor) { textcolor = fgcolor; @@ -156,16 +151,25 @@ void DWINUI::MoveBy(xy_int_t point) { cursor += point; } -// Draw a Centered string using DWIN_WIDTH -void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) { - const int8_t x = _MAX(0U, DWIN_WIDTH - strlen_P(string) * fontWidth(size)) / 2 - 1; +// 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); } -// Draw a char at cursor position -void DWINUI::Draw_Char(const char c) { +// Draw a char +// color: Character color +// x: abscissa of the display +// y: ordinate of the display +// 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, textcolor, backcolor, cursor.x, cursor.y, string, 1); + DWIN_Draw_String(false, font, 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); } @@ -182,21 +186,57 @@ void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rli MoveBy(strlen(string) * fontWidth(font), 0); } -// Draw a signed floating point number +// Draw a numeric integer value // bShow: true=display background color; false=don't display background color -// zeroFill: true=zero fill; false=no zero fill -// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space +// signedMode: 1=signed; 0=unsigned // size: Font size +// color: Character color // bColor: Background color -// iNum: Number of whole digits +// 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) { + char nstr[10]; + sprintf_P(nstr, PSTR("%*li"), (signedMode ? iNum + 1 : iNum), value); + DWIN_Draw_String(bShow, size, 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 +// color: Character color +// bColor: Background color +// iNum: Number of digits // fNum: Number of decimal digits -// x/y: Upper-left point -// value: Float value -void DWINUI::Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value < 0 ? -value : value); - DWIN_Draw_String(bShow, size, color, bColor, x - 6, y, value < 0 ? F("-") : F(" ")); +// 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) { + char nstr[10]; + DWIN_Draw_String(bShow, size, color, bColor, x, y, dtostrf(value, iNum + (signedMode ? 2:1) + fNum, fNum, nstr)); } +// ------------------------- 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); +} + +void DWINUI::Draw_Button(uint8_t id, uint16_t x, uint16_t y) { + switch (id) { + case BTN_Cancel : Draw_Button(GET_TEXT_F(MSG_BUTTON_CANCEL), x, y); break; + case BTN_Confirm : Draw_Button(GET_TEXT_F(MSG_BUTTON_CONFIRM), x, y); break; + case BTN_Continue: Draw_Button(GET_TEXT_F(MSG_BUTTON_CONTINUE), x, y); break; + case BTN_Print : Draw_Button(GET_TEXT_F(MSG_BUTTON_PRINT), x, y); break; + case BTN_Save : Draw_Button(GET_TEXT_F(MSG_BUTTON_SAVE), x, y); break; + case BTN_Purge : Draw_Button(GET_TEXT_F(MSG_BUTTON_PURGE), x, y); break; + default: break; + } +} + +// -------------------------- Extra -------------------------------// + // Draw a circle // color: circle color // x: the abscissa of the center of the circle @@ -244,47 +284,40 @@ void DWINUI::Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r) { // color1 : Start color // color2 : End color uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2) { - uint8_t B,G,R; - float n; - n = (float)(val-minv)/(maxv-minv); - R = (1-n)*GetRColor(color1) + n*GetRColor(color2); - G = (1-n)*GetGColor(color1) + n*GetGColor(color2); - B = (1-n)*GetBColor(color1) + n*GetBColor(color2); - return RGB(R,G,B); + uint8_t B, G, R; + const float n = (float)(val - minv) / (maxv - minv); + R = (1 - n) * GetRColor(color1) + n * GetRColor(color2); + G = (1 - n) * GetGColor(color1) + n * GetGColor(color2); + B = (1 - n) * GetBColor(color1) + n * GetBColor(color2); + return RGB(R, G, B); } -// Color Interpolator through Red->Yellow->Green->Blue +// Color Interpolator through Red->Yellow->Green->Blue (Pro UI) // val : Interpolator minv..maxv // minv : Minimum value // maxv : Maximum value uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) { - uint8_t B,G,R; - const uint8_t maxB = 28; - const uint8_t maxR = 28; - const uint8_t maxG = 38; + uint8_t B, G, R; + const uint8_t maxB = 28, maxR = 28, maxG = 38; const int16_t limv = _MAX(abs(minv), abs(maxv)); - float n; - if (minv>=0) { - n = (float)(val-minv)/(maxv-minv); - } else { - n = (float)val/limv; - } - n = _MIN(1, n); - n = _MAX(-1, n); + float n = minv >= 0 ? (float)(val - minv) / (maxv - minv) : (float)val / limv; + LIMIT(n, -1, 1); if (n < 0) { R = 0; - G = (1+n)*maxG; - B = (-n)*maxB; - } else if (n < 0.5) { - R = maxR*n*2; + G = (1 + n) * maxG; + B = (-n) * maxB; + } + else if (n < 0.5) { + R = maxR * n * 2; G = maxG; B = 0; - } else { + } + else { R = maxR; - G = maxG*(1-n); + G = maxG * (1 - n); B = 0; } - return RGB(R,G,B); + return RGB(R, G, B); } // Draw a checkbox @@ -298,37 +331,10 @@ void DWINUI::Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t } // Clear Menu by filling the menu area with background color -void DWINUI::ClearMenuArea() { +void DWINUI::ClearMainArea() { DWIN_Draw_Rectangle(1, backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1); } -void DWINUI::MenuItemsClear() { - if (MenuItems == nullptr) return; - for (int8_t i = 0; i < MenuItemCount; i++) delete MenuItems[i]; - delete[] MenuItems; - MenuItems = nullptr; - MenuItemCount = 0; - MenuItemTotal = 0; -} - -void DWINUI::MenuItemsPrepare(int8_t totalitems) { - MenuItemsClear(); - MenuItemTotal = totalitems; - MenuItems = new MenuItemClass*[totalitems]; -} - -MenuItemClass* DWINUI::MenuItemsAdd(MenuItemClass* menuitem) { - if (MenuItemCount < MenuItemTotal) { - MenuItems[MenuItemCount] = menuitem; - menuitem->pos = MenuItemCount++; - return menuitem; - } - else { - delete menuitem; - return nullptr; - } -} - /* Title Class ==============================================================*/ TitleClass Title; @@ -369,85 +375,4 @@ void TitleClass::FrameCopy(uint16_t x, uint16_t y, uint16_t w, uint16_t h) { FrameCopy(1, x, y, x + w - 1, y + h - 1); } -/* Menu Class ===============================================================*/ - -MenuClass::MenuClass() { - selected = 0; - topline = 0; -} - -void MenuClass::draw() { - MenuTitle.draw(); - if (DWINUI::onMenuDraw != nullptr) (*DWINUI::onMenuDraw)(this); - for (int8_t i = 0; i < MenuItemCount; i++) - MenuItems[i]->draw(i - topline); - if (DWINUI::onCursorDraw != nullptr) DWINUI::onCursorDraw(line()); - DWIN_UpdateLCD(); -} - -void MenuClass::onScroll(bool dir) { - int8_t sel = selected; - if (dir) sel++; else sel--; - LIMIT(sel, 0, MenuItemCount - 1); - if (sel != selected) { - if (DWINUI::onCursorErase != nullptr) DWINUI::onCursorErase(line()); - if ((sel - topline) == TROWS) { - DWIN_Frame_AreaMove(1, DWIN_SCROLL_UP, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1); - topline++; - MenuItems[sel]->draw(TROWS - 1); - } - if ((sel < topline)) { - DWIN_Frame_AreaMove(1, DWIN_SCROLL_DOWN, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1); - topline--; - MenuItems[sel]->draw(0); - } - selected = sel; - if (DWINUI::onCursorDraw != nullptr) DWINUI::onCursorDraw(line()); - DWIN_UpdateLCD(); - } -} - -void MenuClass::onClick() { - if (MenuItems[selected]->onClick != nullptr) (*MenuItems[selected]->onClick)(); -} - -MenuItemClass *MenuClass::SelectedItem() { - return MenuItems[selected]; -} - -/* MenuItem Class ===========================================================*/ - -MenuItemClass::MenuItemClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)()) { - icon = cicon; - onClick = onclick; - onDraw = ondraw; - const uint8_t len = _MIN(sizeof(caption) - 1, strlen(text)); - memcpy(&caption[0], text, len); - caption[len] = '\0'; -} - -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)()) { - icon = cicon; - onClick = onclick; - onDraw = ondraw; - caption[0] = '\0'; - frameid = id; - frame = { x1, y1, x2, y2 }; -} - -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); -}; - -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) { - value = val; -}; - -#endif // DWIN_CREALITY_LCD_ENHANCED +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/enhanced/dwinui.h b/Marlin/src/lcd/e3v2/proui/dwinui.h similarity index 59% rename from Marlin/src/lcd/e3v2/enhanced/dwinui.h rename to Marlin/src/lcd/e3v2/proui/dwinui.h index 9a717da80d7e..f8ff0917694d 100644 --- a/Marlin/src/lcd/e3v2/enhanced/dwinui.h +++ b/Marlin/src/lcd/e3v2/proui/dwinui.h @@ -22,10 +22,10 @@ #pragma once /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.7.1 - * Date: 2021/11/09 + * DWIN Enhanced implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 3.17.1 + * Date: 2022/04/12 */ #include "dwin_lcd.h" @@ -34,54 +34,110 @@ #include "../common/dwin_color.h" // Extra Icons +#define ICON_AdvSet ICON_Language +#define ICON_BedSizeX ICON_PrintSize +#define ICON_BedSizeY ICON_PrintSize +#define ICON_BedTramming ICON_SetHome +#define ICON_Binary ICON_Contact #define ICON_Brightness ICON_Motion #define ICON_Cancel ICON_StockConfiguration #define ICON_CustomPreheat ICON_SetEndTemp #define ICON_Error ICON_TempTooHigh +#define ICON_ESDiag ICON_Info #define ICON_ExtrudeMinT ICON_HotendTemp #define ICON_FilLoad ICON_WriteEEPROM #define ICON_FilMan ICON_ResumeEEPROM #define ICON_FilSet ICON_ResumeEEPROM #define ICON_FilUnload ICON_ReadEEPROM #define ICON_Flow ICON_StepE -#define ICON_LevBed ICON_SetEndTemp +#define ICON_Folder ICON_More +#define ICON_FWRetract ICON_StepE +#define ICON_FWRetLength ICON_StepE +#define ICON_FWRetSpeed ICON_Setspeed +#define ICON_FWRetZRaise ICON_MoveZ +#define ICON_FWRecSpeed ICON_Setspeed +#define ICON_FWRecExtra ICON_StepE +#define ICON_HomeX ICON_MoveX +#define ICON_HomeY ICON_MoveY +#define ICON_HomeZ ICON_MoveZ +#define ICON_HomeOffset ICON_AdvSet +#define ICON_HomeOffsetX ICON_StepX +#define ICON_HomeOffsetY ICON_StepY +#define ICON_HomeOffsetZ ICON_StepZ +#define ICON_HSMode ICON_StockConfiguration +#define ICON_InvertE0 ICON_StepE +#define ICON_Tram ICON_SetEndTemp +#define ICON_Level ICON_HotendTemp #define ICON_Lock ICON_Cool #define ICON_ManualMesh ICON_HotendTemp +#define ICON_MaxPosX ICON_MoveX +#define ICON_MaxPosY ICON_MoveY +#define ICON_MaxPosZ ICON_MoveZ #define ICON_MeshNext ICON_Axis +#define ICON_MeshPoints ICON_SetEndTemp #define ICON_MeshSave ICON_WriteEEPROM #define ICON_MeshViewer ICON_HotendTemp #define ICON_MoveZ0 ICON_HotendTemp #define ICON_Park ICON_Motion +#define ICON_ParkPos ICON_AdvSet +#define ICON_ParkPosX ICON_StepX +#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_PIDValue ICON_Contact +#define ICON_PrintStats ICON_PrintTime +#define ICON_PrintStatsReset ICON_RemainTime +#define ICON_ProbeDeploy ICON_SetEndTemp +#define ICON_ProbeMargin ICON_PrintSize +#define ICON_ProbeOffsetX ICON_StepX +#define ICON_ProbeOffsetY ICON_StepY +#define ICON_ProbeOffsetZ ICON_StepZ #define ICON_ProbeSet ICON_SetEndTemp +#define ICON_ProbeStow ICON_SetEndTemp #define ICON_ProbeTest ICON_SetEndTemp +#define ICON_ProbeZSpeed ICON_MaxSpeedZ #define ICON_Pwrlossr ICON_Motion #define ICON_Reboot ICON_ResumeEEPROM #define ICON_Runout ICON_MaxAccE #define ICON_Scolor ICON_MaxSpeed +#define ICON_SetBaudRate ICON_Setspeed #define ICON_SetCustomPreheat ICON_SetEndTemp #define ICON_Sound ICON_Cool - -// Default UI Colors -#define Def_Background_Color Color_Bg_Black -#define Def_Cursor_color Rectangle_Color -#define Def_TitleBg_color Color_Bg_Blue -#define Def_TitleTxt_color Color_White -#define Def_Text_Color Color_White -#define Def_Selected_Color Select_Color -#define Def_SplitLine_Color Line_Color -#define Def_Highlight_Color Color_White -#define Def_StatusBg_Color RGB(0,20,20) -#define Def_StatusTxt_Color Color_Yellow -#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 -#define Def_PercentTxt_Color Percent_Color -#define Def_Barfill_Color BarFill_Color -#define Def_Indicator_Color Color_White -#define Def_Coordinate_Color Color_White +#define ICON_TBSetup ICON_Contact +#define ICON_UBLActive ICON_HotendTemp + +#define ICON_CaseLight ICON_Motion +#define ICON_LedControl ICON_Motion + +// Buttons +#define BTN_Continue 85 +#define BTN_Cancel 87 +#define BTN_Confirm 89 +#define BTN_Print 90 +#define BTN_Save 91 +#define BTN_Purge 92 + +// Extended and default UI Colors +#define Color_Black 0 +#define Color_Green RGB(0,63,0) +#define Color_Aqua RGB(0,63,31) +#define Color_Blue RGB(0,0,31) +#define Color_Light_White 0xBDD7 +#define Color_Light_Green 0x3460 +#define Color_Cyan 0x07FF +#define Color_Light_Cyan 0x04F3 +#define Color_Light_Blue 0x3A6A +#define Color_Magenta 0xF81F +#define Color_Light_Magenta 0x9813 +#define Color_Light_Red 0x8800 +#define Color_Orange 0xFA20 +#define Color_Light_Orange 0xFBC0 +#define Color_Light_Yellow 0x8BE0 +#define Color_Brown 0xCC27 +#define Color_Light_Brown 0x6204 +#define Color_Grey 0x18E3 // UI element defines and constants #define DWIN_FONT_MENU font8x16 @@ -89,9 +145,13 @@ #define DWIN_FONT_HEAD font10x20 #define DWIN_FONT_ALERT font10x20 #define STATUS_Y 354 -#define LCD_WIDTH (DWIN_WIDTH / 8) +#define LCD_WIDTH (DWIN_WIDTH / 8) // only if the default font is font8x16 + +// Minimum unit (0.1) : multiple (10) +#define UNITFDIGITS 1 +#define MINUNITMULT POW(10, UNITFDIGITS) -constexpr uint16_t TITLE_HEIGHT = 30, // Title bar height +constexpr uint8_t TITLE_HEIGHT = 30, // Title bar height MLINE = 53, // Menu line height TROWS = (STATUS_Y - TITLE_HEIGHT) / MLINE, // Total rows MROWS = TROWS - 1, // Other-than-Back @@ -110,10 +170,6 @@ constexpr uint16_t TITLE_HEIGHT = 30, // Title bar heig // Menuitem caption Y position #define MBASE(L) (MYPOS(L) + CAPOFF) -// Create and add a MenuItem object to the menu array -#define ADDMENUITEM(V...) DWINUI::MenuItemsAdd(new MenuItemClass(V)) -#define ADDMENUITEM_P(V...) DWINUI::MenuItemsAdd(new MenuItemPtrClass(V)) - typedef struct { uint16_t left, top, right, bottom; } rect_t; typedef struct { uint16_t x, y, w, h; } frame_rect_t; @@ -134,60 +190,16 @@ class TitleClass { }; extern TitleClass Title; -class MenuItemClass { -protected: -public: - int8_t pos = 0; - uint8_t icon = 0; - char caption[32] = ""; - 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); - 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); -}; - -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){} -}; - -class MenuClass { -public: - int8_t topline = 0; - int8_t selected = 0; - TitleClass MenuTitle; - MenuClass(); - virtual ~MenuClass(){}; - inline int8_t line() { return selected - topline; }; - inline int8_t line(uint8_t pos) {return pos - topline; }; - void draw(); - void onScroll(bool dir); - void onClick(); - MenuItemClass* SelectedItem(); -}; -extern MenuClass *CurrentMenu; - namespace DWINUI { extern xy_int_t cursor; extern uint16_t pencolor; extern uint16_t textcolor; extern uint16_t backcolor; + extern uint16_t buttoncolor; extern uint8_t font; + extern FSTR_P const Author; - extern void (*onCursorErase)(const int8_t line); - extern void (*onCursorDraw)(const int8_t line); extern void (*onTitleDraw)(TitleClass* title); - extern void (*onMenuDraw)(MenuClass* menu); // DWIN LCD Initialization void init(); @@ -197,9 +209,11 @@ namespace DWINUI { // Get font character width uint8_t fontWidth(uint8_t cfont); + inline uint8_t fontWidth() { return fontWidth(font); }; // Get font character height uint8_t fontHeight(uint8_t cfont); + inline uint8_t fontHeight() { return fontHeight(font); }; // Get screen x coordinates from text column uint16_t ColToX(uint8_t col); @@ -208,7 +222,7 @@ namespace DWINUI { uint16_t RowToY(uint8_t row); // Set text/number color - void SetColors(uint16_t fgcolor, uint16_t bgcolor); + void SetColors(uint16_t fgcolor, uint16_t bgcolor, uint16_t alcolor); void SetTextColor(uint16_t fgcolor); void SetBackgroundColor(uint16_t bgcolor); @@ -236,6 +250,17 @@ namespace DWINUI { DWIN_Draw_Line(pencolor, cursor.x, cursor.y, x, y); } + // Extend a frame box + // v: value to extend + inline frame_rect_t ExtendFrame(frame_rect_t frame, uint8_t v) { + frame_rect_t t; + t.x = frame.x - v; + t.y = frame.y - v; + t.w = frame.w + 2 * v; + t.h = frame.h + 2 * v; + return t; + } + // Draw an Icon with transparent background from the library ICON // icon: Icon ID // x/y: Upper-left point @@ -243,97 +268,130 @@ namespace DWINUI { DWIN_ICON_Show(ICON, icon, x, y); } - // Draw a positive integer + // 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); + } + + // Draw a numeric integer value // bShow: true=display background color; false=don't display background color - // zeroFill: true=zero fill; false=no zero fill - // zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space + // signedMode: 1=signed; 0=unsigned // size: Font size // color: Character color // bColor: Background color // iNum: Number of digits // x/y: Upper-left coordinate // value: Integer value - inline void Draw_Int(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, long value) { - DWIN_Draw_IntValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, x, y, 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); + + // 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 iNum, long value) { - DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); + Draw_Int(false, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); MoveBy(iNum * fontWidth(font), 0); } inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) { - DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, x, y, value); + Draw_Int(false, 0, font, textcolor, backcolor, iNum, x, y, value); } inline void Draw_Int(uint16_t color, uint8_t iNum, uint16_t x, uint16_t y, long value) { - DWIN_Draw_IntValue(false, true, 0, font, color, backcolor, iNum, x, y, value); + Draw_Int(false, 0, font, 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) { - DWIN_Draw_IntValue(true, true, 0, font, color, bColor, iNum, x, y, value); + Draw_Int(true, 0, font, 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) { - DWIN_Draw_IntValue(true, true, 0, size, color, bColor, iNum, x, y, value); + Draw_Int(true, 0, size, color, bColor, iNum, x, y, value); } - // Draw a floating point number + // 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 iNum, long value) { + Draw_Int(false, 1, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value); + MoveBy(iNum * fontWidth(font), 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); + } + 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); + } + 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); + } + 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); + } + + // Draw a numeric float value // bShow: true=display background color; false=don't display background color - // zeroFill: true=zero fill; false=no zero fill - // zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space + // signedMode: 1=signed; 0=unsigned // size: Font size // color: Character color // bColor: Background color - // iNum: Number of whole digits + // iNum: Number of digits // fNum: Number of decimal digits - // x/y: Upper-left point - // value: Float value - inline void Draw_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value); + // 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); + + // 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 iNum, uint8_t fNum, float value) { - DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); + Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); MoveBy((iNum + fNum + 1) * fontWidth(font), 0); } inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value); + Draw_Float(false, 0, font, textcolor, backcolor, iNum, fNum, x, y, value); } - inline void Draw_Float(uint16_t color, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - DWIN_Draw_FloatValue(false, true, 0, font, color, 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(uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - DWIN_Draw_FloatValue(true, true, 0, font, color, bColor, iNum, fNum, x, y, value); + Draw_Float(true, 0, font, 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) { - DWIN_Draw_FloatValue(true, true, 0, size, color, bColor, iNum, fNum, x, y, value); + Draw_Float(true, 0, size, color, bColor, iNum, fNum, x, y, value); } // Draw a signed floating point number - // bShow: true=display background color; false=don't display background color - // zeroFill: true=zero fill; false=no zero fill - // zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space - // size: Font size - // bColor: Background color - // iNum: Number of whole digits - // fNum: Number of decimal digits - // x/y: Upper-left point - // value: Float value - void Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value); + 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 iNum, uint8_t fNum, float value) { - Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); + Draw_Float(false, 1, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value); MoveBy((iNum + fNum + 1) * fontWidth(font), 0); } inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) { - Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value); + Draw_Float(false, 1, font, 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_Signed_Float(false, true, 0, size, textcolor, backcolor, iNum, fNum, x, y, value); + Draw_Float(false, 1, size, 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_Signed_Float(true, true, 0, font, color, bColor, iNum, fNum, x, y, value); + Draw_Float(true, 1, font, 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_Signed_Float(true, true, 0, size, color, bColor, iNum, fNum, x, y, value); + Draw_Float(true, 1, size, color, bColor, iNum, fNum, x, y, value); } - // Draw a char at cursor position - void Draw_Char(const char c); + // Draw a char + // color: Character color + // x: abscissa of the display + // y: ordinate of the display + // c: ASCII code of char + void Draw_Char(uint16_t color, uint16_t x, uint16_t y, const char c); + inline void Draw_Char(uint16_t x, uint16_t y, const char c) { Draw_Char(textcolor, x, y, c); }; + // Draw a char at cursor position and increment cursor + void Draw_Char(uint16_t color, const char c); + inline void Draw_Char(const char c) { Draw_Char(textcolor, c); } // Draw a string at cursor position // color: Character color @@ -386,7 +444,10 @@ namespace DWINUI { // 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 y, const char * const 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); + } 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)); } @@ -412,6 +473,14 @@ namespace DWINUI { Draw_CenteredString(false, font, textcolor, backcolor, y, title); } + // Draw a box + // mode: 0=frame, 1=fill, 2=XOR fill + // color: Rectangle color + // frame: Box coordinates and size + inline void Draw_Box(uint8_t mode, uint16_t color, frame_rect_t frame) { + DWIN_Draw_Box(mode, color, frame.x, frame.y, frame.w, frame.h); + } + // Draw a circle // Color: circle color // x: abscissa of the center of the circle @@ -440,6 +509,17 @@ namespace DWINUI { // color2 : End color uint16_t ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2); + // ------------------------- Buttons ------------------------------// + + void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, const char * const caption); + inline void Draw_Button(uint16_t color, uint16_t bcolor, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, FSTR_P caption) { + Draw_Button(color, bcolor, x1, y1, x2, y2, FTOP(caption)); + } + inline void Draw_Button(FSTR_P caption, uint16_t x, uint16_t y) { + Draw_Button(textcolor, buttoncolor, x, y, x + 99, y + 37, caption); + } + void Draw_Button(uint8_t id, uint16_t x, uint16_t y); + // -------------------------- Extra -------------------------------// // Draw a circle filled with color @@ -474,17 +554,8 @@ namespace DWINUI { DWIN_WriteToMem(0xA5, addr, length, data); } - // Clear Menu by filling the area with background color + // Clear by filling the area with background color // Area (0, TITLE_HEIGHT, DWIN_WIDTH, STATUS_Y - 1) - void ClearMenuArea(); - - // Clear MenuItems array and free MenuItems elements - void MenuItemsClear(); - - // Prepare MenuItems array - void MenuItemsPrepare(int8_t totalitems); - - // Add elements to the MenuItems array - MenuItemClass* MenuItemsAdd(MenuItemClass* menuitem); + void ClearMainArea(); }; diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp new file mode 100644 index 000000000000..19d726037ce9 --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp @@ -0,0 +1,113 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 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 . + * + */ + +/** + * DWIN Endstops diagnostic page for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 1.2.2 + * Date: 2022/02/24 + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(DWIN_LCD_PROUI) + +#include "dwin_defines.h" + +#if HAS_ESDIAG + +#include "endstop_diag.h" + +#include "../../../core/types.h" +#include "../../marlinui.h" +#include "dwin_lcd.h" +#include "dwinui.h" +#include "dwin_popup.h" +#include "dwin.h" + +#if HAS_FILAMENT_SENSOR + #include "../../../feature/runout.h" +#endif + +#if HAS_BED_PROBE + #include "../../../module/probe.h" +#endif + +ESDiagClass ESDiag; + +void draw_es_label(FSTR_P const flabel=nullptr) { + DWINUI::cursor.x = 40; + if (flabel) DWINUI::Draw_String(F(flabel)); + DWINUI::Draw_String(F(": ")); + DWINUI::MoveBy(0, 25); +} + +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); + 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); +} + +void ESDiagClass::Draw() { + Title.ShowCaption(F("End-stops Diagnostic")); + DWINUI::ClearMainArea(); + Draw_Popup_Bkgd(); + DWINUI::Draw_Button(BTN_Continue, 86, 250); + DWINUI::cursor.y = 80; + #define ES_LABEL(S) draw_es_label(F(STR_##S)) + #if HAS_X_MIN + ES_LABEL(X_MIN); + #endif + #if HAS_Y_MIN + ES_LABEL(Y_MIN); + #endif + #if HAS_Z_MIN + ES_LABEL(Z_MIN); + #endif + #if HAS_FILAMENT_SENSOR + draw_es_label(F(STR_FILAMENT)); + #endif + Update(); +} + +void ESDiagClass::Update() { + DWINUI::cursor.y = 80; + #define ES_REPORT(S) draw_es_state(READ(S##_PIN) != S##_ENDSTOP_INVERTING) + #if HAS_X_MIN + ES_REPORT(X_MIN); + #endif + #if HAS_Y_MIN + ES_REPORT(Y_MIN); + #endif + #if HAS_Z_MIN + ES_REPORT(Z_MIN); + #endif + #if HAS_FILAMENT_SENSOR + draw_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE); + #endif + DWIN_UpdateLCD(); +} + +#endif // HAS_ESDIAG +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/HAL/TEENSY31_32/watchdog.h b/Marlin/src/lcd/e3v2/proui/endstop_diag.h similarity index 73% rename from Marlin/src/HAL/TEENSY31_32/watchdog.h rename to Marlin/src/lcd/e3v2/proui/endstop_diag.h index b8b46a403013..316a1e1ed3d9 100644 --- a/Marlin/src/HAL/TEENSY31_32/watchdog.h +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.h @@ -1,6 +1,6 @@ /** * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 @@ -21,14 +21,17 @@ */ #pragma once -#include "HAL.h" - -// Arduino Due core now has watchdog support +/** + * DWIN End Stops diagnostic page for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 1.2.3 + * Date: 2022/02/24 + */ -void watchdog_init(); +class ESDiagClass { +public: + void Draw(); + void Update(); +}; -inline void HAL_watchdog_refresh() { - // Watchdog refresh sequence - WDOG_REFRESH = 0xA602; - WDOG_REFRESH = 0xB480; -} +extern ESDiagClass ESDiag; diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp new file mode 100644 index 000000000000..1a3a3abfab58 --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp @@ -0,0 +1,254 @@ +/** + * 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 . + * + */ + +/** + * DWIN g-code thumbnail preview + * Author: Miguel A. Risco-Castillo + * version: 2.1 + * Date: 2021/06/19 + * + * This program 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 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 Lesser General Public License + * along with this program. If not, see . + * + * For commercial applications additional licenses can be requested + */ + +#include "dwin_defines.h" + +#if HAS_GCODE_PREVIEW + +#include "../../../core/types.h" +#include "../../marlinui.h" +#include "../../../sd/cardreader.h" +#include "../../../MarlinCore.h" // for wait_for_user +#include "dwin_lcd.h" +#include "dwinui.h" +#include "dwin.h" +#include "dwin_popup.h" +#include "base64.hpp" +#include "gcode_preview.h" + +typedef struct { + char name[13] = ""; //8.3 + null + uint32_t thumbstart = 0; + int thumbsize = 0; + int thumbheight = 0; + int thumbwidth = 0; + uint8_t *thumbdata = nullptr; + float time = 0; + float filament = 0; + float layer = 0; + float width = 0; + float height = 0; + float length = 0; + void setname(const char * const fn); + void clear(); +} fileprop_t; +fileprop_t fileprop; + +void fileprop_t::setname(const char * const fn) { + const uint8_t len = _MIN(sizeof(name) - 1, strlen(fn)); + memcpy(&name[0], fn, len); + name[len] = '\0'; +} + +void fileprop_t::clear() { + fileprop.name[0] = '\0'; + fileprop.thumbstart = 0; + fileprop.thumbsize = 0; + fileprop.thumbheight = 0; + fileprop.thumbwidth = 0; + fileprop.thumbdata = nullptr; + fileprop.time = 0; + fileprop.filament = 0; + fileprop.layer = 0; + fileprop.height = 0; + fileprop.width = 0; + fileprop.length = 0; +} + +void Get_Value(char *buf, const char * const key, float &value) { + char num[10] = ""; + char * posptr = 0; + uint8_t i = 0; + if (!!value) return; + posptr = strstr(buf, key); + if (posptr != nullptr) { + while (i < sizeof(num)) { + char c = posptr[0]; + if (!ISEOL(c) && (c != 0)) { + if ((c > 47 && c < 58) || (c == '.')) num[i++] = c; + posptr++; + } + else { + num[i] = '\0'; + value = atof(num); + return; + } + } + } +} + +bool Has_Preview() { + const char * tbstart = "; thumbnail begin 230x180"; + char * posptr = 0; + uint8_t nbyte = 1; + uint32_t indx = 0; + char buf[256]; + float tmp = 0; + + fileprop.clear(); + fileprop.setname(card.filename); + + card.openFileRead(fileprop.name); + + while ((nbyte > 0) && (indx < 4 * sizeof(buf)) && !fileprop.thumbstart) { + nbyte = card.read(buf, sizeof(buf) - 1); + if (nbyte > 0) { + buf[nbyte] = '\0'; + Get_Value(buf, ";TIME:", fileprop.time); + Get_Value(buf, ";Filament used:", fileprop.filament); + Get_Value(buf, ";Layer height:", fileprop.layer); + Get_Value(buf, ";MINX:", tmp); + Get_Value(buf, ";MAXX:", fileprop.width); + fileprop.width -= tmp; + tmp = 0; + Get_Value(buf, ";MINY:", tmp); + Get_Value(buf, ";MAXY:", fileprop.length); + fileprop.length -= tmp; + tmp = 0; + Get_Value(buf, ";MINZ:", tmp); + Get_Value(buf, ";MAXZ:", fileprop.height); + fileprop.height -= tmp; + posptr = strstr(buf, tbstart); + if (posptr != NULL) { + fileprop.thumbstart = indx + (posptr - &buf[0]); + } + else { + indx += _MAX(10, nbyte - (signed)strlen(tbstart)); + card.setIndex(indx); + } + } + } + + if (!fileprop.thumbstart) { + card.closefile(); + LCD_MESSAGE_F("Thumbnail not found"); + return 0; + } + + // Get the size of the thumbnail + card.setIndex(fileprop.thumbstart + strlen(tbstart)); + for (uint8_t i = 0; i < 16; i++) { + char c = card.get(); + if (!ISEOL(c)) { + buf[i] = c; + } + else { + buf[i] = 0; + break; + } + } + fileprop.thumbsize = atoi(buf); + + // Exit if there isn't a thumbnail + if (!fileprop.thumbsize) { + card.closefile(); + LCD_MESSAGE_F("Invalid Thumbnail Size"); + return 0; + } + + uint16_t readed = 0; + uint8_t buf64[fileprop.thumbsize]; + + fileprop.thumbdata = new uint8_t[3 + 3 * (fileprop.thumbsize / 4)]; // Reserve space for the JPEG thumbnail + + while (readed < fileprop.thumbsize) { + uint8_t c = card.get(); + if (!ISEOL(c) && (c != ';') && (c != ' ')) { + buf64[readed] = c; + readed++; + } + } + card.closefile(); + buf64[readed] = 0; + + fileprop.thumbsize = decode_base64(buf64, fileprop.thumbdata); card.closefile(); + DWINUI::WriteToSRAM(0x00, fileprop.thumbsize, fileprop.thumbdata); + delete[] fileprop.thumbdata; + return true; +} + +void Preview_DrawFromSD() { + if (Has_Preview()) { + char buf[46]; + char str_1[6] = ""; + char str_2[6] = ""; + char str_3[6] = ""; + DWIN_Draw_Rectangle(1, HMI_data.Background_Color, 0, 0, DWIN_WIDTH, STATUS_Y - 1); + if (fileprop.time) { + sprintf_P(buf, PSTR("Estimated time: %i:%02i"), (uint16_t)fileprop.time / 3600, ((uint16_t)fileprop.time % 3600) / 60); + DWINUI::Draw_String(20, 10, buf); + } + if (fileprop.filament) { + sprintf_P(buf, PSTR("Filament used: %s m"), dtostrf(fileprop.filament, 1, 2, str_1)); + DWINUI::Draw_String(20, 30, buf); + } + if (fileprop.layer) { + sprintf_P(buf, PSTR("Layer height: %s mm"), dtostrf(fileprop.layer, 1, 2, str_1)); + DWINUI::Draw_String(20, 50, buf); + } + if (fileprop.width) { + sprintf_P(buf, PSTR("Volume: %sx%sx%s mm"), dtostrf(fileprop.width, 1, 1, str_1), dtostrf(fileprop.length, 1, 1, str_2), dtostrf(fileprop.height, 1, 1, str_3)); + DWINUI::Draw_String(20, 70, buf); + } + DWINUI::Draw_Button(BTN_Print, 26, 290); + DWINUI::Draw_Button(BTN_Cancel, 146, 290); + DWIN_ICON_Show(0, 0, 1, 21, 90, 0x00); + Draw_Select_Highlight(true, 290); + DWIN_UpdateLCD(); + } + else { + HMI_flag.select_flag = 1; + wait_for_user = false; + } +} + +bool Preview_Valid() { + return !!fileprop.thumbstart; +} + +void Preview_Reset() { + fileprop.thumbsize = 0; +} + +#endif // HAS_GCODE_PREVIEW diff --git a/Marlin/src/lcd/e3v2/enhanced/meshviewer.h b/Marlin/src/lcd/e3v2/proui/gcode_preview.h similarity index 77% rename from Marlin/src/lcd/e3v2/enhanced/meshviewer.h rename to Marlin/src/lcd/e3v2/proui/gcode_preview.h index 0ba6ae2d7d15..4417084a242d 100644 --- a/Marlin/src/lcd/e3v2/enhanced/meshviewer.h +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.h @@ -1,8 +1,8 @@ /** - * DWIN Mesh Viewer + * DWIN g-code thumbnail preview * Author: Miguel A. Risco-Castillo - * Version: 3.8.1 - * Date: 2021/11/06 + * version: 2.1 + * Date: 2021/06/19 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -17,12 +17,11 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * + * For commercial applications additional licenses can be requested */ -#pragma once -class MeshViewerClass { -public: - void Draw(); -}; +#pragma once -extern MeshViewerClass MeshViewer; +void Preview_DrawFromSD(); +bool Preview_Valid(); +void Preview_Reset(); diff --git a/Marlin/src/lcd/e3v2/enhanced/lockscreen.cpp b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp similarity index 81% rename from Marlin/src/lcd/e3v2/enhanced/lockscreen.cpp rename to Marlin/src/lcd/e3v2/proui/lockscreen.cpp index ca772184f148..44b595096a88 100644 --- a/Marlin/src/lcd/e3v2/enhanced/lockscreen.cpp +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp @@ -21,15 +21,15 @@ */ /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.6.3 - * Date: 2021/09/08 + * Lock screen implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 2.2.0 + * Date: 2022/04/11 */ #include "../../../inc/MarlinConfigPre.h" -#if ENABLED(DWIN_CREALITY_LCD_ENHANCED) +#if ENABLED(DWIN_LCD_PROUI) #include "../../../core/types.h" #include "dwin_lcd.h" @@ -41,6 +41,7 @@ LockScreenClass lockScreen; uint8_t LockScreenClass::lock_pos = 0; bool LockScreenClass::unlocked = false; +uint8_t LockScreenClass::rprocess = 0; void LockScreenClass::init() { lock_pos = 0; @@ -49,11 +50,11 @@ void LockScreenClass::init() { } void LockScreenClass::draw() { - Title.SetCaption(PSTR("Lock Screen")); - DWINUI::ClearMenuArea(); + Title.SetCaption(GET_TEXT_F(MSG_LOCKSCREEN)); + DWINUI::ClearMainArea(); DWINUI::Draw_Icon(ICON_LOGO, 71, 120); // CREALITY logo - DWINUI::Draw_CenteredString(Color_White, 180, F("Printer is Locked,")); - DWINUI::Draw_CenteredString(Color_White, 200, F("Scroll to unlock.")); + DWINUI::Draw_CenteredString(Color_White, 180, GET_TEXT_F(MSG_LOCKSCREEN_LOCKED)); + DWINUI::Draw_CenteredString(Color_White, 200, GET_TEXT_F(MSG_LOCKSCREEN_UNLOCK)); DWINUI::Draw_CenteredString(Color_White, 240, F("-> | <-")); DWIN_Draw_Box(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20); DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20); @@ -72,4 +73,4 @@ void LockScreenClass::onEncoder(EncoderState encoder_diffState) { DWIN_UpdateLCD(); } -#endif // DWIN_CREALITY_LCD_ENHANCED +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/enhanced/lockscreen.h b/Marlin/src/lcd/e3v2/proui/lockscreen.h similarity index 85% rename from Marlin/src/lcd/e3v2/enhanced/lockscreen.h rename to Marlin/src/lcd/e3v2/proui/lockscreen.h index f0c4c1fde8d2..83d5530be3e4 100644 --- a/Marlin/src/lcd/e3v2/enhanced/lockscreen.h +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.h @@ -22,10 +22,10 @@ #pragma once /** - * DWIN UI Enhanced implementation - * Author: Miguel A. Risco-Castillo - * Version: 3.6.3 - * Date: 2021/09/08 + * Lock screen implementation for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 2.2.0 + * Date: 2022/04/11 */ #include "../common/encoder.h" @@ -36,10 +36,11 @@ class LockScreenClass { static bool unlocked; static uint8_t lock_pos; public: + static uint8_t rprocess; static void init(); static void onEncoder(EncoderState encoder_diffState); static void draw(); - static inline bool isUnlocked() { return unlocked; } + static bool isUnlocked() { return unlocked; } }; extern LockScreenClass lockScreen; diff --git a/Marlin/src/lcd/e3v2/proui/menus.cpp b/Marlin/src/lcd/e3v2/proui/menus.cpp new file mode 100644 index 000000000000..6438545cb251 --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/menus.cpp @@ -0,0 +1,552 @@ +/** + * 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 . + * + */ + +/** + * Menu functions for ProUI + * Author: Miguel A. Risco-Castillo + * Version: 1.4.1 + * Date: 2022/04/14 + * + * This program 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 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 Lesser General Public License + * along with this program. If not, see . + * + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if ENABLED(DWIN_LCD_PROUI) + +#include "../common/encoder.h" +#include "dwin_lcd.h" +#include "dwinui.h" +#include "dwin.h" +#include "menus.h" + +int8_t MenuItemTotal = 0; +int8_t MenuItemCount = 0; +MenuItemClass** 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); + 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); +} + +void Draw_Menu(MenuClass* menu) { + DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color, HMI_data.StatusBg_Color); + DWIN_Draw_Rectangle(1, DWINUI::backcolor, 0, TITLE_HEIGHT, DWIN_WIDTH - 1, STATUS_Y - 1); +} + +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}); +} + +void Erase_Menu_Cursor(const int8_t line) { + const uint16_t ypos = MYPOS(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*/) { + 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); + DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); +} + +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 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); +} + +void onDrawMenuItem(MenuItemClass* menuitem, int8_t line) { + if (menuitem->icon) DWINUI::Draw_Icon(menuitem->icon, ICOX, MBASE(line) - 3); + if (menuitem->frameid) + DWIN_Frame_AreaCopy(menuitem->frameid, menuitem->frame.left, menuitem->frame.top, menuitem->frame.right, menuitem->frame.bottom, LBLX, MBASE(line)); + else if (menuitem->caption) + DWINUI::Draw_String(LBLX, MBASE(line) - 1, menuitem->caption); + DWIN_Draw_HLine(HMI_data.SplitLine_Color, 16, MYPOS(line + 1), 240); +} + +void onDrawSubMenu(MenuItemClass* menuitem, int8_t line) { + onDrawMenuItem(menuitem, line); + DWINUI::Draw_Icon(ICON_More, VALX + 16, MBASE(line) - 3); +} + +void onDrawIntMenu(MenuItemClass* menuitem, int8_t line, int32_t value) { + onDrawMenuItem(menuitem, line); + Draw_Menu_IntValue(HMI_data.Background_Color, line, 4, value); +} + +void onDrawPIntMenu(MenuItemClass* menuitem, int8_t line) { + const int16_t value = *(int16_t*)static_cast(menuitem)->value; + onDrawIntMenu(menuitem, line, value); +} + +void onDrawPInt8Menu(MenuItemClass* menuitem, int8_t line) { + const uint8_t value = *(uint8_t*)static_cast(menuitem)->value; + onDrawIntMenu(menuitem, line, value); +} + +void onDrawPInt32Menu(MenuItemClass* menuitem, int8_t line) { + const uint32_t value = *(uint32_t*)static_cast(menuitem)->value; + onDrawIntMenu(menuitem, line, value); +} + +void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value) { + onDrawMenuItem(menuitem, line); + 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) { + 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); +} + +void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line) { + const bool val = *(bool*)static_cast(menuitem)->value; + onDrawChkbMenu(menuitem, line, val); +} + +//----------------------------------------------------------------------------- +// On click functions +//----------------------------------------------------------------------------- + +// Generic onclick event without draw +// process: process id HMI destiny +// lo: low limit +// hi: high limit +// dp: decimal places, 0 for integers +// val: value / scaled value +// LiveUpdate: live update function when the encoder changes +// Apply: update function when the encoder is pressed +void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, const int32_t val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { + checkkey = process; + MenuData.MinValue = lo; + MenuData.MaxValue = hi; + MenuData.dp = dp; + MenuData.Apply = Apply; + MenuData.LiveUpdate = LiveUpdate; + MenuData.Value = constrain(val, lo, hi); + EncoderRate.enabled = true; +} + +// Generic onclick event for integer values +// process: process id HMI destiny +// lo: scaled low limit +// hi: scaled high limit +// val: value +// LiveUpdate: live update function when the encoder changes +// 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); +} + +// Generic onclick event for float values +// process: process id HMI destiny +// lo: scaled low limit +// hi: scaled high limit +// val: value +// LiveUpdate: live update function when the encoder changes +// Apply: update function when the encoder is pressed +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); +} + +// Generic onclick event for integer values +// lo: scaled low limit +// hi: scaled high limit +// val: value +// LiveUpdate: live update function when the encoder changes +// Apply: update function when the encoder is pressed +void SetIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { + SetValueOnClick(SetInt, lo, hi, val, Apply, LiveUpdate); +} + +// Generic onclick event for set pointer to 16 bit uinteger values +// lo: low limit +// hi: high limit +// LiveUpdate: live update function when the encoder changes +// Apply: update function when the encoder is pressed +void SetPIntOnClick(const int32_t lo, const int32_t hi, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { + MenuData.P_Int = (int16_t*)static_cast(CurrentMenu->SelectedItem())->value; + const int32_t value = *MenuData.P_Int; + SetValueOnClick(SetPInt, lo, hi, value, Apply, LiveUpdate); +} + +// Generic onclick event for float values +// process: process id HMI destiny +// lo: low limit +// hi: high limit +// dp: decimal places +// val: value +void SetFloatOnClick(const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { + SetValueOnClick(SetFloat, lo, hi, dp, val, Apply, LiveUpdate); +} + +// Generic onclick event for set pointer to float values +// lo: low limit +// hi: high limit +// LiveUpdate: live update function when the encoder changes +// Apply: update function when the encoder is pressed +void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)() /*= nullptr*/, void (*LiveUpdate)() /*= nullptr*/) { + MenuData.P_Float = (float*)static_cast(CurrentMenu->SelectedItem())->value; + SetValueOnClick(SetPFloat, lo, hi, dp, *MenuData.P_Float, Apply, LiveUpdate); +} + +// HMI Control functions ====================================================== + +// 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_ENTER) + CurrentMenu->onClick(); + else + CurrentMenu->onScroll(encoder_diffState == ENCODER_DIFF_CW); + } +} + +// Get an integer value using the encoder without draw anything +// lo: low limit +// hi: high limit +// Return value: +// 0 : no change +// 1 : live change +// 2 : apply change +int8_t HMI_GetIntNoDraw(const int32_t lo, const int32_t hi) { + 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(); + 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); + 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; +} + +// Set an integer using the encoder +void HMI_SetInt() { + int8_t val = HMI_GetInt(MenuData.MinValue, MenuData.MaxValue); + switch (val) { + case 0: return; break; + 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); + switch (val) { + case 0: return; break; + case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; + case 2: if (MenuData.Apply) MenuData.Apply(); break; + } +} + +// Set an integer pointer variable using the encoder +void HMI_SetPInt() { + int8_t val = HMI_GetInt(MenuData.MinValue, MenuData.MaxValue); + switch (val) { + case 0: return; + case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; + case 2: *MenuData.P_Int = MenuData.Value; if (MenuData.Apply) MenuData.Apply(); break; + } +} + +// 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); + switch (val) { + case 0: return; + case 1: if (MenuData.LiveUpdate) MenuData.LiveUpdate(); break; + case 2: *MenuData.P_Float = MenuData.Value / POW(10, MenuData.dp); if (MenuData.Apply) MenuData.Apply(); break; + } +} + +// Menu Classes =============================================================== + +MenuClass::MenuClass() { + selected = 0; + topline = 0; +} + +void MenuClass::draw() { + MenuTitle.draw(); + if (onMenuDraw != nullptr) onMenuDraw(this); + for (int8_t i = 0; i < MenuItemCount; i++) + MenuItems[i]->draw(i - topline); + if (onCursorDraw != nullptr) onCursorDraw(line()); + DWIN_UpdateLCD(); +} + +void MenuClass::onScroll(bool dir) { + int8_t sel = selected; + if (dir) sel++; else sel--; + LIMIT(sel, 0, MenuItemCount - 1); + if (sel != selected) { + if (onCursorErase != nullptr) onCursorErase(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); + topline++; + MenuItems[sel]->draw(TROWS - 1); + } + if ((sel < topline)) { + DWIN_Frame_AreaMove(1, DWIN_SCROLL_DOWN, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1); + topline--; + MenuItems[sel]->draw(0); + } + selected = sel; + if (onCursorDraw != nullptr) onCursorDraw(line()); + DWIN_UpdateLCD(); + } +} + +void MenuClass::onClick() { + if (MenuItems[selected]->onClick != nullptr) (*MenuItems[selected]->onClick)(); +} + +MenuItemClass *MenuClass::SelectedItem() { + return MenuItems[selected]; +} + +MenuItemClass** MenuClass::Items() { + return MenuItems; +} + +int8_t MenuClass::count() { + return MenuItemCount; +}; + +/* MenuItem Class ===========================================================*/ + +MenuItemClass::MenuItemClass(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)()) { + icon = cicon; + onClick = onclick; + onDraw = ondraw; + const uint8_t len = _MIN(sizeof(caption) - 1, strlen(text)); + memcpy(&caption[0], text, len); + caption[len] = '\0'; +} + +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)()) { + icon = cicon; + onClick = onclick; + onDraw = ondraw; + caption[0] = '\0'; + frameid = id; + frame = { x1, y1, x2, y2 }; +} + +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) { + value = val; +}; + +// Menu auxiliary functions =================================================== + +void MenuItemsClear() { + if (MenuItems == nullptr) return; + for (int8_t i = 0; i < MenuItemCount; i++) delete MenuItems[i]; + delete[] MenuItems; + MenuItems = nullptr; + MenuItemCount = 0; + MenuItemTotal = 0; +} + +void MenuItemsPrepare(int8_t totalitems) { + MenuItemsClear(); + MenuItemTotal = totalitems; + MenuItems = new MenuItemClass*[totalitems]; +} + +MenuItemClass* MenuItemsAdd(MenuItemClass* 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*/) { + if (MenuItemCount < MenuItemTotal) { + MenuItemClass* menuitem = new MenuItemClass(cicon, text, ondraw, onclick); + return MenuItemsAdd(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*/) { + if (MenuItemCount < MenuItemTotal) { + MenuItemClass* menuitem = new MenuItemClass(cicon, id, x1, y1, x2, y2, ondraw, onclick); + return MenuItemsAdd(menuitem); + } + else return nullptr; +} + +MenuItemClass* MenuItemsAdd(uint8_t cicon, const char * const text, void (*ondraw)(MenuItemClass* menuitem, int8_t line), void (*onclick)(), void* val) { + if (MenuItemCount < MenuItemTotal) { + MenuItemClass* menuitem = new MenuItemPtrClass(cicon, text, ondraw, onclick, val); + return MenuItemsAdd(menuitem); + } + else return nullptr; +} + +bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems) { + if (!menu) menu = new MenuClass(); + const bool NotCurrent = (CurrentMenu != menu); + if (NotCurrent) { + menu->MenuTitle.SetCaption(title); + MenuItemsPrepare(totalitems); + } + return NotCurrent; +} + +void UpdateMenu(MenuClass* &menu) { + if (!menu) return; + if (CurrentMenu != menu) { + PreviousMenu = CurrentMenu; + CurrentMenu = menu; + } + menu->draw(); +} + +void ReDrawMenu() { if (CurrentMenu && checkkey==Menu) CurrentMenu->draw(); } + +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/menus.h b/Marlin/src/lcd/e3v2/proui/menus.h new file mode 100644 index 000000000000..d4514d173237 --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/menus.h @@ -0,0 +1,188 @@ +/** + * 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 . + * + */ + +/** + * Menu functions for ProUI + * Author: Miguel A. Risco-Castillo + * Version: 1.4.1 + * Date: 2022/04/14 + * + * This program 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 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 Lesser General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "dwinui.h" + +typedef struct { + int32_t MaxValue = 0; // Auxiliar max integer/scaled float value + int32_t MinValue = 0; // Auxiliar min integer/scaled float value + int8_t dp = 0; // Auxiliar decimal places + int32_t Value = 0; // Auxiliar integer / scaled float value + int16_t *P_Int = nullptr; // Auxiliar pointer to 16 bit integer variable + float *P_Float = nullptr; // Auxiliar pointer to float variable + void (*Apply)() = nullptr; // Auxiliar apply function + void (*LiveUpdate)() = nullptr; // Auxiliar live update function +} 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) + +// Menu Classes =============================================================== + +class MenuItemClass { +protected: +public: + int8_t pos = 0; + uint8_t icon = 0; + char caption[32] = ""; + 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); + 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(); +}; + +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){} +}; + +class MenuClass { +public: + int8_t topline = 0; + int8_t selected = 0; + TitleClass MenuTitle; + MenuClass(); + virtual ~MenuClass(){}; + inline int8_t line() { return selected - topline; }; + inline int8_t line(uint8_t pos) {return pos - topline; }; + int8_t count(); + virtual void draw(); + virtual void onScroll(bool dir); + void onClick(); + MenuItemClass* SelectedItem(); + static MenuItemClass** Items(); +}; +extern MenuClass *CurrentMenu; +extern MenuClass *PreviousMenu; +extern void (*onMenuDraw)(MenuClass* menu); + +// Menuitem Drawing functions ================================================= + +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 Draw_Chkb_Line(const uint8_t line, const 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); +void onDrawIntMenu(MenuItemClass* menuitem, int8_t line, int32_t value); +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 onDrawChkbMenu(MenuItemClass* menuitem, int8_t line, bool checked); +void onDrawChkbMenu(MenuItemClass* menuitem, int8_t line); + +// On click functions ========================================================= + +void SetOnClick(uint8_t process, const int32_t lo, const int32_t hi, uint8_t dp, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); +void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); +void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); +void SetIntOnClick(const int32_t lo, const int32_t hi, const int32_t val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); +void SetPIntOnClick(const int32_t lo, const int32_t hi, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); +void SetFloatOnClick(const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); +void SetPFloatOnClick(const float lo, const float hi, uint8_t dp, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr); + +// HMI user control functions ================================================= + +void HMI_Menu(); +void HMI_SetInt(); +void HMI_SetPInt(); +void HMI_SetIntNoDraw(); +void HMI_SetFloat(); +void HMI_SetPFloat(); + +// Menu auxiliary functions =================================================== + +// Create a new menu +bool SetMenu(MenuClass* &menu, FSTR_P title, int8_t totalitems); + +//Update the Menu and Draw if it is valid +void UpdateMenu(MenuClass* &menu); + +//Redraw the current Menu if it is valid +void ReDrawMenu(); + +// Clear MenuItems array and free MenuItems elements +void MenuItemsClear(); + +// Prepare MenuItems array +void MenuItemsPrepare(int8_t totalitems); + +// 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); +} +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); +} diff --git a/Marlin/src/lcd/e3v2/proui/meshviewer.cpp b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp new file mode 100644 index 000000000000..c2d01a07eb76 --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.cpp @@ -0,0 +1,145 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 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 . + * + */ + +/** + * Mesh Viewer for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * version: 3.14.1 + * Date: 2022/04/11 + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if BOTH(DWIN_LCD_PROUI, HAS_MESH) + +#include "meshviewer.h" + +#include "../../../core/types.h" +#include "../../marlinui.h" +#include "dwin_lcd.h" +#include "dwinui.h" +#include "dwin.h" +#include "dwin_popup.h" +#include "../../../feature/bedlevel/bedlevel.h" + +#if ENABLED(AUTO_BED_LEVELING_UBL) + #include "ubl_tools.h" +#endif + +MeshViewerClass MeshViewer; + +void MeshViewerClass::DrawMesh(bed_mesh_t zval, const uint8_t sizex, const uint8_t sizey) { + const int8_t mx = 25, my = 25; // Margins + const int16_t stx = (DWIN_WIDTH - 2 * mx) / (sizex - 1), // Steps + sty = (DWIN_WIDTH - 2 * my) / (sizey - 1); + const int8_t rmax = _MIN(mx - 2, stx / 2); + const int8_t rmin = 7; + int16_t zmesh[sizex][sizey]; + #define px(xp) (mx + (xp) * stx) + #define py(yp) (30 + DWIN_WIDTH - my - (yp) * sty) + #define rm(z) ((z - minz) * (rmax - rmin) / _MAX(1, (maxz - minz)) + rmin) + #define DrawMeshValue(xp, yp, zv) DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(xp) - 18, py(yp) - 6, zv) + #define DrawMeshHLine(yp) DWIN_Draw_HLine(HMI_data.SplitLine_Color, px(0), py(yp), DWIN_WIDTH - 2 * mx) + #define DrawMeshVLine(xp) DWIN_Draw_VLine(HMI_data.SplitLine_Color, px(xp), py(sizey - 1), DWIN_WIDTH - 2 * my) + int16_t maxz =-32000; int16_t minz = 32000; + LOOP_L_N(y, sizey) LOOP_L_N(x, sizex) { + const float v = isnan(zval[x][y]) ? 0 : round(zval[x][y] * 100); + zmesh[x][y] = v; + NOLESS(maxz, v); + NOMORE(minz, v); + } + max = (float)maxz / 100; + min = (float)minz / 100; + DWINUI::ClearMainArea(); + DWIN_Draw_Rectangle(0, HMI_data.SplitLine_Color, px(0), py(0), px(sizex - 1), py(sizey - 1)); + LOOP_S_L_N(x, 1, sizex - 1) DrawMeshVLine(x); + LOOP_S_L_N(y, 1, sizey - 1) DrawMeshHLine(y); + LOOP_L_N(y, sizey) { + hal.watchdog_refresh(); + LOOP_L_N(x, sizex) { + uint16_t color = DWINUI::RainbowInt(zmesh[x][y], _MIN(-5, minz), _MAX(5, maxz)); + uint8_t radius = rm(zmesh[x][y]); + DWINUI::Draw_FillCircle(color, px(x), py(y), radius); + if (sizex < 9) { + if (zmesh[x][y] == 0) DWINUI::Draw_Float(font6x12, 1, 2, px(x) - 12, py(y) - 6, 0); + else DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(x) - 18, py(y) - 6, zval[x][y]); + } + else { + char str_1[9]; + str_1[0] = 0; + switch (zmesh[x][y]) { + case -999 ... -100: + DWINUI::Draw_Signed_Float(font6x12, 1, 1, px(x) - 18, py(y) - 6, zval[x][y]); + break; + case -99 ... -1: + sprintf_P(str_1, PSTR("-.%02i"), -zmesh[x][y]); + break; + case 0: + DWIN_Draw_String(false, font6x12, DWINUI::textcolor, DWINUI::backcolor, px(x) - 4, py(y) - 6, "0"); + break; + case 1 ... 99: + sprintf_P(str_1, PSTR(".%02i"), zmesh[x][y]); + break; + case 100 ... 999: + DWINUI::Draw_Signed_Float(font6x12, 1, 1, px(x) - 18, py(y) - 6, zval[x][y]); + break; + } + if (str_1[0]) + DWIN_Draw_String(false, font6x12, DWINUI::textcolor, DWINUI::backcolor, px(x) - 12, py(y) - 6, str_1); + } + } + } +} + +void MeshViewerClass::Draw(bool withsave /*= false*/) { + Title.ShowCaption(GET_TEXT_F(MSG_MESH_VIEWER)); + #if ENABLED(USE_UBL_VIEWER) + DWINUI::ClearMainArea(); + ubl_tools.viewer_print_value = true; + ubl_tools.Draw_Bed_Mesh(-1, 1, 8, 10 + TITLE_HEIGHT); + #else + DrawMesh(bedlevel.z_values, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y); + #endif + if (withsave) { + DWINUI::Draw_Button(BTN_Save, 26, 305); + DWINUI::Draw_Button(BTN_Continue, 146, 305); + Draw_Select_Highlight(HMI_flag.select_flag, 305); + } + else + DWINUI::Draw_Button(BTN_Continue, 86, 305); + + #if ENABLED(USE_UBL_VIEWER) + ubl_tools.Set_Mesh_Viewer_Status(); + #else + char str_1[6], str_2[6] = ""; + ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"), + dtostrf(min, 1, 2, str_1), + dtostrf(max, 1, 2, str_2) + ); + #endif +} + +void Draw_MeshViewer() { MeshViewer.Draw(true); } +void onClick_MeshViewer() { if (HMI_flag.select_flag) SaveMesh(); HMI_ReturnScreen(); } +void Goto_MeshViewer() { if (leveling_is_valid()) Goto_Popup(Draw_MeshViewer, onClick_MeshViewer); else HMI_ReturnScreen(); } + +#endif // DWIN_LCD_PROUI && HAS_MESH diff --git a/Marlin/src/lcd/e3v2/proui/meshviewer.h b/Marlin/src/lcd/e3v2/proui/meshviewer.h new file mode 100644 index 000000000000..1e78ff2657b8 --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/meshviewer.h @@ -0,0 +1,43 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 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 "../../../core/types.h" +#include "../../../feature/bedlevel/bedlevel.h" + +/** + * Mesh Viewer for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * version: 3.14.1 + * Date: 2022/04/11 + */ + +class MeshViewerClass { +public: + float max, min; + void Draw(bool withsave = false); + void DrawMesh(bed_mesh_t zval, const uint8_t sizex, const uint8_t sizey); +}; + +extern MeshViewerClass MeshViewer; + +void Goto_MeshViewer(); diff --git a/Marlin/src/lcd/e3v2/proui/plot.cpp b/Marlin/src/lcd/e3v2/proui/plot.cpp new file mode 100644 index 000000000000..ebc685fa2453 --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/plot.cpp @@ -0,0 +1,94 @@ +/** + * 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 . + * + */ + +/** + * DWIN Single var plot + * Author: Miguel A. Risco-Castillo + * Version: 2.0 + * Date: 2022/01/31 + * + * This program 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 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 Lesser General Public License + * along with this program. If not, see . + * + * For commercial applications additional licenses can be requested + */ + +#include "../../../inc/MarlinConfigPre.h" + +#ifdef DWIN_LCD_PROUI + +#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) + +PlotClass Plot; + +uint16_t grphpoints, r, x2, y2 = 0; +frame_rect_t grphframe = {0}; +float scale = 0; + +void PlotClass::Draw(const frame_rect_t frame, const float max, const float ref) { + grphframe = frame; + grphpoints = 0; + scale = frame.h / max; + x2 = frame.x + frame.w - 1; + 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); + DWINUI::Draw_Box(0, Color_White, DWINUI::ExtendFrame(frame, 1)); + DWIN_Draw_HLine(Color_Red, frame.x, r, frame.w); +} + +void PlotClass::Update(const float value) { + if (!scale) return; + uint16_t y = round((y2) - value * scale); + if (grphpoints < grphframe.w) { + DWIN_Draw_Point(Color_Yellow, 1, 1, grphpoints + grphframe.x, y); + } + else { + DWIN_Frame_AreaMove(1, 0, 1, Plot_Bg_Color, grphframe.x, grphframe.y, x2, y2); + if ((grphpoints % 50) == 0) DWIN_Draw_VLine(Line_Color, x2 - 1, grphframe.y + 1, grphframe.h - 2); + DWIN_Draw_Point(Color_Red, 1, 1, x2 - 1, r); + DWIN_Draw_Point(Color_Yellow, 1, 1, x2 - 1, y); + } + grphpoints++; +} + +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/plot.h b/Marlin/src/lcd/e3v2/proui/plot.h new file mode 100644 index 000000000000..8522c530bd3f --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/plot.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 . + * + */ + +/** + * DWIN Single var plot + * Author: Miguel A. Risco-Castillo + * Version: 1.0 + * Date: 2022/01/30 + * + * This program 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 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 Lesser General Public License + * along with this program. If not, see . + * + * For commercial applications additional licenses can be requested + */ +#pragma once + +#include "dwinui.h" + +class PlotClass { +public: + void Draw(frame_rect_t frame, float max, float ref = 0); + void Update(float value); +}; + +extern PlotClass Plot; diff --git a/Marlin/src/lcd/e3v2/proui/printstats.cpp b/Marlin/src/lcd/e3v2/proui/printstats.cpp new file mode 100644 index 000000000000..5a7b6c9c4170 --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/printstats.cpp @@ -0,0 +1,82 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 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 . + * + */ + +/** + * Print Stats page for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 1.3.0 + * Date: 2022/02/24 + */ + +#include "../../../inc/MarlinConfigPre.h" + +#if BOTH(DWIN_LCD_PROUI, PRINTCOUNTER) + +#include "printstats.h" + +#include "../../../core/types.h" +#include "../../../MarlinCore.h" +#include "../../marlinui.h" +#include "../../../module/printcounter.h" +#include "dwin_lcd.h" +#include "dwinui.h" +#include "dwin_popup.h" +#include "dwin.h" + +PrintStatsClass PrintStats; + +void PrintStatsClass::Draw() { + char buf[50] = ""; + char str[30] = ""; + constexpr int8_t MRG = 30; + + Title.ShowCaption(GET_TEXT_F(MSG_INFO_STATS_MENU)); + DWINUI::ClearMainArea(); + Draw_Popup_Bkgd(); + DWINUI::Draw_Button(BTN_Continue, 86, 250); + printStatistics ps = print_job_timer.getStats(); + + sprintf_P(buf, PSTR(S_FMT ": %i"), GET_TEXT(MSG_INFO_PRINT_COUNT), ps.totalPrints); + DWINUI::Draw_String(MRG, 80, buf); + sprintf_P(buf, PSTR(S_FMT ": %i"), GET_TEXT(MSG_INFO_COMPLETED_PRINTS), ps.finishedPrints); + DWINUI::Draw_String(MRG, 100, buf); + duration_t(print_job_timer.getStats().printTime).toDigital(str, true); + sprintf_P(buf, PSTR(S_FMT ": %s"), GET_TEXT(MSG_INFO_PRINT_TIME), str); + DWINUI::Draw_String(MRG, 120, buf); + duration_t(print_job_timer.getStats().longestPrint).toDigital(str, true); + sprintf_P(buf, PSTR(S_FMT ": %s"), GET_TEXT(MSG_INFO_PRINT_LONGEST), str); + DWINUI::Draw_String(MRG, 140, buf); + sprintf_P(buf, PSTR(S_FMT ": %s m"), GET_TEXT(MSG_INFO_PRINT_FILAMENT), dtostrf(ps.filamentUsed / 1000, 1, 2, str)); + DWINUI::Draw_String(MRG, 160, buf); +} + +void PrintStatsClass::Reset() { + print_job_timer.initStats(); + DONE_BUZZ(true); +} + +void Goto_PrintStats() { + PrintStats.Draw(); + HMI_SaveProcessID(WaitResponse); +} + +#endif // DWIN_LCD_PROUI && PRINTCOUNTER diff --git a/Marlin/src/lcd/e3v2/proui/printstats.h b/Marlin/src/lcd/e3v2/proui/printstats.h new file mode 100644 index 000000000000..705c923da41b --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/printstats.h @@ -0,0 +1,39 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2021 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 + +/** + * Print Stats page for PRO UI + * Author: Miguel A. Risco-Castillo (MRISCOC) + * Version: 1.3.0 + * Date: 2022/02/24 + */ + +class PrintStatsClass { +public: + static void Draw(); + static void Reset(); +}; + +extern PrintStatsClass PrintStats; + +void Goto_PrintStats(); diff --git a/Marlin/src/lcd/e3v2/proui/ubl_tools.cpp b/Marlin/src/lcd/e3v2/proui/ubl_tools.cpp new file mode 100644 index 000000000000..6c9175700574 --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/ubl_tools.cpp @@ -0,0 +1,260 @@ +/** + * 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 + * + * Original Author: Henri-J-Norden + * Original Source: https://github.com/Jyers/Marlin/pull/126 + */ + +#include "../../../inc/MarlinConfigPre.h" +#include "ubl_tools.h" + +#if ENABLED(DWIN_LCD_PROUI) + +#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" +#include "../../../module/planner.h" +#include "../../../gcode/queue.h" +#include "../../../libs/least_squares_fit.h" +#include "../../../libs/vector_3.h" + +UBLMeshToolsClass ubl_tools; + +#if ENABLED(USE_UBL_VIEWER) + bool UBLMeshToolsClass::viewer_asymmetric_range = false; + bool UBLMeshToolsClass::viewer_print_value = false; +#endif +bool UBLMeshToolsClass::goto_mesh_value = false; +uint8_t UBLMeshToolsClass::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*/) { + 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() { + struct linear_fit_data lsf_results; + incremental_LSF_reset(&lsf_results); + GRID_LOOP(x, y) { + if (!isnan(bedlevel.z_values[x][y])) { + xy_pos_t rpos = { bedlevel.get_mesh_x(x), bedlevel.get_mesh_y(y) }; + incremental_LSF(&lsf_results, rpos, bedlevel.z_values[x][y]); + } + } + + if (finish_incremental_LSF(&lsf_results)) { + SERIAL_ECHOPGM("Could not complete LSF!"); + return true; + } + + bedlevel.set_all_mesh_points_to_value(0); + + matrix_3x3 rotation = matrix_3x3::create_look_at(vector_3(lsf_results.A, lsf_results.B, 1)); + GRID_LOOP(i, j) { + float mx = bedlevel.get_mesh_x(i), + my = bedlevel.get_mesh_y(j), + mz = bedlevel.z_values[i][j]; + + if (DEBUGGING(LEVELING)) { + DEBUG_ECHOPAIR_F("before rotation = [", mx, 7); + DEBUG_CHAR(','); + DEBUG_ECHO_F(my, 7); + DEBUG_CHAR(','); + DEBUG_ECHO_F(mz, 7); + DEBUG_ECHOPGM("] ---> "); + DEBUG_DELAY(20); + } + + rotation.apply_rotation_xyz(mx, my, mz); + + if (DEBUGGING(LEVELING)) { + DEBUG_ECHOPAIR_F("after rotation = [", mx, 7); + DEBUG_CHAR(','); + DEBUG_ECHO_F(my, 7); + DEBUG_CHAR(','); + DEBUG_ECHO_F(mz, 7); + DEBUG_ECHOLNPGM("]"); + DEBUG_DELAY(20); + } + + bedlevel.z_values[i][j] = mz - lsf_results.D; + } + return false; + } + +#else + + void UBLMeshToolsClass::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(); + } + +#endif + +void UBLMeshToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove/*=false*/) { + if (zmove) { + planner.synchronize(); + current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES; + planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); + planner.synchronize(); + } + else { + DWIN_Show_Popup(ICON_BLTouch, F("Moving to Point"), F("Please wait until done.")); + HMI_SaveProcessID(NothingToDo); + sprintf_P(cmd, PSTR("G0 F300 Z%s"), dtostrf(Z_CLEARANCE_BETWEEN_PROBES, 1, 3, str_1)); + gcode.process_subcommands_now(cmd); + sprintf_P(cmd, PSTR("G42 F4000 I%i J%i"), mesh_x, mesh_y); + gcode.process_subcommands_now(cmd); + planner.synchronize(); + current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES; + planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder); + planner.synchronize(); + HMI_ReturnScreen(); + } +} + +float UBLMeshToolsClass::get_max_value() { + float max = __FLT_MIN__; + GRID_LOOP(x, y) { + if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] > max) + max = bedlevel.z_values[x][y]; + } + return max; +} + +float UBLMeshToolsClass::get_min_value() { + float min = __FLT_MAX__; + GRID_LOOP(x, y) { + if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] < min) + min = bedlevel.z_values[x][y]; + } + return min; +} + +bool UBLMeshToolsClass::validate() { + float min = __FLT_MAX__, max = __FLT_MIN__; + + 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]; + } + return max <= UBL_Z_OFFSET_MAX && min >= UBL_Z_OFFSET_MIN; +} + +#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*/) { + 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); + const uint16_t cell_height_px = total_width_px / (GRID_MAX_POINTS_Y); + const float v_max = abs(get_max_value()), v_min = abs(get_min_value()), range = _MAX(v_min, v_max); + + // Clear background from previous selection and select new square + DWIN_Draw_Rectangle(1, Color_Bg_Black, _MAX(0, padding_x - gridline_width), _MAX(0, padding_y_top - gridline_width), padding_x + total_width_px, padding_y_top + total_width_px); + if (selected >= 0) { + const auto selected_y = selected / (GRID_MAX_POINTS_X); + const auto selected_x = selected - (GRID_MAX_POINTS_X) * selected_y; + const auto start_y_px = padding_y_top + selected_y * cell_height_px; + const auto start_x_px = padding_x + selected_x * cell_width_px; + DWIN_Draw_Rectangle(1, Color_White, _MAX(0, start_x_px - gridline_width), _MAX(0, start_y_px - gridline_width), start_x_px + cell_width_px, start_y_px + cell_height_px); + } + + // Draw value square grid + char buf[8]; + GRID_LOOP(x, y) { + const auto start_x_px = padding_x + x * cell_width_px; + const auto end_x_px = start_x_px + cell_width_px - 1 - gridline_width; + const auto start_y_px = padding_y_top + ((GRID_MAX_POINTS_Y) - y - 1) * cell_height_px; + const auto end_y_px = start_y_px + cell_height_px - 1 - gridline_width; + DWIN_Draw_Rectangle(1, // RGB565 colors: http://www.barth-dev.de/online/rgb565-color-picker/ + isnan(bedlevel.z_values[x][y]) ? Color_Grey : ( // gray if undefined + (bedlevel.z_values[x][y] < 0 ? + (uint16_t)round(0x1F * -bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? range : v_min)) << 11 : // red if mesh point value is negative + (uint16_t)round(0x3F * bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? range : v_max)) << 5) | // green if mesh point value is positive + _MIN(0x1F, (((uint8_t)abs(bedlevel.z_values[x][y]) / 10) * 4))), // + blue stepping for every mm + start_x_px, start_y_px, end_x_px, end_y_px + ); + + safe_delay(10); + LCD_SERIAL.flushTX(); + + // Draw value text on + if (viewer_print_value) { + int8_t offset_x, offset_y = cell_height_px / 2 - 6; + if (isnan(bedlevel.z_values[x][y])) { // undefined + DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X")); + } + else { // has value + if (GRID_MAX_POINTS_X < 10) + sprintf_P(buf, PSTR("%s"), dtostrf(abs(bedlevel.z_values[x][y]), 1, 2, str_1)); + else + sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(bedlevel.z_values[x][y] - (int16_t)bedlevel.z_values[x][y]) * 100)); + offset_x = cell_width_px / 2 - 3 * (strlen(buf)) - 2; + if (!(GRID_MAX_POINTS_X < 10)) + DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, F(".")); + DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px + 1 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, buf); + } + safe_delay(10); + LCD_SERIAL.flushTX(); + } + } + } + + void UBLMeshToolsClass::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; + if (range > 3e+10F) range = 0.0000001; + char msg[46]; + if (viewer_asymmetric_range) { + dtostrf(-v_min, 1, 3, str_1); + dtostrf( v_max, 1, 3, str_2); + } + else { + dtostrf(-range, 1, 3, str_1); + dtostrf( range, 1, 3, str_2); + } + sprintf_P(msg, PSTR("Red %s..0..%s Green"), str_1, str_2); + ui.set_status(msg); + drawing_mesh = false; + } +#endif + +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/ubl_tools.h b/Marlin/src/lcd/e3v2/proui/ubl_tools.h new file mode 100644 index 000000000000..563794a46385 --- /dev/null +++ b/Marlin/src/lcd/e3v2/proui/ubl_tools.h @@ -0,0 +1,59 @@ +/** + * UBL Tools and Mesh Viewer for Pro UI + * Version: 1.0.0 + * Date: 2022/04/13 + * + * Original Author: Henri-J-Norden (https://github.com/Henri-J-Norden) + * Original Source: https://github.com/Jyers/Marlin/pull/135 + * + * 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/MarlinConfigPre.h" + +//#define USE_UBL_VIEWER 1 + +#define UBL_Z_OFFSET_MIN -3.0 +#define UBL_Z_OFFSET_MAX 3.0 + +class UBLMeshToolsClass { +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 tilt_grid; + + #if ENABLED(AUTO_BED_LEVELING_UBL) + static void manual_value_update(const uint8_t mesh_x, const uint8_t mesh_y, bool undefined=false); + static bool create_plane_from_mesh(); + #else + 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 float get_max_value(); + static float get_min_value(); + static bool validate(); + #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(); diff --git a/Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp b/Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp index f49b17acc190..0ef818666837 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp @@ -155,7 +155,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) { if (currentindex == 0 && currentfolderdepth > 0) { // Add a link to go up a folder // The new panel ignores entries that don't end in .GCO or .gcode so add and pad them. - if (paneltype == AC_panel_new) { + if (paneltype <= AC_panel_new) { TFTSer.println("<<.GCO"); Chiron.SendtoTFTLN(F(".. .gcode")); } @@ -177,7 +177,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) { void FileNavigator::sendFile(panel_type_t paneltype) { if (filelist.isDir()) { // Add mandatory tags for new panel otherwise lines are ignored. - if (paneltype == AC_panel_new) { + if (paneltype <= AC_panel_new) { TFTSer.print(filelist.shortFilename()); TFTSer.println(".GCO"); TFTSer.print(filelist.shortFilename()); diff --git a/Marlin/src/lcd/extui/anycubic_chiron/Tunes.cpp b/Marlin/src/lcd/extui/anycubic_chiron/Tunes.cpp index f228c471c9ca..adbf98e3bb82 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/Tunes.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/Tunes.cpp @@ -35,6 +35,8 @@ #include "../../../inc/MarlinConfigPre.h" +// TODO: Use Marlin's built-in tone player instead. + #if ENABLED(ANYCUBIC_LCD_CHIRON) #include "Tunes.h" @@ -44,15 +46,12 @@ namespace Anycubic { void PlayTune(uint8_t beeperPin, const uint16_t *tune, uint8_t speed=1) { uint8_t pos = 1; - uint16_t wholenotelen = tune[0] / speed; + const uint16_t wholenotelen = tune[0] / speed; do { - uint16_t freq = tune[pos]; - uint16_t notelen = wholenotelen / tune[pos + 1]; - + const uint16_t freq = tune[pos], notelen = wholenotelen / tune[pos + 1]; ::tone(beeperPin, freq, notelen); ExtUI::delay_ms(notelen); pos += 2; - if (pos >= MAX_TUNE_LENGTH) break; } while (tune[pos] != n_END); } diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp index 7a58963c11fe..75061c162a7a 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_extui.cpp @@ -57,14 +57,16 @@ namespace ExtUI { void onPrintTimerStarted() { Chiron.TimerEvent(AC_timer_started); } void onPrintTimerPaused() { Chiron.TimerEvent(AC_timer_paused); } - void onPrintTimerStopped() { Chiron.TimerEvent(AC_timer_stopped); } + void onPrintTimerStopped() { Chiron.TimerEvent(AC_timer_stopped); } + void onPrintDone() {} + void onFilamentRunout(const extruder_t) { Chiron.FilamentRunout(); } + void onUserConfirmRequired(const char * const msg) { Chiron.ConfirmationRequest(msg); } void onStatusChanged(const char * const msg) { Chiron.StatusChange(msg); } void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} void onFactoryReset() {} @@ -92,18 +94,19 @@ namespace ExtUI { // Called after loading or resetting stored settings } - void onConfigurationStoreWritten(bool success) { + void onSettingsStored(bool success) { // Called after the entire EEPROM has been written, // whether successful or not. } - void onConfigurationStoreRead(bool success) { + void onSettingsLoaded(bool success) { // Called after the entire EEPROM has been read, // whether successful or not. } #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { // Called when any mesh points are updated diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp index 9f558e3a9867..285729cc15d2 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp @@ -85,14 +85,24 @@ void ChironTFT::Startup() { // opt_enable FIL_RUNOUT_PULLUP TFTSer.begin(115200); - // wait for the TFT panel to initialise and finish the animation - delay_ms(250); + // Wait for the TFT panel to initialize and finish the animation + safe_delay(1000); // There are different panels for the Chiron with slightly different commands // So we need to know what we are working with. - // Panel type can be defined otherwise detect it automatically - if (panel_type == AC_panel_unknown) DetectPanelType(); + switch (panel_type) { + case AC_panel_new: + SERIAL_ECHOLNF(AC_msg_new_panel_set); + break; + case AC_panel_standard: + SERIAL_ECHOLNF(AC_msg_old_panel_set); + break; + default: + SERIAL_ECHOLNF(AC_msg_auto_panel_detection); + DetectPanelType(); + break; + } // Signal Board has reset SendtoTFTLN(AC_msg_main_board_has_reset); @@ -243,7 +253,7 @@ void ChironTFT::StatusChange(const char * const msg) { case AC_printer_probing: { // If probing completes ok save the mesh and park // Ignore the custom machine name - if (strcmp_P(msg + strlen(CUSTOM_MACHINE_NAME), MARLIN_msg_ready) == 0) { + if (strcmp_P(msg + strlen(MACHINE_NAME), MARLIN_msg_ready) == 0) { injectCommands(F("M500\nG27")); SendtoTFTLN(AC_msg_probing_complete); printer_state = AC_printer_idle; @@ -358,15 +368,14 @@ bool ChironTFT::ReadTFTCommand() { } int8_t ChironTFT::FindToken(char c) { - int8_t pos = 0; - do { + for (int8_t pos = 0; pos < command_len; pos++) { if (panel_command[pos] == c) { #if ACDEBUG(AC_INFO) SERIAL_ECHOLNPGM("Tpos:", pos, " ", c); #endif return pos; } - } while(++pos < command_len); + } #if ACDEBUG(AC_INFO) SERIAL_ECHOLNPGM("Not found: ", c); #endif @@ -433,7 +442,7 @@ void ChironTFT::SendFileList(int8_t startindex) { } void ChironTFT::SelectFile() { - if (panel_type == AC_panel_new) { + if (panel_type <= AC_panel_new) { strncpy(selectedfile, panel_command + 4, command_len - 3); selectedfile[command_len - 4] = '\0'; } @@ -456,7 +465,7 @@ void ChironTFT::SelectFile() { break; default: // enter sub folder // for new panel remove the '.GCO' tag that was added to the end of the path - if (panel_type == AC_panel_new) + if (panel_type <= AC_panel_new) selectedfile[strlen(selectedfile) - 4] = '\0'; filenavigator.changeDIR(selectedfile); SendtoTFTLN(AC_msg_sd_file_open_failed); @@ -469,8 +478,8 @@ void ChironTFT::ProcessPanelRequest() { // Break these up into logical blocks // as its easier to navigate than one huge switch case! int8_t tpos = FindToken('A'); // Panel request are 'A0' - 'A36' - if (tpos != -1) { - const int8_t req = atoi(&panel_command[tpos+1]); + if (tpos >= 0) { + const int8_t req = atoi(&panel_command[tpos + 1]); // Information requests A0 - A8 and A33 if (req <= 8 || req == 33) PanelInfo(req); @@ -486,16 +495,18 @@ void ChironTFT::ProcessPanelRequest() { // This may be a response to a panel type detection query if (panel_type == AC_panel_unknown) { tpos = FindToken('S'); // old panel will respond to 'SIZE' with 'SXY 480 320' - if (tpos != -1) { - if (panel_command[tpos+1]== 'X' && panel_command[tpos+2]=='Y') { + if (tpos >= 0) { + if (panel_command[tpos + 1] == 'X' && panel_command[tpos + 2] =='Y') { panel_type = AC_panel_standard; SERIAL_ECHOLNF(AC_msg_old_panel_detected); } } else { - tpos = FindToken('['); // new panel will respond to 'J200' with '[0]=0' - if (tpos != -1) { - if (panel_command[tpos+1]== '0' && panel_command[tpos+2]==']') { + // new panel will respond to 'J200' with '[0]=0' + // it seems only after a power cycle so detection assumes a new panel + tpos = FindToken('['); + if (tpos >= 0) { + if (panel_command[tpos + 1] == '0' && panel_command[tpos + 2] ==']') { panel_type = AC_panel_new; SERIAL_ECHOLNF(AC_msg_new_panel_detected); } @@ -623,18 +634,18 @@ void ChironTFT::PanelAction(uint8_t req) { SelectFile(); break; - case 14: { // A14 Start Printing + case 14: // A14 Start Printing // Allows printer to restart the job if we don't want to recover if (printer_state == AC_printer_resuming_from_power_outage) { injectCommands(F("M1000 C")); // Cancel recovery printer_state = AC_printer_idle; } #if ACDebugLevel >= 1 - SERIAL_ECHOLNPAIR_F("Print: ", selectedfile); + SERIAL_ECHOLNPGM("Print: ", selectedfile); #endif printFile(selectedfile); SendtoTFTLN(AC_msg_print_from_sd_card); - } break; + break; case 15: // A15 Resuming from outage if (printer_state == AC_printer_resuming_from_power_outage) { @@ -697,7 +708,7 @@ void ChironTFT::PanelAction(uint8_t req) { // Old TFT A22 X -1F1500 A22 X +1F1500 // New TFT A22 X-1.0 F1500 A22 X1.0 F1500 - // lets just wrap this in a gcode relative nonprint move and let the controller deal with it + // Send a G-code-relative non-print move and let the controller deal with it // G91 G0 G90 if (!isPrinting()) { // Ignore request if printing @@ -801,28 +812,25 @@ void ChironTFT::PanelProcess(uint8_t req) { } } break; - case 30: { // A30 Auto leveling - if (FindToken('S') != -1) { // Start probing New panel adds spaces.. + case 30: // A30 Auto leveling + if (FindToken('S') >= 0) { // Start probing New panel adds spaces.. // Ignore request if printing if (isPrinting()) SendtoTFTLN(AC_msg_probing_not_allowed); // forbid auto leveling else { - - SendtoTFTLN(AC_msg_start_probing); injectCommands(F("G28\nG29")); printer_state = AC_printer_probing; } } - else { + else SendtoTFTLN(AC_msg_start_probing); // Just enter levelling menu - } - } break; + break; - case 31: { // A31 Adjust all Probe Points + case 31: // A31 Adjust all Probe Points // The tokens can occur in different places on the new panel so we need to find it. - if (FindToken('C') != -1) { // Restore and apply original offsets + if (FindToken('C') >= 0) { // Restore and apply original offsets if (!isPrinting()) { injectCommands(F("M501\nM420 S1")); selectedmeshpoint.x = selectedmeshpoint.y = 99; @@ -830,7 +838,7 @@ void ChironTFT::PanelProcess(uint8_t req) { } } - else if (FindToken('D') != -1) { // Save Z Offset tables and restore leveling state + else if (FindToken('D') >= 0) { // Save Z Offset tables and restore leveling state if (!isPrinting()) { setAxisPosition_mm(1.0,Z); // Lift nozzle before any further movements are made injectCommands(F("M500")); @@ -839,7 +847,7 @@ void ChironTFT::PanelProcess(uint8_t req) { } } - else if (FindToken('G') != -1) { // Get current offset + else if (FindToken('G') >= 0) { // Get current offset SendtoTFT(F("A31V ")); // When printing use the live z Offset position // we will use babystepping to move the print head @@ -853,7 +861,7 @@ void ChironTFT::PanelProcess(uint8_t req) { else { int8_t tokenpos = FindToken('S'); - if (tokenpos != -1) { // Set offset (adjusts all points by value) + if (tokenpos >= 0) { // Set offset (adjusts all points by value) float Zshift = atof(&panel_command[tokenpos+1]); setSoftEndstopState(false); // disable endstops // Allow temporary Z position nudging during print @@ -907,18 +915,18 @@ void ChironTFT::PanelProcess(uint8_t req) { } } } - } break; + break; - case 32: { // A32 clean leveling beep flag + case 32: // A32 clean leveling beep flag // Ignore request if printing //if (isPrinting()) break; //injectCommands(F("M500\nM420 S1\nG1 Z10 F240\nG1 X0 Y0 F6000")); //TFTSer.println(); - } break; + break; // A33 firmware info request see PanelInfo() - case 34: { // A34 Adjust single mesh point A34 C/S X1 Y1 V123 + case 34: // A34 Adjust single mesh point A34 C/S X1 Y1 V123 if (panel_command[3] == 'C') { // Restore original offsets injectCommands(F("M501\nM420 S1")); selectedmeshpoint.x = selectedmeshpoint.y = 99; @@ -950,7 +958,7 @@ void ChironTFT::PanelProcess(uint8_t req) { } } } - } break; + break; case 36: // A36 Auto leveling for new TFT bet that was a typo in the panel code! SendtoTFTLN(AC_msg_start_probing); diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h index 0fd7770cddfb..e3609b5408df 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h @@ -89,6 +89,10 @@ #define AC_msg_mesh_changes_saved F("Mesh changes saved.") #define AC_msg_old_panel_detected F("Standard TFT panel detected!") #define AC_msg_new_panel_detected F("New TFT panel detected!") +#define AC_msg_auto_panel_detection F("Auto detect panel type (assuming new panel)") +#define AC_msg_old_panel_set F("Set for standard TFT panel.") +#define AC_msg_new_panel_set F("Set for new TFT panel.") + #define AC_msg_powerloss_recovery F("Resuming from power outage! select the same SD file then press resume") // Error messages must not contain spaces #define AC_msg_error_bed_temp F("Abnormal_bed_temp") @@ -161,10 +165,10 @@ namespace Anycubic { AC_menu_change_to_file, AC_menu_change_to_command }; - enum panel_type_t : uint8_t { + enum panel_type_t : uint8_t { // order is important here as we assume new panel if type is unknown AC_panel_unknown, - AC_panel_standard, - AC_panel_new + AC_panel_new, + AC_panel_standard }; enum last_error_t : uint8_t { AC_error_none, diff --git a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp index c0e1b4457897..40a670b5b073 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp @@ -42,9 +42,7 @@ namespace ExtUI { void onMediaError() { AnycubicTFT.OnSDCardError(); } void onMediaRemoved() { AnycubicTFT.OnSDCardStateChange(false); } void onPlayTone(const uint16_t frequency, const uint16_t duration) { - #if ENABLED(SPEAKER) - ::tone(BEEPER_PIN, frequency, duration); - #endif + TERN_(SPEAKER, ::tone(BEEPER_PIN, frequency, duration)); } void onPrintTimerStarted() { AnycubicTFT.OnPrintTimerStarted(); } void onPrintTimerPaused() { AnycubicTFT.OnPrintTimerPaused(); } @@ -54,8 +52,8 @@ namespace ExtUI { void onStatusChanged(const char * const msg) {} void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} + void onPrintDone() {} void onFactoryReset() {} @@ -83,19 +81,20 @@ namespace ExtUI { // Called after loading or resetting stored settings } - void onConfigurationStoreWritten(bool success) { + void onSettingsStored(bool success) { // Called after the entire EEPROM has been written, // whether successful or not. } - void onConfigurationStoreRead(bool success) { + void onSettingsLoaded(bool success) { // Called after the entire EEPROM has been read, // whether successful or not. } #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { // Called when any mesh points are updated 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 98534ba65f87..0da8bb36a780 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp @@ -63,7 +63,7 @@ char AnycubicTFTClass::SelectedDirectory[30]; char AnycubicTFTClass::SelectedFile[FILENAME_LENGTH]; // Serial helpers -static void sendNewLine(void) { LCD_SERIAL.write('\r'); LCD_SERIAL.write('\n'); } +static void sendNewLine() { LCD_SERIAL.write('\r'); LCD_SERIAL.write('\n'); } static void send(const char *str) { LCD_SERIAL.print(str); } static void send_P(PGM_P str) { while (const char c = pgm_read_byte(str++)) @@ -85,8 +85,8 @@ void AnycubicTFTClass::OnSetup() { SENDLINE_DBG_PGM("J17", "TFT Serial Debug: Main board reset... J17"); // J17 Main board reset delay_ms(10); - // initialise the state of the key pins running on the tft - #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) + // Init the state of the key pins running on the TFT + #if BOTH(SDSUPPORT, HAS_SD_DETECT) SET_INPUT_PULLUP(SD_DETECT_PIN); #endif #if ENABLED(FILAMENT_RUNOUT_SENSOR) @@ -916,7 +916,7 @@ void AnycubicTFTClass::GetCommandFromTFT() { } void AnycubicTFTClass::DoSDCardStateCheck() { - #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) + #if BOTH(SDSUPPORT, HAS_SD_DETECT) bool isInserted = isMediaInserted(); if (isInserted) SENDLINE_DBG_PGM("J00", "TFT Serial Debug: SD card state changed... isInserted"); diff --git a/Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp b/Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp index 262dcea36483..0eb95bb041ba 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp +++ b/Marlin/src/lcd/extui/dgus/DGUSDisplay.cpp @@ -46,6 +46,12 @@ DGUSDisplay dgusdisplay; +#ifdef DEBUG_DGUSLCD_COMM + #define DEBUGLCDCOMM_ECHOPGM DEBUG_ECHOPGM +#else + #define DEBUGLCDCOMM_ECHOPGM(...) NOOP +#endif + // Preamble... 2 Bytes, usually 0x5A 0xA5, but configurable constexpr uint8_t DGUS_HEADER1 = 0x5A; constexpr uint8_t DGUS_HEADER2 = 0xA5; @@ -103,12 +109,6 @@ void DGUSDisplay::WriteVariable(uint16_t adr, int8_t value) { WriteVariable(adr, static_cast(&value), sizeof(int8_t)); } -#if ENABLED(DGUS_LCD_UI_MKS) - void DGUSDisplay::MKS_WriteVariable(uint16_t adr, uint8_t value) { - WriteVariable(adr, static_cast(&value), sizeof(uint8_t)); - } -#endif - void DGUSDisplay::WriteVariable(uint16_t adr, long value) { union { long l; char lb[4]; } endian; char tmp[4]; @@ -154,19 +154,19 @@ void DGUSDisplay::ProcessRx() { case DGUS_IDLE: // Waiting for the first header byte receivedbyte = LCD_SERIAL.read(); - //DEBUG_ECHOPGM("< ",x); + //DEBUGLCDCOMM_ECHOPGM("< ", receivedbyte); if (DGUS_HEADER1 == receivedbyte) rx_datagram_state = DGUS_HEADER1_SEEN; break; case DGUS_HEADER1_SEEN: // Waiting for the second header byte receivedbyte = LCD_SERIAL.read(); - //DEBUG_ECHOPGM(" ",x); + //DEBUGLCDCOMM_ECHOPGM(" ", receivedbyte); rx_datagram_state = (DGUS_HEADER2 == receivedbyte) ? DGUS_HEADER2_SEEN : DGUS_IDLE; break; case DGUS_HEADER2_SEEN: // Waiting for the length byte rx_datagram_len = LCD_SERIAL.read(); - DEBUG_ECHOPGM(" (", rx_datagram_len, ") "); + //DEBUGLCDCOMM_ECHOPGM(" (", rx_datagram_len, ") "); // Telegram min len is 3 (command and one word of payload) rx_datagram_state = WITHIN(rx_datagram_len, 3, DGUS_RX_BUFFER_SIZE) ? DGUS_WAIT_TELEGRAM : DGUS_IDLE; @@ -178,20 +178,20 @@ void DGUSDisplay::ProcessRx() { Initialized = true; // We've talked to it, so we defined it as initialized. uint8_t command = LCD_SERIAL.read(); - DEBUG_ECHOPGM("# ", command); + //DEBUGLCDCOMM_ECHOPGM("# ", command); uint8_t readlen = rx_datagram_len - 1; // command is part of len. unsigned char tmp[rx_datagram_len - 1]; unsigned char *ptmp = tmp; while (readlen--) { receivedbyte = LCD_SERIAL.read(); - DEBUG_ECHOPGM(" ", receivedbyte); + //DEBUGLCDCOMM_ECHOPGM(" ", receivedbyte); *ptmp++ = receivedbyte; } - DEBUG_ECHOPGM(" # "); + //DEBUGLCDCOMM_ECHOPGM(" # "); // mostly we'll get this: 5A A5 03 82 4F 4B -- ACK on 0x82, so discard it. if (command == DGUS_CMD_WRITEVAR && 'O' == tmp[0] && 'K' == tmp[1]) { - DEBUG_ECHOLNPGM(">"); + //DEBUGLCDCOMM_ECHOPGM(">"); rx_datagram_state = DGUS_IDLE; break; } @@ -243,7 +243,7 @@ void DGUSDisplay::WritePGM(const char str[], uint8_t len) { } void DGUSDisplay::loop() { - // protect against recursion… ProcessRx() may indirectly call idle() when injecting gcode commands. + // Protect against recursion. ProcessRx() may indirectly call idle() when injecting G-code commands. if (!no_reentrance) { no_reentrance = true; ProcessRx(); @@ -253,16 +253,16 @@ void DGUSDisplay::loop() { rx_datagram_state_t DGUSDisplay::rx_datagram_state = DGUS_IDLE; uint8_t DGUSDisplay::rx_datagram_len = 0; -bool DGUSDisplay::Initialized = false; -bool DGUSDisplay::no_reentrance = false; +bool DGUSDisplay::Initialized = false, + DGUSDisplay::no_reentrance = false; // A SW memory barrier, to ensure GCC does not overoptimize loops #define sw_barrier() asm volatile("": : :"memory"); bool populate_VPVar(const uint16_t VP, DGUS_VP_Variable * const ramcopy) { - // DEBUG_ECHOPGM("populate_VPVar ", VP); + //DEBUG_ECHOPGM("populate_VPVar ", VP); const DGUS_VP_Variable *pvp = DGUSLCD_FindVPVar(VP); - // DEBUG_ECHOLNPGM(" pvp ", (uint16_t )pvp); + //DEBUG_ECHOLNPGM(" pvp ", (uint16_t )pvp); if (!pvp) return false; memcpy_P(ramcopy, pvp, sizeof(DGUS_VP_Variable)); return true; diff --git a/Marlin/src/lcd/extui/dgus/DGUSDisplay.h b/Marlin/src/lcd/extui/dgus/DGUSDisplay.h index e486a0014570..b6773db03be9 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSDisplay.h +++ b/Marlin/src/lcd/extui/dgus/DGUSDisplay.h @@ -29,6 +29,9 @@ #include // size_t +//#define DEBUG_DGUSLCD +//#define DEBUG_DGUSLCD_COMM + #if HAS_BED_PROBE #include "../../../module/probe.h" #endif @@ -47,6 +50,8 @@ typedef enum : uint8_t { DGUS_WAIT_TELEGRAM, //< LEN received, Waiting for to receive all bytes. } rx_datagram_state_t; +constexpr uint16_t swap16(const uint16_t value) { return (value & 0xFFU) << 8U | (value >> 8U); } + // Low-Level access to the display. class DGUSDisplay { public: @@ -63,8 +68,6 @@ class DGUSDisplay { static void WriteVariable(uint16_t adr, uint8_t value); static void WriteVariable(uint16_t adr, int8_t value); static void WriteVariable(uint16_t adr, long value); - static void MKS_WriteVariable(uint16_t adr, uint8_t value); - // Utility functions for bridging ui_api and dbus template @@ -95,14 +98,13 @@ class DGUSDisplay { // Checks two things: Can we confirm the presence of the display and has we initialized it. // (both boils down that the display answered to our chatting) - static inline bool isInitialized() { return Initialized; } + static bool isInitialized() { return Initialized; } private: static void WriteHeader(uint16_t adr, uint8_t cmd, uint8_t payloadlen); static void WritePGM(const char str[], uint8_t len); static void ProcessRx(); - static inline uint16_t swap16(const uint16_t value) { return (value & 0xFFU) << 8U | (value >> 8U); } static rx_datagram_state_t rx_datagram_state; static uint8_t rx_datagram_len; static bool Initialized, no_reentrance; diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp index 2b00fd16f8e2..dc872bff3b0e 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp @@ -40,7 +40,7 @@ #include "../../../feature/powerloss.h" #endif -DGUSScreenHandler ScreenHandler; +DGUSScreenHandlerClass ScreenHandler; uint16_t DGUSScreenHandler::ConfirmVP; @@ -55,14 +55,14 @@ void (*DGUSScreenHandler::confirm_action_cb)() = nullptr; #if ENABLED(SDSUPPORT) int16_t DGUSScreenHandler::top_file = 0, DGUSScreenHandler::file_to_print = 0; - static ExtUI::FileList filelist; + ExtUI::FileList filelist; #endif #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) filament_data_t filament_data; #endif -void DGUSScreenHandler::sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool l4inflash) { +void DGUSScreenHandler::sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool l4inflash) { DGUS_VP_Variable ramcopy; if (populate_VPVar(VP_MSGSTR1, &ramcopy)) { ramcopy.memadr = (void*) line1; @@ -76,13 +76,15 @@ void DGUSScreenHandler::sendinfoscreen(const char *line1, const char *line2, con ramcopy.memadr = (void*) line3; l3inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy); } - if (populate_VPVar(VP_MSGSTR4, &ramcopy)) { - ramcopy.memadr = (void*) line4; - l4inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy); - } + #ifdef VP_MSGSTR4 + if (populate_VPVar(VP_MSGSTR4, &ramcopy)) { + ramcopy.memadr = (void*) line4; + l4inflash ? DGUSScreenHandler::DGUSLCD_SendStringToDisplayPGM(ramcopy) : DGUSScreenHandler::DGUSLCD_SendStringToDisplay(ramcopy); + } + #endif } -void DGUSScreenHandler::HandleUserConfirmationPopUp(uint16_t VP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1, bool l2, bool l3, bool l4) { +void DGUSScreenHandler::HandleUserConfirmationPopUp(uint16_t VP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1, bool l2, bool l3, bool l4) { if (current_screen == DGUSLCD_SCREEN_CONFIRM) // Already showing a pop up, so we need to cancel that first. PopToOldScreen(); @@ -344,6 +346,7 @@ void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var) SetupConfirmAction(nullptr); GotoScreen(DGUSLCD_SCREEN_POPUP); } + #endif // SDSUPPORT void DGUSScreenHandler::ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr) { @@ -508,9 +511,9 @@ void DGUSScreenHandler::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ case VP_Z_STEP_PER_MM: axis = ExtUI::axis_t::Z; break; default: return; } - DEBUG_ECHOLNPAIR_F("value:", value); + DEBUG_ECHOLNPGM("value:", value); ExtUI::setAxisSteps_per_mm(value, axis); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(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; } @@ -531,9 +534,9 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, vo #endif #endif } - DEBUG_ECHOLNPAIR_F("value:", value); + DEBUG_ECHOLNPGM("value:", value); ExtUI::setAxisSteps_per_mm(value, extruder); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(extruder)); + DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisSteps_per_mm(extruder)); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } @@ -626,8 +629,10 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr default: switch (var.VP) { default: return; - case VP_E0_BED_PREHEAT: TERN_(HAS_HOTEND, ui.preheat_all(0)); break; - case VP_E1_BED_PREHEAT: TERN_(HAS_MULTI_HOTEND, ui.preheat_all(1)); break; + case VP_E0_BED_PREHEAT: TERN_(HAS_HOTEND, ui.preheat_all(0)); break; + #if DISABLED(DGUS_LCD_UI_HIPRECY) && HAS_MULTI_HOTEND + case VP_E1_BED_PREHEAT: ui.preheat_all(1); break; + #endif } case 7: break; // Custom preheat case 9: thermalManager.cooldown(); break; // Cool down diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h index 8ee2761c899b..4b627fe0f69f 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h @@ -42,9 +42,6 @@ #endif -// endianness swap -inline uint16_t swap16(const uint16_t value) { return (value & 0xFFU) << 8U | (value >> 8U); } - #if ENABLED(DGUS_LCD_UI_ORIGIN) #include "origin/DGUSScreenHandler.h" #elif ENABLED(DGUS_LCD_UI_MKS) @@ -55,7 +52,7 @@ inline uint16_t swap16(const uint16_t value) { return (value & 0xFFU) << 8U | (v #include "hiprecy/DGUSScreenHandler.h" #endif -extern DGUSScreenHandler ScreenHandler; +extern DGUSScreenHandlerClass ScreenHandler; // Helper to define a DGUS_VP_Variable for common use-cases. #define VPHELPER(VPADR, VPADRVAR, RXFPTR, TXFPTR) { \ diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandlerBase.h b/Marlin/src/lcd/extui/dgus/DGUSScreenHandlerBase.h new file mode 100644 index 000000000000..07a108e84663 --- /dev/null +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandlerBase.h @@ -0,0 +1,241 @@ +/** + * 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 "DGUSDisplay.h" +#include "DGUSVPVariable.h" +#include "DGUSDisplayDef.h" + +#include "../../../inc/MarlinConfig.h" + +enum DGUSLCD_Screens : uint8_t; + +class DGUSScreenHandler { +public: + DGUSScreenHandler() = default; + + static bool loop(); + + // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen + // The bools specifying whether the strings are in RAM or FLASH. + static void sendinfoscreen(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); + } + static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { + sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); + } + + static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + + // "M117" Message -- msg is a RAM ptr. + static void setstatusmessage(const char *msg); + // The same for messages from Flash + static void setstatusmessagePGM(PGM_P const msg); + // Callback for VP "Display wants to change screen on idle printer" + static void ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr); + // Callback for VP "Screen has been changed" + static void ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr); + + // Callback for VP "All Heaters Off" + static void HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr); + // Hook for "Change this temperature" + static void HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr); + // Hook for "Change Flowrate" + static void HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr); + #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) + // Hook for manual move option + static void HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr); + #endif + + // Hook for manual move. + static void HandleManualMove(DGUS_VP_Variable &var, void *val_ptr); + // Hook for manual extrude. + static void HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr); + // Hook for motor lock and unlook + static void HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr); + #if ENABLED(POWER_LOSS_RECOVERY) + // Hook for power loss recovery. + static void HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr); + #endif + // Hook for settings + static void HandleSettings(DGUS_VP_Variable &var, void *val_ptr); + static void HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr); + static void HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr); + + #if HAS_PID_HEATING + // Hook for "Change this temperature PID para" + static void HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr); + // Hook for PID autotune + static void HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr); + #endif + #if HAS_BED_PROBE + // Hook for "Change probe offset z" + static void HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr); + #endif + #if ENABLED(BABYSTEPPING) + // Hook for live z adjust action + static void HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr); + #endif + #if HAS_FAN + // Hook for fan control + static void HandleFanControl(DGUS_VP_Variable &var, void *val_ptr); + #endif + // Hook for heater control + static void HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr); + #if ENABLED(DGUS_PREHEAT_UI) + // Hook for preheat + static void HandlePreheat(DGUS_VP_Variable &var, void *val_ptr); + #endif + #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) + // Hook for filament load and unload filament option + static void HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr); + // Hook for filament load and unload + static void HandleFilamentLoadUnload(DGUS_VP_Variable &var); + #endif + + #if ENABLED(SDSUPPORT) + // Callback for VP "Display wants to change screen when there is a SD card" + static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr); + // Scroll buttons on the file listing screen. + static void DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable &var, void *val_ptr); + // File touched. + static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr); + // start print after confirmation received. + static void DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr); + // User hit the pause, resume or abort button. + static void DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr); + // User confirmed the abort action + static void DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr); + // User hit the tune button + static void DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr); + // Send a single filename to the display. + static void DGUSLCD_SD_SendFilename(DGUS_VP_Variable &var); + // Marlin informed us that a new SD has been inserted. + static void SDCardInserted(); + // Marlin informed us that the SD Card has been removed(). + static void SDCardRemoved(); + // Marlin informed us about a bad SD Card. + static void SDCardError(); + #endif + + // OK Button on the Confirm screen. + static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr); + + // Update data after going to a new screen (by display or by GotoScreen) + // remember to store the last-displayed screen so it can be restored. + // (e.g., for popup messages) + static void UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup=false); + + // Recall the remembered screen. + static void PopToOldScreen(); + + // Make the display show the screen and update all VPs in it. + static void GotoScreen(DGUSLCD_Screens screen, bool ispopup = false); + + static void UpdateScreenVPData(); + + // Helpers to convert and transfer data to the display. + static void DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var); + static void DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var); + static void DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var); + static void DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var); + static void DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var); + static void DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var); + static void DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var); + + #if ENABLED(PRINTCOUNTER) + static void DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var); + static void DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var); + #endif + #if HAS_FAN + static void DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var); + #endif + static void DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var); + #if ENABLED(DGUS_UI_WAITING) + static void DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var); + #endif + + // Send a value from 0..100 to a variable with a range from 0..255 + static void DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr); + + template + static void DGUSLCD_SetValueDirectly(DGUS_VP_Variable &var, void *val_ptr) { + if (!var.memadr) return; + union { unsigned char tmp[sizeof(T)]; T t; } x; + unsigned char *ptr = (unsigned char*)val_ptr; + LOOP_L_N(i, sizeof(T)) x.tmp[i] = ptr[sizeof(T) - i - 1]; + *(T*)var.memadr = x.t; + } + + // Send a float value to the display. + // Display will get a 4-byte integer scaled to the number of digits: + // Tell the display the number of digits and it cheats by displaying a dot between... + template + static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) { + if (var.memadr) { + float f = *(float *)var.memadr; + f *= cpow(10, decimals); + dgusdisplay.WriteVariable(var.VP, (long)f); + } + } + + // Send a float value to the display. + // Display will get a 2-byte integer scaled to the number of digits: + // Tell the display the number of digits and it cheats by displaying a dot between... + template + static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) { + if (var.memadr) { + float f = *(float *)var.memadr; + DEBUG_ECHOLNPAIR_F(" >> ", f, 6); + f *= cpow(10, decimals); + dgusdisplay.WriteVariable(var.VP, (int16_t)f); + } + } + + // Force an update of all VP on the current screen. + static void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } + // Has all VPs sent to the screen + static bool IsScreenComplete() { return ScreenComplete; } + + static DGUSLCD_Screens getCurrentScreen() { return current_screen; } + + static void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } + +protected: + static DGUSLCD_Screens current_screen; //< currently on screen + static constexpr uint8_t NUM_PAST_SCREENS = 4; + static DGUSLCD_Screens past_screens[NUM_PAST_SCREENS]; //< LIFO with past screens for the "back" button. + + static uint8_t update_ptr; //< Last sent entry in the VPList for the actual screen. + static uint16_t skipVP; //< When updating the screen data, skip this one, because the user is interacting with it. + static bool ScreenComplete; //< All VPs sent to screen? + + static uint16_t ConfirmVP; //< context for confirm screen (VP that will be emulated-sent on "OK"). + + #if ENABLED(SDSUPPORT) + static int16_t top_file; //< file on top of file chooser + static int16_t file_to_print; //< touched file to be confirmed + #endif + + static void (*confirm_action_cb)(); +}; diff --git a/Marlin/src/lcd/extui/dgus/dgus_extui.cpp b/Marlin/src/lcd/extui/dgus/dgus_extui.cpp index 04ba6b95c2c7..b041687a14fa 100644 --- a/Marlin/src/lcd/extui/dgus/dgus_extui.cpp +++ b/Marlin/src/lcd/extui/dgus/dgus_extui.cpp @@ -73,8 +73,8 @@ namespace ExtUI { void onStatusChanged(const char * const msg) { ScreenHandler.setstatusmessage(msg); } void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} + void onPrintDone() {} void onFactoryReset() {} @@ -102,18 +102,19 @@ namespace ExtUI { // Called after loading or resetting stored settings } - void onConfigurationStoreWritten(bool success) { + void onSettingsStored(bool success) { // Called after the entire EEPROM has been written, // whether successful or not. } - void onConfigurationStoreRead(bool success) { + void onSettingsLoaded(bool success) { // Called after the entire EEPROM has been read, // whether successful or not. } #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { // Called when any mesh points are updated diff --git a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp index 750acece1c06..1f72c685fb81 100644 --- a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp @@ -42,7 +42,7 @@ #if ENABLED(SDSUPPORT) - static ExtUI::FileList filelist; + extern ExtUI::FileList filelist; 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; @@ -268,7 +268,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { #endif } - DEBUG_ECHOLNPAIR_F("V3:", newvalue); + DEBUG_ECHOLNPGM("V3:", newvalue); *(float *)var.memadr = newvalue; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel @@ -333,9 +333,9 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { if (filament_data.action == 0) { // Go back to utility screen #if HAS_HOTEND thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0); - #endif - #if HAS_MULTI_HOTEND - thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1); + #if HAS_MULTI_HOTEND + thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1); + #endif #endif GotoScreen(DGUSLCD_SCREEN_UTILITY); } @@ -348,7 +348,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { thermalManager.setTargetHotend(e_temp, filament_data.extruder); break; #endif - #if HAS_MULTI_EXTRUDER + #if HAS_MULTI_HOTEND case VP_E1_FILAMENT_LOAD_UNLOAD: filament_data.extruder = ExtUI::extruder_t::E1; thermalManager.setTargetHotend(e_temp, filament_data.extruder); @@ -413,14 +413,10 @@ bool DGUSScreenHandler::loop() { if (!booted && ELAPSED(ms, BOOTSCREEN_TIMEOUT)) { booted = true; - - if (TERN0(POWER_LOSS_RECOVERY, recovery.valid())) - GotoScreen(DGUSLCD_SCREEN_POWER_LOSS); - else - GotoScreen(DGUSLCD_SCREEN_MAIN); + GotoScreen(TERN0(POWER_LOSS_RECOVERY, recovery.valid()) ? DGUSLCD_SCREEN_POWER_LOSS : DGUSLCD_SCREEN_MAIN); } - #endif + return IsScreenComplete(); } diff --git a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h index bb0bd2bd3b42..73e3527d7e7c 100644 --- a/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h @@ -21,224 +21,9 @@ */ #pragma once -#include "../DGUSDisplay.h" -#include "../DGUSVPVariable.h" -#include "../DGUSDisplayDef.h" +#include "../DGUSScreenHandlerBase.h" -#include "../../../../inc/MarlinConfig.h" - -enum DGUSLCD_Screens : uint8_t; - -class DGUSScreenHandler { -public: - DGUSScreenHandler() = default; - - static bool loop(); - - // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen - // The bools specifying whether the strings are in RAM or FLASH. - static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { - sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); - } - static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { - sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); - } - - static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - - // "M117" Message -- msg is a RAM ptr. - static void setstatusmessage(const char *msg); - // The same for messages from Flash - static void setstatusmessagePGM(PGM_P const msg); - // Callback for VP "Display wants to change screen on idle printer" - static void ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr); - // Callback for VP "Screen has been changed" - static void ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr); - - // Callback for VP "All Heaters Off" - static void HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr); - // Hook for "Change this temperature" - static void HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr); - // Hook for "Change Flowrate" - static void HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr); - #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - // Hook for manual move option - static void HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr); - #endif - - // Hook for manual move. - static void HandleManualMove(DGUS_VP_Variable &var, void *val_ptr); - // Hook for manual extrude. - static void HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr); - // Hook for motor lock and unlook - static void HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr); - #if ENABLED(POWER_LOSS_RECOVERY) - // Hook for power loss recovery. - static void HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr); - #endif - // Hook for settings - static void HandleSettings(DGUS_VP_Variable &var, void *val_ptr); - static void HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr); - static void HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr); - - #if HAS_PID_HEATING - // Hook for "Change this temperature PID para" - static void HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr); - // Hook for PID autotune - static void HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if HAS_BED_PROBE - // Hook for "Change probe offset z" - static void HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if ENABLED(BABYSTEPPING) - // Hook for live z adjust action - static void HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if HAS_FAN - // Hook for fan control - static void HandleFanControl(DGUS_VP_Variable &var, void *val_ptr); - #endif - // Hook for heater control - static void HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr); - #if ENABLED(DGUS_PREHEAT_UI) - // Hook for preheat - static void HandlePreheat(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) - // Hook for filament load and unload filament option - static void HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr); - // Hook for filament load and unload - static void HandleFilamentLoadUnload(DGUS_VP_Variable &var); - #endif - - #if ENABLED(SDSUPPORT) - // Callback for VP "Display wants to change screen when there is a SD card" - static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr); - // Scroll buttons on the file listing screen. - static void DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable &var, void *val_ptr); - // File touched. - static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr); - // start print after confirmation received. - static void DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr); - // User hit the pause, resume or abort button. - static void DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr); - // User confirmed the abort action - static void DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr); - // User hit the tune button - static void DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr); - // Send a single filename to the display. - static void DGUSLCD_SD_SendFilename(DGUS_VP_Variable &var); - // Marlin informed us that a new SD has been inserted. - static void SDCardInserted(); - // Marlin informed us that the SD Card has been removed(). - static void SDCardRemoved(); - // Marlin informed us about a bad SD Card. - static void SDCardError(); - #endif - - // OK Button the Confirm screen. - static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr); - - // Update data after went to new screen (by display or by GotoScreen) - // remember: store the last-displayed screen, so it can get returned to. - // (e.g for pop up messages) - static void UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup=false); - - // Recall the remembered screen. - static void PopToOldScreen(); - - // Make the display show the screen and update all VPs in it. - static void GotoScreen(DGUSLCD_Screens screen, bool ispopup = false); - - static void UpdateScreenVPData(); - - // Helpers to convert and transfer data to the display. - static void DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var); - static void DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var); - static void DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var); - - #if ENABLED(PRINTCOUNTER) - static void DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var); - #endif - #if HAS_FAN - static void DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var); - #endif - static void DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var); - #if ENABLED(DGUS_UI_WAITING) - static void DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var); - #endif - - // Send a value from 0..100 to a variable with a range from 0..255 - static void DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr); - - template - static void DGUSLCD_SetValueDirectly(DGUS_VP_Variable &var, void *val_ptr) { - if (!var.memadr) return; - union { unsigned char tmp[sizeof(T)]; T t; } x; - unsigned char *ptr = (unsigned char*)val_ptr; - LOOP_L_N(i, sizeof(T)) x.tmp[i] = ptr[sizeof(T) - i - 1]; - *(T*)var.memadr = x.t; - } - - // Send a float value to the display. - // Display will get a 4-byte integer scaled to the number of digits: - // Tell the display the number of digits and it cheats by displaying a dot between... - template - static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) { - if (var.memadr) { - float f = *(float *)var.memadr; - f *= cpow(10, decimals); - dgusdisplay.WriteVariable(var.VP, (long)f); - } - } - - // Send a float value to the display. - // Display will get a 2-byte integer scaled to the number of digits: - // Tell the display the number of digits and it cheats by displaying a dot between... - template - static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) { - if (var.memadr) { - float f = *(float *)var.memadr; - DEBUG_ECHOLNPAIR_F(" >> ", f, 6); - f *= cpow(10, decimals); - dgusdisplay.WriteVariable(var.VP, (int16_t)f); - } - } - - // Force an update of all VP on the current screen. - static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } - // Has all VPs sent to the screen - static inline bool IsScreenComplete() { return ScreenComplete; } - - static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; } - - static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } - -private: - static DGUSLCD_Screens current_screen; //< currently on screen - static constexpr uint8_t NUM_PAST_SCREENS = 4; - static DGUSLCD_Screens past_screens[NUM_PAST_SCREENS]; //< LIFO with past screens for the "back" button. - - static uint8_t update_ptr; //< Last sent entry in the VPList for the actual screen. - static uint16_t skipVP; //< When updating the screen data, skip this one, because the user is interacting with it. - static bool ScreenComplete; //< All VPs sent to screen? - - static uint16_t ConfirmVP; //< context for confirm screen (VP that will be emulated-sent on "OK"). - - #if ENABLED(SDSUPPORT) - static int16_t top_file; //< file on top of file chooser - static int16_t file_to_print; //< touched file to be confirmed - #endif - - static void (*confirm_action_cb)(); -}; +typedef DGUSScreenHandler DGUSScreenHandlerClass; #if ENABLED(POWER_LOSS_RECOVERY) #define PLR_SCREEN_RECOVER DGUSLCD_SCREEN_SDPRINTMANIPULATION diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp index f3f361f84e83..4c850183da0f 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp @@ -222,12 +222,12 @@ const uint16_t VPList_SDPrintTune[] PROGMEM = { }; const uint16_t VPList_StepPerMM[] PROGMEM = { - VP_X_STEP_PER_MM - , VP_Y_STEP_PER_MM - , VP_Z_STEP_PER_MM - OPTARG(HAS_HOTEND, VP_E0_STEP_PER_MM) - OPTARG(HAS_MULTI_HOTEND, VP_E1_STEP_PER_MM) - , 0x0000 + VP_X_STEP_PER_MM, + VP_Y_STEP_PER_MM, + VP_Z_STEP_PER_MM, + OPTITEM(HAS_HOTEND, VP_E0_STEP_PER_MM) + OPTITEM(HAS_MULTI_HOTEND, VP_E1_STEP_PER_MM) + 0x0000 }; const uint16_t VPList_PIDE0[] PROGMEM = { diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp index 79a3cb91038d..f04bef2fd8da 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp @@ -42,7 +42,7 @@ #if ENABLED(SDSUPPORT) - static ExtUI::FileList filelist; + extern ExtUI::FileList filelist; 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; @@ -268,7 +268,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { #endif } - DEBUG_ECHOLNPAIR_F("V3:", newvalue); + DEBUG_ECHOLNPGM("V3:", newvalue); *(float *)var.memadr = newvalue; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel @@ -411,9 +411,12 @@ bool DGUSScreenHandler::loop() { if (!booted && TERN0(POWER_LOSS_RECOVERY, recovery.valid())) booted = true; - if (!booted && ELAPSED(ms, TERN(USE_MKS_GREEN_UI, 1000, BOOTSCREEN_TIMEOUT))) + if (!booted && ELAPSED(ms, BOOTSCREEN_TIMEOUT)) { booted = true; + GotoScreen(TERN0(POWER_LOSS_RECOVERY, recovery.valid()) ? DGUSLCD_SCREEN_POWER_LOSS : DGUSLCD_SCREEN_MAIN); + } #endif + return IsScreenComplete(); } diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h index bb0bd2bd3b42..73e3527d7e7c 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h @@ -21,224 +21,9 @@ */ #pragma once -#include "../DGUSDisplay.h" -#include "../DGUSVPVariable.h" -#include "../DGUSDisplayDef.h" +#include "../DGUSScreenHandlerBase.h" -#include "../../../../inc/MarlinConfig.h" - -enum DGUSLCD_Screens : uint8_t; - -class DGUSScreenHandler { -public: - DGUSScreenHandler() = default; - - static bool loop(); - - // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen - // The bools specifying whether the strings are in RAM or FLASH. - static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { - sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); - } - static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { - sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); - } - - static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - - // "M117" Message -- msg is a RAM ptr. - static void setstatusmessage(const char *msg); - // The same for messages from Flash - static void setstatusmessagePGM(PGM_P const msg); - // Callback for VP "Display wants to change screen on idle printer" - static void ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr); - // Callback for VP "Screen has been changed" - static void ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr); - - // Callback for VP "All Heaters Off" - static void HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr); - // Hook for "Change this temperature" - static void HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr); - // Hook for "Change Flowrate" - static void HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr); - #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - // Hook for manual move option - static void HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr); - #endif - - // Hook for manual move. - static void HandleManualMove(DGUS_VP_Variable &var, void *val_ptr); - // Hook for manual extrude. - static void HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr); - // Hook for motor lock and unlook - static void HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr); - #if ENABLED(POWER_LOSS_RECOVERY) - // Hook for power loss recovery. - static void HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr); - #endif - // Hook for settings - static void HandleSettings(DGUS_VP_Variable &var, void *val_ptr); - static void HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr); - static void HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr); - - #if HAS_PID_HEATING - // Hook for "Change this temperature PID para" - static void HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr); - // Hook for PID autotune - static void HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if HAS_BED_PROBE - // Hook for "Change probe offset z" - static void HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if ENABLED(BABYSTEPPING) - // Hook for live z adjust action - static void HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if HAS_FAN - // Hook for fan control - static void HandleFanControl(DGUS_VP_Variable &var, void *val_ptr); - #endif - // Hook for heater control - static void HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr); - #if ENABLED(DGUS_PREHEAT_UI) - // Hook for preheat - static void HandlePreheat(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) - // Hook for filament load and unload filament option - static void HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr); - // Hook for filament load and unload - static void HandleFilamentLoadUnload(DGUS_VP_Variable &var); - #endif - - #if ENABLED(SDSUPPORT) - // Callback for VP "Display wants to change screen when there is a SD card" - static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr); - // Scroll buttons on the file listing screen. - static void DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable &var, void *val_ptr); - // File touched. - static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr); - // start print after confirmation received. - static void DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr); - // User hit the pause, resume or abort button. - static void DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr); - // User confirmed the abort action - static void DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr); - // User hit the tune button - static void DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr); - // Send a single filename to the display. - static void DGUSLCD_SD_SendFilename(DGUS_VP_Variable &var); - // Marlin informed us that a new SD has been inserted. - static void SDCardInserted(); - // Marlin informed us that the SD Card has been removed(). - static void SDCardRemoved(); - // Marlin informed us about a bad SD Card. - static void SDCardError(); - #endif - - // OK Button the Confirm screen. - static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr); - - // Update data after went to new screen (by display or by GotoScreen) - // remember: store the last-displayed screen, so it can get returned to. - // (e.g for pop up messages) - static void UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup=false); - - // Recall the remembered screen. - static void PopToOldScreen(); - - // Make the display show the screen and update all VPs in it. - static void GotoScreen(DGUSLCD_Screens screen, bool ispopup = false); - - static void UpdateScreenVPData(); - - // Helpers to convert and transfer data to the display. - static void DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var); - static void DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var); - static void DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var); - - #if ENABLED(PRINTCOUNTER) - static void DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var); - #endif - #if HAS_FAN - static void DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var); - #endif - static void DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var); - #if ENABLED(DGUS_UI_WAITING) - static void DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var); - #endif - - // Send a value from 0..100 to a variable with a range from 0..255 - static void DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr); - - template - static void DGUSLCD_SetValueDirectly(DGUS_VP_Variable &var, void *val_ptr) { - if (!var.memadr) return; - union { unsigned char tmp[sizeof(T)]; T t; } x; - unsigned char *ptr = (unsigned char*)val_ptr; - LOOP_L_N(i, sizeof(T)) x.tmp[i] = ptr[sizeof(T) - i - 1]; - *(T*)var.memadr = x.t; - } - - // Send a float value to the display. - // Display will get a 4-byte integer scaled to the number of digits: - // Tell the display the number of digits and it cheats by displaying a dot between... - template - static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) { - if (var.memadr) { - float f = *(float *)var.memadr; - f *= cpow(10, decimals); - dgusdisplay.WriteVariable(var.VP, (long)f); - } - } - - // Send a float value to the display. - // Display will get a 2-byte integer scaled to the number of digits: - // Tell the display the number of digits and it cheats by displaying a dot between... - template - static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) { - if (var.memadr) { - float f = *(float *)var.memadr; - DEBUG_ECHOLNPAIR_F(" >> ", f, 6); - f *= cpow(10, decimals); - dgusdisplay.WriteVariable(var.VP, (int16_t)f); - } - } - - // Force an update of all VP on the current screen. - static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } - // Has all VPs sent to the screen - static inline bool IsScreenComplete() { return ScreenComplete; } - - static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; } - - static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } - -private: - static DGUSLCD_Screens current_screen; //< currently on screen - static constexpr uint8_t NUM_PAST_SCREENS = 4; - static DGUSLCD_Screens past_screens[NUM_PAST_SCREENS]; //< LIFO with past screens for the "back" button. - - static uint8_t update_ptr; //< Last sent entry in the VPList for the actual screen. - static uint16_t skipVP; //< When updating the screen data, skip this one, because the user is interacting with it. - static bool ScreenComplete; //< All VPs sent to screen? - - static uint16_t ConfirmVP; //< context for confirm screen (VP that will be emulated-sent on "OK"). - - #if ENABLED(SDSUPPORT) - static int16_t top_file; //< file on top of file chooser - static int16_t file_to_print; //< touched file to be confirmed - #endif - - static void (*confirm_action_cb)(); -}; +typedef DGUSScreenHandler DGUSScreenHandlerClass; #if ENABLED(POWER_LOSS_RECOVERY) #define PLR_SCREEN_RECOVER DGUSLCD_SCREEN_SDPRINTMANIPULATION diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp index a7ec99d98281..86920d6841c9 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp @@ -69,7 +69,7 @@ void MKS_reset_settings() { { 20, 20 }, { 20, 20 }, { X_CENTER, Y_CENTER } }; - mks_language_index = 0; + mks_language_index = MKS_SimpleChinese; COPY(mks_corner_offsets, init_dgus_level_offsets); mks_park_pos.set(20, 20, 10); mks_min_extrusion_temp = 0; @@ -560,8 +560,8 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_PID_AUTOTUNE_E0, nullptr, ScreenHandler.HandlePIDAutotune, nullptr), #endif #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) - VPHELPER(VP_LOAD_Filament, nullptr, ScreenHandler.MKS_FilamentLoad, nullptr), - VPHELPER(VP_UNLOAD_Filament, nullptr, ScreenHandler.MKS_FilamentUnLoad, nullptr), + VPHELPER(VP_LOAD_Filament, nullptr, ScreenHandler.FilamentLoad, nullptr), + VPHELPER(VP_UNLOAD_Filament, nullptr, ScreenHandler.FilamentUnLoad, nullptr), VPHELPER(VP_Filament_distance, &distanceFilament, ScreenHandler.GetManualFilament, ScreenHandler.DGUSLCD_SendWordValueToDisplay), VPHELPER(VP_Filament_speed, &filamentSpeed_mm_s, ScreenHandler.GetManualFilamentSpeed, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #endif @@ -618,16 +618,16 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_ZPos, ¤t_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>), // Level Point Set - VPHELPER(VP_Level_Point_One_X, &mks_corner_offsets[0].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_One_Y, &mks_corner_offsets[0].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_Two_X, &mks_corner_offsets[1].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_Two_Y, &mks_corner_offsets[1].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_Three_X, &mks_corner_offsets[2].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_Three_Y, &mks_corner_offsets[2].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_Four_X, &mks_corner_offsets[3].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_Four_Y, &mks_corner_offsets[3].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_Five_X, &mks_corner_offsets[4].x, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Level_Point_Five_Y, &mks_corner_offsets[4].y, ScreenHandler.HandleChangeLevelPoint_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_One_X, &mks_corner_offsets[0].x, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_One_Y, &mks_corner_offsets[0].y, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_Two_X, &mks_corner_offsets[1].x, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_Two_Y, &mks_corner_offsets[1].y, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_Three_X, &mks_corner_offsets[2].x, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_Three_Y, &mks_corner_offsets[2].y, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_Four_X, &mks_corner_offsets[3].x, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_Four_Y, &mks_corner_offsets[3].y, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_Five_X, &mks_corner_offsets[4].x, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Level_Point_Five_Y, &mks_corner_offsets[4].y, ScreenHandler.HandleChangeLevelPoint, ScreenHandler.DGUSLCD_SendWordValueToDisplay), // Print Progress VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay), @@ -639,50 +639,50 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_SD_FileSelect_Back, nullptr, ScreenHandler.SD_FileBack, nullptr), // Print Time - VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay_MKS), + VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay), #if ENABLED(PRINTCOUNTER) VPHELPER_STR(VP_PrintAccTime, nullptr, VP_PrintAccTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintAccTimeToDisplay), VPHELPER_STR(VP_PrintsTotal, nullptr, VP_PrintsTotal_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintsTotalToDisplay), #endif - VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], ScreenHandler.HandleStepPerMMChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), - VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], ScreenHandler.HandleStepPerMMChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), - VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_X_STEP_PER_MM, &planner.settings.axis_steps_per_mm[X_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_Y_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Y_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_Z_STEP_PER_MM, &planner.settings.axis_steps_per_mm[Z_AXIS], ScreenHandler.HandleStepPerMMChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), - VPHELPER(VP_X_MAX_SPEED, &planner.settings.max_feedrate_mm_s[X_AXIS], ScreenHandler.HandleMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), - VPHELPER(VP_Y_MAX_SPEED, &planner.settings.max_feedrate_mm_s[Y_AXIS], ScreenHandler.HandleMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), - VPHELPER(VP_Z_MAX_SPEED, &planner.settings.max_feedrate_mm_s[Z_AXIS], ScreenHandler.HandleMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_X_MAX_SPEED, &planner.settings.max_feedrate_mm_s[X_AXIS], ScreenHandler.HandleMaxSpeedChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_Y_MAX_SPEED, &planner.settings.max_feedrate_mm_s[Y_AXIS], ScreenHandler.HandleMaxSpeedChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_Z_MAX_SPEED, &planner.settings.max_feedrate_mm_s[Z_AXIS], ScreenHandler.HandleMaxSpeedChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), #if HAS_HOTEND - VPHELPER(VP_E0_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E_AXIS_N(0)], ScreenHandler.HandleExtruderMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_E0_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E_AXIS_N(0)], ScreenHandler.HandleExtruderMaxSpeedChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), #if HAS_MULTI_HOTEND - VPHELPER(VP_E1_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], ScreenHandler.HandleExtruderMaxSpeedChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_E1_MAX_SPEED, &planner.settings.max_feedrate_mm_s[E_AXIS_N(1)], ScreenHandler.HandleExtruderMaxSpeedChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), #endif #endif - VPHELPER(VP_X_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[X_AXIS], ScreenHandler.HandleMaxAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Y_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[Y_AXIS], ScreenHandler.HandleMaxAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Z_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[Z_AXIS], ScreenHandler.HandleMaxAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_X_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[X_AXIS], ScreenHandler.HandleMaxAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Y_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[Y_AXIS], ScreenHandler.HandleMaxAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Z_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[Z_AXIS], ScreenHandler.HandleMaxAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #if HAS_HOTEND - VPHELPER(VP_E0_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(0)], ScreenHandler.HandleExtruderAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_E0_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(0)], ScreenHandler.HandleExtruderAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #if HAS_MULTI_HOTEND - VPHELPER(VP_E1_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)], ScreenHandler.HandleExtruderAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_E1_ACC_MAX_SPEED, (uint16_t *)&planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)], ScreenHandler.HandleExtruderAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #endif #endif - VPHELPER(VP_TRAVEL_SPEED, (uint16_t *)&planner.settings.travel_acceleration, ScreenHandler.HandleTravelAccChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), - VPHELPER(VP_FEEDRATE_MIN_SPEED, (uint16_t *)&planner.settings.min_feedrate_mm_s, ScreenHandler.HandleFeedRateMinChange_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), - VPHELPER(VP_T_F_SPEED, (uint16_t *)&planner.settings.min_travel_feedrate_mm_s, ScreenHandler.HandleMin_T_F_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), - VPHELPER(VP_ACC_SPEED, (uint16_t *)&planner.settings.acceleration, ScreenHandler.HandleAccChange_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_TRAVEL_SPEED, (uint16_t *)&planner.settings.travel_acceleration, ScreenHandler.HandleTravelAccChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_FEEDRATE_MIN_SPEED, (uint16_t *)&planner.settings.min_feedrate_mm_s, ScreenHandler.HandleFeedRateMinChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_T_F_SPEED, (uint16_t *)&planner.settings.min_travel_feedrate_mm_s, ScreenHandler.HandleMin_T_F, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_ACC_SPEED, (uint16_t *)&planner.settings.acceleration, ScreenHandler.HandleAccChange, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_X_PARK_POS, &mks_park_pos.x, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Y_PARK_POS, &mks_park_pos.y, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), - VPHELPER(VP_Z_PARK_POS, &mks_park_pos.z, ScreenHandler.GetParkPos_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_X_PARK_POS, &mks_park_pos.x, ScreenHandler.GetParkPos, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Y_PARK_POS, &mks_park_pos.y, ScreenHandler.GetParkPos, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_Z_PARK_POS, &mks_park_pos.z, ScreenHandler.GetParkPos, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #if ENABLED(PREVENT_COLD_EXTRUSION) - VPHELPER(VP_MIN_EX_T, &thermalManager.extrude_min_temp, ScreenHandler.HandleGetExMinTemp_MKS, ScreenHandler.DGUSLCD_SendWordValueToDisplay), + VPHELPER(VP_MIN_EX_T, &thermalManager.extrude_min_temp, ScreenHandler.HandleGetExMinTemp, ScreenHandler.DGUSLCD_SendWordValueToDisplay), #endif #if ENABLED(SENSORLESS_HOMING) // TMC SENSORLESS Setting @@ -725,8 +725,8 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif VPHELPER(VP_EEPROM_CTRL, nullptr, ScreenHandler.EEPROM_CTRL, nullptr), - VPHELPER(VP_LEVEL_BUTTON, nullptr, ScreenHandler.Level_Ctrl_MKS, nullptr), - VPHELPER(VP_LANGUAGE_CHANGE, nullptr, ScreenHandler.LanguageChange_MKS, nullptr), + VPHELPER(VP_LEVEL_BUTTON, nullptr, ScreenHandler.Level_Ctrl, nullptr), + VPHELPER(VP_LANGUAGE_CHANGE, nullptr, ScreenHandler.LanguageChange, nullptr), //VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, nullptr), @@ -743,9 +743,9 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { VPHELPER(VP_AutoTurnOffSw, nullptr, ScreenHandler.GetTurnOffCtrl, nullptr), #if HAS_HOTEND - VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_E0_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(0)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), #if HAS_MULTI_HOTEND - VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged_MKS, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), + VPHELPER(VP_E1_STEP_PER_MM, &planner.settings.axis_steps_per_mm[E_AXIS_N(1)], ScreenHandler.HandleStepPerMMExtruderChanged, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>), #endif #endif @@ -791,10 +791,10 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { //{.VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM}, //{.VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplayPGM}, - {.VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS}, - {.VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS}, - {.VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS}, - {.VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language_MKS}, + {.VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language}, + {.VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language}, + {.VP = VP_MSGSTR3, .memadr = nullptr, .size = VP_MSGSTR3_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language}, + {.VP = VP_MSGSTR4, .memadr = nullptr, .size = VP_MSGSTR4_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = ScreenHandler.DGUSLCD_SendStringToDisplay_Language}, VPHELPER(0, 0, 0, 0) // must be last entry. }; diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.h b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.h index 407782f5595e..9ec2304a36aa 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.h +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.h @@ -100,7 +100,7 @@ extern EX_FILAMENT_DEF ex_filament; typedef enum { UNRUNOUT_STATUS, RUNOUT_STATUS, - RUNOUT_WAITTING_STATUS, + RUNOUT_WAITING_STATUS, RUNOUT_BEGIN_STATUS, } RUNOUT_MKS_STATUS_DEF; diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp index 0e2a971fd1b8..739265e49636 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp @@ -48,40 +48,40 @@ #endif #if ENABLED(SDSUPPORT) - static ExtUI::FileList filelist; + extern ExtUI::FileList filelist; #endif bool DGUSAutoTurnOff = false; -uint8_t mks_language_index; // Initialized by settings.load() +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 DGUSScreenHandler::sendinfoscreen_ch_mks(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4) { +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); dgusdisplay.WriteVariable(VP_MSGSTR2, line2, 32, true); dgusdisplay.WriteVariable(VP_MSGSTR3, line3, 32, true); dgusdisplay.WriteVariable(VP_MSGSTR4, line4, 32, true); } -void DGUSScreenHandler::sendinfoscreen_en_mks(const char *line1, const char *line2, const char *line3, const char *line4) { +void DGUSScreenHandlerMKS::sendinfoscreen_en(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4) { dgusdisplay.WriteVariable(VP_MSGSTR1, line1, 32, true); dgusdisplay.WriteVariable(VP_MSGSTR2, line2, 32, true); dgusdisplay.WriteVariable(VP_MSGSTR3, line3, 32, true); dgusdisplay.WriteVariable(VP_MSGSTR4, line4, 32, true); } -void DGUSScreenHandler::sendinfoscreen_mks(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language) { +void DGUSScreenHandlerMKS::sendinfoscreen(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language) { if (language == MKS_English) - DGUSScreenHandler::sendinfoscreen_en_mks((char *)line1, (char *)line2, (char *)line3, (char *)line4); + DGUSScreenHandlerMKS::sendinfoscreen_en((char *)line1, (char *)line2, (char *)line3, (char *)line4); else if (language == MKS_SimpleChinese) - DGUSScreenHandler::sendinfoscreen_ch_mks((uint16_t *)line1, (uint16_t *)line2, (uint16_t *)line3, (uint16_t *)line4); + DGUSScreenHandlerMKS::sendinfoscreen_ch((uint16_t *)line1, (uint16_t *)line2, (uint16_t *)line3, (uint16_t *)line4); } #endif -void DGUSScreenHandler::DGUSLCD_SendFanToDisplay(DGUS_VP_Variable &var) { +void DGUSScreenHandlerMKS::DGUSLCD_SendFanToDisplay(DGUS_VP_Variable &var) { if (var.memadr) { //DEBUG_ECHOPGM(" DGUS_LCD_SendWordValueToDisplay ", var.VP); //DEBUG_ECHOLNPGM(" data ", *(uint16_t *)var.memadr); @@ -91,14 +91,14 @@ void DGUSScreenHandler::DGUSLCD_SendFanToDisplay(DGUS_VP_Variable &var) { } } -void DGUSScreenHandler::DGUSLCD_SendBabyStepToDisplay_MKS(DGUS_VP_Variable &var) { +void DGUSScreenHandlerMKS::DGUSLCD_SendBabyStepToDisplay(DGUS_VP_Variable &var) { float value = current_position.z; DEBUG_ECHOLNPAIR_F(" >> ", value, 6); value *= cpow(10, 2); dgusdisplay.WriteVariable(VP_SD_Print_Baby, (uint16_t)value); } -void DGUSScreenHandler::DGUSLCD_SendPrintTimeToDisplay_MKS(DGUS_VP_Variable &var) { +void DGUSScreenHandlerMKS::DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var) { duration_t elapsed = print_job_timer.duration(); uint32_t time = elapsed.value; dgusdisplay.WriteVariable(VP_PrintTime_H, uint16_t(time / 3600)); @@ -106,7 +106,7 @@ void DGUSScreenHandler::DGUSLCD_SendPrintTimeToDisplay_MKS(DGUS_VP_Variable &var dgusdisplay.WriteVariable(VP_PrintTime_S, uint16_t((time % 3600) % 60)); } -void DGUSScreenHandler::DGUSLCD_SetUint8(DGUS_VP_Variable &var, void *val_ptr) { +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); @@ -115,13 +115,13 @@ void DGUSScreenHandler::DGUSLCD_SetUint8(DGUS_VP_Variable &var, void *val_ptr) { } } -void DGUSScreenHandler::DGUSLCD_SendGbkToDisplay(DGUS_VP_Variable &var) { +void DGUSScreenHandlerMKS::DGUSLCD_SendGbkToDisplay(DGUS_VP_Variable &var) { DEBUG_ECHOLNPGM(" data ", *(uint16_t *)var.memadr); uint16_t *tmp = (uint16_t*) var.memadr; dgusdisplay.WriteVariable(var.VP, tmp, var.size, true); } -void DGUSScreenHandler::DGUSLCD_SendStringToDisplay_Language_MKS(DGUS_VP_Variable &var) { +void DGUSScreenHandlerMKS::DGUSLCD_SendStringToDisplay_Language(DGUS_VP_Variable &var) { if (mks_language_index == MKS_English) { char *tmp = (char*) var.memadr; dgusdisplay.WriteVariable(var.VP, tmp, var.size, true); @@ -132,7 +132,7 @@ void DGUSScreenHandler::DGUSLCD_SendStringToDisplay_Language_MKS(DGUS_VP_Variabl } } -void DGUSScreenHandler::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { +void DGUSScreenHandlerMKS::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { #if ENABLED(SENSORLESS_HOMING) #if X_HAS_STEALTHCHOP tmc_step.x = stepperX.homing_threshold(); @@ -193,9 +193,8 @@ void DGUSScreenHandler::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { if (!ExtUI::isPrintingFromMedia()) return; // avoid race condition when user stays in this menu and printer finishes. switch (swap16(*(uint16_t*)val_ptr)) { case 0: { // Resume - auto cs = getCurrentScreen(); - if (runout_mks.runout_status != RUNOUT_WAITTING_STATUS && runout_mks.runout_status != UNRUNOUT_STATUS) { + if (runout_mks.runout_status != RUNOUT_WAITING_STATUS && runout_mks.runout_status != UNRUNOUT_STATUS) { if (cs == MKSLCD_SCREEN_PRINT || cs == MKSLCD_SCREEN_PAUSE) GotoScreen(MKSLCD_SCREEN_PAUSE); return; @@ -213,7 +212,6 @@ void DGUSScreenHandler::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { } break; case 1: // Pause - GotoScreen(MKSLCD_SCREEN_PAUSE); if (!ExtUI::isPrintingFromMediaPaused()) { nozzle_park_mks.print_pause_start_flag = 1; @@ -222,6 +220,7 @@ void DGUSScreenHandler::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { //ExtUI::mks_pausePrint(); } break; + case 2: // Abort HandleUserConfirmationPopUp(VP_SD_AbortPrintConfirmed, nullptr, PSTR("Abort printing"), filelist.filename(), PSTR("?"), true, true, false, true); break; @@ -268,7 +267,7 @@ void DGUSScreenHandler::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { } #else - void DGUSScreenHandler::PrintReturn(DGUS_VP_Variable& var, void *val_ptr) { + void DGUSScreenHandlerMKS::PrintReturn(DGUS_VP_Variable& var, void *val_ptr) { uint16_t value = swap16(*(uint16_t*)val_ptr); if (value == 0x0F) GotoScreen(DGUSLCD_SCREEN_MAIN); } @@ -315,14 +314,14 @@ void DGUSScreenHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) { #endif } -void DGUSScreenHandler::ScreenBackChange(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); DEBUG_ECHOLNPGM(" back = 0x%x", target); switch (target) { } } -void DGUSScreenHandler::ZoffsetConfirm(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandlerMKS::ZoffsetConfirm(DGUS_VP_Variable &var, void *val_ptr) { settings.save(); if (printJobOngoing()) GotoScreen(MKSLCD_SCREEN_PRINT); @@ -330,7 +329,7 @@ void DGUSScreenHandler::ZoffsetConfirm(DGUS_VP_Variable &var, void *val_ptr) { GotoScreen(MKSLCD_SCREEN_PAUSE); } -void DGUSScreenHandler::GetTurnOffCtrl(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); switch (value) { @@ -339,7 +338,7 @@ void DGUSScreenHandler::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) { } } -void DGUSScreenHandler::GetMinExtrudeTemp(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); TERN_(PREVENT_COLD_EXTRUSION, thermalManager.extrude_min_temp = value); @@ -347,7 +346,7 @@ void DGUSScreenHandler::GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr) settings.save(); } -void DGUSScreenHandler::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandlerMKS::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("GetZoffsetDistance"); const uint16_t value = swap16(*(uint16_t *)val_ptr); float val_distance = 0; @@ -361,12 +360,12 @@ void DGUSScreenHandler::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr) ZOffset_distance = val_distance; } -void DGUSScreenHandler::GetManualMovestep(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandlerMKS::GetManualMovestep(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("\nGetManualMovestep"); *(uint16_t *)var.memadr = swap16(*(uint16_t *)val_ptr); } -void DGUSScreenHandler::EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandlerMKS::EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr) { const uint16_t eep_flag = swap16(*(uint16_t *)val_ptr); switch (eep_flag) { case 0: @@ -384,7 +383,7 @@ void DGUSScreenHandler::EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr) { } } -void DGUSScreenHandler::Z_offset_select(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); switch (z_value) { case 0: Z_distance = 0.01; break; @@ -394,12 +393,12 @@ void DGUSScreenHandler::Z_offset_select(DGUS_VP_Variable &var, void *val_ptr) { } } -void DGUSScreenHandler::GetOffsetValue(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; - DEBUG_ECHOLNPAIR_F("\nget int6 offset >> ", value, 6); + DEBUG_ECHOLNPGM("\nget int6 offset >> ", value, 6); #endif switch (var.VP) { @@ -411,21 +410,21 @@ void DGUSScreenHandler::GetOffsetValue(DGUS_VP_Variable &var, void *val_ptr) { settings.save(); } -void DGUSScreenHandler::LanguageChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandlerMKS::LanguageChange(DGUS_VP_Variable &var, void *val_ptr) { const uint16_t lag_flag = swap16(*(uint16_t *)val_ptr); switch (lag_flag) { case MKS_SimpleChinese: DGUS_LanguageDisplay(MKS_SimpleChinese); mks_language_index = MKS_SimpleChinese; - dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_Choose); - dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_NoChoose); + dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_Choose); + dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_NoChoose); settings.save(); break; case MKS_English: DGUS_LanguageDisplay(MKS_English); mks_language_index = MKS_English; - dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_NoChoose); - dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_Choose); + dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_NoChoose); + dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_Choose); settings.save(); break; default: break; @@ -436,7 +435,7 @@ void DGUSScreenHandler::LanguageChange_MKS(DGUS_VP_Variable &var, void *val_ptr) uint8_t mesh_point_count = GRID_MAX_POINTS; #endif -void DGUSScreenHandler::Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr) { +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(); @@ -483,7 +482,7 @@ void DGUSScreenHandler::Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr) { } } -void DGUSScreenHandler::MeshLevelDistanceConfig(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); switch (mesh_dist) { case 0: mesh_adj_distance = 0.01; break; @@ -493,7 +492,7 @@ void DGUSScreenHandler::MeshLevelDistanceConfig(DGUS_VP_Variable &var, void *val } } -void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) { +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); // static uint8_t a_first_level = 1; @@ -588,11 +587,11 @@ void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) { #endif // MESH_BED_LEVELING } -void DGUSScreenHandler::SD_FileBack(DGUS_VP_Variable&, void*) { +void DGUSScreenHandlerMKS::SD_FileBack(DGUS_VP_Variable&, void*) { GotoScreen(MKSLCD_SCREEN_HOME); } -void DGUSScreenHandler::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandlerMKS::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) { const uint16_t lcd_value = swap16(*(uint16_t *)val_ptr); lcd_default_light = constrain(lcd_value, 10, 100); @@ -601,7 +600,7 @@ void DGUSScreenHandler::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) { dgusdisplay.WriteVariable(0x0082, &lcd_data, 5, true); } -void DGUSScreenHandler::ManualAssistLeveling(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); // Insist on leveling first time at this screen @@ -654,7 +653,7 @@ void DGUSScreenHandler::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_pt #define mks_min(a, b) ((a) < (b)) ? (a) : (b) #define mks_max(a, b) ((a) > (b)) ? (a) : (b) -void DGUSScreenHandler::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr) { +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); #endif @@ -756,7 +755,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { else if (manualMoveStep == 0x02) manualMoveStep = 100; else if (manualMoveStep == 0x03) manualMoveStep = 1000; - DEBUG_ECHOLNPGM("QUEUE LEN:", queue.length); + DEBUG_ECHOLNPGM("QUEUE LEN:", queue.ring_buffer.length); if (!print_job_timer.isPaused() && !queue.ring_buffer.empty()) return; @@ -893,7 +892,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { return; } -void DGUSScreenHandler::GetParkPos_MKS(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); switch (var.VP) { @@ -905,11 +904,11 @@ void DGUSScreenHandler::GetParkPos_MKS(DGUS_VP_Variable &var, void *val_ptr) { skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } -void DGUSScreenHandler::HandleChangeLevelPoint_MKS(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleChangeLevelPoint_MKS"); +void DGUSScreenHandlerMKS::HandleChangeLevelPoint(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleChangeLevelPoint"); const int16_t value_raw = swap16(*(int16_t*)val_ptr); - DEBUG_ECHOLNPAIR_F("value_raw:", value_raw); + DEBUG_ECHOLNPGM("value_raw:", value_raw); *(int16_t*)var.memadr = value_raw; @@ -917,14 +916,14 @@ void DGUSScreenHandler::HandleChangeLevelPoint_MKS(DGUS_VP_Variable &var, void * skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } -void DGUSScreenHandler::HandleStepPerMMChanged_MKS(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleStepPerMMChanged_MKS"); +void DGUSScreenHandlerMKS::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleStepPerMMChanged"); const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); - DEBUG_ECHOLNPAIR_F("value:", value); + DEBUG_ECHOLNPGM("value:", value); ExtUI::axis_t axis; switch (var.VP) { @@ -934,19 +933,19 @@ void DGUSScreenHandler::HandleStepPerMMChanged_MKS(DGUS_VP_Variable &var, void * case VP_Z_STEP_PER_MM: axis = ExtUI::axis_t::Z; break; } ExtUI::setAxisSteps_per_mm(value, axis); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(axis)); + DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisSteps_per_mm(axis)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } -void DGUSScreenHandler::HandleStepPerMMExtruderChanged_MKS(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged_MKS"); +void DGUSScreenHandlerMKS::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged"); const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); - DEBUG_ECHOLNPAIR_F("value:", value); + DEBUG_ECHOLNPGM("value:", value); ExtUI::extruder_t extruder; switch (var.VP) { @@ -959,19 +958,19 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged_MKS(DGUS_VP_Variable &var #endif } ExtUI::setAxisSteps_per_mm(value, extruder); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(extruder)); + DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisSteps_per_mm(extruder)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } -void DGUSScreenHandler::HandleMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS"); +void DGUSScreenHandlerMKS::HandleMaxSpeedChange(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleMaxSpeedChange"); const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); - DEBUG_ECHOLNPAIR_F("value:", value); + DEBUG_ECHOLNPGM("value:", value); ExtUI::axis_t axis; switch (var.VP) { @@ -981,19 +980,19 @@ void DGUSScreenHandler::HandleMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *va default: return; } ExtUI::setAxisMaxFeedrate_mm_s(value, axis); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxFeedrate_mm_s(axis)); + DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisMaxFeedrate_mm_s(axis)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } -void DGUSScreenHandler::HandleExtruderMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleExtruderMaxSpeedChange_MKS"); +void DGUSScreenHandlerMKS::HandleExtruderMaxSpeedChange(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleExtruderMaxSpeedChange"); const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); - DEBUG_ECHOLNPAIR_F("value:", value); + DEBUG_ECHOLNPGM("value:", value); ExtUI::extruder_t extruder; switch (var.VP) { @@ -1006,19 +1005,19 @@ void DGUSScreenHandler::HandleExtruderMaxSpeedChange_MKS(DGUS_VP_Variable &var, case VP_E1_MAX_SPEED: extruder = ExtUI::extruder_t::E1; break; } ExtUI::setAxisMaxFeedrate_mm_s(value, extruder); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxFeedrate_mm_s(extruder)); + DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisMaxFeedrate_mm_s(extruder)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } -void DGUSScreenHandler::HandleMaxAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleMaxAccChange_MKS"); +void DGUSScreenHandlerMKS::HandleMaxAccChange(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleMaxAccChange"); const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); - DEBUG_ECHOLNPAIR_F("value:", value); + DEBUG_ECHOLNPGM("value:", value); ExtUI::axis_t axis; switch (var.VP) { @@ -1028,13 +1027,13 @@ void DGUSScreenHandler::HandleMaxAccChange_MKS(DGUS_VP_Variable &var, void *val_ case VP_Z_ACC_MAX_SPEED: axis = ExtUI::axis_t::Z; break; } ExtUI::setAxisMaxAcceleration_mm_s2(value, axis); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxAcceleration_mm_s2(axis)); + DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisMaxAcceleration_mm_s2(axis)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } -void DGUSScreenHandler::HandleExtruderAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleExtruderAccChange_MKS"); +void DGUSScreenHandlerMKS::HandleExtruderAccChange(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("HandleExtruderAccChange"); uint16_t value_raw = swap16(*(uint16_t*)val_ptr); DEBUG_ECHOLNPGM("value_raw:", value_raw); @@ -1049,39 +1048,39 @@ void DGUSScreenHandler::HandleExtruderAccChange_MKS(DGUS_VP_Variable &var, void case VP_E1_ACC_MAX_SPEED: extruder = ExtUI::extruder_t::E1; settings.load(); break; #endif } - DEBUG_ECHOLNPAIR_F("value:", value); + DEBUG_ECHOLNPGM("value:", value); ExtUI::setAxisMaxAcceleration_mm_s2(value, extruder); - DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxAcceleration_mm_s2(extruder)); + DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisMaxAcceleration_mm_s2(extruder)); settings.save(); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } -void DGUSScreenHandler::HandleTravelAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandlerMKS::HandleTravelAccChange(DGUS_VP_Variable &var, void *val_ptr) { uint16_t value_travel = swap16(*(uint16_t*)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 DGUSScreenHandler::HandleFeedRateMinChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandlerMKS::HandleFeedRateMinChange(DGUS_VP_Variable &var, void *val_ptr) { uint16_t value_t = swap16(*(uint16_t*)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 DGUSScreenHandler::HandleMin_T_F_MKS(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandlerMKS::HandleMin_T_F(DGUS_VP_Variable &var, void *val_ptr) { uint16_t value_t_f = swap16(*(uint16_t*)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 DGUSScreenHandler::HandleAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandlerMKS::HandleAccChange(DGUS_VP_Variable &var, void *val_ptr) { uint16_t value_acc = swap16(*(uint16_t*)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 DGUSScreenHandler::HandleGetExMinTemp_MKS(DGUS_VP_Variable &var, void *val_ptr) { + void DGUSScreenHandlerMKS::HandleGetExMinTemp(DGUS_VP_Variable &var, void *val_ptr) { const uint16_t value_ex_min_temp = swap16(*(uint16_t*)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 @@ -1115,7 +1114,7 @@ void DGUSScreenHandler::HandleAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr #endif } - DEBUG_ECHOLNPAIR_F("V3:", newvalue); + DEBUG_ECHOLNPGM("V3:", newvalue); *(float *)var.memadr = newvalue; settings.save(); @@ -1168,32 +1167,32 @@ void DGUSScreenHandler::HandleAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr } #endif // BABYSTEPPING -void DGUSScreenHandler::GetManualFilament(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandlerMKS::GetManualFilament(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("GetManualFilament"); uint16_t value_len = swap16(*(uint16_t*)val_ptr); float value = (float)value_len; - DEBUG_ECHOLNPAIR_F("Get Filament len value:", value); + DEBUG_ECHOLNPGM("Get Filament len value:", value); distanceFilament = value; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } -void DGUSScreenHandler::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr) { +void DGUSScreenHandlerMKS::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("GetManualFilamentSpeed"); uint16_t value_len = swap16(*(uint16_t*)val_ptr); - DEBUG_ECHOLNPAIR_F("filamentSpeed_mm_s value:", value_len); + DEBUG_ECHOLNPGM("filamentSpeed_mm_s value:", value_len); filamentSpeed_mm_s = value_len; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } -void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir) { +void DGUSScreenHandlerMKS::FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir) { #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE) uint8_t swap_tool = 0; #else @@ -1254,7 +1253,7 @@ void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ } /** - * M1002: Do a tool-change and relative move for MKS_FilamentLoadUnload + * M1002: Do a tool-change and relative move for FilamentLoadUnload * within the G-code execution window for best concurrency. */ void GcodeSuite::M1002() { @@ -1276,14 +1275,14 @@ void GcodeSuite::M1002() { axis_relative = old_axis_relative; } -void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("MKS_FilamentLoad"); - MKS_FilamentLoadUnload(var, val_ptr, 1); +void DGUSScreenHandlerMKS::FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("FilamentLoad"); + FilamentLoadUnload(var, val_ptr, 1); } -void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("MKS_FilamentUnLoad"); - MKS_FilamentLoadUnload(var, val_ptr, -1); +void DGUSScreenHandlerMKS::FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) { + DEBUG_ECHOLNPGM("FilamentUnLoad"); + FilamentLoadUnload(var, val_ptr, -1); } #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) @@ -1392,7 +1391,7 @@ void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) #endif // DGUS_FILAMENT_LOADUNLOAD -bool DGUSScreenHandler::loop() { +bool DGUSScreenHandlerMKS::loop() { dgusdisplay.loop(); const millis_t ms = millis(); @@ -1444,22 +1443,22 @@ bool DGUSScreenHandler::loop() { return IsScreenComplete(); } -void DGUSScreenHandler::LanguagePInit() { +void DGUSScreenHandlerMKS::LanguagePInit() { switch (mks_language_index) { case MKS_SimpleChinese: - dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_Choose); - dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_NoChoose); + dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_Choose); + dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_NoChoose); break; case MKS_English: - dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_NoChoose); - dgusdisplay.MKS_WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_Choose); + dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE1, MKS_Language_NoChoose); + dgusdisplay.WriteVariable(VP_LANGUAGE_CHANGE2, MKS_Language_Choose); break; default: break; } } -void DGUSScreenHandler::DGUS_ExtrudeLoadInit(void) { +void DGUSScreenHandlerMKS::DGUS_ExtrudeLoadInit() { ex_filament.ex_length = distanceFilament; ex_filament.ex_load_unload_flag = 0; ex_filament.ex_need_time = filamentSpeed_mm_s; @@ -1469,7 +1468,7 @@ void DGUSScreenHandler::DGUS_ExtrudeLoadInit(void) { ex_filament.ex_tick_start = 0; } -void DGUSScreenHandler::DGUS_RunoutInit(void) { +void DGUSScreenHandlerMKS::DGUS_RunoutInit() { #if PIN_EXISTS(MT_DET_1) SET_INPUT_PULLUP(MT_DET_1_PIN); #endif @@ -1479,7 +1478,7 @@ void DGUSScreenHandler::DGUS_RunoutInit(void) { runout_mks.runout_status = UNRUNOUT_STATUS; } -void DGUSScreenHandler::DGUS_Runout_Idle(void) { +void DGUSScreenHandlerMKS::DGUS_Runout_Idle() { #if ENABLED(DGUS_MKS_RUNOUT_SENSOR) // scanf runout pin switch (runout_mks.runout_status) { @@ -1501,10 +1500,10 @@ void DGUSScreenHandler::DGUS_Runout_Idle(void) { case RUNOUT_BEGIN_STATUS: if (READ(MT_DET_1_PIN) != MT_DET_PIN_STATE) - runout_mks.runout_status = RUNOUT_WAITTING_STATUS; + runout_mks.runout_status = RUNOUT_WAITING_STATUS; break; - case RUNOUT_WAITTING_STATUS: + case RUNOUT_WAITING_STATUS: if (READ(MT_DET_1_PIN) == MT_DET_PIN_STATE) runout_mks.runout_status = RUNOUT_BEGIN_STATUS; break; @@ -1514,7 +1513,7 @@ void DGUSScreenHandler::DGUS_Runout_Idle(void) { #endif } -void DGUSScreenHandler::DGUS_LanguageDisplay(uint8_t var) { +void DGUSScreenHandlerMKS::DGUS_LanguageDisplay(uint8_t var) { if (var == MKS_English) { const char home_buf_en[] = "Home"; dgusdisplay.WriteVariable(VP_HOME_Dis, home_buf_en, 32, true); diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h index 0c80cd260ef9..823ed4297cd0 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.h @@ -21,64 +21,26 @@ */ #pragma once -#include "../DGUSDisplay.h" -#include "../DGUSVPVariable.h" -#include "../DGUSDisplayDef.h" - -#include "../../../../inc/MarlinConfig.h" +#include "../DGUSScreenHandlerBase.h" enum DGUSLCD_Screens : uint8_t; -class DGUSScreenHandler { +class DGUSScreenHandlerMKS : public DGUSScreenHandler { public: - DGUSScreenHandler() = default; - - static bool loop(); - - // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen - // The bools specifying whether the strings are in RAM or FLASH. - static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { - sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); - } - static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { - sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); - } - - static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); + DGUSScreenHandlerMKS() = default; #if 0 - static void sendinfoscreen_ch_mks(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4); - static void sendinfoscreen_en_mks(const char *line1, const char *line2, const char *line3, const char *line4) ; - static void sendinfoscreen_mks(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language); + static void sendinfoscreen_ch(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4); + static void sendinfoscreen_en(PGM_P const line1, PGM_P const line2, PGM_P const line3, PGM_P const line4); + static void sendinfoscreen(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language); #endif - // "M117" Message -- msg is a RAM ptr. - static void setstatusmessage(const char *msg); - // The same for messages from Flash - static void setstatusmessagePGM(PGM_P const msg); - // Callback for VP "Display wants to change screen on idle printer" - static void ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr); - // Callback for VP "Screen has been changed" - static void ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr); - static void ScreenBackChange(DGUS_VP_Variable &var, void *val_ptr); - // Callback for VP "All Heaters Off" - static void HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr); - // Hook for "Change this temperature" - static void HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr); - // Hook for "Change Flowrate" - static void HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr); - #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - // Hook for manual move option - static void HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr); - #endif - static void EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr); - static void LanguageChange_MKS(DGUS_VP_Variable &var, void *val_ptr); + static void LanguageChange(DGUS_VP_Variable &var, void *val_ptr); static void GetOffsetValue(DGUS_VP_Variable &var, void *val_ptr); - static void Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr); + static void Level_Ctrl(DGUS_VP_Variable &var, void *val_ptr); static void MeshLevel(DGUS_VP_Variable &var, void *val_ptr); static void MeshLevelDistanceConfig(DGUS_VP_Variable &var, void *val_ptr); static void ManualAssistLeveling(DGUS_VP_Variable &var, void *val_ptr); @@ -87,235 +49,68 @@ class DGUSScreenHandler { static void GetManualMovestep(DGUS_VP_Variable &var, void *val_ptr); static void GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr); static void GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr); - static void GetParkPos_MKS(DGUS_VP_Variable &var, void *val_ptr); + static void GetParkPos(DGUS_VP_Variable &var, void *val_ptr); #if ENABLED(PREVENT_COLD_EXTRUSION) - static void HandleGetExMinTemp_MKS(DGUS_VP_Variable &var, void *val_ptr); + static void HandleGetExMinTemp(DGUS_VP_Variable &var, void *val_ptr); #endif static void DGUS_LanguageDisplay(uint8_t var); static void TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr); static void GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr); - static void LanguagePInit(void); - static void DGUS_Runout_Idle(void); - static void DGUS_RunoutInit(void); - static void DGUS_ExtrudeLoadInit(void); + static void LanguagePInit(); + static void DGUS_Runout_Idle(); + static void DGUS_RunoutInit(); + static void DGUS_ExtrudeLoadInit(); static void LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr); static void SD_FileBack(DGUS_VP_Variable &var, void *val_ptr); - // Hook for manual move. - static void HandleManualMove(DGUS_VP_Variable &var, void *val_ptr); - // Hook for manual extrude. - static void HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr); - // Hook for motor lock and unlook - static void HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr); - #if ENABLED(POWER_LOSS_RECOVERY) - // Hook for power loss recovery. - static void HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr); - #endif - // Hook for settings - static void HandleSettings(DGUS_VP_Variable &var, void *val_ptr); static void HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr); static void HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr); - - static void HandleStepPerMMChanged_MKS(DGUS_VP_Variable &var, void *val_ptr); - static void HandleStepPerMMExtruderChanged_MKS(DGUS_VP_Variable &var, void *val_ptr); - static void HandleMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr); - static void HandleExtruderMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr); - static void HandleAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr); - static void HandleMaxAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr); - static void HandleExtruderAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr); - static void HandleChangeLevelPoint_MKS(DGUS_VP_Variable &var, void *val_ptr); - static void HandleTravelAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr); - static void HandleFeedRateMinChange_MKS(DGUS_VP_Variable &var, void *val_ptr); - static void HandleMin_T_F_MKS(DGUS_VP_Variable &var, void *val_ptr); + static void HandleMaxSpeedChange(DGUS_VP_Variable &var, void *val_ptr); + static void HandleExtruderMaxSpeedChange(DGUS_VP_Variable &var, void *val_ptr); + static void HandleAccChange(DGUS_VP_Variable &var, void *val_ptr); + static void HandleMaxAccChange(DGUS_VP_Variable &var, void *val_ptr); + static void HandleExtruderAccChange(DGUS_VP_Variable &var, void *val_ptr); + static void HandleChangeLevelPoint(DGUS_VP_Variable &var, void *val_ptr); + static void HandleTravelAccChange(DGUS_VP_Variable &var, void *val_ptr); + static void HandleFeedRateMinChange(DGUS_VP_Variable &var, void *val_ptr); + static void HandleMin_T_F(DGUS_VP_Variable &var, void *val_ptr); #if HAS_PID_HEATING - // Hook for "Change this temperature PID para" - static void HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr); - // Hook for PID autotune - static void HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if HAS_BED_PROBE - // Hook for "Change probe offset z" - static void HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if ENABLED(BABYSTEPPING) - // Hook for live z adjust action - static void HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if HAS_FAN - // Hook for fan control - static void HandleFanControl(DGUS_VP_Variable &var, void *val_ptr); - #endif - // Hook for heater control - static void HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr); - #if ENABLED(DGUS_PREHEAT_UI) - // Hook for preheat - static void HandlePreheat(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) - // Hook for filament load and unload filament option - static void HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr); - // Hook for filament load and unload - static void HandleFilamentLoadUnload(DGUS_VP_Variable &var); - - static void MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir); - static void MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr); - static void MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr); - static void MKS_LOAD_UNLOAD_IDLE(); - static void MKS_LOAD_Cancle(DGUS_VP_Variable &var, void *val_ptr); + static void FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir); + static void FilamentLoad(DGUS_VP_Variable &var, void *val_ptr); + static void FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr); static void GetManualFilament(DGUS_VP_Variable &var, void *val_ptr); static void GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr); #endif #if ENABLED(SDSUPPORT) - // Callback for VP "Display wants to change screen when there is a SD card" - static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr); - // Scroll buttons on the file listing screen. - static void DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable &var, void *val_ptr); - // File touched. - static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr); - // start print after confirmation received. - static void DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr); - // User hit the pause, resume or abort button. - static void DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr); - // User confirmed the abort action - static void DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr); - // User hit the tune button - static void DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr); - // Send a single filename to the display. - static void DGUSLCD_SD_SendFilename(DGUS_VP_Variable &var); - // Marlin informed us that a new SD has been inserted. - static void SDCardInserted(); - // Marlin informed us that the SD Card has been removed(). - static void SDCardRemoved(); - // Marlin informed us about a bad SD Card. - static void SDCardError(); // Marlin informed us about SD print completion. static void SDPrintingFinished(); #else static void PrintReturn(DGUS_VP_Variable &var, void *val_ptr); #endif - // OK Button on the Confirm screen. - static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr); - - // Update data after going to a new screen (by display or by GotoScreen) - // remember: store the last-displayed screen, so it can be returned to. - // (e.g for popup messages) - static void UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup=false); - - // Recall the remembered screen. - static void PopToOldScreen(); - - // Make the display show the screen and update all VPs in it. - static void GotoScreen(DGUSLCD_Screens screen, bool ispopup = false); - - static void UpdateScreenVPData(); - - // Helpers to convert and transfer data to the display. - static void DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var); - static void DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var); - static void DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var); static void DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var); - - static void DGUSLCD_SendPrintTimeToDisplay_MKS(DGUS_VP_Variable &var); - static void DGUSLCD_SendBabyStepToDisplay_MKS(DGUS_VP_Variable &var); + static void DGUSLCD_SendBabyStepToDisplay(DGUS_VP_Variable &var); static void DGUSLCD_SendFanToDisplay(DGUS_VP_Variable &var); static void DGUSLCD_SendGbkToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendStringToDisplay_Language_MKS(DGUS_VP_Variable &var); + static void DGUSLCD_SendStringToDisplay_Language(DGUS_VP_Variable &var); static void DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var); - #if ENABLED(PRINTCOUNTER) - static void DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var); - #endif - #if HAS_FAN - static void DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var); - #endif - static void DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var); - #if ENABLED(DGUS_UI_WAITING) - static void DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var); - #endif - - // Send a value from 0..100 to a variable with a range from 0..255 - static void DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr); - static void DGUSLCD_SetUint8(DGUS_VP_Variable &var, void *val_ptr); - template - static void DGUSLCD_SetValueDirectly(DGUS_VP_Variable &var, void *val_ptr) { - if (!var.memadr) return; - union { unsigned char tmp[sizeof(T)]; T t; } x; - unsigned char *ptr = (unsigned char*)val_ptr; - LOOP_L_N(i, sizeof(T)) x.tmp[i] = ptr[sizeof(T) - i - 1]; - *(T*)var.memadr = x.t; - } - - // Send a float value to the display. - // Display will get a 4-byte integer scaled to the number of digits: - // Tell the display the number of digits and it cheats by displaying a dot between... - template - static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) { - if (var.memadr) { - float f = *(float *)var.memadr; - f *= cpow(10, decimals); - dgusdisplay.WriteVariable(var.VP, (long)f); - } - } - - // Send a float value to the display. - // Display will get a 2-byte integer scaled to the number of digits: - // Tell the display the number of digits and it cheats by displaying a dot between... - template - static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) { - if (var.memadr) { - float f = *(float *)var.memadr; - DEBUG_ECHOLNPAIR_F(" >> ", f, 6); - f *= cpow(10, decimals); - dgusdisplay.WriteVariable(var.VP, (int16_t)f); - } - } - - // Force an update of all VP on the current screen. - static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } - // Has all VPs sent to the screen - static inline bool IsScreenComplete() { return ScreenComplete; } - - static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; } - - static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } - -private: - static DGUSLCD_Screens current_screen; //< currently on screen - static constexpr uint8_t NUM_PAST_SCREENS = 4; - static DGUSLCD_Screens past_screens[NUM_PAST_SCREENS]; //< LIFO with past screens for the "back" button. - - static uint8_t update_ptr; //< Last sent entry in the VPList for the actual screen. - static uint16_t skipVP; //< When updating the screen data, skip this one, because the user is interacting with it. - static bool ScreenComplete; //< All VPs sent to screen? - - static uint16_t ConfirmVP; //< context for confirm screen (VP that will be emulated-sent on "OK"). - - #if ENABLED(SDSUPPORT) - static int16_t top_file; //< file on top of file chooser - static int16_t file_to_print; //< touched file to be confirmed - #endif - - static void (*confirm_action_cb)(); + static bool loop(); }; -#define MKS_Language_Choose 0x00 -#define MKS_Language_NoChoose 0x01 +enum MKS_Choose : uint8_t { MKS_Language_Choose, MKS_Language_NoChoose }; +enum MKS_Language : uint8_t { MKS_SimpleChinese, MKS_English }; -#define MKS_SimpleChinese 0 -#define MKS_English 1 -extern uint8_t mks_language_index; +extern MKS_Language mks_language_index; extern bool DGUSAutoTurnOff; #if ENABLED(POWER_LOSS_RECOVERY) #define PLR_SCREEN_RECOVER MKSLCD_SCREEN_PRINT #define PLR_SCREEN_CANCEL MKSLCD_SCREEN_HOME #endif + +typedef DGUSScreenHandlerMKS DGUSScreenHandlerClass; diff --git a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp index b77c92b7eb95..aaa8b72e1182 100644 --- a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.cpp @@ -42,7 +42,7 @@ #if ENABLED(SDSUPPORT) - static ExtUI::FileList filelist; + extern ExtUI::FileList filelist; 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; @@ -268,7 +268,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { #endif } - DEBUG_ECHOLNPAIR_F("V3:", newvalue); + DEBUG_ECHOLNPGM("V3:", newvalue); *(float *)var.memadr = newvalue; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel diff --git a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h index bb0bd2bd3b42..73e3527d7e7c 100644 --- a/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/origin/DGUSScreenHandler.h @@ -21,224 +21,9 @@ */ #pragma once -#include "../DGUSDisplay.h" -#include "../DGUSVPVariable.h" -#include "../DGUSDisplayDef.h" +#include "../DGUSScreenHandlerBase.h" -#include "../../../../inc/MarlinConfig.h" - -enum DGUSLCD_Screens : uint8_t; - -class DGUSScreenHandler { -public: - DGUSScreenHandler() = default; - - static bool loop(); - - // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen - // The bools specifying whether the strings are in RAM or FLASH. - static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { - sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); - } - static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { - sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); - } - - static void HandleUserConfirmationPopUp(uint16_t ConfirmVP, const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); - - // "M117" Message -- msg is a RAM ptr. - static void setstatusmessage(const char *msg); - // The same for messages from Flash - static void setstatusmessagePGM(PGM_P const msg); - // Callback for VP "Display wants to change screen on idle printer" - static void ScreenChangeHookIfIdle(DGUS_VP_Variable &var, void *val_ptr); - // Callback for VP "Screen has been changed" - static void ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr); - - // Callback for VP "All Heaters Off" - static void HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr); - // Hook for "Change this temperature" - static void HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr); - // Hook for "Change Flowrate" - static void HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr); - #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) - // Hook for manual move option - static void HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr); - #endif - - // Hook for manual move. - static void HandleManualMove(DGUS_VP_Variable &var, void *val_ptr); - // Hook for manual extrude. - static void HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr); - // Hook for motor lock and unlook - static void HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr); - #if ENABLED(POWER_LOSS_RECOVERY) - // Hook for power loss recovery. - static void HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr); - #endif - // Hook for settings - static void HandleSettings(DGUS_VP_Variable &var, void *val_ptr); - static void HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr); - static void HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr); - - #if HAS_PID_HEATING - // Hook for "Change this temperature PID para" - static void HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr); - // Hook for PID autotune - static void HandlePIDAutotune(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if HAS_BED_PROBE - // Hook for "Change probe offset z" - static void HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if ENABLED(BABYSTEPPING) - // Hook for live z adjust action - static void HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if HAS_FAN - // Hook for fan control - static void HandleFanControl(DGUS_VP_Variable &var, void *val_ptr); - #endif - // Hook for heater control - static void HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr); - #if ENABLED(DGUS_PREHEAT_UI) - // Hook for preheat - static void HandlePreheat(DGUS_VP_Variable &var, void *val_ptr); - #endif - #if ENABLED(DGUS_FILAMENT_LOADUNLOAD) - // Hook for filament load and unload filament option - static void HandleFilamentOption(DGUS_VP_Variable &var, void *val_ptr); - // Hook for filament load and unload - static void HandleFilamentLoadUnload(DGUS_VP_Variable &var); - #endif - - #if ENABLED(SDSUPPORT) - // Callback for VP "Display wants to change screen when there is a SD card" - static void ScreenChangeHookIfSD(DGUS_VP_Variable &var, void *val_ptr); - // Scroll buttons on the file listing screen. - static void DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable &var, void *val_ptr); - // File touched. - static void DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr); - // start print after confirmation received. - static void DGUSLCD_SD_StartPrint(DGUS_VP_Variable &var, void *val_ptr); - // User hit the pause, resume or abort button. - static void DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr); - // User confirmed the abort action - static void DGUSLCD_SD_ReallyAbort(DGUS_VP_Variable &var, void *val_ptr); - // User hit the tune button - static void DGUSLCD_SD_PrintTune(DGUS_VP_Variable &var, void *val_ptr); - // Send a single filename to the display. - static void DGUSLCD_SD_SendFilename(DGUS_VP_Variable &var); - // Marlin informed us that a new SD has been inserted. - static void SDCardInserted(); - // Marlin informed us that the SD Card has been removed(). - static void SDCardRemoved(); - // Marlin informed us about a bad SD Card. - static void SDCardError(); - #endif - - // OK Button the Confirm screen. - static void ScreenConfirmedOK(DGUS_VP_Variable &var, void *val_ptr); - - // Update data after went to new screen (by display or by GotoScreen) - // remember: store the last-displayed screen, so it can get returned to. - // (e.g for pop up messages) - static void UpdateNewScreen(DGUSLCD_Screens newscreen, bool popup=false); - - // Recall the remembered screen. - static void PopToOldScreen(); - - // Make the display show the screen and update all VPs in it. - static void GotoScreen(DGUSLCD_Screens screen, bool ispopup = false); - - static void UpdateScreenVPData(); - - // Helpers to convert and transfer data to the display. - static void DGUSLCD_SendWordValueToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendStringToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var); - static void DGUSLCD_SendTemperaturePID(DGUS_VP_Variable &var); - static void DGUSLCD_SendPercentageToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendPrintProgressToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var); - - #if ENABLED(PRINTCOUNTER) - static void DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var); - static void DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var); - #endif - #if HAS_FAN - static void DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var); - #endif - static void DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var); - #if ENABLED(DGUS_UI_WAITING) - static void DGUSLCD_SendWaitingStatusToDisplay(DGUS_VP_Variable &var); - #endif - - // Send a value from 0..100 to a variable with a range from 0..255 - static void DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr); - - template - static void DGUSLCD_SetValueDirectly(DGUS_VP_Variable &var, void *val_ptr) { - if (!var.memadr) return; - union { unsigned char tmp[sizeof(T)]; T t; } x; - unsigned char *ptr = (unsigned char*)val_ptr; - LOOP_L_N(i, sizeof(T)) x.tmp[i] = ptr[sizeof(T) - i - 1]; - *(T*)var.memadr = x.t; - } - - // Send a float value to the display. - // Display will get a 4-byte integer scaled to the number of digits: - // Tell the display the number of digits and it cheats by displaying a dot between... - template - static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) { - if (var.memadr) { - float f = *(float *)var.memadr; - f *= cpow(10, decimals); - dgusdisplay.WriteVariable(var.VP, (long)f); - } - } - - // Send a float value to the display. - // Display will get a 2-byte integer scaled to the number of digits: - // Tell the display the number of digits and it cheats by displaying a dot between... - template - static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) { - if (var.memadr) { - float f = *(float *)var.memadr; - DEBUG_ECHOLNPAIR_F(" >> ", f, 6); - f *= cpow(10, decimals); - dgusdisplay.WriteVariable(var.VP, (int16_t)f); - } - } - - // Force an update of all VP on the current screen. - static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } - // Has all VPs sent to the screen - static inline bool IsScreenComplete() { return ScreenComplete; } - - static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; } - - static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } - -private: - static DGUSLCD_Screens current_screen; //< currently on screen - static constexpr uint8_t NUM_PAST_SCREENS = 4; - static DGUSLCD_Screens past_screens[NUM_PAST_SCREENS]; //< LIFO with past screens for the "back" button. - - static uint8_t update_ptr; //< Last sent entry in the VPList for the actual screen. - static uint16_t skipVP; //< When updating the screen data, skip this one, because the user is interacting with it. - static bool ScreenComplete; //< All VPs sent to screen? - - static uint16_t ConfirmVP; //< context for confirm screen (VP that will be emulated-sent on "OK"). - - #if ENABLED(SDSUPPORT) - static int16_t top_file; //< file on top of file chooser - static int16_t file_to_print; //< touched file to be confirmed - #endif - - static void (*confirm_action_cb)(); -}; +typedef DGUSScreenHandler DGUSScreenHandlerClass; #if ENABLED(POWER_LOSS_RECOVERY) #define PLR_SCREEN_RECOVER DGUSLCD_SCREEN_SDPRINTMANIPULATION diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.cpp index 1d97902c7171..15b3f5adcde4 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.cpp @@ -57,7 +57,7 @@ void DGUSDisplay::Loop() { void DGUSDisplay::Init() { LCD_SERIAL.begin(LCD_BAUDRATE); - Read(DGUS_VERSION, 1); + ReadVersions(); } void DGUSDisplay::Read(uint16_t addr, uint8_t size) { @@ -158,6 +158,11 @@ void DGUSDisplay::WriteStringPGM(uint16_t addr, const void* data_ptr, uint8_t si } } +void DGUSDisplay::ReadVersions() { + if (gui_version != 0 && os_version != 0) return; + Read(DGUS_VERSION, 1); +} + void DGUSDisplay::SwitchScreen(DGUS_Screen screen) { DEBUG_ECHOLNPGM("SwitchScreen ", (uint8_t)screen); const uint8_t command[] = { 0x5A, 0x01, 0x00, (uint8_t)screen }; @@ -313,7 +318,7 @@ void DGUSDisplay::ProcessRx() { gcode.reset_stepper_timeout(); if (!vp.size) { - DEBUG_ECHOLN(); + DEBUG_EOL(); vp.rx_handler(vp, nullptr); rx_datagram_state = DGUS_IDLE; @@ -325,18 +330,15 @@ void DGUSDisplay::ProcessRx() { memset(buffer, 0, vp.size); for (uint8_t i = 0; i < dlen; i++) { - if (i >= vp.size) { - break; - } + if (i >= vp.size) break; - if (i + 1 < dlen && tmp[i + 3] == 0xFF && tmp[i + 4] == 0xFF) { + if (i + 1 < dlen && tmp[i + 3] == 0xFF && tmp[i + 4] == 0xFF) break; - } buffer[i] = tmp[i + 3]; } - DEBUG_ECHOLN(); + DEBUG_EOL(); vp.rx_handler(vp, buffer); rx_datagram_state = DGUS_IDLE; @@ -349,7 +351,7 @@ void DGUSDisplay::ProcessRx() { break; } - DEBUG_ECHOLN(); + DEBUG_EOL(); vp.rx_handler(vp, &tmp[3]); rx_datagram_state = DGUS_IDLE; diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h b/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h index 265e2fe584bd..fa5bf3039696 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h @@ -69,6 +69,9 @@ class DGUSDisplay { // Until now I did not need to actively read from the display. That's why there is no ReadVariable // (I extensively use the auto upload of the display) + // Read GUI and OS version from screen + static void ReadVersions(); + // Force display into another screen. static void SwitchScreen(DGUS_Screen screen); // Play sounds using the display speaker. @@ -98,7 +101,7 @@ class DGUSDisplay { // Checks two things: Can we confirm the presence of the display and has we initialized it. // (both boils down that the display answered to our chatting) - static inline bool IsInitialized() { + static bool IsInitialized() { return initialized; } diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp index cf95bb1d761d..88fe30a0273f 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp @@ -47,9 +47,7 @@ void DGUSRxHandler::ScreenChange(DGUS_VP &vp, void *data_ptr) { if (vp.addr == DGUS_Addr::SCREENCHANGE_SD) { #if ENABLED(SDSUPPORT) - #if !PIN_EXISTS(SD_DETECT) - card.mount(); - #endif + IF_DISABLED(HAS_SD_DETECT, card.mount()); if (!ExtUI::isMediaInserted()) { dgus_screen_handler.SetStatusMessage(GET_TEXT_F(MSG_NO_MEDIA)); @@ -466,7 +464,7 @@ void DGUSRxHandler::MoveToPoint(DGUS_VP &vp, void *data_ptr) { } const uint8_t point = ((uint8_t*)data_ptr)[1]; - constexpr float lfrb[4] = LEVEL_CORNERS_INSET_LFRB; + constexpr float lfrb[4] = BED_TRAMMING_INSET_LFRB; float x, y; switch (point) { @@ -493,12 +491,12 @@ void DGUSRxHandler::MoveToPoint(DGUS_VP &vp, void *data_ptr) { break; } - if (ExtUI::getAxisPosition_mm(ExtUI::Z) < Z_MIN_POS + LEVEL_CORNERS_Z_HOP) { - ExtUI::setAxisPosition_mm(Z_MIN_POS + LEVEL_CORNERS_Z_HOP, ExtUI::Z); + if (ExtUI::getAxisPosition_mm(ExtUI::Z) < Z_MIN_POS + BED_TRAMMING_Z_HOP) { + ExtUI::setAxisPosition_mm(Z_MIN_POS + BED_TRAMMING_Z_HOP, ExtUI::Z); } ExtUI::setAxisPosition_mm(x, ExtUI::X); ExtUI::setAxisPosition_mm(y, ExtUI::Y); - ExtUI::setAxisPosition_mm(Z_MIN_POS + LEVEL_CORNERS_HEIGHT, ExtUI::Z); + ExtUI::setAxisPosition_mm(Z_MIN_POS + BED_TRAMMING_HEIGHT, ExtUI::Z); } void DGUSRxHandler::Probe(DGUS_VP &vp, void *data_ptr) { diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp index 17e7a3844592..0b584fac3bce 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.cpp @@ -100,37 +100,37 @@ void DGUSScreenHandler::Loop() { if (new_screen != DGUS_Screen::BOOT) { const DGUS_Screen screen = new_screen; new_screen = DGUS_Screen::BOOT; - - if (current_screen == screen) { + if (current_screen == screen) TriggerFullUpdate(); - } - else { + else MoveToScreen(screen); - } return; } if (!booted && ELAPSED(ms, 3000)) { booted = true; - if (current_screen == DGUS_Screen::BOOT) { + dgus_display.ReadVersions(); + + if (current_screen == DGUS_Screen::BOOT) MoveToScreen(DGUS_Screen::HOME); - } + return; } if (ELAPSED(ms, next_event_ms) || full_update) { next_event_ms = ms + DGUS_UPDATE_INTERVAL_MS; - if (!SendScreenVPData(current_screen, full_update)) { + if (!SendScreenVPData(current_screen, full_update)) DEBUG_ECHOLNPGM("SendScreenVPData failed"); - } + return; } if (current_screen == DGUS_Screen::WAIT && ((wait_continue && !wait_for_user) - || (!wait_continue && IsPrinterIdle()))) { + || (!wait_continue && IsPrinterIdle())) + ) { MoveToScreen(wait_return_screen, true); return; } @@ -151,7 +151,6 @@ void DGUSScreenHandler::Loop() { if (eeprom_save > 0 && ELAPSED(ms, eeprom_save) && IsPrinterIdle()) { eeprom_save = 0; - queue.enqueue_now_P(DGUS_CMD_EEPROM_SAVE); return; } @@ -187,7 +186,6 @@ void DGUSScreenHandler::SettingsReset() { if (!settings_ready) { settings_ready = true; - Ready(); } @@ -202,7 +200,7 @@ void DGUSScreenHandler::StoreSettings(char *buff) { data.initialized = true; data.volume = dgus_display.GetVolume(); data.brightness = dgus_display.GetBrightness(); - data.abl = (ExtUI::getLevelingActive() && ExtUI::getMeshValid()); + data.abl_okay = (ExtUI::getLevelingActive() && ExtUI::getMeshValid()); memcpy(buff, &data, sizeof(data)); } @@ -218,16 +216,14 @@ void DGUSScreenHandler::LoadSettings(const char *buff) { dgus_display.SetBrightness(data.initialized ? data.brightness : DGUS_DEFAULT_BRIGHTNESS); if (data.initialized) { - leveling_active = (data.abl && ExtUI::getMeshValid()); - + leveling_active = (data.abl_okay && ExtUI::getMeshValid()); ExtUI::setLevelingActive(leveling_active); } } void DGUSScreenHandler::ConfigurationStoreWritten(bool success) { - if (!success) { + if (!success) SetStatusMessage(F("EEPROM write failed")); - } } void DGUSScreenHandler::ConfigurationStoreRead(bool success) { @@ -236,7 +232,6 @@ void DGUSScreenHandler::ConfigurationStoreRead(bool success) { } else if (!settings_ready) { settings_ready = true; - Ready(); } } @@ -245,33 +240,25 @@ void DGUSScreenHandler::PlayTone(const uint16_t frequency, const uint16_t durati UNUSED(duration); if (frequency >= 1 && frequency <= 255) { - if (duration >= 1 && duration <= 255) { + if (duration >= 1 && duration <= 255) dgus_display.PlaySound((uint8_t)frequency, (uint8_t)duration); - } - else { + else dgus_display.PlaySound((uint8_t)frequency); - } } } void DGUSScreenHandler::MeshUpdate(const int8_t xpos, const int8_t ypos) { if (current_screen != DGUS_Screen::LEVELING_PROBING) { - if (current_screen == DGUS_Screen::LEVELING_AUTOMATIC) { + if (current_screen == DGUS_Screen::LEVELING_AUTOMATIC) TriggerFullUpdate(); - } - return; } uint8_t point = ypos * GRID_MAX_POINTS_X + xpos; probing_icons[point < 16 ? 0 : 1] |= (1U << (point % 16)); - if (xpos >= GRID_MAX_POINTS_X - 1 - && ypos >= GRID_MAX_POINTS_Y - 1 - && !ExtUI::getMeshValid()) { - probing_icons[0] = 0; - probing_icons[1] = 0; - } + if (xpos >= GRID_MAX_POINTS_X - 1 && ypos >= GRID_MAX_POINTS_Y - 1 && !ExtUI::getMeshValid()) + probing_icons[0] = probing_icons[1] = 0; TriggerFullUpdate(); } @@ -282,15 +269,12 @@ void DGUSScreenHandler::PrintTimerStarted() { void DGUSScreenHandler::PrintTimerPaused() { dgus_display.PlaySound(3); - TriggerFullUpdate(); } void DGUSScreenHandler::PrintTimerStopped() { - if (current_screen != DGUS_Screen::PRINT_STATUS - && current_screen != DGUS_Screen::PRINT_ADJUST) { + if (current_screen != DGUS_Screen::PRINT_STATUS && current_screen != DGUS_Screen::PRINT_ADJUST) return; - } dgus_display.PlaySound(3); @@ -309,23 +293,19 @@ void DGUSScreenHandler::FilamentRunout(const ExtUI::extruder_t extruder) { #if ENABLED(SDSUPPORT) void DGUSScreenHandler::SDCardInserted() { - if (current_screen == DGUS_Screen::HOME) { + if (current_screen == DGUS_Screen::HOME) TriggerScreenChange(DGUS_Screen::PRINT); - } } void DGUSScreenHandler::SDCardRemoved() { - if (current_screen == DGUS_Screen::PRINT) { + if (current_screen == DGUS_Screen::PRINT) TriggerScreenChange(DGUS_Screen::HOME); - } } void DGUSScreenHandler::SDCardError() { SetStatusMessage(GET_TEXT_F(MSG_MEDIA_READ_ERROR)); - - if (current_screen == DGUS_Screen::PRINT) { + if (current_screen == DGUS_Screen::PRINT) TriggerScreenChange(DGUS_Screen::HOME); - } } #endif // SDSUPPORT diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h index 509d59920066..cc59bda6d7fa 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSScreenHandler.h @@ -134,7 +134,7 @@ class DGUSScreenHandler { bool initialized; uint8_t volume; uint8_t brightness; - bool abl; + bool abl_okay; } eeprom_data_t; }; diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp index 8d5703876564..8d48037613ff 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp @@ -341,8 +341,8 @@ void DGUSTxHandler::ABLGrid(DGUS_VP &vp) { int16_t fixed; for (int i = 0; i < DGUS_LEVEL_GRID_SIZE; i++) { - point.x = i % GRID_MAX_POINTS_X; - point.y = i / GRID_MAX_POINTS_X; + point.x = i % (GRID_MAX_POINTS_X); + point.y = i / (GRID_MAX_POINTS_X); fixed = dgus_display.ToFixedPoint(ExtUI::getMeshPoint(point)); data[i] = Swap16(fixed); } diff --git a/Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Constants.h b/Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Constants.h index 9b275fb2f550..846fd1594216 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Constants.h +++ b/Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Constants.h @@ -71,15 +71,15 @@ static_assert((DGUS_LEVEL_GRID_SIZE == GRID_MAX_POINTS_X * GRID_MAX_POINTS_Y), " #define DGUS_DEFAULT_FILAMENT_LEN 10 #endif -#ifndef LEVEL_CORNERS_Z_HOP - #define LEVEL_CORNERS_Z_HOP 4.0 +#ifndef BED_TRAMMING_Z_HOP + #define BED_TRAMMING_Z_HOP 4.0 #endif -#ifndef LEVEL_CORNERS_HEIGHT - #define LEVEL_CORNERS_HEIGHT 0.0 +#ifndef BED_TRAMMING_HEIGHT + #define BED_TRAMMING_HEIGHT 0.0 #endif -static_assert(LEVEL_CORNERS_Z_HOP >= 0, "LEVEL_CORNERS_Z_HOP must be >= 0. Please update your configuration."); +static_assert(BED_TRAMMING_Z_HOP >= 0, "BED_TRAMMING_Z_HOP must be >= 0. Please update your configuration."); #ifndef DGUS_LEVEL_CENTER_X #define DGUS_LEVEL_CENTER_X ((X_BED_SIZE) / 2) diff --git a/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp b/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp index 61b072a3f783..f6f2c0f89df9 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/dgus_reloaded_extui.cpp @@ -83,8 +83,8 @@ namespace ExtUI { } void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} + void onPrintDone() {} void onFactoryReset() { dgus_screen_handler.SettingsReset(); @@ -100,16 +100,17 @@ namespace ExtUI { void onPostprocessSettings() {} - void onConfigurationStoreWritten(bool success) { + void onSettingsStored(bool success) { dgus_screen_handler.ConfigurationStoreWritten(success); } - void onConfigurationStoreRead(bool success) { + void onSettingsLoaded(bool success) { dgus_screen_handler.ConfigurationStoreRead(success); } #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { dgus_screen_handler.MeshUpdate(xpos, ypos); diff --git a/Marlin/src/lcd/extui/example/example.cpp b/Marlin/src/lcd/extui/example/example.cpp index 8f38d2aba6d8..6ef20cf5f0f3 100644 --- a/Marlin/src/lcd/extui/example/example.cpp +++ b/Marlin/src/lcd/extui/example/example.cpp @@ -59,8 +59,8 @@ namespace ExtUI { void onStatusChanged(const char * const msg) {} void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} + void onPrintDone() {} void onFactoryReset() {} @@ -88,18 +88,19 @@ namespace ExtUI { // Called after loading or resetting stored settings } - void onConfigurationStoreWritten(bool success) { + void onSettingsStored(bool success) { // Called after the entire EEPROM has been written, // whether successful or not. } - void onConfigurationStoreRead(bool success) { + void onSettingsLoaded(bool success) { // Called after the entire EEPROM has been read, // whether successful or not. } #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) { // Called when any mesh points are updated diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp index 8b0c0f877c2b..a23ad6e37e76 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/archim2-flash/flash_storage.cpp @@ -178,9 +178,9 @@ bool UIFlashStorage::is_present = false; if (!is_known) { SERIAL_ECHO_MSG("Unable to locate supported SPI Flash Memory."); - SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(" Manufacturer ID, got: ", manufacturer_id); - SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(" Device Type , got: ", device_type); - SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(" Capacity , got: ", capacity); + SERIAL_ECHO_MSG(" Manufacturer ID, got: ", manufacturer_id); + SERIAL_ECHO_MSG(" Device Type , got: ", device_type); + SERIAL_ECHO_MSG(" Capacity , got: ", capacity); } return is_known; @@ -247,7 +247,7 @@ bool UIFlashStorage::is_present = false; case 0xFFFFFFFFul: return read_offset; case delimiter: read_offset = offset; break; default: - SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("Invalid delimiter in Flash: ", delim); + SERIAL_ECHO_MSG("Invalid delimiter in Flash: ", delim); return -1; } } @@ -325,8 +325,7 @@ bool UIFlashStorage::is_present = false; } SERIAL_ECHO_START(); - SERIAL_ECHOPGM("Writing UI settings to SPI Flash (offset ", write_addr); - SERIAL_ECHOPGM(")..."); + SERIAL_ECHOPGM("Writing UI settings to SPI Flash (offset ", write_addr, ")..."); const uint32_t delim = delimiter; write_addr = write(write_addr, &delim, sizeof(delim)); @@ -421,7 +420,7 @@ bool UIFlashStorage::is_present = false; uint32_t addr; uint8_t buff[write_page_size]; - strcpy_P( (char*) buff, (const char*) filename); + strcpy_P((char*)buff, FTOP(filename)); MediaFileReader reader; if (!reader.open((char*) buff)) { @@ -509,7 +508,7 @@ bool UIFlashStorage::is_present = false; bytes_remaining = get_media_file_size(slot); if (bytes_remaining != 0xFFFFFFFFUL) { - SERIAL_ECHO_START(); SERIAL_ECHOLNPGM("Boot media file size:", bytes_remaining); + SERIAL_ECHO_MSG("Boot media file size:", bytes_remaining); addr = get_media_file_start(slot); return true; } 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 40ec16a9dfe6..e3b95c4cd490 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 @@ -1,6 +1,6 @@ -/***************************** - * bio_advanced_settings.cpp * - *****************************/ +/************************* + * advanced_settings.cpp * + *************************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * @@ -28,6 +28,9 @@ using namespace FTDI; using namespace Theme; +#define GRID_COLS 2 +#define GRID_ROWS 9 + void AdvancedSettingsMenu::onRedraw(draw_mode_t what) { if (what & BACKGROUND) { CommandProcessor cmd; @@ -38,58 +41,30 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) { if (what & FOREGROUND) { CommandProcessor cmd; cmd.colors(normal_btn) - .font(Theme::font_medium) - #define GRID_ROWS 9 - #define GRID_COLS 2 + .font(Theme::font_medium) .tag(2) .button(BTN_POS(1,1), BTN_SIZE(1,1), GET_TEXT_F(MSG_DISPLAY_MENU)) - .enabled( - #if HAS_TRINAMIC_CONFIG - 1 - #endif - ) + .enabled(ENABLED(HAS_TRINAMIC_CONFIG)) .tag(3) .button(BTN_POS(1,2), BTN_SIZE(1,1), GET_TEXT_F(MSG_TMC_CURRENT)) - .enabled( - #if HAS_TRINAMIC_CONFIG - 1 - #endif - ) + .enabled(ENABLED(HAS_TRINAMIC_CONFIG)) .tag(4) .button(BTN_POS(1,3), BTN_SIZE(1,1), GET_TEXT_F(MSG_TMC_HOMING_THRS)) .tag(5) .button(BTN_POS(1,4), BTN_SIZE(1,1), GET_TEXT_F(MSG_LCD_ENDSTOPS)) - .enabled( - #if HAS_MULTI_HOTEND - 1 - #endif - ) + .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_VELOCITY)) + .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)) - #if HAS_JUNCTION_DEVIATION - .tag(10) .button(BTN_POS(2,4), BTN_SIZE(1,1), GET_TEXT_F(MSG_JUNCTION_DEVIATION)) - #else - .tag(10) .button(BTN_POS(2,4), BTN_SIZE(1,1), GET_TEXT_F(MSG_JERK)) - #endif - .enabled( - #if ENABLED(BACKLASH_GCODE) - 1 - #endif - ) + .tag(10) .button(BTN_POS(2,4), BTN_SIZE(1,1), GET_TEXT_F(TERN(HAS_JUNCTION_DEVIATION, MSG_JUNCTION_DEVIATION, MSG_JERK))) + .enabled(ENABLED(BACKLASH_GCODE)) .tag(11) .button(BTN_POS(2,5), BTN_SIZE(1,1), GET_TEXT_F(MSG_BACKLASH)) - .enabled( - #if ENABLED(LIN_ADVANCE) - 1 - #endif - ) + .enabled(ENABLED(LIN_ADVANCE)) .tag(12) .button(BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXT_F(MSG_LINEAR_ADVANCE)) .tag(13) .button(BTN_POS(1,7), BTN_SIZE(2,1), GET_TEXT_F(MSG_INTERFACE)) .tag(14) .button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_RESTORE_DEFAULTS)) - .colors(action_btn) - .tag(1). button( BTN_POS(1,9), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_DONE)); - #undef GRID_COLS - #undef GRID_ROWS + .colors(action_btn) + .tag(1) .button( BTN_POS(1,9), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_DONE)); } } @@ -100,35 +75,26 @@ bool AdvancedSettingsMenu::onTouchEnd(uint8_t tag) { case 1: SaveSettingsDialogBox::promptToSaveSettings(); break; case 2: GOTO_SCREEN(DisplayTuningScreen); break; #if HAS_TRINAMIC_CONFIG - case 3: GOTO_SCREEN(StepperCurrentScreen); break; - case 4: GOTO_SCREEN(StepperBumpSensitivityScreen); break; + case 3: GOTO_SCREEN(StepperCurrentScreen); break; + case 4: GOTO_SCREEN(StepperBumpSensitivityScreen); break; #endif case 5: GOTO_SCREEN(EndstopStatesScreen); break; #if HAS_MULTI_HOTEND - case 6: GOTO_SCREEN(NozzleOffsetScreen); break; + case 6: GOTO_SCREEN(NozzleOffsetScreen); break; #endif - case 7: GOTO_SCREEN(StepsScreen); break; case 8: GOTO_SCREEN(MaxVelocityScreen); break; case 9: GOTO_SCREEN(DefaultAccelerationScreen); break; - case 10: - #if HAS_JUNCTION_DEVIATION - GOTO_SCREEN(JunctionDeviationScreen); - #else - GOTO_SCREEN(JerkScreen); - #endif - break; + case 10: GOTO_SCREEN(TERN(HAS_JUNCTION_DEVIATION, JunctionDeviationScreen, JerkScreen)); break; #if ENABLED(BACKLASH_GCODE) - case 11: GOTO_SCREEN(BacklashCompensationScreen); break; + case 11: GOTO_SCREEN(BacklashCompensationScreen); break; #endif #if ENABLED(LIN_ADVANCE) - case 12: GOTO_SCREEN(LinearAdvanceScreen); break; + case 12: GOTO_SCREEN(LinearAdvanceScreen); break; #endif case 13: GOTO_SCREEN(InterfaceSettingsScreen); break; case 14: GOTO_SCREEN(RestoreFailsafeDialogBox); break; - - default: - return false; + default: return false; } return true; } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.h index 29a21fe5d992..fc30093b762f 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/advanced_settings.h @@ -1,6 +1,6 @@ -/*************************** - * bio_advanced_settings.h * - ***************************/ +/*********************** + * advanced_settings.h * + ***********************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_e.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_e.cpp index a5511f94b9eb..b614eada07e1 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_e.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_e.cpp @@ -1,6 +1,6 @@ -/**************************** - * bio_confirm_home_xyz.cpp * - ****************************/ +/************************ + * confirm_home_xyz.cpp * + ************************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_e.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_e.h index 151b784b935b..34895c9d017d 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_e.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_e.h @@ -1,6 +1,6 @@ -/**************************** - * bio_confirm_home_e.h * - ****************************/ +/******************** + * confirm_home_e.h * + ********************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_xyz.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_xyz.cpp index e34df42b84d3..8aab34002105 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_xyz.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_xyz.cpp @@ -1,6 +1,6 @@ -/**************************** - * bio_confirm_home_xyz.cpp * - ****************************/ +/************************ + * confirm_home_xyz.cpp * + ************************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_xyz.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_xyz.h index d8cb1cdb6742..1c1aa369e875 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_xyz.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/confirm_home_xyz.h @@ -1,6 +1,6 @@ -/************************** - * bio_confirm_home_xyz.h * - **************************/ +/********************** + * confirm_home_xyz.h * + **********************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/main_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/main_menu.cpp index adc84dfa25ff..edae2cb04295 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/main_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/main_menu.cpp @@ -1,6 +1,6 @@ -/********************* - * bio_main_menu.cpp * - *********************/ +/***************** + * main_menu.cpp * + *****************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * @@ -28,9 +28,10 @@ using namespace FTDI; using namespace Theme; +#define GRID_COLS 2 +#define GRID_ROWS 10 + void MainMenu::onRedraw(draw_mode_t what) { - #define GRID_ROWS 10 - #define GRID_COLS 2 if (what & BACKGROUND) { CommandProcessor cmd; @@ -56,9 +57,6 @@ void MainMenu::onRedraw(draw_mode_t what) { .colors(action_btn) .tag(1).button(BTN_POS(1,10), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_DONE)); } - - #undef GRID_COLS - #undef GRID_ROWS } bool MainMenu::onTouchEnd(uint8_t tag) { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/main_menu.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/main_menu.h index fdf977fcbfd9..37bbe3dd5e66 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/main_menu.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/main_menu.h @@ -1,6 +1,6 @@ -/********************* - * bio_main_menu.cpp * - *********************/ +/***************** + * main_menu.cpp * + *****************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.cpp index f0c0a59d3658..79a49c79a631 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.cpp @@ -1,6 +1,6 @@ -/******************************* - * bio_printing_dialog_box.cpp * - *******************************/ +/*************************** + * printing_dialog_box.cpp * + ***************************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * @@ -106,8 +106,8 @@ bool BioPrintingDialogBox::onTouchEnd(uint8_t tag) { } void BioPrintingDialogBox::setStatusMessage(FSTR_P message) { - char buff[strlen_P((const char*)message)+1]; - strcpy_P(buff, (const char*) message); + char buff[strlen_P(FTOP(message)) + 1]; + strcpy_P(buff, FTOP(message)); setStatusMessage(buff); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.h index b55038bef282..f260b7441354 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/printing_dialog_box.h @@ -1,6 +1,6 @@ -/***************************** - * bio_printing_dialog_box.h * - *****************************/ +/************************* + * printing_dialog_box.h * + *************************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/screens.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/screens.h index 7294c4aa0b10..81d47179f4f6 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/screens.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/screens.h @@ -96,10 +96,10 @@ enum { #include "../generic/z_offset_screen.h" #include "../generic/files_screen.h" -#include "bio_status_screen.h" -#include "bio_main_menu.h" -#include "bio_tune_menu.h" -#include "bio_advanced_settings.h" -#include "bio_printing_dialog_box.h" -#include "bio_confirm_home_xyz.h" -#include "bio_confirm_home_e.h" +#include "status_screen.h" +#include "main_menu.h" +#include "tune_menu.h" +#include "advanced_settings.h" +#include "printing_dialog_box.h" +#include "confirm_home_xyz.h" +#include "confirm_home_e.h" diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.cpp index 6e4668eb36f5..a6674bed90b6 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.cpp @@ -1,6 +1,6 @@ -/************************* - * bio_status_screen.cpp * - *************************/ +/********************* + * status_screen.cpp * + *********************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.h index 458ddd19a0bd..d074e82de6da 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/status_screen.h @@ -1,6 +1,6 @@ -/************************* - * bio_status_screen.cpp * - *************************/ +/********************* + * status_screen.cpp * + *********************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/tune_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/tune_menu.cpp index 48eff0a66149..d5b3897c4d2d 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/tune_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/tune_menu.cpp @@ -1,6 +1,6 @@ -/********************* - * bio_tune_menu.cpp * - *********************/ +/***************** + * tune_menu.cpp * + *****************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * @@ -29,10 +29,10 @@ using namespace FTDI; using namespace Theme; using namespace ExtUI; -void TuneMenu::onRedraw(draw_mode_t what) { - #define GRID_ROWS 8 - #define GRID_COLS 2 +#define GRID_COLS 2 +#define GRID_ROWS 8 +void TuneMenu::onRedraw(draw_mode_t what) { if (what & BACKGROUND) { CommandProcessor cmd; cmd.cmd(CLEAR_COLOR_RGB(bg_color)) @@ -56,8 +56,6 @@ void TuneMenu::onRedraw(draw_mode_t what) { .enabled(!isPrinting()).tag(7).button(BTN_POS(1,7), BTN_SIZE(2,1), GET_TEXT_F(MSG_RELEASE_XY_AXIS)) .colors(action_btn) .tag(1).button(BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXT_F(MSG_BUTTON_DONE)); } - #undef GRID_COLS - #undef GRID_ROWS } bool TuneMenu::onTouchEnd(uint8_t tag) { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/tune_menu.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/tune_menu.h index 52fe694f37bb..8677bb5e2d56 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/tune_menu.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/tune_menu.h @@ -1,6 +1,6 @@ -/******************* - * bio_tune_menu.h * - *******************/ +/*************** + * tune_menu.h * + ***************/ /**************************************************************************** * Written By Mark Pelletier 2017 - Aleph Objects, Inc. * diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/ui_landscape.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/ui_landscape.h index 754f6e93e11d..dc70f6c0fc18 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/ui_landscape.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/ui_landscape.h @@ -1,3 +1,6 @@ +/****************** + * ui_landscape.h * + ******************/ /**************************************************************************** * This program is free software: you can redistribute it and/or modify * diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/ui_portrait.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/ui_portrait.h index e8b42811224f..7aaf62b7b8cb 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/ui_portrait.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/bioprinter/ui_portrait.h @@ -1,3 +1,6 @@ +/***************** + * ui_portrait.h * + *****************/ /**************************************************************************** * This program is free software: you can redistribute it and/or modify * 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 7549e8d54e93..00cdf76331d6 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 @@ -29,8 +29,8 @@ using namespace FTDI; using namespace ExtUI; using namespace Theme; -#define GRID_ROWS 4 #define GRID_COLS 3 +#define GRID_ROWS 4 #define STEPS_PER_MM_POS BTN_POS(1,1), BTN_SIZE(1,1) #define TMC_CURRENT_POS BTN_POS(2,1), BTN_SIZE(1,1) #define LIN_ADVANCE_POS BTN_POS(3,1), BTN_SIZE(1,1) @@ -53,20 +53,20 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) { if (what & FOREGROUND) { CommandProcessor cmd; cmd.colors(normal_btn) - .font(Theme::font_medium) + .font(Theme::font_medium) .tag(2) .button(STEPS_PER_MM_POS, GET_TEXT_F(MSG_STEPS_PER_MM)) - .enabled(ENABLED(HAS_TRINAMIC_CONFIG)) + .enabled(ENABLED(HAS_TRINAMIC_CONFIG)) .tag(3) .button(TMC_CURRENT_POS, GET_TEXT_F(MSG_TMC_CURRENT)) - .enabled(ENABLED(LIN_ADVANCE)) + .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_VELOCITY)) + .tag(5) .button(VELOCITY_POS, GET_TEXT_F(MSG_MAX_SPEED)) .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)) .tag(9) .button(INTERFACE_POS, GET_TEXT_F(MSG_INTERFACE)) .tag(10).button(DISPLAY_POS, GET_TEXT_F(MSG_DISPLAY_MENU)) .tag(11).button(RESTORE_DEFAULTS_POS, GET_TEXT_F(MSG_RESTORE_DEFAULTS)) - .colors(action_btn) + .colors(action_btn) .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE)); } } 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 5ea9eed0372f..5e61bdb12f18 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 @@ -33,8 +33,8 @@ using namespace FTDI; using namespace ExtUI; using namespace Theme; -#define GRID_ROWS 5 #define GRID_COLS 3 +#define GRID_ROWS 5 #define BED_MESH_TITLE_POS BTN_POS(1,1), BTN_SIZE(3,1) #define PROBE_BED_POS BTN_POS(1,2), BTN_SIZE(1,1) #define SHOW_MESH_POS BTN_POS(2,2), BTN_SIZE(1,1) @@ -60,9 +60,9 @@ void LevelingMenu::onRedraw(draw_mode_t what) { .text(BLTOUCH_TITLE_POS, GET_TEXT_F(MSG_BLTOUCH)) .font(font_medium).colors(normal_btn) .tag(2).button(PROBE_BED_POS, GET_TEXT_F(MSG_PROBE_BED)) - .enabled(ENABLED(HAS_MESH)) + .enabled(ENABLED(HAS_MESH)) .tag(3).button(SHOW_MESH_POS, GET_TEXT_F(MSG_MESH_VIEW)) - .enabled(ENABLED(HAS_MESH)) + .enabled(ENABLED(HAS_MESH)) .tag(4).button(EDIT_MESH_POS, GET_TEXT_F(MSG_EDIT_MESH)) #undef GRID_COLS #define GRID_COLS 2 diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/main_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/main_menu.cpp index 2d404aff6c98..ee299a7f64d6 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/main_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/main_menu.cpp @@ -29,8 +29,8 @@ using namespace FTDI; using namespace Theme; -#define GRID_ROWS 6 #define GRID_COLS 2 +#define GRID_ROWS 6 #define ZPROBE_ZOFFSET_POS BTN_POS(1,1), BTN_SIZE(1,1) #define MOVE_XYZ_POS BTN_POS(1,2), BTN_SIZE(1,1) @@ -57,14 +57,14 @@ void MainMenu::onRedraw(draw_mode_t what) { .font(Theme::font_medium) .tag( 2).button(MOVE_XYZ_POS, GET_TEXT_F(MSG_XYZ_MOVE)) .tag( 3).button(TEMPERATURE_POS, GET_TEXT_F(MSG_TEMPERATURE)) - .enabled(BOTH(HAS_LEVELING, HAS_BED_PROBE)) + .enabled(BOTH(HAS_LEVELING, HAS_BED_PROBE)) .tag( 4).button(ZPROBE_ZOFFSET_POS, GET_TEXT_F(MSG_ZPROBE_ZOFFSET)) .tag( 5).button(MOVE_E_POS, GET_TEXT_F(MSG_E_MOVE)) .tag( 6).button(SPEED_POS, GET_TEXT_F(MSG_PRINT_SPEED)) .tag( 7).button(FLOW_POS, GET_TEXT_F(MSG_FLOW)) .tag( 8).button(ADVANCED_SETTINGS_POS, GET_TEXT_F(MSG_ADVANCED_SETTINGS)) .tag( 9).button(DISABLE_STEPPERS_POS, GET_TEXT_F(MSG_DISABLE_STEPPERS)) - .enabled(HAS_LEVELING) + .enabled(ENABLED(HAS_LEVELING)) .tag(10).button(LEVELING_POS, GET_TEXT_F(MSG_LEVELING)) .tag(11).button(ABOUT_PRINTER_POS, GET_TEXT_F(MSG_INFO_MENU)) .colors(action_btn) 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 b5ce10810636..b01aa81dd441 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 @@ -28,8 +28,8 @@ using namespace FTDI; using namespace ExtUI; using namespace Theme; -#define GRID_ROWS 5 #define GRID_COLS 2 +#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)); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/compat.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/compat.h index 3b63b0fd5be6..afb380aa90ad 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/compat.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/compat.h @@ -43,8 +43,8 @@ #define min(a,b) ((a)<(b)?(a):(b)) #else namespace UI { - static inline uint32_t safe_millis() { return millis(); } - static inline void yield() {} + static uint32_t safe_millis() { return millis(); } + static void yield() {} }; #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp index f2ee1e5639e4..2ce9ed027e86 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_extui.cpp @@ -80,7 +80,7 @@ namespace ExtUI { } void onPrintTimerPaused() {} - void onPrintFinished() {} + void onPrintDone() {} void onFilamentRunout(const extruder_t extruder) { char lcd_msg[30]; @@ -90,14 +90,14 @@ namespace ExtUI { } void onHomingStart() {} - void onHomingComplete() {} + void onHomingDone() {} void onFactoryReset() { InterfaceSettingsScreen::defaultSettings(); } void onStoreSettings(char *buff) { InterfaceSettingsScreen::saveSettings(buff); } void onLoadSettings(const char *buff) { InterfaceSettingsScreen::loadSettings(buff); } void onPostprocessSettings() {} // Called after loading or resetting stored settings - void onConfigurationStoreWritten(bool success) { + void onSettingsStored(bool success) { #ifdef ARCHIM2_SPI_FLASH_EEPROM_BACKUP_SIZE if (success && InterfaceSettingsScreen::backupEEPROM()) { SERIAL_ECHOLNPGM("EEPROM backed up to SPI Flash"); @@ -106,7 +106,7 @@ namespace ExtUI { UNUSED(success); #endif } - void onConfigurationStoreRead(bool) {} + void onSettingsLoaded(bool) {} void onPlayTone(const uint16_t frequency, const uint16_t duration) { sound.play_tone(frequency, duration); } @@ -118,7 +118,8 @@ namespace ExtUI { } #if HAS_LEVELING && HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t x, const int8_t y, const_float_t val) { BedMeshViewScreen::onMeshUpdate(x, y, val); } void onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t state) { BedMeshViewScreen::onMeshUpdate(x, y, state); } #endif 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 8e788421ad25..a796c8edcf5f 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 @@ -1024,9 +1024,7 @@ template bool CLCD::CommandFifo::write(T data, uint16_t len) { uint16_t Command_Space = mem_read_32(REG::CMDB_SPACE) & 0x0FFF; if (Command_Space < (len + padding)) { #if ENABLED(TOUCH_UI_DEBUG) - SERIAL_ECHO_START(); - SERIAL_ECHOPGM("Waiting for ", len + padding); - SERIAL_ECHOLNPGM(" bytes in command queue, now free: ", Command_Space); + SERIAL_ECHO_MSG("Waiting for ", len + padding, " bytes in command queue, now free: ", Command_Space); #endif do { Command_Space = mem_read_32(REG::CMDB_SPACE) & 0x0FFF; 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 b8e687147ba9..da911c772daa 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 @@ -40,13 +40,13 @@ template struct port_pin { typedef port_t port; - static inline void set_high() {port::port() = (port::port() | bits);} - static inline void set_low() {port::port() = (port::port() & (~bits));} - static inline void set_input() {port::ddr() = (port::ddr() & (~bits));} - static inline void set_input_pullup() {set_input(); set_high();} - static inline void set_output() {port::ddr() = (port::ddr() | bits);} - static inline uint8_t read() {return port::pin() & bits;} - static inline void write(bool v) {if (v) set_high(); else set_low();} + static void set_high() {port::port() = (port::port() | bits);} + static void set_low() {port::port() = (port::port() & (~bits));} + static void set_input() {port::ddr() = (port::ddr() & (~bits));} + static void set_input_pullup() {set_input(); set_high();} + static void set_output() {port::ddr() = (port::ddr() | bits);} + static uint8_t read() {return port::pin() & bits;} + static void write(bool v) {if (v) set_high(); else set_low();} }; #define MAKE_AVR_PORT_PINS(ID) \ @@ -109,13 +109,13 @@ template struct arduino_digital_pin { static constexpr uint8_t pin = p; - static inline void set_high() {digitalWrite(p, HIGH);} - static inline void set_low() {digitalWrite(p, LOW);} - static inline void set_input() {pinMode(p, INPUT);} - static inline void set_input_pullup() {pinMode(p, INPUT_PULLUP);} - static inline void set_output() {pinMode(p, OUTPUT);} - static inline uint8_t read() {return digitalRead(p);} - static inline void write(bool v) {digitalWrite(p, v ? HIGH : LOW);} + static void set_high() {digitalWrite(p, HIGH);} + static void set_low() {digitalWrite(p, LOW);} + static void set_input() {pinMode(p, INPUT);} + static void set_input_pullup() {pinMode(p, INPUT_PULLUP);} + static void set_output() {pinMode(p, OUTPUT);} + static uint8_t read() {return digitalRead(p);} + static void write(bool v) {digitalWrite(p, v ? HIGH : LOW);} }; #define MAKE_ARDUINO_PINS(ID) typedef arduino_digital_pin ARDUINO_DIGITAL_##ID; 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 24e93982c22a..648ed5330a98 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 @@ -242,10 +242,10 @@ class CommandProcessor : public CLCD::CommandFifo { } CommandProcessor& toggle2(int16_t x, int16_t y, int16_t w, int16_t h, FSTR_P no, FSTR_P yes, bool state, uint16_t options = FTDI::OPT_3D) { - char text[strlen_P((const char *)no) + strlen_P((const char *)yes) + 2]; - strcpy_P(text, (const char *)no); + char text[strlen_P(FTOP(no)) + strlen_P(FTOP(yes)) + 2]; + strcpy_P(text, FTOP(no)); strcat(text, "\xFF"); - strcat_P(text, (const char *)yes); + strcat_P(text, FTOP(yes)); return toggle(x, y, w, h, text, state, options); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/dl_cache.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/dl_cache.cpp index 1ee73c140e3a..f947a352b1f1 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/dl_cache.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/dl_cache.cpp @@ -131,9 +131,7 @@ bool DLCache::store(uint32_t min_bytes /* = 0*/) { if (dl_size > dl_slot_size) { // Not enough memory to cache the display list. #if ENABLED(TOUCH_UI_DEBUG) - SERIAL_ECHO_START(); - SERIAL_ECHOPGM ("Not enough space in GRAM to cache display list, free space: ", dl_slot_size); - SERIAL_ECHOLNPGM(" Required: ", dl_size); + SERIAL_ECHO_MSG("Not enough space in GRAM to cache display list, free space: ", dl_slot_size, " Required: ", dl_size); #endif dl_slot_used = 0; save_slot(); @@ -141,9 +139,7 @@ bool DLCache::store(uint32_t min_bytes /* = 0*/) { } else { #if ENABLED(TOUCH_UI_DEBUG) - SERIAL_ECHO_START(); - SERIAL_ECHOPGM ("Saving DL to RAMG cache, bytes: ", dl_slot_used); - SERIAL_ECHOLNPGM(" Free space: ", dl_slot_size); + SERIAL_ECHO_MSG("Saving DL to RAMG cache, bytes: ", dl_slot_used, " Free space: ", dl_slot_size); #endif dl_slot_used = dl_size; save_slot(); @@ -160,9 +156,9 @@ void DLCache::save_slot(uint8_t indx, uint32_t addr, uint16_t size, uint16_t use } void DLCache::load_slot(uint8_t indx, uint32_t &addr, uint16_t &size, uint16_t &used) { - addr = CLCD::mem_read_32(DL_CACHE_START + indx * 12 + 0); - size = CLCD::mem_read_32(DL_CACHE_START + indx * 12 + 4); - used = CLCD::mem_read_32(DL_CACHE_START + indx * 12 + 8); + addr = CLCD::mem_read_32(DL_CACHE_START + indx * 12 + 0); + size = CLCD::mem_read_32(DL_CACHE_START + indx * 12 + 4); + used = CLCD::mem_read_32(DL_CACHE_START + indx * 12 + 8); } void DLCache::append() { @@ -171,9 +167,7 @@ void DLCache::append() { #if ENABLED(TOUCH_UI_DEBUG) cmd.execute(); wait_until_idle(); - SERIAL_ECHO_START(); - SERIAL_ECHOPGM ("Appending to DL from RAMG cache, bytes: ", dl_slot_used); - SERIAL_ECHOLNPGM(" REG_CMD_DL: ", CLCD::mem_read_32(REG::CMD_DL)); + SERIAL_ECHO_MSG("Appending to DL from RAMG cache, bytes: ", dl_slot_used, " REG_CMD_DL: ", CLCD::mem_read_32(REG::CMD_DL)); #endif } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_list.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_list.h index 2ddab1b818b4..b204f04743a4 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_list.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/sound_list.h @@ -29,10 +29,10 @@ class SoundList { } list[]; public: static const uint8_t n; - static inline const char* name(uint8_t val) { + static const char* name(uint8_t val) { return (const char* ) pgm_read_ptr_far(&list[val].name); } - static inline FTDI::SoundPlayer::sound_t* data(uint8_t val) { + static FTDI::SoundPlayer::sound_t* data(uint8_t val) { return (FTDI::SoundPlayer::sound_t*) pgm_read_ptr_far(&list[val].data); } }; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp index b4d8156b39d8..c75cdf18121a 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_box.cpp @@ -135,9 +135,9 @@ namespace FTDI { } } - void draw_text_box(CommandProcessor& cmd, int x, int y, int w, int h, FSTR_P pstr, uint16_t options, uint8_t font) { - char str[strlen_P((const char*)pstr) + 1]; - strcpy_P(str, (const char*)pstr); + void draw_text_box(CommandProcessor& cmd, int x, int y, int w, int h, FSTR_P fstr, uint16_t options, uint8_t font) { + char str[strlen_P(FTOP(fstr)) + 1]; + strcpy_P(str, FTOP(fstr)); draw_text_box(cmd, x, y, w, h, (const char*) str, options, font); } } // namespace FTDI diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp index 698bcdb15062..a6d014b56e3b 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/text_ellipsis.cpp @@ -33,6 +33,7 @@ namespace FTDI { const bool use_utf8 = has_utf8_chars(str); #define CHAR_WIDTH(c) use_utf8 ? utf8_fm.get_char_width(c) : clcd_fm.char_widths[(uint8_t)c] #else + constexpr bool use_utf8 = false; #define CHAR_WIDTH(c) utf8_fm.get_char_width(c) #endif FontMetrics utf8_fm(font); @@ -53,21 +54,17 @@ namespace FTDI { breakPoint = (char*)next; } - if (lineWidth > w) { - *breakPoint = '\0'; - strcpy_P(breakPoint,PSTR("...")); - } + if (lineWidth > w) + strcpy_P(breakPoint, PSTR("...")); cmd.apply_text_alignment(x, y, w, h, options); - #if ENABLED(TOUCH_UI_USE_UTF8) - if (use_utf8) { - draw_utf8_text(cmd, x, y, str, font_size_t::from_romfont(font), options); - } else - #endif - { - cmd.CLCD::CommandFifo::text(x, y, font, options); - cmd.CLCD::CommandFifo::str(str); - } + if (use_utf8) { + TERN_(TOUCH_UI_USE_UTF8, draw_utf8_text(cmd, x, y, str, font_size_t::from_romfont(font), options)); + } + else { + cmd.CLCD::CommandFifo::text(x, y, font, options); + cmd.CLCD::CommandFifo::str(str); + } } /** @@ -80,9 +77,9 @@ namespace FTDI { _draw_text_with_ellipsis(cmd, x, y, w, h, tmp, options, font); } - void draw_text_with_ellipsis(CommandProcessor& cmd, int x, int y, int w, int h, FSTR_P pstr, uint16_t options, uint8_t font) { - char tmp[strlen_P((const char*)pstr) + 3]; - strcpy_P(tmp, (const char*)pstr); + void draw_text_with_ellipsis(CommandProcessor& cmd, int x, int y, int w, int h, FSTR_P fstr, uint16_t options, uint8_t font) { + char tmp[strlen_P(FTOP(fstr)) + 3]; + strcpy_P(tmp, FTOP(fstr)); _draw_text_with_ellipsis(cmd, x, y, w, h, tmp, options, font); } } // namespace FTDI diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp index ca25dea3ca9d..ab52a59b9acc 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/extended/unicode/unicode.cpp @@ -74,7 +74,7 @@ return val; } - utf8_char_t FTDI::get_utf8_char_and_inc(char *&c) { + utf8_char_t FTDI::get_utf8_char_and_inc(const char *&c) { utf8_char_t val = *(uint8_t*)c++; if ((val & 0xC0) == 0xC0) while ((*c & 0xC0) == 0x80) @@ -191,9 +191,9 @@ return render_utf8_text(nullptr, 0, 0, str, fs, maxlen); } - uint16_t FTDI::get_utf8_text_width(FSTR_P pstr, font_size_t fs) { - char str[strlen_P((const char*)pstr) + 1]; - strcpy_P(str, (const char*)pstr); + uint16_t FTDI::get_utf8_text_width(FSTR_P fstr, font_size_t fs) { + char str[strlen_P(FTOP(fstr)) + 1]; + strcpy_P(str, FTOP(fstr)); return get_utf8_text_width(str, fs); } @@ -234,9 +234,9 @@ cmd.cmd(RESTORE_CONTEXT()); } - void FTDI::draw_utf8_text(CommandProcessor& cmd, int x, int y, FSTR_P pstr, font_size_t fs, uint16_t options) { - char str[strlen_P((const char*)pstr) + 1]; - strcpy_P(str, (const char*)pstr); + void FTDI::draw_utf8_text(CommandProcessor& cmd, int x, int y, FSTR_P fstr, font_size_t fs, uint16_t options) { + char str[strlen_P(FTOP(fstr)) + 1]; + strcpy_P(str, FTOP(fstr)); draw_utf8_text(cmd, x, y, (const char*) str, fs, options); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp index 6cb85e47c49c..43e5c333651a 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/about_screen.cpp @@ -69,8 +69,8 @@ void AboutScreen::onRedraw(draw_mode_t) { #endif draw_text_box(cmd, HEADING_POS, - #ifdef CUSTOM_MACHINE_NAME - F(CUSTOM_MACHINE_NAME) + #ifdef MACHINE_NAME + F(MACHINE_NAME) #else GET_TEXT_F(MSG_ABOUT_TOUCH_PANEL_1) #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/advanced_settings_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/advanced_settings_menu.cpp index a83cc075156c..8753b44e709b 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/advanced_settings_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/advanced_settings_menu.cpp @@ -64,8 +64,8 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) { #define BACK_POS BTN_POS(1,8), BTN_SIZE(2,1) #endif #else - #define GRID_ROWS 6 #define GRID_COLS 3 + #define GRID_ROWS 6 #define ZPROBE_ZOFFSET_POS BTN_POS(1,1), BTN_SIZE(1,1) #define CASE_LIGHT_POS BTN_POS(1,4), BTN_SIZE(1,1) #define STEPS_PER_MM_POS BTN_POS(2,1), BTN_SIZE(1,1) @@ -105,7 +105,7 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) { .tag(15).button(DISPLAY_POS, GET_TEXT_F(MSG_DISPLAY_MENU)) .tag(9) .button(INTERFACE_POS, GET_TEXT_F(MSG_INTERFACE)) .tag(10).button(RESTORE_DEFAULTS_POS, GET_TEXT_F(MSG_RESTORE_DEFAULTS)) - .tag(5) .button(VELOCITY_POS, GET_TEXT_F(MSG_VELOCITY)) + .tag(5) .button(VELOCITY_POS, GET_TEXT_F(MSG_MAX_SPEED)) .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))) .enabled(ENABLED(BACKLASH_GCODE)) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_numeric_adjustment_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_numeric_adjustment_screen.cpp index 4415ed50fcee..ce3066ae41f2 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_numeric_adjustment_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_numeric_adjustment_screen.cpp @@ -245,8 +245,8 @@ void BaseNumericAdjustmentScreen::widgets_t::adjuster(uint8_t tag, FSTR_P label, } if (_what & FOREGROUND) { - char b[strlen_P(value)+1]; - strcpy_P(b,value); + char b[strlen(value) + 1]; + strcpy(b, value); adjuster_sram_val(tag, label, b, is_enabled); } } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/custom_user_menus.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/custom_user_menus.cpp index bcdcad17be03..2fc6aec09582 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/custom_user_menus.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/custom_user_menus.cpp @@ -54,8 +54,8 @@ void CustomUserMenus::onRedraw(draw_mode_t what) { #endif #if ENABLED(TOUCH_UI_PORTRAIT) - #define GRID_ROWS 11 #define GRID_COLS (1 + _MORE_THAN_TEN) + #define GRID_ROWS 11 #define USER_ITEM_POS(N) BTN_POS((1+((N-1)/10)), ((N-1) % 10 + 1)), BTN_SIZE(1,1) #define BACK_POS BTN_POS(1,11), BTN_SIZE(1,1) #else @@ -64,8 +64,8 @@ void CustomUserMenus::onRedraw(draw_mode_t what) { #else #define _MORE_THAN_FIVE 0 #endif - #define GRID_ROWS 6 #define GRID_COLS (1 + _MORE_THAN_FIVE + _MORE_THAN_TEN + _MORE_THAN_FIFTEEN) + #define GRID_ROWS 6 #define USER_ITEM_POS(N) BTN_POS((1+((N-1)/5)), ((N-1) % 5 + 1)), BTN_SIZE(1,1) #define BACK_POS BTN_POS(1,6), BTN_SIZE(GRID_COLS,1) #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/developer_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/developer_menu.cpp index 34c754d53566..2ec8a3bbd19f 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/developer_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/developer_menu.cpp @@ -52,8 +52,8 @@ void DeveloperMenu::onRedraw(draw_mode_t what) { cmd.cmd(COLOR_RGB(bg_text_enabled)); #if ENABLED(TOUCH_UI_PORTRAIT) - #define GRID_ROWS 10 #define GRID_COLS 1 + #define GRID_ROWS 10 cmd.font(font_large) .text ( BTN_POS(1,1), BTN_SIZE(1,1), F("Developer Menu")) .colors(normal_btn) .tag(2).font(font_medium) .button(BTN_POS(1,2), BTN_SIZE(1,1), F("Show All Widgets")) @@ -68,8 +68,8 @@ void DeveloperMenu::onRedraw(draw_mode_t what) { .tag(1).colors(action_btn) .button(BTN_POS(1,10), BTN_SIZE(1,1), F("Back")); #else - #define GRID_ROWS 6 #define GRID_COLS 2 + #define GRID_ROWS 6 cmd.font(font_medium) .text ( BTN_POS(1,1), BTN_SIZE(2,1), F("Developer Menu")) .colors(normal_btn) .tag(2).font(font_small) .button(BTN_POS(1,2), BTN_SIZE(1,1), F("Show All Widgets")) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp index c7042e760e48..f7e57cf0b9a0 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/endstop_state_screen.cpp @@ -37,6 +37,13 @@ void EndstopStatesScreen::onExit() { BaseScreen::onExit(); } +#define GRID_COLS 6 +#define GRID_ROWS 7 + +#define PIN_BTN(X,Y,PIN,LABEL) button(BTN_POS(X,Y), BTN_SIZE(2,1), LABEL) +#define PIN_ENABLED(X,Y,LABEL,PIN,INV) cmd.enabled(1).colors(READ(PIN##_PIN) != INV ? action_btn : normal_btn).PIN_BTN(X,Y,PIN,LABEL); +#define PIN_DISABLED(X,Y,LABEL,PIN) cmd.enabled(0).PIN_BTN(X,Y,PIN,LABEL); + void EndstopStatesScreen::onRedraw(draw_mode_t) { CommandProcessor cmd; cmd.cmd(CLEAR_COLOR_RGB(bg_color)) @@ -44,20 +51,7 @@ void EndstopStatesScreen::onRedraw(draw_mode_t) { .cmd(CLEAR(true,true,true)) .tag(0); - #define GRID_ROWS 7 - #define GRID_COLS 6 - - #define PIN_BTN(X,Y,PIN,LABEL) button(BTN_POS(X,Y), BTN_SIZE(2,1), LABEL) - #define PIN_ENABLED(X,Y,LABEL,PIN,INV) cmd.enabled(1).colors(READ(PIN##_PIN) != INV ? action_btn : normal_btn).PIN_BTN(X,Y,PIN,LABEL); - #define PIN_DISABLED(X,Y,LABEL,PIN) cmd.enabled(0).PIN_BTN(X,Y,PIN,LABEL); - - cmd.font( - #if ENABLED(TOUCH_UI_PORTRAIT) - font_large - #else - font_medium - #endif - ) + cmd.font(TERN(TOUCH_UI_PORTRAIT, font_large, font_medium)) .text(BTN_POS(1,1), BTN_SIZE(6,1), GET_TEXT_F(MSG_LCD_ENDSTOPS)) .font(font_tiny); #if HAS_X_MAX @@ -121,8 +115,6 @@ void EndstopStatesScreen::onRedraw(draw_mode_t) { cmd.font(font_medium) .colors(action_btn) .tag(1).button(BTN_POS(1,7), BTN_SIZE(6,1), GET_TEXT_F(MSG_BUTTON_DONE)); - #undef GRID_COLS - #undef GRID_ROWS } bool EndstopStatesScreen::onTouchEnd(uint8_t tag) { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_menu.cpp index 9c9e70cebfc1..777698c39860 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/filament_menu.cpp @@ -30,15 +30,15 @@ using namespace ExtUI; using namespace Theme; #if ENABLED(TOUCH_UI_PORTRAIT) - #define GRID_ROWS 9 #define GRID_COLS 2 + #define GRID_ROWS 9 #define TITLE_POS BTN_POS(1,1), BTN_SIZE(2,1) #define RUNOUT_SENSOR_POS BTN_POS(1,2), BTN_SIZE(2,1) #define LIN_ADVANCE_POS BTN_POS(1,3), BTN_SIZE(2,1) #define BACK_POS BTN_POS(1,9), BTN_SIZE(2,1) #else - #define GRID_ROWS 6 #define GRID_COLS 2 + #define GRID_ROWS 6 #define TITLE_POS BTN_POS(1,1), BTN_SIZE(2,1) #define RUNOUT_SENSOR_POS BTN_POS(1,2), BTN_SIZE(2,1) #define LIN_ADVANCE_POS BTN_POS(1,3), BTN_SIZE(2,1) 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 5076e58adf6e..00768dbaf7de 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 @@ -28,7 +28,7 @@ #if ENABLED(TOUCH_UI_PORTRAIT) #define GRID_COLS 6 - #define GRID_ROWS 15 + #define GRID_ROWS 15 #define FILES_PER_PAGE 11 #define PREV_DIR LEFT #define NEXT_DIR RIGHT @@ -40,7 +40,7 @@ #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_COLS 12 #define GRID_ROWS 8 #define FILES_PER_PAGE 6 #define PREV_DIR UP @@ -77,7 +77,7 @@ const char *FilesScreen::getSelectedFilename(bool shortName) { } void FilesScreen::drawSelectedFile() { - if(mydata.selected_tag == 0xFF) return; + if (mydata.selected_tag == 0xFF) return; FileList files; files.seek(getSelectedFileIndex(), true); mydata.flags.is_dir = files.isDir(); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/interface_settings_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/interface_settings_screen.cpp index 5b160c80dfa6..fa4516daab1d 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/interface_settings_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/interface_settings_screen.cpp @@ -52,14 +52,13 @@ void InterfaceSettingsScreen::onEntry() { BaseScreen::onEntry(); } +#define GRID_COLS 4 +#define GRID_ROWS TERN(TOUCH_UI_PORTRAIT, 7, 6) + void InterfaceSettingsScreen::onRedraw(draw_mode_t what) { CommandProcessor cmd; if (what & BACKGROUND) { - - #define GRID_COLS 4 - #define GRID_ROWS TERN(TOUCH_UI_PORTRAIT, 7, 6) - cmd.cmd(CLEAR_COLOR_RGB(bg_color)) .cmd(CLEAR(true,true,true)) .cmd(COLOR_RGB(bg_text_enabled)) @@ -128,7 +127,7 @@ bool InterfaceSettingsScreen::onTouchEnd(uint8_t tag) { LockScreen::disable(); break; #endif - case 5: UIData::enable_animations(!UIData::animations_enabled());; break; + case 5: UIData::enable_animations(!UIData::animations_enabled()); break; case 6: GOTO_SCREEN(InterfaceSoundsScreen); return true; default: return false; @@ -148,8 +147,6 @@ bool InterfaceSettingsScreen::onTouchStart(uint8_t tag) { } #undef EDGE_R #define EDGE_R 0 - #undef GRID_COLS - #undef GRID_ROWS return true; } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/kill_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/kill_screen.cpp index bb44a8717693..61f8caa277f5 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/kill_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/kill_screen.cpp @@ -27,6 +27,9 @@ using namespace FTDI; +#define GRID_COLS 4 +#define GRID_ROWS 8 + // The kill screen is an oddball that happens after Marlin has killed the events // loop. So we only have a show() method rather than onRedraw(). The KillScreen // should not be used as a model for other UI screens as it is an exception. @@ -39,18 +42,12 @@ void KillScreen::show(const char *message) { .cmd(CLEAR(true,true,true)) .tag(0); - #define GRID_COLS 4 - #define GRID_ROWS 8 - cmd.font(Theme::font_large) .cmd(COLOR_RGB(Theme::bg_text_enabled)) .text(BTN_POS(1,2), BTN_SIZE(4,1), message) .text(BTN_POS(1,3), BTN_SIZE(4,1), GET_TEXT_F(MSG_HALTED)) .text(BTN_POS(1,6), BTN_SIZE(4,1), GET_TEXT_F(MSG_PLEASE_RESET)); - #undef GRID_COLS - #undef GRID_ROWS - cmd.cmd(DL::DL_DISPLAY) .cmd(CMD_SWAP) .execute(); 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 ce6045018b10..499f741540ab 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 @@ -37,8 +37,8 @@ void LanguageMenu::onRedraw(draw_mode_t) { .colors(normal_btn) .font(Theme::font_medium); - #define GRID_ROWS 8 #define GRID_COLS 1 + #define GRID_ROWS 8 cmd.tag(1).button(BTN_POS(1,1), BTN_SIZE(1,1), GET_LANGUAGE_NAME(1)); cmd.tag(2).button(BTN_POS(1,2), BTN_SIZE(1,1), GET_LANGUAGE_NAME(2)); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp index 11db21aca9c2..2fb9d18498c0 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp @@ -34,8 +34,8 @@ using namespace ExtUI; using namespace Theme; #if ENABLED(TOUCH_UI_PORTRAIT) - #define GRID_ROWS 8 #define GRID_COLS 2 + #define GRID_ROWS 8 #define LEVELING_TITLE_POS BTN_POS(1,1), BTN_SIZE(2,1) #define LEVEL_AXIS_POS BTN_POS(1,2), BTN_SIZE(2,1) #define BED_MESH_TITLE_POS BTN_POS(1,3), BTN_SIZE(2,1) @@ -48,8 +48,8 @@ using namespace Theme; #define BLTOUCH_TEST_POS BTN_POS(2,7), BTN_SIZE(1,1) #define BACK_POS BTN_POS(1,8), BTN_SIZE(2,1) #else - #define GRID_ROWS 6 #define GRID_COLS 3 + #define GRID_ROWS 6 #define LEVELING_TITLE_POS BTN_POS(1,1), BTN_SIZE(3,1) #define LEVEL_AXIS_POS BTN_POS(1,2), BTN_SIZE(3,1) #define BED_MESH_TITLE_POS BTN_POS(1,3), BTN_SIZE(2,1) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/lock_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/lock_screen.cpp index df8eabbe61be..82b9b2bd19f5 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/lock_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/lock_screen.cpp @@ -39,6 +39,9 @@ void LockScreen::onEntry() { BaseScreen::onEntry(); } +#define GRID_COLS 1 +#define GRID_ROWS TERN(TOUCH_UI_PORTRAIT, 10, 7) + void LockScreen::onRedraw(draw_mode_t what) { CommandProcessor cmd; @@ -50,14 +53,6 @@ void LockScreen::onRedraw(draw_mode_t what) { } if (what & FOREGROUND) { - #if ENABLED(TOUCH_UI_PORTRAIT) - #define GRID_COLS 1 - #define GRID_ROWS 10 - #else - #define GRID_COLS 1 - #define GRID_ROWS 7 - #endif - #undef MARGIN_T #undef MARGIN_B #define MARGIN_T 3 @@ -108,9 +103,6 @@ void LockScreen::onRedraw(draw_mode_t what) { #undef MARGIN_B #define MARGIN_T MARGIN_DEFAULT #define MARGIN_B MARGIN_DEFAULT - - #undef GRID_COLS - #undef GRID_ROWS } } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/main_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/main_menu.cpp index 6ccda405fcc3..001f97490b1d 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/main_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/main_menu.cpp @@ -37,8 +37,8 @@ void MainMenu::onRedraw(draw_mode_t what) { } #if ENABLED(TOUCH_UI_PORTRAIT) - #define GRID_ROWS 8 #define GRID_COLS 2 + #define GRID_ROWS 8 #define ABOUT_PRINTER_POS BTN_POS(1,1), BTN_SIZE(2,1) #define ADVANCED_SETTINGS_POS BTN_POS(1,2), BTN_SIZE(2,1) #if ENABLED(CUSTOM_MENU_MAIN) @@ -55,8 +55,8 @@ void MainMenu::onRedraw(draw_mode_t what) { #define CLEAN_NOZZLE_POS BTN_POS(2,7), BTN_SIZE(1,1) #define BACK_POS BTN_POS(1,8), BTN_SIZE(2,1) #else - #define GRID_ROWS 5 #define GRID_COLS 6 + #define GRID_ROWS 5 #define ADVANCED_SETTINGS_POS BTN_POS(1,1), BTN_SIZE(3,1) #define ABOUT_PRINTER_POS BTN_POS(4,1), BTN_SIZE(3,1) #define AUTO_HOME_POS BTN_POS(1,2), BTN_SIZE(3,1) @@ -80,15 +80,15 @@ void MainMenu::onRedraw(draw_mode_t what) { cmd.colors(normal_btn) .font(Theme::font_medium) .tag( 2).button(AUTO_HOME_POS, GET_TEXT_F(MSG_AUTO_HOME)) - .enabled(ENABLED(NOZZLE_CLEAN_FEATURE)) + .enabled(ENABLED(NOZZLE_CLEAN_FEATURE)) .tag( 3).button(CLEAN_NOZZLE_POS, GET_TEXT_F(MSG_CLEAN_NOZZLE)) .tag( 4).button(MOVE_AXIS_POS, GET_TEXT_F(MSG_MOVE_AXIS)) .tag( 5).button(DISABLE_STEPPERS_POS,GET_TEXT_F(MSG_DISABLE_STEPPERS)) .tag( 6).button(TEMPERATURE_POS, GET_TEXT_F(MSG_TEMPERATURE)) - .enabled(IF_DISABLED(TOUCH_UI_LULZBOT_BIO, 1)) + .enabled(DISABLED(TOUCH_UI_LULZBOT_BIO)) .tag( 7).button(FILAMENTCHANGE_POS, GET_TEXT_F(MSG_FILAMENTCHANGE)) .tag( 8).button(ADVANCED_SETTINGS_POS, GET_TEXT_F(MSG_ADVANCED_SETTINGS)) - .enabled(TERN_(HAS_LEVELING, 1)) + .enabled(ENABLED(HAS_LEVELING)) .tag( 9).button(LEVELING_POS, GET_TEXT_F(MSG_LEVELING)) .tag(10).button(ABOUT_PRINTER_POS, GET_TEXT_F(MSG_INFO_MENU)) #if ENABLED(CUSTOM_MENU_MAIN) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_acceleration_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_acceleration_screen.cpp index be3a24438018..492b908776dd 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_acceleration_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/max_acceleration_screen.cpp @@ -41,13 +41,13 @@ void MaxAccelerationScreen::onRedraw(draw_mode_t what) { w.color(e_axis).adjuster( 8, GET_TEXT_F(MSG_AMAX_E), getAxisMaxAcceleration_mm_s2(E0) ); #elif DISTINCT_E > 1 w.heading(GET_TEXT_F(MSG_AMAX_E)); - w.color(e_axis).adjuster( 8, F(LCD_STR_E0), getAxisMaxAcceleration_mm_s2(E0) ); - w.color(e_axis).adjuster(10, F(LCD_STR_E1), getAxisMaxAcceleration_mm_s2(E1) ); + w.color(e_axis).adjuster( 8, F(STR_E0), getAxisMaxAcceleration_mm_s2(E0) ); + w.color(e_axis).adjuster(10, F(STR_E1), getAxisMaxAcceleration_mm_s2(E1) ); #if DISTINCT_E > 2 - w.color(e_axis).adjuster(12, F(LCD_STR_E2), getAxisMaxAcceleration_mm_s2(E2) ); - #endif - #if DISTINCT_E > 3 - w.color(e_axis).adjuster(14, F(LCD_STR_E3), getAxisMaxAcceleration_mm_s2(E3) ); + w.color(e_axis).adjuster(12, F(STR_E2), getAxisMaxAcceleration_mm_s2(E2) ); + #if DISTINCT_E > 3 + w.color(e_axis).adjuster(14, F(STR_E3), getAxisMaxAcceleration_mm_s2(E3) ); + #endif #endif #endif w.increments(); @@ -65,19 +65,18 @@ bool MaxAccelerationScreen::onTouchHeld(uint8_t tag) { case 8: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E0); break; case 9: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E0); break; #if DISTINCT_E > 1 - case 10: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E1); break; - case 11: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E1); break; - #endif - #if DISTINCT_E > 2 - case 12: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E2); break; - case 13: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E2); break; - #endif - #if DISTINCT_E > 3 - case 14: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E3); break; - case 15: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E3); break; + case 10: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E1); break; + case 11: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E1); break; + #if DISTINCT_E > 2 + case 12: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E2); break; + case 13: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E2); break; + #if DISTINCT_E > 3 + case 14: UI_DECREMENT(AxisMaxAcceleration_mm_s2, E3); break; + case 15: UI_INCREMENT(AxisMaxAcceleration_mm_s2, E3); break; + #endif + #endif #endif - default: - return false; + default: return false; } 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 bca533c94f19..e7fc23ab4870 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_VELOCITY)); + w.heading( GET_TEXT_F(MSG_MAX_SPEED)); 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) ); @@ -42,13 +42,13 @@ void MaxVelocityScreen::onRedraw(draw_mode_t what) { w.color(e_axis) .adjuster( 8, GET_TEXT_F(MSG_VMAX_E), getAxisMaxFeedrate_mm_s(E0) ); #elif HAS_MULTI_EXTRUDER w.heading(GET_TEXT_F(MSG_VMAX_E)); - w.color(e_axis) .adjuster( 8, F(LCD_STR_E0), getAxisMaxFeedrate_mm_s(E0) ); - w.color(e_axis) .adjuster( 10, F(LCD_STR_E1), getAxisMaxFeedrate_mm_s(E1) ); + w.color(e_axis) .adjuster( 8, F(STR_E0), getAxisMaxFeedrate_mm_s(E0) ); + w.color(e_axis) .adjuster( 10, F(STR_E1), getAxisMaxFeedrate_mm_s(E1) ); #if EXTRUDERS > 2 - w.color(e_axis).adjuster( 12, F(LCD_STR_E2), getAxisMaxFeedrate_mm_s(E2) ); - #endif - #if EXTRUDERS > 3 - w.color(e_axis).adjuster( 14, F(LCD_STR_E3), getAxisMaxFeedrate_mm_s(E3) ); + w.color(e_axis).adjuster( 12, F(STR_E2), getAxisMaxFeedrate_mm_s(E2) ); + #if EXTRUDERS > 3 + w.color(e_axis).adjuster( 14, F(STR_E3), getAxisMaxFeedrate_mm_s(E3) ); + #endif #endif #endif w.increments(); @@ -63,24 +63,23 @@ bool MaxVelocityScreen::onTouchHeld(uint8_t tag) { case 5: UI_INCREMENT(AxisMaxFeedrate_mm_s, Y); break; case 6: UI_DECREMENT(AxisMaxFeedrate_mm_s, Z); break; case 7: UI_INCREMENT(AxisMaxFeedrate_mm_s, Z); break; - #if DISTINCT_E > 0 - case 8: UI_DECREMENT(AxisMaxFeedrate_mm_s, E0); break; - case 9: UI_INCREMENT(AxisMaxFeedrate_mm_s, E0); break; - #endif - #if DISTINCT_E > 1 - case 10: UI_DECREMENT(AxisMaxFeedrate_mm_s, E1); break; - case 11: UI_INCREMENT(AxisMaxFeedrate_mm_s, E1); break; - #endif - #if DISTINCT_E > 2 - case 12: UI_DECREMENT(AxisMaxFeedrate_mm_s, E2); break; - case 13: UI_INCREMENT(AxisMaxFeedrate_mm_s, E2); break; - #endif - #if DISTINCT_E > 3 - case 14: UI_DECREMENT(AxisMaxFeedrate_mm_s, E3); break; - case 15: UI_INCREMENT(AxisMaxFeedrate_mm_s, E3); break; + #if DISTINCT_E + case 8: UI_DECREMENT(AxisMaxFeedrate_mm_s, E0); break; + case 9: UI_INCREMENT(AxisMaxFeedrate_mm_s, E0); break; + #if DISTINCT_E > 1 + case 10: UI_DECREMENT(AxisMaxFeedrate_mm_s, E1); break; + case 11: UI_INCREMENT(AxisMaxFeedrate_mm_s, E1); break; + #if DISTINCT_E > 2 + case 12: UI_DECREMENT(AxisMaxFeedrate_mm_s, E2); break; + case 13: UI_INCREMENT(AxisMaxFeedrate_mm_s, E2); break; + #if DISTINCT_E > 3 + case 14: UI_DECREMENT(AxisMaxFeedrate_mm_s, E3); break; + case 15: UI_INCREMENT(AxisMaxFeedrate_mm_s, E3); break; + #endif + #endif + #endif #endif - default: - return false; + default: return false; } SaveSettingsDialogBox::settingsChanged(); return true; diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp index 4e76450683e9..43f33fb3bf0b 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/status_screen.cpp @@ -31,17 +31,12 @@ using namespace FTDI; using namespace Theme; -#if ENABLED(TOUCH_UI_PORTRAIT) - #define GRID_ROWS 16 -#else - #define GRID_ROWS 16 -#endif +#define GRID_COLS 3 +#define GRID_ROWS 16 void StatusScreen::draw_axis_position(draw_mode_t what) { CommandProcessor cmd; - #define GRID_COLS 3 - #if ENABLED(TOUCH_UI_PORTRAIT) #define X_LBL_POS BTN_POS(1, 9), BTN_SIZE(1,2) #define Y_LBL_POS BTN_POS(1,11), BTN_SIZE(1,2) @@ -106,15 +101,10 @@ void StatusScreen::draw_axis_position(draw_mode_t what) { .text(Y_VAL_POS, y_str) .text(Z_VAL_POS, z_str); } - - #undef GRID_COLS } -#if ENABLED(TOUCH_UI_PORTRAIT) - #define GRID_COLS 8 -#else - #define GRID_COLS 12 -#endif +#undef GRID_COLS +#define GRID_COLS TERN(TOUCH_UI_PORTRAIT, 8, 12) void StatusScreen::draw_temperature(draw_mode_t what) { using namespace Theme; @@ -293,11 +283,10 @@ void StatusScreen::draw_progress(draw_mode_t what) { .text(PROGRESS_POS, progress_str); #endif } - - #undef GRID_COLS } void StatusScreen::draw_interaction_buttons(draw_mode_t what) { + #undef GRID_COLS #define GRID_COLS 4 if (what & FOREGROUND) { using namespace ExtUI; @@ -321,10 +310,10 @@ void StatusScreen::draw_interaction_buttons(draw_mode_t what) { .colors(!has_media ? action_btn : normal_btn) .tag(4).button(MENU_BTN_POS, GET_TEXT_F(MSG_BUTTON_MENU)); } - #undef GRID_COLS } void StatusScreen::draw_status_message(draw_mode_t what, const char *message) { + #undef GRID_COLS #define GRID_COLS 1 #if ENABLED(TOUCH_UI_PORTRAIT) @@ -341,12 +330,11 @@ void StatusScreen::draw_status_message(draw_mode_t what, const char *message) { draw_text_box(cmd, STATUS_POS, message, OPT_CENTER, font_large); } - #undef GRID_COLS } void StatusScreen::setStatusMessage(FSTR_P message) { - char buff[strlen_P((const char * const)message)+1]; - strcpy_P(buff, (const char * const) message); + char buff[strlen_P(FTOP(message)) + 1]; + strcpy_P(buff, FTOP(message)); setStatusMessage((const char *) buff); } diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/temperature_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/temperature_screen.cpp index ee53a82bee18..2dbf2d9f06a7 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/temperature_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/temperature_screen.cpp @@ -50,13 +50,13 @@ void TemperatureScreen::onRedraw(draw_mode_t what) { #elif HOTENDS == 1 w.adjuster( 2, GET_TEXT_F(MSG_NOZZLE), getTargetTemp_celsius(E0)); #else - w.adjuster( 2, F(LCD_STR_E0), getTargetTemp_celsius(E0)); - w.adjuster( 4, F(LCD_STR_E1), getTargetTemp_celsius(E1)); + w.adjuster( 2, F(STR_E0), getTargetTemp_celsius(E0)); + w.adjuster( 4, F(STR_E1), getTargetTemp_celsius(E1)); #if HOTENDS > 2 - w.adjuster( 6, F(LCD_STR_E2), getTargetTemp_celsius(E2)); + w.adjuster( 6, F(STR_E2), getTargetTemp_celsius(E2)); #endif #if HOTENDS > 3 - w.adjuster( 8, F(LCD_STR_E3), getTargetTemp_celsius(E3)); + w.adjuster( 8, F(STR_E3), getTargetTemp_celsius(E3)); #endif #endif #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/touch_registers_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/touch_registers_screen.cpp index 5475d67a80b7..6ef8bb452549 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/touch_registers_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/touch_registers_screen.cpp @@ -28,6 +28,9 @@ using namespace FTDI; using namespace Theme; +#define GRID_COLS 2 +#define GRID_ROWS 7 + void TouchRegistersScreen::onRedraw(draw_mode_t) { const uint32_t T_Transform_A = CLCD::mem_read_32(CLCD::REG::TOUCH_TRANSFORM_A); const uint32_t T_Transform_B = CLCD::mem_read_32(CLCD::REG::TOUCH_TRANSFORM_B); @@ -42,8 +45,6 @@ void TouchRegistersScreen::onRedraw(draw_mode_t) { .cmd(CLEAR(true,true,true)) .tag(0); - #define GRID_ROWS 7 - #define GRID_COLS 2 cmd.tag(0) .font(font_xsmall) .fgcolor(transformA) .button(BTN_POS(1,1), BTN_SIZE(1,1), F("TOUCH_XFORM_A")) @@ -69,8 +70,6 @@ void TouchRegistersScreen::onRedraw(draw_mode_t) { cmd.colors(action_btn).font(font_medium) .tag(1).button(BTN_POS(2,7), BTN_SIZE(1,1), F("Back")); - #undef GRID_COLS - #undef GRID_ROWS } bool TouchRegistersScreen::onTouchEnd(uint8_t tag) { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/tune_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/tune_menu.cpp index 98150ceccb3d..0370c4417478 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/tune_menu.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/tune_menu.cpp @@ -30,6 +30,9 @@ using namespace FTDI; using namespace Theme; +#define GRID_COLS 2 +#define GRID_ROWS TERN(TOUCH_UI_PORTRAIT, 9, 5) + void TuneMenu::onRedraw(draw_mode_t what) { if (what & BACKGROUND) { CommandProcessor cmd; @@ -38,8 +41,6 @@ void TuneMenu::onRedraw(draw_mode_t what) { } #if ENABLED(TOUCH_UI_PORTRAIT) - #define GRID_ROWS 9 - #define GRID_COLS 2 #define TEMPERATURE_POS BTN_POS(1,1), BTN_SIZE(2,1) #define FIL_CHANGE_POS BTN_POS(1,2), BTN_SIZE(2,1) #define FILAMENT_POS BTN_POS(1,3), BTN_SIZE(2,1) @@ -51,8 +52,6 @@ void TuneMenu::onRedraw(draw_mode_t what) { #define ADVANCED_SETTINGS_POS BTN_POS(1,9), BTN_SIZE(1,1) #define BACK_POS BTN_POS(2,9), BTN_SIZE(1,1) #else - #define GRID_ROWS 5 - #define GRID_COLS 2 #define TEMPERATURE_POS BTN_POS(1,1), BTN_SIZE(1,1) #define NUDGE_NOZ_POS BTN_POS(2,1), BTN_SIZE(1,1) #define FIL_CHANGE_POS BTN_POS(1,2), BTN_SIZE(1,1) @@ -94,8 +93,6 @@ void TuneMenu::onRedraw(draw_mode_t what) { .tag(1).colors(action_btn) .button(BACK_POS, GET_TEXT_F(MSG_BUTTON_DONE)); } - #undef GRID_COLS - #undef GRID_ROWS } bool TuneMenu::onTouchEnd(uint8_t tag) { diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language.h index cbc05c5aa3b0..8c123db6a1f7 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/language/language.h @@ -20,4 +20,6 @@ ****************************************************************************/ #pragma once +#define LSTR PROGMEM Language_Str + #include "language_en.h" 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 f79f788d8d3a..5dbde8a5c359 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 @@ -36,143 +36,142 @@ #endif namespace Language_en { - PROGMEM Language_Str MSG_BUTTON_OKAY = u8"Okay"; - PROGMEM Language_Str MSG_BUTTON_MENU = u8"Menu"; - PROGMEM Language_Str MSG_BUTTON_MEDIA = u8"Media"; - PROGMEM Language_Str MSG_BUTTON_OPEN = u8"Open"; - PROGMEM Language_Str MSG_CLEAN_NOZZLE = u8"Clean Nozzle"; - PROGMEM Language_Str MSG_VMAX_X = u8"Vmax X"; - PROGMEM Language_Str MSG_VMAX_Y = u8"Vmax Y"; - PROGMEM Language_Str MSG_VMAX_Z = u8"Vmax Z"; - PROGMEM Language_Str MSG_ACCEL_PRINTING = u8"Printing"; - PROGMEM Language_Str MSG_ACCEL_TRAVEL = u8"Travel"; - PROGMEM Language_Str MSG_ACCEL_RETRACT = u8"Retraction"; - PROGMEM Language_Str MSG_AMAX_X = u8"Amax X"; - PROGMEM Language_Str MSG_AMAX_Y = u8"Amax Y"; - PROGMEM Language_Str MSG_AMAX_Z = u8"Amax Z"; - PROGMEM Language_Str MSG_AXIS_X = u8"X"; - PROGMEM Language_Str MSG_AXIS_X2 = u8"X2"; - PROGMEM Language_Str MSG_AXIS_Y = u8"Y"; - PROGMEM Language_Str MSG_AXIS_Y2 = u8"Y2"; - PROGMEM Language_Str MSG_AXIS_Z = u8"Z"; - PROGMEM Language_Str MSG_AXIS_Z2 = u8"Z2"; - PROGMEM Language_Str MSG_AXIS_E = u8"E"; - PROGMEM Language_Str MSG_AXIS_E1 = u8"E1"; - PROGMEM Language_Str MSG_AXIS_E2 = u8"E2"; - PROGMEM Language_Str MSG_AXIS_E3 = u8"E3"; - PROGMEM Language_Str MSG_AXIS_E4 = u8"E4"; - PROGMEM Language_Str MSG_AXIS_ALL = u8"All"; - PROGMEM Language_Str MSG_HOME = u8"Home"; - PROGMEM Language_Str MSG_PRINT_STARTING = u8"Print starting"; - PROGMEM Language_Str MSG_PRINT_FINISHED = u8"Print finished"; - PROGMEM Language_Str MSG_PRINT_ERROR = u8"Print error"; - PROGMEM Language_Str MSG_ABOUT_TOUCH_PANEL_1 = u8"Color Touch Panel"; - PROGMEM Language_Str MSG_ABOUT_TOUCH_PANEL_2 = WEBSITE_URL; - PROGMEM Language_Str MSG_LICENSE = u8"This program is free software: you can redistribute it and/or modify it under the terms of " + LSTR MSG_BUTTON_OKAY = u8"Okay"; + LSTR MSG_BUTTON_MENU = u8"Menu"; + LSTR MSG_BUTTON_MEDIA = u8"Media"; + LSTR MSG_BUTTON_OPEN = u8"Open"; + LSTR MSG_CLEAN_NOZZLE = u8"Clean Nozzle"; + LSTR MSG_VMAX_X = u8"Max X Speed"; + LSTR MSG_VMAX_Y = u8"Max Y Speed"; + LSTR MSG_VMAX_Z = u8"Max Z Speed"; + LSTR MSG_ACCEL_PRINTING = u8"Printing"; + LSTR MSG_ACCEL_TRAVEL = u8"Travel"; + LSTR MSG_ACCEL_RETRACT = u8"Retraction"; + LSTR MSG_AMAX_X = u8"Max X Accel."; + LSTR MSG_AMAX_Y = u8"Max Y Accel."; + LSTR MSG_AMAX_Z = u8"Max Z Accel."; + LSTR MSG_AXIS_X = u8"X"; + LSTR MSG_AXIS_X2 = u8"X2"; + LSTR MSG_AXIS_Y = u8"Y"; + LSTR MSG_AXIS_Y2 = u8"Y2"; + LSTR MSG_AXIS_Z = u8"Z"; + LSTR MSG_AXIS_Z2 = u8"Z2"; + LSTR MSG_AXIS_E = u8"E"; + LSTR MSG_AXIS_E1 = u8"E1"; + LSTR MSG_AXIS_E2 = u8"E2"; + LSTR MSG_AXIS_E3 = u8"E3"; + LSTR MSG_AXIS_E4 = u8"E4"; + LSTR MSG_AXIS_ALL = u8"All"; + LSTR MSG_HOME = u8"Home"; + LSTR MSG_PRINT_STARTING = u8"Print starting"; + LSTR MSG_PRINT_FINISHED = u8"Print finished"; + LSTR MSG_PRINT_ERROR = u8"Print error"; + LSTR MSG_ABOUT_TOUCH_PANEL_1 = u8"Color Touch Panel"; + LSTR MSG_ABOUT_TOUCH_PANEL_2 = WEBSITE_URL; + LSTR MSG_LICENSE = u8"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. To view a copy of the GNU General " "Public License, go to the following location: https://www.gnu.org/licenses."; - PROGMEM Language_Str MSG_RUNOUT_1 = u8"Runout 1"; - PROGMEM Language_Str MSG_RUNOUT_2 = u8"Runout 2"; - PROGMEM Language_Str MSG_DISPLAY_MENU = u8"Display"; - PROGMEM Language_Str MSG_INTERFACE = u8"Interface"; - PROGMEM Language_Str MSG_MEASURE_AUTOMATICALLY = u8"Measure automatically"; - PROGMEM Language_Str MSG_H_OFFSET = u8"H Offset"; - PROGMEM Language_Str MSG_V_OFFSET = u8"V Offset"; - PROGMEM Language_Str MSG_TOUCH_SCREEN = u8"Touch Screen"; - PROGMEM Language_Str MSG_CALIBRATE = u8"Calibrate"; - PROGMEM Language_Str MSG_UNITS_MILLIAMP = u8"mA"; - PROGMEM Language_Str MSG_UNITS_MM = u8"mm"; - PROGMEM Language_Str MSG_UNITS_MM_S = u8"mm/s"; - PROGMEM Language_Str MSG_UNITS_MM_S2 = u8"mm/s" SUPERSCRIPT_TWO; - PROGMEM Language_Str MSG_UNITS_STEP_MM = u8"st/mm"; - PROGMEM Language_Str MSG_UNITS_PERCENT = u8"%"; - PROGMEM Language_Str MSG_UNITS_C = DEGREE_SIGN u8"C"; - PROGMEM Language_Str MSG_IDLE = u8"idle"; - PROGMEM Language_Str MSG_SET_MAXIMUM = u8"Set Maximum"; - PROGMEM Language_Str MSG_PRINT_SPEED = u8"Print Speed"; - PROGMEM Language_Str MSG_LINEAR_ADVANCE = u8"Linear Advance"; - PROGMEM Language_Str MSG_LINEAR_ADVANCE_K = u8"K"; - PROGMEM Language_Str MSG_LINEAR_ADVANCE_K1 = u8"K E1"; - PROGMEM Language_Str MSG_LINEAR_ADVANCE_K2 = u8"K E2"; - PROGMEM Language_Str MSG_LINEAR_ADVANCE_K3 = u8"K E3"; - PROGMEM Language_Str MSG_LINEAR_ADVANCE_K4 = u8"K E4"; - PROGMEM Language_Str MSG_NUDGE_NOZZLE = u8"Nudge Nozzle"; - PROGMEM Language_Str MSG_ADJUST_BOTH_NOZZLES = u8"Adjust Both Nozzles"; - PROGMEM Language_Str MSG_SHOW_OFFSETS = u8"Show Offsets"; - PROGMEM Language_Str MSG_INCREMENT = u8"Increment"; - PROGMEM Language_Str MSG_ERASE_FLASH_WARNING = u8"Are you sure? SPI flash will be erased."; - PROGMEM Language_Str MSG_ERASING = u8"Erasing..."; - PROGMEM Language_Str MSG_ERASED = u8"SPI flash erased"; - PROGMEM Language_Str MSG_CALIBRATION_WARNING = u8"For best results, unload the filament and clean the hotend prior to starting calibration. Continue?"; - PROGMEM Language_Str MSG_START_PRINT_CONFIRMATION = u8"Start printing %s?"; - PROGMEM Language_Str MSG_ABORT_WARNING = u8"Are you sure you want to cancel the print?"; - PROGMEM Language_Str MSG_EXTRUDER_SELECTION = u8"Extruder Selection"; - PROGMEM Language_Str MSG_CURRENT_TEMPERATURE = u8"Current Temp"; - PROGMEM Language_Str MSG_REMOVAL_TEMPERATURE = u8"Removal Temp"; - PROGMEM Language_Str MSG_CAUTION = u8"Caution:"; - PROGMEM Language_Str MSG_HOT = u8"Hot!"; - PROGMEM Language_Str MSG_UNLOAD_FILAMENT = u8"Unload/Retract"; - PROGMEM Language_Str MSG_LOAD_FILAMENT = u8"Load/Extrude"; - PROGMEM Language_Str MSG_MOMENTARY = u8"Momentary"; - PROGMEM Language_Str MSG_CONTINUOUS = u8"Continuous"; - PROGMEM Language_Str MSG_PLEASE_WAIT = u8"Please wait..."; - PROGMEM Language_Str MSG_PRINT_MENU = u8"Print Menu"; - PROGMEM Language_Str MSG_FINE_MOTION = u8"Fine motion"; - PROGMEM Language_Str MSG_ENABLE_MEDIA = u8"Enable Media"; - PROGMEM Language_Str MSG_INSERT_MEDIA = u8"Insert Media..."; - PROGMEM Language_Str MSG_LCD_BRIGHTNESS = u8"LCD brightness"; - PROGMEM Language_Str MSG_SOUND_VOLUME = u8"Sound volume"; - PROGMEM Language_Str MSG_SCREEN_LOCK = u8"Screen lock"; - PROGMEM Language_Str MSG_BOOT_SCREEN = u8"Boot screen"; - PROGMEM Language_Str MSG_SOUNDS = u8"Sounds"; - PROGMEM Language_Str MSG_CLICK_SOUNDS = u8"Click sounds"; - PROGMEM Language_Str MSG_EEPROM_RESTORED = u8"Settings restored from backup"; - PROGMEM Language_Str MSG_EEPROM_RESET = u8"Settings restored to default"; - PROGMEM Language_Str MSG_EEPROM_SAVED = u8"Settings saved!"; - PROGMEM Language_Str MSG_EEPROM_SAVE_PROMPT = u8"Settings applied. Save these settings for next power-on?"; - PROGMEM Language_Str MSG_EEPROM_RESET_WARNING = u8"Are you sure? Customizations will be lost."; + LSTR MSG_RUNOUT_1 = u8"Runout 1"; + LSTR MSG_RUNOUT_2 = u8"Runout 2"; + LSTR MSG_DISPLAY_MENU = u8"Display"; + LSTR MSG_INTERFACE = u8"Interface"; + LSTR MSG_MEASURE_AUTOMATICALLY = u8"Measure automatically"; + LSTR MSG_H_OFFSET = u8"H Offset"; + LSTR MSG_V_OFFSET = u8"V Offset"; + LSTR MSG_TOUCH_SCREEN = u8"Touch Screen"; + LSTR MSG_CALIBRATE = u8"Calibrate"; + LSTR MSG_UNITS_MILLIAMP = u8"mA"; + LSTR MSG_UNITS_MM = u8"mm"; + LSTR MSG_UNITS_MM_S = u8"mm/s"; + LSTR MSG_UNITS_MM_S2 = u8"mm/s" SUPERSCRIPT_TWO; + LSTR MSG_UNITS_STEP_MM = u8"st/mm"; + LSTR MSG_UNITS_PERCENT = u8"%"; + LSTR MSG_UNITS_C = DEGREE_SIGN u8"C"; + LSTR MSG_IDLE = u8"idle"; + LSTR MSG_SET_MAXIMUM = u8"Set Maximum"; + LSTR MSG_PRINT_SPEED = u8"Print Speed"; + LSTR MSG_LINEAR_ADVANCE = u8"Linear Advance"; + LSTR MSG_LINEAR_ADVANCE_K = u8"K"; + LSTR MSG_LINEAR_ADVANCE_K1 = u8"K E1"; + LSTR MSG_LINEAR_ADVANCE_K2 = u8"K E2"; + LSTR MSG_LINEAR_ADVANCE_K3 = u8"K E3"; + LSTR MSG_LINEAR_ADVANCE_K4 = u8"K E4"; + LSTR MSG_NUDGE_NOZZLE = u8"Nudge Nozzle"; + LSTR MSG_ADJUST_BOTH_NOZZLES = u8"Adjust Both Nozzles"; + LSTR MSG_SHOW_OFFSETS = u8"Show Offsets"; + LSTR MSG_INCREMENT = u8"Increment"; + LSTR MSG_ERASE_FLASH_WARNING = u8"Are you sure? SPI flash will be erased."; + LSTR MSG_ERASING = u8"Erasing..."; + LSTR MSG_ERASED = u8"SPI flash erased"; + LSTR MSG_CALIBRATION_WARNING = u8"For best results, unload the filament and clean the hotend prior to starting calibration. Continue?"; + LSTR MSG_START_PRINT_CONFIRMATION = u8"Start printing %s?"; + LSTR MSG_ABORT_WARNING = u8"Are you sure you want to cancel the print?"; + LSTR MSG_EXTRUDER_SELECTION = u8"Extruder Selection"; + LSTR MSG_CURRENT_TEMPERATURE = u8"Current Temp"; + LSTR MSG_REMOVAL_TEMPERATURE = u8"Removal Temp"; + LSTR MSG_CAUTION = u8"Caution:"; + LSTR MSG_HOT = u8"Hot!"; + LSTR MSG_UNLOAD_FILAMENT = u8"Unload/Retract"; + LSTR MSG_LOAD_FILAMENT = u8"Load/Extrude"; + LSTR MSG_MOMENTARY = u8"Momentary"; + LSTR MSG_CONTINUOUS = u8"Continuous"; + LSTR MSG_PRINT_MENU = u8"Print Menu"; + LSTR MSG_FINE_MOTION = u8"Fine motion"; + LSTR MSG_ENABLE_MEDIA = u8"Enable Media"; + LSTR MSG_INSERT_MEDIA = u8"Insert Media..."; + LSTR MSG_LCD_BRIGHTNESS = u8"LCD brightness"; + LSTR MSG_SOUND_VOLUME = u8"Sound volume"; + LSTR MSG_SCREEN_LOCK = u8"Screen lock"; + LSTR MSG_BOOT_SCREEN = u8"Boot screen"; + LSTR MSG_SOUNDS = u8"Sounds"; + LSTR MSG_CLICK_SOUNDS = u8"Click sounds"; + LSTR MSG_EEPROM_RESTORED = u8"Settings restored from backup"; + LSTR MSG_EEPROM_RESET = u8"Settings restored to default"; + LSTR MSG_EEPROM_SAVED = u8"Settings saved!"; + LSTR MSG_EEPROM_SAVE_PROMPT = u8"Settings applied. Save these settings for next power-on?"; + LSTR MSG_EEPROM_RESET_WARNING = u8"Are you sure? Customizations will be lost."; - PROGMEM Language_Str MSG_PASSCODE_REJECTED = u8"Wrong passcode!"; - PROGMEM Language_Str MSG_PASSCODE_ACCEPTED = u8"Passcode accepted!"; - PROGMEM Language_Str MSG_PASSCODE_SELECT = u8"Select Passcode:"; - PROGMEM Language_Str MSG_PASSCODE_REQUEST = u8"Enter Passcode:"; + LSTR MSG_PASSCODE_REJECTED = u8"Wrong passcode!"; + LSTR MSG_PASSCODE_ACCEPTED = u8"Passcode accepted!"; + LSTR MSG_PASSCODE_SELECT = u8"Select Passcode:"; + LSTR MSG_PASSCODE_REQUEST = u8"Enter Passcode:"; - PROGMEM Language_Str MSG_TOUCH_CALIBRATION_START = u8"Release to begin screen calibration"; - PROGMEM Language_Str MSG_TOUCH_CALIBRATION_PROMPT = u8"Touch the dots to calibrate"; - PROGMEM Language_Str MSG_BED_MAPPING_DONE = u8"Bed mapping finished"; - PROGMEM Language_Str MSG_BED_MAPPING_INCOMPLETE = u8"Not all points probed"; - PROGMEM Language_Str MSG_LEVELING = u8"Leveling"; - PROGMEM Language_Str MSG_AXIS_LEVELING = u8"Axis Leveling"; - PROGMEM Language_Str MSG_PROBE_BED = u8"Probe Mesh"; - PROGMEM Language_Str MSG_PRINT_TEST = u8"Print Test (PLA)"; - PROGMEM Language_Str MSG_MOVE_Z_TO_TOP = u8"Raise Z to Top"; + LSTR MSG_TOUCH_CALIBRATION_START = u8"Release to begin screen calibration"; + LSTR MSG_TOUCH_CALIBRATION_PROMPT = u8"Touch the dots to calibrate"; + LSTR MSG_BED_MAPPING_DONE = u8"Bed mapping finished"; + LSTR MSG_BED_MAPPING_INCOMPLETE = u8"Not all points probed"; + LSTR MSG_LEVELING = u8"Leveling"; + LSTR MSG_AXIS_LEVELING = u8"Axis Leveling"; + 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"; #if ENABLED(TOUCH_UI_LULZBOT_BIO) - PROGMEM Language_Str MSG_MOVE_TO_HOME = u8"Move to Home"; - PROGMEM Language_Str MSG_RAISE_PLUNGER = u8"Raise Plunger"; - PROGMEM Language_Str MSG_RELEASE_XY_AXIS = u8"Release X and Y Axis"; - PROGMEM Language_Str MSG_BED_TEMPERATURE = u8"Bed Temperature"; - PROGMEM Language_Str MSG_HOME_XYZ_WARNING = u8"About to move to home position. Ensure the top and the bed of the printer are clear.\n\nContinue?"; - PROGMEM Language_Str MSG_HOME_E_WARNING = u8"About to re-home plunger and auto-level. Remove syringe prior to proceeding.\n\nContinue?"; + LSTR MSG_MOVE_TO_HOME = u8"Move to Home"; + LSTR MSG_RAISE_PLUNGER = u8"Raise Plunger"; + LSTR MSG_RELEASE_XY_AXIS = u8"Release X and Y Axis"; + LSTR MSG_BED_TEMPERATURE = u8"Bed Temperature"; + LSTR MSG_HOME_XYZ_WARNING = u8"About to move to home position. Ensure the top and the bed of the printer are clear.\n\nContinue?"; + LSTR MSG_HOME_E_WARNING = u8"About to re-home plunger and auto-level. Remove syringe prior to proceeding.\n\nContinue?"; #endif #ifdef TOUCH_UI_COCOA_PRESS - PROGMEM Language_Str MSG_BODY = u8"Body"; - PROGMEM Language_Str MSG_SELECT_CHOCOLATE_TYPE = u8"Select Chocolate Type"; - PROGMEM Language_Str MSG_EXTERNAL = u8"External"; - PROGMEM Language_Str MSG_CHOCOLATE = u8"Chocolate"; - PROGMEM Language_Str MSG_UNLOAD_CARTRIDGE = u8"Unload Cartridge"; - PROGMEM Language_Str MSG_LOAD_UNLOAD = u8"Load/Unload"; - PROGMEM Language_Str MSG_FULL_LOAD = u8"Full Load"; - PROGMEM Language_Str MSG_FULL_UNLOAD = u8"Full Unload"; - PROGMEM Language_Str MSG_PREHEAT_CHOCOLATE = u8"Preheat Chocolate"; - PROGMEM Language_Str MSG_PREHEAT_FINISHED = u8"Preheat finished"; - PROGMEM Language_Str MSG_PREHEAT = u8"Preheat"; - PROGMEM Language_Str MSG_BUTTON_PAUSE = u8"Pause"; - PROGMEM Language_Str MSG_BUTTON_RESUME = u8"Resume"; - PROGMEM Language_Str MSG_ELAPSED_PRINT = u8"Elapsed Print"; - PROGMEM Language_Str MSG_XYZ_MOVE = u8"XYZ Move"; - PROGMEM Language_Str MSG_E_MOVE = u8"Extrusion Move"; + LSTR MSG_BODY = u8"Body"; + LSTR MSG_SELECT_CHOCOLATE_TYPE = u8"Select Chocolate Type"; + LSTR MSG_EXTERNAL = u8"External"; + 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_PREHEAT_CHOCOLATE = u8"Preheat Chocolate"; + LSTR MSG_PREHEAT_FINISHED = u8"Preheat finished"; + LSTR MSG_PREHEAT = u8"Preheat"; + LSTR MSG_BUTTON_PAUSE = u8"Pause"; + LSTR MSG_BUTTON_RESUME = u8"Resume"; + LSTR MSG_ELAPSED_PRINT = u8"Elapsed Print"; + LSTR MSG_XYZ_MOVE = u8"XYZ Move"; + LSTR MSG_E_MOVE = u8"Extrusion Move"; #endif }; // namespace Language_en diff --git a/Marlin/src/lcd/extui/malyan/malyan.cpp b/Marlin/src/lcd/extui/malyan/malyan.cpp index df7f305df2be..06c9886f0131 100644 --- a/Marlin/src/lcd/extui/malyan/malyan.cpp +++ b/Marlin/src/lcd/extui/malyan/malyan.cpp @@ -24,7 +24,7 @@ * lcd/extui/malyan/malyan.cpp * * LCD implementation for Malyan's LCD, a separate ESP8266 MCU running - * on Serial1 for the M200 board. This module outputs a pseudo-gcode + * on Serial1 for the M200 board. This module outputs a pseudo-G-code * wrapped in curly braces which the LCD implementation translates into * actual G-code commands. * diff --git a/Marlin/src/lcd/extui/malyan/malyan_extui.cpp b/Marlin/src/lcd/extui/malyan/malyan_extui.cpp index f323728e2747..945ff472e1a1 100644 --- a/Marlin/src/lcd/extui/malyan/malyan_extui.cpp +++ b/Marlin/src/lcd/extui/malyan/malyan_extui.cpp @@ -141,17 +141,18 @@ namespace ExtUI { void onFilamentRunout(const extruder_t extruder) {} void onUserConfirmRequired(const char * const) {} void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() {} + void onHomingDone() {} + void onPrintDone() {} void onFactoryReset() {} void onStoreSettings(char*) {} void onLoadSettings(const char*) {} void onPostprocessSettings() {} - void onConfigurationStoreWritten(bool) {} - void onConfigurationStoreRead(bool) {} + void onSettingsStored(bool) {} + void onSettingsLoaded(bool) {} #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval) {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) {} #endif diff --git a/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h b/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h index 4683ff935187..72394286ac58 100644 --- a/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h +++ b/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h @@ -96,12 +96,12 @@ class SPIFlashStorage { static uint8_t m_pageData[SPI_FLASH_PageSize]; static uint32_t m_currentPage; static uint16_t m_pageDataUsed; - static inline uint16_t pageDataFree() { return SPI_FLASH_PageSize - m_pageDataUsed; } + static uint16_t pageDataFree() { return SPI_FLASH_PageSize - m_pageDataUsed; } static uint32_t m_startAddress; #if HAS_SPI_FLASH_COMPRESSION static uint8_t m_compressedData[SPI_FLASH_PageSize]; static uint16_t m_compressedDataUsed; - static inline uint16_t compressedDataFree() { return SPI_FLASH_PageSize - m_compressedDataUsed; } + static uint16_t compressedDataFree() { return SPI_FLASH_PageSize - m_compressedDataUsed; } #endif }; diff --git a/Marlin/src/lcd/extui/mks_ui/draw_level_settings.cpp b/Marlin/src/lcd/extui/mks_ui/draw_level_settings.cpp index 93d34a85785c..c047e322d6c8 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_level_settings.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_level_settings.cpp @@ -36,7 +36,8 @@ enum { ID_LEVEL_RETURN = 1, ID_LEVEL_POSITION, ID_LEVEL_COMMAND, - ID_LEVEL_ZOFFSET + ID_LEVEL_ZOFFSET, + ID_Z_OFFSET_WIZARD }; static void event_handler(lv_obj_t *obj, lv_event_t event) { @@ -57,6 +58,11 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { case ID_LEVEL_ZOFFSET: lv_draw_auto_level_offset_settings(); break; + #if ENABLED(PROBE_OFFSET_WIZARD) + case ID_Z_OFFSET_WIZARD: + lv_draw_z_offset_wizard(); + break; + #endif #endif } } @@ -67,6 +73,9 @@ void lv_draw_level_settings() { lv_screen_menu_item(scr, machine_menu.LevelingAutoCommandConf, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_LEVEL_COMMAND, 1); #if HAS_BED_PROBE lv_screen_menu_item(scr, machine_menu.LevelingAutoZoffsetConf, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_LEVEL_ZOFFSET, 2); + #if ENABLED(PROBE_OFFSET_WIZARD) + lv_screen_menu_item(scr, machine_menu.LevelingZoffsetTitle, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_Z_OFFSET_WIZARD, 3); + #endif #endif lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACK_POS_X + 10, PARA_UI_BACK_POS_Y, event_handler, ID_LEVEL_RETURN, true); } diff --git a/Marlin/src/lcd/extui/mks_ui/draw_print_file.cpp b/Marlin/src/lcd/extui/mks_ui/draw_print_file.cpp index ebad70859741..0199bc1f555d 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_print_file.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_print_file.cpp @@ -369,7 +369,7 @@ uint32_t lv_open_gcode_file(char *path) { card.openFileRead(cur_name); card.read(public_buf, 512); ps4 = (uint32_t *)strstr((char *)public_buf, ";simage:"); - // Ignore the beginning message of gcode file + // Ignore the beginning message of G-code file if (ps4) { pre_sread_cnt = (uintptr_t)ps4 - (uintptr_t)((uint32_t *)(&public_buf[0])); card.setIndex(pre_sread_cnt); @@ -402,7 +402,7 @@ void lv_gcode_file_read(uint8_t *data_buf) { char temp_test[200]; volatile uint16_t *p_index; - watchdog_refresh(); + hal.watchdog_refresh(); memset(public_buf, 0, 200); while (card.isFileOpen()) { @@ -490,7 +490,7 @@ void cutFileName(char *path, int len, int bytePerLine, char *outStr) { //&& (strIndex2 != 0) && (strIndex1 < strIndex2) ) ? strIndex1 + 1 : tmpFile; - if (strIndex2 == 0 || (strIndex1 > strIndex2)) { // not gcode file + if (strIndex2 == 0 || (strIndex1 > strIndex2)) { // not G-code file #if _LFN_UNICODE if (wcslen(beginIndex) > len) wcsncpy(outStr, beginIndex, len); @@ -503,7 +503,7 @@ void cutFileName(char *path, int len, int bytePerLine, char *outStr) { strcpy(outStr, beginIndex); #endif } - else { // gcode file + else { // G-code file if (strIndex2 - beginIndex > (len - 2)) { #if _LFN_UNICODE wcsncpy(outStr, (const WCHAR *)beginIndex, len - 3); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp b/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp index 1596944bd899..39f270840be4 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp @@ -196,7 +196,7 @@ void lv_draw_ready_print() { buttonExt2 = lv_big_button_create(scr, "F:/bmp_ext2_state.bin", " ", 180, ICON_POS_Y, event_handler, ID_INFO_EXT); #endif #if HAS_HEATED_BED - buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", TERN(HAS_MULTI_HOTEND, 271, 210), ICON_POS_Y, event_handler, ID_INFO_BED); + buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", TERN(HAS_MULTI_HOTEND, 340, 210), ICON_POS_Y, event_handler, ID_INFO_BED); #endif TERN_(HAS_HOTEND, labelExt1 = lv_label_create_empty(scr)); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp index 66b2deda6605..6a8333fd66df 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.cpp @@ -159,7 +159,7 @@ void gCfgItems_init() { gCfgItems.spi_flash_flag = FLASH_INF_VALID_FLAG; W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR); W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems)); - // init gcode command + // Init G-code command W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[0], AUTO_LEVELING_COMMAND_ADDR, 100); W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[1], OTHERS_COMMAND_ADDR_1, 100); W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[2], OTHERS_COMMAND_ADDR_2, 100); @@ -238,7 +238,7 @@ void update_spi_flash() { uint8_t command_buf[512]; W25QXX.init(SPI_QUARTER_SPEED); - // read back the gcode command before erase spi flash + // read back the G-code command before erase spi flash W25QXX.SPI_FLASH_BufferRead((uint8_t *)&command_buf, GCODE_COMMAND_ADDR, sizeof(command_buf)); W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR); W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems)); @@ -249,7 +249,7 @@ void update_gcode_command(int addr, uint8_t *s) { uint8_t command_buf[512]; W25QXX.init(SPI_QUARTER_SPEED); - // read back the gcode command before erase spi flash + // read back the G-code command before erase spi flash W25QXX.SPI_FLASH_BufferRead((uint8_t *)&command_buf, GCODE_COMMAND_ADDR, sizeof(command_buf)); W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR); W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems)); @@ -456,6 +456,10 @@ char *getDispText(int index) { } break; case MOVE_MOTOR_UI: strcpy(public_buf_l, move_menu.title); break; + + #if ENABLED(PROBE_OFFSET_WIZARD) + case Z_OFFSET_WIZARD_UI: break; + #endif case OPERATE_UI: switch (disp_state_stack._disp_state[disp_state_stack._disp_index]) { IF_DISABLED(TFT35, case OPERATE_UI: case PAUSE_UI:) @@ -785,6 +789,10 @@ void GUI_RefreshPage() { case MOVE_MOTOR_UI: break; + #if ENABLED(PROBE_OFFSET_WIZARD) + case Z_OFFSET_WIZARD_UI: break; + #endif + #if ENABLED(MKS_WIFI_MODULE) case WIFI_UI: if (temps_update_flag) { @@ -885,6 +893,9 @@ void clear_cur_ui() { case PRINT_FILE_UI: lv_clear_print_file(); break; case PRINTING_UI: lv_clear_printing(); break; case MOVE_MOTOR_UI: lv_clear_move_motor(); break; + #if ENABLED(PROBE_OFFSET_WIZARD) + case Z_OFFSET_WIZARD_UI: lv_clear_z_offset_wizard(); break; + #endif case OPERATE_UI: lv_clear_operation(); break; case PAUSE_UI: break; case EXTRUSION_UI: lv_clear_extrusion(); break; @@ -993,6 +1004,9 @@ void draw_return_ui() { break; case MOVE_MOTOR_UI: lv_draw_move_motor(); break; + #if ENABLED(PROBE_OFFSET_WIZARD) + case Z_OFFSET_WIZARD_UI: lv_draw_z_offset_wizard(); break; + #endif case OPERATE_UI: lv_draw_operation(); break; case PAUSE_UI: break; case EXTRUSION_UI: lv_draw_extrusion(); break; @@ -1331,7 +1345,6 @@ void lv_screen_menu_item_onoff_update(lv_obj_t *btn, const bool curValue) { lv_label_set_text((lv_obj_t*)btn->child_ll.head, curValue ? machine_menu.enable : machine_menu.disable); } - #if ENABLED(SDSUPPORT) void sd_detection() { @@ -1360,7 +1373,9 @@ void print_time_count() { } void LV_TASK_HANDLER() { - lv_task_handler(); + + if (TERN1(USE_SPI_DMA_TC, !get_lcd_dma_lock())) + lv_task_handler(); #if BOTH(MKS_TEST, SDSUPPORT) if (mks_test_flag == 0x1E) mks_hardware_test(); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_ui.h b/Marlin/src/lcd/extui/mks_ui/draw_ui.h index 950386f878e5..798e662220ef 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_ui.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_ui.h @@ -69,6 +69,7 @@ #include "draw_max_feedrate_settings.h" #include "draw_tmc_step_mode_settings.h" #include "draw_level_settings.h" +#include "draw_z_offset_wizard.h" #include "draw_tramming_pos_settings.h" #include "draw_auto_level_offset_settings.h" #include "draw_filament_change.h" @@ -266,6 +267,7 @@ typedef enum { PRINT_FILE_UI, PRINTING_UI, MOVE_MOTOR_UI, + Z_OFFSET_WIZARD_UI, OPERATE_UI, PAUSE_UI, EXTRUSION_UI, diff --git a/Marlin/src/lcd/extui/mks_ui/draw_z_offset_wizard.cpp b/Marlin/src/lcd/extui/mks_ui/draw_z_offset_wizard.cpp new file mode 100644 index 000000000000..d143234fd53e --- /dev/null +++ b/Marlin/src/lcd/extui/mks_ui/draw_z_offset_wizard.cpp @@ -0,0 +1,228 @@ +/** + * 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 BOTH(HAS_TFT_LVGL_UI, PROBE_OFFSET_WIZARD) + +#include "draw_ui.h" +#include + +#include "../../../gcode/queue.h" +#include "../../../module/motion.h" + +#include "../../../module/planner.h" +#include "../../../inc/MarlinConfig.h" +#include "../../../module/probe.h" + +#if HAS_LEVELING + #include "../../../feature/bedlevel/bedlevel.h" + bool leveling_was_active; +#endif + +extern lv_group_t *g; +static lv_obj_t *scr; + +static lv_obj_t *labelV, *buttonV, *labelP; +static lv_obj_t *labelP_z_offset_ref; +static lv_task_t *updatePosTask; +static char cur_label = 'Z'; +static float cur_pos = 0; +static float cur_OffsetPos = 0; + +// Global storage +float z_offset_backup, calculated_z_offset, z_offset_ref; + +enum { + ID_M_Z_P = 1, + ID_M_Z_N, + ID_M_STEP, + ID_M_SAVE, + ID_M_RETURN +}; + +void disp_cur_wizard_pos() { + char str_1[18]; + sprintf_P(public_buf_l, PSTR("%c:%s mm"), cur_label, dtostrf(cur_pos, 1, 3, str_1)); + if (labelP) lv_label_set_text(labelP, public_buf_l); + + sprintf_P(public_buf_l, PSTR("%c Offset:%s mm"), cur_label, dtostrf(cur_OffsetPos, 1, 3, str_1)); + if (labelP_z_offset_ref) lv_label_set_text(labelP_z_offset_ref, public_buf_l); +} + +static void event_handler(lv_obj_t *obj, lv_event_t event) { + char str_1[16]; + if (event != LV_EVENT_RELEASED) return; + //lv_clear_z_offset_wizard(); + if (!queue.ring_buffer.full(3)) { + bool do_inject = true; + float dist = uiCfg.move_dist; + switch (obj->mks_obj_id) { + case ID_M_Z_N: dist *= -1; case ID_M_Z_P: cur_label = 'Z'; break; + default: do_inject = false; + } + if (do_inject) { + sprintf_P(public_buf_l, PSTR("G91\nG1 %c%s F%d\nG90"), cur_label, dtostrf(dist, 1, 3, str_1), uiCfg.moveSpeed); + queue.inject(public_buf_l); + //calculated_z_offset = probe.offset.z + current_position.z - z_offset_ref; + disp_cur_wizard_pos(); + } + } + + switch (obj->mks_obj_id) { + case ID_M_STEP: + if (ABS((int)(10 * uiCfg.move_dist)) == 10) + uiCfg.move_dist = 0.025; + else if (ABS((int)(1000 * uiCfg.move_dist)) == 25) + uiCfg.move_dist = 0.1; + else + uiCfg.move_dist *= 10.0f; + disp_move_wizard_dist(); + break; + case ID_M_SAVE: + current_position.z = z_offset_ref; // Set Z to z_offset_ref, as we can expect it is at probe height + probe.offset.z = calculated_z_offset; + sync_plan_position(); + // Raise Z as if it was homed + do_z_clearance(Z_POST_CLEARANCE); + hal.watchdog_refresh(); + draw_return_ui(); + return; + case ID_M_RETURN: + probe.offset.z = z_offset_backup; + SET_SOFT_ENDSTOP_LOOSE(false); + TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active)); + #if HOMING_Z_WITH_PROBE && defined(PROBE_OFFSET_WIZARD_START_Z) + set_axis_never_homed(Z_AXIS); // On cancel the Z position needs correction + queue.inject_P(PSTR("G28Z")); + #else // Otherwise do a Z clearance move like after Homing + do_z_clearance(Z_POST_CLEARANCE); + #endif + hal.watchdog_refresh(); + draw_return_ui(); + return; + } + disp_cur_wizard_pos(); +} + +void refresh_wizard_pos(lv_task_t *) { + switch (cur_label) { + case 'Z': + cur_pos = current_position.z; + calculated_z_offset = probe.offset.z + current_position.z - z_offset_ref; + cur_OffsetPos = calculated_z_offset; + break; + default: return; + } + disp_cur_wizard_pos(); +} + +void lv_draw_z_offset_wizard() { + + set_all_unhomed(); + + // Store probe.offset.z for Case: Cancel + z_offset_backup = probe.offset.z; + + #ifdef PROBE_OFFSET_WIZARD_START_Z + probe.offset.z = PROBE_OFFSET_WIZARD_START_Z; + #endif + + // Store Bed-Leveling-State and disable + #if HAS_LEVELING + leveling_was_active = planner.leveling_active; + set_bed_leveling_enabled(leveling_was_active); + #endif + + queue.inject_P(PSTR("G28")); + + z_offset_ref = 0; // Set Z Value for Wizard Position to 0 + calculated_z_offset = probe.offset.z + current_position.z - z_offset_ref; + cur_OffsetPos = calculated_z_offset; + + scr = lv_screen_create(Z_OFFSET_WIZARD_UI, machine_menu.LevelingZoffsetTitle); + + lv_obj_t *buttonXI = lv_big_button_create(scr, "F:/bmp_zAdd.bin", move_menu.z_add, INTERVAL_V, titleHeight, event_handler, ID_M_Z_P); + lv_obj_clear_protect(buttonXI, LV_PROTECT_FOLLOW); + lv_big_button_create(scr, "F:/bmp_zDec.bin", move_menu.z_dec, INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_Z_N); + + // button with image and label changed dynamically by disp_move_dist + buttonV = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_M_STEP); + labelV = lv_label_create_empty(buttonV); + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonV); + #endif + + // save and back + lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_save, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_SAVE); + // cancel and back + 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_M_RETURN); + + // We need to patch the title to leave some space on the right for displaying the status + lv_obj_t * z_offset_ref_title = lv_obj_get_child_back(scr, nullptr); + if (z_offset_ref_title != nullptr) lv_obj_set_width(z_offset_ref_title, (int)(TFT_WIDTH / 2) - 101); + labelP_z_offset_ref = lv_label_create(scr, (int)(TFT_WIDTH / 2) - 80, (int)(TFT_HEIGHT/2)-20, "Z Offset:0.0mm"); + + // We need to patch the Z Offset to leave some space in the middle for displaying the status + lv_obj_t * title= lv_obj_get_child_back(scr, nullptr); + if (title != nullptr) lv_obj_set_width(title, TFT_WIDTH - 101); + labelP = lv_label_create(scr, TFT_WIDTH - 100, TITLE_YPOS, "Z:0.0mm"); + + if (labelP != nullptr) + updatePosTask = lv_task_create(refresh_wizard_pos, 300, LV_TASK_PRIO_LOWEST, 0); + + disp_move_wizard_dist(); + disp_cur_wizard_pos(); +} + +void disp_move_wizard_dist() { + if ((int)(1000 * uiCfg.move_dist) == 25) + lv_imgbtn_set_src_both(buttonV, "F:/bmp_step_move0_1.bin"); + else if ((int)(10 * uiCfg.move_dist) == 1) + lv_imgbtn_set_src_both(buttonV, "F:/bmp_step_move1.bin"); + else if ((int)(10 * uiCfg.move_dist) == 10) + lv_imgbtn_set_src_both(buttonV, "F:/bmp_step_move10.bin"); + + if (gCfgItems.multiple_language) { + if ((int)(1000 * uiCfg.move_dist) == 25) { + lv_label_set_text(labelV, move_menu.step_0025mm); + lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + else if ((int)(10 * uiCfg.move_dist) == 1) { + lv_label_set_text(labelV, move_menu.step_01mm); + lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + else if ((int)(10 * uiCfg.move_dist) == 10) { + lv_label_set_text(labelV, move_menu.step_1mm); + lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET); + } + } +} + +void lv_clear_z_offset_wizard() { + #if HAS_ROTARY_ENCODER + if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g); + #endif + lv_obj_del(scr); +} + +#endif // HAS_TFT_LVGL_UI && PROBE_OFFSET_WIZARD diff --git a/Marlin/src/HAL/ESP32/watchdog.h b/Marlin/src/lcd/extui/mks_ui/draw_z_offset_wizard.h similarity index 74% rename from Marlin/src/HAL/ESP32/watchdog.h rename to Marlin/src/lcd/extui/mks_ui/draw_z_offset_wizard.h index 43db8130763f..47a3d69c46d9 100644 --- a/Marlin/src/HAL/ESP32/watchdog.h +++ b/Marlin/src/lcd/extui/mks_ui/draw_z_offset_wizard.h @@ -1,6 +1,6 @@ /** * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 @@ -22,17 +22,15 @@ #pragma once #ifdef __cplusplus - extern "C" { + extern "C" { /* C-declarations for C++ */ #endif - esp_err_t esp_task_wdt_reset(); +void lv_draw_z_offset_wizard(); +void refresh_wizard_pos(); +void disp_cur_wizard_pos(); +void disp_move_wizard_dist(); +void lv_clear_z_offset_wizard(); #ifdef __cplusplus - } + } /* C-declarations for C++ */ #endif - -// Initialize watchdog with a 4 second interrupt time -void watchdog_init(); - -// Reset watchdog. -inline void HAL_watchdog_refresh() { esp_task_wdt_reset(); } diff --git a/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp b/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp index 4305462162ca..c679751ebe90 100644 --- a/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp +++ b/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp @@ -45,7 +45,7 @@ #if PIN_EXISTS(MT_DET_2) bool mt_det2_sta; #endif - #if HAS_X_MIN || HAS_X_MAX + #if X_HOME_DIR bool endstopx1_sta; #else constexpr static bool endstopx1_sta = true; @@ -55,7 +55,7 @@ #else constexpr static bool endstopx2_sta = true; #endif - #if HAS_Y_MIN || HAS_Y_MAX + #if HAS_Y_AXIS && Y_HOME_DIR bool endstopy1_sta; #else constexpr static bool endstopy1_sta = true; @@ -65,7 +65,7 @@ #else constexpr static bool endstopy2_sta = true; #endif - #if HAS_Z_MIN || HAS_Z_MAX + #if HAS_Z_AXIS && Z_HOME_DIR bool endstopz1_sta; #else constexpr static bool endstopz1_sta = true; @@ -160,6 +160,8 @@ #endif } + #include "../../../libs/buzzer.h" + void init_test_gpio() { endstops.init(); @@ -201,12 +203,7 @@ #endif } - void mks_test_beeper() { - WRITE(BEEPER_PIN, HIGH); - delay(100); - WRITE(BEEPER_PIN, LOW); - delay(100); - } + void mks_test_beeper() { buzzer.click(100); } #if ENABLED(SDSUPPORT) diff --git a/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp b/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp index ba2df10ecbd9..c618127980bb 100644 --- a/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp +++ b/Marlin/src/lcd/extui/mks_ui/pic_manager.cpp @@ -267,12 +267,12 @@ void spiFlashErase_PIC() { W25QXX.init(SPI_QUARTER_SPEED); // erase 0x001000 -64K for (pic_sectorcnt = 0; pic_sectorcnt < (64 - 4) / 4; pic_sectorcnt++) { - watchdog_refresh(); + hal.watchdog_refresh(); W25QXX.SPI_FLASH_SectorErase(PICINFOADDR + pic_sectorcnt * 4 * 1024); } // erase 64K -- 6M for (pic_sectorcnt = 0; pic_sectorcnt < (PIC_SIZE_xM * 1024 / 64 - 1); pic_sectorcnt++) { - watchdog_refresh(); + hal.watchdog_refresh(); W25QXX.SPI_FLASH_BlockErase((pic_sectorcnt + 1) * 64 * 1024); } } @@ -282,7 +282,7 @@ void spiFlashErase_PIC() { volatile uint32_t Font_sectorcnt = 0; W25QXX.init(SPI_QUARTER_SPEED); for (Font_sectorcnt = 0; Font_sectorcnt < 32 - 1; Font_sectorcnt++) { - watchdog_refresh(); + hal.watchdog_refresh(); W25QXX.SPI_FLASH_BlockErase(FONTINFOADDR + Font_sectorcnt * 64 * 1024); } } @@ -414,7 +414,7 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) { return; } - watchdog_refresh(); + hal.watchdog_refresh(); disp_assets_update_progress(fn); W25QXX.init(SPI_QUARTER_SPEED); @@ -427,21 +427,21 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) { totalSizeLoaded += pfileSize; if (assetType == ASSET_TYPE_LOGO) { do { - watchdog_refresh(); + hal.watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); Pic_Logo_Write((uint8_t*)fn, public_buf, pbr); } while (pbr >= BMP_WRITE_BUF_LEN); } else if (assetType == ASSET_TYPE_TITLE_LOGO) { do { - watchdog_refresh(); + hal.watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); Pic_TitleLogo_Write((uint8_t*)fn, public_buf, pbr); } while (pbr >= BMP_WRITE_BUF_LEN); } else if (assetType == ASSET_TYPE_G_PREVIEW) { do { - watchdog_refresh(); + hal.watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); default_view_Write(public_buf, pbr); } while (pbr >= BMP_WRITE_BUF_LEN); @@ -451,7 +451,7 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) { SPIFlash.beginWrite(Pic_Write_Addr); #if HAS_SPI_FLASH_COMPRESSION do { - watchdog_refresh(); + hal.watchdog_refresh(); pbr = file.read(public_buf, SPI_FLASH_PageSize); TERN_(MARLIN_DEV_MODE, totalSizes += pbr); SPIFlash.writeData(public_buf, SPI_FLASH_PageSize); @@ -472,7 +472,7 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) { else if (assetType == ASSET_TYPE_FONT) { Pic_Write_Addr = UNIGBK_FLASH_ADDR; do { - watchdog_refresh(); + hal.watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); W25QXX.SPI_FLASH_BufferWrite(public_buf, Pic_Write_Addr, pbr); Pic_Write_Addr += pbr; @@ -493,11 +493,11 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) { disp_assets_update(); disp_assets_update_progress(F("Erasing pics...")); - watchdog_refresh(); + hal.watchdog_refresh(); spiFlashErase_PIC(); #if HAS_SPI_FLASH_FONT disp_assets_update_progress(F("Erasing fonts...")); - watchdog_refresh(); + hal.watchdog_refresh(); spiFlashErase_FONT(); #endif diff --git a/Marlin/src/lcd/extui/mks_ui/pic_manager.h b/Marlin/src/lcd/extui/mks_ui/pic_manager.h index 320cb20b0b8d..cdcc5b76b8a9 100644 --- a/Marlin/src/lcd/extui/mks_ui/pic_manager.h +++ b/Marlin/src/lcd/extui/mks_ui/pic_manager.h @@ -122,7 +122,7 @@ #define VAR_INF_ADDR 0x000000 #define FLASH_INF_VALID_FLAG 0x20201118 -// Store some gcode commands, such as auto leveling commands +// Store some G-code commands, such as auto-leveling commands #define GCODE_COMMAND_ADDR VAR_INF_ADDR + 3 * 1024 #define AUTO_LEVELING_COMMAND_ADDR GCODE_COMMAND_ADDR #define OTHERS_COMMAND_ADDR_1 AUTO_LEVELING_COMMAND_ADDR + 100 diff --git a/Marlin/src/lcd/extui/mks_ui/tft_Language_en.h b/Marlin/src/lcd/extui/mks_ui/tft_Language_en.h index a41864eec479..5195986e3584 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_Language_en.h +++ b/Marlin/src/lcd/extui/mks_ui/tft_Language_en.h @@ -103,6 +103,8 @@ #define LEVELING_AUTO_COMMAND_EN "AutoLeveling command settings" #define LEVELING_AUTO_ZOFFSET_EN "Nozzle-to-probe offsets settings" +#define LEVELING_ZOFFSET_TITLE_EN "Machine Settings>Z Offset Wizard" + #define LEVELING_PARA_CONF_TITLE_EN "leveling setting" #define AUTO_LEVELING_ENABLE_EN "Enable auto leveling" #define BLTOUCH_LEVELING_ENABLE_EN "Enable BLTouch" @@ -293,6 +295,7 @@ #define CLOSE_TEXT_EN "Close" #define BACK_TEXT_EN "Back" +#define SAVE_TEXT_EN "Save" #define TOOL_PREHEAT_EN "Preheat" #define TOOL_EXTRUDE_EN "Extrusion" diff --git a/Marlin/src/lcd/extui/mks_ui/tft_Language_ru.h b/Marlin/src/lcd/extui/mks_ui/tft_Language_ru.h index 12c600f0886e..da36ed14c771 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_Language_ru.h +++ b/Marlin/src/lcd/extui/mks_ui/tft_Language_ru.h @@ -24,9 +24,9 @@ //****************俄语***************************// #define TOOL_TEXT_RU "инструмент" #define PREHEAT_TEXT_RU " нагрев" -#define MOVE_TEXT_RU "движение" -#define HOME_TEXT_RU "домой" -#define PRINT_TEXT_RU " печать" +#define MOVE_TEXT_RU "двигать" +#define HOME_TEXT_RU "дом" +#define PRINT_TEXT_RU "печать" #define EXTRUDE_TEXT_RU "экструзия" #define LEVELING_TEXT_RU "уровень" #define AUTO_LEVELING_TEXT_RU "aвтоуровень" @@ -40,17 +40,17 @@ #define EXTRUDER_1_TEXT_RU "экструдер1" #define EXTRUDER_2_TEXT_RU "экструдер2" #define HEATBED_TEXT_RU "стол" -#define TEXT_1C_RU "1℃" -#define TEXT_5C_RU "5℃" -#define TEXT_10C_RU "10℃" +#define TEXT_1C_RU "1°Ц" +#define TEXT_5C_RU "5°Ц" +#define TEXT_10C_RU "10°Ц" #define CLOSE_TEXT_RU "выкл" #define BACK_TEXT_RU "назад" #define TOOL_PREHEAT_RU "нагрев" #define TOOL_EXTRUDE_RU "экструдер" -#define TOOL_MOVE_RU "движение" -#define TOOL_HOME_RU "домой" +#define TOOL_MOVE_RU "двигать" +#define TOOL_HOME_RU "дом" #define TOOL_LEVELING_RU "уровень" #define TOOL_AUTO_LEVELING_RU "aвтоуровень" #define TOOL_FILAMENT_RU "замена" @@ -62,33 +62,33 @@ #define AXIS_Y_DEC_TEXT_RU "Y -" #define AXIS_Z_ADD_TEXT_RU "Z +" #define AXIS_Z_DEC_TEXT_RU "Z -" -#define TEXT_01MM_RU "0.1 mm" -#define TEXT_1MM_RU "1 mm" -#define TEXT_10MM_RU "10 mm" +#define TEXT_01MM_RU "0.1 мм" +#define TEXT_1MM_RU "1 мм" +#define TEXT_10MM_RU "10 мм" #define HOME_X_TEXT_RU "X" #define HOME_Y_TEXT_RU "Y" #define HOME_Z_TEXT_RU "Z" -#define HOME_ALL_TEXT_RU "Home" -#define HOME_STOPMOVE_RU "Quickstop" +#define HOME_ALL_TEXT_RU "Дом" +#define HOME_STOPMOVE_RU "Концевик" #define PAGE_UP_TEXT_RU "вверх" #define PAGE_DOWN_TEXT_RU "вниз" #define EXTRUDER_IN_TEXT_RU "втянуть" #define EXTRUDER_OUT_TEXT_RU "выдавить" -#define EXTRUDE_1MM_TEXT_RU "1 mm" -#define EXTRUDE_5MM_TEXT_RU "5 mm" -#define EXTRUDE_10MM_TEXT_RU "10 mm" -#define EXTRUDE_LOW_SPEED_TEXT_RU "мин" -#define EXTRUDE_MEDIUM_SPEED_TEXT_RU "сред" -#define EXTRUDE_HIGH_SPEED_TEXT_RU "выс" - -#define LEVELING_POINT1_TEXT_RU "1 точка" -#define LEVELING_POINT2_TEXT_RU "2 точка" -#define LEVELING_POINT3_TEXT_RU "3 точка" -#define LEVELING_POINT4_TEXT_RU "4 точка" -#define LEVELING_POINT5_TEXT_RU "5 точка" +#define EXTRUDE_1MM_TEXT_RU "1 мм" +#define EXTRUDE_5MM_TEXT_RU "5 мм" +#define EXTRUDE_10MM_TEXT_RU "10 мм" +#define EXTRUDE_LOW_SPEED_TEXT_RU "минимум" +#define EXTRUDE_MEDIUM_SPEED_TEXT_RU "средний" +#define EXTRUDE_HIGH_SPEED_TEXT_RU "высокий" + +#define LEVELING_POINT1_TEXT_RU "Первая позиция" +#define LEVELING_POINT2_TEXT_RU "Вторая позиция" +#define LEVELING_POINT3_TEXT_RU "Третья позиция" +#define LEVELING_POINT4_TEXT_RU "Четвёртое позиция" +#define LEVELING_POINT5_TEXT_RU "Пятая позиция" #define FILESYS_TEXT_RU "система" #define WIFI_TEXT_RU "WiFi" @@ -115,7 +115,7 @@ #define WIFI_RECONNECT_TEXT_RU "выбор сети" #define CLOUD_TEXT_RU "облако" #define CLOUD_BIND_RU "соединён" -#define CLOUD_UNBIND_RU "отсоед." +#define CLOUD_UNBIND_RU "отсоединён" #define CLOUD_UNBINDING_RU "отвязано" #define CLOUD_DISCONNECTED_RU "отключено" #define CLOUD_UNBINDED_RU "несвяз." @@ -126,7 +126,7 @@ #define FAN_DEC_TEXT_RU "уменьшить" #define FAN_OPEN_TEXT_RU "100%" #define FAN_HALF_TEXT_RU "50%" -#define FAN_CLOSE_TEXT_RU "откл" +#define FAN_CLOSE_TEXT_RU "отключить" #define FAN_TIPS1_TEXT_RU "вентилятор" #define FAN_TIPS2_TEXT_RU "вентилятор\nоткл" @@ -156,7 +156,7 @@ #define PRE_HEAT_EXT_TEXT_RU "E" #define PRE_HEAT_BED_TEXT_RU "стол" -#define FILE_LOADING_RU "загрузка......" +#define FILE_LOADING_RU "загрузка" #define NO_FILE_AND_CHECK_RU "нет файла,попробуйте ещё раз!" #define NO_FILE_RU "нет файла!" @@ -170,11 +170,11 @@ #define ABOUT_VERSION_TEXT_RU "Firmware: " #define ABOUT_WIFI_TEXT_RU "WiFi: " -#define PRINTING_OPERATION_RU "опции" +#define PRINTING_OPERATION_RU "опций" #define PRINTING_PAUSE_RU "пауза" #define PRINTING_TEMP_RU "темп" -#define PRINTING_CHANGESPEED_RU "скорости" -#define PRINTING_RESUME_RU "возобн. " +#define PRINTING_CHANGESPEED_RU "скорост" +#define PRINTING_RESUME_RU "возобновить" #define PRINTING_STOP_RU "стоп" #define PRINTING_MORE_RU "больше" #define PRINTING_EXTRUDER_RU "экстр" @@ -222,8 +222,8 @@ #define DIALOG_RETRY_RU "повтор" #define DIALOG_DISABLE_RU "запретить" #define DIALOG_PRINT_MODEL_RU "печать модели?" -#define DIALOG_CANCEL_PRINT_RU "стоп?" -#define DIALOG_STOP_RU "стоп" +#define DIALOG_CANCEL_PRINT_RU "Остановить?" +#define DIALOG_STOP_RU "Остановить" #define DIALOG_REPRINT_FROM_BREAKPOINT_RU "продолжить?" #define DIALOG_ERROR_TIPS1_RU "ошибка:нет файла, попробуйте ещё раз." #define DIALOG_ERROR_TIPS2_RU "ошибка:сбой передачи. установите скорость \nпередачи данных как на плате управления!" @@ -236,8 +236,8 @@ #define DIALOG_REPRINT_RU "Print again" #define DIALOG_WIFI_ENABLE_TIPS_RU "The wifi module is being configured,\nplease wait a moment....." -#define MESSAGE_PAUSING_RU "Стоянка..." -#define MESSAGE_CHANGING_RU "Подождите, пока начнется смена филамента" +#define MESSAGE_PAUSING_RU "Пауза" +#define MESSAGE_CHANGING_RU "Подождите" #define MESSAGE_UNLOAD_RU "Дождитесь выгрузки нити" #define MESSAGE_WAITING_RU "Нажмите кнопку,чтобы возобновить печать" #define MESSAGE_INSERT_RU "Вставьте нить и нажмите кнопку,чтобы продолжить" @@ -250,7 +250,7 @@ #define MESSAGE_PURGE_MORE_RU "чистка" #define MESSAGE_CONTINUE_PRINT_RU "Распечатать" #define EEPROM_SETTINGS_TITLE_RU "Настройки EEPROM" -#define EEPROM_SETTINGS_STORE_RU "Cохранение настроек в EEPROM" +#define EEPROM_SETTINGS_STORE_RU "Cохранить настройки в EEPROM" #define EEPROM_SETTINGS_READ_RU "Чтение настроек из EEPROM" #define EEPROM_SETTINGS_REVERT_RU "Bосстановить заводские настройки по умолчанию" @@ -272,7 +272,7 @@ #define DISABLE_RU "нет" #define KEY_CONFIRM_RU "OK" -#define MACHINE_PARA_TITLE_RU "настройки" +#define MACHINE_PARA_TITLE_RU "Настройки" #define MACHINE_TYPE_CNOFIG_RU "Hастройки принтера" #define MOTOR_CONFIG_RU "Hастройки моторов" #define MACHINE_LEVELING_CONFIG_RU "Hастройки уровня" 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 837d7470d600..38612358110b 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp +++ b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp @@ -125,21 +125,37 @@ void tft_lvgl_init() { ui_cfg_init(); disp_language_init(); - watchdog_refresh(); // LVGL init takes time - - #if MB(MKS_ROBIN_NANO) - OUT_WRITE(PB0, LOW); // HE1 - #endif + hal.watchdog_refresh(); // LVGL init takes time // Init TFT first! SPI_TFT.spi_init(SPI_FULL_SPEED); SPI_TFT.LCD_init(); - watchdog_refresh(); // LVGL init takes time + hal.watchdog_refresh(); // LVGL init takes time + + #if ENABLED(USB_FLASH_DRIVE_SUPPORT) + 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); + #endif + do { + card.media_driver_usbFlash.idle(); + hal.watchdog_refresh(); + delay(2); + } while (!card.media_driver_usbFlash.isInserted() && usb_flash_loop--); + card.mount(); + #elif HAS_LOGO_IN_FLASH + delay(1000); + hal.watchdog_refresh(); + delay(1000); + #endif + + hal.watchdog_refresh(); // LVGL init takes time #if ENABLED(SDSUPPORT) UpdateAssets(); - watchdog_refresh(); // LVGL init takes time + hal.watchdog_refresh(); // LVGL init takes time TERN_(MKS_TEST, mks_test_get()); #endif @@ -235,19 +251,44 @@ void tft_lvgl_init() { #endif } +static lv_disp_drv_t* disp_drv_p; + +#if ENABLED(USE_SPI_DMA_TC) + bool lcd_dma_trans_lock = false; +#endif + +void dmc_tc_handler(struct __DMA_HandleTypeDef * hdma) { + #if ENABLED(USE_SPI_DMA_TC) + lv_disp_flush_ready(disp_drv_p); + lcd_dma_trans_lock = false; + TFT_SPI::Abort(); + #endif +} + void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) { uint16_t width = area->x2 - area->x1 + 1, height = area->y2 - area->y1 + 1; - SPI_TFT.setWindow((uint16_t)area->x1, (uint16_t)area->y1, width, height); + disp_drv_p = disp; - SPI_TFT.tftio.WriteSequence((uint16_t*)color_p, width * height); + SPI_TFT.setWindow((uint16_t)area->x1, (uint16_t)area->y1, width, height); - lv_disp_flush_ready(disp); // Indicate you are ready with the flushing + #if ENABLED(USE_SPI_DMA_TC) + lcd_dma_trans_lock = true; + SPI_TFT.tftio.WriteSequenceIT((uint16_t*)color_p, width * height); + TFT_SPI::DMAtx.XferCpltCallback = dmc_tc_handler; + #else + SPI_TFT.tftio.WriteSequence((uint16_t*)color_p, width * height); + lv_disp_flush_ready(disp_drv_p); // Indicate you are ready with the flushing + #endif W25QXX.init(SPI_QUARTER_SPEED); } +#if ENABLED(USE_SPI_DMA_TC) + bool get_lcd_dma_lock() { return lcd_dma_trans_lock; } +#endif + void lv_fill_rect(lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2, lv_color_t bk_color) { uint16_t width, height; width = x2 - x1 + 1; diff --git a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.h b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.h index 0790d8323c5d..0368140b2858 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.h +++ b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.h @@ -64,6 +64,8 @@ lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p); void lv_fill_rect(lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2, lv_color_t bk_color); +bool get_lcd_dma_lock(); + #ifdef __cplusplus } /* C-declarations for C++ */ #endif diff --git a/Marlin/src/lcd/extui/mks_ui/tft_multi_language.cpp b/Marlin/src/lcd/extui/mks_ui/tft_multi_language.cpp index c69ccf65872b..6e9c37b0169e 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_multi_language.cpp +++ b/Marlin/src/lcd/extui/mks_ui/tft_multi_language.cpp @@ -578,6 +578,8 @@ void machine_setting_disp() { machine_menu.OutLength = FILAMENT_OUT_LENGTH_EN; machine_menu.OutSpeed = FILAMENT_OUT_SPEED_EN; + machine_menu.LevelingZoffsetTitle = LEVELING_ZOFFSET_TITLE_EN; + machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_EN; machine_menu.LevelingParaConf = LEVELING_PARA_CONF_EN; machine_menu.TrammingPosConf = TRAMMING_POS_EN; @@ -767,11 +769,12 @@ void disp_language_init() { move_menu.z_add = AXIS_Z_ADD_TEXT; move_menu.z_dec = AXIS_Z_DEC_TEXT; - move_menu.step_001mm = TEXT_001MM; - move_menu.step_005mm = TEXT_005MM; - move_menu.step_01mm = TEXT_01MM; - move_menu.step_1mm = TEXT_1MM; - move_menu.step_10mm = TEXT_10MM; + move_menu.step_001mm = TEXT_001MM; + move_menu.step_0025mm = TEXT_0025MM; + move_menu.step_005mm = TEXT_005MM; + move_menu.step_01mm = TEXT_01MM; + move_menu.step_1mm = TEXT_1MM; + move_menu.step_10mm = TEXT_10MM; home_menu.home_x = HOME_X_TEXT; home_menu.home_y = HOME_Y_TEXT; @@ -1346,6 +1349,7 @@ void disp_language_init() { case LANG_ENGLISH: common_menu.dialog_confirm_title = TITLE_DIALOG_CONFIRM_EN; common_menu.text_back = BACK_TEXT_EN; + common_menu.text_save = SAVE_TEXT_EN; common_menu.close_machine_tips = DIALOG_CLOSE_MACHINE_EN; common_menu.unbind_printer_tips = DIALOG_UNBIND_PRINTER_EN; common_menu.print_special_title = PRINTING_OTHER_LANGUGE; diff --git a/Marlin/src/lcd/extui/mks_ui/tft_multi_language.h b/Marlin/src/lcd/extui/mks_ui/tft_multi_language.h index 0d0285f322af..2a5135dded4f 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_multi_language.h +++ b/Marlin/src/lcd/extui/mks_ui/tft_multi_language.h @@ -101,6 +101,8 @@ typedef struct machine_common_disp { const char *OutLength; const char *OutSpeed; + const char *LevelingZoffsetTitle; + const char *LevelingParaConfTitle; const char *LevelingParaConf; const char *TrammingPosConf; @@ -294,6 +296,7 @@ extern machine_common_def machine_menu; typedef struct common_menu_disp { const char *text_back; + const char *text_save; const char *dialog_confirm_title; const char *close_machine_tips; const char *unbind_printer_tips; @@ -355,6 +358,7 @@ typedef struct move_menu_disp { const char *z_add; const char *z_dec; const char *step_001mm; + const char *step_0025mm; const char *step_005mm; const char *step_01mm; const char *step_1mm; @@ -777,6 +781,7 @@ extern eeprom_def eeprom_menu; #define AXIS_Z_ADD_TEXT "Z+" #define AXIS_Z_DEC_TEXT "Z-" #define TEXT_001MM "0.01 mm" +#define TEXT_0025MM "0.025 mm" #define TEXT_005MM "0.05 mm" #define TEXT_01MM "0.1 mm" #define TEXT_1MM "1 mm" diff --git a/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.h b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.h index cf32bad3969c..a7281fed4ada 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.h +++ b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.h @@ -39,17 +39,17 @@ class WifiSerial { void begin(uint32_t baud); void begin(uint32_t baud, uint8_t config); void end(); - int available(void); - int read(void); + int available(); + int read(); int write(uint8_t); // Interrupt handlers static int _tx_complete_irq(serial_t *obj); static void _rx_complete_irq(serial_t *obj); - void flush(void); - bool isHalfDuplex(void) const; - void enableHalfDuplexRx(void); + void flush(); + bool isHalfDuplex() const; + void enableHalfDuplexRx(); private: void setRx(uint32_t _rx); diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp index cc8458ce43ef..73a76323fd2b 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp @@ -123,7 +123,7 @@ uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick) { void wifi_delay(int n) { const uint32_t start = getWifiTick(); while (getWifiTickDiff(start, getWifiTick()) < (uint32_t)n) - watchdog_refresh(); + hal.watchdog_refresh(); } void wifi_reset() { @@ -1882,7 +1882,7 @@ void wifi_rcv_handle() { void wifi_looping() { do { wifi_rcv_handle(); - watchdog_refresh(); + hal.watchdog_refresh(); } while (wifi_link_state == WIFI_TRANS_FILE); } @@ -1897,7 +1897,7 @@ void mks_esp_wifi_init() { esp_state = TRANSFER_IDLE; esp_port_begin(1); - watchdog_refresh(); + hal.watchdog_refresh(); wifi_reset(); #if 0 @@ -1950,14 +1950,14 @@ void mks_esp_wifi_init() { } void mks_wifi_firmware_update() { - watchdog_refresh(); + hal.watchdog_refresh(); card.openFileRead((char *)ESP_FIRMWARE_FILE); if (card.isFileOpen()) { card.closefile(); wifi_delay(2000); - watchdog_refresh(); + hal.watchdog_refresh(); if (usartFifoAvailable((SZ_USART_FIFO *)&WifiRxFifo) < 20) return; clear_cur_ui(); @@ -1965,7 +1965,7 @@ void mks_wifi_firmware_update() { lv_draw_dialog(DIALOG_TYPE_UPDATE_ESP_FIRMWARE); lv_task_handler(); - watchdog_refresh(); + hal.watchdog_refresh(); if (wifi_upload(0) >= 0) { card.removeFile((char *)ESP_FIRMWARE_FILE_RENAME); @@ -2028,7 +2028,7 @@ void get_wifi_commands() { // Process critical commands early if (strcmp_P(command, PSTR("M108")) == 0) { wait_for_heatup = false; - TERN_(HAS_LCD_MENU, wait_for_user = false); + TERN_(HAS_MARLINUI_MENU, wait_for_user = false); } if (strcmp_P(command, PSTR("M112")) == 0) kill(FPSTR(M112_KILL_STR), nullptr, true); if (strcmp_P(command, PSTR("M410")) == 0) quickstop_stepper(); diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp b/Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp index 675e0eb666d2..c07cc47a3689 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp @@ -265,7 +265,7 @@ EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t EspUploadResult stat; //IWDG_ReloadCounter(); - watchdog_refresh(); + hal.watchdog_refresh(); if (getWifiTickDiff(startTime, getWifiTick()) > msTimeout) return timeout; @@ -445,7 +445,7 @@ EspUploadResult Sync(uint16_t timeout) { for (;;) { size_t bodyLen; EspUploadResult rc = readPacket(ESP_SYNC, 0, &bodyLen, defaultTimeout); - watchdog_refresh(); + hal.watchdog_refresh(); if (rc != success || bodyLen != 2) break; } } @@ -673,7 +673,7 @@ int32_t wifi_upload(int type) { while (esp_upload.state != upload_idle) { upload_spin(); - watchdog_refresh(); + hal.watchdog_refresh(); } ResetWiFiForUpload(1); diff --git a/Marlin/src/lcd/extui/nextion/nextion_extui.cpp b/Marlin/src/lcd/extui/nextion/nextion_extui.cpp index c19d3aee46f0..0e84fd33cf4f 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_extui.cpp +++ b/Marlin/src/lcd/extui/nextion/nextion_extui.cpp @@ -35,25 +35,25 @@ namespace ExtUI { - void onStartup() { nextion.Startup(); } - void onIdle() { nextion.IdleLoop(); } + void onStartup() { nextion.Startup(); } + void onIdle() { nextion.IdleLoop(); } void onPrinterKilled(FSTR_P const error, FSTR_P const component) { nextion.PrinterKilled(error, component); } void onMediaInserted() {} - void onMediaError() {} - void onMediaRemoved() {} + void onMediaError() {} + void onMediaRemoved() {} void onPlayTone(const uint16_t frequency, const uint16_t duration) {} void onPrintTimerStarted() {} - void onPrintTimerPaused() {} + void onPrintTimerPaused() {} void onPrintTimerStopped() {} - void onFilamentRunout(const extruder_t) {} + void onFilamentRunout(const extruder_t) {} void onUserConfirmRequired(const char * const msg) { nextion.ConfirmationRequest(msg); } - void onStatusChanged(const char * const msg) { nextion.StatusChange(msg); } + void onStatusChanged(const char * const msg) { nextion.StatusChange(msg); } - void onHomingStart() {} - void onHomingComplete() {} - void onPrintFinished() { nextion.PrintFinished(); } + void onHomingStart() {} + void onHomingDone() {} + void onPrintDone() { nextion.PrintFinished(); } - void onFactoryReset() {} + void onFactoryReset() {} void onStoreSettings(char *buff) { // Called when saving to EEPROM (i.e. M500). If the ExtUI needs @@ -61,7 +61,7 @@ namespace ExtUI { // into buff. // Example: - // static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size); + // static_assert(sizeof(myDataStruct) <= eeprom_data_size); // memcpy(buff, &myDataStruct, sizeof(myDataStruct)); } @@ -71,7 +71,7 @@ namespace ExtUI { // from buff // Example: - // static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size); + // static_assert(sizeof(myDataStruct) <= eeprom_data_size); // memcpy(&myDataStruct, buff, sizeof(myDataStruct)); } @@ -79,24 +79,25 @@ namespace ExtUI { // Called after loading or resetting stored settings } - void onConfigurationStoreWritten(bool success) { + void onSettingsStored(bool success) { // Called after the entire EEPROM has been written, // whether successful or not. } - void onConfigurationStoreRead(bool success) { + void onSettingsLoaded(bool success) { // Called after the entire EEPROM has been read, // whether successful or not. } #if HAS_MESH - void onMeshLevelingStart() {} + void onLevelingStart() {} + void onLevelingDone() {} void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) { // Called when any mesh points are updated } - void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) { + void onMeshUpdate(const int8_t xpos, const int8_t ypos, const probe_state_t state) { // Called to indicate a special condition } #endif @@ -116,6 +117,7 @@ namespace ExtUI { void onSteppersDisabled() {} void onSteppersEnabled() {} + } #endif // NEXTION_TFT diff --git a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp index 2c1bde245c02..92349659eb3d 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp +++ b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp @@ -430,25 +430,24 @@ void NextionTFT::PanelInfo(uint8_t req) { break; case 36: // Endstop Info - #if HAS_X_MIN + #if X_HOME_TO_MIN SEND_VALasTXT("x1", READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING ? "triggered" : "open"); - #endif - #if HAS_X_MAX + #elif X_HOME_TO_MAX SEND_VALasTXT("x2", READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING ? "triggered" : "open"); #endif - #if HAS_Y_MIN + #if Y_HOME_TO_MIN SEND_VALasTXT("y1", READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING ? "triggered" : "open"); + #elif Y_HOME_TO_MAX + SEND_VALasTXT("y2", READ(X_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING ? "triggered" : "open"); #endif - #if HAS_Z_MIN + #if Z_HOME_TO_MIN SEND_VALasTXT("z1", READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING ? "triggered" : "open"); - #endif - #if HAS_Z_MAX + #elif Z_HOME_TO_MAX SEND_VALasTXT("z2", READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTING ? "triggered" : "open"); #endif #if HAS_Z2_MIN SEND_VALasTXT("z2", READ(Z2_MIN_PIN) != Z2_MIN_ENDSTOP_INVERTING ? "triggered" : "open"); - #endif - #if HAS_Z2_MAX + #elif HAS_Z2_MAX SEND_VALasTXT("z2", READ(Z2_MAX_PIN) != Z2_MAX_ENDSTOP_INVERTING ? "triggered" : "open"); #endif #if HAS_BED_PROBE diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 54e7db55c290..2aa3f44a8380 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -94,6 +94,10 @@ #include "../../feature/caselight.h" #endif +#if ENABLED(POWER_LOSS_RECOVERY) + #include "../../feature/powerloss.h" +#endif + #if ENABLED(BABYSTEPPING) #include "../../feature/babystep.h" #endif @@ -385,8 +389,10 @@ namespace ExtUI { return !thermalManager.tooColdToExtrude(extruder - E0); } - GcodeSuite::MarlinBusyState getHostKeepaliveState() { return TERN0(HOST_KEEPALIVE_FEATURE, gcode.busy_state); } - bool getHostKeepaliveIsPaused() { return TERN0(HOST_KEEPALIVE_FEATURE, gcode.host_keepalive_is_paused()); } + #if ENABLED(HOST_KEEPALIVE_FEATURE) + GcodeSuite::MarlinBusyState getHostKeepaliveState() { return gcode.busy_state; } + bool getHostKeepaliveIsPaused() { return gcode.host_keepalive_is_paused(); } + #endif #if HAS_SOFTWARE_ENDSTOPS bool getSoftEndstopState() { return soft_endstop._enabled; } @@ -674,6 +680,11 @@ namespace ExtUI { #endif #endif + #if ENABLED(POWER_LOSS_RECOVERY) + bool getPowerLossRecoveryEnabled() { return recovery.enabled; } + 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; @@ -852,16 +863,16 @@ namespace ExtUI { #endif #if ENABLED(BACKLASH_GCODE) - float getAxisBacklash_mm(const axis_t axis) { return backlash.distance_mm[axis]; } + float getAxisBacklash_mm(const axis_t axis) { return backlash.get_distance_mm((AxisEnum)axis); } void setAxisBacklash_mm(const_float_t value, const axis_t axis) - { backlash.distance_mm[axis] = constrain(value,0,5); } + { backlash.set_distance_mm((AxisEnum)axis, constrain(value,0,5)); } - float getBacklashCorrection_percent() { return ui8_to_percent(backlash.correction); } - void setBacklashCorrection_percent(const_float_t value) { backlash.correction = map(constrain(value, 0, 100), 0, 100, 0, 255); } + float getBacklashCorrection_percent() { return backlash.get_correction() * 100.0f; } + void setBacklashCorrection_percent(const_float_t value) { backlash.set_correction(constrain(value, 0, 100) / 100.0f); } #ifdef BACKLASH_SMOOTHING_MM - float getBacklashSmoothing_mm() { return backlash.smoothing_mm; } - void setBacklashSmoothing_mm(const_float_t value) { backlash.smoothing_mm = constrain(value, 0, 999); } + float getBacklashSmoothing_mm() { return backlash.get_smoothing_mm(); } + void setBacklashSmoothing_mm(const_float_t value) { backlash.set_smoothing_mm(constrain(value, 0, 999)); } #endif #endif @@ -878,11 +889,11 @@ namespace ExtUI { #if HAS_MESH - bed_mesh_t& getMeshArray() { return Z_VALUES_ARR; } - float getMeshPoint(const xy_uint8_t &pos) { return Z_VALUES(pos.x, pos.y); } + bed_mesh_t& getMeshArray() { return bedlevel.z_values; } + float getMeshPoint(const xy_uint8_t &pos) { return bedlevel.z_values[pos.x][pos.y]; } void setMeshPoint(const xy_uint8_t &pos, const_float_t zoff) { if (WITHIN(pos.x, 0, (GRID_MAX_POINTS_X) - 1) && WITHIN(pos.y, 0, (GRID_MAX_POINTS_Y) - 1)) { - Z_VALUES(pos.x, pos.y) = zoff; + bedlevel.z_values[pos.x][pos.y] = zoff; TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate()); } } @@ -895,12 +906,10 @@ namespace ExtUI { if (x_target != current_position.x || y_target != current_position.y) { // If moving across bed, raise nozzle to safe height over bed feedrate_mm_s = Z_PROBE_FEEDRATE_FAST; - destination = current_position; - destination.z = Z_CLEARANCE_BETWEEN_PROBES; + destination.set(current_position.x, current_position.y, Z_CLEARANCE_BETWEEN_PROBES); prepare_line_to_destination(); feedrate_mm_s = XY_PROBE_FEEDRATE; - destination.x = x_target; - destination.y = y_target; + destination.set(x_target, y_target); prepare_line_to_destination(); } feedrate_mm_s = Z_PROBE_FEEDRATE_FAST; @@ -1144,7 +1153,7 @@ namespace ExtUI { // At the moment we hook into MarlinUI methods, but this could be cleaned up in the future -void MarlinUI::init() { ExtUI::onStartup(); } +void MarlinUI::init_lcd() { ExtUI::onStartup(); } void MarlinUI::update() { ExtUI::onIdle(); } diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 04a298ba582e..84b2ed8c6d70 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -83,8 +83,10 @@ namespace ExtUI { void injectCommands(char * const); bool commandsInQueue(); - GcodeSuite::MarlinBusyState getHostKeepaliveState(); - bool getHostKeepaliveIsPaused(); + #if ENABLED(HOST_KEEPALIVE_FEATURE) + GcodeSuite::MarlinBusyState getHostKeepaliveState(); + bool getHostKeepaliveIsPaused(); + #endif bool isHeaterIdle(const heater_t); bool isHeaterIdle(const extruder_t); @@ -172,7 +174,8 @@ namespace ExtUI { float getMeshPoint(const xy_uint8_t &pos); void setMeshPoint(const xy_uint8_t &pos, const_float_t zval); void moveToMeshPoint(const xy_uint8_t &pos, const_float_t z); - void onMeshLevelingStart(); + void onLevelingStart(); + void onLevelingDone(); void onMeshUpdate(const int8_t xpos, const int8_t ypos, const_float_t zval); inline void onMeshUpdate(const xy_int8_t &pos, const_float_t zval) { onMeshUpdate(pos.x, pos.y, zval); } @@ -196,7 +199,7 @@ namespace ExtUI { #endif inline void simulateUserClick() { - #if ANY(HAS_LCD_MENU, EXTENSIBLE_UI, DWIN_CREALITY_LCD_JYERSUI) + #if ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, DWIN_CREALITY_LCD_JYERSUI) ui.lcd_clicked = true; #endif } @@ -315,6 +318,11 @@ namespace ExtUI { #endif #endif + #if ENABLED(POWER_LOSS_RECOVERY) + bool getPowerLossRecoveryEnabled(); + void setPowerLossRecoveryEnabled(const bool); + #endif + #if ENABLED(PIDTEMP) float getPIDValues_Kp(const extruder_t); float getPIDValues_Ki(const extruder_t); @@ -398,22 +406,22 @@ namespace ExtUI { void onPrintTimerStarted(); void onPrintTimerPaused(); void onPrintTimerStopped(); - void onPrintFinished(); + void onPrintDone(); void onFilamentRunout(const extruder_t extruder); void onUserConfirmRequired(const char * const msg); void onUserConfirmRequired(FSTR_P const fstr); void onStatusChanged(const char * const msg); void onStatusChanged(FSTR_P const fstr); void onHomingStart(); - void onHomingComplete(); + void onHomingDone(); void onSteppersDisabled(); void onSteppersEnabled(); void onFactoryReset(); void onStoreSettings(char *); void onLoadSettings(const char *); void onPostprocessSettings(); - void onConfigurationStoreWritten(bool success); - void onConfigurationStoreRead(bool success); + void onSettingsStored(bool success); + void onSettingsLoaded(bool success); #if ENABLED(POWER_LOSS_RECOVERY) void onPowerLossResume(); #endif diff --git a/Marlin/src/lcd/fontutils.cpp b/Marlin/src/lcd/fontutils.cpp index 50b671ea33a5..a97e63ac4d3a 100644 --- a/Marlin/src/lcd/fontutils.cpp +++ b/Marlin/src/lcd/fontutils.cpp @@ -40,13 +40,8 @@ #include "fontutils.h" -uint8_t read_byte_ram(uint8_t * str) { - return *str; -} - -uint8_t read_byte_rom(uint8_t * str) { - return pgm_read_byte(str); -} +uint8_t read_byte_ram(const uint8_t *str) { return *str; } +uint8_t read_byte_rom(const uint8_t *str) { return pgm_read_byte(str); } /** * @brief Using binary search to find the position by data_pin @@ -104,9 +99,9 @@ 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 */ -uint8_t* get_utf8_value_cb(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, wchar_t *pval) { uint32_t val = 0; - uint8_t *p = pstart; + const uint8_t *p = pstart; #define NEXT_6_BITS() do{ val <<= 6; p++; valcur = cb_read_byte(p); val |= (valcur & 0x3F); }while(0) diff --git a/Marlin/src/lcd/fontutils.h b/Marlin/src/lcd/fontutils.h index 3901d4439fde..e01962d7ad80 100644 --- a/Marlin/src/lcd/fontutils.h +++ b/Marlin/src/lcd/fontutils.h @@ -38,10 +38,10 @@ #include "../core/macros.h" // read a byte from ROM or RAM -typedef uint8_t (*read_byte_cb_t)(uint8_t * str); +typedef uint8_t (*read_byte_cb_t)(const uint8_t * str); -uint8_t read_byte_ram(uint8_t * str); -uint8_t read_byte_rom(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; @@ -58,11 +58,16 @@ 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 */ -uint8_t* get_utf8_value_cb(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, wchar_t *pval); + +inline const char* get_utf8_value_cb(const char *pstart, read_byte_cb_t cb_read_byte, wchar_t *pval) { + return (const char *)get_utf8_value_cb((const uint8_t *)pstart, cb_read_byte, pval); +} /* Returns length of string in CHARACTERS, NOT BYTES */ uint8_t utf8_strlen(const char *pstart); uint8_t utf8_strlen_P(PGM_P pstart); +inline uint8_t utf8_strlen(FSTR_P fstart) { return utf8_strlen_P(FTOP(fstart)); } /* Returns start byte position of desired char number */ uint8_t utf8_byte_pos_by_char_num(const char *pstart, const uint8_t charnum); diff --git a/Marlin/src/lcd/language/language_an.h b/Marlin/src/lcd/language/language_an.h index 8e4ff0e95cfc..98f3d4ed97e1 100644 --- a/Marlin/src/lcd/language/language_an.h +++ b/Marlin/src/lcd/language/language_an.h @@ -55,7 +55,6 @@ namespace Language_an { LSTR MSG_LEVEL_BED_DONE = _UxGT("Nivelacion feita!"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Achustar desfases"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Desfase aplicau"); - LSTR MSG_SET_ORIGIN = _UxGT("Establir orichen"); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Precalentar ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Precalentar ") PREHEAT_1_LABEL " ~"; @@ -86,7 +85,7 @@ namespace Language_an { LSTR MSG_MOVE_Z = _UxGT("Mover Z"); LSTR MSG_MOVE_E = _UxGT("Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Extrusor *"); - LSTR MSG_MOVE_N_MM = _UxGT("Mover %smm"); + 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"); @@ -107,23 +106,19 @@ namespace Language_an { LSTR MSG_ACC = _UxGT("Aceleracion"); LSTR MSG_VTRAV_MIN = _UxGT("Vel. viache min"); LSTR MSG_ACCELERATION = _UxGT("Accel"); - LSTR MSG_AMAX_A = _UxGT("Acel. max ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Acel. max ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Acel. max ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Acel. max ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Acel. max ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Acel. max ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Acel. max ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Acel. max ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Acel. max ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Acel. max ") STR_C; + LSTR MSG_AMAX_N = _UxGT("Acel. max @"); + LSTR MSG_AMAX_E = _UxGT("Acel. max E"); LSTR MSG_AMAX_EN = _UxGT("Acel. max *"); LSTR MSG_A_RETRACT = _UxGT("Acel. retrac."); LSTR MSG_A_TRAVEL = _UxGT("Acel. Viaje"); LSTR MSG_STEPS_PER_MM = _UxGT("Trangos/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" trangos/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" trangos/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" trangos/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" trangos/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" trangos/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" trangos/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" trangos/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" trangos/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" trangos/mm"); + LSTR MSG_N_STEPS = _UxGT("@ trangos/mm"); LSTR MSG_E_STEPS = _UxGT("E trangos/mm"); LSTR MSG_EN_STEPS = _UxGT("* trangos/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatura"); @@ -169,6 +164,7 @@ namespace Language_an { LSTR MSG_BABYSTEP_X = _UxGT("Micropaso X"); LSTR MSG_BABYSTEP_Y = _UxGT("Micropaso Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Micropaso Z"); + LSTR MSG_BABYSTEP_N = _UxGT("Micropaso @"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Cancelado - Endstop"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Error: en calentar"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("Error: temperatura"); @@ -195,7 +191,7 @@ namespace Language_an { LSTR MSG_INFO_PROTOCOL = _UxGT("Protocolo"); LSTR MSG_CASE_LIGHT = _UxGT("Luz"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Conteo de impresion"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completadas"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Tiempo total d'imp."); diff --git a/Marlin/src/lcd/language/language_bg.h b/Marlin/src/lcd/language/language_bg.h index 05209f771808..2596d62564e6 100644 --- a/Marlin/src/lcd/language/language_bg.h +++ b/Marlin/src/lcd/language/language_bg.h @@ -44,7 +44,6 @@ namespace Language_bg { LSTR MSG_DISABLE_STEPPERS = _UxGT("Изкл. двигатели"); LSTR MSG_AUTO_HOME = _UxGT("Паркиране"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Задай Начало"); - LSTR MSG_SET_ORIGIN = _UxGT("Изходна точка"); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Подгряване ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Подгряване ") PREHEAT_1_LABEL " ~"; @@ -75,7 +74,7 @@ namespace Language_bg { LSTR MSG_MOVE_Z = _UxGT("Движение по Z"); LSTR MSG_MOVE_E = _UxGT("Екструдер"); LSTR MSG_MOVE_EN = _UxGT("Екструдер *"); - LSTR MSG_MOVE_N_MM = _UxGT("Премести с %smm"); + 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"); @@ -99,12 +98,10 @@ namespace Language_bg { LSTR MSG_A_RETRACT = _UxGT("A-откат"); LSTR MSG_A_TRAVEL = _UxGT("A-travel"); LSTR MSG_STEPS_PER_MM = _UxGT("Стъпки/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" стъпки/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" стъпки/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" стъпки/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" стъпки/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" стъпки/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" стъпки/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" стъпки/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" стъпки/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" стъпки/mm"); + LSTR MSG_N_STEPS = _UxGT("@ стъпки/mm"); LSTR MSG_E_STEPS = _UxGT("E стъпки/mm"); LSTR MSG_EN_STEPS = _UxGT("* стъпки/mm"); LSTR MSG_TEMPERATURE = _UxGT("Температура"); @@ -149,6 +146,7 @@ namespace Language_bg { LSTR MSG_BABYSTEP_X = _UxGT("Министъпка X"); LSTR MSG_BABYSTEP_Y = _UxGT("Министъпка Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Министъпка Z"); + LSTR MSG_BABYSTEP_N = _UxGT("Министъпка @"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Стоп Кр.Изключватели"); LSTR MSG_DELTA_CALIBRATE = _UxGT("Делта Калибровка"); LSTR MSG_DELTA_CALIBRATE_X = _UxGT("Калибровка X"); diff --git a/Marlin/src/lcd/language/language_ca.h b/Marlin/src/lcd/language/language_ca.h index 6fba76a552e1..fd46bcc28fc0 100644 --- a/Marlin/src/lcd/language/language_ca.h +++ b/Marlin/src/lcd/language/language_ca.h @@ -53,7 +53,6 @@ namespace Language_ca { LSTR MSG_LEVEL_BED_DONE = _UxGT("Anivellament fet!"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Ajusta decalatge"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Decalatge aplicat"); - LSTR MSG_SET_ORIGIN = _UxGT("Estableix origen"); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Preescalfa ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Preescalfa ") PREHEAT_1_LABEL " ~"; @@ -86,7 +85,7 @@ namespace Language_ca { LSTR MSG_MOVE_Z = _UxGT("Mou Z"); LSTR MSG_MOVE_E = _UxGT("Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Extrusor *"); - LSTR MSG_MOVE_N_MM = _UxGT("Mou %smm"); + 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"); @@ -105,14 +104,12 @@ namespace Language_ca { LSTR MSG_A_RETRACT = _UxGT("Accel. retracc"); LSTR MSG_A_TRAVEL = _UxGT("Accel. Viatge"); LSTR MSG_STEPS_PER_MM = _UxGT("Passos/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" passos/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" passos/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" passos/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" passos/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" passos/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" passos/mm"); - LSTR MSG_E_STEPS = _UxGT("Epassos/mm"); - LSTR MSG_EN_STEPS = _UxGT("*passos/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" passos/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" passos/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" passos/mm"); + LSTR MSG_E_STEPS = _UxGT("@ passos/mm"); + LSTR MSG_N_STEPS = _UxGT("E passos/mm"); + LSTR MSG_EN_STEPS = _UxGT("* passos/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatura"); LSTR MSG_MOTION = _UxGT("Moviment"); LSTR MSG_FILAMENT = _UxGT("Filament"); @@ -157,6 +154,7 @@ namespace Language_ca { LSTR MSG_BABYSTEP_X = _UxGT("Micropas X"); LSTR MSG_BABYSTEP_Y = _UxGT("Micropas Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Micropas Z"); + LSTR MSG_BABYSTEP_N = _UxGT("Micropas @"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Cancel. Endstop"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Error al escalfar"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("Err: TEMP REDUNDANT"); @@ -183,7 +181,7 @@ namespace Language_ca { LSTR MSG_INFO_PROTOCOL = _UxGT("Protocol"); LSTR MSG_CASE_LIGHT = _UxGT("Llum"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Total impressions"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Acabades"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Temps imprimint"); diff --git a/Marlin/src/lcd/language/language_cz.h b/Marlin/src/lcd/language/language_cz.h index 596591e0f66e..d78b43f9a9e0 100644 --- a/Marlin/src/lcd/language/language_cz.h +++ b/Marlin/src/lcd/language/language_cz.h @@ -60,7 +60,7 @@ namespace Language_cz { LSTR MSG_RUN_AUTO_FILES = _UxGT("Autostart"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Uvolnit motory"); LSTR MSG_DEBUG_MENU = _UxGT("Nabídka ladění"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test ukaz. průběhu"); #else LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test uk. průběhu"); @@ -77,7 +77,6 @@ namespace Language_cz { LSTR MSG_Z_FADE_HEIGHT = _UxGT("Výška srovnávání"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Nastavit ofsety"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Ofsety nastaveny"); - LSTR MSG_SET_ORIGIN = _UxGT("Nastavit počátek"); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Zahřát ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Zahřát ") PREHEAT_1_LABEL " ~"; @@ -236,7 +235,7 @@ namespace Language_cz { LSTR MSG_MOVE_E = _UxGT("Extrudér"); LSTR MSG_MOVE_EN = _UxGT("Extrudér *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hotend je studený"); - LSTR MSG_MOVE_N_MM = _UxGT("Posunout o %smm"); + LSTR MSG_MOVE_N_MM = _UxGT("Posunout o $mm"); 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"); @@ -267,43 +266,35 @@ namespace Language_cz { LSTR MSG_SELECT_E = _UxGT("Vybrat *"); LSTR MSG_ACC = _UxGT("Zrychl"); LSTR MSG_JERK = _UxGT("Jerk"); - LSTR MSG_VA_JERK = _UxGT("Max ") LCD_STR_A _UxGT(" Jerk"); - LSTR MSG_VB_JERK = _UxGT("Max ") LCD_STR_B _UxGT(" Jerk"); - LSTR MSG_VC_JERK = _UxGT("Max ") LCD_STR_C _UxGT(" Jerk"); - LSTR MSG_VI_JERK = _UxGT("Max ") LCD_STR_I _UxGT(" Jerk"); - LSTR MSG_VJ_JERK = _UxGT("Max ") LCD_STR_J _UxGT(" Jerk"); - LSTR MSG_VK_JERK = _UxGT("Max ") LCD_STR_K _UxGT(" Jerk"); + LSTR MSG_VA_JERK = _UxGT("Max ") STR_A _UxGT(" Jerk"); + 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_JUNCTION_DEVIATION = _UxGT("Odchylka spoje"); - LSTR MSG_VELOCITY = _UxGT("Rychlost"); - LSTR MSG_VMAX_A = _UxGT("Max ") LCD_STR_A _UxGT(" Rychlost"); - LSTR MSG_VMAX_B = _UxGT("Max ") LCD_STR_B _UxGT(" Rychlost"); - LSTR MSG_VMAX_C = _UxGT("Max ") LCD_STR_C _UxGT(" Rychlost"); - LSTR MSG_VMAX_I = _UxGT("Max ") LCD_STR_I _UxGT(" Rychlost"); - LSTR MSG_VMAX_J = _UxGT("Max ") LCD_STR_J _UxGT(" Rychlost"); - LSTR MSG_VMAX_K = _UxGT("Max ") LCD_STR_K _UxGT(" Rychlost"); - LSTR MSG_VMAX_E = _UxGT("Max ") LCD_STR_E _UxGT(" Rychlost"); + LSTR MSG_MAX_SPEED = _UxGT("Max Rychlost"); + LSTR MSG_VMAX_A = _UxGT("Max ") STR_A _UxGT(" Rychlost"); + LSTR MSG_VMAX_B = _UxGT("Max ") STR_B _UxGT(" Rychlost"); + LSTR MSG_VMAX_C = _UxGT("Max ") STR_C _UxGT(" Rychlost"); + LSTR MSG_VMAX_N = _UxGT("Max @ Rychlost"); + LSTR MSG_VMAX_E = _UxGT("Max E Rychlost"); LSTR MSG_VMAX_EN = _UxGT("Max * Rychlost"); LSTR MSG_VMIN = _UxGT("Vmin"); LSTR MSG_VTRAV_MIN = _UxGT("VTrav Min"); LSTR MSG_ACCELERATION = _UxGT("Akcelerace"); - LSTR MSG_AMAX_A = _UxGT("Max ") LCD_STR_A _UxGT(" Akcel"); - LSTR MSG_AMAX_B = _UxGT("Max ") LCD_STR_B _UxGT(" Akcel"); - LSTR MSG_AMAX_C = _UxGT("Max ") LCD_STR_C _UxGT(" Akcel"); - LSTR MSG_AMAX_I = _UxGT("Max ") LCD_STR_I _UxGT(" Akcel"); - LSTR MSG_AMAX_J = _UxGT("Max ") LCD_STR_J _UxGT(" Akcel"); - LSTR MSG_AMAX_K = _UxGT("Max ") LCD_STR_K _UxGT(" Akcel"); - LSTR MSG_AMAX_E = _UxGT("Max ") LCD_STR_E _UxGT(" Akcel"); + LSTR MSG_AMAX_A = _UxGT("Max ") STR_A _UxGT(" Akcel"); + LSTR MSG_AMAX_B = _UxGT("Max ") STR_B _UxGT(" Akcel"); + LSTR MSG_AMAX_C = _UxGT("Max ") STR_C _UxGT(" Akcel"); + LSTR MSG_AMAX_N = _UxGT("Max @ Akcel"); + LSTR MSG_AMAX_E = _UxGT("Max E Akcel"); LSTR MSG_AMAX_EN = _UxGT("Max * Akcel"); LSTR MSG_A_RETRACT = _UxGT("A-retrakt"); LSTR MSG_A_TRAVEL = _UxGT("A-přejezd"); LSTR MSG_STEPS_PER_MM = _UxGT("Kroků/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" kroků/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" kroků/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" kroků/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" kroků/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" kroků/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" kroků/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" kroků/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" kroků/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" kroků/mm"); + LSTR MSG_N_STEPS = _UxGT("@ kroků/mm"); LSTR MSG_E_STEPS = _UxGT("E kroků/mm"); LSTR MSG_EN_STEPS = _UxGT("* kroků/mm"); LSTR MSG_TEMPERATURE = _UxGT("Teplota"); @@ -408,6 +399,7 @@ namespace Language_cz { LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Babystep Z"); + LSTR MSG_BABYSTEP_N = _UxGT("Babystep @"); LSTR MSG_BABYSTEP_TOTAL = _UxGT("Celkem"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Endstop abort"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Chyba zahřívání"); @@ -421,12 +413,12 @@ namespace Language_cz { LSTR MSG_PLEASE_RESET = _UxGT("Proveďte reset"); LSTR MSG_HEATING = _UxGT("Zahřívání..."); LSTR MSG_COOLING = _UxGT("Chlazení..."); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_BED_HEATING = _UxGT("Zahřívání podložky"); #else LSTR MSG_BED_HEATING = _UxGT("Zahřívání podl."); #endif - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_BED_COOLING = _UxGT("Chlazení podložky"); #else LSTR MSG_BED_COOLING = _UxGT("Chlazení podl."); @@ -465,7 +457,7 @@ namespace Language_cz { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Jas světla"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("NESPRÁVNÁ TISKÁRNA"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Počet tisků"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Dokončeno"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Celkový čas"); @@ -483,13 +475,7 @@ namespace Language_cz { LSTR MSG_INFO_MAX_TEMP = _UxGT("Teplota max"); LSTR MSG_INFO_PSU = _UxGT("Nap. zdroj"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Buzení motorů"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("E Motor %"); + LSTR MSG_DAC_PERCENT_N = _UxGT("@ Motor %"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("DAC uložit EEPROM"); LSTR MSG_ERROR_TMC = _UxGT("TMC CHYBA SPOJENÍ"); LSTR MSG_FILAMENT_CHANGE_HEADER = _UxGT("VÝMĚNA FILAMENTU"); @@ -535,7 +521,7 @@ namespace Language_cz { LSTR MSG_CYCLE_MIX = _UxGT("Střídat mix"); LSTR MSG_GRADIENT_MIX = _UxGT("Přechod mix"); LSTR MSG_REVERSE_GRADIENT = _UxGT("Opačný přechod"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_ACTIVE_VTOOL = _UxGT("Aktivní V-nástroj"); LSTR MSG_START_VTOOL = _UxGT("Spustit V-nástroj"); LSTR MSG_END_VTOOL = _UxGT("Ukončit V-nástroj"); diff --git a/Marlin/src/lcd/language/language_da.h b/Marlin/src/lcd/language/language_da.h index e03260557868..05474744d0ac 100644 --- a/Marlin/src/lcd/language/language_da.h +++ b/Marlin/src/lcd/language/language_da.h @@ -47,7 +47,6 @@ namespace Language_da { LSTR MSG_LEVEL_BED_DONE = _UxGT("Bed level er færdig!"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Sæt forsk. af home"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Forsk. er nu aktiv"); - LSTR MSG_SET_ORIGIN = _UxGT("Sæt origin"); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Forvarm ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Forvarm ") PREHEAT_1_LABEL " ~"; @@ -75,7 +74,7 @@ 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_MM = _UxGT("Flyt %smm"); + 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"); @@ -156,7 +155,7 @@ namespace Language_da { LSTR MSG_INFO_BOARD_MENU = _UxGT("Kort Info"); LSTR MSG_INFO_THERMISTOR_MENU = _UxGT("Thermistors"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Ant. Prints"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Færdige"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Total print tid"); @@ -173,13 +172,7 @@ namespace Language_da { LSTR MSG_INFO_PSU = _UxGT("Strømfors."); LSTR MSG_DRIVE_STRENGTH = _UxGT("Driv Styrke"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Driv %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Driv %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Driv %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Driv %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Driv %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Driv %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("E Driv %"); + LSTR MSG_DAC_PERCENT_N = _UxGT("@ Driv %"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM Skriv"); diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index 00f759a83afc..2b22319361aa 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -56,19 +56,38 @@ namespace Language_de { LSTR MSG_DISABLE_STEPPERS = _UxGT("Motoren deaktivieren"); // M84 :: Max length 19 characters LSTR MSG_DEBUG_MENU = _UxGT("Debug-Menü"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Statusbalken-Test"); + LSTR MSG_HOMING = _UxGT("Homing"); LSTR MSG_AUTO_HOME = _UxGT("Auto Home"); + LSTR MSG_AUTO_HOME_A = _UxGT("Home @"); 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_FILAMENT_SET = _UxGT("Fila. Einstellungen"); + LSTR MSG_FILAMENT_MAN = _UxGT("Filament Management"); + LSTR MSG_LEVBED_FL = _UxGT("Vorne Links"); + LSTR MSG_LEVBED_FR = _UxGT("Vorne Rechts"); + LSTR MSG_LEVBED_C = _UxGT("Mitte"); + LSTR MSG_LEVBED_BL = _UxGT("Hinten Links"); + LSTR MSG_LEVBED_BR = _UxGT("Hinten Rechts"); + LSTR MSG_MANUAL_MESH = _UxGT("manuelles Netz"); + LSTR MSG_AUTO_MESH = _UxGT("Netz auto. erstellen"); LSTR MSG_AUTO_Z_ALIGN = _UxGT("Z-Achsen ausgleichen"); + LSTR MSG_ITERATION = _UxGT("G34 Iteration: %i"); + LSTR MSG_DECREASING_ACCURACY = _UxGT("Genauigkeit sinkt!"); + LSTR MSG_ACCURACY_ACHIEVED = _UxGT("Genauigkeit erreicht"); LSTR MSG_LEVEL_BED_HOMING = _UxGT("XYZ homen"); LSTR MSG_LEVEL_BED_WAITING = _UxGT("Klick zum Starten"); LSTR MSG_LEVEL_BED_NEXT_POINT = _UxGT("Nächste Koordinate"); LSTR MSG_LEVEL_BED_DONE = _UxGT("Nivellieren fertig!"); LSTR MSG_Z_FADE_HEIGHT = _UxGT("Ausblendhöhe"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Setze Homeversatz"); + LSTR MSG_HOME_OFFSET_X = _UxGT("Homeversatz X"); + LSTR MSG_HOME_OFFSET_Y = _UxGT("Homeversatz Y"); + LSTR MSG_HOME_OFFSET_Z = _UxGT("Homeversatz Z"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Homeversatz aktiv"); - LSTR MSG_SET_ORIGIN = _UxGT("Setze Nullpunkte"); //"G92 X0 Y0 Z0" commented out in marlinui.cpp + LSTR MSG_TRAMMING_WIZARD = _UxGT("Tramming Assistent"); + LSTR MSG_SELECT_ORIGIN = _UxGT("Wählen Sie Ursprung"); + LSTR MSG_LAST_VALUE_SP = _UxGT("Letzter Wert "); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = PREHEAT_1_LABEL _UxGT(" Vorwärmen"); LSTR MSG_PREHEAT_1_H = PREHEAT_1_LABEL _UxGT(" Vorwärmen ~"); @@ -88,11 +107,21 @@ namespace Language_de { #endif LSTR MSG_PREHEAT_CUSTOM = _UxGT("benutzerdef. Heizen"); LSTR MSG_COOLDOWN = _UxGT("Abkühlen"); + LSTR MSG_CUTTER_FREQUENCY = _UxGT("Frequenz"); LSTR MSG_LASER_MENU = _UxGT("Laser"); - LSTR MSG_LASER_POWER = _UxGT("Laserleistung"); LSTR MSG_SPINDLE_MENU = _UxGT("Spindel-Steuerung"); + LSTR MSG_LASER_POWER = _UxGT("Laserleistung"); LSTR MSG_SPINDLE_POWER = _UxGT("Spindelleistung"); + LSTR MSG_LASER_TOGGLE = _UxGT("Laser umschalten"); + LSTR MSG_LASER_EVAC_TOGGLE = _UxGT("Gebläse umschalten"); + LSTR MSG_LASER_ASSIST_TOGGLE = _UxGT("Luftunterstützung"); + LSTR MSG_LASER_PULSE_MS = _UxGT("Test Impuls ms"); + LSTR MSG_LASER_FIRE_PULSE = _UxGT("Fire Impuls"); + LSTR MSG_FLOWMETER_FAULT = _UxGT("Feh. Kühlmittelfluss"); + LSTR MSG_SPINDLE_TOGGLE = _UxGT("Spindel umschalten"); + LSTR MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Vakuum umschalten"); + LSTR MSG_SPINDLE_FORWARD = _UxGT("Spindel vorwärts"); LSTR MSG_SPINDLE_REVERSE = _UxGT("Spindelrichtung"); LSTR MSG_SWITCH_PS_ON = _UxGT("Netzteil ein"); LSTR MSG_SWITCH_PS_OFF = _UxGT("Netzteil aus"); @@ -102,10 +131,18 @@ namespace Language_de { LSTR MSG_BED_LEVELING = _UxGT("Bett-Nivellierung"); LSTR MSG_LEVEL_BED = _UxGT("Bett nivellieren"); LSTR MSG_BED_TRAMMING = _UxGT("Bett ausrichten"); + LSTR MSG_BED_TRAMMING_MANUAL = _UxGT("Manuelles ausrichten"); + LSTR MSG_BED_TRAMMING_RAISE = _UxGT("Das Bett anpassen, bis zum auslösen."); + LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Ecken in der Toleranz. Bett ausger."); + LSTR MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Gute Punkte: "); + LSTR MSG_BED_TRAMMING_LAST_Z = _UxGT("Letztes Z: "); LSTR MSG_NEXT_CORNER = _UxGT("Nächste Ecke"); LSTR MSG_MESH_EDITOR = _UxGT("Netz Editor"); + LSTR MSG_MESH_VIEWER = _UxGT("Netzbetrachter"); LSTR MSG_EDIT_MESH = _UxGT("Netz bearbeiten"); + 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_PROBING_POINT = _UxGT("Messpunkt"); LSTR MSG_MESH_X = _UxGT("Index X"); LSTR MSG_MESH_Y = _UxGT("Index Y"); @@ -121,6 +158,7 @@ namespace Language_de { LSTR MSG_IDEX_MODE_DUPLICATE = _UxGT("Duplizieren"); LSTR MSG_IDEX_MODE_MIRRORED_COPY = _UxGT("Spiegelkopie"); LSTR MSG_IDEX_MODE_FULL_CTRL = _UxGT("vollstä. Kontrolle"); + LSTR MSG_IDEX_DUPE_GAP = _UxGT("X-Lücke duplizieren"); LSTR MSG_HOTEND_OFFSET_Z = _UxGT("2. Düse Z"); LSTR MSG_HOTEND_OFFSET_A = _UxGT("2. Düse @"); LSTR MSG_UBL_DOING_G29 = _UxGT("G29 ausführen"); @@ -128,6 +166,7 @@ namespace Language_de { LSTR MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling"); LSTR MSG_LCD_TILTING_MESH = _UxGT("Berührungspunkt"); 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"); LSTR MSG_UBL_BC_INSERT2 = _UxGT("Messen"); LSTR MSG_UBL_BC_REMOVE = _UxGT("Entfernen & messen"); @@ -212,6 +251,10 @@ namespace Language_de { LSTR MSG_SET_LEDS_VIOLET = _UxGT("Violett"); LSTR MSG_SET_LEDS_WHITE = _UxGT("Weiß"); LSTR MSG_SET_LEDS_DEFAULT = _UxGT("Standard"); + LSTR MSG_LED_CHANNEL_N = _UxGT("Kanal ="); + LSTR MSG_LEDS2 = _UxGT("Lichter #2"); + LSTR MSG_NEO2_PRESETS = _UxGT("Licht #2 Voreinst."); + LSTR MSG_NEO2_BRIGHTNESS = _UxGT("Helligkeit"); LSTR MSG_CUSTOM_LEDS = _UxGT("Benutzerdefiniert"); LSTR MSG_INTENSITY_R = _UxGT("Intensität Rot"); LSTR MSG_INTENSITY_G = _UxGT("Intensität Grün"); @@ -224,14 +267,19 @@ namespace Language_de { LSTR MSG_MOVE_X = _UxGT("Bewege X"); LSTR MSG_MOVE_Y = _UxGT("Bewege Y"); LSTR MSG_MOVE_Z = _UxGT("Bewege Z"); + LSTR MSG_MOVE_N = _UxGT("Bewege @"); LSTR MSG_MOVE_E = _UxGT("Bewege Extruder"); LSTR MSG_MOVE_EN = _UxGT("Bewege Extruder *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hotend zu kalt"); - LSTR MSG_MOVE_N_MM = _UxGT(" %s mm"); + LSTR MSG_MOVE_N_MM = _UxGT(" $ mm"); 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_100MM = _UxGT("100,0 mm"); + LSTR MSG_MOVE_0001IN = _UxGT("0.001 in"); + LSTR MSG_MOVE_001IN = _UxGT("0.010 in"); + LSTR MSG_MOVE_01IN = _UxGT("0.100 in"); + LSTR MSG_MOVE_1IN = _UxGT("1.000 in"); LSTR MSG_SPEED = _UxGT("Geschw."); LSTR MSG_BED_Z = _UxGT("Bett Z"); LSTR MSG_NOZZLE = _UxGT("Düse"); @@ -240,6 +288,10 @@ namespace Language_de { LSTR MSG_NOZZLE_STANDBY = _UxGT("Düse bereit"); LSTR MSG_BED = _UxGT("Bett"); LSTR MSG_CHAMBER = _UxGT("Gehäuse"); + LSTR MSG_COOLER = _UxGT("Laser-Kühlmittel"); + LSTR MSG_COOLER_TOGGLE = _UxGT("Kühler umschalten"); + LSTR MSG_FLOWMETER_SAFETY = _UxGT("Durchflusssicherheit"); + LSTR MSG_LASER = _UxGT("Laser"); LSTR MSG_FAN_SPEED = _UxGT("Lüfter"); LSTR MSG_FAN_SPEED_N = _UxGT("Lüfter ~"); LSTR MSG_STORED_FAN_N = _UxGT("Gespeich. Lüfter ~"); @@ -261,55 +313,55 @@ namespace Language_de { LSTR MSG_LCD_OFF = _UxGT("aus"); LSTR MSG_PID_AUTOTUNE = _UxGT("PID Autotune"); 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_TEMP_TOO_HIGH = _UxGT("Autotune fehlge. Temperatur zu hoch."); + LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Autotune fehlge.! Falscher 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"); + LSTR MSG_MPC_AUTOTUNE = _UxGT("Autotune MPC"); + LSTR MSG_MPC_EDIT = _UxGT("MPC * bearbeiten"); + LSTR MSG_MPC_POWER_E = _UxGT("* Leistung"); + LSTR MSG_MPC_BLOCK_HEAT_CAPACITY_E = _UxGT("Block C *"); + 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"); - LSTR MSG_VA_JERK = _UxGT("Max ") LCD_STR_A _UxGT(" Jerk"); - LSTR MSG_VB_JERK = _UxGT("Max ") LCD_STR_B _UxGT(" Jerk"); - LSTR MSG_VC_JERK = _UxGT("Max ") LCD_STR_C _UxGT(" Jerk"); - LSTR MSG_VI_JERK = _UxGT("Max ") LCD_STR_I _UxGT(" Jerk"); - LSTR MSG_VJ_JERK = _UxGT("Max ") LCD_STR_J _UxGT(" Jerk"); - LSTR MSG_VK_JERK = _UxGT("Max ") LCD_STR_K _UxGT(" Jerk"); + LSTR MSG_VA_JERK = _UxGT("Max ") STR_A _UxGT(" Jerk"); + 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_JUNCTION_DEVIATION = _UxGT("Junction Dev"); - LSTR MSG_VELOCITY = _UxGT("Geschwindigkeit"); - LSTR MSG_VMAX_A = _UxGT("V max ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("V max ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("V max ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("V max ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("V max ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("V max ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("V max ") LCD_STR_E; + 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_EN = _UxGT("V max *"); LSTR MSG_VMIN = _UxGT("V min "); LSTR MSG_VTRAV_MIN = _UxGT("V min Leerfahrt"); LSTR MSG_ACCELERATION = _UxGT("Beschleunigung"); - LSTR MSG_AMAX = _UxGT("A max "); // space intentional - LSTR MSG_AMAX_A = _UxGT("A max ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("A max ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("A max ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("A max ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("A max ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("A max ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("A max ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("A max ") STR_A; + 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_EN = _UxGT("A max *"); LSTR MSG_A_RETRACT = _UxGT("A Einzug"); LSTR MSG_A_TRAVEL = _UxGT("A Leerfahrt"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("max. Frequenz"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("min. Vorschub"); LSTR MSG_STEPS_PER_MM = _UxGT("Steps/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" Steps/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" Steps/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" Steps/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" Steps/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" Steps/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" Steps/mm"); - LSTR MSG_E_STEPS = LCD_STR_E _UxGT(" Steps/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" Steps/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" Steps/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" Steps/mm"); + LSTR MSG_N_STEPS = _UxGT("@ Steps/mm"); + LSTR MSG_E_STEPS = _UxGT("E Steps/mm"); LSTR MSG_EN_STEPS = _UxGT("* Steps/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatur"); LSTR MSG_MOTION = _UxGT("Bewegung"); @@ -324,6 +376,9 @@ namespace Language_de { LSTR MSG_ADVANCE_K = _UxGT("Vorschubfaktor"); 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_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"); @@ -334,7 +389,7 @@ namespace Language_de { 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_REFRESH = LCD_STR_REFRESH _UxGT("Aktualisieren"); LSTR MSG_INFO_SCREEN = _UxGT("Info"); LSTR MSG_PREPARE = _UxGT("Vorbereitung"); LSTR MSG_TUNE = _UxGT("Justierung"); @@ -350,23 +405,38 @@ namespace Language_de { LSTR MSG_BUTTON_RESET = _UxGT("Reseten"); LSTR MSG_BUTTON_IGNORE = _UxGT("Ignorieren"); LSTR MSG_BUTTON_CANCEL = _UxGT("Abbrechen"); + LSTR MSG_BUTTON_CONFIRM = _UxGT("Bestätigen"); + LSTR MSG_BUTTON_CONTINUE = _UxGT("Fortsetzen"); LSTR MSG_BUTTON_DONE = _UxGT("Fertig"); LSTR MSG_BUTTON_BACK = _UxGT("Zurück"); LSTR MSG_BUTTON_PROCEED = _UxGT("Weiter"); + LSTR MSG_BUTTON_SKIP = _UxGT("Überspringen"); + LSTR MSG_BUTTON_INFO = _UxGT("Info"); + LSTR MSG_BUTTON_LEVEL = _UxGT("Level"); + LSTR MSG_BUTTON_PAUSE = _UxGT("Pause"); + LSTR MSG_BUTTON_RESUME = _UxGT("Fortsetzen"); + LSTR MSG_BUTTON_ADVANCED = _UxGT("Erweitert"); + LSTR MSG_BUTTON_SAVE = _UxGT("Speichern"); LSTR MSG_PAUSING = _UxGT("Pause..."); LSTR MSG_PAUSE_PRINT = _UxGT("SD-Druck pausieren"); + LSTR MSG_ADVANCED_PAUSE = _UxGT("Erweiterte Pause"); LSTR MSG_RESUME_PRINT = _UxGT("SD-Druck fortsetzen"); + LSTR MSG_HOST_START_PRINT = _UxGT("Host-Druck starten"); LSTR MSG_STOP_PRINT = _UxGT("SD-Druck abbrechen"); + LSTR MSG_END_LOOPS = _UxGT("Wiederholung beenden"); LSTR MSG_PRINTING_OBJECT = _UxGT("Objekt drucken"); LSTR MSG_CANCEL_OBJECT = _UxGT("Objekt abbrechen"); LSTR MSG_CANCEL_OBJECT_N = _UxGT("Objekt abbrechen ="); LSTR MSG_OUTAGE_RECOVERY = _UxGT("Wiederh. n. Stroma."); + LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Druckauftrag fortset."); LSTR MSG_MEDIA_MENU = _UxGT("Druck vom Medium"); LSTR MSG_NO_MEDIA = _UxGT("Kein Medium"); LSTR MSG_DWELL = _UxGT("Warten..."); LSTR MSG_USERWAIT = _UxGT("Klick zum Fortsetzen"); LSTR MSG_PRINT_PAUSED = _UxGT("Druck pausiert..."); LSTR MSG_PRINTING = _UxGT("Druckt..."); + LSTR MSG_STOPPING = _UxGT("Stoppen..."); + LSTR MSG_REMAINING_TIME = _UxGT("Verbleiben"); LSTR MSG_PRINT_ABORTED = _UxGT("Druck abgebrochen"); LSTR MSG_PRINT_DONE = _UxGT("Druck fertig"); LSTR MSG_NO_MOVE = _UxGT("Motoren angeschaltet"); @@ -416,6 +486,7 @@ namespace Language_de { LSTR MSG_BLTOUCH_STOW = _UxGT("Einfahren"); LSTR MSG_BLTOUCH_DEPLOY = _UxGT("Ausfahren"); LSTR MSG_BLTOUCH_SW_MODE = _UxGT("SW-Modus"); + LSTR MSG_BLTOUCH_SPEED_MODE = _UxGT("High Speed"); LSTR MSG_BLTOUCH_5V_MODE = _UxGT("5V-Modus"); LSTR MSG_BLTOUCH_OD_MODE = _UxGT("OD-Modus"); LSTR MSG_BLTOUCH_MODE_STORE = _UxGT("Mode-Store"); @@ -431,33 +502,41 @@ namespace Language_de { 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_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_MOVE_NOZZLE_TO_BED = _UxGT("Bewege Düse zum Bett"); LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Babystep Z"); + LSTR MSG_BABYSTEP_N = _UxGT("Babystep @"); LSTR MSG_BABYSTEP_TOTAL = _UxGT("Total"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Abbr. mit Endstopp"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("HEIZEN ERFOLGLOS"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("REDUND. TEMP-ABWEI."); LSTR MSG_THERMAL_RUNAWAY = " " LCD_STR_THERMOMETER _UxGT(" NICHT ERREICHT"); + LSTR MSG_TEMP_MALFUNCTION = _UxGT("TEMP-FEHLER"); LSTR MSG_THERMAL_RUNAWAY_BED = _UxGT("BETT") " " LCD_STR_THERMOMETER _UxGT(" NICHT ERREICHT"); LSTR MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("GEH.") " " LCD_STR_THERMOMETER _UxGT(" NICHT ERREICHT"); + LSTR MSG_THERMAL_RUNAWAY_COOLER = _UxGT("Kühler Runaway"); + LSTR MSG_COOLING_FAILED = _UxGT("Kühlung fehlgeschla."); LSTR MSG_ERR_MAXTEMP = " " LCD_STR_THERMOMETER _UxGT(" ÜBERSCHRITTEN"); LSTR MSG_ERR_MINTEMP = " " LCD_STR_THERMOMETER _UxGT(" UNTERSCHRITTEN"); LSTR MSG_HALTED = _UxGT("DRUCKER GESTOPPT"); + LSTR MSG_PLEASE_WAIT = _UxGT("Bitte warten..."); LSTR MSG_PLEASE_RESET = _UxGT("Bitte neustarten"); - LSTR MSG_SHORT_DAY = _UxGT("t"); // One character only - LSTR MSG_SHORT_HOUR = _UxGT("h"); // One character only - LSTR MSG_SHORT_MINUTE = _UxGT("m"); // One character only + LSTR MSG_PREHEATING = _UxGT("vorheizen..."); LSTR MSG_HEATING = _UxGT("heizt..."); LSTR MSG_COOLING = _UxGT("kühlt..."); LSTR MSG_BED_HEATING = _UxGT("Bett heizt..."); LSTR MSG_BED_COOLING = _UxGT("Bett kühlt..."); + LSTR MSG_PROBE_HEATING = _UxGT("Sonde heizt..."); + LSTR MSG_PROBE_COOLING = _UxGT("Sonde kühlt..."); LSTR MSG_CHAMBER_HEATING = _UxGT("Gehäuse heizt..."); LSTR MSG_CHAMBER_COOLING = _UxGT("Gehäuse kühlt..."); + LSTR MSG_LASER_COOLING = _UxGT("Laser kühlt..."); LSTR MSG_DELTA_CALIBRATE = _UxGT("Delta kalibrieren"); LSTR MSG_DELTA_CALIBRATE_X = _UxGT("Kalibriere X"); LSTR MSG_DELTA_CALIBRATE_Y = _UxGT("Kalibriere Y"); @@ -475,8 +554,9 @@ namespace Language_de { LSTR MSG_3POINT_LEVELING = _UxGT("3-Punkt-Nivellierung"); LSTR MSG_LINEAR_LEVELING = _UxGT("Lineare Nivellierung"); LSTR MSG_BILINEAR_LEVELING = _UxGT("Bilineare Nivell."); - LSTR MSG_UBL_LEVELING = _UxGT("Unified Bed Leveling"); + LSTR MSG_UBL_LEVELING = _UxGT("Einheit. Bettnivell."); LSTR MSG_MESH_LEVELING = _UxGT("Netz-Nivellierung"); + LSTR MSG_MESH_DONE = _UxGT("Nivellierung fertig"); LSTR MSG_INFO_STATS_MENU = _UxGT("Drucker-Statistik"); LSTR MSG_INFO_BOARD_MENU = _UxGT("Board-Info"); LSTR MSG_INFO_THERMISTOR_MENU = _UxGT("Thermistoren"); @@ -486,36 +566,46 @@ namespace Language_de { LSTR MSG_INFO_RUNAWAY_OFF = _UxGT("Runaway Watch: AUS"); LSTR MSG_INFO_RUNAWAY_ON = _UxGT("Runaway Watch: AN"); LSTR MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Hotend Idle Timeout"); + LSTR MSG_FAN_SPEED_FAULT = _UxGT("Fehler Lüftergeschw."); + LSTR MSG_CASE_LIGHT = _UxGT("Beleuchtung"); LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Helligkeit"); - LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Falscher Drucker"); - #if LCD_WIDTH >= 20 + #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_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_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"); LSTR MSG_INFO_MAX_TEMP = _UxGT("Max Temp"); LSTR MSG_INFO_PSU = _UxGT("Netzteil"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Motorleistung"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Treiber %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Treiber %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Treiber %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Treiber %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Treiber %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Treiber %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("E Treiber %"); + LSTR MSG_DAC_PERCENT_N = _UxGT("@ Treiber %"); LSTR MSG_ERROR_TMC = _UxGT("TMC Verbindungsfehler"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Werte speichern"); LSTR MSG_FILAMENT_CHANGE_HEADER = _UxGT("FILAMENT WECHSEL"); @@ -528,6 +618,8 @@ namespace Language_de { 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_FANCHECK = _UxGT("Lüftergeschw. prüfen"); LSTR MSG_KILL_HOMING_FAILED = _UxGT("Homing gescheitert"); LSTR MSG_LCD_PROBING_FAILED = _UxGT("Probing gescheitert"); @@ -639,4 +731,33 @@ namespace Language_de { #endif LSTR MSG_REHEAT = _UxGT("Erneut aufheizen"); LSTR MSG_REHEATING = _UxGT("Erneut aufhei. ..."); + LSTR MSG_REHEATDONE = _UxGT("Aufwärmen fertig"); + + LSTR MSG_PROBE_WIZARD = _UxGT("Sonden-Assistent"); + LSTR MSG_PROBE_WIZARD_PROBING = _UxGT("Sonden-Bezug"); + LSTR MSG_PROBE_WIZARD_MOVING = _UxGT("Bewege zur Position"); + + LSTR MSG_XATC = _UxGT("X-Verdreh-Assistent"); + LSTR MSG_XATC_DONE = _UxGT("X-Verdreh-Assi fertig!"); + LSTR MSG_XATC_UPDATE_Z_OFFSET = _UxGT("Z-Versatz Sonde akt. auf "); + + LSTR MSG_SOUND = _UxGT("Ton"); + + LSTR MSG_TOP_LEFT = _UxGT("Oben Links"); + LSTR MSG_BOTTOM_LEFT = _UxGT("Unten Links"); + LSTR MSG_TOP_RIGHT = _UxGT("Oben Rechts"); + LSTR MSG_BOTTOM_RIGHT = _UxGT("Unten Rechts"); + LSTR MSG_CALIBRATION_COMPLETED = _UxGT("Kalibrierung beendet"); + LSTR MSG_CALIBRATION_FAILED = _UxGT("Kalibrierung geschei."); + + LSTR MSG_DRIVER_BACKWARD = _UxGT(" Driver zurück"); + + LSTR MSG_SD_CARD = _UxGT("SD Karte"); + LSTR MSG_USB_DISK = _UxGT("USB Disk"); + + LSTR MSG_HOST_SHUTDOWN = _UxGT("Host abschalten"); + + LSTR MSG_SHORT_DAY = _UxGT("t"); // 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_el.h b/Marlin/src/lcd/language/language_el.h index 567706180cb1..47d6a5b2da35 100644 --- a/Marlin/src/lcd/language/language_el.h +++ b/Marlin/src/lcd/language/language_el.h @@ -64,7 +64,6 @@ namespace Language_el { LSTR MSG_LEVEL_BED_DONE = _UxGT("Τέλος επιπεδοποίησης!"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Ορισμός μετατοπίσεων"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Εφαρμογή μετατοπίσεων"); - LSTR MSG_SET_ORIGIN = _UxGT("Ορισμός προέλευσης"); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Προθέρμανση ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Προθέρμανση ") PREHEAT_1_LABEL " ~"; @@ -117,41 +116,33 @@ namespace Language_el { LSTR MSG_LCD_ON = _UxGT("Ενεργοποιημένο"); LSTR MSG_LCD_OFF = _UxGT("Απενεργοποιημένο"); LSTR MSG_ACC = _UxGT("Επιτάχυνση"); - LSTR MSG_VA_JERK = _UxGT("Vαντίδραση ") LCD_STR_A; - LSTR MSG_VB_JERK = _UxGT("Vαντίδραση ") LCD_STR_B; - LSTR MSG_VC_JERK = _UxGT("Vαντίδραση ") LCD_STR_C; - LSTR MSG_VI_JERK = _UxGT("Vαντίδραση ") LCD_STR_I; - LSTR MSG_VJ_JERK = _UxGT("Vαντίδραση ") LCD_STR_J; - LSTR MSG_VK_JERK = _UxGT("Vαντίδραση ") LCD_STR_K; + LSTR MSG_VA_JERK = _UxGT("Vαντίδραση ") STR_A; + LSTR MSG_VB_JERK = _UxGT("Vαντίδραση ") STR_B; + LSTR MSG_VC_JERK = _UxGT("Vαντίδραση ") STR_C; + LSTR MSG_VN_JERK = _UxGT("Vαντίδραση @"); LSTR MSG_VE_JERK = _UxGT("Vαντίδραση E"); - LSTR MSG_VMAX_A = _UxGT("V Μέγιστο") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("V Μέγιστο") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("V Μέγιστο") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("V Μέγιστο") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("V Μέγιστο") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("V Μέγιστο") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("V Μέγιστο") LCD_STR_E; + LSTR MSG_VMAX_A = _UxGT("V Μέγιστο") STR_A; + LSTR MSG_VMAX_B = _UxGT("V Μέγιστο") STR_B; + LSTR MSG_VMAX_C = _UxGT("V Μέγιστο") STR_C; + LSTR MSG_VMAX_N = _UxGT("V Μέγιστο@"); + LSTR MSG_VMAX_E = _UxGT("V ΜέγιστοE"); LSTR MSG_VMAX_EN = _UxGT("V Μέγιστο *"); LSTR MSG_VMIN = _UxGT("V Ελάχιστο"); LSTR MSG_VTRAV_MIN = _UxGT("Vελάχ. μετατόπιση"); LSTR MSG_ACCELERATION = _UxGT("Accel"); - LSTR MSG_AMAX_A = _UxGT("Aμεγ ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Aμεγ ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Aμεγ ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Aμεγ ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Aμεγ ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Aμεγ ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Aμεγ ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Aμεγ ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Aμεγ ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Aμεγ ") STR_C; + LSTR MSG_AMAX_N = _UxGT("Aμεγ @"); + LSTR MSG_AMAX_E = _UxGT("Aμεγ E"); LSTR MSG_AMAX_EN = _UxGT("Aμεγ *"); LSTR MSG_A_RETRACT = _UxGT("Α-ανάσυρση"); LSTR MSG_A_TRAVEL = _UxGT("Α-μετατόπιση"); LSTR MSG_STEPS_PER_MM = _UxGT("Bήματα ανά μμ"); - LSTR MSG_A_STEPS = _UxGT("Bήματα ") LCD_STR_A _UxGT(" ανά μμ"); - LSTR MSG_B_STEPS = _UxGT("Bήματα ") LCD_STR_B _UxGT(" ανά μμ"); - LSTR MSG_C_STEPS = _UxGT("Bήματα ") LCD_STR_C _UxGT(" ανά μμ"); - LSTR MSG_I_STEPS = _UxGT("Bήματα ") LCD_STR_I _UxGT(" ανά μμ"); - LSTR MSG_J_STEPS = _UxGT("Bήματα ") LCD_STR_J _UxGT(" ανά μμ"); - LSTR MSG_K_STEPS = _UxGT("Bήματα ") LCD_STR_K _UxGT(" ανά μμ"); + LSTR MSG_A_STEPS = _UxGT("Bήματα ") STR_A _UxGT(" ανά μμ"); + LSTR MSG_B_STEPS = _UxGT("Bήματα ") STR_B _UxGT(" ανά μμ"); + LSTR MSG_C_STEPS = _UxGT("Bήματα ") STR_C _UxGT(" ανά μμ"); + LSTR MSG_N_STEPS = _UxGT("Bήματα @ ανά μμ"); LSTR MSG_E_STEPS = _UxGT("Bήματα Ε ανά μμ"); LSTR MSG_EN_STEPS = _UxGT("Bήματα * ανά μμ"); LSTR MSG_TEMPERATURE = _UxGT("Θερμοκρασία"); @@ -202,6 +193,7 @@ namespace Language_el { LSTR MSG_HEATING_FAILED_LCD = _UxGT("Αποτυχία θέρμανσης"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("ΠΛΕΟΝΑΖΟΥΣΑ ΘΕΡΜΟΤΗΤΑ"); LSTR MSG_THERMAL_RUNAWAY = _UxGT("ΘΕΡΜΙΚΗ ΔΙΑΦΥΓΗ"); + LSTR MSG_TEMP_MALFUNCTION = _UxGT("ΘΕΡΜΙΚΗ ΔΥΣΛΕΙΤΟΥΡΓΙΑ"); LSTR MSG_ERR_MAXTEMP = _UxGT("ΠΕΡΙΤΤΗ ΘΕΡΜΟΚΡΑΣΙΑ"); LSTR MSG_ERR_MINTEMP = _UxGT("ΑΝΕΠΑΡΚΗΣ ΘΕΡΜΟΚΡΑΣΙΑ"); LSTR MSG_HALTED = _UxGT("Εκτυπωτής διεκόπη"); diff --git a/Marlin/src/lcd/language/language_el_gr.h b/Marlin/src/lcd/language/language_el_gr.h index 53e3ee3b948b..bd2e7d595d9a 100644 --- a/Marlin/src/lcd/language/language_el_gr.h +++ b/Marlin/src/lcd/language/language_el_gr.h @@ -53,7 +53,6 @@ namespace Language_el_gr { LSTR MSG_LEVEL_BED_DONE = _UxGT("Ολοκλήρωση επιπεδοποίησης!"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Ορισμός βασικών μετατοπίσεων"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Εφαρμόστηκαν οι μετατοπίσεις"); - LSTR MSG_SET_ORIGIN = _UxGT("Ορισμός προέλευσης"); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Προθέρμανση ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Προθέρμανση ") PREHEAT_1_LABEL " ~"; @@ -107,41 +106,33 @@ namespace Language_el_gr { LSTR MSG_LCD_OFF = _UxGT("Απενεργοποιημένο"); LSTR MSG_ACC = _UxGT("Επιτάχυνση"); LSTR MSG_JERK = _UxGT("Vαντίδραση"); - LSTR MSG_VA_JERK = _UxGT("Vαντίδραση ") LCD_STR_A; - LSTR MSG_VB_JERK = _UxGT("Vαντίδραση ") LCD_STR_B; - LSTR MSG_VC_JERK = _UxGT("Vαντίδραση ") LCD_STR_C; - LSTR MSG_VI_JERK = _UxGT("Vαντίδραση ") LCD_STR_I; - LSTR MSG_VJ_JERK = _UxGT("Vαντίδραση ") LCD_STR_J; - LSTR MSG_VK_JERK = _UxGT("Vαντίδραση ") LCD_STR_K; + LSTR MSG_VA_JERK = _UxGT("Vαντίδραση ") STR_A; + LSTR MSG_VB_JERK = _UxGT("Vαντίδραση ") STR_B; + LSTR MSG_VC_JERK = _UxGT("Vαντίδραση ") STR_C; + LSTR MSG_VN_JERK = _UxGT("Vαντίδραση @"); LSTR MSG_VE_JERK = _UxGT("Vαντίδραση E"); - LSTR MSG_VMAX_A = _UxGT("Vμεγ ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Vμεγ ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Vμεγ ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Vμεγ ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Vμεγ ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Vμεγ ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Vμεγ ") LCD_STR_E; + LSTR MSG_VMAX_A = _UxGT("Vμεγ ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Vμεγ ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Vμεγ ") STR_C; + LSTR MSG_VMAX_N = _UxGT("Vμεγ @"); + LSTR MSG_VMAX_E = _UxGT("Vμεγ E"); LSTR MSG_VMAX_EN = _UxGT("Vμεγ *"); LSTR MSG_VMIN = _UxGT("Vελαχ"); LSTR MSG_VTRAV_MIN = _UxGT("Vελάχ. μετατόπιση"); LSTR MSG_ACCELERATION = _UxGT("Accel"); - LSTR MSG_AMAX_A = _UxGT("Aμεγ ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Aμεγ ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Aμεγ ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Aμεγ ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Aμεγ ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Aμεγ ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Aμεγ ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Aμεγ ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Aμεγ ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Aμεγ ") STR_C; + LSTR MSG_AMAX_N = _UxGT("Aμεγ @"); + LSTR MSG_AMAX_E = _UxGT("Aμεγ E"); LSTR MSG_AMAX_EN = _UxGT("Aμεγ *"); LSTR MSG_A_RETRACT = _UxGT("Α-ανάσυρση"); LSTR MSG_A_TRAVEL = _UxGT("Α-μετατόπιση"); LSTR MSG_STEPS_PER_MM = _UxGT("Bήματα ανά μμ"); - LSTR MSG_A_STEPS = _UxGT("Bήματα ") LCD_STR_A _UxGT(" ανά μμ"); - LSTR MSG_B_STEPS = _UxGT("Bήματα ") LCD_STR_B _UxGT(" ανά μμ"); - LSTR MSG_C_STEPS = _UxGT("Bήματα ") LCD_STR_C _UxGT(" ανά μμ"); - LSTR MSG_I_STEPS = _UxGT("Bήματα ") LCD_STR_I _UxGT(" ανά μμ"); - LSTR MSG_J_STEPS = _UxGT("Bήματα ") LCD_STR_J _UxGT(" ανά μμ"); - LSTR MSG_K_STEPS = _UxGT("Bήματα ") LCD_STR_K _UxGT(" ανά μμ"); + LSTR MSG_A_STEPS = _UxGT("Bήματα ") STR_A _UxGT(" ανά μμ"); + LSTR MSG_B_STEPS = _UxGT("Bήματα ") STR_B _UxGT(" ανά μμ"); + LSTR MSG_C_STEPS = _UxGT("Bήματα ") STR_C _UxGT(" ανά μμ"); + LSTR MSG_N_STEPS = _UxGT("Bήματα @ ανά μμ"); LSTR MSG_E_STEPS = _UxGT("Bήματα Ε ανά μμ"); LSTR MSG_EN_STEPS = _UxGT("Bήματα * ανά μμ"); LSTR MSG_TEMPERATURE = _UxGT("Θερμοκρασία"); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 1d8861b2c700..81f30b61d8ef 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -27,10 +27,9 @@ * LCD Menu Messages * See also https://marlinfw.org/docs/development/lcd_language.html * - * Substitutions are applied for the following characters when used - * in menu items that call lcd_put_u8str_ind_P with an index: + * Substitutions are applied for the following characters when used in menu items titles: * - * $ displays an inserted C-string + * $ displays an inserted string * = displays '0'....'10' for indexes 0 - 10 * ~ displays '1'....'11' for indexes 0 - 10 * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) @@ -53,7 +52,10 @@ namespace Language_en { LSTR WELCOME_MSG = MACHINE_NAME _UxGT(" Ready."); LSTR MSG_YES = _UxGT("YES"); LSTR MSG_NO = _UxGT("NO"); + LSTR MSG_HIGH = _UxGT("HIGH"); + LSTR MSG_LOW = _UxGT("LOW"); LSTR MSG_BACK = _UxGT("Back"); + LSTR MSG_ERROR = _UxGT("Error"); LSTR MSG_MEDIA_ABORTING = _UxGT("Aborting..."); LSTR MSG_MEDIA_INSERTED = MEDIA_TYPE_EN _UxGT(" Inserted"); LSTR MSG_MEDIA_REMOVED = MEDIA_TYPE_EN _UxGT(" Removed"); @@ -67,6 +69,8 @@ namespace Language_en { LSTR MSG_LCD_SOFT_ENDSTOPS = _UxGT("Soft Endstops"); LSTR MSG_MAIN = _UxGT("Main"); LSTR MSG_ADVANCED_SETTINGS = _UxGT("Advanced Settings"); + LSTR MSG_TOOLBAR_SETUP = _UxGT("Toolbar Setup"); + LSTR MSG_OPTION_DISABLED = _UxGT("Option Disabled"); LSTR MSG_CONFIGURATION = _UxGT("Configuration"); LSTR MSG_RUN_AUTO_FILES = _UxGT("Run Auto Files"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Disable Steppers"); @@ -75,14 +79,19 @@ namespace Language_en { LSTR MSG_HOMING = _UxGT("Homing"); LSTR MSG_AUTO_HOME = _UxGT("Auto Home"); LSTR MSG_AUTO_HOME_A = _UxGT("Home @"); + 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_FILAMENT_SET = _UxGT("Filament Settings"); LSTR MSG_FILAMENT_MAN = _UxGT("Filament Management"); + LSTR MSG_MANUAL_LEVELING = _UxGT("Manual Leveling"); LSTR MSG_LEVBED_FL = _UxGT("Front Left"); LSTR MSG_LEVBED_FR = _UxGT("Front Right"); LSTR MSG_LEVBED_C = _UxGT("Center"); LSTR MSG_LEVBED_BL = _UxGT("Back Left"); LSTR MSG_LEVBED_BR = _UxGT("Back Right"); LSTR MSG_MANUAL_MESH = _UxGT("Manual Mesh"); + LSTR MSG_AUTO_MESH = _UxGT("Auto Build Mesh"); LSTR MSG_AUTO_Z_ALIGN = _UxGT("Auto Z-Align"); LSTR MSG_ITERATION = _UxGT("G34 Iteration: %i"); LSTR MSG_DECREASING_ACCURACY = _UxGT("Accuracy Decreasing!"); @@ -96,11 +105,7 @@ namespace Language_en { LSTR MSG_HOME_OFFSET_X = _UxGT("Home Offset X"); LSTR MSG_HOME_OFFSET_Y = _UxGT("Home Offset Y"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Home Offset Z"); - LSTR MSG_HOME_OFFSET_I = _UxGT("Home Offset ") LCD_STR_I; - LSTR MSG_HOME_OFFSET_J = _UxGT("Home Offset ") LCD_STR_J; - LSTR MSG_HOME_OFFSET_K = _UxGT("Home Offset ") LCD_STR_K; LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Offsets Applied"); - LSTR MSG_SET_ORIGIN = _UxGT("Set Origin"); LSTR MSG_TRAMMING_WIZARD = _UxGT("Tramming Wizard"); LSTR MSG_SELECT_ORIGIN = _UxGT("Select Origin"); LSTR MSG_LAST_VALUE_SP = _UxGT("Last value "); @@ -112,7 +117,14 @@ namespace Language_en { LSTR MSG_PREHEAT_1_ALL = _UxGT("Preheat ") PREHEAT_1_LABEL _UxGT(" All"); LSTR MSG_PREHEAT_1_BEDONLY = _UxGT("Preheat ") PREHEAT_1_LABEL _UxGT(" Bed"); LSTR MSG_PREHEAT_1_SETTINGS = _UxGT("Preheat ") PREHEAT_1_LABEL _UxGT(" Conf"); - + #ifdef PREHEAT_2_LABEL + LSTR MSG_PREHEAT_2 = _UxGT("Preheat ") PREHEAT_2_LABEL; + LSTR MSG_PREHEAT_2_SETTINGS = _UxGT("Preheat ") PREHEAT_2_LABEL _UxGT(" Conf"); + #endif + #ifdef PREHEAT_3_LABEL + LSTR MSG_PREHEAT_3 = _UxGT("Preheat ") PREHEAT_3_LABEL; + LSTR MSG_PREHEAT_3_SETTINGS = _UxGT("Preheat ") PREHEAT_3_LABEL _UxGT(" Conf"); + #endif LSTR MSG_PREHEAT_M = _UxGT("Preheat $"); LSTR MSG_PREHEAT_M_H = _UxGT("Preheat $ ~"); LSTR MSG_PREHEAT_M_END = _UxGT("Preheat $ End"); @@ -147,19 +159,31 @@ namespace Language_en { LSTR MSG_BED_LEVELING = _UxGT("Bed Leveling"); LSTR MSG_LEVEL_BED = _UxGT("Level Bed"); LSTR MSG_BED_TRAMMING = _UxGT("Bed Tramming"); + LSTR MSG_BED_TRAMMING_MANUAL = _UxGT("Manual Tramming"); LSTR MSG_BED_TRAMMING_RAISE = _UxGT("Adjust bed until the probe triggers."); LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Corners within tolerance. Bed trammed."); LSTR MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Good Points: "); LSTR MSG_BED_TRAMMING_LAST_Z = _UxGT("Last Z: "); LSTR MSG_NEXT_CORNER = _UxGT("Next Corner"); LSTR MSG_MESH_EDITOR = _UxGT("Mesh Editor"); + LSTR MSG_MESH_VIEWER = _UxGT("Mesh Viewer"); LSTR MSG_EDIT_MESH = _UxGT("Edit Mesh"); LSTR MSG_MESH_VIEW = _UxGT("View Mesh"); LSTR MSG_EDITING_STOPPED = _UxGT("Mesh Editing Stopped"); + LSTR MSG_NO_VALID_MESH = _UxGT("No valid mesh"); + LSTR MSG_ACTIVATE_MESH = _UxGT("Activate Leveling"); LSTR MSG_PROBING_POINT = _UxGT("Probing Point"); LSTR MSG_MESH_X = _UxGT("Index X"); LSTR MSG_MESH_Y = _UxGT("Index 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("Maximize Area"); + LSTR MSG_MESH_CENTER = _UxGT("Center Area"); LSTR MSG_MESH_EDIT_Z = _UxGT("Z Value"); + LSTR MSG_MESH_CANCEL = _UxGT("Mesh cancelled"); LSTR MSG_CUSTOM_COMMANDS = _UxGT("Custom Commands"); LSTR MSG_M48_TEST = _UxGT("M48 Probe Test"); LSTR MSG_M48_POINT = _UxGT("M48 Point"); @@ -178,6 +202,9 @@ namespace Language_en { LSTR MSG_UBL_TOOLS = _UxGT("UBL Tools"); LSTR MSG_UBL_LEVEL_BED = _UxGT("Unified Bed Leveling"); LSTR MSG_LCD_TILTING_MESH = _UxGT("Tilting Point"); + 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("Manually Build Mesh"); LSTR MSG_UBL_MESH_WIZARD = _UxGT("UBL Mesh Wizard"); LSTR MSG_UBL_BC_INSERT = _UxGT("Place Shim & Measure"); @@ -226,6 +253,7 @@ namespace Language_en { LSTR MSG_UBL_MANUAL_FILLIN = _UxGT("Manual Fill-in"); 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_INVALIDATE_ALL = _UxGT("Invalidate All"); LSTR MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Invalidate Closest"); LSTR MSG_UBL_FINE_TUNE_ALL = _UxGT("Fine Tune All"); @@ -234,6 +262,7 @@ namespace Language_en { LSTR MSG_UBL_STORAGE_SLOT = _UxGT("Memory Slot"); LSTR MSG_UBL_LOAD_MESH = _UxGT("Load Bed Mesh"); LSTR MSG_UBL_SAVE_MESH = _UxGT("Save Bed Mesh"); + 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_UBL_NO_STORAGE = _UxGT("No Storage"); @@ -278,13 +307,11 @@ namespace Language_en { LSTR MSG_MOVE_X = _UxGT("Move X"); // Used by draw_edit_screen LSTR MSG_MOVE_Y = _UxGT("Move Y"); LSTR MSG_MOVE_Z = _UxGT("Move Z"); - LSTR MSG_MOVE_I = _UxGT("Move ") LCD_STR_I; - LSTR MSG_MOVE_J = _UxGT("Move ") LCD_STR_J; - LSTR MSG_MOVE_K = _UxGT("Move ") LCD_STR_K; + LSTR MSG_MOVE_N = _UxGT("Move @"); LSTR MSG_MOVE_E = _UxGT("Move Extruder"); LSTR MSG_MOVE_EN = _UxGT("Move E*"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hotend too cold"); - LSTR MSG_MOVE_N_MM = _UxGT("Move %smm"); + 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"); @@ -294,12 +321,6 @@ namespace Language_en { LSTR MSG_MOVE_01IN = _UxGT("Move 0.1in"); LSTR MSG_MOVE_1IN = _UxGT("Move 1.0in"); LSTR MSG_SPEED = _UxGT("Speed"); - LSTR MSG_MAXSPEED = _UxGT("Max Speed (mm/s)"); - LSTR MSG_MAXSPEED_X = _UxGT("Max ") LCD_STR_A _UxGT(" Speed"); - LSTR MSG_MAXSPEED_Y = _UxGT("Max ") LCD_STR_B _UxGT(" Speed"); - LSTR MSG_MAXSPEED_Z = _UxGT("Max ") LCD_STR_C _UxGT(" Speed"); - LSTR MSG_MAXSPEED_E = _UxGT("Max ") LCD_STR_E _UxGT(" Speed"); - LSTR MSG_MAXSPEED_A = _UxGT("Max @ Speed"); LSTR MSG_BED_Z = _UxGT("Bed Z"); LSTR MSG_NOZZLE = _UxGT("Nozzle"); LSTR MSG_NOZZLE_N = _UxGT("Nozzle ~"); @@ -334,52 +355,56 @@ namespace Language_en { LSTR MSG_PID_AUTOTUNE_E = _UxGT("PID Autotune *"); LSTR MSG_PID_CYCLE = _UxGT("PID Cycles"); LSTR MSG_PID_AUTOTUNE_DONE = _UxGT("PID tuning done"); - 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_AUTOTUNE_FAILED = _UxGT("PID Autotune failed!"); + LSTR MSG_BAD_EXTRUDER_NUM = _UxGT("Bad extruder."); + LSTR MSG_TEMP_TOO_HIGH = _UxGT("Temperature too high."); + LSTR MSG_TIMEOUT = _UxGT("Timeout."); + 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_MPC_MEASURING_AMBIENT = _UxGT("Testing heat loss"); + LSTR MSG_MPC_AUTOTUNE = _UxGT("MPC Autotune"); + LSTR MSG_MPC_EDIT = _UxGT("Edit * MPC"); + LSTR MSG_MPC_POWER_E = _UxGT("Power *"); + LSTR MSG_MPC_BLOCK_HEAT_CAPACITY_E = _UxGT("Block C *"); + 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"); - LSTR MSG_VA_JERK = _UxGT("Max ") LCD_STR_A _UxGT(" Jerk"); - LSTR MSG_VB_JERK = _UxGT("Max ") LCD_STR_B _UxGT(" Jerk"); - LSTR MSG_VC_JERK = _UxGT("Max ") LCD_STR_C _UxGT(" Jerk"); - LSTR MSG_VI_JERK = _UxGT("Max ") LCD_STR_I _UxGT(" Jerk"); - LSTR MSG_VJ_JERK = _UxGT("Max ") LCD_STR_J _UxGT(" Jerk"); - LSTR MSG_VK_JERK = _UxGT("Max ") LCD_STR_K _UxGT(" Jerk"); + LSTR MSG_VA_JERK = _UxGT("Max ") STR_A _UxGT(" Jerk"); + 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_JUNCTION_DEVIATION = _UxGT("Junction Dev"); - LSTR MSG_VELOCITY = _UxGT("Velocity"); - LSTR MSG_VMAX_A = _UxGT("Max ") LCD_STR_A _UxGT(" Vel"); - LSTR MSG_VMAX_B = _UxGT("Max ") LCD_STR_B _UxGT(" Vel"); - LSTR MSG_VMAX_C = _UxGT("Max ") LCD_STR_C _UxGT(" Vel"); - LSTR MSG_VMAX_I = _UxGT("Max ") LCD_STR_I _UxGT(" Vel"); - LSTR MSG_VMAX_J = _UxGT("Max ") LCD_STR_J _UxGT(" Vel"); - LSTR MSG_VMAX_K = _UxGT("Max ") LCD_STR_K _UxGT(" Vel"); - LSTR MSG_VMAX_E = _UxGT("Max ") LCD_STR_E _UxGT(" Vel"); - LSTR MSG_VMAX_EN = _UxGT("Max * Vel"); + LSTR MSG_MAX_SPEED = _UxGT("Max Speed (mm/s)"); + LSTR MSG_VMAX_A = _UxGT("Max ") STR_A _UxGT(" Speed"); + LSTR MSG_VMAX_B = _UxGT("Max ") STR_B _UxGT(" Speed"); + LSTR MSG_VMAX_C = _UxGT("Max ") STR_C _UxGT(" Speed"); + LSTR MSG_VMAX_N = _UxGT("Max @ Speed"); + LSTR MSG_VMAX_E = _UxGT("Max E Speed"); + LSTR MSG_VMAX_EN = _UxGT("Max * Speed"); LSTR MSG_VMIN = _UxGT("Min Velocity"); - LSTR MSG_VTRAV_MIN = _UxGT("Min Travel Vel"); + LSTR MSG_VTRAV_MIN = _UxGT("Min Travel Speed"); LSTR MSG_ACCELERATION = _UxGT("Acceleration"); - LSTR MSG_AMAX_A = _UxGT("Max ") LCD_STR_A _UxGT(" Accel"); - LSTR MSG_AMAX_B = _UxGT("Max ") LCD_STR_B _UxGT(" Accel"); - LSTR MSG_AMAX_C = _UxGT("Max ") LCD_STR_C _UxGT(" Accel"); - LSTR MSG_AMAX_I = _UxGT("Max ") LCD_STR_I _UxGT(" Accel"); - LSTR MSG_AMAX_J = _UxGT("Max ") LCD_STR_J _UxGT(" Accel"); - LSTR MSG_AMAX_K = _UxGT("Max ") LCD_STR_K _UxGT(" Accel"); - LSTR MSG_AMAX_E = _UxGT("Max ") LCD_STR_E _UxGT(" Accel"); + LSTR MSG_AMAX_A = _UxGT("Max ") STR_A _UxGT(" Accel"); + LSTR MSG_AMAX_B = _UxGT("Max ") STR_B _UxGT(" Accel"); + LSTR MSG_AMAX_C = _UxGT("Max ") STR_C _UxGT(" Accel"); + LSTR MSG_AMAX_N = _UxGT("Max @ Accel"); + LSTR MSG_AMAX_E = _UxGT("Max E Accel"); LSTR MSG_AMAX_EN = _UxGT("Max * Accel"); LSTR MSG_A_RETRACT = _UxGT("Retract Accel"); LSTR MSG_A_TRAVEL = _UxGT("Travel Accel"); 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"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" Steps/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" Steps/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" Steps/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" Steps/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" Steps/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" Steps/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" Steps/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" Steps/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" Steps/mm"); + LSTR MSG_N_STEPS = _UxGT("@ steps/mm"); LSTR MSG_E_STEPS = _UxGT("E steps/mm"); LSTR MSG_EN_STEPS = _UxGT("* Steps/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperature"); @@ -396,6 +421,9 @@ namespace Language_en { LSTR MSG_ADVANCE_K_E = _UxGT("Advance K *"); LSTR MSG_CONTRAST = _UxGT("LCD Contrast"); LSTR MSG_BRIGHTNESS = _UxGT("LCD Brightness"); + LSTR MSG_LCD_TIMEOUT_SEC = _UxGT("LCD Timeout (s)"); + LSTR MSG_SCREEN_TIMEOUT = _UxGT("LCD Timeout (m)"); + LSTR MSG_BRIGHTNESS_OFF = _UxGT("Backlight Off"); LSTR MSG_STORE_EEPROM = _UxGT("Store Settings"); LSTR MSG_LOAD_EEPROM = _UxGT("Load Settings"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Restore Defaults"); @@ -408,6 +436,10 @@ namespace Language_en { LSTR MSG_RESET_PRINTER = _UxGT("Reset Printer"); LSTR MSG_REFRESH = LCD_STR_REFRESH _UxGT("Refresh"); LSTR MSG_INFO_SCREEN = _UxGT("Info Screen"); + LSTR MSG_INFO_MACHINENAME = _UxGT("Machine Name"); + LSTR MSG_INFO_SIZE = _UxGT("Size"); + LSTR MSG_INFO_FWVERSION = _UxGT("Firmware Version"); + LSTR MSG_INFO_BUILD = _UxGT("Build Datetime"); LSTR MSG_PREPARE = _UxGT("Prepare"); LSTR MSG_TUNE = _UxGT("Tune"); LSTR MSG_POWER_MONITOR = _UxGT("Power monitor"); @@ -422,12 +454,22 @@ namespace Language_en { LSTR MSG_BUTTON_RESET = _UxGT("Reset"); LSTR MSG_BUTTON_IGNORE = _UxGT("Ignore"); LSTR MSG_BUTTON_CANCEL = _UxGT("Cancel"); + LSTR MSG_BUTTON_CONFIRM = _UxGT("Confirm"); + LSTR MSG_BUTTON_CONTINUE = _UxGT("Continue"); LSTR MSG_BUTTON_DONE = _UxGT("Done"); LSTR MSG_BUTTON_BACK = _UxGT("Back"); LSTR MSG_BUTTON_PROCEED = _UxGT("Proceed"); LSTR MSG_BUTTON_SKIP = _UxGT("Skip"); + LSTR MSG_BUTTON_INFO = _UxGT("Info"); + LSTR MSG_BUTTON_LEVEL = _UxGT("Level"); + LSTR MSG_BUTTON_PAUSE = _UxGT("Pause"); + LSTR MSG_BUTTON_RESUME = _UxGT("Resume"); + LSTR MSG_BUTTON_ADVANCED = _UxGT("Advanced"); + LSTR MSG_BUTTON_SAVE = _UxGT("Save"); + LSTR MSG_BUTTON_PURGE = _UxGT("Purge"); LSTR MSG_PAUSING = _UxGT("Pausing..."); 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"); @@ -436,17 +478,23 @@ namespace Language_en { 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; LSTR MSG_NO_MEDIA = _UxGT("No ") MEDIA_TYPE_EN; LSTR MSG_DWELL = _UxGT("Sleep..."); LSTR MSG_USERWAIT = _UxGT("Click to Resume..."); LSTR MSG_PRINT_PAUSED = _UxGT("Print Paused"); LSTR MSG_PRINTING = _UxGT("Printing..."); + LSTR MSG_STOPPING = _UxGT("Stopping..."); + LSTR MSG_REMAINING_TIME = _UxGT("Remaining"); 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. "); + LSTR MSG_FWRETRACT = _UxGT("Firmware Retract"); LSTR MSG_CONTROL_RETRACT = _UxGT("Retract mm"); LSTR MSG_CONTROL_RETRACT_SWAP = _UxGT("Swap Re.mm"); LSTR MSG_CONTROL_RETRACTF = _UxGT("Retract V"); @@ -512,18 +560,20 @@ namespace Language_en { LSTR MSG_ZPROBE_XOFFSET = _UxGT("Probe X Offset"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Probe Y Offset"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Probe Z Offset"); + LSTR MSG_ZPROBE_MARGIN = _UxGT("Probe Margin"); + LSTR MSG_Z_FEED_RATE = _UxGT("Z Feed Rate"); + LSTR MSG_ENABLE_HS_MODE = _UxGT("Enable HS mode"); LSTR MSG_MOVE_NOZZLE_TO_BED = _UxGT("Move Nozzle to Bed"); LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Babystep Z"); - LSTR MSG_BABYSTEP_I = _UxGT("Babystep ") LCD_STR_I; - LSTR MSG_BABYSTEP_J = _UxGT("Babystep ") LCD_STR_J; - LSTR MSG_BABYSTEP_K = _UxGT("Babystep ") LCD_STR_K; + LSTR MSG_BABYSTEP_N = _UxGT("Babystep @"); LSTR MSG_BABYSTEP_TOTAL = _UxGT("Total"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Endstop Abort"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Heating Failed"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("Err: REDUNDANT TEMP"); LSTR MSG_THERMAL_RUNAWAY = _UxGT("THERMAL RUNAWAY"); + LSTR MSG_TEMP_MALFUNCTION = _UxGT("TEMP MALFUNCTION"); LSTR MSG_THERMAL_RUNAWAY_BED = _UxGT("BED THERMAL RUNAWAY"); LSTR MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("CHAMBER T. RUNAWAY"); LSTR MSG_THERMAL_RUNAWAY_COOLER = _UxGT("Cooler Runaway"); @@ -531,6 +581,7 @@ namespace Language_en { LSTR MSG_ERR_MAXTEMP = _UxGT("Err: MAXTEMP"); LSTR MSG_ERR_MINTEMP = _UxGT("Err: MINTEMP"); LSTR MSG_HALTED = _UxGT("PRINTER HALTED"); + LSTR MSG_PLEASE_WAIT = _UxGT("Please wait..."); LSTR MSG_PLEASE_RESET = _UxGT("Please Reset"); LSTR MSG_PREHEATING = _UxGT("Preheating..."); LSTR MSG_HEATING = _UxGT("Heating..."); @@ -577,31 +628,43 @@ namespace Language_en { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Light Brightness"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("INCORRECT PRINTER"); - #if LCD_WIDTH >= 20 + LSTR MSG_COLORS_GET = _UxGT("Get Color"); + LSTR MSG_COLORS_SELECT = _UxGT("Select Colors"); + LSTR MSG_COLORS_APPLIED = _UxGT("Colors applied"); + LSTR MSG_COLORS_RED = _UxGT("Red"); + LSTR MSG_COLORS_GREEN = _UxGT("Green"); + LSTR MSG_COLORS_BLUE = _UxGT("Blue"); + LSTR MSG_COLORS_WHITE = _UxGT("White"); + LSTR MSG_UI_LANGUAGE = _UxGT("UI Language"); + LSTR MSG_SOUND_ENABLE = _UxGT("Enable sound"); + LSTR MSG_LOCKSCREEN = _UxGT("Lock Screen"); + LSTR MSG_LOCKSCREEN_LOCKED = _UxGT("Printer is Locked,"); + LSTR MSG_LOCKSCREEN_UNLOCK = _UxGT("Scroll to unlock."); + LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Please wait until reboot."); + + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 + LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("No media inserted."); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Please preheat the hot end."); + LSTR MSG_INFO_PRINT_COUNT_RESET = _UxGT("Reset Print Count"); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Print Count"); - LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completed"); - LSTR MSG_INFO_PRINT_TIME = _UxGT("Total Print Time"); + LSTR MSG_INFO_PRINT_TIME = _UxGT("Print Time"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Longest Job Time"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Extruded Total"); #else + LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("No Media"); + LSTR MSG_PLEASE_PREHEAT = _UxGT("Please Preheat"); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Prints"); - LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completed"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Total"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Longest"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Extruded"); #endif + LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completed"); LSTR MSG_INFO_MIN_TEMP = _UxGT("Min Temp"); LSTR MSG_INFO_MAX_TEMP = _UxGT("Max Temp"); LSTR MSG_INFO_PSU = _UxGT("PSU"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Drive Strength"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("E Driver %"); + LSTR MSG_DAC_PERCENT_N = _UxGT("@ Driver %"); LSTR MSG_ERROR_TMC = _UxGT("TMC CONNECTION ERROR"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM Write"); LSTR MSG_FILAMENT_CHANGE_HEADER = _UxGT("FILAMENT CHANGE"); @@ -611,10 +674,14 @@ namespace Language_en { LSTR MSG_FILAMENT_CHANGE_OPTION_HEADER = _UxGT("RESUME OPTIONS:"); LSTR MSG_FILAMENT_CHANGE_OPTION_PURGE = _UxGT("Purge more"); LSTR MSG_FILAMENT_CHANGE_OPTION_RESUME = _UxGT("Continue"); + LSTR MSG_FILAMENT_CHANGE_PURGE_CONTINUE = _UxGT("Purge or Continue?"); LSTR MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Nozzle: "); LSTR MSG_RUNOUT_SENSOR = _UxGT("Runout Sensor"); LSTR MSG_RUNOUT_DISTANCE_MM = _UxGT("Runout Dist mm"); LSTR MSG_RUNOUT_ENABLE = _UxGT("Enable Runout"); + LSTR MSG_RUNOUT_ACTIVE = _UxGT("Runout Active"); + LSTR MSG_INVERT_EXTRUDER = _UxGT("Invert Extruder"); + LSTR MSG_EXTRUDER_MIN_TEMP = _UxGT("Extruder Min Temp."); LSTR MSG_FANCHECK = _UxGT("Fan Tacho Check"); LSTR MSG_KILL_HOMING_FAILED = _UxGT("Homing Failed"); LSTR MSG_LCD_PROBING_FAILED = _UxGT("Probing Failed"); @@ -770,12 +837,7 @@ namespace Language_en { LSTR MSG_PID_C_E = _UxGT("PID-C *"); LSTR MSG_PID_F = _UxGT("PID-F"); LSTR MSG_PID_F_E = _UxGT("PID-F *"); - LSTR MSG_BACKLASH_A = LCD_STR_A; - LSTR MSG_BACKLASH_B = LCD_STR_B; - LSTR MSG_BACKLASH_C = LCD_STR_C; - LSTR MSG_BACKLASH_I = LCD_STR_I; - LSTR MSG_BACKLASH_J = LCD_STR_J; - LSTR MSG_BACKLASH_K = LCD_STR_K; + LSTR MSG_BACKLASH_N = _UxGT("@"); } #if FAN_COUNT == 1 diff --git a/Marlin/src/lcd/language/language_es.h b/Marlin/src/lcd/language/language_es.h index 9c593215bbd7..cc331efd4562 100644 --- a/Marlin/src/lcd/language/language_es.h +++ b/Marlin/src/lcd/language/language_es.h @@ -72,7 +72,6 @@ namespace Language_es { LSTR MSG_Z_FADE_HEIGHT = _UxGT("Compen. Altura"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Ajustar desfases"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Desfase aplicada"); - LSTR MSG_SET_ORIGIN = _UxGT("Establecer origen"); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Precal. ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Precal. ") PREHEAT_1_LABEL " ~"; @@ -230,7 +229,7 @@ namespace Language_es { LSTR MSG_MOVE_E = _UxGT("Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Extrusor *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hotend muy frio"); - LSTR MSG_MOVE_N_MM = _UxGT("Mover %smm"); + 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"); @@ -268,43 +267,35 @@ namespace Language_es { LSTR MSG_SELECT_E = _UxGT("Seleccionar *"); LSTR MSG_ACC = _UxGT("Aceleración"); LSTR MSG_JERK = _UxGT("Jerk"); - LSTR MSG_VA_JERK = _UxGT("Max ") LCD_STR_A _UxGT(" Jerk"); - LSTR MSG_VB_JERK = _UxGT("Max ") LCD_STR_B _UxGT(" Jerk"); - LSTR MSG_VC_JERK = _UxGT("Max ") LCD_STR_C _UxGT(" Jerk"); - LSTR MSG_VI_JERK = _UxGT("Max ") LCD_STR_I _UxGT(" Jerk"); - LSTR MSG_VJ_JERK = _UxGT("Max ") LCD_STR_J _UxGT(" Jerk"); - LSTR MSG_VK_JERK = _UxGT("Max ") LCD_STR_K _UxGT(" Jerk"); + LSTR MSG_VA_JERK = _UxGT("Max ") STR_A _UxGT(" Jerk"); + 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_JUNCTION_DEVIATION = _UxGT("Desvi. Unión"); - LSTR MSG_VELOCITY = _UxGT("Velocidad"); - LSTR MSG_VMAX_A = _UxGT("Max ") LCD_STR_A _UxGT(" Vel"); - LSTR MSG_VMAX_B = _UxGT("Max ") LCD_STR_B _UxGT(" Vel"); - LSTR MSG_VMAX_C = _UxGT("Max ") LCD_STR_C _UxGT(" Vel"); - LSTR MSG_VMAX_I = _UxGT("Max ") LCD_STR_I _UxGT(" Vel"); - LSTR MSG_VMAX_J = _UxGT("Max ") LCD_STR_J _UxGT(" Vel"); - LSTR MSG_VMAX_K = _UxGT("Max ") LCD_STR_K _UxGT(" Vel"); - LSTR MSG_VMAX_E = _UxGT("Max ") LCD_STR_E _UxGT(" Vel"); - LSTR MSG_VMAX_EN = _UxGT("Max * Vel"); + LSTR MSG_MAX_SPEED = _UxGT("Max Velocidad"); + LSTR MSG_VMAX_A = _UxGT("Max ") STR_A _UxGT(" Speed"); + LSTR MSG_VMAX_B = _UxGT("Max ") STR_B _UxGT(" Speed"); + LSTR MSG_VMAX_C = _UxGT("Max ") STR_C _UxGT(" Speed"); + LSTR MSG_VMAX_N = _UxGT("Max @ Speed"); + LSTR MSG_VMAX_E = _UxGT("Max E Speed"); + LSTR MSG_VMAX_EN = _UxGT("Max * Speed"); LSTR MSG_VMIN = _UxGT("Vmin"); LSTR MSG_VTRAV_MIN = _UxGT("Vel. viaje min"); LSTR MSG_ACCELERATION = _UxGT("Acceleración"); - LSTR MSG_AMAX_A = _UxGT("Acel. max") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Acel. max") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Acel. max") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Acel. max") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Acel. max") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Acel. max") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Acel. max") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Acel. max") STR_A; + LSTR MSG_AMAX_B = _UxGT("Acel. max") STR_B; + LSTR MSG_AMAX_C = _UxGT("Acel. max") STR_C; + LSTR MSG_AMAX_N = _UxGT("Acel. max@"); + LSTR MSG_AMAX_E = _UxGT("Acel. maxE"); LSTR MSG_AMAX_EN = _UxGT("Acel. max *"); LSTR MSG_A_RETRACT = _UxGT("Acel. retrac."); LSTR MSG_A_TRAVEL = _UxGT("Acel. Viaje"); LSTR MSG_STEPS_PER_MM = _UxGT("Pasos/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" pasos/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" pasos/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" pasos/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" pasos/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" pasos/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" pasos/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" pasos/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" pasos/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" pasos/mm"); + LSTR MSG_N_STEPS = _UxGT("@ pasos/mm"); LSTR MSG_E_STEPS = _UxGT("E pasos/mm"); LSTR MSG_EN_STEPS = _UxGT("* pasos/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatura"); @@ -414,6 +405,7 @@ namespace Language_es { LSTR MSG_BABYSTEP_X = _UxGT("Micropaso X"); LSTR MSG_BABYSTEP_Y = _UxGT("Micropaso Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Micropaso Z"); + LSTR MSG_BABYSTEP_N = _UxGT("Micropaso @"); LSTR MSG_BABYSTEP_TOTAL = _UxGT("Total"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Cancelado - Endstop"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Calent. fallido"); @@ -463,7 +455,7 @@ namespace Language_es { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Brillo cabina"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Impresora incorrecta"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Cont. de impresión"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completadas"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Tiempo total de imp."); @@ -481,13 +473,7 @@ namespace Language_es { LSTR MSG_INFO_MAX_TEMP = _UxGT("Temp. Máxima"); LSTR MSG_INFO_PSU = _UxGT("F. Aliment."); LSTR MSG_DRIVE_STRENGTH = _UxGT("Fuerza de empuje"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("E Driver %"); + LSTR MSG_DAC_PERCENT_N = _UxGT("@ Driver %"); LSTR MSG_ERROR_TMC = _UxGT("ERROR CONEX. TMC"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Escribe DAC EEPROM"); LSTR MSG_FILAMENT_CHANGE_HEADER = _UxGT("CAMBIAR FILAMENTO"); diff --git a/Marlin/src/lcd/language/language_eu.h b/Marlin/src/lcd/language/language_eu.h index adc812f6ffee..09a0fbeb6ac6 100644 --- a/Marlin/src/lcd/language/language_eu.h +++ b/Marlin/src/lcd/language/language_eu.h @@ -56,7 +56,6 @@ namespace Language_eu { LSTR MSG_LEVEL_BED_DONE = _UxGT("Berdintzea eginda"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Etxe. offset eza."); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Offsetak ezarrita"); - LSTR MSG_SET_ORIGIN = _UxGT("Hasiera ipini"); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Berotu ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Berotu ") PREHEAT_1_LABEL " ~"; @@ -139,7 +138,7 @@ namespace Language_eu { LSTR MSG_MOVE_Z = _UxGT("Mugitu Z"); LSTR MSG_MOVE_E = _UxGT("Estrusorea"); LSTR MSG_MOVE_EN = _UxGT("Estrusorea *"); - LSTR MSG_MOVE_N_MM = _UxGT("Mugitu %smm"); + 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"); @@ -164,23 +163,19 @@ namespace Language_eu { LSTR MSG_SELECT_E = _UxGT("Aukeratu *"); LSTR MSG_ACC = _UxGT("Azelerazioa"); LSTR MSG_JERK = _UxGT("Astindua"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-astindua"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-astindua"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-astindua"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-astindua"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-astindua"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-astindua"); + LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT("-astindua"); + LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT("-astindua"); + LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT("-astindua"); + LSTR MSG_VN_JERK = _UxGT("V@-astindua"); LSTR MSG_VE_JERK = _UxGT("Ve-astindua"); LSTR MSG_VTRAV_MIN = _UxGT("VBidaia min"); LSTR MSG_A_RETRACT = _UxGT("A-retrakt"); LSTR MSG_A_TRAVEL = _UxGT("A-bidaia"); LSTR MSG_STEPS_PER_MM = _UxGT("Pausoak/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" pausoak/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" pausoak/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" pausoak/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" pausoak/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" pausoak/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" pausoak/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" pausoak/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" pausoak/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" pausoak/mm"); + LSTR MSG_N_STEPS = _UxGT("@ pausoak/mm"); LSTR MSG_E_STEPS = _UxGT("E pausoak/mm"); LSTR MSG_EN_STEPS = _UxGT("* pausoak/mm"); LSTR MSG_TEMPERATURE = _UxGT("Tenperatura"); @@ -244,6 +239,7 @@ namespace Language_eu { LSTR MSG_BABYSTEP_X = _UxGT("Mikro-urratsa X"); LSTR MSG_BABYSTEP_Y = _UxGT("Mikro-urratsa Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Mikro-urratsa Z"); + LSTR MSG_BABYSTEP_N = _UxGT("Mikro-urratsa @"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Endstop deusezta."); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Err: Beroketa"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("Err: Tenperatura"); @@ -280,7 +276,7 @@ namespace Language_eu { LSTR MSG_INFO_PROTOCOL = _UxGT("Protokoloa"); LSTR MSG_CASE_LIGHT = _UxGT("Kabina Argia"); LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Argiaren Distira"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Inprim. Zenbaketa"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Burututa"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Inprim. denbora"); @@ -297,13 +293,7 @@ namespace Language_eu { LSTR MSG_INFO_MAX_TEMP = _UxGT("Tenp. Maximoa"); LSTR MSG_INFO_PSU = _UxGT("Elikadura-iturria"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Driver-aren potentzia"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("E Driver %"); + LSTR MSG_DAC_PERCENT_N = _UxGT("@ Driver %"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Idatzi DAC EEPROM"); LSTR MSG_FILAMENT_CHANGE_HEADER_PAUSE = _UxGT("HARIZPIA ALDATU"); LSTR MSG_FILAMENT_CHANGE_HEADER_LOAD = _UxGT("HARIZPIA KARGATU"); diff --git a/Marlin/src/lcd/language/language_fi.h b/Marlin/src/lcd/language/language_fi.h index 62f3aae807a5..8fd53a79e36d 100644 --- a/Marlin/src/lcd/language/language_fi.h +++ b/Marlin/src/lcd/language/language_fi.h @@ -43,7 +43,6 @@ namespace Language_fi { LSTR MSG_RUN_AUTO_FILES = _UxGT("Automaatti"); LSTR MSG_DISABLE_STEPPERS = _UxGT("Vapauta moottorit"); LSTR MSG_AUTO_HOME = _UxGT("Aja referenssiin"); - LSTR MSG_SET_ORIGIN = _UxGT("Aseta origo"); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Esilämmitä ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Esilämmitä ") PREHEAT_1_LABEL " ~"; @@ -72,7 +71,7 @@ namespace Language_fi { LSTR MSG_MOVE_Z = _UxGT("Liikuta Z"); LSTR MSG_MOVE_E = _UxGT("Extruder"); LSTR MSG_MOVE_EN = _UxGT("Extruder *"); - LSTR MSG_MOVE_N_MM = _UxGT("Liikuta %smm"); + 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"); diff --git a/Marlin/src/lcd/language/language_fr.h b/Marlin/src/lcd/language/language_fr.h index e9c55ed4018d..6081234607f4 100644 --- a/Marlin/src/lcd/language/language_fr.h +++ b/Marlin/src/lcd/language/language_fr.h @@ -58,12 +58,10 @@ namespace Language_fr { LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test barre progress."); LSTR MSG_HOMING = _UxGT("Origine"); LSTR MSG_AUTO_HOME = _UxGT("Origine auto"); + LSTR MSG_AUTO_HOME_A = _UxGT("Origine @ auto"); LSTR MSG_AUTO_HOME_X = _UxGT("Origine X auto"); LSTR MSG_AUTO_HOME_Y = _UxGT("Origine Y auto"); LSTR MSG_AUTO_HOME_Z = _UxGT("Origine Z auto"); - LSTR MSG_AUTO_HOME_I = _UxGT("Origine ") LCD_STR_I _UxGT(" auto"); - LSTR MSG_AUTO_HOME_J = _UxGT("Origine ") LCD_STR_J _UxGT(" auto"); - LSTR MSG_AUTO_HOME_K = _UxGT("Origine ") LCD_STR_K _UxGT(" auto"); LSTR MSG_AUTO_Z_ALIGN = _UxGT("Align. Z auto"); LSTR MSG_LEVEL_BED_HOMING = _UxGT("Origine XYZ..."); LSTR MSG_LEVEL_BED_WAITING = _UxGT("Clic pour commencer"); @@ -74,11 +72,7 @@ namespace Language_fr { LSTR MSG_HOME_OFFSET_X = _UxGT("Décal. origine X"); LSTR MSG_HOME_OFFSET_Y = _UxGT("Décal. origine Y"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Décal. origine Z"); - LSTR MSG_HOME_OFFSET_I = _UxGT("Décal. origine ") LCD_STR_I; - LSTR MSG_HOME_OFFSET_J = _UxGT("Décal. origine ") LCD_STR_J; - LSTR MSG_HOME_OFFSET_K = _UxGT("Décal. origine ") LCD_STR_K; LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Décalages appliqués"); - LSTR MSG_SET_ORIGIN = _UxGT("Régler origine"); LSTR MSG_TRAMMING_WIZARD = _UxGT("Assistant Molettes"); LSTR MSG_SELECT_ORIGIN = _UxGT("Molette du lit"); // Not a selection of the origin LSTR MSG_LAST_VALUE_SP = _UxGT("Ecart origine "); @@ -113,7 +107,7 @@ namespace Language_fr { LSTR MSG_LEVEL_BED = _UxGT("Niveau du lit"); LSTR MSG_BED_TRAMMING = _UxGT("Niveau des coins"); LSTR MSG_BED_TRAMMING_RAISE = _UxGT("Relever le coin jusqu'à la sonde"); - LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Coins dans la tolérance. Niveau lit "); + LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Coins dans la tolérance. Niveau lit."); LSTR MSG_NEXT_CORNER = _UxGT("Coin suivant"); LSTR MSG_MESH_EDITOR = _UxGT("Modif. maille"); // 13 car. max LSTR MSG_EDIT_MESH = _UxGT("Modifier grille"); @@ -236,13 +230,11 @@ namespace Language_fr { LSTR MSG_MOVE_X = _UxGT("Déplacer X"); LSTR MSG_MOVE_Y = _UxGT("Déplacer Y"); LSTR MSG_MOVE_Z = _UxGT("Déplacer Z"); - LSTR MSG_MOVE_I = _UxGT("Déplacer ") LCD_STR_I; - LSTR MSG_MOVE_J = _UxGT("Déplacer ") LCD_STR_J; - LSTR MSG_MOVE_K = _UxGT("Déplacer ") LCD_STR_K; + LSTR MSG_MOVE_N = _UxGT("Déplacer @"); LSTR MSG_MOVE_E = _UxGT("Extruder"); LSTR MSG_MOVE_EN = _UxGT("Extruder *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Buse trop froide"); - LSTR MSG_MOVE_N_MM = _UxGT("Déplacer %smm"); + LSTR MSG_MOVE_N_MM = _UxGT("Déplacer $mm"); 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"); @@ -282,45 +274,37 @@ namespace Language_fr { LSTR MSG_SELECT_E = _UxGT("Sélectionner *"); LSTR MSG_ACC = _UxGT("Accélération"); LSTR MSG_JERK = _UxGT("Jerk"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT(" jerk"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT(" jerk"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT(" jerk"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT(" jerk"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT(" jerk"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT(" jerk"); + LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT(" jerk"); + LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT(" jerk"); + LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT(" jerk"); + LSTR MSG_VN_JERK = _UxGT("V@ jerk"); LSTR MSG_VE_JERK = _UxGT("Ve jerk"); - LSTR MSG_VELOCITY = _UxGT("Vélocité"); - LSTR MSG_VMAX_A = _UxGT("Vit. Max ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Vit. Max ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Vit. Max ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Vit. Max ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Vit. Max ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Vit. Max ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Vit. Max ") LCD_STR_E; + LSTR MSG_MAX_SPEED = _UxGT("Max Vélocité"); + LSTR MSG_VMAX_A = _UxGT("Vit. Max ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Vit. Max ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Vit. Max ") STR_C; + LSTR MSG_VMAX_N = _UxGT("Vit. Max @"); + LSTR MSG_VMAX_E = _UxGT("Vit. Max E"); LSTR MSG_VMAX_EN = _UxGT("Vit. Max *"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Déviat. jonct."); LSTR MSG_VMIN = _UxGT("Vit. Min"); LSTR MSG_VTRAV_MIN = _UxGT("Vmin course"); LSTR MSG_ACCELERATION = _UxGT("Accélération"); - LSTR MSG_AMAX_A = _UxGT("Max Accél. ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Max Accél. ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Max Accél. ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Max Accél. ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Max Accél. ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Max Accél. ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Max Accél. ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Max Accél. ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Max Accél. ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Max Accél. ") STR_C; + LSTR MSG_AMAX_N = _UxGT("Max Accél. @"); + LSTR MSG_AMAX_E = _UxGT("Max Accél. E"); LSTR MSG_AMAX_EN = _UxGT("Max Accél. *"); LSTR MSG_A_RETRACT = _UxGT("Acc.rétraction"); LSTR MSG_A_TRAVEL = _UxGT("Acc.course"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Fréquence max"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Vitesse min"); LSTR MSG_STEPS_PER_MM = _UxGT("Pas/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" pas/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" pas/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" pas/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" pas/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" pas/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" pas/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" pas/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" pas/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" pas/mm"); + LSTR MSG_N_STEPS = _UxGT("@ pas/mm"); LSTR MSG_E_STEPS = _UxGT("E pas/mm"); LSTR MSG_EN_STEPS = _UxGT("* pas/mm"); LSTR MSG_TEMPERATURE = _UxGT("Température"); @@ -337,6 +321,8 @@ 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_BRIGHTNESS_OFF = _UxGT("Éteindre l'écran LCD"); LSTR MSG_STORE_EEPROM = _UxGT("Enregistrer config."); LSTR MSG_LOAD_EEPROM = _UxGT("Charger config."); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Restaurer défauts"); @@ -444,9 +430,7 @@ namespace Language_fr { LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Babystep Z"); - LSTR MSG_BABYSTEP_I = _UxGT("Babystep ") LCD_STR_I; - LSTR MSG_BABYSTEP_J = _UxGT("Babystep ") LCD_STR_J; - LSTR MSG_BABYSTEP_K = _UxGT("Babystep ") LCD_STR_K; + LSTR MSG_BABYSTEP_N = _UxGT("Babystep @"); LSTR MSG_BABYSTEP_TOTAL = _UxGT("Total"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Butée abandon"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Err de chauffe"); @@ -504,7 +488,7 @@ namespace Language_fr { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Luminosité"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Imprimante incorrecte"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Nbre impressions"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Terminées"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Tps impr. total"); @@ -522,13 +506,7 @@ namespace Language_fr { LSTR MSG_INFO_MAX_TEMP = _UxGT("Temp Max"); LSTR MSG_INFO_PSU = _UxGT("Alim."); LSTR MSG_DRIVE_STRENGTH = _UxGT("Puiss. moteur "); - LSTR MSG_DAC_PERCENT_A = _UxGT("Driver ") LCD_STR_A _UxGT(" %"); - LSTR MSG_DAC_PERCENT_B = _UxGT("Driver ") LCD_STR_B _UxGT(" %"); - LSTR MSG_DAC_PERCENT_C = _UxGT("Driver ") LCD_STR_C _UxGT(" %"); - LSTR MSG_DAC_PERCENT_I = _UxGT("Driver ") LCD_STR_I _UxGT(" %"); - LSTR MSG_DAC_PERCENT_J = _UxGT("Driver ") LCD_STR_J _UxGT(" %"); - LSTR MSG_DAC_PERCENT_K = _UxGT("Driver ") LCD_STR_K _UxGT(" %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("Driver E %"); + LSTR MSG_DAC_PERCENT_N = _UxGT("Driver @ %"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM sauv."); LSTR MSG_ERROR_TMC = _UxGT("ERREUR CONNEXION TMC"); diff --git a/Marlin/src/lcd/language/language_gl.h b/Marlin/src/lcd/language/language_gl.h index 1f3acf5f09b0..dabd35efcf9b 100644 --- a/Marlin/src/lcd/language/language_gl.h +++ b/Marlin/src/lcd/language/language_gl.h @@ -69,7 +69,6 @@ namespace Language_gl { LSTR MSG_Z_FADE_HEIGHT = _UxGT("Compensación Altura"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Axustar Desfases"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Desfases aplicados"); - LSTR MSG_SET_ORIGIN = _UxGT("Fixar orixe"); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Prequentar ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Prequentar ") PREHEAT_1_LABEL " ~"; @@ -227,7 +226,7 @@ namespace Language_gl { LSTR MSG_MOVE_E = _UxGT("Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Extrusor *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Bico moi frío"); - LSTR MSG_MOVE_N_MM = _UxGT("Mover %smm"); + 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"); @@ -262,52 +261,43 @@ namespace Language_gl { LSTR MSG_PID_AUTOTUNE = _UxGT("Auto-Sint. PID"); LSTR MSG_PID_AUTOTUNE_E = _UxGT("Auto-Sint. PID *"); LSTR MSG_PID_AUTOTUNE_DONE = _UxGT("Fin Auto-Sint PID"); - 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_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"); - LSTR MSG_VA_JERK = _UxGT("Max ") LCD_STR_A _UxGT(" Jerk"); - LSTR MSG_VB_JERK = _UxGT("Max ") LCD_STR_B _UxGT(" Jerk"); - LSTR MSG_VC_JERK = _UxGT("Max ") LCD_STR_C _UxGT(" Jerk"); - LSTR MSG_VI_JERK = _UxGT("Max ") LCD_STR_I _UxGT(" Jerk"); - LSTR MSG_VJ_JERK = _UxGT("Max ") LCD_STR_J _UxGT(" Jerk"); - LSTR MSG_VK_JERK = _UxGT("Max ") LCD_STR_K _UxGT(" Jerk"); + LSTR MSG_VA_JERK = _UxGT("Max ") STR_A _UxGT(" Jerk"); + 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_JUNCTION_DEVIATION = _UxGT("Desvío Unión"); - LSTR MSG_VELOCITY = _UxGT("Velocidade"); - LSTR MSG_VMAX_A = _UxGT("Max ") LCD_STR_A _UxGT(" Vel"); - LSTR MSG_VMAX_B = _UxGT("Max ") LCD_STR_B _UxGT(" Vel"); - LSTR MSG_VMAX_C = _UxGT("Max ") LCD_STR_C _UxGT(" Vel"); - LSTR MSG_VMAX_I = _UxGT("Max ") LCD_STR_I _UxGT(" Vel"); - LSTR MSG_VMAX_J = _UxGT("Max ") LCD_STR_J _UxGT(" Vel"); - LSTR MSG_VMAX_K = _UxGT("Max ") LCD_STR_K _UxGT(" Vel"); - LSTR MSG_VMAX_E = _UxGT("Max ") LCD_STR_E _UxGT(" Vel"); - LSTR MSG_VMAX_EN = _UxGT("Max * Vel"); + LSTR MSG_MAX_SPEED = _UxGT("Max Velocidade"); + LSTR MSG_VMAX_A = _UxGT("Max ") STR_A _UxGT(" Speed"); + LSTR MSG_VMAX_B = _UxGT("Max ") STR_B _UxGT(" Speed"); + LSTR MSG_VMAX_C = _UxGT("Max ") STR_C _UxGT(" Speed"); + LSTR MSG_VMAX_N = _UxGT("Max @ Speed"); + LSTR MSG_VMAX_E = _UxGT("Max E Speed"); + LSTR MSG_VMAX_EN = _UxGT("Max * Speed"); LSTR MSG_VMIN = _UxGT("Vmin"); LSTR MSG_VTRAV_MIN = _UxGT("V-viaxe min"); LSTR MSG_ACCELERATION = _UxGT("Aceleración"); - LSTR MSG_AMAX_A = _UxGT("Max ") LCD_STR_A _UxGT(" Accel"); - LSTR MSG_AMAX_B = _UxGT("Max ") LCD_STR_B _UxGT(" Accel"); - LSTR MSG_AMAX_C = _UxGT("Max ") LCD_STR_C _UxGT(" Accel"); - LSTR MSG_AMAX_I = _UxGT("Max ") LCD_STR_I _UxGT(" Accel"); - LSTR MSG_AMAX_J = _UxGT("Max ") LCD_STR_J _UxGT(" Accel"); - LSTR MSG_AMAX_K = _UxGT("Max ") LCD_STR_K _UxGT(" Accel"); - LSTR MSG_AMAX_E = _UxGT("Max ") LCD_STR_E _UxGT(" Accel"); + LSTR MSG_AMAX_A = _UxGT("Max ") STR_A _UxGT(" Accel"); + LSTR MSG_AMAX_B = _UxGT("Max ") STR_B _UxGT(" Accel"); + LSTR MSG_AMAX_C = _UxGT("Max ") STR_C _UxGT(" Accel"); + LSTR MSG_AMAX_E = _UxGT("Max E Accel"); LSTR MSG_AMAX_EN = _UxGT("Max * Accel"); LSTR MSG_A_RETRACT = _UxGT("A-retrac."); LSTR MSG_A_TRAVEL = _UxGT("A-viaxe"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Frecuencia max"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Avance min"); LSTR MSG_STEPS_PER_MM = _UxGT("Pasos/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" pasos/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" pasos/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" pasos/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" pasos/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" pasos/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" pasos/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" pasos/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" pasos/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" pasos/mm"); + LSTR MSG_N_STEPS = _UxGT("@ pasos/mm"); LSTR MSG_E_STEPS = _UxGT("E pasos/mm"); LSTR MSG_EN_STEPS = _UxGT("* pasos/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatura"); @@ -430,6 +420,7 @@ namespace Language_gl { LSTR MSG_BABYSTEP_X = _UxGT("Micropaso X"); LSTR MSG_BABYSTEP_Y = _UxGT("Micropaso Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Micropaso Z"); + LSTR MSG_BABYSTEP_N = _UxGT("Micropaso @"); LSTR MSG_BABYSTEP_TOTAL = _UxGT("Total"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Erro FinCarro"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Fallo Quentando"); @@ -479,7 +470,7 @@ namespace Language_gl { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Brillo Luces"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("IMPRESORA INCORRECTA"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Total Impresións"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completadas"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Tempo Total Imp."); @@ -497,13 +488,7 @@ namespace Language_gl { LSTR MSG_INFO_MAX_TEMP = _UxGT("Temp Máx"); LSTR MSG_INFO_PSU = _UxGT("Fonte Alimentación"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Forza do Motor"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("E Driver %"); + LSTR MSG_DAC_PERCENT_N = _UxGT("@ Driver %"); LSTR MSG_ERROR_TMC = _UxGT("ERRO CONEX. TMC"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Escribe DAC EEPROM"); LSTR MSG_FILAMENT_CHANGE_HEADER = _UxGT("CAMBIAR FILAMENTO"); diff --git a/Marlin/src/lcd/language/language_hr.h b/Marlin/src/lcd/language/language_hr.h index 23be8abbb185..10f11f616f5f 100644 --- a/Marlin/src/lcd/language/language_hr.h +++ b/Marlin/src/lcd/language/language_hr.h @@ -53,7 +53,6 @@ namespace Language_hr { LSTR MSG_LEVEL_BED_DONE = _UxGT("Niveliranje gotovo!"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Postavi home offsete"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Offsets postavljeni"); - LSTR MSG_SET_ORIGIN = _UxGT("Postavi ishodište"); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Predgrij ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Predgrij ") PREHEAT_1_LABEL " ~"; @@ -79,7 +78,7 @@ 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_N_MM = _UxGT("Miči %smm"); + 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"); @@ -137,7 +136,7 @@ namespace Language_hr { LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Neispravan pisač"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Broj printova"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Završeni"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Ukupno printanja"); diff --git a/Marlin/src/lcd/language/language_hu.h b/Marlin/src/lcd/language/language_hu.h index 204091f5d561..81db96df1702 100644 --- a/Marlin/src/lcd/language/language_hu.h +++ b/Marlin/src/lcd/language/language_hu.h @@ -62,12 +62,10 @@ namespace Language_hu { LSTR MSG_DEBUG_MENU = _UxGT("Hiba Menü"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Haladás sáv teszt"); LSTR MSG_AUTO_HOME = _UxGT("X-Y-Z auto kezdöpont"); + LSTR MSG_AUTO_HOME_A = _UxGT("Kezdö @"); LSTR MSG_AUTO_HOME_X = _UxGT("X kezdöpont"); LSTR MSG_AUTO_HOME_Y = _UxGT("Y kezdöpont"); LSTR MSG_AUTO_HOME_Z = _UxGT("Z kezdöpont"); - LSTR MSG_AUTO_HOME_I = _UxGT("Kezdö ") LCD_STR_I; - LSTR MSG_AUTO_HOME_J = _UxGT("Kezdö ") LCD_STR_J; - LSTR MSG_AUTO_HOME_K = _UxGT("Kezdö ") LCD_STR_K; LSTR MSG_AUTO_Z_ALIGN = _UxGT("Auto Z-igazítás"); LSTR MSG_ITERATION = _UxGT("G34 Ismétlés: %i"); LSTR MSG_DECREASING_ACCURACY = _UxGT("Pontosság csökken!"); @@ -81,11 +79,7 @@ namespace Language_hu { LSTR MSG_HOME_OFFSET_X = _UxGT("X Kezdö eltol."); LSTR MSG_HOME_OFFSET_Y = _UxGT("Y Kezdö eltol."); LSTR MSG_HOME_OFFSET_Z = _UxGT("Z Kezdö eltol."); - LSTR MSG_HOME_OFFSET_I = _UxGT("Kezdö eltol. ") LCD_STR_I; - LSTR MSG_HOME_OFFSET_J = _UxGT("Kezdö eltol. ") LCD_STR_J; - LSTR MSG_HOME_OFFSET_K = _UxGT("Kezdö eltol. ") LCD_STR_K; LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Eltolás beállítva."); - LSTR MSG_SET_ORIGIN = _UxGT("Eredeti Be"); LSTR MSG_TRAMMING_WIZARD = _UxGT("Elektromos varázsló"); LSTR MSG_SELECT_ORIGIN = _UxGT("Eredeti választása"); LSTR MSG_LAST_VALUE_SP = _UxGT("Utolsó érték "); @@ -262,13 +256,11 @@ namespace Language_hu { LSTR MSG_MOVE_X = _UxGT("X mozgás"); LSTR MSG_MOVE_Y = _UxGT("Y mozgás"); LSTR MSG_MOVE_Z = _UxGT("Z mozgás"); - LSTR MSG_MOVE_I = _UxGT("Mozgás ") LCD_STR_I; - LSTR MSG_MOVE_J = _UxGT("Mozgás ") LCD_STR_J; - LSTR MSG_MOVE_K = _UxGT("Mozgás ") LCD_STR_K; + LSTR MSG_MOVE_N = _UxGT("@ mozgás"); LSTR MSG_MOVE_E = _UxGT("Adagoló"); LSTR MSG_MOVE_EN = _UxGT("Adagoló *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("A fej túl hideg"); - LSTR MSG_MOVE_N_MM = _UxGT("Mozgás %smm"); + LSTR MSG_MOVE_N_MM = _UxGT("Mozgás $mm"); 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"); @@ -312,52 +304,44 @@ namespace Language_hu { LSTR MSG_PID_AUTOTUNE_E = _UxGT("PID hangolás *"); LSTR MSG_PID_CYCLE = _UxGT("PID ciklus"); LSTR MSG_PID_AUTOTUNE_DONE = _UxGT("PID hangolás kész"); - 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_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"); - LSTR MSG_VA_JERK = _UxGT("Seb.") LCD_STR_A _UxGT("-Rántás"); - LSTR MSG_VB_JERK = _UxGT("Seb.") LCD_STR_B _UxGT("-Rántás"); - LSTR MSG_VC_JERK = _UxGT("Seb.") LCD_STR_C _UxGT("-Rántás"); - LSTR MSG_VI_JERK = _UxGT("Seb.") LCD_STR_I _UxGT("-Rántás"); - LSTR MSG_VJ_JERK = _UxGT("Seb.") LCD_STR_J _UxGT("-Rántás"); - LSTR MSG_VK_JERK = _UxGT("Seb.") LCD_STR_K _UxGT("-Rántás"); + LSTR MSG_VA_JERK = _UxGT("Seb.") STR_A _UxGT("-Rántás"); + LSTR MSG_VB_JERK = _UxGT("Seb.") STR_B _UxGT("-Rántás"); + LSTR MSG_VC_JERK = _UxGT("Seb.") STR_C _UxGT("-Rántás"); + LSTR MSG_VN_JERK = _UxGT("Seb.@-Rántás"); LSTR MSG_VE_JERK = _UxGT("E ránt. seb."); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Csomopont eltérés"); - LSTR MSG_VELOCITY = _UxGT("Sebesség"); - LSTR MSG_VMAX_A = _UxGT("Max Seb. ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Max Seb. ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Max Seb. ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Max Seb. ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Max Seb. ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Max Seb. ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Max Seb. ") LCD_STR_E; + LSTR MSG_MAX_SPEED = _UxGT("Max Sebesség (mm/s)"); + LSTR MSG_VMAX_A = _UxGT("Max Seb. ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Max Seb. ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Max Seb. ") STR_C; + LSTR MSG_VMAX_N = _UxGT("Max Seb. @"); + LSTR MSG_VMAX_E = _UxGT("Max Seb. E"); LSTR MSG_VMAX_EN = _UxGT("Max sebesség *"); LSTR MSG_VMIN = _UxGT("Min sebesség"); LSTR MSG_VTRAV_MIN = _UxGT("Min utazó.seb."); LSTR MSG_ACCELERATION = _UxGT("Gyorsulás"); - LSTR MSG_AMAX_A = _UxGT("Max gyors. ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Max gyors. ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Max gyors. ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Max gyors. ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Max gyors. ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Max gyors. ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Max gyors. ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Max gyors. ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Max gyors. ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Max gyors. ") STR_C; + LSTR MSG_AMAX_N = _UxGT("Max gyors. @"); + LSTR MSG_AMAX_E = _UxGT("Max gyors. E"); LSTR MSG_AMAX_EN = _UxGT("Max gyorsulás *"); LSTR MSG_A_RETRACT = _UxGT("Visszahúzás"); LSTR MSG_A_TRAVEL = _UxGT("Utazás"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Max frekvencia"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Min elötolás"); LSTR MSG_STEPS_PER_MM = _UxGT("Lépés/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" Lépés/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" Lépés/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" Lépés/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" Lépés/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" Lépés/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" Lépés/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" Lépés/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" Lépés/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" Lépés/mm"); + LSTR MSG_N_STEPS = _UxGT("@ lépés/mm"); LSTR MSG_E_STEPS = _UxGT("E lépés/mm"); LSTR MSG_EN_STEPS = _UxGT("*Lépés/mm"); LSTR MSG_TEMPERATURE = _UxGT("Höfok"); @@ -491,9 +475,7 @@ namespace Language_hu { LSTR MSG_BABYSTEP_X = _UxGT("Mikrolépés X"); LSTR MSG_BABYSTEP_Y = _UxGT("Mikrolépés Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Mikrolépés Z"); - LSTR MSG_BABYSTEP_I = _UxGT("Mikrolépés ") LCD_STR_I; - LSTR MSG_BABYSTEP_J = _UxGT("Mikrolépés ") LCD_STR_J; - LSTR MSG_BABYSTEP_K = _UxGT("Mikrolépés ") LCD_STR_K; + LSTR MSG_BABYSTEP_N = _UxGT("Mikrolépés @"); LSTR MSG_BABYSTEP_TOTAL = _UxGT("Teljes"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Végállás megszakítva!"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Fütés hiba!"); @@ -553,7 +535,7 @@ namespace Language_hu { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Fényerösség"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("HELYTELEN NYOMTATÓ"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Nyomtatás számláló"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Befejezett"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Összes nyomtatási idö"); @@ -571,13 +553,7 @@ namespace Language_hu { LSTR MSG_INFO_MAX_TEMP = _UxGT("Max höfok"); LSTR MSG_INFO_PSU = _UxGT("PSU"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Meghajtási erö"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Meghajtó %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Meghajtó %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Meghajtó %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Meghajtó %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Meghajtó %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Meghajtó %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("E meghajtó %"); + LSTR MSG_DAC_PERCENT_N = _UxGT("@ meghajtó %"); LSTR MSG_ERROR_TMC = _UxGT("TMC CSATLAKOZÁSI HIBA"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM írása"); LSTR MSG_FILAMENT_CHANGE_HEADER = _UxGT("NYOMTATÓSZÁL CSERE"); diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index 780f4e9743e4..b043ac26e168 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -27,10 +27,9 @@ * LCD Menu Messages * See also https://marlinfw.org/docs/development/lcd_language.html * - * Substitutions are applied for the following characters when used - * in menu items that call lcd_put_u8str_ind_P with an index: + * Substitutions are applied for the following characters when used in menu items titles: * - * $ displays an inserted C-string + * $ displays an inserted string * = displays '0'....'10' for indexes 0 - 10 * ~ displays '1'....'11' for indexes 0 - 10 * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) @@ -67,13 +66,21 @@ namespace Language_it { LSTR MSG_DISABLE_STEPPERS = _UxGT("Disabilita Motori"); LSTR MSG_DEBUG_MENU = _UxGT("Menu di debug"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test barra avanzam."); + LSTR MSG_HOMING = _UxGT("Azzeramento"); LSTR MSG_AUTO_HOME = _UxGT("Auto Home"); + LSTR MSG_AUTO_HOME_A = _UxGT("Home @"); 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_AUTO_HOME_I = _UxGT("Home ") LCD_STR_I; - LSTR MSG_AUTO_HOME_J = _UxGT("Home ") LCD_STR_J; - LSTR MSG_AUTO_HOME_K = _UxGT("Home ") LCD_STR_K; + LSTR MSG_FILAMENT_SET = _UxGT("Impostaz.filamento"); + LSTR MSG_FILAMENT_MAN = _UxGT("Gestione filamento"); + LSTR MSG_LEVBED_FL = _UxGT("Davanti Sinistra"); + LSTR MSG_LEVBED_FR = _UxGT("Davanti Destra"); + LSTR MSG_LEVBED_C = _UxGT("Centro"); + LSTR MSG_LEVBED_BL = _UxGT("Dietro Sinistra"); + LSTR MSG_LEVBED_BR = _UxGT("Dietro Destra"); + LSTR MSG_MANUAL_MESH = _UxGT("Mesh Manuale"); + LSTR MSG_AUTO_MESH = _UxGT("Generaz.Autom.Mesh"); LSTR MSG_AUTO_Z_ALIGN = _UxGT("Allineam.automat. Z"); LSTR MSG_ITERATION = _UxGT("Iterazione G34: %i"); LSTR MSG_DECREASING_ACCURACY = _UxGT("Precisione in calo!"); @@ -87,11 +94,7 @@ namespace Language_it { LSTR MSG_HOME_OFFSET_X = _UxGT("Offset home X"); LSTR MSG_HOME_OFFSET_Y = _UxGT("Offset home Y"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Offset home Z"); - LSTR MSG_HOME_OFFSET_I = _UxGT("Offset home ") LCD_STR_I; - LSTR MSG_HOME_OFFSET_J = _UxGT("Offset home ") LCD_STR_J; - LSTR MSG_HOME_OFFSET_K = _UxGT("Offset home ") LCD_STR_K; LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Offset applicato"); - LSTR MSG_SET_ORIGIN = _UxGT("Imposta Origine"); LSTR MSG_TRAMMING_WIZARD = _UxGT("Wizard Tramming"); LSTR MSG_SELECT_ORIGIN = _UxGT("Selez. origine"); LSTR MSG_LAST_VALUE_SP = _UxGT("Ultimo valore "); @@ -137,15 +140,19 @@ namespace Language_it { LSTR MSG_MOVE_AXIS = _UxGT("Muovi Asse"); LSTR MSG_BED_LEVELING = _UxGT("Livella piano"); LSTR MSG_LEVEL_BED = _UxGT("Livella piano"); - LSTR MSG_BED_TRAMMING = _UxGT("Tramming piano"); + LSTR MSG_BED_TRAMMING = _UxGT("Tarat.fine piano"); + LSTR MSG_BED_TRAMMING_MANUAL = _UxGT("Tarat.fine Manuale"); LSTR MSG_BED_TRAMMING_RAISE = _UxGT("Regola la vite finché la sonda non rileva il piano."); LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Tolleranza raggiunta su tutti gli angoli. Piano livellato!"); LSTR MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Punti buoni: "); LSTR MSG_BED_TRAMMING_LAST_Z = _UxGT("Ultimo Z: "); LSTR MSG_NEXT_CORNER = _UxGT("Prossimo punto"); LSTR MSG_MESH_EDITOR = _UxGT("Editor Mesh"); + LSTR MSG_MESH_VIEWER = _UxGT("Visualiz. Mesh"); LSTR MSG_EDIT_MESH = _UxGT("Modifica Mesh"); + 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_PROBING_POINT = _UxGT("Punto sondato"); LSTR MSG_MESH_X = _UxGT("Indice X"); LSTR MSG_MESH_Y = _UxGT("Indice Y"); @@ -220,7 +227,7 @@ namespace Language_it { LSTR MSG_UBL_FILLIN_MESH = _UxGT("Riempimento Mesh"); 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 All"); + LSTR MSG_UBL_FINE_TUNE_ALL = _UxGT("Ritocca Tutto"); LSTR MSG_UBL_FINE_TUNE_CLOSEST = _UxGT("Ritocca Punto Vicino"); LSTR MSG_UBL_STORAGE_MESH_MENU = _UxGT("Mesh Salvate"); LSTR MSG_UBL_STORAGE_SLOT = _UxGT("Slot di memoria"); @@ -270,13 +277,11 @@ namespace Language_it { LSTR MSG_MOVE_X = _UxGT("Muovi X"); LSTR MSG_MOVE_Y = _UxGT("Muovi Y"); LSTR MSG_MOVE_Z = _UxGT("Muovi Z"); - LSTR MSG_MOVE_I = _UxGT("Muovi ") LCD_STR_I; - LSTR MSG_MOVE_J = _UxGT("Muovi ") LCD_STR_J; - LSTR MSG_MOVE_K = _UxGT("Muovi ") LCD_STR_K; + LSTR MSG_MOVE_N = _UxGT("Muovi @"); LSTR MSG_MOVE_E = _UxGT("Estrusore"); LSTR MSG_MOVE_EN = _UxGT("Estrusore *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Ugello freddo"); - LSTR MSG_MOVE_N_MM = _UxGT("Muovi di %smm"); + LSTR MSG_MOVE_N_MM = _UxGT("Muovi di $mm"); 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"); @@ -285,7 +290,6 @@ namespace Language_it { LSTR MSG_MOVE_001IN = _UxGT("Muovi di 0.01\""); LSTR MSG_MOVE_01IN = _UxGT("Muovi di 0.1\""); LSTR MSG_MOVE_1IN = _UxGT("Muovi di 1\""); - LSTR MSG_SPEED = _UxGT("Velocità"); LSTR MSG_BED_Z = _UxGT("Piatto Z"); LSTR MSG_NOZZLE = _UxGT("Ugello"); LSTR MSG_NOZZLE_N = _UxGT("Ugello ~"); @@ -317,55 +321,55 @@ namespace Language_it { LSTR MSG_LCD_ON = _UxGT("On"); LSTR MSG_LCD_OFF = _UxGT("Off"); LSTR MSG_PID_AUTOTUNE = _UxGT("Calibrazione PID"); - LSTR MSG_PID_AUTOTUNE_E = _UxGT("Calibraz. PID *"); + 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_BAD_EXTRUDER_NUM = _UxGT("Calibrazione fallita. Estrusore errato."); - LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Calibrazione fallita. Temperatura troppo alta."); + 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_EDIT = _UxGT("Modif.MPC *"); + LSTR MSG_MPC_POWER_E = _UxGT("Potenza *"); + LSTR MSG_MPC_BLOCK_HEAT_CAPACITY_E = _UxGT("C blocco *"); + 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_SELECT_E = _UxGT("Seleziona *"); LSTR MSG_ACC = _UxGT("Accel"); LSTR MSG_JERK = _UxGT("Jerk"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-jerk"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-jerk"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-jerk"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-jerk"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-jerk"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-jerk"); - LSTR MSG_VE_JERK = _UxGT("Ve-jerk"); + LSTR MSG_VA_JERK = _UxGT("Max Jerk ") STR_A; + LSTR MSG_VB_JERK = _UxGT("Max Jerk ") STR_B; + LSTR MSG_VC_JERK = _UxGT("Max Jerk ") STR_C; + LSTR MSG_VN_JERK = _UxGT("Max Jerk @"); + LSTR MSG_VE_JERK = _UxGT("Max Jerk E"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Deviaz. giunzioni"); - LSTR MSG_VELOCITY = _UxGT("Velocità"); - LSTR MSG_VMAX_A = _UxGT("Vmax ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Vmax ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Vmax ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Vmax ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Vmax ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Vmax ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Vmax ") LCD_STR_E; - LSTR MSG_VMAX_EN = _UxGT("Vmax *"); - LSTR MSG_VMIN = _UxGT("Vmin"); - LSTR MSG_VTRAV_MIN = _UxGT("VTrav min"); + LSTR MSG_MAX_SPEED = _UxGT("Vel.massima (mm/s)"); + LSTR MSG_VMAX_A = _UxGT("Vel.Massima ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Vel.Massima ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Vel.Massima ") STR_C; + LSTR MSG_VMAX_N = _UxGT("Vel.Massima @"); + LSTR MSG_VMAX_E = _UxGT("Vel.Massima E"); + LSTR MSG_VMAX_EN = _UxGT("Vel.Massima *"); + LSTR MSG_VMIN = _UxGT("Vel.Minima"); + LSTR MSG_VTRAV_MIN = _UxGT("Vel.Min spostam."); LSTR MSG_ACCELERATION = _UxGT("Accelerazione"); - LSTR MSG_AMAX_A = _UxGT("Max ") LCD_STR_A _UxGT(" Accel"); - LSTR MSG_AMAX_B = _UxGT("Max ") LCD_STR_B _UxGT(" Accel"); - LSTR MSG_AMAX_C = _UxGT("Max ") LCD_STR_C _UxGT(" Accel"); - LSTR MSG_AMAX_I = _UxGT("Max ") LCD_STR_I _UxGT(" Accel"); - LSTR MSG_AMAX_J = _UxGT("Max ") LCD_STR_J _UxGT(" Accel"); - LSTR MSG_AMAX_K = _UxGT("Max ") LCD_STR_K _UxGT(" Accel"); - LSTR MSG_AMAX_E = _UxGT("Max ") LCD_STR_E _UxGT(" Accel"); - LSTR MSG_AMAX_EN = _UxGT("Max * Accel"); + LSTR MSG_AMAX_A = _UxGT("Acc.Massima ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Acc.Massima ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Acc.Massima ") STR_C; + LSTR MSG_AMAX_N = _UxGT("Acc.Massima @"); + LSTR MSG_AMAX_E = _UxGT("Acc.Massima E"); + LSTR MSG_AMAX_EN = _UxGT("Acc.Massima *"); LSTR MSG_A_RETRACT = _UxGT("A-Ritrazione"); LSTR MSG_A_TRAVEL = _UxGT("A-Spostamento"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Frequenza max"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Feed min"); LSTR MSG_STEPS_PER_MM = _UxGT("Passi/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" passi/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" passi/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" passi/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" passi/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" passi/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" passi/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" passi/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" passi/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" passi/mm"); + LSTR MSG_N_STEPS = _UxGT("@ passi/mm"); LSTR MSG_E_STEPS = _UxGT("E passi/mm"); LSTR MSG_EN_STEPS = _UxGT("* passi/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatura"); @@ -381,6 +385,10 @@ namespace Language_it { 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"); LSTR MSG_LOAD_EEPROM = _UxGT("Carica impostazioni"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Ripristina imp."); @@ -407,12 +415,21 @@ namespace Language_it { LSTR MSG_BUTTON_RESET = _UxGT("Resetta"); LSTR MSG_BUTTON_IGNORE = _UxGT("Ignora"); LSTR MSG_BUTTON_CANCEL = _UxGT("Annulla"); + LSTR MSG_BUTTON_CONFIRM = _UxGT("Conferma"); + LSTR MSG_BUTTON_CONTINUE = _UxGT("Continua"); LSTR MSG_BUTTON_DONE = _UxGT("Fatto"); LSTR MSG_BUTTON_BACK = _UxGT("Indietro"); LSTR MSG_BUTTON_PROCEED = _UxGT("Procedi"); LSTR MSG_BUTTON_SKIP = _UxGT("Salta"); + LSTR MSG_BUTTON_INFO = _UxGT("Info"); + LSTR MSG_BUTTON_LEVEL = _UxGT("Livello"); + 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_PAUSING = _UxGT("Messa in pausa..."); LSTR MSG_PAUSE_PRINT = _UxGT("Pausa stampa"); + LSTR MSG_ADVANCED_PAUSE = _UxGT("Pausa Avanzata"); LSTR MSG_RESUME_PRINT = _UxGT("Riprendi stampa"); LSTR MSG_HOST_START_PRINT = _UxGT("Host Avvio"); LSTR MSG_STOP_PRINT = _UxGT("Arresta stampa"); @@ -421,12 +438,15 @@ namespace Language_it { LSTR MSG_CANCEL_OBJECT = _UxGT("Cancella Oggetto"); LSTR MSG_CANCEL_OBJECT_N = _UxGT("Canc. Oggetto ="); LSTR MSG_OUTAGE_RECOVERY = _UxGT("Ripresa da PowerLoss"); + LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Cont.proc.stampa"); LSTR MSG_MEDIA_MENU = _UxGT("Stampa da media"); LSTR MSG_NO_MEDIA = _UxGT("Media non presente"); LSTR MSG_DWELL = _UxGT("Sospensione..."); LSTR MSG_USERWAIT = _UxGT("Premi tasto.."); LSTR MSG_PRINT_PAUSED = _UxGT("Stampa sospesa"); LSTR MSG_PRINTING = _UxGT("Stampa..."); + LSTR MSG_STOPPING = _UxGT("Fermata..."); + LSTR MSG_REMAINING_TIME = _UxGT("Rimanente"); LSTR MSG_PRINT_ABORTED = _UxGT("Stampa Annullata"); LSTR MSG_PRINT_DONE = _UxGT("Stampa Eseguita"); LSTR MSG_NO_MOVE = _UxGT("Nessun Movimento"); @@ -475,6 +495,7 @@ namespace Language_it { LSTR MSG_BLTOUCH_RESET = _UxGT("Resetta BLTouch"); LSTR MSG_BLTOUCH_DEPLOY = _UxGT("Estendi BLTouch"); LSTR MSG_BLTOUCH_SW_MODE = _UxGT("BLTouch modo SW"); + LSTR MSG_BLTOUCH_SPEED_MODE = _UxGT("Alta Velocità"); LSTR MSG_BLTOUCH_5V_MODE = _UxGT("BLTouch modo 5V"); LSTR MSG_BLTOUCH_OD_MODE = _UxGT("BLTouch modo OD"); LSTR MSG_BLTOUCH_MODE_STORE = _UxGT("BLTouch modo mem."); @@ -491,6 +512,7 @@ namespace Language_it { 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_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"); @@ -499,14 +521,13 @@ namespace Language_it { LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Babystep Z"); - LSTR MSG_BABYSTEP_I = _UxGT("Babystep ") LCD_STR_I; - LSTR MSG_BABYSTEP_J = _UxGT("Babystep ") LCD_STR_J; - LSTR MSG_BABYSTEP_K = _UxGT("Babystep ") LCD_STR_K; + LSTR MSG_BABYSTEP_N = _UxGT("Babystep @"); LSTR MSG_BABYSTEP_TOTAL = _UxGT("Totali"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Interrompi se FC"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Risc.Fallito"); // Max 12 characters LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("Err: TEMP RIDONDANTE"); LSTR MSG_THERMAL_RUNAWAY = _UxGT("TEMP FUORI CONTROLLO"); + LSTR MSG_TEMP_MALFUNCTION = _UxGT("MALFUNZIONAMENTO TEMP"); LSTR MSG_THERMAL_RUNAWAY_BED = _UxGT("TEMP PIAT.FUORI CTRL"); LSTR MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("T.CAMERA FUORI CTRL"); LSTR MSG_THERMAL_RUNAWAY_COOLER = _UxGT("RAFFREDAM.FUORI CTRL"); @@ -514,10 +535,9 @@ namespace Language_it { LSTR MSG_ERR_MAXTEMP = _UxGT("Err: TEMP MASSIMA"); LSTR MSG_ERR_MINTEMP = _UxGT("Err: TEMP MINIMA"); LSTR MSG_HALTED = _UxGT("STAMPANTE FERMATA"); + LSTR MSG_PLEASE_WAIT = _UxGT("Attendere prego..."); LSTR MSG_PLEASE_RESET = _UxGT("Riavviare prego"); - LSTR MSG_SHORT_DAY = _UxGT("g"); // One character - LSTR MSG_SHORT_HOUR = _UxGT("h"); // One character - LSTR MSG_SHORT_MINUTE = _UxGT("m"); // One character + LSTR MSG_PREHEATING = _UxGT("Preriscaldam..."); LSTR MSG_HEATING = _UxGT("Riscaldamento..."); LSTR MSG_COOLING = _UxGT("Raffreddamento.."); LSTR MSG_BED_HEATING = _UxGT("Risc. piatto..."); @@ -562,13 +582,28 @@ namespace Language_it { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Luminosità Luci"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("STAMPANTE ERRATA"); - #if LCD_WIDTH >= 20 - LSTR MSG_INFO_PRINT_COUNT = _UxGT("Contat. stampa"); + #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_INFO_PRINT_COUNT = _UxGT("Stampe"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completati"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Durata"); @@ -579,13 +614,7 @@ namespace Language_it { LSTR MSG_INFO_MAX_TEMP = _UxGT("Temp max"); LSTR MSG_INFO_PSU = _UxGT("Alimentatore"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Potenza Drive"); - LSTR MSG_DAC_PERCENT_A = _UxGT("Driver ") LCD_STR_A _UxGT(" %"); - LSTR MSG_DAC_PERCENT_B = _UxGT("Driver ") LCD_STR_B _UxGT(" %"); - LSTR MSG_DAC_PERCENT_C = _UxGT("Driver ") LCD_STR_C _UxGT(" %"); - LSTR MSG_DAC_PERCENT_I = _UxGT("Driver ") LCD_STR_I _UxGT(" %"); - LSTR MSG_DAC_PERCENT_J = _UxGT("Driver ") LCD_STR_J _UxGT(" %"); - LSTR MSG_DAC_PERCENT_K = _UxGT("Driver ") LCD_STR_K _UxGT(" %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("Driver E %"); + LSTR MSG_DAC_PERCENT_N = _UxGT("Driver @ %"); LSTR MSG_ERROR_TMC = _UxGT("ERR.CONNESSIONE TMC"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Scrivi DAC EEPROM"); LSTR MSG_FILAMENT_CHANGE_HEADER = _UxGT("CAMBIO FILAMENTO"); @@ -721,6 +750,10 @@ namespace Language_it { LSTR MSG_PROBE_WIZARD_PROBING = _UxGT("Altezza di riferimento sonda"); LSTR MSG_PROBE_WIZARD_MOVING = _UxGT("Spostati in posizione di rilevazione"); + LSTR MSG_XATC = _UxGT("Proc.guid.X-Twist"); + LSTR MSG_XATC_DONE = _UxGT("Proc.guid.X-Twist eseg.!"); + LSTR MSG_XATC_UPDATE_Z_OFFSET = _UxGT("Agg.Offset-Z sonda a "); + LSTR MSG_SOUND = _UxGT("Suoni"); LSTR MSG_TOP_LEFT = _UxGT("Alto sinistra"); @@ -734,4 +767,6 @@ namespace Language_it { LSTR MSG_SD_CARD = _UxGT("Scheda SD"); LSTR MSG_USB_DISK = _UxGT("Disco USB"); + + LSTR MSG_HOST_SHUTDOWN = _UxGT("Arresta host"); } diff --git a/Marlin/src/lcd/language/language_jp_kana.h b/Marlin/src/lcd/language/language_jp_kana.h index 16e605cc25c9..0a53ee50d21f 100644 --- a/Marlin/src/lcd/language/language_jp_kana.h +++ b/Marlin/src/lcd/language/language_jp_kana.h @@ -61,7 +61,6 @@ namespace Language_jp_kana { LSTR MSG_LEVEL_BED_DONE = _UxGT("レベリングカンリョウ"); // "Leveling Done!" LSTR MSG_SET_HOME_OFFSETS = _UxGT("キジュンオフセットセッテイ"); // "Set home offsets" LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("オフセットガテキヨウサレマシタ"); // "Offsets applied" - LSTR MSG_SET_ORIGIN = _UxGT("キジュンセット"); // "Set origin" #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = PREHEAT_1_LABEL _UxGT(" ヨネツ"); // "Preheat " PREHEAT_1_LABEL LSTR MSG_PREHEAT_1_H = PREHEAT_1_LABEL _UxGT(" ヨネツ ~"); // "Preheat " PREHEAT_1_LABEL @@ -94,7 +93,7 @@ namespace Language_jp_kana { LSTR MSG_MOVE_Y = _UxGT("Yジク イドウ"); // "Move Y" LSTR MSG_MOVE_Z = _UxGT("Zジク イドウ"); // "Move Z" LSTR MSG_MOVE_E = _UxGT("エクストルーダー"); // "Extruder" - LSTR MSG_MOVE_N_MM = _UxGT("%smm イドウ"); // "Move 0.025mm" + 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" @@ -116,28 +115,23 @@ namespace Language_jp_kana { LSTR MSG_SELECT_E = _UxGT("センタク *"); LSTR MSG_ACC = _UxGT("カソクド mm/s") SUPERSCRIPT_TWO; // "Accel" LSTR MSG_JERK = _UxGT("ヤクドウ mm/s"); // "Jerk" - LSTR MSG_VA_JERK = _UxGT("ジク ヤクドウ mm/s") LCD_STR_A; // "Va-jerk" - LSTR MSG_VB_JERK = _UxGT("ジク ヤクドウ mm/s") LCD_STR_B; // "Vb-jerk" - LSTR MSG_VC_JERK = _UxGT("ジク ヤクドウ mm/s") LCD_STR_C; // "Vc-jerk" - LSTR MSG_VI_JERK = _UxGT("ジク ヤクドウ mm/s") LCD_STR_I; // "Va-jerk" - LSTR MSG_VJ_JERK = _UxGT("ジク ヤクドウ mm/s") LCD_STR_J; // "Vb-jerk" - LSTR MSG_VK_JERK = _UxGT("ジク ヤクドウ mm/s") LCD_STR_K; // "Vc-jerk" - LSTR MSG_A_STEPS = LCD_STR_A _UxGT("ステップ/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT("ステップ/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT("ステップ/mm"); + LSTR MSG_VA_JERK = _UxGT("ジク ヤクドウ mm/s") STR_A; // "Va-jerk" + LSTR MSG_VB_JERK = _UxGT("ジク ヤクドウ mm/s") STR_B; // "Vb-jerk" + LSTR MSG_VC_JERK = _UxGT("ジク ヤクドウ mm/s") STR_C; // "Vc-jerk" + LSTR MSG_VN_JERK = _UxGT("ジク ヤクドウ mm/s@"); // "V@-jerk" + LSTR MSG_A_STEPS = STR_A _UxGT("ステップ/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT("ステップ/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT("ステップ/mm"); + LSTR MSG_N_STEPS = _UxGT("@ステップ/mm"); LSTR MSG_VE_JERK = _UxGT("エクストルーダー ヤクド"); // "Ve-jerk" - LSTR MSG_VMAX_A = _UxGT("サイダイオクリソクド ") LCD_STR_A; // "Vmax A" - LSTR MSG_VMAX_B = _UxGT("サイダイオクリソクド ") LCD_STR_B; // "Vmax B" - LSTR MSG_VMAX_C = _UxGT("サイダイオクリソクド ") LCD_STR_C; // "Vmax C" - LSTR MSG_VMAX_I = _UxGT("サイダイオクリソクド ") LCD_STR_I; // "Vmax I" - LSTR MSG_VMAX_J = _UxGT("サイダイオクリソクド ") LCD_STR_J; // "Vmax J" - LSTR MSG_VMAX_K = _UxGT("サイダイオクリソクド ") LCD_STR_K; // "Vmax K" - LSTR MSG_VMAX_E = _UxGT("サイダイオクリソクド ") LCD_STR_E; // "Vmax E" + LSTR MSG_VMAX_A = _UxGT("サイダイオクリソクド ") STR_A; // "Vmax A" + LSTR MSG_VMAX_B = _UxGT("サイダイオクリソクド ") STR_B; // "Vmax B" + LSTR MSG_VMAX_C = _UxGT("サイダイオクリソクド ") STR_C; // "Vmax C" + LSTR MSG_VMAX_E = _UxGT("サイダイオクリソクド E"); // "Vmax E" LSTR MSG_VMAX_EN = _UxGT("サイダイオクリソクド *"); // "Vmax E1" LSTR MSG_VMIN = _UxGT("サイショウオクリソクド"); // "Vmin" LSTR MSG_VTRAV_MIN = _UxGT("サイショウイドウソクド"); // "VTrav min" LSTR MSG_ACCELERATION = _UxGT("カソクド mm/s") SUPERSCRIPT_TWO; // "Accel" - LSTR MSG_AMAX = _UxGT("サイダイカソクド "); // "Amax " LSTR MSG_A_RETRACT = _UxGT("ヒキコミカソクド"); // "A-retract" LSTR MSG_A_TRAVEL = _UxGT("イドウカソクド"); // "A-travel" LSTR MSG_TEMPERATURE = _UxGT("オンド"); // "Temperature" @@ -217,13 +211,7 @@ namespace Language_jp_kana { LSTR MSG_INFO_MAX_TEMP = _UxGT("セッテイサイコウオン"); // "Max Temp" LSTR MSG_INFO_PSU = _UxGT("デンゲンシュベツ"); // "Power Supply" LSTR MSG_DRIVE_STRENGTH = _UxGT("モータークドウリョク"); // "Drive Strength" - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" DACシュツリョク %"); // "X Driver %" - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" DACシュツリョク %"); // "Y Driver %" - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" DACシュツリョク %"); // "Z Driver %" - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" DACシュツリョク %"); // "I Driver %" - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" DACシュツリョク %"); // "J Driver %" - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" DACシュツリョク %"); // "K Driver %" - LSTR MSG_DAC_PERCENT_E = _UxGT("E DACシュツリョク %"); // "E Driver %" + LSTR MSG_DAC_PERCENT_N = _UxGT("@ DACシュツリョク %"); // "@ Driver %" LSTR MSG_DAC_EEPROM_WRITE = _UxGT("EEPROMヘホゾン"); // "Store memory" LSTR MSG_FILAMENT_CHANGE_HEADER_PAUSE = _UxGT("イチジテイシ"); LSTR MSG_FILAMENT_CHANGE_OPTION_RESUME = _UxGT("プリントサイカイ"); // "Resume print" @@ -251,7 +239,7 @@ namespace Language_jp_kana { LSTR MSG_YES = _UxGT("ハイ"); LSTR MSG_NO = _UxGT("イイエ"); LSTR MSG_BACK = _UxGT("モドリ"); - LSTR MSG_VELOCITY = _UxGT("ソクド"); + LSTR MSG_MAX_SPEED = _UxGT("ソクド"); LSTR MSG_STEPS_PER_MM = _UxGT("ステップ/mm"); LSTR MSG_CUSTOM_COMMANDS = _UxGT("ユーザーコマンド"); LSTR MSG_PRINT_PAUSED = _UxGT("プリントガイチジテイシサレマシタ"); diff --git a/Marlin/src/lcd/language/language_nl.h b/Marlin/src/lcd/language/language_nl.h index 42df92b88039..6b308ba48bac 100644 --- a/Marlin/src/lcd/language/language_nl.h +++ b/Marlin/src/lcd/language/language_nl.h @@ -53,7 +53,6 @@ namespace Language_nl { LSTR MSG_LEVEL_BED_DONE = _UxGT("Bed level kompl."); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Zet home offsets"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("H offset toegep."); - LSTR MSG_SET_ORIGIN = _UxGT("Nulpunt instellen"); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = PREHEAT_1_LABEL _UxGT(" voorverwarmen"); LSTR MSG_PREHEAT_1_H = PREHEAT_1_LABEL _UxGT(" voorverw. ~"); @@ -87,7 +86,7 @@ namespace Language_nl { LSTR MSG_MOVE_Z = _UxGT("Verplaats Z"); LSTR MSG_MOVE_E = _UxGT("Extruder"); LSTR MSG_MOVE_EN = _UxGT("Extruder *"); - LSTR MSG_MOVE_N_MM = _UxGT("Verplaats %smm"); + LSTR MSG_MOVE_N_MM = _UxGT("Verplaats $mm"); LSTR MSG_MOVE_01MM = _UxGT("Verplaats 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Verplaats 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Verplaats 10mm"); @@ -158,6 +157,7 @@ namespace Language_nl { LSTR MSG_BABYSTEP_X = _UxGT("Babystap X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystap Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Babystap Z"); + LSTR MSG_BABYSTEP_N = _UxGT("Babystap @"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Endstop afbr."); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Voorverw. fout"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("Redun. temp fout"); @@ -180,7 +180,7 @@ namespace Language_nl { LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Onjuiste printer"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Printed Aantal"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Totaal Voltooid"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Totale Printtijd"); diff --git a/Marlin/src/lcd/language/language_pl.h b/Marlin/src/lcd/language/language_pl.h index bf94feea54ec..630f94ab12df 100644 --- a/Marlin/src/lcd/language/language_pl.h +++ b/Marlin/src/lcd/language/language_pl.h @@ -27,10 +27,9 @@ * LCD Menu Messages * See also https://marlinfw.org/docs/development/lcd_language.html * - * Substitutions are applied for the following characters when used - * in menu items that call lcd_put_u8str_ind_P with an index: + * Substitutions are applied for the following characters when used in menu items titles: * - * $ displays an inserted C-string + * $ displays an inserted string * = displays '0'....'10' for indexes 0 - 10 * ~ displays '1'....'11' for indexes 0 - 10 * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) @@ -80,7 +79,6 @@ namespace Language_pl { LSTR MSG_Z_FADE_HEIGHT = _UxGT("Wys. zanikania"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Ust. poz. zer."); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Poz. zerowa ust."); - LSTR MSG_SET_ORIGIN = _UxGT("Ustaw punkt zero"); LSTR MSG_SELECT_ORIGIN = _UxGT("Wybierz punkt zero"); LSTR MSG_LAST_VALUE_SP = _UxGT("Poprzednia wartość "); #if HAS_PREHEAT @@ -240,7 +238,7 @@ namespace Language_pl { 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"); - LSTR MSG_MOVE_N_MM = _UxGT("Przesuń co %s mm"); + LSTR MSG_MOVE_N_MM = _UxGT("Przesuń co $ mm"); LSTR MSG_MOVE_01MM = _UxGT("Przesuń co .1 mm"); LSTR MSG_MOVE_1MM = _UxGT("Przesuń co 1 mm"); LSTR MSG_MOVE_10MM = _UxGT("Przesuń co 10 mm"); @@ -274,14 +272,12 @@ namespace Language_pl { LSTR MSG_SELECT_E = _UxGT("Wybierz *"); LSTR MSG_ACC = _UxGT("Przyspieszenie"); LSTR MSG_JERK = _UxGT("Zryw"); - LSTR MSG_VA_JERK = _UxGT("Zryw V") LCD_STR_A; - LSTR MSG_VB_JERK = _UxGT("Zryw V") LCD_STR_B; - LSTR MSG_VC_JERK = _UxGT("Zryw V") LCD_STR_C; - LSTR MSG_VI_JERK = _UxGT("Zryw V") LCD_STR_I; - LSTR MSG_VJ_JERK = _UxGT("Zryw V") LCD_STR_J; - LSTR MSG_VK_JERK = _UxGT("Zryw V") LCD_STR_K; + LSTR MSG_VA_JERK = _UxGT("Zryw V") STR_A; + LSTR MSG_VB_JERK = _UxGT("Zryw V") STR_B; + LSTR MSG_VC_JERK = _UxGT("Zryw V") STR_C; + LSTR MSG_VN_JERK = _UxGT("Zryw V@"); LSTR MSG_VE_JERK = _UxGT("Zryw Ve"); - LSTR MSG_VELOCITY = _UxGT("Prędkość (V)"); + LSTR MSG_MAX_SPEED = _UxGT("Prędkość (V)"); LSTR MSG_VTRAV_MIN = _UxGT("Vskok min"); LSTR MSG_ACCELERATION = _UxGT("Przyspieszenie (A)"); @@ -290,12 +286,10 @@ namespace Language_pl { LSTR MSG_A_TRAVEL = _UxGT("A-przesuń."); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Częstotliwość max"); LSTR MSG_STEPS_PER_MM = _UxGT("kroki/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" kroki/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" kroki/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" kroki/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" kroki/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" kroki/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" kroki/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" kroki/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" kroki/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" kroki/mm"); + LSTR MSG_N_STEPS = _UxGT("@ kroki/mm"); LSTR MSG_E_STEPS = _UxGT("E kroki/mm"); LSTR MSG_EN_STEPS = _UxGT("* kroki/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatura"); @@ -430,7 +424,7 @@ namespace Language_pl { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Jasność oświetlenia"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Niepoprawna drukarka"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Wydrukowano"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Ukończono"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Czas druku"); @@ -446,13 +440,7 @@ namespace Language_pl { LSTR MSG_INFO_PSU = _UxGT("Zasilacz"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Siła silnika"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Siła %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Siła %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Siła %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Siła %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Siła %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Siła %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("E Siła %"); + LSTR MSG_DAC_PERCENT_N = _UxGT("@ Siła %"); LSTR MSG_ERROR_TMC = _UxGT("TMC BŁĄD POŁĄCZENIA"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Zapisz DAC EEPROM"); LSTR MSG_FILAMENT_CHANGE_HEADER = _UxGT("ZMIEŃ FILAMENT"); diff --git a/Marlin/src/lcd/language/language_pt.h b/Marlin/src/lcd/language/language_pt.h index 524c2c97d859..69df8bdf5427 100644 --- a/Marlin/src/lcd/language/language_pt.h +++ b/Marlin/src/lcd/language/language_pt.h @@ -52,7 +52,6 @@ namespace Language_pt { LSTR MSG_LEVEL_BED_DONE = _UxGT("Pronto !"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Definir desvio"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Offsets aplicados"); - LSTR MSG_SET_ORIGIN = _UxGT("Definir origem"); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Pre-aquecer ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Pre-aquecer ") PREHEAT_1_LABEL " ~"; @@ -81,7 +80,7 @@ namespace Language_pt { LSTR MSG_MOVE_Z = _UxGT("Mover Z"); LSTR MSG_MOVE_E = _UxGT("Mover Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Mover Extrusor *"); - LSTR MSG_MOVE_N_MM = _UxGT("Mover %smm"); + 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"); @@ -102,12 +101,10 @@ namespace Language_pt { LSTR MSG_A_RETRACT = _UxGT("A-retracção"); LSTR MSG_A_TRAVEL = _UxGT("A-movimento"); LSTR MSG_STEPS_PER_MM = _UxGT("Passo/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" passo/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" passo/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" passo/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" passo/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" passo/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" passo/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" passo/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" passo/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" passo/mm"); + LSTR MSG_N_STEPS = _UxGT("@ passo/mm"); LSTR MSG_E_STEPS = _UxGT("E passo/mm"); LSTR MSG_EN_STEPS = _UxGT("* passo/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatura"); diff --git a/Marlin/src/lcd/language/language_pt_br.h b/Marlin/src/lcd/language/language_pt_br.h index c66f717f9d28..5b73d6df6def 100644 --- a/Marlin/src/lcd/language/language_pt_br.h +++ b/Marlin/src/lcd/language/language_pt_br.h @@ -67,7 +67,6 @@ namespace Language_pt_br { LSTR MSG_Z_FADE_HEIGHT = _UxGT("Suavizar altura"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Compensar origem"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Alteração aplicada"); - LSTR MSG_SET_ORIGIN = _UxGT("Ajustar Origem"); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Pre-aquecer ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Pre-aquecer ") PREHEAT_1_LABEL " ~"; @@ -213,7 +212,7 @@ namespace Language_pt_br { LSTR MSG_MOVE_E = _UxGT("Mover Extrusor"); LSTR MSG_MOVE_EN = _UxGT("Mover Extrusor *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Extrus. mto fria"); - LSTR MSG_MOVE_N_MM = _UxGT("Mover %smm"); + 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"); @@ -240,26 +239,22 @@ namespace Language_pt_br { LSTR MSG_SELECT_E = _UxGT("Selecionar *"); LSTR MSG_ACC = _UxGT("Acel."); LSTR MSG_JERK = _UxGT("Arrancada"); - LSTR MSG_VA_JERK = _UxGT("arrancada V") LCD_STR_A; - LSTR MSG_VB_JERK = _UxGT("arrancada V") LCD_STR_B; - LSTR MSG_VC_JERK = _UxGT("arrancada V") LCD_STR_C; - LSTR MSG_VI_JERK = _UxGT("arrancada V") LCD_STR_I; - LSTR MSG_VJ_JERK = _UxGT("arrancada V") LCD_STR_J; - LSTR MSG_VK_JERK = _UxGT("arrancada V") LCD_STR_K; + LSTR MSG_VA_JERK = _UxGT("arrancada V") STR_A; + LSTR MSG_VB_JERK = _UxGT("arrancada V") STR_B; + LSTR MSG_VC_JERK = _UxGT("arrancada V") STR_C; + LSTR MSG_VN_JERK = _UxGT("arrancada V@"); LSTR MSG_VE_JERK = _UxGT("arrancada VE"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Desv. Junção"); - LSTR MSG_VELOCITY = _UxGT("Velocidade"); + LSTR MSG_MAX_SPEED = _UxGT("Velocidade"); LSTR MSG_VTRAV_MIN = _UxGT("VDeslocamento min"); LSTR MSG_ACCELERATION = _UxGT("Aceleração"); LSTR MSG_A_RETRACT = _UxGT("Retrair A"); LSTR MSG_A_TRAVEL = _UxGT("Movimento A"); LSTR MSG_STEPS_PER_MM = _UxGT("Passo/mm"); - LSTR MSG_A_STEPS = _UxGT("Passo ") LCD_STR_A _UxGT("/mm"); - LSTR MSG_B_STEPS = _UxGT("Passo ") LCD_STR_B _UxGT("/mm"); - LSTR MSG_C_STEPS = _UxGT("Passo ") LCD_STR_C _UxGT("/mm"); - LSTR MSG_I_STEPS = _UxGT("Passo ") LCD_STR_I _UxGT("/mm"); - LSTR MSG_J_STEPS = _UxGT("Passo ") LCD_STR_J _UxGT("/mm"); - LSTR MSG_K_STEPS = _UxGT("Passo ") LCD_STR_K _UxGT("/mm"); + LSTR MSG_A_STEPS = _UxGT("Passo ") STR_A _UxGT("/mm"); + LSTR MSG_B_STEPS = _UxGT("Passo ") STR_B _UxGT("/mm"); + LSTR MSG_C_STEPS = _UxGT("Passo ") STR_C _UxGT("/mm"); + LSTR MSG_N_STEPS = _UxGT("Passo @/mm"); LSTR MSG_E_STEPS = _UxGT("E/mm"); LSTR MSG_EN_STEPS = _UxGT("*/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatura"); @@ -353,6 +348,7 @@ namespace Language_pt_br { LSTR MSG_BABYSTEP_X = _UxGT("Passinho X"); LSTR MSG_BABYSTEP_Y = _UxGT("Passinho Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Passinho Z"); + LSTR MSG_BABYSTEP_N = _UxGT("Passinho @"); LSTR MSG_BABYSTEP_TOTAL = _UxGT("Total"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Abortar Fim de Curso"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Aquecimento falhou"); @@ -400,7 +396,7 @@ namespace Language_pt_br { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Intensidade Brilho"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Impressora Incorreta"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Total de Impressões"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Realizadas"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Tempo de Impressão"); diff --git a/Marlin/src/lcd/language/language_ro.h b/Marlin/src/lcd/language/language_ro.h index fee63dc2ad90..79160624e7a4 100644 --- a/Marlin/src/lcd/language/language_ro.h +++ b/Marlin/src/lcd/language/language_ro.h @@ -68,7 +68,6 @@ namespace Language_ro { LSTR MSG_Z_FADE_HEIGHT = _UxGT("Fade Inaltime"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Seteaza Offseturile Acasa"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Offseturi Aplicate"); - LSTR MSG_SET_ORIGIN = _UxGT("Seteaza Originea"); #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Preincalzeste ") PREHEAT_1_LABEL; LSTR MSG_PREHEAT_1_H = _UxGT("Preincalzeste ") PREHEAT_1_LABEL " ~"; @@ -226,7 +225,7 @@ namespace Language_ro { LSTR MSG_MOVE_E = _UxGT("Extruder"); LSTR MSG_MOVE_EN = _UxGT("Extruder *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Capat Prea Rece"); - LSTR MSG_MOVE_N_MM = _UxGT("Move %smm"); + 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"); @@ -261,54 +260,46 @@ namespace Language_ro { LSTR MSG_PID_AUTOTUNE = _UxGT("PID Autotune"); LSTR MSG_PID_AUTOTUNE_E = _UxGT("PID Autotune *"); LSTR MSG_PID_AUTOTUNE_DONE = _UxGT("PID tuning done"); - 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_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"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-Jerk"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-Jerk"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-Jerk"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-Jerk"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-Jerk"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-Jerk"); + LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT("-Jerk"); + LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT("-Jerk"); + LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT("-Jerk"); + LSTR MSG_VN_JERK = _UxGT("V@-Jerk"); LSTR MSG_VE_JERK = _UxGT("Ve-Jerk"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Junction Dev"); - LSTR MSG_VELOCITY = _UxGT("Velocity"); - LSTR MSG_VMAX_A = _UxGT("Vmax ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Vmax ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Vmax ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Vmax ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Vmax ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Vmax ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Vmax ") LCD_STR_E; - LSTR MSG_VMAX_EN = _UxGT("Vmax *"); + LSTR MSG_MAX_SPEED = _UxGT("Max Speed"); + LSTR MSG_VMAX_A = _UxGT("Max Speed ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Max Speed ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Max Speed ") STR_C; + LSTR MSG_VMAX_N = _UxGT("Max Speed @"); + LSTR MSG_VMAX_E = _UxGT("Max Speed E"); + LSTR MSG_VMAX_EN = _UxGT("Max Speed *"); LSTR MSG_VMIN = _UxGT("Vmin"); LSTR MSG_VTRAV_MIN = _UxGT("VTrav Min"); LSTR MSG_ACCELERATION = _UxGT("Acceleration"); - LSTR MSG_AMAX_A = _UxGT("Amax ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Amax ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Amax ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Amax ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Amax ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Amax ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Amax ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Amax ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Amax ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Amax ") STR_C; + LSTR MSG_AMAX_N = _UxGT("Amax @"); + LSTR MSG_AMAX_E = _UxGT("Amax E"); LSTR MSG_AMAX_EN = _UxGT("Amax *"); LSTR MSG_A_RETRACT = _UxGT("A-Retract"); LSTR MSG_A_TRAVEL = _UxGT("A-Travel"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Frequency max"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Feed min"); LSTR MSG_STEPS_PER_MM = _UxGT("Steps/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" steps/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" steps/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" steps/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" steps/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" steps/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" steps/mm"); - LSTR MSG_E_STEPS = _UxGT("Esteps/mm"); - LSTR MSG_EN_STEPS = _UxGT("*steps/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" steps/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" steps/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" steps/mm"); + LSTR MSG_N_STEPS = _UxGT("@ steps/mm"); + LSTR MSG_E_STEPS = _UxGT("E steps/mm"); + LSTR MSG_EN_STEPS = _UxGT("* steps/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperature"); LSTR MSG_MOTION = _UxGT("Motion"); LSTR MSG_FILAMENT = _UxGT("Filament"); @@ -436,6 +427,7 @@ namespace Language_ro { LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Babystep Z"); + LSTR MSG_BABYSTEP_N = _UxGT("Babystep @"); LSTR MSG_BABYSTEP_TOTAL = _UxGT("Total"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Endstop Abort"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Heating Failed"); @@ -486,7 +478,7 @@ namespace Language_ro { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Light Brightness"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("INCORRECT PRINTER"); -#if LCD_WIDTH >= 20 +#if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Total Printuri"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Completat"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Timp Imprimare Total"); @@ -504,13 +496,7 @@ namespace Language_ro { LSTR MSG_INFO_MAX_TEMP = _UxGT("Temperatura Maxima"); LSTR MSG_INFO_PSU = _UxGT("PSU"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Drive Strength"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("E Driver %"); + LSTR MSG_DAC_PERCENT_N = _UxGT("@ Driver %"); LSTR MSG_ERROR_TMC = _UxGT("TMC CONNECTION ERROR"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM Write"); LSTR MSG_FILAMENT_CHANGE_HEADER = _UxGT("FILAMENT CHANGE"); diff --git a/Marlin/src/lcd/language/language_ru.h b/Marlin/src/lcd/language/language_ru.h index 495410500a50..5f05f1d2beb3 100644 --- a/Marlin/src/lcd/language/language_ru.h +++ b/Marlin/src/lcd/language/language_ru.h @@ -43,7 +43,7 @@ namespace Language_ru { LSTR MSG_MEDIA_INSERTED = _UxGT("SD карта вставлена"); LSTR MSG_MEDIA_REMOVED = _UxGT("SD карта извлечена"); LSTR MSG_MEDIA_WAITING = _UxGT("Вставьте SD карту"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Сбой инициализации SD"); #else LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Сбой инициализ. SD"); @@ -51,7 +51,7 @@ namespace Language_ru { LSTR MSG_MEDIA_READ_ERROR = _UxGT("Ошибка считывания"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("USB диск удалён"); LSTR MSG_MEDIA_USB_FAILED = _UxGT("Ошибка USB диска"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_KILL_SUBCALL_OVERFLOW = _UxGT("Переполнение вызова"); #else LSTR MSG_KILL_SUBCALL_OVERFLOW = _UxGT("Переполн. вызова"); @@ -66,12 +66,10 @@ namespace Language_ru { LSTR MSG_DEBUG_MENU = _UxGT("Меню отладки"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Тест индикатора"); LSTR MSG_AUTO_HOME = _UxGT("Парковка XYZ"); + LSTR MSG_AUTO_HOME_A = _UxGT("Парковка @"); LSTR MSG_AUTO_HOME_X = _UxGT("Парковка X"); LSTR MSG_AUTO_HOME_Y = _UxGT("Парковка Y"); LSTR MSG_AUTO_HOME_Z = _UxGT("Парковка Z"); - LSTR MSG_AUTO_HOME_I = _UxGT("Парковка ") LCD_STR_I; - LSTR MSG_AUTO_HOME_J = _UxGT("Парковка ") LCD_STR_J; - LSTR MSG_AUTO_HOME_K = _UxGT("Парковка ") LCD_STR_K; LSTR MSG_AUTO_Z_ALIGN = _UxGT("Авто Z-выравнивание"); LSTR MSG_ITERATION = _UxGT("G34 Итерация: %i"); LSTR MSG_DECREASING_ACCURACY = _UxGT("Уменьшение точности!"); @@ -81,27 +79,20 @@ namespace Language_ru { LSTR MSG_LEVEL_BED_NEXT_POINT = _UxGT("Следующая точка"); LSTR MSG_LEVEL_BED_DONE = _UxGT("Выравнивание готово!"); LSTR MSG_Z_FADE_HEIGHT = _UxGT("Высота спада"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_SET_HOME_OFFSETS = _UxGT("Установ. смещения дома"); LSTR MSG_HOME_OFFSET_X = _UxGT("Смещение дома X"); LSTR MSG_HOME_OFFSET_Y = _UxGT("Смещение дома Y"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Смещение дома Z"); - LSTR MSG_HOME_OFFSET_I = _UxGT("Смещение дома ") LCD_STR_I; - LSTR MSG_HOME_OFFSET_J = _UxGT("Смещение дома ") LCD_STR_J; - LSTR MSG_HOME_OFFSET_K = _UxGT("Смещение дома ") LCD_STR_K; #else LSTR MSG_SET_HOME_OFFSETS = _UxGT("Установ.смещ.дома"); LSTR MSG_HOME_OFFSET_X = _UxGT("Смещ. дома X"); LSTR MSG_HOME_OFFSET_Y = _UxGT("Смещ. дома Y"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Смещ. дома Z"); - LSTR MSG_HOME_OFFSET_I = _UxGT("Смещ. дома ") LCD_STR_I; - LSTR MSG_HOME_OFFSET_J = _UxGT("Смещ. дома ") LCD_STR_J; - LSTR MSG_HOME_OFFSET_K = _UxGT("Смещ. дома ") LCD_STR_K; #endif LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Смещения применены"); - LSTR MSG_SET_ORIGIN = _UxGT("Установить ноль"); LSTR MSG_SELECT_ORIGIN = _UxGT("Выберите ноль"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_LAST_VALUE_SP = _UxGT("Последнее знач. "); #else LSTR MSG_LAST_VALUE_SP = _UxGT("Послед. знач. "); @@ -127,7 +118,7 @@ namespace Language_ru { LSTR MSG_COOLDOWN = _UxGT("Охлаждение"); LSTR MSG_CUTTER_FREQUENCY = _UxGT("Частота"); LSTR MSG_LASER_MENU = _UxGT("Управление лазером"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_SPINDLE_MENU = _UxGT("Управление шпинделем"); LSTR MSG_LASER_TOGGLE = _UxGT("Переключить лазер"); LSTR MSG_SPINDLE_TOGGLE = _UxGT("Переключ.шпиндель"); @@ -161,7 +152,7 @@ namespace Language_ru { LSTR MSG_LEVEL_BED = _UxGT("Выровнять стол"); LSTR MSG_BED_TRAMMING = _UxGT("Выровнять углы"); LSTR MSG_NEXT_CORNER = _UxGT("Следующий угол"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_BED_TRAMMING_RAISE = _UxGT("Вверх до срабатыв. зонда"); LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Углы в норме. Вырав.стола"); #else @@ -170,7 +161,7 @@ namespace Language_ru { #endif LSTR MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Хорошие точки: "); LSTR MSG_BED_TRAMMING_LAST_Z = _UxGT("Последняя Z: "); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MESH_EDITOR = _UxGT("Смещение по Z"); LSTR MSG_EDITING_STOPPED = _UxGT("Правка сетки окончена"); #else @@ -205,7 +196,7 @@ namespace Language_ru { LSTR MSG_UBL_LEVEL_BED = _UxGT("Настройка UBL"); LSTR MSG_LCD_TILTING_MESH = _UxGT("Точка разворота"); LSTR MSG_UBL_MANUAL_MESH = _UxGT("Ручной ввод сетки"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_BC_INSERT = _UxGT("Разместить шайбу,измерить"); LSTR MSG_UBL_BC_REMOVE = _UxGT("Убрать и замерить стол"); #else @@ -219,7 +210,7 @@ namespace Language_ru { LSTR MSG_UBL_DEACTIVATE_MESH = _UxGT("Деактивировать UBL"); LSTR MSG_UBL_MESH_EDIT = _UxGT("Редактор сеток"); LSTR MSG_UBL_EDIT_CUSTOM_MESH = _UxGT("Править свою сетку"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_SET_TEMP_BED = _UxGT("Температура стола"); LSTR MSG_UBL_BED_TEMP_CUSTOM = _UxGT("Температура стола"); LSTR MSG_UBL_SET_TEMP_HOTEND = _UxGT("Температура сопла"); @@ -237,7 +228,7 @@ namespace Language_ru { LSTR MSG_UBL_FINE_TUNE_MESH = _UxGT("Точная правка сетки"); LSTR MSG_UBL_BUILD_MESH_MENU = _UxGT("Построить сетку"); LSTR MSG_UBL_BUILD_MESH_M = _UxGT("Построить сетку $"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_BUILD_COLD_MESH = _UxGT("Построить холодную сетку"); #else LSTR MSG_UBL_BUILD_COLD_MESH = _UxGT("Строить холод.сетку"); @@ -245,7 +236,7 @@ namespace Language_ru { LSTR MSG_UBL_MESH_HEIGHT_ADJUST = _UxGT("Правка высоты сетки"); LSTR MSG_UBL_MESH_HEIGHT_AMOUNT = _UxGT("Высота"); LSTR MSG_UBL_VALIDATE_MESH_MENU = _UxGT("Проверить сетку"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_VALIDATE_MESH_M = _UxGT("Проверить сетку $"); LSTR MSG_UBL_VALIDATE_CUSTOM_MESH = _UxGT("Проверить свою сетку"); #else @@ -261,7 +252,7 @@ namespace Language_ru { LSTR MSG_G26_LEAVING = _UxGT("Выйти из G26"); LSTR MSG_UBL_CONTINUE_MESH = _UxGT("Продолжить сетку"); LSTR MSG_UBL_MESH_LEVELING = _UxGT("Выравнивание сетки"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_3POINT_MESH_LEVELING = _UxGT("3-х точечное выравнивание"); #else LSTR MSG_UBL_3POINT_MESH_LEVELING = _UxGT("3-точечное выравн."); @@ -273,7 +264,7 @@ namespace Language_ru { LSTR MSG_UBL_OUTPUT_MAP = _UxGT("Вывести карту сетки"); LSTR MSG_UBL_OUTPUT_MAP_HOST = _UxGT("Вывести на хост"); LSTR MSG_UBL_OUTPUT_MAP_CSV = _UxGT("Вывести в CSV"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_OUTPUT_MAP_BACKUP = _UxGT("Сохранить сетку снаружи"); LSTR MSG_UBL_INFO_UBL = _UxGT("Вывод информации UBL"); LSTR MSG_UBL_FILLIN_AMOUNT = _UxGT("Кол-во заполнителя"); @@ -323,7 +314,7 @@ namespace Language_ru { LSTR MSG_SET_LEDS_DEFAULT = _UxGT("Свет по умолчанию"); LSTR MSG_LED_CHANNEL_N = _UxGT("Канал ="); LSTR MSG_LEDS2 = _UxGT("Свет #2"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_NEO2_PRESETS = _UxGT("Свет #2 предустановки"); #else LSTR MSG_NEO2_PRESETS = _UxGT("Свет #2 предустан."); @@ -341,9 +332,7 @@ namespace Language_ru { LSTR MSG_MOVE_X = _UxGT("Движение по X"); LSTR MSG_MOVE_Y = _UxGT("Движение по Y"); LSTR MSG_MOVE_Z = _UxGT("Движение по Z"); - LSTR MSG_MOVE_I = _UxGT("Движение по ") LCD_STR_I; - LSTR MSG_MOVE_J = _UxGT("Движение по ") LCD_STR_J; - LSTR MSG_MOVE_K = _UxGT("Движение по ") LCD_STR_K; + LSTR MSG_MOVE_N = _UxGT("Движение по @"); LSTR MSG_MOVE_E = _UxGT("Экструдер"); LSTR MSG_MOVE_EN = _UxGT("Экструдер *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Сопло не нагрето"); @@ -360,7 +349,7 @@ namespace Language_ru { LSTR MSG_NOZZLE_STANDBY = _UxGT("Сопло ожидает"); LSTR MSG_BED = _UxGT("Стол, ") LCD_STR_DEGREE "C"; LSTR MSG_CHAMBER = _UxGT("Камера,") LCD_STR_DEGREE "C"; - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_COOLER = _UxGT("Охлаждение лазера"); LSTR MSG_COOLER_TOGGLE = _UxGT("Переключ. охлажд."); LSTR MSG_FLOWMETER_SAFETY = _UxGT("Безопасн. потока"); @@ -393,57 +382,49 @@ namespace Language_ru { LSTR MSG_PID_AUTOTUNE = _UxGT("Автоподбор PID"); LSTR MSG_PID_AUTOTUNE_E = _UxGT("Автоподбор PID *"); LSTR MSG_PID_AUTOTUNE_DONE = _UxGT("Подбор PID выполнен"); - LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Сбой автоподбора. Плохой экструдер."); - LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Сбой автоподбора. Температура повышена."); + LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Сбой автоподбора! Плохой экструдер."); + 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("Рывок"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-рывок"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-рывок"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-рывок"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-рывок"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-рывок"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-рывок"); + LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT("-рывок"); + LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT("-рывок"); + LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT("-рывок"); + LSTR MSG_VN_JERK = _UxGT("V@-рывок"); LSTR MSG_VE_JERK = _UxGT("Ve-рывок"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_JUNCTION_DEVIATION = _UxGT("Отклонение узла"); #else LSTR MSG_JUNCTION_DEVIATION = _UxGT("Отклон. узла"); #endif - LSTR MSG_VELOCITY = _UxGT("Скорость, мм/с"); - LSTR MSG_VMAX_A = _UxGT("Скор.макс ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Скор.макс ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Скор.макс ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Скор.макс ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Скор.макс ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Скор.макс ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Скор.макс ") LCD_STR_E; + LSTR MSG_MAX_SPEED = _UxGT("Скорость, мм/с"); + LSTR MSG_VMAX_A = _UxGT("Скор.макс ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Скор.макс ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Скор.макс ") STR_C; + LSTR MSG_VMAX_N = _UxGT("Скор.макс @"); + LSTR MSG_VMAX_E = _UxGT("Скор.макс E"); LSTR MSG_VMAX_EN = _UxGT("Скор.макс *"); LSTR MSG_VMIN = _UxGT("Скор.мин"); LSTR MSG_VTRAV_MIN = _UxGT("Перемещение мин"); LSTR MSG_ACCELERATION = _UxGT("Ускорение, мм/с2"); - LSTR MSG_AMAX_A = _UxGT("Ускор.макс ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Ускор.макс ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Ускор.макс ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Ускор.макс ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Ускор.макс ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Ускор.макс ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Ускор.макс ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Ускор.макс ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Ускор.макс ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Ускор.макс ") STR_C; + LSTR MSG_AMAX_N = _UxGT("Ускор.макс @"); + LSTR MSG_AMAX_E = _UxGT("Ускор.макс E"); LSTR MSG_AMAX_EN = _UxGT("Ускор.макс *"); LSTR MSG_A_RETRACT = _UxGT("Ускор.втягив."); LSTR MSG_A_TRAVEL = _UxGT("Ускор.путеш."); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Частота макс."); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Подача мин."); LSTR MSG_STEPS_PER_MM = _UxGT("Шагов/мм"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" шаг/мм"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" шаг/мм"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" шаг/мм"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" шаг/мм"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" шаг/мм"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" шаг/мм"); + LSTR MSG_A_STEPS = STR_A _UxGT(" шаг/мм"); + LSTR MSG_B_STEPS = STR_B _UxGT(" шаг/мм"); + LSTR MSG_C_STEPS = STR_C _UxGT(" шаг/мм"); + LSTR MSG_N_STEPS = _UxGT("@ шаг/мм"); LSTR MSG_E_STEPS = _UxGT("E шаг/мм"); LSTR MSG_EN_STEPS = _UxGT("* шаг/мм"); LSTR MSG_TEMPERATURE = _UxGT("Температура"); @@ -452,7 +433,7 @@ namespace Language_ru { LSTR MSG_VOLUMETRIC_ENABLED = _UxGT("E в мм") SUPERSCRIPT_THREE; LSTR MSG_VOLUMETRIC_LIMIT = _UxGT("E огран.,мм") SUPERSCRIPT_THREE; LSTR MSG_VOLUMETRIC_LIMIT_E = _UxGT("E огран. *"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_FILAMENT_DIAM = _UxGT("Диам. филамента"); LSTR MSG_FILAMENT_DIAM_E = _UxGT("Диам. филамента *"); #else @@ -466,7 +447,7 @@ namespace Language_ru { LSTR MSG_CONTRAST = _UxGT("Контраст экрана"); LSTR MSG_STORE_EEPROM = _UxGT("Сохранить настройки"); LSTR MSG_LOAD_EEPROM = _UxGT("Загрузить настройки"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_RESTORE_DEFAULTS = _UxGT("На базовые параметры"); LSTR MSG_INIT_EEPROM = _UxGT("Инициализация EEPROM"); #else @@ -520,7 +501,7 @@ namespace Language_ru { LSTR MSG_NO_MOVE = _UxGT("Нет движения."); LSTR MSG_KILLED = _UxGT("УБИТО. "); LSTR MSG_STOPPED = _UxGT("ОСТАНОВЛЕНО. "); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_CONTROL_RETRACT = _UxGT("Втягивание, мм"); LSTR MSG_CONTROL_RETRACT_SWAP = _UxGT("Смена втягив., мм"); LSTR MSG_CONTROL_RETRACT_RECOVER_SWAP = _UxGT("Возврат смены, мм"); @@ -539,7 +520,7 @@ namespace Language_ru { LSTR MSG_CONTROL_RETRACT_RECOVERF = _UxGT("Возврат V"); LSTR MSG_FILAMENT_SWAP_LENGTH = _UxGT("Поменять длины"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_FILAMENT_SWAP_EXTRA = _UxGT("Поменять дополнительно"); #else LSTR MSG_FILAMENT_SWAP_EXTRA = _UxGT("Поменять дополнит."); @@ -548,7 +529,7 @@ namespace Language_ru { LSTR MSG_TOOL_CHANGE = _UxGT("Смена сопел"); LSTR MSG_TOOL_CHANGE_ZLIFT = _UxGT("Поднятие по Z"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Начальная скор."); LSTR MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Скорость втягив."); #else @@ -568,7 +549,7 @@ namespace Language_ru { LSTR MSG_FILAMENTCHANGE = _UxGT("Смена филамента"); LSTR MSG_FILAMENTCHANGE_E = _UxGT("Смена филамента *"); LSTR MSG_FILAMENTLOAD = _UxGT("Загрузить филамент"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_FILAMENTLOAD_E = _UxGT("Загрузить филамент *"); LSTR MSG_FILAMENTUNLOAD_E = _UxGT("Выгрузить филамент *"); #else @@ -606,7 +587,7 @@ namespace Language_ru { LSTR MSG_ZPROBE_XOFFSET = _UxGT("Смещение X"); LSTR MSG_ZPROBE_YOFFSET = _UxGT("Смещение Y"); LSTR MSG_ZPROBE_ZOFFSET = _UxGT("Смещение Z"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MOVE_NOZZLE_TO_BED = _UxGT("Двигать сопло к столу"); #else LSTR MSG_MOVE_NOZZLE_TO_BED = _UxGT("Двиг. сопло к столу"); @@ -614,9 +595,7 @@ namespace Language_ru { LSTR MSG_BABYSTEP_X = _UxGT("Микрошаг X"); LSTR MSG_BABYSTEP_Y = _UxGT("Микрошаг Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Микрошаг Z"); - LSTR MSG_BABYSTEP_I = _UxGT("Микрошаг ") LCD_STR_I; - LSTR MSG_BABYSTEP_J = _UxGT("Микрошаг ") LCD_STR_J; - LSTR MSG_BABYSTEP_K = _UxGT("Микрошаг ") LCD_STR_K; + LSTR MSG_BABYSTEP_N = _UxGT("Микрошаг @"); LSTR MSG_BABYSTEP_TOTAL = _UxGT("Сумарно"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Сработал концевик"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Разогрев не удался"); @@ -650,7 +629,7 @@ namespace Language_ru { LSTR MSG_DELTA_SETTINGS = _UxGT("Настройки Delta"); LSTR MSG_DELTA_AUTO_CALIBRATE = _UxGT("Авто калибровка"); LSTR MSG_DELTA_HEIGHT_CALIBRATE = _UxGT("Высота Delta"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Зондировать Z-смещения"); #else LSTR MSG_DELTA_Z_OFFSET_CALIBRATE = _UxGT("Зондир. Z-смещения"); @@ -660,7 +639,7 @@ namespace Language_ru { LSTR MSG_DELTA_RADIUS = _UxGT("Радиус"); LSTR MSG_INFO_MENU = _UxGT("О принтере"); LSTR MSG_INFO_PRINTER_MENU = _UxGT("Данные принтера"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_3POINT_LEVELING = _UxGT("3-точечное выравнивание"); LSTR MSG_LINEAR_LEVELING = _UxGT("Линейное выравнивание"); LSTR MSG_BILINEAR_LEVELING = _UxGT("Билинейное выравнивание"); @@ -671,7 +650,7 @@ namespace Language_ru { #endif LSTR MSG_UBL_LEVELING = _UxGT("Управление UBL"); LSTR MSG_MESH_LEVELING = _UxGT("Выравнивание сетки"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MESH_DONE = _UxGT("Зондирование выполнено"); #else LSTR MSG_MESH_DONE = _UxGT("Зондиров. выполнено"); @@ -683,7 +662,7 @@ namespace Language_ru { LSTR MSG_INFO_EXTRUDERS = _UxGT("Экструдеры"); LSTR MSG_INFO_BAUDRATE = _UxGT("Скорость,БОД"); LSTR MSG_INFO_PROTOCOL = _UxGT("Протокол"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_INFO_RUNAWAY_OFF = _UxGT("Контроль утечки Т: Выкл"); LSTR MSG_INFO_RUNAWAY_ON = _UxGT("Контроль утечки Т: Вкл"); LSTR MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Время простоя хотенда"); @@ -696,7 +675,7 @@ namespace Language_ru { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Яркость подсветки"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Неверный принтер"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Счётчик печати"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Общее время печати"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Наидольшее задание"); @@ -713,13 +692,7 @@ namespace Language_ru { LSTR MSG_INFO_MAX_TEMP = _UxGT("Макс. ") LCD_STR_THERMOMETER; LSTR MSG_INFO_PSU = _UxGT("БП"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Сила привода"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Привод, %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Привод, %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Привод, %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Привод, %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Привод, %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Привод, %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("E Привод, %"); + LSTR MSG_DAC_PERCENT_N = _UxGT("@ Привод, %"); LSTR MSG_ERROR_TMC = _UxGT("СБОЙ СВЯЗИ С TMC"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Запись DAC в EEPROM"); LSTR MSG_FILAMENT_CHANGE_HEADER = _UxGT("ЗАМЕНА ФИЛАМЕНТА"); @@ -730,7 +703,7 @@ namespace Language_ru { LSTR MSG_FILAMENT_CHANGE_OPTION_PURGE = _UxGT("Выдавить ещё"); LSTR MSG_FILAMENT_CHANGE_OPTION_RESUME = _UxGT("Возобновить печать"); LSTR MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Сопла: "); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_RUNOUT_SENSOR = _UxGT("Датчик оконч. филамента"); #else LSTR MSG_RUNOUT_SENSOR = _UxGT("Датчик оконч.филам."); @@ -741,7 +714,7 @@ namespace Language_ru { LSTR MSG_MMU2_CHOOSE_FILAMENT_HEADER = _UxGT("ВЫБИРЕТЕ ФИЛАМЕНТ"); LSTR MSG_MMU2_MENU = _UxGT("Настройки MMU"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_KILL_MMU2_FIRMWARE = _UxGT("Обновить прошивку MMU!"); #else LSTR MSG_KILL_MMU2_FIRMWARE = _UxGT("Обнови прошивку MMU"); @@ -756,7 +729,7 @@ namespace Language_ru { LSTR MSG_MMU2_EJECT_FILAMENT_N = _UxGT("Извлечь филамент ~"); LSTR MSG_MMU2_UNLOAD_FILAMENT = _UxGT("Выгрузить филамент"); LSTR MSG_MMU2_LOADING_FILAMENT = _UxGT("Загрузка %i..."); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MMU2_EJECTING_FILAMENT = _UxGT("Извлечение филамента..."); #else LSTR MSG_MMU2_EJECTING_FILAMENT = _UxGT("Извлеч.филамента..."); @@ -768,7 +741,7 @@ namespace Language_ru { LSTR MSG_MMU2_RESETTING = _UxGT("Перезапуск MMU..."); LSTR MSG_MMU2_EJECT_RECOVER = _UxGT("Удалите и нажмите"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MIX = _UxGT("Смешивание"); #else LSTR MSG_MIX = _UxGT("Смешив."); @@ -780,7 +753,7 @@ namespace Language_ru { LSTR MSG_CYCLE_MIX = _UxGT("Цикличное смешивание"); LSTR MSG_GRADIENT_MIX = _UxGT("Градиент смешивания"); LSTR MSG_REVERSE_GRADIENT = _UxGT("Сменить градиент"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_TOGGLE_MIX = _UxGT("Переключить смешивание"); LSTR MSG_ACTIVE_VTOOL = _UxGT("Активация В-инструм."); LSTR MSG_START_VTOOL = _UxGT("Начало В-инструмента"); @@ -808,7 +781,7 @@ namespace Language_ru { LSTR MSG_SNAKE = _UxGT("Змейка"); LSTR MSG_MAZE = _UxGT("Лабиринт"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_BAD_PAGE = _UxGT("Плохой индекс страницы"); LSTR MSG_BAD_PAGE_SPEED = _UxGT("Плохая скорость страницы"); #else @@ -824,7 +797,7 @@ namespace Language_ru { LSTR MSG_REMOVE_PASSWORD = _UxGT("Удалить пароль"); LSTR MSG_PASSWORD_SET = _UxGT("Пароль это "); LSTR MSG_START_OVER = _UxGT("Старт через"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_REMINDER_SAVE_SETTINGS = _UxGT("Запомни для сохранения!"); #else LSTR MSG_REMINDER_SAVE_SETTINGS = _UxGT("Запомни, сохрани!"); @@ -875,7 +848,7 @@ namespace Language_ru { LSTR MSG_LEVEL_X_AXIS = _UxGT("Уровень оси X"); LSTR MSG_AUTO_CALIBRATE = _UxGT("Авто калибровка"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_HEATER_TIMEOUT = _UxGT("Время нагревателя вышло"); #else LSTR MSG_HEATER_TIMEOUT = _UxGT("Время нагрев. вышло"); @@ -884,7 +857,7 @@ namespace Language_ru { LSTR MSG_REHEATING = _UxGT("Нагрев..."); LSTR MSG_PROBE_WIZARD = _UxGT("Мастер Z-зонда"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_PROBE_WIZARD_PROBING = _UxGT("Зондиров. контр. точки Z"); LSTR MSG_PROBE_WIZARD_MOVING = _UxGT("Движение к точке зондиров."); #else diff --git a/Marlin/src/lcd/language/language_sk.h b/Marlin/src/lcd/language/language_sk.h index 9ab08f276638..124080de0b85 100644 --- a/Marlin/src/lcd/language/language_sk.h +++ b/Marlin/src/lcd/language/language_sk.h @@ -31,10 +31,9 @@ * Translated by Michal Holeš, Farma MaM * https://www.facebook.com/farmamam * - * Substitutions are applied for the following characters when used - * in menu items that call lcd_put_u8str_ind_P with an index: + * Substitutions are applied for the following characters when used in menu items titles: * - * $ displays an inserted C-string + * $ displays an inserted string * = displays '0'....'10' for indexes 0 - 10 * ~ displays '1'....'11' for indexes 0 - 10 * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) @@ -72,12 +71,10 @@ namespace Language_sk { LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Test uk. priebehu"); LSTR MSG_HOMING = _UxGT("Parkovanie"); LSTR MSG_AUTO_HOME = _UxGT("Domovská pozícia"); + LSTR MSG_AUTO_HOME_A = _UxGT("Domov os @"); 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_AUTO_HOME_I = _UxGT("Domov os ") LCD_STR_I; - LSTR MSG_AUTO_HOME_J = _UxGT("Domov os ") LCD_STR_J; - LSTR MSG_AUTO_HOME_K = _UxGT("Domov os ") LCD_STR_K; LSTR MSG_FILAMENT_SET = _UxGT("Nastav. filamentu"); LSTR MSG_FILAMENT_MAN = _UxGT("Správa filamentu"); LSTR MSG_LEVBED_FL = _UxGT("Ľavý predný"); @@ -86,6 +83,7 @@ namespace Language_sk { LSTR MSG_LEVBED_BL = _UxGT("Ľavý zadný"); LSTR MSG_LEVBED_BR = _UxGT("Pravý zadný"); LSTR MSG_MANUAL_MESH = _UxGT("Ručná mriežka"); + LSTR MSG_AUTO_MESH = _UxGT("Automat. mriežka"); LSTR MSG_AUTO_Z_ALIGN = _UxGT("Auto-zarovn. Z"); LSTR MSG_ITERATION = _UxGT("Iterácia G34: %i"); LSTR MSG_DECREASING_ACCURACY = _UxGT("Klesajúca presnosť!"); @@ -99,11 +97,7 @@ namespace Language_sk { LSTR MSG_HOME_OFFSET_X = _UxGT("X Ofset"); LSTR MSG_HOME_OFFSET_Y = _UxGT("Y Ofset"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Z Ofset"); - LSTR MSG_HOME_OFFSET_I = LCD_STR_I _UxGT(" Ofset"); - LSTR MSG_HOME_OFFSET_J = LCD_STR_J _UxGT(" Ofset"); - LSTR MSG_HOME_OFFSET_K = LCD_STR_K _UxGT(" Ofset"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Ofsety nastavené"); - LSTR MSG_SET_ORIGIN = _UxGT("Nastaviť začiatok"); LSTR MSG_TRAMMING_WIZARD = _UxGT("Spriev. vyrovn."); LSTR MSG_SELECT_ORIGIN = _UxGT("Vyberte začiatok"); LSTR MSG_LAST_VALUE_SP = _UxGT("Posl. hodnota "); @@ -156,8 +150,11 @@ namespace Language_sk { LSTR MSG_BED_TRAMMING_LAST_Z = _UxGT("Posl. Z: "); LSTR MSG_NEXT_CORNER = _UxGT("Ďalší roh"); LSTR MSG_MESH_EDITOR = _UxGT("Editor sieťe bodov"); + LSTR MSG_MESH_VIEWER = _UxGT("Zobraz. sieťe bodov"); LSTR MSG_EDIT_MESH = _UxGT("Upraviť sieť bodov"); + 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_PROBING_POINT = _UxGT("Skúšam bod"); LSTR MSG_MESH_X = _UxGT("Index X"); LSTR MSG_MESH_Y = _UxGT("Index Y"); @@ -280,13 +277,11 @@ namespace Language_sk { LSTR MSG_MOVE_X = _UxGT("Posunúť X"); LSTR MSG_MOVE_Y = _UxGT("Posunúť Y"); LSTR MSG_MOVE_Z = _UxGT("Posunúť Z"); - LSTR MSG_MOVE_I = _UxGT("Posunúť ") LCD_STR_I; - LSTR MSG_MOVE_J = _UxGT("Posunúť ") LCD_STR_J; - LSTR MSG_MOVE_K = _UxGT("Posunúť ") LCD_STR_K; + LSTR MSG_MOVE_N = _UxGT("Posunúť @"); LSTR MSG_MOVE_E = _UxGT("Extrudér"); LSTR MSG_MOVE_EN = _UxGT("Extrudér *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hotend je studený"); - LSTR MSG_MOVE_N_MM = _UxGT("Posunúť o %smm"); + LSTR MSG_MOVE_N_MM = _UxGT("Posunúť o $mm"); 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"); @@ -296,12 +291,6 @@ namespace Language_sk { LSTR MSG_MOVE_01IN = _UxGT("Posunúť o 0,1in"); LSTR MSG_MOVE_1IN = _UxGT("Posunúť o 1,0in"); LSTR MSG_SPEED = _UxGT("Rýchlosť"); - LSTR MSG_MAXSPEED = _UxGT("Max rýchl. (mm/s)"); - LSTR MSG_MAXSPEED_X = _UxGT("Max rýchl. ") LCD_STR_A; - LSTR MSG_MAXSPEED_Y = _UxGT("Max rýchl. ") LCD_STR_B; - LSTR MSG_MAXSPEED_Z = _UxGT("Max rýchl. ") LCD_STR_C; - LSTR MSG_MAXSPEED_E = _UxGT("Max rýchl. ") LCD_STR_E; - LSTR MSG_MAXSPEED_A = _UxGT("Max rýchl. @"); LSTR MSG_BED_Z = _UxGT("Výška podl."); LSTR MSG_NOZZLE = _UxGT("Tryska"); LSTR MSG_NOZZLE_N = _UxGT("Tryska ~"); @@ -336,54 +325,46 @@ 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_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_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_SELECT_E = _UxGT("Vybrať *"); LSTR MSG_ACC = _UxGT("Zrýchlenie"); LSTR MSG_JERK = _UxGT("Skok"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-skok"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-skok"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-skok"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-skok"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-skok"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-skok"); + LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT("-skok"); + LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT("-skok"); + LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT("-skok"); + LSTR MSG_VN_JERK = _UxGT("V@-skok"); LSTR MSG_VE_JERK = _UxGT("Ve-skok"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Junction Dev"); - LSTR MSG_VELOCITY = _UxGT("Rýchlosť"); - LSTR MSG_VMAX_A = _UxGT("Vmax ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Vmax ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Vmax ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Vmax ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Vmax ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Vmax ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Vmax ") LCD_STR_E; - LSTR MSG_VMAX_EN = _UxGT("Vmax *"); + LSTR MSG_MAX_SPEED = _UxGT("Max rýchl. (mm/s)"); + LSTR MSG_VMAX_A = _UxGT("Max rýchl. ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Max rýchl. ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Max rýchl. ") STR_C; + LSTR MSG_VMAX_N = _UxGT("Max rýchl. @"); + LSTR MSG_VMAX_E = _UxGT("Max rýchl. E"); + LSTR MSG_VMAX_EN = _UxGT("Max rýchl. *"); LSTR MSG_VMIN = _UxGT("Vmin"); LSTR MSG_VTRAV_MIN = _UxGT("VPrej Min"); LSTR MSG_ACCELERATION = _UxGT("Akcelerácia"); - LSTR MSG_AMAX_A = _UxGT("Amax ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Amax ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Amax ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Amax ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Amax ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Amax ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Amax ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Amax ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Amax ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Amax ") STR_C; + LSTR MSG_AMAX_N = _UxGT("Amax @"); + LSTR MSG_AMAX_E = _UxGT("Amax E"); LSTR MSG_AMAX_EN = _UxGT("Amax *"); LSTR MSG_A_RETRACT = _UxGT("A-retrakt"); LSTR MSG_A_TRAVEL = _UxGT("A-prejazd"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Max. frekvencia"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Min. posun"); LSTR MSG_STEPS_PER_MM = _UxGT("Kroky/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" krokov/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" krokov/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" krokov/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" krokov/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" krokov/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" krokov/mm"); - LSTR MSG_E_STEPS = _UxGT("Ekrokov/mm"); - LSTR MSG_EN_STEPS = _UxGT("*krokov/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" krokov/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" krokov/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" krokov/mm"); + LSTR MSG_N_STEPS = _UxGT("@ krokov/mm"); + LSTR MSG_E_STEPS = _UxGT("E krokov/mm"); + LSTR MSG_EN_STEPS = _UxGT("* krokov/mm"); LSTR MSG_TEMPERATURE = _UxGT("Teplota"); LSTR MSG_MOTION = _UxGT("Pohyb"); LSTR MSG_FILAMENT = _UxGT("Filament"); @@ -397,6 +378,7 @@ namespace Language_sk { 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_STORE_EEPROM = _UxGT("Uložiť nastavenie"); LSTR MSG_LOAD_EEPROM = _UxGT("Načítať nastavenie"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("Obnoviť nastavenie"); @@ -427,8 +409,14 @@ namespace Language_sk { LSTR MSG_BUTTON_BACK = _UxGT("Naspäť"); LSTR MSG_BUTTON_PROCEED = _UxGT("Pokračovať"); LSTR MSG_BUTTON_SKIP = _UxGT("Preskočiť"); + LSTR MSG_BUTTON_INFO = _UxGT("Informácie"); + LSTR MSG_BUTTON_LEVEL = _UxGT("Vyrovnať"); + LSTR MSG_BUTTON_PAUSE = _UxGT("Pauza"); + LSTR MSG_BUTTON_RESUME = _UxGT("Obnoviť"); + LSTR MSG_BUTTON_ADVANCED = _UxGT("Pokročilé"); 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č"); @@ -437,12 +425,14 @@ namespace Language_sk { 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"); 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_PRINT_ABORTED = _UxGT("Tlač zrušená"); LSTR MSG_PRINT_DONE = _UxGT("Tlač dokončená"); LSTR MSG_NO_MOVE = _UxGT("Žiadny pohyb."); @@ -492,6 +482,7 @@ namespace Language_sk { LSTR MSG_BLTOUCH_STOW = _UxGT("Zasunúť"); LSTR MSG_BLTOUCH_DEPLOY = _UxGT("Vysunúť"); LSTR MSG_BLTOUCH_SW_MODE = _UxGT("Režim SW"); + LSTR MSG_BLTOUCH_SPEED_MODE = _UxGT("Vysoká rýchl."); LSTR MSG_BLTOUCH_5V_MODE = _UxGT("Režim 5V"); LSTR MSG_BLTOUCH_OD_MODE = _UxGT("Režim OD"); LSTR MSG_BLTOUCH_MODE_STORE = _UxGT("Ulož. režim"); @@ -516,14 +507,13 @@ namespace Language_sk { LSTR MSG_BABYSTEP_X = _UxGT("Babystep X"); LSTR MSG_BABYSTEP_Y = _UxGT("Babystep Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Babystep Z"); - LSTR MSG_BABYSTEP_I = _UxGT("Babystep ") LCD_STR_I; - LSTR MSG_BABYSTEP_J = _UxGT("Babystep ") LCD_STR_J; - LSTR MSG_BABYSTEP_K = _UxGT("Babystep ") LCD_STR_K; + LSTR MSG_BABYSTEP_N = _UxGT("Babystep @"); LSTR MSG_BABYSTEP_TOTAL = _UxGT("Celkom"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Zastavenie Endstop"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Chyba ohrevu"); LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("Chyba: REDUND. TEP."); LSTR MSG_THERMAL_RUNAWAY = _UxGT("TEPLOTNÝ SKOK"); + LSTR MSG_TEMP_MALFUNCTION = _UxGT("TEPLOTNÁ PORUCHA"); LSTR MSG_THERMAL_RUNAWAY_BED = _UxGT("TEPLOTNÝ SKOK PODL."); LSTR MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("TEPLOTNÝ SKOK KOMO."); LSTR MSG_THERMAL_RUNAWAY_COOLER = _UxGT("TEPLOTNÝ SKOK CHLAD."); @@ -531,7 +521,9 @@ namespace Language_sk { LSTR MSG_ERR_MAXTEMP = _UxGT("Chyba: MAXTEMP"); LSTR MSG_ERR_MINTEMP = _UxGT("Chyba: MINTEMP"); LSTR MSG_HALTED = _UxGT("TLAČIAREŇ ZASTAVENÁ"); + LSTR MSG_PLEASE_WAIT = _UxGT("Čakajte prosím..."); LSTR MSG_PLEASE_RESET = _UxGT("Reštartuje ju"); + LSTR MSG_PREHEATING = _UxGT("Zahrievanie..."); LSTR MSG_HEATING = _UxGT("Ohrev..."); LSTR MSG_COOLING = _UxGT("Ochladzovanie..."); LSTR MSG_BED_HEATING = _UxGT("Ohrev podložky..."); @@ -570,36 +562,47 @@ namespace Language_sk { LSTR MSG_INFO_RUNAWAY_OFF = _UxGT("Tepl. ochrana: VYP"); LSTR MSG_INFO_RUNAWAY_ON = _UxGT("Tepl. ochrana: ZAP"); LSTR MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Vypr.čas nečinnosti"); + LSTR MSG_FAN_SPEED_FAULT = _UxGT("Chyba rýchl. vent."); LSTR MSG_CASE_LIGHT = _UxGT("Osvetlenie"); LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Jas svetla"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Nesprávna tlačiareň"); - #if LCD_WIDTH >= 20 + #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_COMPLETED_PRINTS = _UxGT("Dokončené"); 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_INFO_COMPLETED_PRINTS = _UxGT("Hotovo"); + 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é"); #endif + LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Dokončené"); LSTR MSG_INFO_MIN_TEMP = _UxGT("Teplota min"); LSTR MSG_INFO_MAX_TEMP = _UxGT("Teplota max"); LSTR MSG_INFO_PSU = _UxGT("Nap. zdroj"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Budenie motorov"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Motor %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("E Motor %"); + LSTR MSG_DAC_PERCENT_N = _UxGT("@ Motor %"); LSTR MSG_ERROR_TMC = _UxGT("CHYBA KOMUNIKÁ. TMC"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Uložiť do EEPROM"); LSTR MSG_FILAMENT_CHANGE_HEADER = _UxGT("VÝMENA FILAMENTU"); @@ -613,6 +616,7 @@ namespace Language_sk { 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_FANCHECK = _UxGT("Kontrola rýchl."); LSTR MSG_KILL_HOMING_FAILED = _UxGT("Parkovanie zlyhalo"); LSTR MSG_LCD_PROBING_FAILED = _UxGT("Kalibrácia zlyhala"); @@ -732,6 +736,10 @@ namespace Language_sk { LSTR MSG_PROBE_WIZARD_PROBING = _UxGT("Referencia Z"); LSTR MSG_PROBE_WIZARD_MOVING = _UxGT("Presúvam na pozíciu"); + LSTR MSG_XATC = _UxGT("Sprievodca X-Twist"); + LSTR MSG_XATC_DONE = _UxGT("Spriev. X-Twist dokonč.!"); + LSTR MSG_XATC_UPDATE_Z_OFFSET = _UxGT("Aktual. ofset sondy Z na "); + LSTR MSG_SOUND = _UxGT("Zvuk"); LSTR MSG_TOP_LEFT = _UxGT("Ľavý horný"); @@ -745,4 +753,6 @@ namespace Language_sk { LSTR MSG_SD_CARD = _UxGT("SD karta"); LSTR MSG_USB_DISK = _UxGT("USB disk"); + + LSTR MSG_HOST_SHUTDOWN = _UxGT("Vypnúť hosta"); } diff --git a/Marlin/src/lcd/language/language_sv.h b/Marlin/src/lcd/language/language_sv.h index 69161d6b553b..6e6d3e11ecd0 100644 --- a/Marlin/src/lcd/language/language_sv.h +++ b/Marlin/src/lcd/language/language_sv.h @@ -73,7 +73,6 @@ namespace Language_sv { LSTR MSG_Z_FADE_HEIGHT = _UxGT("Falna Höjd"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Sätt Hem Offset"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Offset Tillämpad"); - LSTR MSG_SET_ORIGIN = _UxGT("Sätt Origo"); LSTR MSG_TRAMMING_WIZARD = _UxGT("Justerings Wizard"); LSTR MSG_SELECT_ORIGIN = _UxGT("Välj Origo"); LSTR MSG_LAST_VALUE_SP = _UxGT("Senaste värde "); @@ -253,7 +252,7 @@ namespace Language_sv { LSTR MSG_MOVE_E = _UxGT("Extruder"); LSTR MSG_MOVE_EN = _UxGT("Extruder *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Hetände för kall"); - LSTR MSG_MOVE_N_MM = _UxGT("Flytta %smm"); + LSTR MSG_MOVE_N_MM = _UxGT("Flytta $mm"); LSTR MSG_MOVE_01MM = _UxGT("Flytta 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Flytta 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Flytta 10mm"); @@ -291,52 +290,44 @@ namespace Language_sv { LSTR MSG_PID_AUTOTUNE = _UxGT("PID Autojustera"); LSTR MSG_PID_AUTOTUNE_E = _UxGT("PID Autojustera *"); LSTR MSG_PID_AUTOTUNE_DONE = _UxGT("PID tuning done"); - 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_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"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-Ryck"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-Ryck"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-Ryck"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-Ryck"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-Ryck"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-Ryck"); + LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT("-Ryck"); + LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT("-Ryck"); + LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT("-Ryck"); + LSTR MSG_VN_JERK = _UxGT("V@-Ryck"); LSTR MSG_VE_JERK = _UxGT("Ve-Ryck"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Knutpunkt Avv"); - LSTR MSG_VELOCITY = _UxGT("Hastighet"); - LSTR MSG_VMAX_A = _UxGT("Vmax ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Vmax ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Vmax ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Vmax ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Vmax ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Vmax ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Vmax ") LCD_STR_E; + LSTR MSG_MAX_SPEED = _UxGT("Hastighet"); + LSTR MSG_VMAX_A = _UxGT("Vmax ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Vmax ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Vmax ") STR_C; + LSTR MSG_VMAX_N = _UxGT("Vmax @"); + LSTR MSG_VMAX_E = _UxGT("Vmax E"); LSTR MSG_VMAX_EN = _UxGT("Vmax *"); LSTR MSG_VMIN = _UxGT("Vmin"); LSTR MSG_VTRAV_MIN = _UxGT("VTrav Min"); LSTR MSG_ACCELERATION = _UxGT("Acceleration"); - LSTR MSG_AMAX_A = _UxGT("Amax ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Amax ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Amax ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Amax ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Amax ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Amax ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Amax ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Amax ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Amax ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Amax ") STR_C; + LSTR MSG_AMAX_N = _UxGT("Amax @"); + LSTR MSG_AMAX_E = _UxGT("Amax E"); LSTR MSG_AMAX_EN = _UxGT("Amax *"); LSTR MSG_A_RETRACT = _UxGT("A-Dra tillbaka"); LSTR MSG_A_TRAVEL = _UxGT("A-Färdas"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Frekvens max"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Flöde min"); LSTR MSG_STEPS_PER_MM = _UxGT("Steg/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" Steg/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" Steg/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" Steg/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" Steg/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" Steg/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" Steg/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" Steg/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" Steg/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" Steg/mm"); + LSTR MSG_N_STEPS = _UxGT("@ Steg/mm"); LSTR MSG_E_STEPS = _UxGT("E Steg/mm"); LSTR MSG_EN_STEPS = _UxGT("* Steg/mm"); LSTR MSG_TEMPERATURE = _UxGT("Temperatur"); @@ -470,6 +461,7 @@ namespace Language_sv { LSTR MSG_BABYSTEP_X = _UxGT("Småsteg X"); LSTR MSG_BABYSTEP_Y = _UxGT("Småsteg Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Småsteg Z"); + LSTR MSG_BABYSTEP_N = _UxGT("Småsteg @"); LSTR MSG_BABYSTEP_TOTAL = _UxGT("Total"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Slutstopp Avbrott"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Värma Misslyckad"); @@ -523,7 +515,7 @@ namespace Language_sv { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Ljus ljusstyrka"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("INKORREKT SKRIVARE"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Utskriftsantal"); LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Färdiga"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Total Utskriftstid"); @@ -541,13 +533,7 @@ namespace Language_sv { LSTR MSG_INFO_MAX_TEMP = _UxGT("Max Temp"); LSTR MSG_INFO_PSU = _UxGT("PSU"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Driv Styrka"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Driver %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("E Driver %"); + LSTR MSG_DAC_PERCENT_N = _UxGT("@ Driver %"); LSTR MSG_ERROR_TMC = _UxGT("TMC KOPPLNINGSFEL"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM Skriv"); LSTR MSG_FILAMENT_CHANGE_HEADER = _UxGT("TRÅDBYTE"); diff --git a/Marlin/src/lcd/language/language_tr.h b/Marlin/src/lcd/language/language_tr.h index 4c2bbfa0dc00..b981127ed1cd 100644 --- a/Marlin/src/lcd/language/language_tr.h +++ b/Marlin/src/lcd/language/language_tr.h @@ -72,7 +72,6 @@ namespace Language_tr { LSTR MSG_Z_FADE_HEIGHT = _UxGT("Kaçınma Yüksekliği"); LSTR MSG_SET_HOME_OFFSETS = _UxGT("Ofset Ayarla"); LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Ofset Tamam"); - LSTR MSG_SET_ORIGIN = _UxGT("Sıfır Belirle"); #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 " ~"; @@ -229,7 +228,7 @@ namespace Language_tr { LSTR MSG_MOVE_E = _UxGT("Ekstruder"); LSTR MSG_MOVE_EN = _UxGT("Ekstruder *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Nozul Çok Soğuk"); - LSTR MSG_MOVE_N_MM = _UxGT("%smm"); + 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"); @@ -261,43 +260,35 @@ namespace Language_tr { LSTR MSG_ACC = _UxGT("İvme"); LSTR MSG_JERK = _UxGT("Sarsım"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-Sarsım"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-Sarsım"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-Sarsım"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-Sarsım"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-Sarsım"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _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_JUNCTION_DEVIATION = _UxGT("Jonksiyon Sapması"); - LSTR MSG_VELOCITY = _UxGT("Hız Vektörü"); - LSTR MSG_VMAX_A = _UxGT("HızVektör.max ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("HızVektör.max ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("HızVektör.max ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("HızVektör.max ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("HızVektör.max ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("HızVektör.max ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("HızVektör.max ") LCD_STR_E; + 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_ACCELERATION = _UxGT("Ivme"); - LSTR MSG_AMAX_A = _UxGT("Max. ivme ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Max. ivme ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Max. ivme ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Max. ivme ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Max. ivme ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Max. ivme ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Max. ivme ") LCD_STR_E; + 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_STEPS_PER_MM = _UxGT("Adım/mm"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" adım/mm"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" adım/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" adım/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" adım/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" adım/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" adım/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" adım/mm"); + LSTR MSG_B_STEPS = STR_B _UxGT(" adım/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" adım/mm"); + LSTR MSG_N_STEPS = _UxGT("@ adım/mm"); LSTR MSG_E_STEPS = _UxGT("E adım/mm"); LSTR MSG_EN_STEPS = _UxGT("* adım/mm"); LSTR MSG_TEMPERATURE = _UxGT("Sıcaklık"); @@ -407,6 +398,7 @@ namespace Language_tr { LSTR MSG_BABYSTEP_X = _UxGT("Miniadım X"); LSTR MSG_BABYSTEP_Y = _UxGT("Miniadım Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Miniadım Z"); + LSTR MSG_BABYSTEP_N = _UxGT("Miniadım @"); 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"); @@ -456,7 +448,7 @@ namespace Language_tr { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Aydınlatma Parlaklğı"); LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("Yanlış Yazıcı"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 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"); @@ -474,13 +466,7 @@ namespace Language_tr { LSTR MSG_INFO_MAX_TEMP = _UxGT("Max Sıc."); LSTR MSG_INFO_PSU = _UxGT("Güç Kaynağı"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Sürücü Gücü"); - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" Sürücü %"); - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" Sürücü %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" Sürücü %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" Sürücü %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" Sürücü %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" Sürücü %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("E Sürücü %"); + LSTR MSG_DAC_PERCENT_N = _UxGT("@ Sürücü %"); LSTR MSG_ERROR_TMC = _UxGT("TMC BAĞLANTI HATASI"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("DAC EEPROM Yaz"); LSTR MSG_FILAMENT_CHANGE_HEADER = _UxGT("FILAMAN DEGISTIR"); diff --git a/Marlin/src/lcd/language/language_uk.h b/Marlin/src/lcd/language/language_uk.h index 23110b5e4db9..3c47ccada916 100644 --- a/Marlin/src/lcd/language/language_uk.h +++ b/Marlin/src/lcd/language/language_uk.h @@ -44,7 +44,7 @@ namespace Language_uk { LSTR MSG_MEDIA_INSERTED = _UxGT("SD-картка вставлена"); LSTR MSG_MEDIA_REMOVED = _UxGT("SD-картка видалена"); LSTR MSG_MEDIA_WAITING = _UxGT("Вставте SD-картку"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Збій ініціалізації SD"); #else LSTR MSG_MEDIA_INIT_FAIL = _UxGT("Збій ініціаліз. SD"); @@ -52,7 +52,7 @@ namespace Language_uk { LSTR MSG_MEDIA_READ_ERROR = _UxGT("Помилка зчитування"); LSTR MSG_MEDIA_USB_REMOVED = _UxGT("USB диск видалений"); LSTR MSG_MEDIA_USB_FAILED = _UxGT("Помилка USB диску"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_KILL_SUBCALL_OVERFLOW = _UxGT("Переповнення виклику"); LSTR MSG_LCD_SOFT_ENDSTOPS = _UxGT("Програмні кінцевики"); #else @@ -68,12 +68,10 @@ namespace Language_uk { LSTR MSG_DEBUG_MENU = _UxGT("Меню Debug"); LSTR MSG_PROGRESS_BAR_TEST = _UxGT("Тест лінії прогр."); LSTR MSG_AUTO_HOME = _UxGT("Авто паркування"); + LSTR MSG_AUTO_HOME_A = _UxGT("Паркування @"); LSTR MSG_AUTO_HOME_X = _UxGT("Паркування X"); LSTR MSG_AUTO_HOME_Y = _UxGT("Паркування Y"); LSTR MSG_AUTO_HOME_Z = _UxGT("Паркування Z"); - LSTR MSG_AUTO_HOME_I = _UxGT("Паркування ") LCD_STR_I; - LSTR MSG_AUTO_HOME_J = _UxGT("Паркування ") LCD_STR_J; - LSTR MSG_AUTO_HOME_K = _UxGT("Паркування ") LCD_STR_K; LSTR MSG_AUTO_Z_ALIGN = _UxGT("Авто Z-вирівнювання"); LSTR MSG_ITERATION = _UxGT("G34 Ітерація: %i"); LSTR MSG_DECREASING_ACCURACY = _UxGT("Зменьшення точності!"); @@ -83,27 +81,20 @@ namespace Language_uk { LSTR MSG_LEVEL_BED_NEXT_POINT = _UxGT("Наступна точка"); LSTR MSG_LEVEL_BED_DONE = _UxGT("Завершено!"); LSTR MSG_Z_FADE_HEIGHT = _UxGT("Висота спаду"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_SET_HOME_OFFSETS = _UxGT("Встанов. зміщення дому"); LSTR MSG_HOME_OFFSET_X = _UxGT("Зміщення дому X"); LSTR MSG_HOME_OFFSET_Y = _UxGT("Зміщення дому Y"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Зміщення дому Z"); - LSTR MSG_HOME_OFFSET_I = _UxGT("Зміщення дому ") LCD_STR_I; - LSTR MSG_HOME_OFFSET_J = _UxGT("Зміщення дому ") LCD_STR_J; - LSTR MSG_HOME_OFFSET_K = _UxGT("Зміщення дому ") LCD_STR_K; #else LSTR MSG_SET_HOME_OFFSETS = _UxGT("Встан. зміщ. дому"); LSTR MSG_HOME_OFFSET_X = _UxGT("Зміщ. дому X"); LSTR MSG_HOME_OFFSET_Y = _UxGT("Зміщ. дому Y"); LSTR MSG_HOME_OFFSET_Z = _UxGT("Зміщ. дому Z"); - LSTR MSG_HOME_OFFSET_I = _UxGT("Зміщ. дому ") LCD_STR_I; - LSTR MSG_HOME_OFFSET_J = _UxGT("Зміщ. дому ") LCD_STR_J; - LSTR MSG_HOME_OFFSET_K = _UxGT("Зміщ. дому ") LCD_STR_K; #endif LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Зміщення прийняті"); - LSTR MSG_SET_ORIGIN = _UxGT("Встановити нуль"); LSTR MSG_SELECT_ORIGIN = _UxGT("Оберіть нуль"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_LAST_VALUE_SP = _UxGT("Останнє значення "); #else LSTR MSG_LAST_VALUE_SP = _UxGT("Останнє знач. "); @@ -131,7 +122,7 @@ namespace Language_uk { LSTR MSG_CUTTER_FREQUENCY = _UxGT("Частота"); LSTR MSG_LASER_MENU = _UxGT("Керування лазером"); LSTR MSG_SPINDLE_MENU = _UxGT("Керування шпінделем"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_LASER_POWER = _UxGT("Потужність лазера"); LSTR MSG_SPINDLE_TOGGLE = _UxGT("Перемкн. шпіндель"); LSTR MSG_SPINDLE_EVAC_TOGGLE = _UxGT("Перемкнути вакуум"); @@ -162,7 +153,7 @@ namespace Language_uk { LSTR MSG_BED_LEVELING = _UxGT("Вирівнювання столу"); LSTR MSG_LEVEL_BED = _UxGT("Вирівняти стіл"); LSTR MSG_BED_TRAMMING = _UxGT("Вирівняти кути"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_BED_TRAMMING_RAISE = _UxGT("Вгору до спрацюв. зонду"); LSTR MSG_BED_TRAMMING_IN_RANGE = _UxGT("Кути в межах. Вирів.столу"); #else @@ -172,7 +163,7 @@ namespace Language_uk { LSTR MSG_BED_TRAMMING_GOOD_POINTS = _UxGT("Хороші точки: "); LSTR MSG_BED_TRAMMING_LAST_Z = _UxGT("Остання Z: "); LSTR MSG_NEXT_CORNER = _UxGT("Наступний кут"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MESH_EDITOR = _UxGT("Зміщення по Z"); #else LSTR MSG_MESH_EDITOR = _UxGT("Зміщення Z"); @@ -205,7 +196,7 @@ namespace Language_uk { LSTR MSG_UBL_TOOLS = _UxGT("Інструменти UBL"); LSTR MSG_UBL_LEVEL_BED = _UxGT("Налаштування UBL"); LSTR MSG_LCD_TILTING_MESH = _UxGT("Точка нахилу"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_MANUAL_MESH = _UxGT("Ручне введення сітки"); LSTR MSG_UBL_BC_INSERT = _UxGT("Розмістити шайбу і вимір."); #else @@ -214,7 +205,7 @@ namespace Language_uk { #endif LSTR MSG_UBL_MESH_WIZARD = _UxGT("Майстер сіток UBL"); LSTR MSG_UBL_BC_INSERT2 = _UxGT("Вимірювання"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_BC_REMOVE = _UxGT("Видалити і виміряти стіл"); #else LSTR MSG_UBL_BC_REMOVE = _UxGT("Видали і вимір. стіл"); @@ -226,7 +217,7 @@ namespace Language_uk { 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"; - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_EDIT_CUSTOM_MESH = _UxGT("Редагувати свою сітку"); LSTR MSG_UBL_FINE_TUNE_MESH = _UxGT("Точне редагування сітки"); LSTR MSG_UBL_BUILD_CUSTOM_MESH = _UxGT("Будувати свою сітку"); @@ -256,7 +247,7 @@ namespace Language_uk { LSTR MSG_UBL_CONTINUE_MESH = _UxGT("Продовжити сітку"); LSTR MSG_UBL_MESH_LEVELING = _UxGT("Вирівнювання сітки"); LSTR MSG_UBL_3POINT_MESH_LEVELING = _UxGT("3-точкове вирівн."); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_GRID_MESH_LEVELING = _UxGT("Вирівнювання растру"); #else LSTR MSG_UBL_GRID_MESH_LEVELING = _UxGT("Вирівнюв. растру"); @@ -269,7 +260,7 @@ namespace Language_uk { LSTR MSG_UBL_OUTPUT_MAP_CSV = _UxGT("Вивести в CSV"); LSTR MSG_UBL_OUTPUT_MAP_BACKUP = _UxGT("Зберегти зовні"); LSTR MSG_UBL_INFO_UBL = _UxGT("Інформація по UBL"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_FILLIN_AMOUNT = _UxGT("Обсяг заповнюв."); #else LSTR MSG_UBL_FILLIN_AMOUNT = _UxGT("Обсяг заповн."); @@ -279,7 +270,7 @@ namespace Language_uk { LSTR MSG_UBL_FILLIN_MESH = _UxGT("Заповнити сітку"); LSTR MSG_UBL_INVALIDATE_ALL = _UxGT("Анулювати все"); LSTR MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Анулювати найближчу"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_UBL_FINE_TUNE_ALL = _UxGT("Точно налаштувати все"); LSTR MSG_UBL_FINE_TUNE_CLOSEST = _UxGT("Точно налашт.найближчу"); #else @@ -308,7 +299,7 @@ namespace Language_uk { LSTR MSG_LED_CONTROL = _UxGT("Керування світлом"); LSTR MSG_LEDS = _UxGT("Підсвітка"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_LED_PRESETS = _UxGT("Передустановки світла"); #else LSTR MSG_LED_PRESETS = _UxGT("Передустан. світла"); @@ -324,7 +315,7 @@ namespace Language_uk { LSTR MSG_SET_LEDS_DEFAULT = _UxGT("За умовчанням"); LSTR MSG_LED_CHANNEL_N = _UxGT("Канал ="); LSTR MSG_LEDS2 = _UxGT("Світло #2"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_NEO2_PRESETS = _UxGT("Передустановка світла #2"); #else LSTR MSG_NEO2_PRESETS = _UxGT("Передуст. світла #2"); @@ -342,9 +333,7 @@ namespace Language_uk { LSTR MSG_MOVE_X = _UxGT("Рух по X"); LSTR MSG_MOVE_Y = _UxGT("Рух по Y"); LSTR MSG_MOVE_Z = _UxGT("Рух по Z"); - LSTR MSG_MOVE_I = _UxGT("Рух по ") LCD_STR_I; - LSTR MSG_MOVE_J = _UxGT("Рух по ") LCD_STR_J; - LSTR MSG_MOVE_K = _UxGT("Рух по ") LCD_STR_K; + LSTR MSG_MOVE_N = _UxGT("Рух по @"); LSTR MSG_MOVE_E = _UxGT("Екструдер"); LSTR MSG_MOVE_EN = _UxGT("Екструдер *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Сопло дуже холодне"); @@ -361,7 +350,7 @@ namespace Language_uk { LSTR MSG_NOZZLE_STANDBY = _UxGT("Сопло очікує"); LSTR MSG_BED = _UxGT("Стіл, ") LCD_STR_DEGREE "C"; LSTR MSG_CHAMBER = _UxGT("Камера,") LCD_STR_DEGREE "C"; - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_COOLER = _UxGT("Охолодження лазеру"); LSTR MSG_COOLER_TOGGLE = _UxGT("Перемк. охолодж."); #else @@ -372,7 +361,7 @@ namespace Language_uk { LSTR MSG_LASER = _UxGT("Лазер"); LSTR MSG_FAN_SPEED = _UxGT("Швидк. вент."); LSTR MSG_FAN_SPEED_N = _UxGT("Швидк. вент. ~"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_STORED_FAN_N = _UxGT("Збереж.швидк.вент. ~"); LSTR MSG_EXTRA_FAN_SPEED_N = _UxGT("Дод. швидк. вент. ~"); #else @@ -398,61 +387,53 @@ namespace Language_uk { LSTR MSG_PID_AUTOTUNE = _UxGT("Автопідбір PID"); LSTR MSG_PID_AUTOTUNE_E = _UxGT("Автопідбір PID *"); LSTR MSG_PID_AUTOTUNE_DONE = _UxGT("Підбір PID виконано"); - LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Збій автопідбору. Поганий екструдер."); - LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Збій автопідбору. Температура завищена."); + LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Збій автопідбору! Поганий екструдер."); + 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("Ривок"); - LSTR MSG_VA_JERK = _UxGT("V") LCD_STR_A _UxGT("-ривок"); - LSTR MSG_VB_JERK = _UxGT("V") LCD_STR_B _UxGT("-ривок"); - LSTR MSG_VC_JERK = _UxGT("V") LCD_STR_C _UxGT("-ривок"); - LSTR MSG_VI_JERK = _UxGT("V") LCD_STR_I _UxGT("-ривок"); - LSTR MSG_VJ_JERK = _UxGT("V") LCD_STR_J _UxGT("-ривок"); - LSTR MSG_VK_JERK = _UxGT("V") LCD_STR_K _UxGT("-ривок"); + LSTR MSG_VA_JERK = _UxGT("V") STR_A _UxGT("-ривок"); + LSTR MSG_VB_JERK = _UxGT("V") STR_B _UxGT("-ривок"); + LSTR MSG_VC_JERK = _UxGT("V") STR_C _UxGT("-ривок"); + LSTR MSG_VN_JERK = _UxGT("V@-ривок"); LSTR MSG_VE_JERK = _UxGT("Ve-ривок"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_JUNCTION_DEVIATION = _UxGT("Відхилення вузла"); #else LSTR MSG_JUNCTION_DEVIATION = _UxGT("Відхил.вузла"); #endif - LSTR MSG_VELOCITY = _UxGT("Швидкість, мм/с"); - LSTR MSG_VMAX_A = _UxGT("Швидк.макс ") LCD_STR_A; - LSTR MSG_VMAX_B = _UxGT("Швидк.макс ") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Швидк.макс ") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Швидк.макс ") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Швидк.макс ") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Швидк.макс ") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Швидк.макс ") LCD_STR_E; + LSTR MSG_MAX_SPEED = _UxGT("Швидкість, мм/с"); + LSTR MSG_VMAX_A = _UxGT("Швидк.макс ") STR_A; + LSTR MSG_VMAX_B = _UxGT("Швидк.макс ") STR_B; + LSTR MSG_VMAX_C = _UxGT("Швидк.макс ") STR_C; + LSTR MSG_VMAX_N = _UxGT("Швидк.макс @"); + LSTR MSG_VMAX_E = _UxGT("Швидк.макс E"); LSTR MSG_VMAX_EN = _UxGT("Швидк.макс *"); LSTR MSG_VMIN = _UxGT("Швидк. мін"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_VTRAV_MIN = _UxGT("Переміщення мін"); #else LSTR MSG_VTRAV_MIN = _UxGT("Переміщ. мін"); #endif LSTR MSG_ACCELERATION = _UxGT("Прискорення, мм/с2"); - LSTR MSG_AMAX_A = _UxGT("Приск.макс ") LCD_STR_A; - LSTR MSG_AMAX_B = _UxGT("Приск.макс ") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Приск.макс ") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Приск.макс ") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("Приск.макс ") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Приск.макс ") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Приск.макс ") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Приск.макс ") STR_A; + LSTR MSG_AMAX_B = _UxGT("Приск.макс ") STR_B; + LSTR MSG_AMAX_C = _UxGT("Приск.макс ") STR_C; + LSTR MSG_AMAX_N = _UxGT("Приск.макс @"); + LSTR MSG_AMAX_E = _UxGT("Приск.макс E"); LSTR MSG_AMAX_EN = _UxGT("Приск.макс *"); LSTR MSG_A_RETRACT = _UxGT("Приск.втягув."); LSTR MSG_A_TRAVEL = _UxGT("Приск.переміщ."); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Частота макс."); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Подача мін."); LSTR MSG_STEPS_PER_MM = _UxGT("Кроків на мм"); - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" кроків/мм"); - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" кроків/мм"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" кроків/мм"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" кроків/мм"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" кроків/мм"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" кроків/мм"); + LSTR MSG_A_STEPS = STR_A _UxGT(" кроків/мм"); + LSTR MSG_B_STEPS = STR_B _UxGT(" кроків/мм"); + LSTR MSG_C_STEPS = STR_C _UxGT(" кроків/мм"); + LSTR MSG_N_STEPS = _UxGT("@ кроків/мм"); LSTR MSG_E_STEPS = _UxGT("E кроків/мм"); LSTR MSG_EN_STEPS = _UxGT("* кроків/мм"); LSTR MSG_TEMPERATURE = _UxGT("Температура"); @@ -467,11 +448,19 @@ namespace Language_uk { LSTR MSG_FILAMENT_LOAD = _UxGT("Завантаж., мм"); LSTR MSG_ADVANCE_K = _UxGT("Kоеф. просув."); LSTR MSG_ADVANCE_K_E = _UxGT("Kоеф. просув. *"); - LSTR MSG_CONTRAST = _UxGT("Контраст екрану"); + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 + LSTR MSG_CONTRAST = _UxGT("Контраст екрану"); + LSTR MSG_BRIGHTNESS = _UxGT("Яскравість LCD"); + #else + LSTR MSG_CONTRAST = _UxGT("Контраст"); + LSTR MSG_BRIGHTNESS = _UxGT("Яскравість"); + #endif + LSTR MSG_LCD_TIMEOUT_SEC = _UxGT("LCD Таймаут, с"); + LSTR MSG_BRIGHTNESS_OFF = _UxGT("Підсвітка вимк."); LSTR MSG_STORE_EEPROM = _UxGT("Зберегти в EEPROM"); LSTR MSG_LOAD_EEPROM = _UxGT("Зчитати з EEPROM"); LSTR MSG_RESTORE_DEFAULTS = _UxGT("На базові параметри"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_INIT_EEPROM = _UxGT("Ініціалізація EEPROM"); #else LSTR MSG_INIT_EEPROM = _UxGT("Ініціаліз. EEPROM"); @@ -499,10 +488,17 @@ namespace Language_uk { LSTR MSG_BUTTON_RESET = _UxGT("Зкинути"); LSTR MSG_BUTTON_IGNORE = _UxGT("Ігнорув."); LSTR MSG_BUTTON_CANCEL = _UxGT("Відміна"); + LSTR MSG_BUTTON_CONFIRM = _UxGT("Підтвер."); + LSTR MSG_BUTTON_CONTINUE = _UxGT("Продовж."); LSTR MSG_BUTTON_DONE = _UxGT("Готово"); LSTR MSG_BUTTON_BACK = _UxGT("Назад"); - LSTR MSG_BUTTON_PROCEED = _UxGT("Продовжити"); - LSTR MSG_BUTTON_SKIP = _UxGT("Пропустити"); + LSTR MSG_BUTTON_PROCEED = _UxGT("Продовж."); + LSTR MSG_BUTTON_SKIP = _UxGT("Пропуск"); + LSTR MSG_BUTTON_INFO = _UxGT("Інфо"); + LSTR MSG_BUTTON_LEVEL = _UxGT("Рівень"); + LSTR MSG_BUTTON_PAUSE = _UxGT("Пауза"); + LSTR MSG_BUTTON_RESUME = _UxGT("Звіт"); + LSTR MSG_BUTTON_SAVE = _UxGT("Зберегти"); LSTR MSG_PAUSING = _UxGT("Призупинення..."); LSTR MSG_PAUSE_PRINT = _UxGT("Призупинити друк"); @@ -520,12 +516,14 @@ namespace Language_uk { LSTR MSG_USERWAIT = _UxGT("Продовжити..."); LSTR MSG_PRINT_PAUSED = _UxGT("Друк призупинено"); LSTR MSG_PRINTING = _UxGT("Друк..."); + LSTR MSG_STOPPING = _UxGT("Зупинка..."); + LSTR MSG_REMAINING_TIME = _UxGT("Залишилось"); LSTR MSG_PRINT_ABORTED = _UxGT("Друк скасовано"); LSTR MSG_PRINT_DONE = _UxGT("Друк завершено"); LSTR MSG_NO_MOVE = _UxGT("Немає руху."); LSTR MSG_KILLED = _UxGT("ПЕРЕРВАНО. "); LSTR MSG_STOPPED = _UxGT("ЗУПИНЕНО. "); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_CONTROL_RETRACT = _UxGT("Втягування, мм"); LSTR MSG_CONTROL_RETRACT_SWAP = _UxGT("Зміна втягув.,мм"); LSTR MSG_CONTROL_RETRACT_RECOVER = _UxGT("Повернення, мм"); @@ -547,7 +545,7 @@ namespace Language_uk { LSTR MSG_FILAMENT_PURGE_LENGTH = _UxGT("Очистити довжину"); LSTR MSG_TOOL_CHANGE = _UxGT("Зміна сопла"); LSTR MSG_TOOL_CHANGE_ZLIFT = _UxGT("Підняти по Z"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Початк.швидкість"); LSTR MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Швидкість втягув."); #else @@ -556,7 +554,7 @@ namespace Language_uk { #endif LSTR MSG_FILAMENT_PARK_ENABLED = _UxGT("Паркувати голову"); LSTR MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Відновити швидкість"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_SINGLENOZZLE_FAN_SPEED = _UxGT("Оберти вентилятора"); LSTR MSG_SINGLENOZZLE_FAN_TIME = _UxGT("Час вентилятора"); #else @@ -610,9 +608,7 @@ namespace Language_uk { LSTR MSG_BABYSTEP_X = _UxGT("Мікрокрок X"); LSTR MSG_BABYSTEP_Y = _UxGT("Мікрокрок Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Мікрокрок Z"); - LSTR MSG_BABYSTEP_I = _UxGT("Мікрокрок ") LCD_STR_I; - LSTR MSG_BABYSTEP_J = _UxGT("Мікрокрок ") LCD_STR_J; - LSTR MSG_BABYSTEP_K = _UxGT("Мікрокрок ") LCD_STR_K; + LSTR MSG_BABYSTEP_N = _UxGT("Мікрокрок @"); LSTR MSG_BABYSTEP_TOTAL = _UxGT("Сумарно"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Кінцевик спрацював"); LSTR MSG_HEATING_FAILED_LCD = _UxGT("Збій нагріву"); @@ -621,7 +617,7 @@ namespace Language_uk { LSTR MSG_THERMAL_RUNAWAY_BED = _UxGT("ВИТІК ТЕПЛА СТОЛУ"); LSTR MSG_THERMAL_RUNAWAY_CHAMBER = _UxGT("ВИТІК ТЕПЛА КАМЕРИ"); LSTR MSG_THERMAL_RUNAWAY_COOLER = _UxGT("ВИТІК ОХОЛОДЖЕННЯ"); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_COOLING_FAILED = _UxGT("ОХОЛОДЖЕННЯ НЕ ВДАЛОСЬ"); #else LSTR MSG_COOLING_FAILED = _UxGT("ОХОЛОДЖ. НЕ ВДАЛОСЬ"); @@ -638,7 +634,7 @@ namespace Language_uk { LSTR MSG_BED_HEATING = _UxGT("Нагрів столу..."); LSTR MSG_PROBE_HEATING = _UxGT("Нагрів зонду..."); LSTR MSG_CHAMBER_HEATING = _UxGT("Нагрів камери..."); - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_BED_COOLING = _UxGT("Охолодження столу..."); LSTR MSG_PROBE_COOLING = _UxGT("Охолодження зонду..."); LSTR MSG_CHAMBER_COOLING = _UxGT("Охолодження камери..."); @@ -665,7 +661,7 @@ namespace Language_uk { LSTR MSG_INFO_MENU = _UxGT("Про принтер"); LSTR MSG_INFO_PRINTER_MENU = _UxGT("Дані принтера"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_3POINT_LEVELING = _UxGT("3-точкове вирівнювання"); LSTR MSG_LINEAR_LEVELING = _UxGT("Лінійне вирівнювання"); LSTR MSG_BILINEAR_LEVELING = _UxGT("Білінійне вирівнювання"); @@ -676,7 +672,7 @@ namespace Language_uk { #endif LSTR MSG_UBL_LEVELING = _UxGT("UBL"); LSTR MSG_MESH_LEVELING = _UxGT("Вирівнювання сітки"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MESH_DONE = _UxGT("Зондування сітки виконано"); #else LSTR MSG_MESH_DONE = _UxGT("Зондування виконано"); @@ -688,7 +684,7 @@ namespace Language_uk { LSTR MSG_INFO_EXTRUDERS = _UxGT("Екструдери"); LSTR MSG_INFO_BAUDRATE = _UxGT("Бод"); LSTR MSG_INFO_PROTOCOL = _UxGT("Протокол"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_INFO_RUNAWAY_OFF = _UxGT("Контроль витіку ") LCD_STR_THERMOMETER _UxGT(" Вимк"); LSTR MSG_INFO_RUNAWAY_ON = _UxGT("Контроль витіку ") LCD_STR_THERMOMETER _UxGT(" Увімк"); LSTR MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Час простою хотенду"); @@ -704,34 +700,45 @@ namespace Language_uk { LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Завершено"); LSTR MSG_INFO_PRINT_FILAMENT = _UxGT("Екструдовано"); - #if LCD_WIDTH >= 20 + LSTR MSG_PLEASE_PREHEAT = _UxGT("Нагрійте хотенд"); + LSTR MSG_COLORS_GET = _UxGT("Отримати колір"); + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 + LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("Носій не вставлений"); + LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Перезавантаження..."); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Кількість друків"); - LSTR MSG_INFO_PRINT_TIME = _UxGT("Весь час друку"); + LSTR MSG_INFO_PRINT_TIME = _UxGT("Час друку"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Найдовший час"); + LSTR MSG_COLORS_SELECT = _UxGT("Обрати кольори"); + LSTR MSG_COLORS_APPLIED = _UxGT("Кольори застосовані"); #else + LSTR MSG_MEDIA_NOT_INSERTED = _UxGT("Немає носія"); + LSTR MSG_PLEASE_WAIT_REBOOT = _UxGT("Перезавантаж..."); LSTR MSG_INFO_PRINT_COUNT = _UxGT("Друків"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Загалом"); LSTR MSG_INFO_PRINT_LONGEST = _UxGT("Найдовше"); + LSTR MSG_COLORS_SELECT = _UxGT("Кольори"); + LSTR MSG_COLORS_APPLIED = _UxGT("Кольори застос."); #endif + LSTR MSG_COLORS_RED = _UxGT("Червоний"); + LSTR MSG_COLORS_GREEN = _UxGT("Зелений"); + LSTR MSG_COLORS_BLUE = _UxGT("Синій"); + LSTR MSG_COLORS_WHITE = _UxGT("Білий"); + LSTR MSG_UI_LANGUAGE = _UxGT("Мова"); + LSTR MSG_SOUND_ENABLE = _UxGT("Дозволити звук"); + LSTR MSG_LOCKSCREEN = _UxGT("Блокувати екран"); LSTR MSG_INFO_MIN_TEMP = _UxGT("Мін. ") LCD_STR_THERMOMETER; LSTR MSG_INFO_MAX_TEMP = _UxGT("Макс. ") LCD_STR_THERMOMETER; LSTR MSG_INFO_PSU = _UxGT("Блок жив-ня"); LSTR MSG_DRIVE_STRENGTH = _UxGT("Сила мотору"); - LSTR MSG_DAC_PERCENT_A = _UxGT("Драйвер ") LCD_STR_A _UxGT(", %"); - LSTR MSG_DAC_PERCENT_B = _UxGT("Драйвер ") LCD_STR_B _UxGT(", %"); - LSTR MSG_DAC_PERCENT_C = _UxGT("Драйвер ") LCD_STR_C _UxGT(", %"); - LSTR MSG_DAC_PERCENT_I = _UxGT("Драйвер ") LCD_STR_I _UxGT(", %"); - LSTR MSG_DAC_PERCENT_J = _UxGT("Драйвер ") LCD_STR_J _UxGT(", %"); - LSTR MSG_DAC_PERCENT_K = _UxGT("Драйвер ") LCD_STR_K _UxGT(", %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("Драйвер E, %"); + LSTR MSG_DAC_PERCENT_N = _UxGT("Драйвер @, %"); LSTR MSG_ERROR_TMC = _UxGT("ЗБІЙ ЗВ'ЯЗКУ З TMC"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Запис ЦАП у EEPROM"); LSTR MSG_FILAMENT_CHANGE_HEADER = _UxGT("ЗАМІНА ПРУТКА"); LSTR MSG_FILAMENT_CHANGE_HEADER_PAUSE = _UxGT("ЗУПИНКА ДРУКУ"); LSTR MSG_FILAMENT_CHANGE_HEADER_LOAD = _UxGT("ЗАВАНТАЖИТИ ПРУТОК"); LSTR MSG_FILAMENT_CHANGE_HEADER_UNLOAD = _UxGT("ВИВАНТАЖИТИ ПРУТОК"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_FILAMENT_CHANGE_OPTION_HEADER = _UxGT("ПАРАМЕТРИ ПРОДОВЖЕННЯ:"); #else LSTR MSG_FILAMENT_CHANGE_OPTION_HEADER = _UxGT("ПАРАМ.ПРОДОВЖЕННЯ:"); @@ -739,7 +746,7 @@ namespace Language_uk { LSTR MSG_FILAMENT_CHANGE_OPTION_PURGE = _UxGT("Видавити ще"); LSTR MSG_FILAMENT_CHANGE_OPTION_RESUME = _UxGT("Відновити друк"); LSTR MSG_FILAMENT_CHANGE_NOZZLE = _UxGT(" Сопло: "); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_RUNOUT_SENSOR = _UxGT("Датчик закінчення прутка"); LSTR MSG_RUNOUT_DISTANCE_MM = _UxGT("Відстань закінч.,мм"); #else @@ -757,7 +764,7 @@ namespace Language_uk { LSTR MSG_MMU2_RESUMING = _UxGT("MMU Продовження..."); LSTR MSG_MMU2_LOAD_FILAMENT = _UxGT("MMU Завантажити"); LSTR MSG_MMU2_LOAD_ALL = _UxGT("MMU Завантажити все"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MMU2_LOAD_TO_NOZZLE = _UxGT("MMU Завантажити в сопло"); #else LSTR MSG_MMU2_LOAD_TO_NOZZLE = _UxGT("MMU Завант. в сопло"); @@ -774,7 +781,7 @@ namespace Language_uk { LSTR MSG_MMU2_RESETTING = _UxGT("MMU Перезапуск..."); LSTR MSG_MMU2_EJECT_RECOVER = _UxGT("Видаліть, натисніть"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_MIX = _UxGT("Змішування"); #else LSTR MSG_MIX = _UxGT("Змішув."); @@ -783,7 +790,7 @@ namespace Language_uk { LSTR MSG_MIXER = _UxGT("Змішувач"); LSTR MSG_GRADIENT = _UxGT("Градієнт"); LSTR MSG_FULL_GRADIENT = _UxGT("Повний градієнт"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_TOGGLE_MIX = _UxGT("Переключити змішування"); #else LSTR MSG_TOGGLE_MIX = _UxGT("Переключ.змішування"); @@ -792,7 +799,7 @@ namespace Language_uk { LSTR MSG_GRADIENT_MIX = _UxGT("Градієнт змішування"); LSTR MSG_REVERSE_GRADIENT = _UxGT("Змінити градієнт"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_ACTIVE_VTOOL = _UxGT("Активація В-інструменту"); LSTR MSG_GRADIENT_ALIAS = _UxGT("Псевдонім В-інструменту"); LSTR MSG_RESET_VTOOLS = _UxGT("Зкидання В-інструментів"); @@ -815,7 +822,7 @@ namespace Language_uk { LSTR MSG_MAZE = _UxGT("Лабіринт"); LSTR MSG_BAD_PAGE = _UxGT("Погана сторінка"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_BAD_PAGE_SPEED = _UxGT("Погана швидкість стор."); #else LSTR MSG_BAD_PAGE_SPEED = _UxGT("Погана швидк. стор."); @@ -888,7 +895,7 @@ namespace Language_uk { LSTR MSG_REHEATING = _UxGT("Нагрівання..."); LSTR MSG_PROBE_WIZARD = _UxGT("Майстер Z-зонда"); - #if LCD_WIDTH > 21 + #if LCD_WIDTH > 21 || HAS_DWIN_E3V2 LSTR MSG_PROBE_WIZARD_PROBING = _UxGT("Зондув. контрольної точки Z"); LSTR MSG_PROBE_WIZARD_MOVING = _UxGT("Рух до точки зондування"); #else diff --git a/Marlin/src/lcd/language/language_vi.h b/Marlin/src/lcd/language/language_vi.h index ae0babbf8b34..f963e3e346bc 100644 --- a/Marlin/src/lcd/language/language_vi.h +++ b/Marlin/src/lcd/language/language_vi.h @@ -63,7 +63,6 @@ namespace Language_vi { LSTR MSG_Z_FADE_HEIGHT = _UxGT("Chiều cao mờ dần"); // Fade Height LSTR MSG_SET_HOME_OFFSETS = _UxGT("Đặt bù đắp nhà"); // Set home offsets LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("Bù đắp được áp dụng"); // Offsets applied - LSTR MSG_SET_ORIGIN = _UxGT("Đặt nguồn gốc"); // Set origin #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("Làm nóng ") PREHEAT_1_LABEL _UxGT(" trước"); // Preheat LSTR MSG_PREHEAT_1_H = _UxGT("Làm nóng ") PREHEAT_1_LABEL _UxGT(" trước ~"); // Preheat @@ -228,43 +227,35 @@ namespace Language_vi { LSTR MSG_SELECT_E = _UxGT("Lựa *"); LSTR MSG_ACC = _UxGT("Tăng Tốc"); LSTR MSG_JERK = _UxGT("Giật"); - LSTR MSG_VA_JERK = _UxGT("Giật-V") LCD_STR_A; - LSTR MSG_VB_JERK = _UxGT("Giật-V") LCD_STR_B; - LSTR MSG_VC_JERK = _UxGT("Giật-V") LCD_STR_C; - LSTR MSG_VI_JERK = _UxGT("Giật-V") LCD_STR_I; - LSTR MSG_VJ_JERK = _UxGT("Giật-V") LCD_STR_J; - LSTR MSG_VK_JERK = _UxGT("Giật-V") LCD_STR_K; + LSTR MSG_VA_JERK = _UxGT("Giật-V") STR_A; + LSTR MSG_VB_JERK = _UxGT("Giật-V") STR_B; + LSTR MSG_VC_JERK = _UxGT("Giật-V") STR_C; + LSTR MSG_VN_JERK = _UxGT("Giật-V@"); LSTR MSG_VE_JERK = _UxGT("Giật-Ve"); LSTR MSG_JUNCTION_DEVIATION = _UxGT("Độ Lệch Chỗ Giao"); // Junction Dev - LSTR MSG_VELOCITY = _UxGT("Vận tốc"); // velocity - LSTR MSG_VMAX_A = _UxGT("Vđa") LCD_STR_A; // Vmax - LSTR MSG_VMAX_B = _UxGT("Vđa") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("Vđa") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("Vđa") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("Vđa") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("Vđa") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("Vđa") LCD_STR_E; + LSTR MSG_MAX_SPEED = _UxGT("Vận tốc"); // velocity + LSTR MSG_VMAX_A = _UxGT("Vđa") STR_A; // Vmax + LSTR MSG_VMAX_B = _UxGT("Vđa") STR_B; + LSTR MSG_VMAX_C = _UxGT("Vđa") STR_C; + LSTR MSG_VMAX_N = _UxGT("Vđa@"); + LSTR MSG_VMAX_E = _UxGT("VđaE"); LSTR MSG_VMAX_EN = _UxGT("Vđa *"); LSTR MSG_VMIN = _UxGT("Vthiểu"); // Vmin LSTR MSG_VTRAV_MIN = _UxGT("Vchuyển thiểu"); // VTrav min LSTR MSG_ACCELERATION = _UxGT("Sự tăng tốc"); // Acceleration - LSTR MSG_AMAX_A = _UxGT("Tăng tốc ca") LCD_STR_A; // Amax - LSTR MSG_AMAX_B = _UxGT("Tăng tốc ca") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("Tăng tốc ca") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("Tăng tốc ca") LCD_STR_I; // Amax - LSTR MSG_AMAX_J = _UxGT("Tăng tốc ca") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("Tăng tốc ca") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("Tăng tốc ca") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("Tăng tốc ca") STR_A; // Amax + LSTR MSG_AMAX_B = _UxGT("Tăng tốc ca") STR_B; + LSTR MSG_AMAX_C = _UxGT("Tăng tốc ca") STR_C; + LSTR MSG_AMAX_N = _UxGT("Tăng tốc ca@"); + LSTR MSG_AMAX_E = _UxGT("Tăng tốc caE"); LSTR MSG_AMAX_EN = _UxGT("Tăng tốc ca *"); LSTR MSG_A_RETRACT = _UxGT("TT-Rút"); // A-retract LSTR MSG_A_TRAVEL = _UxGT("TT-Chuyển"); // A-travel LSTR MSG_STEPS_PER_MM = _UxGT("Bước/mm"); // Steps - LSTR MSG_A_STEPS = _UxGT("Bước") LCD_STR_A _UxGT("/mm"); // Steps/mm - LSTR MSG_B_STEPS = _UxGT("Bước") LCD_STR_B _UxGT("/mm"); - LSTR MSG_C_STEPS = _UxGT("Bước") LCD_STR_C _UxGT("/mm"); - LSTR MSG_I_STEPS = _UxGT("Bước") LCD_STR_I _UxGT("/mm"); // Steps/mm - LSTR MSG_J_STEPS = _UxGT("Bước") LCD_STR_J _UxGT("/mm"); - LSTR MSG_K_STEPS = _UxGT("Bước") LCD_STR_K _UxGT("/mm"); + LSTR MSG_A_STEPS = _UxGT("Bước") STR_A _UxGT("/mm"); // Steps/mm + LSTR MSG_B_STEPS = _UxGT("Bước") STR_B _UxGT("/mm"); + LSTR MSG_C_STEPS = _UxGT("Bước") STR_C _UxGT("/mm"); + LSTR MSG_N_STEPS = _UxGT("Bước@/mm"); LSTR MSG_E_STEPS = _UxGT("BướcE/mm"); LSTR MSG_EN_STEPS = _UxGT("Bước */mm"); LSTR MSG_TEMPERATURE = _UxGT("Nhiệt độ"); // Temperature @@ -340,6 +331,7 @@ namespace Language_vi { LSTR MSG_BABYSTEP_X = _UxGT("Nhít X"); // Babystep X LSTR MSG_BABYSTEP_Y = _UxGT("Nhít Y"); LSTR MSG_BABYSTEP_Z = _UxGT("Nhít Z"); + LSTR MSG_BABYSTEP_N = _UxGT("Nhít @"); LSTR MSG_ENDSTOP_ABORT = _UxGT("Hủy bỏ công tắc"); // Endstop abort LSTR MSG_HEATING_FAILED_LCD = _UxGT("Sưởi đầu phun không thành công"); // Heating failed LSTR MSG_ERR_REDUNDANT_TEMP = _UxGT("Điều sai: nhiệt độ dư"); // Err: REDUNDANT TEMP @@ -383,7 +375,7 @@ namespace Language_vi { LSTR MSG_INFO_PROTOCOL = _UxGT("Giao Thức"); // Protocol LSTR MSG_CASE_LIGHT = _UxGT("Đèn Khuông"); // Case light LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Độ Sáng"); // Light Brightness - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("Số In"); // Print Count LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("Đã hoàn thành"); LSTR MSG_INFO_PRINT_TIME = _UxGT("Tổng số thời gian in"); // Total print time @@ -400,13 +392,7 @@ namespace Language_vi { LSTR MSG_INFO_MAX_TEMP = _UxGT("Nhiệt độ tối đa"); // Max temp LSTR MSG_INFO_PSU = _UxGT("Bộ nguồn"); // PSU LSTR MSG_DRIVE_STRENGTH = _UxGT("Sức mạnh ổ đĩa"); // Drive Strength - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" % trình điều khiển"); // X Driver % - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" % trình điều khiển"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" % trình điều khiển"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" % trình điều khiển"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" % trình điều khiển"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" % trình điều khiển"); - LSTR MSG_DAC_PERCENT_E = _UxGT("E % trình điều khiển"); + LSTR MSG_DAC_PERCENT_N = _UxGT("@ % trình điều khiển"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("Ghi DAC EEPROM"); // DAC EEPROM Write LSTR MSG_FILAMENT_CHANGE_HEADER_PAUSE = _UxGT("In tạm dừng"); // PRINT PAUSED LSTR MSG_FILAMENT_CHANGE_HEADER_LOAD = _UxGT("Nạp dây nhựa"); diff --git a/Marlin/src/lcd/language/language_zh_CN.h b/Marlin/src/lcd/language/language_zh_CN.h index d61634e431e1..a4816ff899c0 100644 --- a/Marlin/src/lcd/language/language_zh_CN.h +++ b/Marlin/src/lcd/language/language_zh_CN.h @@ -55,6 +55,7 @@ namespace Language_zh_CN { LSTR MSG_DISABLE_STEPPERS = _UxGT("关闭步进电机"); // "Disable steppers" LSTR MSG_DEBUG_MENU = _UxGT("调试菜单"); // "Debug Menu" LSTR MSG_PROGRESS_BAR_TEST = _UxGT("进度条测试"); // "Progress Bar Test" + LSTR MSG_HOMING = _UxGT("回原点"); LSTR MSG_AUTO_HOME = _UxGT("自动回原点"); // "Auto home" LSTR MSG_AUTO_HOME_X = _UxGT("回X原位"); // "Home X" LSTR MSG_AUTO_HOME_Y = _UxGT("回Y原位"); // "Home Y" @@ -67,7 +68,6 @@ namespace Language_zh_CN { LSTR MSG_Z_FADE_HEIGHT = _UxGT("淡出高度"); // "Fade Height" LSTR MSG_SET_HOME_OFFSETS = _UxGT("设置原点偏移"); // "Set home offsets" LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("偏移已启用"); // "Offsets applied" - LSTR MSG_SET_ORIGIN = _UxGT("设置原点"); // "Set origin" #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("预热 ") PREHEAT_1_LABEL; // "Preheat PREHEAT_2_LABEL" LSTR MSG_PREHEAT_1_H = _UxGT("预热 ") PREHEAT_1_LABEL " ~"; // "Preheat PREHEAT_2_LABEL" @@ -93,8 +93,8 @@ namespace Language_zh_CN { LSTR MSG_SPINDLE_MENU = _UxGT("主轴控制"); LSTR MSG_SPINDLE_POWER = _UxGT("主轴电源"); LSTR MSG_SPINDLE_REVERSE = _UxGT("主轴反转"); - LSTR MSG_SWITCH_PS_ON = _UxGT("电源打开"); // "Switch power on" - LSTR MSG_SWITCH_PS_OFF = _UxGT("电源关闭"); // "Switch power off" + LSTR MSG_SWITCH_PS_ON = _UxGT("开启电源"); // "Switch power on" + LSTR MSG_SWITCH_PS_OFF = _UxGT("关闭电源"); // "Switch power off" LSTR MSG_EXTRUDE = _UxGT("挤出"); // "Extrude" LSTR MSG_RETRACT = _UxGT("回抽"); // "Retract" LSTR MSG_MOVE_AXIS = _UxGT("移动轴"); // "Move axis" @@ -225,7 +225,7 @@ namespace Language_zh_CN { LSTR MSG_MOVE_E = _UxGT("挤出机"); // "Extruder" LSTR MSG_MOVE_EN = _UxGT("挤出机 *"); // "Extruder" LSTR MSG_HOTEND_TOO_COLD = _UxGT("热端太冷"); - LSTR MSG_MOVE_N_MM = _UxGT("移动 %s mm"); // "Move 0.025mm" + LSTR MSG_MOVE_N_MM = _UxGT("移动 $ mm"); // "Move 0.025mm" 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" @@ -260,52 +260,44 @@ namespace Language_zh_CN { LSTR MSG_PID_AUTOTUNE = _UxGT("自动PID"); LSTR MSG_PID_AUTOTUNE_E = _UxGT("自动PID *"); LSTR MSG_PID_AUTOTUNE_DONE = _UxGT("PID调整完成"); - LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("自动调失败. 坏的挤出机"); - LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("自动调失败. 温度太高"); + 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" - LSTR MSG_VA_JERK = _UxGT("轴抖动速率") LCD_STR_A; // "Va-jerk" - LSTR MSG_VB_JERK = _UxGT("轴抖动速率") LCD_STR_B; // "Vb-jerk" - LSTR MSG_VC_JERK = _UxGT("轴抖动速率") LCD_STR_C; // "Vc-jerk" - LSTR MSG_VI_JERK = _UxGT("轴抖动速率") LCD_STR_I; // "Vi-jerk" - LSTR MSG_VJ_JERK = _UxGT("轴抖动速率") LCD_STR_J; // "Vj-jerk" - LSTR MSG_VK_JERK = _UxGT("轴抖动速率") LCD_STR_K; // "Vk-jerk" + LSTR MSG_VA_JERK = _UxGT("轴抖动速率") STR_A; // "Va-jerk" + LSTR MSG_VB_JERK = _UxGT("轴抖动速率") STR_B; // "Vb-jerk" + LSTR MSG_VC_JERK = _UxGT("轴抖动速率") STR_C; // "Vc-jerk" + LSTR MSG_VN_JERK = _UxGT("轴抖动速率@"); // "V@-jerk" LSTR MSG_VE_JERK = _UxGT("挤出机抖动速率"); // "Ve-jerk" LSTR MSG_JUNCTION_DEVIATION = _UxGT("接点差"); - LSTR MSG_VELOCITY = _UxGT("速度"); // "Velocity" - LSTR MSG_VMAX_A = _UxGT("最大进料速率") LCD_STR_A; // "Vmax " max_feedrate_mm_s - LSTR MSG_VMAX_B = _UxGT("最大进料速率") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("最大进料速率") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("最大进料速率") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("最大进料速率") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("最大进料速率") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("最大进料速率") LCD_STR_E; + LSTR MSG_MAX_SPEED = _UxGT("速度"); // "Velocity" + LSTR MSG_VMAX_A = _UxGT("最大进料速率") STR_A; // "Vmax " max_feedrate_mm_s + LSTR MSG_VMAX_B = _UxGT("最大进料速率") STR_B; + LSTR MSG_VMAX_C = _UxGT("最大进料速率") STR_C; + LSTR MSG_VMAX_N = _UxGT("最大进料速率@"); + LSTR MSG_VMAX_E = _UxGT("最大进料速率E"); LSTR MSG_VMAX_EN = _UxGT("最大进料速率 *"); LSTR MSG_VMIN = _UxGT("最小进料速率"); // "Vmin" min_feedrate_mm_s LSTR MSG_VTRAV_MIN = _UxGT("最小移动速率"); // "VTrav min" min_travel_feedrate_mm_s, (target) speed of the move LSTR MSG_ACCELERATION = _UxGT("加速度"); // "Acceleration" - LSTR MSG_AMAX_A = _UxGT("最大打印加速度") LCD_STR_A; // "Amax " max_acceleration_mm_per_s2, acceleration in units/s^2 for print moves - LSTR MSG_AMAX_B = _UxGT("最大打印加速度") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("最大打印加速度") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("最大打印加速度") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("最大打印加速度") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("最大打印加速度") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("最大打印加速度") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("最大打印加速度") STR_A; // "Amax " max_acceleration_mm_per_s2, acceleration in units/s^2 for print moves + LSTR MSG_AMAX_B = _UxGT("最大打印加速度") STR_B; + LSTR MSG_AMAX_C = _UxGT("最大打印加速度") STR_C; + LSTR MSG_AMAX_N = _UxGT("最大打印加速度@"); + LSTR MSG_AMAX_E = _UxGT("最大打印加速度E"); LSTR MSG_AMAX_EN = _UxGT("最大打印加速度 *"); LSTR MSG_A_RETRACT = _UxGT("收进加速度"); // "A-retract" retract_acceleration, E acceleration in mm/s^2 for retracts LSTR MSG_A_TRAVEL = _UxGT("非打印移动加速度"); // "A-travel" travel_acceleration, X, Y, Z acceleration in mm/s^2 for travel (non printing) moves LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("频率最大"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("进给速度"); LSTR MSG_STEPS_PER_MM = _UxGT("轴步数/mm"); // "Steps/mm" axis_steps_per_mm, axis steps-per-unit G92 - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" 步数/mm"); // "Asteps/mm" - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" 步数/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" 步数/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" 步数/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" 步数/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" 步数/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" 步数/mm"); // "Asteps/mm" + LSTR MSG_B_STEPS = STR_B _UxGT(" 步数/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" 步数/mm"); + LSTR MSG_N_STEPS = _UxGT("@ 步数/mm"); LSTR MSG_E_STEPS = _UxGT("E 步数/mm"); // "Esteps/mm" LSTR MSG_EN_STEPS = _UxGT("* 步数/mm"); LSTR MSG_TEMPERATURE = _UxGT("温度"); // "Temperature" @@ -489,7 +481,7 @@ namespace Language_zh_CN { LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("打印机不正确"); // "The printer is incorrect" - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("打印计数"); // "Print Count" LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("完成了"); // "Completed" LSTR MSG_INFO_PRINT_TIME = _UxGT("总打印时间"); // "Total print time" @@ -507,13 +499,7 @@ namespace Language_zh_CN { LSTR MSG_INFO_MAX_TEMP = _UxGT("最高温度"); // "Max Temp" LSTR MSG_INFO_PSU = _UxGT("电源供应"); // "Power Supply" LSTR MSG_DRIVE_STRENGTH = _UxGT("驱动力度"); // "Drive Strength" - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" 驱动 %"); // "X Driver %" - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" 驱动 %"); - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" 驱动 %"); - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" 驱动 %"); - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" 驱动 %"); - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" 驱动 %"); - LSTR MSG_DAC_PERCENT_E = _UxGT("E 驱动 %"); // "E Driver %" + LSTR MSG_DAC_PERCENT_N = _UxGT("@ 驱动 %"); // "E Driver %" LSTR MSG_ERROR_TMC = _UxGT("TMC 连接错误"); LSTR MSG_DAC_EEPROM_WRITE = _UxGT("保存驱动设置"); // "DAC EEPROM Write" LSTR MSG_FILAMENT_CHANGE_HEADER = _UxGT("更换料"); diff --git a/Marlin/src/lcd/language/language_zh_TW.h b/Marlin/src/lcd/language/language_zh_TW.h index 7680721b00e0..5f7c85c8383d 100644 --- a/Marlin/src/lcd/language/language_zh_TW.h +++ b/Marlin/src/lcd/language/language_zh_TW.h @@ -65,7 +65,6 @@ namespace Language_zh_TW { LSTR MSG_Z_FADE_HEIGHT = _UxGT("淡出高度"); // "Fade Height" LSTR MSG_SET_HOME_OFFSETS = _UxGT("設置原點偏移"); // "Set home offsets" LSTR MSG_HOME_OFFSETS_APPLIED = _UxGT("偏移已啟用"); // "Offsets applied" - LSTR MSG_SET_ORIGIN = _UxGT("設置原點"); // "Set origin" #if HAS_PREHEAT LSTR MSG_PREHEAT_1 = _UxGT("預熱 ") PREHEAT_1_LABEL; // "Preheat PREHEAT_1_LABEL" LSTR MSG_PREHEAT_1_H = _UxGT("預熱 ") PREHEAT_1_LABEL " ~"; // "Preheat PREHEAT_1_LABEL" @@ -222,7 +221,7 @@ namespace Language_zh_TW { LSTR MSG_MOVE_E = _UxGT("擠出機"); // "Extruder" LSTR MSG_MOVE_EN = _UxGT("擠出機 *"); // "Extruder *" LSTR MSG_HOTEND_TOO_COLD = _UxGT("噴嘴溫度不夠"); // "Hotend too cold" - LSTR MSG_MOVE_N_MM = _UxGT("移動 %s mm"); // "Move 0.025mm" + LSTR MSG_MOVE_N_MM = _UxGT("移動 $ mm"); // "Move 0.025mm" 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" @@ -252,43 +251,35 @@ namespace Language_zh_TW { LSTR MSG_SELECT_E = _UxGT("選擇 *"); LSTR MSG_ACC = _UxGT("加速度"); // "Accel" acceleration LSTR MSG_JERK = _UxGT("抖動速率"); // "Jerk" - LSTR MSG_VA_JERK = _UxGT("軸抖動速率") LCD_STR_A; // "Va-jerk" - LSTR MSG_VB_JERK = _UxGT("軸抖動速率") LCD_STR_B; - LSTR MSG_VC_JERK = _UxGT("軸抖動速率") LCD_STR_C; - LSTR MSG_VI_JERK = _UxGT("軸抖動速率") LCD_STR_I; - LSTR MSG_VJ_JERK = _UxGT("軸抖動速率") LCD_STR_J; - LSTR MSG_VK_JERK = _UxGT("軸抖動速率") LCD_STR_K; + LSTR MSG_VA_JERK = _UxGT("軸抖動速率") STR_A; // "Va-jerk" + LSTR MSG_VB_JERK = _UxGT("軸抖動速率") STR_B; + LSTR MSG_VC_JERK = _UxGT("軸抖動速率") STR_C; + LSTR MSG_VN_JERK = _UxGT("軸抖動速率@"); LSTR MSG_VE_JERK = _UxGT("擠出機抖動速率"); - LSTR MSG_VELOCITY = _UxGT("速度"); // "Velocity" - LSTR MSG_VMAX_A = _UxGT("最大進料速率") LCD_STR_A; // "Vmax " max_feedrate_mm_s - LSTR MSG_VMAX_B = _UxGT("最大進料速率") LCD_STR_B; - LSTR MSG_VMAX_C = _UxGT("最大進料速率") LCD_STR_C; - LSTR MSG_VMAX_I = _UxGT("最大進料速率") LCD_STR_I; - LSTR MSG_VMAX_J = _UxGT("最大進料速率") LCD_STR_J; - LSTR MSG_VMAX_K = _UxGT("最大進料速率") LCD_STR_K; - LSTR MSG_VMAX_E = _UxGT("最大進料速率") LCD_STR_E; + LSTR MSG_MAX_SPEED = _UxGT("速度"); // "Velocity" + LSTR MSG_VMAX_A = _UxGT("最大進料速率") STR_A; // "Vmax " max_feedrate_mm_s + LSTR MSG_VMAX_B = _UxGT("最大進料速率") STR_B; + LSTR MSG_VMAX_C = _UxGT("最大進料速率") STR_C; + LSTR MSG_VMAX_N = _UxGT("最大進料速率@"); + LSTR MSG_VMAX_E = _UxGT("最大進料速率E"); LSTR MSG_VMAX_EN = _UxGT("最大進料速率 *"); // "Vmax " max_feedrate_mm_s LSTR MSG_VMIN = _UxGT("最小進料速率"); // "Vmin" min_feedrate_mm_s LSTR MSG_VTRAV_MIN = _UxGT("最小移動速率"); // "VTrav min" min_travel_feedrate_mm_s, (target) speed of the move LSTR MSG_ACCELERATION = _UxGT("加速度"); // "Acceleration" - LSTR MSG_AMAX_A = _UxGT("最大列印加速度") LCD_STR_A; // "Amax " max_acceleration_mm_per_s2, acceleration in units/s^2 for print moves - LSTR MSG_AMAX_B = _UxGT("最大列印加速度") LCD_STR_B; - LSTR MSG_AMAX_C = _UxGT("最大列印加速度") LCD_STR_C; - LSTR MSG_AMAX_I = _UxGT("最大列印加速度") LCD_STR_I; - LSTR MSG_AMAX_J = _UxGT("最大列印加速度") LCD_STR_J; - LSTR MSG_AMAX_K = _UxGT("最大列印加速度") LCD_STR_K; - LSTR MSG_AMAX_E = _UxGT("最大列印加速度") LCD_STR_E; + LSTR MSG_AMAX_A = _UxGT("最大列印加速度") STR_A; // "Amax " max_acceleration_mm_per_s2, acceleration in units/s^2 for print moves + LSTR MSG_AMAX_B = _UxGT("最大列印加速度") STR_B; + LSTR MSG_AMAX_C = _UxGT("最大列印加速度") STR_C; + LSTR MSG_AMAX_N = _UxGT("最大列印加速度@"); + LSTR MSG_AMAX_E = _UxGT("最大列印加速度E"); LSTR MSG_AMAX_EN = _UxGT("最大列印加速度 *"); // "Amax " max_acceleration_mm_per_s2, acceleration in units/s^2 for print moves LSTR MSG_A_RETRACT = _UxGT("回縮加速度"); // "A-retract" retract_acceleration, E acceleration in mm/s^2 for retracts LSTR MSG_A_TRAVEL = _UxGT("非列印移動加速度"); // "A-travel" travel_acceleration, X, Y, Z acceleration in mm/s^2 for travel (non printing) moves LSTR MSG_STEPS_PER_MM = _UxGT("軸步數/mm"); // "Steps/mm" axis_steps_per_mm, axis steps-per-unit G92 - LSTR MSG_A_STEPS = LCD_STR_A _UxGT(" 軸步數/mm"); // "Asteps/mm" axis_steps_per_mm, axis steps-per-unit G92 - LSTR MSG_B_STEPS = LCD_STR_B _UxGT(" 軸步數/mm"); - LSTR MSG_C_STEPS = LCD_STR_C _UxGT(" 軸步數/mm"); - LSTR MSG_I_STEPS = LCD_STR_I _UxGT(" 軸步數/mm"); - LSTR MSG_J_STEPS = LCD_STR_J _UxGT(" 軸步數/mm"); - LSTR MSG_K_STEPS = LCD_STR_K _UxGT(" 軸步數/mm"); + LSTR MSG_A_STEPS = STR_A _UxGT(" 軸步數/mm"); // "Asteps/mm" axis_steps_per_mm, axis steps-per-unit G92 + LSTR MSG_B_STEPS = STR_B _UxGT(" 軸步數/mm"); + LSTR MSG_C_STEPS = STR_C _UxGT(" 軸步數/mm"); + LSTR MSG_N_STEPS = _UxGT("@ 軸步數/mm"); LSTR MSG_E_STEPS = _UxGT("擠出機步數/mm"); // "Esteps/mm" LSTR MSG_EN_STEPS = _UxGT("擠出機~步數/mm"); LSTR MSG_TEMPERATURE = _UxGT("溫度"); // "Temperature" @@ -437,7 +428,7 @@ namespace Language_zh_TW { LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("燈亮度"); // "Light BRIGHTNESS" LSTR MSG_KILL_EXPECTED_PRINTER = _UxGT("打印機不正確"); // "The printer is incorrect" - #if LCD_WIDTH >= 20 + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 LSTR MSG_INFO_PRINT_COUNT = _UxGT("列印計數"); // "Print Count" LSTR MSG_INFO_COMPLETED_PRINTS = _UxGT("已完成"); // "Completed" LSTR MSG_INFO_PRINT_TIME = _UxGT("總列印時間"); // "Total print time" @@ -455,13 +446,7 @@ namespace Language_zh_TW { LSTR MSG_INFO_MAX_TEMP = _UxGT("最高溫度"); // "Max Temp" LSTR MSG_INFO_PSU = _UxGT("電源供應"); // "Power Supply" LSTR MSG_DRIVE_STRENGTH = _UxGT("驅動力度"); // "Drive Strength" - LSTR MSG_DAC_PERCENT_A = LCD_STR_A _UxGT(" 驅動 %"); // X Driver % - LSTR MSG_DAC_PERCENT_B = LCD_STR_B _UxGT(" 驅動 %"); // Y Driver % - LSTR MSG_DAC_PERCENT_C = LCD_STR_C _UxGT(" 驅動 %"); // Z Driver % - LSTR MSG_DAC_PERCENT_I = LCD_STR_I _UxGT(" 驅動 %"); // I Driver % - LSTR MSG_DAC_PERCENT_J = LCD_STR_J _UxGT(" 驅動 %"); // J Driver % - LSTR MSG_DAC_PERCENT_K = LCD_STR_K _UxGT(" 驅動 %"); // K Driver % - LSTR MSG_DAC_PERCENT_E = _UxGT("E 驅動 %"); //E Driver % + LSTR MSG_DAC_PERCENT_N = _UxGT("@ 驅動 %"); //E Driver % LSTR MSG_ERROR_TMC = _UxGT("TMC連接錯誤"); // "TMC CONNECTION ERROR" LSTR MSG_DAC_EEPROM_WRITE = _UxGT("保存驅動設置"); // "DAC EEPROM Write" LSTR MSG_FILAMENT_CHANGE_HEADER = _UxGT("更換絲料"); // "FILAMENT CHANGE" diff --git a/Marlin/src/lcd/lcdprint.cpp b/Marlin/src/lcd/lcdprint.cpp index 498b478b1258..692181306993 100644 --- a/Marlin/src/lcd/lcdprint.cpp +++ b/Marlin/src/lcd/lcdprint.cpp @@ -26,25 +26,25 @@ #include "../inc/MarlinConfigPre.h" -#if HAS_WIRED_LCD && !HAS_GRAPHICAL_TFT && !IS_DWIN_MARLINUI +#if HAS_LCDPRINT #include "marlinui.h" #include "lcdprint.h" /** - * lcd_put_u8str_ind_P + * lcd_put_u8str_P * - * Print a string with an index substituted within it: + * Print a string with optional substitutions: * - * $ displays the clipped C-string given by the inStr argument + * $ displays the clipped string given by fstr or cstr * = displays '0'....'10' for indexes 0 - 10 * ~ displays '1'....'11' for indexes 0 - 10 * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) * @ displays an axis name such as XYZUVW, or E for an extruder */ -lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const inStr/*=nullptr*/, const lcd_uint_t maxlen/*=LCD_WIDTH*/) { +lcd_uint_t lcd_put_u8str_P(PGM_P const ptpl, const int8_t ind, const char *cstr/*=nullptr*/, FSTR_P const fstr/*=nullptr*/, const lcd_uint_t maxlen/*=LCD_WIDTH*/) { const uint8_t prop = USE_WIDE_GLYPH ? 2 : 1; - uint8_t *p = (uint8_t*)pstr; + const uint8_t *p = (uint8_t*)ptpl; int8_t n = maxlen; while (n > 0) { wchar_t ch; @@ -71,8 +71,11 @@ lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const i break; } } - else if (ch == '$' && inStr) { - n -= lcd_put_u8str_max_P(inStr, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH); + else if (ch == '$' && fstr) { + n -= lcd_put_u8str_max_P(FTOP(fstr), n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH); + } + else if (ch == '$' && cstr) { + n -= lcd_put_u8str_max(cstr, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH); } else if (ch == '@') { lcd_put_wchar(axis_codes[ind]); @@ -90,7 +93,7 @@ lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const i int calculateWidth(PGM_P const pstr) { if (!USE_WIDE_GLYPH) return utf8_strlen_P(pstr) * MENU_FONT_WIDTH; const uint8_t prop = 2; - uint8_t *p = (uint8_t*)pstr; + const uint8_t *p = (uint8_t*)pstr; int n = 0; do { @@ -103,4 +106,4 @@ int calculateWidth(PGM_P const pstr) { return n * MENU_FONT_WIDTH; } -#endif // HAS_WIRED_LCD +#endif // HAS_LCDPRINT diff --git a/Marlin/src/lcd/lcdprint.h b/Marlin/src/lcd/lcdprint.h index c701a59568f5..2eb47c534b05 100644 --- a/Marlin/src/lcd/lcdprint.h +++ b/Marlin/src/lcd/lcdprint.h @@ -130,80 +130,167 @@ int lcd_glyph_height(); -int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length); +/** + * @brief Draw a UTF-8 character + * + * @param utf8_str : the UTF-8 character + * @param max_length : the output width limit (in pixels on GLCD) + * + * @return the output width (in pixels on GLCD) + */ +int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length); /** - * @brief Draw a UTF-8 string + * @brief Draw a SRAM UTF-8 string * * @param utf8_str : the UTF-8 string - * @param max_length : the pixel length of the string allowed (or number of slots in HD44780) - * - * @return the pixel width + * @param max_length : the output width limit (in pixels on GLCD) * - * Draw a UTF-8 string + * @return the output width (in pixels on GLCD) */ -int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length); +int lcd_put_u8str_max(const char *utf8_str, const pixel_len_t max_length); /** - * Set the print baseline position + * Change the print cursor position */ void lcd_moveto(const lcd_uint_t col, const lcd_uint_t row); /** * @brief Draw a ROM UTF-8 string * - * @param utf8_pstr : the ROM UTF-8 string - * @param max_length : the pixel length of the string allowed (or number of slots in HD44780) - * - * @return the pixel width + * @param pstr : the ROM UTF-8 string + * @param max_length : the output width limit (in pixels on GLCD) * - * Draw a ROM UTF-8 string + * @return the output width (in pixels on GLCD) */ -int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length); -inline int lcd_put_u8str_max_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P utf8_pstr, pixel_len_t max_length) { +int lcd_put_u8str_max_P(PGM_P pstr, const pixel_len_t max_length); +inline int lcd_put_u8str_max_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P pstr, const pixel_len_t max_length) { lcd_moveto(col, row); - return lcd_put_u8str_max_P(utf8_pstr, max_length); + return lcd_put_u8str_max_P(pstr, max_length); } -inline int lcd_put_u8str_max(const lcd_uint_t col, const lcd_uint_t row, FSTR_P const utf8_fstr, pixel_len_t max_length) { - return lcd_put_u8str_max_P(col, row, FTOP(utf8_fstr), max_length); +inline int lcd_put_u8str_max(const lcd_uint_t col, const lcd_uint_t row, FSTR_P const fstr, const pixel_len_t max_length) { + return lcd_put_u8str_max_P(col, row, FTOP(fstr), max_length); } +/** + * @brief Draw an integer, left-justified + * + * @param i : the integer + */ void lcd_put_int(const int i); inline void lcd_put_int(const lcd_uint_t col, const lcd_uint_t row, const int i) { lcd_moveto(col, row); lcd_put_int(i); } +/** + * @brief Draw a ROM UTF-8 string + * + * @param i : the integer + */ inline int lcd_put_u8str_P(PGM_P const pstr) { return lcd_put_u8str_max_P(pstr, PIXEL_LEN_NOLIMIT); } inline int lcd_put_u8str_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P const pstr) { lcd_moveto(col, row); return lcd_put_u8str_P(pstr); } +/** + * @brief Draw a ROM UTF-8 F-string + * + * @param fstr The F-string pointer + * @return the output width (in pixels on GLCD) + */ inline int lcd_put_u8str(FSTR_P const fstr) { return lcd_put_u8str_P(FTOP(fstr)); } inline int lcd_put_u8str(const lcd_uint_t col, const lcd_uint_t row, FSTR_P const fstr) { return lcd_put_u8str_P(col, row, FTOP(fstr)); } -lcd_uint_t lcd_put_u8str_ind_P(PGM_P const pstr, const int8_t ind, PGM_P const inStr=nullptr, const lcd_uint_t maxlen=LCD_WIDTH); -inline lcd_uint_t lcd_put_u8str_ind_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P const pstr, const int8_t ind, PGM_P const inStr=nullptr, const lcd_uint_t maxlen=LCD_WIDTH) { +/** + * @brief Draw a string with optional substitution + * @details Print a string with optional substitutions: + * $ displays the clipped string given by fstr or cstr + * = displays '0'....'10' for indexes 0 - 10 + * ~ displays '1'....'11' for indexes 0 - 10 + * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) + * @ displays an axis name such as XYZUVW, or E for an extruder + * + * @param ptpl A ROM string (template) + * @param ind An index value to use for = ~ * substitution + * @param cstr An SRAM C-string to use for $ substitution + * @param fstr A ROM F-string to use for $ substitution + * @param maxlen The maximum size of the string (in pixels on GLCD) + * @return the output width (in pixels on GLCD) + */ +lcd_uint_t lcd_put_u8str_P(PGM_P const ptpl, const int8_t ind, const char *cstr=nullptr, FSTR_P const fstr=nullptr, const lcd_uint_t maxlen=LCD_WIDTH); +inline lcd_uint_t lcd_put_u8str_P(const lcd_uint_t col, const lcd_uint_t row, PGM_P const ptpl, const int8_t ind, const char *cstr=nullptr, FSTR_P const fstr=nullptr, const lcd_uint_t maxlen=LCD_WIDTH) { lcd_moveto(col, row); - return lcd_put_u8str_ind_P(pstr, ind, inStr, maxlen); + return lcd_put_u8str_P(ptpl, ind, cstr, fstr, maxlen); } -inline lcd_uint_t lcd_put_u8str_ind(const lcd_uint_t col, const lcd_uint_t row, FSTR_P const fstr, const int8_t ind, FSTR_P const inFstr=nullptr, const lcd_uint_t maxlen=LCD_WIDTH) { - return lcd_put_u8str_ind_P(col, row, FTOP(fstr), ind, FTOP(inFstr), maxlen); +/** + * @brief Draw a ROM UTF-8 F-string with optional substitution + * @details (See above) + * + * @param ftpl A ROM F-string (template) + * @param ind An index value to use for = ~ * substitution + * @param cstr An SRAM C-string to use for $ substitution + * @param fstr A ROM F-string to use for $ substitution + * @param maxlen The maximum size of the string (in pixels on GLCD) + * @return the output width (in pixels on GLCD) + */ +inline lcd_uint_t lcd_put_u8str(FSTR_P const ftpl, const int8_t ind, const char *cstr=nullptr, FSTR_P const fstr=nullptr, const lcd_uint_t maxlen=LCD_WIDTH) { + return lcd_put_u8str_P(FTOP(ftpl), ind, cstr, fstr, maxlen); +} +/** + * @param col + * @param row + */ +inline lcd_uint_t lcd_put_u8str(const lcd_uint_t col, const lcd_uint_t row, FSTR_P const ftpl, const int8_t ind, const char *cstr=nullptr, FSTR_P const fstr=nullptr, const lcd_uint_t maxlen=LCD_WIDTH) { + return lcd_put_u8str_P(col, row, FTOP(ftpl), ind, cstr, fstr, maxlen); } +/** + * @brief Draw a SRAM string with no width limit + * + * @param str The UTF-8 string + * @return the output width (in pixels on GLCD) + */ inline int lcd_put_u8str(const char * const str) { return lcd_put_u8str_max(str, PIXEL_LEN_NOLIMIT); } +/** + * @param col + * @param row + */ inline int lcd_put_u8str(const lcd_uint_t col, const lcd_uint_t row, const char * const str) { lcd_moveto(col, row); return lcd_put_u8str(str); } +/** + * @brief Draw a UTF-8 character with no width limit + * + * @param c The wchar 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); } +/** + * @param col + * @param row + */ inline int lcd_put_wchar(const lcd_uint_t col, const lcd_uint_t row, const wchar_t c) { lcd_moveto(col, row); return lcd_put_wchar(c); } +/** + * @brief Calculate the width of a ROM UTF-8 string (in pixels on GLCD) + * + * @param pstr The ROM-based UTF-8 string + * @return the string width (in pixels on GLCD) + */ int calculateWidth(PGM_P const pstr); +/** + * @brief Calculate the width of a ROM UTF-8 string (in pixels on GLCD) + * + * @param pstr The ROM-based UTF-8 string + * @return the string width (in pixels on GLCD) + */ +inline int calculateWidth(FSTR_P const fstr) { return calculateWidth(FTOP(fstr)); } diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 5cf3e668260b..d0c966303324 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -24,7 +24,7 @@ #include "../MarlinCore.h" // for printingIsPaused -#ifdef LED_BACKLIGHT_TIMEOUT +#if LED_POWEROFF_TIMEOUT > 0 || BOTH(HAS_WIRED_LCD, PRINTER_EVENT_LEDS) #include "../feature/leds/leds.h" #endif @@ -43,14 +43,12 @@ MarlinUI ui; #if HAS_DISPLAY #include "../gcode/queue.h" #include "fontutils.h" - #include "../sd/cardreader.h" #endif #if ENABLED(DWIN_CREALITY_LCD) #include "e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "fontutils.h" - #include "e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "e3v2/proui/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "e3v2/jyersui/dwin.h" #endif @@ -70,11 +68,15 @@ MarlinUI ui; constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if HAS_STATUS_MESSAGE - #if ENABLED(STATUS_MESSAGE_SCROLLING) && EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(STATUS_MESSAGE_SCROLLING) && EITHER(HAS_WIRED_LCD, DWIN_LCD_PROUI) uint8_t MarlinUI::status_scroll_offset; // = 0 #endif char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1]; uint8_t MarlinUI::alert_level; // = 0 + #if HAS_STATUS_MESSAGE_TIMEOUT + millis_t MarlinUI::status_message_expire_ms; // = 0 + #endif + statusResetFunc_t MarlinUI::status_reset_callback; // = nullptr #endif #if ENABLED(LCD_SET_PROGRESS_MANUALLY) @@ -97,8 +99,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif #if HAS_LCD_CONTRAST - uint8_t MarlinUI::contrast; // Initialized by settings.load() - + uint8_t MarlinUI::contrast = LCD_CONTRAST_DEFAULT; // Initialized by settings.load() void MarlinUI::set_contrast(const uint8_t value) { contrast = constrain(value, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX); _set_contrast(); @@ -106,7 +107,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif #if HAS_LCD_BRIGHTNESS - uint8_t MarlinUI::brightness = DEFAULT_LCD_BRIGHTNESS; + uint8_t MarlinUI::brightness = LCD_BRIGHTNESS_DEFAULT; bool MarlinUI::backlight = true; void MarlinUI::set_brightness(const uint8_t value) { @@ -117,19 +118,18 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif #if ENABLED(SOUND_MENU_ITEM) - bool MarlinUI::buzzer_enabled = true; + bool MarlinUI::sound_on = ENABLED(SOUND_ON_DEFAULT); #endif -#if EITHER(PCA9632_BUZZER, USE_BEEPER) - #include "../libs/buzzer.h" // for BUZZ() macro +#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 (!buzzer_enabled) return; + if (!sound_on) return; #if ENABLED(PCA9632_BUZZER) PCA9632_buzz(duration, freq); - #elif USE_BEEPER + #elif HAS_BEEPER buzzer.tone(duration, freq); #endif } @@ -140,24 +140,24 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; preheat_t MarlinUI::material_preset[PREHEAT_COUNT]; // Initialized by settings.load() - PGM_P MarlinUI::get_preheat_label(const uint8_t m) { + FSTR_P MarlinUI::get_preheat_label(const uint8_t m) { #define _PDEF(N) static PGMSTR(preheat_##N##_label, PREHEAT_##N##_LABEL); #define _PLBL(N) preheat_##N##_label, REPEAT_1(PREHEAT_COUNT, _PDEF); static PGM_P const preheat_labels[PREHEAT_COUNT] PROGMEM = { REPEAT_1(PREHEAT_COUNT, _PLBL) }; - return (PGM_P)pgm_read_ptr(&preheat_labels[m]); + return FPSTR((PGM_P)pgm_read_ptr(&preheat_labels[m])); } void MarlinUI::apply_preheat(const uint8_t m, const uint8_t pmask, const uint8_t e/*=active_extruder*/) { const preheat_t &pre = material_preset[m]; - TERN_(HAS_HOTEND, if (TEST(pmask, PM_HOTEND)) thermalManager.setTargetHotend(pre.hotend_temp, e)); - TERN_(HAS_HEATED_BED, if (TEST(pmask, PM_BED)) thermalManager.setTargetBed(pre.bed_temp)); - //TERN_(HAS_HEATED_CHAMBER, if (TEST(pmask, PM_CHAMBER)) thermalManager.setTargetBed(pre.chamber_temp)); - TERN_(HAS_FAN, if (TEST(pmask, PM_FAN)) thermalManager.set_fan_speed(0, pre.fan_speed)); + 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_FAN, if (TEST(pmask, PT_FAN)) thermalManager.set_fan_speed(0, pre.fan_speed)); } #endif -#if EITHER(HAS_LCD_MENU, EXTENSIBLE_UI) +#if EITHER(HAS_MARLINUI_MENU, EXTENSIBLE_UI) bool MarlinUI::lcd_clicked; #endif @@ -176,6 +176,97 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #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 + + uint16_t MarlinUI::lcd_backlight_timeout; // 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; + WRITE(LCD_BACKLIGHT_PIN, HIGH); + } + +#elif HAS_DISPLAY_SLEEP + + 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(); + } + +#endif + +void MarlinUI::init() { + + init_lcd(); + + #if HAS_DIGITAL_BUTTONS + #if BUTTON_EXISTS(EN1) + SET_INPUT_PULLUP(BTN_EN1); + #endif + #if BUTTON_EXISTS(EN2) + SET_INPUT_PULLUP(BTN_EN2); + #endif + #if BUTTON_EXISTS(ENC) + SET_INPUT_PULLUP(BTN_ENC); + #endif + #if BUTTON_EXISTS(ENC_EN) + SET_INPUT_PULLUP(BTN_ENC_EN); + #endif + #if BUTTON_EXISTS(BACK) + SET_INPUT_PULLUP(BTN_BACK); + #endif + #if BUTTON_EXISTS(UP) + SET_INPUT(BTN_UP); + #endif + #if BUTTON_EXISTS(DWN) + SET_INPUT(BTN_DWN); + #endif + #if BUTTON_EXISTS(LFT) + SET_INPUT(BTN_LFT); + #endif + #if BUTTON_EXISTS(RT) + SET_INPUT(BTN_RT); + #endif + #endif + + #if HAS_SHIFT_ENCODER + + #if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register + + SET_OUTPUT(SR_DATA_PIN); + SET_OUTPUT(SR_CLK_PIN); + + #elif PIN_EXISTS(SHIFT_CLK) + + SET_OUTPUT(SHIFT_CLK_PIN); + OUT_WRITE(SHIFT_LD_PIN, HIGH); + #if PIN_EXISTS(SHIFT_EN) + OUT_WRITE(SHIFT_EN_PIN, LOW); + #endif + SET_INPUT_PULLUP(SHIFT_OUT_PIN); + + #endif + + #endif // HAS_SHIFT_ENCODER + + #if BOTH(HAS_ENCODER_ACTION, HAS_SLOW_BUTTONS) + slow_buttons = 0; + #endif + + update_buttons(); + + TERN_(HAS_ENCODER_ACTION, encoderDiff = 0); + + reset_status(); // Set welcome message +} + #if HAS_WIRED_LCD #if HAS_MARLINUI_U8GLIB @@ -184,13 +275,11 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #include "lcdprint.h" - #include "../sd/cardreader.h" - #include "../module/temperature.h" #include "../module/planner.h" #include "../module/motion.h" - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU #include "../module/settings.h" #endif @@ -210,7 +299,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #include "../feature/power_monitor.h" #endif - #if ENABLED(PSU_CONTROL) && defined(LED_BACKLIGHT_TIMEOUT) + #if LED_POWEROFF_TIMEOUT > 0 #include "../feature/power.h" #endif @@ -244,18 +333,11 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if IS_DWIN_MARLINUI bool MarlinUI::did_first_redraw; - #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 + bool MarlinUI::old_is_printing; #endif #if ENABLED(SDSUPPORT) - #include "../sd/cardreader.h" - #if MARLINUI_SCROLL_NAME uint8_t MarlinUI::filename_scroll_pos, MarlinUI::filename_scroll_max; #endif @@ -288,7 +370,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU #include "menu/menu.h" screenFunc_t MarlinUI::currentScreen; // Initialized in CTOR @@ -334,10 +416,11 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; SETCURSOR(0, row); // Simulate carriage return }; - uint8_t *p = (uint8_t*)string; + const uint8_t *p = (uint8_t*)string; wchar_t ch; if (wordwrap) { - uint8_t *wrd = nullptr, c = 0; + 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 @@ -372,88 +455,25 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; } } - void MarlinUI::draw_select_screen_prompt(PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) { - const uint8_t plen = utf8_strlen_P(pref), slen = suff ? utf8_strlen_P(suff) : 0; + void MarlinUI::draw_select_screen_prompt(FSTR_P const pref, const char * const string/*=nullptr*/, FSTR_P const suff/*=nullptr*/) { + const uint8_t plen = utf8_strlen(pref), slen = suff ? utf8_strlen(suff) : 0; uint8_t col = 0, row = 0; if (!string && plen + slen <= LCD_WIDTH) { col = (LCD_WIDTH - plen - slen) / 2; row = LCD_HEIGHT > 3 ? 1 : 0; } if (LCD_HEIGHT >= 8) row = LCD_HEIGHT / 2 - 2; - wrap_string_P(col, row, pref, true); + wrap_string_P(col, row, FTOP(pref), true); if (string) { if (col) { col = 0; row++; } // Move to the start of the next line wrap_string(col, row, string); } - if (suff) wrap_string_P(col, row, suff); + if (suff) wrap_string_P(col, row, FTOP(suff)); } #endif // !HAS_GRAPHICAL_TFT - #endif // HAS_LCD_MENU - - void MarlinUI::init() { - - init_lcd(); - - #if HAS_DIGITAL_BUTTONS - #if BUTTON_EXISTS(EN1) - SET_INPUT_PULLUP(BTN_EN1); - #endif - #if BUTTON_EXISTS(EN2) - SET_INPUT_PULLUP(BTN_EN2); - #endif - #if BUTTON_EXISTS(ENC) - SET_INPUT_PULLUP(BTN_ENC); - #endif - #if BUTTON_EXISTS(ENC_EN) - SET_INPUT_PULLUP(BTN_ENC_EN); - #endif - #if BUTTON_EXISTS(BACK) - SET_INPUT_PULLUP(BTN_BACK); - #endif - #if BUTTON_EXISTS(UP) - SET_INPUT(BTN_UP); - #endif - #if BUTTON_EXISTS(DWN) - SET_INPUT(BTN_DWN); - #endif - #if BUTTON_EXISTS(LFT) - SET_INPUT(BTN_LFT); - #endif - #if BUTTON_EXISTS(RT) - SET_INPUT(BTN_RT); - #endif - #endif - - #if HAS_SHIFT_ENCODER - - #if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register - - SET_OUTPUT(SR_DATA_PIN); - SET_OUTPUT(SR_CLK_PIN); - - #elif PIN_EXISTS(SHIFT_CLK) - - SET_OUTPUT(SHIFT_CLK_PIN); - OUT_WRITE(SHIFT_LD_PIN, HIGH); - #if PIN_EXISTS(SHIFT_EN) - OUT_WRITE(SHIFT_EN_PIN, LOW); - #endif - SET_INPUT_PULLUP(SHIFT_OUT_PIN); - - #endif - - #endif // HAS_SHIFT_ENCODER - - #if BOTH(HAS_ENCODER_ACTION, HAS_SLOW_BUTTONS) - slow_buttons = 0; - #endif - - update_buttons(); - - TERN_(HAS_ENCODER_ACTION, encoderDiff = 0); - } + #endif // HAS_MARLINUI_MENU //////////////////////////////////////////// ///////////// Keypad Handling ////////////// @@ -463,19 +483,19 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; volatile uint8_t MarlinUI::keypad_buttons; - #if HAS_LCD_MENU && !HAS_ADC_BUTTONS - - void lcd_move_x(); - void lcd_move_y(); - void lcd_move_z(); + #if HAS_MARLINUI_MENU && !HAS_ADC_BUTTONS void _reprapworld_keypad_move(const AxisEnum axis, const int16_t dir) { ui.manual_move.menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP; ui.encoderPosition = dir; switch (axis) { - case X_AXIS: lcd_move_x(); break; - case Y_AXIS: lcd_move_y(); break; - case Z_AXIS: lcd_move_z(); + 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 default: break; } } @@ -490,7 +510,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; if (keypad_buttons) { #if HAS_ENCODER_ACTION refresh(LCDVIEW_REDRAW_NOW); - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU if (encoderDirection == -(ENCODERBASE)) { // HAS_ADC_BUTTONS forces REVERSE_MENU_DIRECTION, so this indicates menu navigation if (RRK(EN_KEYPAD_UP)) encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; else if (RRK(EN_KEYPAD_DOWN)) encoderPosition -= ENCODER_STEPS_PER_MENU_ITEM; @@ -500,7 +520,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; else #endif { - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU if (RRK(EN_KEYPAD_UP)) encoderPosition -= epps; else if (RRK(EN_KEYPAD_DOWN)) encoderPosition += epps; else if (RRK(EN_KEYPAD_LEFT)) { MenuItem_back::action(); quick_feedback(); } @@ -531,7 +551,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; const bool homed = all_axes_homed(); - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU if (RRK(EN_KEYPAD_MIDDLE)) goto_screen(menu_move); @@ -550,7 +570,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; if (RRK(EN_KEYPAD_UP)) _reprapworld_keypad_move(Y_AXIS, -1); } - #endif // HAS_LCD_MENU + #endif // HAS_MARLINUI_MENU if (!homed && RRK(EN_KEYPAD_F1)) queue.inject_P(G28_STR); return true; @@ -578,7 +598,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; void MarlinUI::status_screen() { - TERN_(HAS_LCD_MENU, ENCODER_RATE_MULTIPLY(false)); + TERN_(HAS_MARLINUI_MENU, ENCODER_RATE_MULTIPLY(false)); #if BASIC_PROGRESS_BAR @@ -588,7 +608,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; // share the same line on the display. // - #if DISABLED(PROGRESS_MSG_ONCE) || (PROGRESS_MSG_EXPIRE > 0) + #if DISABLED(PROGRESS_MSG_ONCE) || PROGRESS_MSG_EXPIRE > 0 #define GOT_MS const millis_t ms = millis(); #endif @@ -622,15 +642,25 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif // BASIC_PROGRESS_BAR - #if HAS_LCD_MENU + bool did_expire = status_reset_callback && (*status_reset_callback)(); + + #if HAS_STATUS_MESSAGE_TIMEOUT + #ifndef GOT_MS + #define GOT_MS + const millis_t ms = millis(); + #endif + did_expire |= status_message_expire_ms && ELAPSED(ms, status_message_expire_ms); + #endif + + if (did_expire) reset_status(); + + #if HAS_MARLINUI_MENU if (use_click()) { #if BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) next_filament_display = millis() + 5000UL; // Show status message for 5s #endif goto_screen(menu_main); - #if DISABLED(NO_LCD_REINIT) - init_lcd(); // May revive the LCD if static electricity killed it - #endif + reinit_lcd(); // Revive a noisy shared SPI LCD return; } @@ -664,7 +694,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; const millis_t ms = millis(); #endif if (ELAPSED(ms, next_beep)) { - buzz(FEEDRATE_CHANGE_BEEP_DURATION, FEEDRATE_CHANGE_BEEP_FREQUENCY); + BUZZ(FEEDRATE_CHANGE_BEEP_DURATION, FEEDRATE_CHANGE_BEEP_FREQUENCY); next_beep = ms + 500UL; } #endif @@ -678,10 +708,10 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; void MarlinUI::kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component) { init(); status_printf(1, F(S_FMT ": " S_FMT), FTOP(lcd_error), FTOP(lcd_component)); - TERN_(HAS_LCD_MENU, return_to_status()); + TERN_(HAS_MARLINUI_MENU, return_to_status()); // RED ALERT. RED ALERT. - #ifdef LED_BACKLIGHT_TIMEOUT + #if ENABLED(PRINTER_EVENT_LEDS) leds.set_color(LEDColorRed()); #ifdef NEOPIXEL_BKGD_INDEX_FIRST neo.set_background_color(255, 0, 0, 0); @@ -706,10 +736,11 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); // Wake up the TFT with most buttons - TERN_(HAS_LCD_MENU, refresh()); + TERN_(HAS_MARLINUI_MENU, refresh()); #if HAS_ENCODER_ACTION - if (clear_buttons) buttons = 0; + if (clear_buttons) + TERN_(HAS_ADC_BUTTONS, keypad_buttons =) buttons = 0; next_button_update_ms = millis() + 500; #else UNUSED(clear_buttons); @@ -717,9 +748,9 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if HAS_CHIRP chirp(); // Buzz and wait. Is the delay needed for buttons to settle? - #if BOTH(HAS_LCD_MENU, USE_BEEPER) + #if BOTH(HAS_MARLINUI_MENU, HAS_BEEPER) for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); } - #elif HAS_LCD_MENU + #elif HAS_MARLINUI_MENU delay(10); #endif #endif @@ -729,7 +760,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; /////////////// Manual Move //////////////// //////////////////////////////////////////// - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU ManualMove MarlinUI::manual_move{}; @@ -771,7 +802,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; // Add a manual move to the queue? if (axis != NO_AXIS_ENUM && ELAPSED(millis(), start_time) && !planner.is_full()) { - const feedRate_t fr_mm_s = (axis <= LOGICAL_AXES) ? manual_feedrate_mm_s[axis] : XY_PROBE_FEEDRATE_MM_S; + const feedRate_t fr_mm_s = (axis < LOGICAL_AXES) ? manual_feedrate_mm_s[axis] : XY_PROBE_FEEDRATE_MM_S; #if IS_KINEMATIC @@ -833,7 +864,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; void MarlinUI::external_encoder() { if (external_control && encoderDiff) { - ubl.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. } @@ -841,7 +872,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif - #endif // HAS_LCD_MENU + #endif // HAS_MARLINUI_MENU /** * Update the LCD, read encoder buttons, etc. @@ -888,11 +919,11 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; static uint16_t max_display_update_time = 0; millis_t ms = millis(); - #if ENABLED(PSU_CONTROL) && defined(LED_BACKLIGHT_TIMEOUT) + #if LED_POWEROFF_TIMEOUT > 0 leds.update_timeout(powerManager.psu_on); #endif - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU // Handle any queued Move Axis motion manual_move.task(); @@ -947,7 +978,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; goto_previous_screen(); } - #endif // HAS_LCD_MENU + #endif // HAS_MARLINUI_MENU if (ELAPSED(ms, next_lcd_update_ms) || TERN0(HAS_MARLINUI_U8GLIB, drawing_screen)) { @@ -994,7 +1025,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; if (encoderPastThreshold || lcd_clicked) { if (encoderPastThreshold && TERN1(IS_TFTGLCD_PANEL, !external_control)) { - #if BOTH(HAS_LCD_MENU, ENCODER_RATE_MULTIPLIER) + #if BOTH(HAS_MARLINUI_MENU, ENCODER_RATE_MULTIPLIER) int32_t encoderMultiplier = 1; @@ -1037,14 +1068,20 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; reset_status_timeout(ms); + #if LCD_BACKLIGHT_TIMEOUT + refresh_backlight_timeout(); + #elif HAS_DISPLAY_SLEEP + refresh_screen_timeout(); + #endif + refresh(LCDVIEW_REDRAW_NOW); - #if ENABLED(PSU_CONTROL) && defined(LED_BACKLIGHT_TIMEOUT) + #if LED_POWEROFF_TIMEOUT > 0 if (!powerManager.psu_on) leds.reset_timeout(ms); #endif - } + } // encoder activity - #endif + #endif // HAS_ENCODER_ACTION // This runs every ~100ms when idling often enough. // Instead of tracking changes just redraw the Status Screen once per second. @@ -1054,7 +1091,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; refresh(LCDVIEW_REDRAW_NOW); } - #if BOTH(HAS_LCD_MENU, SCROLL_LONG_FILENAMES) + #if BOTH(HAS_MARLINUI_MENU, SCROLL_LONG_FILENAMES) // If scrolling of long file names is enabled and we are in the sd card menu, // cause a refresh to occur until all the text has scrolled into view. if (currentScreen == menu_media && !lcd_status_update_delay--) { @@ -1125,7 +1162,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif - TERN_(HAS_LCD_MENU, lcd_clicked = false); + TERN_(HAS_MARLINUI_MENU, lcd_clicked = false); // Keeping track of the longest time for an individual LCD update. // Used to do screen throttling when the planner starts to fill up. @@ -1141,6 +1178,16 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; return_to_status(); #endif + #if LCD_BACKLIGHT_TIMEOUT + 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(); + #endif + // Change state of drawing flag between screen updates if (!drawing_screen) switch (lcdDrawUpdate) { case LCDVIEW_CLEAR_CALL_REDRAW: @@ -1161,7 +1208,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if HAS_ADC_BUTTONS typedef struct { - uint16_t ADCKeyValueMin, ADCKeyValueMax; + raw_adc_t ADCKeyValueMin, ADCKeyValueMax; uint8_t ADCKeyNo; } _stADCKeypadTable_; @@ -1188,10 +1235,10 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif // Calculate the ADC value for the voltage divider with specified pull-down resistor value - #define ADC_BUTTON_VALUE(r) int(HAL_ADC_RANGE * (ADC_BUTTONS_VALUE_SCALE) * r / (r + ADC_BUTTONS_R_PULLUP)) + #define ADC_BUTTON_VALUE(r) raw_adc_t(HAL_ADC_RANGE * (ADC_BUTTONS_VALUE_SCALE) * r / (r + ADC_BUTTONS_R_PULLUP)) - static constexpr uint16_t adc_button_tolerance = HAL_ADC_RANGE * 25 / 1024, - adc_other_button = HAL_ADC_RANGE * 1000 / 1024; + static constexpr raw_adc_t adc_button_tolerance = HAL_ADC_RANGE * 25 / 1024, + adc_other_button = raw_adc_t(uint32_t(HAL_ADC_RANGE * 1000UL) / 1024UL); static const _stADCKeypadTable_ stADCKeyTable[] PROGMEM = { // VALUE_MIN, VALUE_MAX, KEY { adc_other_button, HAL_ADC_RANGE, 1 + BLEN_KEYPAD_F1 }, // F1 @@ -1211,13 +1258,13 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; uint8_t get_ADC_keyValue() { if (thermalManager.ADCKey_count >= 16) { - const uint16_t currentkpADCValue = thermalManager.current_ADCKey_raw; + const raw_adc_t currentkpADCValue = thermalManager.current_ADCKey_raw; thermalManager.current_ADCKey_raw = HAL_ADC_RANGE; thermalManager.ADCKey_count = 0; if (currentkpADCValue < adc_other_button) LOOP_L_N(i, ADC_KEY_NUM) { - const uint16_t lo = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMin), - hi = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMax); + const raw_adc_t lo = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMin), + hi = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMax); if (WITHIN(currentkpADCValue, lo, hi)) return pgm_read_byte(&stADCKeyTable[i].ADCKeyNo); } } @@ -1339,7 +1386,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; 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; } - #if BOTH(HAS_LCD_MENU, AUTO_BED_LEVELING_UBL) + #if BOTH(HAS_MARLINUI_MENU, AUTO_BED_LEVELING_UBL) external_encoder(); #endif lastEncoderBits = enc; @@ -1367,7 +1414,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; void MarlinUI::set_status(const char * const cstr, const bool persist) { if (alert_level) return; - TERN_(HOST_PROMPT_SUPPORT, hostui.notify(cstr)); + TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(cstr)); // Here we have a problem. The message is encoded in UTF8, so // arbitrarily cutting it will be a problem. We MUST be sure @@ -1405,6 +1452,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if SERVICE_INTERVAL_3 > 0 static PGMSTR(service3, "> " SERVICE_NAME_3 "!"); #endif + FSTR_P msg; if (printingIsPaused()) msg = GET_TEXT_F(MSG_PRINT_PAUSED); @@ -1425,21 +1473,28 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; else if (print_job_timer.needsService(3)) msg = FPSTR(service3); #endif - else if (!no_welcome) - msg = GET_TEXT_F(WELCOME_MSG); + else if (!no_welcome) msg = GET_TEXT_F(WELCOME_MSG); + + else if (ENABLED(DWIN_LCD_PROUI)) + msg = F(""); else return; set_status(msg, -1); } + /** + * Set Status with a fixed string and alert level. + * @param fstr A constant F-string to set as the status. + * @param level Alert level. Negative to ignore and reset the level. Non-zero never expires. + */ void MarlinUI::set_status(FSTR_P const fstr, int8_t level) { - PGM_P const pstr = FTOP(fstr); + // Alerts block lower priority messages if (level < 0) level = alert_level = 0; if (level < alert_level) return; alert_level = level; - TERN_(HOST_PROMPT_SUPPORT, hostui.notify(fstr)); + PGM_P const pstr = FTOP(fstr); // Since the message is encoded in UTF8 it must // only be cut on a character boundary. @@ -1459,24 +1514,32 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; strncpy_P(status_message, pstr, maxLen); status_message[maxLen] = '\0'; + TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(fstr)); + finish_status(level > 0); } void MarlinUI::set_alert_status(FSTR_P const fstr) { set_status(fstr, 1); TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); - TERN_(HAS_LCD_MENU, return_to_status()); + TERN_(HAS_MARLINUI_MENU, return_to_status()); } #include - void MarlinUI::status_printf(const uint8_t level, FSTR_P const fmt, ...) { + void MarlinUI::status_printf(int8_t level, FSTR_P const fmt, ...) { + // Alerts block lower priority messages + if (level < 0) level = alert_level = 0; if (level < alert_level) return; alert_level = level; + va_list args; va_start(args, FTOP(fmt)); vsnprintf_P(status_message, MAX_MESSAGE_LENGTH, FTOP(fmt), args); va_end(args); + + TERN_(HOST_STATUS_NOTIFICATIONS, hostui.notify(status_message)); + finish_status(level > 0); } @@ -1484,6 +1547,10 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; UNUSED(persist); + set_status_reset_fn(); + + TERN_(HAS_STATUS_MESSAGE_TIMEOUT, status_message_expire_ms = persist ? 0 : millis() + (STATUS_MESSAGE_TIMEOUT_SEC) * 1000UL); + #if HAS_WIRED_LCD #if BASIC_PROGRESS_BAR || BOTH(FILAMENT_LCD_DISPLAY, SDSUPPORT) @@ -1503,13 +1570,13 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif - #if ENABLED(STATUS_MESSAGE_SCROLLING) && EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(STATUS_MESSAGE_SCROLLING) && EITHER(HAS_WIRED_LCD, DWIN_LCD_PROUI) status_scroll_offset = 0; #endif TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged(status_message)); TERN_(DWIN_CREALITY_LCD, DWIN_StatusChanged(status_message)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_CheckStatusMessage()); + TERN_(DWIN_LCD_PROUI, DWIN_CheckStatusMessage()); TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWIN.Update_Status(status_message)); } @@ -1531,7 +1598,22 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif -#endif +#else // !HAS_STATUS_MESSAGE + + // + // Send the status line as a host notification + // + void MarlinUI::set_status(const char * const cstr, const bool) { + TERN(HOST_PROMPT_SUPPORT, hostui.notify(cstr), UNUSED(cstr)); + } + void MarlinUI::set_status(FSTR_P const fstr, const int8_t) { + TERN(HOST_PROMPT_SUPPORT, hostui.notify(fstr), UNUSED(fstr)); + } + void MarlinUI::status_printf(int8_t, FSTR_P const fstr, ...) { + TERN(HOST_PROMPT_SUPPORT, hostui.notify(fstr), UNUSED(fstr)); + } + +#endif // !HAS_STATUS_MESSAGE #if HAS_DISPLAY @@ -1550,25 +1632,27 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; IF_DISABLED(SDSUPPORT, 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_LCD_MENU, return_to_status()); + TERN_(HAS_MARLINUI_MENU, return_to_status()); } - #if BOTH(PSU_CONTROL, PS_OFF_CONFIRM) + #if BOTH(HAS_MARLINUI_MENU, PSU_CONTROL) + void MarlinUI::poweroff() { - queue.inject(F("M81")); - goto_previous_screen(); + queue.inject(F("M81" TERN_(POWER_OFF_WAIT_FOR_COOLDOWN, "S"))); + return_to_status(); } + #endif void MarlinUI::flow_fault() { LCD_ALERTMESSAGE(MSG_FLOWMETER_FAULT); - TERN_(HAS_BUZZER, buzz(1000, 440)); - TERN_(HAS_LCD_MENU, return_to_status()); + BUZZ(1000, 440); + TERN_(HAS_MARLINUI_MENU, return_to_status()); } void MarlinUI::pause_print() { - #if HAS_LCD_MENU - synchronize(GET_TEXT(MSG_PAUSING)); + #if HAS_MARLINUI_MENU + synchronize(GET_TEXT_F(MSG_PAUSING)); defer_status_screen(); #endif @@ -1641,22 +1725,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif -#elif !HAS_STATUS_MESSAGE // && !HAS_DISPLAY - - // - // Send the status line as a host notification - // - void MarlinUI::set_status(const char * const cstr, const bool) { - TERN(HOST_PROMPT_SUPPORT, hostui.notify(cstr), UNUSED(cstr)); - } - void MarlinUI::set_status(FSTR_P const fstr, const int8_t) { - TERN(HOST_PROMPT_SUPPORT, hostui.notify(fstr), UNUSED(fstr)); - } - void MarlinUI::status_printf(const uint8_t, FSTR_P const fstr, ...) { - TERN(HOST_PROMPT_SUPPORT, hostui.notify(fstr), UNUSED(fstr)); - } - -#endif // !HAS_DISPLAY && !HAS_STATUS_MESSAGE +#endif // HAS_DISPLAY #if ENABLED(SDSUPPORT) @@ -1687,35 +1756,33 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; if (old_status < 2) { #if ENABLED(EXTENSIBLE_UI) ExtUI::onMediaRemoved(); - #elif PIN_EXISTS(SD_DETECT) + #elif HAS_SD_DETECT LCD_MESSAGE(MSG_MEDIA_REMOVED); - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU if (!defer_return_to_status) return_to_status(); #endif #endif } } - #if PIN_EXISTS(SD_DETECT) && DISABLED(NO_LCD_REINIT) - init_lcd(); // Revive a noisy shared SPI LCD - #endif + reinit_lcd(); // Revive a noisy shared SPI LCD refresh(); - #if HAS_WIRED_LCD || defined(LED_BACKLIGHT_TIMEOUT) + #if HAS_WIRED_LCD || LED_POWEROFF_TIMEOUT > 0 const millis_t ms = millis(); #endif TERN_(HAS_WIRED_LCD, next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL); // Delay LCD update for SD activity - #ifdef LED_BACKLIGHT_TIMEOUT + #if LED_POWEROFF_TIMEOUT > 0 leds.reset_timeout(ms); #endif } #endif // SDSUPPORT -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU void MarlinUI::reset_settings() { settings.reset(); completion_feedback(); @@ -1771,7 +1838,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if ENABLED(EEPROM_SETTINGS) - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU void MarlinUI::init_eeprom() { const bool good = settings.init_eeprom(); completion_feedback(good); @@ -1789,30 +1856,30 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #if DISABLED(EEPROM_AUTO_INIT) - static inline PGM_P eeprom_err(const uint8_t msgid) { + static inline FSTR_P eeprom_err(const uint8_t msgid) { switch (msgid) { default: - case 0: return GET_TEXT(MSG_ERR_EEPROM_CRC); - case 1: return GET_TEXT(MSG_ERR_EEPROM_INDEX); - case 2: return GET_TEXT(MSG_ERR_EEPROM_VERSION); + 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); } } void MarlinUI::eeprom_alert(const uint8_t msgid) { - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU editable.uint8 = msgid; goto_screen([]{ - PGM_P const restore_msg = GET_TEXT(MSG_INIT_EEPROM); - char msg[utf8_strlen_P(restore_msg) + 1]; - strcpy_P(msg, restore_msg); + FSTR_P const restore_msg = GET_TEXT_F(MSG_INIT_EEPROM); + char msg[utf8_strlen(restore_msg) + 1]; + strcpy_P(msg, FTOP(restore_msg)); MenuItem_confirm::select_screen( - GET_TEXT(MSG_BUTTON_RESET), GET_TEXT(MSG_BUTTON_IGNORE), + GET_TEXT_F(MSG_BUTTON_RESET), GET_TEXT_F(MSG_BUTTON_IGNORE), init_eeprom, return_to_status, - eeprom_err(editable.uint8), msg, PSTR("?") + eeprom_err(editable.uint8), msg, F("?") ); }); #else - set_status(FPSTR(eeprom_err(msgid))); + set_status(eeprom_err(msgid)); #endif } diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 7014040097c4..66e5e0c26181 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -21,31 +21,21 @@ */ #pragma once -#include "../module/motion.h" -#include "buttons.h" - #include "../inc/MarlinConfig.h" +#include "../sd/cardreader.h" +#include "../module/motion.h" +#include "../libs/buzzer.h" -#if HAS_BUZZER - #include "../libs/buzzer.h" -#endif - -#if ENABLED(SDSUPPORT) - #include "../sd/cardreader.h" -#endif +#include "buttons.h" #if ENABLED(TOUCH_SCREEN_CALIBRATION) #include "tft_io/touch_calibration.h" #endif -#if ANY(HAS_LCD_MENU, ULTIPANEL_FEEDMULTIPLY, SOFT_RESET_ON_KILL) +#if ANY(HAS_MARLINUI_MENU, ULTIPANEL_FEEDMULTIPLY, SOFT_RESET_ON_KILL) #define HAS_ENCODER_ACTION 1 #endif -#if HAS_STATUS_MESSAGE - #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U) -#endif - #if E_MANUAL > 1 #define MULTI_E_MANUAL 1 #endif @@ -54,18 +44,20 @@ #include "../module/printcounter.h" #endif -#if ENABLED(ADVANCED_PAUSE_FEATURE) && ANY(HAS_LCD_MENU, EXTENSIBLE_UI, HAS_DWIN_E3V2) +#if ENABLED(ADVANCED_PAUSE_FEATURE) #include "../feature/pause.h" #endif #if ENABLED(DWIN_CREALITY_LCD) #include "e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "e3v2/proui/dwin.h" #endif #define START_OF_UTF8_CHAR(C) (((C) & 0xC0u) != 0x80U) +typedef bool (*statusResetFunc_t)(); + #if HAS_WIRED_LCD enum LCDViewAction : uint8_t { @@ -80,7 +72,7 @@ uint8_t get_ADC_keyValue(); #endif - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU #include "lcdprint.h" @@ -93,7 +85,7 @@ typedef void (*screenFunc_t)(); typedef void (*menuAction_t)(); - #endif // HAS_LCD_MENU + #endif // HAS_MARLINUI_MENU #endif // HAS_WIRED_LCD @@ -129,7 +121,7 @@ } preheat_t; #endif -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU // Manual Movement class class ManualMove { @@ -197,13 +189,32 @@ //////////// MarlinUI Singleton //////////// //////////////////////////////////////////// +class MarlinUI; +extern MarlinUI ui; + class MarlinUI { public: MarlinUI() { - TERN_(HAS_LCD_MENU, currentScreen = status_screen); + TERN_(HAS_MARLINUI_MENU, currentScreen = status_screen); } + static void init(); + + #if HAS_DISPLAY || HAS_DWIN_E3V2 + static void init_lcd(); + #else + static void init_lcd() {} + #endif + + static void reinit_lcd() { TERN_(REINIT_NOISY_LCD, init_lcd()); } + + #if HAS_WIRED_LCD + static bool detected(); + #else + static bool detected() { return true; } + #endif + #if HAS_MULTI_LANGUAGE static uint8_t language; static void set_language(const uint8_t lang); @@ -214,9 +225,9 @@ class MarlinUI { #endif #if ENABLED(SOUND_MENU_ITEM) - static bool buzzer_enabled; // Initialized by settings.load() + static bool sound_on; // Initialized by settings.load() #else - static constexpr bool buzzer_enabled = true; + static constexpr bool sound_on = true; #endif #if HAS_BUZZER @@ -224,7 +235,7 @@ class MarlinUI { #endif FORCE_INLINE static void chirp() { - TERN_(HAS_CHIRP, buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ)); + TERN_(HAS_CHIRP, TERN(HAS_BUZZER, buzz, BUZZ)(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ)); } #if ENABLED(LCD_HAS_STATUS_INDICATORS) @@ -234,7 +245,7 @@ class MarlinUI { // LCD implementations static void clear_lcd(); - #if BOTH(HAS_LCD_MENU, TOUCH_SCREEN_CALIBRATION) + #if BOTH(HAS_MARLINUI_MENU, TOUCH_SCREEN_CALIBRATION) static void check_touch_calibration() { if (touch_calibration.need_calibration()) currentScreen = touch_calibration_screen; } @@ -252,8 +263,8 @@ class MarlinUI { #ifndef LCD_BRIGHTNESS_MAX #define LCD_BRIGHTNESS_MAX 255 #endif - #ifndef DEFAULT_LCD_BRIGHTNESS - #define DEFAULT_LCD_BRIGHTNESS LCD_BRIGHTNESS_MAX + #ifndef LCD_BRIGHTNESS_DEFAULT + #define LCD_BRIGHTNESS_DEFAULT LCD_BRIGHTNESS_MAX #endif static uint8_t brightness; static bool backlight; @@ -262,6 +273,22 @@ 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; + 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 uint8_t sleep_timeout_minutes; + static millis_t screen_timeout_millis; + static void refresh_screen_timeout(); + static void sleep_on(); + static void sleep_off(); + #endif + #if HAS_DWIN_E3V2_BASIC static void refresh(); #else @@ -270,14 +297,6 @@ class MarlinUI { } #endif - #if HAS_WIRED_LCD - static bool detected(); - static void init_lcd(); - #else - static inline bool detected() { return true; } - static inline void init_lcd() {} - #endif - #if HAS_PRINT_PROGRESS #if HAS_PRINT_PROGRESS_PERMYRIAD typedef uint16_t progress_t; @@ -293,20 +312,20 @@ class MarlinUI { 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); } - #if ENABLED(SHOW_REMAINING_TIME) - static inline 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) - 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(); } - FORCE_INLINE static void reset_remaining_time() { set_remaining_time(0); } - #else - FORCE_INLINE static uint32_t get_remaining_time() { return _calculated_remaining_time(); } - #endif + #endif + #if ENABLED(SHOW_REMAINING_TIME) + 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) + 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(); } + FORCE_INLINE static void reset_remaining_time() { set_remaining_time(0); } + #else + FORCE_INLINE static uint32_t get_remaining_time() { return _calculated_remaining_time(); } #endif #endif static progress_t _get_progress(); @@ -320,7 +339,7 @@ class MarlinUI { #if HAS_STATUS_MESSAGE - #if EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_ENHANCED) + #if EITHER(HAS_WIRED_LCD, DWIN_LCD_PROUI) #if ENABLED(STATUS_MESSAGE_SCROLLING) #define MAX_MESSAGE_LENGTH _MAX(LONG_FILENAME_LENGTH, MAX_LANG_CHARSIZE * 2 * (LCD_WIDTH)) #else @@ -333,6 +352,10 @@ class MarlinUI { static char status_message[]; static uint8_t alert_level; // Higher levels block lower levels + #if HAS_STATUS_MESSAGE_TIMEOUT + static millis_t status_message_expire_ms; // Reset some status messages after a timeout + #endif + #if ENABLED(STATUS_MESSAGE_SCROLLING) static uint8_t status_scroll_offset; static void advance_status_scroll(); @@ -342,30 +365,24 @@ class MarlinUI { static bool has_status(); static void reset_status(const bool no_welcome=false); static void set_alert_status(FSTR_P const fstr); - static inline void reset_alert_level() { alert_level = 0; } + static void reset_alert_level() { alert_level = 0; } + + static statusResetFunc_t status_reset_callback; + static void set_status_reset_fn(const statusResetFunc_t fn=nullptr) { status_reset_callback = fn; } #else static constexpr bool has_status() { return false; } - static inline void reset_status(const bool=false) {} - static inline void set_alert_status(FSTR_P const) {} - static inline void reset_alert_level() {} + static void reset_status(const bool=false) {} + static void set_alert_status(FSTR_P const) {} + static void reset_alert_level() {} + static void set_status_reset_fn(const statusResetFunc_t=nullptr) {} #endif static void set_status(const char * const cstr, const bool persist=false); static void set_status(FSTR_P const fstr, const int8_t level=0); - static void status_printf(const uint8_t level, FSTR_P const fmt, ...); - - #if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED) - static void kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component); - #if DISABLED(LIGHTWEIGHT_UI) - static void draw_status_message(const bool blink); - #endif - #else - static inline void kill_screen(FSTR_P const, FSTR_P const) {} - #endif + static void status_printf(int8_t level, FSTR_P const fmt, ...); #if HAS_DISPLAY - static void init(); static void update(); static void abort_print(); @@ -373,7 +390,7 @@ class MarlinUI { static void resume_print(); static void flow_fault(); - #if BOTH(PSU_CONTROL, PS_OFF_CONFIRM) + #if BOTH(HAS_MARLINUI_MENU, PSU_CONTROL) static void poweroff(); #endif @@ -444,7 +461,7 @@ class MarlinUI { #if HAS_BUZZER static void completion_feedback(const bool good=true); #else - static inline void completion_feedback(const bool=true) { TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); } + static void completion_feedback(const bool=true) { TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); } #endif #if ENABLED(ADVANCED_PAUSE_FEATURE) @@ -468,6 +485,7 @@ 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) @@ -476,17 +494,21 @@ class MarlinUI { #endif static void draw_kill_screen(); + static void kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component); + #if DISABLED(LIGHTWEIGHT_UI) + static void draw_status_message(const bool blink); + #endif #else // No LCD - static inline void init() {} - static inline void update() {} - static inline void return_to_status() {} + static void update() {} + static void return_to_status() {} + static void kill_screen(FSTR_P const, FSTR_P const) {} #endif #if ENABLED(SDSUPPORT) - #if BOTH(SCROLL_LONG_FILENAMES, HAS_LCD_MENU) + #if BOTH(SCROLL_LONG_FILENAMES, HAS_MARLINUI_MENU) #define MARLINUI_SCROLL_NAME 1 #endif #if MARLINUI_SCROLL_NAME @@ -496,24 +518,22 @@ class MarlinUI { #endif #if HAS_PREHEAT - enum PreheatMask : uint8_t { PM_HOTEND = _BV(0), PM_BED = _BV(1), PM_FAN = _BV(2), PM_CHAMBER = _BV(3) }; + enum PreheatTarget : uint8_t { PT_HOTEND, PT_BED, PT_FAN, PT_CHAMBER, PT_ALL = 0xFF }; static preheat_t material_preset[PREHEAT_COUNT]; - static PGM_P get_preheat_label(const uint8_t m); + static FSTR_P get_preheat_label(const uint8_t m); static void apply_preheat(const uint8_t m, const uint8_t pmask, const uint8_t e=active_extruder); - static inline void preheat_set_fan(const uint8_t m) { TERN_(HAS_FAN, apply_preheat(m, PM_FAN)); } - static inline void preheat_hotend(const uint8_t m, const uint8_t e=active_extruder) { TERN_(HAS_HOTEND, apply_preheat(m, PM_HOTEND)); } - static inline void preheat_hotend_and_fan(const uint8_t m, const uint8_t e=active_extruder) { preheat_hotend(m, e); preheat_set_fan(m); } - static inline void preheat_bed(const uint8_t m) { TERN_(HAS_HEATED_BED, apply_preheat(m, PM_BED)); } - static inline void preheat_all(const uint8_t m) { apply_preheat(m, 0xFF); } + static void preheat_set_fan(const uint8_t m) { TERN_(HAS_FAN, apply_preheat(m, _BV(PT_FAN))); } + static void preheat_hotend(const uint8_t m, const uint8_t e=active_extruder) { TERN_(HAS_HOTEND, apply_preheat(m, _BV(PT_HOTEND))); } + static void preheat_hotend_and_fan(const uint8_t m, const uint8_t e=active_extruder) { preheat_hotend(m, e); preheat_set_fan(m); } + static void preheat_bed(const uint8_t m) { TERN_(HAS_HEATED_BED, apply_preheat(m, _BV(PT_BED))); } + static void preheat_all(const uint8_t m) { apply_preheat(m, PT_ALL); } #endif - #if SCREENS_CAN_TIME_OUT - static inline void reset_status_timeout(const millis_t ms) { return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS; } - #else - static inline void reset_status_timeout(const millis_t) {} - #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)); + } - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU #if HAS_TOUCH_BUTTONS static uint8_t touch_buttons; @@ -539,7 +559,7 @@ class MarlinUI { static void set_selection(const bool sel) { selection = sel; } static bool update_selection(); - static void synchronize(PGM_P const msg=nullptr); + static void synchronize(FSTR_P const msg=nullptr); static screenFunc_t currentScreen; static bool screen_changed; @@ -548,11 +568,11 @@ class MarlinUI { // goto_previous_screen and go_back may also be used as menu item callbacks static void _goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back)); - static inline void goto_previous_screen() { _goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, false)); } - static inline void go_back() { _goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, true)); } + static void goto_previous_screen() { _goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, false)); } + static void go_back() { _goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, true)); } static void return_to_status(); - static inline bool on_status_screen() { return currentScreen == status_screen; } + static bool on_status_screen() { return currentScreen == status_screen; } FORCE_INLINE static void run_current_screen() { (*currentScreen)(); } #if ENABLED(LIGHTWEIGHT_UI) @@ -567,7 +587,7 @@ class MarlinUI { TERN(SCREENS_CAN_TIME_OUT, defer_return_to_status = defer, UNUSED(defer)); } - static inline void goto_previous_screen_no_defer() { + static void goto_previous_screen_no_defer() { defer_status_screen(false); goto_previous_screen(); } @@ -585,7 +605,7 @@ class MarlinUI { static float ubl_mesh_value(); #endif - static void draw_select_screen_prompt(PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr); + static void draw_select_screen_prompt(FSTR_P const pref, const char * const string=nullptr, FSTR_P const suff=nullptr); #else @@ -597,43 +617,43 @@ class MarlinUI { #endif - #if EITHER(HAS_LCD_MENU, EXTENSIBLE_UI) + #if EITHER(HAS_MARLINUI_MENU, EXTENSIBLE_UI) static bool lcd_clicked; - static inline bool use_click() { + static bool use_click() { const bool click = lcd_clicked; lcd_clicked = false; return click; } #else static constexpr bool lcd_clicked = false; - static inline bool use_click() { return false; } + static bool use_click() { return false; } #endif - #if ENABLED(ADVANCED_PAUSE_FEATURE) && ANY(HAS_LCD_MENU, EXTENSIBLE_UI, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI) + #if ENABLED(ADVANCED_PAUSE_FEATURE) && ANY(HAS_MARLINUI_MENU, EXTENSIBLE_UI, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) static void pause_show_message(const PauseMessage message, const PauseMode mode=PAUSE_MODE_SAME, const uint8_t extruder=active_extruder); #else - static inline void _pause_show_message() {} + static void _pause_show_message() {} #define pause_show_message(...) _pause_show_message() #endif // // EEPROM: Reset / Init / Load / Store // - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU static void reset_settings(); #endif #if ENABLED(EEPROM_SETTINGS) - #if HAS_LCD_MENU + #if HAS_MARLINUI_MENU static void init_eeprom(); static void load_settings(); static void store_settings(); #endif #if DISABLED(EEPROM_AUTO_INIT) static void eeprom_alert(const uint8_t msgid); - static inline void eeprom_alert_crc() { eeprom_alert(0); } - static inline void eeprom_alert_index() { eeprom_alert(1); } - static inline void eeprom_alert_version() { eeprom_alert(2); } + 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 #endif @@ -650,7 +670,7 @@ class MarlinUI { // // Block interaction while under external control // - #if HAS_LCD_MENU && EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION) + #if HAS_MARLINUI_MENU && EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION) static bool external_control; FORCE_INLINE static void capture() { external_control = true; } FORCE_INLINE static void release() { external_control = false; } @@ -674,7 +694,29 @@ class MarlinUI { #endif static void update_buttons(); - static inline bool button_pressed() { return BUTTON_CLICK() || TERN(TOUCH_SCREEN, touch_pressed(), false); } + + #if HAS_ENCODER_NOISE + #ifndef ENCODER_SAMPLES + #define ENCODER_SAMPLES 10 + #endif + + /** + * 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 + * causing it to erroneously register as if someone clicked the button and in worst case make the + * printer unusable in practice. + */ + static bool hw_button_pressed() { + LOOP_L_N(s, ENCODER_SAMPLES) { + if (!BUTTON_CLICK()) return false; + safe_delay(1); + } + return true; + } + #else + static bool hw_button_pressed() { return BUTTON_CLICK(); } + #endif + #if EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION) static void wait_for_release(); #endif @@ -705,10 +747,13 @@ class MarlinUI { #else - static inline void update_buttons() {} + static void update_buttons() {} + static bool hw_button_pressed() { return false; } #endif + static bool button_pressed() { return hw_button_pressed() || TERN0(TOUCH_SCREEN, touch_pressed()); } + #if ENABLED(TOUCH_SCREEN_CALIBRATION) static void touch_calibration_screen(); #endif @@ -741,8 +786,6 @@ class MarlinUI { #endif }; -extern MarlinUI ui; - #define LCD_MESSAGE_F(S) ui.set_status(F(S)) #define LCD_MESSAGE(M) ui.set_status(GET_TEXT_F(M)) #define LCD_ALERTMESSAGE_F(S) ui.set_alert_status(F(S)) diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index 9337cf4774ff..a1e2beaf72d0 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -22,12 +22,13 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "menu.h" #include "../../module/planner.h" #include "../../module/motion.h" #include "../../module/printcounter.h" +#include "../../module/temperature.h" #include "../../gcode/queue.h" #if HAS_BUZZER @@ -46,7 +47,7 @@ ///////////// Global Variables ///////////// //////////////////////////////////////////// -#if HAS_LEVELING && ANY(LEVEL_BED_CORNERS, PROBE_OFFSET_WIZARD, X_AXIS_TWIST_COMPENSATION) +#if HAS_LEVELING && ANY(LCD_BED_TRAMMING, PROBE_OFFSET_WIZARD, X_AXIS_TWIST_COMPENSATION) bool leveling_was_active; // = false #endif #if ANY(PROBE_MANUALLY, MESH_BED_LEVELING, X_AXIS_TWIST_COMPENSATION) @@ -67,12 +68,13 @@ typedef struct { menuPosition screen_history[6]; uint8_t screen_history_depth = 0; -int8_t MenuItemBase::itemIndex; // Index number for draw and action -PGM_P MenuItemBase::itemString; // A PSTR for substitution -chimera_t editable; // Value Editing +int8_t MenuItemBase::itemIndex; // Index number for draw and action +FSTR_P MenuItemBase::itemStringF; // A string for substitution +const char *MenuItemBase::itemStringC; +chimera_t editable; // Value Editing // Menu Edit Items -PGM_P MenuEditItemBase::editLabel; +FSTR_P MenuEditItemBase::editLabel; void* MenuEditItemBase::editValue; int32_t MenuEditItemBase::minEditValue, MenuEditItemBase::maxEditValue; @@ -133,7 +135,7 @@ void MenuEditItemBase::edit_screen(strfunc_t strfunc, loadfunc_t loadfunc) { // Going to an edit screen sets up some persistent values first void MenuEditItemBase::goto_edit_screen( - PGM_P const el, // Edit label + FSTR_P const el, // Edit label void * const ev, // Edit value pointer const int32_t minv, // Encoder minimum const int32_t maxv, // Encoder maximum @@ -162,15 +164,12 @@ void MenuEditItemBase::goto_edit_screen( #include "../../MarlinCore.h" -bool printer_busy() { - return planner.movesplanned() || printingIsActive(); -} - /** * General function to go directly to a screen */ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, const uint8_t top/*=0*/, const uint8_t items/*=0*/) { if (currentScreen != screen) { + thermalManager.set_menu_cold_override(false); TERN_(IS_DWIN_MARLINUI, did_first_redraw = false); @@ -205,14 +204,14 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co if (on_status_screen()) { defer_status_screen(false); clear_menu_history(); - TERN_(AUTO_BED_LEVELING_UBL, ubl.lcd_map_control = false); + TERN_(AUTO_BED_LEVELING_UBL, bedlevel.lcd_map_control = false); } clear_lcd(); // Re-initialize custom characters that may be re-used #if HAS_MARLINUI_HD44780 - if (TERN1(AUTO_BED_LEVELING_UBL, !ubl.lcd_map_control)) + if (TERN1(AUTO_BED_LEVELING_UBL, !bedlevel.lcd_map_control)) set_custom_characters(on_status_screen() ? CHARSET_INFO : CHARSET_MENU); #endif @@ -220,7 +219,7 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co screen_changed = true; TERN_(HAS_MARLINUI_U8GLIB, drawing_screen = false); - TERN_(HAS_LCD_MENU, encoder_direction_normal()); + TERN_(HAS_MARLINUI_MENU, encoder_direction_normal()); set_selection(false); } @@ -234,8 +233,8 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co // Display a "synchronize" screen with a custom message until // all moves are finished. Go back to calling screen when done. // -void MarlinUI::synchronize(PGM_P const msg/*=nullptr*/) { - static PGM_P sync_message = msg ?: GET_TEXT(MSG_MOVING); +void MarlinUI::synchronize(FSTR_P const fmsg/*=nullptr*/) { + static FSTR_P sync_message = fmsg ?: GET_TEXT_F(MSG_MOVING); push_current_screen(); goto_screen([]{ if (should_draw()) MenuItem_static::draw(LCD_HEIGHT >= 4, sync_message); @@ -276,11 +275,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) { #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) { - BUZZ(100, 659); - BUZZ(100, 698); - } - else BUZZ(20, 440); + if (good) OKAY_BUZZ(); else ERR_BUZZ(); } #endif @@ -325,12 +320,12 @@ void scroll_screen(const uint8_t limit, const bool is_menu) { } if (ui.should_draw()) { if (do_probe) { - MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_ZPROBE_ZOFFSET), BABYSTEP_TO_STR(probe.offset.z)); + MenuEditItemBase::draw_edit_screen(GET_TEXT_F(MSG_ZPROBE_ZOFFSET), BABYSTEP_TO_STR(probe.offset.z)); TERN_(BABYSTEP_ZPROBE_GFX_OVERLAY, ui.zoffset_overlay(probe.offset.z)); } else { #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET) - MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_HOTEND_OFFSET_Z), ftostr54sign(hotend_offset[active_extruder].z)); + MenuEditItemBase::draw_edit_screen(GET_TEXT_F(MSG_HOTEND_OFFSET_Z), ftostr54sign(hotend_offset[active_extruder].z)); #endif } } @@ -341,7 +336,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) { void _lcd_draw_homing() { if (ui.should_draw()) { constexpr uint8_t line = (LCD_HEIGHT - 1) / 2; - MenuItem_static::draw(line, GET_TEXT(MSG_LEVEL_BED_HOMING)); + MenuItem_static::draw(line, GET_TEXT_F(MSG_LEVEL_BED_HOMING)); } } @@ -363,12 +358,13 @@ bool MarlinUI::update_selection() { } void MenuItem_confirm::select_screen( - PGM_P const yes, PGM_P const no, + FSTR_P const yes, FSTR_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, - PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/ + FSTR_P const pref, const char * const string/*=nullptr*/, FSTR_P const suff/*=nullptr*/ ) { ui.defer_status_screen(); - const bool ui_selection = ui.update_selection(), got_click = ui.use_click(); + const bool ui_selection = !yes ? false : !no || ui.update_selection(), + got_click = ui.use_click(); if (got_click || ui.should_draw()) { draw_select_screen(yes, no, ui_selection, pref, string, suff); if (got_click) { @@ -378,4 +374,4 @@ void MenuItem_confirm::select_screen( } } -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index 048dab9b7315..3e88f68690a6 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -30,7 +30,6 @@ extern int8_t encoderLine, encoderTopLine, screen_items; void scroll_screen(const uint8_t limit, const bool is_menu); -bool printer_busy(); typedef void (*selectFunc_t)(); @@ -54,73 +53,75 @@ class MenuItemBase { // Index to interject in the item label and/or for use by its action. static int8_t itemIndex; - // An optional pointer for use in display or by the action - static PGM_P itemString; + // Optional pointers for use in display or by the action + static FSTR_P itemStringF; + static const char* itemStringC; - // Store the index of the item ahead of use by indexed items - FORCE_INLINE static void init(const int8_t ind=0, PGM_P const pstr=nullptr) { itemIndex = ind; itemString = pstr; } + // Store an index and string for later substitution + FORCE_INLINE static void init(const int8_t ind=0, FSTR_P const fstr=nullptr) { itemIndex = ind; itemStringF = fstr; itemStringC = nullptr; } + FORCE_INLINE static void init(const int8_t ind, const char * const cstr) { itemIndex = ind; itemStringC = cstr; itemStringF = nullptr; } // Implementation-specific: // Draw an item either selected (pre_char) or not (space) with post_char - // Menus may set up itemIndex, itemString and pass them to string-building or string-emitting functions - static void _draw(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char); + // Menus may set up itemIndex, itemStringC/F and pass them to string-building or string-emitting functions + static void _draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char pre_char, const char post_char); // Draw an item either selected ('>') or not (space) with post_char - FORCE_INLINE static void _draw(const bool sel, const uint8_t row, PGM_P const pstr, const char post_char) { - _draw(sel, row, pstr, '>', post_char); + FORCE_INLINE static void _draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char post_char) { + _draw(sel, row, fstr, '>', post_char); } }; // STATIC_ITEM(LABEL,...) class MenuItem_static : public MenuItemBase { public: - static void draw(const uint8_t row, PGM_P const pstr, const uint8_t style=SS_DEFAULT, const char * const vstr=nullptr); + static void draw(const uint8_t row, FSTR_P const fstr, const uint8_t style=SS_DEFAULT, const char * const vstr=nullptr); }; // BACK_ITEM(LABEL) class MenuItem_back : public MenuItemBase { public: - FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr) { - _draw(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]); + FORCE_INLINE static void draw(const bool sel, const uint8_t row, FSTR_P const fstr) { + _draw(sel, row, fstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]); } // Back Item action goes back one step in history - FORCE_INLINE static void action(PGM_P const=nullptr) { ui.go_back(); } + FORCE_INLINE static void action(FSTR_P const=nullptr) { ui.go_back(); } }; // CONFIRM_ITEM(LABEL,Y,N,FY,FN,...), // YESNO_ITEM(LABEL,FY,FN,...) class MenuItem_confirm : public MenuItemBase { public: - FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) { - _draw(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]); + FORCE_INLINE static void draw(const bool sel, const uint8_t row, FSTR_P const ftpl, ...) { + _draw(sel, row, ftpl, '>', LCD_STR_ARROW_RIGHT[0]); } // Implemented for HD44780 and DOGM // Draw the prompt, buttons, and state static void draw_select_screen( - PGM_P const yes, // Right option label - PGM_P const no, // Left option label + FSTR_P const yes, // Right option label + FSTR_P const no, // Left option label const bool yesno, // Is "yes" selected? - PGM_P const pref, // Prompt prefix + FSTR_P const pref, // Prompt prefix const char * const string, // Prompt runtime string - PGM_P const suff // Prompt suffix + FSTR_P const suff // Prompt suffix ); static void select_screen( - PGM_P const yes, PGM_P const no, + FSTR_P const yes, FSTR_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, - PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr + FSTR_P const pref, const char * const string=nullptr, FSTR_P const suff=nullptr ); - static inline void select_screen( - PGM_P const yes, PGM_P const no, + static void select_screen( + FSTR_P const yes, FSTR_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, - PGM_P const pref, FSTR_P const string, PGM_P const suff=nullptr + FSTR_P const pref, FSTR_P const string, FSTR_P const suff=nullptr ) { - char str[strlen_P((PGM_P)string) + 1]; - strcpy_P(str, (PGM_P)string); + char str[strlen_P(FTOP(string)) + 1]; + strcpy_P(str, FTOP(string)); select_screen(yes, no, yesFunc, noFunc, pref, str, suff); } // Shortcut for prompt with "NO"/ "YES" labels - FORCE_INLINE static void confirm_screen(selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr) { - select_screen(GET_TEXT(MSG_YES), GET_TEXT(MSG_NO), yesFunc, noFunc, pref, string, suff); + FORCE_INLINE static void confirm_screen(selectFunc_t yesFunc, selectFunc_t noFunc, FSTR_P const pref, const char * const string=nullptr, FSTR_P const suff=nullptr) { + select_screen(GET_TEXT_F(MSG_YES), GET_TEXT_F(MSG_NO), yesFunc, noFunc, pref, string, suff); } }; @@ -149,7 +150,7 @@ class MenuEditItemBase : public MenuItemBase { // The action() method acts like the instantiator. The entire lifespan // of a menu item is within its declaration, so all these values decompose // into behavior and unused items get optimized out. - static PGM_P editLabel; + static FSTR_P editLabel; static void *editValue; static int32_t minEditValue, maxEditValue; // Encoder value range static screenFunc_t callbackFunc; @@ -158,7 +159,7 @@ class MenuEditItemBase : public MenuItemBase { typedef const char* (*strfunc_t)(const int32_t); typedef void (*loadfunc_t)(void *, const int32_t); static void goto_edit_screen( - PGM_P const el, // Edit label + FSTR_P const el, // Edit label void * const ev, // Edit value pointer const int32_t minv, // Encoder minimum const int32_t maxv, // Encoder maximum @@ -171,14 +172,18 @@ class MenuEditItemBase : public MenuItemBase { public: // Implementation-specific: // Draw the current item at specified row with edit data - static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const char * const inStr, const bool pgm=false); + static void draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char * const inStr, const bool pgm=false); + + static void draw(const bool sel, const uint8_t row, FSTR_P const ftpl, FSTR_P const fstr) { + draw(sel, row, ftpl, FTOP(fstr), true); + } // Implementation-specific: // This low-level method is good to draw from anywhere - static void draw_edit_screen(PGM_P const pstr, const char * const value); + static void draw_edit_screen(FSTR_P const fstr, const char * const value); // This method is for the current menu item - static inline void draw_edit_screen(const char * const value) { draw_edit_screen(editLabel, value); } + static void draw_edit_screen(const char * const value) { draw_edit_screen(editLabel, value); } }; #if ENABLED(SDSUPPORT) @@ -186,7 +191,7 @@ class MenuEditItemBase : public MenuItemBase { class MenuItem_sdbase { public: // Implemented for HD44780 and DOGM - static void draw(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir); + static void draw(const bool sel, const uint8_t row, FSTR_P const fstr, CardReader &theCard, const bool isDir); }; #endif @@ -208,7 +213,7 @@ void menu_move(); void lcd_move_z(); void _lcd_draw_homing(); -#define HAS_LINE_TO_Z ANY(DELTA, PROBE_MANUALLY, MESH_BED_LEVELING, LEVEL_BED_CORNERS) +#define HAS_LINE_TO_Z ANY(DELTA, PROBE_MANUALLY, MESH_BED_LEVELING, LCD_BED_TRAMMING) #if HAS_LINE_TO_Z void line_to_z(const_float_t z); @@ -255,7 +260,7 @@ inline void clear_menu_history() { screen_history_depth = 0; } #define STICKY_SCREEN(S) []{ ui.defer_status_screen(); ui.goto_screen(S); } -#if HAS_LEVELING && ANY(LEVEL_BED_CORNERS, PROBE_OFFSET_WIZARD, X_AXIS_TWIST_COMPENSATION) +#if HAS_LEVELING && ANY(LCD_BED_TRAMMING, PROBE_OFFSET_WIZARD, X_AXIS_TWIST_COMPENSATION) extern bool leveling_was_active; #endif diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index a5b4455d6f6d..517feea3e6e4 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -26,9 +26,10 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "menu_item.h" +#include "../../MarlinCore.h" #include "../../module/planner.h" #if DISABLED(NO_VOLUMETRICS) @@ -39,7 +40,7 @@ #include "../../module/probe.h" #endif -#if ENABLED(PIDTEMP) +#if ANY(PIDTEMP, PIDTEMPBED, PIDTEMPCHAMBER) #include "../../module/temperature.h" #endif @@ -67,8 +68,10 @@ void menu_backlash(); LOOP_LOGICAL_AXES(i) driverPercent[i] = stepper_dac.get_current_percent((AxisEnum)i); START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); - #define EDIT_DAC_PERCENT(A) EDIT_ITEM(uint8, MSG_DAC_PERCENT_##A, &driverPercent[_AXIS(A)], 0, 100, []{ stepper_dac.set_current_percents(driverPercent); }) - LOGICAL_AXIS_CODE(EDIT_DAC_PERCENT(E), EDIT_DAC_PERCENT(A), EDIT_DAC_PERCENT(B), EDIT_DAC_PERCENT(C), EDIT_DAC_PERCENT(I), EDIT_DAC_PERCENT(J), EDIT_DAC_PERCENT(K)); + + LOOP_LOGICAL_AXES(a) + EDIT_ITEM_N(uint8, a, MSG_DAC_PERCENT_N, &driverPercent[a], 0, 100, []{ stepper_dac.set_current_percents(driverPercent); }); + ACTION_ITEM(MSG_DAC_EEPROM_WRITE, stepper_dac.commit_eeprom); END_MENU(); } @@ -82,12 +85,12 @@ void menu_backlash(); void menu_pwm() { START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); - #define EDIT_CURRENT_PWM(LABEL,I) EDIT_ITEM_P(long5, PSTR(LABEL), &stepper.motor_current_setting[I], 100, 2000, stepper.refresh_motor_power) + #define EDIT_CURRENT_PWM(LABEL,I) EDIT_ITEM_F(long5, F(LABEL), &stepper.motor_current_setting[I], 100, 2000, stepper.refresh_motor_power) #if ANY_PIN(MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y) - EDIT_CURRENT_PWM(STR_X STR_Y, 0); + EDIT_CURRENT_PWM(STR_A STR_B, 0); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) - EDIT_CURRENT_PWM(STR_Z, 1); + EDIT_CURRENT_PWM(STR_C, 1); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) EDIT_CURRENT_PWM(STR_E, 2); @@ -109,8 +112,8 @@ void menu_backlash(); #if EXTRUDERS == 1 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10); #elif HAS_MULTI_EXTRUDER - LOOP_L_N(n, EXTRUDERS) - EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 10); + EXTRUDER_LOOP() + EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10); #endif #endif @@ -120,16 +123,16 @@ void menu_backlash(); #if ENABLED(VOLUMETRIC_EXTRUDER_LIMIT) EDIT_ITEM_FAST(float42_52, MSG_VOLUMETRIC_LIMIT, &planner.volumetric_extruder_limit[active_extruder], 0.0f, 20.0f, planner.calculate_volumetric_extruder_limits); #if HAS_MULTI_EXTRUDER - LOOP_L_N(n, EXTRUDERS) - EDIT_ITEM_FAST_N(float42_52, n, MSG_VOLUMETRIC_LIMIT_E, &planner.volumetric_extruder_limit[n], 0.0f, 20.00f, planner.calculate_volumetric_extruder_limits); + EXTRUDER_LOOP() + EDIT_ITEM_FAST_N(float42_52, e, MSG_VOLUMETRIC_LIMIT_E, &planner.volumetric_extruder_limit[e], 0.0f, 20.00f, planner.calculate_volumetric_extruder_limits); #endif #endif if (parser.volumetric_enabled) { EDIT_ITEM_FAST(float43, MSG_FILAMENT_DIAM, &planner.filament_size[active_extruder], 1.5f, 3.25f, planner.calculate_volumetric_multipliers); #if HAS_MULTI_EXTRUDER - LOOP_L_N(n, EXTRUDERS) - EDIT_ITEM_FAST_N(float43, n, MSG_FILAMENT_DIAM_E, &planner.filament_size[n], 1.5f, 3.25f, planner.calculate_volumetric_multipliers); + EXTRUDER_LOOP() + EDIT_ITEM_FAST_N(float43, e, MSG_FILAMENT_DIAM_E, &planner.filament_size[e], 1.5f, 3.25f, planner.calculate_volumetric_multipliers); #endif } #endif @@ -139,14 +142,14 @@ void menu_backlash(); EDIT_ITEM_FAST(float4, MSG_FILAMENT_UNLOAD, &fc_settings[active_extruder].unload_length, 0, extrude_maxlength); #if HAS_MULTI_EXTRUDER - LOOP_L_N(n, EXTRUDERS) - EDIT_ITEM_FAST_N(float4, n, MSG_FILAMENTUNLOAD_E, &fc_settings[n].unload_length, 0, extrude_maxlength); + EXTRUDER_LOOP() + EDIT_ITEM_FAST_N(float4, e, MSG_FILAMENTUNLOAD_E, &fc_settings[e].unload_length, 0, extrude_maxlength); #endif EDIT_ITEM_FAST(float4, MSG_FILAMENT_LOAD, &fc_settings[active_extruder].load_length, 0, extrude_maxlength); #if HAS_MULTI_EXTRUDER - LOOP_L_N(n, EXTRUDERS) - EDIT_ITEM_FAST_N(float4, n, MSG_FILAMENTLOAD_E, &fc_settings[n].load_length, 0, extrude_maxlength); + EXTRUDER_LOOP() + EDIT_ITEM_FAST_N(float4, e, MSG_FILAMENTLOAD_E, &fc_settings[e].load_length, 0, extrude_maxlength); #endif #endif @@ -190,7 +193,12 @@ void menu_backlash(); #if ENABLED(PIDTEMPCHAMBER) case H_CHAMBER: tune_temp = autotune_temp_chamber; break; #endif - default: tune_temp = autotune_temp[hid]; break; + default: + #if ENABLED(PIDTEMP) + tune_temp = autotune_temp[hid]; break; + #else + return; + #endif } sprintf_P(cmd, PSTR("M303 U1 E%i S%i"), hid, tune_temp); queue.inject(cmd); @@ -205,43 +213,41 @@ void menu_backlash(); // 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(int16_t e) { - UNUSED(e); - PID_PARAM(Ki, e) = scalePID_i(raw_Ki); - thermalManager.updatePID(); + void copy_and_scalePID_i(const int8_t e) { + switch (e) { + #if ENABLED(PIDTEMPBED) + case H_BED: thermalManager.temp_bed.pid.Ki = scalePID_i(raw_Ki); break; + #endif + #if ENABLED(PIDTEMPCHAMBER) + case H_CHAMBER: thermalManager.temp_chamber.pid.Ki = scalePID_i(raw_Ki); break; + #endif + default: + #if ENABLED(PIDTEMP) + PID_PARAM(Ki, e) = scalePID_i(raw_Ki); + thermalManager.updatePID(); + #endif + break; + } } - void copy_and_scalePID_d(int16_t e) { - UNUSED(e); - PID_PARAM(Kd, e) = scalePID_d(raw_Kd); - thermalManager.updatePID(); + void copy_and_scalePID_d(const int8_t e) { + switch (e) { + #if ENABLED(PIDTEMPBED) + case H_BED: thermalManager.temp_bed.pid.Kd = scalePID_d(raw_Kd); break; + #endif + #if ENABLED(PIDTEMPCHAMBER) + case H_CHAMBER: thermalManager.temp_chamber.pid.Kd = scalePID_d(raw_Kd); break; + #endif + default: + #if ENABLED(PIDTEMP) + PID_PARAM(Kd, e) = scalePID_d(raw_Kd); + thermalManager.updatePID(); + #endif + break; + } } - - #define _DEFINE_PIDTEMP_BASE_FUNCS(N) \ - void copy_and_scalePID_i_E##N() { copy_and_scalePID_i(N); } \ - void copy_and_scalePID_d_E##N() { copy_and_scalePID_d(N); } - -#else - - #define _DEFINE_PIDTEMP_BASE_FUNCS(N) // - -#endif - -#if ENABLED(PID_AUTOTUNE_MENU) - #define DEFINE_PIDTEMP_FUNCS(N) \ - _DEFINE_PIDTEMP_BASE_FUNCS(N); \ - void lcd_autotune_callback_E##N() { _lcd_autotune(heater_id_t(N)); } -#else - #define DEFINE_PIDTEMP_FUNCS(N) _DEFINE_PIDTEMP_BASE_FUNCS(N); -#endif - -#if HAS_HOTEND - DEFINE_PIDTEMP_FUNCS(0); - #if ENABLED(PID_PARAMS_PER_HOTEND) - REPEAT_S(1, HOTENDS, DEFINE_PIDTEMP_FUNCS) - #endif #endif -#if BOTH(AUTOTEMP, HAS_TEMP_HOTEND) || EITHER(PID_AUTOTUNE_MENU, PID_EDIT_MENU) +#if BOTH(AUTOTEMP, HAS_TEMP_HOTEND) || ANY(PID_AUTOTUNE_MENU, PID_EDIT_MENU, MPC_AUTOTUNE_MENU, MPC_EDIT_MENU) #define SHOW_MENU_ADVANCED_TEMPERATURE 1 #endif @@ -250,9 +256,20 @@ void menu_backlash(); // #if SHOW_MENU_ADVANCED_TEMPERATURE + #if ENABLED(MPC_EDIT_MENU) + #define MPC_EDIT_DEFS(N) \ + MPC_t &c = thermalManager.temp_hotend[N].constants; \ + TERN_(MPC_INCLUDE_FAN, editable.decimal = c.ambient_xfer_coeff_fan0 + c.fan255_adjustment) + #endif + void menu_advanced_temperature() { + #if ENABLED(MPC_EDIT_MENU) && !HAS_MULTI_HOTEND + MPC_EDIT_DEFS(0); + #endif + START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); + // // Autotemp, Min, Max, Fact // @@ -272,14 +289,7 @@ void menu_backlash(); // PID-P E5, PID-I E5, PID-D E5, PID-C E5, PID Autotune E5 // - #if ENABLED(PID_EDIT_MENU) - #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); }) - + #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)); \ @@ -309,17 +319,68 @@ void menu_backlash(); #endif - #if ENABLED(PID_AUTOTUNE_MENU) - #define HOTEND_PID_EDIT_MENU_ITEMS(N) \ - _HOTEND_PID_EDIT_MENU_ITEMS(N); \ - EDIT_ITEM_FAST_N(int3, N, MSG_PID_AUTOTUNE_E, &autotune_temp[N], 150, thermalManager.hotend_max_target(N), []{ _lcd_autotune(heater_id_t(MenuItemBase::itemIndex)); }); - #else - #define HOTEND_PID_EDIT_MENU_ITEMS(N) _HOTEND_PID_EDIT_MENU_ITEMS(N); + #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); }) + #endif + + #if ENABLED(PIDTEMP) + #if ENABLED(PID_AUTOTUNE_MENU) + #define HOTEND_PID_EDIT_MENU_ITEMS(N) \ + _HOTEND_PID_EDIT_MENU_ITEMS(N); \ + EDIT_ITEM_FAST_N(int3, N, MSG_PID_AUTOTUNE_E, &autotune_temp[N], 150, thermalManager.hotend_max_target(N), []{ _lcd_autotune(heater_id_t(MenuItemBase::itemIndex)); }); + #else + #define HOTEND_PID_EDIT_MENU_ITEMS(N) _HOTEND_PID_EDIT_MENU_ITEMS(N); + #endif + + HOTEND_PID_EDIT_MENU_ITEMS(0); + #if ENABLED(PID_PARAMS_PER_HOTEND) + REPEAT_S(1, HOTENDS, HOTEND_PID_EDIT_MENU_ITEMS); + #endif #endif - HOTEND_PID_EDIT_MENU_ITEMS(0); - #if ENABLED(PID_PARAMS_PER_HOTEND) - REPEAT_S(1, HOTENDS, HOTEND_PID_EDIT_MENU_ITEMS) + #if ENABLED(MPC_EDIT_MENU) + + #define _MPC_EDIT_ITEMS(N) \ + EDIT_ITEM_FAST_N(float31sign, N, MSG_MPC_POWER_E, &c.heater_power, 1, 200); \ + EDIT_ITEM_FAST_N(float31sign, N, MSG_MPC_BLOCK_HEAT_CAPACITY_E, &c.block_heat_capacity, 0, 40); \ + EDIT_ITEM_FAST_N(float43, N, MSG_SENSOR_RESPONSIVENESS_E, &c.sensor_responsiveness, 0, 1); \ + EDIT_ITEM_FAST_N(float43, N, MSG_MPC_AMBIENT_XFER_COEFF_E, &c.ambient_xfer_coeff_fan0, 0, 1) + + #if ENABLED(MPC_INCLUDE_FAN) + #define MPC_EDIT_ITEMS(N) \ + _MPC_EDIT_ITEMS(N); \ + EDIT_ITEM_FAST_N(float43, N, MSG_MPC_AMBIENT_XFER_COEFF_FAN_E, &editable.decimal, 0, 1, []{ \ + MPC_t &c = thermalManager.temp_hotend[MenuItemBase::itemIndex].constants; \ + c.fan255_adjustment = editable.decimal - c.ambient_xfer_coeff_fan0; \ + }) + #else + #define MPC_EDIT_ITEMS _MPC_EDIT_ITEMS + #endif + + #if HAS_MULTI_HOTEND + static auto mpc_edit_hotend = [](const uint8_t e) { + MPC_EDIT_DEFS(e); + START_MENU(); + BACK_ITEM(MSG_TEMPERATURE); + MPC_EDIT_ITEMS(e); + END_MENU(); + }; + #define MPC_ENTRY(N) SUBMENU_N(N, MSG_MPC_EDIT, []{ mpc_edit_hotend(MenuItemBase::itemIndex); }); + #else + #define MPC_ENTRY MPC_EDIT_ITEMS + #endif + + REPEAT(HOTENDS, MPC_ENTRY); + + #endif // MPC_EDIT_MENU + + #if ENABLED(MPC_AUTOTUNE_MENU) + ACTION_ITEM(MSG_MPC_AUTOTUNE, []{ queue.inject(F("M306 T")); ui.return_to_status(); }); #endif #if ENABLED(PIDTEMPBED) @@ -368,11 +429,11 @@ void menu_backlash(); START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); - #define EDIT_VMAX(N) EDIT_ITEM_FAST(float5, MSG_VMAX_##N, &planner.settings.max_feedrate_mm_s[_AXIS(N)], 1, max_fr_edit_scaled[_AXIS(N)]) - LINEAR_AXIS_CODE(EDIT_VMAX(A), EDIT_VMAX(B), EDIT_VMAX(C), EDIT_VMAX(I), EDIT_VMAX(J), EDIT_VMAX(K)); + LOOP_LINEAR_AXES(a) + EDIT_ITEM_FAST_N(float5, a, MSG_VMAX_N, &planner.settings.max_feedrate_mm_s[a], 1, max_fr_edit_scaled[a]); #if E_STEPPERS - EDIT_ITEM_FAST(float5, MSG_VMAX_E, &planner.settings.max_feedrate_mm_s[E_AXIS_N(active_extruder)], 1, max_fr_edit_scaled.e); + EDIT_ITEM_FAST_N(float5, E_AXIS, MSG_VMAX_N, &planner.settings.max_feedrate_mm_s[E_AXIS_N(active_extruder)], 1, max_fr_edit_scaled.e); #endif #if ENABLED(DISTINCT_E_FACTORS) LOOP_L_N(n, E_STEPPERS) @@ -455,11 +516,9 @@ void menu_backlash(); BACK_ITEM(MSG_ADVANCED_SETTINGS); #if HAS_JUNCTION_DEVIATION - #if ENABLED(LIN_ADVANCE) - EDIT_ITEM(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.001f, 0.3f, planner.recalculate_max_e_jerk); - #else - EDIT_ITEM(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.001f, 0.5f); - #endif + EDIT_ITEM(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.001f, TERN(LIN_ADVANCE, 0.3f, 0.5f) + OPTARG(LIN_ADVANCE, planner.recalculate_max_e_jerk) + ); #endif constexpr xyze_float_t max_jerk_edit = @@ -473,20 +532,13 @@ void menu_backlash(); { LOGICAL_AXIS_LIST(990, 990, 990, 990, 990, 990, 990) } #endif ; - #define EDIT_JERK(N) EDIT_ITEM_FAST(float3, MSG_V##N##_JERK, &planner.max_jerk[_AXIS(N)], 1, max_jerk_edit[_AXIS(N)]) - #if ENABLED(DELTA) - #define EDIT_JERK_C() EDIT_JERK(C) - #else - #define EDIT_JERK_C() EDIT_ITEM_FAST(float52sign, MSG_VC_JERK, &planner.max_jerk.c, 0.1f, max_jerk_edit.c) - #endif - LINEAR_AXIS_CODE( - EDIT_JERK(A), EDIT_JERK(B), EDIT_JERK_C(), - EDIT_JERK(I), EDIT_JERK(J), EDIT_JERK(K) - ); - #if HAS_EXTRUDERS - EDIT_ITEM_FAST(float52sign, MSG_VE_JERK, &planner.max_jerk.e, 0.1f, max_jerk_edit.e); - #endif + LOOP_LOGICAL_AXES(a) { + if (a == C_AXIS || TERN0(HAS_EXTRUDERS, a == E_AXIS)) + EDIT_ITEM_FAST_N(float52sign, a, MSG_VN_JERK, &planner.max_jerk[a], 0.1f, max_jerk_edit[a]); + else + EDIT_ITEM_FAST_N(float3, a, MSG_VN_JERK, &planner.max_jerk[a], 1.0f, max_jerk_edit[a]); + } END_MENU(); } @@ -523,15 +575,12 @@ void menu_advanced_steps_per_mm() { START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); - #define EDIT_QSTEPS(Q) EDIT_ITEM_FAST(float51, MSG_##Q##_STEPS, &planner.settings.axis_steps_per_mm[_AXIS(Q)], 5, 9999, []{ planner.refresh_positioning(); }) - LINEAR_AXIS_CODE( - EDIT_QSTEPS(A), EDIT_QSTEPS(B), EDIT_QSTEPS(C), - EDIT_QSTEPS(I), EDIT_QSTEPS(J), EDIT_QSTEPS(K) - ); + LOOP_LINEAR_AXES(a) + EDIT_ITEM_FAST_N(float61, 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(float51, n, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(n)], 5, 9999, []{ + EDIT_ITEM_FAST_N(float61, 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(); @@ -539,7 +588,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(float51, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); }); + EDIT_ITEM_FAST_N(float61, E_AXIS, MSG_N_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); }); #endif END_MENU(); @@ -565,7 +614,7 @@ void menu_advanced_settings() { #endif // M203 / M205 - Feedrate items - SUBMENU(MSG_VELOCITY, menu_advanced_velocity); + SUBMENU(MSG_MAX_SPEED, menu_advanced_velocity); // M201 - Acceleration items SUBMENU(MSG_ACCELERATION, menu_advanced_acceleration); @@ -646,11 +695,11 @@ void menu_advanced_settings() { CONFIRM_ITEM(MSG_INIT_EEPROM, MSG_BUTTON_INIT, MSG_BUTTON_CANCEL, ui.init_eeprom, nullptr, - GET_TEXT(MSG_INIT_EEPROM), (const char *)nullptr, PSTR("?") + GET_TEXT_F(MSG_INIT_EEPROM), (const char *)nullptr, F("?") ); #endif END_MENU(); } -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU diff --git a/Marlin/src/lcd/menu/menu_backlash.cpp b/Marlin/src/lcd/menu/menu_backlash.cpp index ad276e11c048..6b6cdf2e0bef 100644 --- a/Marlin/src/lcd/menu/menu_backlash.cpp +++ b/Marlin/src/lcd/menu/menu_backlash.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, BACKLASH_GCODE) +#if BOTH(HAS_MARLINUI_MENU, BACKLASH_GCODE) #include "menu_item.h" @@ -36,14 +36,20 @@ void menu_backlash() { START_MENU(); BACK_ITEM(MSG_MAIN); - EDIT_ITEM_FAST(percent, MSG_BACKLASH_CORRECTION, &backlash.correction, all_off, all_on); + editable.uint8 = backlash.get_correction_uint8(); + EDIT_ITEM_FAST(percent, MSG_BACKLASH_CORRECTION, &editable.uint8, backlash.all_off, backlash.all_on, []{ backlash.set_correction_uint8(editable.uint8); }); #if DISABLED(CORE_BACKLASH) || EITHER(MARKFORGED_XY, MARKFORGED_YX) #define _CAN_CALI AXIS_CAN_CALIBRATE #else #define _CAN_CALI(A) true #endif - #define EDIT_BACKLASH_DISTANCE(N) EDIT_ITEM_FAST(float43, MSG_BACKLASH_##N, &backlash.distance_mm[_AXIS(N)], 0.0f, 9.9f); + + #define EDIT_BACKLASH_DISTANCE(N) do { \ + editable.decimal = backlash.get_distance_mm(_AXIS(N)); \ + EDIT_ITEM_FAST_N(float43, _AXIS(N), MSG_BACKLASH_N, &editable.decimal, 0.0f, 9.9f, []{ backlash.set_distance_mm(_AXIS(N), editable.decimal); }); \ + } while (0); + if (_CAN_CALI(A)) EDIT_BACKLASH_DISTANCE(A); #if HAS_Y_AXIS && _CAN_CALI(B) EDIT_BACKLASH_DISTANCE(B); @@ -51,21 +57,22 @@ void menu_backlash() { #if HAS_Z_AXIS && _CAN_CALI(C) EDIT_BACKLASH_DISTANCE(C); #endif - #if LINEAR_AXES >= 4 && _CAN_CALI(I) + #if HAS_I_AXIS && _CAN_CALI(I) EDIT_BACKLASH_DISTANCE(I); #endif - #if LINEAR_AXES >= 5 && _CAN_CALI(J) + #if HAS_J_AXIS && _CAN_CALI(J) EDIT_BACKLASH_DISTANCE(J); #endif - #if LINEAR_AXES >= 6 && _CAN_CALI(K) + #if HAS_K_AXIS && _CAN_CALI(K) EDIT_BACKLASH_DISTANCE(K); #endif #ifdef BACKLASH_SMOOTHING_MM - EDIT_ITEM_FAST(float43, MSG_BACKLASH_SMOOTHING, &backlash.smoothing_mm, 0.0f, 9.9f); + editable.decimal = backlash.get_smoothing_mm(); + EDIT_ITEM_FAST(float43, MSG_BACKLASH_SMOOTHING, &editable.decimal, 0.0f, 9.9f, []{ backlash.set_smoothing_mm(editable.decimal); }); #endif END_MENU(); } -#endif // HAS_LCD_MENU && BACKLASH_GCODE +#endif // HAS_MARLINUI_MENU && BACKLASH_GCODE diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 38a074eb0128..3fe0c582cb10 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, LEVEL_BED_CORNERS) +#if BOTH(HAS_MARLINUI_MENU, LCD_BED_TRAMMING) #include "menu_item.h" #include "../../module/motion.h" @@ -36,21 +36,21 @@ #include "../../feature/bedlevel/bedlevel.h" #endif -#ifndef LEVEL_CORNERS_Z_HOP - #define LEVEL_CORNERS_Z_HOP 4.0 +#ifndef BED_TRAMMING_Z_HOP + #define BED_TRAMMING_Z_HOP 4.0 #endif -#ifndef LEVEL_CORNERS_HEIGHT - #define LEVEL_CORNERS_HEIGHT 0.0 +#ifndef BED_TRAMMING_HEIGHT + #define BED_TRAMMING_HEIGHT 0.0 #endif -#if ENABLED(LEVEL_CORNERS_USE_PROBE) +#if ENABLED(BED_TRAMMING_USE_PROBE) #include "../../module/probe.h" #include "../../module/endstops.h" #if ENABLED(BLTOUCH) #include "../../feature/bltouch.h" #endif - #ifndef LEVEL_CORNERS_PROBE_TOLERANCE - #define LEVEL_CORNERS_PROBE_TOLERANCE 0.2 + #ifndef BED_TRAMMING_PROBE_TOLERANCE + #define BED_TRAMMING_PROBE_TOLERANCE 0.2 #endif float last_z; int good_points; @@ -64,32 +64,32 @@ #endif -static_assert(LEVEL_CORNERS_Z_HOP >= 0, "LEVEL_CORNERS_Z_HOP must be >= 0. Please update your configuration."); +static_assert(BED_TRAMMING_Z_HOP >= 0, "BED_TRAMMING_Z_HOP must be >= 0. Please update your configuration."); -#ifndef LEVEL_CORNERS_LEVELING_ORDER - #define LEVEL_CORNERS_LEVELING_ORDER { LF, RF, LB, RB } // Default - //#define LEVEL_CORNERS_LEVELING_ORDER { LF, LB, RF } // 3 hard-coded points - //#define LEVEL_CORNERS_LEVELING_ORDER { LF, RF } // 3-Point tramming - Rear - //#define LEVEL_CORNERS_LEVELING_ORDER { LF, LB } // 3-Point tramming - Right - //#define LEVEL_CORNERS_LEVELING_ORDER { RF, RB } // 3-Point tramming - Left - //#define LEVEL_CORNERS_LEVELING_ORDER { LB, RB } // 3-Point tramming - Front +#ifndef BED_TRAMMING_LEVELING_ORDER + #define BED_TRAMMING_LEVELING_ORDER { LF, RF, LB, RB } // Default + //#define BED_TRAMMING_LEVELING_ORDER { LF, LB, RF } // 3 hard-coded points + //#define BED_TRAMMING_LEVELING_ORDER { LF, RF } // 3-Point tramming - Rear + //#define BED_TRAMMING_LEVELING_ORDER { LF, LB } // 3-Point tramming - Right + //#define BED_TRAMMING_LEVELING_ORDER { RF, RB } // 3-Point tramming - Left + //#define BED_TRAMMING_LEVELING_ORDER { LB, RB } // 3-Point tramming - Front #endif #define LF 1 #define RF 2 #define RB 3 #define LB 4 -constexpr int lco[] = LEVEL_CORNERS_LEVELING_ORDER; +constexpr int lco[] = BED_TRAMMING_LEVELING_ORDER; constexpr bool level_corners_3_points = COUNT(lco) == 2; -static_assert(level_corners_3_points || COUNT(lco) == 4, "LEVEL_CORNERS_LEVELING_ORDER must have exactly 2 or 4 corners."); +static_assert(level_corners_3_points || COUNT(lco) == 4, "BED_TRAMMING_LEVELING_ORDER must have exactly 2 or 4 corners."); constexpr int lcodiff = ABS(lco[0] - lco[1]); -static_assert(COUNT(lco) == 4 || lcodiff == 1 || lcodiff == 3, "The first two LEVEL_CORNERS_LEVELING_ORDER corners must be on the same edge."); +static_assert(COUNT(lco) == 4 || lcodiff == 1 || lcodiff == 3, "The first two BED_TRAMMING_LEVELING_ORDER corners must be on the same edge."); constexpr int nr_edge_points = level_corners_3_points ? 3 : 4; -constexpr int available_points = nr_edge_points + ENABLED(LEVEL_CENTER_TOO); -constexpr int center_index = TERN(LEVEL_CENTER_TOO, available_points - 1, -1); -constexpr float inset_lfrb[4] = LEVEL_CORNERS_INSET_LFRB; +constexpr int available_points = nr_edge_points + ENABLED(BED_TRAMMING_INCLUDE_CENTER); +constexpr int center_index = TERN(BED_TRAMMING_INCLUDE_CENTER, available_points - 1, -1); +constexpr float inset_lfrb[4] = BED_TRAMMING_INSET_LFRB; constexpr xy_pos_t lf { (X_MIN_BED) + inset_lfrb[0], (Y_MIN_BED) + inset_lfrb[1] }, rb { (X_MAX_BED) - inset_lfrb[2], (Y_MAX_BED) - inset_lfrb[3] }; @@ -120,12 +120,12 @@ static void _lcd_level_bed_corners_get_next_position() { if ((lco[0] == LF && lco[1] == LB) || (lco[0] == LB && lco[1] == LF)) current_position.x = rb.x; // Center Right if ((lco[0] == RF && lco[1] == RB) || (lco[0] == RB && lco[1] == RF)) current_position.x = lf.x; // Left Center if ((lco[0] == LF && lco[1] == RF) || (lco[0] == RF && lco[1] == LF)) current_position.y = rb.y; // Center Back - #if DISABLED(LEVEL_CENTER_TOO) && ENABLED(LEVEL_CORNERS_USE_PROBE) + #if DISABLED(BED_TRAMMING_INCLUDE_CENTER) && ENABLED(BED_TRAMMING_USE_PROBE) bed_corner++; // Must increment the count to ensure it resets the loop if the 3rd point is out of tolerance #endif break; - #if ENABLED(LEVEL_CENTER_TOO) + #if ENABLED(BED_TRAMMING_INCLUDE_CENTER) case 3: current_position.set(X_CENTER, Y_CENTER); break; @@ -134,9 +134,9 @@ static void _lcd_level_bed_corners_get_next_position() { } else { // Four-Corner Bed Tramming with optional center - if (TERN0(LEVEL_CENTER_TOO, bed_corner == center_index)) { + if (TERN0(BED_TRAMMING_INCLUDE_CENTER, bed_corner == center_index)) { current_position.set(X_CENTER, Y_CENTER); - TERN_(LEVEL_CORNERS_USE_PROBE, good_points--); // Decrement to allow one additional probe point + TERN_(BED_TRAMMING_USE_PROBE, good_points--); // Decrement to allow one additional probe point } else { current_position = lf; // Left front @@ -152,10 +152,10 @@ static void _lcd_level_bed_corners_get_next_position() { /** * Level corners, starting in the front-left corner. */ -#if ENABLED(LEVEL_CORNERS_USE_PROBE) +#if ENABLED(BED_TRAMMING_USE_PROBE) #define VALIDATE_POINT(X, Y, STR) static_assert(Probe::build_time::can_reach((X), (Y)), \ - "LEVEL_CORNERS_INSET_LFRB " STR " inset is not reachable with the default NOZZLE_TO_PROBE offset and PROBING_MARGIN.") + "BED_TRAMMING_INSET_LFRB " STR " inset is not reachable with the default NOZZLE_TO_PROBE offset and PROBING_MARGIN.") VALIDATE_POINT(lf.x, Y_CENTER, "left"); VALIDATE_POINT(X_CENTER, lf.y, "front"); VALIDATE_POINT(rb.x, Y_CENTER, "right"); VALIDATE_POINT(X_CENTER, rb.y, "back"); @@ -168,7 +168,7 @@ static void _lcd_level_bed_corners_get_next_position() { TERN_(HAS_MARLINUI_U8GLIB, ui.set_font(FONT_MENU)); // Set up the font for extra info - MenuItem_static::draw(0, GET_TEXT(MSG_PROBING_POINT), SS_INVERT); // "Probing Mesh" heading + MenuItem_static::draw(0, GET_TEXT_F(MSG_PROBING_POINT), SS_INVERT); // "Probing Mesh" heading uint8_t cy = TERN(TFT_COLOR_UI, 3, LCD_HEIGHT - 1), y = LCD_ROW_Y(cy); @@ -197,35 +197,35 @@ static void _lcd_level_bed_corners_get_next_position() { void _lcd_draw_raise() { if (!ui.should_draw()) return; MenuItem_confirm::select_screen( - GET_TEXT(MSG_BUTTON_DONE), GET_TEXT(MSG_BUTTON_SKIP) + GET_TEXT_F(MSG_BUTTON_DONE), GET_TEXT_F(MSG_BUTTON_SKIP) , []{ corner_probing_done = true; wait_for_probe = false; } , []{ wait_for_probe = false; } - , GET_TEXT(MSG_BED_TRAMMING_RAISE) - , (const char*)nullptr, NUL_STR + , GET_TEXT_F(MSG_BED_TRAMMING_RAISE) ); } void _lcd_draw_level_prompt() { if (!ui.should_draw()) return; - MenuItem_confirm::confirm_screen( - []{ queue.inject(TERN(HAS_LEVELING, F("G29N"), FPSTR(G28_STR))); ui.return_to_status(); } - , ui.goto_previous_screen_no_defer - , GET_TEXT(MSG_BED_TRAMMING_IN_RANGE) - , (const char*)nullptr, PSTR("?") + MenuItem_confirm::select_screen( + GET_TEXT_F(TERN(HAS_LEVELING, MSG_BUTTON_LEVEL, MSG_BUTTON_DONE)), + TERN(HAS_LEVELING, GET_TEXT_F(MSG_BUTTON_BACK), nullptr) + , []{ queue.inject(TERN(HAS_LEVELING, F("G29N"), FPSTR(G28_STR))); ui.return_to_status(); } + , TERN(HAS_LEVELING, ui.goto_previous_screen_no_defer, []{}) + , GET_TEXT_F(MSG_BED_TRAMMING_IN_RANGE) ); } bool _lcd_level_bed_corners_probe(bool verify=false) { - if (verify) do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); // do clearance if needed + if (verify) do_blocking_move_to_z(current_position.z + BED_TRAMMING_Z_HOP); // do clearance if needed TERN_(BLTOUCH, if (!bltouch.high_speed_mode) bltouch.deploy()); // Deploy in LOW SPEED MODE on every probe action - do_blocking_move_to_z(last_z - LEVEL_CORNERS_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance + do_blocking_move_to_z(last_z - BED_TRAMMING_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance if (TEST(endstops.trigger_state(), Z_MIN_PROBE)) { // check if probe triggered endstops.hit_on_purpose(); set_current_from_steppers_for_axis(Z_AXIS); sync_plan_position(); TERN_(BLTOUCH, if (!bltouch.high_speed_mode) bltouch.stow()); // Stow in LOW SPEED MODE on every trigger // Triggered outside tolerance range? - if (ABS(current_position.z - last_z) > LEVEL_CORNERS_PROBE_TOLERANCE) { + if (ABS(current_position.z - last_z) > BED_TRAMMING_PROBE_TOLERANCE) { last_z = current_position.z; // Above tolerance. Set a new Z for subsequent corners. good_points = 0; // ...and start over } @@ -245,7 +245,7 @@ static void _lcd_level_bed_corners_get_next_position() { probe_triggered = PROBE_TRIGGERED(); if (probe_triggered) { endstops.hit_on_purpose(); - TERN_(LEVEL_CORNERS_AUDIO_FEEDBACK, ui.buzz(200, 600)); + TERN_(BED_TRAMMING_AUDIO_FEEDBACK, BUZZ(200, 600)); } idle(); } @@ -255,8 +255,8 @@ static void _lcd_level_bed_corners_get_next_position() { } void _lcd_test_corners() { - bed_corner = TERN(LEVEL_CENTER_TOO, center_index, 0); - last_z = LEVEL_CORNERS_HEIGHT; + bed_corner = TERN(BED_TRAMMING_INCLUDE_CENTER, center_index, 0); + last_z = BED_TRAMMING_HEIGHT; endstops.enable_z_probe(true); good_points = 0; ui.goto_screen(_lcd_draw_probing); @@ -264,7 +264,7 @@ static void _lcd_level_bed_corners_get_next_position() { ui.refresh(LCDVIEW_REDRAW_NOW); _lcd_draw_probing(); // update screen with # of good points - do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP + TERN0(BLTOUCH, bltouch.z_extra_clearance())); // clearance + do_blocking_move_to_z(current_position.z + BED_TRAMMING_Z_HOP + TERN0(BLTOUCH, bltouch.z_extra_clearance())); // clearance _lcd_level_bed_corners_get_next_position(); // Select next corner coordinates current_position -= probe.offset_xy; // Account for probe offsets @@ -273,7 +273,7 @@ static void _lcd_level_bed_corners_get_next_position() { TERN_(BLTOUCH, if (bltouch.high_speed_mode) bltouch.deploy()); // Deploy in HIGH SPEED MODE if (!_lcd_level_bed_corners_probe()) { // Probe down to tolerance if (_lcd_level_bed_corners_raise()) { // Prompt user to raise bed if needed - #if ENABLED(LEVEL_CORNERS_VERIFY_RAISED) // Verify + #if ENABLED(BED_TRAMMING_VERIFY_RAISED) // Verify while (!_lcd_level_bed_corners_probe(true)) { // Loop while corner verified if (!_lcd_level_bed_corners_raise()) { // Prompt user to raise bed if needed if (corner_probing_done) return; // Done was selected @@ -294,7 +294,7 @@ static void _lcd_level_bed_corners_get_next_position() { #if ENABLED(BLTOUCH) if (bltouch.high_speed_mode) { // In HIGH SPEED MODE do clearance and stow at the very end - do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); + do_blocking_move_to_z(current_position.z + BED_TRAMMING_Z_HOP); bltouch.stow(); } #endif @@ -303,25 +303,25 @@ static void _lcd_level_bed_corners_get_next_position() { ui.set_selection(true); } -#else // !LEVEL_CORNERS_USE_PROBE +#else // !BED_TRAMMING_USE_PROBE static void _lcd_goto_next_corner() { - line_to_z(LEVEL_CORNERS_Z_HOP); + line_to_z(BED_TRAMMING_Z_HOP); // Select next corner coordinates _lcd_level_bed_corners_get_next_position(); line_to_current_position(manual_feedrate_mm_s.x); - line_to_z(LEVEL_CORNERS_HEIGHT); + line_to_z(BED_TRAMMING_HEIGHT); if (++bed_corner >= available_points) bed_corner = 0; } -#endif // !LEVEL_CORNERS_USE_PROBE +#endif // !BED_TRAMMING_USE_PROBE static void _lcd_level_bed_corners_homing() { _lcd_draw_homing(); if (!all_axes_homed()) return; - #if ENABLED(LEVEL_CORNERS_USE_PROBE) + #if ENABLED(BED_TRAMMING_USE_PROBE) _lcd_test_corners(); if (corner_probing_done) ui.goto_previous_screen_no_defer(); TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active)); @@ -330,15 +330,15 @@ static void _lcd_level_bed_corners_homing() { bed_corner = 0; ui.goto_screen([]{ MenuItem_confirm::select_screen( - GET_TEXT(MSG_BUTTON_NEXT), GET_TEXT(MSG_BUTTON_DONE) + GET_TEXT_F(MSG_BUTTON_NEXT), GET_TEXT_F(MSG_BUTTON_DONE) , _lcd_goto_next_corner , []{ - line_to_z(LEVEL_CORNERS_Z_HOP); // Raise Z off the bed when done + line_to_z(BED_TRAMMING_Z_HOP); // Raise Z off the bed when done TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active)); ui.goto_previous_screen_no_defer(); } - , GET_TEXT(TERN(LEVEL_CENTER_TOO, MSG_LEVEL_BED_NEXT_POINT, MSG_NEXT_CORNER)) - , (const char*)nullptr, PSTR("?") + , GET_TEXT_F(TERN(BED_TRAMMING_INCLUDE_CENTER, MSG_LEVEL_BED_NEXT_POINT, MSG_NEXT_CORNER)) + , (const char*)nullptr, F("?") ); }); ui.set_selection(true); @@ -362,4 +362,4 @@ void _lcd_level_bed_corners() { ui.goto_screen(_lcd_level_bed_corners_homing); } -#endif // HAS_LCD_MENU && LEVEL_BED_CORNERS +#endif // HAS_MARLINUI_MENU && LCD_BED_TRAMMING diff --git a/Marlin/src/lcd/menu/menu_bed_leveling.cpp b/Marlin/src/lcd/menu/menu_bed_leveling.cpp index a47e2517aedf..294666e35621 100644 --- a/Marlin/src/lcd/menu/menu_bed_leveling.cpp +++ b/Marlin/src/lcd/menu/menu_bed_leveling.cpp @@ -71,12 +71,12 @@ #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(MSG_LEVEL_BED_DONE)); + ui.synchronize(GET_TEXT_F(MSG_LEVEL_BED_DONE)); #endif ui.goto_previous_screen_no_defer(); ui.completion_feedback(); } - if (ui.should_draw()) MenuItem_static::draw(LCD_HEIGHT >= 4, GET_TEXT(MSG_LEVEL_BED_DONE)); + if (ui.should_draw()) MenuItem_static::draw(LCD_HEIGHT >= 4, GET_TEXT_F(MSG_LEVEL_BED_DONE)); ui.refresh(LCDVIEW_CALL_REDRAW_NEXT); } @@ -127,7 +127,7 @@ // if (ui.should_draw()) { const float v = current_position.z; - MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001f : 0.0001f), '+')); + MenuEditItemBase::draw_edit_screen(GET_TEXT_F(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001f : 0.0001f), '+')); } } @@ -138,7 +138,7 @@ if (ui.should_draw()) { char msg[10]; sprintf_P(msg, PSTR("%i / %u"), int(manual_probe_index + 1), total_probe_points); - MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_LEVEL_BED_NEXT_POINT), msg); + MenuEditItemBase::draw_edit_screen(GET_TEXT_F(MSG_LEVEL_BED_NEXT_POINT), msg); } ui.refresh(LCDVIEW_CALL_NO_REDRAW); if (!ui.wait_for_move) ui.goto_screen(_lcd_level_bed_get_z); @@ -165,7 +165,7 @@ // void _lcd_level_bed_homing_done() { if (ui.should_draw()) { - MenuItem_static::draw(1, GET_TEXT(MSG_LEVEL_BED_WAITING)); + MenuItem_static::draw(1, GET_TEXT_F(MSG_LEVEL_BED_WAITING)); // Color UI needs a control to detect a touch #if BOTH(TOUCH_SCREEN, HAS_GRAPHICAL_TFT) touch.add_control(CLICK, 0, 0, TFT_WIDTH, TFT_HEIGHT); @@ -214,7 +214,7 @@ BACK_ITEM(MSG_BED_LEVELING); EDIT_ITEM(uint8, MSG_MESH_X, &xind, 0, (GRID_MAX_POINTS_X) - 1); EDIT_ITEM(uint8, MSG_MESH_Y, &yind, 0, (GRID_MAX_POINTS_Y) - 1); - EDIT_ITEM_FAST(float43, MSG_MESH_EDIT_Z, &Z_VALUES(xind, yind), -(LCD_PROBE_Z_RANGE) * 0.5, (LCD_PROBE_Z_RANGE) * 0.5, refresh_planner); + EDIT_ITEM_FAST(float43, MSG_MESH_EDIT_Z, &bedlevel.z_values[xind][yind], -(LCD_PROBE_Z_RANGE) * 0.5, (LCD_PROBE_Z_RANGE) * 0.5, refresh_planner); END_MENU(); } @@ -230,7 +230,7 @@ * Mesh Z Offset: --- (Req: MESH_BED_LEVELING) * Z Probe Offset: --- (Req: HAS_BED_PROBE, Opt: BABYSTEP_ZPROBE_OFFSET) * Level Bed > - * Level Corners > (if homed) + * Bed Tramming > (if homed) * Load Settings (Req: EEPROM_SETTINGS) * Save Settings (Req: EEPROM_SETTINGS) */ @@ -243,7 +243,7 @@ void menu_bed_leveling() { // Auto Home if not using manual probing #if NONE(PROBE_MANUALLY, MESH_BED_LEVELING) - if (!is_homed) GCODES_ITEM(MSG_AUTO_HOME, G28_STR); + if (!is_homed) GCODES_ITEM(MSG_AUTO_HOME, FPSTR(G28_STR)); #endif // Level Bed @@ -252,7 +252,7 @@ void menu_bed_leveling() { SUBMENU(MSG_LEVEL_BED, _lcd_level_bed_continue); #else // Automatic leveling can just run the G-code - GCODES_ITEM(MSG_LEVEL_BED, is_homed ? PSTR("G29") : PSTR("G29N")); + GCODES_ITEM(MSG_LEVEL_BED, is_homed ? F("G29") : F("G29N")); #endif #if ENABLED(MESH_EDIT_MENU) @@ -281,7 +281,7 @@ void menu_bed_leveling() { #else #define LCD_Z_OFFSET_TYPE float42_52 // Values from -99.99 to 99.99 #endif - EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_BED_Z, &mbl.z_offset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); + EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_BED_Z, &bedlevel.z_offset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); #endif #if ENABLED(BABYSTEP_ZPROBE_OFFSET) @@ -290,7 +290,7 @@ void menu_bed_leveling() { EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); #endif - #if ENABLED(LEVEL_BED_CORNERS) + #if ENABLED(LCD_BED_TRAMMING) SUBMENU(MSG_BED_TRAMMING, _lcd_level_bed_corners); #endif diff --git a/Marlin/src/lcd/menu/menu_cancelobject.cpp b/Marlin/src/lcd/menu/menu_cancelobject.cpp index f2a06ecf6a4a..b2d36bf8c30d 100644 --- a/Marlin/src/lcd/menu/menu_cancelobject.cpp +++ b/Marlin/src/lcd/menu/menu_cancelobject.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, CANCEL_OBJECTS) +#if BOTH(HAS_MARLINUI_MENU, CANCEL_OBJECTS) #include "menu_item.h" #include "menu_addon.h" @@ -48,7 +48,7 @@ static void lcd_cancel_object_confirm() { ui.goto_previous_screen(); }, nullptr, - GET_TEXT(MSG_CANCEL_OBJECT), item_num, PSTR("?") + GET_TEXT_F(MSG_CANCEL_OBJECT), item_num, F("?") ); } @@ -71,4 +71,4 @@ void menu_cancelobject() { END_MENU(); } -#endif // HAS_LCD_MENU && CANCEL_OBJECTS +#endif // HAS_MARLINUI_MENU && CANCEL_OBJECTS diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 4cd43e787aca..8b6af33fd11e 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -26,10 +26,12 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "menu_item.h" +#include "../../MarlinCore.h" + #if HAS_FILAMENT_SENSOR #include "../../feature/runout.h" #endif @@ -76,7 +78,7 @@ void menu_advanced_settings(); bar_percent += (int8_t)ui.encoderPosition; LIMIT(bar_percent, 0, 100); ui.encoderPosition = 0; - MenuItem_static::draw(0, GET_TEXT(MSG_PROGRESS_BAR_TEST), SS_DEFAULT|SS_INVERT); + 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_moveto(0, LCD_HEIGHT - 1); ui.draw_progress_bar(bar_percent); } @@ -122,8 +124,8 @@ 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_FAN_SPEED, &toolchange_settings.fan_speed, 0, 255); - EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_FAN_TIME, &toolchange_settings.fan_time, 1, 30); + 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 EDIT_ITEM(float3, MSG_TOOL_CHANGE_ZLIFT, &toolchange_settings.z_raise, 0, 10); END_MENU(); @@ -135,7 +137,7 @@ void menu_advanced_settings(); #include "../../gcode/queue.h" void menu_toolchange_migration() { - PGM_P const msg_migrate = GET_TEXT(MSG_TOOL_MIGRATION_SWAP); + FSTR_P const msg_migrate = GET_TEXT_F(MSG_TOOL_MIGRATION_SWAP); START_MENU(); BACK_ITEM(MSG_CONFIGURATION); @@ -145,9 +147,9 @@ void menu_advanced_settings(); EDIT_ITEM(uint8, MSG_TOOL_MIGRATION_END, &migration.last, 0, EXTRUDERS - 1); // Migrate to a chosen extruder - LOOP_L_N(s, EXTRUDERS) { - if (s != active_extruder) { - ACTION_ITEM_N_P(s, msg_migrate, []{ + EXTRUDER_LOOP() { + if (e != active_extruder) { + ACTION_ITEM_N_F(e, msg_migrate, []{ char cmd[12]; sprintf_P(cmd, PSTR("M217 T%i"), int(MenuItemBase::itemIndex)); queue.inject(cmd); @@ -197,16 +199,16 @@ void menu_advanced_settings(); START_MENU(); BACK_ITEM(MSG_CONFIGURATION); - GCODES_ITEM(MSG_IDEX_MODE_AUTOPARK, PSTR("M605S1\nG28X\nG1X0")); + GCODES_ITEM(MSG_IDEX_MODE_AUTOPARK, F("M605S1\nG28X\nG1X0")); GCODES_ITEM(MSG_IDEX_MODE_DUPLICATE, need_g28 - ? PSTR("M605S1\nT0\nG28\nM605S2\nG28X\nG1X0") // If Y or Z is not homed, do a full G28 first - : PSTR("M605S1\nT0\nM605S2\nG28X\nG1X0") + ? F("M605S1\nT0\nG28\nM605S2\nG28X\nG1X0") // If Y or Z is not homed, do a full G28 first + : F("M605S1\nT0\nM605S2\nG28X\nG1X0") ); GCODES_ITEM(MSG_IDEX_MODE_MIRRORED_COPY, need_g28 - ? PSTR("M605S1\nT0\nG28\nM605S2\nG28X\nG1X0\nM605S3") // If Y or Z is not homed, do a full G28 first - : PSTR("M605S1\nT0\nM605S2\nG28 X\nG1X0\nM605S3") + ? F("M605S1\nT0\nG28\nM605S2\nG28X\nG1X0\nM605S3") // If Y or Z is not homed, do a full G28 first + : F("M605S1\nT0\nM605S2\nG28 X\nG1X0\nM605S3") ); - GCODES_ITEM(MSG_IDEX_MODE_FULL_CTRL, PSTR("M605S0\nG28X")); + GCODES_ITEM(MSG_IDEX_MODE_FULL_CTRL, F("M605S0\nG28X")); EDIT_ITEM(float42_52, MSG_IDEX_DUPE_GAP, &duplicate_extruder_x_offset, (X2_MIN_POS) - (X1_MIN_POS), (X_BED_SIZE) - 20); @@ -244,11 +246,11 @@ void menu_advanced_settings(); EDIT_ITEM(bool, MSG_BLTOUCH_SPEED_MODE, &bltouch.high_speed_mode); #endif #if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU) - CONFIRM_ITEM(MSG_BLTOUCH_5V_MODE, MSG_BLTOUCH_5V_MODE, MSG_BUTTON_CANCEL, bltouch._set_5V_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); - CONFIRM_ITEM(MSG_BLTOUCH_OD_MODE, MSG_BLTOUCH_OD_MODE, MSG_BUTTON_CANCEL, bltouch._set_OD_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); + CONFIRM_ITEM(MSG_BLTOUCH_5V_MODE, MSG_BLTOUCH_5V_MODE, MSG_BUTTON_CANCEL, bltouch._set_5V_mode, nullptr, GET_TEXT_F(MSG_BLTOUCH_MODE_CHANGE)); + CONFIRM_ITEM(MSG_BLTOUCH_OD_MODE, MSG_BLTOUCH_OD_MODE, MSG_BUTTON_CANCEL, bltouch._set_OD_mode, nullptr, GET_TEXT_F(MSG_BLTOUCH_MODE_CHANGE)); ACTION_ITEM(MSG_BLTOUCH_MODE_STORE, bltouch._mode_store); - CONFIRM_ITEM(MSG_BLTOUCH_MODE_STORE_5V, MSG_BLTOUCH_MODE_STORE_5V, MSG_BUTTON_CANCEL, bltouch.mode_conv_5V, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); - CONFIRM_ITEM(MSG_BLTOUCH_MODE_STORE_OD, MSG_BLTOUCH_MODE_STORE_OD, MSG_BUTTON_CANCEL, bltouch.mode_conv_OD, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); + CONFIRM_ITEM(MSG_BLTOUCH_MODE_STORE_5V, MSG_BLTOUCH_MODE_STORE_5V, MSG_BUTTON_CANCEL, bltouch.mode_conv_5V, nullptr, GET_TEXT_F(MSG_BLTOUCH_MODE_CHANGE)); + CONFIRM_ITEM(MSG_BLTOUCH_MODE_STORE_OD, MSG_BLTOUCH_MODE_STORE_OD, MSG_BUTTON_CANCEL, bltouch.mode_conv_OD, nullptr, GET_TEXT_F(MSG_BLTOUCH_MODE_CHANGE)); ACTION_ITEM(MSG_BLTOUCH_MODE_ECHO, bltouch_report); #endif END_MENU(); @@ -262,10 +264,10 @@ void menu_advanced_settings(); ui.defer_status_screen(); START_MENU(); BACK_ITEM(MSG_CONFIGURATION); - GCODES_ITEM(MSG_TOUCHMI_INIT, PSTR("M851 Z0\nG28\nG1 F200 Z0")); + GCODES_ITEM(MSG_TOUCHMI_INIT, F("M851 Z0\nG28\nG1 F200 Z0")); SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset); - GCODES_ITEM(MSG_TOUCHMI_SAVE, PSTR("M500\nG1 F200 Z10")); - GCODES_ITEM(MSG_TOUCHMI_ZTEST, PSTR("G28\nG1 F200 Z0")); + GCODES_ITEM(MSG_TOUCHMI_SAVE, F("M500\nG1 F200 Z10")); + GCODES_ITEM(MSG_TOUCHMI_ZTEST, F("G28\nG1 F200 Z0")); END_MENU(); } @@ -327,7 +329,7 @@ void menu_advanced_settings(); #define MAXTEMP_ALL _MAX(REPEAT(HOTENDS, _MAXTEMP_ITEM) 0) const uint8_t m = MenuItemBase::itemIndex; START_MENU(); - STATIC_ITEM_P(ui.get_preheat_label(m), SS_DEFAULT|SS_INVERT); + STATIC_ITEM_F(ui.get_preheat_label(m), SS_DEFAULT|SS_INVERT); BACK_ITEM(MSG_CONFIGURATION); #if HAS_FAN editable.uint8 = uint8_t(ui.material_preset[m].fan_speed); @@ -367,13 +369,13 @@ void menu_advanced_settings(); #define _DONE_SCRIPT "" #endif #define GCODE_LAMBDA_CONF(N) []{ _lcd_custom_menus_configuration_gcode(F(CONFIG_MENU_ITEM_##N##_GCODE _DONE_SCRIPT)); } - #define _CUSTOM_ITEM_CONF(N) ACTION_ITEM_P(PSTR(CONFIG_MENU_ITEM_##N##_DESC), GCODE_LAMBDA_CONF(N)); - #define _CUSTOM_ITEM_CONF_CONFIRM(N) \ - SUBMENU_P(PSTR(CONFIG_MENU_ITEM_##N##_DESC), []{ \ - MenuItem_confirm::confirm_screen( \ - GCODE_LAMBDA_CONF(N), nullptr, \ - PSTR(CONFIG_MENU_ITEM_##N##_DESC "?") \ - ); \ + #define _CUSTOM_ITEM_CONF(N) ACTION_ITEM_F(F(CONFIG_MENU_ITEM_##N##_DESC), GCODE_LAMBDA_CONF(N)); + #define _CUSTOM_ITEM_CONF_CONFIRM(N) \ + SUBMENU_F(F(CONFIG_MENU_ITEM_##N##_DESC), []{ \ + MenuItem_confirm::confirm_screen( \ + GCODE_LAMBDA_CONF(N), nullptr, \ + F(CONFIG_MENU_ITEM_##N##_DESC "?") \ + ); \ }) #define CUSTOM_ITEM_CONF(N) do{ \ @@ -481,7 +483,7 @@ void menu_configuration() { #if ENABLED(CUSTOM_MENU_CONFIG) if (TERN1(CUSTOM_MENU_CONFIG_ONLY_IDLE, !busy)) { #ifdef CUSTOM_MENU_CONFIG_TITLE - SUBMENU_P(PSTR(CUSTOM_MENU_CONFIG_TITLE), custom_menus_configuration); + SUBMENU_F(F(CUSTOM_MENU_CONFIG_TITLE), custom_menus_configuration); #else SUBMENU(MSG_CUSTOM_COMMANDS, custom_menus_configuration); #endif @@ -538,9 +540,19 @@ void menu_configuration() { #if HAS_LCD_BRIGHTNESS EDIT_ITEM_FAST(uint8, MSG_BRIGHTNESS, &ui.brightness, LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, ui.refresh_brightness, true); #endif - #if HAS_LCD_CONTRAST + #if HAS_LCD_CONTRAST && LCD_CONTRAST_MIN < LCD_CONTRAST_MAX EDIT_ITEM_FAST(uint8, MSG_CONTRAST, &ui.contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, ui.refresh_contrast, true); #endif + + // + // 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); + #elif HAS_DISPLAY_SLEEP + EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.sleep_timeout_minutes, SLEEP_TIMEOUT_MIN, SLEEP_TIMEOUT_MAX, ui.refresh_screen_timeout); + #endif + #if ENABLED(FWRETRACT) SUBMENU(MSG_RETRACT, menu_config_retract); #endif @@ -560,11 +572,11 @@ void menu_configuration() { // Preheat configurations #if HAS_PREHEAT && DISABLED(SLIM_LCD_MENUS) LOOP_L_N(m, PREHEAT_COUNT) - SUBMENU_N_S(m, ui.get_preheat_label(m), MSG_PREHEAT_M_SETTINGS, _menu_configuration_preheat_settings); + SUBMENU_N_f(m, ui.get_preheat_label(m), MSG_PREHEAT_M_SETTINGS, _menu_configuration_preheat_settings); #endif #if ENABLED(SOUND_MENU_ITEM) - EDIT_ITEM(bool, MSG_SOUND, &ui.buzzer_enabled, []{ ui.chirp(); }); + EDIT_ITEM(bool, MSG_SOUND, &ui.sound_on, []{ ui.chirp(); }); #endif #if ENABLED(EEPROM_SETTINGS) @@ -577,4 +589,4 @@ void menu_configuration() { END_MENU(); } -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU diff --git a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp index ea627f69e781..b86f1012586d 100644 --- a/Marlin/src/lcd/menu/menu_delta_calibrate.cpp +++ b/Marlin/src/lcd/menu/menu_delta_calibrate.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU && EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION) +#if HAS_MARLINUI_MENU && EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION) #include "menu_item.h" #include "../../module/delta.h" @@ -41,6 +41,10 @@ #include "../extui/ui_api.h" #endif +#if HAS_PROBE_XY_OFFSET + #include "../../module/probe.h" +#endif + void _man_probe_pt(const xy_pos_t &xy) { if (!ui.wait_for_move) { ui.wait_for_move = true; @@ -88,7 +92,9 @@ void _man_probe_pt(const xy_pos_t &xy) { } void _goto_tower_a(const_float_t a) { - constexpr float dcr = DELTA_PRINTABLE_RADIUS; + float dcr = DELTA_PRINTABLE_RADIUS - PROBING_MARGIN; + TERN_(HAS_PROBE_XY_OFFSET, dcr -= HYPOT(probe.offset_xy.x, probe.offset_xy.y)); + TERN_(HAS_DELTA_SENSORLESS_PROBING, dcr *= sensorless_radius_factor); xy_pos_t tower_vec = { cos(RADIANS(a)), sin(RADIANS(a)) }; _man_probe_pt(tower_vec * dcr); } @@ -107,12 +113,12 @@ void lcd_delta_settings() { START_MENU(); BACK_ITEM(MSG_DELTA_CALIBRATE); EDIT_ITEM(float52sign, MSG_DELTA_HEIGHT, &delta_height, delta_height - 10, delta_height + 10, _recalc_delta_settings); - #define EDIT_ENDSTOP_ADJ(LABEL,N) EDIT_ITEM_P(float43, PSTR(LABEL), &delta_endstop_adj.N, -5, 0, _recalc_delta_settings) + #define EDIT_ENDSTOP_ADJ(LABEL,N) EDIT_ITEM_F(float43, F(LABEL), &delta_endstop_adj.N, -5, 0, _recalc_delta_settings) EDIT_ENDSTOP_ADJ("Ex", a); EDIT_ENDSTOP_ADJ("Ey", b); EDIT_ENDSTOP_ADJ("Ez", c); EDIT_ITEM(float52sign, MSG_DELTA_RADIUS, &delta_radius, delta_radius - 5, delta_radius + 5, _recalc_delta_settings); - #define EDIT_ANGLE_TRIM(LABEL,N) EDIT_ITEM_P(float43, PSTR(LABEL), &delta_tower_angle_trim.N, -5, 5, _recalc_delta_settings) + #define EDIT_ANGLE_TRIM(LABEL,N) EDIT_ITEM_F(float43, F(LABEL), &delta_tower_angle_trim.N, -5, 5, _recalc_delta_settings) EDIT_ANGLE_TRIM("Tx", a); EDIT_ANGLE_TRIM("Ty", b); EDIT_ANGLE_TRIM("Tz", c); @@ -129,7 +135,7 @@ void menu_delta_calibrate() { BACK_ITEM(MSG_MAIN); #if ENABLED(DELTA_AUTO_CALIBRATION) - GCODES_ITEM(MSG_DELTA_AUTO_CALIBRATE, PSTR("G33")); + GCODES_ITEM(MSG_DELTA_AUTO_CALIBRATE, F("G33")); #if ENABLED(EEPROM_SETTINGS) ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings); ACTION_ITEM(MSG_LOAD_EEPROM, ui.load_settings); @@ -151,4 +157,4 @@ void menu_delta_calibrate() { END_MENU(); } -#endif // HAS_LCD_MENU && (DELTA_CALIBRATION_MENU || DELTA_AUTO_CALIBRATION) +#endif // HAS_MARLINUI_MENU && (DELTA_CALIBRATION_MENU || DELTA_AUTO_CALIBRATION) diff --git a/Marlin/src/lcd/menu/menu_filament.cpp b/Marlin/src/lcd/menu/menu_filament.cpp index e7365744e9a1..5902a2f63f35 100644 --- a/Marlin/src/lcd/menu/menu_filament.cpp +++ b/Marlin/src/lcd/menu/menu_filament.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, ADVANCED_PAUSE_FEATURE) +#if BOTH(HAS_MARLINUI_MENU, ADVANCED_PAUSE_FEATURE) #include "menu_item.h" #include "../../module/temperature.h" @@ -35,6 +35,9 @@ #if HAS_FILAMENT_SENSOR #include "../../feature/runout.h" #endif +#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES) + #include "../../MarlinCore.h" +#endif // // Change Filament > Change/Unload/Load Filament @@ -42,22 +45,22 @@ static PauseMode _change_filament_mode; // = PAUSE_MODE_PAUSE_PRINT static int8_t _change_filament_extruder; // = 0 -inline PGM_P _change_filament_command() { +inline FSTR_P _change_filament_command() { switch (_change_filament_mode) { - case PAUSE_MODE_LOAD_FILAMENT: return PSTR("M701 T%d"); + case PAUSE_MODE_LOAD_FILAMENT: return F("M701 T%d"); case PAUSE_MODE_UNLOAD_FILAMENT: return _change_filament_extruder >= 0 - ? PSTR("M702 T%d") : PSTR("M702 ;%d"); + ? F("M702 T%d") : F("M702 ;%d"); case PAUSE_MODE_CHANGE_FILAMENT: case PAUSE_MODE_PAUSE_PRINT: default: break; } - return PSTR("M600 B0 T%d"); + return F("M600 B0 T%d"); } // Initiate Filament Load/Unload/Change at the specified temperature static void _change_filament_with_temp(const uint16_t celsius) { char cmd[11]; - sprintf_P(cmd, _change_filament_command(), _change_filament_extruder); + sprintf_P(cmd, FTOP(_change_filament_command()), _change_filament_extruder); thermalManager.setTargetHotend(celsius, _change_filament_extruder); queue.inject(cmd); } @@ -74,13 +77,13 @@ static void _change_filament_with_custom() { // Menu to choose the temperature and start Filament Change // -inline PGM_P change_filament_header(const PauseMode mode) { +inline FSTR_P change_filament_header(const PauseMode mode) { switch (mode) { - case PAUSE_MODE_LOAD_FILAMENT: return GET_TEXT(MSG_FILAMENTLOAD); - case PAUSE_MODE_UNLOAD_FILAMENT: return GET_TEXT(MSG_FILAMENTUNLOAD); + case PAUSE_MODE_LOAD_FILAMENT: return GET_TEXT_F(MSG_FILAMENTLOAD); + case PAUSE_MODE_UNLOAD_FILAMENT: return GET_TEXT_F(MSG_FILAMENTUNLOAD); default: break; } - return GET_TEXT(MSG_FILAMENTCHANGE); + return GET_TEXT_F(MSG_FILAMENTCHANGE); } void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) { @@ -88,11 +91,11 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) { _change_filament_extruder = extruder; const int8_t old_index = MenuItemBase::itemIndex; START_MENU(); - if (LCD_HEIGHT >= 4) STATIC_ITEM_P(change_filament_header(mode), SS_DEFAULT|SS_INVERT); + if (LCD_HEIGHT >= 4) STATIC_ITEM_F(change_filament_header(mode), SS_DEFAULT|SS_INVERT); BACK_ITEM(MSG_BACK); #if HAS_PREHEAT LOOP_L_N(m, PREHEAT_COUNT) - ACTION_ITEM_N_S(m, ui.get_preheat_label(m), MSG_PREHEAT_M, _change_filament_with_preset); + ACTION_ITEM_N_f(m, ui.get_preheat_label(m), MSG_PREHEAT_M, _change_filament_with_preset); #endif EDIT_ITEM_FAST_N(int3, extruder, MSG_PREHEAT_CUSTOM, &thermalManager.temp_hotend[extruder].target, EXTRUDE_MINTEMP, thermalManager.hotend_max_target(extruder), @@ -129,18 +132,18 @@ void menu_change_filament() { // Change filament #if E_STEPPERS == 1 - PGM_P const msg = GET_TEXT(MSG_FILAMENTCHANGE); + FSTR_P const fmsg = GET_TEXT_F(MSG_FILAMENTCHANGE); if (thermalManager.targetTooColdToExtrude(active_extruder)) - SUBMENU_P(msg, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, 0); }); + SUBMENU_F(fmsg, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, 0); }); else - GCODES_ITEM_P(msg, PSTR("M600 B0")); + GCODES_ITEM_F(fmsg, F("M600 B0")); #else - PGM_P const msg = GET_TEXT(MSG_FILAMENTCHANGE_E); + FSTR_P const fmsg = GET_TEXT_F(MSG_FILAMENTCHANGE_E); LOOP_L_N(s, E_STEPPERS) { if (thermalManager.targetTooColdToExtrude(s)) - SUBMENU_N_P(s, msg, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, MenuItemBase::itemIndex); }); + SUBMENU_N_F(s, fmsg, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, MenuItemBase::itemIndex); }); else { - ACTION_ITEM_N_P(s, msg, []{ + ACTION_ITEM_N_F(s, fmsg, []{ PGM_P const cmdpstr = PSTR("M600 B0 T%i"); char cmd[strlen_P(cmdpstr) + 3 + 1]; sprintf_P(cmd, cmdpstr, int(MenuItemBase::itemIndex)); @@ -154,18 +157,18 @@ void menu_change_filament() { if (!is_busy) { // Load filament #if E_STEPPERS == 1 - PGM_P const msg_load = GET_TEXT(MSG_FILAMENTLOAD); + FSTR_P const msg_load = GET_TEXT_F(MSG_FILAMENTLOAD); if (thermalManager.targetTooColdToExtrude(active_extruder)) - SUBMENU_P(msg_load, []{ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, 0); }); + SUBMENU_F(msg_load, []{ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, 0); }); else - GCODES_ITEM_P(msg_load, PSTR("M701")); + GCODES_ITEM_F(msg_load, F("M701")); #else - PGM_P const msg_load = GET_TEXT(MSG_FILAMENTLOAD_E); + FSTR_P const msg_load = GET_TEXT_F(MSG_FILAMENTLOAD_E); LOOP_L_N(s, E_STEPPERS) { if (thermalManager.targetTooColdToExtrude(s)) - SUBMENU_N_P(s, msg_load, []{ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, MenuItemBase::itemIndex); }); + SUBMENU_N_F(s, msg_load, []{ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, MenuItemBase::itemIndex); }); else { - ACTION_ITEM_N_P(s, msg_load, []{ + ACTION_ITEM_N_F(s, msg_load, []{ char cmd[12]; sprintf_P(cmd, PSTR("M701 T%i"), int(MenuItemBase::itemIndex)); queue.inject(cmd); @@ -176,24 +179,24 @@ void menu_change_filament() { // Unload filament #if E_STEPPERS == 1 - PGM_P const msg_unload = GET_TEXT(MSG_FILAMENTUNLOAD); + FSTR_P const msg_unload = GET_TEXT_F(MSG_FILAMENTUNLOAD); if (thermalManager.targetTooColdToExtrude(active_extruder)) - SUBMENU_P(msg_unload, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, 0); }); + SUBMENU_F(msg_unload, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, 0); }); else - GCODES_ITEM_P(msg_unload, PSTR("M702")); + GCODES_ITEM_F(msg_unload, F("M702")); #else #if ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS) if (too_cold) SUBMENU(MSG_FILAMENTUNLOAD_ALL, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, -1); }); else - GCODES_ITEM(MSG_FILAMENTUNLOAD_ALL, PSTR("M702")); + GCODES_ITEM(MSG_FILAMENTUNLOAD_ALL, F("M702")); #endif - PGM_P const msg_unload = GET_TEXT(MSG_FILAMENTUNLOAD_E); + FSTR_P const msg_unload = GET_TEXT_F(MSG_FILAMENTUNLOAD_E); LOOP_L_N(s, E_STEPPERS) { if (thermalManager.targetTooColdToExtrude(s)) - SUBMENU_N_P(s, msg_unload, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, MenuItemBase::itemIndex); }); + SUBMENU_N_F(s, msg_unload, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, MenuItemBase::itemIndex); }); else { - ACTION_ITEM_N_P(s, msg_unload, []{ + ACTION_ITEM_N_F(s, msg_unload, []{ char cmd[12]; sprintf_P(cmd, PSTR("M702 T%i"), int(MenuItemBase::itemIndex)); queue.inject(cmd); @@ -218,21 +221,21 @@ void menu_change_filament() { static uint8_t hotend_status_extruder = 0; -static PGM_P pause_header() { +static FSTR_P pause_header() { switch (pause_mode) { - case PAUSE_MODE_CHANGE_FILAMENT: return GET_TEXT(MSG_FILAMENT_CHANGE_HEADER); - case PAUSE_MODE_LOAD_FILAMENT: return GET_TEXT(MSG_FILAMENT_CHANGE_HEADER_LOAD); - case PAUSE_MODE_UNLOAD_FILAMENT: return GET_TEXT(MSG_FILAMENT_CHANGE_HEADER_UNLOAD); + case PAUSE_MODE_CHANGE_FILAMENT: return GET_TEXT_F(MSG_FILAMENT_CHANGE_HEADER); + case PAUSE_MODE_LOAD_FILAMENT: return GET_TEXT_F(MSG_FILAMENT_CHANGE_HEADER_LOAD); + case PAUSE_MODE_UNLOAD_FILAMENT: return GET_TEXT_F(MSG_FILAMENT_CHANGE_HEADER_UNLOAD); default: break; } - return GET_TEXT(MSG_FILAMENT_CHANGE_HEADER_PAUSE); + return GET_TEXT_F(MSG_FILAMENT_CHANGE_HEADER_PAUSE); } // Portions from STATIC_ITEM... #define HOTEND_STATUS_ITEM() do { \ if (_menuLineNr == _thisItemNr) { \ if (ui.should_draw()) { \ - IF_DISABLED(HAS_GRAPHICAL_TFT, MenuItem_static::draw(_lcdLineNr, GET_TEXT(MSG_FILAMENT_CHANGE_NOZZLE), SS_INVERT)); \ + IF_DISABLED(HAS_GRAPHICAL_TFT, MenuItem_static::draw(_lcdLineNr, GET_TEXT_F(MSG_FILAMENT_CHANGE_NOZZLE), SS_INVERT)); \ ui.draw_hotend_status(_lcdLineNr, hotend_status_extruder); \ } \ if (_skipStatic && encoderLine <= _thisItemNr) { \ @@ -268,41 +271,41 @@ void menu_pause_option() { // // ADVANCED_PAUSE_FEATURE message screens // -// Warning: msg must have three null bytes to delimit lines! +// Warning: fmsg must have three null bytes to delimit lines! // -void _lcd_pause_message(PGM_P const msg) { - PGM_P const msg1 = msg; +void _lcd_pause_message(FSTR_P const fmsg) { + PGM_P const msg1 = FTOP(fmsg); PGM_P const msg2 = msg1 + strlen_P(msg1) + 1; PGM_P const msg3 = msg2 + strlen_P(msg2) + 1; const bool has2 = msg2[0], has3 = msg3[0], skip1 = !has2 && (LCD_HEIGHT) >= 5; START_SCREEN(); - STATIC_ITEM_P(pause_header(), SS_DEFAULT|SS_INVERT); // 1: Header + STATIC_ITEM_F(pause_header(), SS_DEFAULT|SS_INVERT); // 1: Header if (skip1) SKIP_ITEM(); // Move a single-line message down - STATIC_ITEM_P(msg1); // 2: Message Line 1 - if (has2) STATIC_ITEM_P(msg2); // 3: Message Line 2 - if (has3 && (LCD_HEIGHT) >= 5) STATIC_ITEM_P(msg3); // 4: Message Line 3 (if LCD has 5 lines) + STATIC_ITEM_F(FPSTR(msg1)); // 2: Message Line 1 + if (has2) STATIC_ITEM_F(FPSTR(msg2)); // 3: Message Line 2 + if (has3 && (LCD_HEIGHT) >= 5) STATIC_ITEM_F(FPSTR(msg3)); // 4: Message Line 3 (if LCD has 5 lines) if (skip1 + 1 + has2 + has3 < (LCD_HEIGHT) - 2) SKIP_ITEM(); // Push Hotend Status down, if needed HOTEND_STATUS_ITEM(); // 5: Hotend Status END_SCREEN(); } -void lcd_pause_parking_message() { _lcd_pause_message(GET_TEXT(MSG_PAUSE_PRINT_PARKING)); } -void lcd_pause_changing_message() { _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_INIT)); } -void lcd_pause_unload_message() { _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_UNLOAD)); } -void lcd_pause_heating_message() { _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_HEATING)); } -void lcd_pause_heat_message() { _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_HEAT)); } -void lcd_pause_insert_message() { _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_INSERT)); } -void lcd_pause_load_message() { _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_LOAD)); } -void lcd_pause_waiting_message() { _lcd_pause_message(GET_TEXT(MSG_ADVANCED_PAUSE_WAITING)); } -void lcd_pause_resume_message() { _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_RESUME)); } +void lcd_pause_parking_message() { _lcd_pause_message(GET_TEXT_F(MSG_PAUSE_PRINT_PARKING)); } +void lcd_pause_changing_message() { _lcd_pause_message(GET_TEXT_F(MSG_FILAMENT_CHANGE_INIT)); } +void lcd_pause_unload_message() { _lcd_pause_message(GET_TEXT_F(MSG_FILAMENT_CHANGE_UNLOAD)); } +void lcd_pause_heating_message() { _lcd_pause_message(GET_TEXT_F(MSG_FILAMENT_CHANGE_HEATING)); } +void lcd_pause_heat_message() { _lcd_pause_message(GET_TEXT_F(MSG_FILAMENT_CHANGE_HEAT)); } +void lcd_pause_insert_message() { _lcd_pause_message(GET_TEXT_F(MSG_FILAMENT_CHANGE_INSERT)); } +void lcd_pause_load_message() { _lcd_pause_message(GET_TEXT_F(MSG_FILAMENT_CHANGE_LOAD)); } +void lcd_pause_waiting_message() { _lcd_pause_message(GET_TEXT_F(MSG_ADVANCED_PAUSE_WAITING)); } +void lcd_pause_resume_message() { _lcd_pause_message(GET_TEXT_F(MSG_FILAMENT_CHANGE_RESUME)); } void lcd_pause_purge_message() { #if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE) - _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_CONT_PURGE)); + _lcd_pause_message(GET_TEXT_F(MSG_FILAMENT_CHANGE_CONT_PURGE)); #else - _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_PURGE)); + _lcd_pause_message(GET_TEXT_F(MSG_FILAMENT_CHANGE_PURGE)); #endif } @@ -342,4 +345,4 @@ void MarlinUI::pause_show_message( ui.return_to_status(); } -#endif // HAS_LCD_MENU && ADVANCED_PAUSE_FEATURE +#endif // HAS_MARLINUI_MENU && ADVANCED_PAUSE_FEATURE diff --git a/Marlin/src/lcd/menu/menu_info.cpp b/Marlin/src/lcd/menu/menu_info.cpp index 388aebb74469..101861074d95 100644 --- a/Marlin/src/lcd/menu/menu_info.cpp +++ b/Marlin/src/lcd/menu/menu_info.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, LCD_INFO_MENU) +#if BOTH(HAS_MARLINUI_MENU, LCD_INFO_MENU) #include "menu_item.h" @@ -35,7 +35,7 @@ #endif #define VALUE_ITEM(MSG, VALUE, STYL) do{ char msg[21]; strcpy_P(msg, PSTR(": ")); strcpy(msg + 2, VALUE); STATIC_ITEM(MSG, STYL, msg); }while(0) -#define VALUE_ITEM_P(MSG, PVALUE, STYL) do{ char msg[21]; strcpy_P(msg, PSTR(": ")); strcpy_P(msg + 2, PSTR(PVALUE)); STATIC_ITEM(MSG, STYL, msg); }while(0) +#define VALUE_ITEM_F(MSG, PVALUE, STYL) do{ char msg[21]; strcpy_P(msg, PSTR(": ")); strcpy_P(msg + 2, PSTR(PVALUE)); STATIC_ITEM(MSG, STYL, msg); }while(0) #if ENABLED(PRINTCOUNTER) @@ -56,35 +56,35 @@ VALUE_ITEM(MSG_INFO_COMPLETED_PRINTS, i16tostr3left(stats.finishedPrints), SS_LEFT); // Completed : 666 STATIC_ITEM(MSG_INFO_PRINT_TIME, SS_LEFT); // Total print Time: - STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.printTime).toString(buffer)); // > 99y 364d 23h 59m 59s + STATIC_ITEM_F(F("> "), SS_LEFT, duration_t(stats.printTime).toString(buffer)); // > 99y 364d 23h 59m 59s STATIC_ITEM(MSG_INFO_PRINT_LONGEST, SS_LEFT); // Longest job time: - STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.longestPrint).toString(buffer)); // > 99y 364d 23h 59m 59s + STATIC_ITEM_F(F("> "), SS_LEFT, duration_t(stats.longestPrint).toString(buffer)); // > 99y 364d 23h 59m 59s STATIC_ITEM(MSG_INFO_PRINT_FILAMENT, SS_LEFT); // Extruded total: sprintf_P(buffer, PSTR("%ld.%im") , long(stats.filamentUsed / 1000) , int16_t(stats.filamentUsed / 100) % 10 ); - STATIC_ITEM_P(PSTR("> "), SS_LEFT, buffer); // > 125m + STATIC_ITEM_F(F("> "), SS_LEFT, buffer); // > 125m #if SERVICE_INTERVAL_1 > 0 || SERVICE_INTERVAL_2 > 0 || SERVICE_INTERVAL_3 > 0 strcpy_P(buffer, GET_TEXT(MSG_SERVICE_IN)); #endif #if SERVICE_INTERVAL_1 > 0 - STATIC_ITEM_P(PSTR(SERVICE_NAME_1 " "), SS_LEFT, buffer); // Service X in: - STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.nextService1).toString(buffer)); // > 7d 12h 11m 10s + STATIC_ITEM_F(F(SERVICE_NAME_1 " "), SS_LEFT, buffer); // Service X in: + STATIC_ITEM_F(F("> "), SS_LEFT, duration_t(stats.nextService1).toString(buffer)); // > 7d 12h 11m 10s #endif #if SERVICE_INTERVAL_2 > 0 - STATIC_ITEM_P(PSTR(SERVICE_NAME_2 " "), SS_LEFT, buffer); - STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.nextService2).toString(buffer)); + STATIC_ITEM_F(F(SERVICE_NAME_2 " "), SS_LEFT, buffer); + STATIC_ITEM_F(F("> "), SS_LEFT, duration_t(stats.nextService2).toString(buffer)); #endif #if SERVICE_INTERVAL_3 > 0 - STATIC_ITEM_P(PSTR(SERVICE_NAME_3 " "), SS_LEFT, buffer); - STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.nextService3).toString(buffer)); + STATIC_ITEM_F(F(SERVICE_NAME_3 " "), SS_LEFT, buffer); + STATIC_ITEM_F(F("> "), SS_LEFT, duration_t(stats.nextService3).toString(buffer)); #endif END_SCREEN(); @@ -103,7 +103,7 @@ void menu_info_thermistors() { #if HAS_EXTRUDERS #define THERMISTOR_ID TEMP_SENSOR_0 #include "../thermistornames.h" - STATIC_ITEM_P(PSTR(LCD_STR_E0 ": " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_F(F(STR_E0 ": " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_0_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_0_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -113,7 +113,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_1 #include "../thermistornames.h" - STATIC_ITEM_P(PSTR(LCD_STR_E1 ": " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_F(F(STR_E1 ": " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_1_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_1_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -123,7 +123,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_2 #include "../thermistornames.h" - STATIC_ITEM_P(PSTR(LCD_STR_E2 ": " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_F(F(STR_E2 ": " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_2_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_2_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -133,7 +133,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_3 #include "../thermistornames.h" - STATIC_ITEM_P(PSTR(LCD_STR_E3 ": " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_F(F(STR_E3 ": " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_3_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_3_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -143,7 +143,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_4 #include "../thermistornames.h" - STATIC_ITEM_P(PSTR(LCD_STR_E4 ": " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_F(F(STR_E4 ": " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_4_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_4_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -153,7 +153,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_5 #include "../thermistornames.h" - STATIC_ITEM_P(PSTR(LCD_STR_E5 ": " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_F(F(STR_E5 ": " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_5_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_5_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -163,7 +163,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_6 #include "../thermistornames.h" - STATIC_ITEM_P(PSTR(LCD_STR_E6 ": " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_F(F(STR_E6 ": " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_6_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_6_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -173,7 +173,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_7 #include "../thermistornames.h" - STATIC_ITEM_P(PSTR(LCD_STR_E7 ": " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_F(F(STR_E7 ": " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_7_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_7_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -183,7 +183,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_BED #include "../thermistornames.h" - STATIC_ITEM_P(PSTR("BED: " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_F(F("BED: " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(BED_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(BED_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_BED, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -193,7 +193,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_CHAMBER #include "../thermistornames.h" - STATIC_ITEM_P(PSTR("CHAM: " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_F(F("CHAM: " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(CHAMBER_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(CHAMBER_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_CHAMBER, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -203,7 +203,7 @@ void menu_info_thermistors() { #undef THERMISTOR_ID #define THERMISTOR_ID TEMP_SENSOR_COOLER #include "../thermistornames.h" - STATIC_ITEM_P(PSTR("COOL: " THERMISTOR_NAME), SS_INVERT); + STATIC_ITEM_F(F("COOL: " THERMISTOR_NAME), SS_INVERT); PSTRING_ITEM(MSG_INFO_MIN_TEMP, STRINGIFY(COOLER_MINTEMP), SS_LEFT); PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(COOLER_MAXTEMP), SS_LEFT); STATIC_ITEM(TERN(WATCH_COOLER, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT); @@ -219,9 +219,9 @@ void menu_info_board() { if (ui.use_click()) return ui.go_back(); START_SCREEN(); - STATIC_ITEM_P(PSTR(BOARD_INFO_NAME), SS_DEFAULT|SS_INVERT); // MyPrinterController + STATIC_ITEM_F(F(BOARD_INFO_NAME), SS_DEFAULT|SS_INVERT); // MyPrinterController #ifdef BOARD_WEBSITE_URL - STATIC_ITEM_P(PSTR(BOARD_WEBSITE_URL), SS_LEFT); // www.my3dprinter.com + STATIC_ITEM_F(F(BOARD_WEBSITE_URL), SS_LEFT); // www.my3dprinter.com #endif PSTRING_ITEM(MSG_INFO_BAUDRATE, STRINGIFY(BAUDRATE), SS_CENTER); // Baud: 250000 PSTRING_ITEM(MSG_INFO_PROTOCOL, PROTOCOL_VERSION, SS_CENTER); // Protocol: 1.0 @@ -251,11 +251,11 @@ void menu_info_board() { void menu_info_printer() { if (ui.use_click()) return ui.go_back(); START_SCREEN(); - STATIC_ITEM(MSG_MARLIN, SS_DEFAULT|SS_INVERT); // Marlin - STATIC_ITEM_P(PSTR(SHORT_BUILD_VERSION)); // x.x.x-Branch - STATIC_ITEM_P(PSTR(STRING_DISTRIBUTION_DATE)); // YYYY-MM-DD HH:MM - STATIC_ITEM_P(PSTR(MACHINE_NAME), SS_DEFAULT|SS_INVERT); // My3DPrinter - STATIC_ITEM_P(PSTR(WEBSITE_URL)); // www.my3dprinter.com + STATIC_ITEM(MSG_MARLIN, SS_DEFAULT|SS_INVERT); // Marlin + STATIC_ITEM_F(F(SHORT_BUILD_VERSION)); // x.x.x-Branch + STATIC_ITEM_F(F(STRING_DISTRIBUTION_DATE)); // YYYY-MM-DD HH:MM + STATIC_ITEM_F(F(MACHINE_NAME), SS_DEFAULT|SS_INVERT); // My3DPrinter + STATIC_ITEM_F(F(WEBSITE_URL)); // www.my3dprinter.com PSTRING_ITEM(MSG_INFO_EXTRUDERS, STRINGIFY(EXTRUDERS), SS_CENTER); // Extruders: 2 #if HAS_LEVELING STATIC_ITEM( @@ -317,4 +317,4 @@ void menu_info() { END_MENU(); } -#endif // HAS_LCD_MENU && LCD_INFO_MENU +#endif // HAS_MARLINUI_MENU && LCD_INFO_MENU diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index 624b9b303d08..b48eaf9bae06 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -36,36 +36,36 @@ void lcd_move_z(); // SUBMENU(LABEL, screen_handler) class MenuItem_submenu : public MenuItemBase { public: - FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) { - _draw(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]); + FORCE_INLINE static void draw(const bool sel, const uint8_t row, FSTR_P const fstr, ...) { + _draw(sel, row, fstr, '>', LCD_STR_ARROW_RIGHT[0]); } - static inline void action(PGM_P const, const screenFunc_t func) { ui.push_current_screen(); ui.goto_screen(func); } + static void action(FSTR_P const, const screenFunc_t func) { ui.push_current_screen(); ui.goto_screen(func); } }; // Any menu item that invokes an immediate action class MenuItem_button : public MenuItemBase { public: // Button-y Items are selectable lines with no other indicator - static inline void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) { - _draw(sel, row, pstr, '>', ' '); + static void draw(const bool sel, const uint8_t row, FSTR_P const fstr, ...) { + _draw(sel, row, fstr, '>', ' '); } }; // ACTION_ITEM(LABEL, FUNC) class MenuItem_function : public MenuItem_button { public: - //static inline void action(PGM_P const, const uint8_t, const menuAction_t func) { (*func)(); }; - static inline void action(PGM_P const, const menuAction_t func) { if (func) (*func)(); }; + //static void action(FSTR_P const, const uint8_t, const menuAction_t func) { (*func)(); }; + static void action(FSTR_P const, const menuAction_t func) { if (func) (*func)(); }; }; // GCODES_ITEM(LABEL, GCODES) class MenuItem_gcode : public MenuItem_button { public: - FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) { - _draw(sel, row, pstr, '>', ' '); + FORCE_INLINE static void draw(const bool sel, const uint8_t row, FSTR_P const fstr, ...) { + _draw(sel, row, fstr, '>', ' '); } - static void action(PGM_P const, PGM_P const pgcode) { queue.inject(FPSTR(pgcode)); } - static inline void action(PGM_P const pstr, const uint8_t, PGM_P const pgcode) { action(pstr, pgcode); } + static void action(FSTR_P const, FSTR_P const fgcode) { queue.inject(fgcode); } + static void action(FSTR_P const fstr, const uint8_t, FSTR_P const fgcode) { action(fstr, fgcode); } }; //////////////////////////////////////////// @@ -77,21 +77,21 @@ template class TMenuEditItem : MenuEditItemBase { private: typedef typename NAME::type_t type_t; - static inline float scale(const_float_t value) { return NAME::scale(value); } - static inline float unscale(const_float_t value) { return NAME::unscale(value); } + 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); } public: - FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t * const data, ...) { - MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(*(data))); + 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))); } - FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t (*pget)(), ...) { - MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(pget())); + FORCE_INLINE static void draw(const bool sel, const uint8_t row, FSTR_P const fstr, type_t (*pget)(), ...) { + MenuEditItemBase::draw(sel, row, fstr, NAME::strfunc(pget())); } // Edit screen for this type of item static void edit_screen() { MenuEditItemBase::edit_screen(to_string, load); } static void action( - PGM_P const pstr, // Edit label + FSTR_P const fstr, // Edit label type_t * const ptr, // Value pointer const type_t minValue, // Value range const type_t maxValue, @@ -101,7 +101,7 @@ class TMenuEditItem : MenuEditItemBase { // 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(pstr, ptr, minv, maxv - minv, scale(*ptr) - minv, + goto_edit_screen(fstr, ptr, minv, maxv - minv, scale(*ptr) - minv, edit_screen, callback, live); } }; @@ -117,9 +117,9 @@ class TMenuEditItem : MenuEditItemBase { * * struct MenuEditItemInfo_percent { * typedef uint8_t type_t; - * static inline float scale(const_float_t value) { return value * (100.f/255.f) +0.5f; } - * static inline float unscale(const_float_t value) { return value / (100.f/255.f) +0.5f; } - * static inline const char* strfunc(const_float_t value) { return ui8tostr4pctrj(_DOFIX(uint8_t,value)); } + * 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)); } * }; * typedef TMenuEditItem MenuItem_percent */ @@ -128,9 +128,9 @@ class TMenuEditItem : MenuEditItemBase { #define DEFINE_MENU_EDIT_ITEM_TYPE(NAME, TYPE, STRFUNC, SCALE, ETC...) \ struct MenuEditItemInfo_##NAME { \ typedef TYPE type_t; \ - static inline float scale(const_float_t value) { return value * (SCALE) ETC; } \ - static inline float unscale(const_float_t value) { return value / (SCALE) ETC; } \ - static inline const char* strfunc(const_float_t value) { return STRFUNC(_DOFIX(TYPE,value)); } \ + 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)); } \ }; \ typedef TMenuEditItem MenuItem_##NAME @@ -150,7 +150,7 @@ DEFINE_MENU_EDIT_ITEM_TYPE(float43 ,float ,ftostr43sign ,1000 ); 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(float51 ,float ,ftostr51rj , 10 ); // 1234.5 right-justified +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 @@ -168,16 +168,16 @@ DEFINE_MENU_EDIT_ITEM_TYPE(long5_25 ,uint32_t ,ftostr5rj , 0.04f ); class MenuItem_bool : public MenuEditItemBase { public: - FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const bool onoff) { - MenuEditItemBase::draw(sel, row, pstr, onoff ? GET_TEXT(MSG_LCD_ON) : GET_TEXT(MSG_LCD_OFF), true); + FORCE_INLINE static void draw(const bool sel, const uint8_t row, FSTR_P const fstr, const bool onoff) { + MenuEditItemBase::draw(sel, row, fstr, onoff ? GET_TEXT_F(MSG_LCD_ON) : GET_TEXT_F(MSG_LCD_OFF)); } - FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, bool * const data, ...) { - draw(sel, row, pstr, *data); + FORCE_INLINE static void draw(const bool sel, const uint8_t row, FSTR_P const fstr, bool * const data, ...) { + draw(sel, row, fstr, *data); } - FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const, bool (*pget)(), ...) { - draw(sel, row, pstr, pget()); + FORCE_INLINE static void draw(const bool sel, const uint8_t row, FSTR_P const fstr, FSTR_P const, bool (*pget)(), ...) { + draw(sel, row, fstr, pget()); } - static void action(PGM_P const pstr, bool * const ptr, const screenFunc_t callbackFunc=nullptr) { + static void action(FSTR_P const fstr, bool * const ptr, const screenFunc_t callbackFunc=nullptr) { *ptr ^= true; ui.refresh(); if (callbackFunc) (*callbackFunc)(); } @@ -250,16 +250,16 @@ class MenuItem_bool : public MenuEditItemBase { * * Examples: * BACK_ITEM(MSG_INFO_SCREEN) - * MenuItem_back::action(plabel, ...) - * MenuItem_back::draw(sel, row, plabel, ...) + * MenuItem_back::action(flabel, ...) + * MenuItem_back::draw(sel, row, flabel, ...) * * ACTION_ITEM(MSG_PAUSE_PRINT, lcd_sdcard_pause) - * MenuItem_function::action(plabel, lcd_sdcard_pause) - * MenuItem_function::draw(sel, row, plabel, lcd_sdcard_pause) + * MenuItem_function::action(flabel, lcd_sdcard_pause) + * MenuItem_function::draw(sel, row, flabel, lcd_sdcard_pause) * * EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999) - * MenuItem_int3::action(plabel, &feedrate_percentage, 10, 999) - * MenuItem_int3::draw(sel, row, plabel, &feedrate_percentage, 10, 999) + * MenuItem_int3::action(flabel, &feedrate_percentage, 10, 999) + * MenuItem_int3::draw(sel, row, flabel, &feedrate_percentage, 10, 999) */ #if ENABLED(ENCODER_RATE_MULTIPLIER) @@ -268,52 +268,73 @@ class MenuItem_bool : public MenuEditItemBase { #define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER) #endif -#define _MENU_INNER_P(TYPE, USE_MULTIPLIER, PLABEL, V...) do { \ - PGM_P const plabel = PLABEL; \ +#define _MENU_INNER_F(TYPE, USE_MULTIPLIER, FLABEL, V...) do { \ + FSTR_P const flabel = FLABEL; \ if (encoderLine == _thisItemNr && ui.use_click()) { \ _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER); \ - MenuItem_##TYPE::action(plabel, ##V); \ + MenuItem_##TYPE::action(flabel, ##V); \ if (ui.screen_changed) return; \ } \ if (ui.should_draw()) \ MenuItem_##TYPE::draw \ - (encoderLine == _thisItemNr, _lcdLineNr, plabel, ##V); \ + (encoderLine == _thisItemNr, _lcdLineNr, flabel, ##V); \ }while(0) -#define _MENU_ITEM_P(TYPE, V...) do { \ +// Item with optional data +#define _MENU_ITEM_F(TYPE, V...) do { \ if (_menuLineNr == _thisItemNr) { \ _skipStatic = false; \ - _MENU_INNER_P(TYPE, ##V); \ + _MENU_INNER_F(TYPE, ##V); \ } \ NEXT_ITEM(); \ }while(0) -// Indexed items set a global index value and optional data -#define _MENU_ITEM_N_S_P(TYPE, N, S, V...) do{ \ +// Item with index value, C-string, and optional data +#define _MENU_ITEM_N_S_F(TYPE, N, S, V...) do{ \ if (_menuLineNr == _thisItemNr) { \ _skipStatic = false; \ MenuItemBase::init(N, S); \ - _MENU_INNER_P(TYPE, ##V); \ + _MENU_INNER_F(TYPE, ##V); \ } \ NEXT_ITEM(); \ }while(0) -// Indexed items set a global index value -#define _MENU_ITEM_N_P(TYPE, N, V...) do{ \ +// Item with index value and F-string +#define _MENU_ITEM_N_f_F(TYPE, N, f, V...) do{ \ + if (_menuLineNr == _thisItemNr) { \ + _skipStatic = false; \ + MenuItemBase::init(N, f); \ + _MENU_INNER_F(TYPE, ##V); \ + } \ + NEXT_ITEM(); \ +}while(0) + +// Item with index value +#define _MENU_ITEM_N_F(TYPE, N, V...) do{ \ if (_menuLineNr == _thisItemNr) { \ _skipStatic = false; \ - MenuItemBase::itemIndex = N; \ - _MENU_INNER_P(TYPE, ##V); \ + MenuItemBase::init(N); \ + _MENU_INNER_F(TYPE, ##V); \ } \ NEXT_ITEM(); \ }while(0) // Items with a unique string -#define _MENU_ITEM_S_P(TYPE, S, V...) do{ \ +#define _MENU_ITEM_S_F(TYPE, S, V...) do{ \ + if (_menuLineNr == _thisItemNr) { \ + _skipStatic = false; \ + MenuItemBase::init(0, S); \ + _MENU_INNER_F(TYPE, ##V); \ + } \ + NEXT_ITEM(); \ +}while(0) + +// Items with a unique F-string +#define _MENU_ITEM_f_F(TYPE, f, V...) do{ \ if (_menuLineNr == _thisItemNr) { \ _skipStatic = false; \ - MenuItemBase::itemString = S; \ - _MENU_INNER_P(TYPE, ##V); \ + MenuItemBase::init(0, f); \ + _MENU_INNER_F(TYPE, ##V); \ } \ NEXT_ITEM(); \ }while(0) @@ -321,25 +342,25 @@ class MenuItem_bool : public MenuEditItemBase { // STATIC_ITEM draws a styled string with no highlight. // Parameters: label [, style [, char *value] ] -#define STATIC_ITEM_INNER_P(PLABEL, V...) do{ \ +#define STATIC_ITEM_INNER_F(FLABEL, V...) do{ \ if (_skipStatic && encoderLine <= _thisItemNr) { \ ui.encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \ ++encoderLine; \ } \ if (ui.should_draw()) \ - MenuItem_static::draw(_lcdLineNr, PLABEL, ##V); \ + MenuItem_static::draw(_lcdLineNr, FLABEL, ##V); \ } while(0) -#define STATIC_ITEM_P(PLABEL, V...) do{ \ +#define STATIC_ITEM_F(FLABEL, V...) do{ \ if (_menuLineNr == _thisItemNr) \ - STATIC_ITEM_INNER_P(PLABEL, ##V); \ + STATIC_ITEM_INNER_F(FLABEL, ##V); \ NEXT_ITEM(); \ } while(0) -#define STATIC_ITEM_N_P(PLABEL, N, V...) do{ \ +#define STATIC_ITEM_N_F(FLABEL, N, V...) do{ \ if (_menuLineNr == _thisItemNr) { \ MenuItemBase::init(N); \ - STATIC_ITEM_INNER_P(PLABEL, ##V); \ + STATIC_ITEM_INNER_F(FLABEL, ##V); \ } \ NEXT_ITEM(); \ }while(0) @@ -347,126 +368,167 @@ class MenuItem_bool : public MenuEditItemBase { // PSTRING_ITEM is like STATIC_ITEM but it takes // two PSTRs with the style as the last parameter. -#define PSTRING_ITEM_P(PLABEL, PVAL, STYL) do{ \ +#define PSTRING_ITEM_F(FLABEL, PVAL, STYL) do{ \ constexpr int m = 20; \ char msg[m+1]; \ msg[0] = ':'; msg[1] = ' '; \ strncpy_P(msg+2, PSTR(PVAL), m-2); \ if (msg[m-1] & 0x80) msg[m-1] = '\0'; \ - STATIC_ITEM_P(PLABEL, STYL, msg); \ + STATIC_ITEM_F(FLABEL, STYL, msg); \ }while(0) -#define PSTRING_ITEM(LABEL, V...) PSTRING_ITEM_P(GET_TEXT(LABEL), ##V) +#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) + +// 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) +#define MENU_ITEM_N_S(TYPE, N, S, LABEL, V...) MENU_ITEM_N_S_F(TYPE, N, S, GET_TEXT_F(LABEL), ##V) + +// Menu item with composed C-string substitution +#define MENU_ITEM_S_F(TYPE, S, FLABEL, V...) _MENU_ITEM_S_F(TYPE, S, false, FLABEL, ##V) +#define MENU_ITEM_S(TYPE, S, LABEL, V...) MENU_ITEM_S_F(TYPE, S, GET_TEXT_F(LABEL), ##V) + +// Menu item substitution, indexed +#define MENU_ITEM_N_F(TYPE, N, FLABEL, V...) _MENU_ITEM_N_F(TYPE, N, false, FLABEL, ##V) +#define MENU_ITEM_N(TYPE, N, LABEL, V...) MENU_ITEM_N_F(TYPE, N, GET_TEXT_F(LABEL), ##V) -#define STATIC_ITEM(LABEL, V...) STATIC_ITEM_P(GET_TEXT(LABEL), ##V) -#define STATIC_ITEM_N(LABEL, N, V...) STATIC_ITEM_N_P(GET_TEXT(LABEL), N, ##V) +// Basic menu items, no substitution +#define MENU_ITEM_F(TYPE, FLABEL, V...) _MENU_ITEM_F(TYPE, false, FLABEL, ##V) +#define MENU_ITEM(TYPE, LABEL, V...) MENU_ITEM_F(TYPE, GET_TEXT_F(LABEL), ##V) -#define MENU_ITEM_N_S_P(TYPE, N, S, PLABEL, V...) _MENU_ITEM_N_S_P(TYPE, N, S, false, PLABEL, ##V) -#define MENU_ITEM_N_S(TYPE, N, S, LABEL, V...) MENU_ITEM_N_S_P(TYPE, N, S, GET_TEXT(LABEL), ##V) -#define MENU_ITEM_S_P(TYPE, S, PLABEL, V...) _MENU_ITEM_S_P(TYPE, S, false, PLABEL, ##V) -#define MENU_ITEM_S(TYPE, S, LABEL, V...) MENU_ITEM_S_P(TYPE, S, GET_TEXT(LABEL), ##V) -#define MENU_ITEM_N_P(TYPE, N, PLABEL, V...) _MENU_ITEM_N_P(TYPE, N, false, PLABEL, ##V) -#define MENU_ITEM_N(TYPE, N, LABEL, V...) MENU_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V) -#define MENU_ITEM_P(TYPE, PLABEL, V...) _MENU_ITEM_P(TYPE, false, PLABEL, ##V) -#define MENU_ITEM(TYPE, LABEL, V...) MENU_ITEM_P(TYPE, GET_TEXT(LABEL), ##V) +// Predefined menu item types // -#define BACK_ITEM_P(PLABEL) MENU_ITEM_P(back, PLABEL) +#define BACK_ITEM_F(FLABEL) MENU_ITEM_F(back, FLABEL) #define BACK_ITEM(LABEL) MENU_ITEM(back, LABEL) -#define ACTION_ITEM_N_S_P(N, S, PLABEL, ACTION) MENU_ITEM_N_S_P(function, N, S, PLABEL, ACTION) -#define ACTION_ITEM_N_S(N, S, LABEL, ACTION) ACTION_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ACTION) -#define ACTION_ITEM_S_P(S, PLABEL, ACTION) MENU_ITEM_S_P(function, S, PLABEL, ACTION) -#define ACTION_ITEM_S(S, LABEL, ACTION) ACTION_ITEM_S_P(S, GET_TEXT(LABEL), ACTION) -#define ACTION_ITEM_N_P(N, PLABEL, ACTION) MENU_ITEM_N_P(function, N, PLABEL, ACTION) -#define ACTION_ITEM_N(N, LABEL, ACTION) ACTION_ITEM_N_P(N, GET_TEXT(LABEL), ACTION) -#define ACTION_ITEM_P(PLABEL, ACTION) MENU_ITEM_P(function, PLABEL, ACTION) -#define ACTION_ITEM(LABEL, ACTION) ACTION_ITEM_P(GET_TEXT(LABEL), ACTION) - -#define GCODES_ITEM_N_S_P(N, S, PLABEL, GCODES) MENU_ITEM_N_S_P(gcode, N, S, PLABEL, GCODES) -#define GCODES_ITEM_N_S(N, S, LABEL, GCODES) GCODES_ITEM_N_S_P(N, S, GET_TEXT(LABEL), GCODES) -#define GCODES_ITEM_S_P(S, PLABEL, GCODES) MENU_ITEM_S_P(gcode, S, PLABEL, GCODES) -#define GCODES_ITEM_S(S, LABEL, GCODES) GCODES_ITEM_S_P(S, GET_TEXT(LABEL), GCODES) -#define GCODES_ITEM_N_P(N, PLABEL, GCODES) MENU_ITEM_N_P(gcode, N, PLABEL, GCODES) -#define GCODES_ITEM_N(N, LABEL, GCODES) GCODES_ITEM_N_P(N, GET_TEXT(LABEL), GCODES) -#define GCODES_ITEM_P(PLABEL, GCODES) MENU_ITEM_P(gcode, PLABEL, GCODES) -#define GCODES_ITEM(LABEL, GCODES) GCODES_ITEM_P(GET_TEXT(LABEL), GCODES) - -#define SUBMENU_N_S_P(N, S, PLABEL, DEST) MENU_ITEM_N_S_P(submenu, N, S, PLABEL, DEST) -#define SUBMENU_N_S(N, S, LABEL, DEST) SUBMENU_N_S_P(N, S, GET_TEXT(LABEL), DEST) -#define SUBMENU_S_P(S, PLABEL, DEST) MENU_ITEM_S_P(submenu, S, PLABEL, DEST) -#define SUBMENU_S(S, LABEL, DEST) SUBMENU_S_P(S, GET_TEXT(LABEL), DEST) -#define SUBMENU_N_P(N, PLABEL, DEST) MENU_ITEM_N_P(submenu, N, PLABEL, DEST) -#define SUBMENU_N(N, LABEL, DEST) SUBMENU_N_P(N, GET_TEXT(LABEL), DEST) -#define SUBMENU_P(PLABEL, DEST) MENU_ITEM_P(submenu, PLABEL, DEST) -#define SUBMENU(LABEL, DEST) SUBMENU_P(GET_TEXT(LABEL), DEST) - -#define EDIT_ITEM_N_S_P(TYPE, N, S, PLABEL, V...) MENU_ITEM_N_S_P(TYPE, N, S, PLABEL, ##V) -#define EDIT_ITEM_N_S(TYPE, N, S, LABEL, V...) EDIT_ITEM_N_S_P(TYPE, N, S, GET_TEXT(LABEL), ##V) -#define EDIT_ITEM_S_P(TYPE, S, PLABEL, V...) MENU_ITEM_S_P(TYPE, S, PLABEL, ##V) -#define EDIT_ITEM_S(TYPE, S, LABEL, V...) EDIT_ITEM_S_P(TYPE, S, GET_TEXT(LABEL), ##V) -#define EDIT_ITEM_N_P(TYPE, N, PLABEL, V...) MENU_ITEM_N_P(TYPE, N, PLABEL, ##V) -#define EDIT_ITEM_N(TYPE, N, LABEL, V...) EDIT_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V) -#define EDIT_ITEM_P(TYPE, PLABEL, V...) MENU_ITEM_P(TYPE, PLABEL, ##V) -#define EDIT_ITEM(TYPE, LABEL, V...) EDIT_ITEM_P(TYPE, GET_TEXT(LABEL), ##V) - -#define EDIT_ITEM_FAST_N_S_P(TYPE, N, S, PLABEL, V...) _MENU_ITEM_N_S_P(TYPE, N, S, true, PLABEL, ##V) -#define EDIT_ITEM_FAST_N_S(TYPE, N, S, LABEL, V...) EDIT_ITEM_FAST_N_S_P(TYPE, N, S, true, GET_TEXT(LABEL), ##V) -#define EDIT_ITEM_FAST_S_P(TYPE, S, PLABEL, V...) _MENU_ITEM_S_P(TYPE, S, true, PLABEL, ##V) -#define EDIT_ITEM_FAST_S(TYPE, S, LABEL, V...) EDIT_ITEM_FAST_S_P(TYPE, S, GET_TEXT(LABEL), ##V) -#define EDIT_ITEM_FAST_N_P(TYPE, N, PLABEL, V...) _MENU_ITEM_N_P(TYPE, N, true, PLABEL, ##V) -#define EDIT_ITEM_FAST_N(TYPE, N, LABEL, V...) EDIT_ITEM_FAST_N_P(TYPE, N, GET_TEXT(LABEL), ##V) -#define EDIT_ITEM_FAST_P(TYPE, PLABEL, V...) _MENU_ITEM_P(TYPE, true, PLABEL, ##V) -#define EDIT_ITEM_FAST(TYPE, LABEL, V...) EDIT_ITEM_FAST_P(TYPE, GET_TEXT(LABEL), ##V) - -#define _CONFIRM_ITEM_INNER_P(PLABEL, V...) do { \ +#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) +#define ACTION_ITEM_S_F(S, FLABEL, ACTION) MENU_ITEM_S_F(function, S, FLABEL, ACTION) +#define ACTION_ITEM_S(S, LABEL, ACTION) ACTION_ITEM_S_F(S, GET_TEXT_F(LABEL), ACTION) +#define ACTION_ITEM_N_F(N, FLABEL, ACTION) MENU_ITEM_N_F(function, N, FLABEL, ACTION) +#define ACTION_ITEM_N(N, LABEL, ACTION) ACTION_ITEM_N_F(N, GET_TEXT_F(LABEL), ACTION) +#define ACTION_ITEM_F(FLABEL, ACTION) MENU_ITEM_F(function, FLABEL, ACTION) +#define ACTION_ITEM(LABEL, ACTION) ACTION_ITEM_F(GET_TEXT_F(LABEL), ACTION) + +#define GCODES_ITEM_N_S_F(N, S, FLABEL, GCODES) MENU_ITEM_N_S_F(gcode, N, S, FLABEL, GCODES) +#define GCODES_ITEM_N_S(N, S, LABEL, GCODES) GCODES_ITEM_N_S_F(N, S, GET_TEXT_F(LABEL), GCODES) +#define GCODES_ITEM_S_F(S, FLABEL, GCODES) MENU_ITEM_S_F(gcode, S, FLABEL, GCODES) +#define GCODES_ITEM_S(S, LABEL, GCODES) GCODES_ITEM_S_F(S, GET_TEXT_F(LABEL), GCODES) +#define GCODES_ITEM_N_F(N, FLABEL, GCODES) MENU_ITEM_N_F(gcode, N, FLABEL, GCODES) +#define GCODES_ITEM_N(N, LABEL, GCODES) GCODES_ITEM_N_F(N, GET_TEXT_F(LABEL), GCODES) +#define GCODES_ITEM_F(FLABEL, GCODES) MENU_ITEM_F(gcode, FLABEL, GCODES) +#define GCODES_ITEM(LABEL, GCODES) GCODES_ITEM_F(GET_TEXT_F(LABEL), GCODES) + +#define SUBMENU_N_S_F(N, S, FLABEL, DEST) MENU_ITEM_N_S_F(submenu, N, S, FLABEL, DEST) +#define SUBMENU_N_S(N, S, LABEL, DEST) SUBMENU_N_S_F(N, S, GET_TEXT_F(LABEL), DEST) +#define SUBMENU_S_F(S, FLABEL, DEST) MENU_ITEM_S_F(submenu, S, FLABEL, DEST) +#define SUBMENU_S(S, LABEL, DEST) SUBMENU_S_F(S, GET_TEXT_F(LABEL), DEST) +#define SUBMENU_N_F(N, FLABEL, DEST) MENU_ITEM_N_F(submenu, N, FLABEL, DEST) +#define SUBMENU_N(N, LABEL, DEST) SUBMENU_N_F(N, GET_TEXT_F(LABEL), DEST) +#define SUBMENU_F(FLABEL, DEST) MENU_ITEM_F(submenu, FLABEL, DEST) +#define SUBMENU(LABEL, DEST) SUBMENU_F(GET_TEXT_F(LABEL), DEST) + +#define EDIT_ITEM_N_S_F(TYPE, N, S, FLABEL, V...) MENU_ITEM_N_S_F(TYPE, N, S, FLABEL, ##V) +#define EDIT_ITEM_N_S(TYPE, N, S, LABEL, V...) EDIT_ITEM_N_S_F(TYPE, N, S, GET_TEXT_F(LABEL), ##V) +#define EDIT_ITEM_S_F(TYPE, S, FLABEL, V...) MENU_ITEM_S_F(TYPE, S, FLABEL, ##V) +#define EDIT_ITEM_S(TYPE, S, LABEL, V...) EDIT_ITEM_S_F(TYPE, S, GET_TEXT_F(LABEL), ##V) +#define EDIT_ITEM_N_F(TYPE, N, FLABEL, V...) MENU_ITEM_N_F(TYPE, N, FLABEL, ##V) +#define EDIT_ITEM_N(TYPE, N, LABEL, V...) EDIT_ITEM_N_F(TYPE, N, GET_TEXT_F(LABEL), ##V) +#define EDIT_ITEM_F(TYPE, FLABEL, V...) MENU_ITEM_F(TYPE, FLABEL, ##V) +#define EDIT_ITEM(TYPE, LABEL, V...) EDIT_ITEM_F(TYPE, GET_TEXT_F(LABEL), ##V) + +#define EDIT_ITEM_FAST_N_S_F(TYPE, N, S, FLABEL, V...) _MENU_ITEM_N_S_F(TYPE, N, S, true, FLABEL, ##V) +#define EDIT_ITEM_FAST_N_S(TYPE, N, S, LABEL, V...) EDIT_ITEM_FAST_N_S_F(TYPE, N, S, true, GET_TEXT_F(LABEL), ##V) +#define EDIT_ITEM_FAST_S_F(TYPE, S, FLABEL, V...) _MENU_ITEM_S_F(TYPE, S, true, FLABEL, ##V) +#define EDIT_ITEM_FAST_S(TYPE, S, LABEL, V...) EDIT_ITEM_FAST_S_F(TYPE, S, GET_TEXT_F(LABEL), ##V) +#define EDIT_ITEM_FAST_N_F(TYPE, N, FLABEL, V...) _MENU_ITEM_N_F(TYPE, N, true, FLABEL, ##V) +#define EDIT_ITEM_FAST_N(TYPE, N, LABEL, V...) EDIT_ITEM_FAST_N_F(TYPE, N, GET_TEXT_F(LABEL), ##V) +#define EDIT_ITEM_FAST_F(TYPE, FLABEL, V...) _MENU_ITEM_F(TYPE, true, FLABEL, ##V) +#define EDIT_ITEM_FAST(TYPE, LABEL, V...) EDIT_ITEM_FAST_F(TYPE, GET_TEXT_F(LABEL), ##V) + +// F-string substitution instead of C-string // + +#define MENU_ITEM_N_f_F(TYPE, N, f, FLABEL, V...) _MENU_ITEM_N_f_F(TYPE, N, f, false, FLABEL, ##V) +#define MENU_ITEM_N_f(TYPE, N, f, LABEL, V...) MENU_ITEM_N_f_F(TYPE, N, f, GET_TEXT_F(LABEL), ##V) +#define MENU_ITEM_f_F(TYPE, f, FLABEL, V...) _MENU_ITEM_f_F(TYPE, f, false, FLABEL, ##V) +#define MENU_ITEM_f(TYPE, f, LABEL, V...) MENU_ITEM_f_F(TYPE, f, GET_TEXT_F(LABEL), ##V) + +#define ACTION_ITEM_N_f_F(N, f, FLABEL, ACTION) MENU_ITEM_N_f_F(function, N, f, FLABEL, ACTION) +#define ACTION_ITEM_N_f(N, f, LABEL, ACTION) ACTION_ITEM_N_f_F(N, f, GET_TEXT_F(LABEL), ACTION) +#define ACTION_ITEM_f_F(f, FLABEL, ACTION) MENU_ITEM_f_F(function, f, FLABEL, ACTION) +#define ACTION_ITEM_f(f, LABEL, ACTION) ACTION_ITEM_f_F(f, GET_TEXT_F(LABEL), ACTION) + +#define GCODES_ITEM_N_f_F(N, f, FLABEL, GCODES) MENU_ITEM_N_f_F(gcode, N, f, FLABEL, GCODES) +#define GCODES_ITEM_N_f(N, f, LABEL, GCODES) GCODES_ITEM_N_f_F(N, f, GET_TEXT_F(LABEL), GCODES) +#define GCODES_ITEM_f_F(f, FLABEL, GCODES) MENU_ITEM_f_F(gcode, f, FLABEL, GCODES) +#define GCODES_ITEM_f(f, LABEL, GCODES) GCODES_ITEM_f_F(f, GET_TEXT_F(LABEL), GCODES) + +#define SUBMENU_N_f_F(N, f, FLABEL, DEST) MENU_ITEM_N_f_F(submenu, N, f, FLABEL, DEST) +#define SUBMENU_N_f(N, f, LABEL, DEST) SUBMENU_N_f_F(N, f, GET_TEXT_F(LABEL), DEST) +#define SUBMENU_f_F(f, FLABEL, DEST) MENU_ITEM_f_F(submenu, f, FLABEL, DEST) +#define SUBMENU_f(f, LABEL, DEST) SUBMENU_f_F(f, GET_TEXT_F(LABEL), DEST) + +#define EDIT_ITEM_N_f_F(TYPE, N, f, FLABEL, V...) MENU_ITEM_N_f_F(TYPE, N, f, FLABEL, ##V) +#define EDIT_ITEM_N_f(TYPE, N, f, LABEL, V...) EDIT_ITEM_N_f_F(TYPE, N, f, GET_TEXT_F(LABEL), ##V) +#define EDIT_ITEM_f_F(TYPE, f, FLABEL, V...) MENU_ITEM_f_F(TYPE, f, FLABEL, ##V) +#define EDIT_ITEM_f(TYPE, f, LABEL, V...) EDIT_ITEM_f_F(TYPE, f, GET_TEXT_F(LABEL), ##V) + +#define EDIT_ITEM_FAST_N_f_F(TYPE, N, f, FLABEL, V...) _MENU_ITEM_N_f_F(TYPE, N, f, true, FLABEL, ##V) +#define EDIT_ITEM_FAST_N_f(TYPE, N, f, LABEL, V...) EDIT_ITEM_FAST_N_f_F(TYPE, N, f, true, GET_TEXT_F(LABEL), ##V) +#define EDIT_ITEM_FAST_f_F(TYPE, f, FLABEL, V...) _MENU_ITEM_f_F(TYPE, f, true, FLABEL, ##V) +#define EDIT_ITEM_FAST_f(TYPE, f, LABEL, V...) EDIT_ITEM_FAST_f_F(TYPE, f, GET_TEXT_F(LABEL), ##V) + +#define _CONFIRM_ITEM_INNER_F(FLABEL, V...) do { \ if (encoderLine == _thisItemNr && ui.use_click()) { \ ui.push_current_screen(); \ ui.goto_screen([]{MenuItem_confirm::select_screen(V);}); \ return; \ } \ if (ui.should_draw()) MenuItem_confirm::draw \ - (encoderLine == _thisItemNr, _lcdLineNr, PLABEL, ##V); \ + (encoderLine == _thisItemNr, _lcdLineNr, FLABEL, ##V); \ }while(0) // Indexed items set a global index value and optional data -#define _CONFIRM_ITEM_P(PLABEL, V...) do { \ +#define _CONFIRM_ITEM_F(FLABEL, V...) do { \ if (_menuLineNr == _thisItemNr) { \ _skipStatic = false; \ - _CONFIRM_ITEM_INNER_P(PLABEL, ##V); \ + _CONFIRM_ITEM_INNER_F(FLABEL, ##V); \ } \ NEXT_ITEM(); \ }while(0) // Indexed items set a global index value -#define _CONFIRM_ITEM_N_S_P(N, S, V...) do{ \ +#define _CONFIRM_ITEM_N_S_F(N, S, V...) do{ \ if (_menuLineNr == _thisItemNr) { \ _skipStatic = false; \ MenuItemBase::init(N, S); \ - _CONFIRM_ITEM_INNER_P(TYPE, ##V); \ + _CONFIRM_ITEM_INNER_F(TYPE, ##V); \ } \ NEXT_ITEM(); \ }while(0) // Indexed items set a global index value -#define _CONFIRM_ITEM_N_P(N, V...) _CONFIRM_ITEM_N_S_P(N, nullptr, V) +#define _CONFIRM_ITEM_N_F(N, V...) _CONFIRM_ITEM_N_S_F(N, nullptr, V) -#define CONFIRM_ITEM_P(PLABEL,A,B,V...) _CONFIRM_ITEM_P(PLABEL, GET_TEXT(A), GET_TEXT(B), ##V) -#define CONFIRM_ITEM(LABEL, V...) CONFIRM_ITEM_P(GET_TEXT(LABEL), ##V) +#define CONFIRM_ITEM_F(FLABEL,A,B,V...) _CONFIRM_ITEM_F(FLABEL, GET_TEXT_F(A), GET_TEXT_F(B), ##V) +#define CONFIRM_ITEM(LABEL, V...) CONFIRM_ITEM_F(GET_TEXT_F(LABEL), ##V) -#define YESNO_ITEM_P(PLABEL, V...) CONFIRM_ITEM_P(PLABEL, MSG_YES, MSG_NO, ##V) -#define YESNO_ITEM(LABEL, V...) YESNO_ITEM_P(GET_TEXT(LABEL), ##V) +#define YESNO_ITEM_F(FLABEL, V...) CONFIRM_ITEM_F(FLABEL, MSG_YES, MSG_NO, ##V) +#define YESNO_ITEM(LABEL, V...) YESNO_ITEM_F(GET_TEXT_F(LABEL), ##V) -#define CONFIRM_ITEM_N_S_P(N,S,PLABEL,A,B,V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V) -#define CONFIRM_ITEM_N_S(N,S,LABEL,V...) CONFIRM_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V) -#define CONFIRM_ITEM_N_P(N,PLABEL,A,B,V...) _CONFIRM_ITEM_N_P(N, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V) -#define CONFIRM_ITEM_N(N,LABEL, V...) CONFIRM_ITEM_N_P(N, GET_TEXT(LABEL), ##V) +#define CONFIRM_ITEM_N_S_F(N,S,FLABEL,A,B,V...) _CONFIRM_ITEM_N_S_F(N, S, FLABEL, GET_TEXT_F(A), GET_TEXT_F(B), ##V) +#define CONFIRM_ITEM_N_S(N,S,LABEL,V...) CONFIRM_ITEM_N_S_F(N, S, GET_TEXT_F(LABEL), ##V) +#define CONFIRM_ITEM_N_F(N,FLABEL,A,B,V...) _CONFIRM_ITEM_N_F(N, FLABEL, GET_TEXT_F(A), GET_TEXT_F(B), ##V) +#define CONFIRM_ITEM_N(N,LABEL, V...) CONFIRM_ITEM_N_F(N, GET_TEXT_F(LABEL), ##V) -#define YESNO_ITEM_N_S_P(N,S,PLABEL, V...) _CONFIRM_ITEM_N_S_P(N, S, PLABEL, MSG_YES, MSG_NO, ##V) -#define YESNO_ITEM_N_S(N,S,LABEL, V...) YESNO_ITEM_N_S_P(N, S, GET_TEXT(LABEL), ##V) -#define YESNO_ITEM_N_P(N,PLABEL, V...) CONFIRM_ITEM_N_P(N, PLABEL, MSG_YES, MSG_NO, ##V) -#define YESNO_ITEM_N(N,LABEL, V...) YESNO_ITEM_N_P(N, GET_TEXT(LABEL), ##V) +#define YESNO_ITEM_N_S_F(N,S,FLABEL, V...) _CONFIRM_ITEM_N_S_F(N, S, FLABEL, MSG_YES, MSG_NO, ##V) +#define YESNO_ITEM_N_S(N,S,LABEL, V...) YESNO_ITEM_N_S_F(N, S, GET_TEXT_F(LABEL), ##V) +#define YESNO_ITEM_N_F(N,FLABEL, V...) CONFIRM_ITEM_N_F(N, FLABEL, MSG_YES, MSG_NO, ##V) +#define YESNO_ITEM_N(N,LABEL, V...) YESNO_ITEM_N_F(N, GET_TEXT_F(LABEL), ##V) -#if ENABLED(LEVEL_BED_CORNERS) +#if ENABLED(LCD_BED_TRAMMING) void _lcd_level_bed_corners(); #endif diff --git a/Marlin/src/lcd/menu/menu_job_recovery.cpp b/Marlin/src/lcd/menu/menu_job_recovery.cpp index 963806b1d6b3..6329c5839786 100644 --- a/Marlin/src/lcd/menu/menu_job_recovery.cpp +++ b/Marlin/src/lcd/menu/menu_job_recovery.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, POWER_LOSS_RECOVERY) +#if BOTH(HAS_MARLINUI_MENU, POWER_LOSS_RECOVERY) #include "menu_item.h" #include "../../gcode/queue.h" @@ -54,4 +54,4 @@ void menu_job_recovery() { END_MENU(); } -#endif // HAS_LCD_MENU && POWER_LOSS_RECOVERY +#endif // HAS_MARLINUI_MENU && POWER_LOSS_RECOVERY diff --git a/Marlin/src/lcd/menu/menu_language.cpp b/Marlin/src/lcd/menu/menu_language.cpp index 4c4b7880f2c3..2ea4359c6bb7 100644 --- a/Marlin/src/lcd/menu/menu_language.cpp +++ b/Marlin/src/lcd/menu/menu_language.cpp @@ -41,14 +41,14 @@ void menu_language() { START_MENU(); BACK_ITEM(MSG_MAIN); - MENU_ITEM_P(function, GET_LANG(LCD_LANGUAGE )::LANGUAGE, []{ set_lcd_language(0); }); - MENU_ITEM_P(function, GET_LANG(LCD_LANGUAGE_2)::LANGUAGE, []{ set_lcd_language(1); }); + MENU_ITEM_F(function, FPSTR(GET_LANGUAGE_NAME(1)), []{ set_lcd_language(0); }); + MENU_ITEM_F(function, FPSTR(GET_LANGUAGE_NAME(2)), []{ set_lcd_language(1); }); #if NUM_LANGUAGES > 2 - MENU_ITEM_P(function, GET_LANG(LCD_LANGUAGE_3)::LANGUAGE, []{ set_lcd_language(2); }); + MENU_ITEM_F(function, FPSTR(GET_LANGUAGE_NAME(3)), []{ set_lcd_language(2); }); #if NUM_LANGUAGES > 3 - MENU_ITEM_P(function, GET_LANG(LCD_LANGUAGE_4)::LANGUAGE, []{ set_lcd_language(3); }); + MENU_ITEM_F(function, FPSTR(GET_LANGUAGE_NAME(4)), []{ set_lcd_language(3); }); #if NUM_LANGUAGES > 4 - MENU_ITEM_P(function, GET_LANG(LCD_LANGUAGE_5)::LANGUAGE, []{ set_lcd_language(4); }); + MENU_ITEM_F(function, FPSTR(GET_LANGUAGE_NAME(5)), []{ set_lcd_language(4); }); #endif #endif #endif diff --git a/Marlin/src/lcd/menu/menu_led.cpp b/Marlin/src/lcd/menu/menu_led.cpp index 3261ecc65874..0c08f6fa944b 100644 --- a/Marlin/src/lcd/menu/menu_led.cpp +++ b/Marlin/src/lcd/menu/menu_led.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU && EITHER(LED_CONTROL_MENU, CASE_LIGHT_MENU) +#if HAS_MARLINUI_MENU && EITHER(LED_CONTROL_MENU, CASE_LIGHT_MENU) #include "menu_item.h" @@ -169,4 +169,4 @@ void menu_led() { END_MENU(); } -#endif // HAS_LCD_MENU && LED_CONTROL_MENU +#endif // HAS_MARLINUI_MENU && LED_CONTROL_MENU diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 6e66188c02ce..518f1e0f502d 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "menu_item.h" #include "../../module/temperature.h" @@ -124,13 +124,13 @@ void menu_configuration(); #define _DONE_SCRIPT "" #endif #define GCODE_LAMBDA_MAIN(N) []{ _lcd_custom_menu_main_gcode(F(MAIN_MENU_ITEM_##N##_GCODE _DONE_SCRIPT)); } - #define _CUSTOM_ITEM_MAIN(N) ACTION_ITEM_P(PSTR(MAIN_MENU_ITEM_##N##_DESC), GCODE_LAMBDA_MAIN(N)); - #define _CUSTOM_ITEM_MAIN_CONFIRM(N) \ - SUBMENU_P(PSTR(MAIN_MENU_ITEM_##N##_DESC), []{ \ - MenuItem_confirm::confirm_screen( \ - GCODE_LAMBDA_MAIN(N), nullptr, \ - PSTR(MAIN_MENU_ITEM_##N##_DESC "?") \ - ); \ + #define _CUSTOM_ITEM_MAIN(N) ACTION_ITEM_F(F(MAIN_MENU_ITEM_##N##_DESC), GCODE_LAMBDA_MAIN(N)); + #define _CUSTOM_ITEM_MAIN_CONFIRM(N) \ + SUBMENU_F(F(MAIN_MENU_ITEM_##N##_DESC), []{ \ + MenuItem_confirm::confirm_screen( \ + GCODE_LAMBDA_MAIN(N), nullptr, \ + F(MAIN_MENU_ITEM_##N##_DESC "?") \ + ); \ }) #define CUSTOM_ITEM_MAIN(N) do{ \ @@ -246,11 +246,11 @@ void menu_main() { if (card_detected) { if (!card_open) { - #if PIN_EXISTS(SD_DETECT) - GCODES_ITEM(MSG_CHANGE_MEDIA, PSTR("M21")); // M21 Change Media - #else // - or - - ACTION_ITEM(MSG_RELEASE_MEDIA, []{ // M22 Release Media - queue.inject(PSTR("M22")); + #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--; @@ -258,14 +258,14 @@ void menu_main() { #endif }); #endif - SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); // Media Menu (or Password First) + SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); // Media Menu (or Password First) } } else { - #if PIN_EXISTS(SD_DETECT) - ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media" + #if HAS_SD_DETECT + ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media" #else - GCODES_ITEM(MSG_ATTACH_MEDIA, PSTR("M21")); // M21 Attach Media + GCODES_ITEM(MSG_ATTACH_MEDIA, F("M21")); // M21 Attach Media #endif } }; @@ -279,9 +279,9 @@ void menu_main() { #if MACHINE_CAN_STOP SUBMENU(MSG_STOP_PRINT, []{ MenuItem_confirm::select_screen( - GET_TEXT(MSG_BUTTON_STOP), GET_TEXT(MSG_BACK), + GET_TEXT_F(MSG_BUTTON_STOP), GET_TEXT_F(MSG_BACK), ui.abort_print, nullptr, - GET_TEXT(MSG_STOP_PRINT), (const char *)nullptr, PSTR("?") + GET_TEXT_F(MSG_STOP_PRINT), (const char *)nullptr, F("?") ); }); #endif @@ -342,7 +342,7 @@ void menu_main() { #if ENABLED(CUSTOM_MENU_MAIN) if (TERN1(CUSTOM_MENU_MAIN_ONLY_IDLE, !busy)) { #ifdef CUSTOM_MENU_MAIN_TITLE - SUBMENU_P(PSTR(CUSTOM_MENU_MAIN_TITLE), custom_menus_main); + SUBMENU_F(F(CUSTOM_MENU_MAIN_TITLE), custom_menus_main); #else SUBMENU(MSG_CUSTOM_COMMANDS, custom_menus_main); #endif @@ -353,7 +353,7 @@ void menu_main() { #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES) YESNO_ITEM(MSG_FILAMENTCHANGE, menu_change_filament, nullptr, - GET_TEXT(MSG_FILAMENTCHANGE), (const char *)nullptr, PSTR("?") + GET_TEXT_F(MSG_FILAMENTCHANGE), (const char *)nullptr, F("?") ); #else SUBMENU(MSG_FILAMENTCHANGE, menu_change_filament); @@ -377,13 +377,13 @@ void menu_main() { CONFIRM_ITEM(MSG_SWITCH_PS_OFF, MSG_YES, MSG_NO, ui.poweroff, nullptr, - GET_TEXT(MSG_SWITCH_PS_OFF), (const char *)nullptr, PSTR("?") + GET_TEXT_F(MSG_SWITCH_PS_OFF), (const char *)nullptr, F("?") ); #else - GCODES_ITEM(MSG_SWITCH_PS_OFF, PSTR("M81")); + ACTION_ITEM(MSG_SWITCH_PS_OFF, ui.poweroff); #endif else - GCODES_ITEM(MSG_SWITCH_PS_ON, PSTR("M80")); + GCODES_ITEM(MSG_SWITCH_PS_ON, F("M80")); #endif #if ENABLED(SDSUPPORT) && DISABLED(MEDIA_MENU_AT_TOP) @@ -398,24 +398,24 @@ void menu_main() { ui.return_to_status(); }; #if SERVICE_INTERVAL_1 > 0 - CONFIRM_ITEM_P(PSTR(SERVICE_NAME_1), + CONFIRM_ITEM_F(F(SERVICE_NAME_1), MSG_BUTTON_RESET, MSG_BUTTON_CANCEL, []{ _service_reset(1); }, nullptr, - GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_1), PSTR("?") + GET_TEXT_F(MSG_SERVICE_RESET), F(SERVICE_NAME_1), F("?") ); #endif #if SERVICE_INTERVAL_2 > 0 - CONFIRM_ITEM_P(PSTR(SERVICE_NAME_2), + CONFIRM_ITEM_F(F(SERVICE_NAME_2), MSG_BUTTON_RESET, MSG_BUTTON_CANCEL, []{ _service_reset(2); }, nullptr, - GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_2), PSTR("?") + GET_TEXT_F(MSG_SERVICE_RESET), F(SERVICE_NAME_2), F("?") ); #endif #if SERVICE_INTERVAL_3 > 0 - CONFIRM_ITEM_P(PSTR(SERVICE_NAME_3), + CONFIRM_ITEM_F(F(SERVICE_NAME_3), MSG_BUTTON_RESET, MSG_BUTTON_CANCEL, []{ _service_reset(3); }, nullptr, - GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_3), PSTR("?") + GET_TEXT_F(MSG_SERVICE_RESET), F(SERVICE_NAME_3), F("?") ); #endif #endif @@ -451,9 +451,9 @@ void menu_main() { #if ENABLED(HOST_SHUTDOWN_MENU_ITEM) && defined(SHUTDOWN_ACTION) SUBMENU(MSG_HOST_SHUTDOWN, []{ MenuItem_confirm::select_screen( - GET_TEXT(MSG_BUTTON_PROCEED), GET_TEXT(MSG_BUTTON_CANCEL), + GET_TEXT_F(MSG_BUTTON_PROCEED), GET_TEXT_F(MSG_BUTTON_CANCEL), []{ ui.return_to_status(); hostui.shutdown(); }, nullptr, - GET_TEXT(MSG_HOST_SHUTDOWN), (const char *)nullptr, PSTR("?") + GET_TEXT_F(MSG_HOST_SHUTDOWN), (const char *)nullptr, F("?") ); }); #endif @@ -461,4 +461,4 @@ void menu_main() { END_MENU(); } -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU diff --git a/Marlin/src/lcd/menu/menu_media.cpp b/Marlin/src/lcd/menu/menu_media.cpp index 4ce0a396d4e4..20ef6e3d198f 100644 --- a/Marlin/src/lcd/menu/menu_media.cpp +++ b/Marlin/src/lcd/menu/menu_media.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, SDSUPPORT) +#if BOTH(HAS_MARLINUI_MENU, SDSUPPORT) #include "menu_item.h" #include "../../sd/cardreader.h" @@ -61,10 +61,10 @@ inline void sdcard_start_selected_file() { class MenuItem_sdfile : public MenuItem_sdbase { public: - static inline void draw(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard) { - MenuItem_sdbase::draw(sel, row, pstr, theCard, false); + static inline void draw(const bool sel, const uint8_t row, FSTR_P const fstr, CardReader &theCard) { + MenuItem_sdbase::draw(sel, row, fstr, theCard, false); } - static void action(PGM_P const pstr, CardReader &) { + static void action(FSTR_P const fstr, CardReader &) { #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE) // Save menu state for the selected file sd_encoder_position = ui.encoderPosition; @@ -72,30 +72,30 @@ class MenuItem_sdfile : public MenuItem_sdbase { sd_items = screen_items; #endif #if ENABLED(SD_MENU_CONFIRM_START) - MenuItem_submenu::action(pstr, []{ + MenuItem_submenu::action(fstr, []{ char * const longest = card.longest_filename(); char buffer[strlen(longest) + 2]; buffer[0] = ' '; strcpy(buffer + 1, longest); MenuItem_confirm::select_screen( - GET_TEXT(MSG_BUTTON_PRINT), GET_TEXT(MSG_BUTTON_CANCEL), + GET_TEXT_F(MSG_BUTTON_PRINT), GET_TEXT_F(MSG_BUTTON_CANCEL), sdcard_start_selected_file, nullptr, - GET_TEXT(MSG_START_PRINT), buffer, PSTR("?") + GET_TEXT_F(MSG_START_PRINT), buffer, F("?") ); }); #else sdcard_start_selected_file(); - UNUSED(pstr); + UNUSED(fstr); #endif } }; class MenuItem_sdfolder : public MenuItem_sdbase { public: - static inline void draw(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard) { - MenuItem_sdbase::draw(sel, row, pstr, theCard, true); + static inline void draw(const bool sel, const uint8_t row, FSTR_P const fstr, CardReader &theCard) { + MenuItem_sdbase::draw(sel, row, fstr, theCard, true); } - static void action(PGM_P const, CardReader &theCard) { + static void action(FSTR_P const, CardReader &theCard) { card.cd(theCard.filename); encoderTopLine = 0; ui.encoderPosition = 2 * (ENCODER_STEPS_PER_MENU_ITEM); @@ -119,15 +119,15 @@ void menu_media_filelist() { #if ENABLED(MULTI_VOLUME) ACTION_ITEM(MSG_BACK, []{ ui.goto_screen(menu_media); }); #else - BACK_ITEM_P(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT(MSG_MAIN) : GET_TEXT(MSG_BACK)); + BACK_ITEM_F(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT_F(MSG_MAIN) : GET_TEXT_F(MSG_BACK)); #endif if (card.flag.workDirIsRoot) { - #if !PIN_EXISTS(SD_DETECT) + #if !HAS_SD_DETECT ACTION_ITEM(MSG_REFRESH, []{ encoderTopLine = 0; card.mount(); }); #endif } else if (card.isMounted()) - ACTION_ITEM_P(PSTR(LCD_STR_FOLDER " .."), lcd_sd_updir); + ACTION_ITEM_F(F(LCD_STR_FOLDER " .."), lcd_sd_updir); if (ui.should_draw()) for (uint16_t i = 0; i < fileCnt; i++) { if (_menuLineNr == _thisItemNr) { @@ -146,7 +146,7 @@ void menu_media_filelist() { #if ENABLED(MULTI_VOLUME) void menu_media_select() { START_MENU(); - BACK_ITEM_P(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT(MSG_MAIN) : GET_TEXT(MSG_BACK)); + BACK_ITEM_F(TERN1(BROWSE_MEDIA_ON_INSERT, screen_history_depth) ? GET_TEXT_F(MSG_MAIN) : GET_TEXT_F(MSG_BACK)); #if ENABLED(VOLUME_SD_ONBOARD) ACTION_ITEM(MSG_SD_CARD, []{ card.changeMedia(&card.media_driver_sdcard); card.mount(); ui.goto_screen(menu_media_filelist); }); #endif @@ -161,4 +161,4 @@ void menu_media() { TERN(MULTI_VOLUME, menu_media_select, menu_media_filelist)(); } -#endif // HAS_LCD_MENU && SDSUPPORT +#endif // HAS_MARLINUI_MENU && SDSUPPORT diff --git a/Marlin/src/lcd/menu/menu_mixer.cpp b/Marlin/src/lcd/menu/menu_mixer.cpp index be4363574b26..feb4c59f181c 100644 --- a/Marlin/src/lcd/menu/menu_mixer.cpp +++ b/Marlin/src/lcd/menu/menu_mixer.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, MIXING_EXTRUDER) +#if BOTH(HAS_MARLINUI_MENU, MIXING_EXTRUDER) #include "menu_item.h" #include "menu_addon.h" @@ -89,15 +89,15 @@ char tmp[18]; - PGM_P const slabel = GET_TEXT(MSG_START_Z); - SUBMENU_P(slabel, []{ _lcd_mixer_gradient_z_edit(false); }); + FSTR_P const slabel = GET_TEXT_F(MSG_START_Z); + SUBMENU_F(slabel, []{ _lcd_mixer_gradient_z_edit(false); }); MENU_ITEM_ADDON_START_RJ(11); sprintf_P(tmp, PSTR("%4d.%d mm"), int(mixer.gradient.start_z), int(mixer.gradient.start_z * 10) % 10); lcd_put_u8str(tmp); MENU_ITEM_ADDON_END(); - PGM_P const elabel = GET_TEXT(MSG_END_Z); - SUBMENU_P(elabel, []{ _lcd_mixer_gradient_z_edit(true); }); + FSTR_P const elabel = GET_TEXT_F(MSG_END_Z); + SUBMENU_F(elabel, []{ _lcd_mixer_gradient_z_edit(true); }); MENU_ITEM_ADDON_START_RJ(11); sprintf_P(tmp, PSTR("%4d.%d mm"), int(mixer.gradient.end_z), int(mixer.gradient.end_z * 10) % 10); lcd_put_u8str(tmp); @@ -257,7 +257,7 @@ void menu_mixer() { ui.return_to_status(); }, nullptr, - GET_TEXT(MSG_RESET_VTOOLS), (const char *)nullptr, PSTR("?") + GET_TEXT_F(MSG_RESET_VTOOLS), (const char *)nullptr, F("?") ); #if ENABLED(GRADIENT_MIX) @@ -275,4 +275,4 @@ void menu_mixer() { END_MENU(); } -#endif // HAS_LCD_MENU && MIXING_EXTRUDER +#endif // HAS_MARLINUI_MENU && MIXING_EXTRUDER diff --git a/Marlin/src/lcd/menu/menu_mmu2.cpp b/Marlin/src/lcd/menu/menu_mmu2.cpp index 99e5c0624517..a2412b0f6ae8 100644 --- a/Marlin/src/lcd/menu/menu_mmu2.cpp +++ b/Marlin/src/lcd/menu/menu_mmu2.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfig.h" -#if BOTH(HAS_LCD_MENU, MMU2_MENUS) +#if BOTH(HAS_MARLINUI_MENU, MMU2_MENUS) #include "../../MarlinCore.h" #include "../../feature/mmu/mmu2.h" @@ -48,7 +48,7 @@ void _mmu2_load_filament(uint8_t index) { ui.reset_status(); } void action_mmu2_load_all() { - LOOP_L_N(i, EXTRUDERS) _mmu2_load_filament(i); + EXTRUDER_LOOP() _mmu2_load_filament(e); ui.return_to_status(); } @@ -56,14 +56,14 @@ void menu_mmu2_load_filament() { START_MENU(); BACK_ITEM(MSG_MMU2_MENU); ACTION_ITEM(MSG_MMU2_ALL, action_mmu2_load_all); - LOOP_L_N(i, EXTRUDERS) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ _mmu2_load_filament(MenuItemBase::itemIndex); }); + EXTRUDER_LOOP() ACTION_ITEM_N(e, MSG_MMU2_FILAMENT_N, []{ _mmu2_load_filament(MenuItemBase::itemIndex); }); END_MENU(); } void menu_mmu2_load_to_nozzle() { START_MENU(); BACK_ITEM(MSG_MMU2_MENU); - LOOP_L_N(i, EXTRUDERS) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ action_mmu2_load_filament_to_nozzle(MenuItemBase::itemIndex); }); + EXTRUDER_LOOP() ACTION_ITEM_N(e, MSG_MMU2_FILAMENT_N, []{ action_mmu2_load_filament_to_nozzle(MenuItemBase::itemIndex); }); END_MENU(); } @@ -89,7 +89,7 @@ void action_mmu2_unload_filament() { void menu_mmu2_eject_filament() { START_MENU(); BACK_ITEM(MSG_MMU2_MENU); - LOOP_L_N(i, EXTRUDERS) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ _mmu2_eject_filament(MenuItemBase::itemIndex); }); + EXTRUDER_LOOP() ACTION_ITEM_N(e, MSG_MMU2_FILAMENT_N, []{ _mmu2_eject_filament(MenuItemBase::itemIndex); }); END_MENU(); } @@ -130,7 +130,7 @@ void menu_mmu2_choose_filament() { #if LCD_HEIGHT > 2 STATIC_ITEM(MSG_MMU2_CHOOSE_FILAMENT_HEADER, SS_DEFAULT|SS_INVERT); #endif - LOOP_L_N(i, EXTRUDERS) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ action_mmu2_chosen(MenuItemBase::itemIndex); }); + EXTRUDER_LOOP() ACTION_ITEM_N(e, MSG_MMU2_FILAMENT_N, []{ action_mmu2_chosen(MenuItemBase::itemIndex); }); END_MENU(); } @@ -167,4 +167,4 @@ uint8_t mmu2_choose_filament() { return feeder_index; } -#endif // HAS_LCD_MENU && MMU2_MENUS +#endif // HAS_MARLINUI_MENU && MMU2_MENUS diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index 29a908ac334d..96f632508041 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #define LARGE_AREA_TEST ((X_BED_SIZE) >= 1000 || (Y_BED_SIZE) >= 1000 || (Z_MAX_POS) >= 1000) @@ -57,7 +57,9 @@ // "Motion" > "Move Axis" submenu // -static void _lcd_move_xyz(PGM_P const name, const AxisEnum axis) { +// TODO: Use substitution here with MSG_MOVE_N + +static void _lcd_move_xyz(FSTR_P const name, 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 @@ -90,21 +92,21 @@ static void _lcd_move_xyz(PGM_P const name, const AxisEnum axis) { MenuEditItemBase::draw_edit_screen(name, 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(MSG_MOVE_X), X_AXIS); } +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(MSG_MOVE_Y), 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(MSG_MOVE_Z), Z_AXIS); } + void lcd_move_z() { _lcd_move_xyz(GET_TEXT_F(MSG_MOVE_Z), Z_AXIS); } #endif -#if LINEAR_AXES >= 4 - void lcd_move_i() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_I), I_AXIS); } +#if HAS_I_AXIS + void lcd_move_i() { _lcd_move_xyz(GET_TEXT_F(MSG_MOVE_I), I_AXIS); } #endif -#if LINEAR_AXES >= 5 - void lcd_move_j() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_J), J_AXIS); } +#if HAS_J_AXIS + void lcd_move_j() { _lcd_move_xyz(GET_TEXT_F(MSG_MOVE_J), J_AXIS); } #endif -#if LINEAR_AXES >= 6 - void lcd_move_k() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_K), K_AXIS); } +#if HAS_K_AXIS + void lcd_move_k() { _lcd_move_xyz(GET_TEXT_F(MSG_MOVE_K), K_AXIS); } #endif #if E_MANUAL @@ -123,7 +125,7 @@ void lcd_move_x() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_X), X_AXIS); } if (ui.should_draw()) { TERN_(MULTI_E_MANUAL, MenuItemBase::init(eindex)); MenuEditItemBase::draw_edit_screen( - GET_TEXT(TERN(MULTI_E_MANUAL, MSG_MOVE_EN, MSG_MOVE_E)), + 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) @@ -157,6 +159,7 @@ 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); + thermalManager.set_menu_cold_override(true); } void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int8_t eindex=active_extruder) { @@ -186,22 +189,8 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int SUBMENU(MSG_MOVE_10MM, []{ _goto_manual_move(10); }); SUBMENU(MSG_MOVE_1MM, []{ _goto_manual_move( 1); }); SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move( 0.1f); }); - if (axis == Z_AXIS && (FINE_MANUAL_MOVE) > 0.0f && (FINE_MANUAL_MOVE) < 0.1f) { - // Determine digits needed right of decimal - constexpr 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; - PGM_P const label = GET_TEXT(MSG_MOVE_N_MM); - char tmp[strlen_P(label) + 10 + 1], numstr[10]; - sprintf_P(tmp, label, dtostrf(FINE_MANUAL_MOVE, 1, digs, numstr)); - #if DISABLED(HAS_GRAPHICAL_TFT) - SUBMENU_P(NUL_STR, []{ _goto_manual_move(float(FINE_MANUAL_MOVE)); }); - MENU_ITEM_ADDON_START(0 + ENABLED(HAS_MARLINUI_HD44780)); - lcd_put_u8str(tmp); - MENU_ITEM_ADDON_END(); - #else - SUBMENU_P(tmp, []{ _goto_manual_move(float(FINE_MANUAL_MOVE)); }); - #endif - } + 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)); }); } END_MENU(); } @@ -218,9 +207,9 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int if (too_cold) { ui.goto_screen([]{ MenuItem_confirm::select_screen( - GET_TEXT(MSG_BUTTON_PROCEED), GET_TEXT(MSG_BACK), + GET_TEXT_F(MSG_BUTTON_PROCEED), GET_TEXT_F(MSG_BACK), _goto_menu_move_distance_e, nullptr, - GET_TEXT(MSG_HOTEND_TOO_COLD), (const char *)nullptr, PSTR("!") + GET_TEXT_F(MSG_HOTEND_TOO_COLD), (const char *)nullptr, F("!") ); }); return; @@ -254,52 +243,52 @@ void menu_move() { #if HAS_Z_AXIS SUBMENU(MSG_MOVE_Z, []{ _menu_move_distance(Z_AXIS, lcd_move_z); }); #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS SUBMENU(MSG_MOVE_I, []{ _menu_move_distance(I_AXIS, lcd_move_i); }); #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS SUBMENU(MSG_MOVE_J, []{ _menu_move_distance(J_AXIS, lcd_move_j); }); #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS SUBMENU(MSG_MOVE_K, []{ _menu_move_distance(K_AXIS, lcd_move_k); }); #endif } else - GCODES_ITEM(MSG_AUTO_HOME, G28_STR); + GCODES_ITEM(MSG_AUTO_HOME, FPSTR(G28_STR)); #if ANY(SWITCHING_EXTRUDER, SWITCHING_NOZZLE, MAGNETIC_SWITCHING_TOOLHEAD) #if EXTRUDERS >= 4 switch (active_extruder) { - case 0: GCODES_ITEM_N(1, MSG_SELECT_E, PSTR("T1")); break; - case 1: GCODES_ITEM_N(0, MSG_SELECT_E, PSTR("T0")); break; - case 2: GCODES_ITEM_N(3, MSG_SELECT_E, PSTR("T3")); break; - case 3: GCODES_ITEM_N(2, MSG_SELECT_E, PSTR("T2")); break; + case 0: GCODES_ITEM_N(1, MSG_SELECT_E, F("T1")); break; + case 1: GCODES_ITEM_N(0, MSG_SELECT_E, F("T0")); break; + case 2: GCODES_ITEM_N(3, MSG_SELECT_E, F("T3")); break; + case 3: GCODES_ITEM_N(2, MSG_SELECT_E, F("T2")); break; #if EXTRUDERS == 6 - case 4: GCODES_ITEM_N(5, MSG_SELECT_E, PSTR("T5")); break; - case 5: GCODES_ITEM_N(4, MSG_SELECT_E, PSTR("T4")); break; + case 4: GCODES_ITEM_N(5, MSG_SELECT_E, F("T5")); break; + case 5: GCODES_ITEM_N(4, MSG_SELECT_E, F("T4")); break; #endif } #elif EXTRUDERS == 3 if (active_extruder < 2) { if (active_extruder) - GCODES_ITEM_N(0, MSG_SELECT_E, PSTR("T0")); + GCODES_ITEM_N(0, MSG_SELECT_E, F("T0")); else - GCODES_ITEM_N(1, MSG_SELECT_E, PSTR("T1")); + GCODES_ITEM_N(1, MSG_SELECT_E, F("T1")); } #else if (active_extruder) - GCODES_ITEM_N(0, MSG_SELECT_E, PSTR("T0")); + GCODES_ITEM_N(0, MSG_SELECT_E, F("T0")); else - GCODES_ITEM_N(1, MSG_SELECT_E, PSTR("T1")); + GCODES_ITEM_N(1, MSG_SELECT_E, F("T1")); #endif #elif ENABLED(DUAL_X_CARRIAGE) if (active_extruder) - GCODES_ITEM_N(0, MSG_SELECT_E, PSTR("T0")); + GCODES_ITEM_N(0, MSG_SELECT_E, F("T0")); else - GCODES_ITEM_N(1, MSG_SELECT_E, PSTR("T1")); + GCODES_ITEM_N(1, MSG_SELECT_E, F("T1")); #endif @@ -337,22 +326,22 @@ void menu_move() { START_MENU(); BACK_ITEM(MSG_MOTION); - GCODES_ITEM(MSG_AUTO_HOME, G28_STR); - GCODES_ITEM_N(X_AXIS, MSG_AUTO_HOME_A, PSTR("G28X")); + 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, PSTR("G28Y")); + 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, PSTR("G28Z")); + GCODES_ITEM_N(Z_AXIS, MSG_AUTO_HOME_A, F("G28Z")); #endif - #if LINEAR_AXES >= 4 - GCODES_ITEM_N(I_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS4_STR)); + #if HAS_I_AXIS + GCODES_ITEM_N(I_AXIS, MSG_AUTO_HOME_A, F("G28" STR_I)); #endif - #if LINEAR_AXES >= 5 - GCODES_ITEM_N(J_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS5_STR)); + #if HAS_J_AXIS + GCODES_ITEM_N(J_AXIS, MSG_AUTO_HOME_A, F("G28" STR_J)); #endif - #if LINEAR_AXES >= 6 - GCODES_ITEM_N(K_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS6_STR)); + #if HAS_K_AXIS + GCODES_ITEM_N(K_AXIS, MSG_AUTO_HOME_A, F("G28" STR_K)); #endif END_MENU(); @@ -389,23 +378,23 @@ void menu_motion() { #if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) SUBMENU(MSG_HOMING, menu_home); #else - GCODES_ITEM(MSG_AUTO_HOME, G28_STR); + GCODES_ITEM(MSG_AUTO_HOME, FPSTR(G28_STR)); #if ENABLED(INDIVIDUAL_AXIS_HOMING_MENU) - GCODES_ITEM_N(X_AXIS, MSG_AUTO_HOME_A, PSTR("G28X")); + GCODES_ITEM_N(X_AXIS, MSG_AUTO_HOME_A, F("G28X")); #if HAS_Y_AXIS - GCODES_ITEM_N(Y_AXIS, MSG_AUTO_HOME_A, PSTR("G28Y")); + 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, PSTR("G28Z")); + GCODES_ITEM_N(Z_AXIS, MSG_AUTO_HOME_A, F("G28Z")); #endif - #if LINEAR_AXES >= 4 - GCODES_ITEM_N(I_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS4_STR)); + #if HAS_I_AXIS + GCODES_ITEM_N(I_AXIS, MSG_AUTO_HOME_A, F("G28" STR_I)); #endif - #if LINEAR_AXES >= 5 - GCODES_ITEM_N(J_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS5_STR)); + #if HAS_J_AXIS + GCODES_ITEM_N(J_AXIS, MSG_AUTO_HOME_A, F("G28" STR_J)); #endif - #if LINEAR_AXES >= 6 - GCODES_ITEM_N(K_AXIS, MSG_AUTO_HOME_A, PSTR("G28" AXIS6_STR)); + #if HAS_K_AXIS + GCODES_ITEM_N(K_AXIS, MSG_AUTO_HOME_A, F("G28" STR_K)); #endif #endif #endif @@ -414,14 +403,14 @@ void menu_motion() { // Auto-calibration // #if ENABLED(CALIBRATION_GCODE) - GCODES_ITEM(MSG_AUTO_CALIBRATE, PSTR("G425")); + GCODES_ITEM(MSG_AUTO_CALIBRATE, F("G425")); #endif // // Auto Z-Align // #if EITHER(Z_STEPPER_AUTO_ALIGN, MECHANICAL_GANTRY_CALIBRATION) - GCODES_ITEM(MSG_AUTO_Z_ALIGN, PSTR("G34")); + GCODES_ITEM(MSG_AUTO_Z_ALIGN, F("G34")); #endif // @@ -446,7 +435,7 @@ void menu_motion() { #elif HAS_LEVELING && DISABLED(SLIM_LCD_MENUS) #if DISABLED(PROBE_MANUALLY) - GCODES_ITEM(MSG_LEVEL_BED, PSTR("G29N")); + GCODES_ITEM(MSG_LEVEL_BED, F("G29N")); #endif if (all_axes_homed() && leveling_is_valid()) { @@ -461,20 +450,20 @@ void menu_motion() { #endif - #if ENABLED(LEVEL_BED_CORNERS) && DISABLED(LCD_BED_LEVELING) + #if ENABLED(LCD_BED_TRAMMING) && DISABLED(LCD_BED_LEVELING) SUBMENU(MSG_BED_TRAMMING, _lcd_level_bed_corners); #endif #if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST) - GCODES_ITEM(MSG_M48_TEST, PSTR("G28O\nM48 P10")); + GCODES_ITEM(MSG_M48_TEST, F("G28O\nM48 P10")); #endif // // Disable Steppers // - GCODES_ITEM(MSG_DISABLE_STEPPERS, PSTR("M84")); + GCODES_ITEM(MSG_DISABLE_STEPPERS, F("M84")); END_MENU(); } -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU diff --git a/Marlin/src/lcd/menu/menu_password.cpp b/Marlin/src/lcd/menu/menu_password.cpp index d3a35abff2e0..89ea42d70477 100644 --- a/Marlin/src/lcd/menu/menu_password.cpp +++ b/Marlin/src/lcd/menu/menu_password.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, PASSWORD_FEATURE) +#if BOTH(HAS_MARLINUI_MENU, PASSWORD_FEATURE) #include "../../feature/password/password.h" @@ -49,18 +49,18 @@ void Password::menu_password_entry() { START_MENU(); // "Login" or "New Code" - STATIC_ITEM_P(authenticating ? GET_TEXT(MSG_LOGIN_REQUIRED) : GET_TEXT(MSG_EDIT_PASSWORD), SS_CENTER|SS_INVERT); + STATIC_ITEM_F(authenticating ? GET_TEXT_F(MSG_LOGIN_REQUIRED) : GET_TEXT_F(MSG_EDIT_PASSWORD), SS_CENTER|SS_INVERT); - STATIC_ITEM_P(NUL_STR, SS_CENTER, string); + STATIC_ITEM_F(FPSTR(NUL_STR), SS_CENTER, string); #if HAS_MARLINUI_U8GLIB - STATIC_ITEM_P(NUL_STR, SS_CENTER, ""); + STATIC_ITEM_F(FPSTR(NUL_STR), SS_CENTER, ""); #endif // Make the digit edit item look like a sub-menu - PGM_P const label = GET_TEXT(MSG_ENTER_DIGIT); - EDIT_ITEM_P(uint8, label, &editable.uint8, 0, 9, digit_entered); - MENU_ITEM_ADDON_START(utf8_strlen_P(label) + 1); + 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); SETCURSOR_X(LCD_WIDTH - 2); @@ -184,4 +184,4 @@ void Password::menu_password() { END_MENU(); } -#endif // HAS_LCD_MENU && PASSWORD_FEATURE +#endif // HAS_MARLINUI_MENU && PASSWORD_FEATURE diff --git a/Marlin/src/lcd/menu/menu_power_monitor.cpp b/Marlin/src/lcd/menu/menu_power_monitor.cpp index b43327f63bc2..3cd9909e5cf7 100644 --- a/Marlin/src/lcd/menu/menu_power_monitor.cpp +++ b/Marlin/src/lcd/menu/menu_power_monitor.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU && HAS_POWER_MONITOR +#if HAS_MARLINUI_MENU && HAS_POWER_MONITOR #include "menu_item.h" #include "../../feature/power_monitor.h" @@ -59,4 +59,4 @@ void menu_power_monitor() { END_MENU(); } -#endif // HAS_LCD_MENU && HAS_POWER_MONITOR +#endif // HAS_MARLINUI_MENU && HAS_POWER_MONITOR diff --git a/Marlin/src/lcd/menu/menu_probe_offset.cpp b/Marlin/src/lcd/menu/menu_probe_offset.cpp index add739553380..c7cbebaade82 100644 --- a/Marlin/src/lcd/menu/menu_probe_offset.cpp +++ b/Marlin/src/lcd/menu/menu_probe_offset.cpp @@ -45,15 +45,7 @@ void _goto_manual_move_z(const_float_t); float z_offset_backup, calculated_z_offset, z_offset_ref; inline void z_clearance_move() { - do_z_clearance( - #ifdef Z_AFTER_HOMING - Z_AFTER_HOMING - #elif defined(Z_HOMING_HEIGHT) - Z_HOMING_HEIGHT - #else - 10 - #endif - ); + do_z_clearance(Z_POST_CLEARANCE); } void set_offset_and_go_back(const_float_t z) { @@ -70,27 +62,14 @@ void probe_offset_wizard_menu() { if (LCD_HEIGHT >= 4) STATIC_ITEM(MSG_MOVE_NOZZLE_TO_BED, SS_CENTER|SS_INVERT); - STATIC_ITEM_P(PSTR("Z="), SS_CENTER, ftostr42_52(current_position.z)); + STATIC_ITEM_F(F("Z"), SS_CENTER, ftostr42_52(current_position.z)); STATIC_ITEM(MSG_ZPROBE_ZOFFSET, SS_LEFT, ftostr42_52(calculated_z_offset)); 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) { - char tmp[20], numstr[10]; - // 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; - sprintf_P(tmp, GET_TEXT(MSG_MOVE_N_MM), dtostrf(FINE_MANUAL_MOVE, 1, digs, numstr)); - #if DISABLED(HAS_GRAPHICAL_TFT) - SUBMENU_P(NUL_STR, []{ _goto_manual_move_z(float(FINE_MANUAL_MOVE)); }); - MENU_ITEM_ADDON_START(0 + ENABLED(HAS_MARLINUI_HD44780)); - lcd_put_u8str(tmp); - MENU_ITEM_ADDON_END(); - #else - SUBMENU_P(tmp, []{ _goto_manual_move_z(float(FINE_MANUAL_MOVE)); }); - #endif - } + 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, []{ set_offset_and_go_back(calculated_z_offset); @@ -115,7 +94,7 @@ void probe_offset_wizard_menu() { void prepare_for_probe_offset_wizard() { #if defined(PROBE_OFFSET_WIZARD_XY_POS) || !HOMING_Z_WITH_PROBE - if (ui.should_draw()) MenuItem_static::draw(1, GET_TEXT(MSG_PROBE_WIZARD_PROBING)); + if (ui.should_draw()) MenuItem_static::draw(1, GET_TEXT_F(MSG_PROBE_WIZARD_PROBING)); if (ui.wait_for_move) return; @@ -141,7 +120,7 @@ void prepare_for_probe_offset_wizard() { ui.wait_for_move = true; current_position += probe.offset_xy; line_to_current_position(MMM_TO_MMS(XY_PROBE_FEEDRATE)); - ui.synchronize(GET_TEXT(MSG_PROBE_WIZARD_MOVING)); + ui.synchronize(GET_TEXT_F(MSG_PROBE_WIZARD_MOVING)); ui.wait_for_move = false; SET_SOFT_ENDSTOP_LOOSE(true); // Disable soft endstops for free Z movement diff --git a/Marlin/src/lcd/menu/menu_spindle_laser.cpp b/Marlin/src/lcd/menu/menu_spindle_laser.cpp index 26f555ad620d..9efd68ca005d 100644 --- a/Marlin/src/lcd/menu/menu_spindle_laser.cpp +++ b/Marlin/src/lcd/menu/menu_spindle_laser.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfig.h" -#if HAS_LCD_MENU && HAS_CUTTER +#if HAS_MARLINUI_MENU && HAS_CUTTER #include "menu_item.h" @@ -64,7 +64,7 @@ #if ENABLED(SPINDLE_CHANGE_DIR) if (!is_enabled) { editable.state = is_rev; - ACTION_ITEM_P(is_rev ? GET_TEXT(MSG_CUTTER(REVERSE)) : GET_TEXT(MSG_CUTTER(FORWARD)), []{ cutter.set_reverse(!editable.state); }); + ACTION_ITEM_F(is_rev ? GET_TEXT_F(MSG_CUTTER(REVERSE)) : GET_TEXT_F(MSG_CUTTER(FORWARD)), []{ cutter.set_reverse(!editable.state); }); } #endif @@ -74,11 +74,11 @@ ACTION_ITEM(MSG_LASER_FIRE_PULSE, cutter.test_fire_pulse); #endif - #if BOTH(MARLIN_DEV_MODE, HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY) + #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(); } -#endif // HAS_LCD_MENU && HAS_CUTTER +#endif // HAS_MARLINUI_MENU && HAS_CUTTER diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index 0e3688485804..e493972a9712 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfig.h" -#if HAS_LCD_MENU && HAS_TEMPERATURE +#if HAS_MARLINUI_MENU && HAS_TEMPERATURE #include "menu_item.h" #include "../../module/temperature.h" @@ -88,14 +88,14 @@ void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t i // Indexed "Preheat ABC" and "Heat Bed" items #define PREHEAT_ITEMS(M,E) do{ \ - ACTION_ITEM_N_S(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_both(M, MenuItemBase::itemIndex); }); \ - ACTION_ITEM_N_S(E, ui.get_preheat_label(M), MSG_PREHEAT_M_END_E, []{ _preheat_end(M, MenuItemBase::itemIndex); }); \ + ACTION_ITEM_N_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_both(M, MenuItemBase::itemIndex); }); \ + ACTION_ITEM_N_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_END_E, []{ _preheat_end(M, MenuItemBase::itemIndex); }); \ }while(0) #elif HAS_MULTI_HOTEND // No heated bed, so just indexed "Preheat ABC" items - #define PREHEAT_ITEMS(M,E) ACTION_ITEM_N_S(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_end(M, MenuItemBase::itemIndex); }) + #define PREHEAT_ITEMS(M,E) ACTION_ITEM_N_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_end(M, MenuItemBase::itemIndex); }) #endif @@ -112,16 +112,16 @@ void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t i #if HOTENDS == 1 #if HAS_HEATED_BED - ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, []{ _preheat_both(editable.int8, 0); }); - ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M_END, do_preheat_end_m); + ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M, []{ _preheat_both(editable.int8, 0); }); + ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M_END, do_preheat_end_m); #else - ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m); + ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m); #endif #elif HAS_MULTI_HOTEND HOTEND_LOOP() PREHEAT_ITEMS(editable.int8, e); - ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M_ALL, []() { + ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M_ALL, []() { const celsius_t t = ui.material_preset[editable.int8].hotend_temp; HOTEND_LOOP() thermalManager.setTargetHotend(t, e); TERN(HAS_HEATED_BED, _preheat_bed(editable.int8), ui.return_to_status()); @@ -130,7 +130,7 @@ void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t i #endif #if HAS_HEATED_BED - ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M_BEDONLY, []{ _preheat_bed(editable.int8); }); + ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M_BEDONLY, []{ _preheat_bed(editable.int8); }); #endif END_MENU(); @@ -269,9 +269,9 @@ void menu_temperature() { LOOP_L_N(m, PREHEAT_COUNT) { editable.int8 = m; #if HAS_MULTI_HOTEND || HAS_HEATED_BED - SUBMENU_S(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m); + SUBMENU_f(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m); #elif HAS_HOTEND - ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m); + ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m); #endif } #endif @@ -296,9 +296,9 @@ void menu_temperature() { LOOP_L_N(m, PREHEAT_COUNT) { editable.int8 = m; #if HAS_MULTI_HOTEND || HAS_HEATED_BED - SUBMENU_S(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m); + SUBMENU_f(ui.get_preheat_label(m), MSG_PREHEAT_M, menu_preheat_m); #else - ACTION_ITEM_S(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m); + ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m); #endif } @@ -307,4 +307,4 @@ void menu_temperature() { #endif -#endif // HAS_LCD_MENU && HAS_TEMPERATURE +#endif // HAS_MARLINUI_MENU && HAS_TEMPERATURE diff --git a/Marlin/src/lcd/menu/menu_tmc.cpp b/Marlin/src/lcd/menu/menu_tmc.cpp index ad7d63205879..00d77d164e7e 100644 --- a/Marlin/src/lcd/menu/menu_tmc.cpp +++ b/Marlin/src/lcd/menu/menu_tmc.cpp @@ -26,25 +26,25 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU && HAS_TRINAMIC_CONFIG +#if HAS_MARLINUI_MENU && HAS_TRINAMIC_CONFIG #include "menu_item.h" #include "../../module/stepper/indirection.h" #include "../../feature/tmc_util.h" -#define TMC_EDIT_STORED_I_RMS(ST,STR) EDIT_ITEM_P(uint16_4, PSTR(STR), &stepper##ST.val_mA, 100, 3000, []{ stepper##ST.refresh_stepper_current(); }) +#define TMC_EDIT_STORED_I_RMS(ST,STR) EDIT_ITEM_F(uint16_4, F(STR), &stepper##ST.val_mA, 100, 3000, []{ stepper##ST.refresh_stepper_current(); }) void menu_tmc_current() { START_MENU(); BACK_ITEM(MSG_TMC_DRIVERS); #if AXIS_IS_TMC(X) - TMC_EDIT_STORED_I_RMS(X, STR_X); + TMC_EDIT_STORED_I_RMS(X, STR_A); #endif #if AXIS_IS_TMC(Y) - TMC_EDIT_STORED_I_RMS(Y, STR_Y); + TMC_EDIT_STORED_I_RMS(Y, STR_B); #endif #if AXIS_IS_TMC(Z) - TMC_EDIT_STORED_I_RMS(Z, STR_Z); + TMC_EDIT_STORED_I_RMS(Z, STR_C); #endif #if AXIS_IS_TMC(X2) TMC_EDIT_STORED_I_RMS(X2, STR_X2); @@ -62,35 +62,35 @@ void menu_tmc_current() { TMC_EDIT_STORED_I_RMS(Z4, STR_Z4); #endif #if AXIS_IS_TMC(E0) - TMC_EDIT_STORED_I_RMS(E0, LCD_STR_E0); + TMC_EDIT_STORED_I_RMS(E0, STR_E0); #endif #if AXIS_IS_TMC(E1) - TMC_EDIT_STORED_I_RMS(E1, LCD_STR_E1); + TMC_EDIT_STORED_I_RMS(E1, STR_E1); #endif #if AXIS_IS_TMC(E2) - TMC_EDIT_STORED_I_RMS(E2, LCD_STR_E2); + TMC_EDIT_STORED_I_RMS(E2, STR_E2); #endif #if AXIS_IS_TMC(E3) - TMC_EDIT_STORED_I_RMS(E3, LCD_STR_E3); + TMC_EDIT_STORED_I_RMS(E3, STR_E3); #endif #if AXIS_IS_TMC(E4) - TMC_EDIT_STORED_I_RMS(E4, LCD_STR_E4); + TMC_EDIT_STORED_I_RMS(E4, STR_E4); #endif #if AXIS_IS_TMC(E5) - TMC_EDIT_STORED_I_RMS(E5, LCD_STR_E5); + TMC_EDIT_STORED_I_RMS(E5, STR_E5); #endif #if AXIS_IS_TMC(E6) - TMC_EDIT_STORED_I_RMS(E6, LCD_STR_E6); + TMC_EDIT_STORED_I_RMS(E6, STR_E6); #endif #if AXIS_IS_TMC(E7) - TMC_EDIT_STORED_I_RMS(E7, LCD_STR_E7); + TMC_EDIT_STORED_I_RMS(E7, STR_E7); #endif END_MENU(); } #if ENABLED(HYBRID_THRESHOLD) - #define TMC_EDIT_STORED_HYBRID_THRS(ST, STR) EDIT_ITEM_P(uint8, PSTR(STR), &stepper##ST.stored.hybrid_thrs, 0, 255, []{ stepper##ST.refresh_hybrid_thrs(); }); + #define TMC_EDIT_STORED_HYBRID_THRS(ST, STR) EDIT_ITEM_F(uint8, F(STR), &stepper##ST.stored.hybrid_thrs, 0, 255, []{ stepper##ST.refresh_hybrid_thrs(); }); void menu_tmc_hybrid_thrs() { START_MENU(); @@ -103,14 +103,14 @@ void menu_tmc_current() { TERN_(Z2_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Z2, STR_Z2)); TERN_(Z3_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Z3, STR_Z3)); TERN_(Z4_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(Z4, STR_Z4)); - TERN_(E0_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E0, LCD_STR_E0)); - TERN_(E1_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E1, LCD_STR_E1)); - TERN_(E2_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E2, LCD_STR_E2)); - TERN_(E3_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E3, LCD_STR_E3)); - TERN_(E4_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E4, LCD_STR_E4)); - TERN_(E5_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E5, LCD_STR_E5)); - TERN_(E6_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E6, LCD_STR_E6)); - TERN_(E7_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E7, LCD_STR_E7)); + TERN_(E0_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E0, STR_E0)); + TERN_(E1_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E1, STR_E1)); + TERN_(E2_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E2, STR_E2)); + TERN_(E3_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E3, STR_E3)); + TERN_(E4_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E4, STR_E4)); + TERN_(E5_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E5, STR_E5)); + TERN_(E6_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E6, STR_E6)); + TERN_(E7_HAS_STEALTHCHOP, TMC_EDIT_STORED_HYBRID_THRS(E7, STR_E7)); END_MENU(); } @@ -118,7 +118,7 @@ void menu_tmc_current() { #if ENABLED(SENSORLESS_HOMING) - #define TMC_EDIT_STORED_SGT(ST) EDIT_ITEM_P(int4, PSTR(STR_##ST), &stepper##ST.stored.homing_thrs, stepper##ST.sgt_min, stepper##ST.sgt_max, []{ stepper##ST.refresh_homing_thrs(); }); + #define TMC_EDIT_STORED_SGT(ST) EDIT_ITEM_F(int4, F(STR_##ST), &stepper##ST.stored.homing_thrs, stepper##ST.sgt_min, stepper##ST.sgt_max, []{ stepper##ST.refresh_homing_thrs(); }); void menu_tmc_homing_thrs() { START_MENU(); @@ -141,7 +141,7 @@ void menu_tmc_current() { #if HAS_STEALTHCHOP - #define TMC_EDIT_STEP_MODE(ST, STR) EDIT_ITEM_P(bool, PSTR(STR), &stepper##ST.stored.stealthChop_enabled, []{ stepper##ST.refresh_stepping_mode(); }) + #define TMC_EDIT_STEP_MODE(ST, STR) EDIT_ITEM_F(bool, F(STR), &stepper##ST.stored.stealthChop_enabled, []{ stepper##ST.refresh_stepping_mode(); }) void menu_tmc_step_mode() { START_MENU(); @@ -155,14 +155,14 @@ void menu_tmc_current() { TERN_(Z2_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(Z2, STR_Z2)); TERN_(Z3_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(Z3, STR_Z3)); TERN_(Z4_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(Z4, STR_Z4)); - TERN_(E0_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E0, LCD_STR_E0)); - TERN_(E1_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E1, LCD_STR_E1)); - TERN_(E2_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E2, LCD_STR_E2)); - TERN_(E3_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E3, LCD_STR_E3)); - TERN_(E4_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E4, LCD_STR_E4)); - TERN_(E5_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E5, LCD_STR_E5)); - TERN_(E6_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E6, LCD_STR_E6)); - TERN_(E7_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E7, LCD_STR_E7)); + TERN_(E0_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E0, STR_E0)); + TERN_(E1_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E1, STR_E1)); + TERN_(E2_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E2, STR_E2)); + TERN_(E3_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E3, STR_E3)); + TERN_(E4_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E4, STR_E4)); + TERN_(E5_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E5, STR_E5)); + TERN_(E6_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E6, STR_E6)); + TERN_(E7_HAS_STEALTHCHOP, TMC_EDIT_STEP_MODE(E7, STR_E7)); END_MENU(); } diff --git a/Marlin/src/lcd/menu/menu_touch_screen.cpp b/Marlin/src/lcd/menu/menu_touch_screen.cpp index 5fc4b584d51e..130308dadffa 100644 --- a/Marlin/src/lcd/menu/menu_touch_screen.cpp +++ b/Marlin/src/lcd/menu/menu_touch_screen.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, TOUCH_SCREEN_CALIBRATION) +#if BOTH(HAS_MARLINUI_MENU, TOUCH_SCREEN_CALIBRATION) #include "menu_item.h" #include "../marlinui.h" diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index 4033421b5673..1dd8a1cab6fd 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, ASSISTED_TRAMMING_WIZARD) +#if BOTH(HAS_MARLINUI_MENU, ASSISTED_TRAMMING_WIZARD) #include "menu_item.h" @@ -44,7 +44,7 @@ #include "../../core/debug_out.h" static float z_measured[G35_PROBE_COUNT]; -static bool z_isvalid[G35_PROBE_COUNT]; +static Flags z_isvalid; static uint8_t tram_index = 0; static int8_t reference_index; // = 0 @@ -61,7 +61,10 @@ static bool probe_single_point() { move_to_tramming_wait_pos(); DEBUG_ECHOLNPGM("probe_single_point(", tram_index, ") = ", z_probed_height, "mm"); - return (z_isvalid[tram_index] = !isnan(z_probed_height)); + + const bool v = !isnan(z_probed_height); + z_isvalid.set(tram_index, v); + return v; } static void _menu_single_probe() { @@ -80,7 +83,7 @@ static void tramming_wizard_menu() { // Draw a menu item for each tramming point for (tram_index = 0; tram_index < G35_PROBE_COUNT; tram_index++) - SUBMENU_P((char*)pgm_read_ptr(&tramming_point_name[tram_index]), _menu_single_probe); + SUBMENU_F(FPSTR(pgm_read_ptr(&tramming_point_name[tram_index])), _menu_single_probe); ACTION_ITEM(MSG_BUTTON_DONE, []{ probe.stow(); // Stow before exiting Tramming Wizard @@ -95,7 +98,7 @@ void goto_tramming_wizard() { ui.defer_status_screen(); // Initialize measured point flags - ZERO(z_isvalid); + z_isvalid.reset(); reference_index = -1; // Inject G28, wait for homing to complete, @@ -109,4 +112,4 @@ void goto_tramming_wizard() { }); } -#endif // HAS_LCD_MENU && ASSISTED_TRAMMING_WIZARD +#endif // HAS_MARLINUI_MENU && ASSISTED_TRAMMING_WIZARD diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index b3f078d7a05d..b13c55f80a3b 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "menu_item.h" #include "../../module/motion.h" @@ -50,7 +50,9 @@ #include "../dogm/marlinui_DOGM.h" #endif - void _lcd_babystep(const AxisEnum axis, PGM_P const msg) { + // TODO: Replace fmsg with MSG_BABYSTEP_N and index substitution + + void _lcd_babystep(const AxisEnum axis, FSTR_P const fmsg) { if (ui.use_click()) return ui.goto_previous_screen_no_defer(); if (ui.encoderPosition) { const int16_t steps = int16_t(ui.encoderPosition) * ( @@ -66,7 +68,7 @@ } if (ui.should_draw()) { const float mps = planner.mm_per_step[axis]; - MenuEditItemBase::draw_edit_screen(msg, BABYSTEP_TO_STR(mps * babystep.accum)); + MenuEditItemBase::draw_edit_screen(fmsg, BABYSTEP_TO_STR(mps * babystep.accum)); #if ENABLED(BABYSTEP_DISPLAY_TOTAL) const bool in_view = TERN1(HAS_MARLINUI_U8GLIB, PAGE_CONTAINS(LCD_PIXEL_HEIGHT - MENU_FONT_HEIGHT, LCD_PIXEL_HEIGHT - 1)); if (in_view) { @@ -94,12 +96,12 @@ } #if ENABLED(BABYSTEP_XY) - void _lcd_babystep_x() { _lcd_babystep(X_AXIS, GET_TEXT(MSG_BABYSTEP_X)); } - void _lcd_babystep_y() { _lcd_babystep(Y_AXIS, GET_TEXT(MSG_BABYSTEP_Y)); } + void _lcd_babystep_x() { _lcd_babystep(X_AXIS, GET_TEXT_F(MSG_BABYSTEP_X)); } + void _lcd_babystep_y() { _lcd_babystep(Y_AXIS, GET_TEXT_F(MSG_BABYSTEP_Y)); } #endif #if DISABLED(BABYSTEP_ZPROBE_OFFSET) - void _lcd_babystep_z() { _lcd_babystep(Z_AXIS, GET_TEXT(MSG_BABYSTEP_Z)); } + void _lcd_babystep_z() { _lcd_babystep(Z_AXIS, GET_TEXT_F(MSG_BABYSTEP_Z)); } void lcd_babystep_z() { _lcd_babystep_go(_lcd_babystep_z); } #endif @@ -118,7 +120,7 @@ void menu_tune() { // Manual bed leveling, Bed Z: // #if BOTH(MESH_BED_LEVELING, LCD_BED_LEVELING) - EDIT_ITEM(float43, MSG_BED_Z, &mbl.z_offset, -1, 1); + EDIT_ITEM(float43, MSG_BED_Z, &bedlevel.z_offset, -1, 1); #endif // @@ -199,8 +201,8 @@ void menu_tune() { EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, []{ planner.refresh_e_factor(active_extruder); }); // Flow En: #if HAS_MULTI_EXTRUDER - LOOP_L_N(n, EXTRUDERS) - EDIT_ITEM_N(int3, n, MSG_FLOW_N, &planner.flow_percentage[n], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }); + EXTRUDER_LOOP() + EDIT_ITEM_N(int3, e, MSG_FLOW_N, &planner.flow_percentage[e], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }); #endif #endif @@ -211,8 +213,8 @@ void menu_tune() { #if EXTRUDERS == 1 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10); #elif HAS_MULTI_EXTRUDER - LOOP_L_N(n, EXTRUDERS) - EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 10); + EXTRUDER_LOOP() + EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10); #endif #endif @@ -223,17 +225,17 @@ void menu_tune() { // #if ENABLED(BABYSTEPPING) #if ENABLED(BABYSTEP_XY) - SUBMENU(MSG_BABYSTEP_X, []{ _lcd_babystep_go(_lcd_babystep_x); }); - SUBMENU(MSG_BABYSTEP_Y, []{ _lcd_babystep_go(_lcd_babystep_y); }); + SUBMENU_N(X_AXIS, MSG_BABYSTEP_N, []{ _lcd_babystep_go(_lcd_babystep_x); }); + SUBMENU_N(Y_AXIS, MSG_BABYSTEP_N, []{ _lcd_babystep_go(_lcd_babystep_y); }); #endif #if ENABLED(BABYSTEP_ZPROBE_OFFSET) SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset); #else - SUBMENU(MSG_BABYSTEP_Z, lcd_babystep_z); + SUBMENU_N(Z_AXIS, MSG_BABYSTEP_N, lcd_babystep_z); #endif #endif END_MENU(); } -#endif // HAS_LCD_MENU +#endif // HAS_MARLINUI_MENU diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index a08eceed7797..62c1770bd4c3 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -26,7 +26,7 @@ #include "../../inc/MarlinConfigPre.h" -#if BOTH(HAS_LCD_MENU, AUTO_BED_LEVELING_UBL) +#if BOTH(HAS_MARLINUI_MENU, AUTO_BED_LEVELING_UBL) #include "menu_item.h" #include "../../gcode/gcode.h" @@ -58,7 +58,7 @@ inline float rounded_mesh_value() { /** * This screen displays the temporary mesh value and updates it based on encoder - * movement. While this screen is active ubl.fine_tune_mesh sits in a loop getting + * movement. While this screen is active bedlevel.fine_tune_mesh sits in a loop getting * the current value via ubl_mesh_value, moves the Z axis, and updates the mesh * value until the encoder button is pressed. * @@ -67,39 +67,39 @@ inline float rounded_mesh_value() { * - Draw the graphical overlay, if enabled. * - Update the 'refresh' state according to the display type */ -void _lcd_mesh_fine_tune(PGM_P const msg) { +void _lcd_mesh_fine_tune(FSTR_P const fmsg) { constexpr float mesh_edit_step = 1.0f / 200.0f; ui.defer_status_screen(); - if (ubl.encoder_diff) { + if (bedlevel.encoder_diff) { mesh_edit_accumulator += TERN(IS_TFTGLCD_PANEL, - ubl.encoder_diff * mesh_edit_step / ENCODER_PULSES_PER_STEP, - ubl.encoder_diff > 0 ? mesh_edit_step : -mesh_edit_step + bedlevel.encoder_diff * mesh_edit_step / ENCODER_PULSES_PER_STEP, + bedlevel.encoder_diff > 0 ? mesh_edit_step : -mesh_edit_step ); - ubl.encoder_diff = 0; + bedlevel.encoder_diff = 0; IF_DISABLED(IS_TFTGLCD_PANEL, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT)); } TERN_(IS_TFTGLCD_PANEL, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT)); if (ui.should_draw()) { const float rounded_f = rounded_mesh_value(); - MenuEditItemBase::draw_edit_screen(msg, ftostr43sign(rounded_f)); + MenuEditItemBase::draw_edit_screen(fmsg, ftostr43sign(rounded_f)); TERN_(MESH_EDIT_GFX_OVERLAY, ui.zoffset_overlay(rounded_f)); TERN_(HAS_GRAPHICAL_TFT, ui.refresh(LCDVIEW_NONE)); } } // -// Init mesh editing and go to the fine tuning screen (ubl.fine_tune_mesh) +// Init mesh editing and go to the fine tuning screen (bedlevel.fine_tune_mesh) // To capture encoder events UBL will also call ui.capture and ui.release. // void MarlinUI::ubl_mesh_edit_start(const_float_t initial) { TERN_(HAS_GRAPHICAL_TFT, clear_lcd()); mesh_edit_accumulator = initial; - goto_screen([]{ _lcd_mesh_fine_tune(GET_TEXT(MSG_MESH_EDIT_Z)); }); + goto_screen([]{ _lcd_mesh_fine_tune(GET_TEXT_F(MSG_MESH_EDIT_Z)); }); } // -// Get the mesh value within a Z adjustment loop (ubl.fine_tune_mesh) +// Get the mesh value within a Z adjustment loop (bedlevel.fine_tune_mesh) // float MarlinUI::ubl_mesh_value() { return rounded_mesh_value(); } @@ -176,8 +176,8 @@ void _menu_ubl_height_adjust() { void _lcd_ubl_edit_mesh() { START_MENU(); BACK_ITEM(MSG_UBL_TOOLS); - GCODES_ITEM(MSG_UBL_FINE_TUNE_ALL, PSTR("G29P4RT")); - GCODES_ITEM(MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29P4T")); + GCODES_ITEM(MSG_UBL_FINE_TUNE_ALL, F("G29P4RT")); + GCODES_ITEM(MSG_UBL_FINE_TUNE_CLOSEST, F("G29P4T")); SUBMENU(MSG_UBL_MESH_HEIGHT_ADJUST, _menu_ubl_height_adjust); ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status); END_MENU(); @@ -211,26 +211,13 @@ void _lcd_ubl_edit_mesh() { #if HAS_PREHEAT #if HAS_HEATED_BED #define VALIDATE_MESH_GCODE_ITEM(M) \ - GCODES_ITEM_N_S(M, ui.get_preheat_label(M), MSG_UBL_VALIDATE_MESH_M, PSTR("G28\nG26CPI" STRINGIFY(M))) + GCODES_ITEM_N_f(M, ui.get_preheat_label(M), MSG_UBL_VALIDATE_MESH_M, F("G28\nG26CPI" STRINGIFY(M))); #else #define VALIDATE_MESH_GCODE_ITEM(M) \ - GCODES_ITEM_N_S(M, ui.get_preheat_label(M), MSG_UBL_VALIDATE_MESH_M, PSTR("G28\nG26CPB0I" STRINGIFY(M))) + GCODES_ITEM_N_f(M, ui.get_preheat_label(M), MSG_UBL_VALIDATE_MESH_M, F("G28\nG26CPB0I" STRINGIFY(M))); #endif - - VALIDATE_MESH_GCODE_ITEM(0); - #if PREHEAT_COUNT > 1 - VALIDATE_MESH_GCODE_ITEM(1); - #if PREHEAT_COUNT > 2 - VALIDATE_MESH_GCODE_ITEM(2); - #if PREHEAT_COUNT > 3 - VALIDATE_MESH_GCODE_ITEM(3); - #if PREHEAT_COUNT > 4 - VALIDATE_MESH_GCODE_ITEM(4); - #endif - #endif - #endif - #endif - #endif // HAS_PREHEAT + REPEAT(PREHEAT_COUNT, VALIDATE_MESH_GCODE_ITEM) + #endif ACTION_ITEM(MSG_UBL_VALIDATE_CUSTOM_MESH, _lcd_ubl_validate_custom_mesh); ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status); END_MENU(); @@ -268,7 +255,7 @@ void _lcd_ubl_grid_level() { void _lcd_ubl_mesh_leveling() { START_MENU(); BACK_ITEM(MSG_UBL_TOOLS); - GCODES_ITEM(MSG_UBL_3POINT_MESH_LEVELING, PSTR("G29J0")); + GCODES_ITEM(MSG_UBL_3POINT_MESH_LEVELING, F("G29J0")); SUBMENU(MSG_UBL_GRID_MESH_LEVELING, _lcd_ubl_grid_level); ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status); END_MENU(); @@ -297,14 +284,14 @@ void _menu_ubl_fillin() { START_MENU(); BACK_ITEM(MSG_UBL_BUILD_MESH_MENU); EDIT_ITEM(int3, MSG_UBL_FILLIN_AMOUNT, &ubl_fillin_amount, 0, 9, _lcd_ubl_fillin_amount_cmd); - GCODES_ITEM(MSG_UBL_SMART_FILLIN, PSTR("G29P3T0")); - GCODES_ITEM(MSG_UBL_MANUAL_FILLIN, PSTR("G29P2BT0")); + GCODES_ITEM(MSG_UBL_SMART_FILLIN, F("G29P3T0")); + GCODES_ITEM(MSG_UBL_MANUAL_FILLIN, F("G29P2BT0")); ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status); END_MENU(); } void _lcd_ubl_invalidate() { - ubl.invalidate(); + bedlevel.invalidate(); SERIAL_ECHOLNPGM("Mesh invalidated."); } @@ -330,8 +317,8 @@ void _lcd_ubl_build_mesh() { #else #define PREHEAT_BED_GCODE(M) "" #endif - #define BUILD_MESH_GCODE_ITEM(M) GCODES_ITEM_S(ui.get_preheat_label(M), MSG_UBL_BUILD_MESH_M, \ - PSTR( \ + #define BUILD_MESH_GCODE_ITEM(M) GCODES_ITEM_f(ui.get_preheat_label(M), MSG_UBL_BUILD_MESH_M, \ + F( \ "G28\n" \ PREHEAT_BED_GCODE(M) \ "M109I" STRINGIFY(M) "\n" \ @@ -355,11 +342,11 @@ void _lcd_ubl_build_mesh() { #endif // HAS_PREHEAT SUBMENU(MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_custom_mesh); - GCODES_ITEM(MSG_UBL_BUILD_COLD_MESH, PSTR("G29NP1")); + GCODES_ITEM(MSG_UBL_BUILD_COLD_MESH, F("G29NP1")); SUBMENU(MSG_UBL_FILLIN_MESH, _menu_ubl_fillin); - GCODES_ITEM(MSG_UBL_CONTINUE_MESH, PSTR("G29P1C")); + GCODES_ITEM(MSG_UBL_CONTINUE_MESH, F("G29P1C")); ACTION_ITEM(MSG_UBL_INVALIDATE_ALL, _lcd_ubl_invalidate); - GCODES_ITEM(MSG_UBL_INVALIDATE_CLOSEST, PSTR("G29I")); + GCODES_ITEM(MSG_UBL_INVALIDATE_CLOSEST, F("G29I")); ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status); END_MENU(); } @@ -367,14 +354,14 @@ void _lcd_ubl_build_mesh() { /** * UBL Load / Save Mesh Commands */ -inline void _lcd_ubl_load_save_cmd(const char loadsave, PGM_P const msg) { +inline void _lcd_ubl_load_save_cmd(const char loadsave, FSTR_P const fmsg) { char ubl_lcd_gcode[40]; sprintf_P(ubl_lcd_gcode, PSTR("G29%c%i\nM117 "), loadsave, ubl_storage_slot); - sprintf_P(&ubl_lcd_gcode[strlen(ubl_lcd_gcode)], msg, ubl_storage_slot); + sprintf_P(&ubl_lcd_gcode[strlen(ubl_lcd_gcode)], FTOP(fmsg), ubl_storage_slot); gcode.process_subcommands_now(ubl_lcd_gcode); } -void _lcd_ubl_load_mesh_cmd() { _lcd_ubl_load_save_cmd('L', GET_TEXT(MSG_MESH_LOADED)); } -void _lcd_ubl_save_mesh_cmd() { _lcd_ubl_load_save_cmd('S', GET_TEXT(MSG_MESH_SAVED)); } +void _lcd_ubl_load_mesh_cmd() { _lcd_ubl_load_save_cmd('L', GET_TEXT_F(MSG_MESH_LOADED)); } +void _lcd_ubl_save_mesh_cmd() { _lcd_ubl_load_save_cmd('S', GET_TEXT_F(MSG_MESH_SAVED)); } /** * UBL Mesh Storage submenu @@ -403,8 +390,8 @@ void _lcd_ubl_storage_mesh() { */ void _lcd_ubl_map_edit_cmd() { char ubl_lcd_gcode[50], str[10], str2[10]; - dtostrf(ubl.mesh_index_to_xpos(x_plot), 0, 2, str); - dtostrf(ubl.mesh_index_to_ypos(y_plot), 0, 2, str2); + dtostrf(bedlevel.get_mesh_x(x_plot), 0, 2, str); + dtostrf(bedlevel.get_mesh_y(y_plot), 0, 2, str2); snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29P4X%sY%sR%i"), str, str2, int(n_edit_pts)); queue.inject(ubl_lcd_gcode); } @@ -413,7 +400,7 @@ void _lcd_ubl_map_edit_cmd() { * UBL LCD Map Movement */ void ubl_map_move_to_xy() { - const xy_pos_t xy = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) }; + const xy_pos_t xy = { bedlevel.get_mesh_x(x_plot), bedlevel.get_mesh_y(y_plot) }; // Some printers have unreachable areas in the mesh. Skip the move if unreachable. if (!position_is_reachable(xy)) return; @@ -472,7 +459,7 @@ void ubl_map_screen() { // Validate if needed #if IS_KINEMATIC - const xy_pos_t xy = { ubl.mesh_index_to_xpos(x), ubl.mesh_index_to_ypos(y) }; + const xy_pos_t xy = { bedlevel.get_mesh_x(x), bedlevel.get_mesh_y(y) }; if (position_is_reachable(xy)) break; // Found a valid point ui.encoderPosition += step_dir; // Test the next point #endif @@ -513,7 +500,7 @@ void _ubl_map_screen_homing() { ui.defer_status_screen(); _lcd_draw_homing(); if (all_axes_homed()) { - ubl.lcd_map_control = true; // Return to the map screen after editing Z + bedlevel.lcd_map_control = true; // Return to the map screen after editing Z ui.goto_screen(ubl_map_screen, grid_index(x_plot, y_plot)); // Pre-set the encoder value ui.manual_move.menu_scale = 0; // Immediate move ubl_map_move_to_xy(); // Move to current mesh point @@ -544,9 +531,9 @@ void _ubl_goto_map_screen() { void _lcd_ubl_output_map() { START_MENU(); BACK_ITEM(MSG_UBL_LEVEL_BED); - GCODES_ITEM(MSG_UBL_OUTPUT_MAP_HOST, PSTR("G29T0")); - GCODES_ITEM(MSG_UBL_OUTPUT_MAP_CSV, PSTR("G29T1")); - GCODES_ITEM(MSG_UBL_OUTPUT_MAP_BACKUP, PSTR("G29S-1")); + GCODES_ITEM(MSG_UBL_OUTPUT_MAP_HOST, F("G29T0")); + GCODES_ITEM(MSG_UBL_OUTPUT_MAP_CSV, F("G29T1")); + GCODES_ITEM(MSG_UBL_OUTPUT_MAP_BACKUP, F("G29S-1")); END_MENU(); } @@ -563,7 +550,7 @@ void _menu_ubl_tools() { START_MENU(); BACK_ITEM(MSG_UBL_LEVEL_BED); SUBMENU(MSG_UBL_BUILD_MESH_MENU, _lcd_ubl_build_mesh); - GCODES_ITEM(MSG_UBL_MANUAL_MESH, PSTR("G29I999\nG29P2BT0")); + GCODES_ITEM(MSG_UBL_MANUAL_MESH, F("G29I999\nG29P2BT0")); #if ENABLED(G26_MESH_VALIDATION) SUBMENU(MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh); #endif @@ -589,12 +576,12 @@ void _menu_ubl_tools() { void _lcd_ubl_step_by_step() { START_MENU(); BACK_ITEM(MSG_UBL_LEVEL_BED); - GCODES_ITEM(MSG_UBL_1_BUILD_COLD_MESH, PSTR("G29NP1")); - GCODES_ITEM(MSG_UBL_2_SMART_FILLIN, PSTR("G29P3T0")); + GCODES_ITEM(MSG_UBL_1_BUILD_COLD_MESH, F("G29NP1")); + GCODES_ITEM(MSG_UBL_2_SMART_FILLIN, F("G29P3T0")); SUBMENU(MSG_UBL_3_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh); - GCODES_ITEM(MSG_UBL_4_FINE_TUNE_ALL, PSTR("G29P4RT")); + GCODES_ITEM(MSG_UBL_4_FINE_TUNE_ALL, F("G29P4RT")); SUBMENU(MSG_UBL_5_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh); - GCODES_ITEM(MSG_UBL_6_FINE_TUNE_ALL, PSTR("G29P4RT")); + GCODES_ITEM(MSG_UBL_6_FINE_TUNE_ALL, F("G29P4RT")); ACTION_ITEM(MSG_UBL_7_SAVE_MESH, _lcd_ubl_save_mesh_cmd); END_MENU(); } @@ -663,9 +650,9 @@ void _lcd_ubl_level_bed() { START_MENU(); BACK_ITEM(MSG_MOTION); if (planner.leveling_active) - GCODES_ITEM(MSG_UBL_DEACTIVATE_MESH, PSTR("G29D")); + GCODES_ITEM(MSG_UBL_DEACTIVATE_MESH, F("G29D")); else - GCODES_ITEM(MSG_UBL_ACTIVATE_MESH, PSTR("G29A")); + GCODES_ITEM(MSG_UBL_ACTIVATE_MESH, F("G29A")); #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) editable.decimal = planner.z_fade_height; EDIT_ITEM_FAST(float3, MSG_Z_FADE_HEIGHT, &editable.decimal, 0, 100, []{ set_z_fade_height(editable.decimal); }); @@ -680,8 +667,8 @@ void _lcd_ubl_level_bed() { SUBMENU(MSG_UBL_STORAGE_MESH_MENU, _lcd_ubl_storage_mesh); SUBMENU(MSG_UBL_OUTPUT_MAP, _lcd_ubl_output_map); SUBMENU(MSG_UBL_TOOLS, _menu_ubl_tools); - GCODES_ITEM(MSG_UBL_INFO_UBL, PSTR("G29W")); + GCODES_ITEM(MSG_UBL_INFO_UBL, F("G29W")); END_MENU(); } -#endif // HAS_LCD_MENU && AUTO_BED_LEVELING_UBL +#endif // HAS_MARLINUI_MENU && AUTO_BED_LEVELING_UBL diff --git a/Marlin/src/lcd/menu/menu_x_twist.cpp b/Marlin/src/lcd/menu/menu_x_twist.cpp index 288f16603a88..e46745e8b761 100644 --- a/Marlin/src/lcd/menu/menu_x_twist.cpp +++ b/Marlin/src/lcd/menu/menu_x_twist.cpp @@ -27,6 +27,7 @@ #include "menu_addon.h" #include "../../module/planner.h" #include "../../feature/bedlevel/bedlevel.h" +#include "../../feature/x_twist.h" #include "../../module/motion.h" #include "../../gcode/queue.h" #include "../../module/probe.h" @@ -50,7 +51,7 @@ void xatc_wizard_done() { ui.goto_screen(menu_advanced_settings); } if (ui.should_draw()) - MenuItem_static::draw(LCD_HEIGHT >= 4, GET_TEXT(MSG_XATC_DONE)); + MenuItem_static::draw(LCD_HEIGHT >= 4, GET_TEXT_F(MSG_XATC_DONE)); ui.refresh(LCDVIEW_CALL_REDRAW_NEXT); } @@ -61,14 +62,14 @@ void xatc_wizard_goto_next_point(); // void xatc_wizard_update_z_offset() { MenuItem_confirm::select_screen( - GET_TEXT(MSG_YES), GET_TEXT(MSG_NO) + GET_TEXT_F(MSG_YES), GET_TEXT_F(MSG_NO) , []{ probe.offset.z = z_offset; ui.goto_screen(xatc_wizard_done); } , xatc_wizard_done - , GET_TEXT(MSG_XATC_UPDATE_Z_OFFSET) - , ftostr42_52(z_offset), PSTR("?") + , GET_TEXT_F(MSG_XATC_UPDATE_Z_OFFSET) + , ftostr42_52(z_offset), F("?") ); } @@ -77,7 +78,7 @@ void xatc_wizard_update_z_offset() { // void xatc_wizard_set_offset_and_go_to_next_point() { // Set Z-offset at probed point - xatc.z_values[manual_probe_index++] = probe.offset.z + current_position.z - measured_z; + xatc.z_offset[manual_probe_index++] = probe.offset.z + current_position.z - measured_z; // Go to next point ui.goto_screen(xatc_wizard_goto_next_point); } @@ -92,26 +93,17 @@ void xatc_wizard_menu() { if (LCD_HEIGHT >= 4) STATIC_ITEM(MSG_MOVE_NOZZLE_TO_BED, SS_CENTER|SS_INVERT); - STATIC_ITEM_P(PSTR("Z="), SS_CENTER, ftostr42_52(current_position.z)); + STATIC_ITEM_F(F("Z="), SS_CENTER, ftostr42_52(current_position.z)); STATIC_ITEM(MSG_ZPROBE_ZOFFSET, SS_LEFT, ftostr42_52(calculated_z_offset)); 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) { - char tmp[20], numstr[10]; // 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; - sprintf_P(tmp, GET_TEXT(MSG_MOVE_N_MM), dtostrf(FINE_MANUAL_MOVE, 1, digs, numstr)); - #if DISABLED(HAS_GRAPHICAL_TFT) - SUBMENU_P(NUL_STR, []{ _goto_manual_move_z(float(FINE_MANUAL_MOVE)); }); - MENU_ITEM_ADDON_START(0 + ENABLED(HAS_MARLINUI_HD44780)); - lcd_put_u8str(tmp); - MENU_ITEM_ADDON_END(); - #else - SUBMENU_P(tmp, []{ _goto_manual_move_z(float(FINE_MANUAL_MOVE)); }); - #endif + 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); @@ -126,7 +118,7 @@ void xatc_wizard_moving() { if (ui.should_draw()) { char msg[10]; sprintf_P(msg, PSTR("%i / %u"), manual_probe_index + 1, XATC_MAX_POINTS); - MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_LEVEL_BED_NEXT_POINT), msg); + MenuEditItemBase::draw_edit_screen(GET_TEXT_F(MSG_LEVEL_BED_NEXT_POINT), msg); } ui.refresh(LCDVIEW_CALL_NO_REDRAW); if (!ui.wait_for_move) ui.goto_screen(xatc_wizard_menu); @@ -148,9 +140,11 @@ void xatc_wizard_goto_next_point() { // Deploy certain probes before starting probing TERN_(BLTOUCH, do_z_clearance(Z_CLEARANCE_DEPLOY_PROBE)); + xatc.set_enabled(false); measured_z = probe.probe_at_point(x, XATC_Y_POSITION, PROBE_PT_STOW); + xatc.set_enabled(true); current_position += probe.offset_xy; - current_position.z = XATC_START_Z - probe.offset.z + measured_z; + current_position.z = (XATC_START_Z) - probe.offset.z + measured_z; line_to_current_position(MMM_TO_MMS(XY_PROBE_FEEDRATE)); ui.wait_for_move = false; } @@ -160,12 +154,12 @@ void xatc_wizard_goto_next_point() { else { // Compute the z-offset by averaging the values found with this wizard z_offset = 0; - LOOP_L_N(i, XATC_MAX_POINTS) z_offset += xatc.z_values[i]; + LOOP_L_N(i, XATC_MAX_POINTS) z_offset += xatc.z_offset[i]; z_offset /= XATC_MAX_POINTS; // Subtract the average from the values found with this wizard. // This way they are indipendent from the z-offset - LOOP_L_N(i, XATC_MAX_POINTS) xatc.z_values[i] -= z_offset; + LOOP_L_N(i, XATC_MAX_POINTS) xatc.z_offset[i] -= z_offset; ui.goto_screen(xatc_wizard_update_z_offset); } @@ -177,7 +171,7 @@ void xatc_wizard_goto_next_point() { // void xatc_wizard_homing_done() { if (ui.should_draw()) { - MenuItem_static::draw(1, GET_TEXT(MSG_LEVEL_BED_WAITING)); + MenuItem_static::draw(1, GET_TEXT_F(MSG_LEVEL_BED_WAITING)); // Color UI needs a control to detect a touch #if BOTH(TOUCH_SCREEN, HAS_GRAPHICAL_TFT) @@ -186,8 +180,7 @@ void xatc_wizard_homing_done() { } if (ui.use_click()) { - xatc.spacing = (probe.max_x() - probe.min_x()) / (XATC_MAX_POINTS - 1); - xatc.start = probe.min_x(); + xatc.reset(); SET_SOFT_ENDSTOP_LOOSE(true); // Disable soft endstops for free Z movement diff --git a/Marlin/src/lcd/tft/tft.h b/Marlin/src/lcd/tft/tft.h index 1576518b4bb7..67cec2ee1c7e 100644 --- a/Marlin/src/lcd/tft/tft.h +++ b/Marlin/src/lcd/tft/tft.h @@ -81,24 +81,24 @@ class TFT { static uint16_t buffer[TFT_BUFFER_SIZE]; static void init(); - static inline void set_font(const uint8_t *Font) { string.set_font(Font); } - static inline void add_glyphs(const uint8_t *Font) { string.add_glyphs(Font); } + static void set_font(const uint8_t *Font) { string.set_font(Font); } + static void add_glyphs(const uint8_t *Font) { string.add_glyphs(Font); } - static inline bool is_busy() { return io.isBusy(); } - static inline void abort() { io.Abort(); } - static inline void write_multiple(uint16_t Data, uint16_t Count) { io.WriteMultiple(Data, Count); } - static inline void write_sequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); } - static inline void set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { io.set_window(Xmin, Ymin, Xmax, Ymax); } + 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 set_window(uint16_t Xmin, uint16_t Ymin, uint16_t Xmax, uint16_t Ymax) { io.set_window(Xmin, Ymin, Xmax, Ymax); } - static inline void fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.fill(x, y, width, height, color); } - static inline void canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height) { queue.canvas(x, y, width, height); } - static inline void set_background(uint16_t color) { queue.set_background(color); } - static inline void add_text(uint16_t x, uint16_t y, uint16_t color, TFT_String tft_string, uint16_t maxWidth = 0) { queue.add_text(x, y, color, tft_string.string(), maxWidth); } - static inline void add_text(uint16_t x, uint16_t y, uint16_t color, const char *string, uint16_t maxWidth = 0) { queue.add_text(x, y, color, (uint8_t *)string, maxWidth); } - static inline void add_image(int16_t x, int16_t y, MarlinImage image, uint16_t *colors) { queue.add_image(x, y, image, colors); } - static inline void add_image(int16_t x, int16_t y, MarlinImage image, uint16_t color_main = COLOR_WHITE, uint16_t color_background = COLOR_BACKGROUND, uint16_t color_shadow = COLOR_BLACK) { queue.add_image(x, y, image, color_main, color_background, color_shadow); } - static inline void add_bar(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.add_bar(x, y, width, height, color); } - static inline void add_rectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.add_rectangle(x, y, width, height, color); } + 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); } + static void canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height) { queue.canvas(x, y, width, height); } + static void set_background(uint16_t color) { queue.set_background(color); } + static void add_text(uint16_t x, uint16_t y, uint16_t color, TFT_String tft_string, uint16_t maxWidth = 0) { queue.add_text(x, y, color, tft_string.string(), maxWidth); } + static void add_text(uint16_t x, uint16_t y, uint16_t color, const char *string, uint16_t maxWidth = 0) { queue.add_text(x, y, color, string, maxWidth); } + static void add_image(int16_t x, int16_t y, MarlinImage image, uint16_t *colors) { queue.add_image(x, y, image, colors); } + static void add_image(int16_t x, int16_t y, MarlinImage image, uint16_t color_main = COLOR_WHITE, uint16_t color_background = COLOR_BACKGROUND, uint16_t color_shadow = COLOR_BLACK) { queue.add_image(x, y, image, color_main, color_background, color_shadow); } + static void add_bar(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.add_bar(x, y, width, height, color); } + static void add_rectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { queue.add_rectangle(x, y, width, height, color); } static void draw_edit_screen_buttons(); }; diff --git a/Marlin/src/lcd/tft/tft_queue.cpp b/Marlin/src/lcd/tft/tft_queue.cpp index 3f604005f9e5..25ab452cef31 100644 --- a/Marlin/src/lcd/tft/tft_queue.cpp +++ b/Marlin/src/lcd/tft/tft_queue.cpp @@ -215,13 +215,13 @@ void TFT_Queue::handle_queue_overflow(uint16_t sizeNeeded) { } } -void TFT_Queue::add_text(uint16_t x, uint16_t y, uint16_t color, uint8_t *string, uint16_t maxWidth) { +void TFT_Queue::add_text(uint16_t x, uint16_t y, uint16_t color, const uint8_t *string, uint16_t maxWidth) { handle_queue_overflow(sizeof(parametersCanvasText_t) + maxWidth); parametersCanvas_t *task_parameters = (parametersCanvas_t *)(((uint8_t *)last_task) + sizeof(queueTask_t)); parametersCanvasText_t *parameters = (parametersCanvasText_t *)end_of_queue; last_parameter = end_of_queue; - uint8_t *pointer = string; + const uint8_t *pointer = string; parameters->type = CANVAS_ADD_TEXT; parameters->x = x; diff --git a/Marlin/src/lcd/tft/tft_queue.h b/Marlin/src/lcd/tft/tft_queue.h index 51387254c55d..55d0a526b5e3 100644 --- a/Marlin/src/lcd/tft/tft_queue.h +++ b/Marlin/src/lcd/tft/tft_queue.h @@ -139,7 +139,10 @@ class TFT_Queue { 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); static void set_background(uint16_t color); - static void add_text(uint16_t x, uint16_t y, uint16_t color, uint8_t *string, uint16_t maxWidth); + static void add_text(uint16_t x, uint16_t y, uint16_t color, const uint8_t *string, uint16_t maxWidth); + static void add_text(uint16_t x, uint16_t y, uint16_t color, const char *string, uint16_t maxWidth) { + add_text(x, y, color, (uint8_t *)string, maxWidth); + } static void add_image(int16_t x, int16_t y, MarlinImage image, uint16_t *colors); static void add_image(int16_t x, int16_t y, MarlinImage image, uint16_t color_main, uint16_t color_background, uint16_t color_shadow); diff --git a/Marlin/src/lcd/tft/tft_string.cpp b/Marlin/src/lcd/tft/tft_string.cpp index d5ccfe323a1a..8585d1d82ffa 100644 --- a/Marlin/src/lcd/tft/tft_string.cpp +++ b/Marlin/src/lcd/tft/tft_string.cpp @@ -35,7 +35,7 @@ glyph_t *TFT_String::glyphs[256]; font_t *TFT_String::font_header; -uint8_t TFT_String::data[]; +char TFT_String::data[]; uint16_t TFT_String::span; uint8_t TFT_String::length; @@ -84,24 +84,22 @@ void TFT_String::set() { length = 0; } -uint8_t read_byte(uint8_t *byte) { return *byte; } - /** * Add a string, applying substitutions for the following characters: * - * $ displays an inserted C-string given by the itemString parameter + * $ displays the string given by fstr or cstr * = displays '0'....'10' for indexes 0 - 10 * ~ displays '1'....'11' for indexes 0 - 10 * * displays 'E1'...'E11' for indexes 0 - 10 (By default. Uses LCD_FIRST_TOOL) * @ displays an axis name such as XYZUVW, or E for an extruder */ -void TFT_String::add(uint8_t *string, int8_t index, uint8_t *itemString/*=nullptr*/) { +void TFT_String::add(const char *tpl, const int8_t index, const char *cstr/*=nullptr*/, FSTR_P const fstr/*=nullptr*/) { wchar_t wchar; - while (*string) { - string = get_utf8_value_cb(string, read_byte, &wchar); + while (*tpl) { + tpl = get_utf8_value_cb(tpl, read_byte_ram, &wchar); if (wchar > 255) wchar |= 0x0080; - uint8_t ch = uint8_t(wchar & 0x00FF); + const uint8_t ch = uint8_t(wchar & 0x00FF); if (ch == '=' || ch == '~' || ch == '*') { if (index >= 0) { @@ -111,10 +109,12 @@ void TFT_String::add(uint8_t *string, int8_t index, uint8_t *itemString/*=nullpt add_character('0' + inum); } else - add(index == -2 ? GET_TEXT(MSG_CHAMBER) : GET_TEXT(MSG_BED)); + add(index == -2 ? GET_TEXT_F(MSG_CHAMBER) : GET_TEXT_F(MSG_BED)); } - else if (ch == '$' && itemString) - add(itemString); + else if (ch == '$' && fstr) + add(fstr); + else if (ch == '$' && cstr) + add(cstr); else if (ch == '@') add_character(axis_codes[index]); else @@ -123,19 +123,19 @@ void TFT_String::add(uint8_t *string, int8_t index, uint8_t *itemString/*=nullpt eol(); } -void TFT_String::add(uint8_t *string, uint8_t max_len) { +void TFT_String::add(const char *cstr, uint8_t max_len/*=MAX_STRING_LENGTH*/) { wchar_t wchar; - while (*string && max_len) { - string = get_utf8_value_cb(string, read_byte, &wchar); + while (*cstr && max_len) { + cstr = get_utf8_value_cb(cstr, read_byte_ram, &wchar); if (wchar > 255) wchar |= 0x0080; - uint8_t ch = uint8_t(wchar & 0x00FF); + const uint8_t ch = uint8_t(wchar & 0x00FF); add_character(ch); max_len--; } eol(); } -void TFT_String::add_character(uint8_t character) { +void TFT_String::add_character(const char character) { if (length < MAX_STRING_LENGTH) { data[length] = character; length++; @@ -143,7 +143,7 @@ void TFT_String::add_character(uint8_t character) { } } -void TFT_String::rtrim(uint8_t character) { +void TFT_String::rtrim(const char character) { while (length) { if (data[length - 1] == 0x20 || data[length - 1] == character) { length--; @@ -155,7 +155,7 @@ void TFT_String::rtrim(uint8_t character) { } } -void TFT_String::ltrim(uint8_t character) { +void TFT_String::ltrim(const char character) { uint16_t i, j; for (i = 0; (i < length) && (data[i] == 0x20 || data[i] == character); i++) { span -= glyph(data[i])->DWidth; @@ -166,7 +166,7 @@ void TFT_String::ltrim(uint8_t character) { eol(); } -void TFT_String::trim(uint8_t character) { +void TFT_String::trim(const char character) { rtrim(character); ltrim(character); } diff --git a/Marlin/src/lcd/tft/tft_string.h b/Marlin/src/lcd/tft/tft_string.h index 133889d9ae54..5940a48ac98b 100644 --- a/Marlin/src/lcd/tft/tft_string.h +++ b/Marlin/src/lcd/tft/tft_string.h @@ -21,6 +21,8 @@ */ #pragma once +// TODO: Make AVR-compatible with separate ROM / RAM string methods + #include extern const uint8_t ISO10646_1_5x7[]; @@ -67,41 +69,86 @@ class TFT_String { static glyph_t *glyphs[256]; static font_t *font_header; - static uint8_t data[MAX_STRING_LENGTH + 1]; + static char data[MAX_STRING_LENGTH + 1]; static uint16_t span; // in pixels - static uint8_t length; // in characters - static void add_character(uint8_t character); - static void eol() { data[length] = 0x00; } + static void add_character(const char character); + static void eol() { data[length] = '\0'; } public: + static uint8_t length; // in characters + static void set_font(const uint8_t *font); static void add_glyphs(const uint8_t *font); static font_t *font() { return font_header; }; static uint16_t font_height() { return font_header->FontAscent - font_header->FontDescent; } static glyph_t *glyph(uint8_t character) { return glyphs[character] ?: glyphs[0x3F]; } /* Use '?' for unknown glyphs */ - static inline glyph_t *glyph(uint8_t *character) { return glyph(*character); } + static glyph_t *glyph(uint8_t *character) { return glyph(*character); } + /** + * @brief Set the string empty + */ static void set(); - static void add(uint8_t character) { add_character(character); eol(); } - static void add(uint8_t *string, uint8_t max_len=MAX_STRING_LENGTH); - static void add(uint8_t *string, int8_t index, uint8_t *itemString=nullptr); - static void set(uint8_t *string) { set(); add(string); }; - static void set(uint8_t *string, int8_t index, const char *itemString=nullptr) { set(); add(string, index, (uint8_t *)itemString); }; - static inline void set(const char *string) { set((uint8_t *)string); } - static inline void set(const char *string, int8_t index, const char *itemString=nullptr) { set((uint8_t *)string, index, itemString); } - static inline void add(const char *string) { add((uint8_t *)string); } - - static void trim(uint8_t character=0x20); - static void rtrim(uint8_t character=0x20); - static void ltrim(uint8_t character=0x20); - - static void truncate(uint8_t maxlen) { if (length > maxlen) { length = maxlen; eol(); } } + /** + * @brief Append an ASCII character and EOL + * + * @param character The ASCII character + */ + static void add(const char character) { add_character(character); eol(); } + static void set(wchar_t character) { set(); add(character); } + + /** + * @brief Append / Set C-string + * + * @param cstr The string + * @param max_len Character limit + */ + static void add(const char *cstr, uint8_t max_len=MAX_STRING_LENGTH); + static void set(const char *cstr, uint8_t max_len=MAX_STRING_LENGTH) { set(); add(cstr, max_len); } + + /** + * @brief Append / Set F-string + * + * @param fstr The string + * @param max_len Character limit + */ + static void add(FSTR_P const fstr, uint8_t max_len=MAX_STRING_LENGTH) { add(FTOP(fstr), max_len); } + static void set(FSTR_P const fstr, uint8_t max_len=MAX_STRING_LENGTH) { set(FTOP(fstr), max_len); } + + /** + * @brief Append / Set C-string with optional substitution + * + * @param tpl A string with optional substitution + * @param index An index + * @param cstr An SRAM C-string to use for $ substitution + * @param fstr A ROM F-string to use for $ substitution + */ + static void add(const char *tpl, const int8_t index, const char *cstr=nullptr, FSTR_P const fstr=nullptr); + static void set(const char *tpl, const int8_t index, const char *cstr=nullptr, FSTR_P const fstr=nullptr) { set(); add(tpl, index, cstr, fstr); } + + /** + * @brief Append / Set F-string with optional substitution + * + * @param ftpl A ROM F-string with optional substitution + * @param index An index + * @param cstr An SRAM C-string to use for $ substitution + * @param fstr A ROM F-string to use for $ substitution + */ + static void add(FSTR_P const ftpl, const int8_t index, const char *cstr=nullptr, FSTR_P const fstr=nullptr) { add(FTOP(ftpl), index, cstr, fstr); } + static void set(FSTR_P const ftpl, const int8_t index, const char *cstr=nullptr, FSTR_P const fstr=nullptr) { set(); add(ftpl, index, cstr, fstr); } + + // Common string ops + static void trim(const char character=' '); + static void rtrim(const char character=' '); + static void ltrim(const char character=' '); + static void truncate(const uint8_t maxlen) { if (length > maxlen) { length = maxlen; eol(); } } + + // Accessors + static char *string() { return data; } static uint16_t width() { return span; } - static uint8_t *string() { return data; } - static uint16_t center(uint16_t width) { return span > width ? 0 : (width - span) / 2; } + static uint16_t center(const uint16_t width) { return span > width ? 0 : (width - span) / 2; } }; extern TFT_String tft_string; diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index a04715a2952d..a152907a9dde 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -180,8 +180,8 @@ void Touch::touch(touch_control_t *control) { ui.refresh(); break; case SLIDER: hold(control); ui.encoderPosition = (x - control->x) * control->data / control->width; break; - case INCREASE: hold(control, repeat_delay - 5); TERN(AUTO_BED_LEVELING_UBL, ui.external_control ? ubl.encoder_diff++ : ui.encoderPosition++, ui.encoderPosition++); break; - case DECREASE: hold(control, repeat_delay - 5); TERN(AUTO_BED_LEVELING_UBL, ui.external_control ? ubl.encoder_diff-- : ui.encoderPosition--, ui.encoderPosition--); break; + case INCREASE: hold(control, repeat_delay - 5); TERN(AUTO_BED_LEVELING_UBL, ui.external_control ? bedlevel.encoder_diff++ : ui.encoderPosition++, ui.encoderPosition++); break; + case DECREASE: hold(control, repeat_delay - 5); TERN(AUTO_BED_LEVELING_UBL, ui.external_control ? bedlevel.encoder_diff-- : ui.encoderPosition--, ui.encoderPosition--); break; case HEATER: int8_t heater; heater = control->data; @@ -189,26 +189,26 @@ void Touch::touch(touch_control_t *control) { #if HAS_HOTEND if (heater >= 0) { // HotEnd #if HOTENDS == 1 - MenuItem_int3::action((const char *)GET_TEXT_F(MSG_NOZZLE), &thermalManager.temp_hotend[0].target, 0, thermalManager.hotend_max_target(0), []{ thermalManager.start_watching_hotend(0); }); + MenuItem_int3::action(GET_TEXT_F(MSG_NOZZLE), &thermalManager.temp_hotend[0].target, 0, thermalManager.hotend_max_target(0), []{ thermalManager.start_watching_hotend(0); }); #else MenuItemBase::itemIndex = heater; - MenuItem_int3::action((const char *)GET_TEXT_F(MSG_NOZZLE_N), &thermalManager.temp_hotend[heater].target, 0, thermalManager.hotend_max_target(heater), []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); }); + MenuItem_int3::action(GET_TEXT_F(MSG_NOZZLE_N), &thermalManager.temp_hotend[heater].target, 0, thermalManager.hotend_max_target(heater), []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); }); #endif } #endif #if HAS_HEATED_BED else if (heater == H_BED) { - MenuItem_int3::action((const char *)GET_TEXT_F(MSG_BED), &thermalManager.temp_bed.target, 0, BED_MAX_TARGET, thermalManager.start_watching_bed); + MenuItem_int3::action(GET_TEXT_F(MSG_BED), &thermalManager.temp_bed.target, 0, BED_MAX_TARGET, thermalManager.start_watching_bed); } #endif #if HAS_HEATED_CHAMBER else if (heater == H_CHAMBER) { - MenuItem_int3::action((const char *)GET_TEXT_F(MSG_CHAMBER), &thermalManager.temp_chamber.target, 0, CHAMBER_MAX_TARGET, thermalManager.start_watching_chamber); + MenuItem_int3::action(GET_TEXT_F(MSG_CHAMBER), &thermalManager.temp_chamber.target, 0, CHAMBER_MAX_TARGET, thermalManager.start_watching_chamber); } #endif #if HAS_COOLER else if (heater == H_COOLER) { - MenuItem_int3::action((const char *)GET_TEXT_F(MSG_COOLER), &thermalManager.temp_cooler.target, 0, COOLER_MAX_TARGET, thermalManager.start_watching_cooler); + MenuItem_int3::action(GET_TEXT_F(MSG_COOLER), &thermalManager.temp_cooler.target, 0, COOLER_MAX_TARGET, thermalManager.start_watching_cooler); } #endif @@ -218,19 +218,19 @@ void Touch::touch(touch_control_t *control) { static uint8_t fan, fan_speed; fan = 0; fan_speed = thermalManager.fan_speed[fan]; - MenuItem_percent::action((const char *)GET_TEXT_F(MSG_FIRST_FAN_SPEED), &fan_speed, 0, 255, []{ thermalManager.set_fan_speed(fan, fan_speed); }); + MenuItem_percent::action(GET_TEXT_F(MSG_FIRST_FAN_SPEED), &fan_speed, 0, 255, []{ thermalManager.set_fan_speed(fan, fan_speed); }); break; case FEEDRATE: ui.clear_lcd(); - MenuItem_int3::action((const char *)GET_TEXT_F(MSG_SPEED), &feedrate_percentage, 10, 999); + MenuItem_int3::action(GET_TEXT_F(MSG_SPEED), &feedrate_percentage, 10, 999); break; case FLOWRATE: ui.clear_lcd(); MenuItemBase::itemIndex = control->data; #if EXTRUDERS == 1 - MenuItem_int3::action((const char *)GET_TEXT_F(MSG_FLOW), &planner.flow_percentage[MenuItemBase::itemIndex], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }); + MenuItem_int3::action(GET_TEXT_F(MSG_FLOW), &planner.flow_percentage[MenuItemBase::itemIndex], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }); #else - MenuItem_int3::action((const char *)GET_TEXT_F(MSG_FLOW_N), &planner.flow_percentage[MenuItemBase::itemIndex], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }); + MenuItem_int3::action(GET_TEXT_F(MSG_FLOW_N), &planner.flow_percentage[MenuItemBase::itemIndex], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); }); #endif break; diff --git a/Marlin/src/lcd/tft/touch.h b/Marlin/src/lcd/tft/touch.h index 238453f765ed..6021a840b65e 100644 --- a/Marlin/src/lcd/tft/touch.h +++ b/Marlin/src/lcd/tft/touch.h @@ -106,7 +106,7 @@ class Touch { static millis_t last_touch_ms, time_to_hold, repeat_delay, touch_time; static TouchControlType touch_control_type; - static inline bool get_point(int16_t *x, int16_t *y); + static bool get_point(int16_t *x, int16_t *y); static void touch(touch_control_t *control); static void hold(touch_control_t *control, millis_t delay = 0); @@ -126,7 +126,7 @@ class Touch { static void enable() { enabled = true; } #if HAS_TOUCH_SLEEP static millis_t next_sleep_ms; - static inline bool isSleeping() { return next_sleep_ms == TSLP_SLEEPING; } + static bool isSleeping() { return next_sleep_ms == TSLP_SLEEPING; } static void sleepTimeout(); static void wakeUp(); #endif diff --git a/Marlin/src/lcd/tft/ui_1024x600.cpp b/Marlin/src/lcd/tft/ui_1024x600.cpp index 160f8c29f396..a1b6ee69e3b2 100644 --- a/Marlin/src/lcd/tft/ui_1024x600.cpp +++ b/Marlin/src/lcd/tft/ui_1024x600.cpp @@ -105,12 +105,12 @@ void MarlinUI::draw_kill_screen() { line++; menu_line(line++, COLOR_KILL_SCREEN_BG); - tft_string.set(GET_TEXT(MSG_HALTED)); + tft_string.set(GET_TEXT_F(MSG_HALTED)); tft_string.trim(); tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string); menu_line(line++, COLOR_KILL_SCREEN_BG); - tft_string.set(GET_TEXT(MSG_PLEASE_RESET)); + tft_string.set(GET_TEXT_F(MSG_PLEASE_RESET)); tft_string.trim(); tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string); @@ -181,13 +181,13 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { tft.add_image(8, 28, image, Color); - tft_string.set((uint8_t *)i16tostr3rj(currentTemperature)); + tft_string.set(i16tostr3rj(currentTemperature)); tft_string.add(LCD_STR_DEGREE); tft_string.trim(); tft.add_text(tft_string.center(80) + 2, 82, Color, tft_string); if (targetTemperature >= 0) { - tft_string.set((uint8_t *)i16tostr3rj(targetTemperature)); + tft_string.set(i16tostr3rj(targetTemperature)); tft_string.add(LCD_STR_DEGREE); tft_string.trim(); tft.add_text(tft_string.center(80) + 2, 8, Color, tft_string); @@ -211,7 +211,7 @@ void draw_fan_status(uint16_t x, uint16_t y, const bool blink) { tft.add_image(8, 20, image, COLOR_FAN); - tft_string.set((uint8_t *)ui8tostr4pctrj(thermalManager.fan_speed[0])); + tft_string.set(ui8tostr4pctrj(thermalManager.fan_speed[0])); tft_string.trim(); tft.add_text(tft_string.center(80) + 6, 82, COLOR_FAN, tft_string); } @@ -352,14 +352,14 @@ void MarlinUI::draw_status_screen() { } // Low-level draw_edit_screen can be used to draw an edit screen from anyplace -void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) { +void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const value/*=nullptr*/) { ui.encoder_direction_normal(); TERN_(TOUCH_SCREEN, touch.clear()); uint16_t line = 1; menu_line(line++); - tft_string.set(pstr, itemIndex, itemString); + tft_string.set(fstr, itemIndex, itemStringC, itemStringF); tft_string.trim(); tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); @@ -421,7 +421,7 @@ void TFT::draw_edit_screen_buttons() { } // The Select Screen presents a prompt and two "buttons" -void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) { +void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, const bool yesno, FSTR_P const pref, const char * const string/*=nullptr*/, FSTR_P const suff/*=nullptr*/) { uint16_t line = 1; if (!string) line++; @@ -473,7 +473,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const #endif menu_line(row); - tft_string.set(GET_TEXT(MSG_FILAMENT_CHANGE_NOZZLE)); + tft_string.set(GET_TEXT_F(MSG_FILAMENT_CHANGE_NOZZLE)); tft_string.add('E'); tft_string.add((char)('1' + extruder)); tft_string.add(' '); @@ -501,14 +501,14 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.set_background(COLOR_BACKGROUND); tft.add_rectangle(0, 0, GRID_WIDTH, GRID_HEIGHT, COLOR_WHITE); - for (uint16_t x = 0; x < GRID_MAX_POINTS_X ; x++) - for (uint16_t y = 0; y < GRID_MAX_POINTS_Y ; y++) - if (position_is_reachable({ ubl.mesh_index_to_xpos(x), ubl.mesh_index_to_ypos(y) })) - tft.add_bar(1 + (x * 2 + 1) * (GRID_WIDTH - 4) / GRID_MAX_POINTS_X / 2, GRID_HEIGHT - 3 - ((y * 2 + 1) * (GRID_HEIGHT - 4) / GRID_MAX_POINTS_Y / 2), 2, 2, COLOR_UBL); + for (uint16_t x = 0; x < (GRID_MAX_POINTS_X); x++) + for (uint16_t y = 0; y < (GRID_MAX_POINTS_Y); y++) + if (position_is_reachable({ bedlevel.get_mesh_x(x), bedlevel.get_mesh_y(y) })) + tft.add_bar(1 + (x * 2 + 1) * (GRID_WIDTH - 4) / (GRID_MAX_POINTS_X) / 2, GRID_HEIGHT - 3 - ((y * 2 + 1) * (GRID_HEIGHT - 4) / (GRID_MAX_POINTS_Y) / 2), 2, 2, COLOR_UBL); - tft.add_rectangle((x_plot * 2 + 1) * (GRID_WIDTH - 4) / GRID_MAX_POINTS_X / 2 - 1, GRID_HEIGHT - 5 - ((y_plot * 2 + 1) * (GRID_HEIGHT - 4) / GRID_MAX_POINTS_Y / 2), 6, 6, COLOR_UBL); + tft.add_rectangle((x_plot * 2 + 1) * (GRID_WIDTH - 4) / (GRID_MAX_POINTS_X) / 2 - 1, GRID_HEIGHT - 5 - ((y_plot * 2 + 1) * (GRID_HEIGHT - 4) / (GRID_MAX_POINTS_Y) / 2), 6, 6, COLOR_UBL); - const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) }, + const xy_pos_t pos = { bedlevel.get_mesh_x(x_plot), bedlevel.get_mesh_y(y_plot) }, lpos = pos.asLogical(); tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 - MENU_ITEM_HEIGHT, 120, MENU_ITEM_HEIGHT); @@ -531,7 +531,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.set_background(COLOR_BACKGROUND); tft_string.set(Z_LBL); tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); - tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot])); + tft_string.set(isnan(bedlevel.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(bedlevel.z_values[x_plot][y_plot])); tft_string.trim(); tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); @@ -596,9 +596,9 @@ MotionAxisState motionAxisState; static void quick_feedback() { #if HAS_CHIRP ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle? - #if BOTH(HAS_LCD_MENU, USE_BEEPER) + #if BOTH(HAS_MARLINUI_MENU, HAS_BEEPER) for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); } - #elif HAS_LCD_MENU + #elif HAS_MARLINUI_MENU delay(10); #endif #endif @@ -606,7 +606,7 @@ static void quick_feedback() { #define CUR_STEP_VALUE_WIDTH 104 static void drawCurStepValue() { - tft_string.set((uint8_t *)ftostr52sp(motionAxisState.currentStepSize)); + tft_string.set(ftostr52sp(motionAxisState.currentStepSize)); tft_string.add("mm"); tft.canvas(motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT); tft.set_background(COLOR_BACKGROUND); @@ -693,18 +693,18 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { drawAxisValue(axis); } else { - drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS)); + drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); } #elif HAS_BED_PROBE // only change probe.offset.z probe.offset.z += diff; if (direction < 0 && current_position[axis] < Z_PROBE_OFFSET_RANGE_MIN) { current_position[axis] = Z_PROBE_OFFSET_RANGE_MIN; - drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS)); + drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); } else if (direction > 0 && current_position[axis] > Z_PROBE_OFFSET_RANGE_MAX) { current_position[axis] = Z_PROBE_OFFSET_RANGE_MAX; - drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS)); + drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); } else { drawMessage(""); // clear the error @@ -733,7 +733,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { #if IS_KINEMATIC UNUSED(limited); #else - PGM_P const msg = limited ? GET_TEXT(MSG_LCD_SOFT_ENDSTOPS) : NUL_STR; + FSTR_P const msg = limited ? GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS) : FPSTR(NUL_STR); drawMessage(msg); #endif @@ -766,7 +766,7 @@ static void z_minus() { moveAxis(Z_AXIS, -1); } static void do_home() { quick_feedback(); - drawMessage(GET_TEXT(MSG_LEVEL_BED_HOMING)); + drawMessage(GET_TEXT_F(MSG_LEVEL_BED_HOMING)); queue.inject_P(G28_STR); // Disable touch until home is done TERN_(TOUCH_SCREEN, touch.disable()); diff --git a/Marlin/src/lcd/tft/ui_320x240.cpp b/Marlin/src/lcd/tft/ui_320x240.cpp index d85a917983c0..15031d0da2ec 100644 --- a/Marlin/src/lcd/tft/ui_320x240.cpp +++ b/Marlin/src/lcd/tft/ui_320x240.cpp @@ -181,13 +181,13 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { tft.add_image(0, 18, image, Color); - tft_string.set((uint8_t *)i16tostr3rj(currentTemperature)); + tft_string.set(i16tostr3rj(currentTemperature)); tft_string.add(LCD_STR_DEGREE); tft_string.trim(); tft.add_text(tft_string.center(64) + 2, 72, Color, tft_string); if (targetTemperature >= 0) { - tft_string.set((uint8_t *)i16tostr3rj(targetTemperature)); + tft_string.set(i16tostr3rj(targetTemperature)); tft_string.add(LCD_STR_DEGREE); tft_string.trim(); tft.add_text(tft_string.center(64) + 2, 8, Color, tft_string); @@ -211,7 +211,7 @@ void draw_fan_status(uint16_t x, uint16_t y, const bool blink) { tft.add_image(0, 10, image, COLOR_FAN); - tft_string.set((uint8_t *)ui8tostr4pctrj(thermalManager.fan_speed[0])); + tft_string.set(ui8tostr4pctrj(thermalManager.fan_speed[0])); tft_string.trim(); tft.add_text(tft_string.center(64) + 6, 72, COLOR_FAN, tft_string); } @@ -347,14 +347,14 @@ void MarlinUI::draw_status_screen() { } // Low-level draw_edit_screen can be used to draw an edit screen from anyplace -void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) { +void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const value/*=nullptr*/) { ui.encoder_direction_normal(); TERN_(TOUCH_SCREEN, touch.clear()); uint16_t line = 1; menu_line(line++); - tft_string.set(pstr, itemIndex, itemString); + tft_string.set(fstr, itemIndex, itemStringC, itemStringF); tft_string.trim(); tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); @@ -416,7 +416,7 @@ void TFT::draw_edit_screen_buttons() { } // The Select Screen presents a prompt and two "buttons" -void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) { +void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, const bool yesno, FSTR_P const pref, const char * const string/*=nullptr*/, FSTR_P const suff/*=nullptr*/) { uint16_t line = 1; if (!string) line++; @@ -440,8 +440,8 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); } #if ENABLED(TOUCH_SCREEN) - add_control(48, TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL); - add_control(208, TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM)); + if (no) add_control( 48, TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL); + if (yes) add_control(208, TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM)); #endif } @@ -485,12 +485,12 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const for (uint16_t x = 0; x < (GRID_MAX_POINTS_X); x++) for (uint16_t y = 0; y < (GRID_MAX_POINTS_Y); y++) - if (position_is_reachable({ ubl.mesh_index_to_xpos(x), ubl.mesh_index_to_ypos(y) })) + if (position_is_reachable({ bedlevel.get_mesh_x(x), bedlevel.get_mesh_y(y) })) tft.add_bar(1 + (x * 2 + 1) * (GRID_WIDTH - 4) / (GRID_MAX_POINTS_X) / 2, GRID_HEIGHT - 3 - ((y * 2 + 1) * (GRID_HEIGHT - 4) / (GRID_MAX_POINTS_Y) / 2), 2, 2, COLOR_UBL); tft.add_rectangle((x_plot * 2 + 1) * (GRID_WIDTH - 4) / (GRID_MAX_POINTS_X) / 2 - 1, GRID_HEIGHT - 5 - ((y_plot * 2 + 1) * (GRID_HEIGHT - 4) / (GRID_MAX_POINTS_Y) / 2), 6, 6, COLOR_UBL); - const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) }, + const xy_pos_t pos = { bedlevel.get_mesh_x(x_plot), bedlevel.get_mesh_y(y_plot) }, lpos = pos.asLogical(); tft.canvas(216, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 - MENU_ITEM_HEIGHT, 96, MENU_ITEM_HEIGHT); @@ -513,7 +513,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.set_background(COLOR_BACKGROUND); tft_string.set(Z_LBL); tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); - tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot])); + tft_string.set(isnan(bedlevel.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(bedlevel.z_values[x_plot][y_plot])); tft_string.trim(); tft.add_text(96 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); @@ -578,9 +578,9 @@ MotionAxisState motionAxisState; static void quick_feedback() { #if HAS_CHIRP ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle? - #if BOTH(HAS_LCD_MENU, USE_BEEPER) + #if BOTH(HAS_MARLINUI_MENU, HAS_BEEPER) for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); } - #elif HAS_LCD_MENU + #elif HAS_MARLINUI_MENU delay(10); #endif #endif @@ -588,7 +588,7 @@ static void quick_feedback() { #define CUR_STEP_VALUE_WIDTH 38 static void drawCurStepValue() { - tft_string.set((uint8_t *)ftostr52sp(motionAxisState.currentStepSize)); + tft_string.set(ftostr52sp(motionAxisState.currentStepSize)); tft.canvas(motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, 20); tft.set_background(COLOR_BACKGROUND); tft.add_text(CUR_STEP_VALUE_WIDTH - tft_string.width(), 0, COLOR_AXIS_HOMED, tft_string); @@ -621,7 +621,7 @@ static void drawCurESelection() { tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection)); } -static void drawMessage(const char *msg) { +static void drawMessage(PGM_P const msg) { tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - 29, (TFT_WIDTH / 2) - (BTN_WIDTH / 2) - X_MARGIN, 20); tft.set_background(COLOR_BACKGROUND); tft.add_text(0, 0, COLOR_YELLOW, msg); @@ -652,7 +652,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { #if ENABLED(PREVENT_COLD_EXTRUSION) if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) { - drawMessage("Too cold"); + drawMessage(PSTR("Too cold")); return; } #endif @@ -675,7 +675,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { probe.offset.z = new_offs; else TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP); - drawMessage(""); // clear the error + drawMessage(NUL_STR); // clear the error drawAxisValue(axis); } else { @@ -693,7 +693,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS)); } else { - drawMessage(""); // clear the error + drawMessage(NUL_STR); // clear the error } drawAxisValue(axis); #endif diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp index ff14a9d588ed..5a964525ecd1 100644 --- a/Marlin/src/lcd/tft/ui_480x320.cpp +++ b/Marlin/src/lcd/tft/ui_480x320.cpp @@ -181,13 +181,13 @@ void draw_heater_status(uint16_t x, uint16_t y, const int8_t Heater) { tft.add_image(8, 28, image, Color); - tft_string.set((uint8_t *)i16tostr3rj(currentTemperature)); + tft_string.set(i16tostr3rj(currentTemperature)); tft_string.add(LCD_STR_DEGREE); tft_string.trim(); tft.add_text(tft_string.center(80) + 2, 82, Color, tft_string); if (targetTemperature >= 0) { - tft_string.set((uint8_t *)i16tostr3rj(targetTemperature)); + tft_string.set(i16tostr3rj(targetTemperature)); tft_string.add(LCD_STR_DEGREE); tft_string.trim(); tft.add_text(tft_string.center(80) + 2, 8, Color, tft_string); @@ -211,7 +211,7 @@ void draw_fan_status(uint16_t x, uint16_t y, const bool blink) { tft.add_image(8, 20, image, COLOR_FAN); - tft_string.set((uint8_t *)ui8tostr4pctrj(thermalManager.fan_speed[0])); + tft_string.set(ui8tostr4pctrj(thermalManager.fan_speed[0])); tft_string.trim(); tft.add_text(tft_string.center(80) + 6, 82, COLOR_FAN, tft_string); } @@ -352,14 +352,14 @@ void MarlinUI::draw_status_screen() { } // Low-level draw_edit_screen can be used to draw an edit screen from anyplace -void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char * const value/*=nullptr*/) { +void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const value/*=nullptr*/) { ui.encoder_direction_normal(); TERN_(TOUCH_SCREEN, touch.clear()); uint16_t line = 1; menu_line(line++); - tft_string.set(pstr, itemIndex, itemString); + tft_string.set(fstr, itemIndex, itemStringC, itemStringF); tft_string.trim(); tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); @@ -421,7 +421,7 @@ void TFT::draw_edit_screen_buttons() { } // The Select Screen presents a prompt and two "buttons" -void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) { +void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, const bool yesno, FSTR_P const pref, const char * const string/*=nullptr*/, FSTR_P const suff/*=nullptr*/) { uint16_t line = 1; if (!string) line++; @@ -445,8 +445,8 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string); } #if ENABLED(TOUCH_SCREEN) - add_control(88, TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL); - add_control(328, TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM)); + if (no) add_control( 88, TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL); + if (yes) add_control(328, TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM)); #endif } @@ -490,12 +490,12 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const for (uint16_t x = 0; x < (GRID_MAX_POINTS_X); x++) for (uint16_t y = 0; y < (GRID_MAX_POINTS_Y); y++) - if (position_is_reachable({ ubl.mesh_index_to_xpos(x), ubl.mesh_index_to_ypos(y) })) + if (position_is_reachable({ bedlevel.get_mesh_x(x), bedlevel.get_mesh_y(y) })) tft.add_bar(1 + (x * 2 + 1) * (GRID_WIDTH - 4) / (GRID_MAX_POINTS_X) / 2, GRID_HEIGHT - 3 - ((y * 2 + 1) * (GRID_HEIGHT - 4) / (GRID_MAX_POINTS_Y) / 2), 2, 2, COLOR_UBL); tft.add_rectangle((x_plot * 2 + 1) * (GRID_WIDTH - 4) / (GRID_MAX_POINTS_X) / 2 - 1, GRID_HEIGHT - 5 - ((y_plot * 2 + 1) * (GRID_HEIGHT - 4) / (GRID_MAX_POINTS_Y) / 2), 6, 6, COLOR_UBL); - const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) }, + const xy_pos_t pos = { bedlevel.get_mesh_x(x_plot), bedlevel.get_mesh_y(y_plot) }, lpos = pos.asLogical(); tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 - MENU_ITEM_HEIGHT, 120, MENU_ITEM_HEIGHT); @@ -518,7 +518,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const tft.set_background(COLOR_BACKGROUND); tft_string.set(Z_LBL); tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); - tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot])); + tft_string.set(isnan(bedlevel.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(bedlevel.z_values[x_plot][y_plot])); tft_string.trim(); tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); @@ -583,9 +583,9 @@ MotionAxisState motionAxisState; static void quick_feedback() { #if HAS_CHIRP ui.chirp(); // Buzz and wait. Is the delay needed for buttons to settle? - #if BOTH(HAS_LCD_MENU, USE_BEEPER) + #if BOTH(HAS_MARLINUI_MENU, HAS_BEEPER) for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); } - #elif HAS_LCD_MENU + #elif HAS_MARLINUI_MENU delay(10); #endif #endif @@ -593,7 +593,7 @@ static void quick_feedback() { #define CUR_STEP_VALUE_WIDTH 104 static void drawCurStepValue() { - tft_string.set((uint8_t *)ftostr52sp(motionAxisState.currentStepSize)); + tft_string.set(ftostr52sp(motionAxisState.currentStepSize)); tft_string.add("mm"); tft.canvas(motionAxisState.stepValuePos.x, motionAxisState.stepValuePos.y, CUR_STEP_VALUE_WIDTH, BTN_HEIGHT); tft.set_background(COLOR_BACKGROUND); @@ -622,7 +622,7 @@ static void drawCurESelection() { tft.add_text(tft_string.width(), 0, E_BTN_COLOR, ui8tostr3rj(motionAxisState.e_selection)); } -static void drawMessage(const char *msg) { +static void drawMessage(PGM_P const msg) { tft.canvas(X_MARGIN, TFT_HEIGHT - Y_MARGIN - 34, TFT_HEIGHT / 2, 34); tft.set_background(COLOR_BACKGROUND); tft.add_text(0, 0, COLOR_YELLOW, msg); @@ -653,7 +653,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { #if ENABLED(PREVENT_COLD_EXTRUSION) if (axis == E_AXIS && thermalManager.tooColdToExtrude(motionAxisState.e_selection)) { - drawMessage("Too cold"); + drawMessage(PSTR("Too cold")); return; } #endif @@ -676,7 +676,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { probe.offset.z = new_offs; else TERN(BABYSTEP_HOTEND_Z_OFFSET, hotend_offset[active_extruder].z = new_offs, NOOP); - drawMessage(""); // clear the error + drawMessage(NUL_STR); // clear the error drawAxisValue(axis); } else { @@ -694,7 +694,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) { drawMessage(GET_TEXT(MSG_LCD_SOFT_ENDSTOPS)); } else { - drawMessage(""); // clear the error + drawMessage(NUL_STR); // clear the error } drawAxisValue(axis); #endif diff --git a/Marlin/src/lcd/tft/ui_common.cpp b/Marlin/src/lcd/tft/ui_common.cpp index acc91f51fa83..c9e069dbbd6f 100644 --- a/Marlin/src/lcd/tft/ui_common.cpp +++ b/Marlin/src/lcd/tft/ui_common.cpp @@ -96,16 +96,15 @@ 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(wchar_t c, pixel_len_t max_length) { +int lcd_put_wchar_max(const wchar_t c, const pixel_len_t max_length) { if (max_length < 1) return 0; - tft_string.set(); - tft_string.add(c); + tft_string.set(c); tft.add_text(MENU_TEXT_X_OFFSET, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); lcd_gotopixel((cursor.x + 1) * (TFT_COL_WIDTH) + tft_string.width(), cursor.y * MENU_LINE_HEIGHT); return tft_string.width(); } -int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) { +int lcd_put_u8str_max_P(PGM_P utf8_pstr, const pixel_len_t max_length) { if (max_length < 1) return 0; tft_string.set(utf8_pstr); tft_string.trim(); @@ -115,7 +114,7 @@ int lcd_put_u8str_max_P(PGM_P utf8_pstr, pixel_len_t max_length) { return tft_string.width(); } -int lcd_put_u8str_max(const char * utf8_str, pixel_len_t max_length) { +int lcd_put_u8str_max(const char * utf8_str, const pixel_len_t max_length) { return lcd_put_u8str_max_P(utf8_str, max_length); } @@ -130,10 +129,10 @@ void lcd_put_int(const int i) { // // Draw a generic menu item with pre_char (if selected) and post_char -void MenuItemBase::_draw(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char) { +void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char pre_char, const char post_char) { menu_item(row, sel); - uint8_t *string = (uint8_t *)pstr; + const char *string = FTOP(fstr); MarlinImage image = noImage; switch (*string) { case 0x01: image = imgRefresh; break; // LCD_STR_REFRESH @@ -147,33 +146,34 @@ void MenuItemBase::_draw(const bool sel, const uint8_t row, PGM_P const pstr, co tft.add_image(MENU_ITEM_ICON_X, MENU_ITEM_ICON_Y, image, COLOR_MENU_TEXT, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND); } - tft_string.set(string, itemIndex, itemString); + tft_string.set(string, itemIndex, itemStringC, itemStringF); + tft.add_text(offset, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); } // Draw a menu item with a (potentially) editable value -void MenuEditItemBase::draw(const bool sel, const uint8_t row, PGM_P const pstr, const char * const data, const bool pgm) { +void MenuEditItemBase::draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char * const inStr, const bool pgm) { menu_item(row, sel); - tft_string.set(pstr, itemIndex, itemString); + tft_string.set(fstr, itemIndex, itemStringC, itemStringF); tft.add_text(MENU_TEXT_X_OFFSET, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string); - if (data) { - tft_string.set(data); + if (inStr) { + tft_string.set(inStr); tft.add_text(TFT_WIDTH - MENU_TEXT_X_OFFSET - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string); } } // Draw a static item with no left-right margin required. Centered by default. -void MenuItem_static::draw(const uint8_t row, PGM_P const pstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) { +void MenuItem_static::draw(const uint8_t row, FSTR_P const fstr, const uint8_t style/*=SS_DEFAULT*/, const char * const vstr/*=nullptr*/) { menu_item(row); - tft_string.set(pstr, itemIndex, itemString); + tft_string.set(fstr, itemIndex, itemStringC, itemStringF); if (vstr) tft_string.add(vstr); tft.add_text(tft_string.center(TFT_WIDTH), MENU_TEXT_Y_OFFSET, COLOR_YELLOW, tft_string); } #if ENABLED(SDSUPPORT) - void MenuItem_sdbase::draw(const bool sel, const uint8_t row, PGM_P const, CardReader &theCard, const bool isDir) { + void MenuItem_sdbase::draw(const bool sel, const uint8_t row, FSTR_P const, CardReader &theCard, const bool isDir) { menu_item(row, sel); if (isDir) tft.add_image(MENU_ITEM_ICON_X, MENU_ITEM_ICON_Y, imgDirectory, COLOR_MENU_TEXT, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND); constexpr uint8_t maxlen = (MENU_ITEM_HEIGHT) - (MENU_TEXT_Y_OFFSET) + 1; diff --git a/Marlin/src/lcd/tft_io/tft_io.h b/Marlin/src/lcd/tft_io/tft_io.h index 65602240d63a..50b921cd2a93 100644 --- a/Marlin/src/lcd/tft_io/tft_io.h +++ b/Marlin/src/lcd/tft_io/tft_io.h @@ -121,6 +121,11 @@ class TFT_IO { inline static void WriteReg(uint16_t Reg) { io.WriteReg(Reg); }; inline static void WriteSequence(uint16_t *Data, uint16_t Count) { io.WriteSequence(Data, Count); }; + + #if ENABLED(USE_SPI_DMA_TC) + 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); }; diff --git a/Marlin/src/lcd/thermistornames.h b/Marlin/src/lcd/thermistornames.h index 4f6dd23ece90..2571efe0759c 100644 --- a/Marlin/src/lcd/thermistornames.h +++ b/Marlin/src/lcd/thermistornames.h @@ -70,6 +70,10 @@ #define THERMISTOR_NAME "Zonestar (P802M Hot Bed)" #elif THERMISTOR_ID == 503 #define THERMISTOR_NAME "Zonestar (Z8XM2 Bed)" +#elif THERMISTOR_ID == 504 + #define THERMISTOR_NAME "Zonestar (P802QR2 Hot End)" +#elif THERMISTOR_ID == 505 + #define THERMISTOR_NAME "Zonestar (P802QR2 Bed)" #elif THERMISTOR_ID == 512 #define THERMISTOR_NAME "RPW-Ultra" #elif THERMISTOR_ID == 6 diff --git a/Marlin/src/lcd/touch/touch_buttons.cpp b/Marlin/src/lcd/touch/touch_buttons.cpp index c15bb08281f2..dcdc7def8667 100644 --- a/Marlin/src/lcd/touch/touch_buttons.cpp +++ b/Marlin/src/lcd/touch/touch_buttons.cpp @@ -79,7 +79,7 @@ uint8_t TouchButtons::read_buttons() { #if ENABLED(TOUCH_SCREEN_CALIBRATION) const calibrationState state = touch_calibration.get_calibration_state(); - if (state >= CALIBRATION_TOP_LEFT && state <= CALIBRATION_BOTTOM_RIGHT) { + if (WITHIN(state, CALIBRATION_TOP_LEFT, CALIBRATION_BOTTOM_RIGHT)) { if (touch_calibration.handleTouch(x, y)) ui.refresh(); return 0; } diff --git a/Marlin/src/libs/BL24CXX.cpp b/Marlin/src/libs/BL24CXX.cpp index 6407fac67086..4b5a23e4c550 100644 --- a/Marlin/src/libs/BL24CXX.cpp +++ b/Marlin/src/libs/BL24CXX.cpp @@ -48,17 +48,17 @@ #ifdef __STM32F1__ #define SDA_IN() do{ PIN_MAP[IIC_EEPROM_SDA].gpio_device->regs->CRH &= 0XFFFF0FFF; PIN_MAP[IIC_EEPROM_SDA].gpio_device->regs->CRH |= 8 << 12; }while(0) #define SDA_OUT() do{ PIN_MAP[IIC_EEPROM_SDA].gpio_device->regs->CRH &= 0XFFFF0FFF; PIN_MAP[IIC_EEPROM_SDA].gpio_device->regs->CRH |= 3 << 12; }while(0) -#elif STM32F1 +#elif defined(STM32F1) || defined(STM32F4) #define SDA_IN() SET_INPUT(IIC_EEPROM_SDA) #define SDA_OUT() SET_OUTPUT(IIC_EEPROM_SDA) #endif // IO ops -#define IIC_SCL_0() WRITE(IIC_EEPROM_SCL, LOW) -#define IIC_SCL_1() WRITE(IIC_EEPROM_SCL, HIGH) -#define IIC_SDA_0() WRITE(IIC_EEPROM_SDA, LOW) -#define IIC_SDA_1() WRITE(IIC_EEPROM_SDA, HIGH) -#define READ_SDA() READ(IIC_EEPROM_SDA) +#define IIC_SCL_0() WRITE(IIC_EEPROM_SCL, LOW) +#define IIC_SCL_1() WRITE(IIC_EEPROM_SCL, HIGH) +#define IIC_SDA_0() WRITE(IIC_EEPROM_SDA, LOW) +#define IIC_SDA_1() WRITE(IIC_EEPROM_SDA, HIGH) +#define READ_SDA() READ(IIC_EEPROM_SDA) // // Simple IIC interface via libmaple diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp index 6f80652ce5b4..1dc27d546538 100644 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.cpp +++ b/Marlin/src/libs/L64XX/L64XX_Marlin.cpp @@ -38,8 +38,8 @@ L64XX_Marlin L64xxManager; #include "../../HAL/shared/Delay.h" static const char LINEAR_AXIS_LIST( - str_X[] PROGMEM = "X ", str_Y[] PROGMEM = "Y ", str_Z[] PROGMEM = "Z ", - str_I[] PROGMEM = AXIS4_STR " ", str_J[] PROGMEM = AXIS5_STR " ", str_K[] PROGMEM = AXIS6_STR " " + 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", @@ -66,14 +66,14 @@ void echo_yes_no(const bool yes) { DEBUG_ECHOPGM_P(yes ? PSTR(" YES") : PSTR(" N uint8_t L64XX_Marlin::dir_commands[MAX_L64XX]; // array to hold direction command for each driver -#define _EN_ITEM(N) , INVERT_E##N##_DIR +#define _EN_ITEM(N) , ENABLED(INVERT_E##N##_DIR) const uint8_t L64XX_Marlin::index_to_dir[MAX_L64XX] = { - LINEAR_AXIS_LIST(INVERT_X_DIR, INVERT_Y_DIR, INVERT_Z_DIR, INVERT_I_DIR, INVERT_J_DIR, INVERT_K_DIR) - , (INVERT_X_DIR) ^ BOTH(X_DUAL_STEPPER_DRIVERS, INVERT_X2_VS_X_DIR) // X2 - , (INVERT_Y_DIR) ^ BOTH(Y_DUAL_STEPPER_DRIVERS, INVERT_Y2_VS_Y_DIR) // Y2 - , (INVERT_Z_DIR) ^ ENABLED(INVERT_Z2_VS_Z_DIR) // Z2 - , (INVERT_Z_DIR) ^ ENABLED(INVERT_Z3_VS_Z_DIR) // Z3 - , (INVERT_Z_DIR) ^ ENABLED(INVERT_Z4_VS_Z_DIR) // Z4 + 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_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 @@ -497,7 +497,7 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in } break; #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS case AXIS4_NAME: { position_min = I_center - displacement; position_max = I_center + displacement; @@ -509,7 +509,7 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in } break; #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS case AXIS5_NAME: { position_min = J_center - displacement; position_max = J_center + displacement; @@ -521,7 +521,7 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in } break; #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS case AXIS6_NAME: { position_min = K_center - displacement; position_max = K_center + displacement; diff --git a/Marlin/src/libs/L64XX/L64XX_Marlin.h b/Marlin/src/libs/L64XX/L64XX_Marlin.h index e11d8e872e60..de7c0d605740 100644 --- a/Marlin/src/libs/L64XX/L64XX_Marlin.h +++ b/Marlin/src/libs/L64XX/L64XX_Marlin.h @@ -118,11 +118,11 @@ class L64XX_Marlin : public L64XXHelper { #if ENABLED(MONITOR_L6470_DRIVER_STATUS) static bool monitor_paused; - static inline void pause_monitor(const bool p) { monitor_paused = p; } + 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 inline void pause_monitor(const bool) {} + static void pause_monitor(const bool) {} #endif //protected: diff --git a/Marlin/src/libs/MAX31865.cpp b/Marlin/src/libs/MAX31865.cpp index 6cc8ffca3990..c042504cf872 100644 --- a/Marlin/src/libs/MAX31865.cpp +++ b/Marlin/src/libs/MAX31865.cpp @@ -50,10 +50,6 @@ #define MAX31865_MIN_SAMPLING_TIME_MSEC 0 #endif -#ifdef TARGET_LPC1768 - #include -#endif - #define DEBUG_OUT ENABLED(DEBUG_MAX31865) #include "../core/debug_out.h" @@ -151,24 +147,62 @@ void MAX31865::begin(max31865_numwires_t wires, float zero_res, float ref_res, f digitalWrite(cselPin, HIGH); if (sclkPin != TERN(LARGE_PINMAP, -1UL, 255)) - softSpiBegin(SPI_QUARTER_SPEED); // Define pin modes for Software SPI + softSpiInit(); // Define pin modes for Software SPI else { - DEBUG_ECHOLNPGM("Initializing MAX31865 Hardware SPI"); + DEBUG_ECHOLNPGM("Init MAX31865 Hardware SPI"); SPI.begin(); // Start and configure hardware SPI } initFixedFlags(wires); - clearFault(); // also initializes flags + DEBUG_ECHOLNPGM("MAX31865 Regs: CFG ", readRegister8(MAX31865_CONFIG_REG), + "|RTD ", readRegister16(MAX31865_RTDMSB_REG), + "|HTHRS ", readRegister16(MAX31865_HFAULTMSB_REG), + "|LTHRS ", readRegister16(MAX31865_LFAULTMSB_REG), + "|FLT ", readRegister8(MAX31865_FAULTSTAT_REG)); + + // fault detection cycle seems to initialize the sensor better + runAutoFaultDetectionCycle(); // also initializes flags + + if (lastFault) + SERIAL_ECHOLNPGM("MAX31865 init fault ", lastFault); + + writeRegister16(MAX31865_HFAULTMSB_REG, 0xFFFF); + writeRegister16(MAX31865_LFAULTMSB_REG, 0); + + #if ENABLED(MAX31865_USE_AUTO_MODE) // make a proper first read to initialize _lastRead + + uint16_t rtd = readRegister16(MAX31865_RTDMSB_REG); + + #if MAX31865_IGNORE_INITIAL_FAULTY_READS > 0 + rtd = fixFault(rtd); + #endif + + if (rtd & 1) { + lastRead = 0xFFFF; // some invalid value + lastFault = readRegister8(MAX31865_FAULTSTAT_REG); + clearFault(); // also clears the bias voltage flag, so no further action is required + + DEBUG_ECHOLNPGM("MAX31865 read fault: ", rtd); + } + else { + DEBUG_ECHOLNPGM("RTD MSB:", (rtd >> 8), " RTD LSB:", (rtd & 0x00FF)); + lastRead = rtd; + TERN_(MAX31865_USE_READ_ERROR_DETECTION, lastReadStamp = millis()); + } - #if DISABLED(MAX31865_USE_AUTO_MODE) // make a proper first 1 shot read to initialize _lastRead + #else enableBias(); - DELAY_US(11500); + DELAY_US(2000); // according to the datasheet, 10.5τ+1msec (see below) oneShot(); - DELAY_US(65000); + DELAY_US(63000); uint16_t rtd = readRegister16(MAX31865_RTDMSB_REG); + #if MAX31865_IGNORE_INITIAL_FAULTY_READS > 0 + rtd = fixFault(rtd); + #endif + if (rtd & 1) { lastRead = 0xFFFF; // some invalid value lastFault = readRegister8(MAX31865_FAULTSTAT_REG); @@ -189,7 +223,7 @@ void MAX31865::begin(max31865_numwires_t wires, float zero_res, float ref_res, f TERN_(MAX31865_USE_READ_ERROR_DETECTION, lastReadStamp = now); } - #endif // !MAX31865_USE_AUTO_MODE + #endif // MAX31865_USE_AUTO_MODE DEBUG_ECHOLNPGM( TERN(LARGE_PINMAP, "LARGE_PINMAP", "Regular") @@ -198,7 +232,7 @@ void MAX31865::begin(max31865_numwires_t wires, float zero_res, float ref_res, f " sclkPin: ", sclkPin, " mosiPin: ", mosiPin, " config: ", readRegister8(MAX31865_CONFIG_REG) - ); + ); } /** @@ -240,6 +274,29 @@ void MAX31865::oneShot() { setConfig(MAX31865_CONFIG_1SHOT | MAX31865_CONFIG_BIAS, 1); } +void MAX31865::runAutoFaultDetectionCycle() { + writeRegister8(MAX31865_CONFIG_REG, (stdFlags & 0x11) | 0x84 ); // cfg reg = 100X010Xb + DELAY_US(600); + for (int i = 0; i < 10 && (readRegister8(MAX31865_CONFIG_REG) & 0xC) > 0; i++) DELAY_US(100); // Fault det completes when bits 2 and 3 are zero (or after 10 tries) + readFault(); + clearFault(); +} + +/** + * Set a value in the configuration register. + * + * @param config 8-bit value for the config item + * @param enable whether to enable or disable the value + */ +void MAX31865::setConfig(uint8_t config, bool enable) { + uint8_t t = stdFlags; + if (enable) + t |= config; + else + t &= ~config; + writeRegister8(MAX31865_CONFIG_REG, t); +} + /** * Initialize standard flags with flags that will not change during operation (Hz, polling mode and no. of wires) * @@ -249,12 +306,59 @@ void MAX31865::initFixedFlags(max31865_numwires_t wires) { // set config-defined flags (same for all sensors) stdFlags = TERN(MAX31865_50HZ_FILTER, MAX31865_CONFIG_FILT50HZ, MAX31865_CONFIG_FILT60HZ) | - TERN(MAX31865_USE_AUTO_MODE, MAX31865_CONFIG_MODEAUTO | MAX31865_CONFIG_BIAS, MAX31865_CONFIG_MODEOFF); + TERN(MAX31865_USE_AUTO_MODE, MAX31865_CONFIG_MODEAUTO | MAX31865_CONFIG_BIAS, MAX31865_CONFIG_MODEOFF); if (wires == MAX31865_3WIRE) - stdFlags |= MAX31865_CONFIG_3WIRE; - else // 2 or 4 wire - stdFlags &= ~MAX31865_CONFIG_3WIRE; + stdFlags |= MAX31865_CONFIG_3WIRE; // 3 wire + else + stdFlags &= ~MAX31865_CONFIG_3WIRE; // 2 or 4 wire +} + +#if MAX31865_IGNORE_INITIAL_FAULTY_READS > 0 + + inline uint16_t MAX31865::fixFault(uint16_t rtd) { + if (!ignore_faults || !(rtd & 1)) + return rtd; + + ignore_faults--; + clearFault(); + + DEBUG_ECHOLNPGM("MAX31865 ignoring fault ", (MAX31865_IGNORE_INITIAL_FAULTY_READS) - ignore_faults); + + return rtd & ~1; // 0xFFFE + } + +#endif + +inline uint16_t MAX31865::readRawImmediate() { + uint16_t rtd = readRegister16(MAX31865_RTDMSB_REG); + DEBUG_ECHOLNPGM("MAX31865 RTD MSB:", (rtd >> 8), " LSB:", (rtd & 0x00FF)); + + #if MAX31865_IGNORE_INITIAL_FAULTY_READS > 0 + rtd = fixFault(rtd); + #endif + + if (rtd & 1) { + lastFault = readRegister8(MAX31865_FAULTSTAT_REG); + lastRead |= 1; + clearFault(); // also clears the bias voltage flag, so no further action is required + DEBUG_ECHOLNPGM("MAX31865 read fault: ", lastFault); + } + else { + TERN_(MAX31865_USE_READ_ERROR_DETECTION, const millis_t ms = millis()); + if (TERN0(MAX31865_USE_READ_ERROR_DETECTION, ABS((int)(lastRead - rtd)) > 500 && PENDING(ms, lastReadStamp + 1000))) { + // If 2 readings within 1s differ too much (~20°C) it's a read error. + lastFault = 0x01; + lastRead |= 1; + DEBUG_ECHOLNPGM("MAX31865 read error: ", rtd); + } + else { + lastRead = rtd; + TERN_(MAX31865_USE_READ_ERROR_DETECTION, lastReadStamp = ms); + } + } + + return rtd; } /** @@ -267,30 +371,13 @@ uint16_t MAX31865::readRaw() { #if ENABLED(MAX31865_USE_AUTO_MODE) - const uint16_t rtd = readRegister16(MAX31865_RTDMSB_REG); - DEBUG_ECHOLNPGM("MAX31865 RTD MSB:", (rtd >> 8), " LSB:", (rtd & 0x00FF)); - - if (rtd & 1) { - lastFault = readRegister8(MAX31865_FAULTSTAT_REG); - lastRead |= 1; - clearFault(); // also clears the bias voltage flag, so no further action is required - DEBUG_ECHOLNPGM("MAX31865 read fault: ", rtd); - } - #if ENABLED(MAX31865_USE_READ_ERROR_DETECTION) - else if (ABS(lastRead - rtd) > 500 && PENDING(millis(), lastReadStamp + 1000)) { // if two readings within a second differ too much (~20°C), consider it a read error. - lastFault = 0x01; - lastRead |= 1; - DEBUG_ECHOLNPGM("MAX31865 read error: ", rtd); - } - #endif - else { - lastRead = rtd; - TERN_(MAX31865_USE_READ_ERROR_DETECTION, lastReadStamp = millis()); - } + readRawImmediate(); #else - if (PENDING(millis(), nextEventStamp)) { + const millis_t ms = millis(); + + if (PENDING(ms, nextEventStamp)) { DEBUG_ECHOLNPGM("MAX31865 waiting for event ", nextEvent); return lastRead; } @@ -298,46 +385,26 @@ uint16_t MAX31865::readRaw() { switch (nextEvent) { case SETUP_BIAS_VOLTAGE: enableBias(); - nextEventStamp = millis() + 11; // wait at least 11msec before enabling 1shot + nextEventStamp = ms + 2; // wait at least 10.5*τ (τ = 100nF*430Ω max for PT100 / 10nF*4.3ΚΩ for PT1000 = 43μsec) + 1msec nextEvent = SETUP_1_SHOT_MODE; - DEBUG_ECHOLN("MAX31865 bias voltage enabled"); + DEBUG_ECHOLNPGM("MAX31865 bias voltage enabled"); break; case SETUP_1_SHOT_MODE: oneShot(); - nextEventStamp = millis() + 65; // wait at least 65msec before reading RTD register + nextEventStamp = ms + TERN(MAX31865_50HZ_FILTER, 63, 52); // wait at least 52msec for 60Hz (63msec for 50Hz) before reading RTD register nextEvent = READ_RTD_REG; - DEBUG_ECHOLN("MAX31865 1 shot mode enabled"); + DEBUG_ECHOLNPGM("MAX31865 1 shot mode enabled"); break; - case READ_RTD_REG: { - const uint16_t rtd = readRegister16(MAX31865_RTDMSB_REG); - DEBUG_ECHOLNPGM("MAX31865 RTD MSB:", (rtd >> 8), " LSB:", (rtd & 0x00FF)); - - if (rtd & 1) { - lastFault = readRegister8(MAX31865_FAULTSTAT_REG); - lastRead |= 1; - clearFault(); // also clears the bias voltage flag, so no further action is required - DEBUG_ECHOLNPGM("MAX31865 read fault: ", rtd); - } - #if ENABLED(MAX31865_USE_READ_ERROR_DETECTION) - else if (ABS(lastRead - rtd) > 500 && PENDING(millis(), lastReadStamp + 1000)) { // if two readings within a second differ too much (~20°C), consider it a read error. - lastFault = 0x01; - lastRead |= 1; - DEBUG_ECHOLNPGM("MAX31865 read error: ", rtd); - } - #endif - else { - lastRead = rtd; - TERN_(MAX31865_USE_READ_ERROR_DETECTION, lastReadStamp = millis()); - } - - if (!(rtd & 1)) // if clearFault() was not invoked, need to clear the bias voltage and 1-shot flags + case READ_RTD_REG: + + if (!(readRawImmediate() & 1)) // if clearFault() was not invoked, need to clear the bias voltage and 1-shot flags resetFlags(); nextEvent = SETUP_BIAS_VOLTAGE; - nextEventStamp = millis() + MAX31865_MIN_SAMPLING_TIME_MSEC; // next step should not occur within less than MAX31865_MIN_SAMPLING_TIME_MSEC from the last one - } break; + nextEventStamp = ms + (MAX31865_MIN_SAMPLING_TIME_MSEC); // next step should not occur within less than MAX31865_MIN_SAMPLING_TIME_MSEC from the last one + break; } #endif @@ -411,21 +478,17 @@ float MAX31865::temperature(float rtd_res) { return temp; } -// -// private: -// - /** - * Set a value in the configuration register. - * - * @param config 8-bit value for the config item - * @param enable whether to enable or disable the value + * MAX31865 SPI Timing constants + * See MAX31865 datasheet (https://datasheets.maximintegrated.com/en/ds/MAX31865.pdf) + * All timings in nsec, minimum values. */ -void MAX31865::setConfig(uint8_t config, bool enable) { - uint8_t t = stdFlags; - if (enable) t |= config; else t &= ~config; - writeRegister8(MAX31865_CONFIG_REG, t); -} + +#define MAX31865_SPI_TIMING_TCC 400 // CS to SCLK setup +#define MAX31865_SPI_TIMING_TDC 35 // Data to SCLK setup +#define MAX31865_SPI_TIMING_TCL 100 // SCK half period +#define MAX31865_SPI_TIMING_TCCH 100 // SCK to CS hold +#define MAX31865_SPI_TIMING_TCWH 400 // CS inactive time (min) /** * Read a single byte from the specified register address. @@ -459,18 +522,10 @@ uint16_t MAX31865::readRegister16(uint8_t addr) { * @param n the number of bytes to read */ void MAX31865::readRegisterN(uint8_t addr, uint8_t buffer[], uint8_t n) { - addr &= 0x7F; // make sure top bit is not set - if (sclkPin == TERN(LARGE_PINMAP, -1UL, 255)) - SPI.beginTransaction(spiConfig); - else - digitalWrite(sclkPin, LOW); - digitalWrite(cselPin, LOW); - - #ifdef TARGET_LPC1768 - DELAY_CYCLES(spiSpeed); - #endif + addr &= 0x7F; // make sure top bit is not set + spiBeginTransaction(); spiTransfer(addr); while (n--) { @@ -478,10 +533,15 @@ void MAX31865::readRegisterN(uint8_t addr, uint8_t buffer[], uint8_t n) { buffer++; } - if (sclkPin == TERN(LARGE_PINMAP, -1UL, 255)) - SPI.endTransaction(); + spiEndTransaction(); +} - digitalWrite(cselPin, HIGH); +void MAX31865::writeRegister16(uint8_t addr, uint16_t data) { + spiBeginTransaction(); + spiTransfer(addr | 0x80); // make sure top bit is set + spiTransfer(data >> 8); + spiTransfer(data & 0xFF); + spiEndTransaction(); } /** @@ -491,22 +551,31 @@ void MAX31865::readRegisterN(uint8_t addr, uint8_t buffer[], uint8_t n) { * @param data the data to write */ void MAX31865::writeRegister8(uint8_t addr, uint8_t data) { - if (sclkPin == TERN(LARGE_PINMAP, -1UL, 255)) - SPI.beginTransaction(spiConfig); - else - digitalWrite(sclkPin, LOW); + spiBeginTransaction(); + spiTransfer(addr | 0x80); // make sure top bit is set + spiTransfer(data); + spiEndTransaction(); +} +void MAX31865::spiBeginTransaction() { + digitalWrite(sclkPin, LOW); // ensure CPOL0 + DELAY_NS_VAR(MAX31865_SPI_TIMING_TCWH); // ensure minimum time of CS inactivity after previous operation digitalWrite(cselPin, LOW); + DELAY_NS_VAR(MAX31865_SPI_TIMING_TCC); - #ifdef TARGET_LPC1768 - DELAY_CYCLES(spiSpeed); - #endif - - spiTransfer(addr | 0x80); // make sure top bit is set - spiTransfer(data); + if (sclkPin == TERN(LARGE_PINMAP, -1UL, 255)) + SPI.beginTransaction(spiConfig); + else + digitalWrite(sclkPin, HIGH); +} +void MAX31865::spiEndTransaction() { if (sclkPin == TERN(LARGE_PINMAP, -1UL, 255)) SPI.endTransaction(); + else + digitalWrite(sclkPin, LOW); + + DELAY_NS_VAR(MAX31865_SPI_TIMING_TCCH); digitalWrite(cselPin, HIGH); } @@ -521,42 +590,30 @@ void MAX31865::writeRegister8(uint8_t addr, uint8_t data) { * @return the 8-bit response */ uint8_t MAX31865::spiTransfer(uint8_t x) { - if (sclkPin == TERN(LARGE_PINMAP, -1UL, 255)) return SPI.transfer(x); - #ifdef TARGET_LPC1768 - - return swSpiTransfer(x, spiSpeed, sclkPin, misoPin, mosiPin); - - #else - - uint8_t reply = 0; - for (int i = 7; i >= 0; i--) { - digitalWrite(sclkPin, HIGH); DELAY_NS_VAR(spiDelay); - reply <<= 1; - digitalWrite(mosiPin, x & _BV(i)); DELAY_NS_VAR(spiDelay); - if (digitalRead(misoPin)) reply |= 1; - digitalWrite(sclkPin, LOW); DELAY_NS_VAR(spiDelay); - } - return reply; - - #endif + uint8_t reply = 0; + for (int i = 7; i >= 0; i--) { + digitalWrite(mosiPin, x & _BV(i)); + DELAY_NS_VAR(MAX31865_SPI_TIMING_TDC); + digitalWrite(sclkPin, LOW); + DELAY_NS_VAR(MAX31865_SPI_TIMING_TCL - MAX31865_SPI_TIMING_TDC); + reply <<= 1; + if (digitalRead(misoPin)) reply |= 1; + DELAY_NS_VAR(MAX31865_SPI_TIMING_TDC); + digitalWrite(sclkPin, HIGH); + DELAY_NS_VAR(MAX31865_SPI_TIMING_TCL - MAX31865_SPI_TIMING_TDC); + } + return reply; } -void MAX31865::softSpiBegin(const uint8_t spi_speed) { +void MAX31865::softSpiInit() { DEBUG_ECHOLNPGM("Initializing MAX31865 Software SPI"); - - #ifdef TARGET_LPC1768 - swSpiBegin(sclkPin, misoPin, mosiPin); - spiSpeed = swSpiInit(spi_speed, sclkPin, mosiPin); - #else - spiDelay = (100UL << spi_speed) / 3; // Calculate delay in ns. Top speed is ~10MHz, or 100ns delay between bits. - pinMode(sclkPin, OUTPUT); - digitalWrite(sclkPin, LOW); - pinMode(mosiPin, OUTPUT); - pinMode(misoPin, INPUT); - #endif + pinMode(sclkPin, OUTPUT); + digitalWrite(sclkPin, LOW); + pinMode(mosiPin, OUTPUT); + pinMode(misoPin, INPUT); } #endif // HAS_MAX31865 && !USE_ADAFRUIT_MAX31865 diff --git a/Marlin/src/libs/MAX31865.h b/Marlin/src/libs/MAX31865.h index bc7733b835ec..baea455485d4 100644 --- a/Marlin/src/libs/MAX31865.h +++ b/Marlin/src/libs/MAX31865.h @@ -101,11 +101,7 @@ class MAX31865 { TERN(LARGE_PINMAP, uint32_t, uint8_t) sclkPin, misoPin, mosiPin, cselPin; - #ifdef TARGET_LPC1768 - uint8_t spiSpeed; - #else - uint16_t spiDelay; - #endif + uint16_t spiDelay; float zeroRes, refRes, wireRes; @@ -121,6 +117,11 @@ class MAX31865 { one_shot_event_t nextEvent; #endif + #ifdef MAX31865_IGNORE_INITIAL_FAULTY_READS + uint8_t ignore_faults = MAX31865_IGNORE_INITIAL_FAULTY_READS; + uint16_t fixFault(uint16_t rtd); + #endif + uint8_t stdFlags = 0; void setConfig(uint8_t config, bool enable); @@ -130,9 +131,12 @@ class MAX31865 { uint16_t readRegister16(uint8_t addr); void writeRegister8(uint8_t addr, uint8_t reg); - uint8_t spiTransfer(uint8_t addr); + void writeRegister16(uint8_t addr, uint16_t reg); - void softSpiBegin(const uint8_t spi_speed); + void softSpiInit(); + void spiBeginTransaction(); + uint8_t spiTransfer(uint8_t addr); + void spiEndTransaction(); void initFixedFlags(max31865_numwires_t wires); @@ -141,6 +145,10 @@ class MAX31865 { void oneShot(); void resetFlags(); + uint16_t readRawImmediate(); + + void runAutoFaultDetectionCycle(); + public: #if ENABLED(LARGE_PINMAP) MAX31865(uint32_t spi_cs, uint8_t pin_mapping); diff --git a/Marlin/src/libs/W25Qxx.cpp b/Marlin/src/libs/W25Qxx.cpp index b458a7c965ef..033402d04ab0 100644 --- a/Marlin/src/libs/W25Qxx.cpp +++ b/Marlin/src/libs/W25Qxx.cpp @@ -133,7 +133,7 @@ uint16_t W25QXXFlash::W25QXX_ReadID(void) { return Temp; } -void W25QXXFlash::SPI_FLASH_WriteEnable(void) { +void W25QXXFlash::SPI_FLASH_WriteEnable() { // Select the FLASH: Chip Select low SPI_FLASH_CS_L(); // Send "Write Enable" instruction @@ -151,7 +151,7 @@ void W25QXXFlash::SPI_FLASH_WriteEnable(void) { * Output : None * Return : None *******************************************************************************/ -void W25QXXFlash::SPI_FLASH_WaitForWriteEnd(void) { +void W25QXXFlash::SPI_FLASH_WaitForWriteEnd() { uint8_t FLASH_Status = 0; // Select the FLASH: Chip Select low @@ -216,7 +216,7 @@ void W25QXXFlash::SPI_FLASH_BlockErase(uint32_t BlockAddr) { * Output : None * Return : None *******************************************************************************/ -void W25QXXFlash::SPI_FLASH_BulkErase(void) { +void W25QXXFlash::SPI_FLASH_BulkErase() { // Send write enable instruction SPI_FLASH_WriteEnable(); diff --git a/Marlin/src/libs/W25Qxx.h b/Marlin/src/libs/W25Qxx.h index 1133af2e74dd..778463477d82 100644 --- a/Marlin/src/libs/W25Qxx.h +++ b/Marlin/src/libs/W25Qxx.h @@ -61,11 +61,11 @@ class W25QXXFlash { static void spi_flash_Send(uint8_t b); static void spi_flash_SendBlock(uint8_t token, const uint8_t *buf); static uint16_t W25QXX_ReadID(void); - static void SPI_FLASH_WriteEnable(void); - static void SPI_FLASH_WaitForWriteEnd(void); + static void SPI_FLASH_WriteEnable(); + static void SPI_FLASH_WaitForWriteEnd(); static void SPI_FLASH_SectorErase(uint32_t SectorAddr); static void SPI_FLASH_BlockErase(uint32_t BlockAddr); - static void SPI_FLASH_BulkErase(void); + static void SPI_FLASH_BulkErase(); static void SPI_FLASH_PageWrite(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite); static void SPI_FLASH_BufferWrite(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite); static void SPI_FLASH_BufferRead(uint8_t *pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead); diff --git a/Marlin/src/libs/bresenham.h b/Marlin/src/libs/bresenham.h index 865c43c29e0b..39ab60700769 100644 --- a/Marlin/src/libs/bresenham.h +++ b/Marlin/src/libs/bresenham.h @@ -30,7 +30,7 @@ */ #define FORCE_INLINE __attribute__((always_inline)) inline -#define _O3 __attribute__((optimize("O3"))) +#define __O3 __attribute__((optimize("O3"))) template struct BresenhamCfg { static constexpr uint8_t UID = uid, SIZE = size; }; @@ -114,9 +114,9 @@ class Bresenham { if (tick1(index)) { value[index] += dir[index]; back(index); } } - FORCE_INLINE static void tick1() _O3 { for (uint8_t i = 0; i < Cfg::SIZE; i++) (void)tick1(i); } + FORCE_INLINE static void tick1() __O3 { for (uint8_t i = 0; i < Cfg::SIZE; i++) (void)tick1(i); } - FORCE_INLINE static void tick() _O3 { for (uint8_t i = 0; i < Cfg::SIZE; i++) (void)tick(i); } + FORCE_INLINE static void tick() __O3 { for (uint8_t i = 0; i < Cfg::SIZE; i++) (void)tick(i); } static void report(const uint8_t index) { if (index < Cfg::SIZE) { diff --git a/Marlin/src/libs/buzzer.cpp b/Marlin/src/libs/buzzer.cpp index 57ed5fb41910..a3c838ebc0a3 100644 --- a/Marlin/src/libs/buzzer.cpp +++ b/Marlin/src/libs/buzzer.cpp @@ -22,7 +22,7 @@ #include "../inc/MarlinConfig.h" -#if USE_BEEPER +#if HAS_BEEPER #include "buzzer.h" #include "../module/temperature.h" @@ -45,7 +45,7 @@ Buzzer buzzer; * @param frequency Frequency of the tone in hertz */ void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) { - if (!ui.buzzer_enabled) return; + if (!ui.sound_on) return; while (buffer.isFull()) { tick(); thermalManager.manage_heater(); @@ -55,7 +55,7 @@ void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) { } void Buzzer::tick() { - if (!ui.buzzer_enabled) return; + if (!ui.sound_on) return; const millis_t now = millis(); if (!state.endtime) { @@ -81,4 +81,4 @@ void Buzzer::tick() { else if (ELAPSED(now, state.endtime)) reset(); } -#endif // USE_BEEPER +#endif // HAS_BEEPER diff --git a/Marlin/src/libs/buzzer.h b/Marlin/src/libs/buzzer.h index 21b69002ffd3..b1c286a66222 100644 --- a/Marlin/src/libs/buzzer.h +++ b/Marlin/src/libs/buzzer.h @@ -23,7 +23,7 @@ #include "../inc/MarlinConfig.h" -#if USE_BEEPER +#if HAS_BEEPER #include "circularqueue.h" @@ -61,23 +61,11 @@ */ FORCE_INLINE static void invert() { TOGGLE(BEEPER_PIN); } - /** - * @brief Turn off a digital PIN - * @details Alias of digitalWrite(PIN, LOW) using FastIO - */ - FORCE_INLINE static void off() { WRITE(BEEPER_PIN, LOW); } - - /** - * @brief Turn on a digital PIN - * @details Alias of digitalWrite(PIN, HIGH) using FastIO - */ - FORCE_INLINE static void on() { WRITE(BEEPER_PIN, HIGH); } - /** * @brief Resets the state of the class * @details Brings the class state to a known one. */ - static inline void reset() { + static void reset() { off(); state.endtime = 0; } @@ -86,11 +74,25 @@ /** * @brief Init Buzzer */ - static inline void init() { + static void init() { SET_OUTPUT(BEEPER_PIN); reset(); } + /** + * @brief Turn on a digital PIN + * @details Alias of digitalWrite(PIN, HIGH) using FastIO + */ + FORCE_INLINE static void on() { WRITE(BEEPER_PIN, HIGH); } + + /** + * @brief Turn off a digital PIN + * @details Alias of digitalWrite(PIN, LOW) using FastIO + */ + FORCE_INLINE static void off() { WRITE(BEEPER_PIN, LOW); } + + static void click(const uint16_t duration) { on(); delay(duration); off(); } + /** * @brief Add a tone to the queue * @details Adds a tone_t structure to the ring buffer, will block IO if the @@ -118,8 +120,8 @@ #elif HAS_BUZZER // Buzz indirectly via the MarlinUI instance - #include "../lcd/marlinui.h" #define BUZZ(d,f) ui.buzz(d,f) + #include "../lcd/marlinui.h" #else @@ -127,3 +129,7 @@ #define BUZZ(d,f) 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) diff --git a/Marlin/src/libs/nozzle.cpp b/Marlin/src/libs/nozzle.cpp index e277216ab4e5..4ca8fa2cae1e 100644 --- a/Marlin/src/libs/nozzle.cpp +++ b/Marlin/src/libs/nozzle.cpp @@ -254,11 +254,18 @@ Nozzle nozzle; break; } - do_blocking_move_to_xy( - TERN(NOZZLE_PARK_Y_ONLY, current_position, park).x, - TERN(NOZZLE_PARK_X_ONLY, current_position, park).y, - fr_xy - ); + #ifndef NOZZLE_PARK_MOVE + #define NOZZLE_PARK_MOVE 0 + #endif + switch (NOZZLE_PARK_MOVE) { + case 0: do_blocking_move_to_xy(park, fr_xy); break; + case 1: do_blocking_move_to_x(park.x, fr_xy); break; + case 2: do_blocking_move_to_y(park.y, fr_xy); break; + case 3: do_blocking_move_to_x(park.x, fr_xy); + do_blocking_move_to_y(park.y, fr_xy); break; + case 4: do_blocking_move_to_y(park.y, fr_xy); + do_blocking_move_to_x(park.x, fr_xy); break; + } report_current_position(); } diff --git a/Marlin/src/libs/nozzle.h b/Marlin/src/libs/nozzle.h index 7bbd0e35c11b..69790f5a6786 100644 --- a/Marlin/src/libs/nozzle.h +++ b/Marlin/src/libs/nozzle.h @@ -41,7 +41,7 @@ class Nozzle { * @param end xyz_pos_t defining the ending point * @param strokes number of strokes to execute */ - static void stroke(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t &strokes) _Os; + static void stroke(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t &strokes) __Os; /** * @brief Zig-zag clean pattern @@ -52,7 +52,7 @@ class Nozzle { * @param strokes number of strokes to execute * @param objects number of objects to create */ - static void zigzag(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t &strokes, const uint8_t &objects) _Os; + static void zigzag(const xyz_pos_t &start, const xyz_pos_t &end, const uint8_t &strokes, const uint8_t &objects) __Os; /** * @brief Circular clean pattern @@ -62,7 +62,7 @@ class Nozzle { * @param strokes number of strokes to execute * @param radius radius of circle */ - static void circle(const xyz_pos_t &start, const xyz_pos_t &middle, const uint8_t &strokes, const_float_t radius) _Os; + static void circle(const xyz_pos_t &start, const xyz_pos_t &middle, const uint8_t &strokes, const_float_t radius) __Os; #endif // NOZZLE_CLEAN_FEATURE @@ -77,14 +77,14 @@ class Nozzle { * @param pattern one of the available patterns * @param argument depends on the cleaning pattern */ - static void clean(const uint8_t &pattern, const uint8_t &strokes, const_float_t radius, const uint8_t &objects, const uint8_t cleans) _Os; + static void clean(const uint8_t &pattern, const uint8_t &strokes, const_float_t radius, const uint8_t &objects, const uint8_t cleans) __Os; #endif // NOZZLE_CLEAN_FEATURE #if ENABLED(NOZZLE_PARK_FEATURE) - static float park_mode_0_height(const_float_t park_z) _Os; - static void park(const uint8_t z_action, const xyz_pos_t &park=NOZZLE_PARK_POINT) _Os; + static float park_mode_0_height(const_float_t park_z) __Os; + static void park(const uint8_t z_action, const xyz_pos_t &park=NOZZLE_PARK_POINT) __Os; #endif }; diff --git a/Marlin/src/libs/numtostr.cpp b/Marlin/src/libs/numtostr.cpp index 1e1ac0571012..f4d47983d225 100644 --- a/Marlin/src/libs/numtostr.cpp +++ b/Marlin/src/libs/numtostr.cpp @@ -377,10 +377,10 @@ const char* ftostr53sign(const_float_t f) { return conv; } -// Convert unsigned float to string with ____4.5, __34.5, _234.5, 1234.5 format -const char* ftostr51rj(const_float_t f) { +// 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] = ' '; + conv[0] = RJDIGIT(i, 100000); conv[1] = RJDIGIT(i, 10000); conv[2] = RJDIGIT(i, 1000); conv[3] = RJDIGIT(i, 100); diff --git a/Marlin/src/libs/numtostr.h b/Marlin/src/libs/numtostr.h index b058f3cdf6c6..1704d35e889d 100644 --- a/Marlin/src/libs/numtostr.h +++ b/Marlin/src/libs/numtostr.h @@ -113,8 +113,8 @@ const char* ftostr52sign(const_float_t x); // Convert signed float to string with +12.345 format const char* ftostr53sign(const_float_t f); -// Convert unsigned float to string with 1234.5 format omitting trailing zeros -const char* ftostr51rj(const_float_t x); +// Convert unsigned float to string with 12345.6 format omitting trailing zeros +const char* ftostr61rj(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))); } diff --git a/Marlin/src/libs/stopwatch.h b/Marlin/src/libs/stopwatch.h index fe5101a5beaa..829d510050d3 100644 --- a/Marlin/src/libs/stopwatch.h +++ b/Marlin/src/libs/stopwatch.h @@ -53,7 +53,7 @@ class Stopwatch { * @return true on success */ static bool stop(); - static inline bool abort() { return stop(); } // Alias by default + static bool abort() { return stop(); } // Alias by default /** * @brief Pause the stopwatch @@ -114,7 +114,7 @@ class Stopwatch { #else - static inline void debug(FSTR_P const) {} + static void debug(FSTR_P const) {} #endif }; diff --git a/Marlin/src/libs/vector_3.cpp b/Marlin/src/libs/vector_3.cpp index 614d2121b893..02945fe6871a 100644 --- a/Marlin/src/libs/vector_3.cpp +++ b/Marlin/src/libs/vector_3.cpp @@ -141,8 +141,7 @@ void matrix_3x3::debug(FSTR_P const title) { if (title) SERIAL_ECHOLNF(title); LOOP_L_N(i, 3) { LOOP_L_N(j, 3) { - if (vectors[i][j] >= 0.0) SERIAL_CHAR('+'); - SERIAL_ECHO_F(vectors[i][j], 6); + serial_offset(vectors[i][j], 2); SERIAL_CHAR(' '); } SERIAL_EOL(); diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index 2a4efb47da73..35c9cf63c776 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -60,9 +60,20 @@ 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(); +void refresh_delta_clip_start_height() { + delta_clip_start_height = TERN(HAS_SOFTWARE_ENDSTOPS, + soft_endstop.max.z, + DIFF_TERN(HAS_BED_PROBE, delta_height, probe.offset.z) + ) - delta_safe_distance_from_top(); +} + /** * Recalculate factors used for delta kinematics whenever * settings have been changed (e.g., by M665). @@ -226,6 +237,9 @@ void home_delta() { TERN_(I_SENSORLESS, sensorless_t stealth_states_i = start_sensorless_homing_per_axis(I_AXIS)); TERN_(J_SENSORLESS, sensorless_t stealth_states_j = start_sensorless_homing_per_axis(J_AXIS)); TERN_(K_SENSORLESS, sensorless_t stealth_states_k = start_sensorless_homing_per_axis(K_AXIS)); + #if SENSORLESS_STALLGUARD_DELAY + safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle + #endif #endif // Move all carriages together linearly until an endstop is hit. @@ -242,6 +256,9 @@ void home_delta() { TERN_(I_SENSORLESS, end_sensorless_homing_per_axis(I_AXIS, stealth_states_i)); TERN_(J_SENSORLESS, end_sensorless_homing_per_axis(J_AXIS, stealth_states_j)); TERN_(K_SENSORLESS, end_sensorless_homing_per_axis(K_AXIS, stealth_states_k)); + #if SENSORLESS_STALLGUARD_DELAY + safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle + #endif #endif endstops.validate_homing_move(); diff --git a/Marlin/src/module/delta.h b/Marlin/src/module/delta.h index f1e43c7e4c9d..f7067ef9c713 100644 --- a/Marlin/src/module/delta.h +++ b/Marlin/src/module/delta.h @@ -38,6 +38,10 @@ 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 @@ -45,6 +49,13 @@ extern abc_float_t delta_diagonal_rod_trim; */ void recalc_delta_settings(); +/** + * Get a safe radius for calibration + */ +#if HAS_DELTA_SENSORLESS_PROBING + static constexpr float sensorless_radius_factor = 0.7f; +#endif + /** * Delta Inverse Kinematics * @@ -82,6 +93,8 @@ void inverse_kinematics(const xyz_pos_t &raw); */ float delta_safe_distance_from_top(); +void refresh_delta_clip_start_height(); + /** * Delta Forward Kinematics * diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index 7a2cefdd4cea..0620285e61e3 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -31,6 +31,9 @@ #include "temperature.h" #include "../lcd/marlinui.h" +#define DEBUG_OUT BOTH(USE_SENSORLESS, DEBUG_LEVELING_FEATURE) +#include "../core/debug_out.h" + #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE) #include HAL_PATH(../HAL, endstop_interrupts.h) #endif @@ -78,9 +81,9 @@ Endstops::endstop_mask_t Endstops::live_state = 0; #endif #if ENABLED(Z_MULTI_ENDSTOPS) float Endstops::z2_endstop_adj; - #if NUM_Z_STEPPER_DRIVERS >= 3 + #if NUM_Z_STEPPERS >= 3 float Endstops::z3_endstop_adj; - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 float Endstops::z4_endstop_adj; #endif #endif @@ -352,7 +355,7 @@ void Endstops::init() { } // Endstops::init -// Called at ~1KHz from Temperature ISR: Poll endstop state if required +// Called at ~1kHz from Temperature ISR: Poll endstop state if required void Endstops::poll() { TERN_(PINS_DEBUGGING, run_monitor()); // Report changes in endstop status @@ -403,7 +406,7 @@ void Endstops::not_homing() { void Endstops::resync() { if (!abort_enabled()) return; // If endstops/probes are disabled the loop below can hang - // Wait for Temperature ISR to run at least once (runs at 1KHz) + // Wait for Temperature ISR to run at least once (runs at 1kHz) TERN(ENDSTOP_INTERRUPTS_FEATURE, update(), safe_delay(2)); while (TERN0(ENDSTOP_NOISE_THRESHOLD, endstop_poll_count)) safe_delay(1); } @@ -494,7 +497,7 @@ static void print_es_state(const bool is_hit, FSTR_P const flabel=nullptr) { #pragma GCC diagnostic pop -void _O2 Endstops::report_states() { +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)) @@ -558,7 +561,7 @@ void _O2 Endstops::report_states() { #if HAS_J_MAX ES_REPORT(J_MAX); #endif - #if HAS_K_MIN + #if HAS_K_MIN ES_REPORT(K_MIN); #endif #if HAS_K_MAX @@ -593,9 +596,6 @@ void _O2 Endstops::report_states() { } // Endstops::report_states -// The following routines are called from an ISR context. It could be the temperature ISR, the -// endstop ISR or the Stepper ISR. - #if HAS_DELTA_SENSORLESS_PROBING #define __ENDSTOP(AXIS, ...) AXIS ##_MAX #define _ENDSTOP_PIN(AXIS, ...) AXIS ##_MAX_PIN @@ -607,17 +607,22 @@ void _O2 Endstops::report_states() { #endif #define _ENDSTOP(AXIS, MINMAX) __ENDSTOP(AXIS, MINMAX) -// Check endstops - Could be called from Temperature ISR! +/** + * Called from interrupt context by the Endstop ISR or Stepper ISR! + * Read endstops to get their current states, register hits for all + * axes moving in the direction of their endstops, and abort moves. + */ void Endstops::update() { - #if !ENDSTOP_NOISE_THRESHOLD - if (!abort_enabled()) return; + #if !ENDSTOP_NOISE_THRESHOLD // If not debouncing... + if (!abort_enabled()) return; // ...and not enabled, exit. #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 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_XY) + #if ENABLED(G38_PROBE_TARGET) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, MARKFORGED_YX) #define HAS_G38_PROBE 1 // 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)); @@ -628,7 +633,7 @@ void Endstops::update() { #define X_MAX_TEST() TERN1(DUAL_X_CARRIAGE, TERN0(X_HOME_TO_MAX, stepper.last_moved_extruder == 0) || TERN0(X2_HOME_TO_MAX, stepper.last_moved_extruder != 0)) // Use HEAD for core axes, AXIS for others - #if ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, MARKFORGED_XY) + #if ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, MARKFORGED_YX) #define X_AXIS_HEAD X_HEAD #else #define X_AXIS_HEAD X_AXIS @@ -703,14 +708,14 @@ void Endstops::update() { #else COPY_LIVE_STATE(Z_MIN, Z2_MIN); #endif - #if NUM_Z_STEPPER_DRIVERS >= 3 + #if NUM_Z_STEPPERS >= 3 #if HAS_Z3_MIN UPDATE_ENDSTOP_BIT(Z3, MIN); #else COPY_LIVE_STATE(Z_MIN, Z3_MIN); #endif #endif - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 #if HAS_Z4_MIN UPDATE_ENDSTOP_BIT(Z4, MIN); #else @@ -735,14 +740,14 @@ void Endstops::update() { #else COPY_LIVE_STATE(Z_MAX, Z2_MAX); #endif - #if NUM_Z_STEPPER_DRIVERS >= 3 + #if NUM_Z_STEPPERS >= 3 #if HAS_Z3_MAX UPDATE_ENDSTOP_BIT(Z3, MAX); #else COPY_LIVE_STATE(Z_MAX, Z3_MAX); #endif #endif - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 #if HAS_Z4_MAX UPDATE_ENDSTOP_BIT(Z4, MAX); #else @@ -925,9 +930,9 @@ void Endstops::update() { #if DISABLED(Z_MULTI_ENDSTOPS) #define PROCESS_ENDSTOP_Z(MINMAX) PROCESS_ENDSTOP(Z, MINMAX) - #elif NUM_Z_STEPPER_DRIVERS == 4 + #elif NUM_Z_STEPPERS == 4 #define PROCESS_ENDSTOP_Z(MINMAX) PROCESS_QUAD_ENDSTOP(Z, MINMAX) - #elif NUM_Z_STEPPER_DRIVERS == 3 + #elif NUM_Z_STEPPERS == 3 #define PROCESS_ENDSTOP_Z(MINMAX) PROCESS_TRIPLE_ENDSTOP(Z, MINMAX) #else #define PROCESS_ENDSTOP_Z(MINMAX) PROCESS_DUAL_ENDSTOP(Z, MINMAX) @@ -1059,7 +1064,7 @@ void Endstops::update() { } #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS if (stepper.axis_is_moving(I_AXIS)) { if (stepper.motor_direction(I_AXIS_HEAD)) { // -direction #if HAS_I_MIN || (I_SPI_SENSORLESS && I_HOME_TO_MIN) @@ -1074,7 +1079,7 @@ void Endstops::update() { } #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS if (stepper.axis_is_moving(J_AXIS)) { if (stepper.motor_direction(J_AXIS_HEAD)) { // -direction #if HAS_J_MIN || (J_SPI_SENSORLESS && J_HOME_TO_MIN) @@ -1089,7 +1094,7 @@ void Endstops::update() { } #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS if (stepper.axis_is_moving(K_AXIS)) { if (stepper.motor_direction(K_AXIS_HEAD)) { // -direction #if HAS_K_MIN || (K_SPI_SENSORLESS && K_HOME_TO_MIN) @@ -1107,6 +1112,7 @@ void Endstops::update() { #if ENABLED(SPI_ENDSTOPS) + // Called from idle() to read Trinamic stall states bool Endstops::tmc_spi_homing_check() { bool hit = false; #if X_SPI_SENSORLESS @@ -1345,10 +1351,73 @@ void Endstops::update() { ES_REPORT_CHANGE(K_MAX); #endif SERIAL_ECHOLNPGM("\n"); - set_pwm_duty(pin_t(LED_PIN), local_LED_status); + hal.set_pwm_duty(pin_t(LED_PIN), local_LED_status); local_LED_status ^= 255; old_live_state_local = live_state_local; } } #endif // PINS_DEBUGGING + +#if USE_SENSORLESS + /** + * Change TMC driver currents to N##_CURRENT_HOME, saving the current configuration of each. + */ + void Endstops::set_homing_current(const bool onoff) { + #define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT) + #define HAS_DELTA_X_CURRENT (ENABLED(DELTA) && HAS_CURRENT_HOME(X)) + #define HAS_DELTA_Y_CURRENT (ENABLED(DELTA) && HAS_CURRENT_HOME(Y)) + #if HAS_DELTA_X_CURRENT || HAS_DELTA_Y_CURRENT || HAS_CURRENT_HOME(Z) + #if HAS_DELTA_X_CURRENT + static int16_t saved_current_x; + #endif + #if HAS_DELTA_Y_CURRENT + static int16_t saved_current_y; + #endif + #if HAS_CURRENT_HOME(Z) + static int16_t saved_current_z; + #endif + auto debug_current_on = [](PGM_P const s, const int16_t a, const int16_t b) { + if (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM_P(s); DEBUG_ECHOLNPGM(" current: ", a, " -> ", b); } + }; + if (onoff) { + #if HAS_DELTA_X_CURRENT + saved_current_x = stepperX.getMilliamps(); + stepperX.rms_current(X_CURRENT_HOME); + debug_current_on(PSTR("X"), saved_current_x, X_CURRENT_HOME); + #endif + #if HAS_DELTA_Y_CURRENT + saved_current_y = stepperY.getMilliamps(); + stepperY.rms_current(Y_CURRENT_HOME); + debug_current_on(PSTR("Y"), saved_current_y, Y_CURRENT_HOME); + #endif + #if HAS_CURRENT_HOME(Z) + saved_current_z = stepperZ.getMilliamps(); + stepperZ.rms_current(Z_CURRENT_HOME); + debug_current_on(PSTR("Z"), saved_current_z, Z_CURRENT_HOME); + #endif + } + else { + #if HAS_DELTA_X_CURRENT + stepperX.rms_current(saved_current_x); + debug_current_on(PSTR("X"), X_CURRENT_HOME, saved_current_x); + #endif + #if HAS_DELTA_Y_CURRENT + stepperY.rms_current(saved_current_y); + debug_current_on(PSTR("Y"), Y_CURRENT_HOME, saved_current_y); + #endif + #if HAS_CURRENT_HOME(Z) + stepperZ.rms_current(saved_current_z); + debug_current_on(PSTR("Z"), Z_CURRENT_HOME, saved_current_z); + #endif + } + + TERN_(IMPROVE_HOMING_RELIABILITY, planner.enable_stall_prevention(onoff)); + + #if SENSORLESS_STALLGUARD_DELAY + safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle + #endif + + #endif // XYZ + } +#endif diff --git a/Marlin/src/module/endstops.h b/Marlin/src/module/endstops.h index a35966a98c91..0282b7f263f6 100644 --- a/Marlin/src/module/endstops.h +++ b/Marlin/src/module/endstops.h @@ -47,16 +47,26 @@ enum EndstopEnum : char { _ES_ITEM(HAS_K_MAX, K_MAX) // Extra Endstops for XYZ - _ES_ITEM(HAS_X2_MIN, X2_MIN) - _ES_ITEM(HAS_X2_MAX, X2_MAX) - _ES_ITEM(HAS_Y2_MIN, Y2_MIN) - _ES_ITEM(HAS_Y2_MAX, Y2_MAX) - _ES_ITEM(HAS_Z2_MIN, Z2_MIN) - _ES_ITEM(HAS_Z2_MAX, Z2_MAX) - _ES_ITEM(HAS_Z3_MIN, Z3_MIN) - _ES_ITEM(HAS_Z3_MAX, Z3_MAX) - _ES_ITEM(HAS_Z4_MIN, Z4_MIN) - _ES_ITEM(HAS_Z4_MAX, Z4_MAX) + #if ENABLED(X_DUAL_ENDSTOPS) + _ES_ITEM(HAS_X_MIN, X2_MIN) + _ES_ITEM(HAS_X_MAX, X2_MAX) + #endif + #if ENABLED(Y_DUAL_ENDSTOPS) + _ES_ITEM(HAS_Y_MIN, Y2_MIN) + _ES_ITEM(HAS_Y_MAX, Y2_MAX) + #endif + #if ENABLED(Z_MULTI_ENDSTOPS) + _ES_ITEM(HAS_Z_MIN, Z2_MIN) + _ES_ITEM(HAS_Z_MAX, Z2_MAX) + #if NUM_Z_STEPPERS >= 3 + _ES_ITEM(HAS_Z_MIN, Z3_MIN) + _ES_ITEM(HAS_Z_MAX, Z3_MAX) + #endif + #if NUM_Z_STEPPERS >= 4 + _ES_ITEM(HAS_Z_MIN, Z4_MIN) + _ES_ITEM(HAS_Z_MAX, Z4_MAX) + #endif + #endif // Bed Probe state is distinct or shared with Z_MIN (i.e., when the probe is the only Z endstop) #if !HAS_DELTA_SENSORLESS_PROBING @@ -104,10 +114,10 @@ class Endstops { #if ENABLED(Z_MULTI_ENDSTOPS) static float z2_endstop_adj; #endif - #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 + #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPERS >= 3 static float z3_endstop_adj; #endif - #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4 + #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPERS >= 4 static float z4_endstop_adj; #endif @@ -136,7 +146,7 @@ class Endstops { return enabled || TERN0(HAS_BED_PROBE, z_probe_enabled); } - static inline bool global_enabled() { return enabled_globally; } + static bool global_enabled() { return enabled_globally; } /** * Periodic call to poll endstops if required. Called from temperature ISR @@ -168,7 +178,7 @@ class Endstops { ; } - static inline bool probe_switch_activated() { + static bool probe_switch_activated() { return (true #if ENABLED(PROBE_ACTIVATION_SWITCH) && READ(PROBE_ACTIVATION_SWITCH_PIN) == PROBE_ACTIVATION_SWITCH_STATE @@ -231,6 +241,11 @@ class Endstops { static void clear_endstop_state(); static bool tmc_spi_homing_check(); #endif + public: + // Basic functions for Sensorless Homing + #if USE_SENSORLESS + static void set_homing_current(const bool onoff); + #endif }; extern Endstops endstops; diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 2248c52d85d9..e709c6a9c9f0 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -29,9 +29,8 @@ #include "stepper.h" #include "planner.h" #include "temperature.h" - #include "../gcode/gcode.h" - +#include "../lcd/marlinui.h" #include "../inc/MarlinConfig.h" #if IS_SCARA @@ -51,10 +50,6 @@ #include "../feature/bltouch.h" #endif -#if HAS_STATUS_MESSAGE - #include "../lcd/marlinui.h" -#endif - #if HAS_FILAMENT_SENSOR #include "../feature/runout.h" #endif @@ -125,9 +120,7 @@ xyze_pos_t destination; // {0} ); // Transpose from [XYZ][HOTENDS] to [HOTENDS][XYZ] HOTEND_LOOP() LOOP_ABC(a) hotend_offset[e][a] = tmp[a][e]; - #if ENABLED(DUAL_X_CARRIAGE) - hotend_offset[1].x = _MAX(X2_HOME_POS, X2_MAX_POS); - #endif + TERN_(DUAL_X_CARRIAGE, hotend_offset[1].x = _MAX(X2_HOME_POS, X2_MAX_POS)); } #endif @@ -217,9 +210,7 @@ void report_real_position() { xyze_pos_t npos = LOGICAL_AXIS_ARRAY( planner.get_axis_position_mm(E_AXIS), cartes.x, cartes.y, cartes.z, - planner.get_axis_position_mm(I_AXIS), - planner.get_axis_position_mm(J_AXIS), - planner.get_axis_position_mm(K_AXIS) + cartes.i, cartes.j, cartes.k ); TERN_(HAS_POSITION_MODIFIERS, planner.unapply_modifiers(npos, true)); @@ -246,7 +237,6 @@ void report_current_position_projected() { } #if ENABLED(AUTO_REPORT_POSITION) - //struct PositionReport { void report() { report_current_position_projected(); } }; AutoReporter position_auto_reporter; #endif @@ -263,27 +253,25 @@ void report_current_position_projected() { * Output the current position (processed) to serial while moving */ void report_current_position_moving() { - get_cartesian_from_steppers(); const xyz_pos_t lpos = cartes.asLogical(); - SERIAL_ECHOPGM( - "X:", lpos.x - #if HAS_Y_AXIS - , " Y:", lpos.y - #endif - #if HAS_Z_AXIS - , " Z:", lpos.z - #endif + + SERIAL_ECHOPGM_P( + LIST_N(DOUBLE(LINEAR_AXES), + X_LBL, lpos.x, + SP_Y_LBL, lpos.y, + SP_Z_LBL, lpos.z, + SP_I_LBL, lpos.i, + SP_J_LBL, lpos.j, + SP_K_LBL, lpos.k + ) #if HAS_EXTRUDERS - , " E:", current_position.e + , SP_E_LBL, current_position.e #endif ); stepper.report_positions(); - #if IS_SCARA - scara_report_positions(); - #endif - + TERN_(IS_SCARA, scara_report_positions()); report_current_grblstate_moving(); } @@ -429,7 +417,7 @@ void line_to_current_position(const_feedRate_t fr_mm_s/*=feedrate_mm_s*/) { #if UBL_SEGMENTED // UBL segmented line will do Z-only moves in single segment - ubl.line_to_destination_segmented(scaled_fr_mm_s); + bedlevel.line_to_destination_segmented(scaled_fr_mm_s); #else if (current_position == destination) return; @@ -471,8 +459,8 @@ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/ } /** - * Plan a move to (X, Y, Z, [I, [J, [K]]]) and set the current_position - * Plan a move to (X, Y, Z) with separation of Z from other components. + * Plan a move to (X, Y, Z, [I, [J, [K...]]]) and set the current_position + * Plan a move to (X, Y, Z, [I, [J, [K...]]]) with separation of Z from other components. * * - If Z is moving up, the Z move is done before XY, etc. * - If Z is moving down, the Z move is done after XY, etc. @@ -488,6 +476,15 @@ void do_blocking_move_to(LINEAR_AXIS_ARGS(const float), const_feedRate_t fr_mm_s #if HAS_Z_AXIS const feedRate_t z_feedrate = fr_mm_s ?: homing_feedrate(Z_AXIS); #endif + #if HAS_I_AXIS + const feedRate_t i_feedrate = fr_mm_s ?: homing_feedrate(I_AXIS); + #endif + #if HAS_J_AXIS + const feedRate_t j_feedrate = fr_mm_s ?: homing_feedrate(J_AXIS); + #endif + #if HAS_K_AXIS + const feedRate_t k_feedrate = fr_mm_s ?: homing_feedrate(K_AXIS); + #endif #if IS_KINEMATIC if (!position_is_reachable(x, y)) return; @@ -502,8 +499,8 @@ void do_blocking_move_to(LINEAR_AXIS_ARGS(const float), const_feedRate_t fr_mm_s // when in the danger zone if (current_position.z > delta_clip_start_height) { - if (z > delta_clip_start_height) { // staying in the danger zone - destination.set(x, y, z); // move directly (uninterpolated) + if (z > delta_clip_start_height) { // staying in the danger zone + destination.set(x, y, z); // move directly (uninterpolated) prepare_internal_fast_move_to_destination(); // set current_position from destination if (DEBUGGING(LEVELING)) DEBUG_POS("danger zone move", current_position); return; @@ -513,7 +510,7 @@ void do_blocking_move_to(LINEAR_AXIS_ARGS(const float), const_feedRate_t fr_mm_s if (DEBUGGING(LEVELING)) DEBUG_POS("zone border move", current_position); } - if (z > current_position.z) { // raising? + if (z > current_position.z) { // raising? destination.z = z; prepare_internal_fast_move_to_destination(z_feedrate); // set current_position from destination if (DEBUGGING(LEVELING)) DEBUG_POS("z raise move", current_position); @@ -523,7 +520,7 @@ void do_blocking_move_to(LINEAR_AXIS_ARGS(const float), const_feedRate_t fr_mm_s prepare_internal_move_to_destination(); // set current_position from destination if (DEBUGGING(LEVELING)) DEBUG_POS("xy move", current_position); - if (z < current_position.z) { // lowering? + if (z < current_position.z) { // lowering? destination.z = z; prepare_internal_fast_move_to_destination(z_feedrate); // set current_position from destination if (DEBUGGING(LEVELING)) DEBUG_POS("z lower move", current_position); @@ -532,39 +529,32 @@ void do_blocking_move_to(LINEAR_AXIS_ARGS(const float), const_feedRate_t fr_mm_s #elif IS_SCARA // If Z needs to raise, do it before moving XY - if (destination.z < z) { - destination.z = z; - prepare_internal_fast_move_to_destination(z_feedrate); - } + if (destination.z < z) { destination.z = z; prepare_internal_fast_move_to_destination(z_feedrate); } - destination.set(x, y); - prepare_internal_fast_move_to_destination(xy_feedrate); + destination.set(x, y); prepare_internal_fast_move_to_destination(xy_feedrate); // If Z needs to lower, do it after moving XY - if (destination.z > z) { - destination.z = z; - prepare_internal_fast_move_to_destination(z_feedrate); - } + if (destination.z > z) { destination.z = z; prepare_internal_fast_move_to_destination(z_feedrate); } #else - #if HAS_Z_AXIS - // If Z needs to raise, do it before moving XY - if (current_position.z < z) { - current_position.z = z; - line_to_current_position(z_feedrate); - } + #if HAS_Z_AXIS // If Z needs to raise, do it before moving XY + 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, y); line_to_current_position(xy_feedrate); - #if HAS_Z_AXIS - // If Z needs to lower, do it after moving XY - if (current_position.z > z) { - current_position.z = z; - line_to_current_position(z_feedrate); - } + #if HAS_I_AXIS + current_position.i = i; line_to_current_position(i_feedrate); + #endif + #if HAS_J_AXIS + current_position.j = j; line_to_current_position(j_feedrate); + #endif + #if HAS_K_AXIS + current_position.k = k; line_to_current_position(k_feedrate); + #endif + #if HAS_Z_AXIS // If Z needs to lower, do it after moving XY... + if (current_position.z > z) { current_position.z = z; line_to_current_position(z_feedrate); } #endif #endif @@ -603,7 +593,7 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { } #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS void do_blocking_move_to_i(const_float_t ri, const_feedRate_t fr_mm_s/*=0.0*/) { do_blocking_move_to_xyz_i(current_position, ri, fr_mm_s); } @@ -615,7 +605,7 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { } #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS void do_blocking_move_to_j(const_float_t rj, const_feedRate_t fr_mm_s/*=0.0*/) { do_blocking_move_to_xyzi_j(current_position, rj, fr_mm_s); } @@ -627,7 +617,7 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) { } #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS void do_blocking_move_to_k(const_float_t rk, const_feedRate_t fr_mm_s/*=0.0*/) { do_blocking_move_to_xyzij_k(current_position, rk, fr_mm_s); } @@ -745,7 +735,7 @@ void restore_feedrate_and_scaling() { delta_max_radius_2 = sq(delta_max_radius); break; case Z_AXIS: - delta_clip_start_height = soft_endstop.max[axis] - delta_safe_distance_from_top(); + refresh_delta_clip_start_height(); default: break; } @@ -839,7 +829,7 @@ void restore_feedrate_and_scaling() { #endif } #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS if (axis_was_homed(I_AXIS)) { #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_I) NOLESS(target.i, soft_endstop.min.i); @@ -849,7 +839,7 @@ void restore_feedrate_and_scaling() { #endif } #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS if (axis_was_homed(J_AXIS)) { #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_J) NOLESS(target.j, soft_endstop.min.j); @@ -859,7 +849,7 @@ void restore_feedrate_and_scaling() { #endif } #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS if (axis_was_homed(K_AXIS)) { #if !HAS_SOFTWARE_ENDSTOPS || ENABLED(MIN_SOFTWARE_ENDSTOP_K) NOLESS(target.k, soft_endstop.min.k); @@ -877,8 +867,6 @@ void restore_feedrate_and_scaling() { #endif // !HAS_SOFTWARE_ENDSTOPS -#if !UBL_SEGMENTED - FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { const millis_t ms = millis(); if (ELAPSED(ms, next_idle_ms)) { @@ -914,7 +902,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { * small incremental moves for DELTA or SCARA. * * For Unified Bed Leveling (Delta or Segmented Cartesian) - * the ubl.line_to_destination_segmented method replaces this. + * the bedlevel.line_to_destination_segmented method replaces this. * * For Auto Bed Leveling (Bilinear) with SEGMENT_LEVELED_MOVES * this is replaced by segmented_line_to_destination below. @@ -995,7 +983,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { #else // !IS_KINEMATIC - #if ENABLED(SEGMENT_LEVELED_MOVES) + #if ENABLED(SEGMENT_LEVELED_MOVES) && DISABLED(AUTO_BED_LEVELING_UBL) /** * Prepare a segmented move on a CARTESIAN setup. @@ -1055,7 +1043,7 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { planner.buffer_line(destination, fr_mm_s, active_extruder, cartesian_segment_mm OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)); } - #endif // SEGMENT_LEVELED_MOVES + #endif // SEGMENT_LEVELED_MOVES && !AUTO_BED_LEVELING_UBL /** * Prepare a linear move in a Cartesian setup. @@ -1070,8 +1058,12 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { #if HAS_MESH if (planner.leveling_active && planner.leveling_active_at_z(destination.z)) { #if ENABLED(AUTO_BED_LEVELING_UBL) - ubl.line_to_destination_cartesian(scaled_fr_mm_s, active_extruder); // UBL's motion routine needs to know about - return true; // all moves, including Z-only moves. + #if UBL_SEGMENTED + return bedlevel.line_to_destination_segmented(scaled_fr_mm_s); + #else + bedlevel.line_to_destination_cartesian(scaled_fr_mm_s, active_extruder); // UBL's motion routine needs to know about + return true; // all moves, including Z-only moves. + #endif #elif ENABLED(SEGMENT_LEVELED_MOVES) segmented_line_to_destination(scaled_fr_mm_s); return false; // caller will update current_position @@ -1082,9 +1074,9 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { */ if (xy_pos_t(current_position) != xy_pos_t(destination)) { #if ENABLED(MESH_BED_LEVELING) - mbl.line_to_destination(scaled_fr_mm_s); + bedlevel.line_to_destination(scaled_fr_mm_s); #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) - bilinear_line_to_destination(scaled_fr_mm_s); + bedlevel.line_to_destination(scaled_fr_mm_s); #endif return true; } @@ -1097,7 +1089,6 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { } #endif // !IS_KINEMATIC -#endif // !UBL_SEGMENTED #if HAS_DUPLICATION_MODE bool extruder_duplication_enabled; @@ -1118,16 +1109,15 @@ FORCE_INLINE void segment_idle(millis_t &next_idle_ms) { bool idex_mirrored_mode = false; // Used in mode 3 float x_home_pos(const uint8_t extruder) { - if (extruder == 0) - return X_HOME_POS; - else - /** - * In dual carriage mode the extruder offset provides an override of the - * second X-carriage position when homed - otherwise X2_HOME_POS is used. - * This allows soft recalibration of the second extruder home position - * without firmware reflash (through the M218 command). - */ - return hotend_offset[1].x > 0 ? hotend_offset[1].x : X2_HOME_POS; + if (extruder == 0) return X_HOME_POS; + + /** + * In dual carriage mode the extruder offset provides an override of the + * second X-carriage position when homed - otherwise X2_HOME_POS is used. + * This allows soft recalibration of the second extruder home position + * (with M218 T1 Xn) without firmware reflash. + */ + return hotend_offset[1].x > 0 ? hotend_offset[1].x : X2_HOME_POS; } void idex_set_mirrored_mode(const bool mirr) { @@ -1283,7 +1273,7 @@ void prepare_line_to_destination() { if ( #if UBL_SEGMENTED #if IS_KINEMATIC // UBL using Kinematic / Cartesian cases as a workaround for now. - ubl.line_to_destination_segmented(MMS_SCALED(feedrate_mm_s)) + bedlevel.line_to_destination_segmented(MMS_SCALED(feedrate_mm_s)) #else line_to_destination_cartesian() #endif @@ -1323,14 +1313,14 @@ void prepare_line_to_destination() { TEST(axis_bits, X_AXIS) ? "X" : "", TEST(axis_bits, Y_AXIS) ? "Y" : "", TEST(axis_bits, Z_AXIS) ? "Z" : "", - TEST(axis_bits, I_AXIS) ? AXIS4_STR : "", - TEST(axis_bits, J_AXIS) ? AXIS5_STR : "", - TEST(axis_bits, K_AXIS) ? AXIS6_STR : "" + TEST(axis_bits, I_AXIS) ? STR_I : "", + TEST(axis_bits, J_AXIS) ? STR_J : "", + TEST(axis_bits, K_AXIS) ? STR_K : "" ) ); SERIAL_ECHO_START(); SERIAL_ECHOLN(msg); - TERN_(HAS_STATUS_MESSAGE, ui.set_status(msg)); + ui.set_status(msg); return true; } return false; @@ -1364,9 +1354,7 @@ void prepare_line_to_destination() { #if X_SENSORLESS case X_AXIS: stealth_states.x = tmc_enable_stallguard(stepperX); - #if AXIS_HAS_STALLGUARD(X2) - stealth_states.x2 = tmc_enable_stallguard(stepperX2); - #endif + TERN_(X2_SENSORLESS, stealth_states.x2 = tmc_enable_stallguard(stepperX2)); #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && Y_SENSORLESS stealth_states.y = tmc_enable_stallguard(stepperY); #elif CORE_IS_XZ && Z_SENSORLESS @@ -1377,9 +1365,7 @@ void prepare_line_to_destination() { #if Y_SENSORLESS case Y_AXIS: stealth_states.y = tmc_enable_stallguard(stepperY); - #if AXIS_HAS_STALLGUARD(Y2) - stealth_states.y2 = tmc_enable_stallguard(stepperY2); - #endif + TERN_(Y2_SENSORLESS, stealth_states.y2 = tmc_enable_stallguard(stepperY2)); #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && X_SENSORLESS stealth_states.x = tmc_enable_stallguard(stepperX); #elif CORE_IS_YZ && Z_SENSORLESS @@ -1390,15 +1376,9 @@ void prepare_line_to_destination() { #if Z_SENSORLESS case Z_AXIS: stealth_states.z = tmc_enable_stallguard(stepperZ); - #if AXIS_HAS_STALLGUARD(Z2) - stealth_states.z2 = tmc_enable_stallguard(stepperZ2); - #endif - #if AXIS_HAS_STALLGUARD(Z3) - stealth_states.z3 = tmc_enable_stallguard(stepperZ3); - #endif - #if AXIS_HAS_STALLGUARD(Z4) - stealth_states.z4 = tmc_enable_stallguard(stepperZ4); - #endif + TERN_(Z2_SENSORLESS, stealth_states.z2 = tmc_enable_stallguard(stepperZ2)); + TERN_(Z3_SENSORLESS, stealth_states.z3 = tmc_enable_stallguard(stepperZ3)); + TERN_(Z4_SENSORLESS, stealth_states.z4 = tmc_enable_stallguard(stepperZ4)); #if CORE_IS_XZ && X_SENSORLESS stealth_states.x = tmc_enable_stallguard(stepperX); #elif CORE_IS_YZ && Y_SENSORLESS @@ -1406,6 +1386,15 @@ void prepare_line_to_destination() { #endif break; #endif + #if I_SENSORLESS + case I_AXIS: stealth_states.i = tmc_enable_stallguard(stepperI); break; + #endif + #if J_SENSORLESS + case J_AXIS: stealth_states.j = tmc_enable_stallguard(stepperJ); break; + #endif + #if K_SENSORLESS + case K_AXIS: stealth_states.k = tmc_enable_stallguard(stepperK); break; + #endif } #if ENABLED(SPI_ENDSTOPS) @@ -1417,13 +1406,13 @@ void prepare_line_to_destination() { #if HAS_Z_AXIS case Z_AXIS: if (ENABLED(Z_SPI_SENSORLESS)) endstops.tmc_spi_homing.z = true; break; #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS case I_AXIS: if (ENABLED(I_SPI_SENSORLESS)) endstops.tmc_spi_homing.i = true; break; #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS case J_AXIS: if (ENABLED(J_SPI_SENSORLESS)) endstops.tmc_spi_homing.j = true; break; #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS case K_AXIS: if (ENABLED(K_SPI_SENSORLESS)) endstops.tmc_spi_homing.k = true; break; #endif default: break; @@ -1441,9 +1430,7 @@ void prepare_line_to_destination() { #if X_SENSORLESS case X_AXIS: tmc_disable_stallguard(stepperX, enable_stealth.x); - #if AXIS_HAS_STALLGUARD(X2) - tmc_disable_stallguard(stepperX2, enable_stealth.x2); - #endif + TERN_(X2_SENSORLESS, tmc_disable_stallguard(stepperX2, enable_stealth.x2)); #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && Y_SENSORLESS tmc_disable_stallguard(stepperY, enable_stealth.y); #elif CORE_IS_XZ && Z_SENSORLESS @@ -1454,9 +1441,7 @@ void prepare_line_to_destination() { #if Y_SENSORLESS case Y_AXIS: tmc_disable_stallguard(stepperY, enable_stealth.y); - #if AXIS_HAS_STALLGUARD(Y2) - tmc_disable_stallguard(stepperY2, enable_stealth.y2); - #endif + TERN_(Y2_SENSORLESS, tmc_disable_stallguard(stepperY2, enable_stealth.y2)); #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && X_SENSORLESS tmc_disable_stallguard(stepperX, enable_stealth.x); #elif CORE_IS_YZ && Z_SENSORLESS @@ -1467,15 +1452,9 @@ void prepare_line_to_destination() { #if Z_SENSORLESS case Z_AXIS: tmc_disable_stallguard(stepperZ, enable_stealth.z); - #if AXIS_HAS_STALLGUARD(Z2) - tmc_disable_stallguard(stepperZ2, enable_stealth.z2); - #endif - #if AXIS_HAS_STALLGUARD(Z3) - tmc_disable_stallguard(stepperZ3, enable_stealth.z3); - #endif - #if AXIS_HAS_STALLGUARD(Z4) - tmc_disable_stallguard(stepperZ4, enable_stealth.z4); - #endif + TERN_(Z2_SENSORLESS, tmc_disable_stallguard(stepperZ2, enable_stealth.z2)); + TERN_(Z3_SENSORLESS, tmc_disable_stallguard(stepperZ3, enable_stealth.z3)); + TERN_(Z4_SENSORLESS, tmc_disable_stallguard(stepperZ4, enable_stealth.z4)); #if CORE_IS_XZ && X_SENSORLESS tmc_disable_stallguard(stepperX, enable_stealth.x); #elif CORE_IS_YZ && Y_SENSORLESS @@ -1483,6 +1462,15 @@ void prepare_line_to_destination() { #endif break; #endif + #if I_SENSORLESS + case I_AXIS: tmc_disable_stallguard(stepperI, enable_stealth.i); break; + #endif + #if J_SENSORLESS + case J_AXIS: tmc_disable_stallguard(stepperJ, enable_stealth.j); break; + #endif + #if K_SENSORLESS + case K_AXIS: tmc_disable_stallguard(stepperK, enable_stealth.k); break; + #endif } #if ENABLED(SPI_ENDSTOPS) @@ -1494,13 +1482,13 @@ void prepare_line_to_destination() { #if HAS_Z_AXIS case Z_AXIS: if (ENABLED(Z_SPI_SENSORLESS)) endstops.tmc_spi_homing.z = false; break; #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS case I_AXIS: if (ENABLED(I_SPI_SENSORLESS)) endstops.tmc_spi_homing.i = false; break; #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS case J_AXIS: if (ENABLED(J_SPI_SENSORLESS)) endstops.tmc_spi_homing.j = false; break; #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS case K_AXIS: if (ENABLED(K_SPI_SENSORLESS)) endstops.tmc_spi_homing.k = false; break; #endif default: break; @@ -1553,7 +1541,12 @@ void prepare_line_to_destination() { } // Disable stealthChop if used. Enable diag1 pin on driver. - TERN_(SENSORLESS_HOMING, stealth_states = start_sensorless_homing_per_axis(axis)); + #if ENABLED(SENSORLESS_HOMING) + stealth_states = start_sensorless_homing_per_axis(axis); + #if SENSORLESS_STALLGUARD_DELAY + safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle + #endif + #endif } #if EITHER(MORGAN_SCARA, MP_SCARA) @@ -1589,7 +1582,12 @@ void prepare_line_to_destination() { endstops.validate_homing_move(); // Re-enable stealthChop if used. Disable diag1 pin on driver. - TERN_(SENSORLESS_HOMING, end_sensorless_homing_per_axis(axis, stealth_states)); + #if ENABLED(SENSORLESS_HOMING) + end_sensorless_homing_per_axis(axis, stealth_states); + #if SENSORLESS_STALLGUARD_DELAY + safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle + #endif + #endif } } @@ -1636,7 +1634,7 @@ void prepare_line_to_destination() { phasePerUStep = PHASE_PER_MICROSTEP(X); phaseCurrent = stepperX.get_microstep_counter(); effectorBackoutDir = -X_HOME_DIR; - stepperBackoutDir = INVERT_X_DIR ? effectorBackoutDir : -effectorBackoutDir; + stepperBackoutDir = IF_DISABLED(INVERT_X_DIR, -)effectorBackoutDir; break; #endif #ifdef Y_MICROSTEPS @@ -1644,7 +1642,7 @@ void prepare_line_to_destination() { phasePerUStep = PHASE_PER_MICROSTEP(Y); phaseCurrent = stepperY.get_microstep_counter(); effectorBackoutDir = -Y_HOME_DIR; - stepperBackoutDir = INVERT_Y_DIR ? effectorBackoutDir : -effectorBackoutDir; + stepperBackoutDir = IF_DISABLED(INVERT_Y_DIR, -)effectorBackoutDir; break; #endif #ifdef Z_MICROSTEPS @@ -1652,7 +1650,7 @@ void prepare_line_to_destination() { phasePerUStep = PHASE_PER_MICROSTEP(Z); phaseCurrent = stepperZ.get_microstep_counter(); effectorBackoutDir = -Z_HOME_DIR; - stepperBackoutDir = INVERT_Z_DIR ? effectorBackoutDir : -effectorBackoutDir; + stepperBackoutDir = IF_DISABLED(INVERT_Z_DIR, -)effectorBackoutDir; break; #endif #ifdef I_MICROSTEPS @@ -1660,7 +1658,7 @@ void prepare_line_to_destination() { phasePerUStep = PHASE_PER_MICROSTEP(I); phaseCurrent = stepperI.get_microstep_counter(); effectorBackoutDir = -I_HOME_DIR; - stepperBackoutDir = INVERT_I_DIR ? effectorBackoutDir : -effectorBackoutDir; + stepperBackoutDir = IF_DISABLED(INVERT_I_DIR, -)effectorBackoutDir; break; #endif #ifdef J_MICROSTEPS @@ -1668,7 +1666,7 @@ void prepare_line_to_destination() { phasePerUStep = PHASE_PER_MICROSTEP(J); phaseCurrent = stepperJ.get_microstep_counter(); effectorBackoutDir = -J_HOME_DIR; - stepperBackoutDir = INVERT_J_DIR ? effectorBackoutDir : -effectorBackoutDir; + stepperBackoutDir = IF_DISABLED(INVERT_J_DIR, -)effectorBackoutDir; break; #endif #ifdef K_MICROSTEPS @@ -1676,7 +1674,7 @@ void prepare_line_to_destination() { phasePerUStep = PHASE_PER_MICROSTEP(K); phaseCurrent = stepperK.get_microstep_counter(); effectorBackoutDir = -K_HOME_DIR; - stepperBackoutDir = INVERT_K_DIR ? effectorBackoutDir : -effectorBackoutDir; + stepperBackoutDir = IF_DISABLED(INVERT_K_DIR, -)effectorBackoutDir; break; #endif default: return; @@ -1819,15 +1817,19 @@ void prepare_line_to_destination() { switch (axis) { default: case X_AXIS: es = X_ENDSTOP; break; - case Y_AXIS: es = Y_ENDSTOP; break; - case Z_AXIS: es = Z_ENDSTOP; break; - #if LINEAR_AXES >= 4 + #if HAS_Y_AXIS + case Y_AXIS: es = Y_ENDSTOP; break; + #endif + #if HAS_Z_AXIS + case Z_AXIS: es = Z_ENDSTOP; break; + #endif + #if HAS_I_AXIS case I_AXIS: es = I_ENDSTOP; break; #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS case J_AXIS: es = J_ENDSTOP; break; #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS case K_AXIS: es = K_ENDSTOP; break; #endif } @@ -1880,7 +1882,7 @@ void prepare_line_to_destination() { #if ENABLED(Z_MULTI_ENDSTOPS) if (axis == Z_AXIS) { - #if NUM_Z_STEPPER_DRIVERS == 2 + #if NUM_Z_STEPPERS == 2 const float adj = ABS(endstops.z2_endstop_adj); if (adj) { @@ -1898,13 +1900,13 @@ void prepare_line_to_destination() { adjustFunc_t lock[] = { stepper.set_z1_lock, stepper.set_z2_lock, stepper.set_z3_lock - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 , stepper.set_z4_lock #endif }; float adj[] = { 0, endstops.z2_endstop_adj, endstops.z3_endstop_adj - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 , endstops.z4_endstop_adj #endif }; @@ -1923,7 +1925,7 @@ void prepare_line_to_destination() { lock[1] = lock[2], adj[1] = adj[2]; lock[2] = tempLock, adj[2] = tempAdj; } - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 if (adj[3] < adj[2]) { tempLock = lock[2], tempAdj = adj[2]; lock[2] = lock[3], adj[2] = adj[3]; @@ -1948,14 +1950,14 @@ void prepare_line_to_destination() { // lock the second stepper for the final correction (*lock[1])(true); do_homing_move(axis, adj[2] - adj[1]); - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 // lock the third stepper for the final correction (*lock[2])(true); do_homing_move(axis, adj[3] - adj[2]); #endif } else { - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 (*lock[3])(true); do_homing_move(axis, adj[2] - adj[3]); #endif @@ -1968,7 +1970,7 @@ void prepare_line_to_destination() { stepper.set_z1_lock(false); stepper.set_z2_lock(false); stepper.set_z3_lock(false); - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 stepper.set_z4_lock(false); #endif diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 50df5675e6c8..1dd6d8c4ede2 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -180,19 +180,19 @@ inline float home_bump_mm(const AxisEnum axis) { TERN_(MAX_SOFTWARE_ENDSTOP_Z, amax = max.z); break; #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS case I_AXIS: TERN_(MIN_SOFTWARE_ENDSTOP_I, amin = min.i); TERN_(MIN_SOFTWARE_ENDSTOP_I, amax = max.i); break; #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS case J_AXIS: TERN_(MIN_SOFTWARE_ENDSTOP_J, amin = min.j); TERN_(MIN_SOFTWARE_ENDSTOP_J, amax = max.j); break; #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS case K_AXIS: TERN_(MIN_SOFTWARE_ENDSTOP_K, amin = min.k); TERN_(MIN_SOFTWARE_ENDSTOP_K, amax = max.k); @@ -265,9 +265,11 @@ void report_current_position_projected(); void report_current_position_moving(); #if ENABLED(FULL_REPORT_TO_HOST_FEATURE) - inline void set_and_report_grblstate(const M_StateEnum state) { - M_State_grbl = state; - report_current_grblstate_moving(); + inline void set_and_report_grblstate(const M_StateEnum state, const bool force=true) { + if (force || M_State_grbl != state) { + M_State_grbl = state; + report_current_grblstate_moving(); + } } #endif @@ -333,15 +335,15 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s=0.0f); #if HAS_Z_AXIS void do_blocking_move_to_z(const_float_t rz, const_feedRate_t fr_mm_s=0.0f); #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS void do_blocking_move_to_i(const_float_t ri, const_feedRate_t fr_mm_s=0.0f); void do_blocking_move_to_xyz_i(const xyze_pos_t &raw, const_float_t i, const_feedRate_t fr_mm_s=0.0f); #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS void do_blocking_move_to_j(const_float_t rj, const_feedRate_t fr_mm_s=0.0f); void do_blocking_move_to_xyzi_j(const xyze_pos_t &raw, const_float_t j, const_feedRate_t fr_mm_s=0.0f); #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS void do_blocking_move_to_k(const_float_t rk, const_feedRate_t fr_mm_s=0.0f); void do_blocking_move_to_xyzij_k(const xyze_pos_t &raw, const_float_t k, const_feedRate_t fr_mm_s=0.0f); #endif @@ -402,7 +404,7 @@ void set_axis_is_at_home(const AxisEnum axis); constexpr linear_axis_bits_t axis_homed = linear_bits, axis_trusted = linear_bits; // Zero-endstop machines are always homed and trusted inline void homeaxis(const AxisEnum axis) {} inline void set_axis_never_homed(const AxisEnum) {} - inline linear_axis_bits_t axes_should_home(linear_axis_bits_t=linear_bits) { return false; } + inline linear_axis_bits_t axes_should_home(linear_axis_bits_t=linear_bits) { return 0; } inline bool homing_needed_error(linear_axis_bits_t=linear_bits) { return false; } inline void set_axis_unhomed(const AxisEnum axis) {} inline void set_axis_untrusted(const AxisEnum axis) {} @@ -476,15 +478,15 @@ void home_if_needed(const bool keeplev=false); #define LOGICAL_Z_POSITION(POS) NATIVE_TO_LOGICAL(POS, Z_AXIS) #define RAW_Z_POSITION(POS) LOGICAL_TO_NATIVE(POS, Z_AXIS) #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #define LOGICAL_I_POSITION(POS) NATIVE_TO_LOGICAL(POS, I_AXIS) #define RAW_I_POSITION(POS) LOGICAL_TO_NATIVE(POS, I_AXIS) #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #define LOGICAL_J_POSITION(POS) NATIVE_TO_LOGICAL(POS, J_AXIS) #define RAW_J_POSITION(POS) LOGICAL_TO_NATIVE(POS, J_AXIS) #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #define LOGICAL_K_POSITION(POS) NATIVE_TO_LOGICAL(POS, K_AXIS) #define RAW_K_POSITION(POS) LOGICAL_TO_NATIVE(POS, K_AXIS) #endif diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 45ccdd1702ef..17eab914de6f 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -703,7 +703,7 @@ void Planner::init() { // All other 32-bit MPUs can easily do inverse using hardware division, // so we don't need to reduce precision or to use assembly language at all. // This routine, for all other archs, returns 0x100000000 / d ~= 0xFFFFFFFF / d - static FORCE_INLINE uint32_t get_period_inverse(const uint32_t d) { + FORCE_INLINE static uint32_t get_period_inverse(const uint32_t d) { return d ? 0xFFFFFFFF / d : 0xFFFFFFFF; } #endif @@ -1244,10 +1244,6 @@ void Planner::recalculate() { recalculate_trapezoids(); } -#if HAS_FAN && DISABLED(LASER_SYNCHRONOUS_M106_M107) - #define HAS_TAIL_FAN_SPEED 1 -#endif - /** * Apply fan speeds */ @@ -1264,7 +1260,7 @@ void Planner::recalculate() { #if ENABLED(FAN_SOFT_PWM) #define _FAN_SET(F) thermalManager.soft_pwm_amount_fan[F] = CALC_FAN_SPEED(F); #else - #define _FAN_SET(F) 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(F)); #endif #define FAN_SET(F) do{ kickstart_fan(fan_speed, ms, F); _FAN_SET(F); }while(0) @@ -1308,8 +1304,9 @@ void Planner::check_axes_activity() { xyze_bool_t axis_active = { false }; #endif - #if HAS_TAIL_FAN_SPEED - static uint8_t tail_fan_speed[FAN_COUNT] = ARRAY_N_1(FAN_COUNT, 255); + #if HAS_FAN && DISABLED(LASER_SYNCHRONOUS_M106_M107) + #define HAS_TAIL_FAN_SPEED 1 + static uint8_t tail_fan_speed[FAN_COUNT] = ARRAY_N_1(FAN_COUNT, 13); bool fans_need_update = false; #endif @@ -1345,15 +1342,15 @@ void Planner::check_axes_activity() { #if ANY(DISABLE_X, DISABLE_Y, DISABLE_Z, DISABLE_I, DISABLE_J, DISABLE_K, DISABLE_E) for (uint8_t b = block_buffer_tail; b != block_buffer_head; b = next_block_index(b)) { - block_t *block = &block_buffer[b]; + block_t * const bnext = &block_buffer[b]; LOGICAL_AXIS_CODE( - if (TERN0(DISABLE_E, block->steps.e)) axis_active.e = true, - if (TERN0(DISABLE_X, block->steps.x)) axis_active.x = true, - if (TERN0(DISABLE_Y, block->steps.y)) axis_active.y = true, - if (TERN0(DISABLE_Z, block->steps.z)) axis_active.z = true, - if (TERN0(DISABLE_I, block->steps.i)) axis_active.i = true, - if (TERN0(DISABLE_J, block->steps.j)) axis_active.j = true, - if (TERN0(DISABLE_K, block->steps.k)) axis_active.k = true + if (TERN0(DISABLE_E, bnext->steps.e)) axis_active.e = true, + if (TERN0(DISABLE_X, bnext->steps.x)) axis_active.x = true, + if (TERN0(DISABLE_Y, bnext->steps.y)) axis_active.y = true, + if (TERN0(DISABLE_Z, bnext->steps.z)) axis_active.z = true, + if (TERN0(DISABLE_I, bnext->steps.i)) axis_active.i = true, + if (TERN0(DISABLE_J, bnext->steps.j)) axis_active.j = true, + if (TERN0(DISABLE_K, bnext->steps.k)) axis_active.k = true ); } #endif @@ -1400,8 +1397,8 @@ void Planner::check_axes_activity() { TERN_(AUTOTEMP, autotemp_task()); #if ENABLED(BARICUDA) - TERN_(HAS_HEATER_1, set_pwm_duty(pin_t(HEATER_1_PIN), tail_valve_pressure)); - TERN_(HAS_HEATER_2, set_pwm_duty(pin_t(HEATER_2_PIN), tail_e_to_p_pressure)); + TERN_(HAS_HEATER_1, hal.set_pwm_duty(pin_t(HEATER_1_PIN), tail_valve_pressure)); + TERN_(HAS_HEATER_2, hal.set_pwm_duty(pin_t(HEATER_2_PIN), tail_e_to_p_pressure)); #endif } @@ -1448,14 +1445,14 @@ void Planner::check_axes_activity() { * currently in the planner. */ void Planner::autotemp_task() { - static float oldt = 0; + static float oldt = 0.0f; if (!autotemp_enabled) return; if (thermalManager.degTargetHotend(active_extruder) < autotemp_min - 2) return; // Below the min? - float high = 0.0; + float high = 0.0f; for (uint8_t b = block_buffer_tail; b != block_buffer_head; b = next_block_index(b)) { - block_t *block = &block_buffer[b]; + const block_t * const block = &block_buffer[b]; if (LINEAR_AXIS_GANG(block->steps.x, || block->steps.y, || block->steps.z, || block->steps.i, || block->steps.j, || block->steps.k)) { const float se = (float)block->steps.e / block->step_event_count * SQRT(block->nominal_speed_sqr); // mm/sec; NOLESS(high, se); @@ -1508,7 +1505,7 @@ void Planner::check_axes_activity() { volumetric_extruder_feedrate_limit[e] = (lim && siz) ? lim / CIRCLE_AREA(siz * 0.5f) : 0; } void Planner::calculate_volumetric_extruder_limits() { - LOOP_L_N(e, EXTRUDERS) calculate_volumetric_extruder_limit(e); + EXTRUDER_LOOP() calculate_volumetric_extruder_limit(e); } #endif @@ -1584,55 +1581,45 @@ void Planner::check_axes_activity() { #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) const float fade_scaling_factor = fade_scaling_factor_for_z(raw.z); - #elif DISABLED(MESH_BED_LEVELING) - constexpr float fade_scaling_factor = 1.0; + if (fade_scaling_factor) raw.z += fade_scaling_factor * bedlevel.get_z_correction(raw); + #else + raw.z += bedlevel.get_z_correction(raw); #endif - raw.z += ( - #if ENABLED(MESH_BED_LEVELING) - mbl.get_z(raw OPTARG(ENABLE_LEVELING_FADE_HEIGHT, fade_scaling_factor)) - #elif ENABLED(AUTO_BED_LEVELING_UBL) - fade_scaling_factor ? fade_scaling_factor * ubl.get_z_correction(raw) : 0.0 - #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) - fade_scaling_factor ? fade_scaling_factor * bilinear_z_offset(raw) : 0.0 - #endif - ); + TERN_(MESH_BED_LEVELING, raw.z += bedlevel.get_z_offset()); #endif } void Planner::unapply_leveling(xyz_pos_t &raw) { + if (!leveling_active) return; - if (leveling_active) { - - #if ABL_PLANAR - - matrix_3x3 inverse = matrix_3x3::transpose(bed_level_matrix); + #if ABL_PLANAR - xy_pos_t d = raw - level_fulcrum; - inverse.apply_rotation_xyz(d.x, d.y, raw.z); - raw = d + level_fulcrum; + matrix_3x3 inverse = matrix_3x3::transpose(bed_level_matrix); - #elif HAS_MESH + xy_pos_t d = raw - level_fulcrum; + inverse.apply_rotation_xyz(d.x, d.y, raw.z); + raw = d + level_fulcrum; - #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - const float fade_scaling_factor = fade_scaling_factor_for_z(raw.z); - #elif DISABLED(MESH_BED_LEVELING) - constexpr float fade_scaling_factor = 1.0; - #endif + #elif HAS_MESH - raw.z -= ( - #if ENABLED(MESH_BED_LEVELING) - mbl.get_z(raw OPTARG(ENABLE_LEVELING_FADE_HEIGHT, fade_scaling_factor)) - #elif ENABLED(AUTO_BED_LEVELING_UBL) - fade_scaling_factor ? fade_scaling_factor * ubl.get_z_correction(raw) : 0.0 - #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) - fade_scaling_factor ? fade_scaling_factor * bilinear_z_offset(raw) : 0.0 - #endif - ); + const float z_correction = bedlevel.get_z_correction(raw), + z_full_fade = DIFF_TERN(MESH_BED_LEVELING, raw.z, bedlevel.get_z_offset()), + z_no_fade = z_full_fade - z_correction; + #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + if (!z_fade_height || z_no_fade <= 0.0f) // Not fading or at bed level? + raw.z = z_no_fade; // Unapply full mesh Z. + else if (z_full_fade >= z_fade_height) // Above the fade height? + raw.z = z_full_fade; // Nothing more to unapply. + else // Within the fade zone? + raw.z = z_no_fade / (1.0f - z_correction * inverse_z_fade_height); // Unapply the faded Z offset + #else + raw.z = z_no_fade; #endif - } + + #endif } #endif // HAS_LEVELING @@ -1670,10 +1657,7 @@ void Planner::quick_stop() { // forced to empty, there's no risk the ISR will touch this. delay_before_delivering = BLOCK_DELAY_FOR_1ST_MOVE; - #if HAS_WIRED_LCD - // Clear the accumulated runtime - clear_block_buffer_runtime(); - #endif + TERN_(HAS_WIRED_LCD, clear_block_buffer_runtime()); // Clear the accumulated runtime // Make sure to drop any attempt of queuing moves for 1 second cleaning_buffer_counter = TEMP_TIMER_FREQUENCY; @@ -1709,7 +1693,8 @@ void Planner::endstop_triggered(const AxisEnum axis) { } float Planner::triggered_position_mm(const AxisEnum axis) { - return stepper.triggered_position(axis) * mm_per_step[axis]; + const float result = DIFF_TERN(BACKLASH_COMPENSATION, stepper.triggered_position(axis), backlash.get_applied_steps(axis)); + return result * mm_per_step[axis]; } void Planner::finish_and_disable() { @@ -1731,8 +1716,8 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { // Protect the access to the position. const bool was_enabled = stepper.suspend(); - const int32_t p1 = stepper.position(CORE_AXIS_1), - p2 = stepper.position(CORE_AXIS_2); + const int32_t p1 = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(CORE_AXIS_1), backlash.get_applied_steps(CORE_AXIS_1)), + p2 = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(CORE_AXIS_2), backlash.get_applied_steps(CORE_AXIS_2)); if (was_enabled) stepper.wake_up(); @@ -1741,7 +1726,7 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { axis_steps = (axis == CORE_AXIS_2 ? CORESIGN(p1 - p2) : p1 + p2) * 0.5f; } else - axis_steps = stepper.position(axis); + axis_steps = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(axis), backlash.get_applied_steps(axis)); #elif EITHER(MARKFORGED_XY, MARKFORGED_YX) @@ -1758,11 +1743,12 @@ float Planner::get_axis_position_mm(const AxisEnum axis) { axis_steps = ((axis == CORE_AXIS_1) ? p1 - p2 : p2); } else - axis_steps = stepper.position(axis); + axis_steps = DIFF_TERN(BACKLASH_COMPENSATION, stepper.position(axis), backlash.get_applied_steps(axis)); #else axis_steps = stepper.position(axis); + TERN_(BACKLASH_COMPENSATION, axis_steps -= backlash.get_applied_steps(axis)); #endif @@ -1866,14 +1852,14 @@ bool Planner::_populate_block(block_t * const block, bool split_move, " A:", target.a, " (", da, " steps)" " B:", target.b, " (", db, " steps)" " C:", target.c, " (", dc, " steps)" - #if LINEAR_AXES >= 4 - " " AXIS4_STR ":", target.i, " (", di, " steps)" + #if HAS_I_AXIS + " " STR_I ":", target.i, " (", di, " steps)" #endif - #if LINEAR_AXES >= 5 - " " AXIS5_STR ":", target.j, " (", dj, " steps)" + #if HAS_J_AXIS + " " STR_J ":", target.j, " (", dj, " steps)" #endif - #if LINEAR_AXES >= 6 - " " AXIS6_STR ":", target.k, " (", dk, " steps)" + #if HAS_K_AXIS + " " STR_K ":", target.k, " (", dk, " steps)" #endif #if HAS_EXTRUDERS " E:", target.e, " (", de, " steps)" @@ -1939,13 +1925,13 @@ bool Planner::_populate_block(block_t * const block, bool split_move, if (db + dc < 0) SBI(dm, B_AXIS); // Motor B direction if (CORESIGN(db - dc) < 0) SBI(dm, C_AXIS); // Motor C direction #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS if (di < 0) SBI(dm, I_AXIS); #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS if (dj < 0) SBI(dm, J_AXIS); #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS if (dk < 0) SBI(dm, K_AXIS); #endif #elif ENABLED(MARKFORGED_XY) @@ -2041,15 +2027,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move, steps_dist_mm.b = (db + dc) * mm_per_step[B_AXIS]; steps_dist_mm.c = CORESIGN(db - dc) * mm_per_step[C_AXIS]; #endif - #if LINEAR_AXES >= 4 - steps_dist_mm.i = di * mm_per_step[I_AXIS]; - #endif - #if LINEAR_AXES >= 5 - steps_dist_mm.j = dj * mm_per_step[J_AXIS]; - #endif - #if LINEAR_AXES >= 6 - steps_dist_mm.k = dk * mm_per_step[K_AXIS]; - #endif + TERN_(HAS_I_AXIS, steps_dist_mm.i = di * mm_per_step[I_AXIS]); + TERN_(HAS_J_AXIS, steps_dist_mm.j = dj * mm_per_step[J_AXIS]); + TERN_(HAS_K_AXIS, steps_dist_mm.k = dk * mm_per_step[K_AXIS]); #elif ENABLED(MARKFORGED_XY) steps_dist_mm.a = (da - db) * mm_per_step[A_AXIS]; steps_dist_mm.b = db * mm_per_step[B_AXIS]; @@ -2104,7 +2084,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, ) #elif ENABLED(FOAMCUTTER_XYUV) // Return the largest distance move from either X/Y or I/J plane - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS _MAX(sq(steps_dist_mm.x) + sq(steps_dist_mm.y), sq(steps_dist_mm.i) + sq(steps_dist_mm.j)) #else sq(steps_dist_mm.x) + sq(steps_dist_mm.y) @@ -2197,15 +2177,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move, ); #endif #if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) - #if LINEAR_AXES >= 4 - if (block->steps.i) stepper.enable_axis(I_AXIS); - #endif - #if LINEAR_AXES >= 5 - if (block->steps.j) stepper.enable_axis(J_AXIS); - #endif - #if LINEAR_AXES >= 6 - if (block->steps.k) stepper.enable_axis(K_AXIS); - #endif + TERN_(HAS_I_AXIS, if (block->steps.i) stepper.enable_axis(I_AXIS)); + TERN_(HAS_J_AXIS, if (block->steps.j) stepper.enable_axis(J_AXIS)); + TERN_(HAS_K_AXIS, if (block->steps.k) stepper.enable_axis(K_AXIS)); #endif // Enable extruder(s) @@ -2260,7 +2234,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, // Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill #if EITHER(SLOWDOWN, HAS_WIRED_LCD) || defined(XY_FREQUENCY_LIMIT) - // Segment time im micro seconds + // Segment time in microseconds int32_t segment_time_us = LROUND(1000000.0f / inverse_secs); #endif @@ -2419,7 +2393,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, accel = CEIL((esteps ? settings.acceleration : settings.travel_acceleration) * steps_per_mm); #if ENABLED(LIN_ADVANCE) - + // Linear advance is currently not ready for HAS_I_AXIS #define MAX_E_JERK(N) TERN(HAS_LINEAR_E_JERK, max_e_jerk[E_INDEX_N(N)], max_jerk.e) /** @@ -2486,7 +2460,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, block->acceleration_steps_per_s2 = accel; block->acceleration = accel / steps_per_mm; #if DISABLED(S_CURVE_ACCELERATION) - block->acceleration_rate = (uint32_t)(accel * (sq(4096.0f) / (STEPPER_TIMER_RATE))); + block->acceleration_rate = (uint32_t)(accel * (float(1UL << 24) / (STEPPER_TIMER_RATE))); #endif #if ENABLED(LIN_ADVANCE) if (block->use_advance_lead) { @@ -2824,9 +2798,13 @@ bool Planner::_populate_block(block_t * const block, bool split_move, position = target; // Update the position + #if ENABLED(POWER_LOSS_RECOVERY) + block->sdpos = recovery.command_sdpos(); + block->start_position = position_float.asLogical(); + #endif + TERN_(HAS_POSITION_FLOAT, position_float = target_float); TERN_(GRADIENT_MIX, mixer.gradient_control(target_float.z)); - TERN_(POWER_LOSS_RECOVERY, block->sdpos = recovery.command_sdpos()); return true; // Movement was accepted @@ -2852,6 +2830,9 @@ void Planner::buffer_sync_block(TERN_(LASER_SYNCHRONOUS_M106_M107, uint8_t sync_ block->flag = sync_flag; block->position = position; + #if ENABLED(BACKLASH_COMPENSATION) + LOOP_LINEAR_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]; @@ -2939,7 +2920,7 @@ bool Planner::buffer_segment(const abce_pos_t &abce SERIAL_ECHOPGM_P(SP_Y_LBL, abce.b); #endif SERIAL_ECHOPGM(" (", position.y, "->", target.y); - #if LINEAR_AXES >= ABC + #if HAS_Z_AXIS #if ENABLED(DELTA) SERIAL_ECHOPGM(") C:", abce.c); #else @@ -2949,17 +2930,17 @@ bool Planner::buffer_segment(const abce_pos_t &abce SERIAL_ECHOPGM(" (", position.z, "->", target.z); SERIAL_CHAR(')'); #endif - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS SERIAL_ECHOPGM_P(SP_I_LBL, abce.i); SERIAL_ECHOPGM(" (", position.i, "->", target.i); SERIAL_CHAR(')'); #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS SERIAL_ECHOPGM_P(SP_J_LBL, abce.j); SERIAL_ECHOPGM(" (", position.j, "->", target.j); SERIAL_CHAR(')'); #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS SERIAL_ECHOPGM_P(SP_K_LBL, abce.k); SERIAL_ECHOPGM(" (", position.k, "->", target.k); SERIAL_CHAR(')'); @@ -3119,13 +3100,21 @@ void Planner::set_machine_position_mm(const abce_pos_t &abce) { LROUND(abce.k * settings.axis_steps_per_mm[K_AXIS]) ) ); + if (has_blocks_queued()) { //previous_nominal_speed_sqr = 0.0; // Reset planner junction speeds. Assume start from rest. //previous_speed.reset(); buffer_sync_block(); } - else - stepper.set_position(position); + else { + #if ENABLED(BACKLASH_COMPENSATION) + abce_long_t stepper_pos = position; + LOOP_LINEAR_AXES(axis) stepper_pos[axis] += backlash.get_applied_steps((AxisEnum)axis); + stepper.set_position(stepper_pos); + #else + stepper.set_position(position); + #endif + } } void Planner::set_position_mm(const xyze_pos_t &xyze) { diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 69e3f035ba9d..1af5ccc8106a 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -162,7 +162,7 @@ enum BlockFlag : char { * A single entry in the planner buffer. * Tracks linear movement over multiple axes. * - * The "nominal" values are as-specified by gcode, and + * The "nominal" values are as-specified by G-code, and * may never actually be reached due to acceleration limits. */ typedef struct block_t { @@ -244,6 +244,7 @@ typedef struct block_t { #if ENABLED(POWER_LOSS_RECOVERY) uint32_t sdpos; + xyze_pos_t start_position; #endif #if ENABLED(LASER_POWER_INLINE) @@ -252,7 +253,7 @@ typedef struct block_t { } block_t; -#if ANY(LIN_ADVANCE, SCARA_FEEDRATE_SCALING, GRADIENT_MIX, LCD_SHOW_E_TOTAL) +#if ANY(LIN_ADVANCE, SCARA_FEEDRATE_SCALING, GRADIENT_MIX, LCD_SHOW_E_TOTAL, POWER_LOSS_RECOVERY) #define HAS_POSITION_FLOAT 1 #endif @@ -410,7 +411,7 @@ class Planner { /** * The current position of the tool in absolute steps - * Recalculated if any axis_steps_per_mm are changed by gcode + * Recalculated if any axis_steps_per_mm are changed by G-code */ static xyze_long_t position; @@ -431,15 +432,15 @@ class Planner { static int8_t xy_freq_limit_hz; // Minimum XY frequency setting static float xy_freq_min_speed_factor; // Minimum speed factor setting static int32_t xy_freq_min_interval_us; // Minimum segment time based on xy_freq_limit_hz - static inline void refresh_frequency_limit() { + static void refresh_frequency_limit() { //xy_freq_min_interval_us = xy_freq_limit_hz ?: LROUND(1000000.0f / xy_freq_limit_hz); if (xy_freq_limit_hz) xy_freq_min_interval_us = LROUND(1000000.0f / xy_freq_limit_hz); } - static inline void set_min_speed_factor_u8(const uint8_t v255) { + static void set_min_speed_factor_u8(const uint8_t v255) { xy_freq_min_speed_factor = float(ui8_to_percent(v255)) / 100; } - static inline void set_frequency_limit(const uint8_t hz) { + static void set_frequency_limit(const uint8_t hz) { xy_freq_limit_hz = constrain(hz, 0, 100); refresh_frequency_limit(); } @@ -508,7 +509,7 @@ class Planner { #if HAS_CLASSIC_JERK static void set_max_jerk(const AxisEnum axis, float inMaxJerkMMS); #else - static inline void set_max_jerk(const AxisEnum, const_float_t) {} + static void set_max_jerk(const AxisEnum, const_float_t) {} #endif #if HAS_EXTRUDERS @@ -516,7 +517,7 @@ class Planner { e_factor[e] = flow_percentage[e] * 0.01f * TERN(NO_VOLUMETRICS, 1.0f, volumetric_multiplier[e]); } - static inline void set_flow(const uint8_t e, const int16_t flow) { + static void set_flow(const uint8_t e, const int16_t flow) { flow_percentage[e] = flow; refresh_e_factor(e); } @@ -539,7 +540,7 @@ class Planner { #if ENABLED(FILAMENT_WIDTH_SENSOR) void apply_filament_width_sensor(const int8_t encoded_ratio); - static inline float volumetric_percent(const bool vol) { + static float volumetric_percent(const bool vol) { return 100.0f * (vol ? volumetric_area_nominal / volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] : volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] @@ -588,9 +589,9 @@ class Planner { * Returns 1.0 if planner.z_fade_height is 0.0. * Returns 0.0 if Z is past the specified 'Fade Height'. */ - static inline float fade_scaling_factor_for_z(const_float_t rz) { + static float fade_scaling_factor_for_z(const_float_t rz) { static float z_fade_factor = 1; - if (!z_fade_height) return 1; + if (!z_fade_height || rz <= 0) return 1; if (rz >= z_fade_height) return 0; if (last_fade_z != rz) { last_fade_z = rz; @@ -838,7 +839,7 @@ class Planner { */ static float get_axis_position_mm(const AxisEnum axis); - static inline abce_pos_t get_axis_positions_mm() { + static abce_pos_t get_axis_positions_mm() { const abce_pos_t out = LOGICAL_AXIS_ARRAY( get_axis_position_mm(E_AXIS), get_axis_position_mm(A_AXIS), get_axis_position_mm(B_AXIS), get_axis_position_mm(C_AXIS), @@ -870,7 +871,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 inline bool busy() { + static bool busy() { return (has_blocks_queued() || cleaning_buffer_counter || TERN0(EXTERNAL_CLOSED_LOOP_CONTROLLER, CLOSED_LOOP_WAITING()) ); @@ -927,8 +928,8 @@ class Planner { #if HAS_LINEAR_E_JERK FORCE_INLINE static void recalculate_max_e_jerk() { const float prop = junction_deviation_mm * SQRT(0.5) / (1.0f - SQRT(0.5)); - LOOP_L_N(i, EXTRUDERS) - max_e_jerk[E_INDEX_N(i)] = SQRT(prop * settings.max_acceleration_mm_per_s2[E_INDEX_N(i)]); + EXTRUDER_LOOP() + max_e_jerk[E_INDEX_N(e)] = SQRT(prop * settings.max_acceleration_mm_per_s2[E_INDEX_N(e)]); } #endif @@ -938,7 +939,7 @@ class Planner { #if ENABLED(AUTOTEMP_PROPORTIONAL) static void _autotemp_update_from_hotend(); #else - static inline void _autotemp_update_from_hotend() {} + static void _autotemp_update_from_hotend() {} #endif #endif @@ -1019,7 +1020,7 @@ class Planner { return limit_value; } - #endif // !CLASSIC_JERK + #endif // HAS_JUNCTION_DEVIATION }; #define PLANNER_XY_FEEDRATE() _MIN(planner.settings.max_feedrate_mm_s[X_AXIS], planner.settings.max_feedrate_mm_s[Y_AXIS]) diff --git a/Marlin/src/module/printcounter.cpp b/Marlin/src/module/printcounter.cpp index 27dee76715d4..619fbc137ce4 100644 --- a/Marlin/src/module/printcounter.cpp +++ b/Marlin/src/module/printcounter.cpp @@ -43,7 +43,6 @@ Stopwatch print_job_timer; // Global Print Job Timer instance #if PRINTCOUNTER_SYNC #include "../module/planner.h" - #warning "To prevent step loss, motion will pause for PRINTCOUNTER auto-save." #endif // Service intervals @@ -81,30 +80,36 @@ millis_t PrintCounter::deltaDuration() { return lastDuration - tmp; } -void PrintCounter::incFilamentUsed(float const &amount) { - TERN_(DEBUG_PRINTCOUNTER, debug(PSTR("incFilamentUsed"))); +#if HAS_EXTRUDERS + void PrintCounter::incFilamentUsed(float const &amount) { + TERN_(DEBUG_PRINTCOUNTER, debug(PSTR("incFilamentUsed"))); - // Refuses to update data if object is not loaded - if (!isLoaded()) return; + // Refuses to update data if object is not loaded + if (!isLoaded()) return; - data.filamentUsed += amount; // mm -} + data.filamentUsed += amount; // mm + } +#endif void PrintCounter::initStats() { TERN_(DEBUG_PRINTCOUNTER, debug(PSTR("initStats"))); loaded = true; - data = { 0, 0, 0, 0, 0.0 - #if HAS_SERVICE_INTERVALS - #if SERVICE_INTERVAL_1 > 0 - , SERVICE_INTERVAL_SEC_1 - #endif - #if SERVICE_INTERVAL_2 > 0 - , SERVICE_INTERVAL_SEC_2 - #endif - #if SERVICE_INTERVAL_3 > 0 - , SERVICE_INTERVAL_SEC_3 - #endif + + data = { + .totalPrints = 0 + , .finishedPrints = 0 + , .printTime = 0 + , .longestPrint = 0 + OPTARG(HAS_EXTRUDERS, .filamentUsed = 0.0) + #if SERVICE_INTERVAL_1 > 0 + , .nextService1 = SERVICE_INTERVAL_SEC_1 + #endif + #if SERVICE_INTERVAL_2 > 0 + , .nextService2 = SERVICE_INTERVAL_SEC_2 + #endif + #if SERVICE_INTERVAL_3 > 0 + , .nextService3 = SERVICE_INTERVAL_SEC_3 #endif }; @@ -152,7 +157,7 @@ void PrintCounter::loadStats() { if (data.nextService3 == 0) doBuzz = _service_warn(PSTR(" " SERVICE_NAME_3)); #endif #if HAS_BUZZER && SERVICE_WARNING_BUZZES > 0 - if (doBuzz) for (int i = 0; i < SERVICE_WARNING_BUZZES; i++) BUZZ(200, 404); + if (doBuzz) for (int i = 0; i < SERVICE_WARNING_BUZZES; i++) { BUZZ(200, 404); BUZZ(10, 0); } #else UNUSED(doBuzz); #endif @@ -172,7 +177,7 @@ void PrintCounter::saveStats() { persistentStore.write_data(address + sizeof(uint8_t), (uint8_t*)&data, sizeof(printStatistics)); persistentStore.access_finish(); - TERN_(EXTENSIBLE_UI, ExtUI::onConfigurationStoreWritten(true)); + TERN_(EXTENSIBLE_UI, ExtUI::onSettingsStored(true)); } #if HAS_SERVICE_INTERVALS @@ -211,8 +216,11 @@ void PrintCounter::showStats() { SERIAL_CHAR(')'); #endif - SERIAL_ECHOPGM("\n" STR_STATS "Filament used: ", data.filamentUsed / 1000); - SERIAL_CHAR('m'); + #if HAS_EXTRUDERS + SERIAL_ECHOPGM("\n" STR_STATS "Filament used: ", data.filamentUsed / 1000); + SERIAL_CHAR('m'); + #endif + SERIAL_EOL(); #if SERVICE_INTERVAL_1 > 0 diff --git a/Marlin/src/module/printcounter.h b/Marlin/src/module/printcounter.h index 4deae45a656d..63cc1da158e8 100644 --- a/Marlin/src/module/printcounter.h +++ b/Marlin/src/module/printcounter.h @@ -37,7 +37,9 @@ struct printStatistics { // 16 bytes uint16_t finishedPrints; // Number of complete prints uint32_t printTime; // Accumulated printing time uint32_t longestPrint; // Longest successful print job - float filamentUsed; // Accumulated filament consumed in mm + #if HAS_EXTRUDERS + float filamentUsed; // Accumulated filament consumed in mm + #endif #if SERVICE_INTERVAL_1 > 0 uint32_t nextService1; // Service intervals (or placeholders) #endif @@ -52,12 +54,7 @@ struct printStatistics { // 16 bytes class PrintCounter: public Stopwatch { private: typedef Stopwatch super; - - #if EITHER(USE_WIRED_EEPROM, CPU_32_BIT) - typedef uint32_t eeprom_address_t; - #else - typedef uint16_t eeprom_address_t; - #endif + typedef IF::type eeprom_address_t; static printStatistics data; @@ -112,7 +109,7 @@ class PrintCounter: public Stopwatch { /** * @brief Initialize the print counter */ - static inline void init() { + static void init() { super::init(); loadStats(); } @@ -124,13 +121,15 @@ class PrintCounter: public Stopwatch { */ FORCE_INLINE static bool isLoaded() { return loaded; } - /** - * @brief Increment the total filament used - * @details The total filament used counter will be incremented by "amount". - * - * @param amount The amount of filament used in mm - */ - static void incFilamentUsed(float const &amount); + #if HAS_EXTRUDERS + /** + * @brief Increment the total filament used + * @details The total filament used counter will be incremented by "amount". + * + * @param amount The amount of filament used in mm + */ + static void incFilamentUsed(float const &amount); + #endif /** * @brief Reset the Print Statistics @@ -176,8 +175,8 @@ class PrintCounter: public Stopwatch { */ static bool start(); static bool _stop(const bool completed); - static inline bool stop() { return _stop(true); } - static inline bool abort() { return _stop(false); } + static bool stop() { return _stop(true); } + static bool abort() { return _stop(false); } static void reset(); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 540b4e1ae6a4..519a94d73833 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -77,10 +77,18 @@ #include "servo.h" #endif +#if HAS_PTC + #include "../feature/probe_temp_comp.h" +#endif + +#if ENABLED(X_AXIS_TWIST_COMPENSATION) + #include "../feature/x_twist.h" +#endif + #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../lcd/e3v2/proui/dwin.h" #endif #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) @@ -95,7 +103,7 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() #endif #if ENABLED(SENSORLESS_PROBING) - Probe::sense_bool_t Probe::test_sensitivity; + Probe::sense_bool_t Probe::test_sensitivity = { true, true, true }; #endif #if ENABLED(Z_PROBE_SLED) @@ -121,6 +129,17 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() #endif } +#elif ENABLED(MAGLEV4) + + // Write trigger pin to release the probe + inline void maglev_deploy() { + WRITE(MAGLEV_TRIGGER_PIN, HIGH); + delay(MAGLEV_TRIGGER_DELAY); + WRITE(MAGLEV_TRIGGER_PIN, LOW); + } + + inline void maglev_idle() { do_blocking_move_to_z(10); } + #elif ENABLED(TOUCH_MI_PROBE) // Move to the magnet to unlock the probe @@ -287,17 +306,16 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { if (deploy != PROBE_TRIGGERED()) break; #endif - BUZZ(100, 659); - BUZZ(100, 698); + 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(ds_str); + SERIAL_ECHOLNF(deploy ? GET_EN_TEXT_F(MSG_MANUAL_DEPLOY) : GET_EN_TEXT_F(MSG_MANUAL_STOW)); - TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("Stow Probe"), FPSTR(CONTINUE_STR))); - TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("Stow Probe"))); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_Popup_Confirm(ICON_BLTouch, F("Stow Probe"), FPSTR(CONTINUE_STR))); + 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(); @@ -311,6 +329,10 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { WRITE(SOL1_PIN, deploy); #endif + #elif ENABLED(MAGLEV4) + + deploy ? maglev_deploy() : maglev_idle(); + #elif ENABLED(Z_PROBE_SLED) dock_sled(!deploy); @@ -321,7 +343,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { #elif HAS_Z_SERVO_PROBE - MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][deploy ? 0 : 1]); + servo[Z_PROBE_SERVO_NR].move(servo_angles[Z_PROBE_SERVO_NR][deploy ? 0 : 1]); #elif EITHER(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY) @@ -393,6 +415,21 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { #endif +/** + * Print an error and stop() + */ +void Probe::probe_error_stop() { + SERIAL_ERROR_START(); + SERIAL_ECHOPGM(STR_STOP_PRE); + #if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY) + SERIAL_ECHOPGM(STR_STOP_UNHOMED); + #elif ENABLED(BLTOUCH) + SERIAL_ECHOPGM(STR_STOP_BLTOUCH); + #endif + SERIAL_ECHOLNPGM(STR_STOP_POST); + stop(); +} + /** * Attempt to deploy or stow the probe * @@ -421,8 +458,7 @@ bool Probe::set_deployed(const bool deploy) { #if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY) if (homing_needed_error(TERN_(Z_PROBE_SLED, _BV(X_AXIS)))) { - SERIAL_ERROR_MSG(STR_STOP_UNHOMED); - stop(); + probe_error_stop(); return true; } #endif @@ -462,15 +498,12 @@ bool Probe::set_deployed(const bool deploy) { } /** - * @brief Used by run_z_probe to do a single Z probe move. + * @brief Move down until the probe triggers or the low limit is reached + * Used by run_z_probe to do a single Z probe move. * * @param z Z destination * @param fr_mm_s Feedrate in mm/s * @return true to indicate an error - */ - -/** - * @brief Move down until the probe triggers or the low limit is reached * * @details Used by run_z_probe to get each bed Z height measurement. * Sets current_position.z to the height where the probe triggered @@ -498,12 +531,12 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { #if ENABLED(SENSORLESS_PROBING) sensorless_t stealth_states { false }; #if HAS_DELTA_SENSORLESS_PROBING - if (test_sensitivity.x) stealth_states.x = tmc_enable_stallguard(stepperX); // Delta watches all DIAG pins for a stall + if (test_sensitivity.x) stealth_states.x = tmc_enable_stallguard(stepperX); // Delta watches all DIAG pins for a stall if (test_sensitivity.y) stealth_states.y = tmc_enable_stallguard(stepperY); #endif - if (test_sensitivity.z) stealth_states.z = tmc_enable_stallguard(stepperZ); // All machines will check Z-DIAG for stall + if (test_sensitivity.z) stealth_states.z = tmc_enable_stallguard(stepperZ); // All machines will check Z-DIAG for stall + endstops.set_homing_current(true); // The "homing" current also applies to probing endstops.enable(true); - set_homing_current(true); // The "homing" current also applies to probing #endif TERN_(HAS_QUIET_PROBING, set_probing_paused(true)); @@ -520,6 +553,11 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { #endif ; + // Offset sensorless probing + #if HAS_DELTA_SENSORLESS_PROBING + if (probe_triggered) probe.refresh_largest_sensorless_adj(); + #endif + TERN_(HAS_QUIET_PROBING, set_probing_paused(false)); // Re-enable stealthChop if used. Disable diag1 pin on driver. @@ -530,7 +568,7 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { if (test_sensitivity.y) tmc_disable_stallguard(stepperY, stealth_states.y); #endif if (test_sensitivity.z) tmc_disable_stallguard(stepperZ, stealth_states.z); - set_homing_current(false); + endstops.set_homing_current(false); #endif #if ENABLED(BLTOUCH) @@ -633,8 +671,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) { if (try_to_probe(PSTR("FAST"), z_probe_low_point, z_probe_fast_mm_s, sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return NAN; - const float first_probe_z = current_position.z; - + const float first_probe_z = DIFF_TERN(HAS_DELTA_SENSORLESS_PROBING, current_position.z, largest_sensorless_adj); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("1st Probe Z:", first_probe_z); // Raise to give the probe clearance @@ -676,7 +713,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) { TERN_(MEASURE_BACKLASH_WHEN_PROBING, backlash.measure_with_probe()); - const float z = current_position.z; + const float z = DIFF_TERN(HAS_DELTA_SENSORLESS_PROBING, current_position.z, largest_sensorless_adj); #if EXTRA_PROBING > 0 // Insert Z measurement into probes[]. Keep it sorted ascending. @@ -727,7 +764,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) { #elif TOTAL_PROBING == 2 - const float z2 = current_position.z; + const float z2 = DIFF_TERN(HAS_DELTA_SENSORLESS_PROBING, current_position.z, largest_sensorless_adj); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("2nd Probe Z:", z2, " Discrepancy:", first_probe_z - z2); @@ -772,7 +809,10 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai #endif // On delta keep Z below clip height or do_blocking_move_to will abort - xyz_pos_t npos = { rx, ry, TERN(DELTA, _MIN(delta_clip_start_height, current_position.z), current_position.z) }; + xyz_pos_t npos = LINEAR_AXIS_ARRAY( + rx, ry, TERN(DELTA, _MIN(delta_clip_start_height, current_position.z), current_position.z), + current_position.i, current_position.j, current_position.k + ); if (!can_reach(npos, probe_relative)) { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Position Not Reachable"); return NAN; @@ -783,7 +823,11 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai do_blocking_move_to(npos, feedRate_t(XY_PROBE_FEEDRATE_MM_S)); float measured_z = NAN; - if (!deploy()) measured_z = run_z_probe(sanity_check) + offset.z; + if (!deploy()) { + measured_z = run_z_probe(sanity_check) + offset.z; + TERN_(HAS_PTC, ptc.apply_compensation(measured_z)); + TERN_(X_AXIS_TWIST_COMPENSATION, measured_z += xatc.compensation(npos + offset_xy)); + } if (!isnan(measured_z)) { const bool big_raise = raise_after == PROBE_PT_BIG_RAISE; if (big_raise || raise_after == PROBE_PT_RAISE) @@ -802,7 +846,7 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai SERIAL_ERROR_MSG(STR_ERR_PROBING_FAILED); #endif } - + DEBUG_ECHOLNPGM("measured_z: ", measured_z); return measured_z; } @@ -855,58 +899,39 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai } /** - * Change the current in the TMC drivers to N##_CURRENT_HOME. And we save the current configuration of each TMC driver. + * Set the sensorless Z offset */ - void Probe::set_homing_current(const bool onoff) { - #define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT) - #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Z) - #if ENABLED(DELTA) - static int16_t saved_current_X, saved_current_Y; - #endif - #if HAS_CURRENT_HOME(Z) - static int16_t saved_current_Z; + 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 ((ENABLED(DELTA) && (HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(Y))) || HAS_CURRENT_HOME(Z)) - auto debug_current_on = [](PGM_P const s, const int16_t a, const int16_t b) { - if (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM_P(s); DEBUG_ECHOLNPGM(" current: ", a, " -> ", b); } - }; + if (test_sensitivity.z) offset_sensorless_adj.c = sz; + #endif + } + + /** + * 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 (onoff) { - #if ENABLED(DELTA) - #if HAS_CURRENT_HOME(X) - saved_current_X = stepperX.getMilliamps(); - stepperX.rms_current(X_CURRENT_HOME); - debug_current_on(PSTR("X"), saved_current_X, X_CURRENT_HOME); - #endif - #if HAS_CURRENT_HOME(Y) - saved_current_Y = stepperY.getMilliamps(); - stepperY.rms_current(Y_CURRENT_HOME); - debug_current_on(PSTR("Y"), saved_current_Y, Y_CURRENT_HOME); - #endif - #endif - #if HAS_CURRENT_HOME(Z) - saved_current_Z = stepperZ.getMilliamps(); - stepperZ.rms_current(Z_CURRENT_HOME); - debug_current_on(PSTR("Z"), saved_current_Z, Z_CURRENT_HOME); - #endif - TERN_(IMPROVE_HOMING_RELIABILITY, planner.enable_stall_prevention(true)); - } - else { - #if ENABLED(DELTA) - #if HAS_CURRENT_HOME(X) - stepperX.rms_current(saved_current_X); - debug_current_on(PSTR("X"), X_CURRENT_HOME, saved_current_X); - #endif - #if HAS_CURRENT_HOME(Y) - stepperY.rms_current(saved_current_Y); - debug_current_on(PSTR("Y"), Y_CURRENT_HOME, saved_current_Y); - #endif - #endif - #if HAS_CURRENT_HOME(Z) - stepperZ.rms_current(saved_current_Z); - debug_current_on(PSTR("Z"), Z_CURRENT_HOME, saved_current_Z); - #endif - TERN_(IMPROVE_HOMING_RELIABILITY, planner.enable_stall_prevention(false)); + if (TEST(endstops.state(), Z_MAX)) { + NOLESS(largest_sensorless_adj, offset_sensorless_adj.c); + DEBUG_ECHOLNPGM("Endstop_Z: ", largest_sensorless_adj, " TowerZ"); } #endif } diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index 3c97afcb899c..5a596053d8a7 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -45,6 +45,14 @@ #define PROBE_TRIGGERED() (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) #endif +#ifdef Z_AFTER_HOMING + #define Z_POST_CLEARANCE Z_AFTER_HOMING +#elif defined(Z_HOMING_HEIGHT) + #define Z_POST_CLEARANCE Z_HOMING_HEIGHT +#else + #define Z_POST_CLEARANCE 10 +#endif + #if ENABLED(PREHEAT_BEFORE_LEVELING) #ifndef LEVELING_NOZZLE_TEMP #define LEVELING_NOZZLE_TEMP 0 @@ -58,7 +66,13 @@ class Probe { public: #if ENABLED(SENSORLESS_PROBING) - typedef struct { bool x:1, y:1, z:1; } sense_bool_t; + 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 @@ -70,6 +84,8 @@ class Probe { static void preheat_for_probing(const celsius_t hotend_temp, const celsius_t bed_temp); #endif + static void probe_error_stop(); + static bool set_deployed(const bool deploy); #if IS_KINEMATIC @@ -180,6 +196,15 @@ class Probe { } #endif + /** + * The nozzle is only able to move within the physical bounds of the machine. + * If the PROBE has an OFFSET Marlin may need to apply additional limits so + * the probe can be prevented from going to unreachable points. + * + * e.g., If the PROBE is to the LEFT of the NOZZLE, it will be limited in how + * close it can get the RIGHT edge of the bed (unless the nozzle is able move + * far enough past the right edge). + */ static constexpr float _min_x(const xy_pos_t &probe_offset_xy=offset_xy) { return TERN(IS_KINEMATIC, (X_CENTER) - probe_radius(probe_offset_xy), @@ -212,14 +237,14 @@ class Probe { // constexpr helpers used in build-time static_asserts, relying on default probe offsets. class build_time { - static constexpr xyz_pos_t default_probe_xyz_offset = + static constexpr xyz_pos_t default_probe_xyz_offset = xyz_pos_t( #if HAS_BED_PROBE NOZZLE_TO_PROBE_OFFSET #else { 0 } #endif - ; - static constexpr xy_pos_t default_probe_xy_offset = { default_probe_xyz_offset.x, default_probe_xyz_offset.y }; + ); + static constexpr xy_pos_t default_probe_xy_offset = xy_pos_t({ default_probe_xyz_offset.x, default_probe_xyz_offset.y }); public: static constexpr bool can_reach(float x, float y) { @@ -280,7 +305,8 @@ class Probe { #if USE_SENSORLESS static void enable_stallguard_diag1(); static void disable_stallguard_diag1(); - static void set_homing_current(const bool onoff); + static void set_offset_sensorless_adj(const_float_t sz); + static void refresh_largest_sensorless_adj(); #endif private: diff --git a/Marlin/src/module/servo.cpp b/Marlin/src/module/servo.cpp index 231efe84e1f2..2782be1f2bd9 100644 --- a/Marlin/src/module/servo.cpp +++ b/Marlin/src/module/servo.cpp @@ -30,7 +30,7 @@ #include "servo.h" -HAL_SERVO_LIB servo[NUM_SERVOS]; +hal_servo_t servo[NUM_SERVOS]; #if ENABLED(EDITABLE_SERVO_ANGLES) uint16_t servo_angles[NUM_SERVOS][2]; @@ -39,19 +39,19 @@ HAL_SERVO_LIB servo[NUM_SERVOS]; void servo_init() { #if NUM_SERVOS >= 1 && HAS_SERVO_0 servo[0].attach(SERVO0_PIN); - DETACH_SERVO(0); // Just set up the pin. We don't have a position yet. Don't move to a random position. + servo[0].detach(); // Just set up the pin. We don't have a position yet. Don't move to a random position. #endif #if NUM_SERVOS >= 2 && HAS_SERVO_1 servo[1].attach(SERVO1_PIN); - DETACH_SERVO(1); + servo[1].detach(); #endif #if NUM_SERVOS >= 3 && HAS_SERVO_2 servo[2].attach(SERVO2_PIN); - DETACH_SERVO(2); + servo[2].detach(); #endif #if NUM_SERVOS >= 4 && HAS_SERVO_3 servo[3].attach(SERVO3_PIN); - DETACH_SERVO(3); + servo[3].detach(); #endif } diff --git a/Marlin/src/module/servo.h b/Marlin/src/module/servo.h index 73dbbdddb729..2ed992aa03f7 100644 --- a/Marlin/src/module/servo.h +++ b/Marlin/src/module/servo.h @@ -103,14 +103,11 @@ }; #if HAS_Z_SERVO_PROBE - #define DEPLOY_Z_SERVO() MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][0]) - #define STOW_Z_SERVO() MOVE_SERVO(Z_PROBE_SERVO_NR, servo_angles[Z_PROBE_SERVO_NR][1]) + #define DEPLOY_Z_SERVO() servo[Z_PROBE_SERVO_NR].move(servo_angles[Z_PROBE_SERVO_NR][0]) + #define STOW_Z_SERVO() servo[Z_PROBE_SERVO_NR].move(servo_angles[Z_PROBE_SERVO_NR][1]) #endif #endif // HAS_SERVO_ANGLES -#define MOVE_SERVO(I, P) servo[I].move(P) -#define DETACH_SERVO(I) servo[I].detach() - -extern HAL_SERVO_LIB servo[NUM_SERVOS]; +extern hal_servo_t servo[NUM_SERVOS]; void servo_init(); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 5fda608e3839..0d69c07c2480 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -64,7 +64,7 @@ #if HAS_LEVELING #include "../feature/bedlevel/bedlevel.h" #if ENABLED(X_AXIS_TWIST_COMPENSATION) - #include "../feature/bedlevel/abl/x_twist.h" + #include "../feature/x_twist.h" #endif #endif @@ -74,12 +74,16 @@ #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../lcd/e3v2/proui/dwin.h" #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) #include "../lcd/e3v2/jyersui/dwin.h" #endif +#if ENABLED(HOST_PROMPT_SUPPORT) + #include "../feature/host_actions.h" +#endif + #if HAS_SERVOS #include "servo.h" #endif @@ -174,11 +178,12 @@ #endif #define _EN_ITEM(N) , E##N +#define _EN1_ITEM(N) , E##N:1 -typedef struct { uint16_t LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } tmc_stepper_current_t; -typedef struct { uint32_t LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } tmc_hybrid_threshold_t; -typedef struct { int16_t LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4; } tmc_sgt_t; -typedef struct { bool LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } tmc_stealth_enabled_t; +typedef struct { uint16_t LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } per_stepper_uint16_t; +typedef struct { uint32_t LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } per_stepper_uint32_t; +typedef struct { int16_t LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4; } mot_stepper_int16_t; +typedef struct { bool LINEAR_AXIS_LIST(X:1, Y:1, Z:1, I:1, J:1, K:1), X2:1, Y2:1, Z2:1, Z3:1, Z4:1 REPEAT(E_STEPPERS, _EN1_ITEM); } per_stepper_bool_t; #undef _EN_ITEM @@ -242,9 +247,9 @@ typedef struct SettingsDataStruct { // // MESH_BED_LEVELING // - float mbl_z_offset; // mbl.z_offset + float mbl_z_offset; // bedlevel.z_offset uint8_t mesh_num_x, mesh_num_y; // GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y - float mbl_z_values[TERN(MESH_BED_LEVELING, GRID_MAX_POINTS_X, 3)] // mbl.z_values + 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)]; // @@ -265,18 +270,24 @@ typedef struct SettingsDataStruct { xy_pos_t bilinear_grid_spacing, bilinear_start; // G29 L F #if ENABLED(AUTO_BED_LEVELING_BILINEAR) bed_mesh_t z_values; // G29 - #if ENABLED(X_AXIS_TWIST_COMPENSATION) - XATC xatc; // TBD - #endif #else float z_values[3][3]; #endif + // + // X_AXIS_TWIST_COMPENSATION + // + #if ENABLED(X_AXIS_TWIST_COMPENSATION) + float xatc_spacing; // M423 X Z + float xatc_start; + xatc_array_t xatc_z_offset; + #endif + // // AUTO_BED_LEVELING_UBL // bool planner_leveling_active; // M420 S planner.leveling_active - int8_t ubl_storage_slot; // ubl.storage_slot + int8_t ubl_storage_slot; // bedlevel.storage_slot // // SERVO_ANGLES @@ -294,7 +305,7 @@ typedef struct SettingsDataStruct { int16_t z_offsets_bed[COUNT(ptc.z_offsets_bed)]; // M871 B I V #endif #if ENABLED(PTC_HOTEND) - int16_t z_offsets_hotend[COUNT(ptc.z_offsets_hotend)]; // M871 E I V + int16_t z_offsets_hotend[COUNT(ptc.z_offsets_hotend)]; // M871 E I V #endif #endif @@ -333,12 +344,12 @@ typedef struct SettingsDataStruct { #endif // - // Z_STEPPER_AUTO_ALIGN, Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS + // Z_STEPPER_AUTO_ALIGN, HAS_Z_STEPPER_ALIGN_STEPPER_XY // #if ENABLED(Z_STEPPER_AUTO_ALIGN) - xy_pos_t z_stepper_align_xy[NUM_Z_STEPPER_DRIVERS]; // M422 S X Y - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - xy_pos_t z_stepper_align_stepper_xy[NUM_Z_STEPPER_DRIVERS]; // M422 W X Y + xy_pos_t z_stepper_align_xy[NUM_Z_STEPPERS]; // M422 S X Y + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY + xy_pos_t z_stepper_align_stepper_xy[NUM_Z_STEPPERS]; // M422 W X Y #endif #endif @@ -387,6 +398,15 @@ typedef struct SettingsDataStruct { // uint8_t lcd_brightness; // M256 B + // + // Display Sleep + // + #if LCD_BACKLIGHT_TIMEOUT + uint16_t lcd_backlight_timeout; // M255 S + #elif HAS_DISPLAY_SLEEP + uint8_t sleep_timeout_minutes; // M255 S + #endif + // // Controller fan settings // @@ -413,10 +433,10 @@ typedef struct SettingsDataStruct { // // HAS_TRINAMIC_CONFIG // - tmc_stepper_current_t tmc_stepper_current; // M906 X Y Z X2 Y2 Z2 Z3 Z4 E0 E1 E2 E3 E4 E5 - tmc_hybrid_threshold_t tmc_hybrid_threshold; // M913 X Y Z X2 Y2 Z2 Z3 Z4 E0 E1 E2 E3 E4 E5 - tmc_sgt_t tmc_sgt; // M914 X Y Z X2 Y2 Z2 Z3 Z4 - tmc_stealth_enabled_t tmc_stealth_enabled; // M569 X Y Z X2 Y2 Z2 Z3 Z4 E0 E1 E2 E3 E4 E5 + per_stepper_uint16_t tmc_stepper_current; // M906 X Y Z... + per_stepper_uint32_t tmc_hybrid_threshold; // M913 X Y Z... + mot_stepper_int16_t tmc_sgt; // M914 X Y Z... + per_stepper_bool_t tmc_stealth_enabled; // M569 X Y Z... // // LIN_ADVANCE @@ -472,7 +492,7 @@ typedef struct SettingsDataStruct { // // Ender-3 V2 DWIN // - #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(DWIN_LCD_PROUI) uint8_t dwin_data[eeprom_data_size]; #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) uint8_t dwin_settings[CrealityDWIN.eeprom_data_size]; @@ -513,7 +533,7 @@ typedef struct SettingsDataStruct { // Buzzer enable/disable // #if ENABLED(SOUND_MENU_ITEM) - bool buzzer_enabled; + bool sound_on; #endif // @@ -527,7 +547,7 @@ typedef struct SettingsDataStruct { // MKS UI controller // #if ENABLED(DGUS_LCD_UI_MKS) - uint8_t mks_language_index; // Display Language + MKS_Language mks_language_index; // Display Language xy_int_t mks_corner_offsets[5]; // Bed Tramming xyz_int_t mks_park_pos; // Custom Parking (without NOZZLE_PARK) celsius_t mks_min_extrusion_temp; // Min E Temp (shadow M302 value) @@ -537,6 +557,13 @@ typedef struct SettingsDataStruct { uint8_t ui_language; // M414 S #endif + // + // Model predictive control + // + #if ENABLED(MPCTEMP) + MPC_t mpc_constants[HOTENDS]; // M306 + #endif + } SettingsData; //static_assert(sizeof(SettingsData) <= MARLIN_EEPROM_SIZE, "EEPROM too small to contain SettingsData!"); @@ -580,7 +607,7 @@ void MarlinSettings::postprocess() { TERN_(ENABLE_LEVELING_FADE_HEIGHT, set_z_fade_height(new_z_fade_height, false)); // false = no report - TERN_(AUTO_BED_LEVELING_BILINEAR, refresh_bed_level()); + TERN_(AUTO_BED_LEVELING_BILINEAR, bedlevel.refresh_bed_level()); TERN_(HAS_MOTOR_CURRENT_PWM, stepper.refresh_motor_power()); @@ -599,6 +626,16 @@ void MarlinSettings::postprocess() { // Various factors can change the current position if (oldpos != current_position) report_current_position(); + + // Moved as last update due to interference with Neopixel init + TERN_(HAS_LCD_CONTRAST, ui.refresh_contrast()); + TERN_(HAS_LCD_BRIGHTNESS, ui.refresh_brightness()); + + #if LCD_BACKLIGHT_TIMEOUT + ui.refresh_backlight_timeout(); + #elif HAS_DISPLAY_SLEEP + ui.refresh_screen_timeout(); + #endif } #if BOTH(PRINTCOUNTER, EEPROM_SETTINGS) @@ -648,6 +685,10 @@ void MarlinSettings::postprocess() { #define DEBUG_OUT EITHER(EEPROM_CHITCHAT, DEBUG_LEVELING_FEATURE) #include "../core/debug_out.h" +#if BOTH(EEPROM_CHITCHAT, HOST_PROMPT_SUPPORT) + #define HOST_EEPROM_CHITCHAT 1 +#endif + #if ENABLED(EEPROM_SETTINGS) #define EEPROM_ASSERT(TST,ERR) do{ if (!(TST)) { SERIAL_ERROR_MSG(ERR); eeprom_error = true; } }while(0) @@ -795,7 +836,7 @@ void MarlinSettings::postprocess() { { #if ENABLED(MESH_BED_LEVELING) static_assert( - sizeof(mbl.z_values) == (GRID_MAX_POINTS) * sizeof(mbl.z_values[0][0]), + sizeof(bedlevel.z_values) == (GRID_MAX_POINTS) * sizeof(bedlevel.z_values[0][0]), "MBL Z array is the wrong size." ); #else @@ -805,12 +846,12 @@ void MarlinSettings::postprocess() { const uint8_t mesh_num_x = TERN(MESH_BED_LEVELING, GRID_MAX_POINTS_X, 3), mesh_num_y = TERN(MESH_BED_LEVELING, GRID_MAX_POINTS_Y, 3); - EEPROM_WRITE(TERN(MESH_BED_LEVELING, mbl.z_offset, dummyf)); + EEPROM_WRITE(TERN(MESH_BED_LEVELING, bedlevel.z_offset, dummyf)); EEPROM_WRITE(mesh_num_x); EEPROM_WRITE(mesh_num_y); #if ENABLED(MESH_BED_LEVELING) - EEPROM_WRITE(mbl.z_values); + EEPROM_WRITE(bedlevel.z_values); #else for (uint8_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_WRITE(dummyf); #endif @@ -847,44 +888,49 @@ void MarlinSettings::postprocess() { { #if ENABLED(AUTO_BED_LEVELING_BILINEAR) static_assert( - sizeof(z_values) == (GRID_MAX_POINTS) * sizeof(z_values[0][0]), + sizeof(bedlevel.z_values) == (GRID_MAX_POINTS) * sizeof(bedlevel.z_values[0][0]), "Bilinear Z array is the wrong size." ); - #if ENABLED(X_AXIS_TWIST_COMPENSATION) - static_assert( - sizeof(xatc.z_values) == (XATC_MAX_POINTS) * sizeof(xatc.z_values[0]), - "Z-offset mesh is the wrong size." - ); - #endif - #else - const xy_pos_t bilinear_start{0}, bilinear_grid_spacing{0}; #endif const uint8_t grid_max_x = TERN(AUTO_BED_LEVELING_BILINEAR, GRID_MAX_POINTS_X, 3), grid_max_y = TERN(AUTO_BED_LEVELING_BILINEAR, GRID_MAX_POINTS_Y, 3); EEPROM_WRITE(grid_max_x); EEPROM_WRITE(grid_max_y); - EEPROM_WRITE(bilinear_grid_spacing); - EEPROM_WRITE(bilinear_start); + #if ENABLED(AUTO_BED_LEVELING_BILINEAR) + EEPROM_WRITE(bedlevel.grid_spacing); + EEPROM_WRITE(bedlevel.grid_start); + #else + const xy_pos_t bilinear_grid_spacing{0}, bilinear_start{0}; + EEPROM_WRITE(bilinear_grid_spacing); + EEPROM_WRITE(bilinear_start); + #endif #if ENABLED(AUTO_BED_LEVELING_BILINEAR) - EEPROM_WRITE(z_values); // 9-256 floats - #if ENABLED(X_AXIS_TWIST_COMPENSATION) - EEPROM_WRITE(xatc); - #endif + EEPROM_WRITE(bedlevel.z_values); // 9-256 floats #else dummyf = 0; for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_WRITE(dummyf); #endif } + // + // X Axis Twist Compensation + // + #if ENABLED(X_AXIS_TWIST_COMPENSATION) + _FIELD_TEST(xatc_spacing); + EEPROM_WRITE(xatc.spacing); + EEPROM_WRITE(xatc.start); + EEPROM_WRITE(xatc.z_offset); + #endif + // // Unified Bed Leveling // { _FIELD_TEST(planner_leveling_active); const bool ubl_active = TERN(AUTO_BED_LEVELING_UBL, planner.leveling_active, false); - const int8_t storage_slot = TERN(AUTO_BED_LEVELING_UBL, ubl.storage_slot, -1); + const int8_t storage_slot = TERN(AUTO_BED_LEVELING_UBL, bedlevel.storage_slot, -1); EEPROM_WRITE(ubl_active); EEPROM_WRITE(storage_slot); } @@ -963,13 +1009,13 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(TERN(Y_DUAL_ENDSTOPS, endstops.y2_endstop_adj, dummyf)); // 1 float EEPROM_WRITE(TERN(Z_MULTI_ENDSTOPS, endstops.z2_endstop_adj, dummyf)); // 1 float - #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 + #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPERS >= 3 EEPROM_WRITE(endstops.z3_endstop_adj); // 1 float #else EEPROM_WRITE(dummyf); #endif - #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4 + #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPERS >= 4 EEPROM_WRITE(endstops.z4_endstop_adj); // 1 float #else EEPROM_WRITE(dummyf); @@ -979,7 +1025,7 @@ void MarlinSettings::postprocess() { #if ENABLED(Z_STEPPER_AUTO_ALIGN) EEPROM_WRITE(z_stepper_align.xy); - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY EEPROM_WRITE(z_stepper_align.stepper_xy); #endif #endif @@ -1099,6 +1145,15 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(lcd_brightness); } + // + // LCD Backlight / Sleep Timeout + // + #if LCD_BACKLIGHT_TIMEOUT + EEPROM_WRITE(ui.lcd_backlight_timeout); + #elif HAS_DISPLAY_SLEEP + EEPROM_WRITE(ui.sleep_timeout_minutes); + #endif + // // Controller Fan // @@ -1107,7 +1162,7 @@ void MarlinSettings::postprocess() { #if ENABLED(USE_CONTROLLER_FAN) const controllerFan_settings_t &cfs = controllerFan.settings; #else - controllerFan_settings_t cfs = controllerFan_defaults; + constexpr controllerFan_settings_t cfs = controllerFan_defaults; #endif EEPROM_WRITE(cfs); } @@ -1172,7 +1227,7 @@ void MarlinSettings::postprocess() { { _FIELD_TEST(tmc_stepper_current); - tmc_stepper_current_t tmc_stepper_current{0}; + per_stepper_uint16_t tmc_stepper_current{0}; #if HAS_TRINAMIC_CONFIG #if AXIS_IS_TMC(X) @@ -1243,7 +1298,7 @@ void MarlinSettings::postprocess() { _FIELD_TEST(tmc_hybrid_threshold); #if ENABLED(HYBRID_THRESHOLD) - tmc_hybrid_threshold_t tmc_hybrid_threshold{0}; + per_stepper_uint32_t tmc_hybrid_threshold{0}; TERN_(X_HAS_STEALTHCHOP, tmc_hybrid_threshold.X = stepperX.get_pwm_thrs()); TERN_(Y_HAS_STEALTHCHOP, tmc_hybrid_threshold.Y = stepperY.get_pwm_thrs()); TERN_(Z_HAS_STEALTHCHOP, tmc_hybrid_threshold.Z = stepperZ.get_pwm_thrs()); @@ -1265,7 +1320,7 @@ void MarlinSettings::postprocess() { TERN_(E7_HAS_STEALTHCHOP, tmc_hybrid_threshold.E7 = stepperE7.get_pwm_thrs()); #else #define _EN_ITEM(N) , .E##N = 30 - const tmc_hybrid_threshold_t tmc_hybrid_threshold = { + const per_stepper_uint32_t tmc_hybrid_threshold = { LINEAR_AXIS_LIST(.X = 100, .Y = 100, .Z = 3, .I = 3, .J = 3, .K = 3), .X2 = 100, .Y2 = 100, .Z2 = 3, .Z3 = 3, .Z4 = 3 REPEAT(E_STEPPERS, _EN_ITEM) @@ -1279,7 +1334,7 @@ void MarlinSettings::postprocess() { // TMC StallGuard threshold // { - tmc_sgt_t tmc_sgt{0}; + mot_stepper_int16_t tmc_sgt{0}; #if USE_SENSORLESS LINEAR_AXIS_CODE( TERN_(X_SENSORLESS, tmc_sgt.X = stepperX.homing_threshold()), @@ -1304,7 +1359,7 @@ void MarlinSettings::postprocess() { { _FIELD_TEST(tmc_stealth_enabled); - tmc_stealth_enabled_t tmc_stealth_enabled = { false }; + per_stepper_bool_t tmc_stealth_enabled = { false }; TERN_(X_HAS_STEALTHCHOP, tmc_stealth_enabled.X = stepperX.get_stored_stealthChop()); TERN_(Y_HAS_STEALTHCHOP, tmc_stealth_enabled.Y = stepperY.get_stored_stealthChop()); TERN_(Z_HAS_STEALTHCHOP, tmc_stealth_enabled.Z = stepperZ.get_stored_stealthChop()); @@ -1399,14 +1454,15 @@ void MarlinSettings::postprocess() { // { #if ENABLED(BACKLASH_GCODE) - const xyz_float_t &backlash_distance_mm = backlash.distance_mm; - const uint8_t &backlash_correction = backlash.correction; + xyz_float_t backlash_distance_mm; + LOOP_LINEAR_AXES(axis) backlash_distance_mm[axis] = backlash.get_distance_mm((AxisEnum)axis); + const uint8_t backlash_correction = backlash.get_correction_uint8(); #else const xyz_float_t backlash_distance_mm{0}; const uint8_t backlash_correction = 0; #endif #if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM) - const float &backlash_smoothing_mm = backlash.smoothing_mm; + const float backlash_smoothing_mm = backlash.get_smoothing_mm(); #else const float backlash_smoothing_mm = 3; #endif @@ -1431,18 +1487,20 @@ void MarlinSettings::postprocess() { // // Creality DWIN User Data // - #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(DWIN_LCD_PROUI) { - char dwin_data[eeprom_data_size] = { 0 }; - DWIN_StoreSettings(dwin_data); _FIELD_TEST(dwin_data); + char dwin_data[eeprom_data_size] = { 0 }; + DWIN_CopySettingsTo(dwin_data); EEPROM_WRITE(dwin_data); } - #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) + #endif + + #if ENABLED(DWIN_CREALITY_LCD_JYERSUI) { + _FIELD_TEST(dwin_settings); char dwin_settings[CrealityDWIN.eeprom_data_size] = { 0 }; CrealityDWIN.Save_Settings(dwin_settings); - _FIELD_TEST(dwin_settings); EEPROM_WRITE(dwin_settings); } #endif @@ -1492,7 +1550,7 @@ void MarlinSettings::postprocess() { // Buzzer enable/disable // #if ENABLED(SOUND_MENU_ITEM) - EEPROM_WRITE(ui.buzzer_enabled); + EEPROM_WRITE(ui.sound_on); #endif // @@ -1519,6 +1577,14 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(ui.language); #endif + // + // Model predictive control + // + #if ENABLED(MPCTEMP) + HOTEND_LOOP() + EEPROM_WRITE(thermalManager.temp_hotend[e].constants); + #endif + // // Report final CRC and Data Size // @@ -1546,13 +1612,16 @@ void MarlinSettings::postprocess() { // UBL Mesh // #if ENABLED(UBL_SAVE_ACTIVE_ON_M500) - if (ubl.storage_slot >= 0) - store_mesh(ubl.storage_slot); + if (bedlevel.storage_slot >= 0) + store_mesh(bedlevel.storage_slot); #endif - if (!eeprom_error) LCD_MESSAGE(MSG_SETTINGS_STORED); + if (!eeprom_error) { + LCD_MESSAGE(MSG_SETTINGS_STORED); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_SETTINGS_STORED))); + } - TERN_(EXTENSIBLE_UI, ExtUI::onConfigurationStoreWritten(!eeprom_error)); + TERN_(EXTENSIBLE_UI, ExtUI::onSettingsStored(!eeprom_error)); return !eeprom_error; } @@ -1573,7 +1642,8 @@ void MarlinSettings::postprocess() { stored_ver[1] = '\0'; } DEBUG_ECHO_MSG("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")"); - TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_ERR_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))); IF_DISABLED(EEPROM_AUTO_INIT, ui.eeprom_alert_version()); eeprom_error = true; @@ -1584,7 +1654,7 @@ void MarlinSettings::postprocess() { #if ENABLED(EEPROM_INIT_NOW) uint32_t stored_hash; EEPROM_READ_ALWAYS(stored_hash); - if (stored_hash != build_hash) { EEPROM_FINISH(); return true; } + if (stored_hash != build_hash) { EEPROM_FINISH(); return false; } #endif uint16_t stored_crc; @@ -1700,20 +1770,20 @@ void MarlinSettings::postprocess() { EEPROM_READ_ALWAYS(mesh_num_y); #if ENABLED(MESH_BED_LEVELING) - if (!validating) mbl.z_offset = dummyf; + 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(mbl.z_values); + EEPROM_READ(bedlevel.z_values); } else { // EEPROM data is stale - if (!validating) mbl.reset(); + if (!validating) bedlevel.reset(); for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummyf); } #else // MBL is disabled - skip the stored data for (uint16_t q = mesh_num_x * mesh_num_y; q--;) EEPROM_READ(dummyf); - #endif // MESH_BED_LEVELING + #endif } // @@ -1747,27 +1817,33 @@ 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 + xy_pos_t spacing, start; + EEPROM_READ(spacing); // 2 ints + EEPROM_READ(start); // 2 ints #if ENABLED(AUTO_BED_LEVELING_BILINEAR) if (grid_max_x == (GRID_MAX_POINTS_X) && grid_max_y == (GRID_MAX_POINTS_Y)) { if (!validating) set_bed_leveling_enabled(false); - EEPROM_READ(bilinear_grid_spacing); // 2 ints - EEPROM_READ(bilinear_start); // 2 ints - EEPROM_READ(z_values); // 9 to 256 floats - #if ENABLED(X_AXIS_TWIST_COMPENSATION) - EEPROM_READ(xatc); - #endif + bedlevel.set_grid(spacing, start); + EEPROM_READ(bedlevel.z_values); // 9 to 256 floats } else // EEPROM data is stale #endif // AUTO_BED_LEVELING_BILINEAR { // Skip past disabled (or stale) Bilinear Grid data - xy_pos_t bgs, bs; - EEPROM_READ(bgs); - EEPROM_READ(bs); for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_READ(dummyf); } } + // + // X Axis Twist Compensation + // + #if ENABLED(X_AXIS_TWIST_COMPENSATION) + _FIELD_TEST(xatc_spacing); + EEPROM_READ(xatc.spacing); + EEPROM_READ(xatc.start); + EEPROM_READ(xatc.z_offset); + #endif + // // Unified Bed Leveling active state // @@ -1775,7 +1851,7 @@ void MarlinSettings::postprocess() { _FIELD_TEST(planner_leveling_active); #if ENABLED(AUTO_BED_LEVELING_UBL) const bool &planner_leveling_active = planner.leveling_active; - const int8_t &ubl_storage_slot = ubl.storage_slot; + const int8_t &ubl_storage_slot = bedlevel.storage_slot; #else bool planner_leveling_active; int8_t ubl_storage_slot; @@ -1867,12 +1943,12 @@ void MarlinSettings::postprocess() { EEPROM_READ(TERN(Y_DUAL_ENDSTOPS, endstops.y2_endstop_adj, dummyf)); // 1 float EEPROM_READ(TERN(Z_MULTI_ENDSTOPS, endstops.z2_endstop_adj, dummyf)); // 1 float - #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 + #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPERS >= 3 EEPROM_READ(endstops.z3_endstop_adj); // 1 float #else EEPROM_READ(dummyf); #endif - #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4 + #if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPERS >= 4 EEPROM_READ(endstops.z4_endstop_adj); // 1 float #else EEPROM_READ(dummyf); @@ -1882,7 +1958,7 @@ void MarlinSettings::postprocess() { #if ENABLED(Z_STEPPER_AUTO_ALIGN) EEPROM_READ(z_stepper_align.xy); - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) + #if HAS_Z_STEPPER_ALIGN_STEPPER_XY EEPROM_READ(z_stepper_align.stepper_xy); #endif #endif @@ -1965,8 +2041,10 @@ void MarlinSettings::postprocess() { // #if HAS_USER_THERMISTORS { + user_thermistor_t user_thermistor[USER_THERMISTORS]; _FIELD_TEST(user_thermistor); - EEPROM_READ(thermalManager.user_thermistor); + EEPROM_READ(user_thermistor); + if (!validating) COPY(thermalManager.user_thermistor, user_thermistor); } #endif @@ -1974,80 +2052,76 @@ void MarlinSettings::postprocess() { // Power monitor // { - #if HAS_POWER_MONITOR - uint8_t &power_monitor_flags = power_monitor.flags; - #else - uint8_t power_monitor_flags; - #endif + uint8_t power_monitor_flags; _FIELD_TEST(power_monitor_flags); EEPROM_READ(power_monitor_flags); + TERN_(HAS_POWER_MONITOR, if (!validating) power_monitor.flags = power_monitor_flags); } // // LCD Contrast // { - _FIELD_TEST(lcd_contrast); uint8_t lcd_contrast; + _FIELD_TEST(lcd_contrast); EEPROM_READ(lcd_contrast); - if (!validating) { - TERN_(HAS_LCD_CONTRAST, ui.set_contrast(lcd_contrast)); - } + TERN_(HAS_LCD_CONTRAST, if (!validating) ui.contrast = lcd_contrast); } // // LCD Brightness // { - _FIELD_TEST(lcd_brightness); uint8_t lcd_brightness; + _FIELD_TEST(lcd_brightness); EEPROM_READ(lcd_brightness); - TERN_(HAS_LCD_BRIGHTNESS, if (!validating) ui.set_brightness(lcd_brightness)); + TERN_(HAS_LCD_BRIGHTNESS, if (!validating) ui.brightness = lcd_brightness); } + // + // LCD Backlight / Sleep Timeout + // + #if LCD_BACKLIGHT_TIMEOUT + EEPROM_READ(ui.lcd_backlight_timeout); + #elif HAS_DISPLAY_SLEEP + EEPROM_READ(ui.sleep_timeout_minutes); + #endif + // // Controller Fan // { + controllerFan_settings_t cfs = { 0 }; _FIELD_TEST(controllerFan_settings); - #if ENABLED(CONTROLLER_FAN_EDITABLE) - const controllerFan_settings_t &cfs = controllerFan.settings; - #else - controllerFan_settings_t cfs = { 0 }; - #endif EEPROM_READ(cfs); + TERN_(CONTROLLER_FAN_EDITABLE, if (!validating) controllerFan.settings = cfs); } // // Power-Loss Recovery // { + bool recovery_enabled; _FIELD_TEST(recovery_enabled); - #if ENABLED(POWER_LOSS_RECOVERY) - const bool &recovery_enabled = recovery.enabled; - #else - bool recovery_enabled; - #endif EEPROM_READ(recovery_enabled); + TERN_(POWER_LOSS_RECOVERY, if (!validating) recovery.enabled = recovery_enabled); } // // Firmware Retraction // { + fwretract_settings_t fwretract_settings; + bool autoretract_enabled; _FIELD_TEST(fwretract_settings); + EEPROM_READ(fwretract_settings); + EEPROM_READ(autoretract_enabled); #if ENABLED(FWRETRACT) - EEPROM_READ(fwretract.settings); - #else - fwretract_settings_t fwretract_settings; - EEPROM_READ(fwretract_settings); - #endif - #if BOTH(FWRETRACT, FWRETRACT_AUTORETRACT) - EEPROM_READ(fwretract.autoretract_enabled); - #else - bool autoretract_enabled; - EEPROM_READ(autoretract_enabled); + if (!validating) { + fwretract.settings = fwretract_settings; + TERN_(FWRETRACT_AUTORETRACT, fwretract.autoretract_enabled = autoretract_enabled); + } #endif } @@ -2085,7 +2159,7 @@ void MarlinSettings::postprocess() { { _FIELD_TEST(tmc_stepper_current); - tmc_stepper_current_t currents; + per_stepper_uint16_t currents; EEPROM_READ(currents); #if HAS_TRINAMIC_CONFIG @@ -2155,7 +2229,7 @@ void MarlinSettings::postprocess() { // TMC Hybrid Threshold { - tmc_hybrid_threshold_t tmc_hybrid_threshold; + per_stepper_uint32_t tmc_hybrid_threshold; _FIELD_TEST(tmc_hybrid_threshold); EEPROM_READ(tmc_hybrid_threshold); @@ -2188,7 +2262,7 @@ void MarlinSettings::postprocess() { // TMC StallGuard threshold. // { - tmc_sgt_t tmc_sgt; + mot_stepper_int16_t tmc_sgt; _FIELD_TEST(tmc_sgt); EEPROM_READ(tmc_sgt); #if USE_SENSORLESS @@ -2214,7 +2288,7 @@ void MarlinSettings::postprocess() { { _FIELD_TEST(tmc_stealth_enabled); - tmc_stealth_enabled_t tmc_stealth_enabled; + per_stepper_bool_t tmc_stealth_enabled; EEPROM_READ(tmc_stealth_enabled); #if HAS_TRINAMIC_CONFIG @@ -2337,22 +2411,22 @@ void MarlinSettings::postprocess() { // Backlash Compensation // { - #if ENABLED(BACKLASH_GCODE) - const xyz_float_t &backlash_distance_mm = backlash.distance_mm; - const uint8_t &backlash_correction = backlash.correction; - #else - xyz_float_t backlash_distance_mm; - uint8_t backlash_correction; - #endif - #if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM) - const float &backlash_smoothing_mm = backlash.smoothing_mm; - #else - float backlash_smoothing_mm; - #endif + xyz_float_t backlash_distance_mm; + uint8_t backlash_correction; + float backlash_smoothing_mm; + _FIELD_TEST(backlash_distance_mm); EEPROM_READ(backlash_distance_mm); EEPROM_READ(backlash_correction); EEPROM_READ(backlash_smoothing_mm); + + #if ENABLED(BACKLASH_GCODE) + LOOP_LINEAR_AXES(axis) backlash.set_distance_mm((AxisEnum)axis, backlash_distance_mm[axis]); + backlash.set_correction_uint8(backlash_correction); + #ifdef BACKLASH_SMOOTHING_MM + backlash.set_smoothing_mm(backlash_smoothing_mm); + #endif + #endif } // @@ -2370,12 +2444,12 @@ void MarlinSettings::postprocess() { // // Creality DWIN User Data // - #if ENABLED(DWIN_CREALITY_LCD_ENHANCED) + #if ENABLED(DWIN_LCD_PROUI) { const char dwin_data[eeprom_data_size] = { 0 }; _FIELD_TEST(dwin_data); EEPROM_READ(dwin_data); - if (!validating) DWIN_LoadSettings(dwin_data); + if (!validating) DWIN_CopySettingsFrom(dwin_data); } #elif ENABLED(DWIN_CREALITY_LCD_JYERSUI) { @@ -2428,8 +2502,8 @@ void MarlinSettings::postprocess() { // Buzzer enable/disable // #if ENABLED(SOUND_MENU_ITEM) - _FIELD_TEST(buzzer_enabled); - EEPROM_READ(ui.buzzer_enabled); + _FIELD_TEST(sound_on); + EEPROM_READ(ui.sound_on); #endif // @@ -2463,6 +2537,16 @@ void MarlinSettings::postprocess() { } #endif + // + // Model predictive control + // + #if ENABLED(MPCTEMP) + { + HOTEND_LOOP() + EEPROM_READ(thermalManager.temp_hotend[e].constants); + } + #endif + // // Validate Final Size and CRC // @@ -2474,24 +2558,26 @@ void MarlinSettings::postprocess() { else if (working_crc != stored_crc) { eeprom_error = true; DEBUG_ERROR_MSG("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!"); - TERN_(DWIN_CREALITY_LCD_ENHANCED, LCD_MESSAGE(MSG_ERR_EEPROM_CRC)); + 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()); } else if (!validating) { DEBUG_ECHO_START(); DEBUG_ECHO(version); DEBUG_ECHOLNPGM(" stored settings retrieved (", eeprom_index - (EEPROM_OFFSET), " bytes; crc ", (uint32_t)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) { - ubl.report_state(); + bedlevel.report_state(); - if (!ubl.sanity_check()) { + if (!bedlevel.sanity_check()) { #if BOTH(EEPROM_CHITCHAT, DEBUG_LEVELING_FEATURE) - ubl.echo_name(); + bedlevel.echo_name(); DEBUG_ECHOLNPGM(" initialized.\n"); #endif } @@ -2499,18 +2585,18 @@ void MarlinSettings::postprocess() { eeprom_error = true; #if BOTH(EEPROM_CHITCHAT, DEBUG_LEVELING_FEATURE) DEBUG_ECHOPGM("?Can't enable "); - ubl.echo_name(); + bedlevel.echo_name(); DEBUG_ECHOLNPGM("."); #endif - ubl.reset(); + bedlevel.reset(); } - if (ubl.storage_slot >= 0) { - load_mesh(ubl.storage_slot); - DEBUG_ECHOLNPGM("Mesh ", ubl.storage_slot, " loaded from storage."); + if (bedlevel.storage_slot >= 0) { + load_mesh(bedlevel.storage_slot); + DEBUG_ECHOLNPGM("Mesh ", bedlevel.storage_slot, " loaded from storage."); } else { - ubl.reset(); + bedlevel.reset(); DEBUG_ECHOLNPGM("UBL reset"); } } @@ -2549,7 +2635,7 @@ void MarlinSettings::postprocess() { bool MarlinSettings::load() { if (validate()) { const bool success = _load(); - TERN_(EXTENSIBLE_UI, ExtUI::onConfigurationStoreRead(success)); + TERN_(EXTENSIBLE_UI, ExtUI::onSettingsLoaded(success)); return success; } reset(); @@ -2578,7 +2664,7 @@ void MarlinSettings::postprocess() { return (datasize() + EEPROM_OFFSET + 32) & 0xFFF8; } - #define MESH_STORE_SIZE sizeof(TERN(OPTIMIZED_MESH_STORAGE, mesh_store_t, ubl.z_values)) + #define MESH_STORE_SIZE sizeof(TERN(OPTIMIZED_MESH_STORAGE, mesh_store_t, bedlevel.z_values)) uint16_t MarlinSettings::calc_num_meshes() { return (meshes_end - meshes_start_index()) / MESH_STORE_SIZE; @@ -2604,10 +2690,10 @@ void MarlinSettings::postprocess() { #if ENABLED(OPTIMIZED_MESH_STORAGE) int16_t z_mesh_store[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; - ubl.set_store_from_mesh(ubl.z_values, z_mesh_store); + bedlevel.set_store_from_mesh(bedlevel.z_values, z_mesh_store); uint8_t * const src = (uint8_t*)&z_mesh_store; #else - uint8_t * const src = (uint8_t*)&ubl.z_values; + uint8_t * const src = (uint8_t*)&bedlevel.z_values; #endif // Write crc to MAT along with other data, or just tack on to the beginning or end @@ -2642,7 +2728,7 @@ void MarlinSettings::postprocess() { int16_t z_mesh_store[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; uint8_t * const dest = (uint8_t*)&z_mesh_store; #else - uint8_t * const dest = into ? (uint8_t*)into : (uint8_t*)&ubl.z_values; + uint8_t * const dest = into ? (uint8_t*)into : (uint8_t*)&bedlevel.z_values; #endif persistentStore.access_start(); @@ -2652,11 +2738,11 @@ void MarlinSettings::postprocess() { #if ENABLED(OPTIMIZED_MESH_STORAGE) if (into) { float z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y]; - ubl.set_mesh_from_store(z_mesh_store, z_values); + bedlevel.set_mesh_from_store(z_mesh_store, z_values); memcpy(into, z_values, sizeof(z_values)); } else - ubl.set_mesh_from_store(z_mesh_store, ubl.z_values); + bedlevel.set_mesh_from_store(z_mesh_store, bedlevel.z_values); #endif if (status) SERIAL_ECHOLNPGM("?Unable to load mesh data."); @@ -2712,13 +2798,13 @@ void MarlinSettings::reset() { #if HAS_Z_AXIS && !defined(DEFAULT_ZJERK) #define DEFAULT_ZJERK 0 #endif - #if LINEAR_AXES >= 4 && !defined(DEFAULT_IJERK) + #if HAS_I_AXIS && !defined(DEFAULT_IJERK) #define DEFAULT_IJERK 0 #endif - #if LINEAR_AXES >= 5 && !defined(DEFAULT_JJERK) + #if HAS_J_AXIS && !defined(DEFAULT_JJERK) #define DEFAULT_JJERK 0 #endif - #if LINEAR_AXES >= 6 && !defined(DEFAULT_KJERK) + #if HAS_K_AXIS && !defined(DEFAULT_KJERK) #define DEFAULT_KJERK 0 #endif planner.max_jerk.set( @@ -2782,16 +2868,14 @@ void MarlinSettings::reset() { #endif #if ENABLED(BACKLASH_GCODE) - backlash.correction = (BACKLASH_CORRECTION) * 255; + backlash.set_correction(BACKLASH_CORRECTION); constexpr xyz_float_t tmp = BACKLASH_DISTANCE_MM; - backlash.distance_mm = tmp; + LOOP_LINEAR_AXES(axis) backlash.set_distance_mm((AxisEnum)axis, tmp[axis]); #ifdef BACKLASH_SMOOTHING_MM - backlash.smoothing_mm = BACKLASH_SMOOTHING_MM; + backlash.set_smoothing_mm(BACKLASH_SMOOTHING_MM); #endif #endif - TERN_(EXTENSIBLE_UI, ExtUI::onFactoryReset()); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_SetDataDefaults()); TERN_(DWIN_CREALITY_LCD_JYERSUI, CrealityDWIN.Reset_Settings()); // @@ -2807,7 +2891,9 @@ void MarlinSettings::reset() { // // Buzzer enable/disable // - TERN_(SOUND_MENU_ITEM, ui.buzzer_enabled = true); + #if ENABLED(SOUND_MENU_ITEM) + ui.sound_on = ENABLED(SOUND_ON_DEFAULT); + #endif // // Magnetic Parking Extruder @@ -2820,6 +2906,14 @@ void MarlinSettings::reset() { TERN_(ENABLE_LEVELING_FADE_HEIGHT, new_z_fade_height = (DEFAULT_LEVELING_FADE_HEIGHT)); TERN_(HAS_LEVELING, reset_bed_level()); + // + // X Axis Twist Compensation + // + TERN_(X_AXIS_TWIST_COMPENSATION, xatc.reset()); + + // + // Nozzle-to-probe Offset + // #if HAS_BED_PROBE constexpr float dpo[] = NOZZLE_TO_PROBE_OFFSET; static_assert(COUNT(dpo) == LINEAR_AXES, "NOZZLE_TO_PROBE_OFFSET must contain offsets for each linear axis X, Y, Z...."); @@ -2896,13 +2990,13 @@ void MarlinSettings::reset() { #define Z2_ENDSTOP_ADJUSTMENT 0 #endif endstops.z2_endstop_adj = Z2_ENDSTOP_ADJUSTMENT; - #if NUM_Z_STEPPER_DRIVERS >= 3 + #if NUM_Z_STEPPERS >= 3 #ifndef Z3_ENDSTOP_ADJUSTMENT #define Z3_ENDSTOP_ADJUSTMENT 0 #endif endstops.z3_endstop_adj = Z3_ENDSTOP_ADJUSTMENT; #endif - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 #ifndef Z4_ENDSTOP_ADJUSTMENT #define Z4_ENDSTOP_ADJUSTMENT 0 #endif @@ -3030,12 +3124,21 @@ void MarlinSettings::reset() { // // LCD Contrast // - TERN_(HAS_LCD_CONTRAST, ui.set_contrast(DEFAULT_LCD_CONTRAST)); + TERN_(HAS_LCD_CONTRAST, ui.contrast = LCD_CONTRAST_DEFAULT); // // LCD Brightness // - TERN_(HAS_LCD_BRIGHTNESS, ui.set_brightness(DEFAULT_LCD_BRIGHTNESS)); + TERN_(HAS_LCD_BRIGHTNESS, ui.brightness = LCD_BRIGHTNESS_DEFAULT); + + // + // LCD Backlight / Sleep Timeout + // + #if LCD_BACKLIGHT_TIMEOUT + ui.lcd_backlight_timeout = LCD_BACKLIGHT_TIMEOUT; + #elif HAS_DISPLAY_SLEEP + ui.sleep_timeout_minutes = DISPLAY_SLEEP_MINUTES; + #endif // // Controller Fan @@ -3075,9 +3178,9 @@ void MarlinSettings::reset() { // #if ENABLED(LIN_ADVANCE) - LOOP_L_N(i, EXTRUDERS) { - planner.extruder_advance_K[i] = LIN_ADVANCE_K; - TERN_(EXTRA_LIN_ADVANCE_K, other_extruder_advance_K[i] = LIN_ADVANCE_K); + EXTRUDER_LOOP() { + planner.extruder_advance_K[e] = LIN_ADVANCE_K; + TERN_(EXTRA_LIN_ADVANCE_K, other_extruder_advance_K[e] = LIN_ADVANCE_K); } #endif @@ -3122,7 +3225,7 @@ void MarlinSettings::reset() { // Advanced Pause filament load & unload lengths // #if ENABLED(ADVANCED_PAUSE_FEATURE) - LOOP_L_N(e, EXTRUDERS) { + EXTRUDER_LOOP() { fc_settings[e].unload_length = FILAMENT_CHANGE_UNLOAD_LENGTH; fc_settings[e].load_length = FILAMENT_CHANGE_FAST_LOAD_LENGTH; } @@ -3147,9 +3250,54 @@ void MarlinSettings::reset() { // TERN_(DGUS_LCD_UI_MKS, MKS_reset_settings()); + // + // Ender-3 V2 with ProUI + // + TERN_(DWIN_LCD_PROUI, DWIN_SetDataDefaults()); + + // + // Model predictive control + // + #if ENABLED(MPCTEMP) + constexpr float _mpc_heater_power[] = MPC_HEATER_POWER; + constexpr float _mpc_block_heat_capacity[] = MPC_BLOCK_HEAT_CAPACITY; + constexpr float _mpc_sensor_responsiveness[] = MPC_SENSOR_RESPONSIVENESS; + constexpr float _mpc_ambient_xfer_coeff[] = MPC_AMBIENT_XFER_COEFF; + #if ENABLED(MPC_INCLUDE_FAN) + constexpr float _mpc_ambient_xfer_coeff_fan255[] = MPC_AMBIENT_XFER_COEFF_FAN255; + #endif + constexpr float _filament_heat_capacity_permm[] = FILAMENT_HEAT_CAPACITY_PERMM; + + static_assert(COUNT(_mpc_heater_power) == HOTENDS, "MPC_HEATER_POWER must have HOTENDS items."); + static_assert(COUNT(_mpc_block_heat_capacity) == HOTENDS, "MPC_BLOCK_HEAT_CAPACITY must have HOTENDS items."); + static_assert(COUNT(_mpc_sensor_responsiveness) == HOTENDS, "MPC_SENSOR_RESPONSIVENESS must have HOTENDS items."); + static_assert(COUNT(_mpc_ambient_xfer_coeff) == HOTENDS, "MPC_AMBIENT_XFER_COEFF must have HOTENDS items."); + #if ENABLED(MPC_INCLUDE_FAN) + static_assert(COUNT(_mpc_ambient_xfer_coeff_fan255) == HOTENDS, "MPC_AMBIENT_XFER_COEFF_FAN255 must have HOTENDS items."); + #endif + 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]; + #if ENABLED(MPC_INCLUDE_FAN) + thermalManager.temp_hotend[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]; + } + #endif + postprocess(); - DEBUG_ECHO_MSG("Hardcoded Default Settings Loaded"); + #if EITHER(EEPROM_CHITCHAT, DEBUG_LEVELING_FEATURE) + FSTR_P const hdsl = F("Hardcoded Default Settings Loaded"); + TERN_(HOST_EEPROM_CHITCHAT, hostui.notify(hdsl)); + DEBUG_ECHO_START(); DEBUG_ECHOLNF(hdsl); + #endif + + TERN_(EXTENSIBLE_UI, ExtUI::onFactoryReset()); } #if DISABLED(DISABLE_M503) @@ -3243,24 +3391,25 @@ void MarlinSettings::reset() { LOOP_L_N(px, GRID_MAX_POINTS_X) { CONFIG_ECHO_START(); SERIAL_ECHOPGM(" G29 S3 I", px, " J", py); - SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(mbl.z_values[px][py]), 5); + SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(bedlevel.z_values[px][py]), 5); } } CONFIG_ECHO_START(); - SERIAL_ECHOLNPAIR_F(" G29 S4 Z", LINEAR_UNIT(mbl.z_offset), 5); + SERIAL_ECHOLNPAIR_F(" G29 S4 Z", LINEAR_UNIT(bedlevel.z_offset), 5); } #elif ENABLED(AUTO_BED_LEVELING_UBL) if (!forReplay) { SERIAL_EOL(); - ubl.report_state(); - SERIAL_ECHO_MSG("Active Mesh Slot ", ubl.storage_slot); + bedlevel.report_state(); + SERIAL_ECHO_MSG("Active Mesh Slot ", bedlevel.storage_slot); SERIAL_ECHO_MSG("EEPROM can hold ", calc_num_meshes(), " meshes.\n"); } - //ubl.report_current_mesh(); // This is too verbose for large meshes. A better (more terse) - // solution needs to be found. + //bedlevel.report_current_mesh(); // This is too verbose for large meshes. A better (more terse) + // solution needs to be found. + #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) if (leveling_is_valid()) { @@ -3268,21 +3417,20 @@ void MarlinSettings::reset() { LOOP_L_N(px, GRID_MAX_POINTS_X) { CONFIG_ECHO_START(); SERIAL_ECHOPGM(" G29 W I", px, " J", py); - SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(z_values[px][py]), 5); + SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, LINEAR_UNIT(bedlevel.z_values[px][py]), 5); } } } - // TODO: Create G-code for settings - //#if ENABLED(X_AXIS_TWIST_COMPENSATION) - // CONFIG_ECHO_START(); - // xatc.print_points(); - //#endif - #endif #endif // HAS_LEVELING + // + // X Axis Twist Compensation + // + TERN_(X_AXIS_TWIST_COMPENSATION, gcode.M423_report(forReplay)); + // // Editable Servo Angles // @@ -3329,6 +3477,11 @@ void MarlinSettings::reset() { // TERN_(HAS_LCD_CONTRAST, gcode.M250_report(forReplay)); + // + // Display Sleep + // + TERN_(HAS_GCODE_M255, gcode.M255_report(forReplay)); + // // LCD Brightness // @@ -3427,6 +3580,11 @@ void MarlinSettings::reset() { #endif TERN_(HAS_MULTI_LANGUAGE, gcode.M414_report(forReplay)); + + // + // Model predictive control + // + TERN_(MPCTEMP, gcode.M306_report(forReplay)); } #endif // !DISABLE_M503 diff --git a/Marlin/src/module/settings.h b/Marlin/src/module/settings.h index 967d49c0738e..a8fca60baa12 100644 --- a/Marlin/src/module/settings.h +++ b/Marlin/src/module/settings.h @@ -59,7 +59,7 @@ class MarlinSettings { static bool load(); // Return 'true' if data was loaded ok static bool validate(); // Return 'true' if EEPROM data is ok - static inline void first_load() { + static void first_load() { static bool loaded = false; if (!loaded && load()) loaded = true; } diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index c100051f9808..66cf7a535888 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -84,7 +84,7 @@ Stepper stepper; // Singleton #define BABYSTEPPING_EXTRA_DIR_WAIT #ifdef __AVR__ - #include "speed_lookuptable.h" + #include "stepper/speed_lookuptable.h" #endif #include "endstops.h" @@ -153,7 +153,7 @@ Stepper stepper; // Singleton #endif #endif -axis_flags_t Stepper::axis_enabled; // {0} +stepper_flags_t Stepper::axis_enabled; // {0} // private: @@ -177,9 +177,9 @@ bool Stepper::abort_current_block; #if EITHER(Z_MULTI_ENDSTOPS, Z_STEPPER_AUTO_ALIGN) bool Stepper::locked_Z_motor = false, Stepper::locked_Z2_motor = false - #if NUM_Z_STEPPER_DRIVERS >= 3 + #if NUM_Z_STEPPERS >= 3 , Stepper::locked_Z3_motor = false - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 , Stepper::locked_Z4_motor = false #endif #endif @@ -189,7 +189,7 @@ bool Stepper::abort_current_block; uint32_t Stepper::acceleration_time, Stepper::deceleration_time; uint8_t Stepper::steps_per_isr; -#if HAS_FREEZE_PIN +#if ENABLED(FREEZE_FEATURE) bool Stepper::frozen; // = false #endif @@ -365,7 +365,7 @@ xyze_int8_t Stepper::count_direction{0}; A##4_STEP_WRITE(V); \ } -#if ENABLED(X_DUAL_STEPPER_DRIVERS) +#if HAS_DUAL_X_STEPPERS #define X_APPLY_DIR(v,Q) do{ X_DIR_WRITE(v); X2_DIR_WRITE((v) ^ ENABLED(INVERT_X2_VS_X_DIR)); }while(0) #if ENABLED(X_DUAL_ENDSTOPS) #define X_APPLY_STEP(v,Q) DUAL_ENDSTOP_APPLY_STEP(X,v) @@ -386,7 +386,7 @@ xyze_int8_t Stepper::count_direction{0}; #define X_APPLY_STEP(v,Q) X_STEP_WRITE(v) #endif -#if ENABLED(Y_DUAL_STEPPER_DRIVERS) +#if HAS_DUAL_Y_STEPPERS #define Y_APPLY_DIR(v,Q) do{ Y_DIR_WRITE(v); Y2_DIR_WRITE((v) ^ ENABLED(INVERT_Y2_VS_Y_DIR)); }while(0) #if ENABLED(Y_DUAL_ENDSTOPS) #define Y_APPLY_STEP(v,Q) DUAL_ENDSTOP_APPLY_STEP(Y,v) @@ -398,7 +398,7 @@ xyze_int8_t Stepper::count_direction{0}; #define Y_APPLY_STEP(v,Q) Y_STEP_WRITE(v) #endif -#if NUM_Z_STEPPER_DRIVERS == 4 +#if NUM_Z_STEPPERS == 4 #define Z_APPLY_DIR(v,Q) do{ \ Z_DIR_WRITE(v); Z2_DIR_WRITE((v) ^ ENABLED(INVERT_Z2_VS_Z_DIR)); \ Z3_DIR_WRITE((v) ^ ENABLED(INVERT_Z3_VS_Z_DIR)); Z4_DIR_WRITE((v) ^ ENABLED(INVERT_Z4_VS_Z_DIR)); \ @@ -410,7 +410,7 @@ xyze_int8_t Stepper::count_direction{0}; #else #define Z_APPLY_STEP(v,Q) do{ Z_STEP_WRITE(v); Z2_STEP_WRITE(v); Z3_STEP_WRITE(v); Z4_STEP_WRITE(v); }while(0) #endif -#elif NUM_Z_STEPPER_DRIVERS == 3 +#elif NUM_Z_STEPPERS == 3 #define Z_APPLY_DIR(v,Q) do{ \ Z_DIR_WRITE(v); Z2_DIR_WRITE((v) ^ ENABLED(INVERT_Z2_VS_Z_DIR)); Z3_DIR_WRITE((v) ^ ENABLED(INVERT_Z3_VS_Z_DIR)); \ }while(0) @@ -421,7 +421,7 @@ xyze_int8_t Stepper::count_direction{0}; #else #define Z_APPLY_STEP(v,Q) do{ Z_STEP_WRITE(v); Z2_STEP_WRITE(v); Z3_STEP_WRITE(v); }while(0) #endif -#elif NUM_Z_STEPPER_DRIVERS == 2 +#elif NUM_Z_STEPPERS == 2 #define Z_APPLY_DIR(v,Q) do{ Z_DIR_WRITE(v); Z2_DIR_WRITE((v) ^ ENABLED(INVERT_Z2_VS_Z_DIR)); }while(0) #if ENABLED(Z_MULTI_ENDSTOPS) #define Z_APPLY_STEP(v,Q) DUAL_ENDSTOP_APPLY_STEP(Z,v) @@ -435,15 +435,15 @@ xyze_int8_t Stepper::count_direction{0}; #define Z_APPLY_STEP(v,Q) Z_STEP_WRITE(v) #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #define I_APPLY_DIR(v,Q) I_DIR_WRITE(v) #define I_APPLY_STEP(v,Q) I_STEP_WRITE(v) #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #define J_APPLY_DIR(v,Q) J_DIR_WRITE(v) #define J_APPLY_STEP(v,Q) J_STEP_WRITE(v) #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #define K_APPLY_DIR(v,Q) K_DIR_WRITE(v) #define K_APPLY_STEP(v,Q) K_STEP_WRITE(v) #endif @@ -497,6 +497,9 @@ void Stepper::enable_axis(const AxisEnum axis) { bool Stepper::disable_axis(const AxisEnum axis) { mark_axis_disabled(axis); + + TERN_(DWIN_LCD_PROUI, set_axis_untrusted(axis)); // MRISCOC workaround: https://github.com/MarlinFirmware/Marlin/issues/23095 + // If all the axes that share the enabled bit are disabled const bool can_disable = can_axis_disable(axis); if (can_disable) { @@ -522,7 +525,7 @@ bool Stepper::disable_axis(const AxisEnum axis) { } } - bool Stepper::disable_extruder(E_TERN_(const uint8_t eindex)) { + bool Stepper::disable_extruder(E_TERN_(const uint8_t eindex/*=0*/)) { IF_DISABLED(HAS_MULTI_EXTRUDER, constexpr uint8_t eindex = 0); mark_axis_disabled(E_AXIS E_OPTARG(eindex)); const bool can_disable = can_axis_disable(E_AXIS E_OPTARG(eindex)); @@ -1474,7 +1477,7 @@ void Stepper::isr() { #ifndef __AVR__ // Disable interrupts, to avoid ISR preemption while we reprogram the period // (AVR enters the ISR with global interrupts disabled, so no need to do it here) - DISABLE_ISRS(); + hal.isr_off(); #endif // Program timer compare for the maximum period, so it does NOT @@ -1492,7 +1495,7 @@ void Stepper::isr() { hal_timer_t min_ticks; do { // Enable ISRs to reduce USART processing latency - ENABLE_ISRS(); + hal.isr_on(); if (!nextMainISR) pulse_phase_isr(); // 0 = Do coordinated axes Stepper pulses @@ -1576,7 +1579,7 @@ void Stepper::isr() { * is less than the current count due to something preempting between the * read and the write of the new period value). */ - DISABLE_ISRS(); + hal.isr_off(); /** * Get the current tick value + margin @@ -1611,7 +1614,7 @@ void Stepper::isr() { HAL_timer_set_compare(MF_TIMER_STEP, hal_timer_t(next_isr_ticks)); // Don't forget to finally reenable interrupts - ENABLE_ISRS(); + hal.isr_on(); } #if MINIMUM_STEPPER_PULSE || MAXIMUM_STEPPER_RATE @@ -1640,7 +1643,7 @@ void Stepper::pulse_phase_isr() { if (!current_block) return; // Skipping step processing causes motion to freeze - if (TERN0(HAS_FREEZE_PIN, frozen)) return; + if (TERN0(FREEZE_FEATURE, frozen)) return; // Count of pending loops and events for this iteration const uint32_t pending_events = step_event_count - step_events_completed; @@ -1688,7 +1691,7 @@ void Stepper::pulse_phase_isr() { const bool is_page = IS_PAGE(current_block); #if ENABLED(DIRECT_STEPPING) - // TODO (DerAndere): Add support for LINEAR_AXES >= 4 + // Direct stepping is currently not ready for HAS_I_AXIS if (is_page) { #if STEPPER_PAGE_FORMAT == SP_4x4D_128 @@ -1929,7 +1932,7 @@ uint32_t Stepper::block_phase_isr() { // If current block is finished, reset pointer and finalize state if (step_events_completed >= step_event_count) { #if ENABLED(DIRECT_STEPPING) - // TODO (DerAndere): Add support for LINEAR_AXES >= 4 + // Direct stepping is currently not ready for HAS_I_AXIS #if STEPPER_PAGE_FORMAT == SP_4x4D_128 #define PAGE_SEGMENT_UPDATE_POS(AXIS) \ count_position[_AXIS(AXIS)] += page_step_state.bd[_AXIS(AXIS)] - 128 * 7; @@ -2151,7 +2154,10 @@ uint32_t Stepper::block_phase_isr() { cutter.apply_power(current_block->cutter_power); #endif - TERN_(POWER_LOSS_RECOVERY, recovery.info.sdpos = current_block->sdpos); + #if ENABLED(POWER_LOSS_RECOVERY) + recovery.info.sdpos = current_block->sdpos; + recovery.info.current_position = current_block->start_position; + #endif #if ENABLED(DIRECT_STEPPING) if (IS_PAGE(current_block)) { @@ -2346,13 +2352,9 @@ uint32_t Stepper::block_phase_isr() { #endif #endif // LASER_POWER_INLINE - // At this point, we must ensure the movement about to execute isn't - // trying to force the head against a limit switch. If using interrupt- - // driven change detection, and already against a limit then no call to - // the endstop_triggered method will be done and the movement will be - // done against the endstop. So, check the limits here: If the movement - // is against the limits, the block will be marked as to be killed, and - // on the next call to this ISR, will be discarded. + // If the endstop is already pressed, endstop interrupts won't invoke + // endstop_triggered and the move will grind. So check here for a + // triggered endstop, which marks the block for discard on the next ISR. endstops.update(); #if ENABLED(Z_LATE_ENABLE) @@ -2562,19 +2564,19 @@ void Stepper::init() { TERN_(HAS_X2_DIR, X2_DIR_INIT()); #if HAS_Y_DIR Y_DIR_INIT(); - #if BOTH(Y_DUAL_STEPPER_DRIVERS, HAS_Y2_DIR) + #if BOTH(HAS_DUAL_Y_STEPPERS, HAS_Y2_DIR) Y2_DIR_INIT(); #endif #endif #if HAS_Z_DIR Z_DIR_INIT(); - #if NUM_Z_STEPPER_DRIVERS >= 2 && HAS_Z2_DIR + #if NUM_Z_STEPPERS >= 2 && HAS_Z2_DIR Z2_DIR_INIT(); #endif - #if NUM_Z_STEPPER_DRIVERS >= 3 && HAS_Z3_DIR + #if NUM_Z_STEPPERS >= 3 && HAS_Z3_DIR Z3_DIR_INIT(); #endif - #if NUM_Z_STEPPER_DRIVERS >= 4 && HAS_Z4_DIR + #if NUM_Z_STEPPERS >= 4 && HAS_Z4_DIR Z4_DIR_INIT(); #endif #endif @@ -2624,7 +2626,7 @@ void Stepper::init() { #if HAS_Y_ENABLE Y_ENABLE_INIT(); if (!Y_ENABLE_ON) Y_ENABLE_WRITE(HIGH); - #if BOTH(Y_DUAL_STEPPER_DRIVERS, HAS_Y2_ENABLE) + #if BOTH(HAS_DUAL_Y_STEPPERS, HAS_Y2_ENABLE) Y2_ENABLE_INIT(); if (!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH); #endif @@ -2632,15 +2634,15 @@ void Stepper::init() { #if HAS_Z_ENABLE Z_ENABLE_INIT(); if (!Z_ENABLE_ON) Z_ENABLE_WRITE(HIGH); - #if NUM_Z_STEPPER_DRIVERS >= 2 && HAS_Z2_ENABLE + #if NUM_Z_STEPPERS >= 2 && HAS_Z2_ENABLE Z2_ENABLE_INIT(); if (!Z_ENABLE_ON) Z2_ENABLE_WRITE(HIGH); #endif - #if NUM_Z_STEPPER_DRIVERS >= 3 && HAS_Z3_ENABLE + #if NUM_Z_STEPPERS >= 3 && HAS_Z3_ENABLE Z3_ENABLE_INIT(); if (!Z_ENABLE_ON) Z3_ENABLE_WRITE(HIGH); #endif - #if NUM_Z_STEPPER_DRIVERS >= 4 && HAS_Z4_ENABLE + #if NUM_Z_STEPPERS >= 4 && HAS_Z4_ENABLE Z4_ENABLE_INIT(); if (!Z_ENABLE_ON) Z4_ENABLE_WRITE(HIGH); #endif @@ -2703,7 +2705,7 @@ void Stepper::init() { // Init Step Pins #if HAS_X_STEP - #if EITHER(X_DUAL_STEPPER_DRIVERS, DUAL_X_CARRIAGE) + #if HAS_X2_STEPPER X2_STEP_INIT(); X2_STEP_WRITE(INVERT_X_STEP_PIN); #endif @@ -2711,7 +2713,7 @@ void Stepper::init() { #endif #if HAS_Y_STEP - #if ENABLED(Y_DUAL_STEPPER_DRIVERS) + #if HAS_DUAL_Y_STEPPERS Y2_STEP_INIT(); Y2_STEP_WRITE(INVERT_Y_STEP_PIN); #endif @@ -2719,15 +2721,15 @@ void Stepper::init() { #endif #if HAS_Z_STEP - #if NUM_Z_STEPPER_DRIVERS >= 2 + #if NUM_Z_STEPPERS >= 2 Z2_STEP_INIT(); Z2_STEP_WRITE(INVERT_Z_STEP_PIN); #endif - #if NUM_Z_STEPPER_DRIVERS >= 3 + #if NUM_Z_STEPPERS >= 3 Z3_STEP_INIT(); Z3_STEP_WRITE(INVERT_Z_STEP_PIN); #endif - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 Z4_STEP_INIT(); Z4_STEP_WRITE(INVERT_Z_STEP_PIN); #endif @@ -2963,7 +2965,7 @@ void Stepper::report_positions() { #define _ENABLE_AXIS(A) enable_axis(_AXIS(A)) #define _READ_DIR(AXIS) AXIS ##_DIR_READ() - #define _INVERT_DIR(AXIS) INVERT_## AXIS ##_DIR + #define _INVERT_DIR(AXIS) ENABLED(INVERT_## AXIS ##_DIR) #define _APPLY_DIR(AXIS, INVERT) AXIS ##_APPLY_DIR(INVERT, true) #if MINIMUM_STEPPER_PULSE @@ -2977,7 +2979,12 @@ void Stepper::report_positions() { #else #define CYCLES_EATEN_BABYSTEP 0 #endif - #define EXTRA_CYCLES_BABYSTEP (STEP_PULSE_CYCLES - (CYCLES_EATEN_BABYSTEP)) + + #if CYCLES_EATEN_BABYSTEP < STEP_PULSE_CYCLES + #define EXTRA_CYCLES_BABYSTEP (STEP_PULSE_CYCLES - (CYCLES_EATEN_BABYSTEP)) + #else + #define EXTRA_CYCLES_BABYSTEP 0 + #endif #if EXTRA_CYCLES_BABYSTEP > 20 #define _SAVE_START() const hal_timer_t pulse_start = HAL_timer_get_count(MF_TIMER_PULSE) @@ -3101,21 +3108,21 @@ void Stepper::report_positions() { I_DIR_READ(), J_DIR_READ(), K_DIR_READ() ); - X_DIR_WRITE(INVERT_X_DIR ^ z_direction); + X_DIR_WRITE(ENABLED(INVERT_X_DIR) ^ z_direction); #ifdef Y_DIR_WRITE - Y_DIR_WRITE(INVERT_Y_DIR ^ z_direction); + Y_DIR_WRITE(ENABLED(INVERT_Y_DIR) ^ z_direction); #endif #ifdef Z_DIR_WRITE - Z_DIR_WRITE(INVERT_Z_DIR ^ z_direction); + Z_DIR_WRITE(ENABLED(INVERT_Z_DIR) ^ z_direction); #endif #ifdef I_DIR_WRITE - I_DIR_WRITE(INVERT_I_DIR ^ z_direction); + I_DIR_WRITE(ENABLED(INVERT_I_DIR) ^ z_direction); #endif #ifdef J_DIR_WRITE - J_DIR_WRITE(INVERT_J_DIR ^ z_direction); + J_DIR_WRITE(ENABLED(INVERT_J_DIR) ^ z_direction); #endif #ifdef K_DIR_WRITE - K_DIR_WRITE(INVERT_K_DIR ^ z_direction); + K_DIR_WRITE(ENABLED(INVERT_K_DIR) ^ z_direction); #endif DIR_WAIT_AFTER(); @@ -3184,13 +3191,13 @@ void Stepper::report_positions() { } break; - #if LINEAR_AXES >= 4 + #if HAS_I_AXIS case I_AXIS: BABYSTEP_AXIS(I, 0, direction); break; #endif - #if LINEAR_AXES >= 5 + #if HAS_J_AXIS case J_AXIS: BABYSTEP_AXIS(J, 0, direction); break; #endif - #if LINEAR_AXES >= 6 + #if HAS_K_AXIS case K_AXIS: BABYSTEP_AXIS(K, 0, direction); break; #endif @@ -3261,7 +3268,7 @@ void Stepper::report_positions() { #elif HAS_MOTOR_CURRENT_PWM - #define _WRITE_CURRENT_PWM(P) set_pwm_duty(pin_t(MOTOR_CURRENT_PWM_## P ##_PIN), 255L * current / (MOTOR_CURRENT_PWM_RANGE)) + #define _WRITE_CURRENT_PWM(P) hal.set_pwm_duty(pin_t(MOTOR_CURRENT_PWM_## P ##_PIN), 255L * current / (MOTOR_CURRENT_PWM_RANGE)) switch (driver) { case 0: #if PIN_EXISTS(MOTOR_CURRENT_PWM_X) @@ -3306,34 +3313,37 @@ void Stepper::report_positions() { #elif HAS_MOTOR_CURRENT_PWM + #ifdef __SAM3X8E__ + #define _RESET_CURRENT_PWM_FREQ(P) NOOP + #else + #define _RESET_CURRENT_PWM_FREQ(P) hal.set_pwm_frequency(pin_t(P), MOTOR_CURRENT_PWM_FREQUENCY) + #endif + #define INIT_CURRENT_PWM(P) do{ SET_PWM(MOTOR_CURRENT_PWM_## P ##_PIN); _RESET_CURRENT_PWM_FREQ(MOTOR_CURRENT_PWM_## P ##_PIN); }while(0) + #if PIN_EXISTS(MOTOR_CURRENT_PWM_X) - SET_PWM(MOTOR_CURRENT_PWM_X_PIN); + INIT_CURRENT_PWM(X); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_Y) - SET_PWM(MOTOR_CURRENT_PWM_Y_PIN); + INIT_CURRENT_PWM(Y); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) - SET_PWM(MOTOR_CURRENT_PWM_XY_PIN); + INIT_CURRENT_PWM(XY); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) - SET_PWM(MOTOR_CURRENT_PWM_Z_PIN); + INIT_CURRENT_PWM(Z); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_E) - SET_PWM(MOTOR_CURRENT_PWM_E_PIN); + INIT_CURRENT_PWM(E); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_E0) - SET_PWM(MOTOR_CURRENT_PWM_E0_PIN); + INIT_CURRENT_PWM(E0); #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_E1) - SET_PWM(MOTOR_CURRENT_PWM_E1_PIN); + INIT_CURRENT_PWM(E1); #endif refresh_motor_power(); - // Set Timer5 to 31khz so the PWM of the motor power is as constant as possible. (removes a buzzing noise) - #ifdef __AVR__ - SET_CS5(PRESCALER_1); - #endif #endif } @@ -3353,113 +3363,115 @@ void Stepper::report_positions() { void Stepper::microstep_init() { #if HAS_X_MS_PINS - SET_OUTPUT(X_MS1_PIN); - SET_OUTPUT(X_MS2_PIN); + SET_OUTPUT(X_MS1_PIN); SET_OUTPUT(X_MS2_PIN); #if PIN_EXISTS(X_MS3) SET_OUTPUT(X_MS3_PIN); #endif #endif #if HAS_X2_MS_PINS - SET_OUTPUT(X2_MS1_PIN); - SET_OUTPUT(X2_MS2_PIN); + SET_OUTPUT(X2_MS1_PIN); SET_OUTPUT(X2_MS2_PIN); #if PIN_EXISTS(X2_MS3) SET_OUTPUT(X2_MS3_PIN); #endif #endif #if HAS_Y_MS_PINS - SET_OUTPUT(Y_MS1_PIN); - SET_OUTPUT(Y_MS2_PIN); + SET_OUTPUT(Y_MS1_PIN); SET_OUTPUT(Y_MS2_PIN); #if PIN_EXISTS(Y_MS3) SET_OUTPUT(Y_MS3_PIN); #endif #endif #if HAS_Y2_MS_PINS - SET_OUTPUT(Y2_MS1_PIN); - SET_OUTPUT(Y2_MS2_PIN); + SET_OUTPUT(Y2_MS1_PIN); SET_OUTPUT(Y2_MS2_PIN); #if PIN_EXISTS(Y2_MS3) SET_OUTPUT(Y2_MS3_PIN); #endif #endif #if HAS_Z_MS_PINS - SET_OUTPUT(Z_MS1_PIN); - SET_OUTPUT(Z_MS2_PIN); + SET_OUTPUT(Z_MS1_PIN); SET_OUTPUT(Z_MS2_PIN); #if PIN_EXISTS(Z_MS3) SET_OUTPUT(Z_MS3_PIN); #endif #endif #if HAS_Z2_MS_PINS - SET_OUTPUT(Z2_MS1_PIN); - SET_OUTPUT(Z2_MS2_PIN); + SET_OUTPUT(Z2_MS1_PIN); SET_OUTPUT(Z2_MS2_PIN); #if PIN_EXISTS(Z2_MS3) SET_OUTPUT(Z2_MS3_PIN); #endif #endif #if HAS_Z3_MS_PINS - SET_OUTPUT(Z3_MS1_PIN); - SET_OUTPUT(Z3_MS2_PIN); + SET_OUTPUT(Z3_MS1_PIN); SET_OUTPUT(Z3_MS2_PIN); #if PIN_EXISTS(Z3_MS3) SET_OUTPUT(Z3_MS3_PIN); #endif #endif #if HAS_Z4_MS_PINS - SET_OUTPUT(Z4_MS1_PIN); - SET_OUTPUT(Z4_MS2_PIN); + SET_OUTPUT(Z4_MS1_PIN); SET_OUTPUT(Z4_MS2_PIN); #if PIN_EXISTS(Z4_MS3) SET_OUTPUT(Z4_MS3_PIN); #endif #endif + #if HAS_I_MS_PINS + SET_OUTPUT(I_MS1_PIN); SET_OUTPUT(I_MS2_PIN); + #if PIN_EXISTS(I_MS3) + SET_OUTPUT(I_MS3_PIN); + #endif + #endif + #if HAS_J_MS_PINS + SET_OUTPUT(J_MS1_PIN); SET_OUTPUT(J_MS2_PIN); + #if PIN_EXISTS(J_MS3) + SET_OUTPUT(J_MS3_PIN); + #endif + #endif + #if HAS_K_MS_PINS + SET_OUTPUT(K_MS1_PIN); SET_OUTPUT(K_MS2_PIN); + #if PIN_EXISTS(K_MS3) + SET_OUTPUT(K_MS3_PIN); + #endif + #endif #if HAS_E0_MS_PINS - SET_OUTPUT(E0_MS1_PIN); - SET_OUTPUT(E0_MS2_PIN); + SET_OUTPUT(E0_MS1_PIN); SET_OUTPUT(E0_MS2_PIN); #if PIN_EXISTS(E0_MS3) SET_OUTPUT(E0_MS3_PIN); #endif #endif #if HAS_E1_MS_PINS - SET_OUTPUT(E1_MS1_PIN); - SET_OUTPUT(E1_MS2_PIN); + SET_OUTPUT(E1_MS1_PIN); SET_OUTPUT(E1_MS2_PIN); #if PIN_EXISTS(E1_MS3) SET_OUTPUT(E1_MS3_PIN); #endif #endif #if HAS_E2_MS_PINS - SET_OUTPUT(E2_MS1_PIN); - SET_OUTPUT(E2_MS2_PIN); + SET_OUTPUT(E2_MS1_PIN); SET_OUTPUT(E2_MS2_PIN); #if PIN_EXISTS(E2_MS3) SET_OUTPUT(E2_MS3_PIN); #endif #endif #if HAS_E3_MS_PINS - SET_OUTPUT(E3_MS1_PIN); - SET_OUTPUT(E3_MS2_PIN); + SET_OUTPUT(E3_MS1_PIN); SET_OUTPUT(E3_MS2_PIN); #if PIN_EXISTS(E3_MS3) SET_OUTPUT(E3_MS3_PIN); #endif #endif #if HAS_E4_MS_PINS - SET_OUTPUT(E4_MS1_PIN); - SET_OUTPUT(E4_MS2_PIN); + SET_OUTPUT(E4_MS1_PIN); SET_OUTPUT(E4_MS2_PIN); #if PIN_EXISTS(E4_MS3) SET_OUTPUT(E4_MS3_PIN); #endif #endif #if HAS_E5_MS_PINS - SET_OUTPUT(E5_MS1_PIN); - SET_OUTPUT(E5_MS2_PIN); + SET_OUTPUT(E5_MS1_PIN); SET_OUTPUT(E5_MS2_PIN); #if PIN_EXISTS(E5_MS3) SET_OUTPUT(E5_MS3_PIN); #endif #endif #if HAS_E6_MS_PINS - SET_OUTPUT(E6_MS1_PIN); - SET_OUTPUT(E6_MS2_PIN); + SET_OUTPUT(E6_MS1_PIN); SET_OUTPUT(E6_MS2_PIN); #if PIN_EXISTS(E6_MS3) SET_OUTPUT(E6_MS3_PIN); #endif #endif #if HAS_E7_MS_PINS - SET_OUTPUT(E7_MS1_PIN); - SET_OUTPUT(E7_MS2_PIN); + SET_OUTPUT(E7_MS1_PIN); SET_OUTPUT(E7_MS2_PIN); #if PIN_EXISTS(E7_MS3) SET_OUTPUT(E7_MS3_PIN); #endif @@ -3532,13 +3544,13 @@ void Stepper::report_positions() { #if HAS_E7_MS_PINS case 10: WRITE(E7_MS1_PIN, ms1); break; #endif - #if HAS_I_MICROSTEPS + #if HAS_I_MS_PINS case 11: WRITE(I_MS1_PIN, ms1); break #endif - #if HAS_J_MICROSTEPS + #if HAS_J_MS_PINS case 12: WRITE(J_MS1_PIN, ms1); break #endif - #if HAS_K_MICROSTEPS + #if HAS_K_MS_PINS case 13: WRITE(K_MS1_PIN, ms1); break #endif } @@ -3603,13 +3615,13 @@ void Stepper::report_positions() { #if HAS_E7_MS_PINS case 10: WRITE(E7_MS2_PIN, ms2); break; #endif - #if HAS_I_M_PINS + #if HAS_I_MS_PINS case 11: WRITE(I_MS2_PIN, ms2); break #endif - #if HAS_J_M_PINS + #if HAS_J_MS_PINS case 12: WRITE(J_MS2_PIN, ms2); break #endif - #if HAS_K_M_PINS + #if HAS_K_MS_PINS case 13: WRITE(K_MS2_PIN, ms2); break #endif } diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index f170dd410458..89ba7b06719c 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -46,7 +46,7 @@ #include "planner.h" #include "stepper/indirection.h" #ifdef __AVR__ - #include "speed_lookuptable.h" + #include "stepper/speed_lookuptable.h" #endif // Disable multiple steps per ISR @@ -252,7 +252,7 @@ typedef struct { }; constexpr ena_mask_t linear_bits() { return _BV(LINEAR_AXES) - 1; } constexpr ena_mask_t e_bits() { return (_BV(EXTRUDERS) - 1) << LINEAR_AXES; } -} axis_flags_t; +} stepper_flags_t; // All the stepper enable pins constexpr pin_t ena_pins[] = { @@ -317,6 +317,9 @@ class Stepper { #ifndef PWM_MOTOR_CURRENT #define PWM_MOTOR_CURRENT DEFAULT_PWM_MOTOR_CURRENT #endif + #ifndef MOTOR_CURRENT_PWM_FREQUENCY + #define MOTOR_CURRENT_PWM_FREQUENCY 31400 + #endif #define MOTOR_CURRENT_COUNT LINEAR_AXES #elif HAS_MOTOR_CURRENT_SPI static constexpr uint32_t digipot_count[] = DIGIPOT_MOTOR_CURRENT; @@ -333,7 +336,7 @@ class Stepper { static constexpr uint8_t last_moved_extruder = 0; #endif - #if HAS_FREEZE_PIN + #if ENABLED(FREEZE_FEATURE) static bool frozen; // Set this flag to instantly freeze motion #endif @@ -354,9 +357,9 @@ class Stepper { #endif #if EITHER(Z_MULTI_ENDSTOPS, Z_STEPPER_AUTO_ALIGN) static bool locked_Z_motor, locked_Z2_motor - #if NUM_Z_STEPPER_DRIVERS >= 3 + #if NUM_Z_STEPPERS >= 3 , locked_Z3_motor - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 , locked_Z4_motor #endif #endif @@ -457,11 +460,11 @@ class Stepper { // The stepper subsystem goes to sleep when it runs out of things to execute. // Call this to notify the subsystem that it is time to go to work. - static inline void wake_up() { ENABLE_STEPPER_DRIVER_INTERRUPT(); } + static void wake_up() { ENABLE_STEPPER_DRIVER_INTERRUPT(); } - static inline bool is_awake() { return STEPPER_ISR_ENABLED(); } + static bool is_awake() { return STEPPER_ISR_ENABLED(); } - static inline bool suspend() { + static bool suspend() { const bool awake = is_awake(); if (awake) DISABLE_STEPPER_DRIVER_INTERRUPT(); return awake; @@ -558,18 +561,18 @@ class Stepper { #if EITHER(Z_MULTI_ENDSTOPS, Z_STEPPER_AUTO_ALIGN) FORCE_INLINE static void set_z1_lock(const bool state) { locked_Z_motor = state; } FORCE_INLINE static void set_z2_lock(const bool state) { locked_Z2_motor = state; } - #if NUM_Z_STEPPER_DRIVERS >= 3 + #if NUM_Z_STEPPERS >= 3 FORCE_INLINE static void set_z3_lock(const bool state) { locked_Z3_motor = state; } - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 FORCE_INLINE static void set_z4_lock(const bool state) { locked_Z4_motor = state; } #endif #endif - static inline void set_all_z_lock(const bool lock, const int8_t except=-1) { + static void set_all_z_lock(const bool lock, const int8_t except=-1) { set_z1_lock(lock ^ (except == 0)); set_z2_lock(lock ^ (except == 1)); - #if NUM_Z_STEPPER_DRIVERS >= 3 + #if NUM_Z_STEPPERS >= 3 set_z3_lock(lock ^ (except == 2)); - #if NUM_Z_STEPPER_DRIVERS >= 4 + #if NUM_Z_STEPPERS >= 4 set_z4_lock(lock ^ (except == 3)); #endif #endif @@ -584,18 +587,18 @@ class Stepper { static void refresh_motor_power(); #endif - static axis_flags_t axis_enabled; // Axis stepper(s) ENABLED states + static stepper_flags_t axis_enabled; // Axis stepper(s) ENABLED states - static inline bool axis_is_enabled(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) { + static bool axis_is_enabled(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) { return TEST(axis_enabled.bits, INDEX_OF_AXIS(axis, eindex)); } - static inline void mark_axis_enabled(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) { + static void mark_axis_enabled(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) { SBI(axis_enabled.bits, INDEX_OF_AXIS(axis, eindex)); } - static inline void mark_axis_disabled(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) { + static void mark_axis_disabled(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) { CBI(axis_enabled.bits, INDEX_OF_AXIS(axis, eindex)); } - static inline bool can_axis_disable(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) { + static bool can_axis_disable(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) { return !any_enable_overlap() || !(axis_enabled.bits & enable_overlap[INDEX_OF_AXIS(axis, eindex)]); } @@ -608,10 +611,10 @@ class Stepper { static void enable_e_steppers(); static void disable_e_steppers(); #else - static inline void enable_extruder() {} - static inline bool disable_extruder() { return true; } - static inline void enable_e_steppers() {} - static inline void disable_e_steppers() {} + static void enable_extruder() {} + static bool disable_extruder() { return true; } + static void enable_e_steppers() {} + static void disable_e_steppers() {} #endif #define ENABLE_EXTRUDER(N) enable_extruder(E_TERN_(N)) diff --git a/Marlin/src/module/stepper/indirection.h b/Marlin/src/module/stepper/indirection.h index 93b765d7a52e..f8369ffb1cf5 100644 --- a/Marlin/src/module/stepper/indirection.h +++ b/Marlin/src/module/stepper/indirection.h @@ -206,7 +206,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #endif // I Stepper -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #ifndef I_ENABLE_INIT #define I_ENABLE_INIT() SET_OUTPUT(I_ENABLE_PIN) #define I_ENABLE_WRITE(STATE) WRITE(I_ENABLE_PIN,STATE) @@ -225,7 +225,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #endif // J Stepper -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #ifndef J_ENABLE_INIT #define J_ENABLE_INIT() SET_OUTPUT(J_ENABLE_PIN) #define J_ENABLE_WRITE(STATE) WRITE(J_ENABLE_PIN,STATE) @@ -244,7 +244,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #endif // K Stepper -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #ifndef K_ENABLE_INIT #define K_ENABLE_INIT() SET_OUTPUT(K_ENABLE_PIN) #define K_ENABLE_WRITE(STATE) WRITE(K_ENABLE_PIN,STATE) @@ -405,91 +405,91 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #if EXTRUDERS > 7 #define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else if (E < 4) { E1_STEP_WRITE(V); } else if (E < 6) { E2_STEP_WRITE(V); } else { E3_STEP_WRITE(V); } }while(0) #define NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E0_DIR_WRITE( INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 3: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 4: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 5: E2_DIR_WRITE( INVERT_E2_DIR); break; \ - case 6: E3_DIR_WRITE( INVERT_E3_DIR); break; case 7: E3_DIR_WRITE( INVERT_E3_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 4: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; case 5: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; \ + case 6: E3_DIR_WRITE( ENABLED(INVERT_E3_DIR)); break; case 7: E3_DIR_WRITE( ENABLED(INVERT_E3_DIR)); break; \ } }while(0) #define REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E0_DIR_WRITE(!INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE( INVERT_E1_DIR); break; case 3: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 4: E2_DIR_WRITE( INVERT_E2_DIR); break; case 5: E2_DIR_WRITE(!INVERT_E2_DIR); break; \ - case 6: E3_DIR_WRITE(!INVERT_E3_DIR); break; case 7: E3_DIR_WRITE(!INVERT_E3_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 4: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; case 5: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; \ + case 6: E3_DIR_WRITE(DISABLED(INVERT_E3_DIR)); break; case 7: E3_DIR_WRITE(DISABLED(INVERT_E3_DIR)); break; \ } }while(0) #elif EXTRUDERS > 6 #define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else if (E < 4) { E1_STEP_WRITE(V); } else if (E < 6) { E2_STEP_WRITE(V); } else { E3_STEP_WRITE(V); } }while(0) #define NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E0_DIR_WRITE( INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 3: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 4: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 5: E2_DIR_WRITE( INVERT_E2_DIR); break; \ - case 6: E3_DIR_WRITE( INVERT_E3_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 4: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; case 5: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; \ + case 6: E3_DIR_WRITE( ENABLED(INVERT_E3_DIR)); break; \ } }while(0) #define REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E0_DIR_WRITE(!INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE( INVERT_E1_DIR); break; case 3: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 4: E2_DIR_WRITE( INVERT_E2_DIR); break; case 5: E2_DIR_WRITE(!INVERT_E2_DIR); break; \ - case 6: E3_DIR_WRITE(!INVERT_E3_DIR); } }while(0) + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 4: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; case 5: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; \ + case 6: E3_DIR_WRITE(DISABLED(INVERT_E3_DIR)); } }while(0) #elif EXTRUDERS > 5 #define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else if (E < 4) { E1_STEP_WRITE(V); } else { E2_STEP_WRITE(V); } }while(0) #define NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E0_DIR_WRITE( INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 3: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 4: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 5: E2_DIR_WRITE( INVERT_E2_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 4: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; case 5: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; \ } }while(0) #define REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E0_DIR_WRITE(!INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE( INVERT_E1_DIR); break; case 3: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 4: E2_DIR_WRITE( INVERT_E2_DIR); break; case 5: E2_DIR_WRITE(!INVERT_E2_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 4: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; case 5: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; \ } }while(0) #elif EXTRUDERS > 4 #define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else if (E < 4) { E1_STEP_WRITE(V); } else { E2_STEP_WRITE(V); } }while(0) #define NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E0_DIR_WRITE( INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 3: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 4: E2_DIR_WRITE(!INVERT_E2_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 4: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; \ } }while(0) #define REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E0_DIR_WRITE(!INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE( INVERT_E1_DIR); break; case 3: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 4: E2_DIR_WRITE( INVERT_E2_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 4: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; \ } }while(0) #elif EXTRUDERS > 3 #define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else { E1_STEP_WRITE(V); } }while(0) #define NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E0_DIR_WRITE( INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 3: E1_DIR_WRITE( INVERT_E1_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ } }while(0) #define REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E0_DIR_WRITE(!INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE( INVERT_E1_DIR); break; case 3: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; case 3: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ } }while(0) #elif EXTRUDERS > 2 #define E_STEP_WRITE(E,V) do{ if (E < 2) { E0_STEP_WRITE(V); } else { E1_STEP_WRITE(V); } }while(0) #define NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E0_DIR_WRITE( INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ } }while(0) #define REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E0_DIR_WRITE(!INVERT_E0_DIR); break; \ - case 2: E1_DIR_WRITE( INVERT_E1_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; \ + case 2: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ } }while(0) #else #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) - #define NORM_E_DIR(E) do{ E0_DIR_WRITE(E ? INVERT_E0_DIR : !INVERT_E0_DIR); }while(0) - #define REV_E_DIR(E) do{ E0_DIR_WRITE(E ? !INVERT_E0_DIR : INVERT_E0_DIR); }while(0) + #define NORM_E_DIR(E) do{ E0_DIR_WRITE(E ? ENABLED(INVERT_E0_DIR) : DISABLED(INVERT_E0_DIR)); }while(0) + #define REV_E_DIR(E) do{ E0_DIR_WRITE(E ? DISABLED(INVERT_E0_DIR) : ENABLED(INVERT_E0_DIR)); }while(0) #endif #elif HAS_PRUSA_MMU2 // One multiplexed stepper driver #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) - #define NORM_E_DIR(E) E0_DIR_WRITE(!INVERT_E0_DIR) - #define REV_E_DIR(E) E0_DIR_WRITE( INVERT_E0_DIR) + #define NORM_E_DIR(E) E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)) + #define REV_E_DIR(E) E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)) #elif HAS_PRUSA_MMU1 // One multiplexed stepper driver, reversed on odd index #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) - #define NORM_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? !INVERT_E0_DIR: INVERT_E0_DIR); }while(0) - #define REV_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? INVERT_E0_DIR: !INVERT_E0_DIR); }while(0) + #define NORM_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? DISABLED(INVERT_E0_DIR): ENABLED(INVERT_E0_DIR)); }while(0) + #define REV_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? ENABLED(INVERT_E0_DIR): DISABLED(INVERT_E0_DIR)); }while(0) #elif E_STEPPERS > 1 @@ -500,16 +500,16 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset case 4: E4_STEP_WRITE(V); break; case 5: E5_STEP_WRITE(V); break; case 6: E6_STEP_WRITE(V); break; case 7: E7_STEP_WRITE(V); break; \ } }while(0) #define _NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 3: E3_DIR_WRITE(!INVERT_E3_DIR); break; \ - case 4: E4_DIR_WRITE(!INVERT_E4_DIR); break; case 5: E5_DIR_WRITE(!INVERT_E5_DIR); break; \ - case 6: E6_DIR_WRITE(!INVERT_E6_DIR); break; case 7: E7_DIR_WRITE(!INVERT_E7_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE(DISABLED(INVERT_E3_DIR)); break; \ + case 4: E4_DIR_WRITE(DISABLED(INVERT_E4_DIR)); break; case 5: E5_DIR_WRITE(DISABLED(INVERT_E5_DIR)); break; \ + case 6: E6_DIR_WRITE(DISABLED(INVERT_E6_DIR)); break; case 7: E7_DIR_WRITE(DISABLED(INVERT_E7_DIR)); break; \ } }while(0) #define _REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE( INVERT_E2_DIR); break; case 3: E3_DIR_WRITE( INVERT_E3_DIR); break; \ - case 4: E4_DIR_WRITE( INVERT_E4_DIR); break; case 5: E5_DIR_WRITE( INVERT_E5_DIR); break; \ - case 6: E6_DIR_WRITE( INVERT_E6_DIR); break; case 7: E7_DIR_WRITE( INVERT_E7_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE( ENABLED(INVERT_E3_DIR)); break; \ + case 4: E4_DIR_WRITE( ENABLED(INVERT_E4_DIR)); break; case 5: E5_DIR_WRITE( ENABLED(INVERT_E5_DIR)); break; \ + case 6: E6_DIR_WRITE( ENABLED(INVERT_E6_DIR)); break; case 7: E7_DIR_WRITE( ENABLED(INVERT_E7_DIR)); break; \ } }while(0) #elif E_STEPPERS > 6 @@ -519,16 +519,16 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset case 4: E4_STEP_WRITE(V); break; case 5: E5_STEP_WRITE(V); break; case 6: E6_STEP_WRITE(V); break; \ } }while(0) #define _NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 3: E3_DIR_WRITE(!INVERT_E3_DIR); break; \ - case 4: E4_DIR_WRITE(!INVERT_E4_DIR); break; case 5: E5_DIR_WRITE(!INVERT_E5_DIR); break; \ - case 6: E6_DIR_WRITE(!INVERT_E6_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE(DISABLED(INVERT_E3_DIR)); break; \ + case 4: E4_DIR_WRITE(DISABLED(INVERT_E4_DIR)); break; case 5: E5_DIR_WRITE(DISABLED(INVERT_E5_DIR)); break; \ + case 6: E6_DIR_WRITE(DISABLED(INVERT_E6_DIR)); break; \ } }while(0) #define _REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE( INVERT_E2_DIR); break; case 3: E3_DIR_WRITE( INVERT_E3_DIR); break; \ - case 4: E4_DIR_WRITE( INVERT_E4_DIR); break; case 5: E5_DIR_WRITE( INVERT_E5_DIR); break; \ - case 6: E6_DIR_WRITE( INVERT_E6_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE( ENABLED(INVERT_E3_DIR)); break; \ + case 4: E4_DIR_WRITE( ENABLED(INVERT_E4_DIR)); break; case 5: E5_DIR_WRITE( ENABLED(INVERT_E5_DIR)); break; \ + case 6: E6_DIR_WRITE( ENABLED(INVERT_E6_DIR)); break; \ } }while(0) #elif E_STEPPERS > 5 @@ -538,14 +538,14 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset case 4: E4_STEP_WRITE(V); break; case 5: E5_STEP_WRITE(V); break; \ } }while(0) #define _NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 3: E3_DIR_WRITE(!INVERT_E3_DIR); break; \ - case 4: E4_DIR_WRITE(!INVERT_E4_DIR); break; case 5: E5_DIR_WRITE(!INVERT_E5_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE(DISABLED(INVERT_E3_DIR)); break; \ + case 4: E4_DIR_WRITE(DISABLED(INVERT_E4_DIR)); break; case 5: E5_DIR_WRITE(DISABLED(INVERT_E5_DIR)); break; \ } }while(0) #define _REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE( INVERT_E2_DIR); break; case 3: E3_DIR_WRITE( INVERT_E3_DIR); break; \ - case 4: E4_DIR_WRITE( INVERT_E4_DIR); break; case 5: E5_DIR_WRITE( INVERT_E5_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE( ENABLED(INVERT_E3_DIR)); break; \ + case 4: E4_DIR_WRITE( ENABLED(INVERT_E4_DIR)); break; case 5: E5_DIR_WRITE( ENABLED(INVERT_E5_DIR)); break; \ } }while(0) #elif E_STEPPERS > 4 @@ -555,14 +555,14 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset case 4: E4_STEP_WRITE(V); break; \ } }while(0) #define _NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 3: E3_DIR_WRITE(!INVERT_E3_DIR); break; \ - case 4: E4_DIR_WRITE(!INVERT_E4_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE(DISABLED(INVERT_E3_DIR)); break; \ + case 4: E4_DIR_WRITE(DISABLED(INVERT_E4_DIR)); break; \ } }while(0) #define _REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE( INVERT_E2_DIR); break; case 3: E3_DIR_WRITE( INVERT_E3_DIR); break; \ - case 4: E4_DIR_WRITE( INVERT_E4_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE( ENABLED(INVERT_E3_DIR)); break; \ + case 4: E4_DIR_WRITE( ENABLED(INVERT_E4_DIR)); break; \ } }while(0) #elif E_STEPPERS > 3 @@ -571,25 +571,25 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset case 0: E0_STEP_WRITE(V); break; case 1: E1_STEP_WRITE(V); break; case 2: E2_STEP_WRITE(V); break; case 3: E3_STEP_WRITE(V); break; \ } }while(0) #define _NORM_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE(!INVERT_E2_DIR); break; case 3: E3_DIR_WRITE(!INVERT_E3_DIR); break; \ + case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE(DISABLED(INVERT_E3_DIR)); break; \ } }while(0) #define _REV_E_DIR(E) do{ switch (E) { \ - case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; \ - case 2: E2_DIR_WRITE( INVERT_E2_DIR); break; case 3: E3_DIR_WRITE( INVERT_E3_DIR); break; \ + case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; \ + case 2: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); break; case 3: E3_DIR_WRITE( ENABLED(INVERT_E3_DIR)); break; \ } }while(0) #elif E_STEPPERS > 2 #define _E_STEP_WRITE(E,V) do{ switch (E) { case 0: E0_STEP_WRITE(V); break; case 1: E1_STEP_WRITE(V); break; case 2: E2_STEP_WRITE(V); } }while(0) - #define _NORM_E_DIR(E) do{ switch (E) { case 0: E0_DIR_WRITE(!INVERT_E0_DIR); break; case 1: E1_DIR_WRITE(!INVERT_E1_DIR); break; case 2: E2_DIR_WRITE(!INVERT_E2_DIR); } }while(0) - #define _REV_E_DIR(E) do{ switch (E) { case 0: E0_DIR_WRITE( INVERT_E0_DIR); break; case 1: E1_DIR_WRITE( INVERT_E1_DIR); break; case 2: E2_DIR_WRITE( INVERT_E2_DIR); } }while(0) + #define _NORM_E_DIR(E) do{ switch (E) { case 0: E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); break; case 2: E2_DIR_WRITE(DISABLED(INVERT_E2_DIR)); } }while(0) + #define _REV_E_DIR(E) do{ switch (E) { case 0: E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); break; case 1: E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); break; case 2: E2_DIR_WRITE( ENABLED(INVERT_E2_DIR)); } }while(0) #else #define _E_STEP_WRITE(E,V) do{ if (E == 0) { E0_STEP_WRITE(V); } else { E1_STEP_WRITE(V); } }while(0) - #define _NORM_E_DIR(E) do{ if (E == 0) { E0_DIR_WRITE(!INVERT_E0_DIR); } else { E1_DIR_WRITE(!INVERT_E1_DIR); } }while(0) - #define _REV_E_DIR(E) do{ if (E == 0) { E0_DIR_WRITE( INVERT_E0_DIR); } else { E1_DIR_WRITE( INVERT_E1_DIR); } }while(0) + #define _NORM_E_DIR(E) do{ if (E == 0) { E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); } else { E1_DIR_WRITE(DISABLED(INVERT_E1_DIR)); } }while(0) + #define _REV_E_DIR(E) do{ if (E == 0) { E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); } else { E1_DIR_WRITE( ENABLED(INVERT_E1_DIR)); } }while(0) #endif #if HAS_DUPLICATION_MODE @@ -600,8 +600,8 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define _DUPE(N,T,V) E##N##_##T##_WRITE(V) #endif - #define NDIR(N) _DUPE(N,DIR,!INVERT_E##N##_DIR) - #define RDIR(N) _DUPE(N,DIR, INVERT_E##N##_DIR) + #define NDIR(N) _DUPE(N,DIR,DISABLED(INVERT_E##N##_DIR)) + #define RDIR(N) _DUPE(N,DIR, ENABLED(INVERT_E##N##_DIR)) #define E_STEP_WRITE(E,V) do{ if (extruder_duplication_enabled) { DUPE(STEP,V); } else _E_STEP_WRITE(E,V); }while(0) @@ -647,13 +647,13 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #elif ENABLED(E_DUAL_STEPPER_DRIVERS) #define E_STEP_WRITE(E,V) do{ E0_STEP_WRITE(V); E1_STEP_WRITE(V); }while(0) - #define NORM_E_DIR(E) do{ E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E0_DIR ^ ENABLED(INVERT_E1_VS_E0_DIR)); }while(0) - #define REV_E_DIR(E) do{ E0_DIR_WRITE( INVERT_E0_DIR); E1_DIR_WRITE( INVERT_E0_DIR ^ ENABLED(INVERT_E1_VS_E0_DIR)); }while(0) + #define NORM_E_DIR(E) do{ E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)); E1_DIR_WRITE(DISABLED(INVERT_E0_DIR) ^ ENABLED(INVERT_E1_VS_E0_DIR)); }while(0) + #define REV_E_DIR(E) do{ E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)); E1_DIR_WRITE( ENABLED(INVERT_E0_DIR) ^ ENABLED(INVERT_E1_VS_E0_DIR)); }while(0) #elif E_STEPPERS #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) - #define NORM_E_DIR(E) E0_DIR_WRITE(!INVERT_E0_DIR) - #define REV_E_DIR(E) E0_DIR_WRITE( INVERT_E0_DIR) + #define NORM_E_DIR(E) E0_DIR_WRITE(DISABLED(INVERT_E0_DIR)) + #define REV_E_DIR(E) E0_DIR_WRITE( ENABLED(INVERT_E0_DIR)) #else #define E_STEP_WRITE(E,V) NOOP @@ -895,21 +895,21 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define Z_RESET() #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #define ENABLE_AXIS_I() if (SHOULD_ENABLE(i)) { ENABLE_STEPPER_I(); AFTER_CHANGE(i, true); } #define DISABLE_AXIS_I() if (SHOULD_DISABLE(i)) { DISABLE_STEPPER_I(); AFTER_CHANGE(i, false); set_axis_untrusted(I_AXIS); } #else #define ENABLE_AXIS_I() NOOP #define DISABLE_AXIS_I() NOOP #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #define ENABLE_AXIS_J() if (SHOULD_ENABLE(j)) { ENABLE_STEPPER_J(); AFTER_CHANGE(j, true); } #define DISABLE_AXIS_J() if (SHOULD_DISABLE(j)) { DISABLE_STEPPER_J(); AFTER_CHANGE(j, false); set_axis_untrusted(J_AXIS); } #else #define ENABLE_AXIS_J() NOOP #define DISABLE_AXIS_J() NOOP #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #define ENABLE_AXIS_K() if (SHOULD_ENABLE(k)) { ENABLE_STEPPER_K(); AFTER_CHANGE(k, true); } #define DISABLE_AXIS_K() if (SHOULD_DISABLE(k)) { DISABLE_STEPPER_K(); AFTER_CHANGE(k, false); set_axis_untrusted(K_AXIS); } #else diff --git a/Marlin/src/module/speed_lookuptable.h b/Marlin/src/module/stepper/speed_lookuptable.h similarity index 100% rename from Marlin/src/module/speed_lookuptable.h rename to Marlin/src/module/stepper/speed_lookuptable.h diff --git a/Marlin/src/module/stepper/trinamic.cpp b/Marlin/src/module/stepper/trinamic.cpp index 7baa2108f06a..af09623dc1bb 100644 --- a/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin/src/module/stepper/trinamic.cpp @@ -906,49 +906,18 @@ void reset_trinamic_drivers() { #endif #if USE_SENSORLESS - #if X_SENSORLESS - stepperX.homing_threshold(X_STALL_SENSITIVITY); - #if AXIS_HAS_STALLGUARD(X2) - stepperX2.homing_threshold(CAT(TERN(X2_SENSORLESS, X2, X), _STALL_SENSITIVITY)); - #endif - #endif - #if Y_SENSORLESS - stepperY.homing_threshold(Y_STALL_SENSITIVITY); - #if AXIS_HAS_STALLGUARD(Y2) - stepperY2.homing_threshold(CAT(TERN(Y2_SENSORLESS, Y2, Y), _STALL_SENSITIVITY)); - #endif - #endif - #if Z_SENSORLESS - stepperZ.homing_threshold(Z_STALL_SENSITIVITY); - #if AXIS_HAS_STALLGUARD(Z2) - stepperZ2.homing_threshold(CAT(TERN(Z2_SENSORLESS, Z2, Z), _STALL_SENSITIVITY)); - #endif - #if AXIS_HAS_STALLGUARD(Z3) - stepperZ3.homing_threshold(CAT(TERN(Z3_SENSORLESS, Z3, Z), _STALL_SENSITIVITY)); - #endif - #if AXIS_HAS_STALLGUARD(Z4) - stepperZ4.homing_threshold(CAT(TERN(Z4_SENSORLESS, Z4, Z), _STALL_SENSITIVITY)); - #endif - #endif - #if I_SENSORLESS - stepperI.homing_threshold(I_STALL_SENSITIVITY); - #if AXIS_HAS_STALLGUARD(I) - stepperI.homing_threshold(CAT(TERN(I_SENSORLESS, I, I), _STALL_SENSITIVITY)); - #endif - #endif - #if J_SENSORLESS - stepperJ.homing_threshold(J_STALL_SENSITIVITY); - #if AXIS_HAS_STALLGUARD(J) - stepperJ.homing_threshold(CAT(TERN(J_SENSORLESS, J, J), _STALL_SENSITIVITY)); - #endif - #endif - #if K_SENSORLESS - stepperK.homing_threshold(K_STALL_SENSITIVITY); - #if AXIS_HAS_STALLGUARD(K) - stepperK.homing_threshold(CAT(TERN(K_SENSORLESS, K, K), _STALL_SENSITIVITY)); - #endif - #endif - #endif // USE SENSORLESS + TERN_(X_SENSORLESS, stepperX.homing_threshold(X_STALL_SENSITIVITY)); + TERN_(X2_SENSORLESS, stepperX2.homing_threshold(CAT(TERN(X2_SENSORLESS, X2, X), _STALL_SENSITIVITY))); + TERN_(Y_SENSORLESS, stepperY.homing_threshold(Y_STALL_SENSITIVITY)); + TERN_(Y2_SENSORLESS, stepperY2.homing_threshold(CAT(TERN(Y2_SENSORLESS, Y2, Y), _STALL_SENSITIVITY))); + TERN_(Z_SENSORLESS, stepperZ.homing_threshold(Z_STALL_SENSITIVITY)); + TERN_(Z2_SENSORLESS, stepperZ2.homing_threshold(CAT(TERN(Z2_SENSORLESS, Z2, Z), _STALL_SENSITIVITY))); + TERN_(Z3_SENSORLESS, stepperZ3.homing_threshold(CAT(TERN(Z3_SENSORLESS, Z3, Z), _STALL_SENSITIVITY))); + TERN_(Z4_SENSORLESS, stepperZ4.homing_threshold(CAT(TERN(Z4_SENSORLESS, Z4, Z), _STALL_SENSITIVITY))); + TERN_(I_SENSORLESS, stepperI.homing_threshold(I_STALL_SENSITIVITY)); + TERN_(J_SENSORLESS, stepperJ.homing_threshold(J_STALL_SENSITIVITY)); + TERN_(K_SENSORLESS, stepperK.homing_threshold(K_STALL_SENSITIVITY)); + #endif #ifdef TMC_ADV TMC_ADV() diff --git a/Marlin/src/module/stepper/trinamic.h b/Marlin/src/module/stepper/trinamic.h index 0a956a70b360..dd3a64240f20 100644 --- a/Marlin/src/module/stepper/trinamic.h +++ b/Marlin/src/module/stepper/trinamic.h @@ -74,12 +74,6 @@ #define TMC_CLASS_E(N) TMC_CLASS(E##N, E) #endif -typedef struct { - uint8_t toff; - int8_t hend; - uint8_t hstrt; -} chopper_timing_t; - #ifndef CHOPPER_TIMING_X #define CHOPPER_TIMING_X CHOPPER_TIMING #endif @@ -89,13 +83,13 @@ typedef struct { #if HAS_Z_AXIS && !defined(CHOPPER_TIMING_Z) #define CHOPPER_TIMING_Z CHOPPER_TIMING #endif -#if LINEAR_AXES >= 4 && !defined(CHOPPER_TIMING_I) +#if HAS_I_AXIS && !defined(CHOPPER_TIMING_I) #define CHOPPER_TIMING_I CHOPPER_TIMING #endif -#if LINEAR_AXES >= 5 && !defined(CHOPPER_TIMING_J) +#if HAS_J_AXIS && !defined(CHOPPER_TIMING_J) #define CHOPPER_TIMING_J CHOPPER_TIMING #endif -#if LINEAR_AXES >= 6 && !defined(CHOPPER_TIMING_K) +#if HAS_K_AXIS && !defined(CHOPPER_TIMING_K) #define CHOPPER_TIMING_K CHOPPER_TIMING #endif #if HAS_EXTRUDERS && !defined(CHOPPER_TIMING_E) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index dccdc55034fd..d9db3dce1cbd 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -51,8 +51,8 @@ #if ENABLED(DWIN_CREALITY_LCD) #include "../lcd/e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../lcd/e3v2/proui/dwin.h" #endif #if ENABLED(EXTENSIBLE_UI) @@ -71,6 +71,10 @@ #include "../libs/nozzle.h" #endif +#if LASER_SAFETY_TIMEOUT_MS > 0 + #include "../feature/spindle_laser.h" +#endif + // 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))) @@ -141,7 +145,12 @@ #endif #endif -#if ENABLED(PID_EXTRUSION_SCALING) +#if ENABLED(MPCTEMP) + #include + #include "probe.h" +#endif + +#if EITHER(MPCTEMP, PID_EXTRUSION_SCALING) #include "stepper.h" #endif @@ -173,7 +182,7 @@ #include "tool_change.h" #endif -#if USE_BEEPER +#if HAS_BEEPER #include "../libs/buzzer.h" #endif @@ -196,6 +205,7 @@ Temperature thermalManager; PGMSTR(str_t_thermal_runaway, STR_T_THERMAL_RUNAWAY); +PGMSTR(str_t_temp_malfunction, STR_T_MALFUNCTION); PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); /** @@ -218,8 +228,8 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #else #define _COOLER_FSTR(h) #endif -#define _E_FSTR(h,N) ((HOTENDS) > N && (h) == N) ? F(LCD_STR_E##N) : -#define HEATER_FSTR(h) _BED_FSTR(h) _CHAMBER_FSTR(h) _COOLER_FSTR(h) _E_FSTR(h,1) _E_FSTR(h,2) _E_FSTR(h,3) _E_FSTR(h,4) _E_FSTR(h,5) F(LCD_STR_E0) +#define _E_FSTR(h,N) ((HOTENDS) > N && (h) == N) ? F(STR_E##N) : +#define HEATER_FSTR(h) _BED_FSTR(h) _CHAMBER_FSTR(h) _COOLER_FSTR(h) _E_FSTR(h,1) _E_FSTR(h,2) _E_FSTR(h,3) _E_FSTR(h,4) _E_FSTR(h,5) _E_FSTR(h,6) _E_FSTR(h,7) F(STR_E0) // // Initialize MAX TC objects/SPI @@ -326,7 +336,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #define _INIT_FAN_PIN(P) do{ if (PWM_PIN(P)) SET_PWM(P); else _INIT_SOFT_FAN(P); }while(0) #endif #if ENABLED(FAST_PWM_FAN) - #define SET_FAST_PWM_FREQ(P) set_pwm_frequency(P, FAST_PWM_FAN_FREQUENCY) + #define SET_FAST_PWM_FREQ(P) hal.set_pwm_frequency(pin_t(P), FAST_PWM_FAN_FREQUENCY) #else #define SET_FAST_PWM_FREQ(P) NOOP #endif @@ -436,8 +446,8 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if HAS_HEATED_BED bed_info_t Temperature::temp_bed; // = { 0 } // Init min and max temp with extreme values to prevent false errors during startup - int16_t Temperature::mintemp_raw_BED = TEMP_SENSOR_BED_RAW_LO_TEMP, - Temperature::maxtemp_raw_BED = TEMP_SENSOR_BED_RAW_HI_TEMP; + 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); #endif @@ -447,8 +457,8 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if HAS_HEATED_CHAMBER millis_t next_cool_check_ms_2 = 0; celsius_float_t old_temp = 9999; - int16_t Temperature::mintemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_LO_TEMP, - Temperature::maxtemp_raw_CHAMBER = TEMP_SENSOR_CHAMBER_RAW_HI_TEMP; + 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); #endif @@ -460,8 +470,8 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); bool flag_cooler_state; //bool flag_cooler_excess = false; celsius_float_t previous_temp = 9999; - int16_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP, - Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP; + raw_adc_t Temperature::mintemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_LO_TEMP, + Temperature::maxtemp_raw_COOLER = TEMP_SENSOR_COOLER_RAW_HI_TEMP; #if WATCH_COOLER cooler_watch_t Temperature::watch_cooler{0}; #endif @@ -476,11 +486,17 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if HAS_TEMP_BOARD board_info_t Temperature::temp_board; // = { 0 } #if ENABLED(THERMAL_PROTECTION_BOARD) - int16_t Temperature::mintemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_LO_TEMP, - Temperature::maxtemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_HI_TEMP; + raw_adc_t Temperature::mintemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_LO_TEMP, + Temperature::maxtemp_raw_BOARD = TEMP_SENSOR_BOARD_RAW_HI_TEMP; #endif #endif +#if BOTH(HAS_MARLINUI_MENU, PREVENT_COLD_EXTRUSION) && E_MANUAL > 0 + bool Temperature::allow_cold_extrude_override = false; +#else + constexpr bool Temperature::allow_cold_extrude_override; +#endif + #if ENABLED(PREVENT_COLD_EXTRUSION) bool Temperature::allow_cold_extrude = false; celsius_t Temperature::extrude_min_temp = EXTRUDE_MINTEMP; @@ -502,11 +518,16 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); volatile bool Temperature::raw_temps_ready = false; #if ENABLED(PID_EXTRUSION_SCALING) - int32_t Temperature::last_e_position, Temperature::lpq[LPQ_MAX_LEN]; + 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 +#endif + #define TEMPDIR(N) ((TEMP_SENSOR_##N##_RAW_LO_TEMP) < (TEMP_SENSOR_##N##_RAW_HI_TEMP) ? 1 : -1) +#define TP_CMP(S,A,B) (TEMPDIR(S) < 0 ? ((A)<(B)) : ((A)>(B))) #if HAS_HOTEND // Init mintemp and maxtemp with extreme values to prevent false errors during startup @@ -579,8 +600,8 @@ volatile bool Temperature::raw_temps_ready = false; PID_t tune_pid = { 0, 0, 0 }; celsius_float_t maxT = 0, minT = 10000; - const bool isbed = (heater_id == H_BED); - const bool ischamber = (heater_id == H_CHAMBER); + const bool isbed = (heater_id == H_BED), + ischamber = (heater_id == H_CHAMBER); #if ENABLED(PIDTEMPCHAMBER) #define C_TERN(T,A,B) ((T) ? (A) : (B)) @@ -622,15 +643,18 @@ 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_CREALITY_LCD_ENHANCED, DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(isbed ? PID_BED_START : PID_EXTR_START)); if (target > GHV(CHAMBER_MAX_TARGET, BED_MAX_TARGET, temp_range[heater_id].maxtemp - (HOTEND_OVERSHOOT))) { + SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH))); return; } + SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_AUTOTUNE_START); disable_all_heaters(); @@ -646,10 +670,11 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = false); + LCD_MESSAGE(MSG_HEATING); + // PID Tuning loop - wait_for_heatup = true; // Can be interrupted with M108 - TERN_(HAS_STATUS_MESSAGE, ui.set_status(F("Wait for heat up..."))); - while (wait_for_heatup) { + wait_for_heatup = true; + while (wait_for_heatup) { // Can be interrupted with M108 const millis_t ms = millis(); @@ -715,9 +740,11 @@ volatile bool Temperature::raw_temps_ready = false; #define MAX_OVERSHOOT_PID_AUTOTUNE 30 #endif if (current_temp > target + MAX_OVERSHOOT_PID_AUTOTUNE) { + SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TEMP_TOO_HIGH)); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH))); break; } @@ -753,14 +780,18 @@ volatile bool Temperature::raw_temps_ready = false; #endif if ((ms - _MIN(t1, t2)) > (MAX_CYCLE_TIME_PID_AUTOTUNE * 60L * 1000L)) { TERN_(DWIN_CREALITY_LCD, DWIN_Popup_Temperature(0)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_TUNING_TIMEOUT)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_TUNING_TIMEOUT)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TUNING_TIMEOUT)); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_TIMEOUT))); + SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_TIMEOUT); break; } if (cycles > ncycles && cycles > 2) { + SERIAL_ECHOPGM(STR_PID_AUTOTUNE); SERIAL_ECHOLNPGM(STR_PID_AUTOTUNE_FINISHED); + TERN_(HOST_PROMPT_SUPPORT, hostui.notify(GET_TEXT_F(MSG_PID_AUTOTUNE_DONE))); #if EITHER(PIDTEMPBED, PIDTEMPCHAMBER) FSTR_P const estring = GHV(F("chamber"), F("bed"), FPSTR(NUL_STR)); @@ -807,16 +838,16 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onPidTuningDone(color)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_DONE)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_DONE)); goto EXIT_M303; } // Run HAL idle tasks - TERN_(HAL_IDLETASK, HAL_idletask()); + hal.idletask(); // Run UI update - TERN(HAS_DWIN_E3V2_BASIC, DWIN_Update(), ui.update()); + TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update()); } wait_for_heatup = false; @@ -825,7 +856,7 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(PRINTER_EVENT_LEDS, printerEventLEDs.onPidTuningDone(color)); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_DONE)); - TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_PidTuning(PID_DONE)); + TERN_(DWIN_LCD_PROUI, DWIN_PidTuning(PID_DONE)); EXIT_M303: TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = true); @@ -834,6 +865,229 @@ volatile bool Temperature::raw_temps_ready = false; #endif // HAS_PID_HEATING +#if ENABLED(MPCTEMP) + + void Temperature::MPC_autotune() { + auto housekeeping = [] (millis_t& ms, celsius_float_t& current_temp, millis_t& next_report_ms) { + ms = millis(); + + if (updateTemperaturesIfReady()) { // temp sample ready + current_temp = degHotend(active_extruder); + TERN_(HAS_FAN_LOGIC, manage_extruder_fans(ms)); + } + + if (ELAPSED(ms, next_report_ms)) { + next_report_ms += 1000UL; + + print_heater_states(active_extruder); + SERIAL_EOL(); + } + + hal.idletask(); + TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update()); + + if (!wait_for_heatup) { + SERIAL_ECHOPGM(STR_MPC_AUTOTUNE); + SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_INTERRUPTED); + return false; + } + + return true; + }; + + struct OnExit { + ~OnExit() { + wait_for_heatup = false; + + ui.reset_status(); + + 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); + planner.sync_fan_speeds(fan_speed); + #endif + + do_z_clearance(MPC_TUNING_END_Z); + } + } on_exit; + + SERIAL_ECHOPGM(STR_MPC_AUTOTUNE); + SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_START, active_extruder); + MPCHeaterInfo &hotend = temp_hotend[active_extruder]; + MPC_t &constants = hotend.constants; + + // Move to center of bed, just above bed height and cool with max fan + 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); + 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); + + SERIAL_ECHOLNPGM(STR_MPC_COOLING_TO_AMBIENT); + LCD_MESSAGE(MSG_COOLING); + millis_t ms = millis(), next_report_ms = ms, next_test_ms = ms + 10000UL; + celsius_float_t current_temp = degHotend(active_extruder), + ambient_temp = current_temp; + + wait_for_heatup = true; + for (;;) { // Can be interrupted with M108 + if (!housekeeping(ms, current_temp, next_report_ms)) return; + + if (ELAPSED(ms, next_test_ms)) { + if (current_temp >= ambient_temp) { + ambient_temp = (ambient_temp + current_temp) / 2.0f; + break; + } + ambient_temp = current_temp; + next_test_ms += 10000UL; + } + } + + #if HAS_FAN + set_fan_speed(ANY(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0); + planner.sync_fan_speeds(fan_speed); + #endif + + hotend.modeled_ambient_temp = ambient_temp; + + SERIAL_ECHOLNPGM(STR_MPC_HEATING_PAST_200); + LCD_MESSAGE(MSG_HEATING); + hotend.target = 200.0f; // So M105 looks nice + hotend.soft_pwm_amount = MPC_MAX >> 1; + const millis_t heat_start_time = next_test_ms = ms; + celsius_float_t temp_samples[16]; + uint8_t sample_count = 0; + uint16_t sample_distance = 1; + float t1_time = 0; + + for (;;) { // Can be interrupted with M108 + if (!housekeeping(ms, current_temp, next_report_ms)) return; + + if (ELAPSED(ms, next_test_ms)) { + // Record samples between 100C and 200C + if (current_temp >= 100.0f) { + // If there are too many samples, space them more widely + if (sample_count == COUNT(temp_samples)) { + for (uint8_t i = 0; i < COUNT(temp_samples) / 2; i++) + temp_samples[i] = temp_samples[i*2]; + sample_count /= 2; + sample_distance *= 2; + } + + if (sample_count == 0) t1_time = float(ms - heat_start_time) / 1000.0f; + temp_samples[sample_count++] = current_temp; + } + + if (current_temp >= 200.0f) break; + + next_test_ms += 1000UL * sample_distance; + } + } + hotend.soft_pwm_amount = 0; + + // Calculate physical constants from three equally-spaced samples + sample_count = (sample_count + 1) / 2 * 2 - 1; + const float t1 = temp_samples[0], + t2 = temp_samples[(sample_count - 1) >> 1], + t3 = temp_samples[sample_count - 1]; + float asymp_temp = (t2 * t2 - t1 * t3) / (2 * t2 - t1 - t3), + block_responsiveness = -log((t2 - asymp_temp) / (t1 - asymp_temp)) / (sample_distance * (sample_count >> 1)); + + constants.ambient_xfer_coeff_fan0 = constants.heater_power * (MPC_MAX) / 255 / (asymp_temp - ambient_temp); + constants.fan255_adjustment = 0.0f; + constants.block_heat_capacity = constants.ambient_xfer_coeff_fan0 / block_responsiveness; + constants.sensor_responsiveness = block_responsiveness / (1.0f - (ambient_temp - asymp_temp) * exp(-block_responsiveness * t1_time) / (t1 - asymp_temp)); + + hotend.modeled_block_temp = asymp_temp + (ambient_temp - asymp_temp) * exp(-block_responsiveness * (ms - heat_start_time) / 1000.0f); + hotend.modeled_sensor_temp = current_temp; + + // Allow the system to stabilize under MPC, then get a better measure of ambient loss with and without fan + SERIAL_ECHOLNPGM(STR_MPC_MEASURING_AMBIENT, hotend.modeled_block_temp); + LCD_MESSAGE(MSG_MPC_MEASURING_AMBIENT); + hotend.target = hotend.modeled_block_temp; + next_test_ms = ms + MPC_dT * 1000; + constexpr millis_t settle_time = 20000UL, test_duration = 20000UL; + millis_t settle_end_ms = ms + settle_time, + test_end_ms = settle_end_ms + test_duration; + float total_energy_fan0 = 0.0f; + #if HAS_FAN + bool fan0_done = false; + float total_energy_fan255 = 0.0f; + #endif + float last_temp = current_temp; + + for (;;) { // Can be interrupted with M108 + if (!housekeeping(ms, current_temp, next_report_ms)) return; + + if (ELAPSED(ms, next_test_ms)) { + hotend.soft_pwm_amount = (int)get_pid_output_hotend(active_extruder) >> 1; + + if (ELAPSED(ms, settle_end_ms) && !ELAPSED(ms, test_end_ms) && TERN1(HAS_FAN, !fan0_done)) + 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); + planner.sync_fan_speeds(fan_speed); + settle_end_ms = ms + settle_time; + test_end_ms = settle_end_ms + test_duration; + fan0_done = true; + } + else if (ELAPSED(ms, settle_end_ms) && !ELAPSED(ms, test_end_ms)) + total_energy_fan255 += constants.heater_power * hotend.soft_pwm_amount / 127 * MPC_dT + (last_temp - current_temp) * constants.block_heat_capacity; + #endif + else if (ELAPSED(ms, test_end_ms)) break; + + last_temp = current_temp; + next_test_ms += MPC_dT * 1000; + } + + if (!WITHIN(current_temp, t3 - 15.0f, hotend.target + 15.0f)) { + SERIAL_ECHOLNPGM(STR_MPC_TEMPERATURE_ERROR); + break; + } + } + + const float power_fan0 = total_energy_fan0 * 1000 / test_duration; + constants.ambient_xfer_coeff_fan0 = power_fan0 / (hotend.target - ambient_temp); + + #if HAS_FAN + const float power_fan255 = total_energy_fan255 * 1000 / test_duration, + ambient_xfer_coeff_fan255 = power_fan255 / (hotend.target - ambient_temp); + constants.fan255_adjustment = ambient_xfer_coeff_fan255 - constants.ambient_xfer_coeff_fan0; + #endif + + // Calculate a new and better asymptotic temperature and re-evaluate the other constants + asymp_temp = ambient_temp + constants.heater_power * (MPC_MAX) / 255 / constants.ambient_xfer_coeff_fan0; + block_responsiveness = -log((t2 - asymp_temp) / (t1 - asymp_temp)) / (sample_distance * (sample_count >> 1)); + constants.block_heat_capacity = constants.ambient_xfer_coeff_fan0 / block_responsiveness; + constants.sensor_responsiveness = block_responsiveness / (1.0f - (ambient_temp - asymp_temp) * exp(-block_responsiveness * t1_time) / (t1 - asymp_temp)); + + SERIAL_ECHOPGM(STR_MPC_AUTOTUNE); + SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_FINISHED); + + /* <-- add a slash to enable + SERIAL_ECHOLNPGM("t1_time ", t1_time); + SERIAL_ECHOLNPGM("sample_count ", sample_count); + SERIAL_ECHOLNPGM("sample_distance ", sample_distance); + for (uint8_t i = 0; i < sample_count; i++) + SERIAL_ECHOLNPGM("sample ", i, " : ", temp_samples[i]); + SERIAL_ECHOLNPGM("t1 ", t1, " t2 ", t2, " t3 ", t3); + SERIAL_ECHOLNPGM("asymp_temp ", asymp_temp); + SERIAL_ECHOLNPAIR_F("block_responsiveness ", block_responsiveness, 4); + //*/ + SERIAL_ECHOLNPGM("MPC_BLOCK_HEAT_CAPACITY ", constants.block_heat_capacity); + SERIAL_ECHOLNPAIR_F("MPC_SENSOR_RESPONSIVENESS ", constants.sensor_responsiveness, 4); + SERIAL_ECHOLNPAIR_F("MPC_AMBIENT_XFER_COEFF ", constants.ambient_xfer_coeff_fan0, 4); + TERN_(HAS_FAN, SERIAL_ECHOLNPAIR_F("MPC_AMBIENT_XFER_COEFF_FAN255 ", ambient_xfer_coeff_fan255, 4)); + } + +#endif // MPCTEMP + int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { switch (heater_id) { #if HAS_HEATED_BED @@ -887,16 +1141,6 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { HOTEND_LOOP() { if (temp_hotend[e].celsius >= EXTRUDER_AUTO_FAN_TEMPERATURE) { SBI(fanState, pgm_read_byte(&fanBit[e])); - #if MOTHERBOARD == BOARD_ULTIMAIN_2 - // For the UM2 the head fan is connected to PJ6, which does not have an Arduino PIN definition. So use direct register access. - // https://github.com/Ultimaker/Ultimaker2Marlin/blob/master/Marlin/temperature.cpp#L553 - SBI(DDRJ, 6); SBI(PORTJ, 6); - #endif - } - else { - #if MOTHERBOARD == BOARD_ULTIMAIN_2 - SBI(DDRJ, 6); CBI(PORTJ, 6); - #endif } } @@ -912,7 +1156,7 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { #define _UPDATE_AUTO_FAN(P,D,A) do{ \ if (PWM_PIN(P##_AUTO_FAN_PIN) && A < 255) \ - set_pwm_duty(pin_t(P##_AUTO_FAN_PIN), D ? A : 0); \ + hal.set_pwm_duty(pin_t(P##_AUTO_FAN_PIN), D ? A : 0); \ else \ WRITE(P##_AUTO_FAN_PIN, D); \ }while(0) @@ -984,18 +1228,14 @@ int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { inline void loud_kill(FSTR_P const lcd_msg, const heater_id_t heater_id) { marlin_state = MF_KILLED; thermalManager.disable_all_heaters(); - #if USE_BEEPER + #if HAS_BEEPER for (uint8_t i = 20; i--;) { - WRITE(BEEPER_PIN, HIGH); - delay(25); - watchdog_refresh(); - WRITE(BEEPER_PIN, LOW); - delay(40); - watchdog_refresh(); - delay(40); - watchdog_refresh(); + hal.watchdog_refresh(); + buzzer.click(25); + delay(80); + hal.watchdog_refresh(); } - WRITE(BEEPER_PIN, HIGH); + buzzer.on(); #endif #if ENABLED(NOZZLE_PARK_FEATURE) if (!homing_needed_error()) { @@ -1038,7 +1278,7 @@ void Temperature::_temp_error(const heater_id_t heater_id, FSTR_P const serial_m } disable_all_heaters(); // always disable (even for bogus temp) - watchdog_refresh(); + hal.watchdog_refresh(); #if BOGUS_TEMPERATURE_GRACE_PERIOD const millis_t ms = millis(); @@ -1090,7 +1330,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { static hotend_pid_t work_pid[HOTENDS]; static float temp_iState[HOTENDS] = { 0 }, temp_dState[HOTENDS] = { 0 }; - static bool pid_reset[HOTENDS] = { false }; + static Flags pid_reset; const float pid_error = temp_hotend[ee].target - temp_hotend[ee].celsius; float pid_output; @@ -1100,17 +1340,17 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { || TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out) ) { pid_output = 0; - pid_reset[ee] = true; + pid_reset.set(ee); } else if (pid_error > PID_FUNCTIONAL_RANGE) { - pid_output = BANG_MAX; - pid_reset[ee] = true; + 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[ee] = false; + 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); @@ -1130,9 +1370,9 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { work_pid[ee].Kc = 0; if (this_hotend) { const long e_position = stepper.position(E_AXIS); - if (e_position > last_e_position) { - lpq[lpq_ptr] = e_position - last_e_position; - last_e_position = e_position; + if (e_position > pes_e_position) { + lpq[lpq_ptr] = e_position - pes_e_position; + pes_e_position = e_position; } else lpq[lpq_ptr] = 0; @@ -1175,7 +1415,86 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { } #endif - #else // No PID enabled + #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_block_temp = hotend.modeled_sensor_temp = hotend.celsius; + } + + #if HOTENDS == 1 + constexpr bool this_hotend = true; + #else + const bool this_hotend = (ee == active_extruder); + #endif + + 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 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 + + if (this_hotend) { + const int32_t e_position = stepper.position(E_AXIS); + const float e_speed = (e_position - mpc_e_position) * planner.mm_per_step[E_AXIS] / MPC_dT; + + // The position can appear to make big jumps when, e.g. homing + if (fabs(e_speed) > planner.settings.max_feedrate_mm_s[E_AXIS]) + mpc_e_position = e_position; + else if (e_speed > 0.0f) { // Ignore retract/recover moves + ambient_xfer_coeff += e_speed * constants.filament_heat_capacity_permm; + mpc_e_position = e_position; + } + } + + // Update the modeled temperatures + float blocktempdelta = hotend.soft_pwm_amount * constants.heater_power * (MPC_dT / 127) / constants.block_heat_capacity; + blocktempdelta += (hotend.modeled_ambient_temp - hotend.modeled_block_temp) * ambient_xfer_coeff * MPC_dT / constants.block_heat_capacity; + hotend.modeled_block_temp += blocktempdelta; + + const float sensortempdelta = (hotend.modeled_block_temp - hotend.modeled_sensor_temp) * (constants.sensor_responsiveness * MPC_dT); + hotend.modeled_sensor_temp += sensortempdelta; + + // Any delta between hotend.modeled_sensor_temp and hotend.celsius is either model + // error diverging slowly or (fast) noise. Slowly correct towards this temperature and noise will average out. + const float delta_to_apply = (hotend.celsius - hotend.modeled_sensor_temp) * (MPC_SMOOTHING_FACTOR); + hotend.modeled_block_temp += delta_to_apply; + hotend.modeled_sensor_temp += delta_to_apply; + + // 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); + + float power = 0.0; + if (hotend.target != 0 && TERN1(HEATER_IDLE_HANDLER, !heater_idle[ee].timed_out)) { + // 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; + } + + float pid_output = power * 254.0f / constants.heater_power + 1.0f; // Ensure correct quantization into a range of 0 to 127 + pid_output = constrain(pid_output, 0, MPC_MAX); + + /* <-- add a slash to enable + static uint32_t nexttime = millis() + 1000; + if (ELAPSED(millis(), nexttime)) { + nexttime += 1000; + SERIAL_ECHOLNPGM("block temp ", hotend.modeled_block_temp, + ", celsius ", hotend.celsius, + ", blocktempdelta ", blocktempdelta, + ", delta_to_apply ", delta_to_apply, + ", ambient ", hotend.modeled_ambient_temp, + ", power ", power, + ", pid_output ", pid_output, + ", pwm ", (int)pid_output >> 1); + } + //*/ + + #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; @@ -1323,7 +1642,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { * - Update the heated bed PID output value */ void Temperature::manage_heater() { - if (marlin_state == MF_INITIALIZING) return watchdog_refresh(); // If Marlin isn't started, at least reset the watchdog! + 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; @@ -1444,7 +1763,7 @@ void Temperature::manage_heater() { TERN_(HEATER_IDLE_HANDLER, heater_idle[IDLE_INDEX_BED].update(ms)); - #if HAS_THERMALLY_PROTECTED_BED + #if ENABLED(THERMAL_PROTECTION_BED) tr_state_machine[RUNAWAY_IND_BED].run(temp_bed.celsius, temp_bed.target, H_BED, THERMAL_PROTECTION_BED_PERIOD, THERMAL_PROTECTION_BED_HYSTERESIS); #endif @@ -1562,7 +1881,7 @@ void Temperature::manage_heater() { #endif #if ENABLED(CHAMBER_VENT) flag_chamber_excess_heat = false; - MOVE_SERVO(CHAMBER_VENT_SERVO_NR, 90); + servo[CHAMBER_VENT_SERVO_NR].move(90); #endif } #endif @@ -1578,7 +1897,7 @@ void Temperature::manage_heater() { if (flag_chamber_excess_heat) { temp_chamber.soft_pwm_amount = 0; #if ENABLED(CHAMBER_VENT) - if (!flag_chamber_off) MOVE_SERVO(CHAMBER_VENT_SERVO_NR, temp_chamber.celsius <= temp_chamber.target ? 0 : 90); + if (!flag_chamber_off) servo[CHAMBER_VENT_SERVO_NR].move(temp_chamber.celsius <= temp_chamber.target ? 0 : 90); #endif } else { @@ -1591,7 +1910,7 @@ void Temperature::manage_heater() { temp_chamber.soft_pwm_amount = temp_chamber.celsius < temp_chamber.target ? (MAX_CHAMBER_POWER) >> 1 : 0; #endif #if ENABLED(CHAMBER_VENT) - if (!flag_chamber_off) MOVE_SERVO(CHAMBER_VENT_SERVO_NR, 0); + if (!flag_chamber_off) servo[CHAMBER_VENT_SERVO_NR].move(0); #endif } } @@ -1694,8 +2013,8 @@ void Temperature::manage_heater() { m = (l + r) >> 1; \ if (!m) return celsius_t(pgm_read_word(&TBL[0].celsius)); \ if (m == l || m == r) return celsius_t(pgm_read_word(&TBL[LEN-1].celsius)); \ - int16_t v00 = pgm_read_word(&TBL[m-1].value), \ - v10 = pgm_read_word(&TBL[m-0].value); \ + raw_adc_t v00 = pgm_read_word(&TBL[m-1].value), \ + v10 = pgm_read_word(&TBL[m-0].value); \ if (raw < v00) r = m; \ else if (raw > v10) l = m; \ else { \ @@ -1789,7 +2108,7 @@ void Temperature::manage_heater() { SERIAL_EOL(); } - celsius_float_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int16_t raw) { + celsius_float_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const raw_adc_t raw) { if (!WITHIN(t_index, 0, COUNT(user_thermistor) - 1)) return 25; @@ -1803,9 +2122,9 @@ void Temperature::manage_heater() { - (t.beta_recip * t.res_25_log) - (t.sh_c_coeff * cu(t.res_25_log)); } - // maximum adc value .. take into account the over sampling - const int adc_max = MAX_RAW_THERMISTOR_VALUE, - adc_raw = constrain(raw, 1, adc_max - 1); // constrain to prevent divide-by-zero + // Maximum ADC value .. take into account the over sampling + constexpr raw_adc_t adc_max = MAX_RAW_THERMISTOR_VALUE; + const raw_adc_t adc_raw = constrain(raw, 1, adc_max - 1); // constrain to prevent divide-by-zero const float adc_inverse = (adc_max - adc_raw) - 0.5f, resistance = t.series_res * (adc_raw + 0.5f) / adc_inverse, @@ -1825,7 +2144,7 @@ void Temperature::manage_heater() { #if HAS_HOTEND // Derived from RepRap FiveD extruder::getTemperature() // For hot end temperature measurement. - celsius_float_t Temperature::analog_to_celsius_hotend(const int16_t raw, const uint8_t e) { + celsius_float_t Temperature::analog_to_celsius_hotend(const raw_adc_t raw, const uint8_t e) { if (e >= HOTENDS) { SERIAL_ERROR_START(); SERIAL_ECHO(e); @@ -1841,11 +2160,11 @@ void Temperature::manage_heater() { #elif TEMP_SENSOR_0_IS_MAX_TC #if TEMP_SENSOR_0_IS_MAX31865 return TERN(LIB_INTERNAL_MAX31865, - max31865_0.temperature((uint16_t)raw), + max31865_0.temperature(raw), max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0) ); #else - return raw * 0.25; + return (int16_t)raw * 0.25; #endif #elif TEMP_SENSOR_0_IS_AD595 return TEMP_AD595(raw); @@ -1860,11 +2179,11 @@ void Temperature::manage_heater() { #elif TEMP_SENSOR_1_IS_MAX_TC #if TEMP_SENSOR_0_IS_MAX31865 return TERN(LIB_INTERNAL_MAX31865, - max31865_1.temperature((uint16_t)raw), + max31865_1.temperature(raw), max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1) ); #else - return raw * 0.25; + return (int16_t)raw * 0.25; #endif #elif TEMP_SENSOR_1_IS_AD595 return TEMP_AD595(raw); @@ -1948,7 +2267,7 @@ void Temperature::manage_heater() { #if HAS_HEATED_BED // For bed temperature measurement. - celsius_float_t Temperature::analog_to_celsius_bed(const int16_t raw) { + celsius_float_t Temperature::analog_to_celsius_bed(const raw_adc_t raw) { #if TEMP_SENSOR_BED_IS_CUSTOM return user_thermistor_to_deg_c(CTI_BED, raw); #elif TEMP_SENSOR_BED_IS_THERMISTOR @@ -1966,7 +2285,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_CHAMBER // For chamber temperature measurement. - celsius_float_t Temperature::analog_to_celsius_chamber(const int16_t raw) { + celsius_float_t Temperature::analog_to_celsius_chamber(const raw_adc_t raw) { #if TEMP_SENSOR_CHAMBER_IS_CUSTOM return user_thermistor_to_deg_c(CTI_CHAMBER, raw); #elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR @@ -1984,7 +2303,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_COOLER // For cooler temperature measurement. - celsius_float_t Temperature::analog_to_celsius_cooler(const int16_t raw) { + celsius_float_t Temperature::analog_to_celsius_cooler(const raw_adc_t raw) { #if TEMP_SENSOR_COOLER_IS_CUSTOM return user_thermistor_to_deg_c(CTI_COOLER, raw); #elif TEMP_SENSOR_COOLER_IS_THERMISTOR @@ -2002,7 +2321,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_PROBE // For probe temperature measurement. - celsius_float_t Temperature::analog_to_celsius_probe(const int16_t raw) { + celsius_float_t Temperature::analog_to_celsius_probe(const raw_adc_t raw) { #if TEMP_SENSOR_PROBE_IS_CUSTOM return user_thermistor_to_deg_c(CTI_PROBE, raw); #elif TEMP_SENSOR_PROBE_IS_THERMISTOR @@ -2020,7 +2339,7 @@ void Temperature::manage_heater() { #if HAS_TEMP_BOARD // For motherboard temperature measurement. - celsius_float_t Temperature::analog_to_celsius_board(const int16_t raw) { + celsius_float_t Temperature::analog_to_celsius_board(const raw_adc_t raw) { #if TEMP_SENSOR_BOARD_IS_CUSTOM return user_thermistor_to_deg_c(CTI_BOARD, raw); #elif TEMP_SENSOR_BOARD_IS_THERMISTOR @@ -2038,13 +2357,13 @@ void Temperature::manage_heater() { #if HAS_TEMP_REDUNDANT // For redundant temperature measurement. - celsius_float_t Temperature::analog_to_celsius_redundant(const int16_t raw) { + 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) - return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_0.temperature((uint16_t)raw), raw * 0.25); + 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) - return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_1.temperature((uint16_t)raw), raw * 0.25); + return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_1.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 @@ -2072,22 +2391,22 @@ void Temperature::manage_heater() { */ void Temperature::updateTemperaturesFromRawValues() { - watchdog_refresh(); // Reset because raw_temps_ready was set by the interrupt + hal.watchdog_refresh(); // Reset because raw_temps_ready was set by the interrupt - TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].raw = READ_MAX_TC(0)); - TERN_(TEMP_SENSOR_1_IS_MAX_TC, temp_hotend[1].raw = READ_MAX_TC(1)); - TERN_(TEMP_SENSOR_REDUNDANT_IS_MAX_TC, temp_redundant.raw = READ_MAX_TC(HEATER_ID(TEMP_SENSOR_REDUNDANT_SOURCE))); + 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 HAS_HOTEND - HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e); + HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].getraw(), e); #endif - TERN_(HAS_HEATED_BED, temp_bed.celsius = analog_to_celsius_bed(temp_bed.raw)); - TERN_(HAS_TEMP_CHAMBER, temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.raw)); - TERN_(HAS_TEMP_COOLER, temp_cooler.celsius = analog_to_celsius_cooler(temp_cooler.raw)); - TERN_(HAS_TEMP_PROBE, temp_probe.celsius = analog_to_celsius_probe(temp_probe.raw)); - TERN_(HAS_TEMP_BOARD, temp_board.celsius = analog_to_celsius_board(temp_board.raw)); - TERN_(HAS_TEMP_REDUNDANT, temp_redundant.celsius = analog_to_celsius_redundant(temp_redundant.raw)); + TERN_(HAS_HEATED_BED, temp_bed.celsius = analog_to_celsius_bed(temp_bed.getraw())); + TERN_(HAS_TEMP_CHAMBER, temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.getraw())); + TERN_(HAS_TEMP_COOLER, temp_cooler.celsius = analog_to_celsius_cooler(temp_cooler.getraw())); + TERN_(HAS_TEMP_PROBE, temp_probe.celsius = analog_to_celsius_probe(temp_probe.getraw())); + TERN_(HAS_TEMP_BOARD, temp_board.celsius = analog_to_celsius_board(temp_board.getraw())); + TERN_(HAS_TEMP_REDUNDANT, temp_redundant.celsius = analog_to_celsius_redundant(temp_redundant.getraw())); TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_measured_mm()); TERN_(HAS_POWER_MONITOR, power_monitor.capture_values()); @@ -2113,46 +2432,45 @@ void Temperature::updateTemperaturesFromRawValues() { }; LOOP_L_N(e, COUNT(temp_dir)) { - const int8_t tdir = temp_dir[e]; - if (tdir) { - const int16_t rawtemp = temp_hotend[e].raw * tdir; // normal direction, +rawtemp, else -rawtemp - if (rawtemp > temp_range[e].raw_max * tdir) max_temp_error((heater_id_t)e); - - const bool heater_on = temp_hotend[e].target > 0; - if (heater_on && rawtemp < temp_range[e].raw_min * tdir && !is_preheating(e)) { - #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); - } + 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); + + 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 - else - consecutive_low_temperature_error[e] = 0; + if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED) #endif + min_temp_error((heater_id_t)e); } + #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.raw, maxtemp_raw_BED)) max_temp_error(H_BED); - if (temp_bed.target > 0 && TP_CMP(BED, mintemp_raw_BED, temp_bed.raw)) min_temp_error(H_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); #endif #if BOTH(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER) - if (TP_CMP(CHAMBER, temp_chamber.raw, maxtemp_raw_CHAMBER)) max_temp_error(H_CHAMBER); - if (temp_chamber.target > 0 && TP_CMP(CHAMBER, mintemp_raw_CHAMBER, temp_chamber.raw)) min_temp_error(H_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); #endif #if BOTH(HAS_COOLER, THERMAL_PROTECTION_COOLER) - if (cutter.unitPower > 0 && TP_CMP(COOLER, temp_cooler.raw, maxtemp_raw_COOLER)) max_temp_error(H_COOLER); - if (TP_CMP(COOLER, mintemp_raw_COOLER, temp_cooler.raw)) min_temp_error(H_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); #endif #if BOTH(HAS_TEMP_BOARD, THERMAL_PROTECTION_BOARD) - if (TP_CMP(BOARD, temp_board.raw, maxtemp_raw_BOARD)) max_temp_error(H_BOARD); - if (TP_CMP(BOARD, mintemp_raw_BOARD, temp_board.raw)) min_temp_error(H_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); #endif #undef TP_CMP @@ -2181,7 +2499,7 @@ void Temperature::init() { TERN_(PROBING_HEATERS_OFF, paused_for_probing = false); #if BOTH(PIDTEMP, PID_EXTRUSION_SCALING) - last_e_position = 0; + pes_e_position = 0; #endif // Init (and disable) SPI thermocouples @@ -2251,6 +2569,10 @@ void Temperature::init() { )); #endif + #if ENABLED(MPCTEMP) + HOTEND_LOOP() temp_hotend[e].modeled_block_temp = NAN; + #endif + #if HAS_HEATER_0 #ifdef BOARD_OPENDRAIN_MOSFETS OUT_WRITE_OD(HEATER_0_PIN, HEATER_0_INVERTING); @@ -2326,74 +2648,33 @@ void Temperature::init() { TERN_(HAS_MAXTC_SW_SPI, max_tc_spi.init()); - HAL_adc_init(); + hal.adc_init(); + + TERN_(HAS_TEMP_ADC_0, hal.adc_enable(TEMP_0_PIN)); + TERN_(HAS_TEMP_ADC_1, hal.adc_enable(TEMP_1_PIN)); + TERN_(HAS_TEMP_ADC_2, hal.adc_enable(TEMP_2_PIN)); + TERN_(HAS_TEMP_ADC_3, hal.adc_enable(TEMP_3_PIN)); + TERN_(HAS_TEMP_ADC_4, hal.adc_enable(TEMP_4_PIN)); + TERN_(HAS_TEMP_ADC_5, hal.adc_enable(TEMP_5_PIN)); + TERN_(HAS_TEMP_ADC_6, hal.adc_enable(TEMP_6_PIN)); + TERN_(HAS_TEMP_ADC_7, hal.adc_enable(TEMP_7_PIN)); + TERN_(HAS_JOY_ADC_X, hal.adc_enable(JOY_X_PIN)); + TERN_(HAS_JOY_ADC_Y, hal.adc_enable(JOY_Y_PIN)); + TERN_(HAS_JOY_ADC_Z, hal.adc_enable(JOY_Z_PIN)); + TERN_(HAS_TEMP_ADC_BED, hal.adc_enable(TEMP_BED_PIN)); + TERN_(HAS_TEMP_ADC_CHAMBER, hal.adc_enable(TEMP_CHAMBER_PIN)); + TERN_(HAS_TEMP_ADC_PROBE, hal.adc_enable(TEMP_PROBE_PIN)); + TERN_(HAS_TEMP_ADC_COOLER, hal.adc_enable(TEMP_COOLER_PIN)); + TERN_(HAS_TEMP_ADC_BOARD, hal.adc_enable(TEMP_BOARD_PIN)); + TERN_(HAS_TEMP_ADC_REDUNDANT, hal.adc_enable(TEMP_REDUNDANT_PIN)); + TERN_(FILAMENT_WIDTH_SENSOR, hal.adc_enable(FILWIDTH_PIN)); + TERN_(HAS_ADC_BUTTONS, hal.adc_enable(ADC_KEYPAD_PIN)); + TERN_(POWER_MONITOR_CURRENT, hal.adc_enable(POWER_MONITOR_CURRENT_PIN)); + TERN_(POWER_MONITOR_VOLTAGE, hal.adc_enable(POWER_MONITOR_VOLTAGE_PIN)); - #if HAS_TEMP_ADC_0 - HAL_ANALOG_SELECT(TEMP_0_PIN); - #endif - #if HAS_TEMP_ADC_1 - HAL_ANALOG_SELECT(TEMP_1_PIN); - #endif - #if HAS_TEMP_ADC_2 - HAL_ANALOG_SELECT(TEMP_2_PIN); - #endif - #if HAS_TEMP_ADC_3 - HAL_ANALOG_SELECT(TEMP_3_PIN); - #endif - #if HAS_TEMP_ADC_4 - HAL_ANALOG_SELECT(TEMP_4_PIN); - #endif - #if HAS_TEMP_ADC_5 - HAL_ANALOG_SELECT(TEMP_5_PIN); - #endif - #if HAS_TEMP_ADC_6 - HAL_ANALOG_SELECT(TEMP_6_PIN); - #endif - #if HAS_TEMP_ADC_7 - HAL_ANALOG_SELECT(TEMP_7_PIN); - #endif - #if HAS_JOY_ADC_X - HAL_ANALOG_SELECT(JOY_X_PIN); - #endif - #if HAS_JOY_ADC_Y - HAL_ANALOG_SELECT(JOY_Y_PIN); - #endif - #if HAS_JOY_ADC_Z - HAL_ANALOG_SELECT(JOY_Z_PIN); - #endif #if HAS_JOY_ADC_EN SET_INPUT_PULLUP(JOY_EN_PIN); #endif - #if HAS_TEMP_ADC_BED - HAL_ANALOG_SELECT(TEMP_BED_PIN); - #endif - #if HAS_TEMP_ADC_CHAMBER - HAL_ANALOG_SELECT(TEMP_CHAMBER_PIN); - #endif - #if HAS_TEMP_ADC_COOLER - HAL_ANALOG_SELECT(TEMP_COOLER_PIN); - #endif - #if HAS_TEMP_ADC_PROBE - HAL_ANALOG_SELECT(TEMP_PROBE_PIN); - #endif - #if HAS_TEMP_ADC_BOARD - HAL_ANALOG_SELECT(TEMP_BOARD_PIN); - #endif - #if HAS_TEMP_ADC_REDUNDANT - HAL_ANALOG_SELECT(TEMP_REDUNDANT_PIN); - #endif - #if ENABLED(FILAMENT_WIDTH_SENSOR) - HAL_ANALOG_SELECT(FILWIDTH_PIN); - #endif - #if HAS_ADC_BUTTONS - HAL_ANALOG_SELECT(ADC_KEYPAD_PIN); - #endif - #if ENABLED(POWER_MONITOR_CURRENT) - HAL_ANALOG_SELECT(POWER_MONITOR_CURRENT_PIN); - #endif - #if ENABLED(POWER_MONITOR_VOLTAGE) - HAL_ANALOG_SELECT(POWER_MONITOR_VOLTAGE_PIN); - #endif HAL_timer_start(MF_TIMER_TEMP, TEMP_TIMER_FREQUENCY); ENABLE_TEMPERATURE_INTERRUPT(); @@ -2428,13 +2709,15 @@ void Temperature::init() { #if HAS_HOTEND #define _TEMP_MIN_E(NR) do{ \ - const celsius_t tmin = _MAX(HEATER_##NR##_MINTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, (int)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))); \ + const celsius_t tmin_tmp = TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 0, int16_t(pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MINTEMP_IND].celsius))), \ + tmin = _MAX(HEATER_##NR##_MINTEMP, tmin_tmp); \ temp_range[NR].mintemp = tmin; \ while (analog_to_celsius_hotend(temp_range[NR].raw_min, NR) < tmin) \ temp_range[NR].raw_min += TEMPDIR(NR) * (OVERSAMPLENR); \ }while(0) #define _TEMP_MAX_E(NR) do{ \ - const celsius_t tmax = _MIN(HEATER_##NR##_MAXTEMP, TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, (int)pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MAXTEMP_IND].celsius) - 1)); \ + const celsius_t tmax_tmp = TERN(TEMP_SENSOR_##NR##_IS_CUSTOM, 2000, int16_t(pgm_read_word(&TEMPTABLE_##NR [TEMP_SENSOR_##NR##_MAXTEMP_IND].celsius)) - 1), \ + tmax = _MIN(HEATER_##NR##_MAXTEMP, tmax_tmp); \ temp_range[NR].maxtemp = tmax; \ while (analog_to_celsius_hotend(temp_range[NR].raw_max, NR) > tmax) \ temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \ @@ -2570,19 +2853,29 @@ void Temperature::init() { ); */ - #if HEATER_IDLE_HANDLER + #if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR) + if (state == TRMalfunction) { // temperature invariance may continue, regardless of heater state + variance += ABS(current - last_temp); // no need for detection window now, a single change in variance is enough + last_temp = current; + if (!NEAR_ZERO(variance)) { + variance_timer = millis() + SEC_TO_MS(period_seconds); + variance = 0.0; + state = TRStable; // resume from where we detected the problem + } + } + #endif + + if (TERN1(THERMAL_PROTECTION_VARIANCE_MONITOR, state != TRMalfunction)) { // If the heater idle timeout expires, restart - if (heater_idle[idle_index].timed_out) { + if (TERN0(HEATER_IDLE_HANDLER, heater_idle[idle_index].timed_out)) { state = TRInactive; running_temp = 0; + TERN_(THERMAL_PROTECTION_VARIANCE_MONITOR, variance_timer = 0); } - else - #endif - { - // If the target temperature changes, restart - if (running_temp != target) { + else if (running_temp != target) { // If the target temperature changes, restart running_temp = target; state = target > 0 ? TRFirstHeating : TRInactive; + TERN_(THERMAL_PROTECTION_VARIANCE_MONITOR, variance_timer = 0); } } @@ -2596,7 +2889,7 @@ void Temperature::init() { state = TRStable; // While the temperature is stable watch for a bad temperature - case TRStable: + case TRStable: { #if ENABLED(ADAPTIVE_FAN_SLOWING) if (adaptive_fan_slowing && heater_id >= 0) { @@ -2614,16 +2907,42 @@ void Temperature::init() { } #endif + const millis_t now = millis(); + + #if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR) + if (PENDING(now, variance_timer)) { + variance += ABS(current - last_temp); + last_temp = current; + } + else { + if (NEAR_ZERO(variance) && variance_timer) { // valid variance monitoring window + state = TRMalfunction; + break; + } + variance_timer = now + SEC_TO_MS(period_seconds); + variance = 0.0; + last_temp = current; + } + #endif + if (current >= running_temp - hysteresis_degc) { - timer = millis() + SEC_TO_MS(period_seconds); + timer = now + SEC_TO_MS(period_seconds); break; } - else if (PENDING(millis(), timer)) break; + else if (PENDING(now, timer)) break; state = TRRunaway; + } // fall through + case TRRunaway: TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0)); _temp_error(heater_id, FPSTR(str_t_thermal_runaway), GET_TEXT_F(MSG_THERMAL_RUNAWAY)); + + #if ENABLED(THERMAL_PROTECTION_VARIANCE_MONITOR) + case TRMalfunction: + TERN_(HAS_DWIN_E3V2_BASIC, DWIN_Popup_Temperature(0)); + _temp_error(heater_id, FPSTR(str_t_temp_malfunction), GET_TEXT_F(MSG_TEMP_MALFUNCTION)); + #endif } } @@ -2741,7 +3060,7 @@ void Temperature::disable_all_heaters() { * @param hindex the hotend we're referencing (if MULTI_MAX_TC) * @return integer representing the board's buffer, to be converted later if needed */ - int16_t Temperature::read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex/*=0*/)) { + raw_adc_t Temperature::read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex/*=0*/)) { #define MAXTC_HEAT_INTERVAL 250UL #if HAS_MAX31855 @@ -2760,7 +3079,7 @@ void Temperature::disable_all_heaters() { #if HAS_MULTI_MAX_TC // Needed to return the correct temp when this is called between readings - static int16_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 }; + 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) @@ -2789,7 +3108,7 @@ void Temperature::disable_all_heaters() { // Return last-read value between readings millis_t ms = millis(); if (PENDING(ms, next_max_tc_ms[hindex])) - return (int16_t)THERMO_TEMP(hindex); + return THERMO_TEMP(hindex); next_max_tc_ms[hindex] = ms + MAXTC_HEAT_INTERVAL; @@ -2803,7 +3122,7 @@ void Temperature::disable_all_heaters() { spiInit(MAX_TC_SPEED_BITS); #endif - MAXTC_CS_WRITE(LOW); // enable MAXTC + MAXTC_CS_WRITE(LOW); // Enable MAXTC DELAY_NS(100); // Ensure 100ns delay // Read a big-endian temperature value without using a library @@ -2812,7 +3131,7 @@ void Temperature::disable_all_heaters() { if (i > 0) max_tc_temp <<= 8; // shift left if not the last byte } - MAXTC_CS_WRITE(HIGH); // disable MAXTC + MAXTC_CS_WRITE(HIGH); // Disable MAXTC #else #if HAS_MAX6675_LIBRARY MAX6675 &max6675ref = THERMO_SEL(max6675_0, max6675_1); @@ -2886,7 +3205,7 @@ void Temperature::disable_all_heaters() { THERMO_TEMP(hindex) = max_tc_temp; - return (int16_t)max_tc_temp; + return max_tc_temp; } #endif // HAS_MAX_TC @@ -2921,8 +3240,8 @@ void Temperature::update_raw_temperatures() { TERN_(HAS_TEMP_ADC_BED, temp_bed.update()); TERN_(HAS_TEMP_ADC_CHAMBER, temp_chamber.update()); TERN_(HAS_TEMP_ADC_PROBE, temp_probe.update()); - TERN_(HAS_TEMP_ADC_BOARD, temp_board.update()); TERN_(HAS_TEMP_ADC_COOLER, temp_cooler.update()); + TERN_(HAS_TEMP_ADC_BOARD, temp_board.update()); TERN_(HAS_JOY_ADC_X, joystick.x.update()); TERN_(HAS_JOY_ADC_Y, joystick.y.update()); @@ -3009,8 +3328,9 @@ class SoftPWM { }; /** - * Handle various ~1KHz tasks associated with temperature - * - Heater PWM (~1KHz with scaler) + * Handle various ~1kHz tasks associated with temperature + * - Check laser safety timeout + * - Heater PWM (~1kHz with scaler) * - LCD Button polling (~500Hz) * - Start / Read one ADC sensor * - Advance Babysteps @@ -3019,15 +3339,23 @@ class SoftPWM { */ void Temperature::isr() { + // Shut down the laser if steppers are inactive for > LASER_SAFETY_TIMEOUT_MS ms + #if LASER_SAFETY_TIMEOUT_MS > 0 + if (cutter.last_power_applied && ELAPSED(millis(), gcode.previous_move_ms + (LASER_SAFETY_TIMEOUT_MS))) { + cutter.power = 0; // Prevent planner idle from re-enabling power + cutter.apply_power(0); + } + #endif + static int8_t temp_count = -1; static ADCSensorState adc_sensor_state = StartupDelay; static uint8_t pwm_count = _BV(SOFT_PWM_SCALE); - // avoid multiple loads of pwm_count + // Avoid multiple loads of pwm_count uint8_t pwm_count_tmp = pwm_count; #if HAS_ADC_BUTTONS - static unsigned int raw_ADCKey_value = 0; + static raw_adc_t raw_ADCKey_value = 0; static bool ADCKey_pressed = false; #endif @@ -3301,8 +3629,8 @@ void Temperature::isr() { // 5: / 4 = 244.1406 Hz pwm_count = pwm_count_tmp + _BV(SOFT_PWM_SCALE); - // increment slow_pwm_count only every 64th pwm_count, - // i.e. yielding a PWM frequency of 16/128 Hz (8s). + // Increment slow_pwm_count only every 64th pwm_count, + // i.e., yielding a PWM frequency of 16/128 Hz (8s). if (((pwm_count >> SOFT_PWM_SCALE) & 0x3F) == 0) { slow_pwm_count++; slow_pwm_count &= 0x7F; @@ -3333,8 +3661,8 @@ void Temperature::isr() { * This gives each ADC 0.9765ms to charge up. */ #define ACCUMULATE_ADC(obj) do{ \ - if (!HAL_ADC_READY()) next_sensor_state = adc_sensor_state; \ - else obj.sample(HAL_READ_ADC()); \ + if (!hal.adc_ready()) next_sensor_state = adc_sensor_state; \ + else obj.sample(hal.adc_value()); \ }while(0) ADCSensorState next_sensor_state = adc_sensor_state < SensorsReady ? (ADCSensorState)(int(adc_sensor_state) + 1) : StartSampling; @@ -3366,115 +3694,115 @@ void Temperature::isr() { break; #if HAS_TEMP_ADC_0 - case PrepareTemp_0: HAL_START_ADC(TEMP_0_PIN); break; + case PrepareTemp_0: hal.adc_start(TEMP_0_PIN); break; case MeasureTemp_0: ACCUMULATE_ADC(temp_hotend[0]); break; #endif #if HAS_TEMP_ADC_BED - case PrepareTemp_BED: HAL_START_ADC(TEMP_BED_PIN); break; + case PrepareTemp_BED: hal.adc_start(TEMP_BED_PIN); break; case MeasureTemp_BED: ACCUMULATE_ADC(temp_bed); break; #endif #if HAS_TEMP_ADC_CHAMBER - case PrepareTemp_CHAMBER: HAL_START_ADC(TEMP_CHAMBER_PIN); break; + case PrepareTemp_CHAMBER: hal.adc_start(TEMP_CHAMBER_PIN); break; case MeasureTemp_CHAMBER: ACCUMULATE_ADC(temp_chamber); break; #endif #if HAS_TEMP_ADC_COOLER - case PrepareTemp_COOLER: HAL_START_ADC(TEMP_COOLER_PIN); break; + case PrepareTemp_COOLER: hal.adc_start(TEMP_COOLER_PIN); break; case MeasureTemp_COOLER: ACCUMULATE_ADC(temp_cooler); break; #endif #if HAS_TEMP_ADC_PROBE - case PrepareTemp_PROBE: HAL_START_ADC(TEMP_PROBE_PIN); break; + case PrepareTemp_PROBE: hal.adc_start(TEMP_PROBE_PIN); break; case MeasureTemp_PROBE: ACCUMULATE_ADC(temp_probe); break; #endif #if HAS_TEMP_ADC_BOARD - case PrepareTemp_BOARD: HAL_START_ADC(TEMP_BOARD_PIN); break; + case PrepareTemp_BOARD: hal.adc_start(TEMP_BOARD_PIN); break; case MeasureTemp_BOARD: ACCUMULATE_ADC(temp_board); break; #endif #if HAS_TEMP_ADC_REDUNDANT - case PrepareTemp_REDUNDANT: HAL_START_ADC(TEMP_REDUNDANT_PIN); break; + case PrepareTemp_REDUNDANT: hal.adc_start(TEMP_REDUNDANT_PIN); break; case MeasureTemp_REDUNDANT: ACCUMULATE_ADC(temp_redundant); break; #endif #if HAS_TEMP_ADC_1 - case PrepareTemp_1: HAL_START_ADC(TEMP_1_PIN); break; + case PrepareTemp_1: hal.adc_start(TEMP_1_PIN); break; case MeasureTemp_1: ACCUMULATE_ADC(temp_hotend[1]); break; #endif #if HAS_TEMP_ADC_2 - case PrepareTemp_2: HAL_START_ADC(TEMP_2_PIN); break; + case PrepareTemp_2: hal.adc_start(TEMP_2_PIN); break; case MeasureTemp_2: ACCUMULATE_ADC(temp_hotend[2]); break; #endif #if HAS_TEMP_ADC_3 - case PrepareTemp_3: HAL_START_ADC(TEMP_3_PIN); break; + case PrepareTemp_3: hal.adc_start(TEMP_3_PIN); break; case MeasureTemp_3: ACCUMULATE_ADC(temp_hotend[3]); break; #endif #if HAS_TEMP_ADC_4 - case PrepareTemp_4: HAL_START_ADC(TEMP_4_PIN); break; + case PrepareTemp_4: hal.adc_start(TEMP_4_PIN); break; case MeasureTemp_4: ACCUMULATE_ADC(temp_hotend[4]); break; #endif #if HAS_TEMP_ADC_5 - case PrepareTemp_5: HAL_START_ADC(TEMP_5_PIN); break; + case PrepareTemp_5: hal.adc_start(TEMP_5_PIN); break; case MeasureTemp_5: ACCUMULATE_ADC(temp_hotend[5]); break; #endif #if HAS_TEMP_ADC_6 - case PrepareTemp_6: HAL_START_ADC(TEMP_6_PIN); break; + case PrepareTemp_6: hal.adc_start(TEMP_6_PIN); break; case MeasureTemp_6: ACCUMULATE_ADC(temp_hotend[6]); break; #endif #if HAS_TEMP_ADC_7 - case PrepareTemp_7: HAL_START_ADC(TEMP_7_PIN); break; + case PrepareTemp_7: hal.adc_start(TEMP_7_PIN); break; case MeasureTemp_7: ACCUMULATE_ADC(temp_hotend[7]); break; #endif #if ENABLED(FILAMENT_WIDTH_SENSOR) - case Prepare_FILWIDTH: HAL_START_ADC(FILWIDTH_PIN); break; + case Prepare_FILWIDTH: hal.adc_start(FILWIDTH_PIN); break; case Measure_FILWIDTH: - if (!HAL_ADC_READY()) next_sensor_state = adc_sensor_state; // Redo this state - else filwidth.accumulate(HAL_READ_ADC()); + if (!hal.adc_ready()) next_sensor_state = adc_sensor_state; // Redo this state + else filwidth.accumulate(hal.adc_value()); break; #endif #if ENABLED(POWER_MONITOR_CURRENT) case Prepare_POWER_MONITOR_CURRENT: - HAL_START_ADC(POWER_MONITOR_CURRENT_PIN); + hal.adc_start(POWER_MONITOR_CURRENT_PIN); break; case Measure_POWER_MONITOR_CURRENT: - if (!HAL_ADC_READY()) next_sensor_state = adc_sensor_state; // Redo this state - else power_monitor.add_current_sample(HAL_READ_ADC()); + if (!hal.adc_ready()) next_sensor_state = adc_sensor_state; // Redo this state + else power_monitor.add_current_sample(hal.adc_value()); break; #endif #if ENABLED(POWER_MONITOR_VOLTAGE) case Prepare_POWER_MONITOR_VOLTAGE: - HAL_START_ADC(POWER_MONITOR_VOLTAGE_PIN); + hal.adc_start(POWER_MONITOR_VOLTAGE_PIN); break; case Measure_POWER_MONITOR_VOLTAGE: - if (!HAL_ADC_READY()) next_sensor_state = adc_sensor_state; // Redo this state - else power_monitor.add_voltage_sample(HAL_READ_ADC()); + if (!hal.adc_ready()) next_sensor_state = adc_sensor_state; // Redo this state + else power_monitor.add_voltage_sample(hal.adc_value()); break; #endif #if HAS_JOY_ADC_X - case PrepareJoy_X: HAL_START_ADC(JOY_X_PIN); break; + case PrepareJoy_X: hal.adc_start(JOY_X_PIN); break; case MeasureJoy_X: ACCUMULATE_ADC(joystick.x); break; #endif #if HAS_JOY_ADC_Y - case PrepareJoy_Y: HAL_START_ADC(JOY_Y_PIN); break; + case PrepareJoy_Y: hal.adc_start(JOY_Y_PIN); break; case MeasureJoy_Y: ACCUMULATE_ADC(joystick.y); break; #endif #if HAS_JOY_ADC_Z - case PrepareJoy_Z: HAL_START_ADC(JOY_Z_PIN); break; + case PrepareJoy_Z: hal.adc_start(JOY_Z_PIN); break; case MeasureJoy_Z: ACCUMULATE_ADC(joystick.z); break; #endif @@ -3482,12 +3810,12 @@ void Temperature::isr() { #ifndef ADC_BUTTON_DEBOUNCE_DELAY #define ADC_BUTTON_DEBOUNCE_DELAY 16 #endif - case Prepare_ADC_KEY: HAL_START_ADC(ADC_KEYPAD_PIN); break; + case Prepare_ADC_KEY: hal.adc_start(ADC_KEYPAD_PIN); break; case Measure_ADC_KEY: - if (!HAL_ADC_READY()) + if (!hal.adc_ready()) next_sensor_state = adc_sensor_state; // redo this state else if (ADCKey_count < ADC_BUTTON_DEBOUNCE_DELAY) { - raw_ADCKey_value = HAL_READ_ADC(); + raw_ADCKey_value = hal.adc_value(); if (raw_ADCKey_value <= 900UL * HAL_ADC_RANGE / 1024UL) { NOMORE(current_ADCKey_raw, raw_ADCKey_value); ADCKey_count++; @@ -3512,7 +3840,7 @@ void Temperature::isr() { adc_sensor_state = next_sensor_state; // - // Additional ~1KHz Tasks + // Additional ~1kHz Tasks // #if ENABLED(BABYSTEPPING) && DISABLED(INTEGRATED_BABYSTEPPING) @@ -3593,7 +3921,7 @@ void Temperature::isr() { OPTARG(HAS_TEMP_REDUNDANT, const bool include_r/*=false*/) ) { #if HAS_TEMP_HOTEND - print_heater_state(H_E0, degHotend(target_extruder), degTargetHotend(target_extruder) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTemp(target_extruder))); + print_heater_state(H_NONE, degHotend(target_extruder), degTargetHotend(target_extruder) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTemp(target_extruder))); #endif #if HAS_HEATED_BED print_heater_state(H_BED, degBed(), degTargetBed() OPTARG(SHOW_TEMP_ADC_VALUES, rawBedTemp())); @@ -3637,11 +3965,14 @@ void Temperature::isr() { #if ENABLED(AUTO_REPORT_TEMPERATURES) AutoReporter Temperature::auto_reporter; - void Temperature::AutoReportTemp::report() { print_heater_states(active_extruder); SERIAL_EOL(); } + void Temperature::AutoReportTemp::report() { + print_heater_states(active_extruder OPTARG(HAS_TEMP_REDUNDANT, ENABLED(AUTO_REPORT_REDUNDANT))); + SERIAL_EOL(); + } #endif #if HAS_HOTEND && HAS_STATUS_MESSAGE - void Temperature::set_heating_message(const uint8_t e) { + void Temperature::set_heating_message(const uint8_t e, const bool isM104/*=false*/) { const bool heating = isHeatingHotend(e); ui.status_printf(0, #if HAS_MULTI_HOTEND @@ -3651,6 +3982,14 @@ void Temperature::isr() { #endif , heating ? GET_TEXT(MSG_HEATING) : GET_TEXT(MSG_COOLING) ); + + if (isM104) { + static uint8_t wait_e; wait_e = e; + ui.set_status_reset_fn([]{ + const celsius_t c = degTargetHotend(wait_e); + return c < 30 || degHotendNear(wait_e, c); + }); + } } #endif @@ -3747,7 +4086,7 @@ void Temperature::isr() { // Prevent a wait-forever situation if R is misused i.e. M109 R0 if (wants_to_cool) { - // break after MIN_COOLING_SLOPE_TIME seconds + // Break after MIN_COOLING_SLOPE_TIME seconds // if the temperature did not drop at least MIN_COOLING_SLOPE_DEG if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) { if (old_temp - temp < float(MIN_COOLING_SLOPE_DEG)) break; @@ -3759,7 +4098,7 @@ void Temperature::isr() { #if G26_CLICK_CAN_CANCEL if (click_to_cancel && ui.use_click()) { wait_for_heatup = false; - TERN_(HAS_LCD_MENU, ui.quick_feedback()); + TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); } #endif @@ -3769,7 +4108,7 @@ void Temperature::isr() { wait_for_heatup = false; #if HAS_DWIN_E3V2_BASIC HMI_flag.heat_flag = 0; - duration_t elapsed = print_job_timer.duration(); // print timer + duration_t elapsed = print_job_timer.duration(); // Print timer dwin_heat_time = elapsed.value; #else ui.reset_status(); @@ -3893,7 +4232,7 @@ void Temperature::isr() { #if G26_CLICK_CAN_CANCEL if (click_to_cancel && ui.use_click()) { wait_for_heatup = false; - TERN_(HAS_LCD_MENU, ui.quick_feedback()); + TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); } #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 0e4302938eda..9dc41129b28c 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -56,7 +56,8 @@ typedef enum : int8_t { H_BOARD = HID_BOARD, H_CHAMBER = HID_CHAMBER, H_BED = HID_BED, - H_E0 = HID_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7 + H_E0 = HID_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7, + H_NONE = -128 } heater_id_t; // PID storage @@ -93,6 +94,19 @@ hotend_pid_t; #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 M + } MPC_t; +#endif + /** * States for ADC reading in the ISR */ @@ -176,7 +190,7 @@ enum ADCSensorState : char { #if HAS_PID_HEATING #define PID_K2 (1-float(PID_K1)) - #define PID_dT ((OVERSAMPLENR * float(ACTUAL_ADC_SAMPLES)) / TEMP_TIMER_FREQUENCY) + #define PID_dT ((OVERSAMPLENR * float(ACTUAL_ADC_SAMPLES)) / (TEMP_TIMER_FREQUENCY)) // Apply the scale factors to the PID values #define scalePID_i(i) ( float(i) * PID_dT ) @@ -185,18 +199,26 @@ enum ADCSensorState : char { #define unscalePID_d(d) ( float(d) * PID_dT ) #endif -#if ENABLED(G26_MESH_VALIDATION) && EITHER(HAS_LCD_MENU, EXTENSIBLE_UI) +#if ENABLED(MPCTEMP) + #define MPC_dT ((OVERSAMPLENR * float(ACTUAL_ADC_SAMPLES)) / (TEMP_TIMER_FREQUENCY)) +#endif + +#if ENABLED(G26_MESH_VALIDATION) && EITHER(HAS_MARLINUI_MENU, EXTENSIBLE_UI) #define G26_CLICK_CAN_CANCEL 1 #endif // A temperature sensor typedef struct TempInfo { - uint16_t acc; - int16_t raw; +private: + raw_adc_t acc; + raw_adc_t raw; +public: celsius_float_t celsius; inline void reset() { acc = 0; } - inline void sample(const uint16_t s) { acc += s; } + 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; } } temp_info_t; #if HAS_TEMP_REDUNDANT @@ -218,8 +240,19 @@ struct PIDHeaterInfo : public HeaterInfo { T pid; // Initialized by settings.load() }; +#if ENABLED(MPCTEMP) + struct MPCHeaterInfo : public HeaterInfo { + MPC_t constants; + float modeled_ambient_temp, + modeled_block_temp, + modeled_sensor_temp; + }; +#endif + #if ENABLED(PIDTEMP) typedef struct PIDHeaterInfo hotend_info_t; +#elif ENABLED(MPCTEMP) + typedef struct MPCHeaterInfo hotend_info_t; #else typedef heater_info_t hotend_info_t; #endif @@ -230,9 +263,6 @@ struct PIDHeaterInfo : public HeaterInfo { typedef heater_info_t bed_info_t; #endif #endif -#if HAS_TEMP_PROBE - typedef temp_info_t probe_info_t; -#endif #if HAS_HEATED_CHAMBER #if ENABLED(PIDTEMPCHAMBER) typedef struct PIDHeaterInfo chamber_info_t; @@ -242,12 +272,15 @@ struct PIDHeaterInfo : public HeaterInfo { #elif HAS_TEMP_CHAMBER typedef temp_info_t chamber_info_t; #endif -#if HAS_TEMP_BOARD - typedef temp_info_t board_info_t; +#if HAS_TEMP_PROBE + typedef temp_info_t probe_info_t; #endif #if EITHER(HAS_COOLER, HAS_TEMP_COOLER) typedef heater_info_t cooler_info_t; #endif +#if HAS_TEMP_BOARD + typedef temp_info_t board_info_t; +#endif // Heater watch handling template @@ -286,9 +319,7 @@ struct HeaterWatch { #endif // Temperature sensor read value ranges -typedef struct { int16_t raw_min, raw_max; } raw_range_t; -typedef struct { celsius_t mintemp, maxtemp; } celsius_range_t; -typedef struct { int16_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_range_t; +typedef struct { raw_adc_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_range_t; #define THERMISTOR_ABS_ZERO_C -273.15f // bbbbrrrrr cold ! #define THERMISTOR_RESISTANCE_NOMINAL_C 25.0f // mmmmm comfortable @@ -317,12 +348,12 @@ typedef struct { int16_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_ra #if TEMP_SENSOR_BED_IS_CUSTOM CTI_BED, #endif - #if TEMP_SENSOR_PROBE_IS_CUSTOM - CTI_PROBE, - #endif #if TEMP_SENSOR_CHAMBER_IS_CUSTOM CTI_CHAMBER, #endif + #if TEMP_SENSOR_PROBE_IS_CUSTOM + CTI_PROBE, + #endif #if TEMP_SENSOR_COOLER_IS_CUSTOM CTI_COOLER, #endif @@ -359,7 +390,7 @@ class Temperature { #if HAS_HOTEND static hotend_info_t temp_hotend[HOTENDS]; static const celsius_t hotend_maxtemp[HOTENDS]; - static inline celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); } + 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; @@ -399,19 +430,27 @@ class Temperature { static uint8_t soft_pwm_controller_speed; #endif + #if BOTH(HAS_MARLINUI_MENU, PREVENT_COLD_EXTRUSION) && E_MANUAL > 0 + static bool allow_cold_extrude_override; + static void set_menu_cold_override(const bool allow) { allow_cold_extrude_override = allow; } + #else + static constexpr bool allow_cold_extrude_override = false; + static void set_menu_cold_override(const bool) {} + #endif + #if ENABLED(PREVENT_COLD_EXTRUSION) static bool allow_cold_extrude; static celsius_t extrude_min_temp; - static inline bool tooCold(const celsius_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp - (TEMP_WINDOW); } - static inline bool tooColdToExtrude(const uint8_t E_NAME) { return tooCold(wholeDegHotend(HOTEND_INDEX)); } - static inline bool targetTooColdToExtrude(const uint8_t E_NAME) { return tooCold(degTargetHotend(HOTEND_INDEX)); } + static bool tooCold(const celsius_t temp) { return !allow_cold_extrude && !allow_cold_extrude_override && temp < extrude_min_temp - (TEMP_WINDOW); } + static bool tooColdToExtrude(const uint8_t E_NAME) { return tooCold(wholeDegHotend(HOTEND_INDEX)); } + static bool targetTooColdToExtrude(const uint8_t E_NAME) { return tooCold(degTargetHotend(HOTEND_INDEX)); } #else - static inline bool tooColdToExtrude(const uint8_t) { return false; } - static inline bool targetTooColdToExtrude(const uint8_t) { return false; } + static bool tooColdToExtrude(const uint8_t) { return false; } + static bool targetTooColdToExtrude(const uint8_t) { return false; } #endif - static inline bool hotEnoughToExtrude(const uint8_t e) { return !tooColdToExtrude(e); } - static inline bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); } + static bool hotEnoughToExtrude(const uint8_t e) { return !tooColdToExtrude(e); } + static bool targetHotEnoughToExtrude(const uint8_t e) { return !targetTooColdToExtrude(e); } #if EITHER(SINGLENOZZLE_STANDBY_TEMP, SINGLENOZZLE_STANDBY_FAN) #if ENABLED(SINGLENOZZLE_STANDBY_TEMP) @@ -449,7 +488,7 @@ class Temperature { }; // Convert the given heater_id_t to idle array index - static inline IdleIndex idle_index_for_id(const int8_t heater_id) { + static IdleIndex idle_index_for_id(const int8_t heater_id) { TERN_(HAS_HEATED_BED, if (heater_id == H_BED) return IDLE_INDEX_BED); return (IdleIndex)_MAX(heater_id, 0); } @@ -478,10 +517,14 @@ class Temperature { #endif #if ENABLED(PID_EXTRUSION_SCALING) - static int32_t last_e_position, lpq[LPQ_MAX_LEN]; + 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 + #if HAS_HOTEND static temp_range_t temp_range[HOTENDS]; #endif @@ -491,7 +534,7 @@ class Temperature { static bed_watch_t watch_bed; #endif IF_DISABLED(PIDTEMPBED, static millis_t next_bed_check_ms); - static int16_t mintemp_raw_BED, maxtemp_raw_BED; + static raw_adc_t mintemp_raw_BED, maxtemp_raw_BED; #endif #if HAS_HEATED_CHAMBER @@ -499,7 +542,7 @@ class Temperature { static chamber_watch_t watch_chamber; #endif TERN(PIDTEMPCHAMBER,,static millis_t next_chamber_check_ms); - static int16_t mintemp_raw_CHAMBER, maxtemp_raw_CHAMBER; + static raw_adc_t mintemp_raw_CHAMBER, maxtemp_raw_CHAMBER; #endif #if HAS_COOLER @@ -507,11 +550,11 @@ class Temperature { static cooler_watch_t watch_cooler; #endif static millis_t next_cooler_check_ms, cooler_fan_flush_ms; - static int16_t mintemp_raw_COOLER, maxtemp_raw_COOLER; + static raw_adc_t mintemp_raw_COOLER, maxtemp_raw_COOLER; #endif #if HAS_TEMP_BOARD && ENABLED(THERMAL_PROTECTION_BOARD) - static int16_t mintemp_raw_BOARD, maxtemp_raw_BOARD; + static raw_adc_t mintemp_raw_BOARD, maxtemp_raw_BOARD; #endif #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 @@ -525,7 +568,7 @@ class Temperature { #if HAS_FAN_LOGIC static millis_t fan_update_ms; - static inline void manage_extruder_fans(millis_t ms) { + static void manage_extruder_fans(millis_t ms) { if (ELAPSED(ms, fan_update_ms)) { // only need to check fan state very infrequently const millis_t next_ms = ms + fan_update_interval_ms; #if HAS_PWMFANCHECK @@ -565,26 +608,26 @@ class Temperature { static user_thermistor_t user_thermistor[USER_THERMISTORS]; static void M305_report(const uint8_t t_index, const bool forReplay=true); static void reset_user_thermistors(); - static celsius_float_t user_thermistor_to_deg_c(const uint8_t t_index, const int16_t raw); - static inline bool set_pull_up_res(int8_t t_index, float value) { + static celsius_float_t user_thermistor_to_deg_c(const uint8_t t_index, const raw_adc_t raw); + static bool set_pull_up_res(int8_t t_index, float value) { //if (!WITHIN(t_index, 0, USER_THERMISTORS - 1)) return false; if (!WITHIN(value, 1, 1000000)) return false; user_thermistor[t_index].series_res = value; return true; } - static inline bool set_res25(int8_t t_index, float value) { + static bool set_res25(int8_t t_index, float value) { if (!WITHIN(value, 1, 10000000)) return false; user_thermistor[t_index].res_25 = value; user_thermistor[t_index].pre_calc = true; return true; } - static inline bool set_beta(int8_t t_index, float value) { + static bool set_beta(int8_t t_index, float value) { if (!WITHIN(value, 1, 1000000)) return false; user_thermistor[t_index].beta = value; user_thermistor[t_index].pre_calc = true; return true; } - static inline bool set_sh_coeff(int8_t t_index, float value) { + static bool set_sh_coeff(int8_t t_index, float value) { if (!WITHIN(value, -0.01f, 0.01f)) return false; user_thermistor[t_index].sh_c_coeff = value; user_thermistor[t_index].pre_calc = true; @@ -593,25 +636,25 @@ class Temperature { #endif #if HAS_HOTEND - static celsius_float_t analog_to_celsius_hotend(const int16_t raw, const uint8_t e); + static celsius_float_t analog_to_celsius_hotend(const raw_adc_t raw, const uint8_t e); #endif #if HAS_HEATED_BED - static celsius_float_t analog_to_celsius_bed(const int16_t raw); - #endif - #if HAS_TEMP_PROBE - static celsius_float_t analog_to_celsius_probe(const int16_t raw); + static celsius_float_t analog_to_celsius_bed(const raw_adc_t raw); #endif #if HAS_TEMP_CHAMBER - static celsius_float_t analog_to_celsius_chamber(const int16_t raw); + static celsius_float_t analog_to_celsius_chamber(const raw_adc_t raw); + #endif + #if HAS_TEMP_PROBE + static celsius_float_t analog_to_celsius_probe(const raw_adc_t raw); #endif #if HAS_TEMP_COOLER - static celsius_float_t analog_to_celsius_cooler(const int16_t raw); + static celsius_float_t analog_to_celsius_cooler(const raw_adc_t raw); #endif #if HAS_TEMP_BOARD - static celsius_float_t analog_to_celsius_board(const int16_t raw); + static celsius_float_t analog_to_celsius_board(const raw_adc_t raw); #endif #if HAS_TEMP_REDUNDANT - static celsius_float_t analog_to_celsius_redundant(const int16_t raw); + static celsius_float_t analog_to_celsius_redundant(const raw_adc_t raw); #endif #if HAS_FAN @@ -634,18 +677,18 @@ class Temperature { static uint8_t fan_speed_scaler[FAN_COUNT]; #endif - static inline uint8_t scaledFanSpeed(const uint8_t fan, const uint8_t fs) { + static uint8_t scaledFanSpeed(const uint8_t fan, const uint8_t fs) { UNUSED(fan); // Potentially unused! return (fs * uint16_t(TERN(ADAPTIVE_FAN_SLOWING, fan_speed_scaler[fan], 128))) >> 7; } - static inline uint8_t scaledFanSpeed(const uint8_t fan) { + static uint8_t scaledFanSpeed(const uint8_t fan) { return scaledFanSpeed(fan, fan_speed[fan]); } static constexpr inline uint8_t pwmToPercent(const uint8_t speed) { return ui8_to_percent(speed); } - static inline uint8_t fanSpeedPercent(const uint8_t fan) { return ui8_to_percent(fan_speed[fan]); } - static inline uint8_t scaledFanSpeedPercent(const uint8_t fan) { return ui8_to_percent(scaledFanSpeed(fan)); } + static uint8_t fanSpeedPercent(const uint8_t fan) { return ui8_to_percent(fan_speed[fan]); } + static uint8_t scaledFanSpeedPercent(const uint8_t fan) { return ui8_to_percent(scaledFanSpeed(fan)); } #if ENABLED(EXTRA_FAN_SPEED) typedef struct { uint8_t saved, speed; } extra_fan_t; @@ -659,7 +702,7 @@ class Temperature { #endif // HAS_FAN - static inline void zero_fan_speeds() { + static void zero_fan_speeds() { #if HAS_FAN FANS_LOOP(i) set_fan_speed(i, 0); #endif @@ -674,19 +717,19 @@ class Temperature { /** * Call periodically to manage heaters */ - static void manage_heater() _O2; // Added _O2 to work around a compiler error + static void manage_heater() __O2; // __O2 added to work around a compiler error /** * Preheating hotends */ #if MILLISECONDS_PREHEAT_TIME > 0 - static inline bool is_preheating(const uint8_t E_NAME) { + static bool is_preheating(const uint8_t E_NAME) { return preheat_end_time[HOTEND_INDEX] && PENDING(millis(), preheat_end_time[HOTEND_INDEX]); } - static inline void start_preheat_time(const uint8_t E_NAME) { + static void start_preheat_time(const uint8_t E_NAME) { preheat_end_time[HOTEND_INDEX] = millis() + MILLISECONDS_PREHEAT_TIME; } - static inline void reset_preheat_time(const uint8_t E_NAME) { + static void reset_preheat_time(const uint8_t E_NAME) { preheat_end_time[HOTEND_INDEX] = 0; } #else @@ -697,21 +740,21 @@ class Temperature { //inline so that there is no performance decrease. //deg=degreeCelsius - static inline celsius_float_t degHotend(const uint8_t E_NAME) { + static celsius_float_t degHotend(const uint8_t E_NAME) { return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].celsius); } - static inline celsius_t wholeDegHotend(const uint8_t E_NAME) { + static celsius_t wholeDegHotend(const uint8_t E_NAME) { return TERN0(HAS_HOTEND, static_cast(temp_hotend[HOTEND_INDEX].celsius + 0.5f)); } #if ENABLED(SHOW_TEMP_ADC_VALUES) - static inline int16_t rawHotendTemp(const uint8_t E_NAME) { - return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].raw); + static raw_adc_t rawHotendTemp(const uint8_t E_NAME) { + return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].getraw()); } #endif - static inline celsius_t degTargetHotend(const uint8_t E_NAME) { + static celsius_t degTargetHotend(const uint8_t E_NAME) { return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].target); } @@ -730,11 +773,11 @@ class Temperature { start_watching_hotend(ee); } - static inline bool isHeatingHotend(const uint8_t E_NAME) { + static bool isHeatingHotend(const uint8_t E_NAME) { return temp_hotend[HOTEND_INDEX].target > temp_hotend[HOTEND_INDEX].celsius; } - static inline bool isCoolingHotend(const uint8_t E_NAME) { + static bool isCoolingHotend(const uint8_t E_NAME) { return temp_hotend[HOTEND_INDEX].target < temp_hotend[HOTEND_INDEX].celsius; } @@ -748,16 +791,16 @@ class Temperature { #endif #endif - static inline bool still_heating(const uint8_t e) { + static bool still_heating(const uint8_t e) { return degTargetHotend(e) > TEMP_HYSTERESIS && ABS(wholeDegHotend(e) - degTargetHotend(e)) > TEMP_HYSTERESIS; } - static inline bool degHotendNear(const uint8_t e, const celsius_t temp) { + static bool degHotendNear(const uint8_t e, const celsius_t temp) { return ABS(wholeDegHotend(e) - temp) < (TEMP_HYSTERESIS); } // Start watching a Hotend to make sure it's really heating up - static inline void start_watching_hotend(const uint8_t E_NAME) { + static void start_watching_hotend(const uint8_t E_NAME) { UNUSED(HOTEND_INDEX); #if WATCH_HOTENDS watch_hotend[HOTEND_INDEX].restart(degHotend(HOTEND_INDEX), degTargetHotend(HOTEND_INDEX)); @@ -769,16 +812,16 @@ class Temperature { #if HAS_HEATED_BED #if ENABLED(SHOW_TEMP_ADC_VALUES) - static inline int16_t rawBedTemp() { return temp_bed.raw; } + static raw_adc_t rawBedTemp() { return temp_bed.getraw(); } #endif - static inline celsius_float_t degBed() { return temp_bed.celsius; } - static inline celsius_t wholeDegBed() { return static_cast(degBed() + 0.5f); } - static inline celsius_t degTargetBed() { return temp_bed.target; } - static inline bool isHeatingBed() { return temp_bed.target > temp_bed.celsius; } - static inline bool isCoolingBed() { return temp_bed.target < temp_bed.celsius; } + static celsius_float_t degBed() { return temp_bed.celsius; } + static celsius_t wholeDegBed() { return static_cast(degBed() + 0.5f); } + 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; } // Start watching the Bed to make sure it's really heating up - static inline void start_watching_bed() { TERN_(WATCH_BED, watch_bed.restart(degBed(), degTargetBed())); } + static void start_watching_bed() { TERN_(WATCH_BED, watch_bed.restart(degBed(), degTargetBed())); } static void setTargetBed(const celsius_t celsius) { TERN_(AUTO_POWER_CONTROL, if (celsius) powerManager.power_on()); @@ -792,7 +835,7 @@ class Temperature { static void wait_for_bed_heating(); - static inline bool degBedNear(const celsius_t temp) { + static bool degBedNear(const celsius_t temp) { return ABS(wholeDegBed() - temp) < (TEMP_BED_HYSTERESIS); } @@ -800,25 +843,25 @@ class Temperature { #if HAS_TEMP_PROBE #if ENABLED(SHOW_TEMP_ADC_VALUES) - static inline int16_t rawProbeTemp() { return temp_probe.raw; } + static raw_adc_t rawProbeTemp() { return temp_probe.getraw(); } #endif - static inline celsius_float_t degProbe() { return temp_probe.celsius; } - static inline celsius_t wholeDegProbe() { return static_cast(degProbe() + 0.5f); } - static inline bool isProbeBelowTemp(const celsius_t target_temp) { return wholeDegProbe() < target_temp; } - static inline bool isProbeAboveTemp(const celsius_t target_temp) { return wholeDegProbe() > target_temp; } + static celsius_float_t degProbe() { return temp_probe.celsius; } + static celsius_t wholeDegProbe() { return static_cast(degProbe() + 0.5f); } + static bool isProbeBelowTemp(const celsius_t target_temp) { return wholeDegProbe() < target_temp; } + static bool isProbeAboveTemp(const celsius_t target_temp) { return wholeDegProbe() > target_temp; } static bool wait_for_probe(const celsius_t target_temp, bool no_wait_for_cooling=true); #endif #if HAS_TEMP_CHAMBER #if ENABLED(SHOW_TEMP_ADC_VALUES) - static inline int16_t rawChamberTemp() { return temp_chamber.raw; } + static raw_adc_t rawChamberTemp() { return temp_chamber.getraw(); } #endif - static inline celsius_float_t degChamber() { return temp_chamber.celsius; } - static inline celsius_t wholeDegChamber() { return static_cast(degChamber() + 0.5f); } + static celsius_float_t degChamber() { return temp_chamber.celsius; } + static celsius_t wholeDegChamber() { return static_cast(degChamber() + 0.5f); } #if HAS_HEATED_CHAMBER - static inline celsius_t degTargetChamber() { return temp_chamber.target; } - static inline bool isHeatingChamber() { return temp_chamber.target > temp_chamber.celsius; } - static inline bool isCoolingChamber() { return temp_chamber.target < temp_chamber.celsius; } + static celsius_t degTargetChamber() { return temp_chamber.target; } + 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); #endif #endif @@ -829,49 +872,48 @@ class Temperature { start_watching_chamber(); } // Start watching the Chamber to make sure it's really heating up - static inline void start_watching_chamber() { TERN_(WATCH_CHAMBER, watch_chamber.restart(degChamber(), degTargetChamber())); } + static void start_watching_chamber() { TERN_(WATCH_CHAMBER, watch_chamber.restart(degChamber(), degTargetChamber())); } #endif #if HAS_TEMP_COOLER #if ENABLED(SHOW_TEMP_ADC_VALUES) - static inline int16_t rawCoolerTemp() { return temp_cooler.raw; } + static raw_adc_t rawCoolerTemp() { return temp_cooler.getraw(); } #endif - static inline celsius_float_t degCooler() { return temp_cooler.celsius; } - static inline celsius_t wholeDegCooler() { return static_cast(temp_cooler.celsius + 0.5f); } + static celsius_float_t degCooler() { return temp_cooler.celsius; } + static celsius_t wholeDegCooler() { return static_cast(temp_cooler.celsius + 0.5f); } #if HAS_COOLER - static inline celsius_t degTargetCooler() { return temp_cooler.target; } - static inline bool isLaserHeating() { return temp_cooler.target > temp_cooler.celsius; } - static inline bool isLaserCooling() { return temp_cooler.target < temp_cooler.celsius; } + static celsius_t degTargetCooler() { return temp_cooler.target; } + 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); #endif #endif #if HAS_TEMP_BOARD #if ENABLED(SHOW_TEMP_ADC_VALUES) - static inline int16_t rawBoardTemp() { return temp_board.raw; } + static raw_adc_t rawBoardTemp() { return temp_board.getraw(); } #endif - static inline celsius_float_t degBoard() { return temp_board.celsius; } - static inline celsius_t wholeDegBoard() { return static_cast(temp_board.celsius + 0.5f); } + static celsius_float_t degBoard() { return temp_board.celsius; } + static celsius_t wholeDegBoard() { return static_cast(temp_board.celsius + 0.5f); } #endif #if HAS_TEMP_REDUNDANT #if ENABLED(SHOW_TEMP_ADC_VALUES) - static inline int16_t rawRedundantTemp() { return temp_redundant.raw; } - static inline int16_t rawRedundanTargetTemp() { return (*temp_redundant.target).raw; } + static raw_adc_t rawRedundantTemp() { return temp_redundant.getraw(); } #endif - static inline celsius_float_t degRedundant() { return temp_redundant.celsius; } - static inline celsius_float_t degRedundantTarget() { return (*temp_redundant.target).celsius; } - static inline celsius_t wholeDegRedundant() { return static_cast(temp_redundant.celsius + 0.5f); } - static inline celsius_t wholeDegRedundantTarget() { return static_cast((*temp_redundant.target).celsius + 0.5f); } + static celsius_float_t degRedundant() { return temp_redundant.celsius; } + static celsius_float_t degRedundantTarget() { return (*temp_redundant.target).celsius; } + static celsius_t wholeDegRedundant() { return static_cast(temp_redundant.celsius + 0.5f); } + static celsius_t wholeDegRedundantTarget() { return static_cast((*temp_redundant.target).celsius + 0.5f); } #endif #if HAS_COOLER - static inline void setTargetCooler(const celsius_t celsius) { + static void setTargetCooler(const celsius_t celsius) { temp_cooler.target = constrain(celsius, COOLER_MIN_TARGET, COOLER_MAX_TARGET); start_watching_cooler(); } // Start watching the Cooler to make sure it's really cooling down - static inline void start_watching_cooler() { TERN_(WATCH_COOLER, watch_cooler.restart(degCooler(), degTargetCooler())); } + static void start_watching_cooler() { TERN_(WATCH_COOLER, watch_cooler.restart(degCooler(), degTargetCooler())); } #endif /** @@ -887,7 +929,7 @@ class Temperature { /** * Cooldown, as from the LCD. Disables all heaters and fans. */ - static inline void cooldown() { + static void cooldown() { zero_fan_speeds(); disable_all_heaters(); } @@ -921,26 +963,30 @@ class Temperature { * Update the temp manager when PID values change */ #if ENABLED(PIDTEMP) - static inline void updatePID() { - TERN_(PID_EXTRUSION_SCALING, last_e_position = 0); + static void updatePID() { + TERN_(PID_EXTRUSION_SCALING, pes_e_position = 0); } #endif #endif + #if ENABLED(MPCTEMP) + void MPC_autotune(); + #endif + #if ENABLED(PROBING_HEATERS_OFF) static void pause_heaters(const bool p); #endif #if HEATER_IDLE_HANDLER - static inline void reset_hotend_idle_timer(const uint8_t E_NAME) { + static void reset_hotend_idle_timer(const uint8_t E_NAME) { heater_idle[HOTEND_INDEX].reset(); start_watching_hotend(HOTEND_INDEX); } #if HAS_HEATED_BED - static inline void reset_bed_idle_timer() { + static void reset_bed_idle_timer() { heater_idle[IDLE_INDEX_BED].reset(); start_watching_bed(); } @@ -959,12 +1005,12 @@ class Temperature { #endif #if HAS_HOTEND && HAS_STATUS_MESSAGE - static void set_heating_message(const uint8_t e); + static void set_heating_message(const uint8_t e, const bool isM104=false); #else - static inline void set_heating_message(const uint8_t) {} + static void set_heating_message(const uint8_t, const bool=false) {} #endif - #if HAS_LCD_MENU && HAS_TEMPERATURE + #if HAS_MARLINUI_MENU && HAS_TEMPERATURE static void lcd_preheat(const uint8_t e, const int8_t indh, const int8_t indb); #endif @@ -974,7 +1020,7 @@ class Temperature { static volatile bool raw_temps_ready; static void update_raw_temperatures(); static void updateTemperaturesFromRawValues(); - static inline bool updateTemperaturesIfReady() { + static bool updateTemperaturesIfReady() { if (!raw_temps_ready) return false; updateTemperaturesFromRawValues(); raw_temps_ready = false; @@ -990,10 +1036,15 @@ class Temperature { #else #define READ_MAX_TC(N) read_max_tc() #endif - static int16_t read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex=0)); + static raw_adc_t read_max_tc(TERN_(HAS_MULTI_MAX_TC, const uint8_t hindex=0)); #endif - static void update_autofans(); + #if HAS_AUTO_FAN + #if ENABLED(POWER_OFF_WAIT_FOR_COOLDOWN) + static bool autofans_on; + #endif + static void update_autofans(); + #endif #if HAS_HOTEND static float get_pid_output_hotend(const uint8_t e); @@ -1009,7 +1060,7 @@ class Temperature { static void min_temp_error(const heater_id_t e); static void max_temp_error(const heater_id_t e); - #define HAS_THERMAL_PROTECTION ANY(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_CHAMBER, HAS_THERMALLY_PROTECTED_BED, THERMAL_PROTECTION_COOLER) + #define HAS_THERMAL_PROTECTION ANY(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_CHAMBER, THERMAL_PROTECTION_BED, THERMAL_PROTECTION_COOLER) #if HAS_THERMAL_PROTECTION @@ -1021,26 +1072,32 @@ class Temperature { REPEAT(HOTENDS, _RUNAWAY_IND_E) #undef _RUNAWAY_IND_E #endif - OPTARG(HAS_THERMALLY_PROTECTED_BED, RUNAWAY_IND_BED) + OPTARG(THERMAL_PROTECTION_BED, RUNAWAY_IND_BED) OPTARG(THERMAL_PROTECTION_CHAMBER, RUNAWAY_IND_CHAMBER) OPTARG(THERMAL_PROTECTION_COOLER, RUNAWAY_IND_COOLER) , NR_HEATER_RUNAWAY }; // Convert the given heater_id_t to runaway state array index - static inline RunawayIndex runaway_index_for_id(const int8_t heater_id) { - TERN_(HAS_THERMALLY_PROTECTED_CHAMBER, if (heater_id == H_CHAMBER) return RUNAWAY_IND_CHAMBER); - TERN_(HAS_THERMALLY_PROTECTED_CHAMBER, if (heater_id == H_COOLER) return RUNAWAY_IND_COOLER); - TERN_(HAS_THERMALLY_PROTECTED_BED, if (heater_id == H_BED) return RUNAWAY_IND_BED); + static RunawayIndex runaway_index_for_id(const int8_t heater_id) { + TERN_(THERMAL_PROTECTION_CHAMBER, if (heater_id == H_CHAMBER) return RUNAWAY_IND_CHAMBER); + TERN_(THERMAL_PROTECTION_COOLER, if (heater_id == H_COOLER) return RUNAWAY_IND_COOLER); + TERN_(THERMAL_PROTECTION_BED, if (heater_id == H_BED) return RUNAWAY_IND_BED); return (RunawayIndex)_MAX(heater_id, 0); } - enum TRState : char { TRInactive, TRFirstHeating, TRStable, TRRunaway }; + enum TRState : char { TRInactive, TRFirstHeating, TRStable, TRRunaway + OPTARG(THERMAL_PROTECTION_VARIANCE_MONITOR, TRMalfunction) + }; typedef struct { millis_t timer = 0; TRState state = TRInactive; float 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); } tr_state_machine_t; diff --git a/Marlin/src/module/thermistor/thermistor_504.h b/Marlin/src/module/thermistor/thermistor_504.h new file mode 100644 index 000000000000..61ce3ae1358c --- /dev/null +++ b/Marlin/src/module/thermistor/thermistor_504.h @@ -0,0 +1,93 @@ +/** + * 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 + +// QWG 104F B3950 thermistor +constexpr temp_entry_t temptable_504[] PROGMEM = { + { OV( 15), 330 }, + { OV( 17), 315 }, + { OV( 19), 300 }, + { OV( 20), 295 }, + { OV( 21), 290 }, + { OV( 23), 285 }, + { OV( 25), 280 }, + { OV( 27), 275 }, + { OV( 28), 270 }, + { OV( 31), 265 }, + { OV( 33), 260 }, + { OV( 35), 255 }, + { OV( 38), 250 }, + { OV( 41), 245 }, + { OV( 44), 240 }, + { OV( 48), 235 }, + { OV( 52), 230 }, + { OV( 56), 225 }, + { OV( 61), 220 }, + { OV( 66), 215 }, + { OV( 78), 210 }, + { OV( 92), 205 }, + { OV( 100), 200 }, + { OV( 109), 195 }, + { OV( 120), 190 }, + { OV( 143), 185 }, + { OV( 148), 180 }, + { OV( 156), 175 }, + { OV( 171), 170 }, + { OV( 187), 165 }, + { OV( 205), 160 }, + { OV( 224), 155 }, + { OV( 268), 150 }, + { OV( 293), 145 }, + { OV( 320), 140 }, + { OV( 348), 135 }, + { OV( 379), 130 }, + { OV( 411), 125 }, + { OV( 445), 120 }, + { OV( 480), 115 }, + { OV( 516), 110 }, + { OV( 553), 105 }, + { OV( 591), 100 }, + { OV( 628), 95 }, + { OV( 665), 90 }, + { OV( 702), 85 }, + { OV( 737), 80 }, + { OV( 770), 75 }, + { OV( 801), 70 }, + { OV( 830), 65 }, + { OV( 857), 60 }, + { OV( 881), 55 }, + { OV( 903), 50 }, + { OV( 922), 45 }, + { OV( 939), 40 }, + { OV( 954), 35 }, + { OV( 966), 30 }, + { OV( 977), 25 }, + { OV( 985), 23 }, + { OV( 993), 20 }, + { OV( 999), 18 }, + { OV(1004), 15 }, + { OV(1008), 12 }, + { OV(1012), 8 }, + { OV(1016), 5 }, + { OV(1020), 0 }, + { OV(1023), -5 } +}; diff --git a/Marlin/src/module/thermistor/thermistor_505.h b/Marlin/src/module/thermistor/thermistor_505.h new file mode 100644 index 000000000000..6c94b0e1b456 --- /dev/null +++ b/Marlin/src/module/thermistor/thermistor_505.h @@ -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 . + * + */ +#pragma once + +// ZONESTAR hotbed QWG-104F-3950 thermistor +constexpr temp_entry_t temptable_505[] PROGMEM = { + { OV( 1), 938 }, + { OV( 8), 320 }, + { OV( 16), 300 }, + { OV( 27), 290 }, + { OV( 36), 272 }, + { OV( 47), 258 }, + { OV( 56), 248 }, + { OV( 68), 245 }, + { OV( 78), 237 }, + { OV( 89), 228 }, + { OV( 99), 221 }, + { OV( 110), 215 }, + { OV( 120), 209 }, + { OV( 131), 204 }, + { OV( 141), 199 }, + { OV( 151), 195 }, + { OV( 161), 190 }, + { OV( 171), 187 }, + { OV( 181), 183 }, + { OV( 201), 179 }, + { OV( 221), 170 }, + { OV( 251), 165 }, + { OV( 261), 160 }, + { OV( 321), 150 }, + { OV( 361), 144 }, + { OV( 401), 140 }, + { OV( 421), 133 }, + { OV( 451), 130 }, + { OV( 551), 120 }, + { OV( 571), 117 }, + { OV( 596), 110 }, + { OV( 626), 105 }, + { OV( 666), 100 }, + { OV( 677), 95 }, + { OV( 697), 90 }, + { OV( 717), 85 }, + { OV( 727), 79 }, + { OV( 750), 72 }, + { OV( 789), 69 }, + { OV( 819), 65 }, + { OV( 861), 57 }, + { OV( 870), 55 }, + { OV( 881), 51 }, + { OV( 911), 45 }, + { OV( 922), 39 }, + { OV( 968), 28 }, + { OV( 977), 25 }, + { OV( 985), 23 }, + { OV( 993), 20 }, + { OV( 999), 18 }, + { OV(1004), 15 }, + { OV(1008), 12 }, + { OV(1012), 8 }, + { OV(1016), 5 }, + { OV(1020), 0 }, + { OV(1023), -5 } +}; diff --git a/Marlin/src/module/thermistor/thermistor_66.h b/Marlin/src/module/thermistor/thermistor_66.h index 3b057ac6960e..07cb29767935 100644 --- a/Marlin/src/module/thermistor/thermistor_66.h +++ b/Marlin/src/module/thermistor/thermistor_66.h @@ -27,27 +27,94 @@ constexpr temp_entry_t temptable_66[] PROGMEM = { { OV( 17.9), 500 }, { OV( 21.7), 480 }, { OV( 26.6), 460 }, - { OV( 33.1), 440 }, - { OV( 41.0), 420 }, - { OV( 52.3), 400 }, - { OV( 67.7), 380 }, - { OV( 86.5), 360 }, - { OV( 112.0), 340 }, - { OV( 147.2), 320 }, - { OV( 194.0), 300 }, - { OV( 254.3), 280 }, - { OV( 330.2), 260 }, - { OV( 427.9), 240 }, - { OV( 533.4), 220 }, - { OV( 646.5), 200 }, - { OV( 754.4), 180 }, - { OV( 844.3), 160 }, - { OV( 911.7), 140 }, - { OV( 958.6), 120 }, - { OV( 988.8), 100 }, + { OV( 34.0), 430 }, + { OV( 36.0), 426 }, + { OV( 37.0), 422 }, + { OV( 38.0), 418 }, + { OV( 40.4), 414 }, + { OV( 43.0), 410 }, + { OV( 45.6), 406 }, + { OV( 48.0), 402 }, + { OV( 50.6), 398 }, + { OV( 53.0), 394 }, + { OV( 56.0), 390 }, + { OV( 58.0), 386 }, + { OV( 61.0), 382 }, + { OV( 64.0), 378 }, + { OV( 68.0), 374 }, + { OV( 72.0), 370 }, + { OV( 75.0), 366 }, + { OV( 79.0), 362 }, + { OV( 83.0), 358 }, + { OV( 88.0), 354 }, + { OV( 93.0), 350 }, + { OV( 97.0), 346 }, + { OV( 103.0), 342 }, + { OV( 109.0), 338 }, + { OV( 115.0), 334 }, + { OV( 121.0), 330 }, + { OV( 128.0), 326 }, + { OV( 135.0), 322 }, + { OV( 143.0), 318 }, + { OV( 151.0), 314 }, + { OV( 160.0), 310 }, + { OV( 168.0), 306 }, + { OV( 177.0), 302 }, + { OV( 188.0), 298 }, + { OV( 198.0), 294 }, + { OV( 209.0), 290 }, + { OV( 222.0), 286 }, + { OV( 235.0), 282 }, + { OV( 248.0), 278 }, + { OV( 262.0), 274 }, + { OV( 276.0), 270 }, + { OV( 291.0), 266 }, + { OV( 306.0), 262 }, + { OV( 323.0), 258 }, + { OV( 340.0), 254 }, + { OV( 357.0), 250 }, + { OV( 378.0), 246 }, + { OV( 397.0), 242 }, + { OV( 417.0), 238 }, + { OV( 437.0), 234 }, + { OV( 458.0), 230 }, + { OV( 481.0), 226 }, + { OV( 502.0), 222 }, + { OV( 525.0), 218 }, + { OV( 547.0), 214 }, + { OV( 570.0), 210 }, + { OV( 594.0), 206 }, + { OV( 615.0), 202 }, + { OV( 637.0), 198 }, + { OV( 660.0), 194 }, + { OV( 683.0), 190 }, + { OV( 705.0), 186 }, + { OV( 727.0), 182 }, + { OV( 747.0), 178 }, + { OV( 767.0), 174 }, + { OV( 787.0), 170 }, + { OV( 805.0), 166 }, + { OV( 822.0), 162 }, + { OV( 839.0), 158 }, + { OV( 854.0), 154 }, + { OV( 870.0), 150 }, + { OV( 883.0), 146 }, + { OV( 898.0), 142 }, + { OV( 909.0), 138 }, + { OV( 919.0), 134 }, + { OV( 931.0), 130 }, + { OV( 940.0), 126 }, + { OV( 949.0), 122 }, + { OV( 957.0), 118 }, + { OV( 964.0), 114 }, + { OV( 971.0), 110 }, + { OV( 977.0), 106 }, + { OV( 982.0), 102 }, + { OV( 997.0), 93 }, + { OV(1002.2), 86 }, { OV(1006.6), 80 }, { OV(1015.8), 60 }, - { OV(1021.3), 30 }, - { OV( 1022), 25 }, - { OV( 1023), 20 } + { OV(1019.8), 36 }, + { OV(1020.9), 23 }, + { OV(1022.0), -1 } }; diff --git a/Marlin/src/HAL/AVR/watchdog.h b/Marlin/src/module/thermistor/thermistor_68.h similarity index 53% rename from Marlin/src/HAL/AVR/watchdog.h rename to Marlin/src/module/thermistor/thermistor_68.h index a16c88b35e87..270456dcb59c 100644 --- a/Marlin/src/HAL/AVR/watchdog.h +++ b/Marlin/src/module/thermistor/thermistor_68.h @@ -1,6 +1,6 @@ /** * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 @@ -21,11 +21,34 @@ */ #pragma once -#include +#define REVERSE_TEMP_SENSOR_RANGE_68 1 -// Initialize watchdog with a 4 second interrupt time -void watchdog_init(); - -// Reset watchdog. MUST be called at least every 4 seconds after the -// first watchdog_init or AVR will go into emergency procedures. -inline void HAL_watchdog_refresh() { wdt_reset(); } +// PT100 amplifier board from Dyze Design +const temp_entry_t temptable_68[] PROGMEM = { + { OV(273), 0 }, + { OV(294), 20 }, + { OV(315), 40 }, + { OV(336), 60 }, + { OV(356), 80 }, + { OV(376), 100 }, + { OV(396), 120 }, + { OV(416), 140 }, + { OV(436), 160 }, + { OV(455), 180 }, + { OV(474), 200 }, + { OV(494), 220 }, + { OV(513), 240 }, + { OV(531), 260 }, + { OV(550), 280 }, + { OV(568), 300 }, + { OV(587), 320 }, + { OV(605), 340 }, + { OV(623), 360 }, + { OV(641), 380 }, + { OV(658), 400 }, + { OV(676), 420 }, + { OV(693), 440 }, + { OV(710), 460 }, + { OV(727), 480 }, + { OV(744), 500 } +}; diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index 85f4449636e8..a38b7f381feb 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -27,22 +27,20 @@ #define THERMISTOR_TABLE_SCALE (HAL_ADC_RANGE / _BV(THERMISTOR_TABLE_ADC_RESOLUTION)) #if ENABLED(HAL_ADC_FILTERED) #define OVERSAMPLENR 1 -#elif HAL_ADC_RESOLUTION > 10 - #define OVERSAMPLENR (20 - HAL_ADC_RESOLUTION) #else #define OVERSAMPLENR 16 #endif -#define MAX_RAW_THERMISTOR_VALUE (HAL_ADC_RANGE * (OVERSAMPLENR) - 1) -// Currently Marlin stores all oversampled ADC values as int16_t, make sure the HAL settings do not overflow 15bit -#if MAX_RAW_THERMISTOR_VALUE > ((1 << 15) - 1) - #error "MAX_RAW_THERMISTOR_VALUE is too large for int16_t. Reduce OVERSAMPLENR or HAL_ADC_RESOLUTION." +// Currently Marlin stores all oversampled ADC values as uint16_t, make sure the HAL settings do not overflow 16 bit +#if (HAL_ADC_RANGE) * (OVERSAMPLENR) > 1 << 16 + #error "MAX_RAW_THERMISTOR_VALUE is too large for uint16_t. Reduce OVERSAMPLENR or HAL_ADC_RESOLUTION." #endif +#define MAX_RAW_THERMISTOR_VALUE (uint16_t(HAL_ADC_RANGE) * (OVERSAMPLENR) - 1) -#define OV_SCALE(N) (N) -#define OV(N) int16_t(OV_SCALE(N) * (OVERSAMPLENR) * (THERMISTOR_TABLE_SCALE)) +#define OV_SCALE(N) float(N) +#define OV(N) raw_adc_t(OV_SCALE(N) * (OVERSAMPLENR) * (THERMISTOR_TABLE_SCALE)) -typedef struct { int16_t value; celsius_t celsius; } temp_entry_t; +typedef struct { raw_adc_t value; celsius_t celsius; } temp_entry_t; // Pt1000 and Pt100 handling // @@ -78,6 +76,12 @@ typedef struct { int16_t value; celsius_t celsius; } temp_entry_t; #if ANY_THERMISTOR_IS(503) // Zonestar (Z8XM2) Heated Bed thermistor #include "thermistor_503.h" #endif +#if ANY_THERMISTOR_IS(504) // Zonestar (P802QR2 Hot End) thermistors + #include "thermistor_504.h" +#endif +#if ANY_THERMISTOR_IS(505) // Zonestar (P802QR2 Bed) thermistor + #include "thermistor_505.h" +#endif #if ANY_THERMISTOR_IS(512) // 100k thermistor in RPW-Ultra hotend, Pull-up = 4.7 kOhm, "unknown model" #include "thermistor_512.h" #endif @@ -150,6 +154,9 @@ typedef struct { int16_t value; celsius_t celsius; } temp_entry_t; #if ANY_THERMISTOR_IS(67) // R25 = 500 KOhm, beta25 = 3800 K, 4.7 kOhm pull-up, SliceEngineering 450 °C Thermistor #include "thermistor_67.h" #endif +#if ANY_THERMISTOR_IS(68) // PT-100 with Dyze amplifier board + #include "thermistor_68.h" +#endif #if ANY_THERMISTOR_IS(12) // beta25 = 4700 K, R25 = 100 kOhm, Pull-up = 4.7 kOhm, "Personal calibration for Makibox hot bed" #include "thermistor_12.h" #endif @@ -283,13 +290,6 @@ typedef struct { int16_t value; celsius_t celsius; } temp_entry_t; #define TEMPTABLE_CHAMBER_LEN 0 #endif -#if TEMP_SENSOR_COOLER > 0 - #define TEMPTABLE_COOLER TT_NAME(TEMP_SENSOR_COOLER) - #define TEMPTABLE_COOLER_LEN COUNT(TEMPTABLE_COOLER) -#else - #define TEMPTABLE_COOLER_LEN 0 -#endif - #if TEMP_SENSOR_PROBE > 0 #define TEMPTABLE_PROBE TT_NAME(TEMP_SENSOR_PROBE) #define TEMPTABLE_PROBE_LEN COUNT(TEMPTABLE_PROBE) @@ -297,6 +297,13 @@ typedef struct { int16_t value; celsius_t celsius; } temp_entry_t; #define TEMPTABLE_PROBE_LEN 0 #endif +#if TEMP_SENSOR_COOLER > 0 + #define TEMPTABLE_COOLER TT_NAME(TEMP_SENSOR_COOLER) + #define TEMPTABLE_COOLER_LEN COUNT(TEMPTABLE_COOLER) +#else + #define TEMPTABLE_COOLER_LEN 0 +#endif + #if TEMP_SENSOR_BOARD > 0 #define TEMPTABLE_BOARD TT_NAME(TEMP_SENSOR_BOARD) #define TEMPTABLE_BOARD_LEN COUNT(TEMPTABLE_BOARD) @@ -316,8 +323,8 @@ static_assert(255 > TEMPTABLE_0_LEN || 255 > TEMPTABLE_1_LEN || 255 > TEMPTABLE_ || 255 > TEMPTABLE_4_LEN || 255 > TEMPTABLE_5_LEN || 255 > TEMPTABLE_6_LEN || 255 > TEMPTABLE_7_LEN || 255 > TEMPTABLE_BED_LEN || 255 > TEMPTABLE_CHAMBER_LEN - || 255 > TEMPTABLE_COOLER_LEN || 255 > TEMPTABLE_PROBE_LEN + || 255 > TEMPTABLE_COOLER_LEN || 255 > TEMPTABLE_BOARD_LEN || 255 > TEMPTABLE_REDUNDANT_LEN , "Temperature conversion tables over 255 entries need special consideration." diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 285b4cba845f..d9920ae6fcae 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -32,6 +32,7 @@ #include "../MarlinCore.h" //#define DEBUG_TOOL_CHANGE +//#define DEBUG_TOOLCHANGE_FILAMENT_SWAP #define DEBUG_OUT ENABLED(DEBUG_TOOL_CHANGE) #include "../core/debug_out.h" @@ -42,11 +43,10 @@ #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) migration_settings_t migration = migration_defaults; - bool enable_first_prime; #endif #if ENABLED(TOOLCHANGE_FS_INIT_BEFORE_SWAP) - bool toolchange_extruder_ready[EXTRUDERS]; + Flags toolchange_extruder_ready; #endif #if EITHER(MAGNETIC_PARKING_EXTRUDER, TOOL_SENSOR) \ @@ -89,7 +89,7 @@ #include "../feature/mmu/mmu2.h" #endif -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #include "../lcd/marlinui.h" #endif @@ -116,7 +116,7 @@ void move_extruder_servo(const uint8_t e) { planner.synchronize(); if ((EXTRUDERS & 1) && e < EXTRUDERS - 1) { - MOVE_SERVO(_SERVO_NR(e), servo_angles[_SERVO_NR(e)][e & 1]); + servo[_SERVO_NR(e)].move(servo_angles[_SERVO_NR(e)][e & 1]); safe_delay(500); } } @@ -131,7 +131,7 @@ constexpr int8_t sns_index[2] = { SWITCHING_NOZZLE_SERVO_NR, SWITCHING_NOZZLE_E1_SERVO_NR }; constexpr int16_t sns_angles[2] = SWITCHING_NOZZLE_SERVO_ANGLES; planner.synchronize(); - MOVE_SERVO(sns_index[e], sns_angles[angle_index]); + servo[sns_index[e]].move(sns_angles[angle_index]); safe_delay(500); } @@ -142,7 +142,7 @@ void move_nozzle_servo(const uint8_t angle_index) { planner.synchronize(); - MOVE_SERVO(SWITCHING_NOZZLE_SERVO_NR, servo_angles[SWITCHING_NOZZLE_SERVO_NR][angle_index]); + servo[SWITCHING_NOZZLE_SERVO_NR].move(servo_angles[SWITCHING_NOZZLE_SERVO_NR][angle_index]); safe_delay(500); } @@ -150,6 +150,7 @@ #endif // SWITCHING_NOZZLE +// Move to position routines void _line_to_current(const AxisEnum fr_axis, const float fscale=1) { line_to_current_position(planner.settings.max_feedrate_mm_s[fr_axis] * fscale); } @@ -385,70 +386,64 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. #endif // PARKING_EXTRUDER -#if ENABLED(SWITCHING_TOOLHEAD) +#if ENABLED(TOOL_SENSOR) + + bool tool_sensor_disabled; // = false // Return a bitmask of tool sensor states inline uint8_t poll_tool_sensor_pins() { return (0 - #if ENABLED(TOOL_SENSOR) - #if PIN_EXISTS(TOOL_SENSOR1) - | (READ(TOOL_SENSOR1_PIN) << 0) - #endif - #if PIN_EXISTS(TOOL_SENSOR2) - | (READ(TOOL_SENSOR2_PIN) << 1) - #endif - #if PIN_EXISTS(TOOL_SENSOR3) - | (READ(TOOL_SENSOR3_PIN) << 2) - #endif - #if PIN_EXISTS(TOOL_SENSOR4) - | (READ(TOOL_SENSOR4_PIN) << 3) - #endif - #if PIN_EXISTS(TOOL_SENSOR5) - | (READ(TOOL_SENSOR5_PIN) << 4) - #endif - #if PIN_EXISTS(TOOL_SENSOR6) - | (READ(TOOL_SENSOR6_PIN) << 5) - #endif - #if PIN_EXISTS(TOOL_SENSOR7) - | (READ(TOOL_SENSOR7_PIN) << 6) - #endif - #if PIN_EXISTS(TOOL_SENSOR8) - | (READ(TOOL_SENSOR8_PIN) << 7) - #endif + #if PIN_EXISTS(TOOL_SENSOR1) + | (READ(TOOL_SENSOR1_PIN) << 0) + #endif + #if PIN_EXISTS(TOOL_SENSOR2) + | (READ(TOOL_SENSOR2_PIN) << 1) + #endif + #if PIN_EXISTS(TOOL_SENSOR3) + | (READ(TOOL_SENSOR3_PIN) << 2) + #endif + #if PIN_EXISTS(TOOL_SENSOR4) + | (READ(TOOL_SENSOR4_PIN) << 3) + #endif + #if PIN_EXISTS(TOOL_SENSOR5) + | (READ(TOOL_SENSOR5_PIN) << 4) + #endif + #if PIN_EXISTS(TOOL_SENSOR6) + | (READ(TOOL_SENSOR6_PIN) << 5) + #endif + #if PIN_EXISTS(TOOL_SENSOR7) + | (READ(TOOL_SENSOR7_PIN) << 6) + #endif + #if PIN_EXISTS(TOOL_SENSOR8) + | (READ(TOOL_SENSOR8_PIN) << 7) #endif ); } - #if ENABLED(TOOL_SENSOR) - - bool tool_sensor_disabled; // = false - - uint8_t check_tool_sensor_stats(const uint8_t tool_index, const bool kill_on_error/*=false*/, const bool disable/*=false*/) { - static uint8_t sensor_tries; // = 0 - for (;;) { - if (poll_tool_sensor_pins() == _BV(tool_index)) { - sensor_tries = 0; - return tool_index; - } - else if (kill_on_error && (!tool_sensor_disabled || disable)) { - sensor_tries++; - if (sensor_tries > 10) kill(F("Tool Sensor error")); - safe_delay(5); - } - else { - sensor_tries++; - if (sensor_tries > 10) return -1; - safe_delay(5); - } + uint8_t check_tool_sensor_stats(const uint8_t tool_index, const bool kill_on_error/*=false*/, const bool disable/*=false*/) { + static uint8_t sensor_tries; // = 0 + for (;;) { + if (poll_tool_sensor_pins() == _BV(tool_index)) { + sensor_tries = 0; + return tool_index; + } + else if (kill_on_error && (!tool_sensor_disabled || disable)) { + sensor_tries++; + if (sensor_tries > 10) kill(F("Tool Sensor error")); + safe_delay(5); + } + else { + sensor_tries++; + if (sensor_tries > 10) return -1; + safe_delay(5); } } - - #endif + } inline void switching_toolhead_lock(const bool locked) { #ifdef SWITCHING_TOOLHEAD_SERVO_ANGLES const uint16_t swt_angles[2] = SWITCHING_TOOLHEAD_SERVO_ANGLES; - MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, swt_angles[locked ? 0 : 1]); + servo[SWITCHING_TOOLHEAD_SERVO_NR].move(swt_angles[locked ? 0 : 1]); #elif PIN_EXISTS(SWT_SOLENOID) OUT_WRITE(SWT_SOLENOID_PIN, locked); gcode.dwell(10); @@ -496,9 +491,13 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. switching_toolhead_lock(true); } LCD_MESSAGE_F("TC Success"); - #endif + #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; @@ -901,10 +900,135 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. */ #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) + #ifdef DEBUG_TOOLCHANGE_FILAMENT_SWAP + #define FS_DEBUG(V...) SERIAL_ECHOLNPGM("DEBUG: " V) + #else + #define FS_DEBUG(...) NOOP + #endif + + // Define any variables required + static Flags extruder_was_primed; // Extruders primed status + + #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED) + bool enable_first_prime; // As set by M217 V + #endif + + // Cool down with fan + inline void filament_swap_cooling() { + #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; + #endif + } + + /** + * Check if too cold to move the specified tool + * + * Returns TRUE if too cold to move (also echos message: STR_ERR_HOTEND_TOO_COLD) + * Returns FALSE if able to move. + */ + bool too_cold(uint8_t toolID){ + if (TERN0(PREVENT_COLD_EXTRUSION, !DEBUGGING(DRYRUN) && thermalManager.targetTooColdToExtrude(toolID))) { + SERIAL_ECHO_MSG(STR_ERR_HOTEND_TOO_COLD); + return true; + } + return false; + } + + /** + * 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 + * 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); + 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(); + FS_DEBUG("Set position to: ", e); + current_position.e = e; + sync_plan_position_e(); // Resume new E Position + } + } + + /** + * Prime the currently selected extruder (Filament loading only) + * + * If too_cold(toolID) returns TRUE -> returns without moving extruder. + * Extruders filament = swap_length + extra prime, then performs cutting retraction if enabled. + * If cooling fan is enabled, calls filament_swap_cooling(); + */ + void extruder_prime() { + + if (too_cold(active_extruder)) { + FS_DEBUG("Priming Aborted - Nozzle Too Cold!"); + return; // Extruder too cold to prime + } + + 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 + } + #endif + + //Calculate and perform the priming distance + if (toolchange_settings.extra_prime >= 0) { + // Positive extra_prime value + // - Return filament at speed (fr) then extra_prime at prime speed + FS_DEBUG("Loading Filament for T", active_extruder, " | Distance: ", toolchange_settings.swap_length, " | Speed: ", MMM_TO_MMS(fr), "mm/s"); + unscaled_e_move(toolchange_settings.swap_length, MMM_TO_MMS(fr)); // Prime (Unretract) filament by extruding equal to Swap Length (Unretract) + + if (toolchange_settings.extra_prime > 0) { + FS_DEBUG("Performing Extra Priming for T", active_extruder, " | Distance: ", toolchange_settings.extra_prime, " | Speed: ", MMM_TO_MMS(toolchange_settings.prime_speed), "mm/s"); + unscaled_e_move(toolchange_settings.extra_prime, MMM_TO_MMS(toolchange_settings.prime_speed)); // Extra Prime Distance + } + } + else { + // Negative extra_prime value + // - Unretract distance (swap length) is reduced by the value of extra_prime + const float eswap = toolchange_settings.swap_length + toolchange_settings.extra_prime; + FS_DEBUG("Negative ExtraPrime value - Swap Return Length has been reduced from ", toolchange_settings.swap_length, " to ", eswap); + FS_DEBUG("Loading Filament for T", active_extruder, " | Distance: ", eswap, " | Speed: ", MMM_TO_MMS(fr), "mm/s"); + unscaled_e_move(eswap, MMM_TO_MMS(fr)); + } + + extruder_was_primed.set(active_extruder); // Log that this extruder has been primed + + // 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)); + #endif + + // Cool down with fan + filament_swap_cooling(); + + } + + /** + * Sequence to Prime the currently selected extruder + * Raise Z, move the ToolChange_Park if enabled, prime the extruder, move back. + */ void tool_change_prime() { - if (toolchange_settings.extra_prime > 0 - && TERN(PREVENT_COLD_EXTRUSION, !thermalManager.targetTooColdToExtrude(active_extruder), 1) - ) { + + FS_DEBUG(">>> tool_change_prime()"); + + if (!too_cold(active_extruder)) { destination = current_position; // Remember the old position const bool ok = TERN1(TOOLCHANGE_PARK, all_axes_homed() && toolchange_settings.enable_park); @@ -933,20 +1057,7 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. } #endif - // Prime (All distances are added and slowed down to ensure secure priming in all circumstances) - unscaled_e_move(toolchange_settings.swap_length + toolchange_settings.extra_prime, MMM_TO_MMS(toolchange_settings.prime_speed)); - - // Cutting retraction - #if TOOLCHANGE_FS_WIPE_RETRACT - unscaled_e_move(-(TOOLCHANGE_FS_WIPE_RETRACT), MMM_TO_MMS(toolchange_settings.retract_speed)); - #endif - - // Cool down with fan - #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; - #endif + extruder_prime(); // Move back #if ENABLED(TOOLCHANGE_PARK) @@ -960,13 +1071,11 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. } #endif - // Cutting recover - unscaled_e_move(toolchange_settings.extra_resume + TOOLCHANGE_FS_WIPE_RETRACT, MMM_TO_MMS(toolchange_settings.unretract_speed)); - - // Resume at the old E position - current_position.e = destination.e; - sync_plan_position_e(); + extruder_cutting_recover(destination.e); // Cutting recover } + + FS_DEBUG("<<< tool_change_prime"); + } #endif // TOOLCHANGE_FILAMENT_SWAP @@ -1027,7 +1136,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { DEBUG_ECHOLNPGM("No move (not homed)"); } - TERN_(HAS_LCD_MENU, if (!no_move) ui.update()); + TERN_(HAS_MARLINUI_MENU, if (!no_move) ui.update()); #if ENABLED(DUAL_X_CARRIAGE) const bool idex_full_control = dual_x_carriage_mode == DXC_FULL_CONTROL_MODE; @@ -1043,13 +1152,11 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { TEMPORARY_BED_LEVELING_STATE(false); #endif - // First tool priming. To prime again, reboot the machine. + // First tool priming. To prime again, reboot the machine. -- Should only occur for first T0 after powerup! #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED) - static bool first_tool_is_primed = false; - if (new_tool == old_tool && !first_tool_is_primed && enable_first_prime) { + if (enable_first_prime && old_tool == 0 && new_tool == 0 && !extruder_was_primed[0]) { tool_change_prime(); - first_tool_is_primed = true; - TERN_(TOOLCHANGE_FS_INIT_BEFORE_SWAP, toolchange_extruder_ready[old_tool] = true); // Primed and initialized + TERN_(TOOLCHANGE_FS_INIT_BEFORE_SWAP, toolchange_extruder_ready.set(old_tool)); // Primed and initialized } #endif @@ -1074,20 +1181,17 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { // Unload / Retract #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) - const bool should_swap = can_move_away && toolchange_settings.swap_length, - too_cold = TERN0(PREVENT_COLD_EXTRUSION, - !DEBUGGING(DRYRUN) && (thermalManager.targetTooColdToExtrude(old_tool) || thermalManager.targetTooColdToExtrude(new_tool)) - ); + const bool should_swap = can_move_away && toolchange_settings.swap_length; if (should_swap) { - if (too_cold) { - SERIAL_ECHO_MSG(STR_ERR_HOTEND_TOO_COLD); + if (too_cold(old_tool)) { + // If SingleNozzle setup is too cold, unable to perform tool_change. if (ENABLED(SINGLENOZZLE)) { active_extruder = new_tool; return; } } - else { - // For first new tool, change without unloading the old. 'Just prime/init the new' - if (TERN1(TOOLCHANGE_FS_PRIME_FIRST_USED, first_tool_is_primed)) - unscaled_e_move(-toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.retract_speed)); - TERN_(TOOLCHANGE_FS_PRIME_FIRST_USED, first_tool_is_primed = true); // The first new tool will be primed by toolchanging + else if (extruder_was_primed[old_tool]) { + // Retract the old extruder if it was previously primed + // To-Do: Should SingleNozzle always retract? + FS_DEBUG("Retracting Filament for T", old_tool, ". | Distance: ", toolchange_settings.swap_length, " | Speed: ", MMM_TO_MMS(toolchange_settings.retract_speed), "mm/s"); + unscaled_e_move(-toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.retract_speed)); } } #endif @@ -1192,36 +1296,8 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { #endif #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) - if (should_swap && !too_cold) { - - float fr = toolchange_settings.unretract_speed; - - #if ENABLED(TOOLCHANGE_FS_INIT_BEFORE_SWAP) - if (!toolchange_extruder_ready[new_tool]) { - toolchange_extruder_ready[new_tool] = true; - fr = toolchange_settings.prime_speed; // Next move is a prime - unscaled_e_move(0, MMM_TO_MMS(fr)); // Init planner with 0 length move - } - #endif - - // Unretract (or Prime) - unscaled_e_move(toolchange_settings.swap_length, MMM_TO_MMS(fr)); - - // Extra Prime - unscaled_e_move(toolchange_settings.extra_prime, MMM_TO_MMS(toolchange_settings.prime_speed)); - - // Cutting retraction - #if TOOLCHANGE_FS_WIPE_RETRACT - unscaled_e_move(-(TOOLCHANGE_FS_WIPE_RETRACT), MMM_TO_MMS(toolchange_settings.retract_speed)); - #endif - - // Cool down with fan - #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; - #endif - } + if (should_swap && !too_cold(active_extruder)) + extruder_prime(); // Prime selected Extruder #endif // Prevent a move outside physical bounds @@ -1262,11 +1338,8 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { else DEBUG_ECHOLNPGM("Move back skipped"); #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) - if (should_swap && !too_cold) { - // Cutting recover - unscaled_e_move(toolchange_settings.extra_resume + TOOLCHANGE_FS_WIPE_RETRACT, MMM_TO_MMS(toolchange_settings.unretract_speed)); - current_position.e = 0; - sync_plan_position_e(); // New extruder primed and set to 0 + if (should_swap && !too_cold(active_extruder)) { + extruder_cutting_recover(0); // New extruder primed and set to 0 // Restart Fan #if HAS_FAN && TOOLCHANGE_FS_FAN >= 0 @@ -1292,7 +1365,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { #if ENABLED(EXT_SOLENOID) && DISABLED(PARKING_EXTRUDER) disable_all_solenoids(); - enable_solenoid_on_active_extruder(); + enable_solenoid(active_extruder); #endif #if HAS_PRUSA_MMU1 @@ -1324,7 +1397,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { #endif } - SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, active_extruder); + SERIAL_ECHOLNPGM(STR_ACTIVE_EXTRUDER, active_extruder); #endif // HAS_MULTI_EXTRUDER } @@ -1383,7 +1456,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { // Migrate the retracted state #if ENABLED(FWRETRACT) - fwretract.retracted[migration_extruder] = fwretract.retracted[active_extruder]; + fwretract.retracted.set(migration_extruder, fwretract.retracted[active_extruder]); #endif // Migrate the temperature to the new hotend diff --git a/Marlin/src/module/tool_change.h b/Marlin/src/module/tool_change.h index bbdc0b686278..48af9405fd7d 100644 --- a/Marlin/src/module/tool_change.h +++ b/Marlin/src/module/tool_change.h @@ -29,28 +29,34 @@ typedef struct { #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) - float swap_length, extra_prime, extra_resume; - int16_t prime_speed, retract_speed, unretract_speed, fan, fan_speed, fan_time; + float swap_length; // M217 S + float extra_prime; // M217 E + float extra_resume; // M217 B + int16_t prime_speed; // M217 P + int16_t retract_speed; // M217 R + int16_t unretract_speed; // M217 U + uint8_t fan_speed; // M217 F + uint8_t fan_time; // M217 D #endif #if ENABLED(TOOLCHANGE_PARK) - bool enable_park; - xy_pos_t change_point; + bool enable_park; // M217 W + xyz_pos_t change_point; // M217 X Y I J K #endif - float z_raise; + float z_raise; // M217 Z } toolchange_settings_t; extern toolchange_settings_t toolchange_settings; - #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) - void tool_change_prime(); + #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED) + extern bool enable_first_prime; // M217 V #endif - #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED) - extern bool enable_first_prime; + #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) + void tool_change_prime(); // Prime the currently selected extruder #endif #if ENABLED(TOOLCHANGE_FS_INIT_BEFORE_SWAP) - extern bool toolchange_extruder_ready[EXTRUDERS]; + extern Flags toolchange_extruder_ready; #endif #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) diff --git a/Marlin/src/pins/esp32/pins_ENWI_ESPNP.h b/Marlin/src/pins/esp32/pins_ENWI_ESPNP.h new file mode 100644 index 000000000000..aff7f742edf9 --- /dev/null +++ b/Marlin/src/pins/esp32/pins_ENWI_ESPNP.h @@ -0,0 +1,116 @@ +/** + * 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 + +/** + * Espressif ESP32 (Tensilica Xtensa LX6) on ESPNP by enwi + * Website https://github.com/enwi/ESPNP + */ + +#include "env_validate.h" + +#define BOARD_INFO_NAME "ESPNP" +#define DEFAULT_MACHINE_NAME "ESP Pick and Place" + +// +// I2S (steppers & other output-only pins) +// +#define I2S_STEPPER_STREAM +#define I2S_WS 17 +#define I2S_BCK 22 +#define I2S_DATA 21 + +// +// Servos +// +#define SERVO0_PIN 26 +#define SERVO1_PIN 25 + +// +// Limit Switches +// +#define X_STOP_PIN 36 +#define Y_STOP_PIN 39 +#define Z_STOP_PIN 34 +#define I_STOP_PIN 35 +#define J_STOP_PIN 05 +#define K_STOP_PIN 16 + +// +// Steppers +// +#define X_ENABLE_PIN 136 +#define X_DIR_PIN 137 +#define X_STEP_PIN 138 +#define X_CS_PIN 139 + +#define Y_ENABLE_PIN 140 +#define Y_DIR_PIN 141 +#define Y_STEP_PIN 142 +#define Y_CS_PIN 143 + +#define Z_ENABLE_PIN 144 +#define Z_DIR_PIN 145 +#define Z_STEP_PIN 146 +#define Z_CS_PIN 147 + +#define I_ENABLE_PIN 148 +#define I_DIR_PIN 149 +#define I_STEP_PIN 150 +#define I_CS_PIN 151 + +#define J_ENABLE_PIN 152 +#define J_DIR_PIN 153 +#define J_STEP_PIN 154 +#define J_CS_PIN 155 + +#define K_ENABLE_PIN 156 +#define K_DIR_PIN 157 +#define K_STEP_PIN 158 +#define K_CS_PIN 159 + +// Reduce baud rate to improve software serial reliability +#define TMC_BAUD_RATE 19200 + +// +// Temperature Sensors +// +//#define TEMP_0_PIN 36 // Analog Input +//#define TEMP_BED_PIN 39 // Analog Input + +// General use mosfets, useful for things like pumps and solenoids +// Shift register pins 128, 129, 130 and 131 are broken out and can be used +#define FAN_PIN 132 +#define FAN1_PIN 134 +#define FAN2_PIN 135 +#define FAN3_PIN 136 + +// #define FAN_SOFT_PWM_REQUIRED // check if needed + +// Neopixel Rings +#define NEOPIXEL_PIN 14 +#define NEOPIXEL2_PIN 27 + +// SPI +#define MISO_PIN 19 +#define MOSI_PIN 23 +#define SCK_PIN 18 diff --git a/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h b/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h index bfa38adadf73..025650fef552 100644 --- a/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h +++ b/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h @@ -114,20 +114,15 @@ //#define E1_AUTO_FAN_PIN 149 // need to update Configuration_adv.h @section extruder // -// MicroSD card +// ADC Reference Voltage // -#define SD_MOSI_PIN 23 -#define SD_MISO_PIN 19 -#define SD_SCK_PIN 18 -#define SDSS 5 -#define SD_DETECT_PIN 34 // IO34 default is SD_DET signal(Jump to SDDET) -#define USES_SHARED_SPI // SPI is shared by SD card with TMC SPI drivers +#define ADC_REFERENCE_VOLTAGE 2.5 // 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_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 * ------ ------ @@ -152,56 +147,48 @@ #define EXP2_09_PIN 18 #define EXP2_10_PIN 19 -#if HAS_WIRED_LCD +// +// 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 USES_SHARED_SPI // SPI is shared by SD card with TMC SPI drivers - #define BEEPER_PIN 149 - #define BTN_ENC 13 - #define LCD_PINS_ENABLE 21 - #define LCD_PINS_RS 4 - #define BTN_EN1 14 - #define BTN_EN2 12 +#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 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 15 - #define DOGLCD_CS 16 - //#define DOGLCD_SCK 19 - //#define DOGLCD_MOSI 23 - - // Required for MKS_MINI_12864 with this board - //#define MKS_LCD12864B - - #elif ENABLED(MKS_MINI_12864_V3) - + // 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 + #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_PINS_DC 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 #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif - - #else // !MKS_MINI_12864 - - #define LCD_PINS_D4 0 + #else + #define LCD_PINS_D4 EXP1_06_PIN #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) - #define LCD_PINS_D5 16 - #define LCD_PINS_D6 15 - #define LCD_PINS_D7 17 + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_04_PIN + #define LCD_PINS_D7 EXP1_03_PIN #endif - #define BOARD_ST7920_DELAY_1 96 #define BOARD_ST7920_DELAY_2 48 #define BOARD_ST7920_DELAY_3 600 - - #endif // !MKS_MINI_12864 - + #endif #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/esp32/pins_MRR_ESPE.h b/Marlin/src/pins/esp32/pins_MRR_ESPE.h index 60c8405dfe2d..9b9b54e3aebe 100644 --- a/Marlin/src/pins/esp32/pins_MRR_ESPE.h +++ b/Marlin/src/pins/esp32/pins_MRR_ESPE.h @@ -55,7 +55,9 @@ #define I2S_WS 26 #define I2S_BCK 25 #define I2S_DATA 27 -#undef LIN_ADVANCE // Currently, I2S stream does not work with linear advance +#if ENABLED(LIN_ADVANCE) + #error "I2S stream is currently incompatible with LIN_ADVANCE." +#endif // // Steppers diff --git a/Marlin/src/pins/esp32/pins_PANDA_common.h b/Marlin/src/pins/esp32/pins_PANDA_common.h index 81862fbd553c..7deeca3f6227 100644 --- a/Marlin/src/pins/esp32/pins_PANDA_common.h +++ b/Marlin/src/pins/esp32/pins_PANDA_common.h @@ -62,6 +62,13 @@ #define TEMP_0_PIN 39 // Analog Input #define TEMP_BED_PIN 36 // Analog Input +#if ENABLED(MAX31856_PANDAPI) + #define MAX31856_CLK_PIN 29 + #define MAX31856_MISO_PIN 24 + #define MAX31856_MOSI_PIN 28 + #define MAX31856_CS_PIN 27 +#endif + // // Heaters / Fans // @@ -74,25 +81,48 @@ #define E0_AUTO_FAN_PIN 120 // FAN2 #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) + * ------ ------ + * 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 // ? + // -// SD card +// SD Card // #if ENABLED(SDSUPPORT) - #define SD_MOSI_PIN 23 - #define SD_MISO_PIN 19 - #define SD_SCK_PIN 18 - #define SDSS 5 - #define SD_DETECT_PIN 2 + #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 #endif #if HAS_WIRED_LCD - #define BEEPER_PIN 129 - #define BTN_ENC 12 + #define BEEPER_PIN EXP1_10_PIN - #define BTN_EN1 33 - #define BTN_EN2 32 + #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_06_PIN - #define LCD_PINS_RS 27 - #define LCD_PINS_ENABLE 26 - #define LCD_PINS_D4 14 + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #endif diff --git a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h index acf2d31cf604..7953f678fa48 100644 --- a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h +++ b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h @@ -54,7 +54,7 @@ #endif #ifndef MARLIN_EEPROM_SIZE - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // @@ -234,14 +234,16 @@ // // Průša i3 MK2 Multiplexer Support // -#ifndef E_MUX0_PIN - #define E_MUX0_PIN 40 // Z_CS_PIN -#endif -#ifndef E_MUX1_PIN - #define E_MUX1_PIN 42 // E0_CS_PIN -#endif -#ifndef E_MUX2_PIN - #define E_MUX2_PIN 44 // E1_CS_PIN +#if HAS_PRUSA_MMU1 + #ifndef E_MUX0_PIN + #define E_MUX0_PIN 40 // Z_CS_PIN + #endif + #ifndef E_MUX1_PIN + #define E_MUX1_PIN 42 // E0_CS_PIN + #endif + #ifndef E_MUX2_PIN + #define E_MUX2_PIN 44 // E1_CS_PIN + #endif #endif /** @@ -584,7 +586,6 @@ #define DOGLCD_CS 45 #define DOGLCD_A0 44 - #define LCD_SCREEN_ROT_180 #define BEEPER_PIN 33 #define STAT_LED_RED_PIN 32 @@ -597,6 +598,8 @@ #define SD_DETECT_PIN -1 // Pin 49 for display sd interface, 72 for easy adapter board #define KILL_PIN 31 + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #define DOGLCD_CS 29 @@ -618,12 +621,6 @@ #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 - #define BEEPER_PIN 37 // not connected to a pin #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65 @@ -635,6 +632,8 @@ #define SD_DETECT_PIN 49 #define KILL_PIN 64 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(MINIPANEL) #define BEEPER_PIN 42 @@ -644,12 +643,6 @@ #define DOGLCD_A0 44 #define DOGLCD_CS 66 - // GLCD features - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 - #define BTN_EN1 40 #define BTN_EN2 63 #define BTN_ENC 59 @@ -657,6 +650,8 @@ #define SD_DETECT_PIN 49 #define KILL_PIN 64 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(ZONESTAR_LCD) #define ADC_KEYPAD_PIN 12 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 48b178dab5fe..f0f57c63eedc 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h @@ -60,9 +60,9 @@ /** ------ ------ * 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 | NC 3.25 6 5 | 0.18 - * NC | 4 3 | NC 1.31 | 4 3 | RESET - * GND | 2 1 | 5V GND | 2 1 | NC + * 0.15 6 5 | -- 3.25 6 5 | 0.18 + * -- | 4 3 | -- 1.31 | 4 3 | RESET + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ 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 97d78c0d2434..901204c8110a 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -195,7 +195,7 @@ * (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 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ @@ -237,11 +237,11 @@ * * BEFORE AFTER * ------ ------ - * GND 1 | 1 2 | 2 5V 5V 1 | 1 2 | 2 GND - * CS 3 | 3 4 | 4 BTN_EN2 CS 3 | 3 4 | 4 BTN_EN2 - * SID 5 | 5 6 6 BTN_EN1 SID 5 | 5 6 6 BTN_EN1 - * open 7 | 7 8 | 8 BTN_ENC CLK 7 | 7 8 | 8 BTN_ENC - * CLK 9 | 9 10 | 10 Beeper open 9 | 9 10 | 10 Beeper + * (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 * ------ ------ * LCD LCD */ @@ -270,11 +270,11 @@ * * BEFORE AFTER * ______ ______ - * GND | 1 2 | 5V 5V | 1 2 | GND - * CS | 3 4 | BTN_EN2 CS | 3 4 | BTN_EN2 - * SID | 5 6 BTN_EN1 SID | 5 6 BTN_EN1 - * SCK | 7 8 | BTN_ENC SCK | 7 8 | BTN_ENC - * MOSI | 9 10 | open | 9 10 | MOSI + * |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 * ------ ------ * LCD LCD */ @@ -310,7 +310,7 @@ #define TFT_RESET_PIN EXP1_07_PIN #define TFT_BACKLIGHT_PIN EXP1_08_PIN - #define TFT_RST_PIN EXP2_04_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 @@ -424,13 +424,13 @@ /** * Creality Ender-2 display pinout - * ----- - * 5V | 1 2 | GND - * (MOSI) P1_23 | 3 4 | P1_22 (LCD_CS) - * (LCD_A0) P1_21 | 5 6 P1_20 (BTN_EN2) - * (RESET) P1_19 | 7 8 | P1_18 (BTN_EN1) - * (BTN_ENC) P0_28 | 9 10| P1_30 (SCK) - * ----- + * ------ + * (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 + * ------ * EXP1 */ 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 b9dc845c5b77..25c7ba69b6db 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -46,9 +46,9 @@ #endif #if ENABLED(I2C_EEPROM) - #define MARLIN_EEPROM_SIZE 0x8000 // 32Kb + #define MARLIN_EEPROM_SIZE 0x8000 // 32K #elif ENABLED(SDCARD_EEPROM_EMULATION) - #define MARLIN_EEPROM_SIZE 0x800 // 2Kb + #define MARLIN_EEPROM_SIZE 0x800 // 2K #endif // @@ -250,7 +250,7 @@ * 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 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ @@ -272,7 +272,7 @@ #define EXP2_09_PIN P0_15 #define EXP2_10_PIN P0_17 -#if EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI) +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI // RET6 DWIN ENCODER LCD #define BTN_ENC EXP1_06_PIN @@ -298,11 +298,11 @@ * * BEFORE AFTER * ------ ------ - * GND | 1 2 | 5V 5V | 1 2 | GND - * CS | 3 4 | BTN_EN2 CS | 3 4 | BTN_EN2 - * SID | 5 6 BTN_EN1 SID | 5 6 BTN_EN1 - * open | 7 8 | BTN_ENC open | 7 8 | BTN_ENC - * CLK | 9 10| BEEPER CLK | 9 10| BEEPER + * (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 * ------ ------ * LCD LCD */ @@ -330,15 +330,15 @@ * * The ANET_FULL_GRAPHICS_LCD connector plug: * - * BEFORE AFTER - * ------ ------ - * GND | 1 2 | 5V 5V | 1 2 | GND - * CS | 3 4 | BTN_EN2 CS | 3 4 | BTN_EN2 - * SID | 5 6 BTN_EN1 SID | 5 6 BTN_EN1 - * open | 7 8 | BTN_ENC CLK | 7 8 | BTN_ENC - * CLK | 9 10 | BEEPER open | 9 10 | BEEPER - * ------ ------ - * LCD LCD + * 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 + * ------ ------ + * LCD LCD */ #define LCD_PINS_RS EXP1_03_PIN @@ -366,11 +366,11 @@ /** Creality Ender-2 display pinout * ------ - * 5V | 1 2 | GND - * (MOSI) 1.23 | 3 4 | 1.22 (LCD_RS) - * (LCD_A0) 1.21 | 5 6 1.20 (BTN_EN2) - * RESET 1.19 | 7 8 | 1.18 (BTN_EN1) - * (BTN_ENC) 0.28 | 9 10 | 1.30 (SCK) + * (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 * ------ * EXP1 */ diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h index 52f34ed0f0d5..37d0cb7fb1e0 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h @@ -150,14 +150,15 @@ #endif #if ENABLED(BTT_MOTOR_EXPANSION) - /** ------ ------ - * NC | 1 2 | GND NC | 1 2 | GND - * NC | 3 4 | M1EN M2EN | 3 4 | M3EN - * M1STP | 5 6 M1DIR M1RX | 5 6 M1DIAG - * M2DIR | 7 8 | M2STP M2RX | 7 8 | M2DIAG - * M3DIR | 9 10 | M3STP M3RX | 9 10 | M3DIAG - * ------ ------ - * EXP2 EXP1 + /** + * ------ ------ + * (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 | -- + * ------ ------ + * EXP2 EXP1 * * NB In EXP_MOT_USE_EXP2_ONLY mode EXP1 is not used and M2EN and M3EN need to be jumpered to M1EN */ diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h index 406e65d2954d..7f9e530f3c72 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SBASE.h @@ -278,11 +278,7 @@ #endif #elif ENABLED(MINIPANEL) - // GLCD features - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #endif #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h index 15afe7e23837..95bbe17b9b38 100644 --- a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h +++ b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h @@ -233,9 +233,9 @@ /** ------ ------ * (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_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 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ diff --git a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h index 934b74cbb160..b08ac536b3d0 100644 --- a/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h +++ b/Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h @@ -228,7 +228,7 @@ #define PS_ON_PIN P2_12 // (12) -#if !defined(TEMP_0_CS_PIN) && DISABLED(USE_ZMAX_PLUG) +#if !defined(TEMP_0_CS_PIN) && !(HAS_Z_AXIS && Z_HOME_DIR) #define TEMP_0_CS_PIN P1_28 #endif @@ -258,11 +258,13 @@ // // Průša i3 MK2 Multiplexer Support // -#if SERIAL_PORT != 0 && SERIAL_PORT_2 != 0 - #define E_MUX0_PIN P0_03 // ( 0) Z_CS_PIN - #define E_MUX1_PIN P0_02 // ( 1) E0_CS_PIN +#if HAS_PRUSA_MMU1 + #if SERIAL_PORT != 0 && SERIAL_PORT_2 != 0 + #define E_MUX0_PIN P0_03 // ( 0) Z_CS_PIN + #define E_MUX1_PIN P0_02 // ( 1) E0_CS_PIN + #endif + #define E_MUX2_PIN P0_26 // (63) E1_CS_PIN #endif -#define E_MUX2_PIN P0_26 // (63) E1_CS_PIN /** * LCD / Controller @@ -348,8 +350,6 @@ #endif #if ANY(VIKI2, miniVIKI) - //#define LCD_SCREEN_ROT_180 - #define DOGLCD_CS P0_16 // (16) #define DOGLCD_A0 P2_06 // (59) J3-8 & AUX-2 #define DOGLCD_SCK SD_SCK_PIN @@ -358,6 +358,8 @@ #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 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #else #if ENABLED(FYSETC_MINI_12864) @@ -406,11 +408,7 @@ #endif #if ENABLED(MINIPANEL) - // GLCD features - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #endif #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h index f3ecebde4674..4fbc19eed843 100644 --- a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h +++ b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h @@ -155,8 +155,6 @@ #endif #if ANY(VIKI2, miniVIKI) - //#define LCD_SCREEN_ROT_180 - #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 @@ -164,6 +162,8 @@ #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 + + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #else #if IS_ULTIPANEL #define LCD_PINS_D5 P1_17 // (71) ENET_MDIO @@ -180,11 +180,7 @@ #endif #if ENABLED(MINIPANEL) - // GLCD features - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #endif #endif 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 bdc49fc23648..27b65c22cd5c 100644 --- a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h +++ b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h @@ -35,7 +35,7 @@ // Onboard I2C EEPROM #define I2C_EEPROM -#define MARLIN_EEPROM_SIZE 0x1000 // 4KB (AT24C32) +#define MARLIN_EEPROM_SIZE 0x1000 // 4K (AT24C32) // // Servos @@ -186,11 +186,11 @@ /** * ------ - * 5V | 1 2 | GND - * (LCD_EN) P0_18 | 3 4 | P0_17 (LCD_RS) - * (LCD_D4) P0_15 | 5 6 P0_20 (BTN_EN2) - * RESET | 7 8 | P0_19 (BTN_EN1) - * (BTN_ENC) P0_16 | 9 10 | P2_08 (BEEPER) + * (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 * ------ * EXP */ @@ -203,17 +203,17 @@ #define EXP1_09_PIN P0_16 #define EXP1_10_PIN P2_08 -#if EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI) +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI #error "Ender-3 V2 display requires a custom cable with TX = P0_15, RX = P0_16. Comment out this line to continue." /** * Ender 3 V2 display SKR E3 Turbo (EXP1) Ender 3 V2 display --> SKR E3 Turbo * ------ ------ RX 8 --> 5 P0_15 - * 5V | 1 2 | GND 5V | 1 2 | GND TX 7 --> 9 P0_16 - * (BTN_E1) A | 3 4 | B (BTN_E2) (LCD_EN) P0_18 | 3 4 | P0_17 (LCD_RS) BEEPER 5 --> 10 P2_08 - * BEEPER | 5 6 ENT (BTN_ENC) (LCD_D4) P0_15 | 5 6 P0_20 (BTN_EN2) - * (SKR_RX1) TX | 7 8 | RX (SKR_TX1) Reset | 7 8 | P0_19 (BTN_EN1) - * NC | 9 10 | NC (BTN_ENC) P0_16 | 9 10 | P2_08 (BEEPER) + * -- |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 * ------ ------ */ 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 8107f11937cd..4cff5d59e17d 100644 --- a/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h +++ b/Marlin/src/pins/lpc1769/pins_MKS_SGEN_L_V2.h @@ -36,10 +36,8 @@ // EEPROM, MKS SGEN_L V2.0 hardware has 4K EEPROM on the board // #if NO_EEPROM_SELECTED - //#define SDCARD_EEPROM_EMULATION - //#define I2C_EEPROM // AT24C32 - #define FLASH_EEPROM_EMULATION - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define I2C_EEPROM // AT24C32 + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // @@ -103,6 +101,12 @@ #define Z_MIN_PROBE_PIN P1_24 #endif +// +// Filament Runout Sensor +// +#define FIL_RUNOUT_PIN P1_28 // X+ +#define FIL_RUNOUT2_PIN P1_26 // Y+ + // // Steppers // @@ -203,6 +207,14 @@ #define TEMP_1_PIN P0_25_A2 // Analog Input A2 (TH2) #define TEMP_2_PIN P0_26_A3 // Analog Input A3 (P0.26, No pull up) +#if HOTENDS == 1 && !REDUNDANT_TEMP_MATCH(SOURCE, E1) + #if TEMP_SENSOR_PROBE + #define TEMP_PROBE_PIN TEMP_1_PIN + #elif TEMP_SENSOR_CHAMBER + #define TEMP_CHAMBER_PIN TEMP_1_PIN + #endif +#endif + // // Heaters / Fans // @@ -260,9 +272,9 @@ /** ------ ------ * (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_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 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ @@ -327,9 +339,10 @@ #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_A0_PIN EXP1_03_PIN #define TFT_DC_PIN EXP1_03_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 diff --git a/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h b/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h index dc7dcd6db609..81c7dc9403db 100644 --- a/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h +++ b/Marlin/src/pins/lpc1769/pins_TH3D_EZBOARD.h @@ -157,11 +157,11 @@ /** * ------ - * 5V | 1 2 | GND - * P0_18 | 3 4 | P0_16 - * P0_15 | 5 6 P3_25 - * P2_11 | 7 8 | P3_26 - * P1_30 | 9 10 | P1_31 + * 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 * ------ * EXP1 * @@ -182,11 +182,11 @@ #if ENABLED(CR10_STOCKDISPLAY) /** ------ - * 5V | 1 2 | GND - * LCD_EN | 3 4 | LCD_RS - * LCD_D4 | 5 6 EN2 - * KILL | 7 8 | EN1 - * ENC | 9 10 | BEEPER + * BEEPER |10 9 | ENC + * EN1 | 8 7 | KILL + * EN2 6 5 | LCD_D4 + * LCD_RS | 4 3 | LCD_EN + * GND | 2 1 | 5V * ------ */ #define BEEPER_PIN EXP1_10_PIN @@ -197,11 +197,11 @@ #elif ENABLED(MKS_MINI_12864) /** ------ - * 5V | 1 2 | GND - * SPI-MOSI | 3 4 | SPI-CS - * A0 | 5 6 EN2 - * -- | 7 8 | EN1 - * ENC | 9 10 | SPI-SCK + * SCK |10 9 | ENC + * EN1 | 8 7 | -- + * EN2 6 5 | A0 + * CS | 4 3 | MOSI + * GND | 2 1 | 5V * ------ */ #define DOGLCD_CS EXP1_04_PIN diff --git a/Marlin/src/pins/mega/pins_CNCONTROLS_11.h b/Marlin/src/pins/mega/pins_CNCONTROLS_11.h index 6f9e5e8e6c47..5f7a534d115b 100644 --- a/Marlin/src/pins/mega/pins_CNCONTROLS_11.h +++ b/Marlin/src/pins/mega/pins_CNCONTROLS_11.h @@ -135,17 +135,20 @@ // // LCD / Controller // -#define BEEPER_PIN 6 - -// Pins for DOGM SPI LCD Support -#define DOGLCD_A0 26 -#define DOGLCD_CS 24 -#define DOGLCD_MOSI -1 // Prevent auto-define by Conditionals_post.h -#define DOGLCD_SCK -1 - -#define BTN_EN1 23 -#define BTN_EN2 25 -#define BTN_ENC 27 +#if HAS_WIRED_LCD + #define BEEPER_PIN 6 + + #define BTN_EN1 23 + #define BTN_EN2 25 + #define BTN_ENC 27 + + #if HAS_MARLINUI_U8GLIB + #define DOGLCD_A0 26 + #define DOGLCD_CS 24 + #define DOGLCD_MOSI -1 // Prevent auto-define by Conditionals_post.h + #define DOGLCD_SCK -1 + #endif +#endif // Hardware buttons for manual movement of XYZ #define SHIFT_OUT_PIN 19 diff --git a/Marlin/src/pins/mega/pins_CNCONTROLS_12.h b/Marlin/src/pins/mega/pins_CNCONTROLS_12.h index f1200e09018a..0aa0b59ca945 100644 --- a/Marlin/src/pins/mega/pins_CNCONTROLS_12.h +++ b/Marlin/src/pins/mega/pins_CNCONTROLS_12.h @@ -140,19 +140,20 @@ // // LCD / Controller // -#define BEEPER_PIN 16 - -// Pins for DOGM SPI LCD Support -#define DOGLCD_A0 39 -#define DOGLCD_CS 35 -#define DOGLCD_MOSI 48 -#define DOGLCD_SCK 49 -#define LCD_SCREEN_ROT_180 - -// The encoder and click button -#define BTN_EN1 36 -#define BTN_EN2 34 -#define BTN_ENC 38 +#if HAS_WIRED_LCD + #define BEEPER_PIN 16 + + #define BTN_EN1 36 + #define BTN_EN2 34 + #define BTN_ENC 38 + + #if HAS_MARLINUI_U8GLIB + #define DOGLCD_A0 39 + #define DOGLCD_CS 35 + #define DOGLCD_MOSI 48 + #define DOGLCD_SCK 49 + #endif +#endif // Hardware buttons for manual movement of XYZ #define SHIFT_OUT_PIN 42 @@ -164,3 +165,5 @@ #define STAT_LED_BLUE_PIN -1 #define STAT_LED_RED_PIN 10 // TOOL_0_PWM_PIN + +#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 diff --git a/Marlin/src/pins/mega/pins_GT2560_REV_A.h b/Marlin/src/pins/mega/pins_GT2560_REV_A.h index 1adf8d3079f4..99e8704ea558 100644 --- a/Marlin/src/pins/mega/pins_GT2560_REV_A.h +++ b/Marlin/src/pins/mega/pins_GT2560_REV_A.h @@ -127,7 +127,7 @@ #define LCD_RESET_PIN 16 - #define DEFAULT_LCD_CONTRAST 220 + #define LCD_CONTRAST_INIT 220 #define LCD_BACKLIGHT_PIN -1 #else diff --git a/Marlin/src/pins/mega/pins_GT2560_V3_MC2.h b/Marlin/src/pins/mega/pins_GT2560_V3_MC2.h index 6b22b4139b6d..e683d4dfda4b 100644 --- a/Marlin/src/pins/mega/pins_GT2560_V3_MC2.h +++ b/Marlin/src/pins/mega/pins_GT2560_V3_MC2.h @@ -27,9 +27,9 @@ #define BOARD_INFO_NAME "GT2560 V3.0 (MC2)" -#define X_MIN_PIN 22 -#define X_MAX_PIN 24 -#define Y_MIN_PIN 26 -#define Y_MAX_PIN 28 +#define X_MIN_PIN 22 +#define X_MAX_PIN 24 +#define Y_MIN_PIN 26 +#define Y_MAX_PIN 28 #include "pins_GT2560_V3.h" diff --git a/Marlin/src/pins/mega/pins_HJC2560C_REV2.h b/Marlin/src/pins/mega/pins_HJC2560C_REV2.h index dcf25da070ff..5c3b1dc9f6d6 100644 --- a/Marlin/src/pins/mega/pins_HJC2560C_REV2.h +++ b/Marlin/src/pins/mega/pins_HJC2560C_REV2.h @@ -112,7 +112,7 @@ // // M3/M4/M5 - Spindle/Laser Control // -#if EITHER(SPINDLE_FEATURE, LASER_FEATURE) +#if HAS_CUTTER #define SPINDLE_DIR_PIN 16 #define SPINDLE_LASER_ENA_PIN 17 // Pin should have a pullup! #define SPINDLE_LASER_PWM_PIN 9 // Hardware PWM @@ -134,7 +134,7 @@ #if ENABLED(HJC_LCD_SMART_CONTROLLER) #define LCD_BACKLIGHT_PIN 5 // LCD_Backlight //#ifndef LCD_CONTRAST_PIN - // #define LCD_CONTRAST_PIN 5 // LCD_Contrast + // #define LCD_CONTRAST_PIN 5 // LCD_Contrast //#endif #ifndef FIL_RUNOUT_PIN #define FIL_RUNOUT_PIN 24 // Filament runout diff --git a/Marlin/src/pins/mega/pins_LEAPFROG_XEED2015.h b/Marlin/src/pins/mega/pins_LEAPFROG_XEED2015.h index af5cfd6a2eef..4a32472949a3 100644 --- a/Marlin/src/pins/mega/pins_LEAPFROG_XEED2015.h +++ b/Marlin/src/pins/mega/pins_LEAPFROG_XEED2015.h @@ -84,7 +84,7 @@ #define E1_ENABLE_PIN 33 // -// Filament runout +// Filament Runout Sensor // #define FIL_RUNOUT_PIN 42 // ROT2 Connector #define FIL_RUNOUT2_PIN 44 // ROT1 Connector diff --git a/Marlin/src/pins/mega/pins_MEGACONTROLLER.h b/Marlin/src/pins/mega/pins_MEGACONTROLLER.h index 69c60b29ec54..dc9fa52af8e6 100644 --- a/Marlin/src/pins/mega/pins_MEGACONTROLLER.h +++ b/Marlin/src/pins/mega/pins_MEGACONTROLLER.h @@ -121,7 +121,7 @@ #define CONTROLLER_FAN_PIN FAN2_PIN #endif -#define FAN_SOFT_PWM +#define FAN_SOFT_PWM_REQUIRED // // Misc. Functions @@ -139,17 +139,12 @@ #if ENABLED(MINIPANEL) #define BEEPER_PIN 46 - // Pins for DOGM SPI LCD Support + #define DOGLCD_A0 47 #define DOGLCD_CS 45 #define LCD_BACKLIGHT_PIN 44 // backlight LED on PA3 #define KILL_PIN 12 - // GLCD features - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 #define BTN_EN1 48 #define BTN_EN2 11 @@ -157,6 +152,8 @@ #define SD_DETECT_PIN 49 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #endif // MINIPANEL // diff --git a/Marlin/src/pins/mega/pins_MEGATRONICS.h b/Marlin/src/pins/mega/pins_MEGATRONICS.h index 0308175b2a3f..ac0ba4eea662 100644 --- a/Marlin/src/pins/mega/pins_MEGATRONICS.h +++ b/Marlin/src/pins/mega/pins_MEGATRONICS.h @@ -106,7 +106,7 @@ // #define BEEPER_PIN 33 -#if IS_ULTRA_LCD && IS_NEWPANEL +#if HAS_WIRED_LCD && IS_NEWPANEL #define LCD_PINS_RS 16 #define LCD_PINS_ENABLE 17 @@ -122,7 +122,7 @@ #define SD_DETECT_PIN -1 // RAMPS doesn't use this -#endif // IS_ULTRA_LCD && IS_NEWPANEL +#endif // HAS_WIRED_LCD && IS_NEWPANEL // // M3/M4/M5 - Spindle/Laser Control diff --git a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h index d5122e46a9b3..3bcece400f96 100644 --- a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h +++ b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h @@ -69,7 +69,7 @@ #endif // -// Filament Runout Pins +// Filament Runout Sensor // #ifndef FIL_RUNOUT_PIN #define FIL_RUNOUT_PIN 49 @@ -144,50 +144,39 @@ //#define TEMP_1_MOSI_PIN TEMP_0_MOSI_PIN // -// Augmentation for auto-assigning plugs -// -// Two thermocouple connectors allows for either -// 2 extruders or 1 extruder and a heated bed. -// With no heated bed, an additional 24V fan is possible. +// FET Pin Mapping - FET 1 is closest to the input power connector // -#define MOSFET_A_PIN 6 // H3 EX1_HEAT_PIN -#define MOSFET_B_PIN 11 // B5 EX2_HEAT_PIN -#define MOSFET_C_PIN 45 // L4 HBP_PIN -#define MOSFET_D_PIN 44 // L5 EXTRA_FET_PIN +#define MOSFET_1_PIN 6 // Plug EX1 Pin 1-2 -> PH3 #15 -> Logical 06 +#define MOSFET_2_PIN 7 // Plug EX1 Pin 3-4 -> PH4 #16 -> Logical 07 +#define MOSFET_3_PIN 11 // Plug EX2 1-2 -> PB5 #24 -> Logical 11 +#define MOSFET_4_PIN 12 // Plug EX2 3-4 -> PB6 #25 -> Logical 12 +#define MOSFET_5_PIN 45 // Plug HBD 1-2 -> PL4 #39 -> Logical 45 +#define MOSFET_6_PIN 44 // Plug Extra 1-2 -> PL5 #40 -> Logical 44 (FET not soldered in all boards) // // Heaters / Fans (24V) // -#define HEATER_0_PIN MOSFET_A_PIN - -#if FET_ORDER_EFB // Hotend, Fan, Bed - #define HEATER_BED_PIN MOSFET_C_PIN -#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 -#elif FET_ORDER_EFF // Hotend, Fan, Fan - #define FAN1_PIN MOSFET_C_PIN -#endif -#ifndef FAN_PIN - #if EITHER(FET_ORDER_EFB, FET_ORDER_EFF) // Hotend, Fan, Bed or Hotend, Fan, Fan - #define FAN_PIN MOSFET_B_PIN - #elif EITHER(FET_ORDER_EEF, FET_ORDER_SF) // Hotend, Hotend, Fan or Spindle, Fan - #define FAN_PIN MOSFET_C_PIN - #else - #define FAN_PIN MOSFET_D_PIN - #endif -#endif +#define HEATER_0_PIN MOSFET_1_PIN // EX1 +#define HEATER_1_PIN MOSFET_3_PIN // EX2 +#define HEATER_BED_PIN MOSFET_5_PIN // HBP -#ifndef FAN1_PIN - #define FAN1_PIN 7 // H4 EX1_FAN_PIN +// EX1 FAN (Automatic Fans are disabled by default in Configuration_adv.h - comment that out for auto fans) +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN MOSFET_2_PIN +#else + #ifndef FAN_PIN + #define FAN_PIN MOSFET_2_PIN + #endif #endif - -#ifndef CONTROLLER_FAN_PIN - #define CONTROLLER_FAN_PIN 12 // B6 EX2_FAN_PIN +// EX2 FAN (Automatic Fans are disabled by default in Configuration_adv.h - comment that out for auto fans) +#ifndef E1_AUTO_FAN_PIN + #define E1_AUTO_FAN_PIN MOSFET_4_PIN +#else + #ifndef FAN1_PIN + #define FAN1_PIN MOSFET_4_PIN + #endif #endif // diff --git a/Marlin/src/pins/mega/pins_PICA.h b/Marlin/src/pins/mega/pins_PICA.h index 47c101711c4f..0e29d8dffe75 100644 --- a/Marlin/src/pins/mega/pins_PICA.h +++ b/Marlin/src/pins/mega/pins_PICA.h @@ -51,6 +51,7 @@ #define SERVO0_PIN 3 #define SERVO1_PIN 4 #define SERVO2_PIN 5 + // // Limit Switches // diff --git a/Marlin/src/pins/mega/pins_WEEDO_62A.h b/Marlin/src/pins/mega/pins_WEEDO_62A.h new file mode 100644 index 000000000000..4b3bf6a43bee --- /dev/null +++ b/Marlin/src/pins/mega/pins_WEEDO_62A.h @@ -0,0 +1,106 @@ +/** + * 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 . + * + */ + +/** + * Based on WEEDO 62A pin configuration + * Copyright (c) 2019 WEEDO3D Perron + */ + +#pragma once + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "WEEDO 62A" +#endif + +// +// Limit Switches +// +#define X_MIN_PIN 3 +#define X_MAX_PIN 2 +#define Y_MIN_PIN 40 +#define Y_MAX_PIN 41 +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 + +// +// Steppers +// +#define X_STEP_PIN 26 +#define X_DIR_PIN 28 +#define X_ENABLE_PIN 24 + +#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 E0_STEP_PIN 54 +#define E0_DIR_PIN 55 +#define E0_ENABLE_PIN 38 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 13 // ANALOG NUMBERING +#define TEMP_BED_PIN 14 // ANALOG NUMBERING + +// +// Heaters / Fans +// +#define HEATER_0_PIN 10 // EXTRUDER 1 +#define HEATER_BED_PIN 8 // BED +#define FAN_PIN 4 // IO pin. Buffer needed + +// +// Misc. Functions +// +#define PS_ON_PIN 12 +#define LED_PIN 13 + +// +// SD Support +// +#if ENABLED(SDSUPPORT) + #define SDSS 53 + #define SD_DETECT_PIN 49 +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + #define BEEPER_PIN 37 + + #define DOGLCD_A0 27 + #define DOGLCD_CS 29 + #define LCD_RESET_PIN 25 + #define LCD_CONTRAST_INIT 255 + + #define BTN_EN1 33 + #define BTN_EN2 31 + #define BTN_ENC 35 +#endif diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 0f0f42508db0..3ea3c6b48d3c 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -37,27 +37,31 @@ #define MAX_E_STEPPERS 8 -#if MB(RAMPS_13_EFB, RAMPS_14_EFB, RAMPS_PLUS_EFB, RAMPS_14_RE_ARM_EFB, RAMPS_SMART_EFB, RAMPS_DUO_EFB, RAMPS4DUE_EFB) - #define FET_ORDER_EFB 1 -#elif MB(RAMPS_13_EEB, RAMPS_14_EEB, RAMPS_PLUS_EEB, RAMPS_14_RE_ARM_EEB, RAMPS_SMART_EEB, RAMPS_DUO_EEB, RAMPS4DUE_EEB) - #define FET_ORDER_EEB 1 -#elif MB(RAMPS_13_EFF, RAMPS_14_EFF, RAMPS_PLUS_EFF, RAMPS_14_RE_ARM_EFF, RAMPS_SMART_EFF, RAMPS_DUO_EFF, RAMPS4DUE_EFF) - #define FET_ORDER_EFF 1 -#elif MB(RAMPS_13_EEF, RAMPS_14_EEF, RAMPS_PLUS_EEF, RAMPS_14_RE_ARM_EEF, RAMPS_SMART_EEF, RAMPS_DUO_EEF, RAMPS4DUE_EEF) - #define FET_ORDER_EEF 1 -#elif MB(RAMPS_13_SF, RAMPS_14_SF, RAMPS_PLUS_SF, RAMPS_14_RE_ARM_SF, RAMPS_SMART_SF, RAMPS_DUO_SF, RAMPS4DUE_SF) || EITHER(SPINDLE_FEATURE, LASER_FEATURE) - #define FET_ORDER_SF 1 -#elif HAS_MULTI_HOTEND && TEMP_SENSOR_BED - #define FET_ORDER_EEB 1 -#elif HAS_MULTI_HOTEND - #define FET_ORDER_EEF 1 -#elif TEMP_SENSOR_BED - #define FET_ORDER_EFB 1 -#else - #define FET_ORDER_EFF 1 +#if NONE(FET_ORDER_EEF, FET_ORDER_EEB, FET_ORDER_EFF, FET_ORDER_EFB, FET_ORDER_SF) + #if MB(RAMPS_13_EFB, RAMPS_14_EFB, RAMPS_PLUS_EFB, RAMPS_14_RE_ARM_EFB, RAMPS_SMART_EFB, RAMPS_DUO_EFB, RAMPS4DUE_EFB) + #define FET_ORDER_EFB 1 + #elif MB(RAMPS_13_EEB, RAMPS_14_EEB, RAMPS_PLUS_EEB, RAMPS_14_RE_ARM_EEB, RAMPS_SMART_EEB, RAMPS_DUO_EEB, RAMPS4DUE_EEB) + #define FET_ORDER_EEB 1 + #elif MB(RAMPS_13_EFF, RAMPS_14_EFF, RAMPS_PLUS_EFF, RAMPS_14_RE_ARM_EFF, RAMPS_SMART_EFF, RAMPS_DUO_EFF, RAMPS4DUE_EFF) + #define FET_ORDER_EFF 1 + #elif MB(RAMPS_13_EEF, RAMPS_14_EEF, RAMPS_PLUS_EEF, RAMPS_14_RE_ARM_EEF, RAMPS_SMART_EEF, RAMPS_DUO_EEF, RAMPS4DUE_EEF) + #define FET_ORDER_EEF 1 + #elif MB(RAMPS_13_SF, RAMPS_14_SF, RAMPS_PLUS_SF, RAMPS_14_RE_ARM_SF, RAMPS_SMART_SF, RAMPS_DUO_SF, RAMPS4DUE_SF) + #define FET_ORDER_SF 1 + #elif HAS_MULTI_HOTEND || (HAS_EXTRUDERS && HAS_CUTTER) + #if TEMP_SENSOR_BED + #define FET_ORDER_EEB 1 + #else + #define FET_ORDER_EEF 1 + #endif + #elif TEMP_SENSOR_BED + #define FET_ORDER_EFB 1 + #else + #define FET_ORDER_EFF 1 + #endif #endif -#if !(BOTH(IS_ULTRA_LCD, IS_NEWPANEL) && ANY(PANEL_ONE, VIKI2, miniVIKI, WYH_L12864, MINIPANEL, REPRAPWORLD_KEYPAD)) +#if !(BOTH(HAS_WIRED_LCD, IS_NEWPANEL) && ANY(PANEL_ONE, VIKI2, miniVIKI, WYH_L12864, MINIPANEL, REPRAPWORLD_KEYPAD)) #define HAS_FREE_AUX2_PINS 1 #endif @@ -119,6 +123,8 @@ #include "ramps/pins_ZRIB_V20.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 #elif MB(ZRIB_V52) #include "ramps/pins_ZRIB_V52.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 +#elif MB(ZRIB_V53) + #include "ramps/pins_ZRIB_V53.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 #elif MB(FELIX2) #include "ramps/pins_FELIX2.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 #elif MB(RIGIDBOARD) @@ -195,6 +201,8 @@ #include "ramps/pins_RAMPS_S_12.h" // ATmega2560 env:mega2560 #elif MB(LONGER3D_LK1_PRO, LONGER3D_LKx_PRO) #include "ramps/pins_LONGER3D_LKx_PRO.h" // ATmega2560 env:mega2560 +#elif MB(PXMALION_CORE_I3) + #include "ramps/pins_PXMALION_CORE_I3.h" // ATmega2560 env:mega2560 // // RAMBo and derivatives @@ -279,6 +287,8 @@ #include "mega/pins_MALYAN_M180.h" // ATmega2560 env:mega2560 #elif MB(PROTONEER_CNC_SHIELD_V3) #include "mega/pins_PROTONEER_CNC_SHIELD_V3.h"// ATmega2560 env:mega2560 +#elif MB(WEEDO_62A) + #include "mega/pins_WEEDO_62A.h" // ATmega2560 env:mega2560 // // ATmega1281, ATmega2561 @@ -454,14 +464,14 @@ #include "sam/pins_ARCHIM2.h" // SAM3X8E env:DUE_archim env:DUE_archim_debug #elif MB(ALLIGATOR) #include "sam/pins_ALLIGATOR_R2.h" // SAM3X8E env:DUE env:DUE_debug -#elif MB(ADSK) - #include "sam/pins_ADSK.h" // SAM3X8E env:DUE env:DUE_debug -#elif MB(PRINTRBOARD_G2) - #include "sam/pins_PRINTRBOARD_G2.h" // SAM3X8C env:DUE_USB #elif MB(CNCONTROLS_15D) #include "sam/pins_CNCONTROLS_15D.h" // SAM3X8E env:DUE env:DUE_USB #elif MB(KRATOS32) #include "sam/pins_KRATOS32.h" // SAM3X8E env:DUE env:DUE_USB +#elif MB(PRINTRBOARD_G2) + #include "sam/pins_PRINTRBOARD_G2.h" // SAM3X8C env:DUE_USB +#elif MB(ADSK) + #include "sam/pins_ADSK.h" // SAM3X8C env:DUE env:DUE_debug // // STM32 ARM Cortex-M0 @@ -482,15 +492,15 @@ #elif MB(STM3R_MINI) #include "stm32f1/pins_STM3R_MINI.h" // STM32F103VE? env:STM32F103VE env:STM32F103RE_maple #elif MB(GTM32_PRO_VB) - #include "stm32f1/pins_GTM32_PRO_VB.h" // STM32F103VE env:STM32F103VE env:STM32F103RE_maple + #include "stm32f1/pins_GTM32_PRO_VB.h" // STM32F103VE env:STM32F103VE env:STM32F103VE_GTM32_maple #elif MB(GTM32_PRO_VD) - #include "stm32f1/pins_GTM32_PRO_VD.h" // STM32F103VE env:STM32F103VE env:STM32F103RE_maple + #include "stm32f1/pins_GTM32_PRO_VD.h" // STM32F103VE env:STM32F103VE env:STM32F103VE_GTM32_maple #elif MB(GTM32_MINI) - #include "stm32f1/pins_GTM32_MINI.h" // STM32F103VE env:STM32F103VE env:STM32F103RE_maple + #include "stm32f1/pins_GTM32_MINI.h" // STM32F103VE env:STM32F103VE env:STM32F103VE_GTM32_maple #elif MB(GTM32_MINI_A30) - #include "stm32f1/pins_GTM32_MINI_A30.h" // STM32F103VE env:STM32F103VE env:STM32F103RE_maple + #include "stm32f1/pins_GTM32_MINI_A30.h" // STM32F103VE env:STM32F103VE env:STM32F103VE_GTM32_maple #elif MB(GTM32_REV_B) - #include "stm32f1/pins_GTM32_REV_B.h" // STM32F103VE env:STM32F103VE env:STM32F103RE_maple + #include "stm32f1/pins_GTM32_REV_B.h" // STM32F103VE env:STM32F103VE env:STM32F103VE_GTM32_maple #elif MB(MORPHEUS) #include "stm32f1/pins_MORPHEUS.h" // STM32F103RE env:STM32F103RE env:STM32F103RE_maple #elif MB(CHITU3D) @@ -546,7 +556,7 @@ #elif MB(LONGER3D_LK) #include "stm32f1/pins_LONGER3D_LK.h" // STM32F1 env:STM32F103VE_longer env:STM32F103VE_longer_maple #elif MB(CCROBOT_MEEB_3DP) - #include "stm32f1/pins_CCROBOT_MEEB_3DP.h" // STM32F1 env:STM32F103RC_meeb + #include "stm32f1/pins_CCROBOT_MEEB_3DP.h" // STM32F1 env:STM32F103RC_meeb_maple #elif MB(CHITU3D_V5) #include "stm32f1/pins_CHITU3D_V5.h" // STM32F1 env:chitu_f103 env:chitu_f103_maple env:chitu_v5_gpio_init env:chitu_v5_gpio_init_maple #elif MB(CHITU3D_V6) @@ -554,21 +564,27 @@ #elif MB(CHITU3D_V9) #include "stm32f1/pins_CHITU3D_V9.h" // STM32F1 env:chitu_f103 env:chitu_f103_maple #elif MB(CREALITY_V4) - #include "stm32f1/pins_CREALITY_V4.h" // STM32F1 env:STM32F103RET6_creality env:STM32F103RET6_creality_maple + #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:STM32F103RET6_creality env:STM32F103RET6_creality_maple + #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_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) - #include "stm32f1/pins_CREALITY_V423.h" // STM32F1 env:STM32F103RET6_creality + #include "stm32f1/pins_CREALITY_V423.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer #elif MB(CREALITY_V427) - #include "stm32f1/pins_CREALITY_V427.h" // STM32F1 env:STM32F103RET6_creality env:STM32F103RET6_creality_maple + #include "stm32f1/pins_CREALITY_V427.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V431, CREALITY_V431_A, CREALITY_V431_B, CREALITY_V431_C, CREALITY_V431_D) - #include "stm32f1/pins_CREALITY_V431.h" // STM32F1 env:STM32F103RET6_creality env:STM32F103RET6_creality_maple + #include "stm32f1/pins_CREALITY_V431.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V452) - #include "stm32f1/pins_CREALITY_V452.h" // STM32F1 env:STM32F103RET6_creality env:STM32F103RET6_creality_maple + #include "stm32f1/pins_CREALITY_V452.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V453) - #include "stm32f1/pins_CREALITY_V453.h" // STM32F1 env:STM32F103RET6_creality env:STM32F103RET6_creality_maple + #include "stm32f1/pins_CREALITY_V453.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V24S1) - #include "stm32f1/pins_CREALITY_V24S1.h" // STM32F1 env:STM32F103RET6_creality env:STM32F103RET6_creality_maple + #include "stm32f1/pins_CREALITY_V24S1.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple +#elif MB(CREALITY_V24S1_301) + #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(TRIGORILLA_PRO) #include "stm32f1/pins_TRIGORILLA_PRO.h" // STM32F1 env:trigorilla_pro env:trigorilla_pro_maple #elif MB(FLY_MINI) @@ -587,6 +603,8 @@ #include "stm32f1/pins_ZM3E4_V2_0.h" // STM32F1 env:STM32F103VE_ZM3E4V2_USB env:STM32F103VE_ZM3E4V2_USB_maple #elif MB(ERYONE_ERY32_MINI) #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 // // ARM Cortex-M4F @@ -657,6 +675,8 @@ #include "stm32f4/pins_MKS_ROBIN_PRO_V2.h" // STM32F4 env:mks_robin_pro2 #elif MB(MKS_ROBIN_NANO_V3) #include "stm32f4/pins_MKS_ROBIN_NANO_V3.h" // STM32F4 env:mks_robin_nano_v3 env:mks_robin_nano_v3_usb_flash_drive env:mks_robin_nano_v3_usb_flash_drive_msc +#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 #elif MB(ANET_ET4P) @@ -675,6 +695,8 @@ #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 // // ARM Cortex M7 @@ -686,6 +708,10 @@ #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_V3_0) + #include "stm32h7/pins_BTT_SKR_V3_0.h" // STM32H7 env:STM32H743Vx_btt +#elif MB(BTT_SKR_V3_0_EZ) + #include "stm32h7/pins_BTT_SKR_V3_0_EZ.h" // STM32H7 env:STM32H743Vx_btt #elif MB(TEENSY41) #include "teensy4/pins_TEENSY41.h" // Teensy-4.x env:teensy41 #elif MB(T41U5XBB) @@ -713,6 +739,8 @@ #include "esp32/pins_PANDA_M4.h" // ESP32 env:PANDA #elif MB(MKS_TINYBEE) #include "esp32/pins_MKS_TINYBEE.h" // ESP32 env:mks_tinybee +#elif MB(ENWI_ESPNP) + #include "esp32/pins_ENWI_ESPNP.h" // ESP32 env:esp32 // // Adafruit Grand Central M4 (SAMD51 ARM Cortex-M4) @@ -720,6 +748,10 @@ #elif MB(AGCM4_RAMPS_144) #include "samd/pins_RAMPS_144.h" // SAMD51 env:SAMD51_grandcentral_m4 +#elif MB(BRICOLEMON_V1_0) + #include "samd/pins_BRICOLEMON_V1_0.h" // SAMD51 env:SAMD51_grandcentral_m4 +#elif MB(BRICOLEMON_LITE_V1_0) + #include "samd/pins_BRICOLEMON_LITE_V1_0.h" // SAMD51 env:SAMD51_grandcentral_m4 // // Custom board (with custom PIO env) @@ -813,8 +845,8 @@ #elif MB(RAMPS_LONGER3D_LK4PRO) #error "BOARD_RAMPS_LONGER3D_LK4PRO is now BOARD_LONGER3D_LKx_PRO. Please update your configuration." #elif MB(BTT_SKR_V2_0) - #error "BTT_SKR_V2_0 is now BTT_SKR_V2_0_REV_A or BTT_SKR_V2_0_REV_B. See https://bit.ly/3t5d9JQ for more information. Please update your configuration." - #elif MB(BOARD_TH3D_EZBOARD_LITE_V2) + #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 defined(MOTHERBOARD) #error "Unknown MOTHERBOARD value set in Configuration.h." @@ -845,6 +877,7 @@ #undef BOARD_RAMPS_DAGOMA #undef BOARD_RAMPS_LONGER3D_LK4PRO #undef BOARD_BTT_SKR_V2_0 + #undef BOARD_TH3D_EZBOARD_LITE_V2 #endif diff --git a/Marlin/src/pins/pinsDebug.h b/Marlin/src/pins/pinsDebug.h index e5db7f7b54be..b662f09ba9ef 100644 --- a/Marlin/src/pins/pinsDebug.h +++ b/Marlin/src/pins/pinsDebug.h @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ +#pragma once #include "../inc/MarlinConfig.h" diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index dc0d5225db32..d7e84b996605 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -141,24 +141,24 @@ REPORT_NAME_ANALOG(__LINE__, TEMP_BED_PIN) #endif #endif -#if PIN_EXISTS(TEMP_BOARD) - #if ANALOG_OK(TEMP_BOARD_PIN) - REPORT_NAME_ANALOG(__LINE__, TEMP_BOARD_PIN) - #endif -#endif #if PIN_EXISTS(TEMP_CHAMBER) #if ANALOG_OK(TEMP_CHAMBER_PIN) REPORT_NAME_ANALOG(__LINE__, TEMP_CHAMBER_PIN) #endif #endif +#if PIN_EXISTS(TEMP_PROBE) + #if ANALOG_OK(TEMP_PROBE_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_PROBE_PIN) + #endif +#endif #if PIN_EXISTS(TEMP_COOLER) #if ANALOG_OK(TEMP_COOLER_PIN) REPORT_NAME_ANALOG(__LINE__, TEMP_COOLER_PIN) #endif #endif -#if PIN_EXISTS(TEMP_PROBE) - #if ANALOG_OK(TEMP_PROBE_PIN) - REPORT_NAME_ANALOG(__LINE__, TEMP_PROBE_PIN) +#if PIN_EXISTS(TEMP_BOARD) + #if ANALOG_OK(TEMP_BOARD_PIN) + REPORT_NAME_ANALOG(__LINE__, TEMP_BOARD_PIN) #endif #endif #if PIN_EXISTS(ADC_KEYPAD) @@ -823,7 +823,7 @@ #if HAS_KILL REPORT_NAME_DIGITAL(__LINE__, KILL_PIN) #endif -#if HAS_FREEZE_PIN +#if PIN_EXISTS(FREEZE) REPORT_NAME_DIGITAL(__LINE__, FREEZE_PIN) #endif #if PIN_EXISTS(LCD_BACKLIGHT) @@ -1601,6 +1601,24 @@ #if PIN_EXISTS(Z4_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, Z4_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(E0_DIAG) REPORT_NAME_DIGITAL(__LINE__, E0_DIAG_PIN) #endif diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h index fe8c4c6c41aa..ab42c30a8f32 100644 --- a/Marlin/src/pins/pins_postprocess.h +++ b/Marlin/src/pins/pins_postprocess.h @@ -468,16 +468,16 @@ #ifndef Z2_USE_ENDSTOP #define Z2_USE_ENDSTOP _ZSTOP_ #endif - #if NUM_Z_STEPPER_DRIVERS >= 3 && !defined(Z3_USE_ENDSTOP) + #if NUM_Z_STEPPERS >= 3 && !defined(Z3_USE_ENDSTOP) #define Z3_USE_ENDSTOP _ZSTOP_ #endif - #if NUM_Z_STEPPER_DRIVERS >= 4 && !defined(Z4_USE_ENDSTOP) + #if NUM_Z_STEPPERS >= 4 && !defined(Z4_USE_ENDSTOP) #define Z4_USE_ENDSTOP _ZSTOP_ #endif #endif #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #ifdef I_STOP_PIN #if I_HOME_TO_MIN #define I_MIN_PIN I_STOP_PIN @@ -500,7 +500,7 @@ #undef I_MAX_PIN #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #ifdef J_STOP_PIN #if J_HOME_TO_MIN #define J_MIN_PIN J_STOP_PIN @@ -523,7 +523,7 @@ #undef J_MAX_PIN #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #ifdef K_STOP_PIN #if K_HOME_TO_MIN #define K_MIN_PIN K_STOP_PIN @@ -546,6 +546,7 @@ #undef K_MAX_PIN #endif +// Filament Sensor first pin alias #if HAS_FILAMENT_SENSOR #define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN // Filament Sensor first pin alias #else @@ -598,12 +599,13 @@ #define X2_E_INDEX E_STEPPERS #endif -// The X2 axis, if any, should be the next open extruder port #if HAS_X2_STEPPER && !defined(X2_DIAG_PIN) && !defined(X2_STEP_PIN) && !PIN_EXISTS(X2_CS_PIN) #define Y2_E_INDEX INCREMENT(X2_E_INDEX) #else #define Y2_E_INDEX X2_E_INDEX #endif + +// The X2 axis, if any, should be the next open extruder port #if HAS_X2_STEPPER #ifndef X2_STEP_PIN #define X2_STEP_PIN _EPIN(X2_E_INDEX, STEP) @@ -686,13 +688,14 @@ #define X2_MS3_PIN -1 #endif -// The Y2 axis, if any, should be the next open extruder port -#if ENABLED(Y_DUAL_STEPPER_DRIVERS) && !defined(Y2_DIAG_PIN) && !defined(Y2_STEP_PIN) && !PIN_EXISTS(Y2_CS_PIN) +#if HAS_DUAL_Y_STEPPERS && !defined(Y2_DIAG_PIN) && !defined(Y2_STEP_PIN) && !PIN_EXISTS(Y2_CS_PIN) #define Z2_E_INDEX INCREMENT(Y2_E_INDEX) #else #define Z2_E_INDEX Y2_E_INDEX #endif -#if ENABLED(Y_DUAL_STEPPER_DRIVERS) + +// The Y2 axis, if any, should be the next open extruder port +#if HAS_DUAL_Y_STEPPERS #ifndef Y2_STEP_PIN #define Y2_STEP_PIN _EPIN(Y2_E_INDEX, STEP) #define Y2_DIR_PIN _EPIN(Y2_E_INDEX, DIR) @@ -771,13 +774,14 @@ #define Y2_MS3_PIN -1 #endif -// The Z2 axis, if any, should be the next open extruder port -#if NUM_Z_STEPPER_DRIVERS >= 2 && !defined(Z2_DIAG_PIN) && !defined(Z2_STEP_PIN) && !PIN_EXISTS(Z2_CS_PIN) +#if NUM_Z_STEPPERS >= 2 && !defined(Z2_DIAG_PIN) && !defined(Z2_STEP_PIN) && !PIN_EXISTS(Z2_CS_PIN) #define Z3_E_INDEX INCREMENT(Z2_E_INDEX) #else #define Z3_E_INDEX Z2_E_INDEX #endif -#if NUM_Z_STEPPER_DRIVERS >= 2 + +// The Z2 axis, if any, should be the next open extruder port +#if NUM_Z_STEPPERS >= 2 #ifndef Z2_STEP_PIN #define Z2_STEP_PIN _EPIN(Z2_E_INDEX, STEP) #define Z2_DIR_PIN _EPIN(Z2_E_INDEX, DIR) @@ -856,13 +860,14 @@ #define Z2_MS3_PIN -1 #endif -// The Z3 axis, if any, should be the next open extruder port -#if NUM_Z_STEPPER_DRIVERS >= 3 && !defined(Z3_DIAG_PIN) && !defined(Z3_STEP_PIN) && !PIN_EXISTS(Z3_CS_PIN) +#if NUM_Z_STEPPERS >= 3 && !defined(Z3_DIAG_PIN) && !defined(Z3_STEP_PIN) && !PIN_EXISTS(Z3_CS_PIN) #define Z4_E_INDEX INCREMENT(Z3_E_INDEX) #else #define Z4_E_INDEX Z3_E_INDEX #endif -#if NUM_Z_STEPPER_DRIVERS >= 3 + +// The Z3 axis, if any, should be the next open extruder port +#if NUM_Z_STEPPERS >= 3 #ifndef Z3_STEP_PIN #define Z3_STEP_PIN _EPIN(Z3_E_INDEX, STEP) #define Z3_DIR_PIN _EPIN(Z3_E_INDEX, DIR) @@ -941,13 +946,14 @@ #define Z3_MS3_PIN -1 #endif -// The Z4 axis, if any, should be the next open extruder port -#if NUM_Z_STEPPER_DRIVERS >= 4 && !defined(Z4_DIAG_PIN) && !defined(Z4_STEP_PIN) && !PIN_EXISTS(Z4_CS_PIN) +#if NUM_Z_STEPPERS >= 4 && !defined(Z4_DIAG_PIN) && !defined(Z4_STEP_PIN) && !PIN_EXISTS(Z4_CS_PIN) #define I_E_INDEX INCREMENT(Z4_E_INDEX) #else #define I_E_INDEX Z4_E_INDEX #endif -#if NUM_Z_STEPPER_DRIVERS >= 4 + +// The Z4 axis, if any, should be the next open extruder port +#if NUM_Z_STEPPERS >= 4 #ifndef Z4_STEP_PIN #define Z4_STEP_PIN _EPIN(Z4_E_INDEX, STEP) #define Z4_DIR_PIN _EPIN(Z4_E_INDEX, DIR) @@ -1026,13 +1032,14 @@ #define Z4_MS3_PIN -1 #endif -// The I axis, if any, should be the next open extruder port -#if LINEAR_AXES >= 4 && !defined(I_DIAG_PIN) && !defined(I_STEP_PIN) && !PIN_EXISTS(I_CS_PIN) +#if HAS_I_AXIS && !defined(I_DIAG_PIN) && !defined(I_STEP_PIN) && !PIN_EXISTS(I_CS_PIN) #define J_E_INDEX INCREMENT(I_E_INDEX) #else #define J_E_INDEX I_E_INDEX #endif -#if LINEAR_AXES >= 4 + +// The I axis, if any, should be the next open extruder port +#if HAS_I_AXIS #ifndef I_STEP_PIN #define I_STEP_PIN _EPIN(I_E_INDEX, STEP) #define I_DIR_PIN _EPIN(I_E_INDEX, DIR) @@ -1111,13 +1118,14 @@ #define I_MS3_PIN -1 #endif -// The J axis, if any, should be the next open extruder port -#if LINEAR_AXES >= 5 && !defined(J_DIAG_PIN) && !defined(J_STEP_PIN) && !PIN_EXISTS(J_CS_PIN) +#if HAS_J_AXIS && !defined(J_DIAG_PIN) && !defined(J_STEP_PIN) && !PIN_EXISTS(J_CS_PIN) #define K_E_INDEX INCREMENT(J_E_INDEX) #else #define K_E_INDEX J_E_INDEX #endif -#if LINEAR_AXES >= 5 + +// The J axis, if any, should be the next open extruder port +#if HAS_J_AXIS #ifndef J_STEP_PIN #define J_STEP_PIN _EPIN(J_E_INDEX, STEP) #define J_DIR_PIN _EPIN(J_E_INDEX, DIR) @@ -1197,7 +1205,7 @@ #endif // The K axis, if any, should be the next open extruder port -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #ifndef K_STEP_PIN #define K_STEP_PIN _EPIN(K_E_INDEX, STEP) #define K_DIR_PIN _EPIN(K_E_INDEX, DIR) @@ -1311,6 +1319,9 @@ #undef X_MAX_PIN #define X_MAX_PIN -1 #endif +#if NONE(USE_XMIN_PLUG, USE_XMAX_PLUG) + #undef X_STOP_PIN +#endif #if DISABLED(USE_YMIN_PLUG) #undef Y_MIN_PIN #define Y_MIN_PIN -1 @@ -1319,6 +1330,9 @@ #undef Y_MAX_PIN #define Y_MAX_PIN -1 #endif +#if NONE(USE_YMIN_PLUG, USE_YMAX_PLUG) + #undef Y_STOP_PIN +#endif #if DISABLED(USE_ZMIN_PLUG) #undef Z_MIN_PIN #define Z_MIN_PIN -1 @@ -1327,6 +1341,9 @@ #undef Z_MAX_PIN #define Z_MAX_PIN -1 #endif +#if NONE(USE_ZMIN_PLUG, USE_ZMAX_PLUG) + #undef Z_STOP_PIN +#endif #if DISABLED(USE_IMIN_PLUG) #undef I_MIN_PIN #define I_MIN_PIN -1 @@ -1335,6 +1352,9 @@ #undef I_MAX_PIN #define I_MAX_PIN -1 #endif +#if NONE(USE_IMIN_PLUG, USE_IMAX_PLUG) + #undef I_STOP_PIN +#endif #if DISABLED(USE_JMIN_PLUG) #undef J_MIN_PIN #define J_MIN_PIN -1 @@ -1343,6 +1363,9 @@ #undef J_MAX_PIN #define J_MAX_PIN -1 #endif +#if NONE(USE_JMIN_PLUG, USE_JMAX_PLUG) + #undef J_STOP_PIN +#endif #if DISABLED(USE_KMIN_PLUG) #undef K_MIN_PIN #define K_MIN_PIN -1 @@ -1351,6 +1374,9 @@ #undef K_MAX_PIN #define K_MAX_PIN -1 #endif +#if NONE(USE_KMIN_PLUG, USE_KMAX_PLUG) + #undef K_STOP_PIN +#endif #if DISABLED(X_DUAL_ENDSTOPS) || X_HOME_TO_MAX #undef X2_MIN_PIN @@ -1370,16 +1396,16 @@ #if DISABLED(Z_MULTI_ENDSTOPS) || Z_HOME_TO_MIN #undef Z2_MAX_PIN #endif -#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 3 || Z_HOME_TO_MAX +#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPERS < 3 || Z_HOME_TO_MAX #undef Z3_MIN_PIN #endif -#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 3 || Z_HOME_TO_MIN +#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPERS < 3 || Z_HOME_TO_MIN #undef Z3_MAX_PIN #endif -#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 4 || Z_HOME_TO_MAX +#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPERS < 4 || Z_HOME_TO_MAX #undef Z4_MIN_PIN #endif -#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 4 || Z_HOME_TO_MIN +#if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPERS < 4 || Z_HOME_TO_MIN #undef Z4_MAX_PIN #endif diff --git a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h index a7d1a6282048..9150bf13655d 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h @@ -163,9 +163,11 @@ // // Průša i3 MK2 Multiplexer Support // -#define E_MUX0_PIN 17 -#define E_MUX1_PIN 16 -#define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 +#if HAS_PRUSA_MMU1 + #define E_MUX0_PIN 17 + #define E_MUX1_PIN 16 + #define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 +#endif // // LCD / Controller diff --git a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h index 45c09ae33e3b..413eb8c98cc6 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RETRO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RETRO.h @@ -55,7 +55,6 @@ #define X_MIN_PIN 12 // X- #define Y_MIN_PIN 11 // Y- - #define Z_MIN_PIN 10 // Z- #define X_MAX_PIN 81 // X+ #define Y_MAX_PIN 57 // Y+ @@ -78,15 +77,16 @@ #endif #if ENABLED(BLTOUCH) - #define Z_MIN_PIN 11 // Y-MIN - #define SERVO0_PIN 10 // Z-MIN - #else - #define Z_MIN_PIN 10 + #define Z_MIN_PIN 11 // Y- + #define SERVO0_PIN 10 // Z- #endif #endif #define Z_MAX_PIN 7 +#ifndef Z_MIN_PIN + #define Z_MIN_PIN 10 // Z- +#endif // // Z Probe (when not Z_MIN_PIN) @@ -157,9 +157,11 @@ // // Průša i3 MK2 Multiplexer Support // -#define E_MUX0_PIN 17 -#define E_MUX1_PIN 16 -#define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 +#if HAS_PRUSA_MMU1 + #define E_MUX0_PIN 17 + #define E_MUX1_PIN 16 + #define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 +#endif // // LCD / Controller diff --git a/Marlin/src/pins/rambo/pins_MINIRAMBO.h b/Marlin/src/pins/rambo/pins_MINIRAMBO.h index ab25e2e692af..31d44f2b34ba 100644 --- a/Marlin/src/pins/rambo/pins_MINIRAMBO.h +++ b/Marlin/src/pins/rambo/pins_MINIRAMBO.h @@ -130,10 +130,12 @@ // // Průša i3 MK2 Multiplexer Support // -#define E_MUX0_PIN 17 -#define E_MUX1_PIN 16 -#if !MB(MINIRAMBO_10A) - #define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 +#if HAS_PRUSA_MMU1 + #define E_MUX0_PIN 17 + #define E_MUX1_PIN 16 + #if !MB(MINIRAMBO_10A) + #define E_MUX2_PIN 78 // 84 in MK2 Firmware, with BEEPER as 78 + #endif #endif // diff --git a/Marlin/src/pins/rambo/pins_RAMBO.h b/Marlin/src/pins/rambo/pins_RAMBO.h index 41e59c1b22dd..5484b193b93b 100644 --- a/Marlin/src/pins/rambo/pins_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_RAMBO.h @@ -186,9 +186,11 @@ // // Průša i3 MK2 Multiplexer Support // -#define E_MUX0_PIN 17 -#define E_MUX1_PIN 16 -#define E_MUX2_PIN 84 // 84 in MK2 Firmware +#if HAS_PRUSA_MMU1 + #define E_MUX0_PIN 17 + #define E_MUX1_PIN 16 + #define E_MUX2_PIN 84 // 84 in MK2 Firmware +#endif // // LCD / Controller @@ -214,7 +216,6 @@ #define DOGLCD_A0 70 #define DOGLCD_CS 71 - #define LCD_SCREEN_ROT_180 #define BTN_EN1 85 #define BTN_EN2 84 @@ -225,6 +226,8 @@ #define STAT_LED_RED_PIN 22 #define STAT_LED_BLUE_PIN 32 + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #else // !VIKI2 && !miniVIKI #define BEEPER_PIN 79 // AUX-4 diff --git a/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h b/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h index c2a691a3b73b..4c2645e64b2a 100644 --- a/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h +++ b/Marlin/src/pins/rambo/pins_SCOOVO_X9H.h @@ -148,10 +148,11 @@ // Pins for DOGM SPI LCD Support #define DOGLCD_A0 70 #define DOGLCD_CS 71 - #define LCD_SCREEN_ROT_180 #define SD_DETECT_PIN -1 // Pin 72 if using easy adapter board #define STAT_LED_RED_PIN 22 #define STAT_LED_BLUE_PIN 32 -#endif // VIKI2/miniVIKI + + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 +#endif diff --git a/Marlin/src/pins/ramps/pins_3DRAG.h b/Marlin/src/pins/ramps/pins_3DRAG.h index 48eeacd5c478..6f5b775af9ce 100644 --- a/Marlin/src/pins/ramps/pins_3DRAG.h +++ b/Marlin/src/pins/ramps/pins_3DRAG.h @@ -111,7 +111,7 @@ #define SPINDLE_LASER_PWM_PIN 46 // Hardware PWM #define SPINDLE_LASER_ENA_PIN 62 // Pullup! #define SPINDLE_DIR_PIN 48 - #elif !BOTH(IS_ULTRA_LCD, IS_NEWPANEL) // Use expansion header if no LCD in use + #elif !BOTH(HAS_WIRED_LCD, IS_NEWPANEL) // Use expansion header if no LCD in use #define SPINDLE_LASER_ENA_PIN 16 // Pullup or pulldown! #define SPINDLE_DIR_PIN 17 #if !NUM_SERVOS // Use servo connector if possible @@ -135,7 +135,7 @@ // // LCD / Controller // -#if IS_ULTRA_LCD && IS_NEWPANEL +#if HAS_WIRED_LCD && IS_NEWPANEL #undef BEEPER_PIN // TODO: Remap EXP1/2 based on adapter @@ -164,7 +164,7 @@ #define BEEPER_PIN 33 -#endif // IS_ULTRA_LCD && IS_NEWPANEL +#endif // HAS_WIRED_LCD && IS_NEWPANEL #if IS_U8GLIB_ST7920 #define BOARD_ST7920_DELAY_1 0 diff --git a/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h b/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h index c2896146e64f..e3baea76e4de 100644 --- a/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h +++ b/Marlin/src/pins/ramps/pins_AZTEEG_X3_PRO.h @@ -158,7 +158,7 @@ #if ENABLED(CASE_LIGHT_ENABLE) && PIN_EXISTS(CASE_LIGHT) && defined(DOGLCD_A0) && DOGLCD_A0 == CASE_LIGHT_PIN #undef DOGLCD_A0 // Steal pin 44 for the case light; if you have a Viki2 and have connected it #define DOGLCD_A0 57 // following the Panucatt wiring diagram, you may need to tweak these pin assignments - // as the wiring diagram uses pin 44 for DOGLCD_A0 + // as the wiring diagram uses pin 44 for DOGLCD_A0. #endif // diff --git a/Marlin/src/pins/ramps/pins_FELIX2.h b/Marlin/src/pins/ramps/pins_FELIX2.h index e572d3f2866c..bdf83c44ba8e 100644 --- a/Marlin/src/pins/ramps/pins_FELIX2.h +++ b/Marlin/src/pins/ramps/pins_FELIX2.h @@ -49,7 +49,7 @@ // // LCD / Controller // -#if IS_ULTRA_LCD && IS_NEWPANEL +#if HAS_WIRED_LCD && IS_NEWPANEL #define SD_DETECT_PIN 6 diff --git a/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h b/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h index 9c6b74f1269d..b8de260909b6 100644 --- a/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h +++ b/Marlin/src/pins/ramps/pins_FYSETC_F6_13.h @@ -234,7 +234,7 @@ #if ENABLED(FYSETC_MINI_12864) // - // See https://wiki.fysetc.com/Mini12864_Panel/?fbclid=IwAR1FyjuNdVOOy9_xzky3qqo_WeM5h-4gpRnnWhQr_O1Ef3h0AFnFXmCehK8 + // See https://wiki.fysetc.com/Mini12864_Panel/ // #define DOGLCD_A0 16 #define DOGLCD_CS 17 diff --git a/Marlin/src/pins/ramps/pins_K8600.h b/Marlin/src/pins/ramps/pins_K8600.h index 015512992782..2dabd9d59b93 100644 --- a/Marlin/src/pins/ramps/pins_K8600.h +++ b/Marlin/src/pins/ramps/pins_K8600.h @@ -69,7 +69,7 @@ // // LCD / Controller // -#if IS_ULTRA_LCD && IS_NEWPANEL +#if HAS_WIRED_LCD && IS_NEWPANEL #undef BEEPER_PIN #undef LCD_PINS_RS diff --git a/Marlin/src/pins/ramps/pins_K8800.h b/Marlin/src/pins/ramps/pins_K8800.h index 9bc74943b47a..f1362ec61d34 100644 --- a/Marlin/src/pins/ramps/pins_K8800.h +++ b/Marlin/src/pins/ramps/pins_K8800.h @@ -30,8 +30,6 @@ #define BOARD_INFO_NAME "K8800" #define DEFAULT_MACHINE_NAME "Vertex Delta" -//#define LCD_SCREEN_ROT_180 - // // Limit Switches // @@ -109,7 +107,8 @@ #define LCD_CONTRAST_MIN 0 #define LCD_CONTRAST_MAX 100 - #define DEFAULT_LCD_CONTRAST 30 + #define LCD_CONTRAST_INIT 30 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #if IS_NEWPANEL #define BTN_EN1 17 diff --git a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h index 729a82b9c633..a7817c6f3a7b 100644 --- a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h +++ b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h @@ -105,7 +105,9 @@ // // Průša i3 MK2 Multiplexer Support // -#define E_MUX2_PIN -1 +#if HAS_PRUSA_MMU1 + #define E_MUX2_PIN -1 +#endif // // Misc. Functions diff --git a/Marlin/src/pins/ramps/pins_MKS_GEN_13.h b/Marlin/src/pins/ramps/pins_MKS_GEN_13.h index 4742ac9b0d25..5f373f99d74b 100644 --- a/Marlin/src/pins/ramps/pins_MKS_GEN_13.h +++ b/Marlin/src/pins/ramps/pins_MKS_GEN_13.h @@ -89,7 +89,7 @@ * 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 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ diff --git a/Marlin/src/pins/ramps/pins_MKS_GEN_L.h b/Marlin/src/pins/ramps/pins_MKS_GEN_L.h index 522a34cda199..4dca1ca187b0 100644 --- a/Marlin/src/pins/ramps/pins_MKS_GEN_L.h +++ b/Marlin/src/pins/ramps/pins_MKS_GEN_L.h @@ -37,6 +37,12 @@ // Power outputs EFBF or EFBE #define MOSFET_D_PIN 7 +// Hotend, Hotend, Bed + Fan on D9 +#if FET_ORDER_EEB + #define MOSFET_B_PIN 7 + #define FAN_PIN 9 +#endif + // // CS Pins wired to avoid conflict with the LCD // See https://www.thingiverse.com/asset:66604 diff --git a/Marlin/src/pins/ramps/pins_PXMALION_CORE_I3.h b/Marlin/src/pins/ramps/pins_PXMALION_CORE_I3.h new file mode 100644 index 000000000000..12c40c7dca03 --- /dev/null +++ b/Marlin/src/pins/ramps/pins_PXMALION_CORE_I3.h @@ -0,0 +1,86 @@ +/** + * 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 . + * + */ + +/** + * Pxmalion Core i3 - https://github.com/Pxmalion + */ + +#include "env_validate.h" + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Core i3" +#endif + +// +// Servos +// +#define SERVO0_PIN 51 +#define SERVO1_PIN -1 +#define SERVO2_PIN -1 +#define SERVO3_PIN -1 + +// +// Limit Switches +// +#define X_STOP_PIN 3 +#define Y_STOP_PIN 2 +#define Z_MIN_PIN 19 +#define Z_MAX_PIN 18 + +// TODO: Filament Runout Sensor +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN -1 +#endif + +// +// Steppers +// +#define X_CS_PIN -1 +#define Y_CS_PIN -1 +#define Z_CS_PIN -1 +#define E0_CS_PIN -1 +#define E1_CS_PIN -1 + +// +// Heaters / Fans +// +#define FET_ORDER_EFB +#ifndef MOSFET_A_PIN + #define MOSFET_A_PIN 8 +#endif +#ifndef MOSFET_B_PIN + #define MOSFET_B_PIN 7 +#endif +#ifndef MOSFET_C_PIN + #define MOSFET_C_PIN 9 +#endif + +// +// Misc. Functions +// +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN -1 // Analog Input +#endif + +#define PS_ON_PIN 11 + +#include "pins_RAMPS.h" diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index 4697ff61b2c4..4ab7f4007331 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -120,14 +120,14 @@ #define X_DIR_PIN 55 #define X_ENABLE_PIN 38 #ifndef X_CS_PIN - #define X_CS_PIN AUX3_03_PIN + #define X_CS_PIN 53 #endif #define Y_STEP_PIN 60 #define Y_DIR_PIN 61 #define Y_ENABLE_PIN 56 #ifndef Y_CS_PIN - #define Y_CS_PIN AUX3_07_PIN + #define Y_CS_PIN 49 #endif #ifndef Z_STEP_PIN @@ -241,7 +241,7 @@ // Misc. Functions // #ifndef SDSS - #define SDSS AUX3_03_PIN + #define SDSS AUX3_06_PIN #endif #define LED_PIN 13 @@ -270,7 +270,7 @@ // M3/M4/M5 - Spindle/Laser Control // #if HAS_CUTTER && !defined(SPINDLE_LASER_ENA_PIN) - #if !NUM_SERVOS // Use servo connector if possible + #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 #define SPINDLE_DIR_PIN 5 @@ -412,30 +412,59 @@ // // Průša i3 MK2 Multiplexer Support // -#ifndef E_MUX0_PIN - #define E_MUX0_PIN 40 // Z_CS_PIN -#endif -#ifndef E_MUX1_PIN - #define E_MUX1_PIN 42 // E0_CS_PIN -#endif -#ifndef E_MUX2_PIN - #define E_MUX2_PIN 44 // E1_CS_PIN +#if HAS_PRUSA_MMU1 + #ifndef E_MUX0_PIN + #define E_MUX0_PIN 40 // Z_CS_PIN + #endif + #ifndef E_MUX1_PIN + #define E_MUX1_PIN 42 // E0_CS_PIN + #endif + #ifndef E_MUX2_PIN + #define E_MUX2_PIN 44 // E1_CS_PIN + #endif #endif // -// AUX3 : GND D52 D50 5V -// NC D53 D51 D49 +// AUX1 5V GND D2 D1 +// 2 4 6 8 +// 1 3 5 7 +// 5V GND A3 A4 +// +#define AUX1_05_PIN 57 // (A3) +#define AUX1_06_PIN 2 +#define AUX1_07_PIN 58 // (A4) +#define AUX1_08_PIN 1 -#define AUX3_03_PIN 53 -#define AUX3_04_PIN 52 -#define AUX3_05_PIN 51 -#define AUX3_06_PIN 50 -#define AUX3_07_PIN 49 +// +// AUX2 GND A9 D40 D42 A11 +// 2 4 6 8 10 +// 1 3 5 7 9 +// VCC A5 A10 D44 A12 +// +#define AUX2_03_PIN 59 // (A5) +#define AUX2_04_PIN 63 // (A9) +#define AUX2_05_PIN 64 // (A10) +#define AUX2_06_PIN 40 +#define AUX2_07_PIN 44 +#define AUX2_08_PIN 42 +#define AUX2_09_PIN 66 // (A12) +#define AUX2_10_PIN 65 // (A11) // -// AUX4 : D16 D17 D23 D25 D27 D29 D31 D33 D35 D37 D39 D41 D43 D45 D47 D32 GND 5V +// AUX3 GND D52 D50 5V +// 7 5 3 1 +// 8 6 4 2 +// NC D53 D51 D49 // +#define AUX3_02_PIN 49 +#define AUX3_03_PIN 50 +#define AUX3_04_PIN 51 +#define AUX3_05_PIN 52 +#define AUX3_06_PIN 53 +// +// AUX4 5V GND D32 D47 D45 D43 D41 D39 D37 D35 D33 D31 D29 D27 D25 D23 D17 D16 +// #define AUX4_03_PIN 32 #define AUX4_04_PIN 47 #define AUX4_05_PIN 45 @@ -454,35 +483,69 @@ #define AUX4_18_PIN 16 /** - * LCD adapter. NOTE: These come in two variants. The socket keys can be + * LCD adapters come in different variants. The socket keys can be * on either side, and may be backwards on some boards / displays. - * ------ ------ - * D37 |10 9 | D35 (MISO) D50 |10 9 | D52 (SCK) - * D17 | 8 7 | D16 D31 | 8 7 | 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 | NC - * ------ ------ - * EXP1 EXP2 */ #ifndef EXP1_03_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_09_PIN AUX4_10_PIN - #define EXP1_10_PIN AUX4_09_PIN - #define EXP2_03_PIN AUX4_07_PIN - #define EXP2_04_PIN AUX3_07_PIN - #define EXP2_05_PIN AUX3_05_PIN - #define EXP2_06_PIN AUX4_11_PIN - #define EXP2_07_PIN AUX3_03_PIN - #define EXP2_08_PIN AUX4_12_PIN - #define EXP2_09_PIN AUX3_04_PIN - #define EXP2_10_PIN AUX3_06_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 + + #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 | -- + * ------ ------ + * EXP1 EXP2 + */ + #define EXP1_09_PIN AUX4_12_PIN + #define EXP1_10_PIN AUX4_11_PIN + + #define EXP2_03_PIN AUX4_07_PIN + #define EXP2_06_PIN AUX4_09_PIN + #define EXP2_08_PIN AUX4_10_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 | -- + * ------ ------ + * EXP1 EXP2 + */ + #define EXP1_09_PIN AUX4_10_PIN + #define EXP1_10_PIN AUX4_09_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 + #else + #define EXP2_03_PIN AUX4_07_PIN + #define EXP2_06_PIN AUX4_11_PIN + #define EXP2_08_PIN AUX4_12_PIN + #endif + + #endif + #endif ////////////////////////// @@ -491,10 +554,7 @@ #if HAS_WIRED_LCD - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 // // LCD Display output pins @@ -507,12 +567,12 @@ #elif BOTH(IS_NEWPANEL, PANEL_ONE) - #define LCD_PINS_RS 40 - #define LCD_PINS_ENABLE 42 - #define LCD_PINS_D4 65 - #define LCD_PINS_D5 66 - #define LCD_PINS_D6 44 - #define LCD_PINS_D7 64 + #define LCD_PINS_RS AUX2_06_PIN + #define LCD_PINS_ENABLE AUX2_08_PIN + #define LCD_PINS_D4 AUX2_10_PIN + #define LCD_PINS_D5 AUX2_09_PIN + #define LCD_PINS_D6 AUX2_07_PIN + #define LCD_PINS_D7 AUX2_05_PIN #elif ENABLED(TFTGLCD_PANEL_SPI) @@ -533,12 +593,16 @@ #elif ENABLED(ZONESTAR_LCD) #error "CAUTION! ZONESTAR_LCD on RAMPS requires wiring modifications. It plugs into AUX2 but GND and 5V need to be swapped. Comment out this line to continue." - #define LCD_PINS_RS 64 - #define LCD_PINS_ENABLE 44 - #define LCD_PINS_D4 63 - #define LCD_PINS_D5 40 - #define LCD_PINS_D6 42 - #define LCD_PINS_D7 65 + #define LCD_PINS_RS AUX2_05_PIN + #define LCD_PINS_ENABLE AUX2_07_PIN + #define LCD_PINS_D4 AUX2_04_PIN + #define LCD_PINS_D5 AUX2_06_PIN + #define LCD_PINS_D6 AUX2_08_PIN + #define LCD_PINS_D7 AUX2_10_PIN + + #elif ENABLED(AZSMZ_12864) + + // Pins only defined for RAMPS_SMART currently #else @@ -570,8 +634,8 @@ // Buttons attached to a shift register // Not wired yet //#define SHIFT_CLK_PIN 38 - //#define SHIFT_LD_PIN 42 - //#define SHIFT_OUT_PIN 40 + //#define SHIFT_LD_PIN AUX2_08_PIN + //#define SHIFT_OUT_PIN AUX2_06_PIN //#define SHIFT_EN_PIN EXP1_08_PIN #endif @@ -612,10 +676,10 @@ #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) - #define BTN_EN1 64 - #define BTN_EN2 59 - #define BTN_ENC 63 - #define SD_DETECT_PIN 42 + #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 #elif ENABLED(LCD_I2C_PANELOLU2) @@ -627,8 +691,8 @@ #elif ENABLED(LCD_I2C_VIKI) - #define BTN_EN1 40 // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42. - #define BTN_EN2 42 + #define BTN_EN1 AUX2_06_PIN // https://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains AUX2-06 and AUX2-08. + #define BTN_EN2 AUX2_08_PIN #define BTN_ENC -1 #define LCD_SDSS SDSS @@ -636,17 +700,17 @@ #elif ANY(VIKI2, miniVIKI) - #define DOGLCD_CS 45 - #define DOGLCD_A0 44 - #define LCD_SCREEN_ROT_180 + #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 - #define STAT_LED_RED_PIN 32 + #define STAT_LED_RED_PIN AUX4_03_PIN #define STAT_LED_BLUE_PIN EXP1_09_PIN #define BTN_EN1 22 #define BTN_EN2 7 - #define BTN_ENC 39 + #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 @@ -692,7 +756,7 @@ #elif ENABLED(FYSETC_MINI_12864) - // From https://wiki.fysetc.com/Mini12864_Panel/?fbclid=IwAR1FyjuNdVOOy9_xzky3qqo_WeM5h-4gpRnnWhQr_O1Ef3h0AFnFXmCehK8 + // From https://wiki.fysetc.com/Mini12864_Panel/ #define DOGLCD_A0 EXP1_07_PIN #define DOGLCD_CS EXP1_08_PIN @@ -723,19 +787,18 @@ #elif ENABLED(MINIPANEL) - #define BEEPER_PIN 42 - // not connected to a pin - #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65 + #define BEEPER_PIN AUX2_08_PIN + #define LCD_BACKLIGHT_PIN AUX2_10_PIN - #define DOGLCD_A0 44 - #define DOGLCD_CS 66 + #define DOGLCD_A0 AUX2_07_PIN + #define DOGLCD_CS AUX2_09_PIN - #define BTN_EN1 40 - #define BTN_EN2 63 - #define BTN_ENC 59 + #define BTN_EN1 AUX2_06_PIN + #define BTN_EN2 AUX2_04_PIN + #define BTN_ENC AUX2_03_PIN - #define SD_DETECT_PIN EXP2_04_PIN - #define KILL_PIN 64 + #define SD_DETECT_PIN AUX3_02_PIN + #define KILL_PIN AUX2_05_PIN #elif ENABLED(ZONESTAR_LCD) @@ -747,14 +810,14 @@ #elif ENABLED(G3D_PANEL) - #define BEEPER_PIN EXP2_06_PIN + #define BEEPER_PIN EXP1_10_PIN #define SD_DETECT_PIN EXP2_04_PIN #define KILL_PIN EXP2_03_PIN - #define BTN_EN1 EXP1_10_PIN - #define BTN_EN2 EXP1_09_PIN - #define BTN_ENC EXP2_08_PIN + #define BTN_EN1 EXP2_06_PIN + #define BTN_EN2 EXP2_08_PIN + #define BTN_ENC EXP1_09_PIN #elif IS_TFTGLCD_PANEL @@ -764,11 +827,10 @@ #define BEEPER_PIN EXP2_06_PIN - // Buttons are directly attached to AUX-2 - #if ENABLED(PANEL_ONE) - #define BTN_EN1 59 // AUX2 PIN 3 - #define BTN_EN2 63 // AUX2 PIN 4 - #define BTN_ENC EXP2_04_PIN + #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 @@ -781,17 +843,17 @@ #endif // HAS_WIRED_LCD #if IS_RRW_KEYPAD && !HAS_ADC_BUTTONS - #define SHIFT_OUT_PIN 40 - #define SHIFT_CLK_PIN 44 - #define SHIFT_LD_PIN 42 + #define SHIFT_OUT_PIN AUX2_06_PIN + #define SHIFT_CLK_PIN AUX2_07_PIN + #define SHIFT_LD_PIN AUX2_08_PIN #ifndef BTN_EN1 - #define BTN_EN1 64 + #define BTN_EN1 AUX2_05_PIN #endif #ifndef BTN_EN2 - #define BTN_EN2 59 + #define BTN_EN2 AUX2_03_PIN #endif #ifndef BTN_ENC - #define BTN_ENC 63 + #define BTN_ENC AUX2_04_PIN #endif #endif @@ -802,15 +864,15 @@ /** * FYSETC TFT-81050 display pinout * - * Board Display - * ----- ----- - * (SCK) D52 | 1 2 | D50 (MISO) MISO | 1 2 | SCK - * (SD_CS) D53 | 3 4 | D33 (BNT_EN2) (BNT_EN2) MOD_RESET | 3 4 | SD_CS - * (MOSI) D51 | 5 6 D31 (BNT_EN1) (BNT_EN1) LCD_CS | 5 6 MOSI - * RESET | 7 8 | D49 (SD_DET) SD_DET | 7 8 | RESET - * NC | 9 10| GND GND | 9 10| 5V - * ----- ----- - * EXP2 EXP1 + * 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) + * ------ ------ + * EXP2 * * Needs custom cable: * @@ -835,6 +897,7 @@ #define SD_DETECT_PIN EXP2_04_PIN - #define CLCD_MOD_RESET EXP2_08_PIN - #define CLCD_SPI_CS EXP2_06_PIN + #define CLCD_MOD_RESET EXP2_06_PIN + #define CLCD_SPI_CS EXP2_08_PIN + #endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 diff --git a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h index def71fefc13e..679503e98268 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h @@ -30,9 +30,8 @@ // // Heaters / Fans // - -// Power outputs EFBF or EFBE -#define MOSFET_D_PIN 7 +#define MOSFET_B_PIN 7 // For HEATER_1_PIN ("EEF" or "EEB") +#define FAN_PIN 9 #define FIL_RUNOUT_PIN 2 #if NUM_RUNOUT_SENSORS >= 2 @@ -40,7 +39,12 @@ #endif #ifndef SD_DETECT_PIN - #define SD_DETECT_PIN 49 // Always define onboard SD detect + #if SD_CONNECTION_IS(ONBOARD) + //#define HAS_ONBOARD_SD_DETECT // If the SD_DETECT_PIN is wired up + #endif + #if ENABLED(HAS_ONBOARD_SD_DETECT) || !SD_CONNECTION_IS(ONBOARD) + #define SD_DETECT_PIN 49 + #endif #endif #ifndef PS_ON_PIN diff --git a/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h b/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h index a69572dee7a8..0c554c353faf 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_PLUS.h @@ -23,10 +23,6 @@ /** * Arduino Mega with RAMPS v1.4Plus, also known as 3DYMY version, pin assignments - * The differences to the RAMPS v1.4 are: - * - Swap heater E0 with E1 - * - Swap pins 8 and 10. Bed/Fan/Hotend as labeled on the board are on pins 8/9/10. - * - Change pins 16->42, 17->44 and 29->53 used for display. * * Applies to the following boards: * @@ -35,6 +31,11 @@ * RAMPS_PLUS_EFF (Extruder, Fan, Fan) * RAMPS_PLUS_EEF (Extruder, Extruder, Fan) * RAMPS_PLUS_SF (Spindle, Controller Fan) + * + * Differences from RAMPS v1.4: + * - Swap heater E0 with E1 + * - Swap pins 8 and 10. Bed/Fan/Hotend as labeled on the board are on pins 8/9/10. + * - Change EXP1/2 pins */ #include "env_validate.h" @@ -62,15 +63,32 @@ #define E1_ENABLE_PIN 24 #define E1_CS_PIN -1 -#include "pins_RAMPS.h" +/** 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 | -- + * ------ ------ + * 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 -#if IS_ULTRA_LCD && NONE(REPRAPWORLD_GRAPHICAL_LCD, CR10_STOCKDISPLAY) && !BOTH(IS_NEWPANEL, PANEL_ONE) - #if DISABLED(MKS_12864OLED) || ENABLED(MKS_12864OLED_SSD1306) - #undef LCD_PINS_RS - #define LCD_PINS_RS 42 // 3DYMY boards pin 16 -> 42 - #undef LCD_PINS_ENABLE - #define LCD_PINS_ENABLE 44 // 3DYMY boards pin 17 -> 44 - #endif - #undef LCD_PINS_D7 - #define LCD_PINS_D7 53 // 3DYMY boards pin 29 -> 53 -#endif +#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 + +#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 e1ba91cde8f0..f41573b527cd 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_S_12.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_S_12.h @@ -233,14 +233,16 @@ // // Průša i3 MK2 Multiplexer Support // -#ifndef E_MUX0_PIN - #define E_MUX0_PIN 29 // E2_STEP_PIN -#endif -#ifndef E_MUX1_PIN - #define E_MUX1_PIN 28 // E2_DIR_PIN -#endif -#ifndef E_MUX2_PIN - #define E_MUX2_PIN 39 // E2_ENABLE_PIN +#if HAS_PRUSA_MMU1 + #ifndef E_MUX0_PIN + #define E_MUX0_PIN 29 // E2_STEP_PIN + #endif + #ifndef E_MUX1_PIN + #define E_MUX1_PIN 28 // E2_DIR_PIN + #endif + #ifndef E_MUX2_PIN + #define E_MUX2_PIN 39 // E2_ENABLE_PIN + #endif #endif ////////////////////////// diff --git a/Marlin/src/pins/ramps/pins_RL200.h b/Marlin/src/pins/ramps/pins_RL200.h index 047ad160bed1..52d0173c00a8 100644 --- a/Marlin/src/pins/ramps/pins_RL200.h +++ b/Marlin/src/pins/ramps/pins_RL200.h @@ -31,8 +31,8 @@ #if HOTENDS > 2 || E_STEPPERS > 2 #error "RL200v1 supports up to 2 hotends / E-steppers. Comment out this line to continue." -#elif NUM_Z_STEPPER_DRIVERS != 2 - #error "RL200 uses dual Z stepper motors. Set NUM_Z_STEPPER_DRIVERS to 2 or comment out this line to continue." +#elif NUM_Z_STEPPERS != 2 + #error "RL200 uses dual Z stepper motors. Set NUM_Z_STEPPERS to 2 or comment out this line to continue." #elif !(AXIS_DRIVER_TYPE_X(DRV8825) && AXIS_DRIVER_TYPE_Y(DRV8825) && AXIS_DRIVER_TYPE_Z(DRV8825) && AXIS_DRIVER_TYPE_Z2(DRV8825) && AXIS_DRIVER_TYPE_E0(DRV8825)) #error "You must set ([XYZ]|Z2|E0)_DRIVER_TYPE to DRV8825 in Configuration.h for RL200." #endif diff --git a/Marlin/src/pins/ramps/pins_RUMBA.h b/Marlin/src/pins/ramps/pins_RUMBA.h index d8e2dd09715f..7d17bf2e12ed 100644 --- a/Marlin/src/pins/ramps/pins_RUMBA.h +++ b/Marlin/src/pins/ramps/pins_RUMBA.h @@ -220,7 +220,7 @@ #define RGB_LED_B_PIN 40 #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN 25 + #define NEOPIXEL_PIN 38 #endif #else diff --git a/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h b/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h index b884fcbfc7c1..977be79191b8 100644 --- a/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h +++ b/Marlin/src/pins/ramps/pins_TENLOG_D3_HERO.h @@ -148,6 +148,7 @@ // // Misc. Functions // +//#define PS_ON_PIN 40 // The M80/M81 PSU pin for boards v2.1-2.3 //#define CASE_LIGHT_PIN 5 #define SDSS 53 //#ifndef LED_PIN diff --git a/Marlin/src/pins/ramps/pins_TT_OSCAR.h b/Marlin/src/pins/ramps/pins_TT_OSCAR.h index 01769fbff0cd..9d844ebcdcba 100644 --- a/Marlin/src/pins/ramps/pins_TT_OSCAR.h +++ b/Marlin/src/pins/ramps/pins_TT_OSCAR.h @@ -226,7 +226,7 @@ // // M3/M4/M5 - Spindle/Laser Control // -#if EITHER(SPINDLE_FEATURE, LASER_FEATURE) && !PIN_EXISTS(SPINDLE_LASER_ENA) +#if HAS_CUTTER && !PIN_EXISTS(SPINDLE_LASER_ENA) #if !NUM_SERVOS // Prefer the servo connector #define SPINDLE_LASER_ENA_PIN 4 // Pullup or pulldown! #define SPINDLE_LASER_PWM_PIN 6 // Hardware PWM @@ -252,15 +252,17 @@ // // Průša i3 MK2 Multiplexer Support // -//#ifndef E_MUX0_PIN -// #define E_MUX0_PIN 58 // Y_CS_PIN -//#endif -//#ifndef E_MUX1_PIN -// #define E_MUX1_PIN 53 // Z_CS_PIN -//#endif -//#ifndef E_MUX2_PIN -// #define E_MUX2_PIN 49 // En_CS_PIN -//#endif +#if 0 && HAS_PRUSA_MMU1 + #ifndef E_MUX0_PIN + #define E_MUX0_PIN 58 // Y_CS_PIN + #endif + #ifndef E_MUX1_PIN + #define E_MUX1_PIN 53 // Z_CS_PIN + #endif + #ifndef E_MUX2_PIN + #define E_MUX2_PIN 49 // En_CS_PIN + #endif +#endif ////////////////////////// // LCDs and Controllers // @@ -402,7 +404,6 @@ #define DOGLCD_CS 45 #define DOGLCD_A0 44 - #define LCD_SCREEN_ROT_180 #define BEEPER_PIN 33 #define STAT_LED_RED_PIN 32 @@ -416,6 +417,8 @@ #define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board //#define KILL_PIN 31 + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #define DOGLCD_CS 29 @@ -437,13 +440,6 @@ #define DOGLCD_A0 27 #define DOGLCD_CS 25 - // GLCD features - //#define LCD_CONTRAST_INIT 190 - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 - #define BEEPER_PIN 37 #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65 @@ -455,6 +451,9 @@ #define SD_DETECT_PIN 49 //#define KILL_PIN 64 + //#define LCD_CONTRAST_INIT 190 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(MINIPANEL) #define BEEPER_PIN 42 @@ -464,13 +463,6 @@ #define DOGLCD_A0 44 #define DOGLCD_CS 66 - // GLCD features - //#define LCD_CONTRAST_INIT 190 - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 - #define BTN_EN1 40 #define BTN_EN2 63 #define BTN_ENC 59 @@ -479,6 +471,9 @@ #define SD_DETECT_PIN 49 //#define KILL_PIN 64 + //#define LCD_CONTRAST_INIT 190 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #else // Beeper on AUX-4 diff --git a/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h b/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h index 9823d4cf4b75..128f1974e0e6 100644 --- a/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h +++ b/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h @@ -98,7 +98,7 @@ #endif #ifndef E0_AUTO_FAN_PIN - #define E0_AUTO_FAN_PIN 69 + #define E0_AUTO_FAN_PIN 77 #endif // diff --git a/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h b/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h index 091356a11f82..37060ab94541 100644 --- a/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h +++ b/Marlin/src/pins/ramps/pins_ULTIMAKER_OLD.h @@ -172,7 +172,7 @@ #define LCD_PINS_D6 32 #define LCD_PINS_D7 30 -#elif BOTH(BOARD_REV_1_5, IS_ULTRA_LCD) +#elif BOTH(BOARD_REV_1_5, HAS_WIRED_LCD) #define BEEPER_PIN 18 diff --git a/Marlin/src/pins/ramps/pins_ZRIB_V52.h b/Marlin/src/pins/ramps/pins_ZRIB_V52.h index 27f043914f07..002b9dbef580 100644 --- a/Marlin/src/pins/ramps/pins_ZRIB_V52.h +++ b/Marlin/src/pins/ramps/pins_ZRIB_V52.h @@ -49,111 +49,111 @@ #include "pins_MKS_BASE_common.h" // ... RAMPS -/* - Available connectors on MKS BASE v1.4 (Basically same as ZRIB V5.2) - - ======= - | GND | - |-----| E0 - | 10 | (10) PB4 ** Pin23 ** PWM10 - |-----| - | GND | - |-----| E1 - | 7 | ( 7) PH4 ** Pin16 ** PWM7 - |-----| - | GND | - |-----| FAN - | 9 | ( 9) PH6 ** Pin18 ** PWM9 - ======= - - ======= - | GND | - |-----| Heated Bed - | 8 | ( 8) PH5 ** Pin17 ** PWM8 - ======= - - ========== - | 12-24V | - |--------| Power - | GND | - ========== - - 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 - |----|----|-----| - | 50 | 52 | RST | (50) PB3 ** Pin22 ** SPI_MISO - ================= (52) PB1 ** Pin20 ** SPI_SCK - - XS6/AUX-1 Connector - ====================== - | 5V | GND | NC | 20 | (20) PD1 ** Pin44 ** I2C_SDA - |----|-----|----|----| - | 50 | 51 | 52 | 21 | (50) PB3 ** Pin22 ** SPI_MISO - ====================== (51) PB2 ** Pin21 ** SPI_MOSI - (52) PB1 ** Pin20 ** SPI_SCK - (21) PD0 ** Pin43 ** I2C_SCL - - Temperature - ================================== - | GND | 69 | GND | 68 | GND | 67 | - ================================== - (69) PK7 ** Pin82 ** A15 - (68) PK6 ** Pin83 ** A14 - (67) PK5 ** Pin84 ** A13 - - Limit Switches - ============ - | 2 | GND | X+ ( 2) PE4 ** Pin6 ** PWM2 - |----|-----| - | 3 | GND | X- ( 3) PE5 ** Pin7 ** PWM3 - |----|-----| - | 15 | GND | Y+ (15) PJ0 ** Pin63 ** USART3_RX - |----|-----| - | 14 | GND | Y- (14) PJ1 ** Pin64 ** USART3_TX - |----|-----| - | 19 | GND | Z+ (19) PD2 ** Pin45 ** USART1_RX - |----|-----| - | 18 | GND | Z- (18) PD3 ** Pin46 ** USART1_TX - ============ - - EXP1 - ============ - | 37 | 35 | (37) PC0 ** Pin53 ** D37 - |-----|----| (35) PC2 ** Pin55 ** D35 - | 17 | 16 | (17) PH0 ** Pin12 ** USART2_RX - |-----|----| (16) PH1 ** Pin13 ** USART2_TX - | 23 | 25 | (23) PA1 ** Pin77 ** D23 - |-----|----| (25) PA3 ** Pin75 ** D25 - | 27 | 29 | (27) PA5 ** Pin73 ** D27 - |-----|----| (29) PA7 ** Pin71 ** D29 - | GND | 5V | - ============ - - EXP2 - ============ - | 50 | 52 | (50) PB3 ** Pin22 ** SPI_MISO - |-----|----| (52) PB1 ** Pin20 ** SPI_SCK - | 31 | 53 | (31) PC6 ** Pin59 ** D31 - |-----|----| (53) PB0 ** Pin19 ** SPI_SS - | 33 | 51 | (33) PC4 ** Pin57 ** D33 - |-----|----| (51) PB2 ** Pin21 ** SPI_MOSI - | 49 | 41 | (49) PL0 ** Pin35 ** D49 - |-----|----| (41) PG0 ** Pin51 ** D41 - | GND | NC | - ============ -*/ +/** + * Available connectors on MKS BASE v1.4 (Basically same as ZRIB V5.2) + * + * ======= + * | GND | + * |-----| E0 + * | 10 | (10) PB4 ** Pin23 ** PWM10 + * |-----| + * | GND | + * |-----| E1 + * | 7 | ( 7) PH4 ** Pin16 ** PWM7 + * |-----| + * | GND | + * |-----| FAN + * | 9 | ( 9) PH6 ** Pin18 ** PWM9 + * ======= + * + * ======= + * | GND | + * |-----| Heated Bed + * | 8 | ( 8) PH5 ** Pin17 ** PWM8 + * ======= + * + * ========== + * | 12-24V | + * |--------| Power + * | GND | + * ========== + * + * 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 + * |----|----|-----| + * | 50 | 52 | RST | (50) PB3 ** Pin22 ** SPI_MISO + * ================= (52) PB1 ** Pin20 ** SPI_SCK + * + * XS6/AUX-1 Connector + * ====================== + * | 5V | GND | NC | 20 | (20) PD1 ** Pin44 ** I2C_SDA + * |----|-----|----|----| + * | 50 | 51 | 52 | 21 | (50) PB3 ** Pin22 ** SPI_MISO + * ====================== (51) PB2 ** Pin21 ** SPI_MOSI + * (52) PB1 ** Pin20 ** SPI_SCK + * (21) PD0 ** Pin43 ** I2C_SCL + * + * Temperature + * ================================== + * | GND | 69 | GND | 68 | GND | 67 | + * ================================== + * (69) PK7 ** Pin82 ** A15 + * (68) PK6 ** Pin83 ** A14 + * (67) PK5 ** Pin84 ** A13 + * + * Limit Switches + * ============ + * | 2 | GND | X+ ( 2) PE4 ** Pin6 ** PWM2 + * |----|-----| + * | 3 | GND | X- ( 3) PE5 ** Pin7 ** PWM3 + * |----|-----| + * | 15 | GND | Y+ (15) PJ0 ** Pin63 ** USART3_RX + * |----|-----| + * | 14 | GND | Y- (14) PJ1 ** Pin64 ** USART3_TX + * |----|-----| + * | 19 | GND | Z+ (19) PD2 ** Pin45 ** USART1_RX + * |----|-----| + * | 18 | GND | Z- (18) PD3 ** Pin46 ** USART1_TX + * ============ + * + * EXP1 + * ============ + * | 37 | 35 | (37) PC0 ** Pin53 ** D37 + * |-----|----| (35) PC2 ** Pin55 ** D35 + * | 17 | 16 | (17) PH0 ** Pin12 ** USART2_RX + * |-----|----| (16) PH1 ** Pin13 ** USART2_TX + * | 23 | 25 | (23) PA1 ** Pin77 ** D23 + * |-----|----| (25) PA3 ** Pin75 ** D25 + * | 27 | 29 | (27) PA5 ** Pin73 ** D27 + * |-----|----| (29) PA7 ** Pin71 ** D29 + * | GND | 5V | + * ============ + * + * EXP2 + * ============ + * | 50 | 52 | (50) PB3 ** Pin22 ** SPI_MISO + * |-----|----| (52) PB1 ** Pin20 ** SPI_SCK + * | 31 | 53 | (31) PC6 ** Pin59 ** D31 + * |-----|----| (53) PB0 ** Pin19 ** SPI_SS + * | 33 | 51 | (33) PC4 ** Pin57 ** D33 + * |-----|----| (51) PB2 ** Pin21 ** SPI_MOSI + * | 49 | 41 | (49) PL0 ** Pin35 ** D49 + * |-----|----| (41) PG0 ** Pin51 ** D41 + * | GND | NC | + * ============ + */ diff --git a/Marlin/src/pins/ramps/pins_ZRIB_V53.h b/Marlin/src/pins/ramps/pins_ZRIB_V53.h new file mode 100644 index 000000000000..3a2604586ef0 --- /dev/null +++ b/Marlin/src/pins/ramps/pins_ZRIB_V53.h @@ -0,0 +1,511 @@ +/** + * 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 + +/** + * ZRIB V5.3 Based on MKS BASE v1.4 with A4982 stepper drivers and digital micro-stepping + */ + +#include "env_validate.h" + +#if HOTENDS > 2 + #error "ZRIB V5.3 only supports up to 2 hotends. Comment out this line to continue." +#elif E_STEPPERS > 3 + #error "ZRIB V5.3 only supports up to 3 E-steppers. Comment out this line to continue." +#endif + +#define BOARD_INFO_NAME "ZRIB V5.3" + +// +// PIN 12 Connector +// +#define PIN_12_PIN 12 + +// +// XS1 Connector +// +#define XS1_01_PIN 42 +#define XS1_03_PIN 43 +#define XS1_05_PIN 44 +#define XS1_07_PIN 45 +#define XS1_08_PIN 47 + +// +// XS6 Connector +// +#define XS6_01_PIN 20 +#define XS6_03_PIN 52 +#define XS6_05_PIN 51 +#define XS6_07_PIN 50 +#define XS6_08_PIN 21 + +// +// Servos / XS3 Connector +// +#ifndef SERVO0_PIN + #define SERVO0_PIN 11 // Analog Output +#endif +#ifndef SERVO1_PIN + #define SERVO1_PIN 12 // Analog Output +#endif + +// +// Limit Switches +// +#ifndef X_STOP_PIN + #ifndef X_MIN_PIN + #define X_MIN_PIN 3 + #endif + #ifndef X_MAX_PIN + #define X_MAX_PIN 2 + #endif +#endif +#ifndef Y_STOP_PIN + #ifndef Y_MIN_PIN + #define Y_MIN_PIN 14 + #endif + #ifndef Y_MAX_PIN + #define Y_MAX_PIN 15 + #endif +#endif +#ifndef Z_STOP_PIN + #ifndef Z_MIN_PIN + #define Z_MIN_PIN 18 + #endif + #ifndef Z_MAX_PIN + #define Z_MAX_PIN 19 + #endif +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 19 +#endif + +// +// Steppers +// +#define X_STEP_PIN 54 +#define X_DIR_PIN 55 +#define X_ENABLE_PIN 38 + +#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 + +#if NUM_Z_STEPPERS == 2 + #define Z2_STEP_PIN 26 // E0 connector + #define Z2_DIR_PIN 28 + #define Z2_ENABLE_PIN 24 + + #define E0_STEP_PIN 36 // E1 connector + #define E0_DIR_PIN 34 + #define E0_ENABLE_PIN 30 + + #define E1_STEP_PIN 4 // E2 connector + #define E1_DIR_PIN 5 + #define E1_ENABLE_PIN 22 +#else + #define E0_STEP_PIN 26 + #define E0_DIR_PIN 28 + #define E0_ENABLE_PIN 24 + + #define E1_STEP_PIN 36 + #define E1_DIR_PIN 34 + #define E1_ENABLE_PIN 30 + + #define E2_STEP_PIN 4 + #define E2_DIR_PIN 5 + #define E2_ENABLE_PIN 22 +#endif + +// +// Temperature Sensors +// +#ifndef TEMP_0_PIN + #define TEMP_0_PIN 13 // Analog Input +#endif +#ifndef TEMP_1_PIN + #define TEMP_1_PIN 15 // Analog Input +#endif +#ifndef TEMP_BED_PIN + #define TEMP_BED_PIN 14 // Analog Input +#endif + +// +// Heaters / Fans Connectors +// + +#define HEATER_0_PIN 10 +#define HEATER_1_PIN 7 +#define FAN_PIN 9 +#define HEATER_BED_PIN 8 +#define FAN1_PIN 6 + +// +// Misc. Functions +// +#ifndef SDSS + #define SDSS 53 +#endif + +#define LED_PIN 13 + +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN XS1_01_PIN +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN XS1_03_PIN +#endif + +#if HAS_TMC_UART + /** + * TMC2209 stepper drivers + * + * Hardware serial communication ports. + * If undefined software serial is used according to the pins below + * + * Serial2 -- AUX-4 Pin 18 (D16 TX2) and AUX-4 Pin 17 (D17 RX2) + * Serial1 -- Pins D18 and D19 are used for Z-MIN and Z-MAX + */ + //#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 + + #ifndef X_SERIAL_TX_PIN + #define X_SERIAL_TX_PIN XS1_08_PIN + #endif + #ifndef X_SERIAL_RX_PIN + #define X_SERIAL_RX_PIN PIN_12_PIN + #endif + #ifndef X2_SERIAL_TX_PIN + #define X2_SERIAL_TX_PIN -1 + #endif + #ifndef X2_SERIAL_RX_PIN + #define X2_SERIAL_RX_PIN -1 + #endif + + #ifndef Y_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN XS1_08_PIN + #endif + #ifndef Y_SERIAL_RX_PIN + #define Y_SERIAL_RX_PIN PIN_12_PIN + #endif + #ifndef Y2_SERIAL_TX_PIN + #define Y2_SERIAL_TX_PIN -1 + #endif + #ifndef Y2_SERIAL_RX_PIN + #define Y2_SERIAL_RX_PIN -1 + #endif + + #ifndef Z_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN XS1_08_PIN + #endif + #ifndef Z_SERIAL_RX_PIN + #define Z_SERIAL_RX_PIN PIN_12_PIN + #endif + #ifndef Z2_SERIAL_TX_PIN + #define Z2_SERIAL_TX_PIN XS1_08_PIN + #endif + #ifndef Z2_SERIAL_RX_PIN + #define Z2_SERIAL_RX_PIN PIN_12_PIN + #endif + + #ifndef E0_SERIAL_TX_PIN + #define E0_SERIAL_TX_PIN -1 + #endif + #ifndef E0_SERIAL_RX_PIN + #define E0_SERIAL_RX_PIN -1 + #endif + #ifndef E1_SERIAL_TX_PIN + #define E1_SERIAL_TX_PIN -1 + #endif + #ifndef E1_SERIAL_RX_PIN + #define E1_SERIAL_RX_PIN -1 + #endif + #ifndef E2_SERIAL_TX_PIN + #define E2_SERIAL_TX_PIN -1 + #endif + #ifndef E2_SERIAL_RX_PIN + #define E2_SERIAL_RX_PIN -1 + #endif + #ifndef E3_SERIAL_TX_PIN + #define E3_SERIAL_TX_PIN -1 + #endif + #ifndef E3_SERIAL_RX_PIN + #define E3_SERIAL_RX_PIN -1 + #endif + #ifndef E4_SERIAL_TX_PIN + #define E4_SERIAL_TX_PIN -1 + #endif + #ifndef E4_SERIAL_RX_PIN + #define E4_SERIAL_RX_PIN -1 + #endif + #ifndef E5_SERIAL_TX_PIN + #define E5_SERIAL_TX_PIN -1 + #endif + #ifndef E5_SERIAL_RX_PIN + #define E5_SERIAL_RX_PIN -1 + #endif + #ifndef E6_SERIAL_TX_PIN + #define E6_SERIAL_TX_PIN -1 + #endif + #ifndef E6_SERIAL_RX_PIN + #define E6_SERIAL_RX_PIN -1 + #endif + #ifndef E7_SERIAL_TX_PIN + #define E7_SERIAL_TX_PIN -1 + #endif + #ifndef E7_SERIAL_RX_PIN + #define E7_SERIAL_RX_PIN -1 + #endif +#endif + +/** + * 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 + * D23 6 5 D25 D33 6 5 D51 (MOSI) + * D27 | 4 3 | D29 D49 | 4 3 | D41 + * GND | 2 1 | 5V GND | 2 1 | -- + * ------ ------ + * 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 +#endif + +////////////////////////// +// LCDs and Controllers // +////////////////////////// + +#if ENABLED(ZONESTAR_12864LCD) + #define LCDSCREEN_NAME "ZONESTAR LCD12864" + #define LCD_SDSS 16 + #define LCD_PINS_RS 16 // ST7920_CS_PIN LCD_PIN_RS (PIN4 of LCD module) + #define LCD_PINS_ENABLE 23 // ST7920_DAT_PIN LCD_PIN_R/W (PIN5 of LCD module) + #define LCD_PINS_D4 17 // ST7920_CLK_PIN LCD_PIN_ENABLE (PIN6 of LCD module) + #define BTN_EN2 25 + #define BTN_EN1 27 + #define BTN_ENC 29 + #define BEEPER_PIN 37 + #define KILL_PIN 35 +#elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define LCDSCREEN_NAME "Reprap LCD12864" + // Use EXP1 & EXP2 connector + #define LCD_PINS_RS 16 // ST7920_CS_PIN LCD_PIN_RS + #define LCD_PINS_ENABLE 17 // ST7920_DAT_PIN LCD_PIN_ENABLE + #define LCD_PINS_D4 23 // ST7920_CLK_PIN LCD_PIN_R/W + #define BTN_EN1 31 + #define BTN_EN2 33 + #define BTN_ENC 35 + #define BEEPER_PIN 37 + #define KILL_PIN 41 +#endif + +//================================================================================ +// OLED 128x64 +//================================================================================ + +#if EITHER(ZONESTAR_12864OLED, ZONESTAR_12864OLED_SSD1306) + #define LCDSCREEN_NAME "ZONESTAR 12864OLED" + #define LCD_SDSS 16 + #define LCD_PINS_RS 23 // RESET Pull low for 1s to init + #define LCD_PINS_DC 17 + #define DOGLCD_CS 16 // CS + #define BTN_EN2 25 + #define BTN_EN1 27 + #define BTN_ENC 29 + #define BEEPER_PIN -1 + #define KILL_PIN -1 + #if EITHER(OLED_HW_IIC, OLED_HW_SPI) + #error "Oops! You must choose SW SPI for ZRIB V53 board and connect the OLED screen to EXP1 connector." + #else // SW_SPI + #define DOGLCD_A0 LCD_PINS_DC + #define DOGLCD_MOSI 35 // SDA + #define DOGLCD_SCK 37 // SCK + #endif +#endif // OLED 128x64 + +//================================================================================ +// LCD 2004 KEYPAD +//================================================================================ + +#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 ADC_KEYPAD_PIN 10 // A10 for ADCKEY + #define BEEPER_PIN EXP1_10_PIN +#endif + +/** + * ZRIB V5.3 Main Board + * + * Available connectors on ZRIB V5.3 + * + * ======= + * | GND | + * |-----| E0 + * | 10 | (10) PB4 ** Pin23 ** PWM10 + * |-----| + * | GND | + * |-----| E1 + * | 7 | ( 7) PH4 ** Pin16 ** PWM7 + * |-----| + * | GND | + * |-----| FAN + * | 9 | ( 9) PH6 ** Pin18 ** PWM9 + * ======= + * ======= + * | GND | + * |-----| Heated Bed + * | 8 | ( 8) PH5 ** Pin17 ** PWM8 + * ======= + * ========== + * | 12-24V | + * |--------| Power + * | GND | + * ========== + * 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 + * |----|----|-----| + * | 50 | 52 | RST | (50) PB3 ** Pin22 ** SPI_MISO + * ================= (52) PB1 ** Pin20 ** SPI_SCK + * XS6 Connector + * ====================== + * | 5V | GND | NC | 20 | (20) PD1 ** Pin44 ** I2C_SDA + * |----|-----|----|----| + * | 50 | 51 | 52 | 21 | (50) PB3 ** Pin22 ** SPI_MISO + * ====================== (51) PB2 ** Pin21 ** SPI_MOSI + * (52) PB1 ** Pin20 ** SPI_SCK + * (21) PD0 ** Pin43 ** I2C_SCL + * XS1 Connector + * ====================== + * | 5V | GND | NC | 47 | (47) PL2 ** Pin37 ** D47 + * |----|-----|----|----| + * | 42 | 43 | 44 | 45 | (45) PL4 ** Pin39 ** D45 + * ====================== (44) PL5 ** Pin40 ** D44 + * (43) PL6 ** Pin41 ** D43 + * (42) PL7 ** Pin42 ** D42 + * Temperature + * ================================== + * | GND | 69 | GND | 68 | GND | 67 | + * ================================== + * (69) PK7 ** Pin82 ** A15 + * (68) PK6 ** Pin83 ** A14 + * (67) PK5 ** Pin84 ** A13 + * Limit Switches + * ============ + * | 2 | GND | X+ ( 2) PE4 ** Pin6 ** PWM2 + * |----|-----| + * | 3 | GND | X- ( 3) PE5 ** Pin7 ** PWM3 + * |----|-----| + * | 15 | GND | Y+ (15) PJ0 ** Pin63 ** USART3_RX + * |----|-----| + * | 14 | GND | Y- (14) PJ1 ** Pin64 ** USART3_TX + * |----|-----| + * | 19 | GND | Z+ (19) PD2 ** Pin45 ** USART1_RX + * |----|-----| + * | 18 | GND | Z- (18) PD3 ** Pin46 ** USART1_TX + * ============ + * EXP1 + * ============ + * | 37 | 35 | (37) PC0 ** Pin53 ** D37 + * |-----|----| (35) PC2 ** Pin55 ** D35 + * | 17 | 16 | (17) PH0 ** Pin12 ** USART2_RX + * |-----|----| (16) PH1 ** Pin13 ** USART2_TX + * | 23 | 25 | (23) PA1 ** Pin77 ** D23 + * |-----|----| (25) PA3 ** Pin75 ** D25 + * | 27 | 29 | (27) PA5 ** Pin73 ** D27 + * |-----|----| (29) PA7 ** Pin71 ** D29 + * | GND | 5V | + * ============ + * EXP2 + * ============ + * | 50 | 52 | (50) PB3 ** Pin22 ** SPI_MISO + * |-----|----| (52) PB1 ** Pin20 ** SPI_SCK + * | 31 | 53 | (31) PC6 ** Pin59 ** D31 + * |-----|----| (53) PB0 ** Pin19 ** SPI_SS + * | 33 | 51 | (33) PC4 ** Pin57 ** D33 + * |-----|----| (51) PB2 ** Pin21 ** SPI_MOSI + * | 49 | 41 | (49) PL0 ** Pin35 ** D49 + * |-----|----| (41) PG0 ** Pin51 ** D41 + * | GND | NC | + * ============ + * + * PIN 12 + * ====== + * | 12 | (12) PB6 ** Pin25 ** D12 + * ====== +*/ diff --git a/Marlin/src/pins/sam/pins_KRATOS32.h b/Marlin/src/pins/sam/pins_KRATOS32.h index f429e5634706..f7867f9b2607 100644 --- a/Marlin/src/pins/sam/pins_KRATOS32.h +++ b/Marlin/src/pins/sam/pins_KRATOS32.h @@ -34,7 +34,7 @@ // #if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) #define I2C_EEPROM - #define MARLIN_EEPROM_SIZE 0x1F400 // 16KB + #define MARLIN_EEPROM_SIZE 0x1F400 // 16K #endif // diff --git a/Marlin/src/pins/sam/pins_RADDS.h b/Marlin/src/pins/sam/pins_RADDS.h index 7a865b4ad870..af24014614c1 100644 --- a/Marlin/src/pins/sam/pins_RADDS.h +++ b/Marlin/src/pins/sam/pins_RADDS.h @@ -34,7 +34,7 @@ // #if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) #define I2C_EEPROM - #define MARLIN_EEPROM_SIZE 0x2000 // 8KB + #define MARLIN_EEPROM_SIZE 0x2000 // 8K #endif // @@ -286,7 +286,7 @@ #endif // SPARK_FULL_GRAPHICS #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) - #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #define BTN_ENC_EN 47 // Detect the presence of the encoder #endif #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h b/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h index 30f209ad3713..980a957a505a 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h +++ b/Marlin/src/pins/sam/pins_RAMPS_FD_V1.h @@ -134,71 +134,98 @@ #define SDSS 4 #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 | -- + * ------ ------ + * 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 + // // LCD / Controller // #if HAS_WIRED_LCD // ramps-fd lcd adaptor - #define BEEPER_PIN 37 - #define BTN_EN1 33 - #define BTN_EN2 31 - #define BTN_ENC 35 - #define SD_DETECT_PIN 49 + #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 #if IS_NEWPANEL - #define LCD_PINS_RS 16 - #define LCD_PINS_ENABLE 17 + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN #endif #if ENABLED(FYSETC_MINI_12864) #define DOGLCD_CS LCD_PINS_ENABLE #define DOGLCD_A0 LCD_PINS_RS - #define DOGLCD_SCK 76 - #define DOGLCD_MOSI 75 + #define DOGLCD_SCK EXP2_09_PIN + #define DOGLCD_MOSI EXP2_05_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 23 // 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 25 + #define RGB_LED_R_PIN EXP1_06_PIN #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN 27 + #define RGB_LED_G_PIN EXP1_07_PIN #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN 29 + #define RGB_LED_B_PIN EXP1_08_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN 25 + #define NEOPIXEL_PIN EXP1_06_PIN #endif #elif IS_NEWPANEL - #define LCD_PINS_D4 23 - #define LCD_PINS_D5 25 - #define LCD_PINS_D6 27 - #define LCD_PINS_D7 29 + #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 #if ENABLED(MINIPANEL) - #define DOGLCD_CS 25 - #define DOGLCD_A0 27 + #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_A0 EXP1_07_PIN #endif #endif #if ANY(VIKI2, miniVIKI) - #define DOGLCD_A0 16 + #define DOGLCD_A0 EXP1_04_PIN #define KILL_PIN 51 - #define STAT_LED_BLUE_PIN 29 - #define STAT_LED_RED_PIN 23 - #define DOGLCD_CS 17 - #define DOGLCD_SCK 76 // SCK_PIN - Required for DUE Hardware SPI - #define DOGLCD_MOSI 75 // MOSI_PIN - #define DOGLCD_MISO 74 // MISO_PIN + #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 #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 96d0c9e1cc9a..2b8942c6ad2d 100644 --- a/Marlin/src/pins/sam/pins_RAMPS_SMART.h +++ b/Marlin/src/pins/sam/pins_RAMPS_SMART.h @@ -61,53 +61,43 @@ */ #define BOARD_INFO_NAME "RAMPS-SMART" -#define ALLOW_SAM3X8E -#include "../ramps/pins_RAMPS.h" // I2C EEPROM with 4K of space #define I2C_EEPROM -#define MARLIN_EEPROM_SIZE 0x1000 - -#define SDA_PIN 20 -#define SCL_PIN 21 +#define MARLIN_EEPROM_SIZE 0x1000 // 4K // See EEPROM device datasheet for the following values. These are for 24xx256 -#define EEPROM_SERIAL_ADDR 0x50 // 7 bit i2c address (without R/W bit) -#define EEPROM_PAGE_SIZE 64 // page write buffer size -#define EEPROM_PAGE_WRITE_TIME 7 // page write time in milliseconds (docs say 5ms but that is too short) - -#define TWI_CLOCK_FREQ 400000 -#define EEPROM_ADDRSZ_BYTES TWI_MMR_IADRSZ_2_BYTE // TWI_MMR_IADRSZ_1_BYTE for 1 byte, or TWI_MMR_IADRSZ_2_BYTE for 2 byte -#define EEPROM_AVAILABLE EEPROM_I2C - -#define RESET_PIN 42 // Resets the board if the jumper is attached +#define EEPROM_DEVICE_ADDRESS 0x50 // 7 bit i2c address (without R/W bit) +#define EEPROM_WRITE_DELAY 7 // page write time in milliseconds (docs say 5ms but that is too short) +//#define EEPROM_PAGE_SIZE 64 // page write buffer size +//#define TWI_CLOCK_FREQ 400000 +//#define EEPROM_ADDRSZ_BYTES TWI_MMR_IADRSZ_2_BYTE // TWI_MMR_IADRSZ_1_BYTE for 1 byte, or TWI_MMR_IADRSZ_2_BYTE for 2 byte +//#define EEPROM_AVAILABLE EEPROM_I2C // // Temperature Sensors // -#undef TEMP_0_PIN #define TEMP_0_PIN 9 // Analog Input - -#undef TEMP_1_PIN #define TEMP_1_PIN 10 // Analog Input - -#undef TEMP_BED_PIN #define TEMP_BED_PIN 11 // Analog Input // SPI for MAX Thermocouple -#undef TEMP_0_CS_PIN #if DISABLED(SDSUPPORT) #define TEMP_0_CS_PIN 67 // Don't use 53 if using Display/SD card #else #define TEMP_0_CS_PIN 67 // Don't use 49 (SD_DETECT_PIN) #endif +#define SDA_PIN 20 +#define SCL_PIN 21 +#define RESET_PIN 42 // Resets the board if the jumper is attached + // // LCD / Controller // - -// Support for AZSMZ 12864 LCD with SD Card 3D printer smart controller control panel #if ENABLED(AZSMZ_12864) + + // Support for AZSMZ 12864 LCD with SD Card 3D printer smart controller control panel #define BEEPER_PIN 66 // Smart RAMPS 1.42 pinout diagram on RepRap WIKI erroneously says this should be pin 65 #define DOGLCD_A0 59 #define DOGLCD_CS 44 @@ -116,4 +106,37 @@ #define BTN_ENC 67 // Smart RAMPS 1.42 pinout diagram on RepRap WIKI erroneously says this should be pin 66 #define SD_DETECT_PIN 49 // Pin 49 for display sd interface, 72 for easy adapter board #define KILL_PIN 42 + +#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 | -- + * ------ ------ + * 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 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 + #endif + +#define ALLOW_SAM3X8E +#include "../ramps/pins_RAMPS.h" diff --git a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h index 65ecd37e62da..064ce2751ab3 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_11.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_11.h @@ -18,19 +18,12 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Ported sys0724 & Vynt */ #pragma once /** * Arduino Mega? or Due with RuRAMPS4DUE pin assignments - * - * Applies to the following boards: - * RURAMPS4DUE (Hotend0, Hotend1, Hotend2, Fan0, Fan1, Bed) - * - * Differences between - * RADDS | RuRAMPS4DUE - * | + * Ported by sys0724 & Vynt */ #include "env_validate.h" @@ -117,10 +110,6 @@ //#define E3_MS2_PIN ? //#define E3_MS3_PIN ? -#if USES_Z_MIN_PROBE_PIN - #define Z_MIN_PROBE_PIN 49 -#endif - #ifndef FIL_RUNOUT_PIN #define FIL_RUNOUT_PIN Y_MIN_PIN #endif @@ -157,7 +146,7 @@ // SPI for MAX Thermocouple /* #if DISABLED(SDSUPPORT) - #define TEMP_0_CS_PIN 53 + #define TEMP_0_CS_PIN EXP1_03_PIN #else #define TEMP_0_CS_PIN 49 #endif @@ -183,7 +172,7 @@ // // EEPROM // -#define MARLIN_EEPROM_SIZE 0x8000 // 32Kb (24lc256) +#define MARLIN_EEPROM_SIZE 0x8000 // 32K (24lc256) #define I2C_EEPROM // EEPROM on I2C-0 //#define EEPROM_SD // EEPROM on SDCARD //#define SPI_EEPROM // EEPROM on SPI-0 @@ -194,59 +183,87 @@ // 32Mb FLASH //#define SPI_FLASH_CS_PIN ? +/** + * ------ ------ + * (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 | -- + * ------ ------ + * 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 + // // LCD / Controller // #if HAS_WIRED_LCD #if ANY(RADDS_DISPLAY, IS_RRD_SC, IS_RRD_FG_SC) - #define BEEPER_PIN 62 - #define LCD_PINS_D4 48 - #define LCD_PINS_D5 50 - #define LCD_PINS_D6 52 - #define LCD_PINS_D7 53 - #define SD_DETECT_PIN 51 + #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 #endif #if EITHER(RADDS_DISPLAY, IS_RRD_SC) - #define LCD_PINS_RS 63 - #define LCD_PINS_ENABLE 64 + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN #elif IS_RRD_FG_SC - #define LCD_PINS_RS 52 - #define LCD_PINS_ENABLE 53 + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN #elif HAS_U8GLIB_I2C_OLED - #define BEEPER_PIN 62 - #define LCD_SDSS 10 - #define SD_DETECT_PIN 51 + #define BEEPER_PIN EXP1_10_PIN + #define LCD_SDSS EXP2_07_PIN + #define SD_DETECT_PIN EXP2_04_PIN #elif ENABLED(FYSETC_MINI_12864) - #define BEEPER_PIN 62 - #define DOGLCD_CS 64 - #define DOGLCD_A0 63 + #define BEEPER_PIN EXP1_10_PIN + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_A0 EXP1_07_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 48 // 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 50 // D5 + #define RGB_LED_R_PIN EXP1_05_PIN // D5 #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN 52 // D6 + #define RGB_LED_G_PIN EXP1_04_PIN // D6 #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN 53 // D7 + #define RGB_LED_B_PIN EXP1_03_PIN // D7 #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN 50 // D5 + #define NEOPIXEL_PIN EXP1_05_PIN // D5 #endif #elif ENABLED(SPARK_FULL_GRAPHICS) @@ -263,9 +280,9 @@ #endif // SPARK_FULL_GRAPHICS #if IS_NEWPANEL - #define BTN_EN1 44 - #define BTN_EN2 42 - #define BTN_ENC 40 + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_06_PIN + #define BTN_ENC EXP1_09_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 76a2d5a3985f..cc919d0a4fdc 100644 --- a/Marlin/src/pins/sam/pins_RURAMPS4D_13.h +++ b/Marlin/src/pins/sam/pins_RURAMPS4D_13.h @@ -53,13 +53,6 @@ #define Z_MIN_PIN 47 #define Z_MAX_PIN 43 -// -// Z Probe (when not Z_MIN_PIN) -// -#ifndef Z_MIN_PROBE_PIN - #define Z_MIN_PROBE_PIN 49 -#endif - // // Steppers // @@ -105,7 +98,7 @@ #define E2_CS_PIN 61 #endif -#if USES_Z_MIN_PROBE_PIN +#ifndef Z_MIN_PROBE_PIN #define Z_MIN_PROBE_PIN 49 #endif @@ -169,7 +162,7 @@ // // EEPROM // -#define MARLIN_EEPROM_SIZE 0x8000 // 32Kb (24lc256) +#define MARLIN_EEPROM_SIZE 0x8000 // 32K (24lc256) #define I2C_EEPROM // EEPROM on I2C-0 //#define EEPROM_SD // EEPROM on SDCARD //#define SPI_EEPROM // EEPROM on SPI-0 @@ -180,74 +173,101 @@ // 32Mb FLASH //#define SPI_FLASH_CS_PIN ? +/** + * ------ ------ + * (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 | -- + * ------ ------ + * 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 + // // LCD / Controller // #if HAS_WIRED_LCD #if ANY(RADDS_DISPLAY, IS_RRD_SC, IS_RRD_FG_SC) - #define BEEPER_PIN 62 - #define LCD_PINS_D4 48 - #define LCD_PINS_D5 50 - #define LCD_PINS_D6 52 - #define LCD_PINS_D7 53 - #define SD_DETECT_PIN 51 + #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 #endif #if EITHER(RADDS_DISPLAY, IS_RRD_SC) - #define LCD_PINS_RS 63 - #define LCD_PINS_ENABLE 64 + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN #elif IS_RRD_FG_SC - #define LCD_PINS_RS 52 - #define LCD_PINS_ENABLE 53 + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN #elif HAS_U8GLIB_I2C_OLED - #define BEEPER_PIN 62 - #define LCD_SDSS 10 - #define SD_DETECT_PIN 51 + #define BEEPER_PIN EXP1_10_PIN + #define LCD_SDSS EXP2_07_PIN + #define SD_DETECT_PIN EXP2_04_PIN #elif ENABLED(FYSETC_MINI_12864) - #define BEEPER_PIN 62 - #define DOGLCD_CS 64 - #define DOGLCD_A0 63 + #define BEEPER_PIN EXP1_10_PIN + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_A0 EXP1_07_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 48 // 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 50 // D5 + #define RGB_LED_R_PIN EXP1_05_PIN // D5 #endif #ifndef RGB_LED_G_PIN - #define RGB_LED_G_PIN 52 // D6 + #define RGB_LED_G_PIN EXP1_04_PIN // D6 #endif #ifndef RGB_LED_B_PIN - #define RGB_LED_B_PIN 53 // D7 + #define RGB_LED_B_PIN EXP1_03_PIN // D7 #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define NEOPIXEL_PIN 50 // D5 + #define NEOPIXEL_PIN EXP1_05_PIN // D5 #endif #elif ENABLED(MKS_MINI_12864) + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_05_PIN - #define DOGLCD_A0 52 - #define DOGLCD_CS 50 - - #define SD_DETECT_PIN 51 + #define SD_DETECT_PIN EXP2_04_PIN #endif #if IS_NEWPANEL - #define BTN_EN1 44 - #define BTN_EN2 42 - #define BTN_ENC 40 + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_06_PIN + #define BTN_ENC EXP1_09_PIN #endif #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) diff --git a/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h b/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h new file mode 100644 index 000000000000..382c607d239b --- /dev/null +++ b/Marlin/src/pins/samd/pins_BRICOLEMON_LITE_V1_0.h @@ -0,0 +1,616 @@ +/** + * 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 + +/** + * BRICOLEMON LITE Board. Based on atsamd51 (AGCM4), bootloader and credits by ADAFRUIT. + * This board its a 3.3V LOGIC Board, following the ADAFRUIT example, all of the board is open source. + * Schematic: Refer to the Bricolemon + * 3DSTEP: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon%20Lite/LC_BG_002_PCB_V1I4.step + * PinDemux: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon/PinDEMUX.xlsx + * + * NOTE: We need the Serial port on the -1 to make it work!!. Remember to change it on configuration.h #define SERIAL_PORT -1 + */ + +#if NOT_TARGET(ARDUINO_GRAND_CENTRAL_M4) + #error "Oops! Select 'Adafruit Grand Central M4' in 'Tools > Board.'" +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BRICOLEMON LITE V1.0" // , Lemoncrest & BricoGeek collaboration. +#endif + +/** + * 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 0x10000 // 64K (CAT24C512) + +// This is another option to emulate an EEPROM, but it's more efficient to not lose the data in the first place. +//#define SDCARD_EEPROM_EMULATION + +// +// BLTOUCH PIN: This pin is the signal pin for the BLTOUCH sensor. +// +#define SERVO0_PIN 33 // BLTouch PWM + +// +// Limit Switches +// +#define X_STOP_PIN 10 +#define Y_STOP_PIN 11 +#define Z_STOP_PIN 12 + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN 12 +#endif + +// +// Steppers +// +#define X_STEP_PIN 3 +#define X_DIR_PIN 22 +#define X_ENABLE_PIN 26 + +#define Y_STEP_PIN 4 +#define Y_DIR_PIN 23 +#define Y_ENABLE_PIN 27 + +#define Z_STEP_PIN 5 +#define Z_DIR_PIN 24 +#define Z_ENABLE_PIN 28 + +#define E0_STEP_PIN 2 +#define E0_DIR_PIN 25 +#define E0_ENABLE_PIN 29 + +// 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. +#define FIL_RUNOUT_PIN 32 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 1 +#define TEMP_BED_PIN 3 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 6 +#define HEATER_BED_PIN 7 +#define FAN_PIN 8 +#define FAN1_PIN 9 + +// +// LCD / Controller +// + +/** + * Bricolemon Expansion connectors + * + * ------ ------ + * VCC | 1 2 | GND KILL | 1 2 | GND + * LCD7 | 3 4 | LCDD6 RESET | 3 4 | SD_DETECT + * LCD5 | 5 6 LCDD4 MOSI | 5 6 BTN_EN1 + * LCDRS | 7 8 | LCDDE SS | 7 8 | BTN_EN2 + * BTN_ENCODER | 9 10 | BEEPER SCLK | 9 10 | MISO + * ------ ------ + * EXP1 EXP2 + * + *- This extra connector is for a serial display like the MKS TFT. + * MKS TFT + * ------ + * RX0 | . . | NC + * TX0 | . . NC + * GND | . . GND + * 5B | . . | 5V + * ------ + * + *- Special mapping of EXP1 to EXP3 to work with Ender displays. + * + * Enable CR10_STOCKDISPLAY in Configuration.h and connect EXP1 to the display EXP3 with this mapping. + * ------ + * VCC | 1 2 | GND + * LCDDE | 3 4 | LCDRS + * LCDD4 | 5 6 BTN_EN2 + * RESET | 7 8 | BTN_EN1 + * BTN_ENCODER | 9 10 | BEEPER + * ------ + * + *- Digital pinout reference of the Bricolemon for advanced users/configurations. + * + * ------ ------ + * VCC | 1 2 | GND D49 | 1 2 | GND + * D39 | 3 4 | D38 RST | 3 4 | D44 + * D37 | 5 6 D36 D51 | 5 6 D42 + * D34 | 7 8 | D35 D53 | 7 8 | D43 + * D40 | 9 10 | D41 D52 | 9 10 | D50 + * ------ ------ + * EXP1 EXP2 + * + *- Pin table overview + * LCD--- SPI--- + * LCD4 36 MISO 50 + * LCD5 37 SS 53 + * LCD6 38 SCKL 52 + * LCD7 39 MOSI 51 + * LCDRS 34 BEEPER + * LCDDE 35 BEEP 41 + * ENCODER--- SD-CARD--- + * BTN_EN1 42 + * BTN_EN2 43 SD_DETECT 44 + * 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 + +#if ENABLED(CR10_STOCKDISPLAY) + #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 + +/************************************/ +/***** Configurations Section ******/ +/************************************/ + +/** + * 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 + * - Reprap Display + * - Ender 5 New Serial Display + * - Any Reprap character display like + */ + +#if HAS_WIRED_LCD + + // + // LCD Display output pins + // + #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + + #if LCD_SERIAL_PORT != 1 + #error "LCD_SERIAL_PORT should be 1 for this display." + #endif + + // DWIN Encoder + #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN + + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP1_10_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 + + #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_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_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_04_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_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_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 + #endif + + #define LCD_PINS_D7 EXP1_03_PIN + + #if !IS_NEWPANEL + #define BEEPER_PIN EXP1_10_PIN + #endif + + #endif + + #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_EN_PIN 17 + #endif + + #endif + + // + // LCD Display input pins + // + #if IS_NEWPANEL + + #if IS_RRD_SC + + #define BEEPER_PIN EXP1_10_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + // TO TEST + #define BTN_EN1 EXP3_08_PIN + #define BTN_EN2 EXP3_06_PIN + + #else + // Definitions for any standard Display + #define BTN_EN1 EXP2_06_PIN + #define BTN_EN2 EXP2_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 + + #define BTN_ENC EXP1_09_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_04_PIN + #endif + #define KILL_PIN EXP2_01_PIN + + #if ENABLED(BQ_LCD_SMART_CONTROLLER) + //#define LCD_BACKLIGHT_PIN EXP1_03_PIN // TO TEST + #endif + + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + // TO TEST + //#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 + + #elif ENABLED(LCD_I2C_PANELOLU2) + + // TO TEST + //#define BTN_EN1 47 + //#define BTN_EN2 EXP2_08_PIN + //#define BTN_ENC 32 + //#define LCD_SDSS SDSS + //#define KILL_PIN EXP1_10_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_ENC -1 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN EXP2_01_PIN + + #elif ANY(VIKI2, miniVIKI) + + // TO TEST + //#define DOGLCD_CS 45 + //#define DOGLCD_A0 EXP2_04_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 BTN_EN1 22 + //#define BTN_EN2 7 + //#define BTN_ENC EXP1_03_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_08_PIN + //#define BTN_EN2 EXP1_05_PIN + //#define BTN_ENC 31 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN EXP2_01_PIN + //#define KILL_PIN EXP1_10_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 + + //#ifndef KILL_PIN + // #define KILL_PIN EXP1_10_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_06_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_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_09_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 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_09_PIN + //#define SHIFT_CLK_PIN EXP2_04_PIN + //#define SHIFT_LD_PIN EXP2_06_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_01_PIN // AUX3 PIN 7 + #else + // TO TEST + //#define BTN_EN1 EXP1_05_PIN + //#define BTN_EN2 EXP1_08_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 + #endif + + #endif + #endif // IS_NEWPANEL + +#endif // HAS_WIRED_LCD + +// +// SD Support +// + +/** + * Bricolemon has an SD slot, but to change it to your LCD or Custom, set the option to one of the following: + * + * LCD - Use the SD drive in the external LCD controller. + * ONBOARD - Use the SD drive on the control board. + * CUSTOM_CABLE - Use a custom cable to access the SD (as defined in a pins file). + * + * :[ 'LCD', 'ONBOARD', 'CUSTOM_CABLE' ] + */ + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SDSS 83 + #undef SD_DETECT_PIN + #define SD_DETECT_PIN 95 +#else + #define SDSS EXP2_07_PIN +#endif + +#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 + + /** + * 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. + */ + //#define X_HARDWARE_SERIAL Serial1 + //#define Y_HARDWARE_SERIAL Serial1 + //#define Z_HARDWARE_SERIAL Serial1 + //#define E0_HARDWARE_SERIAL Serial1 + + // 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 + + // + // 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 + +#endif diff --git a/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h b/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h new file mode 100644 index 000000000000..0f4bb1d0b591 --- /dev/null +++ b/Marlin/src/pins/samd/pins_BRICOLEMON_V1_0.h @@ -0,0 +1,676 @@ +/** + * 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 + +/** + * BRICOLEMON Board. Based on ATSAMD51 (AGCM4), bootloader and credits by ADAFRUIT. + */ + +#if NOT_TARGET(ARDUINO_GRAND_CENTRAL_M4) + #error "Oops! Select 'Adafruit Grand Central M4' in 'Tools > Board.'" +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BRICOLEMON V1.0" // , Lemoncrest & BricoGeek collaboration. +#endif + +/** + * BRICOLEMON Board. Based on atsamd51 (AGCM4), bootloader and credits by ADAFRUIT. + * This board its a 3.3V LOGIC Board, following the ADAFRUIT example, all of the board is open source. + * Schematic: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon/EsquemaBricolemon_REVB.pdf + * 3DSTEP: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon/BricolemonREVB.step + * PinDemux: https://github.com/bricogeek/bricolemon/blob/master/Documentacion/Bricolemon/PinDEMUX.xlsx + * + * 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 0x10000 // 64K (CAT24C512) + +//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 10 +#define Y_STOP_PIN 11 +#define Z_STOP_PIN 12 + +/** + * 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 3 +#define X_DIR_PIN 22 +#define X_ENABLE_PIN 26 + +#define Y_STEP_PIN 4 +#define Y_DIR_PIN 23 +#define Y_ENABLE_PIN 27 + +#define Z_STEP_PIN 5 +#define Z_DIR_PIN 24 +#define Z_ENABLE_PIN 28 + +#define E0_STEP_PIN 2 +#define E0_DIR_PIN 25 +#define E0_ENABLE_PIN 29 + +#define E1_STEP_PIN 13 +#define E1_DIR_PIN 46 +#define E1_ENABLE_PIN 47 + +// 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. +#define FIL_RUNOUT_PIN 32 + +// 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 1 + +// 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 3 +#endif + +#define TEMP_BED_PIN 2 + +// +// Heaters / Fans +// +#define HEATER_0_PIN 6 +#define HEATER_1_PIN 45 +#define HEATER_BED_PIN 7 + +// The board has 4 PWM fans, use and configure as desired +#define FAN_PIN 8 +#define FAN1_PIN 9 +#define FAN2_PIN 30 +#define FAN3_PIN 31 + +// +// LCD / Controller +// + +/** + * Bricolemon Expansion connectors + * + * ------ ------ + * VCC | 1 2 | GND KILL | 1 2 | GND + * LCD7 | 3 4 | LCDD6 RESET | 3 4 | SD_DETECT + * LCD5 | 5 6 LCDD4 MOSI | 5 6 BTN_EN1 + * LCDRS | 7 8 | LCDDE SS | 7 8 | BTN_EN2 + * BTN_ENCODER | 9 10 | BEEPER SCLK | 9 10 | MISO + * ------ ------ + * EXP1 EXP2 + * + *- This extra connector is for a serial display like the MKS TFT. + * MKS TFT + * ------ + * RX0 | . . | NC + * TX0 | . . NC + * GND | . . GND + * 5B | . . | 5V + * ------ + * + *- Special mapping of EXP1 to EXP3 to work with Ender displays. + * + * Enable CR10_STOCKDISPLAY in Configuration.h and connect EXP1 to the display EXP3 with this mapping. + * ------ + * VCC | 1 2 | GND + * LCDDE | 3 4 | LCDRS + * LCDD4 | 5 6 BTN_EN2 + * RESET | 7 8 | BTN_EN1 + * BTN_ENCODER | 9 10 | BEEPER + * ------ + * + *- Digital pinout reference of the Bricolemon for advanced users/configurations. + * + * ------ ------ + * VCC | 1 2 | GND D49 | 1 2 | GND + * D39 | 3 4 | D38 RST | 3 4 | D44 + * D37 | 5 6 D36 D51 | 5 6 D42 + * D34 | 7 8 | D35 D53 | 7 8 | D43 + * D40 | 9 10 | D41 D52 | 9 10 | D50 + * ------ ------ + * EXP1 EXP2 + * + *- Pin table overview + * LCD--- SPI--- + * LCD4 36 MISO 50 + * LCD5 37 SS 53 + * LCD6 38 SCKL 52 + * LCD7 39 MOSI 51 + * LCDRS 34 BEEPER + * LCDDE 35 BEEP 41 + * ENCODER--- SD-CARD--- + * BTN_EN1 42 SD_DETECT 44 + * BTN_EN2 43 KILL_PIN 49 + * 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 + +#if ENABLED(CR10_STOCKDISPLAY) + #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 + +/************************************/ +/***** 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 HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + + #if LCD_SERIAL_PORT != 1 + #error "LCD_SERIAL_PORT should be 1 for this display." + #endif + + // DWIN Encoder + #define BTN_ENC EXP1_09_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN + + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP1_10_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 + + #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_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_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_04_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_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_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 + #endif + + #define LCD_PINS_D7 EXP1_03_PIN + + #if !IS_NEWPANEL + #define BEEPER_PIN EXP1_10_PIN + #endif + + #endif + + #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_EN_PIN 17 + #endif + + #endif + + // + // LCD Display input pins + // + #if IS_NEWPANEL + + #if IS_RRD_SC + + #define BEEPER_PIN EXP1_10_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + // TO TEST + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_06_PIN + #else + // Definitions fpr any standard Display + #define BTN_EN1 EXP2_06_PIN + #define BTN_EN2 EXP2_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 + + #define BTN_ENC EXP1_09_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_04_PIN + #endif + #define KILL_PIN EXP2_01_PIN + + #if ENABLED(BQ_LCD_SMART_CONTROLLER) + //#define LCD_BACKLIGHT_PIN EXP1_03_PIN // TO TEST + #endif + + #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD) + + // TO TEST + //#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 + + #elif ENABLED(LCD_I2C_PANELOLU2) + + // TO TEST + //#define BTN_EN1 47 + //#define BTN_EN2 EXP2_08_PIN + //#define BTN_ENC 32 + //#define LCD_SDSS SDSS + //#define KILL_PIN EXP1_10_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_ENC -1 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN EXP2_01_PIN + + #elif ANY(VIKI2, miniVIKI) + + // TO TEST + //#define DOGLCD_CS 45 + //#define DOGLCD_A0 EXP2_04_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 BTN_EN1 22 + //#define BTN_EN2 7 + //#define BTN_ENC EXP1_03_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_08_PIN + //#define BTN_EN2 EXP1_05_PIN + //#define BTN_ENC 31 + + //#define LCD_SDSS SDSS + //#define SD_DETECT_PIN EXP2_01_PIN + //#define KILL_PIN EXP1_10_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 + + //#ifndef KILL_PIN + // #define KILL_PIN EXP1_10_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_06_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_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_09_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 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_09_PIN + //#define SHIFT_CLK_PIN EXP2_04_PIN + //#define SHIFT_LD_PIN EXP2_06_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_01_PIN // AUX3 PIN 7 + #else + // TO TEST + //#define BTN_EN1 EXP1_05_PIN + //#define BTN_EN2 EXP1_08_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 + #endif + + #endif + #endif // IS_NEWPANEL + +#endif // HAS_WIRED_LCD + +// +// SD Support +// + +/** + * Bricolemon has an SD slot, but to change it to your LCD or Custom, set the option to one of the following: + * + * LCD - Use the SD drive in the external LCD controller. + * ONBOARD - Use the SD drive on the control board. + * CUSTOM_CABLE - Use a custom cable to access the SD (as defined in a pins file). + * + * :[ 'LCD', 'ONBOARD', 'CUSTOM_CABLE' ] + */ + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) + #define SDSS 83 + #undef SD_DETECT_PIN + #define SD_DETECT_PIN 95 +#else + #define SDSS EXP2_07_PIN +#endif + +#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 449ae0273e23..406162c0896e 100644 --- a/Marlin/src/pins/samd/pins_RAMPS_144.h +++ b/Marlin/src/pins/samd/pins_RAMPS_144.h @@ -413,7 +413,6 @@ // TO TEST //#define DOGLCD_CS 45 //#define DOGLCD_A0 44 - //#define LCD_SCREEN_ROT_180 //#define BEEPER_PIN 33 //#define STAT_LED_RED_PIN 32 @@ -426,6 +425,8 @@ //#define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board //#define KILL_PIN 31 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) // TO TEST @@ -460,18 +461,14 @@ //#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 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(FYSETC_MINI_12864) // From https://wiki.fysetc.com/Mini12864_Panel/?fbclid=IwAR1FyjuNdVOOy9_xzky3qqo_WeM5h-4gpRnnWhQr_O1Ef3h0AFnFXmCehK8 @@ -518,12 +515,6 @@ //#define DOGLCD_A0 44 //#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 40 //#define BTN_EN2 55 // Mega/Due:63 - AGCM4:55 //#define BTN_ENC 72 // Mega/Due:59 - AGCM4:72 @@ -531,6 +522,8 @@ //#define SD_DETECT_PIN 49 //#define KILL_PIN 56 // Mega/Due:64 - AGCM4:56 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(ZONESTAR_LCD) // TO TEST diff --git a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h index 02f4a6e985b6..5fe0d3842dd4 100644 --- a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h +++ b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h @@ -135,7 +135,7 @@ #define LCD_BACKLIGHT_PIN 17 // LCD backlight LED #endif -#if NONE(SPINDLE_FEATURE, LASER_FEATURE) && ENABLED(SANGUINOLOLU_V_1_2) && !BOTH(IS_ULTRA_LCD, IS_NEWPANEL) // try to use IO Header +#if !HAS_CUTTER && ENABLED(SANGUINOLOLU_V_1_2) && !BOTH(HAS_WIRED_LCD, IS_NEWPANEL) // try to use IO Header #define CASE_LIGHT_PIN 4 // Hardware PWM - see if IO Header is available #endif @@ -207,11 +207,7 @@ #endif - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_0 - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #elif ENABLED(ZONESTAR_LCD) // For the Tronxy Melzi boards @@ -272,7 +268,7 @@ // M3/M4/M5 - Spindle/Laser Control // #if HAS_CUTTER - #if !MB(AZTEEG_X1) && ENABLED(SANGUINOLOLU_V_1_2) && !BOTH(IS_ULTRA_LCD, IS_NEWPANEL) // try to use IO Header + #if !MB(AZTEEG_X1) && ENABLED(SANGUINOLOLU_V_1_2) && !BOTH(HAS_WIRED_LCD, IS_NEWPANEL) // try to use IO Header #define SPINDLE_LASER_ENA_PIN 10 // Pullup or pulldown! #define SPINDLE_LASER_PWM_PIN 4 // Hardware PWM diff --git a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h index cb2dec160029..0a8143c37600 100644 --- a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h +++ b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h @@ -146,7 +146,7 @@ #define FAN1_PIN -1 // -//filament run out sensor +// Filament Runout Sensor // #if EITHER(Z6S_ZFAULT, Z6BS_ZFAULT) #define FIL_RUNOUT_PIN 13 @@ -162,32 +162,38 @@ #endif #define SD_DETECT_PIN -1 -/*=================================================== - * ZMIB Version 1 - EXP1 Connector - * MOSI(D5) TX1(D11) ENA(D12) ENC(D29/A2) 5V - * SCK(D7) RX1(D10) SCS(D4) ENB(D2) GND - *=================================================== - * ZMIB Version 2 - EXP1 Connector - * MOSI(D5) TX1(D11) ENA(D12) ENC(D29/A2) 5V - * SCK(D7) RX1(D10) SCS(D3) ENB(D2) GND - *=================================================== - * LCD 128x64 - *==================================================*/ +/** 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) + * ------ + */ +#define EXP1_03_PIN 2 +#define EXP1_04_PIN 29 +#ifndef IS_ZMIB_V2 + #define EXP1_05_PIN 4 // ZMIB V1 +#else + #define EXP1_05_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 #if ENABLED(ZONESTAR_12864LCD) // // LCD 128x64 // - #define LCDSCREEN_NAME "ZONESTAR_12864LCD" + #define LCDSCREEN_NAME "ZONESTAR_12864LCD" #define FORCE_SOFT_SPI - //#define LCD_SDSS 11 - #define LCD_PINS_RS 11 // ST7920_CS_PIN LCD_PIN_RS (PIN4 of LCD module) - #ifdef IS_ZMIB_V2 - #define LCD_PINS_ENABLE 3 // ST7920_DAT_PIN LCD_PIN_R/W (PIN5 of LCD module) - #else - #define LCD_PINS_ENABLE 4 // ST7920_DAT_PIN LCD_PIN_R/W (PIN5 of LCD module) - #endif - #define LCD_PINS_D4 10 // ST7920_CLK_PIN LCD_PIN_ENABLE (PIN6 of LCD module) + //#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 BOARD_ST7920_DELAY_1 DELAY_2_NOP #define BOARD_ST7920_DELAY_2 DELAY_2_NOP @@ -199,34 +205,28 @@ // #define LCDSCREEN_NAME "ZONESTAR 12864OLED" #define FORCE_SOFT_SPI - #ifdef IS_ZMIB_V2 - #define LCD_PINS_RS 3 // RESET - #else - #define LCD_PINS_RS 4 // RESET - #endif - #define LCD_PINS_DC 10 // DC - #define DOGLCD_CS 11 // CS + #define LCD_PINS_RS EXP1_05_PIN + #define LCD_PINS_DC EXP1_07_PIN + #define DOGLCD_CS EXP1_08_PIN + #if ENABLED(OLED_HW_IIC) #error "Oops! can't choose HW IIC for ZMIB board!!" - #elif ENABLED(OLED_HW_SPI) - // HW SPI - #define DOGLCD_A0 LCD_PINS_DC // A0 = DC #else - // SW SPI - #define DOGLCD_A0 LCD_PINS_DC // A0 = DC - #define DOGLCD_MOSI AVR_MOSI_PIN // SDA - #define DOGLCD_SCK AVR_SCK_PIN // SCK + #define DOGLCD_A0 LCD_PINS_DC + #if DISABLED(OLED_HW_SPI) + #define DOGLCD_MOSI AVR_MOSI_PIN // Software SPI + #define DOGLCD_SCK AVR_SCK_PIN + #endif #endif - #endif // // All the above are also RRDSC with rotary encoder // #if IS_RRD_SC - #define BTN_EN1 2 - #define BTN_EN2 12 - #define BTN_ENC 29 + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_06_PIN + #define BTN_ENC EXP1_04_PIN #define BEEPER_PIN -1 #define KILL_PIN -1 #endif diff --git a/Marlin/src/pins/sensitive_pins.h b/Marlin/src/pins/sensitive_pins.h index 5f2bd0467e1c..07634dacdd94 100644 --- a/Marlin/src/pins/sensitive_pins.h +++ b/Marlin/src/pins/sensitive_pins.h @@ -155,7 +155,7 @@ #endif -#if LINEAR_AXES >= 4 +#if HAS_I_AXIS #if PIN_EXISTS(I_MIN) #define _I_MIN I_MIN_PIN, @@ -201,7 +201,7 @@ #endif -#if LINEAR_AXES >= 5 +#if HAS_J_AXIS #if PIN_EXISTS(J_MIN) #define _J_MIN J_MIN_PIN, @@ -247,7 +247,7 @@ #endif -#if LINEAR_AXES >= 6 +#if HAS_K_AXIS #if PIN_EXISTS(K_MIN) #define _K_MIN K_MIN_PIN, @@ -658,7 +658,7 @@ #define _X2_PINS #endif -#if ENABLED(Y_DUAL_STEPPER_DRIVERS) +#if HAS_DUAL_Y_STEPPERS #if PIN_EXISTS(Y2_CS) && AXIS_HAS_SPI(Y2) #define _Y2_CS Y2_CS_PIN, #else @@ -684,7 +684,7 @@ #define _Y2_PINS #endif -#if NUM_Z_STEPPER_DRIVERS >= 2 +#if NUM_Z_STEPPERS >= 2 #if PIN_EXISTS(Z2_CS) && AXIS_HAS_SPI(Z2) #define _Z2_CS Z2_CS_PIN, #else @@ -710,7 +710,7 @@ #define _Z2_PINS #endif -#if NUM_Z_STEPPER_DRIVERS >= 3 +#if NUM_Z_STEPPERS >= 3 #if PIN_EXISTS(Z3_CS) && AXIS_HAS_SPI(Z3) #define _Z3_CS Z3_CS_PIN, #else @@ -736,7 +736,7 @@ #define _Z3_PINS #endif -#if NUM_Z_STEPPER_DRIVERS >= 4 +#if NUM_Z_STEPPERS >= 4 #if PIN_EXISTS(Z4_CS) && AXIS_HAS_SPI(Z4) #define _Z4_CS Z4_CS_PIN, #else diff --git a/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h b/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h index 904a9a56fac6..d38d4bbdb378 100644 --- a/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h +++ b/Marlin/src/pins/stm32f0/pins_MALYAN_M300.h @@ -33,7 +33,7 @@ #if NO_EEPROM_SELECTED #define FLASH_EEPROM_EMULATION #ifndef MARLIN_EEPROM_SIZE - #define MARLIN_EEPROM_SIZE 0x800U // 2KB + #define MARLIN_EEPROM_SIZE 0x800U // 2K #endif #endif diff --git a/Marlin/src/pins/stm32f1/env_validate.h b/Marlin/src/pins/stm32f1/env_validate.h index 2e7b78517215..2d325428ac8c 100644 --- a/Marlin/src/pins/stm32f1/env_validate.h +++ b/Marlin/src/pins/stm32f1/env_validate.h @@ -22,5 +22,11 @@ #pragma once #if NOT_TARGET(__STM32F1__, STM32F1) - #error "Oops! Select an STM32F1 board in 'Tools > Board.'" + #if DISABLED(ALLOW_STM32F4) + #error "Oops! Select an STM32F1 board in 'Tools > Board.'" + #elif NOT_TARGET(STM32F4) + #error "Oops! Select an STM32F4 board in 'Tools > Board.'" + #endif #endif + +#undef ALLOW_STM32F4 diff --git a/Marlin/src/pins/stm32f1/pins_BEAST.h b/Marlin/src/pins/stm32f1/pins_BEAST.h index 2ace47822e16..d494b29c1448 100644 --- a/Marlin/src/pins/stm32f1/pins_BEAST.h +++ b/Marlin/src/pins/stm32f1/pins_BEAST.h @@ -93,7 +93,7 @@ #define FAN_PIN PB10 #endif -#define FAN_SOFT_PWM +#define FAN_SOFT_PWM_REQUIRED // // Temperature Sensors diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_CR6.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_CR6.h index 570d102c4758..e3e91ff35ad4 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_CR6.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_CR6.h @@ -52,9 +52,9 @@ #if ENABLED(I2C_EEPROM) #define IIC_EEPROM_SDA PB7 #define IIC_EEPROM_SCL PB6 - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #elif ENABLED(SDCARD_EEPROM_EMULATION) - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // @@ -113,7 +113,7 @@ #define HEATER_BED_PIN PC9 // HOT BED #define FAN_PIN PC6 // FAN -#define FAN_SOFT_PWM +#define FAN_SOFT_PWM_REQUIRED #define CONTROLLER_FAN_PIN PC7 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 dae43d3c13ed..7300919d9df7 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h @@ -33,9 +33,9 @@ #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE (0x800U) // 2KB + #define EEPROM_PAGE_SIZE (0x800U) // 2K #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K #endif // @@ -156,14 +156,14 @@ #define USB_CONNECT_INVERTING false /** - * ----- - * 5V | 1 2 | GND - * (LCD_EN) PB7 | 3 4 | PB8 (LCD_RS) - * (LCD_D4) PB9 | 5 6 PA10 (BTN_EN2) - * RESET | 7 8 | PA9 (BTN_EN1) - * (BTN_ENC) PB6 | 9 10| PA15 (BEEPER) - * ----- - * EXP1 + * ------ + * (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 + * ------ + * EXP1 */ #if HAS_WIRED_LCD @@ -195,13 +195,13 @@ #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) /** Creality Ender-2 display pinout - * ----- - * 5V | 1 2 | GND - * (MOSI) PB7 | 3 4 | PB8 (LCD_RS) - * (LCD_A0) PB9 | 5 6 PA10 (BTN_EN2) - * RESET | 7 8 | PA9 (BTN_EN1) - * (BTN_ENC) PB6 | 9 10| PA15 (SCK) - * ----- + * ------ + * (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 + * ------ * EXP1 */ @@ -228,15 +228,15 @@ /** 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 |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) + * ------ ------ + * EXP1 EXP1 * * Needs custom cable: * 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 2ab7a61e0b95..b5fddc4d7494 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 @@ -29,7 +29,7 @@ #if NO_EEPROM_SELECTED #define I2C_EEPROM #define SOFT_I2C_EEPROM - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #define I2C_SDA_PIN PB7 #define I2C_SCL_PIN PB6 #undef NO_EEPROM_SELECTED 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 8c8043be8b2a..e728af317d82 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 @@ -33,9 +33,9 @@ #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE (0x800U) // 2KB + #define EEPROM_PAGE_SIZE (0x800U) // 2K #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K #endif // @@ -120,11 +120,11 @@ /** * SKR Mini E3 V1.0, V1.2 SKR Mini E3 V2.0 * ------ ------ - * 5V | 1 2 | GND 5V | 1 2 | GND - * (LCD_EN) PB7 | 3 4 | PB8 (LCD_RS) (LCD_EN) PB15 | 3 4 | PB8 (LCD_RS) - * (LCD_D4) PB9 | 5 6 PA10 (BTN_EN2) (LCD_D4) PB9 | 5 6 PA10 (BTN_EN2) - * RESET | 7 8 | PA9 (BTN_EN1) RESET | 7 8 | PA9 (BTN_EN1) - * (BTN_ENC) PB6 | 9 10 | PB5 (BEEPER) (BTN_ENC) PA15 | 9 10 | PB5 (BEEPER) + * (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 */ @@ -136,16 +136,16 @@ #define EXP1_3 PB7 #endif -#if EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI) +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI /** - * ------ ------ ------ - * VCC | 1 2 | GND VCC | 1 2 | GND GND | 2 1 | VCC - * A | 3 4 | B A | 3 4 | B B | 4 3 | A - * | 5 6 TX BEEP | 5 6 ENT ENT | 6 5 | BEEP - * | 7 8 | RX TX | 7 8 | RX RX | 8 7 | TX - * BEEP | 9 10 | ENT | 9 10 | | 10 9 | - * ------ ------ ------ - * EXP1 DWIN DWIN (plug) + * ------ ------ ------ + * (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 + * ------ ------ ------ + * EXP1 DWIN DWIN (plug) * * All pins are labeled as printed on DWIN PCB. Connect TX-TX, A-A and so on. */ @@ -206,15 +206,15 @@ /** * TFTGLCD_PANEL_SPI display pinout * - * Board Display - * ------ ------ - * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) - * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) LCD_CS | 3 4 | SD_CS (PA10) - * (FREE) PB9 | 5 6 | PA10 (SD_CS) (FREE) | 5 6 | MOSI (SPI1-MOSI) - * RESET | 7 8 | PA9 (MOD_RESET) (PB5) SD_DET | 7 8 | (FREE) - * (BEEPER) PB6 | 9 10 | PB5 (SD_DET) GND | 9 10 | 5V - * ------ ------ - * EXP1 EXP1 + * 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) + * ------ ------ + * EXP1 EXP1 * * Needs custom cable: * @@ -236,8 +236,72 @@ #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + + #error "CAUTION! FYSETC_MINI_12864_2_1 / MKS_MINI_12864_V3 / BTT_MINI_12864_V1 requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. Comment out this line to continue." + + /** + * FYSETC_MINI_12864_2_1 / MKS_MINI_12864_V3 / BTT_MINI_12864_V1 display pinout + * + * 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 + * ------ ------ + * EXP1 EXP1 + * + * --- ------ + * RST | 1 | (MISO) |10 9 | SCK + * (RX2) PA2 | 2 | BTN_EN1 | 8 7 | (SS) + * (TX2) PA3 | 3 | BTN_EN2 | 6 5 | MOSI + * GND | 4 | (CD) | 4 3 | (RST) + * 5V | 5 | (GND) | 2 1 | (KILL) + * --- ------ + * TFT EXP2 + * + * Needs custom cable: + * + * 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 + * + * TFT-2 ----------- EXP2-9 + * TFT-3 ----------- EXP2-5 + * + * 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 DOGLCD_CS PA9 + #define DOGLCD_A0 PB5 + #define DOGLCD_SCK PA2 + #define DOGLCD_MOSI PA3 + + #define BTN_ENC PA15 + #define BTN_EN1 PB9 + #define BTN_EN2 PB15 + + #define FORCE_SOFT_SPI + #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." + #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." #endif #endif // HAS_WIRED_LCD @@ -249,15 +313,15 @@ /** * 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) (PB5) SD_DET | 7 8 | RESET - * (BEEPER) PB6 | 9 10 | PB5 (SD_DET) GND | 9 10 | 5V - * ------ ------ - * EXP1 EXP1 + * 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) + * ------ ------ + * EXP1 EXP1 * * Needs custom cable: * 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 a6cc5ffa60fb..1ea947ffdf18 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 @@ -33,9 +33,9 @@ #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE (0x800U) // 2KB + #define EEPROM_PAGE_SIZE (0x800U) // 2K #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K #endif // @@ -80,6 +80,23 @@ #endif #endif +#if HAS_TMC_UART // Shared with EXP1 + #define X_SERIAL_TX_PIN PC10 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PC11 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PC12 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PC14 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + // // Heaters / Fans // @@ -98,7 +115,7 @@ * (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 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ diff --git a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h index b0b201f1d50d..ed3a653d2192 100644 --- a/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h +++ b/Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h @@ -43,9 +43,9 @@ // #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE 0x800U // 2KB + #define EEPROM_PAGE_SIZE 0x800U // 2K #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D.h b/Marlin/src/pins/stm32f1/pins_CHITU3D.h index 2d33fb9f2cc2..1f56e59a23c5 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D.h @@ -87,7 +87,7 @@ #define FAN_PIN PG14 // MAIN BOARD FAN #endif -#define FAN_SOFT_PWM +#define FAN_SOFT_PWM_REQUIRED // // Temperature Sensors @@ -178,7 +178,6 @@ // Pins for DOGM SPI LCD Support #define DOGLCD_A0 PC12 // 44 #define DOGLCD_CS PC13 // 45 - #define LCD_SCREEN_ROT_180 #define BTN_EN1 PB6 // 22 #define BTN_EN2 PA7 // 7 @@ -192,6 +191,8 @@ #define STAT_LED_RED_PIN PC0 // 32 #define STAT_LED_BLUE_PIN PC3 // 35 + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #define BTN_EN1 PC3 // 35 #define BTN_EN2 PC5 // 37 @@ -214,11 +215,7 @@ #define SDSS PD5 // 53 #define KILL_PIN PE0 // 64 - // GLCD features - // Uncomment screen orientation - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 + // The encoder and click button #define BTN_EN1 PC8 // 40 #define BTN_EN2 PD15 // 63 @@ -226,6 +223,8 @@ // not connected to a pin #define SD_DETECT_PIN PD1 // 49 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #else // Beeper on AUX-4 diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_common.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_common.h index 989b7eec6f65..bc41e97041fc 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D_common.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_common.h @@ -44,10 +44,10 @@ #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 EEPROM_PAGE_SIZE (0x800U) // 2K, but will use 2x more (4K) #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE #else - #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM + #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2K, require this amount of RAM #endif // diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1.h index ffd7baa00c4d..0d2ad835d397 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) v101 as found in the Ender 7 board pin assignments + * 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 new file mode 100644 index 000000000000..66ee8af61b6a --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V24S1_301.h @@ -0,0 +1,94 @@ +/** + * 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 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. + */ + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "Creality V24S1 only supports one hotend / E-stepper. Comment out this line to continue." +#endif + +#if BOTH(BLTOUCH, Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) + #error "Disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN when using BLTOUCH with Creality V24S1-301." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Creality V24S1-301" +#endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME "Ender 3 S1" +#endif + +// +// Servos +// +#if !defined(SERVO0_PIN) && !defined(HAS_PIN_27_BOARD) + #define SERVO0_PIN PC13 // BLTouch OUT +#endif + +// +// Limit Switches +// +#define Z_STOP_PIN PA15 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PC14 // BLTouch IN +#endif + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PC15 // "Pulled-high" +#endif + +// +// Heaters / Fans +// +#define HEATER_BED_PIN PA7 // HOT BED +#define FAN1_PIN PC0 // extruder fan + +// +// SD Card +// +#define ONBOARD_SPI_DEVICE 1 +#define ONBOARD_SD_CS_PIN PA4 // SDSS + +// +// M3/M4/M5 - Spindle/Laser Control +// +#if HAS_CUTTER + //#define HEATER_0_PIN -1 + //#define HEATER_BED_PIN -1 + #define FAN_PIN -1 + #define SPINDLE_LASER_ENA_PIN PC0 // FET 1 + #define SPINDLE_LASER_PWM_PIN PC0 // Bed FET + #define SPINDLE_DIR_PIN PC0 // FET 4 + #define LASER_SOFT_PWM_PIN PC0 +#endif + +#include "pins_CREALITY_V4.h" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V25S1.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V25S1.h new file mode 100644 index 000000000000..0425a45d1d25 --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V25S1.h @@ -0,0 +1,152 @@ +/** + * 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 v2.5.S1 (STM32F103RE / STM32F103RC) as found in the CR-10 Smart Pro + */ + +#include "env_validate.h" + +#if HAS_MULTI_HOTEND || E_STEPPERS > 1 + #error "Creality V2.5.S1 only supports one hotend / E-stepper. Comment out this line to continue." +#endif + +#define BOARD_INFO_NAME "Creality v2.5.S1" +#define DEFAULT_MACHINE_NAME "Creality3D" + +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +#define DISABLE_DEBUG + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 + //#define SDCARD_EEPROM_EMULATION + //#define FLASH_EEPROM_EMULATION +#endif + +#if ENABLED(IIC_BL24CXX_EEPROM) + #define IIC_EEPROM_SDA PA11 + #define IIC_EEPROM_SCL PA12 + #define MARLIN_EEPROM_SIZE 0x800 // 2K (24C16) +#elif EITHER(SDCARD_EEPROM_EMULATION, FLASH_EEPROM_EMULATION) + #define MARLIN_EEPROM_SIZE 0x800 // 2K +#endif + +// +// Limit Switches +// +#define X_STOP_PIN PC4 +#define Y_STOP_PIN PC5 + +#if ENABLED(BLTOUCH) + #define Z_STOP_PIN -1 + #define SERVO0_PIN PC14 // BLTouch OUT PIN + #ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PC15 // BLTouch IN PIN + #endif +#else + #define Z_STOP_PIN PC15 + #if ENABLED(PROBE_ACTIVATION_SWITCH) + #define PROBE_TARE_PIN PC14 + #define PROBE_ACTIVATION_SWITCH_PIN PB2 + #endif +#endif + +// +// Filament Runout Sensor +// +#if ENABLED(FILAMENT_RUNOUT_SENSOR) + #define FIL_RUNOUT_PIN PA15 // "Pulled-high" +#endif + +// +// Steppers +// +#define X_STEP_PIN PB8 +#define X_DIR_PIN PB7 +#define X_ENABLE_PIN PC3 + +#define Y_STEP_PIN PB6 +#define Y_DIR_PIN PB5 +#define Y_ENABLE_PIN X_ENABLE_PIN + +#define Z_STEP_PIN PB4 +#define Z_DIR_PIN PB3 +#define Z_ENABLE_PIN X_ENABLE_PIN + +#define E0_STEP_PIN PC2 +#define E0_DIR_PIN PB9 +#define E0_ENABLE_PIN X_ENABLE_PIN + +// +// Temperature Sensors +// +#define TEMP_0_PIN PB1 // TH1 +#define TEMP_BED_PIN PB0 // TB1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB14 // HEATER1 +#define HEATER_BED_PIN PB13 // HOT BED + +#define FAN_PIN PB15 // FAN +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN PC13 // FAN +#endif +#define FAN_SOFT_PWM_REQUIRED + +// +// SD Card +// +#define SD_DETECT_PIN PC7 +#define SDCARD_CONNECTION ONBOARD +#define ON_BOARD_SPI_DEVICE 1 +#define ONBOARD_SD_CS_PIN PC12 // SDSS +#define SDIO_SUPPORT +#define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer + +// +// Misc. Functions +// +#define CASE_LIGHT_PIN PA7 + +// +// Suicide Power +// +#define PS_ON_PIN PA0 +#define MOTOR_CIRCUIT_PIN PA1 + +// +// Motor Protect +// +#define MOTOR_PROTECT_PIN PC0 + +// +// WiFi Reset +// +#define RESET_WIFI_PIN PB12 diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index bf2a55fc7b99..5552d19ab926 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -22,7 +22,7 @@ #pragma once /** - * Creality 4.2.x (STM32F103RET6) board pin assignments + * Creality 4.2.x (STM32F103RE / STM32F103RC) board pin assignments */ #include "env_validate.h" @@ -40,6 +40,13 @@ #define BOARD_NO_NATIVE_USB +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +#ifndef DISABLE_DEBUG + #define DISABLE_DEBUG +#endif + // // EEPROM // @@ -51,9 +58,9 @@ #if ENABLED(IIC_BL24CXX_EEPROM) #define IIC_EEPROM_SDA PA11 #define IIC_EEPROM_SCL PA12 - #define MARLIN_EEPROM_SIZE 0x800 // 2Kb (24C16) + #define MARLIN_EEPROM_SIZE 0x800 // 2K (24C16) #elif ENABLED(SDCARD_EEPROM_EMULATION) - #define MARLIN_EEPROM_SIZE 0x800 // 2Kb + #define MARLIN_EEPROM_SIZE 0x800 // 2K #endif // @@ -72,7 +79,9 @@ // #define X_STOP_PIN PA5 #define Y_STOP_PIN PA6 -#define Z_STOP_PIN PA7 +#ifndef Z_STOP_PIN + #define Z_STOP_PIN PA7 +#endif #ifndef Z_MIN_PROBE_PIN #define Z_MIN_PROBE_PIN PB1 // BLTouch IN @@ -120,11 +129,6 @@ #endif #define E0_ENABLE_PIN X_ENABLE_PIN -// -// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role -// -#define DISABLE_DEBUG - // // Temperature Sensors // @@ -143,17 +147,13 @@ #ifndef FAN_PIN #define FAN_PIN PA0 // FAN #endif -#if PIN_EXISTS(FAN) - #define FAN_SOFT_PWM -#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 @@ -189,7 +189,7 @@ #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for CR10_STOCKDISPLAY with the Creality V4 controller." #endif -#elif EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI) +#elif HAS_DWIN_E3V2 || IS_DWIN_MARLINUI // RET6 DWIN ENCODER LCD #define BTN_ENC PB14 diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h index ae54805a94c6..1c9a0a8f997f 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h @@ -1,6 +1,6 @@ /** * Marlin 3D Printer Firmware - * Copyright (C) 2016 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 @@ -22,7 +22,7 @@ #pragma once /** - * CREALITY 4.2.10 (STM32F103) board pin assignments + * CREALITY 4.2.10 (STM32F103RE / STM32F103RC) board pin assignments */ #include "env_validate.h" @@ -40,34 +40,24 @@ #define BOARD_NO_NATIVE_USB +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +#define DISABLE_DEBUG + // // 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 PA11 - #define IIC_EEPROM_SCL PA12 - #define MARLIN_EEPROM_SIZE 0x800 // 2Kb (24C16) - #else - #define SDCARD_EEPROM_EMULATION // SD EEPROM until all EEPROM is BL24CXX - #define MARLIN_EEPROM_SIZE 0x800 // 2Kb - #endif - - // SPI - //#define SPI_EEPROM // EEPROM on SPI-0 - //#define SPI_CHAN_EEPROM1 ? - //#define SPI_EEPROM1_CS_PIN ? - - // 2K EEPROM - //#define SPI_EEPROM2_CS_PIN ? - - // 32Mb FLASH - //#define SPI_FLASH_CS_PIN ? + #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 +#endif +#if ENABLED(IIC_BL24CXX_EEPROM) + #define IIC_EEPROM_SDA PA11 + #define IIC_EEPROM_SCL PA12 + #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 // @@ -82,7 +72,9 @@ #define Y_STOP_PIN PA7 #define Z_STOP_PIN PA5 -#define Z_MIN_PROBE_PIN PA5 // BLTouch IN +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PA5 // BLTouch IN +#endif // // Filament Runout Sensor @@ -94,42 +86,37 @@ // // Steppers // -#define X_ENABLE_PIN PC3 #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 -#define Y_ENABLE_PIN PC3 #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 -#define Z_ENABLE_PIN PC3 #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 -#define E0_ENABLE_PIN PC3 #ifndef E0_STEP_PIN #define E0_STEP_PIN PB4 #endif #ifndef E0_DIR_PIN #define E0_DIR_PIN PB3 #endif - -// -// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role -// -#define DISABLE_DEBUG +#define E0_ENABLE_PIN X_ENABLE_PIN // // Temperature Sensors @@ -144,7 +131,7 @@ #define HEATER_BED_PIN PA1 // HOT BED #define FAN_PIN PA2 // FAN -#define FAN_SOFT_PWM +#define FAN_SOFT_PWM_REQUIRED // // SD Card @@ -167,7 +154,7 @@ * PB10 | 8 7 | PE8 * PB14 6 5 | PB13 * PB12 | 4 3 | PB15 - * GND | 2 1 | 5V + * GND | 2 1 | 5V * ------ * EXP1 */ @@ -191,7 +178,7 @@ * PB10 | 8 7 | ? * PA6 6 5 | PA5 * PA4 | 4 3 | PA7 - * GND | 2 1 | 5V + * GND | 2 1 | 5V * ------ * EXP1 */ @@ -216,7 +203,7 @@ #define BTN_EN1 EXP1_08_PIN #define BTN_EN2 EXP1_06_PIN -#elif EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI) +#elif HAS_DWIN_E3V2 || IS_DWIN_MARLINUI // RET6 DWIN ENCODER LCD #define BTN_ENC PB14 diff --git a/Marlin/src/HAL/TEENSY40_41/watchdog.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h similarity index 76% rename from Marlin/src/HAL/TEENSY40_41/watchdog.h rename to Marlin/src/pins/stm32f1/pins_CREALITY_V422.h index 03ab151b0706..5499adb07668 100644 --- a/Marlin/src/HAL/TEENSY40_41/watchdog.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h @@ -1,6 +1,6 @@ /** * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 @@ -22,9 +22,10 @@ #pragma once /** - * HAL Watchdog for Teensy 4.0 (IMXRT1062DVL6A) / 4.1 (IMXRT1062DVJ6A) + * CREALITY v4.2.2 (STM32F103RE / STM32F103RC) board pin assignments */ -void watchdog_init(); +#define BOARD_INFO_NAME "Creality v4.2.2" +#define DEFAULT_MACHINE_NAME "Creality3D" -void HAL_watchdog_refresh(); +#include "pins_CREALITY_V4.h" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V423.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V423.h index 186051c1fcb0..c174b0e56ed6 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V423.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V423.h @@ -22,7 +22,7 @@ #pragma once /** - * CREALITY v4.2.3 (STM32F103) board pin assignments + * CREALITY v4.2.3 (STM32F103RE / STM32F103RC) board pin assignments */ #define BOARD_INFO_NAME "Creality v4.2.3" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h index c327abee7796..077f4c73a657 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V427.h @@ -22,7 +22,7 @@ #pragma once /** - * CREALITY v4.2.7 (STM32F103) board pin assignments + * CREALITY v4.2.7 (STM32F103RE / STM32F103RC) board pin assignments */ #define BOARD_INFO_NAME "Creality v4.2.7" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V431.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V431.h index 2f1f2ffb4113..9226b537d91b 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V431.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V431.h @@ -22,7 +22,7 @@ #pragma once /** - * CREALITY v4.3.1 (STM32F103) board pin assignments + * CREALITY v4.3.1 (STM32F103RE / STM32F103RC) board pin assignments */ #define BOARD_INFO_NAME "Creality v4.3.1" diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h index 9b6862d99bd4..ced64e2a893c 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V452.h @@ -22,7 +22,7 @@ #pragma once /** - * Creality v4.5.2 (STM32F103RET6) board pin assignments + * Creality v4.5.2 (STM32F103RE / STM32F103RC) board pin assignments */ #if HAS_MULTI_HOTEND || E_STEPPERS > 1 diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h index fd3ea93c32d3..e7296d1ed077 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V453.h @@ -22,7 +22,7 @@ #pragma once /** - * Creality v4.5.3 (STM32F103RET6) board pin assignments + * Creality v4.5.3 (STM32F103RE / STM32F103RC) board pin assignments */ #if HAS_MULTI_HOTEND || E_STEPPERS > 1 diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h index 023fca21ce98..a9ff02d1f4e2 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V45x.h @@ -47,9 +47,9 @@ #if ENABLED(IIC_BL24CXX_EEPROM) #define IIC_EEPROM_SDA PA11 #define IIC_EEPROM_SCL PA12 - #define MARLIN_EEPROM_SIZE 0x800 // 2Kb (24C16) + #define MARLIN_EEPROM_SIZE 0x800 // 2K (24C16) #elif ENABLED(SDCARD_EEPROM_EMULATION) - #define MARLIN_EEPROM_SIZE 0x800 // 2Kb + #define MARLIN_EEPROM_SIZE 0x800 // 2K #endif // @@ -97,7 +97,7 @@ // Heaters / Fans // -#define FAN_SOFT_PWM +#define FAN_SOFT_PWM_REQUIRED // // SD Card diff --git a/Marlin/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h b/Marlin/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h index fea5b00b50d8..8d0093a4d989 100644 --- a/Marlin/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h @@ -38,11 +38,10 @@ //#define DISABLE_DEBUG #define DISABLE_JTAG //#define ENABLE_SPI3 -#define FLASH_EEPROM_EMULATION -#define FAN_SOFT_PWM -#if ENABLED(FLASH_EEPROM_EMULATION) - #define EEPROM_PAGE_SIZE (0x800U) // 2KB +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800U) // 2K #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) #define MARLIN_EEPROM_SIZE (EEPROM_PAGE_SIZE) #endif @@ -118,6 +117,8 @@ #endif #endif +#define FAN_SOFT_PWM_REQUIRED + // // Misc. Functions // diff --git a/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h b/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h index 947e36c765e7..9efae6e3a887 100644 --- a/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h +++ b/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h @@ -41,7 +41,7 @@ #define BOARD_NO_NATIVE_USB // Avoid conflict with TIMER_SERVO when using the STM32 HAL -#define TEMP_TIMER 5 +#define TEMP_TIMER 5 // // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role @@ -53,9 +53,9 @@ // #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE (0x800U) // 2KB + #define EEPROM_PAGE_SIZE (0x800U) // 2K #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K #endif // @@ -92,7 +92,7 @@ #define Z_MAX_PIN PC4 // +Z #ifndef FIL_RUNOUT_PIN - #define FIL_RUNOUT_PIN MT_DET_1_PIN + #define FIL_RUNOUT_PIN PA4 // MT_DET #endif // @@ -217,14 +217,14 @@ // #if ENABLED(PSU_CONTROL) #define KILL_PIN PA2 // PW_DET - #define KILL_PIN_STATE HIGH + #define KILL_PIN_STATE HIGH //#define PS_ON_PIN PA3 // PW_CN /PW_OFF #endif #if HAS_TFT_LVGL_UI #define MT_DET_1_PIN PA4 // MT_DET #define MT_DET_2_PIN PE6 - #define MT_DET_PIN_STATE LOW + #define MT_DET_PIN_STATE LOW #endif // diff --git a/Marlin/src/pins/stm32f1/pins_FLY_MINI.h b/Marlin/src/pins/stm32f1/pins_FLY_MINI.h index e4c741eae7f9..952b40c1dedb 100644 --- a/Marlin/src/pins/stm32f1/pins_FLY_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_FLY_MINI.h @@ -30,10 +30,12 @@ // // Flash EEPROM Emulation // -#define FLASH_EEPROM_EMULATION -#define EEPROM_PAGE_SIZE 0x800 // 2KB -#define EEPROM_START_ADDRESS (0x8000000 + 256 * 1024 - 2 * EEPROM_PAGE_SIZE) // 256K firmware space -#define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE 0x800 // 2K + #define EEPROM_START_ADDRESS (0x8000000 + 256 * 1024 - 2 * EEPROM_PAGE_SIZE) // 256K firmware space + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE +#endif // // Servos @@ -123,9 +125,9 @@ /** ------ ------ * (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_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 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h index 7ffe67c4f86b..9250ee112762 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h @@ -27,7 +27,7 @@ #define BOARD_WEBSITE_URL "fysetc.com" #define BOARD_NO_NATIVE_USB - +#define RESET_STEPPERS_ON_MEDIA_INSERT #define DISABLE_JTAG #define pins_v2_20190128 // new pins define @@ -40,9 +40,9 @@ // #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE (0x800U) // 2KB + #define EEPROM_PAGE_SIZE (0x800U) // 2K #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K #endif // @@ -166,9 +166,7 @@ #endif //#define LCD_CONTRAST_INIT 190 - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #endif diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h index 0c2f2fc5db31..beda50d29b1b 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h @@ -32,14 +32,14 @@ //#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 #define BOARD_NO_NATIVE_USB - +#define RESET_STEPPERS_ON_MEDIA_INSERT #define DISABLE_JTAG #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE (0x800U) // 2KB + #define EEPROM_PAGE_SIZE (0x800U) // 2K #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K #endif // @@ -163,13 +163,11 @@ #define DOGLCD_CS EXP1_04_PIN #define DOGLCD_SCK EXP1_05_PIN #define DOGLCD_MOSI EXP1_03_PIN - //#define LCD_SCREEN_ROT_90 - //#define LCD_SCREEN_ROT_180 - //#define LCD_SCREEN_ROT_270 #if EITHER(FYSETC_MINI_12864, U8GLIB_ST7920) #define FORCE_SOFT_SPI #endif + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #endif #define LCD_PINS_RS EXP1_04_PIN // CS -- SOFT SPI for ENDER3 LCD diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h b/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h index 520764a503bc..5515132c7844 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_MINI.h @@ -53,7 +53,7 @@ // Enable EEPROM Emulation for this board as it doesn't have EEPROM #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // @@ -186,7 +186,7 @@ #ifdef GTM32_PRO_VB_USE_LCD_BEEPER // This is pin 32 on J2 FFC40 and pin, goes to the beeper // on Geeetech's version of RepRapDiscount Smart Controller - // (e.g. on Rostock 301) + // (e.g., on Rostock 301) #define BEEPER_PIN PE12 #else // This is the beeper on the board itself diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h b/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h index cb5200bc27da..dc23680b8c20 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h @@ -53,7 +53,7 @@ // Enable EEPROM Emulation for this board as it doesn't have EEPROM #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h index 88aa35f2c08b..4b5d38e8c544 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h @@ -58,7 +58,7 @@ // Enable EEPROM Emulation for this board as it doesn't have EEPROM #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h b/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h index 12a6d5b84d7f..968d9cb6bd58 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_REV_B.h @@ -53,7 +53,7 @@ // Enable EEPROM Emulation for this board as it doesn't have EEPROM #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // diff --git a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h index beae0a3bf0b6..86a8ed6b9a81 100644 --- a/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h +++ b/Marlin/src/pins/stm32f1/pins_JGAURORA_A5S_A1.h @@ -53,9 +53,9 @@ #endif #if ENABLED(I2C_EEPROM) - //#define MARLIN_EEPROM_SIZE 0x8000UL // 32KB + //#define MARLIN_EEPROM_SIZE 0x8000UL // 32K #elif ENABLED(FLASH_EEPROM_EMULATION) - //#define MARLIN_EEPROM_SIZE 0x1000UL // 4KB + //#define MARLIN_EEPROM_SIZE 0x1000UL // 4K //#define MARLIN_EEPROM_SIZE (EEPROM_START_ADDRESS + (EEPROM_PAGE_SIZE) * 2UL) #endif diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index 15c6955a83a8..59d9b8d95676 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -89,14 +89,19 @@ #define HEATER_BED_PIN PA8 // pin 67 (Hot Bed Mosfet) #define FAN_PIN PA15 // pin 77 (4cm Fan) -#ifdef MAPLE_STM32F1 - #define FAN_SOFT_PWM // Required to avoid issues with heating or STLink - #define FAN_MIN_PWM 35 // Fan will not start in 1-30 range - #define FAN_MAX_PWM 255 + +#if TERN(MAPLE_STM32F1, ENABLED(FAN_SOFT_PWM), ENABLED(FAST_PWM_FAN)) && FAN_MIN_PWM < 5 // Required to avoid issues with heating or STLink + #error "FAN_MIN_PWM must be 5 or higher." // Fan will not start in 1-30 range +#endif + +#if defined(MAPLE_STM32F1) || DISABLED(FAST_PWM_FAN) // STM32 HAL required to allow TIMER2 Hardware PWM + #define FAN_SOFT_PWM_REQUIRED #else - #define FAST_PWM_FAN // STM32 Variant allow TIMER2 Hardware PWM - #define FAN_MIN_PWM 5 - #define FAN_MAX_PWM 255 + #if FAST_PWM_FAN_FREQUENCY <= 1000 // Default 1000 is noisy, max 65K (uint16) + #error "FAST_PWM_FAN_FREQUENCY must be greater than 1000." + #elif FAST_PWM_FAN_FREQUENCY > 65535 + #error "FAST_PWM_FAN_FREQUENCY must be less than 65536." + #endif #endif //#define BEEPER_PIN PD13 // pin 60 (Servo PWM output 5V/GND on Board V0G+) made for BL-Touch sensor @@ -152,7 +157,7 @@ #if defined(TFT_BACKLIGHT_PWM) && !defined(MAPLE_STM32F1) #define HAS_LCD_BRIGHTNESS 1 - #define DEFAULT_LCD_BRIGHTNESS TFT_BACKLIGHT_PWM + #define LCD_BRIGHTNESS_DEFAULT TFT_BACKLIGHT_PWM #endif #if ENABLED(SDIO_SUPPORT) @@ -189,19 +194,19 @@ #define EEPROM_SCK_PIN BOARD_SPI1_SCK_PIN // PA5 pin 30 #define EEPROM_MISO_PIN BOARD_SPI1_MISO_PIN // PA6 pin 31 #define EEPROM_MOSI_PIN BOARD_SPI1_MOSI_PIN // PA7 pin 32 - #define EEPROM_PAGE_SIZE 0x1000U // 4KB (from datasheet) - #define MARLIN_EEPROM_SIZE 16UL * (EEPROM_PAGE_SIZE) // Limit to 64KB for now... + #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 - #define SPI_FLASH_SIZE 0x40000U // limit to 256KB (M993 will reboot with 512) + #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 #define SPI_FLASH_MISO_PIN PA6 #define SPI_FLASH_SCK_PIN PA5 #elif ENABLED(FLASH_EEPROM_EMULATION) // SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h) - #define EEPROM_PAGE_SIZE (0x800U) // 2KB + #define EEPROM_PAGE_SIZE (0x800U) // 2K #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) #define MARLIN_EEPROM_SIZE (EEPROM_PAGE_SIZE) #else - #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM + #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2K, require this amount of RAM #endif diff --git a/Marlin/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h b/Marlin/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h index 87526bac8797..37c67708848c 100644 --- a/Marlin/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_MINGDA_MPX_ARM_MINI.h @@ -46,16 +46,16 @@ #define I2C_EEPROM #undef NO_EEPROM_SELECTED -#define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#define MARLIN_EEPROM_SIZE 0x1000 // 4K #define USE_SHARED_EEPROM 1 // Use Platform-independent Arduino functions for I2C EEPROM #define E2END 0xFFFF // EEPROM end address AT24C256 (32kB) */ #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE 0x800U // 2KB + #define EEPROM_PAGE_SIZE 0x800U // 2K #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K #endif #define SPI_DEVICE 2 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h index 29baeba934f1..6ab20681ad5a 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h @@ -53,7 +53,7 @@ #endif #if ENABLED(FLASH_EEPROM_EMULATION) - #define EEPROM_PAGE_SIZE (0x800U) // 2KB + #define EEPROM_PAGE_SIZE (0x800U) // 2K #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) #define MARLIN_EEPROM_SIZE (EEPROM_PAGE_SIZE) #endif @@ -125,7 +125,7 @@ //#define TEMP_0_CS_PIN PE6 // TC2 - CS2 // -// Filament runout sensor +// Filament Runout Sensor // #define FIL_RUNOUT_PIN PF11 // MT_DET diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h index a51f28bf957f..7a9595b90961 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h @@ -54,7 +54,7 @@ #if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) #define I2C_EEPROM // EEPROM on I2C-0 - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // @@ -205,6 +205,34 @@ //#define LED_PIN PB2 +/** + * ------ ------ + * 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 + * ------ ------ + * 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 + // // SD Card // @@ -219,11 +247,11 @@ #define ONBOARD_SD_CS_PIN PC11 #elif SD_CONNECTION_IS(LCD) #define ENABLE_SPI1 - #define SDSS PE10 - #define SD_SCK_PIN PA5 - #define SD_MISO_PIN PA6 - #define SD_MOSI_PIN PA7 - #define SD_DETECT_PIN PE12 + #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 #endif // @@ -240,27 +268,26 @@ // Shared SPI TFT - #define LCD_BACKLIGHT_PIN PD13 + #define LCD_BACKLIGHT_PIN EXP1_08_PIN - #define TOUCH_CS_PIN PE14 // SPI1_NSS - #define TOUCH_SCK_PIN PA5 // SPI1_SCK - #define TOUCH_MISO_PIN PA6 // SPI1_MISO - #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI + #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 BTN_EN1 PE8 - #define BTN_EN2 PE11 - #define BTN_ENC PE13 + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_06_PIN + #define BTN_ENC EXP1_09_PIN - #define TFT_CS_PIN PD11 - #define TFT_SCK_PIN PA5 - #define TFT_MISO_PIN PA6 - #define TFT_MOSI_PIN PA7 - #define TFT_DC_PIN PD10 - #define TFT_RST_PIN PC6 + #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_A0_PIN TFT_DC_PIN - #define TFT_RESET_PIN PC6 - #define TFT_BACKLIGHT_PIN PD13 + #define TFT_RESET_PIN EXP1_07_PIN + #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 @@ -271,22 +298,22 @@ #if ENABLED(TFT_CLASSIC_UI) // Emulated DOGM SPI - #define LCD_PINS_ENABLE PD13 - #define LCD_PINS_RS PC6 - #define BTN_ENC PE13 - #define BTN_EN1 PE8 - #define BTN_EN2 PE11 + #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 #elif ENABLED(TFT_COLOR_UI) #define TFT_BUFFER_SIZE 14400 #endif #if HAS_WIRED_LCD && !HAS_SPI_TFT - #define BEEPER_PIN PC5 - #define BTN_ENC PE13 - #define LCD_PINS_ENABLE PD13 - #define LCD_PINS_RS PC6 - #define BTN_EN1 PE8 - #define BTN_EN2 PE11 + #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 LCD_BACKLIGHT_PIN -1 #if ENABLED(MKS_MINI_12864) @@ -296,18 +323,18 @@ #define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN -1 - #define DOGLCD_A0 PD11 - #define DOGLCD_CS PE15 - #define DOGLCD_SCK PA5 - #define DOGLCD_MOSI PA7 + #define DOGLCD_A0 EXP1_04_PIN + #define DOGLCD_CS EXP1_05_PIN + #define DOGLCD_SCK EXP2_09_PIN + #define DOGLCD_MOSI EXP2_05_PIN #elif IS_TFTGLCD_PANEL #if ENABLED(TFTGLCD_PANEL_SPI) - #define PIN_SPI_SCK PA5 - #define PIN_TFT_MISO PA6 - #define PIN_TFT_MOSI PA7 - #define TFTGLCD_CS PE8 + #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 #endif #ifndef BEEPER_PIN @@ -315,26 +342,26 @@ #endif #elif ENABLED(FYSETC_MINI_12864_2_1) - #define DOGLCD_CS PD13 - #define DOGLCD_A0 PC6 - #define LCD_PINS_DC DOGLCD_A0 + #define LCD_PINS_DC EXP1_07_PIN + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_A0 DOGLCD_A0 #define LCD_BACKLIGHT_PIN -1 - #define LCD_RESET_PIN PE14 - #define NEOPIXEL_PIN PE15 - #define DOGLCD_MOSI PA7 - #define DOGLCD_SCK PA5 + #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 #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif - //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #else // !MKS_MINI_12864 - #define LCD_PINS_D4 PE14 + #define LCD_PINS_D4 EXP1_06_PIN #if IS_ULTIPANEL - #define LCD_PINS_D5 PE15 - #define LCD_PINS_D6 PD11 - #define LCD_PINS_D7 PD10 + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_04_PIN + #define LCD_PINS_D7 EXP1_03_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder @@ -360,7 +387,7 @@ #endif #ifndef BEEPER_PIN - #define BEEPER_PIN PC5 + #define BEEPER_PIN EXP1_10_PIN #endif #if ENABLED(SPEAKER) && BEEPER_PIN == PC5 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_V1_1_common.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_V1_1_common.h index 4eaf2e946939..31e034e025e9 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_V1_1_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_V1_1_common.h @@ -27,7 +27,7 @@ // Onboard I2C EEPROM #if NO_EEPROM_SELECTED #define I2C_EEPROM - #define MARLIN_EEPROM_SIZE 0x1000// 4KB + #define MARLIN_EEPROM_SIZE 0x1000// 4K #undef NO_EEPROM_SELECTED #endif 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 e02d1db7863d..4af88c18482a 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h @@ -40,9 +40,9 @@ // #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE (0x800U) // 2KB + #define EEPROM_PAGE_SIZE (0x800U) // 2K #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K #endif // @@ -145,7 +145,7 @@ * (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 | NC GND | 2 1 | 5V + * GND | 2 1 | 5V GND | 2 1 | -- GND | 2 1 | 5V * ------ ------ ------ * EXP1 EXP2 "Ender-3 EXP1" */ @@ -197,9 +197,10 @@ #define DOGLCD_MOSI EXP2_05_PIN #elif ENABLED(FYSETC_MINI_12864_2_1) + + #define LCD_PINS_DC EXP1_07_PIN #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define LCD_PINS_DC DOGLCD_A0 + #define DOGLCD_A0 LCD_PINS_DC #define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN EXP1_06_PIN #define NEOPIXEL_PIN EXP1_05_PIN @@ -207,7 +208,7 @@ #define DOGLCD_SCK EXP2_09_PIN #define FORCE_SOFT_SPI #define SOFTWARE_SPI - //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #else diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h index c981fdc00a57..dac09d037fc6 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h @@ -45,9 +45,9 @@ // #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE (0x800U) // 2KB + #define EEPROM_PAGE_SIZE (0x800U) // 2K #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K #endif #define SPI_DEVICE 2 @@ -153,6 +153,9 @@ #define FSMC_CS_PIN PD7 // NE4 #define FSMC_RS_PIN PD11 // A0 + #define TFT_CS_PIN FSMC_CS_PIN + #define TFT_RS_PIN FSMC_RS_PIN + #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 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h index c729274c54cf..115058a19f77 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h @@ -45,3 +45,7 @@ //#define LED_PIN PB2 #include "pins_MKS_ROBIN_NANO_common.h" + +#if HAS_TFT_LVGL_UI && FAN1_PIN != PB0 && HEATER_1_PIN != PB0 + #define BOARD_INIT() OUT_WRITE(PB0, LOW) +#endif 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 592d585982df..6e11e1bcd351 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -54,7 +54,7 @@ #if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) #define I2C_EEPROM // EEPROM on I2C-0 - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // @@ -193,7 +193,9 @@ // #if ENABLED(MKS_PWC) #if ENABLED(TFT_LVGL_UI) - #undef PSU_CONTROL + #if ENABLED(PSU_CONTROL) + #error "PSU_CONTROL is incompatible with MKS_PWC plus TFT_LVGL_UI." + #endif #undef MKS_PWC #define SUICIDE_PIN PB2 #define SUICIDE_PIN_STATE LOW @@ -280,11 +282,10 @@ #define TFT_MISO_PIN PA6 #define TFT_MOSI_PIN PA7 #define TFT_DC_PIN PD10 - #define TFT_RST_PIN PC6 #define TFT_A0_PIN TFT_DC_PIN #define TFT_RESET_PIN PC6 - #define TFT_BACKLIGHT_PIN PD13 + #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 @@ -339,9 +340,9 @@ #endif #elif ENABLED(FYSETC_MINI_12864_2_1) + #define LCD_PINS_DC PC6 #define DOGLCD_CS PD13 - #define DOGLCD_A0 PC6 - #define LCD_PINS_DC DOGLCD_A0 + #define DOGLCD_A0 DOGLCD_A0 #define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN PE14 #define NEOPIXEL_PIN PE15 @@ -350,7 +351,7 @@ #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif - //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #else // !MKS_MINI_12864 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 c1d0e591e972..2040a4ba29d8 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h @@ -42,9 +42,9 @@ #endif #if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE (0x800U) // 2KB + #define EEPROM_PAGE_SIZE (0x800U) // 2K #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K #endif #define SPI_DEVICE 2 @@ -98,15 +98,6 @@ #ifndef HEATER_0_PIN #define HEATER_0_PIN PC3 #endif -#if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) - #ifndef FAN1_PIN - #define FAN1_PIN PB0 - #endif -#else - #ifndef HEATER_1_PIN - #define HEATER_1_PIN PB0 - #endif -#endif #ifndef FAN_PIN #define FAN_PIN PB1 // FAN #endif @@ -114,12 +105,22 @@ #define HEATER_BED_PIN PA0 #endif +#if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) + #ifndef FAN1_PIN + #define FAN1_PIN PB0 + #endif +#elif !defined(HEATER_1_PIN) + #define HEATER_1_PIN PB0 +#endif + // // Power Supply Control // #if ENABLED(MKS_PWC) #if ENABLED(TFT_LVGL_UI) - #undef PSU_CONTROL + #if ENABLED(PSU_CONTROL) + #error "PSU_CONTROL is incompatible with MKS_PWC plus TFT_LVGL_UI." + #endif #undef MKS_PWC #define SUICIDE_PIN PB2 #define SUICIDE_PIN_STATE LOW diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h index a738a4faa259..53f207adb7ab 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h @@ -185,7 +185,9 @@ // #if ENABLED(MKS_PWC) #if ENABLED(TFT_LVGL_UI) - #undef PSU_CONTROL + #if ENABLED(PSU_CONTROL) + #error "PSU_CONTROL is incompatible with MKS_PWC plus TFT_LVGL_UI." + #endif #undef MKS_PWC #define SUICIDE_PIN PG11 #define SUICIDE_PIN_STATE LOW diff --git a/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h b/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h new file mode 100644 index 000000000000..98ef165e2d66 --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_PANDA_PI_V29.h @@ -0,0 +1,222 @@ +/** + * 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" + +#define BOARD_INFO_NAME "PANDA PI V2.9" + +// Release PB3/PB4 (TMC_SW Pins) from JTAG pins +#define DISABLE_JTAG + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION) + #define FLASH_EEPROM_EMULATION + #define EEPROM_PAGE_SIZE (0x800U) // 2K + #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K +#endif + +// +// Servos +// +#define SERVO0_PIN PA11 // SERVOS + +// +// Limit Switches +// +#define X_STOP_PIN PA3 // X-STOP +#define Y_STOP_PIN PC9 // Y-STOP +#define Z_STOP_PIN PA1 // 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 PC2 // E0-STOP +//#endif + +// +// Steppers +// +#define X_ENABLE_PIN PC12 +#define X_STEP_PIN PC11 +#define X_DIR_PIN PB6 + +#define Y_ENABLE_PIN PC12 +#define Y_STEP_PIN PB5 +#define Y_DIR_PIN PB4 + +#define Z_ENABLE_PIN PC12 +#define Z_STEP_PIN PB3 +#define Z_DIR_PIN PA15 + +#define E0_ENABLE_PIN PC12 +#define E0_STEP_PIN PB15 +#define E0_DIR_PIN PB14 + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PB5 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PB4 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PB3 + #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 MSerial1 + //#define Y_HARDWARE_SERIAL MSerial1 + //#define Z_HARDWARE_SERIAL MSerial1 + //#define E0_HARDWARE_SERIAL MSerial1 + + #define X_SERIAL_TX_PIN PC10 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PC11 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PC12 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PD2 + #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 PB0 // Analog Input "TH0" +#define TEMP_BED_PIN PB1 // Analog Input "TB0" +#define TEMP_1_PIN PA2 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PB12 // "HE" +#define HEATER_BED_PIN PB13 // "HB" +#define FAN_PIN PA8 // "FAN0" +#define HEATER_1_PIN PA12 + +// +// SD Support +// +#define ONBOARD_SPI_DEVICE 1 // SPI1 +#define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card +#define SDSS ONBOARD_SD_CS_PIN + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif +#if SD_CONNECTION_IS(ONBOARD) + //#define SD_DETECT_PIN PA4 + #define SD_SCK_PIN PA5 + #define SD_MISO_PIN PA6 + #define SD_MOSI_PIN PA7 +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "SD CUSTOM_CABLE is not compatible with SKR E3 DIP." +#endif + +// +// LCD / Controller +// +#if HAS_WIRED_LCD + #define BTN_ENC PA0 + #define BTN_EN1 PC4 + #define BTN_EN2 PC5 + + #define LCD_PINS_RS PC0 + #define LCD_PINS_ENABLE PC2 + #define LCD_PINS_D4 PC1 +#endif + +#if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + + #error "CAUTION! LCD_FYSETC_TFT81050 requires wiring modifications. See 'pins_BTT_SKR_E3_DIP.h' for details. Comment out this line to continue." + + /** 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 + * + * 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 + */ + + #define CLCD_SPI_BUS 1 // SPI1 connector + + #define BEEPER_PIN PB6 + + #define CLCD_MOD_RESET PA9 + #define CLCD_SPI_CS PB8 + + #if SD_CONNECTION_IS(LCD) && BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + #define SD_DETECT_PIN PA15 + #define SD_SS_PIN PA10 + #endif + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN PC3 + +#endif diff --git a/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h b/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h index 7171de919d03..e189fc3f97b9 100644 --- a/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_STM3R_MINI.h @@ -91,7 +91,7 @@ #endif #define FAN1_PIN PD13 -#define FAN_SOFT_PWM +#define FAN_SOFT_PWM_REQUIRED // // Temperature Sensors diff --git a/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h b/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h index bf38955127e4..4ffa8da924d3 100644 --- a/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h @@ -45,14 +45,16 @@ // // EEPROM // -#define FLASH_EEPROM_EMULATION +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION +#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 EEPROM_PAGE_SIZE (0x800U) // 2K, but will use 2x more (4K) #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE #else - #define MARLIN_EEPROM_SIZE (0x800U) // On SD, Limit to 2KB, require this amount of RAM + #define MARLIN_EEPROM_SIZE (0x800U) // On SD, Limit to 2K, require this amount of RAM #endif // diff --git a/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h b/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h index ba948bc479fe..f1f03a7dd789 100644 --- a/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h +++ b/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h @@ -30,9 +30,9 @@ #if NO_EEPROM_SELECTED #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE (0x800) // 2KB + #define EEPROM_PAGE_SIZE (0x800) // 2K #define EEPROM_START_ADDRESS (0x08000000 + (STM32_FLASH_SIZE) * 1024 - 2 * EEPROM_PAGE_SIZE) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K #endif //============================================================================= @@ -224,7 +224,7 @@ #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 DOGLCD_A0 LCD_PINS_DC // A0 = DC + #define DOGLCD_A0 LCD_PINS_DC #define DOGLCD_MOSI EXP1_10_PIN // SDA #define DOGLCD_SCK EXP1_09_PIN // SCK // Encoder diff --git a/Marlin/src/pins/stm32f1/pins_ZM3E4_V1_0.h b/Marlin/src/pins/stm32f1/pins_ZM3E4_V1_0.h index 49e9564b2738..17e13bdc87ba 100644 --- a/Marlin/src/pins/stm32f1/pins_ZM3E4_V1_0.h +++ b/Marlin/src/pins/stm32f1/pins_ZM3E4_V1_0.h @@ -30,9 +30,9 @@ #if NO_EEPROM_SELECTED #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE (0x800) // 2KB + #define EEPROM_PAGE_SIZE (0x800) // 2K #define EEPROM_START_ADDRESS (0x08000000 + (STM32_FLASH_SIZE) * 1024 - 2 * EEPROM_PAGE_SIZE) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K #endif //#define OPTION_DUALZ_DRIVE diff --git a/Marlin/src/pins/stm32f1/pins_ZM3E4_V2_0.h b/Marlin/src/pins/stm32f1/pins_ZM3E4_V2_0.h index 295ab4c50ccc..df0eb9c3d812 100644 --- a/Marlin/src/pins/stm32f1/pins_ZM3E4_V2_0.h +++ b/Marlin/src/pins/stm32f1/pins_ZM3E4_V2_0.h @@ -30,9 +30,9 @@ #if NO_EEPROM_SELECTED #define FLASH_EEPROM_EMULATION - #define EEPROM_PAGE_SIZE (0x800) // 2KB + #define EEPROM_PAGE_SIZE (0x800) // 2K #define EEPROM_START_ADDRESS (0x08000000 + (STM32_FLASH_SIZE) * 1024 - 2 * EEPROM_PAGE_SIZE) - #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2K #endif //#define OPTION_DUALZ_DRIVE diff --git a/Marlin/src/pins/stm32f4/pins_ANET_ET4.h b/Marlin/src/pins/stm32f4/pins_ANET_ET4.h index eb3af65f32eb..09da5adf7c6d 100644 --- a/Marlin/src/pins/stm32f4/pins_ANET_ET4.h +++ b/Marlin/src/pins/stm32f4/pins_ANET_ET4.h @@ -39,7 +39,7 @@ #if NO_EEPROM_SELECTED //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation #define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation - //#define IIC_BL24CXX_EEPROM // Use I2C EEPROM onboard IC (AT24C04C, Size 4KB, PageSize 16B) + //#define IIC_BL24CXX_EEPROM // Use I2C EEPROM onboard IC (AT24C04C, Size 4K, PageSize 16B) #endif #if ENABLED(FLASH_EEPROM_EMULATION) @@ -50,7 +50,7 @@ #define IIC_EEPROM_SDA PB11 #define IIC_EEPROM_SCL PB10 #define EEPROM_DEVICE_ADDRESS 0xA0 - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // @@ -203,19 +203,12 @@ #if ENABLED(SDSUPPORT) - #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 - #if DISABLED(SDIO_SUPPORT) #define SOFTWARE_SPI - #define SDSS SDIO_D3_PIN - #define SD_SCK_PIN SDIO_CK_PIN - #define SD_MISO_PIN SDIO_D0_PIN - #define SD_MOSI_PIN SDIO_CMD_PIN + #define SDSS PC11 + #define SD_SCK_PIN PC12 + #define SD_MISO_PIN PC8 + #define SD_MOSI_PIN PD2 #endif #ifndef SD_DETECT_PIN diff --git a/Marlin/src/pins/stm32f4/pins_ARMED.h b/Marlin/src/pins/stm32f4/pins_ARMED.h index 7cccac7caa3a..6d5b87240d6b 100644 --- a/Marlin/src/pins/stm32f4/pins_ARMED.h +++ b/Marlin/src/pins/stm32f4/pins_ARMED.h @@ -40,7 +40,7 @@ #if NO_EEPROM_SELECTED #define I2C_EEPROM - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // @@ -150,7 +150,7 @@ #if ENABLED(FYSETC_MINI_12864) // - // See https://wiki.fysetc.com/Mini12864_Panel/?fbclid=IwAR1FyjuNdVOOy9_xzky3qqo_WeM5h-4gpRnnWhQr_O1Ef3h0AFnFXmCehK8 + // See https://wiki.fysetc.com/Mini12864_Panel/ // #define DOGLCD_A0 PE9 #define DOGLCD_CS PE8 diff --git a/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h b/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h index 4cf9768fbe80..653735bd61d0 100644 --- a/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h +++ b/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h @@ -29,9 +29,11 @@ #define BOARD_INFO_NAME "Artillery Ruby" -#define FLASH_EEPROM_EMULATION -//#define I2C_EEPROM -//#define E2END 0xFFF // 4KB +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION + //#define I2C_EEPROM +#endif +//#define E2END 0xFFF // 4K #define HAL_TIMER_RATE F_CPU @@ -155,7 +157,7 @@ #define NEOPIXEL_PIN PB9 #endif - #define DEFAULT_LCD_CONTRAST 255 + #define LCD_CONTRAST_INIT 255 #else #define LCD_PINS_RS PC15 #define LCD_PINS_ENABLE PB6 diff --git a/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h b/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h index d8a83bef3a89..9da6e1a01b6a 100644 --- a/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h +++ b/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h @@ -42,7 +42,7 @@ //#define I2C_EEPROM #define SRAM_EEPROM_EMULATION -#define MARLIN_EEPROM_SIZE 0x2000 // 8KB +#define MARLIN_EEPROM_SIZE 0x2000 // 8K // // Servos @@ -140,25 +140,17 @@ // // Onboard SD support // -#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 - #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION ONBOARD #endif #if SD_CONNECTION_IS(ONBOARD) #define SDIO_SUPPORT // Use SDIO for onboard SD - - #ifndef SDIO_SUPPORT + #if DISABLED(SDIO_SUPPORT) #define SOFTWARE_SPI // Use soft SPI for onboard SD - #define SDSS SDIO_D3_PIN - #define SD_SCK_PIN SDIO_CK_PIN - #define SD_MISO_PIN SDIO_D0_PIN - #define SD_MOSI_PIN SDIO_CMD_PIN + #define SDSS PC11 + #define SD_SCK_PIN PC12 + #define SD_MISO_PIN PC8 + #define SD_MOSI_PIN PD2 #endif #endif 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 653ebd82a1dd..99de2e43e7a3 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h @@ -197,16 +197,16 @@ #endif /** - * -----------------------------------BTT002 V1.0---------------------------------------- - * ------ ------ | - * PA3 | 1 2 | GND 5V | 1 2 | GND | - * NRESET | 3 4 | PC4 (SD_DET) (LCD_D7) PE13 | 3 4 | PE12 (LCD_D6) | - * (MOSI) PA7 | 5 6 | PB0 (BTN_EN2) (LCD_D5) PE11 | 5 6 | PE10 (LCD_D4) | - * (SD_SS) PA4 | 7 8 | PC5 (BTN_EN1) (LCD_RS) PE8 | 7 8 | PE9 (LCD_EN) | - * (SCK) PA5 | 9 10 | PA6 (MISO) (BTN_ENC) PB1 | 9 10 | PE7 (BEEPER) | - * ------ ------ | - * EXP2 EXP1 | - * -------------------------------------------------------------------------------------- + * ---------------------------------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 | + * ------ ------ | + * EXP1 EXP2 | + * ------------------------------------------------------------------------------ */ #define EXP1_03_PIN PE13 #define EXP1_04_PIN PE12 diff --git a/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h b/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h index d1f38f5c8098..40f953a7e8f5 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_E3_RRF.h @@ -36,7 +36,7 @@ // Onboard I2C EEPROM #define I2C_EEPROM -#define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#define MARLIN_EEPROM_SIZE 0x1000 // 4K // // Servos @@ -184,24 +184,24 @@ #endif /** - * BTT E3 RRF - * ----- - * 5V | 1 2 | GND - * (LCD_EN) PE11 | 3 4 | PB1 (LCD_RS) - * (LCD_D4) PE10 | 5 6 PB2 (BTN_EN2) - * RESET | 7 8 | PE7 (BTN_EN1) - * (BTN_ENC) PE9 | 9 10| PE8 (BEEPER) - * ----- + * 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 + * ------ * EXP1 */ #if HAS_WIRED_LCD - #if ENABLED(CR10_STOCKDISPLAY) + #if EITHER(CR10_STOCKDISPLAY, LCD_FOR_MELZI) #define BEEPER_PIN PE8 - #define BTN_ENC PE9 + #define BTN_ENC PE9 #define BTN_EN1 PE7 #define BTN_EN2 PB2 @@ -209,6 +209,40 @@ #define LCD_PINS_ENABLE PE11 #define LCD_PINS_D4 PE10 + #if ENABLED(LCD_FOR_MELZI) + + #error "CAUTION! LCD_FOR_MELZI requires wiring modifications. See 'pins_BTT_E3_RRF.h' for details. Comment out this line to continue." + + /** LCD_FOR_MELZI display pinout + * + * 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) + * ------ ------ + * EXP1 Ribbon + * + * 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 + */ + + #endif + #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_E3_RRF.h' for details. Comment out this line to continue." @@ -244,15 +278,15 @@ /** * TFTGLCD_PANEL_SPI display pinout * - * Board Display - * ----- ----- - * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) - * (FREE) PE11 | 3 4 | PB1 (LCD_CS) (PE7) LCD_CS | 3 4 | SD_CS (PB2) - * (FREE) PE10 | 5 6 | PB2 (SD_CS) (FREE) | 5 6 | MOSI (SPI1-MOSI) - * RESET | 7 8 | PE7 (MOD_RESET) (PE8) SD_DET | 7 8 | (FREE) - * (BEEPER) PE9 | 9 10| PE8 (SD_DET) GND | 9 10| 5V - * ----- ----- - * EXP1 EXP1 + * 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) + * ------ ------ + * EXP1 EXP1 * * Needs custom cable: * @@ -275,11 +309,15 @@ #endif #else - #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BTT_E3_RRF." + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, LCD_FOR_MELZI, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BTT_E3_RRF." #endif // Alter timing for graphical display - #if IS_U8GLIB_ST7920 + #if ENABLED(LCD_FOR_MELZI) // LCD_FOR_MELZI default timing is too fast. This works but may be reduced. + #define BOARD_ST7920_DELAY_1 200 + #define BOARD_ST7920_DELAY_2 400 + #define BOARD_ST7920_DELAY_3 1200 + #elif IS_U8GLIB_ST7920 #define BOARD_ST7920_DELAY_1 96 #define BOARD_ST7920_DELAY_2 48 #define BOARD_ST7920_DELAY_3 600 @@ -293,20 +331,20 @@ /** FYSETC TFT TFT81050 display pinout * - * Board Display - * ----- ----- - * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) - * (FREE) PE11 | 3 4 | PB1 (LCD_CS) (PE7) MOD_RESET | 3 4 | SD_CS (PB2) - * (FREE) PE10 | 5 6 | PB2 (SD_CS) (PB1) LCD_CS | 5 6 | MOSI (SPI1-MOSI) - * RESET | 7 8 | PE7 (MOD_RESET) (PE8) SD_DET | 7 8 | RESET - * (BEEPER) PE9 | 9 10| PE8 (SD_DET) GND | 9 10| 5V - * ----- ----- - * EXP1 EXP1 + * 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) + * ------ ------ + * EXP1 EXP1 * * Needs custom cable: * * Board Adapter Display - * _________ + * * EXP1-1 ----------- EXP1-10 * EXP1-2 ----------- EXP1-9 * SPI1-4 ----------- EXP1-6 @@ -338,13 +376,6 @@ #if SD_CONNECTION_IS(ONBOARD) #define SDIO_SUPPORT // Use SDIO for onboard SD - #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 - //#define SDIO_CLOCK 48000000 #define SD_DETECT_PIN PC4 #elif SD_CONNECTION_IS(CUSTOM_CABLE) 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 dfa9d8a7b9dd..68d92e1c30d7 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h @@ -37,7 +37,7 @@ // Onboard I2C EEPROM #define I2C_EEPROM -#define MARLIN_EEPROM_SIZE 0x2000 // 8KB (24C64 ... 64Kb = 8KB) +#define MARLIN_EEPROM_SIZE 0x2000 // 8K (24C64) // // Servos @@ -365,14 +365,14 @@ #endif /** - * ------ ------ - * NC | 1 2 | GND 5V | 1 2 | GND - * RESET | 3 4 | PB10 (SD_DETECT) (LCD_D7) PG5 | 3 4 | PG6 (LCD_D6) - * (MOSI) PB15 | 5 6 | PH10 (BTN_EN2) (LCD_D5) PG7 | 5 6 | PG8 (LCD_D4) - * (SD_SS) PB12 | 7 8 | PD10 (BTN_EN1) (LCD_RS) PA8 | 7 8 | PC10 (LCD_EN) - * (SCK) PB13 | 9 10 | PB14 (MISO) (BTN_ENC) PA15 | 9 10 | PC11 (BEEPER) - * ------ ------ - * EXP2 EXP1 + * ------ ------ + * (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 | -- + * ------ ------ + * EXP1 EXP2 */ #define EXP1_03_PIN PG5 #define EXP1_04_PIN PG6 diff --git a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h index fd367e87c04f..dd8812fe2af9 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_PRO_V1_0.h @@ -37,4 +37,8 @@ #define TEMP_0_PIN PF4 // TH0 #endif +#if !defined(Z_MIN_PROBE_PIN) && DISABLED(BLTOUCH) + #define Z_MIN_PROBE_PIN PC5 // Probe (Proximity switch) port +#endif + #include "pins_BTT_OCTOPUS_V1_common.h" 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 9db0459be954..4255881baf86 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h @@ -28,7 +28,7 @@ // Onboard I2C EEPROM #define I2C_EEPROM -#define MARLIN_EEPROM_SIZE 0x8000 // 32KB (24C32A) +#define MARLIN_EEPROM_SIZE 0x1000 // 4KB (AT24C32) #define I2C_SCL_PIN PB8 #define I2C_SDA_PIN PB9 @@ -61,11 +61,7 @@ // Z Probe (when not Z_MIN_PIN) // #ifndef Z_MIN_PROBE_PIN - #if ENABLED(BLTOUCH) - #define Z_MIN_PROBE_PIN PB7 - #else - #define Z_MIN_PROBE_PIN PC5 // Probe (Proximity switch) port - #endif + #define Z_MIN_PROBE_PIN PB7 #endif // @@ -330,7 +326,7 @@ * (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 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ @@ -379,14 +375,14 @@ #if ENABLED(BTT_MOTOR_EXPANSION) /** - * ------ ------ - * NC | 1 2 | GND NC | 1 2 | GND - * NC | 3 4 | M1EN M2EN | 3 4 | M3EN - * M1STP | 5 6 M1DIR M1RX | 5 6 M1DIAG - * M2DIR | 7 8 | M2STP M2RX | 7 8 | M2DIAG - * M3DIR | 9 10 | M3STP M3RX | 9 10 | M3DIAG - * ------ ------ - * EXP2 EXP1 + * ------ ------ + * 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 | -- + * ------ ------ + * EXP1 EXP2 */ // M1 on Driver Expansion Module @@ -534,9 +530,9 @@ * (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 | NC - * NC | 14 | | 3 | PE15 (ESP-EN) - * (ESP-RX) PD8 | 15 | | 2 | NC + * (ESP-IO4) PD10 | 13 | | 4 | -- + * -- | 14 | | 3 | PE15 (ESP-EN) + * (ESP-RX) PD8 | 15 | | 2 | -- * (ESP-TX) PD9 | 16 | | 1 | PE14 (ESP-RST) * ------- * WIFI 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 1a1ac4ec2171..5e424d4105fb 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h @@ -317,7 +317,7 @@ * (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 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ @@ -367,8 +367,8 @@ #if ENABLED(BTT_MOTOR_EXPANSION) /** ----- ----- - * NC | . . | GND NC | . . | GND - * NC | . . | M1EN M2EN | . . | M3EN + * -- | . . | GND -- | . . | GND + * -- | . . | M1EN M2EN | . . | M3EN * M1STP | . . M1DIR M1RX | . . M1DIAG * M2DIR | . . | M2STP M2RX | . . | M2DIAG * M3DIR | . . | M3STP M3RX | . . | M3DIAG @@ -466,13 +466,13 @@ * * The WYH_L12864 connector plug: * - * BEFORE AFTER - * ______ ______ - * GND | 1 2 | 5V 5V | 1 2 | GND - * CS | 3 4 | BTN_EN2 CS | 3 4 | BTN_EN2 - * SID | 5 6 BTN_EN1 SID | 5 6 BTN_EN1 - * SCK | 7 8 | BTN_ENC SCK | 7 8 | BTN_ENC - * MOSI | 9 10 | MOSI | 9 10 | + * 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 * ------ ------ * LCD LCD */ @@ -550,12 +550,12 @@ // /** - * ----- - * TX | 1 2 | GND Enable PG1 // Must be high for module to run - * Enable | 3 4 | GPIO2 Reset PG0 // active low, probably OK to leave floating - * Reset | 5 6 | GPIO0 GPIO2 PF15 // must be high (ESP3D software configures this with a pullup so OK to leave as floating) - * 3.3V | 7 8 | RX GPIO0 PF14 // Leave as unused (ESP3D software configures this with a pullup so OK to leave as floating) - * ----- + * ------ + * 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 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 196ca4631998..4e311d48628a 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 @@ -23,6 +23,8 @@ #include "env_validate.h" +#define USES_DIAG_JUMPERS + // If you have the BigTreeTech driver expansion module, enable BTT_MOTOR_EXPANSION // https://github.com/bigtreetech/BTT-Expansion-module/tree/master/BTT%20EXP-MOT //#define BTT_MOTOR_EXPANSION @@ -253,7 +255,7 @@ #define FAN_PIN PB7 // Fan0 #endif -#if EITHER(SPINDLE_FEATURE, LASER_FEATURE) +#if HAS_CUTTER #ifndef SPINDLE_LASER_PWM_PIN #define SPINDLE_LASER_PWM_PIN PB5 #endif @@ -333,14 +335,14 @@ #endif /** - * ------ ------ - * NC | 1 2 | GND 5V | 1 2 | GND - * RESET | 3 4 | PC4 (SD_DETECT) (LCD_D7) PE13 | 3 4 | PE12 (LCD_D6) - * (MOSI) PA7 | 5 6 PB2 (BTN_EN2) (LCD_D5) PE11 | 5 6 PE10 (LCD_D4) - * (SD_SS) PA4 | 7 8 | PE7 (BTN_EN1) (LCD_RS) PE9 | 7 8 | PB1 (LCD_EN) - * (SCK) PA5 | 9 10 | PA6 (MISO) (BTN_ENC) PB0 | 9 10 | PC5 (BEEPER) - * ------ ------ - * EXP2 EXP1 + * ------ ------ + * (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 | -- + * ------ ------ + * EXP1 EXP2 */ #define EXP1_03_PIN PE13 #define EXP1_04_PIN PE12 @@ -365,32 +367,22 @@ // 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 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 - #elif SD_CONNECTION_IS(ONBOARD) - #define SDIO_SUPPORT // Use SDIO for onboard SD - #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 - #elif SD_CONNECTION_IS(CUSTOM_CABLE) #error "No custom SD drive cable defined for this board." #endif #if ENABLED(BTT_MOTOR_EXPANSION) /** ----- ----- - * NC | . . | GND NC | . . | GND - * NC | . . | M1EN M2EN | . . | M3EN + * -- | . . | GND -- | . . | GND + * -- | . . | M1EN M2EN | . . | M3EN * M1STP | . . M1DIR M1RX | . . M1DIAG * M2DIR | . . | M2STP M2RX | . . | M2DIAG * M3DIR | . . | M3STP M3RX | . . | M3DIAG @@ -535,6 +527,11 @@ #endif #if HAS_SPI_TFT + + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_06_PIN + #define BTN_ENC EXP1_09_PIN + // // e.g., BTT_TFT35_SPI_V1_0 (480x320, 3.5", SPI Stock Display with Rotary Encoder in BIQU B1 SE) // @@ -550,9 +547,6 @@ #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 #endif // @@ -572,9 +566,9 @@ * (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 | NC - * NC | 14 | | 3 | 3.3V (ESP-EN) - * (ESP-RX) PD8 | 15 | | 2 | NC + * (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 diff --git a/Marlin/src/HAL/STM32F1/watchdog.h b/Marlin/src/pins/stm32f4/pins_CREALITY_V24S1_301F4.h similarity index 63% rename from Marlin/src/HAL/STM32F1/watchdog.h rename to Marlin/src/pins/stm32f4/pins_CREALITY_V24S1_301F4.h index 68920f8cb692..883640d5772e 100644 --- a/Marlin/src/HAL/STM32F1/watchdog.h +++ b/Marlin/src/pins/stm32f4/pins_CREALITY_V24S1_301F4.h @@ -1,6 +1,6 @@ /** * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 @@ -22,14 +22,17 @@ #pragma once /** - * HAL for stm32duino.com based on Libmaple and compatible (STM32F1) + * Creality V24S1_301F4 (STM32F401RC) board pin assignments as found on Ender 3 S1. */ -#include +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Creality V24S1-301F4" +#endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME "Ender-3 S1 F4" +#endif -// Initialize watchdog with a 4 or 8 second countdown time -void watchdog_init(); +#define DISABLE_DEBUG false // DISABLE_(DEBUG|JTAG) is not supported for STM32F4. +#define ALLOW_STM32F4 -// Reset watchdog. MUST be called every 4 or 8 seconds after the -// first watchdog_init or the STM32F1 will reset. -void HAL_watchdog_refresh(); +#include "../stm32f1/pins_CREALITY_V24S1_301.h" diff --git a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h index af316cf4b1d0..3f5f7262b387 100644 --- a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h +++ b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h @@ -50,11 +50,11 @@ // the 128kB sector allocated for EEPROM emulation. #define FLASH_EEPROM_LEVELING #elif ENABLED(I2C_EEPROM) - #define MARLIN_EEPROM_SIZE 0x2000 // 8KB + #define MARLIN_EEPROM_SIZE 0x2000 // 8K #endif #ifndef MARLIN_EEPROM_SIZE - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // @@ -181,7 +181,7 @@ * 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 | NC + * GND | 2 1 | 5V GND | 2 1 | -- * ------ ------ * EXP1 EXP2 */ diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h b/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h index 054da6275465..29aff20ffd4f 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V20.h @@ -139,26 +139,26 @@ #endif /** - * ----- ----- - * 5V | 1 2 | GND 5V | 1 2 | GND - * RESET | 3 4 | PC3 (SD_DETECT) (LCD_D7) PB7 | 3 4 | PB6 (LCD_D6) - * (SD_MOSI) PA7 5 6 | PC11 (BTN_EN2) (LCD_D5) PB14 5 6 | PB13 (LCD_D4) - * (SD_SS) PA4 | 7 8 | PC10 (BTN_EN1) (LCD_RS) PB12 | 7 8 | PB15 (LCD_EN) - * (SD_SCK) PA5 | 9 10| PA6 (SD_MISO) (BTN_ENC) PC12 | 9 10| PC9 (BEEPER) - * ----- ----- - * EXP2 EXP1 + * ------ ------ + * (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 + * ------ ------ + * EXP2 EXP1 */ /** -* ----- -* (BEEPER) PC9 | 1 2 | PC12 (BTN_ENC) -* (BTN_EN1) PC10 | 3 4 | PB14 (LCD_D5/MISO) -* (BTN_EN2) PC11 5 6 | PB13 (LCD_D4/SCK) -* (LCD_RS) PB12 | 7 8 | PB15 (LCD_EN/MOSI) -* GND | 9 10| 5V -* ----- -* EXP3 -*/ + * ------ + * 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) + * ------ + * EXP3 + */ #define EXP1_03_PIN PB7 #define EXP1_04_PIN PB6 diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h index 85071034c2a8..299cc153773d 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_S6.h @@ -50,7 +50,7 @@ // 128 kB sector allocated for EEPROM emulation. #define FLASH_EEPROM_LEVELING #elif ENABLED(I2C_EEPROM) - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // @@ -128,7 +128,7 @@ #define Y_SERIAL_TX_PIN PE14 #endif #ifndef Y_SERIAL_RX_PIN - #define Y_SERIAL_RX_PIN PC4 + #define Y_SERIAL_RX_PIN PE13 #endif #ifndef Z_SERIAL_TX_PIN #define Z_SERIAL_TX_PIN PD11 @@ -203,7 +203,7 @@ * 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 + * GND | 2 1 | 5V GND | 2 1 | 5V * ------ ------ * EXP1 EXP2 */ diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_S6_V2_0.h b/Marlin/src/pins/stm32f4/pins_FYSETC_S6_V2_0.h index 6f1c9be8f5b0..a9ce1383d8ca 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_S6_V2_0.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_S6_V2_0.h @@ -39,11 +39,17 @@ #if HAS_TMC_UART #define X_SERIAL_TX_PIN PE8 + #define X_SERIAL_RX_PIN PE8 #define Y_SERIAL_TX_PIN PC4 + #define Y_SERIAL_RX_PIN PC4 #define Z_SERIAL_TX_PIN PD12 + #define Z_SERIAL_RX_PIN PD12 #define E0_SERIAL_TX_PIN PA15 + #define E0_SERIAL_RX_PIN PA15 #define E1_SERIAL_TX_PIN PC5 + #define E1_SERIAL_RX_PIN PC5 #define E2_SERIAL_TX_PIN PE0 + #define E2_SERIAL_RX_PIN PE0 #endif // diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER.h b/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER.h index e05811552e2b..67f276bd2295 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_SPIDER.h @@ -39,7 +39,7 @@ #endif #if ENABLED(I2C_EEPROM) - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // diff --git a/Marlin/src/pins/stm32f4/pins_INDEX_REV03.h b/Marlin/src/pins/stm32f4/pins_INDEX_REV03.h index 8560a04375c0..ba3172aa8008 100644 --- a/Marlin/src/pins/stm32f4/pins_INDEX_REV03.h +++ b/Marlin/src/pins/stm32f4/pins_INDEX_REV03.h @@ -40,7 +40,7 @@ */ #define SRAM_EEPROM_EMULATION -#define MARLIN_EEPROM_SIZE 0x2000 // 8KB +#define MARLIN_EEPROM_SIZE 0x2000 // 8K // I2C MCP3426 (16-Bit, 240SPS, dual-channel ADC) #define HAS_MCP3426_ADC @@ -60,12 +60,12 @@ // 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 +//#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 @@ -73,64 +73,108 @@ #define X_STEP_PIN PB15 #define X_DIR_PIN PB14 #define X_ENABLE_PIN PD9 -#define X_SERIAL_TX_PIN PD8 -#define X_SERIAL_RX_PIN PD8 #define Y_STEP_PIN PE15 #define Y_DIR_PIN PE14 #define Y_ENABLE_PIN PB13 -#define Y_SERIAL_TX_PIN PB12 -#define Y_SERIAL_RX_PIN PB12 #define Z_STEP_PIN PE7 #define Z_DIR_PIN PB1 #define Z_ENABLE_PIN PE9 -#define Z_SERIAL_TX_PIN PE8 -#define Z_SERIAL_RX_PIN PE8 #define I_STEP_PIN PC4 #define I_DIR_PIN PA4 #define I_ENABLE_PIN PB0 -#define I_SERIAL_TX_PIN PC5 -#define I_SERIAL_RX_PIN PC5 #define J_STEP_PIN PE11 #define J_DIR_PIN PE10 #define J_ENABLE_PIN PE13 -#define J_SERIAL_TX_PIN PE12 -#define J_SERIAL_RX_PIN PE12 -#define K_SERIAL_TX_PIN PA2 -#define K_SERIAL_RX_PIN PA2 #define K_STEP_PIN PD6 #define K_DIR_PIN PD7 #define K_ENABLE_PIN PA3 -// Reduce baud rate to improve software serial reliability -#define TMC_BAUD_RATE 19200 +#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 -// Not required for this board. Fails to compile otherwise. -// PD0 is not connected on this board. -#define TEMP_0_PIN PD0 - -// General use mosfets, useful for things like pumps and solenoids +// +// Heaters / Fans +// #define FAN_PIN PE2 #define FAN1_PIN PE3 #define FAN2_PIN PE4 #define FAN3_PIN PE5 -#define FAN_SOFT_PWM +#define FAN_SOFT_PWM_REQUIRED -// Neopixel Rings +// +// 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 diff --git a/Marlin/src/pins/stm32f4/pins_LERDGE_S.h b/Marlin/src/pins/stm32f4/pins_LERDGE_S.h index c904d57a1f0a..0e8b6e09a865 100644 --- a/Marlin/src/pins/stm32f4/pins_LERDGE_S.h +++ b/Marlin/src/pins/stm32f4/pins_LERDGE_S.h @@ -133,8 +133,10 @@ // // Průša i3 MK2 Multi Material Multiplexer Support // -//#define E_MUX0_PIN -1 -//#define E_MUX1_PIN -1 +#if HAS_PRUSA_MMU1 + //#define E_MUX0_PIN -1 + //#define E_MUX1_PIN -1 +#endif // // LED / Lighting @@ -184,15 +186,15 @@ #define EEPROM_SCK_PIN PB13 // datasheet: CLK pin, found with multimeter, not tested #define EEPROM_MISO_PIN PB14 // datasheet: DO pin, found with multimeter, not tested #define EEPROM_MOSI_PIN PB15 // datasheet: DI pin, found with multimeter, not tested - #define EEPROM_PAGE_SIZE 0x1000U // 4KB (from datasheet) - #define MARLIN_EEPROM_SIZE 16UL * (EEPROM_PAGE_SIZE) // Limit to 64KB for now... + #define EEPROM_PAGE_SIZE 0x1000U // 4K (from datasheet) + #define MARLIN_EEPROM_SIZE 16UL * (EEPROM_PAGE_SIZE) // Limit to 64K for now... #elif ENABLED(I2C_EEPROM) // FM24CL64BG (CYP1813) 64Kbit F-RAM #define SOFT_I2C_EEPROM // Force the use of Software I2C #define I2C_SDA_PIN PG13 #define I2C_SCL_PIN PG14 // To be confirmed on the Lerdge S, but probably same as the K - #define MARLIN_EEPROM_SIZE 0x10000 + #define MARLIN_EEPROM_SIZE 0x2000U // 8K #else - #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2KB, require this amount of RAM + #define MARLIN_EEPROM_SIZE 0x800U // On SD, Limit to 2K, require this amount of RAM #endif // diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h index 2f77c0f9d6f9..736c79b6e034 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8.h @@ -44,7 +44,7 @@ //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation //#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation #define I2C_EEPROM // Need use jumpers set i2c for EEPROM -#define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#define MARLIN_EEPROM_SIZE 0x1000 // 4K #define I2C_SCL_PIN PB8 // I2C_SCL and CAN_RX #define I2C_SDA_PIN PB9 // I2C_SDA and CAN_TX @@ -239,7 +239,7 @@ * (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 + * GND | 2 1 | 5V GND | 2 1 | 3.3V * ------ ------ * EXP1 EXP2 */ @@ -261,25 +261,26 @@ #define EXP2_09_PIN PA5 #define EXP2_10_PIN PA6 -#ifndef SDCARD_CONNECTION - #define SDCARD_CONNECTION ONBOARD -#endif - -#if SD_CONNECTION_IS(ONBOARD) - #define ENABLE_SPI3 - #define SD_SS_PIN -1 - #define SDSS PC9 - #define SD_SCK_PIN PC10 - #define SD_MISO_PIN PC11 - #define SD_MOSI_PIN PC12 - #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 +#if ENABLED(SDSUPPORT) + #ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD + #endif + #if SD_CONNECTION_IS(ONBOARD) + #define ENABLE_SPI3 + #define SD_SS_PIN -1 + #define SDSS PC9 + #define SD_SCK_PIN PC10 + #define SD_MISO_PIN PC11 + #define SD_MOSI_PIN PC12 + #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 + #endif #endif #if ANY(TFT_COLOR_UI, TFT_CLASSIC_UI) @@ -288,16 +289,16 @@ #define TFT_MISO_PIN EXP2_10_PIN #define TFT_MOSI_PIN EXP2_05_PIN #define TFT_DC_PIN EXP1_03_PIN - #define TFT_RST_PIN EXP1_07_PIN #define TFT_A0_PIN TFT_DC_PIN #define TFT_RESET_PIN EXP1_07_PIN - #define TFT_BACKLIGHT_PIN EXP1_08_PIN + + #define LCD_BACKLIGHT_PIN EXP1_08_PIN + #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 - #define LCD_BACKLIGHT_PIN EXP1_08_PIN #ifndef TFT_WIDTH #define TFT_WIDTH 480 #endif @@ -339,17 +340,21 @@ // 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 PD11 - #define DOGLCD_CS EXP1_04_PIN - //#define DOGLCD_SCK EXP2_09_PIN - //#define DOGLCD_MOSI EXP2_05_PIN + + #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 #elif ENABLED(FYSETC_MINI_12864_2_1) + + #define LCD_PINS_DC EXP1_07_PIN #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define LCD_PINS_DC DOGLCD_A0 + #define DOGLCD_A0 LCD_PINS_DC #define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN EXP1_06_PIN #define NEOPIXEL_PIN EXP1_05_PIN @@ -358,7 +363,7 @@ #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif - //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #else 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 bbf162bb0d98..989010e47f36 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 @@ -36,7 +36,7 @@ //#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation #if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) #define I2C_EEPROM - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #define I2C_SCL_PIN PB6 #define I2C_SDA_PIN PB7 #endif @@ -119,6 +119,14 @@ #define TEMP_1_PIN PA2 // TH2 #define TEMP_BED_PIN PC0 // TB1 +#if HOTENDS == 1 && !REDUNDANT_TEMP_MATCH(SOURCE, E1) + #if TEMP_SENSOR_PROBE + #define TEMP_PROBE_PIN TEMP_1_PIN + #elif TEMP_SENSOR_CHAMBER + #define TEMP_CHAMBER_PIN TEMP_1_PIN + #endif +#endif + // // Heaters / Fans // @@ -165,7 +173,9 @@ // #if ENABLED(MKS_PWC) #if ENABLED(TFT_LVGL_UI) - #undef PSU_CONTROL + #if ENABLED(PSU_CONTROL) + #error "PSU_CONTROL is incompatible with MKS_PWC plus TFT_LVGL_UI." + #endif #undef MKS_PWC #define SUICIDE_PIN PB2 #define SUICIDE_PIN_STATE LOW @@ -273,16 +283,16 @@ #define TFT_MISO_PIN EXP2_10_PIN #define TFT_MOSI_PIN EXP2_05_PIN #define TFT_DC_PIN EXP1_03_PIN - #define TFT_RST_PIN EXP1_07_PIN #define TFT_A0_PIN TFT_DC_PIN #define TFT_RESET_PIN EXP1_07_PIN - #define TFT_BACKLIGHT_PIN EXP1_08_PIN + + #define LCD_BACKLIGHT_PIN EXP1_08_PIN + #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 - #define LCD_BACKLIGHT_PIN EXP1_08_PIN #ifndef TFT_WIDTH #define TFT_WIDTH 480 #endif @@ -336,9 +346,9 @@ //#undef SHOW_BOOTSCREEN #elif ENABLED(FYSETC_MINI_12864_2_1) + #define LCD_PINS_DC EXP1_07_PIN #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN - #define LCD_PINS_DC DOGLCD_A0 + #define DOGLCD_A0 LCD_PINS_DC #define LCD_BACKLIGHT_PIN -1 #define LCD_RESET_PIN EXP1_06_PIN #define NEOPIXEL_PIN EXP1_05_PIN @@ -347,7 +357,7 @@ #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif - //#define LCD_SCREEN_ROT_180 + //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 #else // !MKS_MINI_12864 @@ -366,9 +376,16 @@ #endif // HAS_WIRED_LCD +#if HAS_TFT_LVGL_UI + // Enable SPI DMA, this requires button pins, thus no buttons. Default is DISABLED. + //#define USE_SPI_DMA_TC +#endif + #if ANY(TFT_COLOR_UI, TFT_LVGL_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 + #if DISABLED(USE_SPI_DMA_TC) + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_06_PIN + #define BTN_ENC EXP1_09_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 68b238525477..ff020f9c9c5a 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h @@ -37,7 +37,7 @@ //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation //#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation #define I2C_EEPROM -#define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#define MARLIN_EEPROM_SIZE 0x1000 // 4K #define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support @@ -305,16 +305,15 @@ #define TFT_MISO_PIN EXP2_10_PIN #define TFT_MOSI_PIN EXP2_05_PIN #define TFT_DC_PIN EXP1_03_PIN - #define TFT_RST_PIN EXP1_07_PIN #define TFT_A0_PIN TFT_DC_PIN #define TFT_RESET_PIN EXP1_07_PIN - #define TFT_BACKLIGHT_PIN EXP1_08_PIN + #define LCD_BACKLIGHT_PIN EXP1_08_PIN + #define TFT_BACKLIGHT_PIN LCD_BACKLIGHT_PIN #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 1 - #define LCD_BACKLIGHT_PIN EXP1_08_PIN #ifndef TFT_WIDTH #define TFT_WIDTH 480 #endif diff --git a/Marlin/src/pins/stm32f4/pins_RUMBA32_AUS3D.h b/Marlin/src/pins/stm32f4/pins_RUMBA32_AUS3D.h index f2073457b13b..e926a2b0c6a4 100644 --- a/Marlin/src/pins/stm32f4/pins_RUMBA32_AUS3D.h +++ b/Marlin/src/pins/stm32f4/pins_RUMBA32_AUS3D.h @@ -33,10 +33,10 @@ #if NO_EEPROM_SELECTED #if MB(RUMBA32_V1_0) #define FLASH_EEPROM_EMULATION - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #elif MB(RUMBA32_V1_1) #define I2C_EEPROM - #define MARLIN_EEPROM_SIZE 0x2000 // 8KB (24LC64T-I/OT) + #define MARLIN_EEPROM_SIZE 0x2000 // 8K (24LC64T-I/OT) #endif #endif diff --git a/Marlin/src/pins/stm32f4/pins_RUMBA32_BTT.h b/Marlin/src/pins/stm32f4/pins_RUMBA32_BTT.h index 28d2dfd1806f..2f3e121fe17a 100644 --- a/Marlin/src/pins/stm32f4/pins_RUMBA32_BTT.h +++ b/Marlin/src/pins/stm32f4/pins_RUMBA32_BTT.h @@ -30,7 +30,7 @@ #if NO_EEPROM_SELECTED #define I2C_EEPROM - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB (24LC32AT-I/OT) + #define MARLIN_EEPROM_SIZE 0x1000 // 4K (24LC32AT-I/OT) #endif #if ENABLED(FLASH_EEPROM_EMULATION) diff --git a/Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h b/Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h index 0b539417d6d0..3833a3a007a9 100644 --- a/Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h +++ b/Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h @@ -37,7 +37,7 @@ #if NO_EEPROM_SELECTED #define FLASH_EEPROM_EMULATION - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif #if ENABLED(FLASH_EEPROM_EMULATION) diff --git a/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h b/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h index cf7c9ed8a681..873a4d4ad382 100644 --- a/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h +++ b/Marlin/src/pins/stm32f4/pins_RUMBA32_common.h @@ -35,7 +35,7 @@ // Use soft PWM for fans - PWM is not working properly when paired with STM32 Arduino Core v1.7.0 // This can be removed when Core version is updated and PWM behaviour is fixed. -#define FAN_SOFT_PWM +#define FAN_SOFT_PWM_REQUIRED // // Configure Timers diff --git a/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h b/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h index 7ccb57e2387b..0b527a6fdb78 100644 --- a/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h +++ b/Marlin/src/pins/stm32f4/pins_STEVAL_3DP001V1.h @@ -48,82 +48,82 @@ // // Limit Switches // -#define X_MIN_PIN 39 // PD8 X_STOP -#define Y_MIN_PIN 40 // PD9 Y_STOP -#define Z_MIN_PIN 41 // PD10 Z_STOP +#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 44 // PD0 W_STOP -#define Y_MAX_PIN 43 // PA8 V_STOP -#define Z_MAX_PIN 42 // PD11 U_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 16 // PA4 +// #define Z_MIN_PROBE_PIN PA4 // SPI1_CS //#endif // // Filament runout // -//#define FIL_RUNOUT_PIN 53 // PA3 BED_THE +//#define FIL_RUNOUT_PIN PA3 // BED_THERMISTOR_3 // // Steppers // -#define X_STEP_PIN 61 // PE14 X_PWM -#define X_DIR_PIN 62 // PE15 X_DIR -#define X_ENABLE_PIN 60 // PE13 X_RES -#define X_CS_PIN 16 // PA4 SPI_CS +#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 64 // PB10 Y_PWM -#define Y_DIR_PIN 65 // PE9 Y_DIR -#define Y_ENABLE_PIN 63 // PE10 Y_RES -#define Y_CS_PIN 16 // PA4 SPI_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 67 // PC6 Z_PWM -#define Z_DIR_PIN 68 // PC0 Z_DIR -#define Z_ENABLE_PIN 66 // PC15 Z_RES -#define Z_CS_PIN 16 // PA4 SPI_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 71 // PD12 E1_PW -#define E0_DIR_PIN 70 // PC13 E1_DIR -#define E0_ENABLE_PIN 69 // PC14 E1_RE -#define E0_CS_PIN 16 // PA4 SPI_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 73 // PE5 E2_PWM -#define E1_DIR_PIN 74 // PE6 E2_DIR -#define E1_ENABLE_PIN 72 // PE4 E2_RESE -#define E1_CS_PIN 16 // PA4 SPI_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 77 // PB8 E3_PWM -#define E2_DIR_PIN 76 // PE2 E3_DIR -#define E2_ENABLE_PIN 75 // PE3 E3_RESE -#define E2_CS_PIN 16 // PA4 SPI_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 16 // PA4 SPI_CS -#define Y2_CS_PIN 16 // PA4 SPI_CS -#define Z2_CS_PIN 16 // PA4 SPI_CS -#define Z3_CS_PIN 16 // PA4 SPI_CS -#define E3_CS_PIN 16 // PA4 SPI_CS -#define E4_CS_PIN 16 // PA4 SPI_CS -#define E5_CS_PIN 16 // PA4 SPI_CS +#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 17 // PA5 - #define L6470_CHAIN_MISO_PIN 18 // PA6 - #define L6470_CHAIN_MOSI_PIN 19 // PA7 - #define L6470_CHAIN_SS_PIN 16 // PA4 + #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 13 // PB13 SPI_S - //#define SD_MISO_PIN 12 // PB14 SPI_M - //#define SD_MOSI_PIN 11 // PB15 SPI_M + //#define SD_SCK_PIN PB13 // SPI2_SCK + //#define SD_MISO_PIN PB14 // SPI2_MISO + //#define SD_MOSI_PIN PB15 // SPI2_MOSI #endif /** @@ -144,215 +144,182 @@ // // Temperature Sensors // -#define TEMP_0_PIN 3 // Analog input 3, digital pin 54 PA0 E1_THERMISTOR -#define TEMP_1_PIN 4 // Analog input 4, digital pin 55 PA1 E2_THERMISTOR -#define TEMP_2_PIN 5 // Analog input 5, digital pin 56 PA2 E3_THERMISTOR -#define TEMP_BED_PIN 0 // Analog input 0, digital pin 51 PC2 BED_THERMISTOR_1 -#define TEMP_BED_1_PIN 1 // Analog input 1, digital pin 52 PC3 BED_THERMISTOR_2 -#define TEMP_BED_2_PIN 2 // Analog input 2, digital pin 53 PA3 BED_THERMISTOR_3 +#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 48 // PC7 E1_HEAT_PWM -#define HEATER_1_PIN 49 // PB0 E2_HEAT_PWM -#define HEATER_2_PIN 50 // PB1 E3_HEAT_PWM -#define HEATER_BED_PIN 46 // PD14 (BED_HEAT_1 FET -#define HEATER_BED_1_PIN 45 // PD13 (BED_HEAT_2 FET -#define HEATER_BED_2_PIN 47 // PD15 (BED_HEAT_3 FET +#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 57 // PC4 E1_FAN PWM pin, Part cooling fan FET -#define FAN1_PIN 58 // PC5 E2_FAN PWM pin, Extruder fan FET -#define FAN2_PIN 59 // PE8 E3_FAN PWM pin, Controller fan 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 58 // FAN1_PIN + #define E0_AUTO_FAN_PIN PC5 // FAN1_PIN #endif // // Misc functions // -#define LED_PIN -1 // 9 // PE1 green LED Heart beat -#define PS_ON_PIN -1 -#define KILL_PIN -1 -#define POWER_LOSS_PIN -1 // PWR_LOSS / nAC_FAULT +#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 66 // PA15 SD_CA -//#define BEEPER_PIN 24 // PC9 SDIO_D1 -//#define LCD_PINS_RS 65 // PE9 Y_DIR -//#define LCD_PINS_ENABLE 59 // PE8 E3_FAN -//#define LCD_PINS_D4 10 // PB12 SPI_C -//#define LCD_PINS_D5 13 // PB13 SPI_S -//#define LCD_PINS_D6 12 // PB14 SPI_M -//#define LCD_PINS_D7 11 // PB15 SPI_M -//#define BTN_EN1 57 // PC4 E1_FAN -//#define BTN_EN2 58 // PC5 E2_FAN -//#define BTN_ENC 52 // PC3 BED_THE +//#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 49 // PB0 E2_HEAT -//#define EXT1_PIN 50 // PB1 E3_HEAT -//#define EXT2_PIN // PB2 not used (tied to ground -//#define EXT3_PIN 39 // PD8 X_STOP -//#define EXT4_PIN 40 // PD9 Y_STOP -//#define EXT5_PIN 41 // PD10 Z_STOP -//#define EXT6_PIN 42 // PD11 -//#define EXT7_PIN 71 // PD12 E1_PW -//#define EXT8_PIN 64 // PB10 Y_PWM +//#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 -// 2 // PD3 CTS -// 3 // PD4 RTS -// 4 // PD5 TX -// 5 // PD6 RX -// 6 // PB5 WIFI_WAKEUP -// 7 // PE11 WIFI_RESET -// 8 // PE12 WIFI_BOOT +// PD3 CTS +// PD4 RTS +// PD5 TX +// PD6 RX +// PB5 WIFI_WAKEUP +// PE11 WIFI_RESET +// PE12 WIFI_BOOT // I2C USER -// 14 // PB7 SDA -// 15 // PB6 SCL +// PB7 SDA +// PB6 SCL // JTAG -// 20 // PA13 JTAG_TMS/SWDIO -// 21 // PA14 JTAG_TCK/SWCLK -// 22 // PB3 JTAG_TDO/SWO +// PA13 JTAG_TMS/SWDIO +// PA14 JTAG_TCK/SWCLK +// PB3 JTAG_TDO/SWO // // Onboard SD support // -#define SDIO_D0_PIN 23 // PC8 SDIO_D0 -#define SDIO_D1_PIN 24 // PC9 SDIO_D1 -//#define SD_CARD_DETECT_PIN 25 // PA15 SD_CARD_DETECT -#define SDIO_D2_PIN 26 // PC10 SDIO_D2 -#define SDIO_D3_PIN 27 // PC11 SDIO_D3 -#define SDIO_CK_PIN 28 // PC12 SDIO_CK -#define SDIO_CMD_PIN 29 // PD2 SDIO_CMD - #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION ONBOARD #endif #if SD_CONNECTION_IS(ONBOARD) - #define SDIO_SUPPORT // Use SDIO for onboard SD - #ifndef SDIO_SUPPORT + #define SDIO_SUPPORT // Use SDIO for onboard SD + #if DISABLED(SDIO_SUPPORT) #define SOFTWARE_SPI // Use soft SPI for onboard SD - #define SDSS SDIO_D3_PIN - #define SD_SCK_PIN SDIO_CK_PIN - #define SD_MISO_PIN SDIO_D0_PIN - #define SD_MOSI_PIN SDIO_CMD_PIN + #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 16 // PA4 SPI_CS + #define SDSS PA4 // SPI1_CS #endif // OTG -// 30 // PA11 OTG_DM -// 31 // PA12 OTG_DP +// PA11 OTG_DM +// PA12 OTG_DP // USER_PINS -// 34 // PD7 USER3 -// 35 // PB9 USER1 -// 36 // PE0 USER2 -// 37 // PB4 USER4 +// PD7 USER3 +// PB9 USER1 +// PE0 USER2 +// PB4 USER4 // USERKET -// 38 // PE7 USER_BUTTON +// PE7 USER_BUTTON -// 0 // PA9 TX -// 1 // PA10 RX +// PA9 TX +// PA10 RX // IR/PROBE -// 32 // PD1 IR_OUT -// 33 // PC1 IR_ON +// PD1 IR_OUT +// PC1 IR_ON /** * Logical pin vs. port/pin cross reference * - * PA0 54 // E1_THERMISTOR PA9 0 // TX - * PA1 55 // E2_THERMISTOR PA10 1 // RX - * PA2 56 // E3_THERMISTOR PD3 2 // CTS - * PA3 53 // BED_THERMISTOR_3 PD4 3 // RTS - * PA4 16 // SPI_CS PD5 4 // TX - * PA5 17 // SPI_SCK PD6 5 // RX - * PA6 18 // SPI_MISO PB5 6 // WIFI_WAKEUP - * PA7 19 // SPI_MOSI PE11 7 // WIFI_RESET - * PA8 43 // V_STOP PE12 8 // WIFI_BOOT - * PA9 0 // TX PE1 9 // STATUS_LED - * PA10 1 // RX PB12 10 // SPI_CS - * PA11 30 // OTG_DM PB15 11 // SPI_MOSI - * PA12 31 // OTG_DP PB14 12 // SPI_MISO - * PA13 20 // JTAG_TMS/SWDIO PB13 13 // SPI_SCK - * PA14 21 // JTAG_TCK/SWCLK PB7 14 // SDA - * PA15 25 // SD_CARD_DETECT PB6 15 // SCL - * PB0 49 // E2_HEAT_PWM PA4 16 // SPI_CS - * PB1 50 // E3_HEAT_PWM PA5 17 // SPI_SCK - * PB3 22 // JTAG_TDO/SWO PA6 18 // SPI_MISO - * PB4 37 // USER4 PA7 19 // SPI_MOSI - * PB5 6 // WIFI_WAKEUP PA13 20 // JTAG_TMS/SWDIO - * PB6 15 // SCL PA14 21 // JTAG_TCK/SWCLK - * PB7 14 // SDA PB3 22 // JTAG_TDO/SWO - * PB8 77 // E3_PWM PC8 23 // SDIO_D0 - * PB9 35 // USER1 PC9 24 // SDIO_D1 - * PB10 64 // Y_PWM PA15 25 // SD_CARD_DETECT - * PB12 10 // SPI_CS PC10 26 // SDIO_D2 - * PB13 13 // SPI_SCK PC11 27 // SDIO_D3 - * PB14 12 // SPI_MISO PC12 28 // SDIO_CK - * PB15 11 // SPI_MOSI PD2 29 // SDIO_CMD - * PC0 68 // Z_DIR PA11 30 // OTG_DM - * PC1 33 // IR_ON PA12 31 // OTG_DP - * PC2 51 // BED_THERMISTOR_1 PD1 32 // IR_OUT - * PC3 52 // BED_THERMISTOR_2 PC1 33 // IR_ON - * PC4 57 // E1_FAN PD7 34 // USER3 - * PC5 58 // E2_FAN PB9 35 // USER1 - * PC6 67 // Z_PWM PE0 36 // USER2 - * PC7 48 // E1_HEAT_PWM PB4 37 // USER4 - * PC8 23 // SDIO_D0 PE7 38 // USER_BUTTON - * PC9 24 // SDIO_D1 PD8 39 // X_STOP - * PC10 26 // SDIO_D2 PD9 40 // Y_STOP - * PC11 27 // SDIO_D3 PD10 41 // Z_STOP - * PC12 28 // SDIO_CK PD11 42 // U_STOP - * PC13 70 // E1_DIR PA8 43 // V_STOP - * PC14 69 // E1_RESET PD0 44 // W_STOP - * PC15 66 // Z_RESET PD13 45 // BED_HEAT_2 - * PD0 44 // W_STOP PD14 46 // BED_HEAT_1 - * PD1 32 // IR_OUT PD15 47 // BED_HEAT_3 - * PD2 29 // SDIO_CMD PC7 48 // E1_HEAT_PWM - * PD3 2 // CTS PB0 49 // E2_HEAT_PWM - * PD4 3 // RTS PB1 50 // E3_HEAT_PWM - * PD5 4 // TX PC2 51 // BED_THERMISTOR_1 - * PD6 5 // RX PC3 52 // BED_THERMISTOR_2 - * PD7 34 // USER3 PA3 53 // BED_THERMISTOR_3 - * PD8 39 // X_STOP PA0 54 // E1_THERMISTOR - * PD9 40 // Y_STOP PA1 55 // E2_THERMISTOR - * PD10 41 // Z_STOP PA2 56 // E3_THERMISTOR - * PD11 42 // U_STOP PC4 57 // E1_FAN - * PD12 71 // E1_PWM PC5 58 // E2_FAN - * PD13 45 // BED_HEAT_2 PE8 59 // E3_FAN - * PD14 46 // BED_HEAT_1 PE13 60 // X_RESET - * PD15 47 // BED_HEAT_3 PE14 61 // X_PWM - * PE0 36 // USER2 PE15 62 // X_DIR - * PE1 9 // STATUS_LED PE10 63 // Y_RESET - * PE2 76 // E3_DIR PB10 64 // Y_PWM - * PE3 75 // E3_RESET PE9 65 // Y_DIR - * PE4 72 // E2_RESET PC15 66 // Z_RESET - * PE5 73 // E2_PWM PC6 67 // Z_PWM - * PE6 74 // E2_DIR PC0 68 // Z_DIR - * PE7 38 // USER_BUTTON PC14 69 // E1_RESET - * PE8 59 // E3_FAN PC13 70 // E1_DIR - * PE9 65 // Y_DIR PD12 71 // E1_PWM - * PE10 63 // Y_RESET PE4 72 // E2_RESET - * PE11 7 // WIFI_RESET PE5 73 // E2_PWM - * PE12 8 // WIFI_BOOT PE6 74 // E2_DIR - * PE13 60 // X_RESET PE3 75 // E3_RESET - * PE14 61 // X_PWM PE2 76 // E3_DIR - * PE15 62 // X_DIR PB8 77 // E3_PWM + * 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 6368142c3427..1439e6de651c 100644 --- a/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h +++ b/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h @@ -34,7 +34,7 @@ // Onboard I2C EEPROM #if NO_EEPROM_SELECTED #define I2C_EEPROM - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #define I2C_SCL_PIN PB6 #define I2C_SDA_PIN PB7 #undef NO_EEPROM_SELECTED @@ -130,6 +130,20 @@ // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 + + // Default TMC slave addresses + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 1 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 2 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif #endif // @@ -184,12 +198,12 @@ // /** - * ______ - * 5V | 1 2 | GND - * PB15 | 3 4 | PB12 - * PB13 | 5 6 PC5 - * ---- | 7 8 | PC4 - * PB0 | 9 10 | PA14 + * ------ + * PA14 |10 9 | PB0 + * PC4 | 8 7 | -- + * PC5 | 6 5 PB13 + * PB12 | 4 3 | PB15 + * GND | 2 1 | 5V * ------ * EXP1 * @@ -209,12 +223,12 @@ #define EXP1_10_PIN PA14 #if ENABLED(CR10_STOCKDISPLAY) - /** ______ - * 5V | 1 2 | GND - * LCD_EN | 3 4 | LCD_RS - * LCD_D4 | 5 6 EN2 - * RESET | 7 8 | EN1 - * ENC | 9 10 | BEEPER + /** ------ + * BEEPER |10 9 | ENC + * EN1 | 8 7 | RESET + * EN2 | 6 5 LCD_D4 + * LCD_RS | 4 3 | LCD_EN + * GND | 2 1 | 5V * ------ */ #ifdef DISABLE_JTAGSWD @@ -230,12 +244,12 @@ #define BOARD_ST7920_DELAY_3 750 #elif ENABLED(MKS_MINI_12864) - /** ______ - * 5V | 1 2 | GND - * SPI-MOSI | 3 4 | SPI-CS - * A0 | 5 6 EN2 - * -- | 7 8 | EN1 - * ENC | 9 10 | SPI-SCK + /** ------ + * SCK |10 9 | ENC + * EN1 | 8 7 | -- + * EN2 | 6 5 A0 + * CS | 4 3 | MOSI + * GND | 2 1 | 5V * ------ */ #define DOGLCD_CS EXP1_04_PIN diff --git a/Marlin/src/pins/stm32f4/pins_VAKE403D.h b/Marlin/src/pins/stm32f4/pins_VAKE403D.h index bb5507b29a06..089231e3aa51 100644 --- a/Marlin/src/pins/stm32f4/pins_VAKE403D.h +++ b/Marlin/src/pins/stm32f4/pins_VAKE403D.h @@ -32,7 +32,7 @@ #define BOARD_INFO_NAME "STM32F4 VAkE" //#define I2C_EEPROM -#define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#define MARLIN_EEPROM_SIZE 0x1000 // 4K // // Servos @@ -150,8 +150,10 @@ // // Průša i3 MK2 Multi Material Multiplexer Support // -//#define E_MUX0_PIN PG3 -//#define E_MUX1_PIN PG4 +#if HAS_PRUSA_MMU1 + //#define E_MUX0_PIN PG3 + //#define E_MUX1_PIN PG4 +#endif #define LED_PIN PB14 // Alive #define PS_ON_PIN PE0 @@ -159,27 +161,61 @@ #define POWER_LOSS_PIN PA4 // ?? Power loss / nAC_FAULT #if ENABLED(SDSUPPORT) - #define SD_DETECT_PIN PB7 - #define SD_SS_PIN PB_15 // USD_CS -> CS for onboard SD + #define SD_DETECT_PIN EXP2_04_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 + * ------ ------ + * 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 ? + // // LCD / Controller // #if HAS_WIRED_LCD + #if ENABLED(SDSUPPORT) #define SDSS PB6 // CS for SD card in LCD #endif - #define BEEPER_PIN PC9 - #define LCD_PINS_RS PC12 - #define LCD_PINS_ENABLE PD7 - #define LCD_PINS_D4 PD1 - #define LCD_PINS_D5 PD2 - #define LCD_PINS_D6 PD3 - #define LCD_PINS_D7 PD4 - #define BTN_EN1 PD6 - #define BTN_EN2 PD0 - #define BTN_ENC PB12 + + #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 LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_RS EXP1_07_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 + #endif // Alter timing for graphical display diff --git a/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h b/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h index 75c7217163b8..48f986e2ca70 100644 --- a/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h +++ b/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h @@ -69,7 +69,7 @@ * (X_DIR) PB15 | · · | PB9 (X_CS) * (LCD_D4) PB13 | · · | AVDD * _CN8_ PB12 | · · | GND - * NC | · · | PC8 (HEATER_0) PA15 | · · | PA5 (SCLK) + * -- | · · | PC8 (HEATER_0) PA15 | · · | PA5 (SCLK) * IOREF | · · | PC9 (BEEPER) PC7 | · · | PA6 (MISO) * RESET | · · | PC10 (SERVO1_PIN) PB5 | · · | PA7 (MOSI) * +3.3V | · · | PC11 (HEATER_BED) PB3 | · · | PD14 (SD_DETECT) @@ -86,7 +86,7 @@ * PF3 | · · | PD4 PF4 | · · | PF15 * PF5 | · · | PD3 (E_STEP) PB6 | · · | PG14 (E_EN) * PF10 | · · | GND (E_DIR) PB2 | · · | PG9 (E_CS) - * NC | · · | PE2 GND | · · | PE8 + * -- | · · | PE2 GND | · · | PE8 * PA7 | · · | PE4 PD13 | · · | PE7 * PF2 | · · | PE5 PD12 | · · | GND * (Y_STEP) PF1 | · · | PE6 (Y_EN) (Z_STEP) PD11 | · · | PE10 (Z_EN) diff --git a/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h b/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h index 486c10e71164..5bfc2551acfa 100644 --- a/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h +++ b/Marlin/src/pins/stm32f7/pins_REMRAM_V1.h @@ -44,14 +44,13 @@ #define X_MAX_PIN 59 #define Y_MIN_PIN 60 #define Y_MAX_PIN 61 - #define Z_MIN_PIN 62 #define Z_MAX_PIN 63 #else #define X_STOP_PIN 36 #define Y_STOP_PIN 39 - #define Z_MIN_PIN 62 #define Z_MAX_PIN 42 #endif +#define Z_MIN_PIN 62 // // Z Probe (when not Z_MIN_PIN) 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 cec1a838fc93..4fc3504ed1c9 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 @@ -41,7 +41,7 @@ #define SOFT_I2C_EEPROM // Force the use of Software I2C #define I2C_SCL_PIN PB6 #define I2C_SDA_PIN PB7 - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // @@ -144,28 +144,28 @@ /** * SKR Mini E3 V3.0 - * ------ - * 5V | 1 2 | GND - * (LCD_EN) PD6 | 3 4 | PB8 (LCD_RS) - * (LCD_D4) PB9 | 5 6 PA10 (BTN_EN2) - * RESET | 7 8 | PA9 (BTN_EN1) - * (BTN_ENC) PA15 | 9 10 | PB5 (BEEPER) - * ------ - * EXP1 + * ------ + * (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 + * ------ + * EXP1 */ #define EXP1_09_PIN PA15 #define EXP1_03_PIN PD6 -#if EITHER(DWIN_CREALITY_LCD, IS_DWIN_MARLINUI) +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI /** - * ------ ------ ------ - * VCC | 1 2 | GND VCC | 1 2 | GND GND | 2 1 | VCC - * A | 3 4 | B A | 3 4 | B B | 4 3 | A - * | 5 6 TX BEEP | 5 6 ENT ENT | 6 5 | BEEP - * | 7 8 | RX TX | 7 8 | RX RX | 8 7 | TX - * BEEP | 9 10 | ENT | 9 10 | | 10 9 | - * ------ ------ ------ - * EXP1 DWIN DWIN (plug) + * ------ ------ ------ + * (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 + * ------ ------ ------ + * EXP1 DWIN DWIN (plug) * * All pins are labeled as printed on DWIN PCB. Connect TX-TX, A-A and so on. */ @@ -226,15 +226,15 @@ /** * TFTGLCD_PANEL_SPI display pinout * - * Board Display - * ------ ------ - * 5V | 1 2 | GND (SPI1-MISO) MISO | 1 2 | SCK (SPI1-SCK) - * (FREE) PB7 | 3 4 | PB8 (LCD_CS) (PA9) LCD_CS | 3 4 | SD_CS (PA10) - * (FREE) PB9 | 5 6 | PA10 (SD_CS) (FREE) | 5 6 | MOSI (SPI1-MOSI) - * RESET | 7 8 | PA9 (MOD_RESET) (PB5) SD_DET | 7 8 | (FREE) - * (BEEPER) PB6 | 9 10 | PB5 (SD_DET) GND | 9 10 | 5V - * ------ ------ - * EXP1 EXP1 + * 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: * @@ -256,8 +256,51 @@ #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + + #error "CAUTION! FYSETC_MINI_12864_2_1 and clones require wiring modifications. See 'pins_BTT_SKR_MINI_E3_V3_0.h' for details. Comment out this line to continue." + + /** + * + * 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 | -- + * ------ ------ + * EXP1 EXP1 + * + * ------ + * -- |10 9 | -- + * --- (RESET) | 8 7 | -- + * | 3 | (MOSI) | 6 5#| (EN2) + * | 2 | (DIN) -- | 4 3 | (EN1) + * | 1 | (LCD_SCK)| 2 1 | -- + * --- ------ + * Neopixel EXP2 + * + * Needs custom cable. Connect EN2-EN2, LCD_CS-LCD_CS and so on. + * + * Check twice index position!!! (marked as # here) + * 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 DOGLCD_CS PA9 + #define DOGLCD_A0 PA10 + #define DOGLCD_SCK PB8 + #define DOGLCD_MOSI PD6 + + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + #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." + #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 // HAS_WIRED_LCD @@ -269,15 +312,15 @@ /** * 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) (PB5) SD_DET | 7 8 | RESET - * (BEEPER) PB6 | 9 10 | PB5 (SD_DET) GND | 9 10 | 5V - * ------ ------ - * EXP1 EXP1 + * 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) + * ------ ------ + * EXP1 EXP1 * * Needs custom cable: * diff --git a/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h index 9eb0acf1448d..5a772eb21b09 100644 --- a/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_SE_BX.h @@ -30,7 +30,7 @@ // Onboard I2C EEPROM #define I2C_EEPROM -#define MARLIN_EEPROM_SIZE 0x1000 // 4KB (24C32 ... 32Kb = 4KB) +#define MARLIN_EEPROM_SIZE 0x1000 // 4K (24C32) #define HAS_OTG_USB_HOST_SUPPORT // USB Flash Drive support @@ -50,8 +50,6 @@ #define LED_PIN PA13 #define BEEPER_PIN PA14 -#define TFT_BACKLIGHT_PIN PB5 - #define POWER_MONITOR_PIN PB0 #define RPI_POWER_PIN PE5 diff --git a/Marlin/src/HAL/LINUX/watchdog.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0.h similarity index 85% rename from Marlin/src/HAL/LINUX/watchdog.h rename to Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0.h index 49a0d9c631d8..d83548608585 100644 --- a/Marlin/src/HAL/LINUX/watchdog.h +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0.h @@ -1,6 +1,6 @@ /** * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 @@ -21,5 +21,6 @@ */ #pragma once -void watchdog_init(); -void HAL_watchdog_refresh(); +#define BOARD_INFO_NAME "BTT SKR V3" + +#include "pins_BTT_SKR_V3_0_common.h" diff --git a/Marlin/src/HAL/STM32/watchdog.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_EZ.h similarity index 85% rename from Marlin/src/HAL/STM32/watchdog.h rename to Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_EZ.h index 49a0d9c631d8..003f20f5cf6e 100644 --- a/Marlin/src/HAL/STM32/watchdog.h +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_EZ.h @@ -1,6 +1,6 @@ /** * Marlin 3D Printer Firmware - * Copyright (c) 2020 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 @@ -21,5 +21,6 @@ */ #pragma once -void watchdog_init(); -void HAL_watchdog_refresh(); +#define BOARD_INFO_NAME "BTT SKR V3 EZ" + +#include "pins_BTT_SKR_V3_0_common.h" 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 new file mode 100644 index 000000000000..02e195a1852e --- /dev/null +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h @@ -0,0 +1,569 @@ +/** + * 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 + +#if NOT_TARGET(STM32H7) + #error "Oops! Select an STM32H7 board in 'Tools > Board.'" +#endif + +// If you have the BigTreeTech driver expansion module, enable BTT_MOTOR_EXPANSION +// https://github.com/bigtreetech/BTT-Expansion-module/tree/master/BTT%20EXP-MOT +//#define BTT_MOTOR_EXPANSION + +#if BOTH(HAS_WIRED_LCD, BTT_MOTOR_EXPANSION) + #if EITHER(CR10_STOCKDISPLAY, ENDER2_STOCKDISPLAY) + #define EXP_MOT_USE_EXP2_ONLY 1 + #else + #error "You can't use both an LCD and a Motor Expansion Module on EXP1/EXP2 at the same time." + #endif +#endif + +#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 PA14 + #define I2C_SDA_PIN PA13 + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#endif + +// +// Servos +// +#define SERVO0_PIN PE5 + +// +// Trinamic Stallguard pins +// +#define X_DIAG_PIN PC1 // X-STOP +#define Y_DIAG_PIN PC3 // Y-STOP +#define Z_DIAG_PIN PC0 // Z-STOP +#define E0_DIAG_PIN PC2 // E0DET +#define E1_DIAG_PIN PA0 // E1DET + +// +// Limit Switches +// +#ifdef X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN + #if X_HOME_TO_MIN + #define X_MAX_PIN PC2 // E0DET + #else + #define X_MIN_PIN PC2 // E0DET + #endif +#elif ENABLED(X_DUAL_ENDSTOPS) + #ifndef X_MIN_PIN + #define X_MIN_PIN PC1 // X-STOP + #endif + #ifndef X_MAX_PIN + #define X_MAX_PIN PC2 // E0DET + #endif +#else + #define X_STOP_PIN PC1 // X-STOP +#endif + +#ifdef Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN + #if Y_HOME_TO_MIN + #define Y_MAX_PIN PA0 // E1DET + #else + #define Y_MIN_PIN PA0 // E1DET + #endif +#elif ENABLED(Y_DUAL_ENDSTOPS) + #ifndef Y_MIN_PIN + #define Y_MIN_PIN PC3 // Y-STOP + #endif + #ifndef Y_MAX_PIN + #define Y_MAX_PIN PA0 // E1DET + #endif +#else + #define Y_STOP_PIN PC3 // Y-STOP +#endif + +#ifdef Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN + #if Z_HOME_TO_MIN + #define Z_MAX_PIN PC15 // PWRDET + #else + #define Z_MIN_PIN PC15 // PWRDET + #endif +#elif ENABLED(Z_MULTI_ENDSTOPS) + #ifndef Z_MIN_PIN + #define Z_MIN_PIN PC0 // Z-STOP + #endif + #ifndef Z_MAX_PIN + #define Z_MAX_PIN PC15 // PWRDET + #endif +#else + #ifndef Z_STOP_PIN + #define Z_STOP_PIN PC0 // Z-STOP + #endif +#endif + +// +// Z Probe (when not Z_MIN_PIN) +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PC13 +#endif + +// +// Probe enable +// +#if ENABLED(PROBE_ENABLE_DISABLE) + #ifndef PROBE_ENABLE_PIN + #define PROBE_ENABLE_PIN SERVO0_PIN + #endif +#endif + +// +// Filament Runout Sensor +// +#define FIL_RUNOUT_PIN PC2 // E0DET +#define FIL_RUNOUT2_PIN PA0 // E1DET + +// +// Power Supply Control +// +#ifndef PS_ON_PIN + #define PS_ON_PIN PE4 // PS-ON +#endif + +// +// Power Loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PC15 // PWRDET +#endif + +// +// Steppers +// +#define X_STEP_PIN PD4 +#define X_DIR_PIN PD3 +#define X_ENABLE_PIN PD6 +#ifndef X_CS_PIN + #define X_CS_PIN PD5 +#endif + +#define Y_STEP_PIN PA15 +#define Y_DIR_PIN PA8 +#define Y_ENABLE_PIN PD1 +#ifndef Y_CS_PIN + #define Y_CS_PIN PD0 +#endif + +#define Z_STEP_PIN PE2 +#define Z_DIR_PIN PE3 +#define Z_ENABLE_PIN PE0 +#ifndef Z_CS_PIN + #define Z_CS_PIN PE1 +#endif + +#ifndef E0_STEP_PIN + #define E0_STEP_PIN PD15 +#endif +#ifndef E0_DIR_PIN + #define E0_DIR_PIN PD14 +#endif +#ifndef E0_ENABLE_PIN + #define E0_ENABLE_PIN PC7 +#endif +#ifndef E0_CS_PIN + #define E0_CS_PIN PC6 +#endif + +#ifndef E1_STEP_PIN + #define E1_STEP_PIN PD11 +#endif +#ifndef E1_DIR_PIN + #define E1_DIR_PIN PD10 +#endif +#ifndef E1_ENABLE_PIN + #define E1_ENABLE_PIN PD13 +#endif +#ifndef E1_CS_PIN + #define E1_CS_PIN PD12 +#endif + +// +// Temperature Sensors +// +#ifndef TEMP_0_PIN + #define TEMP_0_PIN PA2 // TH0 +#endif +#ifndef TEMP_1_PIN + #define TEMP_1_PIN PA3 // TH1 +#endif +#ifndef TEMP_BED_PIN + #define TEMP_BED_PIN PA1 // TB +#endif + +#if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) + #if TEMP_SENSOR_PROBE + #define TEMP_PROBE_PIN TEMP_1_PIN + #elif TEMP_SENSOR_CHAMBER + #define TEMP_CHAMBER_PIN TEMP_1_PIN + #endif +#endif + +// +// Heaters / Fans +// +#ifndef HEATER_0_PIN + #define HEATER_0_PIN PB3 // Heater0 +#endif +#ifndef HEATER_1_PIN + #define HEATER_1_PIN PB4 // Heater1 +#endif +#ifndef HEATER_BED_PIN + #define HEATER_BED_PIN PD7 // Hotbed +#endif +#ifndef FAN_PIN + #define FAN_PIN PB7 // Fan0 +#endif + +#if HAS_CUTTER + #ifndef SPINDLE_LASER_PWM_PIN + #define SPINDLE_LASER_PWM_PIN PB5 + #endif + #ifndef SPINDLE_LASER_ENA_PIN + #define SPINDLE_LASER_ENA_PIN PB6 + #endif +#else + #ifndef FAN1_PIN + #define FAN1_PIN PB6 // Fan1 + #endif + #ifndef FAN2_PIN + #define FAN2_PIN PB5 // Fan2 + #endif +#endif // SPINDLE_FEATURE || LASER_FEATURE + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #ifndef TMC_SW_MOSI + #define TMC_SW_MOSI PE13 + #endif + #ifndef TMC_SW_MISO + #define TMC_SW_MISO PE15 + #endif + #ifndef TMC_SW_SCK + #define TMC_SW_SCK PE14 + #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 + + // + // Software serial + // + #define X_SERIAL_TX_PIN PD5 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PD0 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PE1 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PC6 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PD12 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +// +// SD Connection +// +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +/** + * ------ ------ + * (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 | -- + * ------ ------ + * 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 + +// +// 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 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 +#elif SD_CONNECTION_IS(ONBOARD) + #define SDIO_SUPPORT + #define SDIO_CLOCK 24000000 // 24MHz +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "No custom SD drive cable defined for this board." +#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 + * + * 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 + #if !EXP_MOT_USE_EXP2_ONLY + #define E2_DIAG_PIN EXP1_06_PIN + #define E2_CS_PIN EXP1_05_PIN + #if HAS_TMC_UART + #define E2_SERIAL_TX_PIN EXP1_05_PIN + #define E2_SERIAL_RX_PIN EXP1_05_PIN + #endif + #endif + + // M2 on Driver Expansion Module + #define E3_STEP_PIN EXP2_08_PIN + #define E3_DIR_PIN EXP2_07_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 + #if HAS_TMC_UART + #define E3_SERIAL_TX_PIN EXP1_07_PIN + #define E3_SERIAL_RX_PIN EXP1_07_PIN + #endif + #else + #define E3_ENABLE_PIN EXP2_04_PIN + #endif + + // M3 on Driver Expansion Module + #define E4_STEP_PIN EXP2_10_PIN + #define E4_DIR_PIN EXP2_09_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 + #if HAS_TMC_UART + #define E4_SERIAL_TX_PIN EXP1_09_PIN + #define E4_SERIAL_RX_PIN EXP1_09_PIN + #endif + #else + #define E4_ENABLE_PIN EXP2_04_PIN + #endif + +#endif // BTT_MOTOR_EXPANSION + +// +// LCDs and Controllers +// +#if IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS EXP2_08_PIN + #endif + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN EXP1_10_PIN + #define BTN_ENC EXP1_09_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + + #define LCD_PINS_RS EXP1_04_PIN + + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 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 + + #else + + #define LCD_PINS_RS EXP1_07_PIN + + #define BTN_EN1 EXP2_08_PIN + #define BTN_EN2 EXP2_06_PIN + + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #if ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS EXP1_08_PIN + #define DOGLCD_A0 EXP1_07_PIN + //#define LCD_BACKLIGHT_PIN -1 + #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_05_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_04_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_03_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_05_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 + + #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 + +#if HAS_SPI_TFT + // + // 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 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 +#endif + +// +// NeoPixel LED +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PE6 +#endif + +// +// 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 diff --git a/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h b/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h index cb038fe73702..82d9cec8949b 100644 --- a/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h +++ b/Marlin/src/pins/teensy2/pins_PRINTRBOARD.h @@ -121,7 +121,7 @@ // // LCD / Controller // -#if IS_ULTRA_LCD && IS_NEWPANEL +#if HAS_WIRED_LCD && IS_NEWPANEL #define LCD_PINS_RS 9 // E1 JP11-11 #define LCD_PINS_ENABLE 8 // E0 JP11-10 @@ -135,7 +135,6 @@ #define DOGLCD_A0 40 // F2 JP2-2 #define DOGLCD_CS 41 // F3 JP2-4 - #define LCD_SCREEN_ROT_180 #define BTN_EN1 2 // D2 TX1 JP2-5 #define BTN_EN2 3 // D3 RX1 JP2-7 @@ -146,6 +145,8 @@ #define STAT_LED_RED_PIN 12 // C2 JP11-14 #define STAT_LED_BLUE_PIN 10 // C0 JP11-12 + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(LCD_I2C_PANELOLU2) #define BTN_EN1 3 // D3 RX1 JP2-7 @@ -162,7 +163,7 @@ #endif -#endif // IS_ULTRA_LCD && IS_NEWPANEL +#endif // HAS_WIRED_LCD && IS_NEWPANEL #ifndef SDSS #define SDSS 26 // B6 SDCS diff --git a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h index 76b98ccbeb33..1ac953c89f8b 100644 --- a/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h +++ b/Marlin/src/pins/teensy2/pins_PRINTRBOARD_REVF.h @@ -212,7 +212,6 @@ #define BEEPER_PIN 8 // E0 JP11-10 #define DOGLCD_A0 40 // F2 JP2-2 #define DOGLCD_CS 41 // F3 JP2-4 - #define LCD_SCREEN_ROT_180 #define BTN_EN1 2 // D2 TX1 JP2-5 #define BTN_EN2 3 // D3 RX1 JP2-7 @@ -223,6 +222,8 @@ #define STAT_LED_RED_PIN 12 // C2 JP11-14 #define STAT_LED_BLUE_PIN 10 // C0 JP11-12 + #define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 + #elif ENABLED(MINIPANEL) #if DISABLED(USE_INTERNAL_SD) diff --git a/Marlin/src/pins/teensy2/pins_TEENSYLU.h b/Marlin/src/pins/teensy2/pins_TEENSYLU.h index 535ce534d437..ab722478fd93 100644 --- a/Marlin/src/pins/teensy2/pins_TEENSYLU.h +++ b/Marlin/src/pins/teensy2/pins_TEENSYLU.h @@ -145,7 +145,7 @@ // // LCD / Controller // -#if IS_ULTRA_LCD && IS_NEWPANEL +#if HAS_WIRED_LCD && IS_NEWPANEL #define BEEPER_PIN -1 @@ -158,7 +158,7 @@ #define SD_DETECT_PIN -1 -#endif // IS_ULTRA_LCD && IS_NEWPANEL +#endif // HAS_WIRED_LCD && IS_NEWPANEL // // M3/M4/M5 - Spindle/Laser Control diff --git a/Marlin/src/sd/Sd2Card.cpp b/Marlin/src/sd/Sd2Card.cpp index a81932d49485..2d84c95a3d19 100644 --- a/Marlin/src/sd/Sd2Card.cpp +++ b/Marlin/src/sd/Sd2Card.cpp @@ -249,7 +249,7 @@ bool DiskIODriver_SPI_SD::init(const uint8_t sckRateID, const pin_t chipSelectPi const millis_t init_timeout = millis() + SD_INIT_TIMEOUT; uint32_t arg; - watchdog_refresh(); // In case init takes too long + hal.watchdog_refresh(); // In case init takes too long // Set pin modes #if ENABLED(ZONESTAR_12864OLED) @@ -270,7 +270,7 @@ bool DiskIODriver_SPI_SD::init(const uint8_t sckRateID, const pin_t chipSelectPi // Must supply min of 74 clock cycles with CS high. LOOP_L_N(i, 10) spiSend(0xFF); - watchdog_refresh(); // In case init takes too long + hal.watchdog_refresh(); // In case init takes too long // Command to go idle in SPI mode while ((status_ = cardCommand(CMD0, 0)) != R1_IDLE_STATE) { @@ -284,7 +284,7 @@ bool DiskIODriver_SPI_SD::init(const uint8_t sckRateID, const pin_t chipSelectPi crcSupported = (cardCommand(CMD59, 1) == R1_IDLE_STATE); #endif - watchdog_refresh(); // In case init takes too long + hal.watchdog_refresh(); // In case init takes too long // check SD version for (;;) { @@ -306,7 +306,7 @@ bool DiskIODriver_SPI_SD::init(const uint8_t sckRateID, const pin_t chipSelectPi } } - watchdog_refresh(); // In case init takes too long + hal.watchdog_refresh(); // In case init takes too long // Initialize card and send host supports SDHC if SD2 arg = type() == SD_CARD_TYPE_SD2 ? 0x40000000 : 0; @@ -392,50 +392,51 @@ bool DiskIODriver_SPI_SD::readData(uint8_t *dst) { #if ENABLED(SD_CHECK_AND_RETRY) #ifdef FAST_CRC - static const uint16_t crctab16[] PROGMEM = { - 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, - 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, - 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, - 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, - 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, - 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, - 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, - 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, - 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, - 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, - 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, - 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, - 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, - 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, - 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, - 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, - 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, - 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, - 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, - 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, - 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, - 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, - 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, - 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, - 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, - 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, - 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, - 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, - 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, - 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, - 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, - 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0 - }; + static const uint16_t crctab16[] PROGMEM = { + 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, + 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, + 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, + 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, + 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, + 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, + 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, + 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, + 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, + 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, + 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, + 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, + 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, + 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, + 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, + 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, + 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, + 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, + 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, + 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, + 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, + 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, + 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, + 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, + 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, + 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, + 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, + 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, + 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, + 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, + 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, + 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0 + }; // faster CRC-CCITT // uses the x^16,x^12,x^5,x^1 polynomial. - static uint16_t CRC_CCITT(const uint8_t *data, size_t n) { - uint16_t crc = 0; - for (size_t i = 0; i < n; i++) { - crc = pgm_read_word(&crctab16[(crc >> 8 ^ data[i]) & 0xFF]) ^ (crc << 8); + static uint16_t CRC_CCITT(const uint8_t *data, size_t n) { + uint16_t crc = 0; + for (size_t i = 0; i < n; i++) + crc = pgm_read_word(&crctab16[(crc >> 8 ^ data[i]) & 0xFF]) ^ (crc << 8); + return crc; } - return crc; - } + #else + // slower CRC-CCITT // uses the x^16,x^12,x^5,x^1 polynomial. static uint16_t CRC_CCITT(const uint8_t *data, size_t n) { @@ -449,7 +450,9 @@ bool DiskIODriver_SPI_SD::readData(uint8_t *dst) { } return crc; } + #endif + #endif // SD_CHECK_AND_RETRY bool DiskIODriver_SPI_SD::readData(uint8_t *dst, const uint16_t count) { diff --git a/Marlin/src/sd/SdBaseFile.cpp b/Marlin/src/sd/SdBaseFile.cpp index b357495a3edb..1c1e0c7d145a 100644 --- a/Marlin/src/sd/SdBaseFile.cpp +++ b/Marlin/src/sd/SdBaseFile.cpp @@ -89,6 +89,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) { if (!vol_->cacheRawBlock(dirBlock_, action)) return nullptr; @@ -384,6 +385,20 @@ int8_t SdBaseFile::lsPrintNext(uint8_t flags, uint8_t indent) { return DIR_IS_FILE(&dir) ? 1 : 2; } +/** + * Calculate a checksum for an 8.3 filename + * + * \param name The 8.3 file name to calculate + * + * \return The checksum byte + */ +uint8_t lfn_checksum(const uint8_t *name) { + uint8_t sum = 0; + for (uint8_t i = 11; i; i--) + sum = ((sum & 1) << 7) + (sum >> 1) + *name++; + return sum; +} + // Format directory name field from a 8.3 name string bool SdBaseFile::make83Name(const char *str, uint8_t *name, const char **ptr) { uint8_t n = 7, // Max index until a dot is found @@ -430,6 +445,10 @@ bool SdBaseFile::mkdir(SdBaseFile *parent, const char *path, bool pFlag) { SdBaseFile *sub = &dir1; SdBaseFile *start = parent; + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + uint8_t dlname[LONG_FILENAME_LENGTH]; + #endif + if (!parent || isOpen()) return false; if (*path == '/') { @@ -439,28 +458,31 @@ bool SdBaseFile::mkdir(SdBaseFile *parent, const char *path, bool pFlag) { parent = &dir2; } } - while (1) { - if (!make83Name(path, dname, &path)) return false; + + for (;;) { + if (!TERN(LONG_FILENAME_WRITE_SUPPORT, parsePath(path, dname, dlname, &path), make83Name(path, dname, &path))) return false; while (*path == '/') path++; if (!*path) break; - if (!sub->open(parent, dname, O_READ)) { - if (!pFlag || !sub->mkdir(parent, dname)) + if (!sub->open(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname), O_READ)) { + if (!pFlag || !sub->mkdir(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname))) return false; } if (parent != start) parent->close(); parent = sub; sub = parent != &dir1 ? &dir1 : &dir2; } - return mkdir(parent, dname); + return mkdir(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname)); } -bool SdBaseFile::mkdir(SdBaseFile *parent, const uint8_t dname[11]) { +bool SdBaseFile::mkdir(SdBaseFile *parent, const uint8_t dname[11] + OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) +) { if (ENABLED(SDCARD_READONLY)) return false; if (!parent->isDir()) return false; // create a normal file - if (!open(parent, dname, O_CREAT | O_EXCL | O_RDWR)) return false; + if (!open(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname), O_CREAT | O_EXCL | O_RDWR)) return false; // convert file to directory flags_ = O_READ; @@ -578,6 +600,10 @@ bool SdBaseFile::open(SdBaseFile *dirFile, const char *path, uint8_t oflag) { SdBaseFile dir1, dir2; SdBaseFile *parent = dirFile, *sub = &dir1; + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + uint8_t dlname[LONG_FILENAME_LENGTH]; + #endif + if (!dirFile || isOpen()) return false; if (*path == '/') { // Path starts with '/' @@ -589,90 +615,244 @@ bool SdBaseFile::open(SdBaseFile *dirFile, const char *path, uint8_t oflag) { } for (;;) { - if (!make83Name(path, dname, &path)) return false; + if (!TERN(LONG_FILENAME_WRITE_SUPPORT, parsePath(path, dname, dlname, &path), make83Name(path, dname, &path))) return false; while (*path == '/') path++; if (!*path) break; - if (!sub->open(parent, dname, O_READ)) return false; + if (TERN0(LONG_FILENAME_WRITE_SUPPORT, !sub->open(parent, dname, dlname, O_READ))) return false; if (parent != dirFile) parent->close(); parent = sub; sub = parent != &dir1 ? &dir1 : &dir2; } - return open(parent, dname, oflag); + return open(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname), oflag); } -// open with filename in dname -bool SdBaseFile::open(SdBaseFile *dirFile, const uint8_t dname[11], uint8_t oflag) { +// open with filename in dname and long filename in dlname +bool SdBaseFile::open(SdBaseFile *dirFile, const uint8_t dname[11] + OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) + , uint8_t oflag +) { bool emptyFound = false, fileFound = false; - uint8_t index; + uint8_t index = 0; dir_t *p; - vol_ = dirFile->vol_; + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + // LFN - Long File Name support + const bool useLFN = dlname[0] != 0; + bool lfnFileFound = false; + vfat_t *pvFat; + uint8_t emptyCount = 0, + emptyIndex = 0, + reqEntriesNum = useLFN ? getLFNEntriesNum((char*)dlname) + 1 : 1, + lfnNameLength = useLFN ? strlen((char*)dlname) : 0, + lfnName[LONG_FILENAME_LENGTH], + lfnSequenceNumber = 0, + lfnChecksum = 0; + #endif + // Rewind this dir + vol_ = dirFile->vol_; dirFile->rewind(); - // search for file + // search for file while (dirFile->curPosition_ < dirFile->fileSize_) { - index = 0xF & (dirFile->curPosition_ >> 5); - p = dirFile->readDirCache(); - if (!p) return false; + // Get absolute index position + index = (dirFile->curPosition_ >> 5) IF_DISABLED(LONG_FILENAME_WRITE_SUPPORT, & 0x0F); + // Get next entry + if (!(p = dirFile->readDirCache())) return false; + + // Check empty status: Is entry empty? if (p->name[0] == DIR_NAME_FREE || p->name[0] == DIR_NAME_DELETED) { - // remember first empty slot + // Count the contiguous available entries in which (eventually) fit the new dir entry, if it's a write operation if (!emptyFound) { - dirBlock_ = dirFile->vol_->cacheBlockNumber(); - dirIndex_ = index; - emptyFound = true; + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + if (emptyCount == 0) emptyIndex = index; + // Incr empty entries counter + // If found the required empty entries, mark it + if (++emptyCount == reqEntriesNum) { + dirBlock_ = dirFile->vol_->cacheBlockNumber(); + dirIndex_ = index & 0xF; + emptyFound = true; + } + #else + dirBlock_ = dirFile->vol_->cacheBlockNumber(); + dirIndex_ = index; + emptyFound = true; + #endif } - // done if no entries follow + // Done if no entries follow if (p->name[0] == DIR_NAME_FREE) break; } - else if (!memcmp(dname, p->name, 11)) { - fileFound = true; - break; + else { // Entry not empty + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + // Reset empty counter + if (!emptyFound) emptyCount = 0; + // Search for SFN or LFN? + if (!useLFN) { + // Check using SFN: file found? + if (!memcmp(dname, p->name, 11)) { + fileFound = true; + break; + } + } + else { + // Check using LFN: LFN not found? continue search for LFN + if (!lfnFileFound) { + // Is this dir a LFN? + if (isDirLFN(p)) { + // Get VFat dir entry + pvFat = (vfat_t *) p; + // Get checksum from the last entry of the sequence + if (pvFat->sequenceNumber & 0x40) lfnChecksum = pvFat->checksum; + // Get LFN sequence number + lfnSequenceNumber = pvFat->sequenceNumber & 0x1F; + if WITHIN(lfnSequenceNumber, 1, reqEntriesNum) { + // Check checksum for all other entries with the starting checksum fetched before + if (lfnChecksum == pvFat->checksum) { + // Set chunk of LFN from VFAT entry into lfnName + getLFNName(pvFat, (char *)lfnName, lfnSequenceNumber); + // LFN found? + if (!strncasecmp((char*)dlname, (char*)lfnName, lfnNameLength)) lfnFileFound = true; + } + } + } + } + else { // Complete LFN found, check for related SFN + // Check if only the SFN checksum match because the filename may be different due to different truncation methods + if (!isDirLFN(p) && (lfnChecksum == lfn_checksum(p->name))) { + fileFound = true; + break; + } + else lfnFileFound = false; // SFN not valid for the LFN found, reset LFN FileFound + } + } + #else + + if (!memcmp(dname, p->name, 11)) { + fileFound = true; + break; + } + + #endif // LONG_FILENAME_WRITE_SUPPORT } } + if (fileFound) { // don't open existing file if O_EXCL if (oflag & O_EXCL) return false; + TERN_(LONG_FILENAME_WRITE_SUPPORT, index &= 0xF); } else { // don't create unless O_CREAT and O_WRITE if ((oflag & (O_CREAT | O_WRITE)) != (O_CREAT | O_WRITE)) return false; - if (emptyFound) { - index = dirIndex_; - p = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); - if (!p) return false; - } - else { - if (dirFile->type_ == FAT_FILE_TYPE_ROOT_FIXED) return false; - // add and zero cluster for dirFile - first cluster is in cache for write - if (!dirFile->addDirCluster()) return false; + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) - // use first entry in cluster - p = dirFile->vol_->cache()->dir; - index = 0; - } - // initialize as empty file - memset(p, 0, sizeof(*p)); - memcpy(p->name, dname, 11); + // Use bookmark index if found empty entries + if (emptyFound) index = emptyIndex; - // set timestamps - if (dateTime_) { - // call user date/time function - dateTime_(&p->creationDate, &p->creationTime); - } - else { - // use default date/time - p->creationDate = FAT_DEFAULT_DATE; - p->creationTime = FAT_DEFAULT_TIME; - } - p->lastAccessDate = p->creationDate; - p->lastWriteDate = p->creationDate; - p->lastWriteTime = p->creationTime; + // Make room for needed entries + while (emptyCount < reqEntriesNum) { + p = dirFile->readDirCache(); + if (!p) break; + emptyCount++; + } + while (emptyCount < reqEntriesNum) { + if (dirFile->type_ == FAT_FILE_TYPE_ROOT_FIXED) return false; + // add and zero cluster for dirFile - first cluster is in cache for write + if (!dirFile->addDirCluster()) return false; + emptyCount += dirFile->vol_->blocksPerCluster() * 16; + } + + // Move to 1st entry to write + if (!dirFile->seekSet(32 * index)) return false; + + // Dir entries write loop: [LFN] + SFN(1) + LOOP_L_N(dirWriteIdx, reqEntriesNum) { + index = (dirFile->curPosition_ / 32) & 0xF; + p = dirFile->readDirCache(); + // LFN or SFN Entry? + if (dirWriteIdx < reqEntriesNum - 1) { + // Write LFN Entries + pvFat = (vfat_t *) p; + // initialize as empty file + memset(pvFat, 0, sizeof(*pvFat)); + lfnSequenceNumber = (reqEntriesNum - dirWriteIdx - 1) & 0x1F; + pvFat->attributes = DIR_ATT_LONG_NAME; + pvFat->checksum = lfn_checksum(dname); + // Set sequence number and mark as last LFN entry if it's the 1st loop + pvFat->sequenceNumber = lfnSequenceNumber | (dirWriteIdx == 0 ? 0x40 : 0); + // Set LFN name block + setLFNName(pvFat, (char*)dlname, lfnSequenceNumber); + } + else { + // Write SFN Entry + // initialize as empty file + memset(p, 0, sizeof(*p)); + memcpy(p->name, dname, 11); + + // set timestamps + if (dateTime_) { + // call user date/time function + dateTime_(&p->creationDate, &p->creationTime); + } + else { + // use default date/time + p->creationDate = FAT_DEFAULT_DATE; + p->creationTime = FAT_DEFAULT_TIME; + } + p->lastAccessDate = p->creationDate; + p->lastWriteDate = p->creationDate; + p->lastWriteTime = p->creationTime; + } + + // write entry to SD + dirFile->vol_->cacheSetDirty(); + if (!dirFile->vol_->cacheFlush()) return false; + } + + #else // !LONG_FILENAME_WRITE_SUPPORT + + if (emptyFound) { + index = dirIndex_; + p = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!p) return false; + } + else { + if (dirFile->type_ == FAT_FILE_TYPE_ROOT_FIXED) return false; + + // add and zero cluster for dirFile - first cluster is in cache for write + if (!dirFile->addDirCluster()) return false; + + // use first entry in cluster + p = dirFile->vol_->cache()->dir; + index = 0; + } + + // initialize as empty file + memset(p, 0, sizeof(*p)); + memcpy(p->name, dname, 11); + + // set timestamps + if (dateTime_) { + // call user date/time function + dateTime_(&p->creationDate, &p->creationTime); + } + else { + // use default date/time + p->creationDate = FAT_DEFAULT_DATE; + p->creationTime = FAT_DEFAULT_TIME; + } + + p->lastAccessDate = p->creationDate; + p->lastWriteDate = p->creationDate; + p->lastWriteTime = p->creationTime; + + // write entry to SD + if (!dirFile->vol_->cacheFlush()) return false; + + #endif // !LONG_FILENAME_WRITE_SUPPORT - // write entry to SD - if (!dirFile->vol_->cacheFlush()) return false; } // open entry in cache return openCachedEntry(index, oflag); @@ -808,6 +988,191 @@ bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) { return false; } +#if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + + /** + * Check if dir is a long file name entry (LFN) + * + * \param[in] dir Parent of this directory will be opened. Must not be root. + * \return true if the dir is a long file name entry (LFN) + */ + bool SdBaseFile::isDirLFN(const dir_t* dir) { + if (DIR_IS_LONG_NAME(dir)) { + vfat_t *VFAT = (vfat_t*)dir; + // Sanity-check the VFAT entry. The first cluster is always set to zero. And the sequence number should be higher than 0 + if ((VFAT->firstClusterLow == 0) && WITHIN((VFAT->sequenceNumber & 0x1F), 1, MAX_VFAT_ENTRIES)) return true; + } + return false; + } + + /** + * Check if dirname string is a long file name (LFN) + * + * \param[in] dirname The string to check + * \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 dotFound = false; + if (idx > 12) return true; // LFN due to filename length > 12 ("filename.ext") + // Check dot(s) position + while (idx) { + if (dirname[--idx] == '.') { + if (!dotFound) { + // Last dot (extension) is allowed only + // in position [1..8] from start or [0..3] from end for SFN else it's a LFN + // A filename starting with "." is a LFN (eg. ".file" ->in SFN-> "file~1 ") + // A filename ending with "." is a SFN (if length <= 9) (eg. "file." ->in SFN-> "file ") + if (idx > 8 || idx == 0 || (length - idx - 1) > 3) return true; // LFN due to dot extension position + dotFound = true; + } + else { + // Found another dot, is a LFN + return true; + } + } + } + // If no dots found, the filename must be of max 8 characters + if ((!dotFound) && length > 8) return true; // LFN due to max filename (without extension) length + return false; + } + + /** + * Parse path and return 8.3 format and LFN filenames (if the parsed path is a LFN) + * 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) { + // Init randomizer for SFN generation + randomSeed(millis()); + // Parse the LFN + uint8_t ilfn = 0; + bool lastDotFound = false; + const char *pLastDot = 0; + const char *lfnpath = path; + uint8_t c; + + while (*lfnpath && *lfnpath != '/') { + if (ilfn == LONG_FILENAME_LENGTH - 1) return false; // Name too long + c = *lfnpath++; // Get char and advance + // Fail for illegal characters + PGM_P p = PSTR("|<>^+=?/[];:,*\"\\"); + while (uint8_t b = pgm_read_byte(p++)) if (b == c) return false; // Check reserved characters + if (c < 0x20 || c == 0x7F) return false; // Check non-printable characters + if (c == '.' && (lfnpath - 1) > path) { // Skip dot '.' check in 1st position + // Save last dot pointer (skip if starts with '.') + pLastDot = lfnpath - 1; + lastDotFound = true; + } + lname[ilfn++] = c; // Set LFN character + } + // Terminate LFN + lname[ilfn] = 0; + + // Parse/generate 8.3 SFN. Will take + // until 8 characters for the filename part + // until 3 characters for the extension part (if exists) + // Add 4 more characters if name part < 3 + // Add '~cnt' characters if it's a LFN + const bool isLFN = isDirNameLFN((char*)lname); + + uint8_t n = isLFN ? 5 : 7, // Max index for each component of the file: + // starting with 7 or 5 (if LFN) + // switch to 10 for extension if the last dot is found + i = 11; + while (i) name[--i] = ' '; // Set whole FILENAMEEXT to spaces + while (*path && *path != '/') { + c = *path++; // Get char and advance + // Skip spaces and dots (if it's not the last dot) + if (c == ' ') continue; + if (c == '.' && (!lastDotFound || (lastDotFound && path < pLastDot))) continue; + // Fail for illegal characters + PGM_P p = PSTR("|<>^+=?/[];:,*\"\\"); + while (uint8_t b = pgm_read_byte(p++)) if (b == c) return false; // Check reserved characters + if (c < 0x21 || c == 0x7F) return false; // Check non-printable characters + // Is last dot? + if (c == '.') { + // Switch to extension part + n = 10; + i = 8; + } + // If in valid range add the character + else if (i <= n) // Check size for 8.3 format + name[i++] = c + (WITHIN(c, 'a', 'z') ? 'A' - 'a' : 0); // Uppercase required for 8.3 name + } + // If it's a LFN then the SFN always need: + // - A minimal of 3 characters (otherwise 4 chars are added) + // - The '~cnt' at the end + if (isLFN) { + // Get the 1st free character + uint8_t iFree = 0; + while (1) if (name[iFree++] == ' ' || iFree == 11) break; + iFree--; + // Check minimal length + if (iFree < 3) { + // Append 4 extra characters + name[iFree++] = random(0,24) + 'A'; name[iFree++] = random(0,24) + 'A'; + name[iFree++] = random(0,24) + 'A'; name[iFree++] = random(0,24) + 'A'; + } + // Append '~cnt' characters + if (iFree > 5) iFree = 5; // Force the append in the last 3 characters of name part + name[iFree++] = '~'; + name[iFree++] = random(1,9) + '0'; + name[iFree++] = random(1,9) + '0'; + } + + // Check if LFN is needed + if (!isLFN) lname[0] = 0; // Zero LFN + *ptrNextPath = path; // Set passed pointer to the end + return name[0] != ' '; // Return true if any name was set + } + + /** + * 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; + 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 + lname[idx] = utf16_ch & 0xFF; + lname[idx + 1] = (utf16_ch >> 8) & 0xFF; + #else + // Replace all multibyte characters to '_' + lname[startOffset + i] = (utf16_ch > 0xFF) ? '_' : (utf16_ch & 0xFF); + #endif + } + } + + /** + * 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); + LOOP_L_N(i, FILENAME_LENGTH) { + uint16_t ch = 0; + if ((startOffset + i) < nameLength) + ch = lname[startOffset + i]; + else if ((startOffset + i) > nameLength) + ch = 0xFFFF; + // Set char + if (i < 5) + pFatDir->name1[i] = ch; + else if (i < 11) + pFatDir->name2[i - 5] = ch; + else + pFatDir->name3[i - 11] = ch; + } + } + +#endif // LONG_FILENAME_WRITE_SUPPORT + #if 0 /** * Open a directory's parent directory. @@ -1049,20 +1414,6 @@ int16_t SdBaseFile::read(void *buf, uint16_t nbyte) { return nbyte; } -/** - * Calculate a checksum for an 8.3 filename - * - * \param name The 8.3 file name to calculate - * - * \return The checksum byte - */ -uint8_t lfn_checksum(const uint8_t *name) { - uint8_t sum = 0; - for (uint8_t i = 11; i; i--) - sum = ((sum & 1) << 7) + (sum >> 1) + *name++; - return sum; -} - /** * Read the next entry in a directory. * @@ -1110,30 +1461,40 @@ int8_t SdBaseFile::readDir(dir_t *dir, char *longFilename) { if (VFAT->firstClusterLow == 0) { const uint8_t seq = VFAT->sequenceNumber & 0x1F; if (WITHIN(seq, 1, MAX_VFAT_ENTRIES)) { - n = (seq - 1) * (FILENAME_LENGTH); - if (n == 0) { + if (seq == 1) { checksum = VFAT->checksum; checksum_error = 0; } else if (checksum != VFAT->checksum) // orphan detected checksum_error = 1; - LOOP_L_N(i, FILENAME_LENGTH) { - const uint16_t utf16_ch = (i >= 11) ? VFAT->name3[i - 11] : (i >= 5) ? VFAT->name2[i - 5] : VFAT->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 = (n + i) * 2; // This is fixed as FAT LFN always contain UTF-16LE encoding - longFilename[idx] = utf16_ch & 0xFF; - longFilename[idx + 1] = (utf16_ch >> 8) & 0xFF; - #else - // Replace all multibyte characters to '_' - longFilename[n + i] = (utf16_ch > 0xFF) ? '_' : (utf16_ch & 0xFF); - #endif - } + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + + getLFNName(VFAT, longFilename, seq); // Get chunk of LFN from VFAT entry + + #else // !LONG_FILENAME_WRITE_SUPPORT + + n = (seq - 1) * (FILENAME_LENGTH); + + LOOP_L_N(i, FILENAME_LENGTH) { + const uint16_t utf16_ch = (i >= 11) ? VFAT->name3[i - 11] : (i >= 5) ? VFAT->name2[i - 5] : VFAT->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 = (n + i) * 2; // This is fixed as FAT LFN always contain UTF-16LE encoding + longFilename[idx] = utf16_ch & 0xFF; + longFilename[idx + 1] = (utf16_ch >> 8) & 0xFF; + #else + // Replace all multibyte characters to '_' + longFilename[n + i] = (utf16_ch > 0xFF) ? '_' : (utf16_ch & 0xFF); + #endif + } + + #endif // !LONG_FILENAME_WRITE_SUPPORT + // If this VFAT entry is the last one, add a NUL terminator at the end of the string if (VFAT->sequenceNumber & 0x40) - longFilename[(n + FILENAME_LENGTH) * LONG_FILENAME_CHARSIZE] = '\0'; + longFilename[LONG_FILENAME_CHARSIZE * TERN(LONG_FILENAME_WRITE_SUPPORT, seq * FILENAME_LENGTH, (n + FILENAME_LENGTH))] = '\0'; } } } @@ -1227,6 +1588,11 @@ bool SdBaseFile::remove() { dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); if (!d) return false; + #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) + // get SFN checksum before name rewrite (needed for LFN deletion) + const uint8_t sfn_checksum = lfn_checksum(d->name); + #endif + // mark entry deleted d->name[0] = DIR_NAME_DELETED; @@ -1234,8 +1600,48 @@ bool SdBaseFile::remove() { type_ = FAT_FILE_TYPE_CLOSED; // write entry to SD - return vol_->cacheFlush(); - return true; + #if DISABLED(LONG_FILENAME_WRITE_SUPPORT) + + return vol_->cacheFlush(); + + #else // LONG_FILENAME_WRITE_SUPPORT + + flags_ = 0; + + if (!vol_->cacheFlush()) return false; + + // Check if the entry has a LFN + bool lastEntry = false; + // loop back to search for any LFN entries related to this file + LOOP_S_LE_N(sequenceNumber, 1, MAX_VFAT_ENTRIES) { + dirIndex_ = (dirIndex_ - 1) & 0xF; + if (dirBlock_ == 0) break; + if (dirIndex_ == 0xF) dirBlock_--; + dir_t *dir = cacheDirEntry(SdVolume::CACHE_FOR_WRITE); + if (!dir) return false; + + // check for valid LFN: not deleted, not top dirs (".", ".."), must be a LFN + if (dir->name[0] == DIR_NAME_DELETED || dir->name[0] == '.' || !isDirLFN(dir)) break; + // check coherent LFN: checksum and sequenceNumber must match + vfat_t* dirlfn = (vfat_t*) dir; + if (dirlfn->checksum != sfn_checksum || (dirlfn->sequenceNumber & 0x1F) != sequenceNumber) break; // orphan entry + // is last entry of LFN ? + lastEntry = (dirlfn->sequenceNumber & 0x40); + // mark as deleted + dirlfn->sequenceNumber = DIR_NAME_DELETED; + // Flush to SD + if (!vol_->cacheFlush()) return false; + // exit on last entry of LFN deleted + if (lastEntry) break; + } + + // Restore current index + //if (!seekSet(32UL * dirIndex_)) return false; + //dirIndex_ += prevDirIndex; + + return true; + + #endif // LONG_FILENAME_WRITE_SUPPORT } /** diff --git a/Marlin/src/sd/SdBaseFile.h b/Marlin/src/sd/SdBaseFile.h index 342edefb7079..bda44c6bd5c3 100644 --- a/Marlin/src/sd/SdBaseFile.h +++ b/Marlin/src/sd/SdBaseFile.h @@ -377,8 +377,26 @@ class SdBaseFile { 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]); - bool open(SdBaseFile *dirFile, const uint8_t dname[11], uint8_t oflag); + bool mkdir(SdBaseFile *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 + ); bool openCachedEntry(uint8_t cacheIndex, uint8_t oflags); dir_t* readDirCache(); + + // 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); + #endif }; diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index da6e84c75942..5e03795692da 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -33,8 +33,8 @@ #if ENABLED(DWIN_CREALITY_LCD) #include "../lcd/e3v2/creality/dwin.h" -#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) - #include "../lcd/e3v2/enhanced/dwin.h" +#elif ENABLED(DWIN_LCD_PROUI) + #include "../lcd/e3v2/proui/dwin.h" #endif #include "../module/planner.h" // for synchronize @@ -171,7 +171,7 @@ CardReader::CardReader() { workDirDepth = 0; ZERO(workDirParents); - #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) + #if BOTH(SDSUPPORT, HAS_SD_DETECT) SET_INPUT_PULLUP(SD_DETECT_PIN); #endif @@ -195,11 +195,15 @@ char *createFilename(char * const buffer, const dir_t &p) { } // -// Return 'true' if the item is a folder or G-code file +// Return 'true' if the item is a folder, G-code file or Binary file // -bool CardReader::is_dir_or_gcode(const dir_t &p) { +bool CardReader::is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, bool onlyBin/*=false*/)) { //uint8_t pn0 = p.name[0]; + #if DISABLED(CUSTOM_FIRMWARE_UPLOAD) + constexpr bool onlyBin = false; + #endif + if ( (p.attributes & DIR_ATT_HIDDEN) // Hidden by attribute // When readDir() > 0 these must be false: //|| pn0 == DIR_NAME_FREE || pn0 == DIR_NAME_DELETED // Clear or Deleted entry @@ -208,10 +212,15 @@ bool CardReader::is_dir_or_gcode(const dir_t &p) { ) return false; flag.filenameIsDir = DIR_IS_SUBDIR(&p); // We know it's a File or Folder + setBinFlag(p.name[8] == 'B' && // List .bin files (a firmware file for flashing) + p.name[9] == 'I' && + p.name[10]== 'N'); return ( flag.filenameIsDir // All Directories are ok - || (p.name[8] == 'G' && p.name[9] != '~') // Non-backup *.G* files are accepted + || fileIsBinary() // BIN files are accepted + || (!onlyBin && p.name[8] == 'G' + && p.name[9] != '~') // Non-backup *.G* files are accepted ); } @@ -222,7 +231,7 @@ int CardReader::countItems(SdFile dir) { dir_t p; int c = 0; while (dir.readDir(&p, longFilename) > 0) - c += is_dir_or_gcode(p); + c += is_visible_entity(p); #if ALL(SDCARD_SORT_ALPHA, SDSORT_USES_RAM, SDSORT_CACHE_NAMES) nrFiles = c; @@ -237,7 +246,7 @@ int CardReader::countItems(SdFile dir) { void CardReader::selectByIndex(SdFile dir, const uint8_t index) { dir_t p; for (uint8_t cnt = 0; dir.readDir(&p, longFilename) > 0;) { - if (is_dir_or_gcode(p)) { + if (is_visible_entity(p)) { if (cnt == index) { createFilename(filename, p); return; // 0 based index @@ -253,7 +262,7 @@ void CardReader::selectByIndex(SdFile dir, const uint8_t index) { void CardReader::selectByName(SdFile dir, const char * const match) { dir_t p; for (uint8_t cnt = 0; dir.readDir(&p, longFilename) > 0; cnt++) { - if (is_dir_or_gcode(p)) { + if (is_visible_entity(p)) { createFilename(filename, p); if (strcasecmp(match, filename) == 0) return; } @@ -271,9 +280,9 @@ void CardReader::selectByName(SdFile dir, const char * const match) { * good addition. */ void CardReader::printListing( - SdFile parent + SdFile parent, const char * const prepend + OPTARG(CUSTOM_FIRMWARE_UPLOAD, bool onlyBin/*=false*/) OPTARG(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames/*=false*/) - , const char * const prepend/*=nullptr*/ OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong/*=nullptr*/) ) { dir_t p; @@ -283,61 +292,47 @@ void CardReader::printListing( size_t lenPrepend = prepend ? strlen(prepend) + 1 : 0; // Allocate enough stack space for the full path including / separator char path[lenPrepend + FILENAME_LENGTH]; - if (prepend) { - strcpy(path, prepend); - path[lenPrepend - 1] = '/'; - } + if (prepend) { strcpy(path, prepend); path[lenPrepend - 1] = '/'; } char* dosFilename = path + lenPrepend; createFilename(dosFilename, p); // Get a new directory object using the full path // and dive recursively into it. SdFile child; // child.close() in destructor - if (child.open(&parent, dosFilename, O_READ)) + if (child.open(&parent, dosFilename, O_READ)) { #if ENABLED(LONG_FILENAME_HOST_SUPPORT) if (includeLongNames) { 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] = '/'; - } + if (prependLong) { strcpy(pathLong, prependLong); pathLong[lenPrependLong - 1] = '/'; } strcpy(pathLong + lenPrependLong, longFilename); - printListing(child, true, path, pathLong); + printListing(child, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin), true, pathLong); } else - printListing(child, false, path); + printListing(child, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin)); #else - printListing(child, path); + printListing(child, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin)); #endif + } else { SERIAL_ECHO_MSG(STR_SD_CANT_OPEN_SUBDIR, dosFilename); return; } } - else if (is_dir_or_gcode(p)) { - if (prepend) { - SERIAL_ECHO(prepend); - SERIAL_CHAR('/'); - } + else if (is_visible_entity(p OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin))) { + if (prepend) { SERIAL_ECHO(prepend); SERIAL_CHAR('/'); } SERIAL_ECHO(createFilename(filename, p)); SERIAL_CHAR(' '); + SERIAL_ECHO(p.fileSize); #if ENABLED(LONG_FILENAME_HOST_SUPPORT) - if (!includeLongNames) - #endif - SERIAL_ECHOLN(p.fileSize); - #if ENABLED(LONG_FILENAME_HOST_SUPPORT) - else { - SERIAL_ECHO(p.fileSize); + if (includeLongNames) { SERIAL_CHAR(' '); - if (prependLong) { - SERIAL_ECHO(prependLong); - SERIAL_CHAR('/'); - } - SERIAL_ECHOLN(longFilename[0] ? longFilename : "???"); + if (prependLong) { SERIAL_ECHO(prependLong); SERIAL_CHAR('/'); } + SERIAL_ECHO(longFilename[0] ? longFilename : filename); } #endif + SERIAL_EOL(); } } } @@ -345,10 +340,16 @@ void CardReader::printListing( // // List all files on the SD card // -void CardReader::ls(TERN_(LONG_FILENAME_HOST_SUPPORT, bool includeLongNames/*=false*/)) { +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*/) +) { if (flag.mounted) { root.rewind(); - printListing(root OPTARG(LONG_FILENAME_HOST_SUPPORT, includeLongNames)); + printListing(root, nullptr OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin) OPTARG(LONG_FILENAME_HOST_SUPPORT, includeLongNames)); } } @@ -385,9 +386,9 @@ void CardReader::ls(TERN_(LONG_FILENAME_HOST_SUPPORT, bool includeLongNames/*=fa diveDir.rewind(); selectByName(diveDir, segment); - // Print /LongNamePart to serial output + // Print /LongNamePart to serial output or the short name if not available SERIAL_CHAR('/'); - SERIAL_ECHO(longFilename[0] ? longFilename : "???"); + SERIAL_ECHO(longFilename[0] ? longFilename : filename); // If the filename was printed then that's it if (!flag.filenameIsDir) break; @@ -455,10 +456,11 @@ void CardReader::mount() { if (flag.mounted) cdroot(); - #if ENABLED(USB_FLASH_DRIVE_SUPPORT) || PIN_EXISTS(SD_DETECT) - else if (marlin_state != MF_INITIALIZING) - ui.set_status(GET_TEXT_F(MSG_MEDIA_INIT_FAIL), -1); - #endif + else { + #if EITHER(HAS_SD_DETECT, USB_FLASH_DRIVE_SUPPORT) + if (marlin_state != MF_INITIALIZING) LCD_ALERTMESSAGE(MSG_MEDIA_INIT_FAIL); + #endif + } ui.refresh(); } @@ -471,50 +473,67 @@ void CardReader::mount() { #endif void CardReader::manage_media() { - static uint8_t prev_stat = 2; // First call, no prior state + static uint8_t prev_stat = 2; // At boot we don't know if media is present or not uint8_t stat = uint8_t(IS_SD_INSERTED()); - if (stat == prev_stat) return; + if (stat == prev_stat) return; // Already checked and still no change? - DEBUG_ECHOLNPGM("SD: Status changed from ", prev_stat, " to ", stat); + DEBUG_SECTION(cmm, "CardReader::manage_media()", true); + DEBUG_ECHOLNPGM("Media present: ", prev_stat, " -> ", stat); - flag.workDirIsRoot = true; // Return to root on mount/release + if (!ui.detected()) { + DEBUG_ECHOLNPGM("SD: No UI Detected."); + return; + } - if (ui.detected()) { + flag.workDirIsRoot = true; // Return to root on mount/release/init - uint8_t old_stat = prev_stat; - prev_stat = stat; // Change now to prevent re-entry + const uint8_t old_stat = prev_stat; + prev_stat = stat; // Change now to prevent re-entry in safe_delay - if (stat) { // Media Inserted - safe_delay(500); // Some boards need a delay to get settled - if (TERN1(SD_IGNORE_AT_STARTUP, old_stat != 2)) - mount(); // Try to mount the media - #if MB(FYSETC_CHEETAH, FYSETC_CHEETAH_V12, FYSETC_AIO_II) - reset_stepper_drivers(); // Workaround for Cheetah bug - #endif - if (!isMounted()) stat = 0; // Not mounted? - } - else { - #if PIN_EXISTS(SD_DETECT) - release(); // Card is released + if (stat) { // Media Inserted + safe_delay(500); // Some boards need a delay to get settled + + // 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 } - ui.media_changed(old_stat, stat); // Update the UI - - if (stat) { - TERN_(SDCARD_EEPROM_EMULATION, settings.first_load()); - if (old_stat == 2) { // First mount? - DEBUG_ECHOLNPGM("First mount."); - #if ENABLED(POWER_LOSS_RECOVERY) - recovery.check(); // Check for PLR file. (If not there then call autofile_begin) - #elif DISABLED(NO_SD_AUTOSTART) - autofile_begin(); // Look for auto0.g on the next loop - #endif - } - } + TERN_(RESET_STEPPERS_ON_MEDIA_INSERT, reset_stepper_drivers()); // Workaround for Cheetah bug } - else - DEBUG_ECHOLNPGM("SD: No UI Detected."); + else { + TERN_(HAS_SD_DETECT, release()); // Card is released + } + + ui.media_changed(old_stat, stat); // Update the UI or flag an error + + 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... + + 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. + TERN_(POWER_LOSS_RECOVERY, if (recovery.check()) do_auto = false); + + // Look for auto0.g on the next idle() + IF_DISABLED(NO_SD_AUTOSTART, if (do_auto) autofile_begin()); } /** @@ -867,6 +886,7 @@ void CardReader::selectFileByIndex(const uint16_t nr) { strcpy(filename, sortshort[nr]); strcpy(longFilename, sortnames[nr]); flag.filenameIsDir = IS_DIR(nr); + setBinFlag(strcmp_P(strrchr(filename, '.'), PSTR(".BIN")) == 0); return; } #endif @@ -884,6 +904,7 @@ void CardReader::selectFileByName(const char * const match) { strcpy(filename, sortshort[nr]); strcpy(longFilename, sortnames[nr]); flag.filenameIsDir = IS_DIR(nr); + setBinFlag(strcmp_P(strrchr(filename, '.'), PSTR(".BIN")) == 0); return; } #endif diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index 53e1a7ffc3cb..d2f462c2a777 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -80,6 +80,9 @@ typedef struct { filenameIsDir:1, workDirIsRoot:1, abort_sd_printing:1 + #if DO_LIST_BIN_FILES + , filenameIsBin:1 + #endif #if ENABLED(BINARY_FILE_TRANSFER) , binary_mode:1 #endif @@ -115,7 +118,7 @@ class CardReader { static void mount(); static void release(); - static inline bool isMounted() { return flag.mounted; } + static bool isMounted() { return flag.mounted; } // Handle media insert/remove static void manage_media(); @@ -128,7 +131,7 @@ class CardReader { static uint8_t autofile_index; // Next auto#.g index to run, plus one. Ignored by autofile_check when zero. static void autofile_begin(); // Begin check. Called automatically after boot-up. static bool autofile_check(); // Check for the next auto-start file and run it. - static inline void autofile_cancel() { autofile_index = 0; } + static void autofile_cancel() { autofile_index = 0; } #endif // Basic file ops @@ -138,7 +141,7 @@ class CardReader { static bool fileExists(const char * const name); static void removeFile(const char * const name); - static inline char* longest_filename() { return longFilename[0] ? longFilename : filename; } + static char* longest_filename() { return longFilename[0] ? longFilename : filename; } #if ENABLED(LONG_FILENAME_HOST_SUPPORT) static void printLongPath(char * const path); // Used by M33 #endif @@ -163,18 +166,18 @@ class CardReader { static void endFilePrintNow(TERN_(SD_RESORT, const bool re_sort=false)); static void abortFilePrintNow(TERN_(SD_RESORT, const bool re_sort=false)); static void fileHasFinished(); - static inline void abortFilePrintSoon() { flag.abort_sd_printing = isFileOpen(); } - static inline void pauseSDPrint() { flag.sdprinting = false; } - static inline bool isPrinting() { return flag.sdprinting; } - static inline bool isPaused() { return isFileOpen() && !isPrinting(); } + static void abortFilePrintSoon() { flag.abort_sd_printing = isFileOpen(); } + static void pauseSDPrint() { flag.sdprinting = false; } + static bool isPrinting() { return flag.sdprinting; } + static bool isPaused() { return isFileOpen() && !isPrinting(); } #if HAS_PRINT_PROGRESS_PERMYRIAD - static inline uint16_t permyriadDone() { + static uint16_t permyriadDone() { if (flag.sdprintdone) return 10000; if (isFileOpen() && filesize) return sdpos / ((filesize + 9999) / 10000); return 0; } #endif - static inline uint8_t percentDone() { + static uint8_t percentDone() { if (flag.sdprintdone) return 100; if (isFileOpen() && filesize) return sdpos / ((filesize + 99) / 100); return 0; @@ -204,7 +207,13 @@ class CardReader { FORCE_INLINE static void getfilename_sorted(const uint16_t nr) { selectFileByIndex(nr); } #endif - static void ls(TERN_(LONG_FILENAME_HOST_SUPPORT, bool includeLongNames=false)); + 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) + ); #if ENABLED(POWER_LOSS_RECOVERY) static bool jobRecoverFileExists(); @@ -212,21 +221,25 @@ class CardReader { static void removeJobRecoveryFile(); #endif + // Binary flag for the current file + static bool fileIsBinary() { return TERN0(DO_LIST_BIN_FILES, flag.filenameIsBin); } + static void setBinFlag(const bool bin) { TERN(DO_LIST_BIN_FILES, flag.filenameIsBin = bin, UNUSED(bin)); } + // Current Working Dir - Set by cd, cdup, cdroot, and diveToFile(true, ...) - static inline char* getWorkDirName() { workDir.getDosName(filename); return filename; } - static inline SdFile& getWorkDir() { return workDir.isOpen() ? workDir : root; } + static char* getWorkDirName() { workDir.getDosName(filename); return filename; } + static SdFile& getWorkDir() { return workDir.isOpen() ? workDir : root; } // Print File stats - static inline uint32_t getFileSize() { return filesize; } - static inline uint32_t getIndex() { return sdpos; } - static inline bool isFileOpen() { return isMounted() && file.isOpen(); } - static inline bool eof() { return getIndex() >= getFileSize(); } + static uint32_t getFileSize() { return filesize; } + static uint32_t getIndex() { return sdpos; } + static bool isFileOpen() { return isMounted() && file.isOpen(); } + static bool eof() { return getIndex() >= getFileSize(); } // File data operations - static inline int16_t get() { int16_t out = (int16_t)file.read(); sdpos = file.curPosition(); return out; } - static inline int16_t read(void *buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; } - static inline int16_t write(void *buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; } - static inline void setIndex(const uint32_t index) { file.seekSet((sdpos = index)); } + static int16_t get() { int16_t out = (int16_t)file.read(); sdpos = file.curPosition(); return out; } + static int16_t read(void *buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; } + static int16_t write(void *buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; } + static void setIndex(const uint32_t index) { file.seekSet((sdpos = index)); } // TODO: rename to diskIODriver() static DiskIODriver* diskIODriver() { return driver; } @@ -331,14 +344,14 @@ class CardReader { // // Directory items // - static bool is_dir_or_gcode(const dir_t &p); + 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 void printListing( - SdFile parent + SdFile parent, const char * const prepend + OPTARG(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin=false) OPTARG(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames=false) - , const char * const prepend=nullptr OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong=nullptr) ); @@ -349,7 +362,7 @@ class CardReader { #if ENABLED(USB_FLASH_DRIVE_SUPPORT) #define IS_SD_INSERTED() DiskIODriver_USBFlash::isInserted() -#elif PIN_EXISTS(SD_DETECT) +#elif HAS_SD_DETECT #define IS_SD_INSERTED() (READ(SD_DETECT_PIN) == SD_DETECT_STATE) #else // No card detect line? Assume the card is inserted. diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp index 05671167c800..a681af4efa63 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp @@ -61,10 +61,8 @@ #define USB_NO_TEST_UNIT_READY // Required for removable media adapter #define USB_HOST_MANUAL_POLL // Optimization to shut off IRQ automatically - // Workarounds for keeping Marlin's watchdog timer from barking... - void marlin_yield() { - thermalManager.manage_heater(); - } + // Workarounds to keep Marlin's watchdog timer from barking... + void marlin_yield() { thermalManager.manage_heater(); } #define SYSTEM_OR_SPECIAL_YIELD(...) marlin_yield(); #define delay(x) safe_delay(x) @@ -82,6 +80,7 @@ #define UHS_START (usb.Init() == 0) #define UHS_STATE(state) UHS_USB_HOST_STATE_##state + #elif ENABLED(USE_OTG_USB_HOST) #if HAS_SD_HOST_DRIVE @@ -93,7 +92,9 @@ #define UHS_START usb.start() #define rREVISION 0 #define UHS_STATE(state) USB_STATE_##state + #else + #include "lib-uhs2/Usb.h" #include "lib-uhs2/masstorage.h" @@ -102,6 +103,7 @@ #define UHS_START usb.start() #define UHS_STATE(state) USB_STATE_##state + #endif #include "Sd2Card_FlashDrive.h" @@ -271,11 +273,11 @@ bool DiskIODriver_USBFlash::init(const uint8_t, const pin_t) { if (!isInserted()) return false; #if USB_DEBUG >= 1 - const uint32_t sectorSize = bulk.GetSectorSize(0); - if (sectorSize != 512) { - SERIAL_ECHOLNPGM("Expecting sector size of 512. Got: ", sectorSize); - return false; - } + const uint32_t sectorSize = bulk.GetSectorSize(0); + if (sectorSize != 512) { + SERIAL_ECHOLNPGM("Expecting sector size of 512. Got: ", sectorSize); + return false; + } #endif #if USB_DEBUG >= 3 diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp b/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp index a1a3b7d50ead..09fd57b15467 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/usbhost.cpp @@ -27,19 +27,18 @@ #if ENABLED(USB_FLASH_DRIVE_SUPPORT) && DISABLED(USE_UHS3_USB) +#if !PINS_EXIST(USB_CS, USB_INTR) + #error "USB_FLASH_DRIVE_SUPPORT requires USB_CS_PIN and USB_INTR_PIN to be defined." +#endif + #include "Usb.h" #include "usbhost.h" uint8_t MAX3421e::vbusState = 0; // constructor -void MAX3421e::cs() { - WRITE(USB_CS_PIN,0); -} - -void MAX3421e::ncs() { - WRITE(USB_CS_PIN,1); -} +void MAX3421e::cs() { WRITE(USB_CS_PIN, LOW); } +void MAX3421e::ncs() { WRITE(USB_CS_PIN, HIGH); } // write single byte into MAX3421 register void MAX3421e::regWr(uint8_t reg, uint8_t data) { @@ -47,7 +46,7 @@ void MAX3421e::regWr(uint8_t reg, uint8_t data) { spiSend(reg | 0x02); spiSend(data); ncs(); -}; +} // multiple-byte write // return a pointer to memory position after last written @@ -76,8 +75,8 @@ uint8_t MAX3421e::regRd(uint8_t reg) { ncs(); return rv; } -// multiple-byte register read +// multiple-byte register read // return a pointer to a memory position after last read uint8_t* MAX3421e::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p) { cs(); @@ -86,8 +85,8 @@ uint8_t* MAX3421e::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p) { ncs(); return data_p; } -// GPIO read. See gpioWr for explanation +// GPIO read. See gpioWr for explanation // GPIN pins are in high nybbles of IOPINS1, IOPINS2 uint8_t MAX3421e::gpioRd() { return (regRd(rIOPINS2) & 0xF0) | // pins 4-7, clean lower nybble diff --git a/README.md b/README.md index 72b354d4feb6..e54c8f093a7e 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,16 @@ -# Marlin 3D Printer Firmware +

MarlinFirmware's logo

-![GitHub](https://img.shields.io/github/license/marlinfirmware/marlin.svg) -![GitHub contributors](https://img.shields.io/github/contributors/marlinfirmware/marlin.svg) -![GitHub Release Date](https://img.shields.io/github/release-date/marlinfirmware/marlin.svg) -[![Build Status](https://github.com/MarlinFirmware/Marlin/workflows/CI/badge.svg?branch=bugfix-2.0.x)](https://github.com/MarlinFirmware/Marlin/actions) +

Marlin 3D Printer Firmware

- +

+ GPL-V3.0 License + Contributors + Last Release Date + CI Status + GitHub Sponsors +
+ Follow MarlinFirmware on Twitter +

Additional documentation can be found at the [Marlin Home Page](https://marlinfw.org/). Please test this firmware and let us know if it misbehaves in any way. Volunteers are standing by! @@ -32,11 +37,11 @@ To build Marlin 2.0 you'll need [Arduino IDE 1.8.8 or newer](https://www.arduino Platform|MCU|Example Boards --------|---|------- [Arduino AVR](https://www.arduino.cc/)|ATmega|RAMPS, Melzi, RAMBo - [Teensy++ 2.0](http://www.microchip.com/wwwproducts/en/AT90USB1286)|AT90USB1286|Printrboard + [Teensy++ 2.0](https://www.microchip.com/en-us/product/AT90USB1286)|AT90USB1286|Printrboard [Arduino Due](https://www.arduino.cc/en/Guide/ArduinoDue)|SAM3X8E|RAMPS-FD, RADDS, RAMPS4DUE [ESP32](https://github.com/espressif/arduino-esp32)|ESP32|FYSETC E4, E4d@BOX, MRR - [LPC1768](http://www.nxp.com/products/microcontrollers-and-processors/arm-based-processors-and-mcus/lpc-cortex-m-mcus/lpc1700-cortex-m3/512kb-flash-64kb-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/512kb-flash-64kb-sram-ethernet-usb-lqfp100-package:LPC1769FBD100)|ARM® Cortex-M3|Smoothieboard, Azteeg X5 mini, TH3D EZBoard + [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 [STM32F7x6](https://www.st.com/en/microcontrollers-microprocessors/stm32f7x6.html)|ARM® Cortex-M7|The Borg, RemRam V1 @@ -57,10 +62,10 @@ To build Marlin 2.0 you'll need [Arduino IDE 1.8.8 or newer](https://www.arduino The Issue Queue is reserved for Bug Reports and Feature Requests. To get help with configuration and troubleshooting, please use the following resources: -- [Marlin Documentation](http://marlinfw.org) - Official Marlin documentation +- [Marlin Documentation](https://marlinfw.org) - Official Marlin documentation - [Marlin Discord](https://discord.gg/n5NJ59y) - Discuss issues with Marlin users and developers - Facebook Group ["Marlin Firmware"](https://www.facebook.com/groups/1049718498464482/) -- RepRap.org [Marlin Forum](http://forums.reprap.org/list.php?415) +- 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 @@ -72,15 +77,16 @@ 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://api.flattr.com/button/flattr-badge-large.png)](http://www.thinkyhead.com/donate-to-marlin) + - 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 + - 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   [![Flattr Erik](https://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=ErikZalm&url=https://github.com/MarlinFirmware/Marlin&title=Marlin&language=&tags=github&category=software) + - Erik van der Zalm [[@ErikZalm](https://github.com/ErikZalm)] - Netherlands   [💸 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_example b/buildroot/bin/build_example index 8ebb58f972e1..cff8ea253e62 100755 --- a/buildroot/bin/build_example +++ b/buildroot/bin/build_example @@ -24,6 +24,6 @@ cp "$SUB"/_Statusscreen.h Marlin/ 2>/dev/null echo "Building the firmware now..." HERE=`dirname "$0"` -$HERE/mftest -a -n1 || { echo "Failed"; exit 1; } +$HERE/mftest -s -a -n1 || { echo "Failed"; exit 1; } echo "Success" diff --git a/buildroot/bin/mftest b/buildroot/bin/mftest index 9a58ba9cfcd2..9aa5e127327e 100755 --- a/buildroot/bin/mftest +++ b/buildroot/bin/mftest @@ -17,6 +17,7 @@ usage() { Usage: mftest [-t|--env=] [-n|--num=] [-m|--make] [-y|--build=] mftest [-a|--autobuild] mftest [-r|--rebuild] + mftest [-s|--silent] mftest [-u|--autoupload] [-n|--num=] OPTIONS @@ -30,7 +31,7 @@ OPTIONS -v --verbose Extra output for debugging. -s --silent Silence build output from PlatformIO. -env shortcuts: tree due esp lin lpc|lpc8 lpc9 m128 m256|mega stm|f1 f4 f7 s6 teensy|t31|t32 t35|t36 t40|t41 +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 " } @@ -52,7 +53,7 @@ TESTENV='-' CHOICE=0 DEBUG=0 -while getopts 'abhmruvyn:t:-:' OFLAG; do +while getopts 'abhmrsuvyn:t:-:' OFLAG; do case "${OFLAG}" in a) AUTO_BUILD=1 ; bugout "Auto-Build target..." ;; h) EXIT_USAGE=1 ;; @@ -84,6 +85,7 @@ while getopts 'abhmruvyn:t:-:' OFLAG; do esac ;; rebuild) REBUILD=1 ; bugout "Rebuilding previous..." ;; + silent) SILENT_FLAG="-s" ;; make) USE_MAKE=1 ; bugout "Using make with Docker..." ;; debug|verbose) DEBUG=1 ; bugout "Debug ON" ;; build) case "$OVAL" in @@ -150,7 +152,7 @@ if ((AUTO_BUILD)); then *) SYS='uni' ;; esac echo ; echo -n "Auto " ; ((AUTO_BUILD == 2)) && echo "Upload..." || echo "Build..." - MB=$( grep -E "^\s*#define MOTHERBOARD" Marlin/Configuration.h | awk '{ print $3 }' | $SED 's/BOARD_//' ) + MB=$( grep -E "^\s*#define MOTHERBOARD" Marlin/Configuration.h | awk '{ print $3 }' | $SED 's/BOARD_//;s/\r//' ) [[ -z $MB ]] && { echo "Error - Can't read MOTHERBOARD setting." ; exit 1 ; } BLINE=$( grep -E "define\s+BOARD_$MB\b" Marlin/src/core/boards.h ) BNUM=$( $SED -E 's/^.+BOARD_[^ ]+ +([0-9]+).+$/\1/' <<<"$BLINE" ) diff --git a/buildroot/bin/use_example_configs b/buildroot/bin/use_example_configs index 83c0f5485d2c..bfd4aa612f0e 100755 --- a/buildroot/bin/use_example_configs +++ b/buildroot/bin/use_example_configs @@ -1,8 +1,20 @@ #!/usr/bin/env bash +# +# use_example_configs [repo:]configpath +# +# Examples: +# 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 +# + +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=bugfix-2.0.x ; RDIR="${PART1// /%20}" ; } +[[ -n $PART2 ]] && { REPO="$PART1" ; RDIR="${PART2// /%20}" ; } \ + || { REPO=$BRANCH ; RDIR="${PART1// /%20}" ; } EXAMPLES="https://github.com/raw/MarlinFirmware/Configurations/$REPO/config/examples" which curl >/dev/null && TOOL='curl -L -s -S -f -o wgot' @@ -12,6 +24,8 @@ 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 diff --git a/buildroot/share/PlatformIO/boards/marlin_CREALITY_STM32F401RC.json b/buildroot/share/PlatformIO/boards/marlin_CREALITY_STM32F401RC.json new file mode 100644 index 000000000000..82f49fa815d6 --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_CREALITY_STM32F401RC.json @@ -0,0 +1,65 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m4", + "extra_flags": "-DSTM32F401xx", + "f_cpu": "84000000L", + "hwids": [ + [ + "0x1EAF", + "0x0003" + ], + [ + "0x0483", + "0x3748" + ] + ], + "ldscript": "ldscript.ld", + "mcu": "stm32f401rct6", + "variant": "MARLIN_CREALITY_STM32F401RC" + }, + "debug": { + "jlink_device": "STM32F401RC", + "openocd_target": "stm32f4x", + "svd_path": "STM32F40x.svd", + "tools": { + "stlink": { + "server": { + "arguments": [ + "-f", + "scripts/interface/stlink.cfg", + "-c", + "transport select hla_swd", + "-f", + "scripts/target/stm32f4x.cfg", + "-c", + "reset_config none" + ], + "executable": "bin/openocd", + "package": "tool-openocd" + } + } + } + }, + "frameworks": [ + "arduino", + "stm32cube" + ], + "name": "STM32F401RC (64k RAM. 256k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 65536, + "maximum_size": 262144, + "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/stm32f401rc.html", + "vendor": "Generic" +} diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32F407VET6_CCM.json b/buildroot/share/PlatformIO/boards/marlin_STM32F407VET6_CCM.json new file mode 100644 index 000000000000..faf32c200e47 --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_STM32F407VET6_CCM.json @@ -0,0 +1,56 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m4", + "extra_flags": "-DSTM32F407xx -DSTM32F4", + "f_cpu": "168000000L", + "hwids": [ + [ + "0x1EAF", + "0x0003" + ], + [ + "0x0483", + "0x3748" + ] + ], + "mcu": "stm32f407vet6", + "product_line": "STM32F407xx", + "variant": "Generic_F4x7Vx" + }, + "debug": { + "default_tools": [ + "stlink" + ], + "jlink_device": "STM32F407VE", + "openocd_extra_args": [ + "-c", + "reset_config none" + ], + "openocd_target": "stm32f4x", + "svd_path": "STM32F40x.svd" + }, + "frameworks": [ + "arduino", + "cmsis", + "stm32cube", + "libopencm3" + ], + "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" + ], + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32-high-performance-mcus/stm32f4-series/stm32f407-417/stm32f407vg.html", + "vendor": "Generic" +} diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32G0B1RE.json b/buildroot/share/PlatformIO/boards/marlin_STM32G0B1RE.json index 86f632f53b8d..28c3451b4cdb 100644 --- a/buildroot/share/PlatformIO/boards/marlin_STM32G0B1RE.json +++ b/buildroot/share/PlatformIO/boards/marlin_STM32G0B1RE.json @@ -9,7 +9,7 @@ }, "mcu": "stm32g0b1ret6", "product_line": "STM32G0B1xx", - "variant": "STM32G0xx/MARLIN_G0B1RE" + "variant": "MARLIN_G0B1RE" }, "debug": { "default_tools": [ diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32H743Vx.json b/buildroot/share/PlatformIO/boards/marlin_STM32H743Vx.json new file mode 100644 index 000000000000..3b8fa73060b7 --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_STM32H743Vx.json @@ -0,0 +1,61 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m7", + "extra_flags": "-DSTM32H7xx -DSTM32H743xx", + "f_cpu": "400000000L", + "mcu": "stm32h743vit6", + "product_line": "STM32H743xx", + "variant": "MARLIN_H743Vx" + }, + "connectivity": [ + "can", + "ethernet" + ], + "debug": { + "jlink_device": "STM32H743VI", + "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": "STM32H743VI (1024k RAM. 2048k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 1048576, + "maximum_size": 2097152, + "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/stm32h743vi.html", + "vendor": "ST" +} diff --git a/buildroot/share/PlatformIO/boards/marlin_index_mobo_rev03.json b/buildroot/share/PlatformIO/boards/marlin_index_mobo_rev03.json index c65f1dd70356..ef5ebfa56066 100644 --- a/buildroot/share/PlatformIO/boards/marlin_index_mobo_rev03.json +++ b/buildroot/share/PlatformIO/boards/marlin_index_mobo_rev03.json @@ -5,6 +5,10 @@ "extra_flags": "-DSTM32F407xx", "f_cpu": "168000000L", "hwids": [ + [ + "0x0483", + "0xdf11" + ], [ "0x1EAF", "0x0003" @@ -12,10 +16,6 @@ [ "0x0483", "0x3748" - ], - [ - "0x0483", - "0xdf11" ] ], "mcu": "stm32f407vet6", @@ -35,7 +35,7 @@ "disable_flushing": false, "maximum_ram_size": 131072, "maximum_size": 524288, - "protocol": "stlink", + "protocol": "dfu", "protocols": [ "stlink", "dfu", diff --git a/buildroot/share/PlatformIO/boards/marlin_CHITU_F103.json b/buildroot/share/PlatformIO/boards/marlin_maple_CHITU_F103.json similarity index 95% rename from buildroot/share/PlatformIO/boards/marlin_CHITU_F103.json rename to buildroot/share/PlatformIO/boards/marlin_maple_CHITU_F103.json index dbfbc21cb275..45c80b3ec037 100644 --- a/buildroot/share/PlatformIO/boards/marlin_CHITU_F103.json +++ b/buildroot/share/PlatformIO/boards/marlin_maple_CHITU_F103.json @@ -15,7 +15,7 @@ ] ], "mcu": "stm32f103zet6", - "variant": "marlin_CHITU_F103" + "variant": "marlin_maple_CHITU_F103" }, "debug": { "jlink_device": "STM32F103ZE", diff --git a/buildroot/share/PlatformIO/boards/marlin_MEEB_3DP.json b/buildroot/share/PlatformIO/boards/marlin_maple_MEEB_3DP.json similarity index 96% rename from buildroot/share/PlatformIO/boards/marlin_MEEB_3DP.json rename to buildroot/share/PlatformIO/boards/marlin_maple_MEEB_3DP.json index 73ec9aaf48e2..54fd5fbed950 100644 --- a/buildroot/share/PlatformIO/boards/marlin_MEEB_3DP.json +++ b/buildroot/share/PlatformIO/boards/marlin_maple_MEEB_3DP.json @@ -18,7 +18,7 @@ "ldscript": "stm32f103xc.ld" }, "mcu": "stm32f103rct6", - "variant": "marlin_MEEB_3DP" + "variant": "marlin_maple_MEEB_3DP" }, "debug": { "jlink_device": "STM32F103RC", diff --git a/buildroot/share/PlatformIO/debugging/launch.json b/buildroot/share/PlatformIO/debugging/launch.json index 335c4c663e89..583d860eb36c 100644 --- a/buildroot/share/PlatformIO/debugging/launch.json +++ b/buildroot/share/PlatformIO/debugging/launch.json @@ -12,26 +12,17 @@ "version": "0.2.0", "configurations": [ { - "name": "Debug STM32 (launch)", + "name": "Debug STM32 (ST-Link)", "request": "launch", "type": "cortex-debug", "servertype": "openocd", "cwd": "${workspaceRoot}", "showDevDebugOutput": false, "configFiles": [ "interface/stlink.cfg", "target/stm32f4x.cfg" ], - "device": "STM32F407", - "executable": ".pio/build/BIGTREE_SKR_2_USB_debug/firmware.elf", - }, - { - "name": "Debug STM32 (attach)", - "request": "attach", - "type": "cortex-debug", - "servertype": "openocd", - "cwd": "${workspaceRoot}", - "showDevDebugOutput": false, - "configFiles": [ "interface/stlink.cfg", "target/stm32f4x.cfg" ], - "device": "STM32F407", - "executable": ".pio/build/BIGTREE_SKR_2_USB_debug/firmware.elf", + "device": "stlink", + "executable": "${workspaceRoot}/.pio/build/BIGTREE_SKR_2_USB_debug/firmware.elf", + "openOCDLaunchCommands": [ "init", "reset init" ], + "svdFile": "${env:HOME}/.platformio/platforms/ststm32@12.1.1/misc/svd/STM32F40x.svd", }, { "name": "Debug Sim", diff --git a/buildroot/share/PlatformIO/ldscripts/fysetc_stm32f103rc.ld b/buildroot/share/PlatformIO/ldscripts/crealityPro.ld similarity index 50% rename from buildroot/share/PlatformIO/ldscripts/fysetc_stm32f103rc.ld rename to buildroot/share/PlatformIO/ldscripts/crealityPro.ld index 6777e5918262..442c5c75078f 100644 --- a/buildroot/share/PlatformIO/ldscripts/fysetc_stm32f103rc.ld +++ b/buildroot/share/PlatformIO/ldscripts/crealityPro.ld @@ -1,11 +1,7 @@ -/* - * Linker script for Generic STM32F103RC boards, using the generic bootloader (which takes the lower 8k of memory) - */ - MEMORY { - ram (rwx) : ORIGIN = 0x20000000, LENGTH = 48K - rom (rx) : ORIGIN = 0x08008000, LENGTH = 256K - 32K + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - 40 + rom (rx) : ORIGIN = 0x08010000, LENGTH = 512K - 64K } /* Provide memory region aliases for common.inc */ @@ -15,4 +11,4 @@ REGION_ALIAS("REGION_BSS", ram); REGION_ALIAS("REGION_RODATA", rom); /* Let common.inc handle the real work. */ -INCLUDE common.inc +INCLUDE common.inc \ No newline at end of file diff --git a/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py b/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py index eccee7606804..551f4c63160b 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py +++ b/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py @@ -4,29 +4,9 @@ import pioutil if pioutil.is_pio_build(): - try: - import configparser - except ImportError: - import ConfigParser as configparser - import os Import("env", "projenv") - config = configparser.ConfigParser() - config.read("platformio.ini") - - # - # Upload actions - # - def before_upload(source, target, env): - env.Execute("pwd") - - def after_upload(source, target, env): - env.Execute("pwd") - - env.AddPreAction("upload", before_upload) - env.AddPostAction("upload", after_upload) - flash_size = 0 vect_tab_addr = 0 @@ -38,6 +18,3 @@ def after_upload(source, target, env): 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)) - - import marlin - marlin.custom_ld_script("STM32F103RC_MEEB_3DP.ld") diff --git a/buildroot/share/PlatformIO/scripts/common-cxxflags.py b/buildroot/share/PlatformIO/scripts/common-cxxflags.py index 4a48e44742da..1e8f0dcb0552 100644 --- a/buildroot/share/PlatformIO/scripts/common-cxxflags.py +++ b/buildroot/share/PlatformIO/scripts/common-cxxflags.py @@ -29,7 +29,7 @@ def add_cpu_freq(): # It useful to keep two live versions: a debug version for debugging and another for # release, for flashing when upload is not done automatically by jlink/stlink. # Without this, PIO needs to recompile everything twice for any small change. - if env.GetBuildType() == "debug" and env.get('UPLOAD_PROTOCOL') not in ['jlink', 'stlink']: + if env.GetBuildType() == "debug" and env.get('UPLOAD_PROTOCOL') not in ['jlink', 'stlink', 'custom']: env['BUILD_DIR'] = '$PROJECT_BUILD_DIR/$PIOENV/debug' # On some platform, F_CPU is a runtime variable. Since it's used to convert from ns diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.h b/buildroot/share/PlatformIO/scripts/common-dependencies.h index a88e7084670b..da2d380a82b6 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.h +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.h @@ -45,19 +45,15 @@ #define HAS_SAVED_POSITIONS #endif -#if ENABLED(HOST_PROMPT_SUPPORT) && DISABLED(EMERGENCY_PARSER) - #define HAS_GCODE_M876 -#endif - #if ENABLED(DUET_SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD) #define HAS_SMART_EFF_MOD #endif -#if HAS_LCD_MENU +#if HAS_MARLINUI_MENU #if ENABLED(BACKLASH_GCODE) #define HAS_MENU_BACKLASH #endif - #if ENABLED(LEVEL_BED_CORNERS) + #if ENABLED(LCD_BED_TRAMMING) #define HAS_MENU_BED_CORNERS #endif #if ENABLED(CANCEL_OBJECTS) diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.py b/buildroot/share/PlatformIO/scripts/common-dependencies.py index 24e780d9b670..e9e8c7918767 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.py +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.py @@ -15,7 +15,7 @@ FEATURE_CONFIG = {} def validate_pio(): - PIO_VERSION_MIN = (5, 0, 3) + PIO_VERSION_MIN = (6, 0, 1) try: from platformio import VERSION as PIO_VERSION weights = (1000, 100, 1) @@ -174,7 +174,7 @@ def apply_features_config(): env.SConscript(feat['extra_scripts'], exports="env") if 'src_filter' in feat: - blab("========== Adding src_filter for %s... " % feature, 2) + 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']) @@ -184,7 +184,7 @@ def apply_features_config(): src_filter = re.sub(r'[+-]' + d, '', src_filter) src_filter = feat['src_filter'] + ' ' + src_filter - set_env_field('src_filter', [src_filter]) + set_env_field('build_src_filter', [src_filter]) env.Replace(SRC_FILTER=src_filter) if 'lib_ignore' in feat: diff --git a/buildroot/share/PlatformIO/scripts/marlin.py b/buildroot/share/PlatformIO/scripts/marlin.py index 2114a05fb388..8ac36b7d59b5 100644 --- a/buildroot/share/PlatformIO/scripts/marlin.py +++ b/buildroot/share/PlatformIO/scripts/marlin.py @@ -49,13 +49,8 @@ def encrypt_mks(source, target, env, new_name): 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 - import re - patt = re.compile("^\\s*#define\\s+FIRMWARE_BIN\\s+\"?(.+)\"?") - with open(join("Marlin", "Configuration.h"), encoding="utf-8") as f: - for line in f: - m = patt.search(line) - if m != None: - new_name = m.group(1) + mf = env["MARLIN_FEATURES"] + if "FIRMWARE_BIN" in mf: new_name = mf["FIRMWARE_BIN"] fwpath = target[0].path fwfile = open(fwpath, "rb") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin.py b/buildroot/share/PlatformIO/scripts/mks_robin.py deleted file mode 100644 index 7b423bedabc7..000000000000 --- a/buildroot/share/PlatformIO/scripts/mks_robin.py +++ /dev/null @@ -1,5 +0,0 @@ -# -# mks_robin.py -# -import robin -robin.prepare("0x08007000", "mks_robin.ld", "Robin.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_e3.py b/buildroot/share/PlatformIO/scripts/mks_robin_e3.py deleted file mode 100644 index 645230c625c2..000000000000 --- a/buildroot/share/PlatformIO/scripts/mks_robin_e3.py +++ /dev/null @@ -1,5 +0,0 @@ -# -# mks_robin_e3.py -# -import robin -robin.prepare("0x08005000", "mks_robin_e3.ld", "Robin_e3.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py b/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py deleted file mode 100644 index bb15cb5a70f2..000000000000 --- a/buildroot/share/PlatformIO/scripts/mks_robin_e3p.py +++ /dev/null @@ -1,5 +0,0 @@ -# -# mks_robin_e3p.py -# -import robin -robin.prepare("0x08007000", "mks_robin_e3p.ld", "Robin_e3p.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_lite.py b/buildroot/share/PlatformIO/scripts/mks_robin_lite.py deleted file mode 100644 index 123b043f7cfb..000000000000 --- a/buildroot/share/PlatformIO/scripts/mks_robin_lite.py +++ /dev/null @@ -1,5 +0,0 @@ -# -# mks_robin_lite.py -# -import robin -robin.prepare("0x08005000", "mks_robin_lite.ld", "mksLite.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_lite3.py b/buildroot/share/PlatformIO/scripts/mks_robin_lite3.py deleted file mode 100644 index 092231eae81f..000000000000 --- a/buildroot/share/PlatformIO/scripts/mks_robin_lite3.py +++ /dev/null @@ -1,5 +0,0 @@ -# -# mks_robin_lite3.py -# -import robin -robin.prepare("0x08005000", "mks_robin_lite.ld", "mksLite3.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_mini.py b/buildroot/share/PlatformIO/scripts/mks_robin_mini.py deleted file mode 100644 index d1d175dd1c17..000000000000 --- a/buildroot/share/PlatformIO/scripts/mks_robin_mini.py +++ /dev/null @@ -1,5 +0,0 @@ -# -# mks_robin_mini.py -# -import robin -robin.prepare("0x08007000", "mks_robin_mini.ld", "Robin_mini.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_nano.py b/buildroot/share/PlatformIO/scripts/mks_robin_nano.py deleted file mode 100644 index 32d1af23662c..000000000000 --- a/buildroot/share/PlatformIO/scripts/mks_robin_nano.py +++ /dev/null @@ -1,5 +0,0 @@ -# -# mks_robin_nano.py -# -import robin -robin.prepare("0x08007000", "mks_robin_nano.ld", "Robin_nano.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py b/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py deleted file mode 100644 index 7e635bd6ecf7..000000000000 --- a/buildroot/share/PlatformIO/scripts/mks_robin_nano35.py +++ /dev/null @@ -1,5 +0,0 @@ -# -# mks_robin_nano35.py -# -import robin -robin.prepare("0x08007000", "mks_robin_nano.ld", "Robin_nano35.bin") diff --git a/buildroot/share/PlatformIO/scripts/mks_robin_pro.py b/buildroot/share/PlatformIO/scripts/mks_robin_pro.py deleted file mode 100644 index 54526aeaef57..000000000000 --- a/buildroot/share/PlatformIO/scripts/mks_robin_pro.py +++ /dev/null @@ -1,5 +0,0 @@ -# -# mks_robin_pro.py -# -import robin -robin.prepare("0x08007000", "mks_robin_pro.ld", "Robin_pro.bin") diff --git a/buildroot/share/PlatformIO/scripts/offset_and_rename.py b/buildroot/share/PlatformIO/scripts/offset_and_rename.py index 00803b722eff..ddbb786fecd1 100644 --- a/buildroot/share/PlatformIO/scripts/offset_and_rename.py +++ b/buildroot/share/PlatformIO/scripts/offset_and_rename.py @@ -57,7 +57,6 @@ def encrypt(source, target, env): def rename_target(source, target, env): firmware = os.path.join(target[0].dir.path, board.get("build.rename")) - import shutil - shutil.copy(target[0].path, firmware) + os.replace(target[0].path, firmware) marlin.add_post_action(rename_target) diff --git a/buildroot/share/PlatformIO/scripts/preflight-checks.py b/buildroot/share/PlatformIO/scripts/preflight-checks.py index 9f38ffe8bfa2..dbd0510b5dff 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -102,6 +102,10 @@ def sanity_check_target(): 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) diff --git a/buildroot/share/PlatformIO/scripts/preprocessor.py b/buildroot/share/PlatformIO/scripts/preprocessor.py index 6f4ed900cab1..d9c472006c28 100644 --- a/buildroot/share/PlatformIO/scripts/preprocessor.py +++ b/buildroot/share/PlatformIO/scripts/preprocessor.py @@ -3,6 +3,7 @@ # import subprocess,os,re +nocache = 1 verbose = 0 def blab(str): @@ -50,7 +51,7 @@ def run_preprocessor(env, fn=None): # def search_compiler(env): - ENV_BUILD_PATH = os.path.join(env.Dictionary('PROJECT_BUILD_DIR'), env['PIOENV']) + ENV_BUILD_PATH = os.path.join(env['PROJECT_BUILD_DIR'], env['PIOENV']) GCC_PATH_CACHE = os.path.join(ENV_BUILD_PATH, ".gcc_path") try: @@ -60,7 +61,8 @@ def search_compiler(env): except: pass - if os.path.exists(GCC_PATH_CACHE): + # 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() @@ -87,7 +89,7 @@ def search_compiler(env): # 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 os.path.exists(ENV_BUILD_PATH): + 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) diff --git a/buildroot/share/PlatformIO/scripts/robin.py b/buildroot/share/PlatformIO/scripts/robin.py deleted file mode 100644 index ffc9a43b9004..000000000000 --- a/buildroot/share/PlatformIO/scripts/robin.py +++ /dev/null @@ -1,14 +0,0 @@ -# -# robin.py -# - -# Apply customizations for a MKS Robin -def prepare(address, ldname, fwname): - import pioutil - if pioutil.is_pio_build(): - import marlin - def encrypt(source, target, env): - marlin.encrypt_mks(source, target, env, fwname) - marlin.relocate_firmware(address) - marlin.custom_ld_script(ldname) - marlin.add_post_action(encrypt); diff --git a/buildroot/share/PlatformIO/scripts/signature.py b/buildroot/share/PlatformIO/scripts/signature.py index 654e3ea67738..593f9580b330 100644 --- a/buildroot/share/PlatformIO/scripts/signature.py +++ b/buildroot/share/PlatformIO/scripts/signature.py @@ -163,7 +163,9 @@ def compute_build_signature(env): # Generate a C source file for storing this array with open('Marlin/src/mczip.h','wb') as result_file: - result_file.write(b'#warning "Generated file \'mc.zip\' is embedded"\n') + 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(): diff --git a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/startup.S b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/startup.S new file mode 100644 index 000000000000..81999dda6a42 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/startup.S @@ -0,0 +1,124 @@ + /** + ****************************************************************************** + * @file startup_stm32f401xc.s + * @author MCD Application Team + * @version V2.4.2 + * @date 13-November-2015 + * @brief STM32F401xCxx Devices vector table for GCC based toolchains. + * This module performs: + * - Set the initial SP + * - Set the initial PC == Reset_Handler, + * - Set the vector table entries with the exceptions ISR address + * - Branches to main in the C library (which eventually + * calls main()). + * After Reset the Cortex-M4 processor is in Thread mode, + * priority is Privileged, and the Stack is set to Main. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2015 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. + * + ****************************************************************************** + */ + + .syntax unified + .cpu cortex-m4 + .fpu softvfp + .thumb + +/** + * @brief This is the code that gets called when the processor first + * starts execution following a reset event. Only the absolutely + * necessary set is performed, after which the application + * supplied main() routine is called. + * @param None + * @retval : None + */ + + .section .text.Reset_Handler + .globl Reset_Handler + .type Reset_Handler, %function +Reset_Handler: +/* Check for magic code at the end of SRAM to detemine whether to jump to DFU */ + ldr r0, =0x2000FFF0 // End of SRAM for your CPU + ldr r1, =0xDEADBEEF + ldr r2, [r0, #0] + str r0, [r0, #0] // Invalidate + cmp r2, r1 + beq Jump_To_DFU + +/* Original Reset_Handler code */ + ldr sp, =_estack /* set stack pointer */ + +/* Copy the data segment initializers from flash to SRAM */ + movs r1, #0 + b LoopCopyDataInit + +CopyDataInit: + ldr r3, =_sidata + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 + +LoopCopyDataInit: + ldr r0, =_sdata + ldr r3, =_edata + adds r2, r0, r1 + cmp r2, r3 + bcc CopyDataInit + ldr r2, =_sbss + b LoopFillZerobss +/* Zero fill the bss segment. */ +FillZerobss: + movs r3, #0 + str r3, [r2], #4 + +LoopFillZerobss: + ldr r3, = _ebss + cmp r2, r3 + bcc FillZerobss + +/* Call the clock system intitialization function.*/ + bl SystemInit +/* Call static constructors */ + bl __libc_init_array +/* Call the application's entry point.*/ + bl main + bx lr + +Jump_To_DFU: + ldr r0, =0x40023844 // RCC_APB2ENR + ldr r1, =0x00004000 // ENABLE SYSCFG CLOCK + str r1, [r0, #0] + ldr r0, =0x40013800 // SYSCFG_MEMRMP + ldr r1, =0x00000001 // MAP ROM AT ZERO + str r1, [r0, #0] + ldr r0, =0x1FFF0000 // ROM BASE + ldr sp, [r0, #0] // SP @ +0 + ldr r0, [r0, #4] // PC @ +4 + bx r0 +.size Reset_Handler, .-Reset_Handler + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/variant.h index 0c66ae89b88a..ca7a53d7827b 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/variant.h @@ -107,8 +107,8 @@ extern "C" { // TIM9 - STEP_TIMER // TIM10 - TEMP_TIMER // TIM11 - -#define TIMER_SERVO TIM2 -#define TIMER_TONE TIM5 +#define TIMER_SERVO TIM2 // TIMER_SERVO must be defined in this file +#define TIMER_TONE TIM5 // TIMER_TONE must be defined in this file // UART Definitions #define SERIAL_UART_INSTANCE 1 diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h index 56574501002d..068d0b9ee587 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/variant.h @@ -245,9 +245,9 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c -#define TIMER_TONE TIM7 -#define TIMER_SERVO TIM5 -#define TIMER_SERIAL TIM2 +#define TIMER_TONE TIM7 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file +#define TIMER_SERIAL TIM2 // TIMER_SERIAL must be defined in this file // UART Definitions // Define here Serial instance number to map on Serial generic name 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 646d635679f6..edc1c91c5374 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/variant.h @@ -245,9 +245,9 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c -#define TIMER_TONE TIM7 -#define TIMER_SERVO TIM5 -#define TIMER_SERIAL TIM8 +#define TIMER_TONE TIM7 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM5 // TIMER_SERVO must be defined in this file +#define TIMER_SERIAL TIM8 // TIMER_SERIAL must be defined in this file // UART Definitions // Define here Serial instance number to map on Serial generic name 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 41e46411022c..2c70693991ed 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/variant.h @@ -255,9 +255,9 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c -#define TIMER_TONE TIM10 -#define TIMER_SERVO TIM5 -#define TIMER_SERIAL TIM7 +#define TIMER_TONE TIM10 // 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 ENABLE_HWSERIAL1 done automatically by the #define SERIAL_UART_INSTANCE below diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429/variant.h index 0147ece0ab20..b8e4b9667e80 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429/variant.h @@ -141,10 +141,10 @@ extern "C" { #define PG15 111 //D79 // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 125 +#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 112 +#define NUM_ANALOG_FIRST NUM_DIGITAL_PINS //#define ADC_RESOLUTION 12 @@ -165,9 +165,9 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pin. See PinMap_PWM. -#define TIMER_TONE TIM6 -#define TIMER_SERVO TIM5 -#define TIMER_SERIAL TIM7 +#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 diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/variant.h index f512a311e32c..22b919697027 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/variant.h @@ -141,10 +141,10 @@ extern "C" { #define PG15 111 //D79 // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 125 +#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 112 +#define NUM_ANALOG_FIRST NUM_DIGITAL_PINS //#define ADC_RESOLUTION 12 @@ -165,9 +165,9 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pin. See PinMap_PWM. -#define TIMER_TONE TIM6 -#define TIMER_SERVO TIM5 -#define TIMER_SERIAL TIM7 +#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 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 11ebf561f36c..b5cf0bad9d50 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 @@ -255,9 +255,9 @@ extern "C" { // 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 // Only 1 Servo PIN on SKR-PRO, so use the same timer as defined in PeripheralPins -#define TIMER_SERIAL TIM7 +#define TIMER_TONE TIM2 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM5 // Only 1 Servo PIN on SKR-PRO, so use the same timer as defined in PeripheralPins +#define TIMER_SERIAL TIM7 // TIMER_SERIAL must be defined in this file // UART Definitions //#define ENABLE_HWSERIAL1 done automatically by the #define SERIAL_UART_INSTANCE below 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 74f29514a885..285ad662e0fe 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 @@ -157,9 +157,9 @@ extern "C" { // 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 +#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_SERIAL TIM7 // TIMER_SERIAL must be defined in this file // UART1 for TFT port #define ENABLE_HWSERIAL1 diff --git a/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/PeripheralPins.c new file mode 100644 index 000000000000..418ef5aa7abc --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/PeripheralPins.c @@ -0,0 +1,252 @@ +/* + ******************************************************************************* + * 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 STM32F401R[(B-C)|(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 + {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)}, + {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)}, + {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)}, + {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)}, + {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 + +//*** No CAN *** + +//*** No ETHERNET *** + +//*** No QUADSPI *** + +//*** USB *** + +#ifdef HAL_PCD_MODULE_ENABLED +WEAK const PinMap PinMap_USB_OTG_FS[] = { +#ifndef ARDUINO_CoreBoard_F401RC + {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 +#endif + {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_CREALITY_STM32F401RC/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/PinNamesVar.h new file mode 100644 index 000000000000..e1536bcf30f4 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/PinNamesVar.h @@ -0,0 +1,33 @@ +/* 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, +#endif \ No newline at end of file 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 new file mode 100644 index 000000000000..1dd047bb9005 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/hal_conf_custom.h @@ -0,0 +1,495 @@ +/** + ****************************************************************************** + * @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_CRC_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_IWDG_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_RTC_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_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_EXTI_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_SD_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_HCD_MODULE_ENABLED +//#define HAL_FMPI2C_MODULE_ENABLED +//#define HAL_SPDIFRX_MODULE_ENABLED +//#define HAL_DFSDM_MODULE_ENABLED +//#define HAL_LPTIM_MODULE_ENABLED +//#define HAL_MMC_MODULE_ENABLED + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#ifndef HSE_VALUE +#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#ifndef HSE_STARTUP_TIMEOUT +#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 + */ +#if !defined (VDD_VALUE) +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#endif +#if !defined (TICK_INT_PRIORITY) +#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */ +#endif +#if !defined (USE_RTOS) +#define USE_RTOS 0U +#endif +#if !defined (PREFETCH_ENABLE) +#define PREFETCH_ENABLE 1U +#endif +#if !defined (INSTRUCTION_CACHE_ENABLE) +#define INSTRUCTION_CACHE_ENABLE 1U +#endif +#if !defined (DATA_CACHE_ENABLE) +#define DATA_CACHE_ENABLE 1U +#endif + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848_PHY_ADDRESS Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x000000FFU +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY 0x00000FFFU + +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ +#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver + * Activated: CRC code is present inside driver + * Deactivated: CRC code cleaned from driver + */ +#ifndef USE_SPI_CRC +#define USE_SPI_CRC 0U +#endif + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED +#include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED +#include "stm32f4xx_hal_gpio.h" +#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_CUSTOM_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/ldscript.ld new file mode 100644 index 000000000000..004714cd6dc0 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/ldscript.ld @@ -0,0 +1,187 @@ +/* +***************************************************************************** +** + +** File : LinkerScript.ld +** +** Abstract : Linker script for STM32F401RETx Device with +** 512KByte FLASH, 96KByte 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 = 0x20010000; /* 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 = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +RAM (xrw) : ORIGIN = 0x20000000, 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); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM AT> FLASH + + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(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) } +} \ No newline at end of file diff --git a/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/variant.cpp new file mode 100644 index 000000000000..71f3509ed57b --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/variant.cpp @@ -0,0 +1,238 @@ +/* + 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 + +// 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_12, // Digital pin 27 + PB_13, // Digital pin 28 + PB_14, // Digital pin 29 + PB_15, // Digital pin 30 + + PC_0, // Digital pin 31 + PC_1, // Digital pin 32 + PC_2, // Digital pin 33 + PC_3, // Digital pin 34 + PC_4, // Digital pin 35 + PC_5, // Digital pin 36 + PC_6, // Digital pin 37 + PC_7, // Digital pin 38 + PC_8, // Digital pin 39 + PC_9, // Digital pin 40 + PC_10, // Digital pin 41 + PC_11, // Digital pin 42 + PC_12, // Digital pin 43 + PC_13, // Digital pin 44 + PC_14, // Digital pin 45 + PC_15, // Digital pin 46 + + PD_2, // Digital pin 47 + + PH_0, // Digital pin 48, used by the external oscillator + PH_1 // Digital pin 49, 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 + 31, // A10, PC0 + 32, // A11, PC1 + 33, // A12, PC2 + 34, // A13, PC3 + 35, // A14, PC4 + 36 // 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_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 \ 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 new file mode 100644 index 000000000000..b5a4e5ef80c2 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/variant.h @@ -0,0 +1,151 @@ +/* + 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 + + +// | DIGITAL | ANALOG | USART | TWI | SPI | SPECIAL | +// |---------|--------|-----------|----------|------------------------|-----------| +#define PA0 0 // | 0 | A0 | | | | | +#define PA1 1 // | 1 | A1 | | | | | +#define PA2 2 // | 2 | A2 | USART2_TX | | | | +#define PA3 3 // | 3 | A3 | USART2_RX | | | | +#define PA4 4 // | 4 | A4 | | | SPI1_SS, (SPI3_SS) | | +#define PA5 5 // | 5 | A5 | | | SPI1_SCK | | +#define PA6 6 // | 6 | A6 | | | SPI1_MISO | | +#define PA7 7 // | 7 | A7 | | | SPI1_MOSI | | +#define PA8 8 // | 8 | | | TWI3_SCL | | | +#define PA9 9 // | 9 | | USART1_TX | | | | +#define PA10 10 // | 10 | | USART1_RX | | | | +#define PA11 11 // | 11 | | USART6_TX | | | | +#define PA12 12 // | 12 | | USART6_RX | | | | +#define PA13 13 // | 13 | | | | | SWD_SWDIO | +#define PA14 14 // | 14 | | | | | SWD_SWCLK | +#define PA15 15 // | 15 | | | | SPI3_SS, (SPI1_SS) | | +// |---------|--------|-----------|----------|------------------------|-----------| +#define PB0 16 // | 16 | A8 | | | | | +#define PB1 17 // | 17 | A9 | | | | | +#define PB2 18 // | 18 | | | | | BOOT1 | +#define PB3 19 // | 19 | | | TWI2_SDA | SPI3_SCK, (SPI1_SCK) | | +#define PB4 20 // | 20 | | | TWI3_SDA | 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 | | | TWI2_SCL | SPI2_SCK | | +#define PB12 27 // | 27 | | | | SPI2_SS | | +#define PB13 28 // | 28 | | | | SPI2_SCK | | +#define PB14 29 // | 29 | | | | SPI2_MISO | | +#define PB15 30 // | 30 | | | | SPI2_MOSI | | +// |---------|--------|-----------|----------|------------------------|-----------| +#define PC0 31 // | 31 | A10 | | | | | +#define PC1 32 // | 32 | A11 | | | | | +#define PC2 33 // | 33 | A12 | | | SPI2_MISO | | +#define PC3 34 // | 34 | A13 | | | SPI2_MOSI | | +#define PC4 35 // | 35 | A14 | | | | | +#define PC5 36 // | 36 | A15 | | | | | +#define PC6 37 // | 37 | | USART6_TX | | | | +#define PC7 38 // | 38 | | USART6_RX | | | | +#define PC8 39 // | 39 | | | | | | +#define PC9 40 // | 40 | | | TWI3_SDA | | | +#define PC10 41 // | 41 | | | | SPI3_SCK | | +#define PC11 42 // | 42 | | | | SPI3_MISO | | +#define PC12 43 // | 43 | | | | SPI3_MOSI | | +#define PC13 44 // | 44 | | | | | | +#define PC14 45 // | 45 | | | | | OSC32_IN | +#define PC15 46 // | 46 | | | | | OSC32_OUT | +// |---------|--------|-----------|----------|------------------------|-----------| +#define PD2 47 // | 47 | | | | | | +// |---------|--------|-----------|----------|------------------------|-----------| +#define PH0 48 // | 48 | | | | | OSC_IN | +#define PH1 49 // | 49 | | | | | OSC_OUT | +// |---------|--------|-----------|----------|------------------------|-----------| + +// This must be a literal +#define NUM_DIGITAL_PINS 50 +#define NUM_ANALOG_INPUTS 16 + +// SPI definitions +#define PIN_SPI_SS PA4 +#define PIN_SPI_SS1 PA4 +#define PIN_SPI_MOSI PA7 +#define PIN_SPI_MISO PA6 +#define PIN_SPI_SCK PA5 + + +// Timer Definitions +#define TIMER_TONE TIM2 +#define TIMER_SERVO TIM5 +#define TIMER_SERIAL TIM11 + +// UART Definitions +//#define ENABLE_HWSERIAL1 done automatically by the #define SERIAL_UART_INSTANCE below +#define ENABLE_HWSERIAL2 + + +// Define here Serial instance number to map on Serial generic name (if not already used by SerialUSB) +#define SERIAL_UART_INSTANCE 1 //1 for Serial = Serial1 (USART1) + +// Default pin used for 'Serial' instance +// Mandatory for Firmata +#define PIN_SERIAL_RX PA10 +#define PIN_SERIAL_TX PA9 + +// Used when user instanciate 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 + +#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 + +#endif /* _VARIANT_ARDUINO_STM32_ */ \ No newline at end of file diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/variant.h index 333bb02e5a22..8f17d052bba9 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/variant.h @@ -126,10 +126,10 @@ extern "C" { // Timer Definitions #ifndef TIMER_TONE - #define TIMER_TONE TIM3 + #define TIMER_TONE TIM3 // TIMER_TONE must be defined in this file #endif #ifndef TIMER_SERVO - #define TIMER_SERVO TIM2 + #define TIMER_SERVO TIM2 // TIMER_SERVO must be defined in this file #endif // UART Definitions 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 3a6b7037adf0..3440343ffa1e 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 @@ -118,7 +118,7 @@ extern "C" { #endif #ifndef LSE_STARTUP_TIMEOUT - #define LSE_STARTUP_TIMEOUT 50U // No 32.7KHz LSE on this board, reduced to avoid delays + #define LSE_STARTUP_TIMEOUT 50U // No 32.7kHz LSE on this board, reduced to avoid delays #endif /* Tip: To avoid modifying this file each time you need to use different HSE, diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/variant.h index 56ae719077ce..e64272745b9d 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/variant.h @@ -121,9 +121,9 @@ extern "C" { #define TEMP_TIMER 3 // Leave TIMER 4 for TFT backlight PWM or Servo freq... #define STEP_TIMER 5 -#define TIMER_TONE TIM6 -#define TIMER_SERVO TIM7 -#define TIMER_SERIAL TIM8 +#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file +#define TIMER_SERIAL TIM8 // TIMER_SERIAL must be defined in this file // UART Definitions // Define here Serial instance number to map on Serial generic name diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/variant.h index 496d8817a181..e01d67fd59c1 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/variant.h @@ -133,10 +133,10 @@ extern "C" { // Timer Definitions (optional) // Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin #ifndef TIMER_TONE - #define TIMER_TONE TIM6 + #define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file #endif #ifndef TIMER_SERVO - #define TIMER_SERVO TIM7 + #define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file #endif // UART Definitions diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/variant.h index fb878f8b78f3..330a7efbf83a 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/variant.h @@ -177,8 +177,8 @@ extern "C" { // Timer Definitions (optional) // Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin -#define TIMER_TONE TIM6 -#define TIMER_SERVO TIM7 +#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file // UART Definitions // Define here Serial instance number to map on Serial generic name diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407VE/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F407VE/variant.h index 3eed1473093c..df8bf064fca1 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F407VE/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407VE/variant.h @@ -299,10 +299,10 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c -#define TIMER_TONE TIM6 +#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file // Do not use basic timer: OC is required -#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work +#define TIMER_SERVO TIM2 // TODO: advanced-control timers don't work // UART Definitions // Define here Serial instance number to map on Serial generic name diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.h index f00cc5f61235..855616f66b4a 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/variant.h @@ -134,15 +134,15 @@ extern "C" { // Timer Definitions // Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin #ifndef TIMER_TONE -#define TIMER_TONE TIM6 + #define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file #endif #ifndef TIMER_SERVO -#define TIMER_SERVO TIM7 + #define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file #endif #ifndef TIMER_SERIAL -#define TIMER_SERIAL TIM9 + #define TIMER_SERIAL TIM9 // TIMER_SERIAL must be defined in this file #endif // UART Definitions diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/variant.h index 94fa79c065d8..ba145d058cb3 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/variant.h @@ -153,13 +153,13 @@ extern "C" { // Timer Definitions // Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin #ifndef TIMER_TONE - #define TIMER_TONE TIM6 + #define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file #endif #ifndef TIMER_SERVO - #define TIMER_SERVO TIM7 + #define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file #endif #ifndef TIMER_SERIAL - #define TIMER_SERIAL TIM5 + #define TIMER_SERIAL TIM5 // TIMER_SERIAL must be defined in this file #endif // UART Definitions diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/variant.h index fd9a5c7741b4..2bfce85e21f9 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/variant.h @@ -185,10 +185,10 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c -#define TIMER_TONE TIM6 +#define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file // Do not use basic timer: OC is required -#define TIMER_SERVO TIM1 //TODO: advanced-control timers don't work +#define TIMER_SERVO TIM1 // TODO: advanced-control timers don't work // UART Definitions // Define here Serial instance number to map on Serial generic name 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 bcd5aa378edf..d4982113a010 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/variant.h @@ -93,17 +93,15 @@ extern "C" { #define PIN_SPI_MISO PA6 #define PIN_SPI_SCK PA5 - // Timer Definitions -#define TIMER_TONE TIM2 -#define TIMER_SERVO TIM5 -#define TIMER_SERIAL TIM11 +#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_SERIAL TIM11 // TIMER_SERIAL must be defined in this file // UART Definitions //#define ENABLE_HWSERIAL1 done automatically by the #define SERIAL_UART_INSTANCE below #define ENABLE_HWSERIAL2 - // Define here Serial instance number to map on Serial generic name (if not already used by SerialUSB) #define SERIAL_UART_INSTANCE 1 //1 for Serial = Serial1 (USART1) @@ -148,4 +146,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_FYSETC_S6/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/variant.h index 4bd5b63dfe56..4f77dc688f35 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/variant.h @@ -133,9 +133,9 @@ extern "C" { // Timer Definitions // Do not use timer used by PWM pin. See PinMap_PWM. -#define TIMER_TONE TIM6 -#define TIMER_SERVO TIM5 -#define TIMER_SERIAL TIM7 +#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 diff --git a/buildroot/share/PlatformIO/variants/STM32G0xx/MARLIN_G0B1RE/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PeripheralPins.c similarity index 100% rename from buildroot/share/PlatformIO/variants/STM32G0xx/MARLIN_G0B1RE/PeripheralPins.c rename to buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PeripheralPins.c diff --git a/buildroot/share/PlatformIO/variants/STM32G0xx/MARLIN_G0B1RE/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PinNamesVar.h similarity index 100% rename from buildroot/share/PlatformIO/variants/STM32G0xx/MARLIN_G0B1RE/PinNamesVar.h rename to buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PinNamesVar.h diff --git a/buildroot/share/PlatformIO/variants/STM32G0xx/MARLIN_G0B1RE/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/ldscript.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/STM32G0xx/MARLIN_G0B1RE/ldscript.ld rename to buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/ldscript.ld diff --git a/buildroot/share/PlatformIO/variants/STM32G0xx/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp similarity index 85% rename from buildroot/share/PlatformIO/variants/STM32G0xx/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp rename to buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp index e53fb4182c2e..8af7150dc781 100644 --- a/buildroot/share/PlatformIO/variants/STM32G0xx/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp @@ -115,11 +115,11 @@ extern "C" { * AHB Prescaler = 1 * APB1 Prescaler = 1 * PLL_M = 1 - * PLL_N = 16 - * PLL_R = 2 + * PLL_N = 24 + * PLL_R = 3 * PLL_P = 2 - * PLL_Q = 2 - * USB(Hz) = 48000000 (HSI48M) + * PLL_Q = 4 + * USB(Hz) = 48000000 (PLLQ) * @param None * @retval None */ @@ -129,22 +129,31 @@ WEAK void SystemClock_Config(void) RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; 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; + /** 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.OscillatorType = RCC_OSCILLATORTYPE_HSE; 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.PLLN = 24; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; - RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; - RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_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(); @@ -164,7 +173,7 @@ WEAK void SystemClock_Config(void) /** Initializes the peripherals clocks */ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; - PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; + PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { Error_Handler(); diff --git a/buildroot/share/PlatformIO/variants/STM32G0xx/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h similarity index 97% rename from buildroot/share/PlatformIO/variants/STM32G0xx/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h rename to buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h index 65aff2ce27b1..9cb3d45a0d95 100644 --- a/buildroot/share/PlatformIO/variants/STM32G0xx/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h @@ -150,10 +150,10 @@ // Timer Definitions // Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin #ifndef TIMER_TONE - #define TIMER_TONE TIM6 + #define TIMER_TONE TIM6 // TIMER_TONE must be defined in this file #endif #ifndef TIMER_SERVO - #define TIMER_SERVO TIM7 + #define TIMER_SERVO TIM7 // TIMER_SERVO must be defined in this file #endif // UART Definitions diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PeripheralPins.c new file mode 100644 index 000000000000..49c4cbb87aa9 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PeripheralPins.c @@ -0,0 +1,539 @@ +/* + ******************************************************************************* + * 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 STM32H742V(G-I)Hx.xml, STM32H742V(G-I)Tx.xml + * STM32H743V(G-I)Hx.xml, STM32H743VGTx.xml + * STM32H743VITx.xml, STM32H750VBTx.xml + * STM32H753VIHx.xml, STM32H753VITx.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 + {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)}, + {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)}, + {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)}, + {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 + {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)}, + {PE_1, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, + {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)}, + {PE_0, UART8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART8)}, + {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_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_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)}, + {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_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)}, + {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)}, + {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 + {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_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 + +//*** QUADSPI *** + +#ifdef HAL_QSPI_MODULE_ENABLED +WEAK const PinMap PinMap_QUADSPI_DATA0[] = { + {PC_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO0 + {PD_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO0 + {PE_7, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK2_IO0 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_QSPI_MODULE_ENABLED +WEAK const PinMap PinMap_QUADSPI_DATA1[] = { + {PC_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO1 + {PD_12, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO1 + {PE_8, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK2_IO1 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_QSPI_MODULE_ENABLED +WEAK const PinMap PinMap_QUADSPI_DATA2[] = { + {PE_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO2 + {PE_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK2_IO2 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_QSPI_MODULE_ENABLED +WEAK const PinMap PinMap_QUADSPI_DATA3[] = { + {PA_1, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO3 + {PD_13, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_IO3 + {PE_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK2_IO3 + {NC, NP, 0} +}; +#endif + +#ifdef HAL_QSPI_MODULE_ENABLED +WEAK const PinMap PinMap_QUADSPI_SCLK[] = { + {PB_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_CLK + {NC, NP, 0} +}; +#endif + +#ifdef HAL_QSPI_MODULE_ENABLED +WEAK const PinMap PinMap_QUADSPI_SSEL[] = { + {PB_6, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)}, // QUADSPI_BK1_NCS + {PB_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK1_NCS + {PC_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QUADSPI)}, // QUADSPI_BK2_NCS + {NC, NP, 0} +}; +#endif + +//*** 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_OTG1_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_OTG1_FS)}, // USB_OTG_FS_ID + {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_DM + {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG1_FS)}, // USB_OTG_FS_DP + {NC, NP, 0} +}; +#endif + +#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_4, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_SOF + // {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG2_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_OTG2_FS)}, // USB_OTG_HS_DM + {PB_15, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG2_FS)}, // USB_OTG_HS_DP +#else + {PA_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D0 + {PA_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_CK + {PB_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D1 + {PB_1, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D2 + {PB_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D7 + {PB_10, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D3 + {PB_11, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D4 + {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D5 + {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_D6 + {PC_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_STP + {PC_2_C, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_HS)}, // USB_OTG_HS_ULPI_DIR + {PC_3_C, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG2_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_SDIO2)}, // SDMMC2_CMD + {PB_3, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDIO2)}, // SDMMC2_D2 + {PB_4, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDIO2)}, // SDMMC2_D3 + {PB_8, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF7_SDIO1)}, // SDMMC1_CKIN + {PB_8_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D4 + {PB_8_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDIO2)}, // SDMMC2_D4 + {PB_9, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF7_SDIO1)}, // SDMMC1_CDIR + {PB_9_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D5 + {PB_9_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDIO2)}, // SDMMC2_D5 + {PB_14, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDIO2)}, // SDMMC2_D0 + {PB_15, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_SDIO2)}, // SDMMC2_D1 + {PC_1, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_SDIO2)}, // SDMMC2_CK + {PC_6, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF8_SDIO1)}, // SDMMC1_D0DIR + {PC_6_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D6 + {PC_6_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDIO2)}, // SDMMC2_D6 + {PC_7, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF8_SDIO1)}, // SDMMC1_D123DIR + {PC_7_ALT1, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D7 + {PC_7_ALT2, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_SDIO2)}, // SDMMC2_D7 + {PC_8, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D0 + {PC_9, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D1 + {PC_10, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D2 + {PC_11, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO1)}, // SDMMC1_D3 + {PC_12, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO1)}, // SDMMC1_CK + {PD_2, SDMMC1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO1)}, // SDMMC1_CMD + {PD_6, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF11_SDIO2)}, // SDMMC2_CK + {PD_7, SDMMC2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF11_SDIO2)}, // SDMMC2_CMD + {NC, NP, 0} +}; +#endif + +#endif /* !CUSTOM_PERIPHERAL_PINS */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PinNamesVar.h new file mode 100644 index 000000000000..2128732a400c --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PinNamesVar.h @@ -0,0 +1,112 @@ +/* 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_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, /* SYS_WKUP0 */ +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = PA_2, /* SYS_WKUP1 */ +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = PC_13, /* SYS_WKUP2 */ +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = NC, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = PC_1, /* SYS_WKUP5 */ +#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, + USB_OTG_HS_DM = PB_14, + USB_OTG_HS_DP = PB_15, + USB_OTG_HS_ID = PB_12, + USB_OTG_HS_SOF = PA_4, + 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 = PB_13, +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/ldscript.ld new file mode 100644 index 000000000000..7d248a268283 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/ldscript.ld @@ -0,0 +1,208 @@ +/* +****************************************************************************** +** +** File : LinkerScript.ld +** +** Author : Auto-generated by STM32CubeIDE +** +** Abstract : Linker script for STM32H743VI Device from STM32H7 series +** 2048Kbytes FLASH +** 128Kbytes DTCMRAM +** 64Kbytes ITCMRAM +** 512Kbytes RAM_D1 +** 288Kbytes RAM_D2 +** 64Kbytes RAM_D3 +** +** 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 = 0x24080000; /* end of "RAM_D1" Ram type memory */ + +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Memories definition */ +MEMORY +{ + DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K + ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K + RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K + RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K + RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K + 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_D1" Ram type memory */ + .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_D1 AT> FLASH + + /* Uninitialized data section into "RAM_D1" 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_D1 + + /* User_heap_stack section, used to check that there is enough "RAM_D1" Ram type memory left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >RAM_D1 + + /* 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_H743Vx/variant_MARLIN_STM32H743VX.cpp b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.cpp new file mode 100644 index 000000000000..7813f8860e58 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.cpp @@ -0,0 +1,245 @@ +/* + ******************************************************************************* + * 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(STM32H743xx) +#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 +}; + +/* + * @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 = {}; + + /** 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_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 = 5; // 25Mhz / 5 = 5Mhz + RCC_OscInitStruct.PLL.PLLN = 192; // 25Mhz / 5 * 192 = 960Mhz + RCC_OscInitStruct.PLL.PLLP = 2; // 960Mhz / 2 = 480Mhz + RCC_OscInitStruct.PLL.PLLQ = 20; // 960Mhz / 20 = 48Mhz for USB + RCC_OscInitStruct.PLL.PLLR = 20; // 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_QSPI + | 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; + + /* PLL1 qclk used for USB 48 Mhz */ + /* PLL1 qclk also used for FMC, QUADSPI, 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 PLL1 qclk + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL; + // QSPI from PLL1 qclk + PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_PLL; + // 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_H743Vx/variant_MARLIN_STM32H743VX.h b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.h new file mode 100644 index 000000000000..35cf65dee9b9 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.h @@ -0,0 +1,268 @@ +/* + ******************************************************************************* + * 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 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 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_QSPI_MODULE_DISABLED) + #define HAL_QSPI_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_LERDGE/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_LERDGE/variant.h index d82f0006553f..e7bc7c0bc1db 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_LERDGE/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_LERDGE/variant.h @@ -183,7 +183,7 @@ extern "C" { // Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c // FANs may require PWM timers 3 10 11 13 // The LED/RGB connectors timer 4 -// Beware: STEP_TIMER default is 6 and TEMP_TIMER 14 for the F407 +// Beware: MCU_TIMER_STEP default is 6 and MCU_TIMER_TEMP 14 for the F407 #ifndef TIMER_TONE #define TIMER_TONE TIM8 // TIM3 or TIM8 for SPEAKER compat on the lerdge K (PC6) #endif // TIM4 for that on the Lerdge S (PD11) 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 ec6e498b2179..30c3d953494f 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/variant.h @@ -103,8 +103,8 @@ extern "C" { // Timer Definitions // Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin -#define TIMER_TONE TIM5 -#define TIMER_SERVO TIM7 +#define TIMER_TONE TIM5 // TIMER_TONE must be defined in this file +#define TIMER_SERVO TIM4 // TIMER_SERVO must be defined in this file // UART Definitions // Define here Serial instance number to map on Serial generic name diff --git a/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/board.cpp b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_CHITU_F103/board.cpp rename to buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board.cpp diff --git a/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/board/board.h b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board/board.h similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_CHITU_F103/board/board.h rename to buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board/board.h diff --git a/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/common.inc b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/ld/common.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/common.inc rename to buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/ld/common.inc diff --git a/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/extra_libs.inc b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/ld/extra_libs.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/extra_libs.inc rename to buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/ld/extra_libs.inc diff --git a/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/flash.ld b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/ld/flash.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/flash.ld rename to buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/ld/flash.ld diff --git a/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/stm32f103z_dfu.ld b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/ld/stm32f103z_dfu.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/stm32f103z_dfu.ld rename to buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/ld/stm32f103z_dfu.ld diff --git a/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/stm32f103zc.ld b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/ld/stm32f103zc.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/stm32f103zc.ld rename to buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/ld/stm32f103zc.ld diff --git a/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/stm32f103zd.ld b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/ld/stm32f103zd.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/stm32f103zd.ld rename to buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/ld/stm32f103zd.ld diff --git a/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/stm32f103ze.ld b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/ld/stm32f103ze.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/stm32f103ze.ld rename to buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/ld/stm32f103ze.ld diff --git a/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/vector_symbols.inc b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/ld/vector_symbols.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_CHITU_F103/ld/vector_symbols.inc rename to buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/ld/vector_symbols.inc diff --git a/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/pins_arduino.h b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/pins_arduino.h similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_CHITU_F103/pins_arduino.h rename to buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/pins_arduino.h diff --git a/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/variant.h b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/variant.h similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_CHITU_F103/variant.h rename to buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/variant.h diff --git a/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/boards.cpp b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/boards.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/boards.cpp rename to buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/boards.cpp diff --git a/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/boards_setup.cpp b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/boards_setup.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/boards_setup.cpp rename to buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/boards_setup.cpp diff --git a/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/start.S b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/start.S similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/start.S rename to buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/start.S diff --git a/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/start_c.c b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/start_c.c similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/start_c.c rename to buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/start_c.c diff --git a/buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/syscalls.c b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/syscalls.c similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_CHITU_F103/wirish/syscalls.c rename to buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/syscalls.c diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/board.cpp b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/board.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/board.cpp rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/board.cpp diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/board/board.h b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/board/board.h similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/board/board.h rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/board/board.h diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/bootloader.ld b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/bootloader.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/bootloader.ld rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/bootloader.ld diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/common.inc b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/common.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/common.inc rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/common.inc diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/extra_libs.inc b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/extra_libs.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/extra_libs.inc rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/extra_libs.inc diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/flash.ld b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/flash.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/flash.ld rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/flash.ld diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/jtag.ld b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/jtag.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/jtag.ld rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/jtag.ld diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/mem-flash.inc b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/mem-flash.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/mem-flash.inc rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/mem-flash.inc diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/mem-jtag.inc b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/mem-jtag.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/mem-jtag.inc rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/mem-jtag.inc diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/mem-ram.inc b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/mem-ram.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/mem-ram.inc rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/mem-ram.inc diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/ram.ld b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/ram.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/ram.ld rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/ram.ld diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103rb.ld b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/stm32f103rb.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103rb.ld rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/stm32f103rb.ld diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103rb_bootloader.ld b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/stm32f103rb_bootloader.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103rb_bootloader.ld rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/stm32f103rb_bootloader.ld diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103rc.ld b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/stm32f103rc.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103rc.ld rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/stm32f103rc.ld diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103rc_bootloader.ld b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/stm32f103rc_bootloader.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103rc_bootloader.ld rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/stm32f103rc_bootloader.ld diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103re.ld b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/stm32f103re.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/stm32f103re.ld rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/stm32f103re.ld diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/vector_symbols.inc b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/vector_symbols.inc similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/ld/vector_symbols.inc rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/ld/vector_symbols.inc diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/pins_arduino.h b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/pins_arduino.h similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/pins_arduino.h rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/pins_arduino.h diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/variant.h b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/variant.h similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/variant.h rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/variant.h diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/boards.cpp b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/boards.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/boards.cpp rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/boards.cpp diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/boards_setup.cpp b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/boards_setup.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/boards_setup.cpp rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/boards_setup.cpp diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/start.S b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/start.S similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/start.S rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/start.S diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/start_c.c b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/start_c.c similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/start_c.c rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/start_c.c diff --git a/buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/syscalls.c b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/syscalls.c similarity index 100% rename from buildroot/share/PlatformIO/variants/marlin_MEEB_3DP/wirish/syscalls.c rename to buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/syscalls.c diff --git a/buildroot/share/dwin/bin/DWIN_ICO.py b/buildroot/share/dwin/bin/DWIN_ICO.py new file mode 100644 index 000000000000..8ac680c61e7c --- /dev/null +++ b/buildroot/share/dwin/bin/DWIN_ICO.py @@ -0,0 +1,342 @@ +# DWIN_ICO +# - Dissect and create DWIN .ico files for their LCD displays. +# +# Copyright (c) 2020 Brent Burton +# +# 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 . +#---------------------------------------------------------------- +# +# This is not a normal Microsoft .ICO file, but it has a similar +# structure for containing a number of icon images. Each icon is +# a small JPG file. +# +# The file has a directory header containing fixed-length +# records, and each record points to its data at an offset later +# in the file. +# +# The directory entries are 16 bytes each, and the entire +# directory is 4KB (0 - 0x1000). This supports 256 entries. +# +# Multibyte values are in Big Endian format. +# +# Header: (offset 0x0) +# W H offset ?? len ?? ?? +# Entry 0: xxxx xxxx 00001000 xx 10a2 00 00000000 +# Entry 1: xxxx xxxx 000020a2 xx 0eac 00 00000000 +# Entry 2: xxxx xxxx 00002f4e xx 0eaa 00 00000000 +# ... +# 0x00001000: ffd8 ffe1 0018 ... jpeg exif and data follow .. ffd9 +# 0x000020a2: ffd8 ffe1 ... +# ...rest of ICO entries' data... +# +# Header structure: +# Offset Len What +# 0 2 width +# 2 2 height +# 4 4 file byte position from SEEK_BEG +# 8 3 length of data +# 11 5 ??? all zeroes +# +# Other notes: +# * The index of each icon corresponds to the Icon number in dwin.h +# * One exception is number 39: that header entry is blank, and dwin.h +# does not define a name for 39. This is specially handled to +# prevent reordering stock icons. + +import os +import struct +from PIL import Image + +def getJpegResolution(jpegFile): + """Returns a 2-tuple containing the jpegFile's (width, height). + """ + img = Image.open(jpegFile) + return img.size + +class DWIN_ICO_File(): + def __init__(self): + self.entries = [] # list of header entries + + def splitFile(self, filename, outDir): + if not filename[-4:].lower() == '.ico': + raise RuntimeError('Input file must end in .ico') + + with open(filename, 'rb') as infile: + self._parseHeader(infile) + self._splitEntryData(infile, outDir) + + return + + def _parseHeader(self, infile): + maxEntries = 256 + count = 0 + validEntries = 0 + while count < maxEntries: + rawBytes = infile.read(16) + entry = Entry() + entry.parseRawData(rawBytes) + # check that it is valid: is offset nonzero? + # Special case: treat 39 as valid + if (entry.offset > 0) or (count == 39): + validEntries += 1 + self.entries.append(entry) + count += 1 + return + + def _splitEntryData(self, infile, outDir): + print('Splitting Entry Data...') + if 0 == len(self.entries): + raise RuntimeError('.ico file is not loaded yet') + + # check for output dir: + if not os.path.exists(outDir): + os.mkdir(outDir) + + # keep a count + count = 0 + for entry in self.entries: + # Skip any empty entries. (Special handling of 39.) + if entry.length == 0: + count += 1 + continue + # Seek file position, read length bytes, and write to new output file. + print('%02d: offset: 0x%06x len: 0x%04x width: %d height: %d' % + (count, entry.offset, entry.length, entry.width, entry.height)) + outfilename = os.path.join(outDir, + '%03d-%s.jpg' % (count, _iconNames[count])) + with open(outfilename, 'wb') as outfile: + infile.seek(entry.offset) + blob = infile.read(entry.length) + outfile.write(blob) + print('Wrote %d bytes to %s' % (entry.length, outfilename)) + + count += 1 + return + + def createFile(self, iconDir, filename): + '''Create a new .ico file from the contents of iconDir. + + The contents of iconDir are processed to get image + resolution, and a new entry is created for each. + + Each filename must have a leading number followed by a + dash, which is the icon index. E.g., "071-ICON_StepX.jpg". + ''' + self.entries = [Entry() for i in range(0,256)] + # 1. Scan icon directory and record all valid files + print('Scanning icon directory', iconDir) + count = 0 + for dirEntry in os.scandir(iconDir): + if not dirEntry.is_file(): + print('...Ignoring', dirEntry.path) + continue + # process each file: + try: + index = int(dirEntry.name[0:3]) + if (index < 0) or (index > 255): + print('...Ignoring invalid index on', dirEntry.path) + continue + #dirEntry.path is iconDir/name + w,h = getJpegResolution(dirEntry.path) + length = dirEntry.stat().st_size + e = self.entries[index] + e.width = w + e.height = h + e.length = length + e.filename = dirEntry.path + count += 1 + except Exception as e: + print('Whoops: ', e) + pass + print('...Scanned %d icon files' % (count)) + + # 2. Scan over valid header entries and update offsets + self._updateHeaderOffsets() + + # 3. Write out header to .ico file, the append each icon file + self._combineAndWriteIcoFile(filename) + print('Scanning done. %d icons included.' % (count)) + + def _updateHeaderOffsets(self): + """Iterate over all header entries and update their offsets. + """ + offset = 256 * 16 + for i in range(0,256): + e = self.entries[i] + if e.length == 0: + continue + e.offset = offset + offset += e.length + #print('%03d: (%d x %d) len=%d off=%d' % + # (i, e.width, e.height, e.length, e.offset)) + return + + def _combineAndWriteIcoFile(self, filename): + """Write out final .ico file. + All header entries are updated, so write out + the final header contents, and concat each icon + file to the .ico. + """ + with open(filename, 'wb') as outfile: + # 1. Write header directory + for e in self.entries: + outfile.write( e.serialize() ) + if outfile.tell() != 4096: + raise RuntimeError('Header directory write failed. Not 4096 bytes') + # 2. For each entry, concat the icon file data + for e in self.entries: + if 0 == e.length: continue + guts = self._getFileContents(e.filename, e.length) + outfile.write(guts) + return + + def _getFileContents(self, filename, length): + """Read contents of filename, and return bytes""" + with open(filename, 'rb') as infile: + contents = infile.read(length) + if len(contents) != length: + raise RuntimeError('Failed to read contents of', filename) + return contents + +class Entry(): + '''Entry objects record resolution and size information + about each icon stored in an ICO file. + ''' + __slots__ = ('width', 'height', 'offset', 'length', 'filename') + + def __init__(self, w=0, h=0, length=0, offset=0): + self.width = w + self.height = h + self.offset = offset + self.length = length + self.filename = None + + def parseRawData(self, rawEntryBytes): + if len(rawEntryBytes) != 16: + raise RuntimeError('Entry: data must be 16 bytes long') + + # Split data into bigendian fields + (w, h, off, len3, len21, b1,b2,b3,b4,b5) = \ + struct.unpack('>HHLBHBBBBB', rawEntryBytes) + self.width = w + self.height = h + self.offset = off + self.length = len3 * 65536 + len21 + return + + def serialize(self): + """Convert this Entry's information into a 16-byte + .ico directory entry record. Return bytes object. + """ + len21 = self.length % 65536 + len3 = self.length // 65536 + rawdata = struct.pack('>HHLBHBBBBB', self.width, self.height, + self.offset, len3, len21, + 0, 0, 0, 0, 0) + return rawdata + +_iconNames = { + 0 : 'ICON_LOGO', + 1 : 'ICON_Print_0', + 2 : 'ICON_Print_1', + 3 : 'ICON_Prepare_0', + 4 : 'ICON_Prepare_1', + 5 : 'ICON_Control_0', + 6 : 'ICON_Control_1', + 7 : 'ICON_Leveling_0', + 8 : 'ICON_Leveling_1', + 9 : 'ICON_HotendTemp', + 10 : 'ICON_BedTemp', + 11 : 'ICON_Speed', + 12 : 'ICON_Zoffset', + 13 : 'ICON_Back', + 14 : 'ICON_File', + 15 : 'ICON_PrintTime', + 16 : 'ICON_RemainTime', + 17 : 'ICON_Setup_0', + 18 : 'ICON_Setup_1', + 19 : 'ICON_Pause_0', + 20 : 'ICON_Pause_1', + 21 : 'ICON_Continue_0', + 22 : 'ICON_Continue_1', + 23 : 'ICON_Stop_0', + 24 : 'ICON_Stop_1', + 25 : 'ICON_Bar', + 26 : 'ICON_More', + 27 : 'ICON_Axis', + 28 : 'ICON_CloseMotor', + 29 : 'ICON_Homing', + 30 : 'ICON_SetHome', + 31 : 'ICON_PLAPreheat', + 32 : 'ICON_ABSPreheat', + 33 : 'ICON_Cool', + 34 : 'ICON_Language', + 35 : 'ICON_MoveX', + 36 : 'ICON_MoveY', + 37 : 'ICON_MoveZ', + 38 : 'ICON_Extruder', + # no 39 + 40 : 'ICON_Temperature', + 41 : 'ICON_Motion', + 42 : 'ICON_WriteEEPROM', + 43 : 'ICON_ReadEEPROM', + 44 : 'ICON_ResumeEEPROM', + 45 : 'ICON_Info', + 46 : 'ICON_SetEndTemp', + 47 : 'ICON_SetBedTemp', + 48 : 'ICON_FanSpeed', + 49 : 'ICON_SetPLAPreheat', + 50 : 'ICON_SetABSPreheat', + 51 : 'ICON_MaxSpeed', + 52 : 'ICON_MaxAccelerated', + 53 : 'ICON_MaxJerk', + 54 : 'ICON_Step', + 55 : 'ICON_PrintSize', + 56 : 'ICON_Version', + 57 : 'ICON_Contact', + 58 : 'ICON_StockConfiguraton', + 59 : 'ICON_MaxSpeedX', + 60 : 'ICON_MaxSpeedY', + 61 : 'ICON_MaxSpeedZ', + 62 : 'ICON_MaxSpeedE', + 63 : 'ICON_MaxAccX', + 64 : 'ICON_MaxAccY', + 65 : 'ICON_MaxAccZ', + 66 : 'ICON_MaxAccE', + 67 : 'ICON_MaxSpeedJerkX', + 68 : 'ICON_MaxSpeedJerkY', + 69 : 'ICON_MaxSpeedJerkZ', + 70 : 'ICON_MaxSpeedJerkE', + 71 : 'ICON_StepX', + 72 : 'ICON_StepY', + 73 : 'ICON_StepZ', + 74 : 'ICON_StepE', + 75 : 'ICON_Setspeed', + 76 : 'ICON_SetZOffset', + 77 : 'ICON_Rectangle', + 78 : 'ICON_BLTouch', + 79 : 'ICON_TempTooLow', + 80 : 'ICON_AutoLeveling', + 81 : 'ICON_TempTooHigh', + 82 : 'ICON_NoTips_C', + 83 : 'ICON_NoTips_E', + 84 : 'ICON_Continue_C', + 85 : 'ICON_Continue_E', + 86 : 'ICON_Cancel_C', + 87 : 'ICON_Cancel_E', + 88 : 'ICON_Confirm_C', + 89 : 'ICON_Confirm_E', + 90 : 'ICON_Info_0', + 91 : 'ICON_Info_1' + } diff --git a/buildroot/share/dwin/bin/LICENSE b/buildroot/share/dwin/bin/LICENSE new file mode 100644 index 000000000000..f288702d2fa1 --- /dev/null +++ b/buildroot/share/dwin/bin/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/buildroot/share/dwin/bin/README.md b/buildroot/share/dwin/bin/README.md new file mode 100644 index 000000000000..9d513bc0c8f5 --- /dev/null +++ b/buildroot/share/dwin/bin/README.md @@ -0,0 +1,92 @@ +# DWIN Icon Tools + +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. + +Standard `.JPG` files can be installed for things like the boot screen, and `.ICO` files can contain several images within a structured file format. + +## DWIN Banks + +Each JPEG and ICO file starts with a number that tells DWIN which bank it should be stored in. Each numbered bank is 32K in size, so a single JPEG or ICO file can be up to 32kB before it starts to overwrite the next bank. For example, if the file loaded into bank 0 is over 32K, the next file should be numbered "2" so it loads into bank 2. The limit to the total size of all files installed on the display is usually 512KB, corresponding to 16 banks. All JPEG images, ICO containers, and fonts must fit into this space, so you may need to apply a lot of JPEG compression. + +## The Tools + +This folder includes two useful scripts, one to convert JPEG images into ICO files and another to extract JPEGs from ICO files. + +### splitIco.py + +The `splitIco.py` script reads an ICO file and extracts the component JPEG images, saving them in a new folder. Each icon is named by its index in the ICO, also using symbol names from Marlin's `dwin.h` header file for the display. + +### makeIco.py + +The `makeIco.py` script reads all the images in a folder and combines them into a single `.ICO` file. + +## Dependencies + +These tools are written in Python 3 using the [Pillow image library](https://pillow.readthedocs.io/en/latest/index.html). + +## Credits + +Created by Brent Burton [[@b-pub](https://github.com/b-pub)] + +## License + +These tools are provided under the GPL 3 license. See the `LICENSE` file for details. + +# Usage & Dependencies + +These tools must be run from a terminal with access to an installed Python 3 and the Pillow image library. + +Pillow is most easily installed with pip: + + 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 + +The following explanations will refer back to this layout. + +### `splitIco.py` - Split the ICO archive + +If you want to edit the individual icons stored in an ICO file (or add more images) you'll first need to extract all the images from the archive using `splitIco.py`. + +**Usage:** `splitIco.py #.ICO foldername`. + +**Example:** + +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 + +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. + +### `makeIco.py` - Combine JPEGs into `ICO` archive + +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. diff --git a/buildroot/share/dwin/bin/makeIco.py b/buildroot/share/dwin/bin/makeIco.py new file mode 100755 index 000000000000..274082acee87 --- /dev/null +++ b/buildroot/share/dwin/bin/makeIco.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 +# +# Make a DWIN .ico file from a directory of JPEG icon files. +# +# Copyright (c) 2020 Brent Burton +# +# 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 . +#---------------------------------------------------------------- + +import os +import os.path +import argparse +import DWIN_ICO + +version = '2.0.7' + +#---------------- +if __name__ == '__main__': + try: + parser = argparse.ArgumentParser(description='Make .ico from JPEG files') + parser.add_argument('iconDir', type=str, nargs=1, + help='name of directory containing icon JPGs') + parser.add_argument('filename', type=str, nargs=1, + help='name of new .ico file to create') + args = parser.parse_args() + + filename = args.filename[0] + iconDir = args.iconDir[0] + + if os.path.isfile(filename): + raise RuntimeError("ICO file '%s' already exists." % (filename)) + + if not os.path.exists(iconDir): + raise RuntimeError("Icon directory '%s' doesn't exist." % (iconDir)) + + print("Making .ico file '%s' from contents of '%s'" % (filename, iconDir)) + ico = DWIN_ICO.DWIN_ICO_File() + ico.createFile(iconDir, filename) + + except Exception as e: + print('Error: ', e) + diff --git a/buildroot/share/dwin/bin/splitIco.py b/buildroot/share/dwin/bin/splitIco.py new file mode 100755 index 000000000000..ce6ba89749c9 --- /dev/null +++ b/buildroot/share/dwin/bin/splitIco.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 +# +# Split a DWIN .ico file into separate images. +# +# Copyright (c) 2020 Brent Burton +# +# 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 . +#---------------------------------------------------------------- + +import os +import os.path +import argparse +import DWIN_ICO + +version = '2.0.7' + +#---------------- +if __name__ == '__main__': + try: + parser = argparse.ArgumentParser(description='Split .ico into JPEG files') + parser.add_argument('filename', type=str, nargs=1, + help='name of input .ico file to split') + parser.add_argument('outputDir', type=str, nargs=1, + help='name of output directory to create') + args = parser.parse_args() + + filename = args.filename[0] + outputDir = args.outputDir[0] + + if not os.path.isfile(filename): + raise RuntimeError("ICO file '%s' doesn't exist" % (filename)) + + if os.path.exists(outputDir): + raise RuntimeError("Output directory '%s' already exists." % (outputDir)) + + print('Splitting %s into dir %s' % (filename, outputDir)) + ico = DWIN_ICO.DWIN_ICO_File() + ico.splitFile(filename, outputDir) + + except Exception as e: + print('Error: ', e) diff --git a/buildroot/share/dwin/icons-2/000-ICON_BootLogo.jpg b/buildroot/share/dwin/icons-2/000-ICON_BootLogo.jpg new file mode 100644 index 000000000000..3ca4d1cf55cc Binary files /dev/null and b/buildroot/share/dwin/icons-2/000-ICON_BootLogo.jpg differ diff --git a/buildroot/share/dwin/icons-2/001-ICON_OpenSourceFirmware.jpg b/buildroot/share/dwin/icons-2/001-ICON_OpenSourceFirmware.jpg new file mode 100644 index 000000000000..a2c43da314b1 Binary files /dev/null and b/buildroot/share/dwin/icons-2/001-ICON_OpenSourceFirmware.jpg differ diff --git a/buildroot/share/dwin/icons-2/002-ICON_GitHub.jpg b/buildroot/share/dwin/icons-2/002-ICON_GitHub.jpg new file mode 100644 index 000000000000..0be90fa9bd94 Binary files /dev/null and b/buildroot/share/dwin/icons-2/002-ICON_GitHub.jpg differ diff --git a/buildroot/share/dwin/icons-2/003-ICON_Website.jpg b/buildroot/share/dwin/icons-2/003-ICON_Website.jpg new file mode 100644 index 000000000000..4e0e08a5fa1b Binary files /dev/null and b/buildroot/share/dwin/icons-2/003-ICON_Website.jpg differ diff --git a/buildroot/share/dwin/icons-2/004-ICON_Copyright.jpg b/buildroot/share/dwin/icons-2/004-ICON_Copyright.jpg new file mode 100644 index 000000000000..a3691d68c244 Binary files /dev/null and b/buildroot/share/dwin/icons-2/004-ICON_Copyright.jpg differ diff --git a/buildroot/share/dwin/icons-3/000-ICON_LOGO_Marlin.jpg b/buildroot/share/dwin/icons-3/000-ICON_LOGO_Marlin.jpg new file mode 100644 index 000000000000..f3e81f2284f1 Binary files /dev/null and b/buildroot/share/dwin/icons-3/000-ICON_LOGO_Marlin.jpg differ diff --git a/buildroot/share/dwin/icons-3/001-ICON_HotendOff.jpg b/buildroot/share/dwin/icons-3/001-ICON_HotendOff.jpg new file mode 100644 index 000000000000..08e18413ec0f Binary files /dev/null and b/buildroot/share/dwin/icons-3/001-ICON_HotendOff.jpg differ diff --git a/buildroot/share/dwin/icons-3/002-ICON_HotendOn.jpg b/buildroot/share/dwin/icons-3/002-ICON_HotendOn.jpg new file mode 100644 index 000000000000..5b501bd6d995 Binary files /dev/null and b/buildroot/share/dwin/icons-3/002-ICON_HotendOn.jpg differ diff --git a/buildroot/share/dwin/icons-3/003-ICON_BedOff.jpg b/buildroot/share/dwin/icons-3/003-ICON_BedOff.jpg new file mode 100644 index 000000000000..db9b546b3303 Binary files /dev/null and b/buildroot/share/dwin/icons-3/003-ICON_BedOff.jpg differ diff --git a/buildroot/share/dwin/icons-3/004-ICON_BedOn.jpg b/buildroot/share/dwin/icons-3/004-ICON_BedOn.jpg new file mode 100644 index 000000000000..c934b2fb99ac Binary files /dev/null and b/buildroot/share/dwin/icons-3/004-ICON_BedOn.jpg differ diff --git a/buildroot/share/dwin/icons-3/005-ICON_Fan0.jpg b/buildroot/share/dwin/icons-3/005-ICON_Fan0.jpg new file mode 100644 index 000000000000..c5c9957040b1 Binary files /dev/null and b/buildroot/share/dwin/icons-3/005-ICON_Fan0.jpg differ diff --git a/buildroot/share/dwin/icons-3/006-ICON_Fan1.jpg b/buildroot/share/dwin/icons-3/006-ICON_Fan1.jpg new file mode 100644 index 000000000000..8111a3db7485 Binary files /dev/null and b/buildroot/share/dwin/icons-3/006-ICON_Fan1.jpg differ diff --git a/buildroot/share/dwin/icons-3/007-ICON_Fan2.jpg b/buildroot/share/dwin/icons-3/007-ICON_Fan2.jpg new file mode 100644 index 000000000000..80a220be6376 Binary files /dev/null and b/buildroot/share/dwin/icons-3/007-ICON_Fan2.jpg differ diff --git a/buildroot/share/dwin/icons-3/008-ICON_Fan3.jpg b/buildroot/share/dwin/icons-3/008-ICON_Fan3.jpg new file mode 100644 index 000000000000..ba0cae54b012 Binary files /dev/null and b/buildroot/share/dwin/icons-3/008-ICON_Fan3.jpg differ diff --git a/buildroot/share/dwin/icons-3/009-ICON_Halted.jpg b/buildroot/share/dwin/icons-3/009-ICON_Halted.jpg new file mode 100644 index 000000000000..f13fae954773 Binary files /dev/null and b/buildroot/share/dwin/icons-3/009-ICON_Halted.jpg differ diff --git a/buildroot/share/dwin/icons-3/010-ICON_Question.jpg b/buildroot/share/dwin/icons-3/010-ICON_Question.jpg new file mode 100644 index 000000000000..a8d0cddaa8eb Binary files /dev/null and b/buildroot/share/dwin/icons-3/010-ICON_Question.jpg differ diff --git a/buildroot/share/dwin/icons-3/011-ICON_Alert.jpg b/buildroot/share/dwin/icons-3/011-ICON_Alert.jpg new file mode 100644 index 000000000000..603648e86433 Binary files /dev/null and b/buildroot/share/dwin/icons-3/011-ICON_Alert.jpg differ diff --git a/buildroot/share/dwin/icons-3/012-ICON_RotateCW.jpg b/buildroot/share/dwin/icons-3/012-ICON_RotateCW.jpg new file mode 100644 index 000000000000..36f404b9c963 Binary files /dev/null and b/buildroot/share/dwin/icons-3/012-ICON_RotateCW.jpg differ diff --git a/buildroot/share/dwin/icons-3/013-ICON_RotateCCW.jpg b/buildroot/share/dwin/icons-3/013-ICON_RotateCCW.jpg new file mode 100644 index 000000000000..3dc443c193cc Binary files /dev/null and b/buildroot/share/dwin/icons-3/013-ICON_RotateCCW.jpg differ diff --git a/buildroot/share/dwin/icons-3/014-ICON_UpArrow.jpg b/buildroot/share/dwin/icons-3/014-ICON_UpArrow.jpg new file mode 100644 index 000000000000..26b08ca10c13 Binary files /dev/null and b/buildroot/share/dwin/icons-3/014-ICON_UpArrow.jpg differ diff --git a/buildroot/share/dwin/icons-3/015-ICON_DownArrow.jpg b/buildroot/share/dwin/icons-3/015-ICON_DownArrow.jpg new file mode 100644 index 000000000000..5587a3f7f2db Binary files /dev/null and b/buildroot/share/dwin/icons-3/015-ICON_DownArrow.jpg differ diff --git a/buildroot/share/dwin/icons-6/000-ICON_LOGO_Creality.jpg b/buildroot/share/dwin/icons-6/000-ICON_LOGO_Creality.jpg new file mode 100644 index 000000000000..2ceb758a881a Binary files /dev/null and b/buildroot/share/dwin/icons-6/000-ICON_LOGO_Creality.jpg differ diff --git a/buildroot/share/dwin/icons-6/001-ICON_Print_0.jpg b/buildroot/share/dwin/icons-6/001-ICON_Print_0.jpg new file mode 100644 index 000000000000..8729a753c180 Binary files /dev/null and b/buildroot/share/dwin/icons-6/001-ICON_Print_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/002-ICON_Print_1.jpg b/buildroot/share/dwin/icons-6/002-ICON_Print_1.jpg new file mode 100644 index 000000000000..f89841ad1c80 Binary files /dev/null and b/buildroot/share/dwin/icons-6/002-ICON_Print_1.jpg differ diff --git a/buildroot/share/dwin/icons-6/003-ICON_Prepare_0.jpg b/buildroot/share/dwin/icons-6/003-ICON_Prepare_0.jpg new file mode 100644 index 000000000000..2722fa4352db Binary files /dev/null and b/buildroot/share/dwin/icons-6/003-ICON_Prepare_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/004-ICON_Prepare_1.jpg b/buildroot/share/dwin/icons-6/004-ICON_Prepare_1.jpg new file mode 100644 index 000000000000..627082b6fb31 Binary files /dev/null and b/buildroot/share/dwin/icons-6/004-ICON_Prepare_1.jpg differ diff --git a/buildroot/share/dwin/icons-6/005-ICON_Control_0.jpg b/buildroot/share/dwin/icons-6/005-ICON_Control_0.jpg new file mode 100644 index 000000000000..dfe23a3d4f46 Binary files /dev/null and b/buildroot/share/dwin/icons-6/005-ICON_Control_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/006-ICON_Control_1.jpg b/buildroot/share/dwin/icons-6/006-ICON_Control_1.jpg new file mode 100644 index 000000000000..2a813b655e2b Binary files /dev/null and b/buildroot/share/dwin/icons-6/006-ICON_Control_1.jpg differ diff --git a/buildroot/share/dwin/icons-6/007-ICON_Leveling_0.jpg b/buildroot/share/dwin/icons-6/007-ICON_Leveling_0.jpg new file mode 100644 index 000000000000..34d12c62f521 Binary files /dev/null and b/buildroot/share/dwin/icons-6/007-ICON_Leveling_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/008-ICON_Leveling_1.jpg b/buildroot/share/dwin/icons-6/008-ICON_Leveling_1.jpg new file mode 100644 index 000000000000..f75e3720043c Binary files /dev/null and b/buildroot/share/dwin/icons-6/008-ICON_Leveling_1.jpg differ diff --git a/buildroot/share/dwin/icons-6/009-ICON_HotendTemp.jpg b/buildroot/share/dwin/icons-6/009-ICON_HotendTemp.jpg new file mode 100644 index 000000000000..0bf1437c646d Binary files /dev/null and b/buildroot/share/dwin/icons-6/009-ICON_HotendTemp.jpg differ diff --git a/buildroot/share/dwin/icons-6/010-ICON_BedTemp.jpg b/buildroot/share/dwin/icons-6/010-ICON_BedTemp.jpg new file mode 100644 index 000000000000..186d02ad3b92 Binary files /dev/null and b/buildroot/share/dwin/icons-6/010-ICON_BedTemp.jpg differ diff --git a/buildroot/share/dwin/icons-6/011-ICON_Speed.jpg b/buildroot/share/dwin/icons-6/011-ICON_Speed.jpg new file mode 100644 index 000000000000..387c166566b7 Binary files /dev/null and b/buildroot/share/dwin/icons-6/011-ICON_Speed.jpg differ diff --git a/buildroot/share/dwin/icons-6/012-ICON_Zoffset.jpg b/buildroot/share/dwin/icons-6/012-ICON_Zoffset.jpg new file mode 100644 index 000000000000..2e74ee3986d9 Binary files /dev/null and b/buildroot/share/dwin/icons-6/012-ICON_Zoffset.jpg differ diff --git a/buildroot/share/dwin/icons-6/013-ICON_Back.jpg b/buildroot/share/dwin/icons-6/013-ICON_Back.jpg new file mode 100644 index 000000000000..7ffb646b396e Binary files /dev/null and b/buildroot/share/dwin/icons-6/013-ICON_Back.jpg differ diff --git a/buildroot/share/dwin/icons-6/014-ICON_File.jpg b/buildroot/share/dwin/icons-6/014-ICON_File.jpg new file mode 100644 index 000000000000..44a2fa1fd2c0 Binary files /dev/null and b/buildroot/share/dwin/icons-6/014-ICON_File.jpg differ diff --git a/buildroot/share/dwin/icons-6/015-ICON_PrintTime.jpg b/buildroot/share/dwin/icons-6/015-ICON_PrintTime.jpg new file mode 100644 index 000000000000..9b7bfdbaf124 Binary files /dev/null and b/buildroot/share/dwin/icons-6/015-ICON_PrintTime.jpg differ diff --git a/buildroot/share/dwin/icons-6/016-ICON_RemainTime.jpg b/buildroot/share/dwin/icons-6/016-ICON_RemainTime.jpg new file mode 100644 index 000000000000..ad958d31af67 Binary files /dev/null and b/buildroot/share/dwin/icons-6/016-ICON_RemainTime.jpg differ diff --git a/buildroot/share/dwin/icons-6/017-ICON_Setup_0.jpg b/buildroot/share/dwin/icons-6/017-ICON_Setup_0.jpg new file mode 100644 index 000000000000..92fdc079c619 Binary files /dev/null and b/buildroot/share/dwin/icons-6/017-ICON_Setup_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/018-ICON_Setup_1.jpg b/buildroot/share/dwin/icons-6/018-ICON_Setup_1.jpg new file mode 100644 index 000000000000..6c6793452182 Binary files /dev/null and b/buildroot/share/dwin/icons-6/018-ICON_Setup_1.jpg differ diff --git a/buildroot/share/dwin/icons-6/019-ICON_Pause_0.jpg b/buildroot/share/dwin/icons-6/019-ICON_Pause_0.jpg new file mode 100644 index 000000000000..2f6e83110965 Binary files /dev/null and b/buildroot/share/dwin/icons-6/019-ICON_Pause_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/020-ICON_Pause_1.jpg b/buildroot/share/dwin/icons-6/020-ICON_Pause_1.jpg new file mode 100644 index 000000000000..746b943c149f Binary files /dev/null and b/buildroot/share/dwin/icons-6/020-ICON_Pause_1.jpg differ diff --git a/buildroot/share/dwin/icons-6/021-ICON_Continue_0.jpg b/buildroot/share/dwin/icons-6/021-ICON_Continue_0.jpg new file mode 100644 index 000000000000..929004bb786e Binary files /dev/null and b/buildroot/share/dwin/icons-6/021-ICON_Continue_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/022-ICON_Continue_1.jpg b/buildroot/share/dwin/icons-6/022-ICON_Continue_1.jpg new file mode 100644 index 000000000000..4c8c78f38fa3 Binary files /dev/null and b/buildroot/share/dwin/icons-6/022-ICON_Continue_1.jpg differ diff --git a/buildroot/share/dwin/icons-6/023-ICON_Stop_0.jpg b/buildroot/share/dwin/icons-6/023-ICON_Stop_0.jpg new file mode 100644 index 000000000000..320b4e6b9934 Binary files /dev/null and b/buildroot/share/dwin/icons-6/023-ICON_Stop_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/024-ICON_Stop_1.jpg b/buildroot/share/dwin/icons-6/024-ICON_Stop_1.jpg new file mode 100644 index 000000000000..fdbc3686ca56 Binary files /dev/null and b/buildroot/share/dwin/icons-6/024-ICON_Stop_1.jpg differ diff --git a/buildroot/share/dwin/icons-6/025-ICON_Bar.jpg b/buildroot/share/dwin/icons-6/025-ICON_Bar.jpg new file mode 100644 index 000000000000..1449d9a1827a Binary files /dev/null and b/buildroot/share/dwin/icons-6/025-ICON_Bar.jpg differ diff --git a/buildroot/share/dwin/icons-6/026-ICON_More.jpg b/buildroot/share/dwin/icons-6/026-ICON_More.jpg new file mode 100644 index 000000000000..6ee088a7f221 Binary files /dev/null and b/buildroot/share/dwin/icons-6/026-ICON_More.jpg differ diff --git a/buildroot/share/dwin/icons-6/027-ICON_Axis.jpg b/buildroot/share/dwin/icons-6/027-ICON_Axis.jpg new file mode 100644 index 000000000000..2eb19a0011ee Binary files /dev/null and b/buildroot/share/dwin/icons-6/027-ICON_Axis.jpg differ diff --git a/buildroot/share/dwin/icons-6/028-ICON_CloseMotor.jpg b/buildroot/share/dwin/icons-6/028-ICON_CloseMotor.jpg new file mode 100644 index 000000000000..cdb4f74d40f2 Binary files /dev/null and b/buildroot/share/dwin/icons-6/028-ICON_CloseMotor.jpg differ diff --git a/buildroot/share/dwin/icons-6/029-ICON_Homing.jpg b/buildroot/share/dwin/icons-6/029-ICON_Homing.jpg new file mode 100644 index 000000000000..ce263014ead9 Binary files /dev/null and b/buildroot/share/dwin/icons-6/029-ICON_Homing.jpg differ diff --git a/buildroot/share/dwin/icons-6/030-ICON_SetHome.jpg b/buildroot/share/dwin/icons-6/030-ICON_SetHome.jpg new file mode 100644 index 000000000000..14aedc0dd019 Binary files /dev/null and b/buildroot/share/dwin/icons-6/030-ICON_SetHome.jpg differ diff --git a/buildroot/share/dwin/icons-6/031-ICON_PLAPreheat.jpg b/buildroot/share/dwin/icons-6/031-ICON_PLAPreheat.jpg new file mode 100644 index 000000000000..7b8eb5857d6c Binary files /dev/null and b/buildroot/share/dwin/icons-6/031-ICON_PLAPreheat.jpg differ diff --git a/buildroot/share/dwin/icons-6/032-ICON_ABSPreheat.jpg b/buildroot/share/dwin/icons-6/032-ICON_ABSPreheat.jpg new file mode 100644 index 000000000000..274604d2f92b Binary files /dev/null and b/buildroot/share/dwin/icons-6/032-ICON_ABSPreheat.jpg differ diff --git a/buildroot/share/dwin/icons-6/033-ICON_Cool.jpg b/buildroot/share/dwin/icons-6/033-ICON_Cool.jpg new file mode 100644 index 000000000000..014e6f5dcbab Binary files /dev/null and b/buildroot/share/dwin/icons-6/033-ICON_Cool.jpg differ diff --git a/buildroot/share/dwin/icons-6/034-ICON_Language.jpg b/buildroot/share/dwin/icons-6/034-ICON_Language.jpg new file mode 100644 index 000000000000..055b4c1ae8e6 Binary files /dev/null and b/buildroot/share/dwin/icons-6/034-ICON_Language.jpg differ diff --git a/buildroot/share/dwin/icons-6/035-ICON_MoveX.jpg b/buildroot/share/dwin/icons-6/035-ICON_MoveX.jpg new file mode 100644 index 000000000000..54f834caaf12 Binary files /dev/null and b/buildroot/share/dwin/icons-6/035-ICON_MoveX.jpg differ diff --git a/buildroot/share/dwin/icons-6/036-ICON_MoveY.jpg b/buildroot/share/dwin/icons-6/036-ICON_MoveY.jpg new file mode 100644 index 000000000000..b82a5b25cd6f Binary files /dev/null and b/buildroot/share/dwin/icons-6/036-ICON_MoveY.jpg differ diff --git a/buildroot/share/dwin/icons-6/037-ICON_MoveZ.jpg b/buildroot/share/dwin/icons-6/037-ICON_MoveZ.jpg new file mode 100644 index 000000000000..487d6e4e4436 Binary files /dev/null and b/buildroot/share/dwin/icons-6/037-ICON_MoveZ.jpg differ diff --git a/buildroot/share/dwin/icons-6/038-ICON_Extruder.jpg b/buildroot/share/dwin/icons-6/038-ICON_Extruder.jpg new file mode 100644 index 000000000000..155b9a58576d Binary files /dev/null and b/buildroot/share/dwin/icons-6/038-ICON_Extruder.jpg differ diff --git a/buildroot/share/dwin/icons-6/040-ICON_Temperature.jpg b/buildroot/share/dwin/icons-6/040-ICON_Temperature.jpg new file mode 100644 index 000000000000..eaea25bbd881 Binary files /dev/null and b/buildroot/share/dwin/icons-6/040-ICON_Temperature.jpg differ diff --git a/buildroot/share/dwin/icons-6/041-ICON_Motion.jpg b/buildroot/share/dwin/icons-6/041-ICON_Motion.jpg new file mode 100644 index 000000000000..472a6354e43d Binary files /dev/null and b/buildroot/share/dwin/icons-6/041-ICON_Motion.jpg differ diff --git a/buildroot/share/dwin/icons-6/042-ICON_WriteEEPROM.jpg b/buildroot/share/dwin/icons-6/042-ICON_WriteEEPROM.jpg new file mode 100644 index 000000000000..2a4dd5b9296c Binary files /dev/null and b/buildroot/share/dwin/icons-6/042-ICON_WriteEEPROM.jpg differ diff --git a/buildroot/share/dwin/icons-6/043-ICON_ReadEEPROM.jpg b/buildroot/share/dwin/icons-6/043-ICON_ReadEEPROM.jpg new file mode 100644 index 000000000000..53aab6b7578c Binary files /dev/null and b/buildroot/share/dwin/icons-6/043-ICON_ReadEEPROM.jpg differ diff --git a/buildroot/share/dwin/icons-6/044-ICON_ResumeEEPROM.jpg b/buildroot/share/dwin/icons-6/044-ICON_ResumeEEPROM.jpg new file mode 100644 index 000000000000..840bac572861 Binary files /dev/null and b/buildroot/share/dwin/icons-6/044-ICON_ResumeEEPROM.jpg differ diff --git a/buildroot/share/dwin/icons-6/045-ICON_Info.jpg b/buildroot/share/dwin/icons-6/045-ICON_Info.jpg new file mode 100644 index 000000000000..34e63e587a1c Binary files /dev/null and b/buildroot/share/dwin/icons-6/045-ICON_Info.jpg differ diff --git a/buildroot/share/dwin/icons-6/046-ICON_SetEndTemp.jpg b/buildroot/share/dwin/icons-6/046-ICON_SetEndTemp.jpg new file mode 100644 index 000000000000..33f50041836c Binary files /dev/null and b/buildroot/share/dwin/icons-6/046-ICON_SetEndTemp.jpg differ diff --git a/buildroot/share/dwin/icons-6/047-ICON_SetBedTemp.jpg b/buildroot/share/dwin/icons-6/047-ICON_SetBedTemp.jpg new file mode 100644 index 000000000000..09e5072ab9b4 Binary files /dev/null and b/buildroot/share/dwin/icons-6/047-ICON_SetBedTemp.jpg differ diff --git a/buildroot/share/dwin/icons-6/048-ICON_FanSpeed.jpg b/buildroot/share/dwin/icons-6/048-ICON_FanSpeed.jpg new file mode 100644 index 000000000000..6ed23f653fa9 Binary files /dev/null and b/buildroot/share/dwin/icons-6/048-ICON_FanSpeed.jpg differ diff --git a/buildroot/share/dwin/icons-6/049-ICON_SetPLAPreheat.jpg b/buildroot/share/dwin/icons-6/049-ICON_SetPLAPreheat.jpg new file mode 100644 index 000000000000..f69c6f454e19 Binary files /dev/null and b/buildroot/share/dwin/icons-6/049-ICON_SetPLAPreheat.jpg differ diff --git a/buildroot/share/dwin/icons-6/050-ICON_SetABSPreheat.jpg b/buildroot/share/dwin/icons-6/050-ICON_SetABSPreheat.jpg new file mode 100644 index 000000000000..07620e14eb12 Binary files /dev/null and b/buildroot/share/dwin/icons-6/050-ICON_SetABSPreheat.jpg differ diff --git a/buildroot/share/dwin/icons-6/051-ICON_MaxSpeed.jpg b/buildroot/share/dwin/icons-6/051-ICON_MaxSpeed.jpg new file mode 100644 index 000000000000..eaaa21255b62 Binary files /dev/null and b/buildroot/share/dwin/icons-6/051-ICON_MaxSpeed.jpg differ diff --git a/buildroot/share/dwin/icons-6/052-ICON_MaxAccelerated.jpg b/buildroot/share/dwin/icons-6/052-ICON_MaxAccelerated.jpg new file mode 100644 index 000000000000..4e9c3ad6e410 Binary files /dev/null and b/buildroot/share/dwin/icons-6/052-ICON_MaxAccelerated.jpg differ diff --git a/buildroot/share/dwin/icons-6/053-ICON_MaxJerk.jpg b/buildroot/share/dwin/icons-6/053-ICON_MaxJerk.jpg new file mode 100644 index 000000000000..119df1a03d64 Binary files /dev/null and b/buildroot/share/dwin/icons-6/053-ICON_MaxJerk.jpg differ diff --git a/buildroot/share/dwin/icons-6/054-ICON_Step.jpg b/buildroot/share/dwin/icons-6/054-ICON_Step.jpg new file mode 100644 index 000000000000..4a0da4a487cd Binary files /dev/null and b/buildroot/share/dwin/icons-6/054-ICON_Step.jpg differ diff --git a/buildroot/share/dwin/icons-6/055-ICON_PrintSize.jpg b/buildroot/share/dwin/icons-6/055-ICON_PrintSize.jpg new file mode 100644 index 000000000000..4f08d5f1f92c Binary files /dev/null and b/buildroot/share/dwin/icons-6/055-ICON_PrintSize.jpg differ diff --git a/buildroot/share/dwin/icons-6/056-ICON_Version.jpg b/buildroot/share/dwin/icons-6/056-ICON_Version.jpg new file mode 100644 index 000000000000..2d275d82b4a3 Binary files /dev/null and b/buildroot/share/dwin/icons-6/056-ICON_Version.jpg differ diff --git a/buildroot/share/dwin/icons-6/057-ICON_Contact.jpg b/buildroot/share/dwin/icons-6/057-ICON_Contact.jpg new file mode 100644 index 000000000000..5138789de89a Binary files /dev/null and b/buildroot/share/dwin/icons-6/057-ICON_Contact.jpg differ diff --git a/buildroot/share/dwin/icons-6/058-ICON_StockConfiguraton.jpg b/buildroot/share/dwin/icons-6/058-ICON_StockConfiguraton.jpg new file mode 100644 index 000000000000..8e2b6fedbe13 Binary files /dev/null and b/buildroot/share/dwin/icons-6/058-ICON_StockConfiguraton.jpg differ diff --git a/buildroot/share/dwin/icons-6/059-ICON_MaxSpeedX.jpg b/buildroot/share/dwin/icons-6/059-ICON_MaxSpeedX.jpg new file mode 100644 index 000000000000..c60504f326f7 Binary files /dev/null and b/buildroot/share/dwin/icons-6/059-ICON_MaxSpeedX.jpg differ diff --git a/buildroot/share/dwin/icons-6/060-ICON_MaxSpeedY.jpg b/buildroot/share/dwin/icons-6/060-ICON_MaxSpeedY.jpg new file mode 100644 index 000000000000..c3b3cc7ce18f Binary files /dev/null and b/buildroot/share/dwin/icons-6/060-ICON_MaxSpeedY.jpg differ diff --git a/buildroot/share/dwin/icons-6/061-ICON_MaxSpeedZ.jpg b/buildroot/share/dwin/icons-6/061-ICON_MaxSpeedZ.jpg new file mode 100644 index 000000000000..fe79df374681 Binary files /dev/null and b/buildroot/share/dwin/icons-6/061-ICON_MaxSpeedZ.jpg differ diff --git a/buildroot/share/dwin/icons-6/062-ICON_MaxSpeedE.jpg b/buildroot/share/dwin/icons-6/062-ICON_MaxSpeedE.jpg new file mode 100644 index 000000000000..519f1b448c84 Binary files /dev/null and b/buildroot/share/dwin/icons-6/062-ICON_MaxSpeedE.jpg differ diff --git a/buildroot/share/dwin/icons-6/063-ICON_MaxAccX.jpg b/buildroot/share/dwin/icons-6/063-ICON_MaxAccX.jpg new file mode 100644 index 000000000000..9258c8618fa3 Binary files /dev/null and b/buildroot/share/dwin/icons-6/063-ICON_MaxAccX.jpg differ diff --git a/buildroot/share/dwin/icons-6/064-ICON_MaxAccY.jpg b/buildroot/share/dwin/icons-6/064-ICON_MaxAccY.jpg new file mode 100644 index 000000000000..1a163314560c Binary files /dev/null and b/buildroot/share/dwin/icons-6/064-ICON_MaxAccY.jpg differ diff --git a/buildroot/share/dwin/icons-6/065-ICON_MaxAccZ.jpg b/buildroot/share/dwin/icons-6/065-ICON_MaxAccZ.jpg new file mode 100644 index 000000000000..23255ce0e591 Binary files /dev/null and b/buildroot/share/dwin/icons-6/065-ICON_MaxAccZ.jpg differ diff --git a/buildroot/share/dwin/icons-6/066-ICON_MaxAccE.jpg b/buildroot/share/dwin/icons-6/066-ICON_MaxAccE.jpg new file mode 100644 index 000000000000..5bd3fedd6e15 Binary files /dev/null and b/buildroot/share/dwin/icons-6/066-ICON_MaxAccE.jpg differ diff --git a/buildroot/share/dwin/icons-6/067-ICON_MaxSpeedJerkX.jpg b/buildroot/share/dwin/icons-6/067-ICON_MaxSpeedJerkX.jpg new file mode 100644 index 000000000000..c316c750b58c Binary files /dev/null and b/buildroot/share/dwin/icons-6/067-ICON_MaxSpeedJerkX.jpg differ diff --git a/buildroot/share/dwin/icons-6/068-ICON_MaxSpeedJerkY.jpg b/buildroot/share/dwin/icons-6/068-ICON_MaxSpeedJerkY.jpg new file mode 100644 index 000000000000..c7cda895033b Binary files /dev/null and b/buildroot/share/dwin/icons-6/068-ICON_MaxSpeedJerkY.jpg differ diff --git a/buildroot/share/dwin/icons-6/069-ICON_MaxSpeedJerkZ.jpg b/buildroot/share/dwin/icons-6/069-ICON_MaxSpeedJerkZ.jpg new file mode 100644 index 000000000000..be450cd460ac Binary files /dev/null and b/buildroot/share/dwin/icons-6/069-ICON_MaxSpeedJerkZ.jpg differ diff --git a/buildroot/share/dwin/icons-6/070-ICON_MaxSpeedJerkE.jpg b/buildroot/share/dwin/icons-6/070-ICON_MaxSpeedJerkE.jpg new file mode 100644 index 000000000000..3c926b856519 Binary files /dev/null and b/buildroot/share/dwin/icons-6/070-ICON_MaxSpeedJerkE.jpg differ diff --git a/buildroot/share/dwin/icons-6/071-ICON_StepX.jpg b/buildroot/share/dwin/icons-6/071-ICON_StepX.jpg new file mode 100644 index 000000000000..f1015b82185f Binary files /dev/null and b/buildroot/share/dwin/icons-6/071-ICON_StepX.jpg differ diff --git a/buildroot/share/dwin/icons-6/072-ICON_StepY.jpg b/buildroot/share/dwin/icons-6/072-ICON_StepY.jpg new file mode 100644 index 000000000000..9bb3e6e6beb7 Binary files /dev/null and b/buildroot/share/dwin/icons-6/072-ICON_StepY.jpg differ diff --git a/buildroot/share/dwin/icons-6/073-ICON_StepZ.jpg b/buildroot/share/dwin/icons-6/073-ICON_StepZ.jpg new file mode 100644 index 000000000000..78dce2a36933 Binary files /dev/null and b/buildroot/share/dwin/icons-6/073-ICON_StepZ.jpg differ diff --git a/buildroot/share/dwin/icons-6/074-ICON_StepE.jpg b/buildroot/share/dwin/icons-6/074-ICON_StepE.jpg new file mode 100644 index 000000000000..58eaff565032 Binary files /dev/null and b/buildroot/share/dwin/icons-6/074-ICON_StepE.jpg differ diff --git a/buildroot/share/dwin/icons-6/075-ICON_Setspeed.jpg b/buildroot/share/dwin/icons-6/075-ICON_Setspeed.jpg new file mode 100644 index 000000000000..94b808f716a2 Binary files /dev/null and b/buildroot/share/dwin/icons-6/075-ICON_Setspeed.jpg differ diff --git a/buildroot/share/dwin/icons-6/076-ICON_SetZOffset.jpg b/buildroot/share/dwin/icons-6/076-ICON_SetZOffset.jpg new file mode 100644 index 000000000000..14aedc0dd019 Binary files /dev/null and b/buildroot/share/dwin/icons-6/076-ICON_SetZOffset.jpg differ diff --git a/buildroot/share/dwin/icons-6/077-ICON_Rectangle.jpg b/buildroot/share/dwin/icons-6/077-ICON_Rectangle.jpg new file mode 100644 index 000000000000..3069eccd5048 Binary files /dev/null and b/buildroot/share/dwin/icons-6/077-ICON_Rectangle.jpg differ diff --git a/buildroot/share/dwin/icons-6/078-ICON_BLTouch.jpg b/buildroot/share/dwin/icons-6/078-ICON_BLTouch.jpg new file mode 100644 index 000000000000..b3234d45aa12 Binary files /dev/null and b/buildroot/share/dwin/icons-6/078-ICON_BLTouch.jpg differ diff --git a/buildroot/share/dwin/icons-6/079-ICON_TempTooLow.jpg b/buildroot/share/dwin/icons-6/079-ICON_TempTooLow.jpg new file mode 100644 index 000000000000..c403c328f5ed Binary files /dev/null and b/buildroot/share/dwin/icons-6/079-ICON_TempTooLow.jpg differ diff --git a/buildroot/share/dwin/icons-6/080-ICON_AutoLeveling.jpg b/buildroot/share/dwin/icons-6/080-ICON_AutoLeveling.jpg new file mode 100644 index 000000000000..837c5ee28161 Binary files /dev/null and b/buildroot/share/dwin/icons-6/080-ICON_AutoLeveling.jpg differ diff --git a/buildroot/share/dwin/icons-6/081-ICON_TempTooHigh.jpg b/buildroot/share/dwin/icons-6/081-ICON_TempTooHigh.jpg new file mode 100644 index 000000000000..07aae4e5ec33 Binary files /dev/null and b/buildroot/share/dwin/icons-6/081-ICON_TempTooHigh.jpg differ diff --git a/buildroot/share/dwin/icons-6/082-ICON_NoTips_C.jpg b/buildroot/share/dwin/icons-6/082-ICON_NoTips_C.jpg new file mode 100644 index 000000000000..b55706060c8b Binary files /dev/null and b/buildroot/share/dwin/icons-6/082-ICON_NoTips_C.jpg differ diff --git a/buildroot/share/dwin/icons-6/083-ICON_NoTips_E.jpg b/buildroot/share/dwin/icons-6/083-ICON_NoTips_E.jpg new file mode 100644 index 000000000000..470b88a52664 Binary files /dev/null and b/buildroot/share/dwin/icons-6/083-ICON_NoTips_E.jpg differ diff --git a/buildroot/share/dwin/icons-6/084-ICON_Continue_C.jpg b/buildroot/share/dwin/icons-6/084-ICON_Continue_C.jpg new file mode 100644 index 000000000000..718fd59591a4 Binary files /dev/null and b/buildroot/share/dwin/icons-6/084-ICON_Continue_C.jpg differ diff --git a/buildroot/share/dwin/icons-6/085-ICON_Continue_E.jpg b/buildroot/share/dwin/icons-6/085-ICON_Continue_E.jpg new file mode 100644 index 000000000000..2fb635d2bffa Binary files /dev/null and b/buildroot/share/dwin/icons-6/085-ICON_Continue_E.jpg differ diff --git a/buildroot/share/dwin/icons-6/086-ICON_Cancel_C.jpg b/buildroot/share/dwin/icons-6/086-ICON_Cancel_C.jpg new file mode 100644 index 000000000000..af203f508107 Binary files /dev/null and b/buildroot/share/dwin/icons-6/086-ICON_Cancel_C.jpg differ diff --git a/buildroot/share/dwin/icons-6/087-ICON_Cancel_E.jpg b/buildroot/share/dwin/icons-6/087-ICON_Cancel_E.jpg new file mode 100644 index 000000000000..db1642e00c59 Binary files /dev/null and b/buildroot/share/dwin/icons-6/087-ICON_Cancel_E.jpg differ diff --git a/buildroot/share/dwin/icons-6/088-ICON_Confirm_C.jpg b/buildroot/share/dwin/icons-6/088-ICON_Confirm_C.jpg new file mode 100644 index 000000000000..6f441efb82cb Binary files /dev/null and b/buildroot/share/dwin/icons-6/088-ICON_Confirm_C.jpg differ diff --git a/buildroot/share/dwin/icons-6/089-ICON_Confirm_E.jpg b/buildroot/share/dwin/icons-6/089-ICON_Confirm_E.jpg new file mode 100644 index 000000000000..5f424b67ea7c Binary files /dev/null and b/buildroot/share/dwin/icons-6/089-ICON_Confirm_E.jpg differ diff --git a/buildroot/share/dwin/icons-6/090-ICON_Info_0.jpg b/buildroot/share/dwin/icons-6/090-ICON_Info_0.jpg new file mode 100644 index 000000000000..d392a301ed8d Binary files /dev/null and b/buildroot/share/dwin/icons-6/090-ICON_Info_0.jpg differ diff --git a/buildroot/share/dwin/icons-6/091-ICON_Info_1.jpg b/buildroot/share/dwin/icons-6/091-ICON_Info_1.jpg new file mode 100644 index 000000000000..cde9c0b064e2 Binary files /dev/null and b/buildroot/share/dwin/icons-6/091-ICON_Info_1.jpg differ diff --git a/buildroot/share/dwin/icons-svg/alert.svg b/buildroot/share/dwin/icons-svg/alert.svg new file mode 100644 index 000000000000..e98bd58bd8e1 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/alert.svg @@ -0,0 +1,85 @@ + + + + + + + + image/svg+xml + + + + + + + + ! + + diff --git a/buildroot/share/dwin/icons-svg/bed_flat_old.svg b/buildroot/share/dwin/icons-svg/bed_flat_old.svg new file mode 100644 index 000000000000..e4b860bc7158 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/bed_flat_old.svg @@ -0,0 +1,72 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/bed_flat_on.svg b/buildroot/share/dwin/icons-svg/bed_flat_on.svg new file mode 100644 index 000000000000..a87b0c0ff071 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/bed_flat_on.svg @@ -0,0 +1,91 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/bed_leveled_off.svg b/buildroot/share/dwin/icons-svg/bed_leveled_off.svg new file mode 100644 index 000000000000..161b8d11d457 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/bed_leveled_off.svg @@ -0,0 +1,83 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/bed_leveled_on.svg b/buildroot/share/dwin/icons-svg/bed_leveled_on.svg new file mode 100644 index 000000000000..bda0c77a9ebc --- /dev/null +++ b/buildroot/share/dwin/icons-svg/bed_leveled_on.svg @@ -0,0 +1,103 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/bed_off.svg b/buildroot/share/dwin/icons-svg/bed_off.svg new file mode 100644 index 000000000000..936710e49bda --- /dev/null +++ b/buildroot/share/dwin/icons-svg/bed_off.svg @@ -0,0 +1,64 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/bed_on.svg b/buildroot/share/dwin/icons-svg/bed_on.svg new file mode 100644 index 000000000000..61218e57a6a2 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/bed_on.svg @@ -0,0 +1,84 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/bedline.svg b/buildroot/share/dwin/icons-svg/bedline.svg new file mode 100644 index 000000000000..51670b7a196a --- /dev/null +++ b/buildroot/share/dwin/icons-svg/bedline.svg @@ -0,0 +1,64 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/down_arrow.svg b/buildroot/share/dwin/icons-svg/down_arrow.svg new file mode 100644 index 000000000000..9c1d07efe064 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/down_arrow.svg @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/fan.svg b/buildroot/share/dwin/icons-svg/fan.svg new file mode 100644 index 000000000000..0040f26b6b8e --- /dev/null +++ b/buildroot/share/dwin/icons-svg/fan.svg @@ -0,0 +1,155 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/halted.svg b/buildroot/share/dwin/icons-svg/halted.svg new file mode 100644 index 000000000000..38a78384bcdc --- /dev/null +++ b/buildroot/share/dwin/icons-svg/halted.svg @@ -0,0 +1,83 @@ + + + + + + + + image/svg+xml + + + + + + + + X + + diff --git a/buildroot/share/dwin/icons-svg/hotend_off.svg b/buildroot/share/dwin/icons-svg/hotend_off.svg new file mode 100644 index 000000000000..14da6a23ebfb --- /dev/null +++ b/buildroot/share/dwin/icons-svg/hotend_off.svg @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/hotend_on.svg b/buildroot/share/dwin/icons-svg/hotend_on.svg new file mode 100644 index 000000000000..f112ba186b06 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/hotend_on.svg @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/question.svg b/buildroot/share/dwin/icons-svg/question.svg new file mode 100644 index 000000000000..8d8849ca4e56 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/question.svg @@ -0,0 +1,75 @@ + + + + + + + + image/svg+xml + + + + + + + + ? + + diff --git a/buildroot/share/dwin/icons-svg/rotate_ccw.svg b/buildroot/share/dwin/icons-svg/rotate_ccw.svg new file mode 100644 index 000000000000..8b007725c674 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/rotate_ccw.svg @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/rotate_cw.svg b/buildroot/share/dwin/icons-svg/rotate_cw.svg new file mode 100644 index 000000000000..446ad519ec0c --- /dev/null +++ b/buildroot/share/dwin/icons-svg/rotate_cw.svg @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/icons-svg/up_arrow.svg b/buildroot/share/dwin/icons-svg/up_arrow.svg new file mode 100644 index 000000000000..bc20be269339 --- /dev/null +++ b/buildroot/share/dwin/icons-svg/up_arrow.svg @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/buildroot/share/dwin/make_jpgs.sh b/buildroot/share/dwin/make_jpgs.sh new file mode 100755 index 000000000000..0acace7388df --- /dev/null +++ b/buildroot/share/dwin/make_jpgs.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +mkdir -p icons-3 + +convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/hotend_off.svg ./icons-3/001-ICON_HotendOff.jpg +convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/hotend_on.svg ./icons-3/002-ICON_HotendOn.jpg + +convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/bed_off.svg ./icons-3/003-ICON_BedOff.jpg +convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/bed_on.svg ./icons-3/004-ICON_BedOn.jpg + +convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/fan.svg ./icons-3/005-ICON_Fan0.jpg +convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 -distort SRT 22.5 ./icons-svg/fan.svg ./icons-3/006-ICON_Fan1.jpg +convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 -distort SRT 45 ./icons-svg/fan.svg ./icons-3/007-ICON_Fan2.jpg +convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 -distort SRT 67.5 ./icons-svg/fan.svg ./icons-3/008-ICON_Fan3.jpg + +convert -size 96x96 -background "#333e44" -quality 100 -sampling-factor 4:4:4 ./icons-svg/halted.svg ./icons-3/009-ICON_Halted.jpg +convert -size 96x96 -background "#333e44" -quality 100 -sampling-factor 4:4:4 ./icons-svg/question.svg ./icons-3/010-ICON_Question.jpg +convert -size 96x96 -background "#333e44" -quality 100 -sampling-factor 4:4:4 ./icons-svg/alert.svg ./icons-3/011-ICON_Alert.jpg + +convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/rotate_cw.svg ./icons-3/012-ICON_RotateCW.jpg +convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/rotate_ccw.svg ./icons-3/013-ICON_RotateCCW.jpg +convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/up_arrow.svg ./icons-3/014-ICON_UpArrow.jpg +convert -size 48x48 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/down_arrow.svg ./icons-3/015-ICON_DownArrow.jpg + +convert -size 48x8 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/bedline.svg ./icons-3/016-ICON_Bedline.jpg + +convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/bed_leveled_off.svg ./icons-3/017-ICON_BedLeveledOff.jpg +convert -size 48x36 -background "#080808" -quality 100 -sampling-factor 4:4:4 ./icons-svg/bed_leveled_on.svg ./icons-3/018-ICON_BedLeveledOn.jpg + +rm 3.ICO +./bin/makeIco.py icons-3 3.ICO diff --git a/buildroot/share/fonts/genpages.c b/buildroot/share/fonts/genpages.c index dea5b05c5c80..8009e553fa68 100644 --- a/buildroot/share/fonts/genpages.c +++ b/buildroot/share/fonts/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; - uint8_t *p = pstart; + const uint8_t *p = pstart; /*size_t maxlen = strlen(pstart);*/ assert(NULL != pstart); diff --git a/buildroot/share/git/mfconfig b/buildroot/share/git/mfconfig index 70642a5d39cb..d3e0b67b3e40 100755 --- a/buildroot/share/git/mfconfig +++ b/buildroot/share/git/mfconfig @@ -74,6 +74,8 @@ if [[ $ACTION == "init" ]]; then # a 'BASE' branch with only defaults as a starting point. # + SED=$(which gsed sed | head -n1) + echo "- Initializing BASE branch..." # Use the import branch as the source @@ -82,6 +84,14 @@ if [[ $ACTION == "init" ]]; then # Copy to a temporary location TEMP=$( mktemp -d ) ; cp -R config $TEMP + # Strip all #error lines + IFS=$'\n'; set -f + for fn in $( find $TEMP/config -type f -name "Configuration.h" ); do + $SED -i~ -e "20,30{/#error/d}" "$fn" + rm "$fn~" + done + unset IFS; set +f + # Make sure we're not on the 'BASE' branch... git checkout init-repo >/dev/null 2>&1 || exit @@ -149,7 +159,6 @@ if [[ $ACTION == "init" ]]; then ((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset TPARA..." >/dev/null # Update the %VERSION% in the README.md file - SED=$(which gsed sed | head -n1) VERS=$( echo $EXPORT | $SED 's/release-//' ) eval "${SED} -E -i~ -e 's/%VERSION%/$VERS/g' README.md" rm -f README.md~ diff --git a/buildroot/share/git/mffp b/buildroot/share/git/mffp index 0680b3dba562..ab4dd4c0b771 100755 --- a/buildroot/share/git/mffp +++ b/buildroot/share/git/mffp @@ -6,7 +6,7 @@ # By default: `git push upstream HEAD:bugfix-2.0.x` # -usage() { echo "usage: `basename $0` [1|2] [ref]" 1>&2 } +usage() { echo "usage: `basename $0` [1|2] [ref]" 1>&2 ; } [[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage ; exit 1; } @@ -17,7 +17,7 @@ elif [[ $# == 1 ]]; then MFINFO=$(mfinfo) || exit 1 REF=${1:-HEAD} else - usage + usage ; exit 1 fi IFS=' ' read -a INFO <<< "$MFINFO" diff --git a/buildroot/share/git/mfnew b/buildroot/share/git/mfnew index 6d067a7f08e6..48703e67a14d 100755 --- a/buildroot/share/git/mfnew +++ b/buildroot/share/git/mfnew @@ -5,9 +5,7 @@ # Create a new branch from the default target with the given name # -usage() { - echo "usage: `basename $0` [1|2] [name]" 1>&2 -} +usage() { echo "usage: `basename $0` [1|2] [name]" 1>&2 ; } [[ $# < 3 && $1 != "-h" && $1 != "--help" ]] || { usage; exit 1; } diff --git a/buildroot/share/git/mfprep b/buildroot/share/git/mfprep index 7a8e05ee317c..6a8850286153 100755 --- a/buildroot/share/git/mfprep +++ b/buildroot/share/git/mfprep @@ -2,54 +2,69 @@ # # mfprep tag1 [tag2] # -# Find commits in bugfix-2.0.x not yet in 2.0.x +# Find commits in bugfix-2.0.x that are not yet in 2.0.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. # SED=$(which gsed sed | head -n1) SELF=`basename "$0"` +DRYRUN=0 [[ $# < 1 || $# > 2 ]] && { echo "Usage $SELF tag1 [tag2]" ; exit 1 ; } TAG1=$1 TAG2=${2:-"HEAD"} +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 ; } +[[ -n "$MTAG" ]] || { echo "Can't find tag bf-$TAG1" ; exit 1 ; } MTAG=`git tag | grep -e "^$TAG1\$"` -[[ -n $MTAG ]] || { echo "Can't find tag $TAG1" ; exit 1 ; } +[[ -n "$MTAG" ]] || { echo "Can't find tag $TAG1" ; exit 1 ; } -# Generate log of recent commits for bugfix-2.0.x and 2.0.x +# Generate log of recent commits for bugfix-2.0.x and DEST TMPDIR=`mktemp -d` LOGB="$TMPDIR/log-bf.txt" -LOG2="$TMPDIR/log-20x.txt" +LOG2="$TMPDIR/log-2x.txt" TMPF="$TMPDIR/tmp.txt" -SCRF="$TMPDIR/update-20x.sh" +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 2.0.x +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 ; } -# Go through commit text from 2.0.x removing all matches from the bugfix log +# Go through commit text from DEST removing all matches from the bugfix log cat "$LOG2" | while read line; do - #echo "... $line" - if [[ $line =~ (\(#[0-9]{5}\))$ ]]; then - PATT=${BASH_REMATCH[1]} + if [[ $line =~ \(((#[0-9]{5}),* *)((#[0-9]{5}),* *)?((#[0-9]{5}),* *)?((#[0-9]{5}),* *)?((#[0-9]{5}),* *)?((#[0-9]{5}),* *)?\)$ ]]; then + PATT="" + for i in ${!BASH_REMATCH[@]}; do + if ((i > 0 && (i % 2 == 0))); then + if [[ -n "${BASH_REMATCH[i]}" ]]; then + [[ -n "$PATT" ]] && PATT="$PATT|" + PATT="$PATT${BASH_REMATCH[i]}" + fi + fi + done #echo "... $PATT" + [[ -n "$PATT" ]] && { grep -vE "$PATT" "$LOGB" >"$TMPF" ; cp "$TMPF" "$LOGB" ; } else PATT=$( $SED -E 's/^\[[0-9a-f]{10}\]( . )?(.+)$/\2/' <<<"$line" ) + [[ -n "$PATT" ]] && { grep -v "$PATT" "$LOGB" >"$TMPF" ; cp "$TMPF" "$LOGB" ; } fi - [[ -n $PATT ]] && { grep -v "$PATT" "$LOGB" >"$TMPF" ; cp "$TMPF" "$LOGB" ; } done # Convert remaining commits into git commands -echo -e "#!/usr/bin/env bash\nset -e\ngit checkout 2.0.x\n" >"$TMPF" +echo -e "#!/usr/bin/env bash\nset -e\ngit checkout ${DEST}\n" >"$TMPF" cat "$LOGB" | while read line; do if [[ $line =~ ^\[([0-9a-f]{10})\]\ *(.*)$ ]]; then CID=${BASH_REMATCH[1]} @@ -60,5 +75,6 @@ cat "$LOGB" | while read line; do fi done mv "$TMPF" "$SCRF" +chmod +x "$SCRF" -open "$TMPDIR" +((DRYRUN)) && rm -r "$TMPDIR" || open "$TMPDIR" diff --git a/buildroot/share/pixmaps/logo/marlin-outrun-nf-500.png b/buildroot/share/pixmaps/logo/marlin-outrun-nf-500.png new file mode 100644 index 000000000000..e36a3eb5c216 Binary files /dev/null and b/buildroot/share/pixmaps/logo/marlin-outrun-nf-500.png differ diff --git a/buildroot/share/scripts/MarlinBinaryProtocol.py b/buildroot/share/scripts/MarlinBinaryProtocol.py new file mode 100644 index 000000000000..4887ad991978 --- /dev/null +++ b/buildroot/share/scripts/MarlinBinaryProtocol.py @@ -0,0 +1,434 @@ +# +# MarlinBinaryProtocol.py +# Supporting Firmware upload via USB/Serial, saving to the attached media. +# +import serial +import math +import time +from collections import deque +import threading +import sys +import datetime +import random +try: + import heatshrink + heatshrink_exists = True +except ImportError: + heatshrink_exists = False + + +def millis(): + return time.perf_counter() * 1000 + +class TimeOut(object): + def __init__(self, milliseconds): + self.duration = milliseconds + self.reset() + + def reset(self): + self.endtime = millis() + self.duration + + def timedout(self): + return millis() > self.endtime + +class ReadTimeout(Exception): + pass +class FatalError(Exception): + pass +class SycronisationError(Exception): + pass +class PayloadOverflow(Exception): + pass +class ConnectionLost(Exception): + pass + +class Protocol(object): + device = None + baud = None + max_block_size = 0 + port = None + block_size = 0 + + packet_transit = None + packet_status = None + packet_ping = None + + errors = 0 + packet_buffer = None + simulate_errors = 0 + sync = 0 + connected = False + syncronised = False + worker_thread = None + + response_timeout = 1000 + + applications = [] + responses = deque() + + def __init__(self, device, baud, bsize, simerr, timeout): + print("pySerial Version:", serial.VERSION) + self.port = serial.Serial(device, baudrate = baud, write_timeout = 0, timeout = 1) + self.device = device + self.baud = baud + self.block_size = int(bsize) + self.simulate_errors = max(min(simerr, 1.0), 0.0); + self.connected = True + self.response_timeout = timeout + + self.register(['ok', 'rs', 'ss', 'fe'], self.process_input) + + self.worker_thread = threading.Thread(target=Protocol.receive_worker, args=(self,)) + self.worker_thread.start() + + def receive_worker(self): + while self.port.in_waiting: + self.port.reset_input_buffer() + + def dispatch(data): + for tokens, callback in self.applications: + for token in tokens: + if token == data[:len(token)]: + callback((token, data[len(token):])) + return + + def reconnect(): + print("Reconnecting..") + self.port.close() + for x in range(10): + try: + if self.connected: + self.port = serial.Serial(self.device, baudrate = self.baud, write_timeout = 0, timeout = 1) + return + else: + print("Connection closed") + return + except: + time.sleep(1) + raise ConnectionLost() + + while self.connected: + try: + data = self.port.readline().decode('utf8').rstrip() + if len(data): + #print(data) + dispatch(data) + except OSError: + reconnect() + except UnicodeDecodeError: + # dodgy client output or datastream corruption + self.port.reset_input_buffer() + + def shutdown(self): + self.connected = False + self.worker_thread.join() + self.port.close() + + def process_input(self, data): + #print(data) + self.responses.append(data) + + def register(self, tokens, callback): + self.applications.append((tokens, callback)) + + def send(self, protocol, packet_type, data = bytearray()): + self.packet_transit = self.build_packet(protocol, packet_type, data) + self.packet_status = 0 + self.transmit_attempt = 0 + + timeout = TimeOut(self.response_timeout * 20) + while self.packet_status == 0: + try: + if timeout.timedout(): + raise ConnectionLost() + self.transmit_packet(self.packet_transit) + self.await_response() + except ReadTimeout: + self.errors += 1 + #print("Packetloss detected..") + self.packet_transit = None + + def await_response(self): + timeout = TimeOut(self.response_timeout) + while not len(self.responses): + time.sleep(0.00001) + if timeout.timedout(): + raise ReadTimeout() + + while len(self.responses): + token, data = self.responses.popleft() + switch = {'ok' : self.response_ok, 'rs': self.response_resend, 'ss' : self.response_stream_sync, 'fe' : self.response_fatal_error} + switch[token](data) + + def send_ascii(self, data, send_and_forget = False): + self.packet_transit = bytearray(data, "utf8") + b'\n' + self.packet_status = 0 + self.transmit_attempt = 0 + + timeout = TimeOut(self.response_timeout * 20) + while self.packet_status == 0: + try: + if timeout.timedout(): + return + self.port.write(self.packet_transit) + if send_and_forget: + self.packet_status = 1 + else: + self.await_response_ascii() + except ReadTimeout: + self.errors += 1 + #print("Packetloss detected..") + except serial.serialutil.SerialException: + return + self.packet_transit = None + + def await_response_ascii(self): + timeout = TimeOut(self.response_timeout) + while not len(self.responses): + time.sleep(0.00001) + if timeout.timedout(): + raise ReadTimeout() + token, data = self.responses.popleft() + self.packet_status = 1 + + def corrupt_array(self, data): + rid = random.randint(0, len(data) - 1) + data[rid] ^= 0xAA + return data + + def transmit_packet(self, packet): + packet = bytearray(packet) + if(self.simulate_errors > 0 and random.random() > (1.0 - self.simulate_errors)): + if random.random() > 0.9: + #random data drop + start = random.randint(0, len(packet)) + end = start + random.randint(1, 10) + packet = packet[:start] + packet[end:] + #print("Dropping {0} bytes".format(end - start)) + else: + #random corruption + packet = self.corrupt_array(packet) + #print("Single byte corruption") + self.port.write(packet) + self.transmit_attempt += 1 + + def build_packet(self, protocol, packet_type, data = bytearray()): + PACKET_TOKEN = 0xB5AD + + if len(data) > self.max_block_size: + raise PayloadOverflow() + + packet_buffer = bytearray() + + packet_buffer += self.pack_int8(self.sync) # 8bit sync id + packet_buffer += self.pack_int4_2(protocol, packet_type) # 4 bit protocol id, 4 bit packet type + packet_buffer += self.pack_int16(len(data)) # 16bit packet length + packet_buffer += self.pack_int16(self.build_checksum(packet_buffer)) # 16bit header checksum + + if len(data): + packet_buffer += data + packet_buffer += self.pack_int16(self.build_checksum(packet_buffer)) + + packet_buffer = self.pack_int16(PACKET_TOKEN) + packet_buffer # 16bit start token, not included in checksum + return packet_buffer + + # checksum 16 fletchers + def checksum(self, cs, value): + cs_low = (((cs & 0xFF) + value) % 255); + return ((((cs >> 8) + cs_low) % 255) << 8) | cs_low; + + def build_checksum(self, buffer): + cs = 0 + for b in buffer: + cs = self.checksum(cs, b) + return cs + + def pack_int32(self, value): + return value.to_bytes(4, byteorder='little') + + def pack_int16(self, value): + return value.to_bytes(2, byteorder='little') + + def pack_int8(self, value): + return value.to_bytes(1, byteorder='little') + + def pack_int4_2(self, vh, vl): + value = ((vh & 0xF) << 4) | (vl & 0xF) + return value.to_bytes(1, byteorder='little') + + def connect(self): + print("Connecting: Switching Marlin to Binary Protocol...") + self.send_ascii("M28B1") + self.send(0, 1) + + def disconnect(self): + self.send(0, 2) + self.syncronised = False + + def response_ok(self, data): + try: + packet_id = int(data); + except ValueError: + return + if packet_id != self.sync: + raise SycronisationError() + self.sync = (self.sync + 1) % 256 + self.packet_status = 1 + + def response_resend(self, data): + packet_id = int(data); + self.errors += 1 + if not self.syncronised: + print("Retrying syncronisation") + elif packet_id != self.sync: + raise SycronisationError() + + def response_stream_sync(self, data): + sync, max_block_size, protocol_version = data.split(',') + self.sync = int(sync) + self.max_block_size = int(max_block_size) + self.block_size = self.max_block_size if self.max_block_size < self.block_size else self.block_size + self.protocol_version = protocol_version + self.packet_status = 1 + self.syncronised = True + print("Connection synced [{0}], binary protocol version {1}, {2} byte payload buffer".format(self.sync, self.protocol_version, self.max_block_size)) + + def response_fatal_error(self, data): + raise FatalError() + + +class FileTransferProtocol(object): + protocol_id = 1 + + class Packet(object): + QUERY = 0 + OPEN = 1 + CLOSE = 2 + WRITE = 3 + ABORT = 4 + + responses = deque() + def __init__(self, protocol, timeout = None): + protocol.register(['PFT:success', 'PFT:version:', 'PFT:fail', 'PFT:busy', 'PFT:ioerror', 'PTF:invalid'], self.process_input) + self.protocol = protocol + self.response_timeout = timeout or protocol.response_timeout + + def process_input(self, data): + #print(data) + self.responses.append(data) + + def await_response(self, timeout = None): + timeout = TimeOut(timeout or self.response_timeout) + while not len(self.responses): + time.sleep(0.0001) + if timeout.timedout(): + raise ReadTimeout() + + return self.responses.popleft() + + def connect(self): + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.QUERY); + + token, data = self.await_response() + if token != 'PFT:version:': + return False + + self.version, _, compression = data.split(':') + if compression != 'none': + algorithm, window, lookahead = compression.split(',') + self.compression = {'algorithm': algorithm, 'window': int(window), 'lookahead': int(lookahead)} + else: + self.compression = {'algorithm': 'none'} + + print("File Transfer version: {0}, compression: {1}".format(self.version, self.compression['algorithm'])) + + def open(self, filename, compression, dummy): + payload = b'\1' if dummy else b'\0' # dummy transfer + payload += b'\1' if compression else b'\0' # payload compression + payload += bytearray(filename, 'utf8') + b'\0'# target filename + null terminator + + timeout = TimeOut(5000) + token = None + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.OPEN, payload); + while token != 'PFT:success' and not timeout.timedout(): + try: + token, data = self.await_response(1000) + if token == 'PFT:success': + print(filename,"opened") + return + elif token == 'PFT:busy': + print("Broken transfer detected, purging") + self.abort() + time.sleep(0.1) + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.OPEN, payload); + timeout.reset() + elif token == 'PFT:fail': + raise Exception("Can not open file on client") + except ReadTimeout: + pass + raise ReadTimeout() + + def write(self, data): + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.WRITE, data); + + def close(self): + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.CLOSE); + token, data = self.await_response(1000) + if token == 'PFT:success': + print("File closed") + return + elif token == 'PFT:ioerror': + print("Client storage device IO error") + elif token == 'PFT:invalid': + print("No open file") + + def abort(self): + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.ABORT); + token, data = self.await_response() + if token == 'PFT:success': + print("Transfer Aborted") + + def copy(self, filename, dest_filename, compression, dummy): + self.connect() + + compression_support = heatshrink_exists and self.compression['algorithm'] == 'heatshrink' and compression + if compression and (not heatshrink_exists or not self.compression['algorithm'] == 'heatshrink'): + print("Compression not supported by client") + #compression_support = False + + data = open(filename, "rb").read() + filesize = len(data) + + self.open(dest_filename, compression_support, dummy) + + block_size = self.protocol.block_size + if compression_support: + data = heatshrink.encode(data, window_sz2=self.compression['window'], lookahead_sz2=self.compression['lookahead']) + + cratio = filesize / len(data) + + blocks = math.floor((len(data) + block_size - 1) / block_size) + kibs = 0 + dump_pctg = 0 + start_time = millis() + for i in range(blocks): + start = block_size * i + end = start + block_size + 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='') + 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() + print("Transfer complete") + + +class EchoProtocol(object): + def __init__(self, protocol): + protocol.register(['echo:'], self.process_input) + self.protocol = protocol + + def process_input(self, data): + print(data) diff --git a/buildroot/share/scripts/g29_auto.py b/buildroot/share/scripts/g29_auto.py index ca36346dd9dd..5cf27b996865 100755 --- a/buildroot/share/scripts/g29_auto.py +++ b/buildroot/share/scripts/g29_auto.py @@ -1,13 +1,13 @@ #!/usr/bin/env python -# This file is for preprocessing gcode and the new G29 Autobedleveling from Marlin -# It will analyse the first 2 Layer and return the maximum size for this part -# After this it will replace with g29_keyword = ';MarlinG29Script' with the new G29 LRFB -# the new file will be created in the same folder. +# This file is for preprocessing G-code and the new G29 Auto bed leveling from Marlin +# It will analyze the first 2 layers and return the maximum size for this part +# Then it will be replaced with g29_keyword = ';MarlinG29Script' with the new G29 LRFB. +# The new file will be created in the same folder. from __future__ import print_function -# your gcode-file/folder +# Your G-code file/folder folder = './' my_file = 'test.gcode' diff --git a/buildroot/share/scripts/upload.py b/buildroot/share/scripts/upload.py new file mode 100644 index 000000000000..c7730d8f299d --- /dev/null +++ b/buildroot/share/scripts/upload.py @@ -0,0 +1,288 @@ +import argparse +import sys +import os +import time +import random +import serial + +Import("env") + +# Needed (only) for compression, but there are problems with pip install heatshrink +#try: +# import heatshrink +#except ImportError: +# # Install heatshrink +# print("Installing 'heatshrink' python module...") +# env.Execute(env.subst("$PYTHONEXE -m pip install heatshrink")) +# +# Not tested: If it's safe to install python libraries in PIO python try: +# env.Execute(env.subst("$PYTHONEXE -m pip install https://github.com/p3p/pyheatshrink/releases/download/0.3.3/pyheatshrink-pip.zip")) + +import MarlinBinaryProtocol + +# Internal debug flag +Debug = False + +#-----------------# +# Upload Callback # +#-----------------# +def Upload(source, target, env): + + #------------------# + # Marlin functions # + #------------------# + def _GetMarlinEnv(marlinEnv, feature): + if not marlinEnv: return None + return marlinEnv[feature] if feature in marlinEnv else None + + #----------------# + # Port functions # + #----------------# + def _GetUploadPort(env): + if Debug: print('Autodetecting upload port...') + env.AutodetectUploadPort(env) + port = env.subst('$UPLOAD_PORT') + if not port: + raise Exception('Error detecting the upload port.') + if Debug: print('OK') + return port + + #-------------------------# + # Simple serial functions # + #-------------------------# + def _Send(data): + if Debug: print(f'>> {data}') + strdata = bytearray(data, 'utf8') + b'\n' + port.write(strdata) + time.sleep(0.010) + + def _Recv(): + clean_responses = [] + responses = port.readlines() + for Resp in responses: + # Test: suppress invaid chars (coming from debug info) + try: + clean_response = Resp.decode('utf8').rstrip().lstrip() + clean_responses.append(clean_response) + except: + pass + if Debug: print(f'<< {clean_response}') + return clean_responses + + #------------------# + # SDCard functions # + #------------------# + def _CheckSDCard(): + if Debug: print('Checking SD card...') + _Send('M21') + Responses = _Recv() + if len(Responses) < 1 or not any('SD card ok' in r for r in Responses): + raise Exception('Error accessing SD card') + if Debug: print('SD Card OK') + return True + + #----------------# + # File functions # + #----------------# + def _GetFirmwareFiles(UseLongFilenames): + if Debug: print('Get firmware files...') + _Send(f"M20 F{'L' if UseLongFilenames else ''}") + Responses = _Recv() + if len(Responses) < 3 or not any('file list' in r for r in Responses): + raise Exception('Error getting firmware files') + if Debug: print('OK') + return Responses + + def _FilterFirmwareFiles(FirmwareList, UseLongFilenames): + Firmwares = [] + for FWFile in FirmwareList: + # For long filenames take the 3rd column of the firmwares list + if UseLongFilenames: + Space = 0 + Space = FWFile.find(' ') + if Space >= 0: Space = FWFile.find(' ', Space + 1) + if Space >= 0: FWFile = FWFile[Space + 1:] + if not '/' in FWFile and '.BIN' in FWFile.upper(): + Firmwares.append(FWFile[:FWFile.upper().index('.BIN') + 4]) + return Firmwares + + def _RemoveFirmwareFile(FirmwareFile): + _Send(f'M30 /{FirmwareFile}') + Responses = _Recv() + Removed = len(Responses) >= 1 and any('File deleted' in r for r in Responses) + if not Removed: + raise Exception(f"Firmware file '{FirmwareFile}' not removed") + return Removed + + + #---------------------# + # Callback Entrypoint # + #---------------------# + port = None + protocol = None + filetransfer = None + + # Get Marlin evironment vars + MarlinEnv = env['MARLIN_FEATURES'] + marlin_pioenv = _GetMarlinEnv(MarlinEnv, 'PIOENV') + marlin_motherboard = _GetMarlinEnv(MarlinEnv, 'MOTHERBOARD') + marlin_board_info_name = _GetMarlinEnv(MarlinEnv, 'BOARD_INFO_NAME') + marlin_board_custom_build_flags = _GetMarlinEnv(MarlinEnv, 'BOARD_CUSTOM_BUILD_FLAGS') + marlin_firmware_bin = _GetMarlinEnv(MarlinEnv, 'FIRMWARE_BIN') + marlin_long_filename_host_support = _GetMarlinEnv(MarlinEnv, 'LONG_FILENAME_HOST_SUPPORT') is not None + marlin_longname_write = _GetMarlinEnv(MarlinEnv, 'LONG_FILENAME_WRITE_SUPPORT') is not None + marlin_custom_firmware_upload = _GetMarlinEnv(MarlinEnv, 'CUSTOM_FIRMWARE_UPLOAD') is not None + marlin_short_build_version = _GetMarlinEnv(MarlinEnv, 'SHORT_BUILD_VERSION') + marlin_string_config_h_author = _GetMarlinEnv(MarlinEnv, 'STRING_CONFIG_H_AUTHOR') + + # Get firmware upload params + upload_firmware_source_name = str(source[0]) # Source firmware filename + upload_speed = env['UPLOAD_SPEED'] if 'UPLOAD_SPEED' in env else 115200 + # baud rate of serial connection + upload_port = _GetUploadPort(env) # Serial port to use + + # Set local upload params + upload_firmware_target_name = os.path.basename(upload_firmware_source_name) + # Target firmware filename + upload_timeout = 1000 # Communication timout, lossy/slow connections need higher values + upload_blocksize = 512 # Transfer block size. 512 = Autodetect + upload_compression = True # Enable compression + upload_error_ratio = 0 # Simulated corruption ratio + upload_test = False # Benchmark the serial link without storing the file + upload_reset = True # Trigger a soft reset for firmware update after the upload + + # Set local upload params based on board type to change script behavior + # "upload_delete_old_bins": delete all *.bin files in the root of SD Card + upload_delete_old_bins = marlin_motherboard in ['BOARD_CREALITY_V4', 'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423', + 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', + 'BOARD_CREALITY_V24S1'] + # "upload_random_name": generate a random 8.3 firmware filename to upload + upload_random_filename = marlin_motherboard in ['BOARD_CREALITY_V4', 'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423', + 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', + 'BOARD_CREALITY_V24S1'] and not marlin_long_filename_host_support + + try: + + # Start upload job + print(f"Uploading firmware '{os.path.basename(upload_firmware_target_name)}' to '{marlin_motherboard}' via '{upload_port}'") + + # Dump some debug info + if Debug: + print('Upload using:') + print('---- Marlin -----------------------------------') + print(f' PIOENV : {marlin_pioenv}') + print(f' SHORT_BUILD_VERSION : {marlin_short_build_version}') + print(f' STRING_CONFIG_H_AUTHOR : {marlin_string_config_h_author}') + print(f' MOTHERBOARD : {marlin_motherboard}') + print(f' BOARD_INFO_NAME : {marlin_board_info_name}') + print(f' CUSTOM_BUILD_FLAGS : {marlin_board_custom_build_flags}') + print(f' FIRMWARE_BIN : {marlin_firmware_bin}') + print(f' LONG_FILENAME_HOST_SUPPORT : {marlin_long_filename_host_support}') + print(f' LONG_FILENAME_WRITE_SUPPORT : {marlin_longname_write}') + print(f' CUSTOM_FIRMWARE_UPLOAD : {marlin_custom_firmware_upload}') + print('---- Upload parameters ------------------------') + print(f' Source : {upload_firmware_source_name}') + print(f' Target : {upload_firmware_target_name}') + print(f' Port : {upload_port} @ {upload_speed} baudrate') + print(f' Timeout : {upload_timeout}') + print(f' Block size : {upload_blocksize}') + print(f' Compression : {upload_compression}') + print(f' Error ratio : {upload_error_ratio}') + print(f' Test : {upload_test}') + print(f' Reset : {upload_reset}') + print('-----------------------------------------------') + + # Custom implementations based on board parameters + # Generate a new 8.3 random filename + if upload_random_filename: + upload_firmware_target_name = f"fw-{''.join(random.choices('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', k=5))}.BIN" + print(f"Board {marlin_motherboard}: Overriding firmware filename to '{upload_firmware_target_name}'") + + # Delete all *.bin files on the root of SD Card (if flagged) + if upload_delete_old_bins: + # CUSTOM_FIRMWARE_UPLOAD is needed for this feature + if not marlin_custom_firmware_upload: + raise Exception(f"CUSTOM_FIRMWARE_UPLOAD must be enabled in 'Configuration_adv.h' for '{marlin_motherboard}'") + + # Init serial port + port = serial.Serial(upload_port, baudrate = upload_speed, write_timeout = 0, timeout = 0.1) + port.reset_input_buffer() + + # Check SD card status + _CheckSDCard() + + # Get firmware files + FirmwareFiles = _GetFirmwareFiles(marlin_long_filename_host_support) + if Debug: + for FirmwareFile in FirmwareFiles: + print(f'Found: {FirmwareFile}') + + # Get all 1st level firmware files (to remove) + OldFirmwareFiles = _FilterFirmwareFiles(FirmwareFiles[1:len(FirmwareFiles)-2], marlin_long_filename_host_support) # Skip header and footers of list + if len(OldFirmwareFiles) == 0: + print('No old firmware files to delete') + else: + print(f"Remove {len(OldFirmwareFiles)} old firmware file{'s' if len(OldFirmwareFiles) != 1 else ''}:") + for OldFirmwareFile in OldFirmwareFiles: + print(f" -Removing- '{OldFirmwareFile}'...") + print(' OK' if _RemoveFirmwareFile(OldFirmwareFile) else ' Error!') + + # Close serial + port.close() + + # Cleanup completed + if Debug: print('Cleanup completed') + + # WARNING! The serial port must be closed here because the serial transfer that follow needs it! + + # Upload firmware file + if Debug: print(f"Copy '{upload_firmware_source_name}' --> '{upload_firmware_target_name}'") + protocol = MarlinBinaryProtocol.Protocol(upload_port, upload_speed, upload_blocksize, float(upload_error_ratio), int(upload_timeout)) + #echologger = MarlinBinaryProtocol.EchoProtocol(protocol) + protocol.connect() + filetransfer = MarlinBinaryProtocol.FileTransferProtocol(protocol) + filetransfer.copy(upload_firmware_source_name, upload_firmware_target_name, upload_compression, upload_test) + protocol.disconnect() + + # Notify upload completed + protocol.send_ascii('M117 Firmware uploaded') + + # Remount SD card + print('Wait for SD card release...') + time.sleep(1) + print('Remount SD card') + protocol.send_ascii('M21') + + # Trigger firmware update + if upload_reset: + print('Trigger firmware update...') + protocol.send_ascii('M997', True) + + protocol.shutdown() + print('Firmware update completed') + + except KeyboardInterrupt: + if port: port.close() + if filetransfer: filetransfer.abort() + if protocol: protocol.shutdown() + raise + + except serial.SerialException as se: + if port: port.close() + print(f'Serial excepion: {se}') + raise Exception(se) + + except MarlinBinaryProtocol.FatalError: + if port: port.close() + if protocol: protocol.shutdown() + print('Too many retries, Abort') + raise + + except: + if port: port.close() + if protocol: protocol.shutdown() + print('Firmware not updated') + raise + +# Attach custom upload callback +env.Replace(UPLOADCMD=Upload) diff --git a/buildroot/share/vscode/MarlinFirmware.code-workspace b/buildroot/share/vscode/MarlinFirmware.code-workspace new file mode 100644 index 000000000000..bd433b07f0e2 --- /dev/null +++ b/buildroot/share/vscode/MarlinFirmware.code-workspace @@ -0,0 +1,4 @@ +{ + "folders": [ { "path": "../../.." } ], + "extensions": { "recommendations": [ "marlinfirmware.auto-build" ] } +} diff --git a/buildroot/share/vscode/auto_build.py b/buildroot/share/vscode/auto_build.py index ac8432729f0a..5bd769478e0e 100644 --- a/buildroot/share/vscode/auto_build.py +++ b/buildroot/share/vscode/auto_build.py @@ -72,7 +72,7 @@ from __future__ import print_function from __future__ import division -import sys,os +import sys,os,re pwd = os.getcwd() # make sure we're executing from the correct directory level pwd = pwd.replace('\\', '/') @@ -123,7 +123,7 @@ # ########################################################################################## -def get_answer(board_name, cpu_label_txt, cpu_a_txt, cpu_b_txt): +def get_answer(board_name, question_txt, options, default_value=1): if python_ver == 2: import Tkinter as tk @@ -151,10 +151,10 @@ def disable_event(): root_get_answer.protocol("WM_DELETE_WINDOW", disable_event) root_get_answer.resizable(False, False) - root_get_answer.radio_state = 1 # declare variables used by TK and enable + root_get_answer.radio_state = default_value # declare variables used by TK and enable global get_answer_val - get_answer_val = 2 # return get_answer_val, set default to match radio_state default + get_answer_val = default_value # return get_answer_val, set default to match radio_state default radio_state = tk.IntVar() radio_state.set(get_answer_val) @@ -162,35 +162,27 @@ def disable_event(): l1 = tk.Label(text=board_name, fg="light green", bg="dark green", font="default 14 bold").grid(row=0, columnspan=2, sticky='EW', ipadx=2, ipady=2) - l2 = tk.Label(text=cpu_label_txt).grid(row=1, pady=4, columnspan=2, sticky='EW') - - b4 = tk.Radiobutton( - text=cpu_a_txt, - fg="black", - bg="lightgray", - relief=tk.SUNKEN, - selectcolor="green", - variable=radio_state, - value=1, - indicatoron=0, - command=CPU_exit_3 - ).grid(row=2, pady=1, ipady=2, ipadx=10, columnspan=2) - - b5 = tk.Radiobutton( - text=cpu_b_txt, - fg="black", - bg="lightgray", - relief=tk.SUNKEN, - selectcolor="green", - variable=radio_state, - value=2, - indicatoron=0, - command=CPU_exit_3 - ).grid(row=3, pady=1, ipady=2, ipadx=10, columnspan=2) # use same variable but inverted so they will track - - b6 = tk.Button(text="Cancel", fg="red", command=kill_session).grid(row=4, column=0, padx=4, pady=4, ipadx=2, ipady=2) - - b7 = tk.Button(text="Continue", fg="green", command=got_answer).grid(row=4, column=1, padx=4, pady=4, ipadx=2, ipady=2) + l2 = tk.Label(text=question_txt).grid(row=1, pady=4, columnspan=2, sticky='EW') + + buttons = [] + + for index, val in enumerate(options): + buttons.append( + tk.Radiobutton( + text=val, + fg="black", + bg="lightgray", + relief=tk.SUNKEN, + selectcolor="green", + variable=radio_state, + value=index + 1, + indicatoron=0, + command=CPU_exit_3 + ).grid(row=index + 2, pady=1, ipady=2, ipadx=10, columnspan=2)) + + b6 = tk.Button(text="Cancel", fg="red", command=kill_session).grid(row=(2 + len(options)), column=0, padx=4, pady=4, ipadx=2, ipady=2) + + b7 = tk.Button(text="Continue", fg="green", command=got_answer).grid(row=(2 + len(options)), column=1, padx=4, pady=4, ipadx=2, ipady=2) def got_answer_(): root_get_answer.destroy() @@ -485,6 +477,11 @@ def get_env_from_line(line, start_position): return env, next_position +def invalid_board(): + print('ERROR - invalid board') + print(board_name) + raise SystemExit(0) # quit if unable to find board + # scan pins.h for board name and return the environment(s) found def get_starting_env(board_name_full, version): # get environment starting point @@ -496,48 +493,26 @@ def get_starting_env(board_name_full, version): with open(path, 'r') as myfile: pins_h = myfile.read() - env_A = '' - env_B = '' - env_C = '' - board_name = board_name_full[6:] # only use the part after "BOARD_" since we're searching the pins.h file pins_h = pins_h.split('\n') - environment = '' - board_line = '' - cpu_A = '' - cpu_B = '' - i = 0 list_start_found = False - for lines in pins_h: - i = i + 1 # i is always one ahead of the index into pins_h - if 0 < lines.find("Unknown MOTHERBOARD value set in Configuration.h"): - break # no more - if 0 < lines.find('1280'): + possible_envs = None + for i, line in enumerate(pins_h): + if 0 < line.find("Unknown MOTHERBOARD value set in Configuration.h"): + invalid_board(); + if list_start_found == False and 0 < line.find('1280'): list_start_found = True - if list_start_found == False: # skip lines until find start of CPU list + elif list_start_found == False: # skip lines until find start of CPU list continue - board = lines.find(board_name) - comment_start = lines.find('// ') - cpu_A_loc = comment_start - cpu_B_loc = 0 - if board > 0: # need to look at the next line for environment info - cpu_line = pins_h[i] - comment_start = cpu_line.find('// ') - env_A, next_position = get_env_from_line(cpu_line, comment_start) # get name of environment & start of search for next - env_B, next_position = get_env_from_line(cpu_line, next_position) # get next environment, if it exists - env_C, next_position = get_env_from_line(cpu_line, next_position) # get next environment, if it exists - break - return env_A, env_B, env_C - -# Scan input string for CPUs that users may need to select from -# return: CPU name -def get_CPU_name(environment): - CPU_list = ('1280', '2560', '644', '1284', 'LPC1768', 'DUE') - CPU_name = '' - for CPU in CPU_list: - if 0 < environment.find(CPU): - return CPU + # Use a regex to find the board. Make sure it is surrounded by separators so the full boardname + # will be matched, even if multiple exist in a single MB macro. This avoids problems with boards + # such as MALYAN_M200 and MALYAN_M200_V2 where one board is a substring of the other. + if re.search(r'MB.*[\(, ]' + board_name + r'[, \)]', line): + # need to look at the next line for environment info + possible_envs = re.findall(r'env:([^ ]+)', pins_h[i + 1]) + break + return possible_envs # get environment to be used for the build @@ -549,71 +524,81 @@ def no_environment(): print(board_name) raise SystemExit(0) # no environment so quit - def invalid_board(): - print('ERROR - invalid board') - print(board_name) - raise SystemExit(0) # quit if unable to find board + possible_envs = get_starting_env(board_name, ver_Marlin) - CPU_question = (('1280', '2560', '1280 or 2560 CPU?'), ('644', '1284', '644 or 1284 CPU?')) + if not possible_envs: + no_environment() - if 0 < board_name.find('MELZI'): - get_answer( - board_name, " Which flavor of Melzi? ", "Melzi (Optiboot bootloader)", "Melzi " - ) + # Proceed to ask questions based on the available environments to filter down to a smaller list. + # If more then one remains after this filtering the user will be prompted to choose between + # all remaining options. + + # Filter selection based on CPU choice + CPU_questions = [ + {'options':['1280', '2560'], 'text':'1280 or 2560 CPU?', 'default':2}, + {'options':['644', '1284'], 'text':'644 or 1284 CPU?', 'default':2}, + {'options':['STM32F103RC', 'STM32F103RE'], 'text':'MCU Type?', 'default':1}] + + for question in CPU_questions: + if any(question['options'][0] in env for env in possible_envs) and any(question['options'][1] in env for env in possible_envs): + get_answer(board_name, question['text'], [question['options'][0], question['options'][1]], question['default']) + possible_envs = [env for env in possible_envs if question['options'][get_answer_val - 1] in env] + + # Choose which STM32 framework to use, if both are available + if [env for env in possible_envs if '_maple' in env] and [env for env in possible_envs if '_maple' not in env]: + get_answer(board_name, 'Which STM32 Framework should be used?', ['ST STM32 (Preferred)', 'Maple (Deprecated)']) if 1 == get_answer_val: - target_env = 'melzi_optiboot' + possible_envs = [env for env in possible_envs if '_maple' not in env] else: - target_env = 'melzi' - else: - env_A, env_B, env_C = get_starting_env(board_name, ver_Marlin) + possible_envs = [env for env in possible_envs if '_maple' in env] - if env_A == '': - no_environment() - if env_B == '': - return env_A # only one environment so finished + # Both USB and non-USB STM32 options exist, filter based on these + if any('STM32F103R' in env for env in possible_envs) and any('_USB' in env for env in possible_envs) and any('_USB' not in env for env in possible_envs): + get_answer(board_name, 'USB Support?', ['USB', 'No USB']) + if 1 == get_answer_val: + possible_envs = [env for env in possible_envs if '_USB' in env] + else: + possible_envs = [env for env in possible_envs if '_USB' not in env] - CPU_A = get_CPU_name(env_A) - CPU_B = get_CPU_name(env_B) + if not possible_envs: + no_environment() + if len(possible_envs) == 1: + return possible_envs[0] # only one environment so finished - for item in CPU_question: - if CPU_A == item[0]: - get_answer(board_name, item[2], item[0], item[1]) - if 2 == get_answer_val: - target_env = env_B - else: - target_env = env_A - return target_env + target_env = None - if env_A == 'LPC1768': - if build_type == 'traceback' or (build_type == 'clean' and get_build_last() == 'LPC1768_debug_and_upload'): - target_env = 'LPC1768_debug_and_upload' - else: - target_env = 'LPC1768' - elif env_A == 'DUE': - target_env = 'DUE' - if build_type == 'traceback' or (build_type == 'clean' and get_build_last() == 'DUE_debug'): - target_env = 'DUE_debug' - elif env_B == 'DUE_USB': - get_answer(board_name, 'DUE Download Port?', '(Native) USB port', 'Programming port') - if 1 == get_answer_val: - target_env = 'DUE_USB' - else: - target_env = 'DUE' - elif env_A == 'STM32F103RC_btt' or env_A == 'STM32F103RE_btt': - if env_A == 'STM32F103RE_btt': - get_answer(board_name, 'MCU Type?', 'STM32F103RC', 'STM32F103RE') - if 1 == get_answer_val: - env_A = 'STM32F103RC_btt' - target_env = env_A - if env_A == 'STM32F103RC_btt': - get_answer(board_name, 'RCT6 Flash Size?', '512K', '256K') - if 1 == get_answer_val: - target_env += '_512K' - get_answer(board_name, 'USB Support?', 'USB', 'No USB') - if 1 == get_answer_val: - target_env += '_USB' + # A few environments require special behavior + if 'LPC1768' in possible_envs: + if build_type == 'traceback' or (build_type == 'clean' and get_build_last() == 'LPC1768_debug_and_upload'): + target_env = 'LPC1768_debug_and_upload' else: - invalid_board() + target_env = 'LPC1768' + elif 'DUE' in possible_envs: + target_env = 'DUE' + if build_type == 'traceback' or (build_type == 'clean' and get_build_last() == 'DUE_debug'): + target_env = 'DUE_debug' + elif 'DUE_USB' in possible_envs: + get_answer(board_name, 'DUE Download Port?', ['(Native) USB port', 'Programming port']) + if 1 == get_answer_val: + target_env = 'DUE_USB' + else: + target_env = 'DUE' + else: + options = possible_envs + # Perform some substitutions for environment names which follow a consistent + # naming pattern and are very commonly used. This is fragile code, and replacements + # should only be made here for stable environments unlikely to change often. + for i, option in enumerate(options): + if 'melzi' in option: + options[i] = 'Melzi' + elif 'sanguino1284p' in option: + options[i] = 'sanguino1284p' + if 'optiboot' in option: + options[i] = options[i] + ' (Optiboot Bootloader)' + if 'optimized' in option: + options[i] = options[i] + ' (Optimized for Size)' + get_answer(board_name, 'Which environment?', options) + target_env = possible_envs[get_answer_val - 1] if build_type == 'traceback' and target_env != 'LPC1768_debug_and_upload' and target_env != 'DUE_debug' and Marlin_ver == 2: print("ERROR - this board isn't setup for traceback") diff --git a/buildroot/tests/BIGTREE_GTR_V1_0 b/buildroot/tests/BIGTREE_GTR_V1_0 index 0a80a6b78c70..d6eccaff07dc 100755 --- a/buildroot/tests/BIGTREE_GTR_V1_0 +++ b/buildroot/tests/BIGTREE_GTR_V1_0 @@ -22,18 +22,26 @@ exec_test $1 $2 "BigTreeTech GTR | 8 Extruders | Auto-Fan | Mixed TMC Drivers | restore_configs opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \ EXTRUDERS 5 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 TEMP_SENSOR_3 1 TEMP_SENSOR_4 1 \ - NUM_Z_STEPPER_DRIVERS 4 \ + Z_DRIVER_TYPE A4988 Z2_DRIVER_TYPE A4988 Z3_DRIVER_TYPE A4988 Z4_DRIVER_TYPE A4988 \ DEFAULT_Kp_LIST '{ 22.2, 20.0, 21.0, 19.0, 18.0 }' DEFAULT_Ki_LIST '{ 1.08 }' DEFAULT_Kd_LIST '{ 114.0, 112.0, 110.0, 108.0 }' -opt_enable TOOLCHANGE_FILAMENT_SWAP TOOLCHANGE_MIGRATION_FEATURE TOOLCHANGE_FS_INIT_BEFORE_SWAP TOOLCHANGE_FS_PRIME_FIRST_USED \ +opt_enable TOOLCHANGE_FILAMENT_SWAP TOOLCHANGE_MIGRATION_FEATURE TOOLCHANGE_FS_SLOW_FIRST_PRIME TOOLCHANGE_FS_PRIME_FIRST_USED \ PID_PARAMS_PER_HOTEND Z_MULTI_ENDSTOPS exec_test $1 $2 "BigTreeTech GTR | 6 Extruders | Quad Z + Endstops" "$3" restore_configs opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \ EXTRUDERS 3 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 \ - SERVO_DELAY '{ 300, 300, 300 }' -opt_enable SWITCHING_TOOLHEAD TOOL_SENSOR -exec_test $1 $2 "BigTreeTech GTR | Switching Toolhead | Tool Sensors" "$3" + SERVO_DELAY '{ 300, 300, 300 }' \ + SWITCHING_TOOLHEAD_X_POS '{ 215, 0 ,0 }' \ + MPC_HEATER_POWER '{ 40.0f, 40.0f, 40.0f }' \ + MPC_BLOCK_HEAT_CAPACITY '{ 16.7f, 16.7f, 16.7f }' \ + MPC_SENSOR_RESPONSIVENESS '{ 0.22f, 0.22f, 0.22f }' \ + MPC_AMBIENT_XFER_COEFF '{ 0.068f, 0.068f, 0.068f }' \ + MPC_AMBIENT_XFER_COEFF_FAN255 '{ 0.097f, 0.097f, 0.097f }' \ + FILAMENT_HEAT_CAPACITY_PERMM '{ 5.6e-3f, 3.6e-3f, 5.6e-3f }' +opt_enable SWITCHING_TOOLHEAD TOOL_SENSOR MPCTEMP MPC_EDIT_MENU MPC_AUTOTUNE_MENU +opt_disable PIDTEMP +exec_test $1 $2 "BigTreeTech GTR | MPC | Switching Toolhead | Tool Sensors" "$3" # clean up restore_configs diff --git a/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive b/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive index 34bf77be27a4..78aec1329558 100755 --- a/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive +++ b/buildroot/tests/BIGTREE_GTR_V1_0_usb_flash_drive @@ -10,7 +10,7 @@ restore_configs opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT 3 \ EXTRUDERS 8 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 TEMP_SENSOR_3 1 TEMP_SENSOR_4 1 TEMP_SENSOR_5 1 TEMP_SENSOR_6 1 TEMP_SENSOR_7 1 opt_enable SDSUPPORT USB_FLASH_DRIVE_SUPPORT USE_OTG_USB_HOST \ - REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER BLTOUCH LEVEL_BED_CORNERS LEVEL_CORNERS_USE_PROBE \ + REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER BLTOUCH LCD_BED_TRAMMING BED_TRAMMING_USE_PROBE \ NEOPIXEL_LED Z_SAFE_HOMING FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE # Not necessary to enable auto-fan for all extruders to hit problematic code paths opt_set E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 NEOPIXEL_PIN PF13 \ diff --git a/buildroot/tests/BIGTREE_SKR_PRO b/buildroot/tests/BIGTREE_SKR_PRO index 2503b28544ad..2f1075c7ef22 100755 --- a/buildroot/tests/BIGTREE_SKR_PRO +++ b/buildroot/tests/BIGTREE_SKR_PRO @@ -26,7 +26,7 @@ opt_set MOTHERBOARD BOARD_BTT_SKR_PRO_V1_1 SERIAL_PORT -1 \ CUTTER_POWER_UNIT PERCENT \ SPINDLE_LASER_PWM_PIN HEATER_1_PIN SPINDLE_LASER_ENA_PIN HEATER_2_PIN \ TEMP_SENSOR_COOLER 1000 TEMP_COOLER_PIN PD13 -opt_enable LASER_FEATURE REPRAP_DISCOUNT_SMART_CONTROLLER +opt_enable LASER_FEATURE LASER_SAFETY_TIMEOUT_MS REPRAP_DISCOUNT_SMART_CONTROLLER exec_test $1 $2 "BigTreeTech SKR Pro | Laser (Percent) | Cooling | LCD" "$3" # clean up diff --git a/buildroot/tests/DUE b/buildroot/tests/DUE index 37678501e431..a2f3fda7a7ac 100755 --- a/buildroot/tests/DUE +++ b/buildroot/tests/DUE @@ -17,7 +17,7 @@ opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS GCODE_MACROS \ FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING \ ASSISTED_TRAMMING REPORT_TRAMMING_MM ASSISTED_TRAMMING_WAIT_POSITION \ EEPROM_SETTINGS SDSUPPORT BINARY_FILE_TRANSFER \ - BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \ + BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN \ NEOPIXEL_LED NEOPIXEL_PIN CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_USE_RGB_LED CASE_LIGHT_MENU \ NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_DISTANCE_MM FILAMENT_RUNOUT_SENSOR \ AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ @@ -35,9 +35,9 @@ exec_test $1 $2 "RAMPS4DUE_EFB with ABL (Bilinear), ExtUI, S-Curve, many options # RADDS with BLTouch, ABL(B), 3 x Z auto-align # restore_configs -opt_set MOTHERBOARD BOARD_RADDS NUM_Z_STEPPER_DRIVERS 3 +opt_set MOTHERBOARD BOARD_RADDS Z_DRIVER_TYPE A4988 Z2_DRIVER_TYPE A4988 Z3_DRIVER_TYPE A4988 opt_enable USE_XMAX_PLUG USE_YMAX_PLUG ENDSTOPPULLUPS BLTOUCH AUTO_BED_LEVELING_BILINEAR \ - Z_STEPPER_AUTO_ALIGN Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS Z_SAFE_HOMING + Z_STEPPER_AUTO_ALIGN Z_STEPPER_ALIGN_STEPPER_XY Z_SAFE_HOMING pins_set ramps/RAMPS X_MAX_PIN -1 pins_set ramps/RAMPS Y_MAX_PIN -1 exec_test $1 $2 "RADDS with ABL (Bilinear), Triple Z Axis, Z_STEPPER_AUTO_ALIGN, E_DUAL_STEPPER_DRIVERS" "$3" diff --git a/buildroot/tests/FYSETC_F6 b/buildroot/tests/FYSETC_F6 index 9306686af5ce..17f8eb42b1e2 100755 --- a/buildroot/tests/FYSETC_F6 +++ b/buildroot/tests/FYSETC_F6 @@ -10,7 +10,7 @@ set -e # Build with the default configurations # restore_configs -opt_set MOTHERBOARD BOARD_FYSETC_F6_13 +opt_set MOTHERBOARD BOARD_FYSETC_F6_13 LCD_SERIAL_PORT 1 opt_enable DGUS_LCD_UI_FYSETC exec_test $1 $2 "FYSETC F6 1.3 with DGUS" "$3" diff --git a/buildroot/tests/FYSETC_S6 b/buildroot/tests/FYSETC_S6 index 4794e11354d4..6d67800d77ec 100755 --- a/buildroot/tests/FYSETC_S6 +++ b/buildroot/tests/FYSETC_S6 @@ -13,5 +13,13 @@ opt_enable MEATPACK_ON_SERIAL_PORT_1 opt_set Y_DRIVER_TYPE TMC2209 Z_DRIVER_TYPE TMC2130 exec_test $1 $2 "FYSETC S6 Example" "$3" +# +# Build with the default configurations with FYSETC TFT81050 +# +restore_configs +opt_set MOTHERBOARD BOARD_FYSETC_S6_V2_0 SERIAL_PORT 1 +opt_enable TOUCH_UI_FTDI_EVE LCD_FYSETC_TFT81050 S6_TFT_PINMAP +exec_test $1 $2 "FYSETC S6 2 with LCD FYSETC TFT81050" "$3" + # cleanup restore_configs diff --git a/buildroot/tests/LPC1768 b/buildroot/tests/LPC1768 index 92ba286693e8..9fb7479d9921 100755 --- a/buildroot/tests/LPC1768 +++ b/buildroot/tests/LPC1768 @@ -14,8 +14,8 @@ set -e #exec_test $1 $2 "Default Configuration" "$3" restore_configs -opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EFB SERIAL_PORT_3 3 \ - NEOPIXEL_TYPE NEO_GRB RGB_LED_R_PIN P2_12 RGB_LED_G_PIN P1_23 RGB_LED_B_PIN P1_22 RGB_LED_W_PIN P1_24 +opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EFB SERIAL_PORT_3 3 \ + NEOPIXEL_TYPE NEO_RGB RGB_LED_R_PIN P2_12 RGB_LED_G_PIN P1_23 RGB_LED_B_PIN P1_22 RGB_LED_W_PIN P1_24 opt_enable FYSETC_MINI_12864_2_1 SDSUPPORT SDCARD_READONLY SERIAL_PORT_2 RGBW_LED E_DUAL_STEPPER_DRIVERS \ NEOPIXEL_LED NEOPIXEL_IS_SEQUENTIAL NEOPIXEL_STARTUP_TEST NEOPIXEL_BKGD_INDEX_FIRST NEOPIXEL_BKGD_INDEX_LAST NEOPIXEL_BKGD_COLOR NEOPIXEL_BKGD_ALWAYS_ON exec_test $1 $2 "ReARM EFB VIKI2, SDSUPPORT, 2 Serial ports (USB CDC + UART0), NeoPixel" "$3" diff --git a/buildroot/tests/LPC1769 b/buildroot/tests/LPC1769 index 3fe99734ca6b..086dffffc92c 100755 --- a/buildroot/tests/LPC1769 +++ b/buildroot/tests/LPC1769 @@ -21,7 +21,7 @@ opt_set MOTHERBOARD BOARD_SMOOTHIEBOARD \ opt_enable TFTGLCD_PANEL_SPI SDSUPPORT ADAPTIVE_FAN_SLOWING NO_FAN_SLOWING_IN_PID_TUNING \ MAX31865_SENSOR_OHMS_0 MAX31865_CALIBRATION_OHMS_0 \ FIX_MOUNTED_PROBE AUTO_BED_LEVELING_BILINEAR G29_RETRY_AND_RECOVER Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ - BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET LEVEL_CORNERS_USE_PROBE LEVEL_CORNERS_VERIFY_RAISED \ + BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BED_TRAMMING_USE_PROBE BED_TRAMMING_VERIFY_RAISED \ PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT \ Z_SAFE_HOMING ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE \ LCD_INFO_MENU ARC_SUPPORT BEZIER_CURVE_SUPPORT EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES SDCARD_SORT_ALPHA EMERGENCY_PARSER diff --git a/buildroot/tests/SAMD51_grandcentral_m4 b/buildroot/tests/SAMD51_grandcentral_m4 index 92a62c9d37a4..e6e27d8cb8c9 100755 --- a/buildroot/tests/SAMD51_grandcentral_m4 +++ b/buildroot/tests/SAMD51_grandcentral_m4 @@ -16,7 +16,6 @@ opt_set MOTHERBOARD BOARD_AGCM4_RAMPS_144 SERIAL_PORT -1 \ RESTORE_LEVELING_AFTER_G28 false \ LCD_LANGUAGE it \ SDCARD_CONNECTION LCD \ - NUM_Z_STEPPER_DRIVERS 2 \ HOMING_BUMP_MM '{ 0, 0, 0 }' opt_enable ENDSTOP_INTERRUPTS_FEATURE S_CURVE_ACCELERATION BLTOUCH Z_MIN_PROBE_REPEATABILITY_TEST \ FILAMENT_RUNOUT_SENSOR G26_MESH_VALIDATION MESH_EDIT_GFX_OVERLAY Z_SAFE_HOMING \ diff --git a/buildroot/tests/STM32F103RC_btt b/buildroot/tests/STM32F103RC_btt index e76060aee82f..16419cbfa232 100755 --- a/buildroot/tests/STM32F103RC_btt +++ b/buildroot/tests/STM32F103RC_btt @@ -13,7 +13,6 @@ restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_MINI_E3_V1_0 SERIAL_PORT 1 SERIAL_PORT_2 -1 \ X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2209 Z_DRIVER_TYPE TMC2209 E0_DRIVER_TYPE TMC2209 opt_enable PINS_DEBUGGING Z_IDLE_HEIGHT - exec_test $1 $2 "BigTreeTech SKR Mini E3 1.0 - Basic Config with TMC2209 HW Serial" "$3" # clean up diff --git a/buildroot/tests/STM32F103RC_btt_maple b/buildroot/tests/STM32F103RC_btt_maple index e74e5902132c..90e33ab52925 100755 --- a/buildroot/tests/STM32F103RC_btt_maple +++ b/buildroot/tests/STM32F103RC_btt_maple @@ -13,7 +13,6 @@ restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_MINI_E3_V1_0 SERIAL_PORT 1 SERIAL_PORT_2 -1 \ X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2209 Z_DRIVER_TYPE TMC2209 E0_DRIVER_TYPE TMC2209 opt_enable PINS_DEBUGGING Z_IDLE_HEIGHT - exec_test $1 $2 "BigTreeTech SKR Mini E3 1.0 - Basic Config with TMC2209 HW Serial" "$3" # clean up diff --git a/buildroot/tests/STM32F103RC_meeb b/buildroot/tests/STM32F103RC_meeb_maple similarity index 100% rename from buildroot/tests/STM32F103RC_meeb rename to buildroot/tests/STM32F103RC_meeb_maple diff --git a/buildroot/tests/STM32F103RE_btt_USB b/buildroot/tests/STM32F103RE_btt_USB index c63a90e43681..7b264ea28312 100755 --- a/buildroot/tests/STM32F103RE_btt_USB +++ b/buildroot/tests/STM32F103RE_btt_USB @@ -15,7 +15,7 @@ exec_test $1 $2 "BigTreeTech SKR E3 DIP v1.0 - Basic Configuration" "$3" restore_configs opt_set MOTHERBOARD BOARD_BTT_SKR_CR6 SERIAL_PORT -1 SERIAL_PORT_2 2 TEMP_SENSOR_BED 1 -opt_enable CR10_STOCKDISPLAY \ +opt_enable CR10_STOCKDISPLAY FAN_SOFT_PWM \ NOZZLE_AS_PROBE Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN Z_SAFE_HOMING \ PROBE_ACTIVATION_SWITCH PROBE_TARE PROBE_TARE_ONLY_WHILE_INACTIVE \ PROBING_HEATERS_OFF PREHEAT_BEFORE_PROBING diff --git a/buildroot/tests/STM32F103RET6_creality b/buildroot/tests/STM32F103RE_creality similarity index 52% rename from buildroot/tests/STM32F103RET6_creality rename to buildroot/tests/STM32F103RE_creality index ca7573cf16c3..5e6d5f044ac3 100755 --- a/buildroot/tests/STM32F103RET6_creality +++ b/buildroot/tests/STM32F103RE_creality @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Build tests for STM32F103RET6_creality +# Build tests for STM32F103RE_creality # # exit on first failure @@ -13,24 +13,24 @@ use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" opt_enable MARLIN_DEV_MODE BUFFER_MONITORING BLTOUCH AUTO_BED_LEVELING_BILINEAR Z_SAFE_HOMING exec_test $1 $2 "Ender 3 v2 with CrealityUI" "$3" -use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" -opt_disable DWIN_CREALITY_LCD -opt_enable DWIN_CREALITY_LCD_ENHANCED BLTOUCH AUTO_BED_LEVELING_UBL Z_SAFE_HOMING -exec_test $1 $2 "Ender 3 v2 with Enhanced UI" "$3" - use_example_configs "Creality/Ender-3 V2/CrealityV422/CrealityUI" opt_disable DWIN_CREALITY_LCD opt_enable DWIN_CREALITY_LCD_JYERSUI AUTO_BED_LEVELING_BILINEAR PROBE_MANUALLY exec_test $1 $2 "Ender 3 v2 with JyersUI" "$3" -use_example_configs "Creality/Ender-3 V2/CrealityV422/MarlinUI" -opt_add SDCARD_EEPROM_EMULATION AUTO_BED_LEVELING_BILINEAR Z_SAFE_HOMING -exec_test $1 $2 "Ender 3 v2 with MarlinUI" "$3" +use_example_configs "Creality/Ender-3 S1" +opt_disable DWIN_CREALITY_LCD Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN AUTO_BED_LEVELING_BILINEAR CONFIGURATION_EMBEDDING CANCEL_OBJECTS FWRETRACT +opt_enable DWIN_LCD_PROUI INDIVIDUAL_AXIS_HOMING_SUBMENU LCD_SET_PROGRESS_MANUALLY STATUS_MESSAGE_SCROLLING \ + SOUND_MENU_ITEM PRINTCOUNTER NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_SENSOR \ + BLTOUCH Z_SAFE_HOMING AUTO_BED_LEVELING_UBL MESH_EDIT_MENU \ + LIMITED_MAX_FR_EDITING LIMITED_MAX_ACCEL_EDITING LIMITED_JERK_EDITING BAUD_RATE_GCODE +opt_set PREHEAT_3_LABEL '"CUSTOM"' PREHEAT_3_TEMP_HOTEND 240 PREHEAT_3_TEMP_BED 60 PREHEAT_3_FAN_SPEED 128 +exec_test $1 $2 "Ender-3 S1 with ProUI" "$3" restore_configs opt_set MOTHERBOARD BOARD_CREALITY_V452 SERIAL_PORT 1 opt_disable NOZZLE_TO_PROBE_OFFSET -opt_enable NOZZLE_AS_PROBE Z_SAFE_HOMING Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN \ +opt_enable NOZZLE_AS_PROBE Z_SAFE_HOMING Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN FAN_SOFT_PWM \ PROBE_ACTIVATION_SWITCH PROBE_TARE PROBE_TARE_ONLY_WHILE_INACTIVE exec_test $1 $2 "Creality V4.5.2 PROBE_ACTIVATION_SWITCH, Probe Tare" "$3" diff --git a/buildroot/tests/STM32F401RC_creality b/buildroot/tests/STM32F401RC_creality new file mode 100755 index 000000000000..380711d061c2 --- /dev/null +++ b/buildroot/tests/STM32F401RC_creality @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# +# Build tests for STM32F401RC_creality +# + +# exit on first failure +set -e + +use_example_configs "Creality/Ender-3 V2/CrealityV422/MarlinUI" +opt_add SDCARD_EEPROM_EMULATION AUTO_BED_LEVELING_BILINEAR Z_SAFE_HOMING +opt_set MOTHERBOARD BOARD_CREALITY_V24S1_301F4 +exec_test $1 $2 "Ender 3 v2 with MarlinUI" "$3" + +# clean up +restore_configs diff --git a/buildroot/tests/mega1280 b/buildroot/tests/mega1280 index a7f25953acd0..5bf37289ba61 100755 --- a/buildroot/tests/mega1280 +++ b/buildroot/tests/mega1280 @@ -39,7 +39,7 @@ exec_test $1 $2 "(No PWM)" "$3" restore_configs opt_set MOTHERBOARD BOARD_ZRIB_V52 \ LCD_LANGUAGE pt REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 \ - EXTRUDERS 2 TEMP_SENSOR_1 1 + EXTRUDERS 2 TEMP_SENSOR_1 1 X2_DRIVER_TYPE A4988 opt_enable USE_XMAX_PLUG DUAL_X_CARRIAGE REPRAPWORLD_KEYPAD exec_test $1 $2 "ZRIB_V52 | DUAL_X_CARRIAGE" "$3" diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index bf3290b9d02c..fc24cf212509 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -35,7 +35,7 @@ opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO LCD_LANGUAGE jp_kana DEFAULT_EJERK 10 \ EXTRUDERS 5 TEMP_SENSOR_1 1 TEMP_SENSOR_2 5 TEMP_SENSOR_3 20 TEMP_SENSOR_4 1000 TEMP_SENSOR_BED 1 opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI SHOW_CUSTOM_BOOTSCREEN BOOT_MARLIN_LOGO_SMALL \ LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME STATUS_MESSAGE_SCROLLING SCROLL_LONG_FILENAMES \ - SDSUPPORT SDCARD_SORT_ALPHA NO_SD_AUTOSTART USB_FLASH_DRIVE_SUPPORT CANCEL_OBJECTS \ + SDSUPPORT LONG_FILENAME_WRITE_SUPPORT SDCARD_SORT_ALPHA NO_SD_AUTOSTART USB_FLASH_DRIVE_SUPPORT CANCEL_OBJECTS \ Z_PROBE_SLED AUTO_BED_LEVELING_UBL UBL_HILBERT_CURVE RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT \ EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN \ MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE QUICK_HOME \ @@ -179,9 +179,8 @@ opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 0 LCD_LANGUAGE en TEMP_SENSOR_C DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' \ MANUAL_FEEDRATE '{ 50*60, 50*60, 4*60 }' \ AXIS_RELATIVE_MODES '{ false, false, false }' -opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT \ - LASER_FEATURE AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN LASER_COOLANT_FLOW_METER MEATPACK_ON_SERIAL_PORT_1 - +opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT MEATPACK_ON_SERIAL_PORT_1 \ + LASER_FEATURE LASER_SAFETY_TIMEOUT_MS LASER_COOLANT_FLOW_METER AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN exec_test $1 $2 "MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Flowmeter | 12864 LCD | meatpack | SERIAL_PORT_2 " "$3" # @@ -194,9 +193,8 @@ opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 0 LCD_LANGUAGE en TEMP_SENSOR_C DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' \ MANUAL_FEEDRATE '{ 50*60, 50*60, 4*60 }' \ AXIS_RELATIVE_MODES '{ false, false, false }' -opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT \ - LASER_FEATURE AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN LASER_COOLANT_FLOW_METER I2C_AMMETER - +opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT PRINTCOUNTER I2C_AMMETER \ + LASER_FEATURE LASER_SAFETY_TIMEOUT_MS LASER_COOLANT_FLOW_METER AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN exec_test $1 $2 "MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Flowmeter | 44780 LCD " "$3" # @@ -207,7 +205,8 @@ opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 1 \ TEMP_SENSOR_0 -2 TEMP_SENSOR_REDUNDANT -2 \ TEMP_SENSOR_REDUNDANT_SOURCE E1 TEMP_SENSOR_REDUNDANT_TARGET E0 \ TEMP_0_CS_PIN 11 TEMP_1_CS_PIN 12 - +opt_enable MPCTEMP +opt_disable PIDTEMP exec_test $1 $2 "MEGA2560 RAMPS | Redundant temperature sensor | 2x MAX6675" "$3" # diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index a54c04eeb21c..167f6d89aae2 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -14,7 +14,7 @@ opt_set MOTHERBOARD BOARD_RAMBO \ EXTRUDERS 2 TEMP_SENSOR_0 -2 TEMP_SENSOR_1 1 TEMP_SENSOR_BED 2 \ TEMP_SENSOR_PROBE 1 TEMP_PROBE_PIN 12 \ TEMP_SENSOR_CHAMBER 3 TEMP_CHAMBER_PIN 3 HEATER_CHAMBER_PIN 45 \ - GRID_MAX_POINTS_X 16 \ + GRID_MAX_POINTS_X 16 AUTO_POWER_E_TEMP 80 \ FANMUX0_PIN 53 opt_disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN USE_WATCHDOG opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_PROGRESS_BAR_TEST \ @@ -24,7 +24,7 @@ opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_P BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \ NEOPIXEL_LED NEOPIXEL_PIN CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_MENU \ PID_PARAMS_PER_HOTEND PID_AUTOTUNE_MENU PID_EDIT_MENU LCD_SHOW_E_TOTAL \ - PRINTCOUNTER SERVICE_NAME_1 SERVICE_INTERVAL_1 LEVEL_BED_CORNERS LEVEL_CENTER_TOO \ + PRINTCOUNTER SERVICE_NAME_1 SERVICE_INTERVAL_1 LCD_BED_TRAMMING BED_TRAMMING_INCLUDE_CENTER \ NOZZLE_PARK_FEATURE FILAMENT_RUNOUT_SENSOR FILAMENT_RUNOUT_DISTANCE_MM \ ADVANCED_PAUSE_FEATURE FILAMENT_LOAD_UNLOAD_GCODES FILAMENT_UNLOAD_ALL_EXTRUDERS \ PASSWORD_FEATURE PASSWORD_ON_STARTUP PASSWORD_ON_SD_PRINT_MENU PASSWORD_AFTER_SD_PRINT_END PASSWORD_AFTER_SD_PRINT_ABORT \ @@ -32,7 +32,7 @@ opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_P SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE \ BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE BEZIER_CURVE_SUPPORT \ FWRETRACT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \ - PSU_CONTROL PS_OFF_CONFIRM PS_OFF_SOUND AUTO_POWER_CONTROL \ + PSU_CONTROL PS_OFF_CONFIRM PS_OFF_SOUND POWER_OFF_WAIT_FOR_COOLDOWN \ POWER_LOSS_RECOVERY POWER_LOSS_PIN POWER_LOSS_STATE POWER_LOSS_RECOVER_ZHOME POWER_LOSS_ZHOME_POS \ SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER LIN_ADVANCE EXTRA_LIN_ADVANCE_K \ HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL @@ -51,12 +51,13 @@ opt_set MOTHERBOARD BOARD_RAMBO \ DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' \ MANUAL_FEEDRATE '{ 50*60, 50*60, 4*60 }' \ AXIS_RELATIVE_MODES '{ false, false, false }' \ - LEVEL_CORNERS_LEVELING_ORDER '{ LF, RF }' + BED_TRAMMING_LEVELING_ORDER '{ LF, RF }' \ + X2_DRIVER_TYPE A4988 Y2_DRIVER_TYPE A4988 opt_enable USE_XMAX_PLUG USE_YMAX_PLUG USE_ZMAX_PLUG \ REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER REVERSE_ENCODER_DIRECTION SDSUPPORT EEPROM_SETTINGS \ - S_CURVE_ACCELERATION X_DUAL_STEPPER_DRIVERS X_DUAL_ENDSTOPS Y_DUAL_STEPPER_DRIVERS Y_DUAL_ENDSTOPS \ + S_CURVE_ACCELERATION X_DUAL_ENDSTOPS Y_DUAL_ENDSTOPS \ ADAPTIVE_STEP_SMOOTHING CNC_COORDINATE_SYSTEMS GCODE_MOTION_MODES \ - LEVEL_BED_CORNERS LEVEL_CENTER_TOO + LCD_BED_TRAMMING BED_TRAMMING_INCLUDE_CENTER opt_disable MIN_SOFTWARE_ENDSTOP_Z MAX_SOFTWARE_ENDSTOPS exec_test $1 $2 "Rambo CNC Configuration" "$3" @@ -115,7 +116,7 @@ opt_set MOTHERBOARD BOARD_RAMBO \ FAN_MIN_PWM 50 FAN_KICKSTART_TIME 100 \ XY_FREQUENCY_LIMIT 15 opt_enable COREYX USE_XMAX_PLUG MIXING_EXTRUDER GRADIENT_MIX \ - BABYSTEPPING BABYSTEP_DISPLAY_TOTAL FILAMENT_LCD_DISPLAY FILAMENT_WIDTH_SENSOR \ + BABYSTEPPING BABYSTEP_DISPLAY_TOTAL FILAMENT_LCD_DISPLAY \ REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER MENU_ADDAUTOSTART SDSUPPORT SDCARD_SORT_ALPHA \ ENDSTOP_NOISE_THRESHOLD FAN_SOFT_PWM \ FIX_MOUNTED_PROBE PROBING_ESTEPPERS_OFF PROBE_OFFSET_WIZARD \ diff --git a/buildroot/tests/rumba32 b/buildroot/tests/rumba32 index f26af33610c6..833769d0b9ba 100755 --- a/buildroot/tests/rumba32 +++ b/buildroot/tests/rumba32 @@ -11,7 +11,7 @@ restore_configs opt_set MOTHERBOARD BOARD_RUMBA32_V1_0 SERIAL_PORT -1 \ TEMP_SENSOR_BED 1 X_DRIVER_TYPE TMC2130 opt_disable PIDTEMP -opt_enable PIDTEMPBED +opt_enable PIDTEMPBED FAN_SOFT_PWM opt_disable THERMAL_PROTECTION_BED exec_test $1 $2 "RUMBA32 V1.0 with TMC2130, PID Bed, and bed thermal protection disabled" "$3" @@ -19,12 +19,13 @@ exec_test $1 $2 "RUMBA32 V1.0 with TMC2130, PID Bed, and bed thermal protection restore_configs opt_set MOTHERBOARD BOARD_RUMBA32_V1_1 SERIAL_PORT -1 \ TEMP_SENSOR_BED 1 X_DRIVER_TYPE TMC2130 Y_DRIVER_TYPE TMC2208 -opt_enable PIDTEMPBED EEPROM_SETTINGS EEPROM_CHITCHAT REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER +opt_enable PIDTEMPBED FAN_SOFT_PWM EEPROM_SETTINGS EEPROM_CHITCHAT REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER exec_test $1 $2 "RUMBA32 V1.1 with TMC2130, TMC2208, PID Bed, EEPROM settings, and graphic LCD controller" "$3" # Build examples restore_configs opt_set MOTHERBOARD BOARD_RUMBA32_MKS SERIAL_PORT -1 X_DRIVER_TYPE TMC2130 Y_DRIVER_TYPE TMC2208 +opt_enable FAN_SOFT_PWM exec_test $1 $2 "RUMBA32 MKS Default Config with Mixed TMC Drivers" "$3" # cleanup diff --git a/buildroot/tests/teensy31 b/buildroot/tests/teensy31 index 10dde2be99ad..7465a67fdde1 100755 --- a/buildroot/tests/teensy31 +++ b/buildroot/tests/teensy31 @@ -14,7 +14,7 @@ exec_test $1 $2 "Teensy3.1 with default config" "$3" # Zero endstops, as with a CNC # restore_configs -opt_set MOTHERBOARD BOARD_TEENSY31_32 +opt_set MOTHERBOARD BOARD_TEENSY31_32 X_HOME_DIR 0 Y_HOME_DIR 0 Z_HOME_DIR 0 opt_disable USE_XMIN_PLUG USE_YMIN_PLUG USE_ZMIN_PLUG exec_test $1 $2 "Teensy3.1 with Zero Endstops" "$3" diff --git a/buildroot/tests/teensy35 b/buildroot/tests/teensy35 index 09e8cee58ef3..64ce4e65505a 100755 --- a/buildroot/tests/teensy35 +++ b/buildroot/tests/teensy35 @@ -101,7 +101,7 @@ exec_test $1 $2 "Teensy 3.5/3.6 COREXZ | BACKLASH" "$3" # Enable Dual Z with Dual Z endstops # restore_configs -opt_set MOTHERBOARD BOARD_TEENSY35_36 NUM_Z_STEPPER_DRIVERS 2 Z2_MIN_PIN 2 +opt_set MOTHERBOARD BOARD_TEENSY35_36 Z_DRIVER_TYPE A4988 Z2_DRIVER_TYPE A4988 Z2_MIN_PIN 2 opt_enable Z_MULTI_ENDSTOPS USE_XMAX_PLUG pins_set ramps/RAMPS X_MAX_PIN -1 exec_test $1 $2 "Dual Z with Dual Z endstops" "$3" diff --git a/buildroot/tests/teensy41 b/buildroot/tests/teensy41 index 1affd7c89e12..56bd5043c736 100755 --- a/buildroot/tests/teensy41 +++ b/buildroot/tests/teensy41 @@ -105,7 +105,7 @@ exec_test $1 $2 "Teensy 4.0/4.1 COREXZ" "$3" # Enable Dual Z with Dual Z endstops # restore_configs -opt_set MOTHERBOARD BOARD_TEENSY41 NUM_Z_STEPPER_DRIVERS 2 Z2_MIN_PIN 2 +opt_set MOTHERBOARD BOARD_TEENSY41 Z_DRIVER_TYPE A4988 Z2_DRIVER_TYPE A4988 Z2_MIN_PIN 2 opt_enable Z_MULTI_ENDSTOPS USE_XMAX_PLUG pins_set ramps/RAMPS X_MAX_PIN -1 exec_test $1 $2 "Dual Z with Dual Z endstops" "$3" diff --git a/buildroot/web-ui/data/www/index.html b/buildroot/web-ui/data/www/index.html index 54bcc13d7386..1a8db1cafb04 100644 --- a/buildroot/web-ui/data/www/index.html +++ b/buildroot/web-ui/data/www/index.html @@ -456,7 +456,7 @@
- +
diff --git a/buildroot/web-ui/data/www/webmarlin-class.js b/buildroot/web-ui/data/www/webmarlin-class.js index 393fd88eef26..2cfc4cbfba6f 100644 --- a/buildroot/web-ui/data/www/webmarlin-class.js +++ b/buildroot/web-ui/data/www/webmarlin-class.js @@ -349,18 +349,18 @@ class jsLog { var wmGCommands = { CustomCmd : new wmGCommandItem('',null,null,'Custom command'), - MoveFw : new wmGCommandItem('G1','Y{0}',10,'Move forward on Y axis'), - MoveBw : new wmGCommandItem('G1','Y-{0}',10,'Move backward on Y axis'), - MoveSx : new wmGCommandItem('G1','X{0}',10,'Move left on X axis'), - MoveDx : new wmGCommandItem('G1','X-{0}',10,'Move right on X axis'), - MoveUp : new wmGCommandItem('G1','Z{0}',10,'Move up on Z axis'), - MoveDw : new wmGCommandItem('G1','Z-{0}',10,'Move down on Z axis'), + MoveFw : new wmGCommandItem('G1','Y{0}',10,'Move Y forward'), + MoveBw : new wmGCommandItem('G1','Y-{0}',10,'Move Y backward'), + MoveSx : new wmGCommandItem('G1','X{0}',10,'Move X left'), + MoveDx : new wmGCommandItem('G1','X-{0}',10,'Move X right'), + MoveUp : new wmGCommandItem('G1','Z{0}',10,'Move Z up'), + MoveDw : new wmGCommandItem('G1','Z-{0}',10,'Move Z down'), FillRetrive : new wmGCommandItem('G10',null,null,'Retract filament'), FillExtrude : new wmGCommandItem('GYYYY',null,null,'Extrude filament'), - MoveHome : new wmGCommandItem('G28',null,null,'Go home on all axis'), - MoveHomeX : new wmGCommandItem('G28','X',null,'Go home on X axis'), - MoveHomeY : new wmGCommandItem('G28','Y',null,'Go home on Y axis'), - MoveHomeZ : new wmGCommandItem('G28','Z',null,'Go home on Z axis'), + MoveHome : new wmGCommandItem('G28',null,null,'Home all axes'), + MoveHomeX : new wmGCommandItem('G28','X',null,'Home X axis'), + MoveHomeY : new wmGCommandItem('G28','Y',null,'Home Y axis'), + MoveHomeZ : new wmGCommandItem('G28','Z',null,'Home Z axis'), StepEnable : new wmGCommandItem('M17','{0}','E X Y Z','Enable stepper'), StepEnableAll : new wmGCommandItem('M17',null,null,'Enable all steppers'), StepDisable : new wmGCommandItem('M18','{0}','E X Y Z','Disable stepper'), diff --git a/config/README.md b/config/README.md index c322cdf71bb4..609b5d4c6ffd 100644 --- a/config/README.md +++ b/config/README.md @@ -1,3 +1,3 @@ # Where have all the configurations gone? -## https://github.com/MarlinFirmware/Configurations/archive/release-2.0.9.3.zip +## https://github.com/MarlinFirmware/Configurations/archive/release-2.0.9.4.zip diff --git a/docker/Dockerfile b/docker/Dockerfile index 903b8b71fd32..7d32f9c63758 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,7 +1,7 @@ FROM python:3.9.0-buster -RUN pip install -U https://github.com/platformio/platformio-core/archive/develop.zip -RUN platformio update +RUN pip install -U platformio +RUN pio upgrade --dev # To get the test platforms RUN pip install PyYaml #ENV PATH /code/buildroot/bin/:/code/buildroot/tests/:${PATH} diff --git a/ini/avr.ini b/ini/avr.ini index e4d64de712a1..5944f8158344 100644 --- a/ini/avr.ini +++ b/ini/avr.ini @@ -13,15 +13,15 @@ # AVR (8-bit) Common Environment values # [common_avr8] +platform = atmelavr@~3.4 build_flags = ${common.build_flags} -Wl,--relax board_build.f_cpu = 16000000L -src_filter = ${common.default_src_filter} + +build_src_filter = ${common.default_src_filter} + # # ATmega2560 # [env:mega2560] -platform = atmelavr extends = common_avr8 board = megaatmega2560 @@ -33,7 +33,6 @@ board = megaatmega2560 # BOARD_EINSTART_S # [env:mega2560ext] -platform = atmelavr extends = env:mega2560 board_build.variant = MARLIN_MEGA_EXTENDED extra_scripts = ${common.extra_scripts} @@ -43,7 +42,6 @@ extra_scripts = ${common.extra_scripts} # ATmega1280 # [env:mega1280] -platform = atmelavr extends = common_avr8 board = megaatmega1280 @@ -61,7 +59,6 @@ build_flags = ${common.build_flags} -fno-tree-scev-cprop -fno-split-wide # MightyBoard ATmega1280 # [env:MightyBoard1280] -platform = atmelavr extends = mega_extended_optimized board = megaatmega1280 @@ -69,7 +66,6 @@ board = megaatmega1280 # MightyBoard ATmega2560 # [env:MightyBoard2560] -platform = atmelavr extends = mega_extended_optimized board = megaatmega2560 @@ -77,7 +73,6 @@ board = megaatmega2560 # RAMBo # [env:rambo] -platform = atmelavr extends = common_avr8 board = reprap_rambo @@ -85,7 +80,6 @@ board = reprap_rambo # FYSETC F6 V1.3 / V1.4 # [env:FYSETC_F6] -platform = atmelavr extends = common_avr8 board = fysetc_f6_13 @@ -93,7 +87,6 @@ board = fysetc_f6_13 # Sanguinololu (ATmega644p) # [env:sanguino644p] -platform = atmelavr extends = common_avr8 board = sanguino_atmega644p @@ -101,19 +94,10 @@ board = sanguino_atmega644p # Sanguinololu (ATmega1284p) # [env:sanguino1284p] -platform = atmelavr extends = common_avr8 board = sanguino_atmega1284p board_upload.maximum_size = 126976 -# -# Melzi and clones (ATmega1284p) -# -[env:melzi] -platform = atmelavr -extends = env:sanguino1284p -upload_speed = 57600 - # # Sanguinololu (ATmega1284p stock bootloader with tuned flags) # @@ -122,22 +106,24 @@ upload_speed = 57600 build_flags = ${common.build_flags} -fno-tree-scev-cprop -fno-split-wide-types -Wl,--relax -mcall-prologues [env:sanguino1284p_optimized] -platform = atmelavr -extends = env:melzi +extends = env:sanguino1284p build_flags = ${tuned_1284p.build_flags} # -# Melzi and clones (alias for sanguino1284p_optimized) +# Melzi and clones (ATmega1284p) # +[env:melzi] +extends = env:sanguino1284p +upload_speed = 57600 + [env:melzi_optimized] -platform = atmelavr -extends = env:sanguino1284p_optimized +extends = env:sanguino1284p_optimized +upload_speed = 57600 # # Melzi and clones (Optiboot bootloader) # [env:melzi_optiboot] -platform = atmelavr extends = common_avr8 board = sanguino_atmega1284p upload_speed = 115200 @@ -147,29 +133,5 @@ board_upload.maximum_size = 130048 # Melzi and clones (Zonestar Melzi2 with tuned flags) # [env:melzi_optiboot_optimized] -platform = atmelavr extends = env:melzi_optiboot build_flags = ${tuned_1284p.build_flags} - -# -# AT90USB1286 boards using CDC bootloader -# - BRAINWAVE -# - BRAINWAVE_PRO -# - SAV_MKI -# - TEENSYLU -# -[env:at90usb1286_cdc] -platform = teensy -extends = common_avr8 -board = marlin_at90usb1286 -lib_ignore = ${env:common_avr8.lib_ignore}, Teensy_ADC, NativeEthernet - -# -# AT90USB1286 boards using DFU bootloader -# - Printrboard -# - Printrboard Rev.F -# - ? 5DPRINT ? -# -[env:at90usb1286_dfu] -platform = teensy -extends = env:at90usb1286_cdc diff --git a/ini/due.ini b/ini/due.ini index 9123af8cdc88..c1e2375d7c5a 100644 --- a/ini/due.ini +++ b/ini/due.ini @@ -16,12 +16,11 @@ # - RADDS # [env:DUE] -platform = atmelsam -board = due -src_filter = ${common.default_src_filter} + + +platform = atmelsam +board = due +build_src_filter = ${common.default_src_filter} + + [env:DUE_USB] -platform = atmelsam extends = env:DUE board = dueUSB @@ -29,7 +28,6 @@ board = dueUSB # Archim SAM # [common_DUE_archim] -platform = atmelsam extends = env:DUE board = marlin_archim build_flags = ${common.build_flags} @@ -39,5 +37,4 @@ extra_scripts = ${common.extra_scripts} Marlin/src/HAL/DUE/upload_extra_script.py [env:DUE_archim] -platform = ${common_DUE_archim.platform} extends = common_DUE_archim diff --git a/ini/esp32.ini b/ini/esp32.ini index 0815486cc993..05b045f16e83 100644 --- a/ini/esp32.ini +++ b/ini/esp32.ini @@ -13,23 +13,21 @@ # Espressif ESP32 # [env:esp32] -platform = espressif32@2.1.0 -board = esp32dev -build_flags = ${common.build_flags} -DCORE_DEBUG_LEVEL=0 -src_filter = ${common.default_src_filter} + -lib_ignore = NativeEthernet -upload_speed = 500000 -monitor_speed = 250000 -#upload_port = marlinesp.local +platform = espressif32@2.1.0 +board = esp32dev +build_flags = ${common.build_flags} -DCORE_DEBUG_LEVEL=0 +build_src_filter = ${common.default_src_filter} + +lib_ignore = NativeEthernet +upload_speed = 500000 +monitor_speed = 250000 +#upload_port = marlinesp.local #board_build.flash_mode = qio [env:FYSETC_E4] -platform = espressif32@2.1.0 extends = env:esp32 board_build.partitions = default_16MB.csv [env:PANDA] -platform = espressif32@2.1.0 extends = env:esp32 build_flags = ${env:esp32.build_flags} -DUSE_ESP32_EXIO -DUSE_ESP32_TASK_WDT lib_deps = ${common.lib_deps} @@ -40,5 +38,4 @@ monitor_speed = 115200 [env:mks_tinybee] extends = env:esp32 -platform = espressif32@2.1.0 board_build.partitions = default_8MB.csv diff --git a/ini/features.ini b/ini/features.ini index 5f69fcca25d5..355544029e0c 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -18,25 +18,27 @@ POSTMORTEM_DEBUGGING = src_filter=+ + + + + + src_filter=+ + + + + +HAS_T(RINAMIC_CONFIG|MC_SPI) = src_filter=+ HAS_STEALTHCHOP = src_filter=+ SR_LCD_3W_NL = SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip HAS_MOTOR_CURRENT_I2C = SlowSoftI2CMaster src_filter=+ -HAS_TMC26X = TMC26XStepper=https://github.com/trinamic/TMC26XStepper/archive/master.zip - src_filter=+ +HAS_TMC26X = TMC26XStepper=https://github.com/MarlinFirmware/TMC26XStepper/archive/master.zip + src_filter=+ HAS_L64XX = Arduino-L6470@0.8.0 src_filter=+ + + + LIB_INTERNAL_MAX31865 = src_filter=+ NEOPIXEL_LED = adafruit/Adafruit NeoPixel@~1.8.0 src_filter=+ I2C_AMMETER = peterus/INA226Lib@1.1.2 + src_filter=+ USES_LIQUIDCRYSTAL = LiquidCrystal=https://github.com/MarlinFirmware/New-LiquidCrystal/archive/1.5.1.zip USES_LIQUIDCRYSTAL_I2C = marcoschwartz/LiquidCrystal_I2C@1.1.4 USES_LIQUIDTWI2 = LiquidTWI2@1.2.7 -HAS_WIRED_LCD = src_filter=+ +HAS_LCDPRINT = src_filter=+ HAS_MARLINUI_HD44780 = src_filter=+ -HAS_MARLINUI_U8GLIB = U8glib-HAL@~0.5.0 +HAS_MARLINUI_U8GLIB = U8glib-HAL@~0.5.2 src_filter=+ HAS_(FSMC|SPI|LTDC)_TFT = src_filter=+ + + HAS_FSMC_TFT = src_filter=+ + @@ -46,13 +48,13 @@ SOFT_I2C_EEPROM = SlowSoftI2CMaster, SlowSoftWire=https:/ SPI_EEPROM = src_filter=+ HAS_DWIN_E3V2|IS_DWIN_MARLINUI = src_filter=+ DWIN_CREALITY_LCD = src_filter=+ -DWIN_CREALITY_LCD_ENHANCED = src_filter=+ +DWIN_LCD_PROUI = src_filter=+ DWIN_CREALITY_LCD_JYERSUI = src_filter=+ IS_DWIN_MARLINUI = src_filter=+ HAS_GRAPHICAL_TFT = src_filter=+ IS_TFTGLCD_PANEL = src_filter=+ HAS_TOUCH_BUTTONS = src_filter=+ -HAS_LCD_MENU = src_filter=+ +HAS_MARLINUI_MENU = src_filter=+ HAS_GAMES = src_filter=+ MARLIN_BRICKOUT = src_filter=+ MARLIN_INVADERS = src_filter=+ @@ -97,7 +99,7 @@ USB_FLASH_DRIVE_SUPPORT = src_filter=+ + AUTO_BED_LEVELING_BILINEAR = src_filter=+ AUTO_BED_LEVELING_(3POINT|(BI)?LINEAR) = src_filter=+ -X_AXIS_TWIST_COMPENSATION = src_filter=+ + +X_AXIS_TWIST_COMPENSATION = src_filter=+ + + MESH_BED_LEVELING = src_filter=+ + AUTO_BED_LEVELING_UBL = src_filter=+ + UBL_HILBERT_CURVE = src_filter=+ @@ -198,11 +200,12 @@ AUTO_REPORT_POSITION = src_filter=+ REPETIER_GCODE_M360 = src_filter=+ HAS_GCODE_M876 = src_filter=+ HAS_RESUME_CONTINUE = src_filter=+ +LCD_SET_PROGRESS_MANUALLY = src_filter=+ HAS_STATUS_MESSAGE = src_filter=+ HAS_LCD_CONTRAST = src_filter=+ +HAS_GCODE_M255 = src_filter=+ HAS_LCD_BRIGHTNESS = src_filter=+ HAS_BUZZER = src_filter=+ -LCD_SET_PROGRESS_MANUALLY = src_filter=+ TOUCH_SCREEN_CALIBRATION = src_filter=+ ARC_SUPPORT = src_filter=+ GCODE_MOTION_MODES = src_filter=+ @@ -217,6 +220,7 @@ HAS_EXTRUDERS = src_filter=+ HAS_COOLER = src_filter=+ AUTO_REPORT_TEMPERATURES = src_filter=+ +MPCTEMP = src_filter=+ INCH_MODE_SUPPORT = src_filter=+ TEMPERATURE_UNITS_SUPPORT = src_filter=+ NEED_HEX_PRINT = src_filter=+ diff --git a/ini/lpc176x.ini b/ini/lpc176x.ini index 3c5f43764ba6..0cb26628fe49 100644 --- a/ini/lpc176x.ini +++ b/ini/lpc176x.ini @@ -20,7 +20,7 @@ lib_ldf_mode = off lib_compat_mode = strict extra_scripts = ${common.extra_scripts} Marlin/src/HAL/LPC1768/upload_extra_script.py -src_filter = ${common.default_src_filter} + + +build_src_filter = ${common.default_src_filter} + + lib_deps = ${common.lib_deps} Servo custom_marlin.USES_LIQUIDCRYSTAL = arduino-libraries/LiquidCrystal@~1.0.7 @@ -34,11 +34,9 @@ build_flags = ${common.build_flags} -DU8G_HAL_LINKS -IMarlin/src/HAL/LPC17 # NXP LPC176x ARM Cortex-M3 # [env:LPC1768] -platform = ${common_LPC.platform} extends = common_LPC board = nxp_lpc1768 [env:LPC1769] -platform = ${common_LPC.platform} extends = common_LPC board = nxp_lpc1769 diff --git a/ini/native.ini b/ini/native.ini index fe5fe3a5d05a..e860a55958f2 100644 --- a/ini/native.ini +++ b/ini/native.ini @@ -13,14 +13,14 @@ # No supported Arduino libraries, base Marlin only # [env:linux_native] -platform = native -framework = -build_flags = -D__PLAT_LINUX__ -std=gnu++17 -ggdb -g -lrt -lpthread -D__MARLIN_FIRMWARE__ -Wno-expansion-to-defined -src_build_flags = -Wall -IMarlin/src/HAL/LINUX/include -build_unflags = -Wall -lib_ldf_mode = off -lib_deps = -src_filter = ${common.default_src_filter} + +platform = native +framework = +build_flags = -D__PLAT_LINUX__ -std=gnu++17 -ggdb -g -lrt -lpthread -D__MARLIN_FIRMWARE__ -Wno-expansion-to-defined +build_src_flags = -Wall -IMarlin/src/HAL/LINUX/include +build_unflags = -Wall +lib_ldf_mode = off +lib_deps = +build_src_filter = ${common.default_src_filter} + # # Native Simulation @@ -34,14 +34,14 @@ src_filter = ${common.default_src_filter} + [simulator_common] platform = native framework = -build_flags = ${common.build_flags} -std=gnu++17 -D__PLAT_NATIVE_SIM__ -DU8G_HAL_LINKS -I/usr/include/SDL2 -IMarlin -IMarlin/src/HAL/NATIVE_SIM/include -IMarlin/src/HAL/NATIVE_SIM/u8g -src_build_flags = -Wall -Wno-expansion-to-defined -Wcast-align +build_flags = ${common.build_flags} -std=gnu++17 -D__PLAT_NATIVE_SIM__ -DU8G_HAL_LINKS -I/usr/include/SDL2 -IMarlin -IMarlin/src/HAL/NATIVE_SIM/u8g +build_src_flags = -Wall -Wno-expansion-to-defined -Wcast-align release_flags = -g0 -O3 -flto debug_build_flags = -fstack-protector-strong -g -g3 -ggdb lib_compat_mode = off -src_filter = ${common.default_src_filter} + +build_src_filter = ${common.default_src_filter} + lib_deps = ${common.lib_deps} - MarlinSimUI=https://github.com/p3p/MarlinSimUI/archive/master.zip + MarlinSimUI=https://github.com/p3p/MarlinSimUI/archive/refs/heads/bugfix-2.0.x.zip Adafruit NeoPixel=https://github.com/p3p/Adafruit_NeoPixel/archive/marlin_sim_native.zip LiquidCrystal=https://github.com/p3p/LiquidCrystal/archive/master.zip extra_scripts = ${common.extra_scripts} @@ -52,12 +52,10 @@ extends = simulator_common build_flags = ${simulator_common.build_flags} -ldl -lpthread -lSDL2 -lSDL2_net -lGL [env:simulator_linux_debug] -platform = ${simulator_linux.platform} extends = simulator_linux build_type = debug [env:simulator_linux_release] -platform = ${simulator_linux.platform} extends = simulator_linux build_type = release build_flags = ${simulator_linux.build_flags} ${simulator_linux.release_flags} @@ -65,12 +63,12 @@ build_flags = ${simulator_linux.build_flags} ${simulator_linux.release_flags} # # Simulator for macOS (MacPorts) # -# sudo port install gcc10 gdb glm libsdl2 libsdl2_net freetype +# sudo port install gcc11 gdb glm libsdl2 libsdl2_net freetype # sudo port install ld64 @3_3 +ld64_xcode # # cd /opt/local/bin # sudo rm -f gcc g++ cc -# sudo ln -s gcc-mp-10 gcc ; sudo ln -s g++-mp-10 g++ ; sudo ln -s g++ cc +# sudo ln -s gcc-mp-11 gcc ; sudo ln -s g++-mp-11 g++ ; sudo ln -s g++ cc # This step may be obsolete: # sudo port uninstall ld64 ld64-latest # @@ -81,7 +79,6 @@ build_flags = ${simulator_linux.build_flags} ${simulator_linux.release_flags} # [simulator_macos] build_unflags = -lGL -custom_verbose = 0 build_flags = -I/opt/local/include -I/opt/local/include/freetype2 @@ -92,16 +89,18 @@ build_flags = -lSDL2 [env:simulator_macos_debug] -platform = ${env:simulator_linux_release.platform} extends = env:simulator_linux_debug build_flags = ${env:simulator_linux_debug.build_flags} ${simulator_macos.build_flags} -ggdb -Og -D_THREAD_SAFE build_unflags = ${simulator_macos.build_unflags} +custom_verbose = 0 +custom_gcc = g++ [env:simulator_macos_release] -platform = ${env:simulator_linux_release.platform} extends = env:simulator_linux_release build_flags = ${env:simulator_linux_release.build_flags} ${simulator_macos.build_flags} build_unflags = ${simulator_macos.build_unflags} +custom_verbose = 0 +custom_gcc = g++ # # Simulator for Windows 10 @@ -110,8 +109,7 @@ build_unflags = ${simulator_macos.build_unflags} # pacman -S --needed base-devel mingw-w64-x86_64-toolchain mingw64/mingw-w64-x86_64-glm mingw64/mingw-w64-x86_64-SDL2 mingw64/mingw-w64-x86_64-SDL2_net mingw-w64-x86_64-dlfcn # [env:simulator_windows] -platform = ${simulator_common.platform} extends = simulator_common -src_build_flags = ${simulator_common.src_build_flags} -fpermissive +build_src_flags = ${simulator_common.build_src_flags} -fpermissive build_flags = ${simulator_common.build_flags} ${simulator_common.debug_build_flags} -IC:\\msys64\\mingw64\\include\\SDL2 -fno-stack-protector -Wl,-subsystem,windows -ldl -lmingw32 -lSDL2main -lSDL2 -lSDL2_net -lopengl32 -lssp build_type = debug diff --git a/ini/renamed.ini b/ini/renamed.ini new file mode 100644 index 000000000000..75f5dc3accc7 --- /dev/null +++ b/ini/renamed.ini @@ -0,0 +1,58 @@ +# +# Marlin Firmware +# PlatformIO Configuration File +# + +################################# +# # +# Renamed Environments # +# # +################################# + +# +# A platform that doesn't match anything in pins.h +# + +[renamed] +platform = ststm32 +board = genericSTM32F103RE + +# +# List of environment names that are no longer used +# + +[env:STM32F103RET6_creality_maple] +# Renamed to STM32F103RE_creality_maple +extends = renamed + +[env:STM32F103RET6_creality] +# Renamed to STM32F103RE_creality +extends = renamed + +[env:STM32F103RET6_creality_xfer] +# Renamed to STM32F103RE_creality_xfer +extends = renamed + +[env:STM32F103RC_btt_512K] +# Renamed to STM32F103RE_btt +extends = renamed + +[env:STM32F103RC_btt_512K_USB] +# Renamed to STM32F103RE_btt_USB +extends = renamed + +[env:STM32F103RC_btt_512K_maple] +# Renamed to STM32F103RE_btt_maple +extends = renamed + +[env:STM32F103RC_btt_512K_USB_maple] +# Renamed to STM32F103RE_btt_USB_maple +extends = renamed + +[env:STM32F103RC_meeb] +# Renamed to STM32F103RC_meeb_maple +extends = renamed + +[env:STM32F103VE_GTM32] +# Renamed to STM32F103VE_GTM32_maple +extends = renamed diff --git a/ini/samd51.ini b/ini/samd51.ini index 34fcc84371c8..d7d9b3a4211c 100644 --- a/ini/samd51.ini +++ b/ini/samd51.ini @@ -13,14 +13,14 @@ # Adafruit Grand Central M4 (Atmel SAMD51P20A ARM Cortex-M4) # [env:SAMD51_grandcentral_m4] -platform = atmelsam -board = adafruit_grandcentral_m4 -build_flags = ${common.build_flags} -std=gnu++17 -build_unflags = -std=gnu++11 -src_filter = ${common.default_src_filter} + -lib_deps = ${common.lib_deps} - SoftwareSerialM -extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py +platform = atmelsam +board = adafruit_grandcentral_m4 +build_flags = ${common.build_flags} -std=gnu++17 +build_unflags = -std=gnu++11 +build_src_filter = ${common.default_src_filter} + +lib_deps = ${common.lib_deps} + SoftwareSerialM +extra_scripts = ${common.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py custom_marlin.SDSUPPORT = SdFat - Adafruit Fork, Adafruit SPIFlash -debug_tool = jlink +debug_tool = jlink diff --git a/ini/stm32-common.ini b/ini/stm32-common.ini index 54bc746ff4ff..c8f28cd0e314 100644 --- a/ini/stm32-common.ini +++ b/ini/stm32-common.ini @@ -16,8 +16,9 @@ build_flags = ${common.build_flags} -std=gnu++14 -DHAL_STM32 -DUSBCON -DUSBD_USE_CDC -DTIM_IRQ_PRIO=13 + -DADC_RESOLUTION=12 build_unflags = -std=gnu++11 -src_filter = ${common.default_src_filter} + + +build_src_filter = ${common.default_src_filter} + + extra_scripts = ${common.extra_scripts} pre:buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py diff --git a/ini/stm32f0.ini b/ini/stm32f0.ini index 4559f115bd8e..d62ac3acf54f 100644 --- a/ini/stm32f0.ini +++ b/ini/stm32f0.ini @@ -23,7 +23,6 @@ # Malyan M200 v2 (STM32F070RB) # [env:STM32F070RB_malyan] -platform = ${common_stm32.platform} extends = common_stm32 board = marlin_malyanM200v2 build_flags = ${common_stm32.build_flags} -DHAL_PCD_MODULE_ENABLED @@ -34,7 +33,6 @@ build_flags = ${common_stm32.build_flags} -DHAL_PCD_MODULE_ENABLED # Malyan M200 v2 (STM32F070CB) # [env:STM32F070CB_malyan] -platform = ${common_stm32.platform} extends = common_stm32 board = malyanm200_f070cb build_flags = ${common_stm32.build_flags} @@ -45,10 +43,9 @@ build_flags = ${common_stm32.build_flags} # Malyan M300 (STM32F070CB) # [env:malyan_M300] -platform = ${common_stm32.platform} -extends = common_stm32 -board = malyanm300_f070cb -build_flags = ${common_stm32.build_flags} - -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB - -DHAL_UART_MODULE_ENABLED -src_filter = ${common.default_src_filter} + +extends = common_stm32 +board = malyanm300_f070cb +build_flags = ${common_stm32.build_flags} + -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB + -DHAL_UART_MODULE_ENABLED +build_src_filter = ${common.default_src_filter} + diff --git a/ini/stm32f1-maple.ini b/ini/stm32f1-maple.ini index 969bb815dacd..18c861ba1ebe 100644 --- a/ini/stm32f1-maple.ini +++ b/ini/stm32f1-maple.ini @@ -22,67 +22,74 @@ # # HAL/STM32F1 Common Environment values # -[common_stm32f1] +[STM32F1_maple] platform = ststm32@~12.1 board_build.core = maple build_flags = !python Marlin/src/HAL/STM32F1/build_flags.py ${common.build_flags} -DARDUINO_ARCH_STM32 -DMAPLE_STM32F1 build_unflags = -std=gnu11 -std=gnu++11 -src_filter = ${common.default_src_filter} + +build_src_filter = ${common.default_src_filter} + lib_ignore = SPI, FreeRTOS701, FreeRTOS821 lib_deps = ${common.lib_deps} SoftwareSerialM platform_packages = tool-stm32duino extra_scripts = ${common.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/fix_framework_weakness.py - pre:buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py - buildroot/share/PlatformIO/scripts/offset_and_rename.py + pre:buildroot/share/PlatformIO/scripts/fix_framework_weakness.py + pre:buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py + buildroot/share/PlatformIO/scripts/custom_board.py + buildroot/share/PlatformIO/scripts/offset_and_rename.py # -# STM32F103RC +# Generic STM32F103RC environment # -[common_STM32F103RC_maple] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103RC -monitor_speed = 115200 +[env:STM32F103RC_maple] +extends = STM32F1_maple +board = genericSTM32F103RC +monitor_speed = 115200 + +# +# Generic STM32F103RE environment +# +[env:STM32F103RE_maple] +extends = STM32F1_maple +board = genericSTM32F103RE +monitor_speed = 115200 # # MEEB_3DP (STM32F103RCT6 with 512K) # -[env:STM32F103RC_meeb] -platform = ${common_stm32f1.platform} -extends = common_STM32F103RC_maple -board = marlin_MEEB_3DP -build_flags = ${common_stm32f1.build_flags} - -DDEBUG_LEVEL=0 - -DSS_TIMER=4 - -DSTM32_FLASH_SIZE=512 - -DHSE_VALUE=12000000U - -DUSE_USB_COMPOSITE - -DVECT_TAB_OFFSET=0x2000 - -DGENERIC_BOOTLOADER -extra_scripts = ${common_stm32f1.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py - buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py -lib_deps = ${common_stm32f1.lib_deps} - USBComposite for STM32F1@0.91 +[env:STM32F103RC_meeb_maple] +extends = env:STM32F103RC_maple +board = marlin_maple_MEEB_3DP +build_flags = ${STM32F1_maple.build_flags} + -DDEBUG_LEVEL=0 + -DSS_TIMER=4 + -DSTM32_FLASH_SIZE=512 + -DHSE_VALUE=12000000U + -DUSE_USB_COMPOSITE + -DVECT_TAB_OFFSET=0x2000 + -DGENERIC_BOOTLOADER +board_build.ldscript = STM32F103RC_MEEB_3DP.ld +extra_scripts = ${STM32F1_maple.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py + buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py +lib_deps = ${STM32F1_maple.lib_deps} + USBComposite for STM32F1@0.91 custom_marlin.NEOPIXEL_LED = Adafruit NeoPixel=https://github.com/ccccmagicboy/Adafruit_NeoPixel#meeb_3dp_use -debug_tool = stlink -upload_protocol = dfu +debug_tool = stlink +upload_protocol = dfu # # FYSETC STM32F103RC # [env:STM32F103RC_fysetc_maple] -platform = ${common_stm32f1.platform} -extends = common_STM32F103RC_maple -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py -build_flags = ${common_stm32f1.build_flags} -DDEBUG_LEVEL=0 -lib_ldf_mode = chain -debug_tool = stlink -upload_protocol = serial +extends = env:STM32F103RC_maple +extra_scripts = ${STM32F1_maple.extra_scripts} + buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py +build_flags = ${STM32F1_maple.build_flags} -DDEBUG_LEVEL=0 +lib_ldf_mode = chain +debug_tool = stlink +upload_protocol = serial # # BigTree SKR Mini V1.1 / SKR Mini E3 & MZ (STM32F103RCT6 ARM Cortex-M3) @@ -91,47 +98,52 @@ upload_protocol = serial # STM32F103RC_btt_USB_maple ......... RCT6 with 256K (USB mass storage) # [env:STM32F103RC_btt_maple] -platform = ${common_stm32f1.platform} -extends = common_STM32F103RC_maple +extends = env:STM32F103RC_maple board_build.address = 0x08007000 board_build.ldscript = STM32F103RC_SKR_MINI_256K.ld -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/custom_board.py -build_flags = ${common_stm32f1.build_flags} - -DDEBUG_LEVEL=0 -DSS_TIMER=4 +build_flags = ${STM32F1_maple.build_flags} -DDEBUG_LEVEL=0 -DSS_TIMER=4 monitor_speed = 115200 [env:STM32F103RC_btt_USB_maple] -platform = ${common_stm32f1.platform} -extends = env:STM32F103RC_btt_maple -build_flags = ${env:STM32F103RC_btt_maple.build_flags} -DUSE_USB_COMPOSITE -lib_deps = ${env:STM32F103RC_btt_maple.lib_deps} - USBComposite for STM32F1@0.91 +extends = env:STM32F103RC_btt_maple +build_flags = ${env:STM32F103RC_btt_maple.build_flags} -DUSE_USB_COMPOSITE +lib_deps = ${env:STM32F103RC_btt_maple.lib_deps} + USBComposite for STM32F1@0.91 # -# Generic STM32F103RE environment +# Creality (STM32F103RET6) # -[env:STM32F103RE_maple] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103RE -monitor_speed = 115200 +[env:STM32F103RE_creality_maple] +extends = env:STM32F103RE_maple +build_flags = ${STM32F1_maple.build_flags} -DTEMP_TIMER_CHAN=4 +board_build.address = 0x08007000 +board_build.ldscript = creality.ld +extra_scripts = ${STM32F1_maple.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/random-bin.py +debug_tool = jlink +upload_protocol = jlink # -# Creality (STM32F103RET6) +# Creality (STM32F103RCT6) # -[env:STM32F103RET6_creality_maple] -platform = ${common_stm32f1.platform} -extends = env:STM32F103RE_maple -build_flags = ${common_stm32f1.build_flags} -DTEMP_TIMER_CHAN=4 +[env:STM32F103RC_creality_maple] +extends = env:STM32F103RC_maple +build_flags = ${STM32F1_maple.build_flags} -DTEMP_TIMER_CHAN=4 board_build.address = 0x08007000 board_build.ldscript = creality.ld -extra_scripts = ${common_stm32f1.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/random-bin.py - buildroot/share/PlatformIO/scripts/custom_board.py +extra_scripts = ${STM32F1_maple.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/random-bin.py debug_tool = jlink upload_protocol = jlink +# +# Creality (STM32F103RET6) +# +[env:STM32F103RE_creality_smartPro_maple] +extends = env:STM32F103RE_creality_maple +board_build.address = 0x08010000 +board_build.ldscript = crealityPro.ld + # # BigTree SKR Mini E3 V2.0 & DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3) # @@ -139,222 +151,197 @@ upload_protocol = jlink # STM32F103RE_btt_USB_maple ......... RET6 (USB mass storage) # [env:STM32F103RE_btt_maple] -platform = ${common_stm32f1.platform} -extends = env:STM32F103RE_maple +extends = env:STM32F103RE_maple board_build.address = 0x08007000 board_build.ldscript = STM32F103RE_SKR_MINI_512K.ld -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/custom_board.py -build_flags = ${common_stm32f1.build_flags} -DDEBUG_LEVEL=0 -DSS_TIMER=4 -debug_tool = stlink -upload_protocol = stlink +build_flags = ${STM32F1_maple.build_flags} -DDEBUG_LEVEL=0 -DSS_TIMER=4 +debug_tool = stlink +upload_protocol = stlink [env:STM32F103RE_btt_USB_maple] -platform = ${common_stm32f1.platform} -extends = env:STM32F103RE_btt_maple -build_flags = ${env:STM32F103RE_btt_maple.build_flags} -DUSE_USB_COMPOSITE -lib_deps = ${common_stm32f1.lib_deps} - USBComposite for STM32F1@0.91 +extends = env:STM32F103RE_btt_maple +build_flags = ${env:STM32F103RE_btt_maple.build_flags} -DUSE_USB_COMPOSITE +lib_deps = ${STM32F1_maple.lib_deps} + USBComposite for STM32F1@0.91 # # Geeetech GTM32 (STM32F103VET6) # -[env:STM32F103VE_GTM32] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 +[env:STM32F103VE_GTM32_maple] +extends = STM32F1_maple board = genericSTM32F103VE -build_flags = ${common_stm32f1.build_flags} - -ffunction-sections -fdata-sections -nostdlib -MMD - -DMCU_STM32F103VE -DARDUINO_GENERIC_STM32F103V -DARDUINO_ARCH_STM32F1 -DBOARD_generic_stm32f103v - -DDEBUG_LEVEL=DEBUG_NONE -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DVECT_TAB_ADDR=0x8000000 - -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6 +build_flags = ${STM32F1_maple.build_flags} + -ffunction-sections -fdata-sections -nostdlib -MMD + -DMCU_STM32F103VE -DARDUINO_GENERIC_STM32F103V -DARDUINO_ARCH_STM32F1 -DBOARD_generic_stm32f103v + -DDEBUG_LEVEL=DEBUG_NONE -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DVECT_TAB_ADDR=0x8000000 + -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6 upload_protocol = serial # # Longer 3D board in Alfawise U20 (STM32F103VET6) # [env:STM32F103VE_longer_maple] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103VE +extends = STM32F1_maple +board = genericSTM32F103VE board_build.address = 0x08010000 board_build.rename = project.bin board_build.ldscript = STM32F103VE_longer.ld -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/custom_board.py -build_flags = ${common_stm32f1.build_flags} - -DMCU_STM32F103VE -DSTM32F1xx -USERIAL_USB -DU20 -DTS_V12 -build_unflags = ${common_stm32f1.build_unflags} - -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6 +build_flags = ${STM32F1_maple.build_flags} + -DMCU_STM32F103VE -DSTM32F1xx -USERIAL_USB -DU20 -DTS_V12 +build_unflags = ${STM32F1_maple.build_unflags} + -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6 # # MKS Robin Mini (STM32F103VET6) # [env:mks_robin_mini_maple] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103VE -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_robin_mini.py -build_flags = ${common_stm32f1.build_flags} - -DMCU_STM32F103VE +extends = STM32F1_maple +board = genericSTM32F103VE +board_build.address = 0x08007000 +board_build.rename = Robin_mini.bin +board_build.ldscript = mks_robin_mini.ld +build_flags = ${STM32F1_maple.build_flags} -DMCU_STM32F103VE # # MKS Robin Nano (STM32F103VET6) # [env:mks_robin_nano35_maple] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103VE -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_robin_nano35.py -build_flags = ${common_stm32f1.build_flags} - -DMCU_STM32F103VE -DSS_TIMER=4 -debug_tool = jlink -upload_protocol = jlink +extends = STM32F1_maple +board = genericSTM32F103VE +board_build.address = 0x08007000 +board_build.rename = Robin_nano35.bin +board_build.ldscript = mks_robin_nano.ld +build_flags = ${STM32F1_maple.build_flags} -DMCU_STM32F103VE -DSS_TIMER=4 +debug_tool = jlink +upload_protocol = jlink # # MKS Robin (STM32F103ZET6) # [env:mks_robin_maple] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103ZE -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_robin.py -build_flags = ${common_stm32f1.build_flags} - -DSS_TIMER=4 -DSTM32_XL_DENSITY +extends = STM32F1_maple +board = genericSTM32F103ZE +board_build.address = 0x08007000 +board_build.rename = Robin.bin +board_build.ldscript = mks_robin.ld +build_flags = ${STM32F1_maple.build_flags} -DSS_TIMER=4 -DSTM32_XL_DENSITY # # MKS Robin Pro (STM32F103ZET6) # [env:mks_robin_pro_maple] -platform = ${common_stm32f1.platform} -extends = env:mks_robin_maple -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_robin_pro.py +extends = env:mks_robin_maple +board_build.address = 0x08007000 +board_build.rename = Robin_pro.bin +board_build.ldscript = mks_robin_pro.ld # # TRIGORILLA PRO (STM32F103ZET6) # [env:trigorilla_pro_maple] -platform = ${common_stm32f1.platform} extends = env:mks_robin_maple -extra_scripts = ${common_stm32f1.extra_scripts} +extra_scripts = ${STM32F1_maple.extra_scripts} # # MKS Robin E3D (STM32F103RCT6) and # MKS Robin E3 with TMC2209 # [env:mks_robin_e3_maple] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103RC -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_robin_e3.py -build_flags = ${common_stm32f1.build_flags} - -DDEBUG_LEVEL=0 -DSS_TIMER=4 +extends = STM32F1_maple +board = genericSTM32F103RC +board_build.address = 0x08005000 +board_build.rename = Robin_e3.bin +board_build.ldscript = mks_robin_e3.ld +build_flags = ${STM32F1_maple.build_flags} -DDEBUG_LEVEL=0 -DSS_TIMER=4 # # MKS Robin E3p (STM32F103VET6) # - LVGL UI # [env:mks_robin_e3p_maple] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103VE -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_robin_e3p.py -build_flags = ${common_stm32f1.build_flags} - -DMCU_STM32F103VE -DSS_TIMER=4 -debug_tool = jlink -upload_protocol = jlink +extends = STM32F1_maple +board = genericSTM32F103VE +board_build.address = 0x08007000 +board_build.rename = Robin_e3p.bin +board_build.ldscript = mks_robin_e3p.ld +build_flags = ${STM32F1_maple.build_flags} -DMCU_STM32F103VE -DSS_TIMER=4 +debug_tool = jlink +upload_protocol = jlink # # MKS Robin Lite/Lite2 (STM32F103RCT6) # [env:mks_robin_lite_maple] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103RC -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_robin_lite.py +extends = STM32F1_maple +board = genericSTM32F103RC +board_build.address = 0x08005000 +board_build.rename = mksLite.bin +board_build.ldscript = mks_robin_lite.ld # # MKS ROBIN LITE3 (STM32F103RCT6) # [env:mks_robin_lite3_maple] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103RC -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/mks_robin_lite3.py +extends = STM32F1_maple +board = genericSTM32F103RC +board_build.address = 0x08005000 +board_build.rename = mksLite3.bin +board_build.ldscript = mks_robin_lite.ld # # JGAurora A5S A1 (STM32F103ZET6) # [env:jgaurora_a5s_a1_maple] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103ZE +extends = STM32F1_maple +board = genericSTM32F103ZE board_build.address = 0x0800A000 board_build.ldscript = jgaurora_a5s_a1.ld -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/custom_board.py - buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py -build_flags = ${common_stm32f1.build_flags} - -DSTM32F1xx -DSTM32_XL_DENSITY +extra_scripts = ${STM32F1_maple.extra_scripts} + buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py +build_flags = ${STM32F1_maple.build_flags} -DSTM32F1xx -DSTM32_XL_DENSITY # # Malyan M200 (STM32F103CB) # [env:STM32F103CB_malyan_maple] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = marlin_malyanM200 -build_flags = ${common_stm32f1.build_flags} - -DMCU_STM32F103CB -D__STM32F1__=1 -std=c++1y -DSERIAL_USB -ffunction-sections -fdata-sections - -Wl,--gc-sections -DDEBUG_LEVEL=0 -D__MARLIN_FIRMWARE__ -lib_ignore = ${common_stm32f1.lib_ignore} - SoftwareSerialM +extends = STM32F1_maple +board = marlin_malyanM200 +build_flags = ${STM32F1_maple.build_flags} + -DMCU_STM32F103CB -D__STM32F1__=1 -std=c++1y -DSERIAL_USB -ffunction-sections -fdata-sections + -Wl,--gc-sections -DDEBUG_LEVEL=0 -D__MARLIN_FIRMWARE__ +lib_ignore = ${STM32F1_maple.lib_ignore} + SoftwareSerialM # # Chitu boards like Tronxy X5s (STM32F103ZET6) # [env:chitu_f103_maple] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = marlin_CHITU_F103 -extra_scripts = ${common_stm32f1.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py - buildroot/share/PlatformIO/scripts/chitu_crypt.py -build_flags = ${common_stm32f1.build_flags} - -DSTM32F1xx -DSTM32_XL_DENSITY -build_unflags = ${common_stm32f1.build_unflags} - -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG= -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6 +extends = STM32F1_maple +board = marlin_maple_CHITU_F103 +extra_scripts = ${STM32F1_maple.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py + buildroot/share/PlatformIO/scripts/chitu_crypt.py +build_flags = ${STM32F1_maple.build_flags} -DSTM32F1xx -DSTM32_XL_DENSITY +build_unflags = ${STM32F1_maple.build_unflags} + -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG= -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6 # # Some Chitu V5 boards have a problem with GPIO init. # Use this target if G28 or G29 are always failing. # [env:chitu_v5_gpio_init_maple] -platform = ${common_stm32f1.platform} -extends = env:chitu_f103_maple -build_flags = ${env:chitu_f103_maple.build_flags} -DCHITU_V5_Z_MIN_BUGFIX +extends = env:chitu_f103_maple +build_flags = ${env:chitu_f103_maple.build_flags} -DCHITU_V5_Z_MIN_BUGFIX # # FLYmaker FLY Mini (STM32F103RCT6) # [env:FLY_MINI_maple] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 -board = genericSTM32F103RC +extends = STM32F1_maple +board = genericSTM32F103RC board_build.address = 0x08005000 board_build.ldscript = fly_mini.ld -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/custom_board.py -build_flags = ${common_stm32f1.build_flags} - -DDEBUG_LEVEL=0 -DSS_TIMER=4 +build_flags = ${STM32F1_maple.build_flags} -DDEBUG_LEVEL=0 -DSS_TIMER=4 # # Zonestar ZM3E2 V1.0 / ZM3E4 V1.0 / ZM3E4 V2.0 @@ -364,57 +351,47 @@ build_flags = ${common_stm32f1.build_flags} # STM32F103VE_ZM3E4V2_USB_maple ......... VET6 with 512K # [ZONESTAR_ZM3E_maple] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 +extends = STM32F1_maple platform_packages = tool-stm32duino board_build.address = 0x08005000 board_build.offset = 0x5000 board_upload.maximum_size = 237568 -extra_scripts = ${common.extra_scripts} - buildroot/share/PlatformIO/scripts/custom_board.py - buildroot/share/PlatformIO/scripts/offset_and_rename.py -build_flags = ${common_stm32f1.build_flags} - -D__STM32F1__=1 -DDEBUG_LEVEL=0 -DSS_TIMER=4 -DSERIAL_USB -lib_deps = ${common_stm32f1.lib_deps} - USBComposite for STM32F1@0.91 +build_flags = ${STM32F1_maple.build_flags} + -D__STM32F1__=1 -DDEBUG_LEVEL=0 -DSS_TIMER=4 -DSERIAL_USB +lib_deps = ${STM32F1_maple.lib_deps} + USBComposite for STM32F1@0.91 lib_ignore = Adafruit NeoPixel, SPI, SailfishLCD, SailfishRGB_LED, SlowSoftI2CMaster, TMCStepper [env:STM32F103RC_ZM3E2_USB_maple] -platform = ${ZONESTAR_ZM3E_maple.platform} extends = ZONESTAR_ZM3E_maple board = genericSTM32F103RC board_build.ldscript = ZONESTAR_ZM3E_256K.ld [env:STM32F103VC_ZM3E4_USB_maple] -platform = ${ZONESTAR_ZM3E_maple.platform} extends = ZONESTAR_ZM3E_maple board = genericSTM32F103VC board_build.ldscript = ZONESTAR_ZM3E_256K.ld build_flags = ${ZONESTAR_ZM3E_maple.build_flags} -DTONE_TIMER=1 -DTONE_CHANNEL=2 [env:STM32F103VE_ZM3E4V2_USB_maple] -platform = ${ZONESTAR_ZM3E_maple.platform} -extends = ZONESTAR_ZM3E_maple -board = genericSTM32F103VE -board_build.ldscript = ZONESTAR_ZM3E_512K.ld -build_flags = ${ZONESTAR_ZM3E_maple.build_flags} -DTONE_TIMER=1 -DTONE_CHANNEL=2 +extends = ZONESTAR_ZM3E_maple +board = genericSTM32F103VE +board_build.ldscript = ZONESTAR_ZM3E_512K.ld +build_flags = ${ZONESTAR_ZM3E_maple.build_flags} -DTONE_TIMER=1 -DTONE_CHANNEL=2 board_upload.maximum_size = 499712 # # ERYONE ERY32 Mini (STM32F103VET6) # [env:ERYONE_ERY32_MINI_maple] -platform = ${common_stm32f1.platform} -extends = common_stm32f1 +extends = STM32F1_maple board = genericSTM32F103VE -build_flags = ${common_stm32f1.build_flags} - -ffunction-sections -fdata-sections -nostdlib -MMD - -DMCU_STM32F103VE -DARDUINO_GENERIC_STM32F103V -DARDUINO_ARCH_STM32F1 - -DDEBUG_LEVEL=DEBUG_NONE -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 - -DSS_TIMER=4 +build_flags = ${STM32F1_maple.build_flags} + -ffunction-sections -fdata-sections -nostdlib -MMD + -DMCU_STM32F103VE -DARDUINO_GENERIC_STM32F103V -DARDUINO_ARCH_STM32F1 + -DDEBUG_LEVEL=DEBUG_NONE -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 + -DSS_TIMER=4 board_build.variant = MARLIN_F103Vx board_build.ldscript = eryone_ery32_mini.ld board_build.address = 0x08004000 -build_unflags = ${common_stm32f1.build_unflags} -extra_scripts = ${common_stm32f1.extra_scripts} - buildroot/share/PlatformIO/scripts/custom_board.py +build_unflags = ${STM32F1_maple.build_unflags} diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index a2cd1b0f5867..a4ad79adfaff 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -30,7 +30,6 @@ monitor_speed = 115200 # STM32F103RE # [env:STM32F103RE] -platform = ${common_stm32.platform} extends = common_stm32 board = genericSTM32F103RE monitor_speed = 115200 @@ -39,7 +38,6 @@ monitor_speed = 115200 # STM32F103VE # [env:STM32F103VE] -platform = ${common_stm32.platform} extends = common_stm32 board = genericSTM32F103VE monitor_speed = 115200 @@ -48,7 +46,6 @@ monitor_speed = 115200 # STM32F103ZE # [env:STM32F103ZE] -platform = ${common_stm32.platform} extends = common_stm32 board = genericSTM32F103ZE monitor_speed = 115200 @@ -60,7 +57,6 @@ monitor_speed = 115200 # STM32F103RC_btt_USB ......... RCT6 with 256K (USB mass storage) # [env:STM32F103RC_btt] -platform = ${common_stm32.platform} extends = common_STM32F103RC_variant build_flags = ${common_STM32F103RC_variant.build_flags} -DTIMER_SERVO=TIM5 @@ -68,7 +64,6 @@ board_build.offset = 0x7000 board_upload.offset_address = 0x08007000 [env:STM32F103RC_btt_USB] -platform = ${common_stm32.platform} extends = env:STM32F103RC_btt platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${env:STM32F103RC_btt.build_flags} @@ -78,12 +73,22 @@ build_flags = ${env:STM32F103RC_btt.build_flags} -DUSBD_USE_CDC_MSC build_unflags = ${common_stm32.build_unflags} -DUSBD_USE_CDC +# +# Panda Pi V2.9 - Standalone (STM32F103RC) +# Headless, without direct Pi control, but potentially hosting OctoPrint, stepdaemon, etc. +# +[env:PANDA_PI_V29] +extends = common_STM32F103RC_variant +build_flags = ${common_STM32F103RC_variant.build_flags} + -DTIMER_SERVO=TIM1 +board_build.offset = 0x5000 +board_upload.offset_address = 0x08005000 + # # MKS Robin (STM32F103ZET6) # Uses HAL STM32 to support Marlin UI for TFT screen with optional touch panel # [env:mks_robin] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103ZE board_build.variant = MARLIN_F103Zx @@ -98,7 +103,6 @@ build_unflags = ${stm32_variant.build_unflags} # MKS Robin E3/E3D (STM32F103RCT6) with TMC2209 # [env:mks_robin_e3] -platform = ${common_stm32.platform} extends = common_STM32F103RC_variant board_build.encrypt = Robin_e3.bin board_build.offset = 0x5000 @@ -107,16 +111,13 @@ build_flags = ${common_STM32F103RC_variant.build_flags} -DTIMER_SERVO=TIM5 -DDEFAULT_SPI=3 build_unflags = ${common_STM32F103RC_variant.build_unflags} -DUSBCON -DUSBD_USE_CDC -monitor_speed = 115200 debug_tool = stlink # -# Creality (STM32F103RET6) +# Creality (STM32F103Rx) # -[env:STM32F103RET6_creality] -platform = ${common_stm32.platform} +[STM32F103Rx_creality] extends = stm32_variant -board = genericSTM32F103RE board_build.variant = MARLIN_F103Rx board_build.offset = 0x7000 board_upload.offset_address = 0x08007000 @@ -132,6 +133,42 @@ monitor_speed = 115200 debug_tool = jlink upload_protocol = jlink +# +# Custom upload to SD via Marlin with Binary Protocol +# +[STM32F103Rx_creality_xfer] +extends = STM32F103Rx_creality +extra_scripts = ${STM32F103Rx_creality.extra_scripts} + pre:buildroot/share/scripts/upload.py +upload_protocol = custom + +# +# Creality 512K (STM32F103RE) +# +[env:STM32F103RE_creality] +extends = STM32F103Rx_creality +board = genericSTM32F103RE + +[env:STM32F103RE_creality_xfer] +extends = STM32F103Rx_creality_xfer +board = genericSTM32F103RE + +[env:STM32F103RE_creality_smartPro] +extends = STM32F103Rx_creality +board_build.offset = 0x10000 +board_upload.offset_address = 0x08010000 + +# +# Creality 256K (STM32F103RC) +# +[env:STM32F103RC_creality] +extends = STM32F103Rx_creality +board = genericSTM32F103RC + +[env:STM32F103RC_creality_xfer] +extends = STM32F103Rx_creality_xfer +board = genericSTM32F103RC + # # BigTree SKR Mini E3 V2.0 & DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3) # @@ -139,7 +176,6 @@ upload_protocol = jlink # STM32F103RE_btt_USB ......... RET6 (USB mass storage) # [env:STM32F103RE_btt] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103RE board_build.variant = MARLIN_F103Rx @@ -154,7 +190,6 @@ debug_tool = jlink upload_protocol = jlink [env:STM32F103RE_btt_USB] -platform = ${common_stm32.platform} extends = env:STM32F103RE_btt platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${env:STM32F103RE_btt.build_flags} @@ -167,7 +202,6 @@ build_unflags = ${stm32_variant.build_unflags} -DUSBD_USE_CDC # board Hispeedv1 # [env:flsun_hispeedv1] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103VE board_build.variant = MARLIN_F103Vx @@ -184,7 +218,6 @@ build_unflags = ${stm32_variant.build_unflags} # MKS Robin Nano V1.2 and V2 # [env:mks_robin_nano35] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103VE board_build.variant = MARLIN_F103Vx @@ -203,7 +236,6 @@ upload_protocol = jlink # Mingda MPX_ARM_MINI # [env:mingda_mpx_arm_mini] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103ZE board_build.variant = MARLIN_F103Zx @@ -217,19 +249,17 @@ build_unflags = ${stm32_variant.build_unflags} # Malyan M200 (STM32F103CB) # [env:STM32F103CB_malyan] -platform = ${common_stm32.platform} -extends = common_stm32 -board = malyanm200_f103cb -build_flags = ${common_stm32.build_flags} - -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB - -DHAL_UART_MODULE_ENABLED -src_filter = ${common.default_src_filter} + +extends = common_stm32 +board = malyanm200_f103cb +build_flags = ${common_stm32.build_flags} + -DHAL_PCD_MODULE_ENABLED -DDISABLE_GENERIC_SERIALUSB + -DHAL_UART_MODULE_ENABLED +build_src_filter = ${common.default_src_filter} + # # FLYmaker FLY Mini (STM32F103RCT6) # [env:FLY_MINI] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103RC board_build.variant = MARLIN_F103Rx @@ -241,7 +271,6 @@ build_flags = ${stm32_variant.build_flags} -DSS_TIMER=4 # MKS Robin Mini (STM32F103VET6) # [env:mks_robin_mini] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103VE board_build.variant = MARLIN_F103Vx @@ -255,7 +284,6 @@ build_flags = ${stm32_variant.build_flags} # MKS Robin Lite/Lite2 (STM32F103RCT6) # [env:mks_robin_lite] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103RC board_build.variant = MARLIN_F103Rx @@ -267,7 +295,6 @@ board_upload.offset_address = 0x08005000 # MKS ROBIN LITE3 (STM32F103RCT6) # [env:mks_robin_lite3] -platform = ${common_stm32.platform} extends = env:mks_robin_lite board_build.encrypt = mksLite3.bin @@ -275,7 +302,6 @@ board_build.encrypt = mksLite3.bin # MKS Robin Pro (STM32F103ZET6) # [env:mks_robin_pro] -platform = ${common_stm32.platform} extends = env:mks_robin board_build.encrypt = Robin_pro.bin @@ -284,7 +310,6 @@ board_build.encrypt = Robin_pro.bin # - LVGL UI # [env:mks_robin_e3p] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103VE board_build.variant = MARLIN_F103Vx @@ -301,12 +326,10 @@ upload_protocol = jlink # JGAurora A5S A1 (STM32F103ZET6) # [env:jgaurora_a5s_a1] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103ZE board_build.variant = MARLIN_F103Zx board_build.offset = 0xA000 -board_build.rename = firmware_for_sd_upload.bin board_upload.offset_address = 0x0800A000 build_flags = ${stm32_variant.build_flags} -DSTM32F1xx -DSTM32_XL_DENSITY @@ -317,7 +340,6 @@ extra_scripts = ${stm32_variant.extra_scripts} # FYSETC STM32F103RC # [env:STM32F103RC_fysetc] -platform = ${common_stm32.platform} extends = common_STM32F103RC_variant extra_scripts = ${common_STM32F103RC_variant.extra_scripts} buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py @@ -329,10 +351,9 @@ upload_protocol = serial # Longer 3D board in Alfawise U20 (STM32F103VET6) # [env:STM32F103VE_longer] -platform = ${common_stm32.platform} +extends = stm32_variant lib_deps = ${common.lib_deps} https://github.com/tpruvot/STM32_Servo_OpenDrain/archive/2.0.zip -extends = stm32_variant board = genericSTM32F103VE board_build.variant = MARLIN_F103VE_LONGER board_build.rename = project.bin @@ -348,7 +369,6 @@ debug_tool = stlink # TRIGORILLA PRO (STM32F103ZET6) # [env:trigorilla_pro] -platform = ${stm32_variant.platform} extends = stm32_variant board = genericSTM32F103ZE board_build.variant = MARLIN_F103Zx @@ -361,7 +381,6 @@ build_unflags = ${stm32_variant.build_unflags} # Chitu boards like Tronxy X5s (STM32F103ZET6) # [env:chitu_f103] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F103ZE board_build.variant = MARLIN_F103Zx @@ -377,7 +396,6 @@ extra_scripts = ${stm32_variant.extra_scripts} # Use this target if G28 or G29 are always failing. # [env:chitu_v5_gpio_init] -platform = ${common_stm32.platform} extends = env:chitu_f103 build_flags = ${env:chitu_f103.build_flags} -DCHITU_V5_Z_MIN_BUGFIX @@ -389,7 +407,6 @@ build_flags = ${env:chitu_f103.build_flags} -DCHITU_V5_Z_MIN_BUGFIX # STM32F103VE_ZM3E4V2_USB ......... VET6 with 512K # [ZONESTAR_ZM3E] -platform = ${common_stm32.platform} extends = stm32_variant platform_packages = ${stm_flash_drive.platform_packages} board_upload.offset_address = 0x08005000 @@ -401,20 +418,17 @@ build_flags = ${common_stm32.build_flags} build_unflags = ${stm32_variant.build_unflags} -DUSBD_USE_CDC [env:STM32F103RC_ZM3E2_USB] -platform = ${ZONESTAR_ZM3E.platform} extends = ZONESTAR_ZM3E board = genericSTM32F103RC board_build.variant = MARLIN_F103Rx [env:STM32F103VC_ZM3E4_USB] -platform = ${ZONESTAR_ZM3E.platform} extends = ZONESTAR_ZM3E board = genericSTM32F103VC board_build.variant = MARLIN_F103Vx build_flags = ${ZONESTAR_ZM3E.build_flags} -DTIMER_TONE=TIM1 [env:STM32F103VE_ZM3E4V2_USB] -platform = ${ZONESTAR_ZM3E.platform} extends = ZONESTAR_ZM3E board = genericSTM32F103VE board_build.variant = MARLIN_F103Vx diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index d7c80cf0e910..688cc1054736 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -23,7 +23,6 @@ # ARMED (STM32) # [env:ARMED] -platform = ${common_stm32.platform} extends = common_stm32 board = armed_v1 build_flags = ${common_stm32.build_flags} @@ -34,7 +33,6 @@ build_flags = ${common_stm32.build_flags} # 'STEVAL-3DP001V1' STM32F401VE board - https://www.st.com/en/evaluation-tools/steval-3dp001v1.html # [env:STM32F401VE_STEVAL] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STEVAL_STM32F401VE build_flags = ${stm32_variant.build_flags} @@ -45,17 +43,16 @@ build_flags = ${stm32_variant.build_flags} # STM32F401RC # [env:FYSETC_CHEETAH_V20] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_FYSETC_CHEETAH_V20 board_build.offset = 0x8000 build_flags = ${stm32_variant.build_flags} -DSTM32F401xC +upload_command = dfu-util -a 0 -s 0x08008000:leave -D "$SOURCE" # # FLYF407ZG # [env:FLYF407ZG] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STM32F407ZGT6 board_build.variant = MARLIN_FLY_F407ZG @@ -66,7 +63,6 @@ upload_protocol = dfu # FYSETC S6 (STM32F446RET6 ARM Cortex-M4) # [env:FYSETC_S6] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_fysetc_s6 board_build.offset = 0x10000 @@ -80,7 +76,6 @@ upload_command = dfu-util -a 0 -s 0x08010000:leave -D "$SOURCE" # FYSETC S6 new bootloader # [env:FYSETC_S6_8000] -platform = ${common_stm32.platform} extends = env:FYSETC_S6 board = marlin_fysetc_s6 board_build.offset = 0x8000 @@ -93,7 +88,6 @@ upload_command = dfu-util -a 0 -s 0x08008000:leave -D "$SOURCE" # Shield - https://github.com/jmz52/Hardware # [env:STM32F407VE_black] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_blackSTM32F407VET6 build_flags = ${stm32_variant.build_flags} @@ -103,7 +97,6 @@ build_flags = ${stm32_variant.build_flags} # STM32F407VET6 Index Mobo Rev 03 # [env:Index_Mobo_Rev03] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_index_mobo_rev03 build_flags = ${stm32_variant.build_flags} @@ -117,7 +110,6 @@ extra_scripts = ${stm32_variant.extra_scripts} # Comment out board_build.offset = 0x10000 if you don't plan to use OpenBLT/flashing directly to 0x08000000. # [env:Anet_ET4_OpenBLT] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STM32F407VGT6_CCM board_build.variant = MARLIN_F4x7Vx @@ -137,7 +129,6 @@ upload_protocol = jlink # BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) # [env:BIGTREE_SKR_PRO] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_BigTree_SKR_Pro board_build.offset = 0x8000 @@ -149,7 +140,6 @@ upload_protocol = stlink # BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) with USB Flash Drive Support # [env:BIGTREE_SKR_PRO_usb_flash_drive] -platform = ${common_stm32.platform} extends = env:BIGTREE_SKR_PRO platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${stm_flash_drive.build_flags} -DSTM32F407_5ZX @@ -159,7 +149,6 @@ build_unflags = ${env:BIGTREE_SKR_PRO.build_unflags} -DUSBCON -DUSBD_USE_CDC # BigTreeTech E3 RRF (STM32F407VGT6 ARM Cortex-M4) # [env:BIGTREE_E3_RRF] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STM32F407VGT6_CCM board_build.variant = MARLIN_BIGTREE_E3_RRF @@ -173,7 +162,6 @@ build_flags = ${stm32_variant.build_flags} # Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4) # [env:BIGTREE_GTR_V1_0] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_BigTree_GTR_v1 board_build.offset = 0x8000 @@ -183,7 +171,6 @@ build_flags = ${stm32_variant.build_flags} -DSTM32F407IX # Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4) with USB Flash Drive Support # [env:BIGTREE_GTR_V1_0_usb_flash_drive] -platform = ${common_stm32.platform} extends = env:BIGTREE_GTR_V1_0 platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${stm_flash_drive.build_flags} -DSTM32F407IX @@ -193,7 +180,6 @@ build_unflags = ${env:BIGTREE_GTR_V1_0.build_unflags} -DUSBCON -DUSBD_USE_CD # BigTreeTech BTT002 V1.0 (STM32F407VGT6 ARM Cortex-M4) # [env:BIGTREE_BTT002] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_BigTree_BTT002 board_build.offset = 0x8000 @@ -208,7 +194,6 @@ build_flags = ${stm32_variant.build_flags} # BigTreeTech BTT002 V1.x with 512k of flash (STM32F407VET6 ARM Cortex-M4) # [env:BIGTREE_BTT002_VET6] -platform = ${env:BIGTREE_BTT002.platform} extends = env:BIGTREE_BTT002 board = marlin_BigTree_BTT002_VET6 @@ -216,7 +201,6 @@ board = marlin_BigTree_BTT002_VET6 # BigTreeTech SKR V2.0 (STM32F407VGT6 ARM Cortex-M4) with USB Flash Drive Support # [env:BIGTREE_SKR_2] -platform = ${common_stm32.platform} extends = stm32_variant platform_packages = ${stm_flash_drive.platform_packages} board = marlin_STM32F407VGT6_CCM @@ -234,13 +218,11 @@ upload_protocol = stlink # BigTreeTech SKR V2.0 (STM32F407VGT6 ARM Cortex-M4) with USB Media Share Support # [env:BIGTREE_SKR_2_USB] -platform = ${common_stm32.platform} extends = env:BIGTREE_SKR_2 build_flags = ${env:BIGTREE_SKR_2.build_flags} -DUSBD_USE_CDC_MSC build_unflags = ${env:BIGTREE_SKR_2.build_unflags} -DUSBD_USE_CDC [env:BIGTREE_SKR_2_USB_debug] -platform = ${common_stm32.platform} extends = env:BIGTREE_SKR_2_USB build_flags = ${env:BIGTREE_SKR_2_USB.build_flags} -O0 build_unflags = ${env:BIGTREE_SKR_2_USB.build_unflags} -Os -NDEBUG @@ -249,31 +231,18 @@ build_unflags = ${env:BIGTREE_SKR_2_USB.build_unflags} -Os -NDEBUG # Bigtreetech SKR V2.0 F429 (STM32F429VGT6 ARM Cortex-M4) with USB Flash Drive Support # [env:BIGTREE_SKR_2_F429] -platform = ${common_stm32.platform} -extends = stm32_variant -platform_packages = ${stm_flash_drive.platform_packages} +extends = env:BIGTREE_SKR_2 board = marlin_STM32F429VGT6 -board_build.variant = MARLIN_F4x7Vx -board_build.offset = 0x8000 -board_upload.offset_address = 0x08008000 -build_flags = ${stm_flash_drive.build_flags} - -DUSE_USBHOST_HS -DUSE_USB_HS_IN_FS - -DUSBD_IRQ_PRIO=5 -DUSBD_IRQ_SUBPRIO=6 - -DHSE_VALUE=8000000U -DHAL_SD_MODULE_ENABLED - -DPIN_SERIAL3_RX=PD_9 -DPIN_SERIAL3_TX=PD_8 -upload_protocol = stlink # # BigTreeTech SKR V2.0 F429 (STM32F429VGT6 ARM Cortex-M4) with USB Media Share Support # [env:BIGTREE_SKR_2_F429_USB] -platform = ${common_stm32.platform} extends = env:BIGTREE_SKR_2_F429 build_flags = ${env:BIGTREE_SKR_2_F429.build_flags} -DUSBD_USE_CDC_MSC build_unflags = ${env:BIGTREE_SKR_2_F429.build_unflags} -DUSBD_USE_CDC [env:BIGTREE_SKR_2_F429_USB_debug] -platform = ${common_stm32.platform} extends = env:BIGTREE_SKR_2_F429_USB build_flags = ${env:BIGTREE_SKR_2_F429_USB.build_flags} -O0 build_unflags = ${env:BIGTREE_SKR_2_F429_USB.build_unflags} -Os -NDEBUG @@ -282,18 +251,19 @@ build_unflags = ${env:BIGTREE_SKR_2_F429_USB.build_unflags} -Os -NDEBUG # BigTreeTech Octopus V1.0/1.1 / Octopus Pro V1.0 (STM32F446ZET6 ARM Cortex-M4) # [env:BIGTREE_OCTOPUS_V1] -platform = ${common_stm32.platform} -extends = stm32_variant -board = marlin_BigTree_Octopus_v1 -board_build.offset = 0x8000 -build_flags = ${stm32_variant.build_flags} - -DSTM32F446_5VX -DUSE_USB_HS_IN_FS +extends = stm32_variant +board = marlin_BigTree_Octopus_v1 +board_build.offset = 0x8000 +board_upload.offset_address = 0x08008000 +debug_tool = stlink +upload_protocol = stlink +build_flags = ${stm32_variant.build_flags} + -DSTM32F446_5VX -DUSE_USB_HS_IN_FS # # BigTreeTech Octopus V1.0/1.1 / Octopus Pro V1.0 (STM32F446ZET6 ARM Cortex-M4) with USB Flash Drive Support # [env:BIGTREE_OCTOPUS_V1_USB] -platform = ${common_stm32.platform} extends = env:BIGTREE_OCTOPUS_V1 platform_packages = ${stm_flash_drive.platform_packages} build_unflags = -DUSBD_USE_CDC @@ -307,32 +277,31 @@ build_flags = ${stm_flash_drive.build_flags} # BigTreeTech Octopus Pro V1.0 (STM32F429ZGT6 ARM Cortex-M4) # [env:BIGTREE_OCTOPUS_PRO_V1_F429] -platform = ${common_stm32.platform} -extends = stm32_variant -board = marlin_BigTree_Octopus_Pro_v1_F429 -board_build.offset = 0x8000 -build_flags = ${stm32_variant.build_flags} - -DUSE_USB_HS_IN_FS +extends = stm32_variant +board = marlin_BigTree_Octopus_Pro_v1_F429 +board_build.offset = 0x8000 +board_upload.offset_address = 0x08008000 +debug_tool = stlink +upload_protocol = stlink +build_flags = ${stm32_variant.build_flags} + -DUSE_USB_HS_IN_FS # # BigTreeTech Octopus Pro V1.0 (STM32F429ZGT6 ARM Cortex-M4) with USB Flash Drive Support # [env:BIGTREE_OCTOPUS_PRO_V1_F429_USB] -platform = ${common_stm32.platform} extends = env:BIGTREE_OCTOPUS_PRO_V1_F429 platform_packages = ${stm_flash_drive.platform_packages} build_unflags = -DUSBD_USE_CDC build_flags = ${stm_flash_drive.build_flags} - -DSTM32F446_5VX -DUSE_USB_HS_IN_FS - -DUSE_USBHOST_HS -DUSBD_IRQ_PRIO=5 - -DUSBD_IRQ_SUBPRIO=6 + -DUSE_USB_HS_IN_FS -DUSE_USBHOST_HS + -DUSBD_IRQ_PRIO=5 -DUSBD_IRQ_SUBPRIO=6 -DUSBD_USE_CDC_MSC # # Lerdge base # [lerdge_common] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STM32F407ZGT6 board_build.variant = MARLIN_LERDGE @@ -349,7 +318,6 @@ extra_scripts = ${common_stm32.extra_scripts} # Lerdge X (STM32F407VE) # [env:LERDGEX] -platform = ${lerdge_common.platform} extends = lerdge_common board_build.encrypt = Lerdge_X_firmware_force.bin @@ -357,7 +325,6 @@ board_build.encrypt = Lerdge_X_firmware_force.bin # Lerdge X with USB Flash Drive Support # [env:LERDGEX_usb_flash_drive] -platform = ${env:LERDGEX.platform} extends = env:LERDGEX platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} @@ -366,7 +333,6 @@ build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} # Lerdge S (STM32F407ZG) # [env:LERDGES] -platform = ${lerdge_common.platform} extends = lerdge_common board_build.encrypt = Lerdge_firmware_force.bin @@ -374,7 +340,6 @@ board_build.encrypt = Lerdge_firmware_force.bin # Lerdge S with USB Flash Drive Support # [env:LERDGES_usb_flash_drive] -platform = ${env:LERDGES.platform} extends = env:LERDGES platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} @@ -383,7 +348,6 @@ build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} # Lerdge K (STM32F407ZG) # [env:LERDGEK] -platform = ${lerdge_common.platform} extends = lerdge_common board_build.encrypt = Lerdge_K_firmware_force.bin build_flags = ${lerdge_common.build_flags} -DLERDGEK @@ -392,7 +356,6 @@ build_flags = ${lerdge_common.build_flags} -DLERDGEK # Lerdge K with USB Flash Drive Support # [env:LERDGEK_usb_flash_drive] -platform = ${env:LERDGEK.platform} extends = env:LERDGEK platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} @@ -401,7 +364,6 @@ build_flags = ${stm_flash_drive.build_flags} ${lerdge_common.build_flags} # RUMBA32 # [env:rumba32] -platform = ${common_stm32.platform} extends = stm32_variant board = rumba32_f446ve board_build.variant = MARLIN_F446VE @@ -418,7 +380,6 @@ upload_protocol = dfu # MKS Robin Pro V2 # [env:mks_robin_pro2] -platform = ${common_stm32.platform} extends = stm32_variant platform_packages = ${stm_flash_drive.platform_packages} board = genericSTM32F407VET6 @@ -440,7 +401,6 @@ build_flags = -DPIN_WIRE_SCL=PB6 -DPIN_WIRE_SDA=PB7 # MKS Robin Nano V3 # [env:mks_robin_nano_v3] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STM32F407VGT6_CCM board_build.variant = MARLIN_F4x7Vx @@ -457,7 +417,6 @@ upload_protocol = jlink # Currently, using a STM32duino fork, until USB Host get merged # [env:mks_robin_nano_v3_usb_flash_drive] -platform = ${common_stm32.platform} extends = env:mks_robin_nano_v3 platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1.build_flags} @@ -471,18 +430,39 @@ build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1.build_flags} # Currently, using a STM32duino fork, until USB Host and USB Device MSC get merged # [env:mks_robin_nano_v3_usb_flash_drive_msc] -platform = ${common_stm32.platform} extends = env:mks_robin_nano_v3_usb_flash_drive build_flags = ${env:mks_robin_nano_v3_usb_flash_drive.build_flags} -DUSBD_USE_CDC_MSC build_unflags = -DUSBD_USE_CDC +# +# MKS Robin Nano V3_1 +# +[env:mks_robin_nano_v3_1] +extends = env:mks_robin_nano_v3 +board = marlin_STM32F407VET6_CCM + +# +# MKS Robin Nano V3.1 with USB Flash Drive Support +# Currently, using a STM32duino fork, until USB Host get merged +# +[env:mks_robin_nano_v3_1_usb_flash_drive] +extends = env:mks_robin_nano_v3_usb_flash_drive +board = marlin_STM32F407VET6_CCM + +# +# MKS Robin Nano V3.1 with USB Flash Drive Support and Shared Media +# Currently, using a STM32duino fork, until USB Host and USB Device MSC get merged +# +[env:mks_robin_nano_v3_1_usb_flash_drive_msc] +extends = env:mks_robin_nano_v3_usb_flash_drive_msc +board = marlin_STM32F407VET6_CCM + # # MKS Eagle # 5 TMC2209 uart mode on board # [env:mks_eagle] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STM32F407VGT6_CCM board_build.variant = MARLIN_F4x7Vx @@ -500,7 +480,6 @@ upload_protocol = jlink # Currently, using a STM32duino fork, until USB Host get merged # [env:mks_eagle_usb_flash_drive] -platform = ${common_stm32.platform} extends = env:mks_eagle platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1.build_flags} @@ -514,7 +493,6 @@ build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1.build_flags} # Currently, using a STM32duino fork, until USB Host and USB Device MSC get merged # [env:mks_eagle_usb_flash_drive_msc] -platform = ${common_stm32.platform} extends = env:mks_eagle_usb_flash_drive build_flags = ${env:mks_eagle_usb_flash_drive.build_flags} -DUSBD_USE_CDC_MSC @@ -530,7 +508,6 @@ build_flags = -DPIN_WIRE_SCL=PB8 -DPIN_WIRE_SDA=PB9 # MKS Monster8 # [env:mks_monster8] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STM32F407VGT6_CCM board_build.variant = MARLIN_F4x7Vx @@ -548,7 +525,6 @@ upload_protocol = jlink # Currently, using a STM32duino fork, until USB Host get merged # [env:mks_monster8_usb_flash_drive] -platform = ${common_stm32.platform} extends = env:mks_monster8 platform_packages = ${stm_flash_drive.platform_packages} build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1_CAN.build_flags} @@ -562,7 +538,6 @@ build_flags = ${stm_flash_drive.build_flags} ${stm32f4_I2C1_CAN.build_flag # Currently, using a STM32duino fork, until USB Host and USB Device MSC get merged # [env:mks_monster8_usb_flash_drive_msc] -platform = ${common_stm32.platform} extends = env:mks_monster8_usb_flash_drive build_flags = ${env:mks_monster8_usb_flash_drive.build_flags} -DUSBD_USE_CDC_MSC @@ -572,15 +547,17 @@ build_unflags = -DUSBD_USE_CDC # TH3D EZBoard v2.0 (STM32F405RGT6 ARM Cortex-M4) # [env:TH3D_EZBoard_V2] -platform = ${common_stm32.platform} extends = stm32_variant board = genericSTM32F405RG board_build.variant = MARLIN_TH3D_EZBOARD_V2 +board_build.encrypt = firmware.bin board_build.offset = 0xC000 board_upload.offset_address = 0x0800C000 build_flags = ${stm32_variant.build_flags} -DHSE_VALUE=12000000U -O0 debug_tool = stlink upload_protocol = stlink +extra_scripts = ${stm32_variant.extra_scripts} + buildroot/share/PlatformIO/scripts/openblt.py # # BOARD_MKS_ROBIN_NANO_V1_3_F4 @@ -588,7 +565,6 @@ upload_protocol = stlink # - MKS Robin Nano-S V1.3 (STM32F407VET6) 4 TMC2225 + 1 Pololu Plug # [env:mks_robin_nano_v1_3_f4] -platform = ${common_stm32.platform} extends = stm32_variant board = marlin_STM32F407VGT6_CCM board_build.variant = MARLIN_F4x7Vx @@ -610,12 +586,39 @@ upload_protocol = jlink # Artillery Ruby # [env:Artillery_Ruby] -platform = ${common_stm32.platform} extends = common_stm32 board = marlin_Artillery_Ruby build_flags = ${common_stm32.build_flags} -DSTM32F401xC -DTARGET_STM32F4 -DDISABLE_GENERIC_SERIALUSB -DARDUINO_ARCH_STM32 -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS -DUSB_PRODUCT=\"Artillery_3D_Printer\" + -DFLASH_DATA_SECTOR=1U -DFLASH_BASE_ADDRESS=0x08004000 extra_scripts = ${common_stm32.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py + +# +# Ender-3 S1 STM32F401RC_creality +# +[env:STM32F401RC_creality] +extends = stm32_variant +board = genericSTM32F401RC +board_build.variant = MARLIN_CREALITY_STM32F401RC +board_build.offset = 0x10000 +board_upload.offset_address = 0x08010000 +build_flags = ${stm32_variant.build_flags} -DMCU_STM32F401RC -DSTM32F4 + -DSS_TIMER=4 -DTIMER_SERVO=TIM5 + -DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8 +build_unflags = ${stm32_variant.build_unflags} -DUSBCON -DUSBD_USE_CDC +extra_scripts = ${stm32_variant.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/random-bin.py +monitor_speed = 115200 + +[env:STM32F401RC_creality_jlink] +extends = env:STM32F401RC_creality +debug_tool = jlink +upload_protocol = jlink + +[env:STM32F401RC_creality_stlink] +extends = env:STM32F401RC_creality +debug_tool = stlink +upload_protocol = stlink diff --git a/ini/stm32f7.ini b/ini/stm32f7.ini index 200740589b1a..62755c846d47 100644 --- a/ini/stm32f7.ini +++ b/ini/stm32f7.ini @@ -25,7 +25,6 @@ # being readily available based on STM32F7 MCUs # [env:NUCLEO_F767ZI] -platform = ${common_stm32.platform} extends = common_stm32 board = nucleo_f767zi build_flags = ${common_stm32.build_flags} -DTIMER_SERIAL=TIM9 @@ -34,6 +33,5 @@ build_flags = ${common_stm32.build_flags} -DTIMER_SERIAL=TIM9 # REMRAM_V1 # [env:REMRAM_V1] -platform = ${common_stm32.platform} extends = common_stm32 board = remram_v1 diff --git a/ini/stm32g0.ini b/ini/stm32g0.ini index 99f167a4df32..e6094c1e312d 100644 --- a/ini/stm32g0.ini +++ b/ini/stm32g0.ini @@ -23,17 +23,16 @@ # BigTree SKR mini E3 V3.0 (STM32G0B1RET6 ARM Cortex-M0+) # [env:STM32G0B1RE_btt] -platform = ststm32@~14.1.0 -platform_packages = framework-arduinoststm32@https://github.com/stm32duino/Arduino_Core_STM32/archive/main.zip -extends = stm32_variant -board = marlin_STM32G0B1RE +extends = stm32_variant +platform = ststm32@~14.1.0 +platform_packages = framework-arduinoststm32@https://github.com/stm32duino/Arduino_Core_STM32/archive/main.zip +board = marlin_STM32G0B1RE board_build.offset = 0x2000 board_upload.offset_address = 0x08002000 -build_flags = ${stm32_variant.build_flags} - -DADC_RESOLUTION=12 - -DPIN_SERIAL4_RX=PC_11 -DPIN_SERIAL4_TX=PC_10 - -DSERIAL_RX_BUFFER_SIZE=1024 -DSERIAL_TX_BUFFER_SIZE=1024 - -DTIMER_SERVO=TIM3 -DTIMER_TONE=TIM4 - -DSTEP_TIMER_IRQ_PRIO=0 -upload_protocol = stlink -debug_tool = stlink +build_flags = ${stm32_variant.build_flags} + -DPIN_SERIAL4_RX=PC_11 -DPIN_SERIAL4_TX=PC_10 + -DSERIAL_RX_BUFFER_SIZE=1024 -DSERIAL_TX_BUFFER_SIZE=1024 + -DTIMER_SERVO=TIM3 -DTIMER_TONE=TIM4 + -DSTEP_TIMER_IRQ_PRIO=0 +upload_protocol = stlink +debug_tool = stlink diff --git a/ini/stm32h7.ini b/ini/stm32h7.ini index 16d1067e52c9..c5d7d6299a1e 100644 --- a/ini/stm32h7.ini +++ b/ini/stm32h7.ini @@ -23,7 +23,6 @@ # BigTreeTech SKR SE BX (STM32H743IIT6 ARM Cortex-M7) # [env:BTT_SKR_SE_BX] -platform = ${common_stm32.platform} extends = stm32_variant platform_packages = framework-arduinoststm32@https://github.com/thisiskeithb/Arduino_Core_STM32/archive/biqu-bx-workaround.zip board = marlin_BTT_SKR_SE_BX @@ -39,3 +38,24 @@ build_flags = ${stm32_variant.build_flags} ${stm_flash_drive.build_flags} -DHAL_SD_MODULE_ENABLED upload_protocol = cmsis-dap debug_tool = cmsis-dap + +# +# BigTreeTech SKR V3.0 / V3.0 EZ (STM32H743VIT6 ARM Cortex-M7) +# +[env:STM32H743Vx_btt] +extends = stm32_variant +platform = ststm32@~14.1.0 +platform_packages = framework-arduinoststm32@https://github.com/stm32duino/Arduino_Core_STM32/archive/main.zip +board = marlin_STM32H743Vx +board_build.offset = 0x20000 +board_upload.offset_address = 0x08020000 +build_flags = ${stm32_variant.build_flags} + -DPIN_SERIAL1_RX=PA_10 -DPIN_SERIAL1_TX=PA_9 + -DPIN_SERIAL3_RX=PD_9 -DPIN_SERIAL3_TX=PD_8 + -DPIN_SERIAL4_RX=PA_1 -DPIN_SERIAL4_TX=PA_0 + -DSERIAL_RX_BUFFER_SIZE=1024 -DSERIAL_TX_BUFFER_SIZE=1024 + -DTIMER_SERVO=TIM5 -DTIMER_TONE=TIM2 + -DSTEP_TIMER_IRQ_PRIO=0 + -DD_CACHE_DISABLED +upload_protocol = cmsis-dap +debug_tool = cmsis-dap diff --git a/ini/teensy.ini b/ini/teensy.ini index ef1ad766bcbb..dac4b40c3053 100644 --- a/ini/teensy.ini +++ b/ini/teensy.ini @@ -9,43 +9,72 @@ # # ################################# +# +# Teensy AVR +# +[teensy_avr] +platform = teensy +platform_packages = toolchain-atmelavr@~1.70300.0 +extends = common_avr8 +lib_ignore = ${env:common_avr8.lib_ignore}, NativeEthernet + +# +# AT90USB1286 boards using CDC bootloader +# e.g., BRAINWAVE, BRAINWAVE_PRO, SAV_MKI, TEENSYLU +# +[env:at90usb1286_cdc] +extends = teensy_avr +board = marlin_at90usb1286 +lib_ignore = ${teensy_avr.lib_ignore}, Teensy_ADC + +# +# AT90USB1286 boards using DFU bootloader +# e.g., Printrboard, Printrboard Rev.F, 5DPRINT +# +[env:at90usb1286_dfu] +extends = env:at90usb1286_cdc + # # Teensy++ 2.0 # [env:teensy20] -platform = teensy -extends = common_avr8 -board = teensy2pp -lib_ignore = ${env:common_avr8.lib_ignore}, NativeEthernet +extends = teensy_avr +board = teensy2pp + +# +# Teensy 3.x - 4.x +# +[teensy_arm] +platform = teensy@~4.12.0 +build_src_filter = ${common.default_src_filter} +lib_ignore = NativeEthernet # # Teensy 3.1 / 3.2 (ARM Cortex-M4) # [env:teensy31] -platform = teensy@~4.12.0 -board = teensy31 -src_filter = ${common.default_src_filter} + -lib_ignore = NativeEthernet +extends = teensy_arm +board = teensy31 +build_src_filter = ${teensy_arm.build_src_filter} + # # Teensy 3.5 / 3.6 (ARM Cortex-M4) # [env:teensy35] -platform = teensy@~4.12.0 -board = teensy35 -src_filter = ${common.default_src_filter} + -lib_ignore = NativeEthernet +extends = teensy_arm +board = teensy35 +build_src_filter = ${teensy_arm.build_src_filter} + [env:teensy36] -platform = teensy@~4.12.0 -board = teensy36 -src_filter = ${common.default_src_filter} + -lib_ignore = NativeEthernet +extends = teensy_arm +board = teensy36 +build_src_filter = ${teensy_arm.build_src_filter} + # # Teensy 4.0 / 4.1 (ARM Cortex-M7) # [env:teensy41] -platform = teensy@~4.12.0 -board = teensy41 -src_filter = ${common.default_src_filter} + +extends = teensy_arm +board = teensy41 +build_src_filter = ${teensy_arm.build_src_filter} + +lib_ignore = diff --git a/platformio.ini b/platformio.ini index 74ac012f1976..ae50293e3f2b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -32,6 +32,7 @@ extra_configs = ini/stm32h7.ini ini/stm32g0.ini ini/teensy.ini + ini/renamed.ini # # The 'common' section applies to most Marlin builds. @@ -51,7 +52,7 @@ lib_deps = default_src_filter = + - - + - - - - - - - - - - - - - + - - - - - - - - - - - @@ -95,11 +96,11 @@ default_src_filter = + - - + - - - - + - - - - - - - - - - - - - - @@ -150,6 +151,7 @@ default_src_filter = + - - + - - - - + - - - - - @@ -204,6 +206,7 @@ default_src_filter = + - - + - - - + - - - - @@ -213,11 +216,11 @@ default_src_filter = + - - + - - - + - - - - - + - - - - - - - - - - @@ -237,6 +240,7 @@ default_src_filter = + - - + - - - + - - - - @@ -278,7 +282,7 @@ monitor_flags = # Just print the dependency tree # [env:include_tree] -platform = atmelavr -board = megaatmega2560 -build_flags = -c -H -std=gnu++11 -Wall -Os -D__MARLIN_FIRMWARE__ -src_filter = + +platform = atmelavr +board = megaatmega2560 +build_flags = -c -H -std=gnu++11 -Wall -Os -D__MARLIN_FIRMWARE__ +build_src_filter = +