Compare commits

..

2 Commits

Author SHA1 Message Date
Scott Lahteine 515a06d4b8 tweak style 2024-04-18 17:44:39 -05:00
InsanityAutomation 812da8d902 Fix Duplicated Temp Report 2024-04-08 09:41:38 -04:00
272 changed files with 1275 additions and 19732 deletions
-73
View File
@@ -1,73 +0,0 @@
#
# ci-unit-tests.yml
# Build and execute unit tests to catch functional issues in code
#
name: CI - Unit Tests
on:
pull_request:
branches:
- bugfix-2.1.x
# Cannot be enabled on 2.1.x until it contains the unit test framework
#- 2.1.x
paths-ignore:
- config/**
- data/**
- docs/**
- '**/*.md'
push:
branches:
- bugfix-2.1.x
# Cannot be enabled on 2.1.x until it contains the unit test framework
#- 2.1.x
paths-ignore:
- config/**
- data/**
- docs/**
- '**/*.md'
jobs:
# This runs all unit tests as a single job. While it should be possible to break this up into
# multiple jobs, they currently run quickly and finish long before the compilation tests.
run_unit_tests:
name: Unit Test
# These tests will only be able to run on the bugfix-2.1.x branch, until the next release
# pulls them into additional branches.
if: github.repository == 'MarlinFirmware/Marlin'
runs-on: ubuntu-latest
steps:
- name: Check out the PR
uses: actions/checkout@v4
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v4
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
- name: Select Python 3.9
uses: actions/setup-python@v5
with:
python-version: '3.9'
architecture: 'x64'
- name: Install PlatformIO
run: |
pip install -U platformio
pio upgrade --dev
pio pkg update --global
- name: Run All Unit Tests
run: |
make unit-test-all-local
@@ -1,9 +1,9 @@
#
# ci-build-tests.yml
# test-builds.yml
# Do test builds to catch compile errors
#
name: CI - Build Tests
name: CI
on:
pull_request:
@@ -27,7 +27,7 @@ on:
jobs:
test_builds:
name: Build Test
name: Run All Tests
if: github.repository == 'MarlinFirmware/Marlin'
runs-on: ubuntu-latest
+4 -30
View File
@@ -12,12 +12,7 @@ help:
@echo "make tests-single-local-docker : Run a single test locally, using docker"
@echo "make tests-all-local : Run all tests locally"
@echo "make tests-all-local-docker : Run all tests locally, using docker"
# @echo "make unit-test-single-ci : Run a single code test from inside the CI"
# @echo "make unit-test-single-local : Run a single code test locally"
# @echo "make unit-test-single-local-docker : Run a single code test locally, using docker-compose"
@echo "make unit-test-all-local : Run all code tests locally"
@echo "make unit-test-all-local-docker : Run all code tests locally, using docker-compose"
@echo "make setup-local-docker : Setup local docker-compose"
@echo "make setup-local-docker : Build the local docker image"
@echo ""
@echo "Options for testing:"
@echo " TEST_TARGET Set when running tests-single-*, to select the"
@@ -48,7 +43,7 @@ tests-single-local:
tests-single-local-docker:
@if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make tests-all-local-docker" ; return 1; fi
@if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make tests-single-local TEST_TARGET=$(TEST_TARGET) VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD) ONLY_TEST="$(ONLY_TEST)"
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) $(MAKE) tests-single-local TEST_TARGET=$(TEST_TARGET) VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD) ONLY_TEST="$(ONLY_TEST)"
tests-all-local:
export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \
@@ -57,31 +52,10 @@ tests-all-local:
tests-all-local-docker:
@if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make tests-all-local VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD)
#unit-test-single-ci:
# export GIT_RESET_HARD=true
# $(MAKE) unit-test-single-local TEST_TARGET=$(TEST_TARGET)
# TODO: How can we limit tests with ONLY_TEST with platformio?
#unit-test-single-local:
# @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make unit-test-all-local" ; return 1; fi
# platformio run -t marlin_$(TEST_TARGET)
#unit-test-single-local-docker:
# @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET=<your-module> or use make unit-test-all-local-docker" ; return 1; fi
# @if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
# $(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make unit-test-single-local TEST_TARGET=$(TEST_TARGET) ONLY_TEST="$(ONLY_TEST)"
unit-test-all-local:
platformio run -t test-marlin -e linux_native_test
unit-test-all-local-docker:
@if ! $(CONTAINER_RT_BIN) images -q $(CONTAINER_IMAGE) > /dev/null ; then $(MAKE) setup-local-docker ; fi
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) make unit-test-all-local
$(CONTAINER_RT_BIN) run $(CONTAINER_RT_OPTS) $(CONTAINER_IMAGE) $(MAKE) tests-all-local VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) GIT_RESET_HARD=$(GIT_RESET_HARD)
setup-local-docker:
$(CONTAINER_RT_BIN) buildx build -t $(CONTAINER_IMAGE) -f docker/Dockerfile .
$(CONTAINER_RT_BIN) build -t $(CONTAINER_IMAGE) -f docker/Dockerfile .
PINS := $(shell find Marlin/src/pins -mindepth 2 -name '*.h')
+322 -1848
View File
File diff suppressed because it is too large Load Diff
+213 -416
View File
File diff suppressed because it is too large Load Diff
+10 -162
View File
@@ -16,7 +16,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
@@ -28,177 +28,25 @@
/**
* Marlin release version identifier
*/
#define SHORT_BUILD_VERSION "DW7.4.9"
//#define SHORT_BUILD_VERSION "bugfix-2.1.x"
/**
* Verbose version identifier which should contain a reference to the location
* from where the binary was downloaded or the source code was compiled.
*/
#if(ENABLED(MachineMini))
#define VerChar1 "M"
#elif(ENABLED(MachineEnder2))
#define VerChar1 "E2"
#elif(ENABLED(MachineEnder2Pro))
#define VerChar1 "E2P"
#elif(ENABLED(MachineEnder3))
#define VerChar1 "E3"
#elif ENABLED(MachineEnder3V2)
#define VerChar1 "E3V2"
#elif ENABLED(MachineEnder3S1)
#define VerChar1 "E3S1"
#elif ENABLED(MachineEnder3Max)
#define VerChar1 "E3M"
#elif(ENABLED(MachineEnder4))
#define VerChar1 "E4"
#elif(ENABLED(MachineEnder5))
#define VerChar1 "E5"
#elif(ENABLED(MachineEnder6))
#define VerChar1 "E6"
#elif(ENABLED(MachineEnder7))
#define VerChar1 "E7"
#elif(ENABLED(MachineSermoonD1))
#define VerChar1 "D1"
#elif(ENABLED(MachineEnder5Plus))
#define VerChar1 "E5P"
#elif(ENABLED(MachineCR20))
#define VerChar1 "2"
#elif(ENABLED(MachineCR10Orig))
#define VerChar1 "O"
#elif(ENABLED(MachineCR10Std))
#define VerChar1 "S"
#elif(ENABLED(MachineCRX))
#define VerChar1 "X"
#elif(ENABLED(MachineCR6))
#define VerChar1 "CR6"
#elif(ENABLED(MachineCR5))
#define VerChar1 "CR5"
#elif(ENABLED(MachineCR6Max))
#define VerChar1 "CR6M"
#elif(ENABLED(MachineS4))
#define VerChar1 "4"
#elif(ENABLED(MachineS5) || ENABLED(MachineCR10Max))
#define VerChar1 "5"
#elif ENABLED(MachineCR2020)
#define VerChar1 "20"
#elif(ENABLED(MachineCR30))
#define VerChar1 "CR30"
#endif
#if(ENABLED(HotendStock))
#define VerChar2 "S"
#elif(ENABLED(HotendE3D))
#define VerChar2 "E"
#elif ENABLED(HotendMosquito)
#define VerChar2 "M"
#endif
#if(ENABLED(HotendAllMetal))
#define VerChar3 "M"
#else
#define VerChar3 "S"
#endif
#if(ENABLED(BedAC))
#define VerChar4 "A"
#elif(ENABLED(BedDC))
#define VerChar4 "D"
#else
#define VerChar4 "N"
#endif
#if(ENABLED(ABL_EZABL))
#define VerChar5 "A"
#elif(ENABLED(ABL_BLTOUCH))
#define VerChar5 "B"
#else
#define VerChar5 "N"
#endif
#if(ENABLED(ABL_UBL))
#define VerChar6 "U"
#elif(ENABLED(ABL_BI))
#define VerChar6 "B"
#else
#define VerChar6 "N"
#endif
#define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION " TM3D " VerChar1 VerChar2 VerChar3 VerChar4 VerChar5 VerChar6
//#define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION
/**
* The STRING_DISTRIBUTION_DATE represents when the binary file was built,
* here we define this default string as the date where the latest release
* version was tagged.
*/
#define STRING_DISTRIBUTION_DATE "2024-04-08"
//#define STRING_DISTRIBUTION_DATE "2024-04-08"
/**
* Defines a generic printer name to be output to the LCD after booting Marlin.
*/
#if(ENABLED(MachineMini))
#define CUSTOM_MACHINE_NAME "Mini SuPeR"
#elif(ENABLED(MachineCR10Smart))
#define CUSTOM_MACHINE_NAME "TM3D CR10Smart"
#elif(ENABLED(MachineCR10SmartPro))
#define CUSTOM_MACHINE_NAME "TM3D CR10SmartPro"
#elif(ENABLED(MachineEnder2))
#define CUSTOM_MACHINE_NAME "TM3D Ender2"
#elif(ENABLED(MachineEnder2Pro))
#define CUSTOM_MACHINE_NAME "TM3D Ender2 Pro"
#elif(ENABLED(MachineEnder3))
#define CUSTOM_MACHINE_NAME "TM3D Ender3"
#elif(ENABLED(MachineEnder3Max))
#define CUSTOM_MACHINE_NAME "TM3D E3Max"
#elif(ENABLED(MachineEnder6))
#define CUSTOM_MACHINE_NAME "TM3D Ender6"
#elif(ENABLED(MachineEnder7))
#define CUSTOM_MACHINE_NAME "TM3D Ender7"
#elif(ENABLED(MachineEnder3V2))
#define CUSTOM_MACHINE_NAME "TM3D Ender3V2"
#elif(ENABLED(MachineEnder3S1))
#define CUSTOM_MACHINE_NAME "TM3D Ender3S1"
#elif(ENABLED(MachineEnder4))
#define CUSTOM_MACHINE_NAME "TM3D Ender4"
#elif(ENABLED(MachineEnder5))
#define CUSTOM_MACHINE_NAME "TM3D Ender5"
#elif(ENABLED(MachineEnder5Plus))
#define CUSTOM_MACHINE_NAME "TM3D E5 Plus"
#elif(ENABLED(MachineCR20))
#define CUSTOM_MACHINE_NAME "SuPeR CR-20"
#elif(ENABLED(MachineCR10Orig))
#define CUSTOM_MACHINE_NAME "SuPeR CR-10"
#elif(ENABLED(MachineCRX))
#define CUSTOM_MACHINE_NAME "TM3D CR-X"
#elif ENABLED(MachineCR10SProV2)
#define CUSTOM_MACHINE_NAME "TM3D 10SProV2"
#elif(ENABLED(MachineCR10SPro))
#define CUSTOM_MACHINE_NAME "TM3D 10S Pro"
#elif(ENABLED(MachineCR10Max))
#define CUSTOM_MACHINE_NAME "TM3D Max"
#elif(ENABLED(MachineCR10SV3))
#define CUSTOM_MACHINE_NAME "TM3D CR10V3"
#elif(ENABLED(MachineCR10SV2))
#define CUSTOM_MACHINE_NAME "TM3D CR10V2"
#elif(ENABLED(MachineCR10Std))
#define CUSTOM_MACHINE_NAME "300 SuPeR"
#elif(ENABLED(MachineS4))
#define CUSTOM_MACHINE_NAME "400 SuPeR"
#elif(ENABLED(MachineS5))
#define CUSTOM_MACHINE_NAME "500 SuPeR"
#elif ENABLED(MachineCR2020)
#define CUSTOM_MACHINE_NAME "TM3D 2020"
#elif ENABLED(MachineSermoonD1)
#define CUSTOM_MACHINE_NAME "SermoonD1"
#elif ENABLED(MachineCR5)
#define CUSTOM_MACHINE_NAME "CR5 Pro"
#elif ENABLED(MachineCR6)
#define CUSTOM_MACHINE_NAME "CR6"
#elif ENABLED(MachineCR6Max)
#define CUSTOM_MACHINE_NAME "CR6 Max"
#elif ENABLED(MachineCR30)
#define CUSTOM_MACHINE_NAME "CR30 Printmill"
#endif
//#define MACHINE_NAME "3D Printer"
/**
* The SOURCE_CODE_URL is the location where users will find the Marlin Source
@@ -206,7 +54,7 @@
* has a distinct Github fork— the Source Code URL should just be the main
* Marlin repository.
*/
#define SOURCE_CODE_URL "https://github.com/InsanityAutomation/Marlin/tree/CrealityDwin_2.0"
//#define SOURCE_CODE_URL "github.com/MarlinFirmware/Marlin"
/**
* Default generic printer UUID.
@@ -217,12 +65,12 @@
* The WEBSITE_URL is the location where users can get more information such as
* documentation about a specific Marlin release.
*/
#define WEBSITE_URL "tinymachines3d.com"
//#define WEBSITE_URL "marlinfw.org"
/**
* Set the vendor info the serial USB interface, if changable
* Currently only supported by DUE platform
*/
//#define USB_DEVICE_VENDOR_ID 0x0000
//#define USB_DEVICE_PRODUCT_ID 0x0000
//#define USB_DEVICE_MANUFACTURE_NAME WEBSITE_URL
//#define USB_DEVICE_VENDOR_ID 0x0000
//#define USB_DEVICE_PRODUCT_ID 0x0000
//#define USB_DEVICE_MANUFACTURE_NAME WEBSITE_URL
-93
View File
@@ -1,93 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
*
*/
/**
* Custom Bitmap for splashscreen
*
* You may use one of the following tools to generate the C++ bitmap array from
* a black and white image:
*
* - http://www.marlinfw.org/tools/u8glib/converter.html
* - http://www.digole.com/tools/PicturetoC_Hex_converter.php
*/
#define CUSTOM_BOOTSCREEN_TIMEOUT 2500
#define CUSTOM_BOOTSCREEN_BMPWIDTH 128
#define CUSTOM_BOOTSCREEN_INVERTED
const unsigned char custom_start_bmp[] PROGMEM = {
B11111101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,B11111111,B11111111,B11111111,
B11111110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,B11111111,B11111111,B11111111,
B11111100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,
B11111100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
B11111110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000101,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,
B11111100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000110,B00000111,B11000000,B00000000,B00000001,B11110000,B00111111,
B11111110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000100,B00001010,B00100000,B00000000,B00000010,B00001000,B00011111,
B11111100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000110,B00010100,B00010000,B00000000,B00000101,B00000100,B00111111,
B11111110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000100,B00101000,B00001000,B00000000,B00001010,B00000010,B00011111,
B11111100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000110,B01010100,B00000100,B00000000,B00010101,B00000001,B00111111,
B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B01100000,B00000100,B00000000,B00011000,B00000001,B00011111,
B11111100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101110,B01010000,B00000100,B00000000,B00010100,B00000001,B00111111,
B11111110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010100,B01100000,B00000100,B00000000,B00011000,B00000001,B00011111,
B11111100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100110,B01010100,B00000100,B00011100,B00010101,B00000001,B00111111,
B11111110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010100,B00101000,B00001000,B00101010,B00001010,B00000010,B00011111,
B11111100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101110,B00010100,B00010000,B01010001,B00000101,B00000100,B00111111,
B11111110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00001010,B00100000,B01100001,B00000010,B10001000,B00011111,
B11111100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000110,B00000111,B11000000,B01010001,B00000001,B11110000,B00111111,
B11111110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000100,B00000000,B00000000,B00101010,B00000000,B00000000,B00011111,
B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111110,B00000000,B00000000,B00011100,B00000000,B00000000,B00111111,
B11111110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010100,B00000000,B00000000,B00000000,B00000000,B00000000,B00011111,
B11111100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000100,B11111111,B11111111,B11111111,B11111111,B11111111,B10011111,
B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000110,B11010101,B01010101,B01010101,B01010101,B01010101,B10111111,
B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000110,B11000100,B00010000,B01000001,B00000100,B00010001,B10111111,
B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000100,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010110,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111100,B11000100,B00010000,B01000001,B00000100,B00010001,B10111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000110,B10000100,B00010000,B01000001,B00000100,B00010000,B10011111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010100,B11010101,B01010101,B01010101,B01010101,B01010101,B10111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111100,B11111111,B11111111,B11111111,B11111111,B11111111,B10011111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111110,B00000000,B00000000,B00000000,B00000000,B00000000,B00111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111101,B01010101,B01010101,B01010101,B01010101,B01010101,B01011111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,
B11100000,B00101110,B11111011,B01111101,B11111011,B11111011,B11001111,B11000001,B11011111,B10111011,B00111110,B11000000,B11100001,B11111110,B00111100,B00011111,
B11111101,B11101110,B01111011,B00111001,B11111001,B11110011,B11001111,B10011110,B11011111,B10111011,B00111110,B11011111,B11011110,B11111100,B11011101,B11100111,
B11111101,B11101110,B00111011,B10111011,B11111001,B11101011,B11010111,B10111111,B01011111,B10111011,B01011110,B11011111,B11011110,B11111101,B11101101,B11110111,
B11111101,B11101110,B10111011,B11010011,B11111010,B11101011,B10110111,B00111111,B11011111,B10111011,B01001110,B11011111,B11011111,B11111111,B11001101,B11110011,
B11111101,B11101110,B11011011,B11000111,B11111010,B11101011,B10111011,B01111111,B11000000,B00111011,B01101110,B11000000,B11100011,B11111111,B00011101,B11110011,
B11111101,B11101110,B11001011,B11101111,B11111010,B11011011,B10111011,B01111111,B11011111,B10111011,B01100110,B11011111,B11111000,B11111111,B11001101,B11110011,
B11111101,B11101110,B11101011,B11101111,B11111011,B01011011,B00000011,B00111111,B01011111,B10111011,B01110110,B11011111,B11111110,B01111111,B11101101,B11110011,
B11111101,B11101110,B11110011,B11101111,B11111011,B01011011,B01111001,B10111110,B11011111,B10111011,B01111010,B11011111,B11011110,B01111101,B11101101,B11110111,
B11111101,B11101110,B11110011,B11101111,B11111011,B10111010,B11111101,B10011110,B11011111,B10111011,B01111100,B11011111,B11011110,B11111101,B11001101,B11100111,
B11111101,B11101110,B11111011,B11101111,B11111011,B10111010,B11111101,B11000001,B11011111,B10111011,B01111110,B11000000,B11100000,B11111110,B00011100,B00011111
};
-74
View File
@@ -1,74 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
*
*/
/**
* Custom Status Screen bitmap
*
* Place this file in the root with your configuration files
* and enable CUSTOM_STATUS_SCREEN_IMAGE in Configuration.h.
*
* Use the Marlin Bitmap Converter to make your own:
* http://marlinfw.org/tools/u8glib/converter.html
*/
//
// Status Screen Logo bitmap
//
#define STATUS_LOGO_Y 3
#define STATUS_LOGO_WIDTH 24
const unsigned char status_logo_bmp[] PROGMEM = {
B11111111,B11111111,B11111111,
B10000000,B00000000,B00000001,
B10001110,B00000000,B11100001,
B10011111,B00000001,B11110001,
B10010011,B10000001,B00111001,
B10011111,B10000001,B11111001,
B10011111,B10000001,B11111001,
B10011111,B10111001,B11111001,
B10001111,B00101000,B11110001,
B10000000,B00111000,B00000001,
B10000000,B00000000,B00000001,
B10011111,B11111111,B11111001,
B10010001,B01110100,B10011001,
B10011011,B00000110,B10101001,
B10011011,B01010100,B10101001,
B10011011,B01010110,B10101001,
B10011011,B01010100,B10011001,
B10011111,B11111111,B11111001,
B11111111,B11111111,B11111111
};
//
// Use default bitmaps
//
#define STATUS_HOTEND_ANIM
#define STATUS_BED_ANIM
#if HOTENDS < 2
#define STATUS_LOGO_X 8
#define STATUS_HEATERS_X 40
#define STATUS_BED_X 72
#else
#define STATUS_LOGO_X 0
#define STATUS_HEATERS_X 32
#define STATUS_BED_X 80
#endif
+2 -2
View File
@@ -141,8 +141,8 @@ typedef Servo hal_servo_t;
#error "LCD_SERIAL_PORT must be from 0 to 3."
#endif
#define LCD_SERIAL lcdSerial
#if HAS_DGUS_LCD || ENABLED(DGUS_LCD_UI_CREALITY_TOUCH) || ENABLED(EXTENSIBLE_UI)
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.get_tx_buffer_free()
#if HAS_DGUS_LCD
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.get_tx_buffer_free()
#endif
#endif
+1 -1
View File
@@ -629,7 +629,7 @@ MSerialT1 customizedSerial1(MSerialT1::HasEmergencyParser);
template class MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> >;
MSerialLCD lcdSerial(MSerialLCD::HasEmergencyParser);
#if HAS_DGUS_LCD || ENABLED(DGUS_LCD_UI_CREALITY_TOUCH) || ENABLED(EXTENSIBLE_UI)
#if HAS_DGUS_LCD
template<typename Cfg>
typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::get_tx_buffer_free() {
const ring_buffer_pos_t t = tx_buffer.tail, // next byte to send.
+2 -2
View File
@@ -205,7 +205,7 @@
static ring_buffer_pos_t available();
static void write(const uint8_t c);
static void flushTX();
#if HAS_DGUS_LCD || ENABLED(DGUS_LCD_UI_CREALITY_TOUCH) || ENABLED(EXTENSIBLE_UI)
#if HAS_DGUS_LCD
static ring_buffer_pos_t get_tx_buffer_free();
#endif
@@ -276,7 +276,7 @@
static constexpr bool DROPPED_RX = false;
static constexpr bool RX_FRAMING_ERRORS = false;
static constexpr bool MAX_RX_QUEUED = false;
static constexpr bool RX_OVERRUNS = (ANY(HAS_DGUS_LCD, SERIAL_STATS_RX_BUFFER_OVERRUNS) || ENABLED(DWINOS_4));
static constexpr bool RX_OVERRUNS = ALL(HAS_DGUS_LCD, SERIAL_STATS_RX_BUFFER_OVERRUNS);
};
typedef Serial1Class< MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> > > MSerialLCD;
+1 -30
View File
@@ -123,11 +123,6 @@ void MarlinHAL::init() {
// Register min serial
TERN_(POSTMORTEM_DEBUGGING, install_min_serial());
// warn if low memory after init
if (freeMemory() < 1024) {
SERIAL_WARN_MSG("HAL: low memory after init!\n");
}
}
void MarlinHAL::init_board() {}
@@ -152,31 +147,7 @@ void MarlinHAL::delay_ms(const int ms) {
delay(ms);
}
void MarlinHAL::idletask() {
#if ENABLED(MARLIN_DEV_MODE)
// check & print serial RX errors
MSerialT *serials[] = { &MSerial1, &MSerial2 };
for (int serial = 0; serial < 2; serial++) {
usart_receive_error_t err = serials[serial]->getReceiveError();
if (err != usart_receive_error_t::None) {
// "Warning: MSerial[n] RX [Framing|Parity|Overrun] Error"
SERIAL_WARN_START();
SERIAL_ECHOPGM(" MSerial");
SERIAL_ECHO(serial + 1);
SERIAL_ECHOPGM(" RX ");
switch(err) {
case usart_receive_error_t::FramingError: SERIAL_ECHOPGM("Framing"); break;
case usart_receive_error_t::ParityError: SERIAL_ECHOPGM("Parity"); break;
case usart_receive_error_t::OverrunError: SERIAL_ECHOPGM("Overrun"); break;
case usart_receive_error_t::RxDataDropped: SERIAL_ECHOPGM("DataDropped"); break;
default: break;
}
SERIAL_ECHOPGM(" Error");
SERIAL_EOL();
}
}
#endif
}
void MarlinHAL::idletask() {}
uint8_t MarlinHAL::get_reset_source() {
// Query reset cause from RMU
+3 -23
View File
@@ -46,34 +46,14 @@ constexpr bool serial_handles_emergency(int port) {
//
// Define serial ports
//
// serial port where RX and TX use IRQs
#define DEFINE_IRQ_SERIAL_MARLIN(name, n) \
#define DEFINE_HWSERIAL_MARLIN(name, n) \
MSerialT name(serial_handles_emergency(n), \
&USART##n##_config, \
BOARD_USART##n##_TX_PIN, \
BOARD_USART##n##_RX_PIN);
// serial port where RX uses DMA and TX uses IRQs
// all serial ports use DMA1
// since there are 4 USARTs and 4 DMA channels, we can use the USART number as the DMA channel
#define DEFINE_DMA_SERIAL_MARLIN(name, n) \
MSerialT name(serial_handles_emergency(n), \
&USART##n##_config, \
BOARD_USART##n##_TX_PIN, \
BOARD_USART##n##_RX_PIN, \
M4_DMA1, \
((en_dma_channel_t)(n - 1))); // map USART1 to DMA channel 0, USART2 to DMA channel 1, etc.
#define DEFINE_SERIAL_MARLIN(name, n) TERN(SERIAL_DMA, DEFINE_DMA_SERIAL_MARLIN(name, n), DEFINE_IRQ_SERIAL_MARLIN(name, n))
DEFINE_SERIAL_MARLIN(MSerial1, 1);
DEFINE_SERIAL_MARLIN(MSerial2, 2);
// TODO: remove this warning when SERIAL_DMA has been tested some more
#if ENABLED(SERIAL_DMA)
#warning "SERIAL_DMA may be unstable on HC32F460."
#endif
DEFINE_HWSERIAL_MARLIN(MSerial1, 1);
DEFINE_HWSERIAL_MARLIN(MSerial2, 2);
//
// Serial port assertions
+8 -38
View File
@@ -25,42 +25,17 @@
#include <drivers/usart/Usart.h>
// Optionally set uart IRQ priority to reduce overflow errors
//#define UART_RX_IRQ_PRIO 1
//#define UART_TX_IRQ_PRIO 1
//#define UART_RX_DMA_IRQ_PRIO 1
// #define UART_IRQ_PRIO 1
struct MarlinSerial : public Usart {
MarlinSerial(
struct usart_config_t *usart_device,
gpio_pin_t tx_pin,
gpio_pin_t rx_pin
#if ENABLED(SERIAL_DMA)
, M4_DMA_TypeDef *dma_unit = nullptr,
en_dma_channel_t rx_dma_channel = DmaCh0
#endif
) : Usart(usart_device, tx_pin, rx_pin) {
#if ENABLED(SERIAL_DMA)
if (dma_unit != nullptr) {
enableRxDma(dma_unit, rx_dma_channel);
}
#endif
}
MarlinSerial(struct usart_config_t *usart_device, gpio_pin_t tx_pin, gpio_pin_t rx_pin) : Usart(usart_device, tx_pin, rx_pin) {}
#if defined(UART_RX_IRQ_PRIO) || defined(UART_TX_IRQ_PRIO) || defined(UART_RX_DMA_IRQ_PRIO)
#ifdef UART_IRQ_PRIO
void setPriority() {
#if defined(UART_RX_IRQ_PRIO)
NVIC_SetPriority(c_dev()->interrupts.rx_data_available.interrupt_number, UART_RX_IRQ_PRIO);
NVIC_SetPriority(c_dev()->interrupts.rx_error.interrupt_number, UART_RX_IRQ_PRIO);
#endif
#if defined(UART_TX_IRQ_PRIO)
NVIC_SetPriority(c_dev()->interrupts.tx_buffer_empty.interrupt_number, UART_TX_IRQ_PRIO);
NVIC_SetPriority(c_dev()->interrupts.tx_complete.interrupt_number, UART_TX_IRQ_PRIO);
#endif
#if defined(UART_RX_DMA_IRQ_PRIO) && ENABLED(SERIAL_DMA)
NVIC_SetPriority(c_dev()->dma.rx.rx_data_available_dma_btc.interrupt_number, UART_RX_DMA_IRQ_PRIO);
#endif
NVIC_SetPriority(c_dev()->interrupts.rx_data_available.interrupt_number, UART_IRQ_PRIO);
NVIC_SetPriority(c_dev()->interrupts.rx_error.interrupt_number, UART_IRQ_PRIO);
NVIC_SetPriority(c_dev()->interrupts.tx_buffer_empty.interrupt_number, UART_IRQ_PRIO);
NVIC_SetPriority(c_dev()->interrupts.tx_complete.interrupt_number, UART_IRQ_PRIO);
}
void begin(uint32_t baud) {
@@ -72,12 +47,7 @@ struct MarlinSerial : public Usart {
Usart::begin(baud, config);
setPriority();
}
void begin(uint32_t baud, const stc_usart_uart_init_t *config, const bool rxNoiseFilter = true) {
Usart::begin(baud, config, rxNoiseFilter);
setPriority();
}
#endif // UART_RX_IRQ_PRIO || UART_TX_IRQ_PRIO || UART_RX_DMA_IRQ_PRIO
#endif
};
typedef Serial1Class<MarlinSerial> MSerialT;
-70
View File
@@ -1,70 +0,0 @@
/**
* app_config.h is included by the hc32f460 arduino build script for every source file.
* it is used to configure the arduino core (and ddl) automatically according
* to the settings in Configuration.h and Configuration_adv.h.
*/
#pragma once
#ifndef _HC32_APP_CONFIG_H_
#define _HC32_APP_CONFIG_H_
#include "../../inc/MarlinConfigPre.h"
//
// dev mode
//
#if ENABLED(MARLIN_DEV_MODE)
#define __DEBUG 1
#define __CORE_DEBUG 1
#endif
//
// Fault Handlers and Panic
//
#if ENABLED(POSTMORTEM_DEBUGGING)
// disable arduino core fault handler, as we define our own
#define CORE_DISABLE_FAULT_HANDLER 1
#endif
// force-enable panic handler so that we can use our custom one (in MinSerial)
#define PANIC_ENABLE 1
// use short filenames in ddl debug and core panic output
#define __DEBUG_SHORT_FILENAMES 1
#define __PANIC_SHORT_FILENAMES 1
// omit panic messages in core panic output
#define __OMIT_PANIC_MESSAGE 1
//
// Usart
//
// disable serial globals (Serial1, Serial2, ...), as we define our own
#define DISABLE_SERIAL_GLOBALS 1
// increase the size of the Usart buffers (both RX and TX)
// NOTE:
// the heap usage will increase by (SERIAL_BUFFER_SIZE - 64) * "number of serial ports used"
// if running out of heap, the system may become unstable
//#define SERIAL_BUFFER_SIZE 256
// enable support for Usart Clock Divider / Oversampling auto config
#define USART_AUTO_CLKDIV_OS_CONFIG 1
// enable USART_RX_DMA_SUPPORT core option when SERIAL_DMA is enabled
#if ENABLED(SERIAL_DMA)
#define USART_RX_DMA_SUPPORT 1
#endif
//
// Misc.
//
// redirect printf to host serial
#define REDIRECT_PRINTF_TO_SERIAL 1
// FIXME override F_CPU to PCLK1, as marlin freaks out otherwise
#define F_CPU (SYSTEM_CLOCK_FREQUENCIES.pclk1)
#endif // _HC32_APP_CONFIG_H_
-29
View File
@@ -20,20 +20,6 @@
*
*/
#pragma once
#include <core_util.h>
#if !defined(ARDUINO_CORE_VERSION_INT) || !defined(GET_VERSION_INT)
// version macros were introduced in arduino core version 1.1.0
// below that version, we polyfill them
#define GET_VERSION_INT(major, minor, patch) ((major * 100000) + (minor * 1000) + patch)
#define ARDUINO_CORE_VERSION_INT GET_VERSION_INT(1, 0, 0)
#endif
#if ARDUINO_CORE_VERSION_INT < GET_VERSION_INT(1, 1, 0)
// because we use app_config.h introduced in arduino core version 1.1.0, the
// HAL is not compatible with older versions
#error "The HC32 HAL is not compatible with Arduino Core versions < 1.1.0. Consider updating the Arduino Core."
#endif
#ifndef BOARD_XTAL_FREQUENCY
#error "BOARD_XTAL_FREQUENCY is required for HC32F460."
@@ -88,18 +74,3 @@
#error "HC32 HAL uses a custom panic handler. Do not define PANIC_USARTx_TX_PIN."
#endif
#endif
#if ENABLED(SERIAL_DMA)
#if !defined(USART_RX_DMA_SUPPORT)
#error "SERIAL_DMA requires USART_RX_DMA_SUPPORT to be enabled in the arduino core."
#endif
// USART_RX_DMA_SUPPORT does not implement core_hook_usart_rx_irq, which is required for the emergency parser
#if ENABLED(EMERGENCY_PARSER)
#error "EMERGENCY_PARSER is not supported with SERIAL_DMA. Please disable either SERIAL_DMA or EMERGENCY_PARSER."
#endif
#if ARDUINO_CORE_VERSION_INT < GET_VERSION_INT(1, 1, 0)
#error "SERIAL_DMA is not supported with arduino core version < 1.1.0."
#endif
#endif
+17 -26
View File
@@ -54,7 +54,7 @@
fn \
}
stc_sd_handle_t *handle = nullptr;
stc_sd_handle_t *handle;
bool SDIO_Init() {
// Configure SDIO pins
@@ -66,45 +66,36 @@ bool SDIO_Init() {
GPIO_SetFunc(BOARD_SDIO_CMD, Func_Sdio);
GPIO_SetFunc(BOARD_SDIO_DET, Func_Sdio);
// If a handle is already initialized, free it before creating a new one
// otherwise, we will leak memory, which will eventually crash the system
if (handle != nullptr) {
delete handle->pstcDmaInitCfg;
delete handle->pstcCardInitCfg;
delete handle;
handle = nullptr;
}
// Create DMA configuration
stc_sdcard_dma_init_t *dmaConf = new stc_sdcard_dma_init_t;
dmaConf->DMAx = SDIO_DMA_PERIPHERAL;
dmaConf->enDmaCh = SDIO_DMA_CHANNEL;
// Create card configuration
// This should be a fairly safe configuration for most cards
stc_sdcard_init_t *cardConf = new stc_sdcard_init_t;
cardConf->enBusWidth = SdiocBusWidth4Bit;
cardConf->enClkFreq = SdiocClk400K;
cardConf->enSpeedMode = SdiocNormalSpeedMode;
cardConf->pstcInitCfg = nullptr;
// Create handle in DMA mode
handle = new stc_sd_handle_t;
handle->SDIOCx = SDIO_PERIPHERAL;
handle->enDevMode = SdCardDmaMode;
handle->pstcDmaInitCfg = dmaConf;
//handle->pstcCardInitCfg = cardConf; // assigned in SDCARD_Init
// Create card configuration
// This should be a fairly safe configuration for most cards
stc_sdcard_init_t cardConf = {
.enBusWidth = SdiocBusWidth4Bit,
.enClkFreq = SdiocClk400K,
.enSpeedMode = SdiocNormalSpeedMode,
//.pstcInitCfg = NULL,
};
// Initialize sd card
en_result_t rc = SDCARD_Init(handle, cardConf);
en_result_t rc = SDCARD_Init(handle, &cardConf);
if (rc != Ok) printf("SDIO_Init() error (rc=%u)\n", rc);
return rc == Ok;
}
bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) {
CORE_ASSERT(handle != nullptr, "SDIO not initialized", return false);
CORE_ASSERT(dst != nullptr, "SDIO_ReadBlock dst is NULL", return false);
CORE_ASSERT(handle != NULL, "SDIO not initialized");
CORE_ASSERT(dst != NULL, "SDIO_ReadBlock dst is NULL");
WITH_RETRY(SDIO_READ_RETRIES, {
en_result_t rc = SDCARD_ReadBlocks(handle, block, 1, dst, SDIO_READ_TIMEOUT);
@@ -116,8 +107,8 @@ bool SDIO_ReadBlock(uint32_t block, uint8_t *dst) {
}
bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) {
CORE_ASSERT(handle != nullptr, "SDIO not initialized", return false);
CORE_ASSERT(src != nullptr, "SDIO_WriteBlock src is NULL", return false);
CORE_ASSERT(handle != NULL, "SDIO not initialized");
CORE_ASSERT(src != NULL, "SDIO_WriteBlock src is NULL");
WITH_RETRY(SDIO_WRITE_RETRIES, {
en_result_t rc = SDCARD_WriteBlocks(handle, block, 1, (uint8_t *)src, SDIO_WRITE_TIMEOUT);
@@ -129,12 +120,12 @@ bool SDIO_WriteBlock(uint32_t block, const uint8_t *src) {
}
bool SDIO_IsReady() {
CORE_ASSERT(handle != nullptr, "SDIO not initialized", return false);
CORE_ASSERT(handle != NULL, "SDIO not initialized");
return bool(handle->stcCardStatus.READY_FOR_DATA);
}
uint32_t SDIO_GetCardSize() {
CORE_ASSERT(handle != nullptr, "SDIO not initialized", return 0);
CORE_ASSERT(handle != NULL, "SDIO not initialized");
// Multiply number of blocks with block size to get size in bytes
const uint64_t cardSizeBytes = uint64_t(handle->stcSdCardInfo.u32LogBlockNbr) * uint64_t(handle->stcSdCardInfo.u32LogBlockSize);
+1 -4
View File
@@ -37,10 +37,7 @@ Timer::Timer() {
}
Timer::~Timer() {
if (timerid != 0) {
timer_delete(timerid);
timerid = 0;
}
timer_delete(timerid);
}
void Timer::init(uint32_t sig_id, uint32_t sim_freq, callback_fn* fn) {
-2
View File
@@ -21,7 +21,6 @@
*/
#ifdef __PLAT_LINUX__
#ifndef UNIT_TEST
//#define GPIO_LOGGING // Full GPIO and Positional Logging
@@ -136,5 +135,4 @@ int main() {
read_serial.join();
}
#endif // UNIT_TEST
#endif // __PLAT_LINUX__
+1 -1
View File
@@ -100,7 +100,7 @@ extern DefaultSerial1 USBSerial;
#else
#error "LCD_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
#endif
#if HAS_DGUS_LCD || ENABLED(DWINOS_4)
#if HAS_DGUS_LCD
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.available()
#endif
#endif
+1 -1
View File
@@ -112,7 +112,7 @@
#else
#error "LCD_SERIAL_PORT must be from 1 to 9, or -1 for Native USB."
#endif
#if HAS_DGUS_LCD || ENABLED(DGUS_LCD_UI_CREALITY_TOUCH) || ENABLED(EXTENSIBLE_UI)
#if HAS_DGUS_LCD
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
#endif
#endif
-3
View File
@@ -43,7 +43,6 @@
#else // Arduino non-DMA
FORCE_INLINE static uint8_t buffer_overruns() { return 0; }
typedef void (*usart_rx_callback_t)(serial_t * obj);
struct MarlinSerial : public HardwareSerial {
@@ -54,8 +53,6 @@
inline void begin(unsigned long baud) { begin(baud, SERIAL_8N1); }
void _rx_complete_irq(serial_t *obj);
FORCE_INLINE static uint8_t buffer_overruns() { return 0; } // Not implemented. Void to avoid platform-dependent code.
FORCE_INLINE uint32_t dropped() { return 0; }
protected:
usart_rx_callback_t _rx_callback;
+1 -1
View File
@@ -138,7 +138,7 @@
#define LCD_SERIAL MSERIAL(1) // dummy port
static_assert(false, "LCD_SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.")
#endif
#if HAS_DGUS_LCD || ENABLED(DGUS_LCD_UI_CREALITY_TOUCH) || ENABLED(DWINOS_4)
#if HAS_DGUS_LCD
#define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
#endif
#endif
+4 -9
View File
@@ -266,7 +266,7 @@ PGMSTR(M112_KILL_STR, "M112 Shutdown");
MarlinState marlin_state = MF_INITIALIZING;
// For M109 and M190, this flag may be cleared (by M108) to exit the wait loop
bool wait_for_heatup = true;
bool wait_for_heatup = false;
// For M0/M1, this flag may be cleared (by M108) to exit the wait-for-user loop
#if HAS_RESUME_CONTINUE
@@ -474,16 +474,11 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
#if HAS_KILL
// Check if the kill button was pressed and wait to ensure the signal is not noise
// typically caused by poor insulation and grounding on LCD cables.
// Lower numbers here will increase response time and therefore safety rating.
// It is recommended to set this as low as possibe without false triggers.
// Check if the kill button was pressed and wait just in case it was an accidental
// key kill key press
// -------------------------------------------------------------------------------
#ifndef KILL_DELAY
#define KILL_DELAY 250
#endif
static int killCount = 0; // make the inactivity button a bit less responsive
const int KILL_DELAY = 750;
if (kill_state())
killCount++;
else if (killCount > 0)
-1
View File
@@ -131,7 +131,6 @@
#define BOARD_PXMALION_CORE_I3 1164 // Pxmalion Core I3
#define BOARD_PANOWIN_CUTLASS 1165 // Panowin Cutlass (as found in the Panowin F1)
#define BOARD_KODAMA_BARDO 1166 // Kodama Bardo V1.x (as found in the Kodama Trinus)
#define BOARD_DAGOMA_D6 1167 // Dagoma D6 (as found in the Dagoma DiscoUltimate V2 TMC)
//
// RAMBo and derivatives
+1 -1
View File
@@ -197,7 +197,7 @@ void HostUI::action(FSTR_P const fstr, const bool eol) {
#endif
#if HAS_FILAMENT_SENSOR
if (runout.filament_ran_out) { // Disable a triggered sensor
runout.enabled[active_extruder] = false;
runout.enabled = false;
runout.reset();
}
#endif
+1 -1
View File
@@ -135,7 +135,7 @@ void MMU2::reset() {
int8_t MMU2::get_current_tool() { return extruder == MMU2_NO_TOOL ? -1 : extruder; }
#if ANY(HAS_PRUSA_MMU2S, MMU_EXTRUDER_SENSOR)
#define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != runout.out_state())
#define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE)
#else
#define FILAMENT_PRESENT() true
#endif
+6 -15
View File
@@ -214,21 +214,12 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load
impatient_beep(max_beep_count);
#if ALL(FILAMENT_CHANGE_RESUME_ON_INSERT, FILAMENT_RUNOUT_SENSOR)
#if MULTI_FILAMENT_SENSOR
LOOP_S_LE_N(i, 1, NUM_RUNOUT_SENSORS) {
pin_t pin;
switch (i) {
default: continue;
#define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break;
REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT)
#undef _CASE_RUNOUT
}
const RunoutMode rm = runout.mode[i - 1];
if (rm != RM_NONE && rm != RM_MOTION_SENSOR && extDigitalRead(pin) != runout.out_state(i - 1))
wait_for_user = false;
#define _CASE_INSERTED(N) case N-1: if (READ(FIL_RUNOUT##N##_PIN) != FIL_RUNOUT##N##_STATE) wait_for_user = false; break;
switch (active_extruder) {
REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_INSERTED)
}
#else
if (READ(FIL_RUNOUT_PIN) != runout.out_state(active_extruder))
wait_for_user = false;
if (READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_STATE) wait_for_user = false;
#endif
#endif
idle_no_sleep();
@@ -689,7 +680,7 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_
#endif
// If resume_position is negative
//if (resume_position.e < 0) unscaled_e_move(resume_position.e, feedRate_t(PAUSE_PARK_RETRACT_FEEDRATE));
if (resume_position.e < 0) unscaled_e_move(resume_position.e, feedRate_t(PAUSE_PARK_RETRACT_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));
@@ -698,7 +689,7 @@ void resume_print(const_float_t slow_load_length/*=0*/, const_float_t fast_load_
// Now all extrusion positions are resumed and ready to be confirmed
// Set extruder to saved position
planner.set_e_position_mm((destination.e = current_position.e = resume_position.e));
sync_plan_position_e();
ui.pause_show_message(PAUSE_MESSAGE_STATUS);
#ifdef ACTION_ON_RESUMED
+5 -3
View File
@@ -57,7 +57,9 @@ enum PauseMessage : char {
};
#if M600_PURGE_MORE_RESUMABLE
// Input methods can Purge More, Resume, or request input
/**
* Input methods can Purge More, Resume, or request input
*/
enum PauseMenuResponse : char {
PAUSE_RESPONSE_WAIT_FOR,
PAUSE_RESPONSE_EXTRUDE_MORE,
@@ -107,7 +109,7 @@ void wait_for_confirmation(
void resume_print(
const_float_t slow_load_length=0, // (mm) Slow Load Length for finishing move
const_float_t fast_load_length=0, // (mm) Fast Load Length for initial move
const_float_t purge_length=ADVANCED_PAUSE_PURGE_LENGTH, // (mm) Purge length
const_float_t extrude_length=ADVANCED_PAUSE_PURGE_LENGTH, // (mm) Purge length
const int8_t max_beep_count=0, // Beep alert for attention
const celsius_t targetTemp=0 // (°C) A target temperature for the hotend
DXC_PARAMS // Dual-X-Carriage extruder index
@@ -116,7 +118,7 @@ void resume_print(
bool load_filament(
const_float_t slow_load_length=0, // (mm) Slow Load Length for finishing move
const_float_t fast_load_length=0, // (mm) Fast Load Length for initial move
const_float_t purge_length=0, // (mm) Purge length
const_float_t extrude_length=0, // (mm) Purge length
const int8_t max_beep_count=0, // Beep alert for attention
const bool show_lcd=false, // Set LCD status messages?
const bool pause_for_user=false, // Pause for user before returning?
-1
View File
@@ -122,7 +122,6 @@ void Power::power_off() {
TERN_(HAS_SUICIDE, suicide());
if (!psu_on) return;
SERIAL_ECHOLNPGM(STR_POWEROFF);
SERIAL_ECHOLNPGM(STR_POWEROFF);
+12 -7
View File
@@ -32,9 +32,9 @@
FilamentMonitor runout;
bool FilamentMonitorBase::enabled[NUM_RUNOUT_SENSORS], // Initialized by settings.load
FilamentMonitorBase::filament_ran_out; // = false
RunoutMode FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS]; // Initialized by settings.load
bool FilamentMonitorBase::enabled = true,
FilamentMonitorBase::filament_ran_out; // = false
#if ENABLED(HOST_ACTION_COMMANDS)
bool FilamentMonitorBase::host_handling; // = false
#endif
@@ -45,10 +45,15 @@ RunoutMode FilamentMonitorBase::mode[NUM_RUNOUT_SENSORS]; // Initialized by sett
#include "../core/debug_out.h"
#endif
float RunoutResponseDelayed::runout_distance_mm[NUM_RUNOUT_SENSORS]; // Initialized by settings.load
countdown_t RunoutResponseDelayed::mm_countdown;
uint8_t FilamentSensorCore::motion_detected;
int8_t RunoutResponseDelayed::runout_count[NUM_RUNOUT_SENSORS]; // = 0
#if HAS_FILAMENT_RUNOUT_DISTANCE
float RunoutResponseDelayed::runout_distance_mm = FILAMENT_RUNOUT_DISTANCE_MM;
countdown_t RunoutResponseDelayed::mm_countdown;
#if ENABLED(FILAMENT_MOTION_SENSOR)
uint8_t FilamentSensorEncoder::motion_detected;
#endif
#else
int8_t RunoutResponseDebounced::runout_count[NUM_RUNOUT_SENSORS]; // = 0
#endif
//
// Filament Runout event handler
+223 -107
View File
@@ -44,6 +44,12 @@
#define FILAMENT_RUNOUT_THRESHOLD 5
#endif
#if ENABLED(FILAMENT_MOTION_SENSOR)
#define HAS_FILAMENT_MOTION 1
#endif
#if DISABLED(FILAMENT_MOTION_SENSOR) || ENABLED(FILAMENT_SWITCH_AND_MOTION)
#define HAS_FILAMENT_SWITCH 1
#endif
typedef Flags<
#if NUM_MOTION_SENSORS > NUM_RUNOUT_SENSORS
@@ -58,37 +64,24 @@ inline bool should_monitor_runout() { return did_pause_print || printingIsActive
template<class RESPONSE_T, class SENSOR_T>
class TFilamentMonitor;
class FilamentSensorCore;
class FilamentSensor;
class RunoutResponseDelayed;
class RunoutResponseDebounced;
/********************************* TEMPLATE SPECIALIZATION *********************************/
typedef TFilamentMonitor<
RunoutResponseDelayed,
FilamentSensorCore
TERN(HAS_FILAMENT_RUNOUT_DISTANCE, RunoutResponseDelayed, RunoutResponseDebounced),
FilamentSensor
> FilamentMonitor;
extern FilamentMonitor runout;
/*******************************************************************************************/
enum RunoutMode : uint8_t {
RM_NONE,
RM_OUT_ON_LOW,
RM_OUT_ON_HIGH,
RM_RESERVED3,
RM_RESERVED4,
RM_RESERVED5,
RM_RESERVED6,
RM_MOTION_SENSOR
};
class FilamentMonitorBase {
public:
static bool enabled[NUM_RUNOUT_SENSORS], filament_ran_out;
static RunoutMode mode[NUM_RUNOUT_SENSORS];
static uint8_t out_state(const uint8_t e=0) { return mode[e] == RM_OUT_ON_HIGH ? HIGH : LOW; }
static bool enabled, filament_ran_out;
#if ENABLED(HOST_ACTION_COMMANDS)
static bool host_handling;
@@ -118,14 +111,24 @@ class TFilamentMonitor : public FilamentMonitorBase {
// Call this method when filament is present,
// so the response can reset its counter.
static void filament_present(const uint8_t e) { response.filament_present(e); }
static float& runout_distance(const uint8_t e=0) { return response.runout_distance_mm[e]; }
static void set_runout_distance(const_float_t mm, const uint8_t e=0) { response.runout_distance_mm[e] = mm; }
static void filament_present(const uint8_t extruder) {
response.filament_present(extruder);
}
#if ENABLED(FILAMENT_SWITCH_AND_MOTION)
static void filament_motion_present(const uint8_t extruder) {
response.filament_motion_present(extruder);
}
#endif
#if HAS_FILAMENT_RUNOUT_DISTANCE
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 void block_completed(const block_t * const b) {
if (enabled[active_extruder]) {
if (enabled) {
response.block_completed(b);
sensor.block_completed(b);
}
@@ -134,11 +137,11 @@ class TFilamentMonitor : public FilamentMonitorBase {
// Give the response a chance to update its counter.
static void run() {
if (enabled && !filament_ran_out && should_monitor_runout()) {
cli(); // Prevent RunoutResponseDelayed::block_completed from accumulating here
TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, cli()); // Prevent RunoutResponseDelayed::block_completed from accumulating here
response.run();
sensor.run();
const runout_flags_t runout_flags = response.has_run_out();
sei();
TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, sei());
#if MULTI_FILAMENT_SENSOR
#if ENABLED(WATCH_ALL_RUNOUT_SENSORS)
const bool ran_out = bool(runout_flags); // any sensor triggers
@@ -179,40 +182,27 @@ class FilamentSensorBase {
static void filament_present(const uint8_t extruder) {
runout.filament_present(extruder); // ...which calls response.filament_present(extruder)
}
#if ENABLED(FILAMENT_SWITCH_AND_MOTION)
static void filament_motion_present(const uint8_t extruder) {
runout.filament_motion_present(extruder); // ...which calls response.filament_motion_present(extruder)
}
#endif
public:
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
INIT_RUNOUT_PIN(1);
#endif
#if NUM_RUNOUT_SENSORS >= 2
INIT_RUNOUT_PIN(2);
#endif
#if NUM_RUNOUT_SENSORS >= 3
INIT_RUNOUT_PIN(3);
#endif
#if NUM_RUNOUT_SENSORS >= 4
INIT_RUNOUT_PIN(4);
#endif
#if NUM_RUNOUT_SENSORS >= 5
INIT_RUNOUT_PIN(5);
#endif
#if NUM_RUNOUT_SENSORS >= 6
INIT_RUNOUT_PIN(6);
#endif
#if NUM_RUNOUT_SENSORS >= 7
INIT_RUNOUT_PIN(7);
#endif
#if NUM_RUNOUT_SENSORS >= 8
INIT_RUNOUT_PIN(8);
#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);
REPEAT_1(NUM_RUNOUT_SENSORS, INIT_RUNOUT_PIN)
#undef INIT_RUNOUT_PIN
#if ENABLED(FILAMENT_SWITCH_AND_MOTION)
#define INIT_MOTION_PIN(N) _INIT_RUNOUT_PIN(FIL_MOTION##N##_PIN, FIL_MOTION##N##_STATE, FIL_MOTION##N##_PULLUP, FIL_MOTION##N##_PULLDOWN);
REPEAT_1(NUM_MOTION_SENSORS, INIT_MOTION_PIN)
#undef INIT_MOTION_PIN
#endif
#undef _INIT_RUNOUT_PIN
#undef INIT_RUNOUT_PIN
}
// Return a bitmask of runout pin states
static uint8_t poll_runout_pins() {
#define _OR_RUNOUT(N) | (READ(FIL_RUNOUT##N##_PIN) ? _BV((N) - 1) : 0)
@@ -222,7 +212,7 @@ class FilamentSensorBase {
// Return a bitmask of runout flag states (1 bits always indicates runout)
static uint8_t poll_runout_states() {
#define _INVERT_BIT(N) | (runout.out_state(N-1) ? 0 : _BV(N-1))
#define _INVERT_BIT(N) | (FIL_RUNOUT##N##_STATE ? 0 : _BV(N - 1))
return poll_runout_pins() ^ uint8_t(0 REPEAT_1(NUM_RUNOUT_SENSORS, _INVERT_BIT));
#undef _INVERT_BIT
}
@@ -244,21 +234,17 @@ class FilamentSensorBase {
#endif
};
class FilamentSensorCore : public FilamentSensorBase {
private:
static uint8_t motion_detected;
#if HAS_FILAMENT_MOTION
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())
&& !TERN0(MULTI_NOZZLE_DUPLICATION, extruder_duplication_enabled)
) return TEST(runout_states, extruder); // A specific extruder ran out
#else
UNUSED(extruder);
#endif
return !!runout_states; // Any extruder ran out
}
/**
* This sensor uses a magnetic encoder disc and a Hall effect
* sensor (or a slotted disc and optical sensor). The state
* will toggle between 0 and 1 on filament movement. It can detect
* filament runout and stripouts or jams.
*/
class FilamentSensorEncoder : public FilamentSensorBase {
private:
static uint8_t motion_detected;
static void poll_motion_sensor() {
static uint8_t old_state;
@@ -266,17 +252,17 @@ class FilamentSensorCore : public FilamentSensorBase {
change = old_state ^ new_state;
old_state = new_state;
#if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG)
if (change) {
SERIAL_ECHOPGM("Motion detected:");
for(uint8_t e = 0; e < NUM_RUNOUT_SENSORS; ++e)
if (TEST(change, e)) SERIAL_CHAR(' ', '0' + e);
SERIAL_EOL();
}
#endif
#if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG)
if (change) {
SERIAL_ECHOPGM("Motion detected:");
for (uint8_t e = 0; e < TERN(FILAMENT_SWITCH_AND_MOTION, NUM_MOTION_SENSORS, NUM_RUNOUT_SENSORS); ++e)
if (TEST(change, e)) SERIAL_CHAR(' ', '0' + e);
SERIAL_EOL();
}
#endif
motion_detected |= change;
}
motion_detected |= change;
}
public:
static void block_completed(const block_t * const b) {
@@ -289,12 +275,36 @@ class FilamentSensorCore : public FilamentSensorBase {
motion_detected = 0;
}
static void run() {
if (runout.mode[active_extruder] == RM_MOTION_SENSOR) {
poll_motion_sensor();
static void run() { poll_motion_sensor(); }
};
#endif // HAS_FILAMENT_MOTION
#if HAS_FILAMENT_SWITCH
/**
* This is a simple endstop switch in the path of the filament.
* It can detect filament runout, but not stripouts or jams.
*/
class FilamentSensorSwitch : public FilamentSensorBase {
private:
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())
&& !TERN0(MULTI_NOZZLE_DUPLICATION, extruder_duplication_enabled)
) return TEST(runout_states, extruder); // A specific extruder ran out
#else
UNUSED(extruder);
#endif
return !!runout_states; // Any extruder ran out
}
else if (runout.mode[active_extruder] != RM_NONE) {
for(uint8_t s = 0; s < NUM_RUNOUT_SENSORS; ++s) {
public:
static void block_completed(const block_t * const) {}
static void run() {
for (uint8_t s = 0; s < NUM_RUNOUT_SENSORS; ++s) {
const bool out = poll_runout_state(s);
if (!out) filament_present(s);
#if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG)
@@ -306,12 +316,36 @@ class FilamentSensorCore : public FilamentSensorBase {
#endif
}
}
}
};
};
#endif // HAS_FILAMENT_SWITCH
/**
* This is a simple endstop switch in the path of the filament.
* It can detect filament runout, but not stripouts or jams.
*/
class FilamentSensor : public FilamentSensorBase {
private:
TERN_(HAS_FILAMENT_MOTION, static FilamentSensorEncoder encoder_sensor);
TERN_(HAS_FILAMENT_SWITCH, static FilamentSensorSwitch switch_sensor);
public:
static void block_completed(const block_t * const b) {
TERN_(HAS_FILAMENT_MOTION, encoder_sensor.block_completed(b));
TERN_(HAS_FILAMENT_SWITCH, switch_sensor.block_completed(b));
}
static void run() {
TERN_(HAS_FILAMENT_MOTION, encoder_sensor.run());
TERN_(HAS_FILAMENT_SWITCH, switch_sensor.run());
}
};
/********************************* RESPONSE TYPE *********************************/
typedef struct {
#if HAS_FILAMENT_RUNOUT_DISTANCE
typedef struct {
float runout[NUM_RUNOUT_SENSORS];
Flags<NUM_RUNOUT_SENSORS> runout_reset; // Reset runout later
#if ENABLED(FILAMENT_SWITCH_AND_MOTION)
@@ -320,16 +354,15 @@ typedef struct {
#endif
} countdown_t;
// RunoutResponseDelayed triggers a runout event only if the length
// of filament specified by FIL_RUNOUT_DISTANCE_MM has been fed
// during a runout condition.
class RunoutResponseDelayed {
private:
static countdown_t mm_countdown;
// RunoutResponseDelayed triggers a runout event only if the length
// of filament specified by FILAMENT_RUNOUT_DISTANCE_MM has been fed
// during a runout condition.
class RunoutResponseDelayed {
private:
static countdown_t mm_countdown;
public:
static float runout_distance_mm[NUM_RUNOUT_SENSORS];
static int8_t runout_count[NUM_RUNOUT_SENSORS];
public:
static float runout_distance_mm;
static void reset() {
for (uint8_t i = 0; i < NUM_RUNOUT_SENSORS; ++i) filament_present(i);
@@ -338,33 +371,116 @@ class RunoutResponseDelayed {
#endif
}
static void run() {
#if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG)
static millis_t t = 0;
const millis_t ms = millis();
if (ELAPSED(ms, t)) {
t = millis() + 1000UL;
for(uint8_t i; i < NUM_RUNOUT_SENSORS; ++i)
SERIAL_ECHO(i ? F(", ") : F("Remaining mm: "), mm_countdown[i]);
static void run() {
#if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG)
static millis_t t = 0;
const millis_t ms = millis();
if (ELAPSED(ms, t)) {
t = millis() + 1000UL;
for (uint8_t i = 0; i < NUM_RUNOUT_SENSORS; ++i)
SERIAL_ECHO(i ? F(", ") : F("Runout remaining mm: "), mm_countdown.runout[i]);
#if ENABLED(FILAMENT_SWITCH_AND_MOTION)
for (uint8_t i = 0; i < NUM_MOTION_SENSORS; ++i)
SERIAL_ECHO(i ? F(", ") : F("Motion remaining mm: "), mm_countdown.motion[i]);
#endif
SERIAL_EOL();
SERIAL_EOL();
}
#endif
}
static runout_flags_t has_run_out() {
runout_flags_t runout_flags{0};
for (uint8_t i = 0; i < NUM_RUNOUT_SENSORS; ++i) if (mm_countdown.runout[i] < 0) runout_flags.set(i);
#if ENABLED(FILAMENT_SWITCH_AND_MOTION)
for (uint8_t i = 0; i < NUM_MOTION_SENSORS; ++i) if (mm_countdown.motion[i] < 0) runout_flags.set(i);
#endif
return runout_flags;
}
static void filament_present(const uint8_t extruder) {
if (mm_countdown.runout[extruder] < runout_distance_mm || did_pause_print) {
// Reset runout only if it is smaller than runout_distance or printing is paused.
// On Bowden systems retract may be larger than runout_distance_mm, so if retract
// was added leave it in place, or the following unretract will cause runout event.
mm_countdown.runout[extruder] = runout_distance_mm;
mm_countdown.runout_reset.clear(extruder);
}
else {
// If runout is larger than runout distance, we cannot reset right now, as Bowden and retract
// distance larger than runout_distance_mm leads to negative runout right after unretract.
// But we cannot ignore filament_present event. After unretract, runout will become smaller
// than runout_distance_mm and should be reset after that. So activate delayed reset.
mm_countdown.runout_reset.set(extruder);
}
}
#if ENABLED(FILAMENT_SWITCH_AND_MOTION)
static void filament_motion_present(const uint8_t extruder) {
// Same logic as filament_present
if (mm_countdown.motion[extruder] < runout_distance_mm || did_pause_print) {
mm_countdown.motion[extruder] = runout_distance_mm;
mm_countdown.motion_reset.clear(extruder);
}
else
mm_countdown.motion_reset.set(extruder);
}
#endif
}
static runout_flags_t has_run_out() {
runout_flags_t runout_flags{0};
static void block_completed(const block_t * const b) {
const int32_t esteps = b->steps.e;
if (!esteps) return;
// No calculation unless paused or printing
if (!should_monitor_runout()) return;
// No need to ignore retract/unretract movement since they complement each other
const uint8_t e = b->extruder;
const float mm = (b->direction_bits.e ? esteps : -esteps) * planner.mm_per_step[E_AXIS_N(e)];
if (e < NUM_RUNOUT_SENSORS) {
mm_countdown.runout[e] -= mm;
if (mm_countdown.runout_reset[e]) filament_present(e); // Reset pending. Try to reset.
}
#if ENABLED(FILAMENT_SWITCH_AND_MOTION)
if (e < NUM_MOTION_SENSORS) {
mm_countdown.motion[e] -= mm;
if (mm_countdown.motion_reset[e]) filament_motion_present(e); // Reset pending. Try to reset.
}
#endif
}
};
#else // !HAS_FILAMENT_RUNOUT_DISTANCE
// RunoutResponseDebounced triggers a runout event after a runout
// condition has been detected runout_threshold times in a row.
class RunoutResponseDebounced {
private:
static constexpr int8_t runout_threshold = FILAMENT_RUNOUT_THRESHOLD;
static int8_t runout_count[NUM_RUNOUT_SENSORS];
public:
static void reset() {
for (uint8_t i = 0; i < NUM_RUNOUT_SENSORS; ++i) filament_present(i);
}
static void run() {
for (uint8_t i = 0; i < NUM_RUNOUT_SENSORS; ++i) if (runout_count[i] >= 0) runout_count[i]--;
}
static runout_flags_t has_run_out() {
runout_flags_t runout_flags{0};
for (uint8_t i = 0; i < NUM_RUNOUT_SENSORS; ++i) if (runout_count[i] < 0) runout_flags.set(i);
return runout_flags;
}
}
static void block_completed(const block_t * const) { }
static void filament_present(const uint8_t extruder) {
runout_count[extruder] = runout_distance_mm[extruder];
runout_count[extruder] = runout_threshold;
}
};
#endif // !HAS_FILAMENT_RUNOUT_DISTANCE
-3
View File
@@ -985,9 +985,6 @@ G29_TYPE GcodeSuite::G29() {
process_subcommands_now(F(EVENT_GCODE_AFTER_G29));
#endif
TERN_(HAS_DWIN_E3V2_BASIC, DWIN_LevelingDone());
TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
TERN_(HAS_MULTI_HOTEND, if (active_extruder != 0) tool_change(0));
probe.use_probing_tool(false);
report_current_position();
+1 -1
View File
@@ -66,7 +66,7 @@ void GcodeSuite::M111() {
SERIAL_ECHOPGM(STR_DEBUG_OFF);
#if !(defined(__AVR__) && defined(USBCON))
#if ENABLED(SERIAL_STATS_RX_BUFFER_OVERRUNS)
//SERIAL_ECHOPGM("\nBuffer Overruns: ", MYSERIAL1.buffer_overruns());
SERIAL_ECHOPGM("\nBuffer Overruns: ", MYSERIAL1.buffer_overruns());
#endif
#if ENABLED(SERIAL_STATS_RX_FRAMING_ERRORS)
SERIAL_ECHOPGM("\nFraming Errors: ", MYSERIAL1.framing_errors());
+1 -1
View File
@@ -94,7 +94,7 @@ void GcodeSuite::M600() {
// In this case, for duplicating modes set DXC_ext to the extruder that ran out.
#if MULTI_FILAMENT_SENSOR
if (idex_is_duplicating())
DXC_ext = (READ(FIL_RUNOUT2_PIN) == runout.out_state(1)) ? 1 : 0;
DXC_ext = (READ(FIL_RUNOUT2_PIN) == FIL_RUNOUT2_STATE) ? 1 : 0;
#else
DXC_ext = active_extruder;
#endif
@@ -72,7 +72,6 @@ void GcodeSuite::M413_report(const bool forReplay/*=true*/) {
, " B", recovery.bed_temp_threshold
#endif
);
SERIAL_ECHO(" ; ");
serialprintln_onoff(recovery.enabled);
}
@@ -28,46 +28,36 @@
#include "../../../feature/runout.h"
/**
* M591: Configure filament runout detection
* M412: Enable / Disable filament runout detection
*
* Parameters
* R : Reset the runout sensor
* S<bool> : Reset and enable/disable the runout sensor
* H<bool> : Enable/disable host handling of filament runout
* L<linear> : Extra distance to continue after runout is triggered or motion interval
* D<linear> : Alias for L
* P<index> : Mode 0 = NONE
* 1 = Switch NO (HIGH = filament present)
* 2 = Switch NC (LOW = filament present)
* 3 = Encoder / Motion Sensor
* D<linear> : Extra distance to continue after runout is triggered
*/
void GcodeSuite::M591() {
if (parser.seen("RSDP" TERN_(HOST_ACTION_COMMANDS, "H"))) {
void GcodeSuite::M412() {
if (parser.seen("RS"
TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, "D")
TERN_(HOST_ACTION_COMMANDS, "H")
)) {
#if ENABLED(HOST_ACTION_COMMANDS)
if (parser.seen('H')) runout.host_handling = parser.value_bool();
#endif
const bool seenR = parser.seen_test('R'), seenS = parser.seen('S');
if (seenR || seenS) runout.reset();
const uint8_t tool = TERN0(MULTI_FILAMENT_SENSOR, parser.ushortval('E', active_extruder));
if (seenS) runout.enabled[tool] = parser.value_bool();
if (parser.seen('D') || parser.seen('L')) runout.set_runout_distance(parser.value_linear_units(), tool);
if (parser.seen('P')) {
const RunoutMode tmp_mode = (RunoutMode)parser.value_int();
switch (tmp_mode) {
case RM_NONE ... RM_OUT_ON_HIGH:
case RM_MOTION_SENSOR:
runout.mode[tool] = tmp_mode;
runout.setup();
default: break;
}
}
if (seenS) runout.enabled = parser.value_bool();
#if HAS_FILAMENT_RUNOUT_DISTANCE
if (parser.seenval('D')) runout.set_runout_distance(parser.value_linear_units());
#endif
}
else {
SERIAL_ECHO_START();
SERIAL_ECHOPGM("Filament runout ");
serialprint_onoff(runout.enabled[active_extruder]);
SERIAL_ECHOPGM(" ; Distance ", runout.runout_distance(active_extruder), "mm");
SERIAL_ECHOPGM(" ; Mode ", runout.mode[active_extruder]);
serialprint_onoff(runout.enabled);
#if HAS_FILAMENT_RUNOUT_DISTANCE
SERIAL_ECHOPGM(" ; Distance ", runout.runout_distance(), "mm");
#endif
#if ENABLED(HOST_ACTION_COMMANDS)
SERIAL_ECHOPGM(" ; Host handling ");
serialprint_onoff(runout.host_handling);
@@ -76,19 +66,18 @@ void GcodeSuite::M591() {
}
}
void GcodeSuite::M591_report(const bool forReplay/*=true*/) {
void GcodeSuite::M412_report(const bool forReplay/*=true*/) {
TERN_(MARLIN_SMALL_BUILD, return);
report_heading_etc(forReplay, F(STR_FILAMENT_RUNOUT_SENSOR));
for(int e=0; e < NUM_RUNOUT_SENSORS; e++)
SERIAL_ECHOLNPGM(
" M591"
#if MULTI_FILAMENT_SENSOR
" E", e,
#endif
" S", runout.enabled[e]
, " D", LINEAR_UNIT(runout.runout_distance(e))
, " P", runout.mode[e]
);
SERIAL_ECHOPGM(
" M412 S", runout.enabled
#if HAS_FILAMENT_RUNOUT_DISTANCE
, " D", LINEAR_UNIT(runout.runout_distance())
#endif
, " ; Sensor "
);
serialprintln_onoff(runout.enabled);
}
#endif // HAS_FILAMENT_SENSOR
+4 -5
View File
@@ -865,6 +865,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
case 407: M407(); break; // M407: Display measured filament diameter
#endif
#if HAS_FILAMENT_SENSOR
case 412: M412(); break; // M412: Enable/Disable filament runout detection
#endif
#if HAS_MULTI_LANGUAGE
case 414: M414(); break; // M414: Select multi language menu
#endif
@@ -939,11 +943,6 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
case 575: M575(); break; // M575: Set serial baudrate
#endif
#if HAS_FILAMENT_SENSOR
case 412: M412(); break; // Alias to M591
case 591: M591(); break; // M591 Configure filament runout detection
#endif
#if ENABLED(NONLINEAR_EXTRUSION)
case 592: M592(); break; // M592: Nonlinear Extrusion control
#endif
+3 -4
View File
@@ -234,6 +234,7 @@
* M406 - Disable Filament Sensor flow control. (Requires FILAMENT_WIDTH_SENSOR)
* M407 - Display measured filament diameter in millimeters. (Requires FILAMENT_WIDTH_SENSOR)
* M410 - Quickstop. Abort all planned moves.
* M412 - Enable / Disable Filament Runout Detection. (Requires FILAMENT_RUNOUT_SENSOR)
* M413 - Enable / Disable Power-Loss Recovery. (Requires POWER_LOSS_RECOVERY)
* M414 - Set language by index. (Requires LCD_LANGUAGE_2...)
* M420 - Enable/Disable Leveling (with current values) S1=enable S0=disable (Requires MESH_BED_LEVELING or ABL)
@@ -258,7 +259,6 @@
* M554 - Get or set IP gateway. (Requires enabled Ethernet port)
* M569 - Enable stealthChop on an axis. (Requires at least one _DRIVER_TYPE to be TMC2130/2160/2208/2209/5130/5160)
* M575 - Change the serial baud rate. (Requires BAUD_RATE_GCODE)
* M591 - Configure Filament Runout Detection. (Requires FILAMENT_RUNOUT_SENSOR)
* M592 - Get or set nonlinear extrusion parameters. (Requires NONLINEAR_EXTRUSION)
* M593 - Get or set input shaping parameters. (Requires INPUT_SHAPING_[XY])
* M600 - Pause for filament change: "M600 X<pos> Y<pos> Z<raise> E<first_retract> L<later_retract>". (Requires ADVANCED_PAUSE_FEATURE)
@@ -1035,9 +1035,8 @@ private:
#endif
#if HAS_FILAMENT_SENSOR
static void M412() { M591(); }
static void M591();
static void M591_report(const bool forReplay=true);
static void M412();
static void M412_report(const bool forReplay=true);
#endif
#if HAS_MULTI_LANGUAGE
+1 -1
View File
@@ -154,7 +154,7 @@ void GcodeSuite::M115() {
// AUTOLEVEL (G29)
cap_line(F("AUTOLEVEL"), ENABLED(HAS_AUTOLEVEL));
// RUNOUT (M591, M600)
// RUNOUT (M412, M600)
cap_line(F("RUNOUT"), ENABLED(FILAMENT_RUNOUT_SENSOR));
// Z_PROBE (G30)
-2
View File
@@ -373,8 +373,6 @@ void plan_arc(
planner.apply_leveling(raw);
#endif
hints.curve_radius = i > 1 ? radius : 0;
// calculate safe speed for stopping by the end of the arc
const float arc_mm_remaining = flat_mm - segment_mm * i;
hints.safe_exit_speed_sqr = _MIN(limiting_speed_sqr, 2 * limiting_accel * arc_mm_remaining);
+24 -32
View File
@@ -1191,14 +1191,10 @@
* Fill in undefined Filament Sensor options
*/
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
#define HAS_FILAMENT_SENSOR 1
#ifndef NUM_RUNOUT_SENSORS
#define NUM_RUNOUT_SENSORS E_STEPPERS
#endif
#if ENABLED(MIXING_EXTRUDER)
#define WATCH_ALL_RUNOUT_SENSORS
#endif
#if NUM_RUNOUT_SENSORS >= 1
#ifndef FIL_RUNOUT1_STATE
#define FIL_RUNOUT1_STATE FIL_RUNOUT_STATE
#endif
#ifndef FIL_RUNOUT1_PULLUP
#define FIL_RUNOUT1_PULLUP FIL_RUNOUT_PULLUP
#endif
@@ -1207,7 +1203,9 @@
#endif
#endif
#if NUM_RUNOUT_SENSORS >= 2
#define MULTI_FILAMENT_SENSOR 1
#ifndef FIL_RUNOUT2_STATE
#define FIL_RUNOUT2_STATE FIL_RUNOUT_STATE
#endif
#ifndef FIL_RUNOUT2_PULLUP
#define FIL_RUNOUT2_PULLUP FIL_RUNOUT_PULLUP
#endif
@@ -1216,6 +1214,9 @@
#endif
#endif
#if NUM_RUNOUT_SENSORS >= 3
#ifndef FIL_RUNOUT3_STATE
#define FIL_RUNOUT3_STATE FIL_RUNOUT_STATE
#endif
#ifndef FIL_RUNOUT3_PULLUP
#define FIL_RUNOUT3_PULLUP FIL_RUNOUT_PULLUP
#endif
@@ -1224,6 +1225,9 @@
#endif
#endif
#if NUM_RUNOUT_SENSORS >= 4
#ifndef FIL_RUNOUT4_STATE
#define FIL_RUNOUT4_STATE FIL_RUNOUT_STATE
#endif
#ifndef FIL_RUNOUT4_PULLUP
#define FIL_RUNOUT4_PULLUP FIL_RUNOUT_PULLUP
#endif
@@ -1232,6 +1236,9 @@
#endif
#endif
#if NUM_RUNOUT_SENSORS >= 5
#ifndef FIL_RUNOUT5_STATE
#define FIL_RUNOUT5_STATE FIL_RUNOUT_STATE
#endif
#ifndef FIL_RUNOUT5_PULLUP
#define FIL_RUNOUT5_PULLUP FIL_RUNOUT_PULLUP
#endif
@@ -1240,6 +1247,9 @@
#endif
#endif
#if NUM_RUNOUT_SENSORS >= 6
#ifndef FIL_RUNOUT6_STATE
#define FIL_RUNOUT6_STATE FIL_RUNOUT_STATE
#endif
#ifndef FIL_RUNOUT6_PULLUP
#define FIL_RUNOUT6_PULLUP FIL_RUNOUT_PULLUP
#endif
@@ -1248,6 +1258,9 @@
#endif
#endif
#if NUM_RUNOUT_SENSORS >= 7
#ifndef FIL_RUNOUT7_STATE
#define FIL_RUNOUT7_STATE FIL_RUNOUT_STATE
#endif
#ifndef FIL_RUNOUT7_PULLUP
#define FIL_RUNOUT7_PULLUP FIL_RUNOUT_PULLUP
#endif
@@ -1256,6 +1269,9 @@
#endif
#endif
#if NUM_RUNOUT_SENSORS >= 8
#ifndef FIL_RUNOUT8_STATE
#define FIL_RUNOUT8_STATE FIL_RUNOUT_STATE
#endif
#ifndef FIL_RUNOUT8_PULLUP
#define FIL_RUNOUT8_PULLUP FIL_RUNOUT_PULLUP
#endif
@@ -1865,30 +1881,6 @@
#define NEOPIXEL_BKGD_INDEX_LAST NEOPIXEL_BKGD_INDEX_FIRST
#endif
/*** TEMPORARY COMPATIBILITY ***/
#if HAS_FILAMENT_SENSOR
#ifndef FIL_RUNOUT_ENABLED
#if FIL_RUNOUT_ENABLED_DEFAULT
#define FIL_RUNOUT_ENABLED ARRAY_N_1(NUM_RUNOUT_SENSORS, true)
#else
#define FIL_RUNOUT_ENABLED ARRAY_N_1(NUM_RUNOUT_SENSORS, false)
#endif
#endif
#ifndef FIL_RUNOUT_MODE
#if FIL_RUNOUT_STATE
#define FIL_RUNOUT_MODE ARRAY_N_1(NUM_RUNOUT_SENSORS, 1)
#else
#define FIL_RUNOUT_MODE ARRAY_N_1(NUM_RUNOUT_SENSORS, 2)
#endif
#endif
#ifndef FIL_RUNOUT_DISTANCE_MM
#define FIL_RUNOUT_DISTANCE_MM ARRAY_N_1(NUM_RUNOUT_SENSORS, 10)
#endif
#undef FIL_RUNOUT_ENABLED_DEFAULT
#undef FIL_RUNOUT_STATE
#undef FILAMENT_RUNOUT_DISTANCE_MM
#endif
#if ALL(SPI_FLASH, HAS_MEDIA, MARLIN_DEV_MODE)
#define SPI_FLASH_BACKUP 1
#endif
-6
View File
@@ -954,12 +954,6 @@
#define HAS_MOTOR_CURRENT_I2C 1
#endif
#if ENABLED(DUAL_X_CARRIAGE)
#ifndef INVERT_X2_DIR
#define INVERT_X2_DIR INVERT_X_DIR
#endif
#endif
// X2 but not IDEX => Dual Synchronized X Steppers
#if defined(X2_DRIVER_TYPE) && DISABLED(DUAL_X_CARRIAGE)
#define HAS_SYNCED_X_STEPPERS 1
+1 -1
View File
@@ -2902,7 +2902,7 @@
#define HAS_TEMPERATURE 1
#endif
#if HAS_TEMPERATURE && ANY(HAS_MARLINUI_MENU, HAS_DWIN_E3V2, HAS_DGUS_LCD_CLASSIC, DGUS_LCD_UI_CREALITY_TOUCH)
#if HAS_TEMPERATURE && ANY(HAS_MARLINUI_MENU, HAS_DWIN_E3V2, HAS_DGUS_LCD_CLASSIC)
#ifdef PREHEAT_10_LABEL
#define PREHEAT_COUNT 10
#elif defined(PREHEAT_9_LABEL)
+16 -83
View File
@@ -235,11 +235,9 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
#error "SERIAL_XON_XOFF and SERIAL_STATS_* features not supported on USB-native AVR devices."
#endif
// Serial DMA is only available for some STM32 MCUs and HC32
// Serial DMA is only available for some STM32 MCUs
#if ENABLED(SERIAL_DMA)
#if defined(ARDUINO_ARCH_HC32)
// checks for HC32 are located in HAL/HC32/inc/SanityCheck.h
#elif !HAL_STM32 || NONE(STM32F0xx, STM32F1xx, STM32F2xx, STM32F4xx, STM32F7xx)
#if !HAL_STM32 || NONE(STM32F0xx, STM32F1xx, STM32F2xx, STM32F4xx, STM32F7xx)
#error "SERIAL_DMA is only available for some STM32 MCUs and requires HAL/STM32."
#elif !defined(HAL_UART_MODULE_ENABLED) || defined(HAL_UART_MODULE_ONLY)
#error "SERIAL_DMA requires STM32 platform HAL UART (without HAL_UART_MODULE_ONLY)."
@@ -541,71 +539,10 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
#error "You can't enable FIL_RUNOUT7_PULLUP and FIL_RUNOUT7_PULLDOWN at the same time."
#elif ALL(FIL_RUNOUT8_PULLUP, FIL_RUNOUT8_PULLDOWN)
#error "You can't enable FIL_RUNOUT8_PULLUP and FIL_RUNOUT8_PULLDOWN at the same time."
#elif DISABLED(ADVANCED_PAUSE_FEATURE)
static_assert(nullptr == strstr(FILAMENT_RUNOUT_SCRIPT, "M600"), "ADVANCED_PAUSE_FEATURE is required to use M600 with FILAMENT_RUNOUT_SENSOR.");
#elif defined(FIL_RUNOUT_ENABLED_DEFAULT)
#error "FIL_RUNOUT_ENABLED_DEFAULT is now set with the FILAMENT_RUNOUT_ENABLED array."
#elif defined(FILAMENT_RUNOUT_DISTANCE_MM)
#error "FILAMENT_RUNOUT_DISTANCE_MM is now set with the FIL_RUNOUT_DISTANCE_MM array."
#elif defined(FIL_RUNOUT_STATE) || defined(FIL_RUNOUT2_STATE) || defined(FIL_RUNOUT3_STATE) || defined(FIL_RUNOUT4_STATE) || defined(FIL_RUNOUT5_STATE) || defined(FIL_RUNOUT6_STATE) || defined(FIL_RUNOUT7_STATE) || defined(FIL_RUNOUT8_STATE)
#ifdef FIL_RUNOUT_STATE
#if FIL_RUNOUT_STATE
#error "FIL_RUNOUT_STATE HIGH is now set with FIL_RUNOUT_MODE { 2 ... }."
#else
#error "FIL_RUNOUT_STATE LOW is now set with FIL_RUNOUT_MODE { 1 ... }."
#endif
#endif
#ifdef FIL_RUNOUT2_STATE
#if FIL_RUNOUT2_STATE
#error "FIL_RUNOUT2_STATE HIGH is now set with FIL_RUNOUT_MODE { n, 2 ... }."
#else
#error "FIL_RUNOUT2_STATE LOW is now set with FIL_RUNOUT_MODE { n, 1 ... }."
#endif
#endif
#ifdef FIL_RUNOUT3_STATE
#if FIL_RUNOUT3_STATE
#error "FIL_RUNOUT3_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, 2 ... }."
#else
#error "FIL_RUNOUT3_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, 1 ... }."
#endif
#endif
#ifdef FIL_RUNOUT4_STATE
#if FIL_RUNOUT4_STATE
#error "FIL_RUNOUT4_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, n, 2 ... }."
#else
#error "FIL_RUNOUT4_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, n, 1 ... }."
#endif
#endif
#ifdef FIL_RUNOUT5_STATE
#if FIL_RUNOUT5_STATE
#error "FIL_RUNOUT5_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, n, n, 2 ... }."
#else
#error "FIL_RUNOUT5_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, n, n, 1 ... }."
#endif
#endif
#ifdef FIL_RUNOUT6_STATE
#if FIL_RUNOUT6_STATE
#error "FIL_RUNOUT6_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, n, n, n, 2 ... }."
#else
#error "FIL_RUNOUT6_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, n, n, n, 1 ... }."
#endif
#endif
#ifdef FIL_RUNOUT7_STATE
#if FIL_RUNOUT7_STATE
#error "FIL_RUNOUT7_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, n, n, n, n, 2 ... }."
#else
#error "FIL_RUNOUT7_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, n, n, n, n, 1 ... }."
#endif
#endif
#ifdef FIL_RUNOUT8_STATE
#if FIL_RUNOUT8_STATE
#error "FIL_RUNOUT8_STATE HIGH is now set with FIL_RUNOUT_MODE { n, n, n, n, n, n, n, 2 ... }."
#else
#error "FIL_RUNOUT8_STATE LOW is now set with FIL_RUNOUT_MODE { n, n, n, n, n, n, n, 1 ... }."
#endif
#endif
#elif ENABLED(FILAMENT_MOTION_SENSOR)
#error "FILAMENT_MOTION_SENSOR is now set with FIL_RUNOUT_MODE { 7 ... }."
#elif FILAMENT_RUNOUT_DISTANCE_MM < 0
#error "FILAMENT_RUNOUT_DISTANCE_MM must be greater than or equal to zero."
#elif DISABLED(ADVANCED_PAUSE_FEATURE) && defined(FILAMENT_RUNOUT_SCRIPT)
static_assert(nullptr == strstr(FILAMENT_RUNOUT_SCRIPT, "M600"), "FILAMENT_RUNOUT_SCRIPT cannot make use of M600 unless ADVANCED_PAUSE_FEATURE is enabled");
#endif
#endif
@@ -1597,16 +1534,14 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i
#endif
#if ENABLED(LCD_BED_TRAMMING)
#if ENABLED(BED_TRAMMING_USE_PROBE)
#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 "BED_TRAMMING_USE_PROBE requires a real probe."
#elif ENABLED(SENSORLESS_PROBING)
#error "BED_TRAMMING_USE_PROBE is incompatible with SENSORLESS_PROBING."
#endif
#else
#ifndef BED_TRAMMING_INSET_LFRB
#error "LCD_BED_TRAMMING requires BED_TRAMMING_INSET_LFRB values."
#endif
#endif
#endif
@@ -1902,8 +1837,6 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i
#error "DUAL_X_CARRIAGE requires X2_HOME_POS, X2_MIN_POS, and X2_MAX_POS."
#elif X_HOME_TO_MAX
#error "DUAL_X_CARRIAGE requires X_HOME_DIR -1."
#elif (X2_HOME_POS <= X1_MAX_POS) || (X2_MAX_POS < X1_MAX_POS)
#error "DUAL_X_CARRIAGE will crash if X1 can meet or exceed X2 travel."
#endif
#endif
@@ -2707,7 +2640,7 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i
+ COUNT_ENABLED(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON, ANYCUBIC_TFT35, ANYCUBIC_LCD_VYPER) \
+ DGUS_UI_IS(ORIGIN) + DGUS_UI_IS(FYSETC) + DGUS_UI_IS(HIPRECY) + DGUS_UI_IS(MKS) + DGUS_UI_IS(RELOADED) + DGUS_UI_IS(IA_CREALITY) \
+ COUNT_ENABLED(ENDER2_STOCKDISPLAY, CR10_STOCKDISPLAY) \
+ COUNT_ENABLED(DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_PORTRAIT, DWIN_MARLINUI_LANDSCAPE, DGUS_LCD_UI_CREALITY_TOUCH) \
+ 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) \
@@ -3635,9 +3568,9 @@ static_assert(_PLUS_TEST(3), "DEFAULT_MAX_ACCELERATION values must be positive."
#error "LED_CONTROL_MENU requires an LCD controller that implements the menu."
#endif
//#if ENABLED(CUSTOM_MENU_MAIN) && NONE(HAS_MARLINUI_MENU, TOUCH_UI_FTDI_EVE, TFT_LVGL_UI)
//#error "CUSTOM_MENU_MAIN requires an LCD controller that implements the menu."
//#endif
#if ENABLED(CUSTOM_MENU_MAIN) && NONE(HAS_MARLINUI_MENU, TOUCH_UI_FTDI_EVE, TFT_LVGL_UI)
#error "CUSTOM_MENU_MAIN requires an LCD controller that implements the menu."
#endif
#if ENABLED(CASE_LIGHT_USE_NEOPIXEL) && DISABLED(NEOPIXEL_LED)
#error "CASE_LIGHT_USE_NEOPIXEL requires NEOPIXEL_LED."
@@ -4002,11 +3935,11 @@ static_assert(_PLUS_TEST(3), "DEFAULT_MAX_ACCELERATION values must be positive."
#if !(defined(WIFI_SSID) && defined(WIFI_PWD))
#error "ESP32 motherboard with WIFISUPPORT requires WIFI_SSID and WIFI_PWD."
#endif
#elif ENABLED(WIFI_CUSTOM_COMMAND) && NONE(ESP3D_WIFISUPPORT, WIFISUPPORT)
#elif ENABLED(WIFI_CUSTOM_COMMAND)
#error "WIFI_CUSTOM_COMMAND requires an ESP32 motherboard and WIFISUPPORT."
#elif ENABLED(OTASUPPORT) && NONE(ESP3D_WIFISUPPORT, WIFISUPPORT)
#elif ENABLED(OTASUPPORT)
#error "OTASUPPORT requires an ESP32 motherboard and WIFISUPPORT."
#elif (defined(WIFI_SSID) || defined(WIFI_PWD)) && NONE(ESP3D_WIFISUPPORT, WIFISUPPORT)
#elif defined(WIFI_SSID) || defined(WIFI_PWD)
#error "WIFI_SSID and WIFI_PWD only apply to ESP32 motherboard with WIFISUPPORT."
#endif
+1 -1
View File
@@ -42,7 +42,7 @@
* version was tagged.
*/
#ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "2024-04-15"
#define STRING_DISTRIBUTION_DATE "2024-04-08"
#endif
/**
+1 -1
View File
@@ -99,7 +99,7 @@
#warning "Warning! Don't use dummy thermistors (998/999) for final build!"
#endif
#if NONE(HAS_RESUME_CONTINUE, HOST_PROMPT_SUPPORT, UNIT_TEST)
#if NONE(HAS_RESUME_CONTINUE, HOST_PROMPT_SUPPORT)
#warning "Your Configuration provides no method to acquire user feedback!"
#endif
+1 -1
View File
@@ -1169,7 +1169,7 @@ void MarlinUI::draw_status_screen() {
lcd_moveto(LCD_WIDTH - 9, 2);
lcd_put_lchar('S');
#endif // LCD_INFO_SCREEN_STYLE
+1 -7
View File
@@ -377,13 +377,7 @@ void MarlinUI::draw_kill_screen() {
void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
#if HAS_DISPLAY_SLEEP
void MarlinUI::sleep_display(const bool sleep/*=true*/) {
static bool asleep = false;
if (asleep != sleep){
sleep ? u8g.sleepOn() : u8g.sleepOff();
asleep = sleep;
}
}
void MarlinUI::sleep_display(const bool sleep/*=true*/) { sleep ? u8g.sleepOn() : u8g.sleepOff(); }
#endif
#if HAS_LCD_BRIGHTNESS
@@ -84,7 +84,7 @@ TFT_IO tftio;
#define X_HI (UPSCALE(TFT_PIXEL_OFFSET_X, WIDTH) - 1)
#define Y_HI (UPSCALE(TFT_PIXEL_OFFSET_Y, HEIGHT) - 1)
// RGB565 color picker: https://rgbcolorpicker.com/565
// RGB565 color picker: https://embeddednotepad.com/page/rgb565-color-picker
// Hex code to color name: https://www.color-name.com/
#define COLOR_BLACK 0x0000 // #000000
+3 -7
View File
@@ -2950,11 +2950,7 @@ void hmiControl() {
void hmiLeveling() {
popupWindowLeveling();
dwinUpdateLCD();
#if defined(MAIN_MENU_ITEM_1_GCODE)
queue.inject(F(MAIN_MENU_ITEM_1_GCODE));
#else
queue.inject(F("G28O\nG29\nG28\nG1Z0"));
#endif
queue.inject(F("G28O\nG29"));
}
#endif
@@ -4072,8 +4068,8 @@ void hmiInit() {
hmiSDCardInit();
for (uint16_t t = 0; t <= 100; t += 2) {
dwinIconShow(ICON, ICON_Bar, 15, 450);
dwinDrawRectangle(1, COLOR_BG_BLACK, 15 + t * 242 / 100, 450, 257, 470);
dwinIconShow(ICON, ICON_Bar, 15, 260);
dwinDrawRectangle(1, COLOR_BG_BLACK, 15 + t * 242 / 100, 260, 257, 280);
dwinUpdateLCD();
delay(20);
}
@@ -48,7 +48,6 @@ void dwinStartup() {
dwinFrameClear(COLOR_BG_BLACK); // MarlinUI handles the bootscreen so just clear here
dwinJPGShowAndCache(3);
dwinUpdateLCD();
dwinJPGShowAndCache(3);
}
/*---------------------------------------- Picture related functions ----------------------------------------*/
+2 -2
View File
@@ -108,8 +108,8 @@ void MarlinUI::clear_lcd() {
#define INFO_CENTER ((LCD_PIXEL_WIDTH) - 200 / 2)
#define VERSION_Y 84
#endif
dwinJPGShowAndCache(0); // Ensure DACAI stays on boot screen
dwinDrawString(false, font10x20, COLOR_YELLOW, COLOR_BG_BLACK, INFO_CENTER - (dwin_string.length * 10) / 2, 230, S(dwin_string.string()));
dwinDrawString(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();
+6 -11
View File
@@ -199,7 +199,7 @@ typedef struct {
} select_t;
select_t select_page{0}, select_print{0};
#if ENABLED(LCD_BED_TRAMMING) && DISABLED(BED_TRAMMING_USE_PROBE)
#if ENABLED(LCD_BED_TRAMMING)
constexpr float bed_tramming_inset_lfbr[] = BED_TRAMMING_INSET_LFRB;
#endif
@@ -2318,12 +2318,12 @@ void setMoveZ() { hmiValue.axis = Z_AXIS; setPFloatOnClick(Z_MIN_POS, Z_MAX_POS,
#if HAS_FILAMENT_SENSOR
void setRunoutEnable() {
runout.reset();
runout.enabled[0] = !runout.enabled[0];
Draw_Chkb_Line(CurrentMenu->line(), runout.enabled[0]);
DWIN_UpdateLCD();
toggleCheckboxLine(runout.enabled);
}
void ApplyRunoutDistance() { runout.set_runout_distance(MenuData.Value / MINUNITMULT); }
void SetRunoutDistance() { SetFloatOnClick(0, 999, UNITFDIGITS, runout.runout_distance(), ApplyRunoutDistance); }
#if HAS_FILAMENT_RUNOUT_DISTANCE
void applyRunoutDistance() { runout.set_runout_distance(menuData.value / MINUNITMULT); }
void setRunoutDistance() { setFloatOnClick(0, 999, UNITFDIGITS, runout.runout_distance(), applyRunoutDistance); }
#endif
#endif
#if ENABLED(CONFIGURE_FILAMENT_CHANGE)
@@ -2388,11 +2388,6 @@ void setFlow() { setPIntOnClick(FLOW_EDIT_MIN, FLOW_EDIT_MAX, []{ planner.refres
#if ENABLED(LCD_BED_TRAMMING)
void tramXY(const uint8_t point, float &x, float &y) {
#if ENABLED(BED_TRAMMING_USE_PROBE)
float bed_tramming_inset_lfbr[] = {X_MIN_BED + probe.min_x() + 0.01f, Y_MIN_BED + probe.min_y() + 0.01f,
X_MAX_BED - probe.max_x() - 0.01f, Y_MAX_BED - probe.max_y() - 0.01f };
#endif
switch (point) {
case 0:
LCD_MESSAGE(MSG_TRAM_FL);
+1 -1
View File
@@ -85,7 +85,7 @@ void ESDiag::update() {
TERN_(USE_X_MIN, ES_REPORT(X_MIN)); TERN_(USE_X_MAX, ES_REPORT(X_MAX));
TERN_(USE_Y_MIN, ES_REPORT(Y_MIN)); TERN_(USE_Y_MAX, ES_REPORT(Y_MAX));
TERN_(USE_Z_MIN, ES_REPORT(Z_MIN)); TERN_(USE_Z_MAX, ES_REPORT(Z_MAX));
TERN_(HAS_FILAMENT_SENSOR, draw_es_state(READ(FIL_RUNOUT1_PIN) != runout.out_state());
TERN_(HAS_FILAMENT_SENSOR, draw_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE));
dwinUpdateLCD();
}
@@ -1,357 +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 <https://www.gnu.org/licenses/>.
*
*/
/* DGUS implementation written by coldtobi in 2019 for Marlin */
#include "../../../inc/MarlinConfigPre.h"
#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#define DEBUG_ECHOLNPAIR DEBUG_ECHOLNPGM
#if HOTENDS > 2
#error "More than 2 hotends not implemented on the Display UI design."
#endif
#include "../ui_api.h"
#include "../../../MarlinCore.h"
#include "../../../module/temperature.h"
#include "../../../module/motion.h"
#include "../../../gcode/queue.h"
#include "../../../module/planner.h"
#include "../../../sd/cardreader.h"
#include "../../../libs/duration_t.h"
#include "../../../module/printcounter.h"
#if ENABLED(POWER_LOSS_RECOVERY)
#include "../../../feature/powerloss.h"
#endif
#include "DGUSDisplay.h"
#include "DGUSVPVariable.h"
#include "DGUSDisplayDef.h"
// Preamble... 2 Bytes, usually 0x5A 0xA5, but configurable
constexpr uint8_t DGUS_HEADER1 = 0x5A;
constexpr uint8_t DGUS_HEADER2 = 0xA5;
constexpr uint8_t DGUS_CMD_WRITEVAR = 0x82;
constexpr uint8_t DGUS_CMD_READVAR = 0x83;
#if ENABLED(DEBUG_DGUSLCD)
bool dguslcd_local_debug; // = false;
#endif
#define dgusserial LCD_SERIAL
void DGUSDisplay::InitDisplay() {
dgusserial.begin(LCD_BAUDRATE);
/*delay(500); // Attempt to fix possible handshake error
ResetDisplay(); // Reset for firmware update
delay(500); // Attempt to fix possible handshake error
*/
if (true
#if ENABLED(POWER_LOSS_RECOVERY)
&& !recovery.valid()
#endif
)
RequestScreen(
#if ENABLED(SHOW_BOOTSCREEN)
DGUSLCD_SCREEN_BOOT
#else
DGUSLCD_SCREEN_MAIN
#endif
);
}
void DGUSDisplay::ResetDisplay() {
SERIAL_ECHOLN("ResetDisplay");
const unsigned char resetCommand[] = { 0x55, 0xAA, 0x5A, 0xA5 };
WriteVariable(0x04, resetCommand, sizeof(resetCommand));
}
void DGUSDisplay::ReadVariable(uint16_t adr) {
WriteHeader(adr, DGUS_CMD_READVAR, sizeof(uint8_t));
// Specify to read one byte
dgusserial.write(static_cast<uint8_t>(1));
}
void DGUSDisplay::WriteVariable(uint16_t adr, const void* values, uint8_t valueslen, bool isstr, char fillChar) {
const char* myvalues = static_cast<const char*>(values);
bool strend = !myvalues;
WriteHeader(adr, DGUS_CMD_WRITEVAR, valueslen);
while (valueslen--) {
char x;
if (!strend) x = *myvalues++;
if ((isstr && !x) || strend) {
strend = true;
x = fillChar;
}
dgusserial.write(x);
}
}
void DGUSDisplay::WriteVariable(uint16_t adr, uint16_t value) {
value = (value & 0xffU) << 8U | (value >> 8U);
WriteVariable(adr, static_cast<const void*>(&value), sizeof(uint16_t));
}
void DGUSDisplay::WriteVariable(uint16_t adr, int16_t value) {
union { int16_t l; char lb[2]; } endian;
char tmp[2];
endian.l = value;
tmp[0] = endian.lb[1];
tmp[1] = endian.lb[0];
WriteVariable(adr, static_cast<const void*>(&tmp), sizeof(int16_t));
}
void DGUSDisplay::WriteVariable(uint16_t adr, uint8_t value) {
WriteVariable(adr, static_cast<const void*>(&value), sizeof(uint8_t));
}
void DGUSDisplay::WriteVariable(uint16_t adr, int8_t value) {
WriteVariable(adr, static_cast<const void*>(&value), sizeof(int8_t));
}
void DGUSDisplay::WriteVariable(uint16_t adr, long value) {
union { long l; char lb[4]; } endian;
char tmp[4];
endian.l = value;
tmp[0] = endian.lb[3];
tmp[1] = endian.lb[2];
tmp[2] = endian.lb[1];
tmp[3] = endian.lb[0];
WriteVariable(adr, static_cast<const void*>(&tmp), sizeof(long));
}
void DGUSDisplay::WriteVariable(uint16_t adr, float value) {
static_assert(sizeof(float) == 4);
union { float l; char lb[4]; } endian;
char tmp[4];
endian.l = value;
tmp[0] = endian.lb[3];
tmp[1] = endian.lb[2];
tmp[2] = endian.lb[1];
tmp[3] = endian.lb[0];
WriteVariable(adr, static_cast<const void*>(&tmp), sizeof(float));
}
void DGUSDisplay::WriteVariablePGM(uint16_t adr, const void* values, uint8_t valueslen, bool isstr, char fillChar) {
const char* myvalues = static_cast<const char*>(values);
bool strend = !myvalues;
WriteHeader(adr, DGUS_CMD_WRITEVAR, valueslen);
while (valueslen--) {
char x;
if (!strend) x = pgm_read_byte(myvalues++);
if ((isstr && !x) || strend) {
strend = true;
x = fillChar;
}
dgusserial.write(x);
}
}
void DGUSDisplay::SetVariableDisplayColor(uint16_t sp, uint16_t color) {
WriteVariable(sp + 0x03, color);
}
void DGUSDisplay::ProcessRx() {
#if ENABLED(DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS)
if (!dgusserial.available() && dgusserial.buffer_overruns()) {
// Overrun, but reset the flag only when the buffer is empty
// We want to extract as many as valid datagrams possible...
DEBUG_ECHOPGM("OVFL");
rx_datagram_state = DGUS_IDLE;
//dgusserial.reset_rx_overun();
dgusserial.flush();
}
#endif
uint8_t receivedbyte;
while (dgusserial.available()) {
switch (rx_datagram_state) {
case DGUS_IDLE: // Waiting for the first header byte
receivedbyte = dgusserial.read();
//DEBUGLCDCOMM_ECHOPAIR("< ",receivedbyte);
if (DGUS_HEADER1 == receivedbyte) rx_datagram_state = DGUS_HEADER1_SEEN;
break;
case DGUS_HEADER1_SEEN: // Waiting for the second header byte
receivedbyte = dgusserial.read();
//DEBUGLCDCOMM_ECHOPAIR(" ", 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 = dgusserial.read();
//DEBUGLCDCOMM_ECHOPAIR(" (", 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;
break;
case DGUS_WAIT_TELEGRAM: // wait for complete datagram to arrive.
if (dgusserial.available() < rx_datagram_len) return;
Initialized = true; // We've talked to it, so we defined it as initialized.
uint8_t command = dgusserial.read();
// DEBUGLCDCOMM_ECHOPAIR("# ", 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 = dgusserial.read();
//DEBUGLCDCOMM_ECHOPAIR(" ", receivedbyte);
*ptmp++ = receivedbyte;
}
//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(">");
rx_datagram_state = DGUS_IDLE;
break;
}
/* AutoUpload, (and answer to) Command 0x83 :
| tmp[0 1 2 3 4 ... ]
| Example 5A A5 06 83 20 01 01 78 01
| / / | | \ / | \ \
| Header | | | | \_____\_ DATA (Words!)
| DatagramLen / VPAdr |
| Command DataLen (in Words) */
if (command == DGUS_CMD_READVAR) {
const uint16_t vp = tmp[0] << 8 | tmp[1];
//const uint8_t dlen = tmp[2] << 1; // Convert to Bytes. (Display works with words)
//DEBUG_ECHOPAIR(" vp=", vp, " dlen=", dlen);
DGUS_VP_Variable ramcopy;
DEBUG_ECHOLNPAIR("VP received: ", vp , " - val ", tmp[3]);
if (populate_VPVar(vp, &ramcopy)) {
if (ramcopy.set_by_display_handler)
ramcopy.set_by_display_handler(ramcopy, &tmp[3]);
else
DEBUG_ECHOLNPGM(" VPVar found, no handler.");
}
else
DEBUG_ECHOLNPAIR(" VPVar not found:", vp);
rx_datagram_state = DGUS_IDLE;
break;
}
// discard anything else
rx_datagram_state = DGUS_IDLE;
}
}
}
size_t DGUSDisplay::GetFreeTxBuffer() { return SERIAL_GET_TX_BUFFER_FREE(); }
void DGUSDisplay::WriteHeader(uint16_t adr, uint8_t cmd, uint8_t payloadlen) {
dgusserial.write(DGUS_HEADER1);
dgusserial.write(DGUS_HEADER2);
dgusserial.write(payloadlen + 3);
dgusserial.write(cmd);
dgusserial.write(adr >> 8);
dgusserial.write(adr & 0xFF);
}
void DGUSDisplay::WritePGM(const char str[], uint8_t len) {
while (len--) dgusserial.write(pgm_read_byte(str++));
}
void DGUSDisplay::loop() {
// protect against recursion… ProcessRx() may indirectly call idle() when injecting gcode commands.
if (!no_reentrance) {
no_reentrance = true;
ProcessRx();
//Because crappy VPHELPER macros cant take calcs or functions, process updated value here. If we handle only in button handler code, we will miss changes over M290
dgusdisplay.WriteVariable(VP_Z_OFFSET, (int16_t)(100*ExtUI::getZOffset_mm()));
no_reentrance = false;
}
}
void DGUSDisplay::RequestScreen(DGUSLCD_Screens screen) {
displayRequest = screen;
DEBUG_ECHOLNPAIR("GotoScreen ", screen);
const unsigned char gotoscreen[] = { 0x5A, 0x01, (unsigned char) (screen >> 8U), (unsigned char) (screen & 0xFFU) };
WriteVariable(0x84, gotoscreen, sizeof(gotoscreen));
}
void DGUSDisplay::SetTouchScreenConfiguration(bool enable_standby, bool enable_sound, uint8_t standby_brightness, uint8_t brightness, uint16_t standbyTimeSeconds) {
// Main configuration (System_Config)
unsigned char cfg_bits = 0x0;
cfg_bits |= 1UL << 5; // 5: load 22 touch file
cfg_bits |= 1UL << 4; // 4: auto-upload should always be enabled
if (enable_sound) cfg_bits |= 1UL << 3; // 3: audio
if (enable_standby) cfg_bits |= 1UL << 2; // 2: backlight on standby
cfg_bits |= 1UL << 1; // 1 & 0: 270 degrees orientation of display
cfg_bits |= 1UL << 0;
DEBUG_ECHOLNPAIR("Update touch screen config - standby ", enable_standby);
DEBUG_ECHOLNPAIR("Update touch screen config - sound ", enable_sound);
const unsigned char config_set[] = { 0x5A, 0x00, (unsigned char) (cfg_bits >> 8U), (unsigned char) (cfg_bits & 0xFFU) };
WriteVariable(0x80 /*System_Config*/, config_set, sizeof(config_set));
// Standby brightness (LED_Config)
uint16_t dwinStandbyTimeSeconds = 100 * standbyTimeSeconds; /* milliseconds, but divided by 10 (not 5 like the docs say) */
const unsigned char brightness_set[] = {
brightness /*% active*/,
standby_brightness /*% standby*/,
static_cast<uint8_t>(dwinStandbyTimeSeconds >> 8),
static_cast<uint8_t>(dwinStandbyTimeSeconds)
};
WriteVariable(0x82 /*LED_Config*/, brightness_set, sizeof(brightness_set));
}
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;
DGUSLCD_Screens DGUSDisplay::displayRequest = DGUSLCD_SCREEN_BOOT;
// 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_ECHOLNPAIR("populate_VPVar ", VP);
const DGUS_VP_Variable *pvp = DGUSLCD_FindVPVar(VP);
// DEBUG_ECHOLNPAIR(" pvp ", (uint16_t )pvp);
if (!pvp) return false;
memcpy_P(ramcopy, pvp, sizeof(DGUS_VP_Variable));
return true;
}
#endif // HAS_DGUS_LCD
@@ -1,136 +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 <https://www.gnu.org/licenses/>.
*
*/
#pragma once
//#define DEBUG_DGUSLCD
//#define DEBUG_DGUSLCD_OUTGOING_COMM
/* Creality DGUS implementation written by Sebastiaan Dammann in 2020 for Marlin */
#include "../../../inc/MarlinConfigPre.h"
#include "../../../MarlinCore.h"
#if HAS_BED_PROBE
#include "../../../module/probe.h"
#endif
#include "DGUSVPVariable.h"
enum DGUSLCD_Screens : uint8_t;
#ifndef DEBUG_OUT
#define DEBUG_OUT ENABLED(DEBUG_DGUSLCD)
#endif
#include "../../../core/debug_out.h"
typedef enum : uint8_t {
DGUS_IDLE, //< waiting for DGUS_HEADER1.
DGUS_HEADER1_SEEN, //< DGUS_HEADER1 received
DGUS_HEADER2_SEEN, //< DGUS_HEADER2 received
DGUS_WAIT_TELEGRAM, //< LEN received, Waiting for to receive all bytes.
} rx_datagram_state_t;
typedef void (*UPDATE_CURRENT_SCREEN_CALLBACK)(DGUSLCD_Screens screen);
// Low-Level access to the display.
class DGUSDisplay {
public:
DGUSDisplay() = default;
static void InitDisplay();
static void ResetDisplay();
// Variable access.
static void WriteVariable(uint16_t adr, const void* values, uint8_t valueslen, bool isstr=false, char fillChar = ' ');
static void WriteVariablePGM(uint16_t adr, const void* values, uint8_t valueslen, bool isstr=false, char fillChar = ' ');
static void WriteVariable(uint16_t adr, int16_t value);
static void WriteVariable(uint16_t adr, uint16_t value);
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 WriteVariable(uint16_t adr, float value);
static void SetVariableDisplayColor(uint16_t sp, uint16_t color);
static void ReadVariable(uint16_t adr);
// Utility functions for bridging ui_api and dgus
template<typename T, float(*Getter)(const T), T selector, typename WireType=uint16_t>
static void SetVariable(DGUS_VP_Variable &var) {
WriteVariable(var.VP, (WireType)Getter(selector));
}
template<typename T, void(*Setter)(const float V, const T), T selector>
static void GetVariable(DGUS_VP_Variable &var, void *val_ptr) {
uint16_t newvalue = swap16(*(uint16_t*)val_ptr);
Setter(newvalue, selector);
}
// Force display into another screen.
// (And trigger update of containing VPs)
// (to implement a pop up message, which may not be nested)
static void RequestScreen(DGUSLCD_Screens screen);
static void SetTouchScreenConfiguration(bool enable_standby, bool enable_sound, uint8_t standby_brightness, uint8_t active_brightness, uint16_t standbyTimeSeconds);
// Periodic tasks, eg. Rx-Queue handling.
static void loop();
public:
// Helper for users of this class to estimate if an interaction would be blocking.
static size_t GetFreeTxBuffer();
// Checks two things: Can we confirm the presence of the display and has we initiliazed it.
// (both boils down that the display answered to our chatting)
static inline 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;
static DGUSLCD_Screens displayRequest;
};
#define GET_VARIABLE(f, t, V...) (&DGUSDisplay::GetVariable<decltype(t), f, t, ##V>)
#define SET_VARIABLE(f, t, V...) (&DGUSDisplay::SetVariable<decltype(t), f, t, ##V>)
extern DGUSDisplay dgusdisplay;
// compile-time x^y
template<typename T>
constexpr T cpow(const T x, const int y) { return y == 0 ? 1.0 : x * cpow(x, y - 1); }
/// Find the flash address of a DGUS_VP_Variable for the VP.
const DGUS_VP_Variable* DGUSLCD_FindVPVar(const uint16_t vp);
/// Helper to populate a DGUS_VP_Variable for a given VP. Return false if not found.
bool populate_VPVar(const uint16_t VP, DGUS_VP_Variable * const ramcopy);
@@ -1,53 +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 <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/* DGUS implementation written by Sebastiaan Dammann in 2020 for Marlin */
#include "DGUSVPVariable.h"
#include <stdint.h>
// This file defines the interaction between Marlin and the display firmware.
// information on which screen which VP is displayed
// As this is a sparse table, two arrays are needed:
// one to list the VPs of one screen and one to map screens to the lists.
// (Strictly this would not be necessary, but allows to only send data the display needs and reducing load on Marlin)
struct VPMapping {
const uint8_t screen;
const uint16_t *VPList; // The list is null-terminated.
};
extern const struct VPMapping VPMap[];
// List of VPs handled by Marlin / The Display.
extern const struct DGUS_VP_Variable ListOfVP[];
#define DWIN_DEFAULT_FILLER_CHAR ' '
#define DWIN_SCROLLER_FILLER_CHAR 0x0
#include "../../../inc/MarlinConfig.h"
#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#include "creality_touch/DGUSDisplayDef.h"
#endif
File diff suppressed because it is too large Load Diff
@@ -1,469 +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 <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "DGUSDisplay.h"
#include "DGUSVPVariable.h"
#include "../../../inc/MarlinConfig.h"
#if HAS_COLOR_LEDS
#include "../../../feature/leds/leds.h"
#if ENABLED(PRINTER_EVENT_LEDS)
#define HAS_COLOR_LEDS_PREFERENCES 1
#endif
#endif
#include "../../../module/motion.h"
enum DGUSLCD_Screens : uint8_t;
struct creality_dwin_settings_t {
size_t settings_size;
uint8_t settings_version;
bool led_state;
bool display_standby;
bool display_sound;
int16_t standby_screen_brightness;
int16_t screen_brightness;
int16_t standby_time_seconds;
#if HAS_COLOR_LEDS_PREFERENCES
LEDColor LastLEDColor;
#endif
};
class DGUSScreenHandler {
public:
DGUSScreenHandler() = default;
static bool loop();
static void Init();
static void DefaultSettings();
static void LoadSettings(const char* buff);
static void StoreSettings(char* buff);
static void SetTouchScreenConfiguration();
static void KillScreenCalled();
static void OnPowerlossResume();
static void RequestSaveSettings();
// 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);
static void HandleDevelopmentTestButton(DGUS_VP_Variable &var, void *val_ptr);
/// "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);
static void HandleFanSpeedChanged(DGUS_VP_Variable &var, void *val_ptr);
// Hook for "Change Flowrate"
static void HandleFlowRateChanged(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)
static void TogglePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr);
// Hook for power loss recovery.
static void HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr);
#endif
// Version sanity check
static void HandleScreenVersion(DGUS_VP_Variable &var, void *val_ptr);
// Hook for settings
static void HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr);
static void HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr);
static void HandleFadeHeight(DGUS_VP_Variable &var, void *val_ptr);
// Hook for move to position
static void HandlePositionChange(DGUS_VP_Variable &var, void *val_ptr);
static void HandleToggleTouchScreenMute(DGUS_VP_Variable &var, void *val_ptr);
static void HandleToggleTouchScreenStandbySetting(DGUS_VP_Variable &var, void *val_ptr);
static void HandleTouchScreenBrightnessSetting(DGUS_VP_Variable &var, void *val_ptr);
static void HandleTouchScreenStandbyBrightnessSetting(DGUS_VP_Variable &var, void *val_ptr);
static void HandleTouchScreenStandbyTimeSetting(DGUS_VP_Variable &var, void *val_ptr);
#if HAS_PROBE_SETTINGS
static void HandleToggleProbeHeaters(DGUS_VP_Variable &var, void *val_ptr);
static void HandleToggleProbeTemperatureStabilization(DGUS_VP_Variable &var, void *val_ptr);
static void HandleToggleProbePreheatTemp(DGUS_VP_Variable &var, void *val_ptr);
#endif
#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
static void HandleZoffsetChange(DGUS_VP_Variable &var, void *val_ptr);
#if HAS_MESH
// Hook for "Change probe offset z"
static void OnMeshLevelingStart();
static void OnMeshLevelingUpdate(const int8_t x, const int8_t y, const float z);
static void InitMeshValues();
static void ResetMeshValues();
static void UpdateMeshValue(const int8_t x, const int8_t y, const float z);
static void HandleMeshPoint(DGUS_VP_Variable &var, void *val_ptr);
#endif
// LED
#if HAS_COLOR_LEDS
static void HandleLED(DGUS_VP_Variable &var, void *val_ptr);
static void SendLEDToDisplay(DGUS_VP_Variable &var);
#endif
// Hook for live z adjust action
static void HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr);
// 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);
/// 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();
static void SetPrintingFromHost();
#endif
static void HandleLEDToggle();
static void HandleFanToggle();
static void FilamentRunout();
static void OnFactoryReset();
#if HAS_BUZZER || ENABLED(SPEAKER)
static void Buzzer(const uint16_t frequency, const uint16_t duration);
#endif
static void OnHomingStart();
static void OnHomingComplete();
static void OnPrintFinished();
// 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 save_current_screen=true);
// Recall the remembered screen.
static void PopToOldScreen();
static void OnBackButton(DGUS_VP_Variable &var, void *val_ptr);
// Make the display show the screen and update all VPs in it.
static void GotoScreen(DGUSLCD_Screens screen, bool save_current_screen = true);
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_SendScrollingStringToDisplay(DGUS_VP_Variable &var);
static void DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable &var);
static void DGUSLCD_SendScrollingStringToDisplayPGM(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_SendPrintTimeWithRemainingToDisplay(DGUS_VP_Variable &var);
static void DGUSLCD_SendPrintTimeRemainingToDisplay(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);
static void DGUSLCD_SendFanSpeedToDisplay(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
static void DGUSLCD_SendAboutFirmwareWebsite(DGUS_VP_Variable &var);
static void DGUSLCD_SendAboutFirmwareVersion(DGUS_VP_Variable &var);
static void DGUSLCD_SendAboutPrintSize(DGUS_VP_Variable &var);
/// 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<typename T>
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;
}
template<DGUSLCD_Screens TPage>
static void DGUSLCD_NavigateToPage(DGUS_VP_Variable &var, void *val_ptr) {
GotoScreen(TPage);
}
template<DGUSLCD_Screens TPage, typename Handler>
static void DGUSLCD_NavigateToPage(DGUS_VP_Variable &var, void *val_ptr) {
GotoScreen(TPage);
Handler::Init();
}
/// 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<unsigned int decimals>
static void DGUSLCD_SendFloatAsLongValueToDisplay(DGUS_VP_Variable &var) {
if (var.memadr) {
double d = static_cast<double>(*(float *)var.memadr);
d *= cpow(10, decimals);
// Round - truncated values look like skipped numbers
static_assert(sizeof(long) == 4, "Assuming long is 4 bytes");
long roundedValue = static_cast<long>(round(d));
dgusdisplay.WriteVariable(var.VP, roundedValue);
}
}
// Receive a float from the display - Display will send a 2-byte integer scaled to the number of digits
template<unsigned int decimals>
static void DGUSLCD_SetFloatAsIntFromDisplay(DGUS_VP_Variable &var, void *val_ptr) {
if (var.memadr) {
uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
float value = static_cast<float>(static_cast<double>(value_raw) /cpow(10, decimals));
*(float *)var.memadr = value;
}
}
// Receive a float from the display - Display will send a 4-byte integer scaled to the number of digits
template<unsigned int decimals>
static void DGUSLCD_SetFloatAsLongFromDisplay(DGUS_VP_Variable &var, void *val_ptr) {
if (var.memadr) {
uint32_t value_raw = uInt32Value(*(uint32_t*)val_ptr);
float value = static_cast<float>(static_cast<double>(value_raw) /cpow(10, decimals));
*(float *)var.memadr = value;
}
}
static void DGUSLCD_SendULongToDisplay(DGUS_VP_Variable &var) {
if (var.memadr) {
// Round - truncated values look like skipped numbers
long roundedValue = *(uint32_t *) var.memadr;
dgusdisplay.WriteVariable(var.VP, roundedValue);
}
}
static void DGUSLCD_ReceiveULongFromDisplay(DGUS_VP_Variable &var, void* val_ptr) {
if (var.memadr) {
// Round - truncated values look like skipped numbers
uint32_t incomingValue = *(uint32_t *) val_ptr;
*(uint32_t*)var.memadr = uInt32Value(incomingValue);
}
}
// Toggle a boolean at the specified memory address
static void DGUSLCD_ToggleBoolean(DGUS_VP_Variable &var, void *val_ptr) {
if (var.memadr) {
SERIAL_ECHOLNPGM("Toggle boolean - ", var.VP);
bool* val = (bool *)var.memadr;
*val = !*val;
}
}
// Send an icon to the display, depending on whether it is true or false
template<unsigned int value_if_true, unsigned int value_if_false>
static void DGUSLCD_SendIconValue(DGUS_VP_Variable &var) {
if (var.memadr) {
bool value = *(bool *)var.memadr;
uint16_t valueToSend = value ? value_if_true : value_if_false;
dgusdisplay.WriteVariable(var.VP, valueToSend);
}
}
/// 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<unsigned int decimals>
static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) {
if (var.memadr) {
double d = static_cast<double>(*(float *)var.memadr);
d *= cpow(10, decimals);
// Round - truncated values look like skipped numbers
int16_t roundedValue = static_cast<int16_t>(round(d));
dgusdisplay.WriteVariable(var.VP, roundedValue);
}
}
template<AxisEnum Axis>
static void SendAxisTrustValue(DGUS_VP_Variable &var) {
bool trust = axis_is_trusted(Axis);
uint16_t color = trust ? 0xFFFF /*White*/ : 0XF800 /*Red*/;
dgusdisplay.SetVariableDisplayColor(var.VP, color);
}
/// 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 bool HandlePendingUserConfirmation();
static void SetSynchronousOperationStart();
static void SetSynchronousOperationFinish();
static bool HasCurrentSynchronousOperation() { return HasSynchronousOperation; }
static void SendBusyState(DGUS_VP_Variable &var);
static void SetViewMeshLevelState();
static bool fwretract_available;
private:
static void HandleScreenVersionMismatchLEDFlash();
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").
static uint8_t MeshLevelIndex;
static uint8_t MeshLevelIconIndex;
static bool SaveSettingsRequested;
static bool HasScreenVersionMismatch;
static bool HasSynchronousOperation;
#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
private:
FORCE_INLINE static DGUSLCD_Screens GetPreviousScreen() {
return past_screens[0];
}
public: // Needed for VP auto-upload
static bool HasRGBSettings;
static creality_dwin_settings_t Settings;
};
extern DGUSScreenHandler ScreenHandler;
struct DGUSSynchronousOperation {
private:
bool is_running;
public:
DGUSSynchronousOperation() : is_running(false) {}
// Don't allow this to be created on the stack
void* operator new (std::size_t size) = delete;
void start() {
is_running = true;
ScreenHandler.SetSynchronousOperationStart();
}
void done() {
is_running = false;
ScreenHandler.SetSynchronousOperationFinish();
}
~DGUSSynchronousOperation() {
if (is_running) {
ScreenHandler.SetSynchronousOperationFinish();
}
}
};
@@ -1,67 +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 <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <stdint.h>
/**
* DGUSVPVariable.h
*
* Created on: Feb 9, 2019
* Author: tobi
*/
struct DGUS_VP_Variable {
uint16_t VP;
void* memadr; // If nullptr, the value cannot be uploaded to the display.
uint8_t size;
// Callback that will be called if the display modified the value.
// nullptr makes it readonly for the display.
void (*set_by_display_handler)(DGUS_VP_Variable &var, void *val_ptr);
void (*send_to_display_handler)(DGUS_VP_Variable &var);
template<typename T>
DGUS_VP_Variable& operator =(T &o) {
*(T*)memadr = o; // warning this is not typesafe.
// TODO: Call out the display or mark as dirty for the next update.
return *this;
}
};
// endianness swap
FORCE_INLINE uint16_t swap16(const uint16_t value) { return (value & 0xffU) << 8U | (value >> 8U); }
FORCE_INLINE int16_t swap16(const int16_t value) {
union { int16_t l; char lb[2]; } endian;
endian.l = value;
char tmp = endian.lb[1];
endian.lb[1] = endian.lb[0];
endian.lb[0] = tmp;
return endian.l;
}
FORCE_INLINE uint32_t uInt32Value(const uint32_t value) { return ((value>>24)&0xff) | ((value<<8)&0xff0000) | ((value>>8)&0xff00) | ((value<<24)&0xff000000); }
FORCE_INLINE uint16_t uInt16Value(void *val_ptr) { return swap16(*static_cast<uint16_t*>(val_ptr)); }
@@ -1,230 +0,0 @@
#include "../../../../inc/MarlinConfigPre.h"
#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#include "../DGUSDisplayDef.h"
#include "../DGUSDisplay.h"
#include "../DGUSScreenHandler.h"
#include "EstepsHandler.h"
#include "AxisSettingsHandler.h"
#include "../../ui_api.h"
#include "../../../marlinui.h"
#include "../../../../module/temperature.h"
#include "../../../../module/settings.h"
#include "../../../../module/planner.h"
#include "../../../../gcode/gcode.h"
#if HAS_TRINAMIC_CONFIG
#include "../../../../feature/tmc_util.h"
#include "../../../../module/stepper/indirection.h"
#endif
AxisEnum AxisSettingsHandler::current_axis;
uint16_t AxisSettingsHandler::axis_settings_title_icon = ICON_AXIS_SETTINGS_TITLE_X;
float AxisSettingsHandler::axis_steps_mm;
uint16_t AxisSettingsHandler::max_acceleration_mm_per_s2;
float AxisSettingsHandler::jerk;
feedRate_t AxisSettingsHandler::max_feedrate;
#if HAS_TRINAMIC_CONFIG
bool AxisSettingsHandler::has_tmc_settings = true;
#else
bool AxisSettingsHandler::has_tmc_settings = false;
#endif
uint16_t AxisSettingsHandler::tmc_current;
bool AxisSettingsHandler::stealthchop;
uint32_t AxisSettingsHandler::hybrid_threshold;
void AxisSettingsHandler::HandleNavigation(DGUS_VP_Variable &var, void *val_ptr) {
switch (uInt16Value(val_ptr)) {
case AXIS_SETTINGS_NAV_BUTTON_VAL_X:
current_axis = X_AXIS;
axis_settings_title_icon = ICON_AXIS_SETTINGS_TITLE_X;
break;
case AXIS_SETTINGS_NAV_BUTTON_VAL_Y:
current_axis = Y_AXIS;
axis_settings_title_icon = ICON_AXIS_SETTINGS_TITLE_Y;
break;
case AXIS_SETTINGS_NAV_BUTTON_VAL_Z:
current_axis = Z_AXIS;
axis_settings_title_icon = ICON_AXIS_SETTINGS_TITLE_Z;
break;
case AXIS_SETTINGS_NAV_BUTTON_VAL_E:
current_axis = E_AXIS;
axis_settings_title_icon = ICON_AXIS_SETTINGS_TITLE_E;
break;
}
// Load settings for axis
axis_steps_mm = planner.settings.axis_steps_per_mm[current_axis];
max_acceleration_mm_per_s2 = static_cast<uint16_t>(planner.settings.max_acceleration_mm_per_s2[current_axis]);
IF_ENABLED(CLASSIC_JERK, jerk = planner.max_jerk[current_axis]);
max_feedrate = planner.settings.max_feedrate_mm_s[current_axis];
#if HAS_TRINAMIC_CONFIG
switch (current_axis){
#if AXIS_IS_TMC(X)
case X_AXIS:
tmc_current = stepperX.getMilliamps();
#if AXIS_HAS_STEALTHCHOP(X)
stealthchop = stepperX.get_stored_stealthChop();
#if ENABLED(HYBRID_THRESHOLD)
hybrid_threshold = static_cast<uint32_t>(stepperX.get_pwm_thrs());
#endif
#endif
break;
#endif
#if AXIS_IS_TMC(Y)
case Y_AXIS:
tmc_current = stepperY.getMilliamps();
#if AXIS_HAS_STEALTHCHOP(Y)
stealthchop = stepperY.get_stored_stealthChop();
#if ENABLED(HYBRID_THRESHOLD)
hybrid_threshold = static_cast<uint32_t>(stepperY.get_pwm_thrs());
#endif
#endif
break;
#endif
#if AXIS_IS_TMC(Z)
case Z_AXIS:
tmc_current = stepperZ.getMilliamps();
#if AXIS_HAS_STEALTHCHOP(Z)
stealthchop = stepperZ.get_stored_stealthChop();
#if ENABLED(HYBRID_THRESHOLD)
hybrid_threshold = static_cast<uint32_t>(stepperZ.get_pwm_thrs());
#endif
#endif
break;
#endif
#if AXIS_IS_TMC(E0)
case E_AXIS:
tmc_current = stepperE0.getMilliamps();
#if AXIS_HAS_STEALTHCHOP(E0)
stealthchop = stepperE0.get_stored_stealthChop();
#if ENABLED(HYBRID_THRESHOLD)
hybrid_threshold = static_cast<uint32_t>(stepperE0.get_pwm_thrs());
#endif
#endif
break;
#endif
default:
// Too bad
break;
}
#endif
// Nav
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_AXIS_SETTINGS_AXIS);
}
void AxisSettingsHandler::HandleBackNavigation(DGUS_VP_Variable &var, void *val_ptr) {
// Save settings for axis
planner.settings.axis_steps_per_mm[current_axis] = axis_steps_mm;
planner.settings.max_acceleration_mm_per_s2[current_axis] = max_acceleration_mm_per_s2;
IF_ENABLED(CLASSIC_JERK, planner.max_jerk[current_axis] = jerk);
planner.settings.max_feedrate_mm_s[current_axis] = max_feedrate;
// If we're handling the E-axis, the back button might end on that screen. Show that we didn't forget the settings.
if (current_axis == E_AXIS) {
EstepsHandler::set_esteps = axis_steps_mm;
EstepsHandler::calculated_esteps = axis_steps_mm;
}
#if HAS_TRINAMIC_CONFIG
switch (current_axis){
#if AXIS_IS_TMC(X)
case X_AXIS:
stepperX.rms_current(tmc_current);
#if AXIS_HAS_STEALTHCHOP(X)
stepperX.set_stealthChop(stealthchop);
#if ENABLED(HYBRID_THRESHOLD)
stepperX.set_pwm_thrs(hybrid_threshold);
#endif
#endif
break;
#endif
#if AXIS_IS_TMC(Y)
case Y_AXIS:
stepperY.rms_current(tmc_current);
#if AXIS_HAS_STEALTHCHOP(Y)
stepperY.set_stealthChop(stealthchop);
#if ENABLED(HYBRID_THRESHOLD)
stepperY.set_pwm_thrs(hybrid_threshold);
#endif
#endif
break;
#endif
#if AXIS_IS_TMC(Z)
case Z_AXIS:
stepperZ.rms_current(tmc_current);
#if AXIS_HAS_STEALTHCHOP(Z)
stepperZ.set_stealthChop(stealthchop);
#if ENABLED(HYBRID_THRESHOLD)
stepperZ.set_pwm_thrs(hybrid_threshold);
#endif
#endif
break;
#endif
#if AXIS_IS_TMC(E0)
case E_AXIS:
stepperE0.rms_current(tmc_current);
#if AXIS_HAS_STEALTHCHOP(E0)
stepperE0.set_stealthChop(stealthchop);
#if ENABLED(HYBRID_THRESHOLD)
stepperE0.set_pwm_thrs(hybrid_threshold);
#endif
#endif
break;
#endif
default:
// Too bad
break;
}
#endif
// Save and pop
ScreenHandler.PopToOldScreen();
settings.save();
}
void AxisSettingsHandler::HandleTMCNavigation(DGUS_VP_Variable &var, void *val_ptr) {
#if HAS_TRINAMIC_CONFIG
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_AXIS_SETTINGS_TMC);
#endif
}
#endif
@@ -1,26 +0,0 @@
#include <cstdint>
class AxisSettingsHandler {
private:
static AxisEnum current_axis;
public:
static uint16_t axis_settings_title_icon;
static float axis_steps_mm;
static uint16_t max_acceleration_mm_per_s2;
static float jerk;
static feedRate_t max_feedrate;
static bool has_tmc_settings;
static uint16_t tmc_current;
static bool stealthchop;
static uint32_t hybrid_threshold;
public:
static void HandleNavigation(DGUS_VP_Variable &var, void *val_ptr);
static void HandleBackNavigation(DGUS_VP_Variable &var, void *val_ptr);
static void HandleTMCNavigation(DGUS_VP_Variable &var, void *val_ptr);
};
@@ -1,796 +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 <https://www.gnu.org/licenses/>.
*
*/
/* DGUS implementation written by Sebastiaan Dammann in 2020 for Marlin */
#include "../../../../inc/MarlinConfigPre.h"
#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#include "../DGUSDisplayDef.h"
#include "../DGUSDisplay.h"
#include "../DGUSScreenHandler.h"
#include "AxisSettingsHandler.h"
#include "EstepsHandler.h"
#include "FilamentLoadUnloadHandler.h"
#include "PIDHandler.h"
#include "MeshValidationHandler.h"
#include "../../../../module/temperature.h"
#include "../../../../module/motion.h"
#include "../../../../module/planner.h"
#include "../../../../feature/caselight.h"
#if ENABLED(BABYSTEPPING)
#include "../../../../feature/babystep.h"
#endif
#if ENABLED(FWRETRACT)
#include "../../../../feature/fwretract.h"
#endif
#if HAS_COLOR_LEDS
#include "../../../../feature/leds/leds.h"
#endif
#if ENABLED(POWER_LOSS_RECOVERY)
#include "../../../../feature/powerloss.h"
#endif
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
#include "../../../../feature/runout.h"
#endif
#include "../../ui_api.h"
#include "../../../marlinui.h"
#include "PageHandlers.h"
#if ENABLED(DGUS_UI_MOVE_DIS_OPTION)
uint16_t distanceToMove = 10;
#endif
using namespace ExtUI;
const char MarlinVersion[] PROGMEM = SHORT_BUILD_VERSION;
// ----- Common var lists
#if HOTENDS >= 1
#define VPList_HeatHotend VP_T_E0_Is, VP_T_E0_Set,
#else
#define VPList_HeatHotend
#endif
#if HAS_HEATED_BED
#define VPList_HeatBed VP_T_Bed_Is, VP_T_Bed_Set,
#else
#define VPList_HeatBed
#endif
#define VPList_Common VP_BACK_BUTTON_STATE, VP_Z_OFFSET, VP_BUTTON_BEDLEVELKEY
#define VPList_CommonWithStatus VPList_HeatHotend VPList_HeatBed VP_Z_OFFSET, VP_Feedrate_Percentage, VP_BACK_BUTTON_STATE
#define VPList_CommonWithHeatOnly VPList_HeatHotend VPList_HeatBed VP_BACK_BUTTON_STATE, VP_Z_OFFSET
// ----- Which variables to auto-update on which screens
const uint16_t VPList_None[] PROGMEM = {
VPList_Common,
0x0000
};
const uint16_t VPList_DialogStop[] PROGMEM = {
VPList_Common,
0x0000
};
const uint16_t VPList_Main[] PROGMEM = {
VPList_CommonWithStatus,
0x0000
};
const uint16_t VPList_SDFileList[] PROGMEM = {
VPList_CommonWithStatus,
VP_SD_FileName0,
VP_SD_FileName1,
VP_SD_FileName2,
VP_SD_FileName3,
VP_SD_FileName4,
VP_SD_FileName5,
0x0000
};
const uint16_t VPList_Control[] PROGMEM = {
VPList_CommonWithStatus,
VP_LED_TOGGLE,
VP_MUTE_ICON,
0x0000
};
const uint16_t VPList_Feed[] PROGMEM = {
VPList_CommonWithStatus,
VP_FILCHANGE_NOZZLE_TEMP,
VP_FILCHANGE_LENGTH,
0x0000
};
const uint16_t VPList_Temp[] PROGMEM = {
VPList_CommonWithStatus,
VP_FAN_TOGGLE,
0x0000
};
const uint16_t VPList_PreheatPLASettings[] PROGMEM = {
VPList_CommonWithStatus,
VP_PREHEAT_PLA_HOTEND_TEMP,
VP_PREHEAT_PLA_BED_TEMP,
0x0000
};
const uint16_t VPList_PreheatABSSettings[] PROGMEM = {
VPList_CommonWithStatus,
VP_PREHEAT_ABS_HOTEND_TEMP,
VP_PREHEAT_ABS_BED_TEMP,
0x0000
};
const uint16_t VPList_PrintPausingError[] PROGMEM = {
VPList_CommonWithStatus,
VP_X_POSITION,
VP_Y_POSITION,
VP_Z_POSITION_PRECISION,
VP_Z_OFFSET,
VP_Fan0_Percentage,
VP_Feedrate_Percentage,
VP_PrintProgress_Percentage,
VP_PrintTimeProgressBar,
VP_PrintTime,
VP_PrintTimeWithRemainingVisible,
VP_PrintTimeRemaining,
VP_LINEAR_ADVANCE_FACTOR,
0x0000
};
const uint16_t VPList_PrintScreen[] PROGMEM = {
VPList_CommonWithStatus,
VP_X_POSITION, VP_Y_POSITION, VP_Z_POSITION, VP_Z_POSITION_PRECISION,
SP_X_POSITION, SP_Y_POSITION, SP_Z_POSITION,
VP_Flowrate_E0,
VP_Fan0_Percentage,
VP_PrintProgress_Percentage,
VP_PrintTimeProgressBar,
VP_PrintTime,
VP_PrintTimeWithRemainingVisible,
VP_PrintTimeRemaining,
VP_LINEAR_ADVANCE_FACTOR,
VP_FWRETRACT_INDICATOR_ICON,
0x0000
};
const uint16_t VPList_Leveling[] PROGMEM = {
VPList_CommonWithStatus,
VP_MESH_LEVEL_TEMP,
0x0000
};
const uint16_t VPList_ZOffsetLevel[] PROGMEM = {
VPList_CommonWithStatus,
0x0000
};
const uint16_t VPList_TuneScreen[] PROGMEM = {
VPList_CommonWithStatus,
VP_PrintTime,
VP_Flowrate_E0,
VP_LED_TOGGLE,
VP_FAN_TOGGLE,
VP_Fan0_Percentage,
0x0000
};
const uint16_t VPList_TuneExtraScreen[] PROGMEM = {
VPList_CommonWithStatus,
VP_LINEAR_ADVANCE_FACTOR,
VP_RGB_NAV_BUTTON_ICON,
0x0000
};
const uint16_t VPList_Prepare[] PROGMEM = {
VPList_CommonWithStatus,
VP_PrintTime,
0x0000
};
const uint16_t VPList_Info[] PROGMEM = {
VPList_CommonWithStatus,
VP_PrintTime,
VP_PRINTER_BEDSIZE,
VP_MARLIN_WEBSITE,
VP_MARLIN_VERSION,
0x0000
};
const uint16_t VPList_EstepsCalibration[] PROGMEM = {
VPList_CommonWithHeatOnly,
VP_ESTEPS_CURRENT,
VP_ESTEPS_CALIBRATION_TEMP,
VP_ESTEPS_CALIBRATION_LENGTH,
VP_ESTEPS_CALIBRATION_LEFTOVER_LENGTH,
VP_ESTEPS_CALIBRATION_MARK_LENGTH,
VP_ESTEPS_CALCULATED_ESTEPS,
0x0000
};
const uint16_t VPList_PidTune[] PROGMEM = {
VPList_CommonWithHeatOnly,
VP_PIDTUNE_TARGET_TEMP,
VP_PIDTUNE_FAN_TOGGLE_ICON,
VP_PIDTUNE_CYCLES,
0x0000
};
const uint16_t VPList_FWRetractTune[] PROGMEM = {
VPList_CommonWithStatus,
VP_FWRETRACT_RETRACT_LENGTH,
VP_FWRETRACT_RETRACT_FEEDRATE,
VP_FWRETRACT_RETRACT_ZHOP,
VP_FWRETRACT_RESTART_LENGTH,
VP_FWRETRACT_RESTART_FEEDRATE,
VP_FWRETRACT_TOGGLE_BUTTON_ICON,
0x0000
};
const uint16_t VPList_LevelingSettings[] PROGMEM = {
VPList_CommonWithStatus,
VP_TOGGLE_PROBING_HEATERS_OFF_ONOFF_ICON,
VP_TOGGLE_PROBE_PREHEAT_HOTEND_TEMP,
VP_TOGGLE_PROBE_PREHEAT_BED_TEMP,
VP_TOGGLE_POST_PROBING_TEMPERATURE_STABILIZATION_ICON,
VP_LEVELING_FADE_HEIGHT,
0x0000
};
const uint16_t VPList_AxisSettingsNav[] PROGMEM = {
VPList_CommonWithStatus,
0x0000
};
const uint16_t VPList_AxisSettingsAxis[] PROGMEM = {
VPList_CommonWithHeatOnly,
VP_AXIS_SETTINGS_TITLE_ICON,
VP_AXIS_SETTINGS_AXIS_STEPSMM,
VP_AXIS_SETTINGS_AXIS_MAX_ACCEL,
VP_AXIS_SETTINGS_AXIS_JERK,
VP_AXIS_SETTINGS_AXIS_FEEDRATE,
VP_AXIS_TMC_NAV_ICON,
0x0000
};
const uint16_t VPList_AxisSettingsTMC[] PROGMEM = {
VPList_CommonWithHeatOnly,
VP_AXIS_SETTINGS_AXIS_TMCCURRENT,
VP_AXIS_SETTINGS_AXIS_TMCSTEALTHCHOP_ICON,
VP_AXIS_SETTINGS_AXIS_TMCHYBRIDTHRESHOLD,
0x0000
};
const uint16_t VPList_AdvMovementSettings[] PROGMEM = {
VPList_CommonWithHeatOnly,
VP_MOV_MINIMUM_SEGMENT_TIME,
VP_MOV_MINIMUM_FEEDRATE,
VP_MOV_NORMAL_ACCELERATION,
VP_MOV_RETRACT_ACCELERATION,
VP_MOV_MINIMUM_TRAVEL_FEEDRATE,
VP_MOV_MINIMUM_TRAVEL_ACCELERATION,
0x0000
};
const uint16_t VPList_MiscSettings[] PROGMEM = {
VPList_CommonWithHeatOnly,
VP_FILAMENTRUNOUT_SENSOR_TOGGLE_ICON,
VP_PLR_TOGGLE_ICON,
VP_STANDBY_BACKLIGHT_ICON,
VP_SCREEN_BACKLIGHT_STANDBY,
VP_SCREEN_BACKLIGHT,
VP_SCREEN_STANDBY_TIME,
VP_RGB_NAV_BUTTON_ICON,
0x0000
};
const uint16_t VPList_MeshValidation[] PROGMEM = {
VPList_CommonWithHeatOnly,
VP_MESHPATTERN_NOZZLE_TEMP,
VP_MESHPATTERN_BED_TEMP,
VP_MESHPATTERN_BUTTON_ICON,
0x0000
};
const uint16_t VPList_Calibrate[] PROGMEM = {
VPList_CommonWithStatus,
0x0000
};
const uint16_t VPList_RGB[] PROGMEM = {
VPList_CommonWithHeatOnly,
VP_RGB_CONTROL_R,
VP_RGB_CONTROL_G,
VP_RGB_CONTROL_B,
VP_RGB_CONTROL_W,
VP_RGB_CONTROL_I,
0x0000
};
// -- Mapping from screen to variable list
const struct VPMapping VPMap[] PROGMEM = {
{ DGUSLCD_SCREEN_BOOT, VPList_None },
{ DGUSLCD_SCREEN_MAIN, VPList_Main },
{ DGUSLCD_SCREEN_SDFILELIST, VPList_SDFileList },
{ DGUSLCD_SCREEN_FILAMENTRUNOUT1, VPList_PrintPausingError },
{ DGUSLCD_SCREEN_FILAMENTRUNOUT2, VPList_PrintPausingError },
{ DGUSLCD_SCREEN_PRINT_FINISH, VPList_PrintScreen },
{ DGUSLCD_SCREEN_PRINT_RUNNING, VPList_PrintScreen },
{ DGUSLCD_SCREEN_PRINT_PAUSED, VPList_PrintScreen },
{ DGUSLCD_SCREEN_TUNING, VPList_TuneScreen },
{ DGUSLCD_SCREEN_TUNING_EXTRA, VPList_TuneExtraScreen },
{ DGUSLCD_SCREEN_PREPARE, VPList_Prepare },
{ DGUSLCD_SCREEN_INFO, VPList_Info },
{ DGUSLCD_SCREEN_MOVE1MM, VPList_PrintScreen },
{ DGUSLCD_SCREEN_MOVE10MM, VPList_PrintScreen },
{ DGUSLCD_SCREEN_MOVE01MM, VPList_PrintScreen },
{ DGUSLCD_SCREEN_FEED, VPList_Feed },
{ DGUSLCD_SCREEN_SETUP, VPList_Control },
{ DGUSLCD_SCREEN_TEMP, VPList_Temp },
{ DGUSLCD_SCREEN_TEMP_PLA, VPList_PreheatPLASettings },
{ DGUSLCD_SCREEN_TEMP_ABS, VPList_PreheatABSSettings },
{ DGUSLCD_SCREEN_INFO, VPList_PrintScreen },
{ DGUSLCD_SCREEN_ZOFFSET_LEVEL, VPList_ZOffsetLevel },
{ DGUSLCD_SCREEN_LEVELING, VPList_Leveling },
{ DGUSLCD_SCREEN_POWER_LOSS, VPList_None },
{ DGUSLCD_SCREEN_THERMAL_RUNAWAY, VPList_None },
{ DGUSLCD_SCREEN_HEATING_FAILED, VPList_None },
{ DGUSLCD_SCREEN_THERMISTOR_ERROR, VPList_None },
{ DGUSLCD_SCREEN_AUTOHOME, VPList_PrintScreen },
{ DGUSLCD_SCREEN_DIALOG_PAUSE, VPList_None },
{ DGUSLCD_SCREEN_DIALOG_STOP, VPList_DialogStop },
{ DGUSLCD_SCREEN_CONFIRM, VPList_None },
{ DGUSLCD_SCREEN_POPUP, VPList_None },
{ DGUSLCD_SCREEN_ESTEPS_CALIBRATION, VPList_EstepsCalibration },
{ DGUSLCD_SCREEN_PIDTUNE_CALIBRATION, VPList_PidTune },
{ DGUSLCD_SCREEN_TUNEFWRETRACT, VPList_FWRetractTune },
{ DGUSLCD_SCREEN_ESTEPS_CALIBRATION_RESULTS, VPList_EstepsCalibration },
{ DGUSLCD_SCREEN_LEVELING_SETTINGS, VPList_LevelingSettings },
{ DGUSLCD_SCREEN_AXIS_SETTINGS_NAV, VPList_AxisSettingsNav },
{ DGUSLCD_SCREEN_AXIS_SETTINGS_AXIS , VPList_AxisSettingsAxis },
{ DGUSLCD_SCREEN_AXIS_SETTINGS_TMC, VPList_AxisSettingsTMC },
{ DGUSLCD_SCREEN_ADV_MOV_SETTINGS, VPList_AdvMovementSettings },
{ DGUSLCD_SCREEN_MISC_SETTINGS, VPList_MiscSettings },
{ DGUSLCD_SCREEN_MESH_VALIDATION, VPList_MeshValidation },
{ DGUSLCD_SCREEN_CALIBRATE, VPList_Calibrate },
{ DGUSLCD_SCREEN_RGB, VPList_RGB},
{ 0 , nullptr } // List is terminated with an nullptr as table entry.
};
// Helper to define a DGUS_VP_Variable for common use cases.
#define VPHELPER(VPADR, VPADRVAR, RXFPTR, TXFPTR ) { .VP=VPADR, .memadr=VPADRVAR, .size=sizeof(VPADRVAR), \
.set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR }
// Helper to define a DGUS_VP_Variable when the sizeo of the var cannot be determined automaticalyl (eg. a string)
#define VPHELPER_STR(VPADR, VPADRVAR, STRLEN, RXFPTR, TXFPTR ) { .VP=VPADR, .memadr=VPADRVAR, .size=STRLEN, \
.set_by_display_handler = RXFPTR, .send_to_display_handler = TXFPTR }
const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
// Back button state
VPHELPER(VP_BACK_BUTTON_STATE, nullptr, nullptr, ScreenHandler.SendBusyState),
// Screen version
VPHELPER(VP_UI_VERSION_MAJOR, nullptr, ScreenHandler.HandleScreenVersion, nullptr),
#if HOTENDS >= 1
VPHELPER(VP_Flowrate_E0, &planner.flow_percentage[ExtUI::extruder_t::E0], ScreenHandler.HandleFlowRateChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_T_E0_Is, &thermalManager.temp_hotend[0].celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_T_E0_Set, &thermalManager.temp_hotend[0].target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#if HAS_HEATED_BED
VPHELPER(VP_T_Bed_Is, &thermalManager.temp_bed.celsius, nullptr, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<0>),
VPHELPER(VP_T_Bed_Set, &thermalManager.temp_bed.target, ScreenHandler.HandleTemperatureChanged, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
VPHELPER(VP_MESH_LEVEL_TEMP, &thermalManager.temp_hotend[0].target, nullptr, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
// Feedrate
VPHELPER(VP_Feedrate_Percentage, &feedrate_percentage, ScreenHandler.DGUSLCD_SetValueDirectly<int16_t>, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_PrintProgress_Percentage, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay),
VPHELPER(VP_PrintTimeProgressBar, nullptr, nullptr, ScreenHandler.DGUSLCD_SendPrintProgressToDisplay),
// Calibration
// ... e-steps
VPHELPER(VP_ESTEPS_CURRENT, &EstepsHandler::set_esteps, ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_ESTEPS_CALIBRATION_TEMP, &EstepsHandler::calibration_temperature, ScreenHandler.DGUSLCD_SetValueDirectly<uint16_t>, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_ESTEPS_CALIBRATION_LENGTH, &EstepsHandler::filament_to_extrude, ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_ESTEPS_CALIBRATION_MARK_LENGTH, &EstepsHandler::mark_filament_mm, ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_ESTEPS_CALIBRATION_LEFTOVER_LENGTH, &EstepsHandler::remaining_filament, EstepsHandler::HandleRemainingFilament, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_ESTEPS_CALCULATED_ESTEPS, &EstepsHandler::calculated_esteps, ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_ESTEPS_CALIBRATESTART_BUTTON, nullptr, EstepsHandler::HandleStartButton, nullptr),
VPHELPER(VP_ESTEPS_APPLY_BUTTON, nullptr, EstepsHandler::HandleApplyButton, nullptr),
VPHELPER(VP_ESTEPS_BACK_BUTTON, nullptr, EstepsHandler::HandleBackButton, nullptr),
VPHELPER(VP_ESTEP_NAV_BUTTON, nullptr, (ScreenHandler.DGUSLCD_NavigateToPage<DGUSLCD_SCREEN_ESTEPS_CALIBRATION, EstepsHandler>), nullptr),
// ... PID
VPHELPER(VP_PIDTUNE_TARGET_TEMP, &PIDHandler::calibration_temperature, ScreenHandler.DGUSLCD_SetValueDirectly<uint16_t>, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_PIDTUNE_CYCLES, &PIDHandler::cycles, ScreenHandler.DGUSLCD_SetValueDirectly<uint16_t>, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_PIDTUNE_FAN_TOGGLE, &PIDHandler::fan_on, ScreenHandler.DGUSLCD_ToggleBoolean, nullptr),
VPHELPER(VP_PIDTUNE_FAN_TOGGLE_ICON, &PIDHandler::fan_on, nullptr, (ScreenHandler.DGUSLCD_SendIconValue<ICON_TOGGLE_ON, ICON_TOGGLE_OFF>)),
VPHELPER(VP_PIDTUNE_START_BUTTON, nullptr, PIDHandler::HandleStartButton, nullptr),
VPHELPER(VP_PIDTUNE_NAV_BUTTON, nullptr, (ScreenHandler.DGUSLCD_NavigateToPage<DGUSLCD_SCREEN_PIDTUNE_CALIBRATION, PIDHandler>), nullptr),
VPHELPER(VP_GENERIC_BACK_BUTTON, nullptr, ScreenHandler.OnBackButton, nullptr),
#if HAS_MESH
// ... Mesh validation
VPHELPER(VP_MESHPATTERN_NOZZLE_TEMP, &MeshValidationHandler::nozzle_temperature, MeshValidationHandler::HandleTemperature, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_MESHPATTERN_BED_TEMP, &MeshValidationHandler::bed_temperature, MeshValidationHandler::HandleTemperature, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_MESHPATTERN_BUTTON_ICON, &MeshValidationHandler::is_running, nullptr, (ScreenHandler.DGUSLCD_SendIconValue<MESHPATTERN_BUTTON_CANCEL, MESHPATTERN_BUTTON_START>)),
VPHELPER(VP_MESHPATTERN_START_BUTTON, nullptr, MeshValidationHandler::HandleStartOrCancelButton, nullptr),
VPHELPER(VP_MESHPATTERN_NAV_BUTTON, nullptr, (ScreenHandler.DGUSLCD_NavigateToPage<DGUSLCD_SCREEN_MESH_VALIDATION, MeshValidationHandler>), nullptr),
#endif
// Axis settings
VPHELPER(VP_AXIS_SETTINGS_NAV_BUTTON, nullptr, AxisSettingsHandler::HandleNavigation, nullptr),
VPHELPER(VP_AXIS_SETTINGS_TITLE_ICON, &AxisSettingsHandler::axis_settings_title_icon, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_AXIS_SETTINGS_AXIS_STEPSMM, &AxisSettingsHandler::axis_steps_mm, ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_AXIS_SETTINGS_AXIS_MAX_ACCEL, &AxisSettingsHandler::max_acceleration_mm_per_s2, ScreenHandler.DGUSLCD_SetValueDirectly<uint16_t>, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_AXIS_SETTINGS_AXIS_JERK, &AxisSettingsHandler::jerk, ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_AXIS_SETTINGS_AXIS_FEEDRATE, &AxisSettingsHandler::max_feedrate, ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_AXIS_SETTINGS_AXIS_TMCCURRENT, &AxisSettingsHandler::tmc_current, ScreenHandler.DGUSLCD_SetValueDirectly<uint16_t>, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_AXIS_SETTINGS_AXIS_TMCSTEALTHCHOP_BUTTON, &AxisSettingsHandler::stealthchop, ScreenHandler.DGUSLCD_ToggleBoolean, nullptr),
VPHELPER(VP_AXIS_SETTINGS_AXIS_TMCSTEALTHCHOP_ICON, &AxisSettingsHandler::stealthchop, nullptr, (ScreenHandler.DGUSLCD_SendIconValue<ICON_TOGGLE_ON, ICON_TOGGLE_OFF>)),
VPHELPER(VP_AXIS_SETTINGS_AXIS_TMCHYBRIDTHRESHOLD, &AxisSettingsHandler::hybrid_threshold, ScreenHandler.DGUSLCD_ReceiveULongFromDisplay, ScreenHandler.DGUSLCD_SendULongToDisplay),
VPHELPER(VP_AXIS_TMC_NAV_ICON, &AxisSettingsHandler::has_tmc_settings, nullptr, (ScreenHandler.DGUSLCD_SendIconValue<AXIS_TMC_NAV_ICON_SHOWING, AXIS_TMC_NAV_ICON_HIDING>)),
VPHELPER(VP_AXIS_SETTINGS_NAV_BACKBUTTON, nullptr, AxisSettingsHandler::HandleBackNavigation, nullptr),
VPHELPER(VP_AXIS_TUNING_NAV_BUTTON, nullptr, (ScreenHandler.DGUSLCD_NavigateToPage<DGUSLCD_SCREEN_AXIS_SETTINGS_NAV>), nullptr),
VPHELPER(VP_AXIS_TMC_NAV_BUTTON, nullptr, (ScreenHandler.DGUSLCD_NavigateToPage<DGUSLCD_SCREEN_AXIS_SETTINGS_TMC>), nullptr),
// Advanced movement settings
VPHELPER(VP_MOV_NAV_BUTTON, nullptr, (ScreenHandler.DGUSLCD_NavigateToPage<DGUSLCD_SCREEN_ADV_MOV_SETTINGS>), nullptr),
VPHELPER(VP_MOV_MINIMUM_SEGMENT_TIME, &planner.settings.min_segment_time_us, ScreenHandler.DGUSLCD_SetValueDirectly<uint16_t>, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_MOV_MINIMUM_FEEDRATE, &planner.settings.min_feedrate_mm_s, ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_MOV_NORMAL_ACCELERATION, &planner.settings.acceleration, ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_MOV_RETRACT_ACCELERATION, &planner.settings.retract_acceleration, ScreenHandler.DGUSLCD_SetFloatAsLongFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<1>),
VPHELPER(VP_MOV_MINIMUM_TRAVEL_FEEDRATE, &planner.settings.min_travel_feedrate_mm_s, ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_MOV_MINIMUM_TRAVEL_ACCELERATION, &planner.settings.travel_acceleration, ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
// Misc settings
VPHELPER(VP_MISCSETTINGS_NAV_BUTTON, nullptr, (ScreenHandler.DGUSLCD_NavigateToPage<DGUSLCD_SCREEN_MISC_SETTINGS>), nullptr),
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
VPHELPER(VP_FILAMENTRUNOUT_SENSOR_TOGGLE_BUTTON, &runout.enabled, ScreenHandler.DGUSLCD_ToggleBoolean, nullptr),
VPHELPER(VP_FILAMENTRUNOUT_SENSOR_TOGGLE_ICON, &runout.enabled, nullptr, (ScreenHandler.DGUSLCD_SendIconValue<ICON_TOGGLE_ON, ICON_TOGGLE_OFF>)),
#endif
#if ENABLED(POWER_LOSS_RECOVERY)
VPHELPER(VP_PLR_TOGGLE_BUTTON, nullptr, ScreenHandler.TogglePowerLossRecovery, nullptr),
VPHELPER(VP_PLR_TOGGLE_ICON, &PrintJobRecovery::enabled, nullptr, (ScreenHandler.DGUSLCD_SendIconValue<ICON_TOGGLE_ON, ICON_TOGGLE_OFF>)),
#endif
// Preheat settings
#ifdef PREHEAT_1_LABEL
VPHELPER(VP_PREHEAT_PLA_HOTEND_TEMP, &ui.material_preset[0].hotend_temp, ScreenHandler.DGUSLCD_SetValueDirectly<int16_t>, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_PREHEAT_PLA_BED_TEMP, &ui.material_preset[0].bed_temp, ScreenHandler.DGUSLCD_SetValueDirectly<int16_t>, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#ifdef PREHEAT_2_LABEL
VPHELPER(VP_PREHEAT_ABS_HOTEND_TEMP, &ui.material_preset[1].hotend_temp, ScreenHandler.DGUSLCD_SetValueDirectly<int16_t>, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_PREHEAT_ABS_BED_TEMP, &ui.material_preset[1].bed_temp, ScreenHandler.DGUSLCD_SetValueDirectly<int16_t>, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
// About info
VPHELPER_STR(VP_MARLIN_WEBSITE, nullptr, VP_MARLIN_WEBSITE_LEN, nullptr, ScreenHandler.DGUSLCD_SendAboutFirmwareWebsite),
VPHELPER_STR(VP_MARLIN_VERSION, nullptr, VP_MARLIN_VERSION_LEN, nullptr, ScreenHandler.DGUSLCD_SendAboutFirmwareVersion),
VPHELPER_STR(VP_PRINTER_BEDSIZE, nullptr, VP_PRINTER_BEDSIZE_LEN, nullptr, ScreenHandler.DGUSLCD_SendAboutPrintSize),
// Position Data
VPHELPER(VP_X_POSITION, &current_position.x, ScreenHandler.HandlePositionChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_Y_POSITION, &current_position.y, ScreenHandler.HandlePositionChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_Z_POSITION, &current_position.z, ScreenHandler.HandlePositionChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_Z_POSITION_PRECISION, &current_position.z, nullptr, ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
VPHELPER(SP_X_POSITION, nullptr, nullptr, ScreenHandler.SendAxisTrustValue<X_AXIS>),
VPHELPER(SP_Y_POSITION, nullptr, nullptr, ScreenHandler.SendAxisTrustValue<Y_AXIS>),
VPHELPER(SP_Z_POSITION, nullptr, nullptr, ScreenHandler.SendAxisTrustValue<Z_AXIS>),
#if HAS_BED_PROBE
VPHELPER(VP_Z_OFFSET, &probe.offset.z, ScreenHandler.HandleZoffsetChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>),
#elif ENABLED(BABYSTEP_DISPLAY_TOTAL)
VPHELPER(VP_Z_OFFSET, nullptr, ScreenHandler.HandleZoffsetChange, nullptr),
#endif
VPHELPER(VP_FAN_TOGGLE, &thermalManager.fan_speed[0], nullptr, ScreenHandler.DGUSLCD_SendFanStatusToDisplay),
VPHELPER(VP_Fan0_Percentage, &thermalManager.fan_speed[0], ScreenHandler.HandleFanSpeedChanged, ScreenHandler.DGUSLCD_SendFanSpeedToDisplay),
#if ENABLED(POWER_LOSS_RECOVERY)
VPHELPER(VP_POWER_LOSS_RECOVERY, nullptr, &ScreenHandler.HandlePowerLossRecovery, nullptr),
#endif
VPHELPER_STR(VP_PrintTime, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeToDisplay),
VPHELPER_STR(VP_PrintTimeWithRemainingVisible, nullptr, VP_PrintTime_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeWithRemainingToDisplay),
VPHELPER_STR(VP_PrintTimeRemaining, nullptr, VP_PrintTimeRemaining_LEN, nullptr, ScreenHandler.DGUSLCD_SendPrintTimeRemainingToDisplay),
VPHELPER(VP_SCREENCHANGE, nullptr, ScreenHandler.ScreenChangeHook, nullptr),
VPHELPER(VP_CONFIRMED, nullptr, ScreenHandler.ScreenConfirmedOK, nullptr),
#if HAS_PROBE_SETTINGS
VPHELPER(VP_TOGGLE_PROBING_HEATERS_OFF_ONOFF_BUTTON, nullptr, ScreenHandler.HandleToggleProbeHeaters, nullptr),
VPHELPER(VP_TOGGLE_PROBING_HEATERS_OFF_ONOFF_ICON, &probe.settings.turn_heaters_off, nullptr, (ScreenHandler.DGUSLCD_SendIconValue<ICON_ACCURACY_TOGGLE_ON, ICON_ACCURACY_TOGGLE_OFF>)),
VPHELPER(VP_TOGGLE_POST_PROBING_TEMPERATURE_STABILIZATION_BUTTON, nullptr, ScreenHandler.HandleToggleProbeTemperatureStabilization, nullptr),
VPHELPER(VP_TOGGLE_POST_PROBING_TEMPERATURE_STABILIZATION_ICON, &probe.settings.stabilize_temperatures_after_probing, nullptr, (ScreenHandler.DGUSLCD_SendIconValue<ICON_POST_PROBE_TEMP_STABILIZATION_TOGGLE_ON, ICON_POST_PROBE_TEMP_STABILIZATION_TOGGLE_OFF>)),
VPHELPER(VP_TOGGLE_PROBE_PREHEAT_HOTEND_TEMP, &probe.settings.preheat_hotend_temp, ScreenHandler.HandleToggleProbePreheatTemp, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_TOGGLE_PROBE_PREHEAT_BED_TEMP, &probe.settings.preheat_bed_temp, ScreenHandler.HandleToggleProbePreheatTemp, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
#endif
#if HAS_MESH
VPHELPER(VP_LEVELING_FADE_HEIGHT, &planner.z_fade_height, ScreenHandler.HandleFadeHeight, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
#endif
VPHELPER(VP_LEVELING_NAV_BUTTON, nullptr, (ScreenHandler.DGUSLCD_NavigateToPage<DGUSLCD_SCREEN_ZOFFSET_LEVEL>), nullptr),
VPHELPER(VP_LEVELING_EDIT_NAV_BUTTON, nullptr, (ScreenHandler.DGUSLCD_NavigateToPage<DGUSLCD_SCREEN_LEVELING>), nullptr),
VPHELPER(VP_TOGGLE_PROBE_SETTINGS_NAV_BUTTON, nullptr, (ScreenHandler.DGUSLCD_NavigateToPage<DGUSLCD_SCREEN_LEVELING_SETTINGS>), nullptr),
// Creality has the same button ID mapped all over the place, so let the generic handler figure it out
VPHELPER(VP_BUTTON_MAINENTERKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_ADJUSTENTERKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_PREPAREENTERKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_RESUMEPRINTKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_SELECTFILEKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_STARTPRINTKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_STOPPRINTKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_PAUSEPRINTKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_COOLDOWN, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_TEMPCONTROL, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_BEDLEVELKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_HEATLOADSTARTKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
VPHELPER(VP_BUTTON_MOVEKEY, nullptr, DGUSCrealityDisplay_HandleReturnKeyEvent, nullptr),
// File listing
VPHELPER(VP_SD_ScrollEvent, nullptr, ScreenHandler.DGUSLCD_SD_ScrollFilelist, nullptr),
VPHELPER(VP_SD_FileSelected, nullptr, ScreenHandler.DGUSLCD_SD_FileSelected, nullptr),
VPHELPER(VP_SD_FileSelectConfirm, nullptr, ScreenHandler.DGUSLCD_SD_StartPrint, nullptr),
VPHELPER_STR(VP_SD_FileName0, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
VPHELPER_STR(VP_SD_FileName1, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
VPHELPER_STR(VP_SD_FileName2, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
VPHELPER_STR(VP_SD_FileName3, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
VPHELPER_STR(VP_SD_FileName4, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
VPHELPER_STR(VP_SD_FileName5, nullptr, VP_SD_FileName_LEN, nullptr, ScreenHandler.DGUSLCD_SD_SendFilename),
// Firmware retract
VPHELPER(VP_FWRETRACT_NAV_BUTTON, nullptr, ScreenHandler.DGUSLCD_NavigateToPage<DGUSLCD_SCREEN_TUNEFWRETRACT>, nullptr),
VPHELPER(VP_FWRETRACT_RETRACT_LENGTH, &fwretract.settings.retract_length, ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_FWRETRACT_RETRACT_FEEDRATE, &fwretract.settings.retract_feedrate_mm_s, ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_FWRETRACT_RETRACT_ZHOP, &fwretract.settings.retract_zraise, ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_FWRETRACT_RESTART_LENGTH, &fwretract.settings.retract_recover_extra, ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_FWRETRACT_RESTART_FEEDRATE, &fwretract.settings.retract_recover_feedrate_mm_s, ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_FWRETRACT_INDICATOR_ICON, &fwretract.autoretract_enabled, nullptr, (ScreenHandler.DGUSLCD_SendIconValue<ICON_FWRETRACT_AUTO_ENGAGED, ICON_FWRETRACT_AUTO_DISENGAGED>)),
VPHELPER(VP_FWRETRACT_TOGGLE_BUTTON_ICON, &fwretract.autoretract_enabled, nullptr, (ScreenHandler.DGUSLCD_SendIconValue<ICON_FWRETRACT_AUTO_TOGGLE_ON, ICON_FWRETRACT_AUTO_TOGGLE_OFF>)),
VPHELPER(VP_FWRETRACT_TOGGLE_BUTTON, &fwretract.autoretract_enabled, ScreenHandler.DGUSLCD_ToggleBoolean, nullptr),
// Other tuning
#if ENABLED(LIN_ADVANCE)
VPHELPER(VP_LINEAR_ADVANCE_FACTOR, &planner.extruder_advance_K[0], ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<2>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>),
#endif
VPHELPER(VP_OTHER_TUNE_NAV_BUTTON, nullptr, (ScreenHandler.DGUSLCD_NavigateToPage<DGUSLCD_SCREEN_TUNING_EXTRA>), nullptr),
// Additional buttons
VPHELPER(VP_MUTE_TOGGLE, nullptr, ScreenHandler.HandleToggleTouchScreenMute, nullptr),
VPHELPER(VP_STANDBY_BACKLIGHT_TOGGLE, nullptr, ScreenHandler.HandleToggleTouchScreenStandbySetting, nullptr),
// Additional settings
VPHELPER(VP_SCREEN_BACKLIGHT_STANDBY, &ScreenHandler.Settings.standby_screen_brightness, ScreenHandler.HandleTouchScreenStandbyBrightnessSetting, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_SCREEN_BACKLIGHT, &ScreenHandler.Settings.screen_brightness, ScreenHandler.HandleTouchScreenBrightnessSetting, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_SCREEN_STANDBY_TIME, &ScreenHandler.Settings.standby_time_seconds, ScreenHandler.HandleTouchScreenStandbyTimeSetting, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
// RGB
VPHELPER(VP_RGB_NAV_BUTTON_ICON, &ScreenHandler.HasRGBSettings, nullptr, (ScreenHandler.DGUSLCD_SendIconValue<ICON_RGB_SETTINGS_AVAILABLE, ICON_RGB_SETTINGS_UNAVAILABLE>)),
#if HAS_COLOR_LEDS
VPHELPER(VP_RGB_NAV_BUTTON, nullptr, ScreenHandler.DGUSLCD_NavigateToPage<DGUSLCD_SCREEN_RGB>, nullptr),
VPHELPER(VP_RGB_CONTROL_R, &leds.color.r, ScreenHandler.HandleLED, ScreenHandler.SendLEDToDisplay),
VPHELPER(VP_RGB_CONTROL_G, &leds.color.g, ScreenHandler.HandleLED, ScreenHandler.SendLEDToDisplay),
VPHELPER(VP_RGB_CONTROL_B, &leds.color.b, ScreenHandler.HandleLED, ScreenHandler.SendLEDToDisplay),
#if EITHER(RGBW_LED, NEOPIXEL_LED)
VPHELPER(VP_RGB_CONTROL_W, &leds.color.w, ScreenHandler.HandleLED, ScreenHandler.SendLEDToDisplay),
#if ENABLED(NEOPIXEL_LED)
VPHELPER(VP_RGB_CONTROL_I, &leds.color.i, ScreenHandler.HandleLED, ScreenHandler.SendLEDToDisplay),
#endif
#endif
#endif
// Filament load/unload
VPHELPER(VP_FILCHANGE_NAV_BUTTON, nullptr, (ScreenHandler.DGUSLCD_NavigateToPage<DGUSLCD_SCREEN_FEED, FilamentLoadUnloadHandler>), nullptr),
VPHELPER(VP_FILCHANGE_LENGTH, &FilamentLoadUnloadHandler::length, ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_FILCHANGE_NOZZLE_TEMP, &FilamentLoadUnloadHandler::nozzle_temperature, FilamentLoadUnloadHandler::HandleTemperature, ScreenHandler.DGUSLCD_SendWordValueToDisplay),
VPHELPER(VP_FILCHANGE_ACTION_BUTTON, nullptr, FilamentLoadUnloadHandler::HandleLoadUnloadButton, nullptr),
// Icons
#if ENABLED(CASE_LIGHT_ENABLE)
VPHELPER(VP_LED_TOGGLE, &caselight.on, nullptr, (ScreenHandler.DGUSLCD_SendIconValue<ICON_LED_TOGGLE_ON, ICON_LED_TOGGLE_OFF>)),
#endif
VPHELPER(VP_STANDBY_BACKLIGHT_ICON, &ScreenHandler.Settings.display_standby, nullptr, (ScreenHandler.DGUSLCD_SendIconValue<ICON_TOGGLE_ON, ICON_TOGGLE_OFF>)),
VPHELPER(VP_MUTE_ICON, &ScreenHandler.Settings.display_sound, nullptr, (ScreenHandler.DGUSLCD_SendIconValue<ICON_SOUND_TOGGLE_ON, ICON_SOUND_TOGGLE_OFF>)),
// Development test button
VPHELPER(VP_DEVELOPMENT_HELPER_BUTTON, nullptr, ScreenHandler.HandleDevelopmentTestButton, nullptr),
// Mesh override input
#if MESH_INPUT_SUPPORTED_SIZE == GRID_MAX_POINTS && HAS_MESH
//#define _VPHELPER_GP(N) VPHELPER((VP_MESH_INPUT_X0_Y0 + ( ##N## * MESH_INPUT_DATA_SIZE)), nullptr, ScreenHandler.HandleMeshPoint, nullptr),
//REPEAT(MESH_INPUT_SUPPORTED_SIZE, _VPHELPER_GP)
VPHELPER((VP_MESH_INPUT_X0_Y0 + ( 0 * MESH_INPUT_DATA_SIZE)), nullptr, ScreenHandler.HandleMeshPoint, nullptr),
VPHELPER((VP_MESH_INPUT_X0_Y0 + ( 1 * MESH_INPUT_DATA_SIZE)), nullptr, ScreenHandler.HandleMeshPoint, nullptr),
VPHELPER((VP_MESH_INPUT_X0_Y0 + ( 2 * MESH_INPUT_DATA_SIZE)), nullptr, ScreenHandler.HandleMeshPoint, nullptr),
VPHELPER((VP_MESH_INPUT_X0_Y0 + ( 3 * MESH_INPUT_DATA_SIZE)), nullptr, ScreenHandler.HandleMeshPoint, nullptr),
VPHELPER((VP_MESH_INPUT_X0_Y0 + ( 4 * MESH_INPUT_DATA_SIZE)), nullptr, ScreenHandler.HandleMeshPoint, nullptr),
VPHELPER((VP_MESH_INPUT_X0_Y0 + ( 5 * MESH_INPUT_DATA_SIZE)), nullptr, ScreenHandler.HandleMeshPoint, nullptr),
VPHELPER((VP_MESH_INPUT_X0_Y0 + ( 6 * MESH_INPUT_DATA_SIZE)), nullptr, ScreenHandler.HandleMeshPoint, nullptr),
VPHELPER((VP_MESH_INPUT_X0_Y0 + ( 7 * MESH_INPUT_DATA_SIZE)), nullptr, ScreenHandler.HandleMeshPoint, nullptr),
VPHELPER((VP_MESH_INPUT_X0_Y0 + ( 8 * MESH_INPUT_DATA_SIZE)), nullptr, ScreenHandler.HandleMeshPoint, nullptr),
VPHELPER((VP_MESH_INPUT_X0_Y0 + ( 9 * MESH_INPUT_DATA_SIZE)), nullptr, ScreenHandler.HandleMeshPoint, nullptr),
VPHELPER((VP_MESH_INPUT_X0_Y0 + ( 10 * MESH_INPUT_DATA_SIZE)), nullptr, ScreenHandler.HandleMeshPoint, nullptr),
VPHELPER((VP_MESH_INPUT_X0_Y0 + ( 11 * MESH_INPUT_DATA_SIZE)), nullptr, ScreenHandler.HandleMeshPoint, nullptr),
VPHELPER((VP_MESH_INPUT_X0_Y0 + ( 12 * MESH_INPUT_DATA_SIZE)), nullptr, ScreenHandler.HandleMeshPoint, nullptr),
VPHELPER((VP_MESH_INPUT_X0_Y0 + ( 13 * MESH_INPUT_DATA_SIZE)), nullptr, ScreenHandler.HandleMeshPoint, nullptr),
VPHELPER((VP_MESH_INPUT_X0_Y0 + ( 14 * MESH_INPUT_DATA_SIZE)), nullptr, ScreenHandler.HandleMeshPoint, nullptr),
VPHELPER((VP_MESH_INPUT_X0_Y0 + ( 15 * MESH_INPUT_DATA_SIZE)), nullptr, ScreenHandler.HandleMeshPoint, nullptr),
#endif
// M117 LCD String (We don't need the string in memory but "just" push it to the display on demand, hence the nullptr
{ .VP = VP_M117, .memadr = nullptr, .size = VP_M117_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplay },
{ .VP = VP_M117_STATIC, .memadr = nullptr, .size = VP_M117_STATIC_LEN, .set_by_display_handler = nullptr, .send_to_display_handler =&ScreenHandler.DGUSLCD_SendStringToDisplay },
// Messages for the User, shared by the popup and the kill screen. They cant be autouploaded as we do not buffer content.
{ .VP = VP_MSGSTR1, .memadr = nullptr, .size = VP_MSGSTR1_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
{ .VP = VP_MSGSTR2, .memadr = nullptr, .size = VP_MSGSTR2_LEN, .set_by_display_handler = nullptr, .send_to_display_handler = &ScreenHandler.DGUSLCD_SendStringToDisplayPGM },
{ .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 },
VPHELPER(0, 0, 0, 0) // must be last entry.
};
#endif // DGUS_LCD_UI_ORIGIN
@@ -1,562 +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 <https://www.gnu.org/licenses/>.
*
*/
#pragma once
enum DGUSLCD_Screens : uint8_t {
DGUSLCD_SCREEN_BOOT = 0,
DGUSLCD_SCREEN_MAIN = 28,
DGUSLCD_SCREEN_CONFIRM = 66,
DGUSLCD_SCREEN_SDPRINTMANIPULATION = 37 ,
DGUSLCD_SCREEN_SDPRINTTUNE = 41,
DGUSLCD_SCREEN_SDFILELIST = 67,
DGUSLCD_SCREEN_FILAMENTRUNOUT1 = 34, // DWINTouchPage::ERR_FILAMENTRUNOUT_HOTEND_COLD
DGUSLCD_SCREEN_FILAMENTRUNOUT2 = 35, // DWINTouchPage::ERR_FILAMENTRUNOUT_FILAMENT_LOADED
DGUSLCD_SCREEN_PRINT_FINISH = 36, // DWINTouchPage::PRINT_FINISHED
DGUSLCD_SCREEN_PRINT_RUNNING = 37, // DWINTouchPage::PRINT_PROGRESS_RUNNING
DGUSLCD_SCREEN_PRINT_PAUSED = 39, // DWINTouchPage::PRINT_PROGRESS_PAUSED
DGUSLCD_SCREEN_DIALOG_PAUSE = 38, // DWINTouchPage::DIALOG_PAUSE_PRINTING
DGUSLCD_SCREEN_DIALOG_STOP = 40, // DWINTouchPage::DIALOG_STOP_PRINTING
DGUSLCD_SCREEN_TUNING = 41, // DWINTouchPage::MENU_TUNING
DGUSLCD_SCREEN_TUNING_EXTRA = 79, // (this is a new page)
DGUSLCD_SCREEN_PREPARE = 42, // DWINTouchPage::MENU_PREPARE
DGUSLCD_SCREEN_MOVE10MM = 43, // DWINTouchPage::MOVE_1MM
DGUSLCD_SCREEN_MOVE1MM = 44, // DWINTouchPage::MOVE_10MM
DGUSLCD_SCREEN_MOVE01MM = 45, // DWINTouchPage::MOVE_01MM
DGUSLCD_SCREEN_FEED = 46, // DWINTouchPage::FEED
DGUSLCD_SCREEN_SETUP = 47, // DWINTouchPage::MENU_CONTROL
DGUSLCD_SCREEN_TEMP = 48, // DWINTouchPage::MENU_TEMP
DGUSLCD_SCREEN_TEMP_PLA = 49, // DWINTouchPage::MENU_PLA_TEMP
DGUSLCD_SCREEN_TEMP_ABS = 50, // DWINTouchPage::MENU_ABS_TEMP
DGUSLCD_SCREEN_INFO = 51, // DWINTouchPage::MENU_ABOUT
DGUSLCD_SCREEN_ZOFFSET_LEVEL = 52, // DWINTouchPage::MENU_ZOFFSET_LEVELING
DGUSLCD_SCREEN_LEVELING = 53, // DWINTouchPage::LEVELING
DGUSLCD_SCREEN_POWER_LOSS = 54, // DWINTouchPage::DIALOG_POWER_FAILURE
DGUSLCD_SCREEN_THERMAL_RUNAWAY = 57, // DWINTouchPage::ERR_THERMAL_RUNAWAY
DGUSLCD_SCREEN_HEATING_FAILED = 58, // DWINTouchPage::ERR_HEATING_FAILED
DGUSLCD_SCREEN_THERMISTOR_ERROR = 59, // DWINTouchPage::ERR_THERMISTOR
DGUSLCD_SCREEN_AUTOHOME = 61, // DWINTouchPage::AUTOHOME_IN_PROGRESS
DGUSLCD_SCREEN_POPUP = 63, // NEW - does not exist in original display
DGUSLCD_SCREEN_KILL = 64, // NEW - does not exist in original display
DGUSLCD_SCREEN_PIDTUNE_CALIBRATION = 68,
DGUSLCD_SCREEN_ESTEPS_CALIBRATION = 69,
DGUSLCD_SCREEN_TUNEFWRETRACT = 70,
DGUSLCD_SCREEN_ESTEPS_CALIBRATION_RESULTS = 71,
DGUSLCD_SCREEN_LEVELING_SETTINGS = 72,
DGUSLCD_SCREEN_AXIS_SETTINGS_NAV = 73,
DGUSLCD_SCREEN_AXIS_SETTINGS_AXIS = 74,
DGUSLCD_SCREEN_AXIS_SETTINGS_TMC = 75,
DGUSLCD_SCREEN_ADV_MOV_SETTINGS = 76,
DGUSLCD_SCREEN_MISC_SETTINGS = 77,
DGUSLCD_SCREEN_MESH_VALIDATION = 78,
DGUSLCD_SCREEN_CALIBRATE = 80,
DGUSLCD_SCREEN_RGB = 81
};
// Version checks
constexpr uint16_t VP_UI_VERSION_MAJOR = 0xFFFA;
constexpr uint16_t EXPECTED_UI_VERSION_MAJOR = 61;
constexpr uint16_t VERSION_MISMATCH_BUZZ_AMOUNT = 5;
constexpr uint16_t VERSION_MISMATCH_LED_FLASH_DELAY = 1000;
#define VP_STARTPROGRESSBAR 0x1000
// // Storage space for the Killscreen messages. Reused for the popup.
constexpr uint16_t VP_MSGSTR1 = 0x2010;
constexpr uint8_t VP_MSGSTR1_LEN = 0x20; // might be more place for it...
constexpr uint16_t VP_MSGSTR2 = 0x2030;
constexpr uint8_t VP_MSGSTR2_LEN = 0x40;
constexpr uint16_t VP_MSGSTR3 = 0x2070;
constexpr uint8_t VP_MSGSTR3_LEN = 0x40;
constexpr uint16_t VP_MSGSTR4 = 0x2080;
constexpr uint8_t VP_MSGSTR4_LEN = 0x20;
// // Screenchange request for screens that only make sense when printer is idle.
// // e.g movement is only allowed if printer is not printing.
// // Marlin must confirm by setting the screen manually.
// constexpr uint16_t VP_SCREENCHANGE_ASK = 0x2000;
constexpr uint16_t VP_SCREENCHANGE = 0x219f; // Key-Return button to new menu pressed. Data contains target screen in low byte and info in high byte.
// constexpr uint16_t VP_TEMP_ALL_OFF = 0x2002; // Turn all heaters off. Value arbitrary ;)=
// constexpr uint16_t VP_SCREENCHANGE_WHENSD = 0x2003; // "Print" Button touched -- go only there if there is an SD Card.
constexpr uint16_t VP_CONFIRMED = 0x219E; // OK on confirm screen.
// // Buttons on the SD-Card File listing.
// constexpr uint16_t VP_SD_ScrollEvent = 0x2020; // Data: 0 for "up a directory", numbers are the amount to scroll, e.g -1 one up, 1 one down
// constexpr uint16_t VP_SD_FileSelected = 0x2022; // Number of file field selected.
constexpr uint16_t VP_SD_FileSelectConfirm = 0x2024; // (This is a virtual VP and emulated by the Confirm Screen when a file has been confirmed)
// constexpr uint16_t VP_SD_ResumePauseAbort = 0x2026; // Resume(Data=0), Pause(Data=1), Abort(Data=2) SD Card prints
constexpr uint16_t VP_SD_AbortPrintConfirmed = 0x2028; // Abort print confirmation (virtual, will be injected by the confirm dialog)
// constexpr uint16_t VP_SD_Print_Setting = 0x2040;
// constexpr uint16_t VP_SD_Print_LiveAdjustZ = 0x2050; // Data: 0 down, 1 up
// // Controls for movement (we can't use the incremental / decremental feature of the display at this feature works only with 16 bit values
// // (which would limit us to 655.35mm, which is likely not a problem for common setups, but i don't want to rule out hangprinters support)
// // A word about the coding: The VP will be per axis and the return code will be an signed 16 bit value in 0.01 mm resolution, telling us
// // the relative travel amount t he user wants to do. So eg. if the display sends us VP=2100 with value 100, the user wants us to move X by +1 mm.
constexpr uint16_t VP_MOVE_X = 0x2100;
constexpr uint16_t VP_MOVE_Y = 0x2102;
constexpr uint16_t VP_MOVE_Z = 0x2104;
constexpr uint16_t VP_MOVE_E0 = 0x2110;
// constexpr uint16_t VP_MOVE_E1 = 0x2112;
// //constexpr uint16_t VP_MOVE_E2 = 0x2114;
// //constexpr uint16_t VP_MOVE_E3 = 0x2116;
// //constexpr uint16_t VP_MOVE_E4 = 0x2118;
// //constexpr uint16_t VP_MOVE_E5 = 0x211A;
constexpr uint16_t VP_HOME_ALL = 0x2120;
// constexpr uint16_t VP_MOTOR_LOCK_UNLOK = 0x2130;
// // Power loss recovery
// constexpr uint16_t VP_POWER_LOSS_RECOVERY = 0x2180;
// // Fan Control Buttons , switch between "off" and "on"
// constexpr uint16_t VP_FAN0_CONTROL = 0x2200;
// constexpr uint16_t VP_FAN1_CONTROL = 0x2202;
// //constexpr uint16_t VP_FAN2_CONTROL = 0x2204;
// //constexpr uint16_t VP_FAN3_CONTROL = 0x2206;
// // Heater Control Buttons , triged between "cool down" and "heat PLA" state
constexpr uint16_t VP_E0_CONTROL = 0x2210;
// constexpr uint16_t VP_E1_CONTROL = 0x2212;
// //constexpr uint16_t VP_E2_CONTROL = 0x2214;
// //constexpr uint16_t VP_E3_CONTROL = 0x2216;
// //constexpr uint16_t VP_E4_CONTROL = 0x2218;
// //constexpr uint16_t VP_E5_CONTROL = 0x221A;
constexpr uint16_t VP_BED_CONTROL = 0x221C;
// // Preheat
// constexpr uint16_t VP_E0_BED_PREHEAT = 0x2220;
// constexpr uint16_t VP_E1_BED_CONTROL = 0x2222;
// //constexpr uint16_t VP_E2_BED_CONTROL = 0x2224;
// //constexpr uint16_t VP_E3_BED_CONTROL = 0x2226;
// //constexpr uint16_t VP_E4_BED_CONTROL = 0x2228;
// //constexpr uint16_t VP_E5_BED_CONTROL = 0x222A;
// // Filament load and unload
// constexpr uint16_t VP_E0_FILAMENT_LOAD_UNLOAD = 0x2300;
// constexpr uint16_t VP_E1_FILAMENT_LOAD_UNLOAD = 0x2302;
// // Settings store , reset
// constexpr uint16_t VP_SETTINGS = 0x2400;
// // PID autotune
constexpr uint16_t VP_PID_AUTOTUNE_E0 = 0x2410;
// //constexpr uint16_t VP_PID_AUTOTUNE_E1 = 0x2412;
// //constexpr uint16_t VP_PID_AUTOTUNE_E2 = 0x2414;
// //constexpr uint16_t VP_PID_AUTOTUNE_E3 = 0x2416;
// //constexpr uint16_t VP_PID_AUTOTUNE_E4 = 0x2418;
// //constexpr uint16_t VP_PID_AUTOTUNE_E5 = 0x241A;
constexpr uint16_t VP_PID_AUTOTUNE_BED = 0x2420;
// // Firmware version on the boot screen.
constexpr uint16_t VP_PRINTER_BEDSIZE = 0x1074;
constexpr uint16_t VP_PRINTER_BEDSIZE_LEN = 12;
constexpr uint16_t VP_MARLIN_VERSION = 0x2222;
constexpr uint8_t VP_MARLIN_VERSION_LEN = 32;
constexpr uint16_t VP_MARLIN_WEBSITE = 0x2242;
constexpr uint8_t VP_MARLIN_WEBSITE_LEN = 32;
constexpr uint16_t VP_STANDBY_BACKLIGHT_ICON = 0x2280;
constexpr uint16_t VP_STANDBY_BACKLIGHT_TOGGLE = 0x2282;
constexpr uint16_t VP_MUTE_ICON = 0x2284;
constexpr uint16_t VP_MUTE_TOGGLE = 0x2286;
constexpr uint16_t VP_SCREEN_BACKLIGHT_STANDBY = 0x228D;
constexpr uint16_t VP_SCREEN_BACKLIGHT = 0x2384;
constexpr uint16_t VP_SCREEN_STANDBY_TIME = 0x2386;
// Material preheat settings
constexpr uint16_t VP_PREHEAT_PLA_HOTEND_TEMP = 0x1102;
constexpr uint16_t VP_PREHEAT_PLA_BED_TEMP = 0x1104;
constexpr uint16_t VP_PREHEAT_ABS_HOTEND_TEMP = 0x1108;
constexpr uint16_t VP_PREHEAT_ABS_BED_TEMP = 0x110a;
// Place for status messages.
// ... We have memory space for scrolling messages
constexpr uint16_t VP_M117 = 0x3000 + (3 * 1); // Text Variable Pointer. First three VP must be reserved [a VP is two bytes red.]. Text is saved after the 3rd VP and ended with 0x00 or 0x0F.
constexpr uint8_t VP_M117_LEN = 100;
// ... And memory space for static (short) messages. Note this VPAddr is also the VP of the 5 beta and alpha 4 touch screens.
constexpr uint8_t M117_STATIC_DISPLAY_LEN = 28; // Fits "TFT flashed incorrectly v0" exactly
constexpr uint16_t VP_M117_STATIC = 0x21B3;
constexpr uint8_t VP_M117_STATIC_LEN = 70;
// // Temperatures.
constexpr uint16_t VP_T_E0_Is = 0x1036; // 4 Byte Integer - HEAD_CURRENT_TEMP_VP
constexpr uint16_t VP_T_E0_Set = 0x1034; // 2 Byte Integer - HEAD_SET_TEMP_VP
constexpr uint16_t VP_T_Bed_Is = 0x103c; // 4 Byte Integer - BED_SET_TEMP_VP
constexpr uint16_t VP_T_Bed_Set = 0x103A; // 2 Byte Integer - BED_CURRENT_TEMP_VP
constexpr uint16_t VP_Flowrate_E0 = 0x228A; // 2 Byte Integer
constexpr uint16_t VP_Fan0_Percentage = 0x228F; // 2 Byte Integer (0..100)
constexpr uint16_t VP_Feedrate_Percentage = 0x1006; // 2 Byte Integer (0..100) - PRINT_SPEED_RATE_VP
constexpr uint16_t VP_PrintProgress_Percentage = 0x1016; // 2 Byte Integer (0..100)
constexpr uint16_t VP_PrintTimeProgressBar = 0x100E;
constexpr uint16_t VP_PrintTime = 0x21a0;
constexpr uint16_t VP_PrintTimeWithRemainingVisible = 0x2335;
constexpr uint16_t VP_PrintTime_LEN = 19;
constexpr uint16_t VP_PrintTimeRemaining = 0x231f;
constexpr uint16_t VP_PrintTimeRemaining_LEN = 21;
constexpr uint16_t VP_HideRemainingTime_Ico = 0x2380;
constexpr uint16_t ICON_REMAINING_VISIBLE = 26;
constexpr uint16_t ICON_REMAINING_HIDDEN = 27;
constexpr uint16_t VP_Z_OFFSET = 0x1026;
// // SDCard File Listing
constexpr uint16_t VP_SD_ScrollEvent = 0x20D4; // Data: 0 for "up a directory", numbers are the amount to scroll, e.g -1 one up, 1 one down
constexpr uint16_t VP_SD_FileSelected = 0x2200; // Number of file field selected.
constexpr uint16_t VP_SD_FileName_LEN = 21; // LEN is shared for all entries.
constexpr uint16_t VP_SD_FileName_CNT = 5; // LEN is shared for all entries.
constexpr uint16_t DGUS_SD_FILESPERSCREEN = VP_SD_FileName_CNT; // FIXME move that info to the display and read it from there.
constexpr uint16_t VP_SD_FileName0 = 0x20D5;
constexpr uint16_t VP_SD_FileName1 = VP_SD_FileName0 + VP_SD_FileName_LEN;
constexpr uint16_t VP_SD_FileName2 = VP_SD_FileName1 + VP_SD_FileName_LEN;
constexpr uint16_t VP_SD_FileName3 = VP_SD_FileName2 + VP_SD_FileName_LEN;
constexpr uint16_t VP_SD_FileName4 = VP_SD_FileName3 + VP_SD_FileName_LEN;
constexpr uint16_t VP_SD_FileName5 = VP_SD_FileName4 + VP_SD_FileName_LEN;
constexpr uint16_t VP_SD_Print_ProbeOffsetZ = 0x32A0; //
constexpr uint16_t VP_SD_Print_Filename = 0x2000; //
constexpr uint16_t VP_ICON_OVERLAY_CLEAR = 10;
constexpr uint16_t VP_ICON_OVERLAY_SELECTED = 6;
// // Step per mm
constexpr uint16_t VP_X_STEP_PER_MM = 0x3600;
constexpr uint16_t VP_Y_STEP_PER_MM = 0x3604;
constexpr uint16_t VP_Z_STEP_PER_MM = 0x3608;
constexpr uint16_t VP_E0_STEP_PER_MM = 0x3610;
// // PIDs
constexpr uint16_t VP_E0_PID_P = 0x3700;
constexpr uint16_t VP_E0_PID_I = 0x3702;
constexpr uint16_t VP_E0_PID_D = 0x3704;
constexpr uint16_t VP_BED_PID_P = 0x3710;
constexpr uint16_t VP_BED_PID_I = 0x3712;
constexpr uint16_t VP_BED_PID_D = 0x3714;
// Power loss recovery
constexpr uint16_t VP_POWER_LOSS_RECOVERY = 0x105F;
// Buttons defined by Creality - Don't worry if you're confused by the naming, so am I
constexpr uint16_t VP_BUTTON_MAINENTERKEY = 0x1002;
constexpr uint16_t VP_BUTTON_ADJUSTENTERKEY = 0x1004;
constexpr uint16_t VP_BUTTON_PAUSEPRINTKEY = 0x100A;
constexpr uint16_t VP_BUTTON_TEMPCONTROL = 0x1030;
constexpr uint16_t VP_BUTTON_COOLDOWN = 0x1032;
constexpr uint16_t VP_BUTTON_PREPAREENTERKEY = 0x103E;
constexpr uint16_t VP_BUTTON_SELECTFILEKEY = 0x20D3;
constexpr uint16_t VP_BUTTON_STARTPRINTKEY = 0x20D2;
constexpr uint16_t VP_BUTTON_STOPPRINTKEY = 0x1008;
constexpr uint16_t VP_BUTTON_RESUMEPRINTKEY = 0x100C;
constexpr uint16_t VP_BUTTON_BEDLEVELKEY = 0x1044;
constexpr uint16_t VP_BUTTON_HEATLOADSTARTKEY = 0x1056;
// Additional stuff defined by Creality
constexpr uint16_t VP_FAN_TOGGLE = 0x101E;
constexpr uint16_t VP_LED_TOGGLE = 0x101F;
// Axis settings
constexpr uint16_t VP_AXIS_SETTINGS_NAV_BUTTON = 0x22D9;
constexpr uint16_t AXIS_SETTINGS_NAV_BUTTON_VAL_X = 1;
constexpr uint16_t AXIS_SETTINGS_NAV_BUTTON_VAL_Y = 2;
constexpr uint16_t AXIS_SETTINGS_NAV_BUTTON_VAL_Z = 3;
constexpr uint16_t AXIS_SETTINGS_NAV_BUTTON_VAL_E = 4;
constexpr uint16_t VP_AXIS_SETTINGS_TITLE_ICON = 0x22DB;
constexpr uint16_t ICON_AXIS_SETTINGS_TITLE_X = 20;
constexpr uint16_t ICON_AXIS_SETTINGS_TITLE_Y = 21;
constexpr uint16_t ICON_AXIS_SETTINGS_TITLE_Z = 22;
constexpr uint16_t ICON_AXIS_SETTINGS_TITLE_E = 23;
constexpr uint16_t VP_AXIS_SETTINGS_NAV_BACKBUTTON = 0x22DD;
constexpr uint16_t VP_AXIS_SETTINGS_AXIS_STEPSMM = 0x22DF; // 2-byte
constexpr uint16_t VP_AXIS_SETTINGS_AXIS_MAX_ACCEL = 0x22E1; // 4-byte (!)
constexpr uint16_t VP_AXIS_SETTINGS_AXIS_JERK = 0x22E5; // 2-byte
constexpr uint16_t VP_AXIS_SETTINGS_AXIS_FEEDRATE = 0x22E7; // 2-byte
constexpr uint16_t VP_AXIS_SETTINGS_AXIS_TMCCURRENT = 0x22E9; // 2-byte
constexpr uint16_t VP_AXIS_SETTINGS_AXIS_TMCSTEALTHCHOP_BUTTON = 0x22EB; // 2-byte
constexpr uint16_t VP_AXIS_SETTINGS_AXIS_TMCSTEALTHCHOP_ICON = 0x22ED; // 2-byte
constexpr uint16_t VP_AXIS_SETTINGS_AXIS_TMCHYBRIDTHRESHOLD = 0x22EF; // 4-byte (!)
constexpr uint16_t VP_AXIS_TUNING_NAV_BUTTON = 0x22F5;
constexpr uint16_t VP_AXIS_TMC_NAV_BUTTON = 0x22F7;
constexpr uint16_t VP_AXIS_TMC_NAV_ICON = 0x22F3; // 2-byte
constexpr uint16_t AXIS_TMC_NAV_ICON_SHOWING = 10;
constexpr uint16_t AXIS_TMC_NAV_ICON_HIDING = 11;
// ... Advanced movement settings
constexpr uint16_t VP_MOV_NAV_BUTTON = 0x2305;
constexpr uint16_t VP_MOV_MINIMUM_SEGMENT_TIME = 0x22F9; // uint 2-byte
constexpr uint16_t VP_MOV_MINIMUM_FEEDRATE = 0x22FB; // float 2-byte
constexpr uint16_t VP_MOV_NORMAL_ACCELERATION = 0x22FD; // float 2-byte
constexpr uint16_t VP_MOV_MINIMUM_TRAVEL_FEEDRATE = 0x2301; // float 2-byte
constexpr uint16_t VP_MOV_MINIMUM_TRAVEL_ACCELERATION = 0x2303; // float 2-byte
constexpr uint16_t VP_MOV_RETRACT_ACCELERATION = 0x2307; // float 4-byte
// Misc settings
constexpr uint16_t VP_MISCSETTINGS_NAV_BUTTON = 0x2311;
constexpr uint16_t VP_FILAMENTRUNOUT_SENSOR_TOGGLE_BUTTON = 0x2309;
constexpr uint16_t VP_FILAMENTRUNOUT_SENSOR_TOGGLE_ICON = 0x230b;
constexpr uint16_t VP_PLR_TOGGLE_BUTTON = 0x230d;
constexpr uint16_t VP_PLR_TOGGLE_ICON = 0x230F;
// Mesh leveling
constexpr uint16_t VP_LEVELING_NAV_BUTTON = 0x238a;
constexpr uint16_t VP_LEVELING_EDIT_NAV_BUTTON = 0x23A8;
constexpr uint16_t VP_MESH_SCREEN_MESSAGE_ICON = 0x22cb;
constexpr uint16_t MESH_SCREEN_MESSAGE_ICON_LEVELING = 5;
constexpr uint16_t MESH_SCREEN_MESSAGE_ICON_VIEWING = 6;
constexpr uint16_t VP_MESH_LEVEL_TEMP = 0x108A;
constexpr uint16_t VP_MESH_LEVEL_STATUS = 0x108D;
constexpr uint8_t DGUS_GRID_VISUALIZATION_START_ID = GRID_MAX_POINTS > (4*4) ? 30 : 1;
static_assert(
(GRID_MAX_POINTS == 16 && DGUS_GRID_VISUALIZATION_START_ID == 1)|| // CR-6 SE
(GRID_MAX_POINTS == 49 && DGUS_GRID_VISUALIZATION_START_ID == 30) || // CR-6 MAX
(GRID_MAX_POINTS != 16 && GRID_MAX_POINTS != 49), // Custom Leveling
"Incorrect offset selected for leveling config"
);
static_assert(GRID_MAX_POINTS_X == GRID_MAX_POINTS_Y, "Assuming bed leveling points is square");
constexpr uint16_t VP_MESH_LEVEL_X0_Y0 = 0x1350;
constexpr uint16_t SP_MESH_LEVEL_X0_Y0 = 0x5000;
constexpr uint16_t MESH_LEVEL_EDGE_MAX_POINTS = 4;
constexpr uint16_t MESH_LEVEL_VP_SIZE = 0x4; // 4-byte native float
constexpr uint16_t MESH_LEVEL_SP_SIZE = 0x10; // 0x10 distance
constexpr uint16_t MESH_LEVEL_VP_EDGE_SIZE = MESH_LEVEL_VP_SIZE * MESH_LEVEL_EDGE_MAX_POINTS;
constexpr uint16_t MESH_LEVEL_SP_EDGE_SIZE = MESH_LEVEL_SP_SIZE * MESH_LEVEL_EDGE_MAX_POINTS;
constexpr uint16_t MESH_LEVEL_MAX_POINTS = MESH_LEVEL_EDGE_MAX_POINTS * MESH_LEVEL_EDGE_MAX_POINTS;
// Mesh inputs
constexpr uint16_t VP_MESH_INPUT_X0_Y0 = 0x2360;
#define MESH_INPUT_SUPPORTED_X_SIZE 4
#define MESH_INPUT_SUPPORTED_Y_SIZE 4
#define MESH_INPUT_SUPPORTED_SIZE 16
#define MESH_INPUT_DATA_SIZE 2 // 2 byte integer
// Color table: https://stackoverflow.com/q/13720937/646215
// Color picker: https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html
// Colors below were picked on bed leveling visualizer defaults
constexpr uint16_t MESH_COLOR_BELOW_ZERO = 0x899B; // Blue
constexpr uint16_t MESH_COLOR_NEAR_ZERO = 0x1C80; // Green
constexpr uint16_t MESH_COLOR_ABOVE_ZERO = 0xB800; // Purple
constexpr uint16_t MESH_COLOR_NOT_MEASURED = 0xFFFF; // White (becomes invisible on white background)
constexpr float MESH_NEAR_ZERO = 0.020;
constexpr float MESH_UNSET_EPSILON = 0.001;
// Mesh validation pattern
constexpr uint16_t VP_MESHPATTERN_NOZZLE_TEMP = 0x2313;
constexpr uint16_t VP_MESHPATTERN_BED_TEMP = 0x2315;
constexpr uint16_t VP_MESHPATTERN_START_BUTTON = 0x2317;
constexpr uint16_t VP_MESHPATTERN_BUTTON_ICON = 0x2319;
constexpr uint16_t VP_MESHPATTERN_NAV_BUTTON = 0x231B;
constexpr uint16_t MESHPATTERN_BUTTON_START = 24; // This icon does not exist, and will therefore not show
constexpr uint16_t MESHPATTERN_BUTTON_CANCEL = 25;
// Movement screen
constexpr uint16_t VP_X_POSITION = 0x1048;
constexpr uint16_t SP_X_POSITION = 0x4000;
constexpr uint16_t VP_Y_POSITION = 0x104A;
constexpr uint16_t SP_Y_POSITION = 0x4030;
constexpr uint16_t VP_Z_POSITION = 0x104C;
constexpr uint16_t VP_Z_POSITION_PRECISION = 0x108F;
constexpr uint16_t SP_Z_POSITION = 0x4060;
constexpr uint16_t VP_BUTTON_MOVEKEY = 0x1046;
// Buttons
constexpr uint16_t VP_ESTEP_NAV_BUTTON = 0x2291;
constexpr uint16_t VP_PIDTUNE_NAV_BUTTON = 0x2293;
constexpr uint16_t VP_GENERIC_BACK_BUTTON = 0x2295; // Generic button for popping back to the old display
constexpr uint16_t GENERIC_BACK_BUTTON_NEED_SAVE = 0x1;
// PID tuning
constexpr uint16_t VP_PIDTUNE_TARGET_TEMP = 0x2297;
constexpr uint16_t VP_PIDTUNE_CYCLES = 0x2299;
constexpr uint16_t VP_PIDTUNE_FAN_TOGGLE = 0x238C;
constexpr uint16_t VP_PIDTUNE_FAN_TOGGLE_ICON = 0x238E;
constexpr uint16_t VP_PIDTUNE_START_BUTTON = 0x229B;
// FWRetract
constexpr uint16_t VP_FWRETRACT_NAV_BUTTON = 0x22AD;
constexpr uint16_t VP_FWRETRACT_RETRACT_LENGTH = 0x22B1;
constexpr uint16_t VP_FWRETRACT_RETRACT_FEEDRATE = 0x22B3;
constexpr uint16_t VP_FWRETRACT_RETRACT_ZHOP = 0x22B5;
constexpr uint16_t VP_FWRETRACT_RESTART_LENGTH = 0x22B7;
constexpr uint16_t VP_FWRETRACT_RESTART_FEEDRATE = 0x22B9;
constexpr uint16_t VP_FWRETRACT_TOGGLE_BUTTON = 0x22BB;
constexpr uint16_t VP_FWRETRACT_TOGGLE_BUTTON_ICON = 0x22BD;
constexpr uint16_t VP_FWRETRACT_INDICATOR_ICON = 0x22BF;
// Other tuning
constexpr uint16_t VP_LINEAR_ADVANCE_FACTOR = 0x22AF;
constexpr uint16_t VP_OTHER_TUNE_NAV_BUTTON = 0x2382;
// Leveling settings
constexpr uint16_t VP_TOGGLE_PROBING_HEATERS_OFF_ONOFF_BUTTON = 0x22C1;
constexpr uint16_t VP_TOGGLE_PROBING_HEATERS_OFF_ONOFF_ICON = 0x22C3;
constexpr uint16_t VP_TOGGLE_PROBE_PREHEAT_HOTEND_TEMP = 0x22C5;
constexpr uint16_t VP_TOGGLE_PROBE_PREHEAT_BED_TEMP = 0x22C7;
constexpr uint16_t VP_TOGGLE_PROBE_SETTINGS_NAV_BUTTON = 0x22C9;
constexpr uint16_t VP_TOGGLE_POST_PROBING_TEMPERATURE_STABILIZATION_ICON = 0x22CD;
constexpr uint16_t VP_TOGGLE_POST_PROBING_TEMPERATURE_STABILIZATION_BUTTON = 0x22CF;
constexpr uint16_t VP_LEVELING_FADE_HEIGHT = 0x231D;
// E-steps calibration
constexpr uint16_t VP_ESTEPS_CURRENT = 0x229d;
constexpr uint16_t VP_ESTEPS_CALIBRATION_TEMP = 0x229f;
constexpr uint16_t VP_ESTEPS_CALIBRATION_LENGTH = 0x22a1;
constexpr uint16_t VP_ESTEPS_CALIBRATION_MARK_LENGTH = 0x22ab;
constexpr uint16_t VP_ESTEPS_CALIBRATION_LEFTOVER_LENGTH = 0x22a3;
constexpr uint16_t VP_ESTEPS_CALCULATED_ESTEPS = 0x22a5;
constexpr uint16_t VP_ESTEPS_CALIBRATESTART_BUTTON = 0x22a7;
constexpr uint16_t VP_ESTEPS_APPLY_BUTTON = 0x22a9;
constexpr uint16_t VP_ESTEPS_BACK_BUTTON = 0x22D7;
// RGB
constexpr uint16_t VP_RGB_NAV_BUTTON = 0x2390;
constexpr uint16_t VP_RGB_CONTROL_R = 0x2392;
constexpr uint16_t VP_RGB_CONTROL_G = 0x2394;
constexpr uint16_t VP_RGB_CONTROL_B = 0x2396;
constexpr uint16_t VP_RGB_CONTROL_W = 0x2398;
constexpr uint16_t VP_RGB_CONTROL_I = 0x239A; // brightness
constexpr uint16_t VP_RGB_NAV_BUTTON_ICON = 0x239E;
constexpr uint16_t ICON_RGB_SETTINGS_AVAILABLE = 28;
constexpr uint16_t ICON_RGB_SETTINGS_UNAVAILABLE = 29;
// Filament load/unload
constexpr uint16_t VP_FILCHANGE_NAV_BUTTON = 0x23a6;
constexpr uint16_t VP_FILCHANGE_NOZZLE_TEMP = 0x23a0;
constexpr uint16_t VP_FILCHANGE_LENGTH = 0x23a2;
constexpr uint16_t VP_FILCHANGE_ACTION_BUTTON = 0x23a4;
constexpr uint16_t FILCHANGE_ACTION_UNLOAD_BUTTON = 1;
constexpr uint16_t FILCHANGE_ACTION_LOAD_BUTTON = 2;
// Icons
constexpr uint16_t ICON_TOGGLE_ON = 1;
constexpr uint16_t ICON_TOGGLE_OFF = 2;
constexpr uint16_t ICON_BACK_BUTTON_ENABLED = 7;
constexpr uint16_t ICON_BACK_BUTTON_DISABLED = 8;
constexpr uint16_t ICON_THROBBER_ANIM_OFF = 0;
constexpr uint16_t ICON_THROBBER_ANIM_ON = 1;
// Allow to visually disable/enable the back button
constexpr uint16_t VP_BACK_BUTTON_STATE = 0x22D1;
// Throbber animation
constexpr uint16_t VP_BUSY_ANIM_STATE = 0x22D3;
// Toggles
constexpr uint16_t ICON_FAN_TOGGLE_ON = 1;
constexpr uint16_t ICON_FAN_TOGGLE_OFF = 2;
constexpr uint16_t ICON_LED_TOGGLE_ON = 3;
constexpr uint16_t ICON_LED_TOGGLE_OFF = 4;
constexpr uint16_t ICON_SOUND_TOGGLE_ON = 5;
constexpr uint16_t ICON_SOUND_TOGGLE_OFF = 6;
constexpr uint16_t ICON_FWRETRACT_AUTO_TOGGLE_ON = 9;
constexpr uint16_t ICON_FWRETRACT_AUTO_TOGGLE_OFF = 10;
constexpr uint16_t ICON_ACCURACY_TOGGLE_ON = 11;
constexpr uint16_t ICON_ACCURACY_TOGGLE_OFF = 12;
constexpr uint16_t ICON_POST_PROBE_TEMP_STABILIZATION_TOGGLE_ON = 13;
constexpr uint16_t ICON_POST_PROBE_TEMP_STABILIZATION_TOGGLE_OFF = 14;
constexpr uint16_t ICON_FWRETRACT_AUTO_DISENGAGED = 4; // This icon deliberately does not exist
constexpr uint16_t ICON_FWRETRACT_AUTO_ENGAGED = 3;
// Development helper
constexpr uint16_t VP_DEVELOPMENT_HELPER_BUTTON = 0x22D5;
constexpr uint16_t VP_DEVELOPMENT_HELPER_BUTTON_ACTION_FIRMWARE_UPDATE = 2;
constexpr uint16_t VP_DEVELOPMENT_HELPER_BUTTON_ACTION_TO_MAIN_MENU = 4;
constexpr uint16_t VP_DEVELOPMENT_HELPER_BUTTON_ACTION_RESET_DISPLAY = 8;
@@ -1,188 +0,0 @@
#include "../../../../inc/MarlinConfigPre.h"
#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#include "../DGUSDisplayDef.h"
#include "../DGUSDisplay.h"
#include "../DGUSScreenHandler.h"
#include "EstepsHandler.h"
#include "../../ui_api.h"
#include "../../../marlinui.h"
#include "../../../../module/temperature.h"
#include "../../../../module/settings.h"
#include "../../../../module/planner.h"
#include "../../../../gcode/gcode.h"
// Storage init
float EstepsHandler::set_esteps = 0;
float EstepsHandler::calculated_esteps = 0;
float EstepsHandler::remaining_filament = 0;
float EstepsHandler::mark_filament_mm = 0;
float EstepsHandler::filament_to_extrude = 0;
celsius_t EstepsHandler::calibration_temperature = 0;
void EstepsHandler::Init() {
// Use steps
set_esteps = ExtUI::getAxisSteps_per_mm(ExtUI::E0);
calculated_esteps = 0;
// Reset
filament_to_extrude = 100;
mark_filament_mm = 120;
remaining_filament = 0;
// Use configured PLA temps + 10 degrees
calibration_temperature = ui.material_preset[0].hotend_temp + 10;
// Welcome message
SetStatusMessage(PSTR("Ready"));
}
void EstepsHandler::HandleStartButton(DGUS_VP_Variable &var, void *val_ptr) {
//static_assert(ADVANCED_PAUSE_PURGE_LENGTH == 0, "Assuming PURGE_LENGTH is 0 so we can use M701");
// Validate
if (calibration_temperature < EXTRUDE_MINTEMP) {
SetStatusMessage(PSTR("Invalid temperature set"));
return;
}
if (filament_to_extrude < 10) {
SetStatusMessage(PSTR("Invalid extrusion length set"));
return;
}
if (mark_filament_mm < filament_to_extrude) {
SetStatusMessage(PSTR("Invalid mark length set"));
return;
}
// Synchronous operation - disable back button
DGUSSynchronousOperation syncOperation;
syncOperation.start();
// Prepare
bool zAxisWasRelative = GcodeSuite::axis_is_relative(Z_AXIS);
bool eAxisWasRelative = GcodeSuite::axis_is_relative(E_AXIS);
#if ENABLED(LIN_ADVANCE)
float kFactor = planner.extruder_advance_K[0];
#endif
GcodeSuite::set_e_relative();
GcodeSuite::set_relative_mode(true);
#if ENABLED(LIN_ADVANCE)
planner.extruder_advance_K[0] = 0;
#endif
ExtUI::injectCommands_P("G0 Z5 F150");
queue.advance();
// Heat up if necessary
if (abs(ExtUI::getActualTemp_celsius(ExtUI::E0) - calibration_temperature) > 2) {
thermalManager.setTargetHotend(calibration_temperature, ExtUI::H0);
SetStatusMessage(PSTR("Heating up..."));
thermalManager.wait_for_hotend(ExtUI::H0, false);
}
planner.synchronize();
// Set-up command
SetStatusMessage(PSTR("Extruding..."));
char cmd[64];
sprintf_P(cmd, PSTR("G1 E%f F50"), filament_to_extrude);
ExtUI::injectCommands(cmd);
queue.advance();
planner.synchronize();
// Restore position
ExtUI::injectCommands_P("G0 Z-5 F150");
queue.advance();
planner.synchronize();
// Restore defaults
if (!zAxisWasRelative) GcodeSuite::set_relative_mode(false);
if (!eAxisWasRelative) GcodeSuite::set_e_absolute();
#if ENABLED(LIN_ADVANCE)
planner.extruder_advance_K[0] = kFactor;
#endif
// Done
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_ESTEPS_CALIBRATION_RESULTS, false);
ScreenHandler.Buzzer(0, 250);
syncOperation.done();
SetStatusMessage(PSTR("Measure remaining filament"));
}
void EstepsHandler::HandleApplyButton(DGUS_VP_Variable &var, void *val_ptr) {
if (abs(calculated_esteps) < 1) {
// User intented to set e-steps directly
ExtUI::setAxisSteps_per_mm(set_esteps, ExtUI::E0);
} else {
ExtUI::setAxisSteps_per_mm(calculated_esteps, ExtUI::E0);
}
SaveSettingsAndReturn(true);
}
void EstepsHandler::HandleBackButton(DGUS_VP_Variable &var, void *val_ptr) {
// User intented to set e-steps directly
ExtUI::setAxisSteps_per_mm(set_esteps, ExtUI::E0);
SaveSettingsAndReturn(false);
}
void EstepsHandler::SaveSettingsAndReturn(bool fullConfirm) {
// Save & reset
settings.save();
if (fullConfirm) ScreenHandler.Buzzer(0, 250);
ScreenHandler.PopToOldScreen();
if (fullConfirm) ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MAIN, false);
SetStatusMessage(PSTR("New e-steps value saved"));
}
void EstepsHandler::HandleRemainingFilament(DGUS_VP_Variable &var, void *val_ptr) {
ScreenHandler.DGUSLCD_SetFloatAsIntFromDisplay<1>(var, val_ptr);
// Calculate
constexpr float precision = 0.01;
float actualExtrusion = mark_filament_mm - remaining_filament;
if (actualExtrusion < (-precision)) {
SetStatusMessage(PSTR("Mark filament further"));
return;
}
if (actualExtrusion < precision) {
SetStatusMessage(PSTR("E-steps are correct"));
calculated_esteps = set_esteps;
return;
}
float current_steps = ExtUI::getAxisSteps_per_mm(ExtUI::E0);
SERIAL_ECHOLNPGM("Current steps: ", current_steps);
SERIAL_ECHOLNPGM("Actual extrusion: ", actualExtrusion);
float new_steps = (current_steps * filament_to_extrude) / actualExtrusion;
SERIAL_ECHOLNPGM("New steps: ", new_steps);
calculated_esteps = new_steps;
// Status update
SetStatusMessage(PSTR("Calculated new e-steps"));
}
void EstepsHandler::SetStatusMessage(PGM_P statusMessage) {
ScreenHandler.setstatusmessagePGM(statusMessage);
}
#endif
@@ -1,29 +0,0 @@
#pragma once
#include <cstdint>
class EstepsHandler {
public:
static void Init();
static void HandleStartButton(DGUS_VP_Variable &var, void *val_ptr);
static void HandleApplyButton(DGUS_VP_Variable &var, void *val_ptr);
static void HandleBackButton(DGUS_VP_Variable &var, void *val_ptr);
static void HandleRemainingFilament(DGUS_VP_Variable &var, void *val_ptr);
public:
static float set_esteps;
static float calculated_esteps;
static float mark_filament_mm;
static float remaining_filament;
static float filament_to_extrude;
static celsius_t calibration_temperature;
private:
static void SaveSettingsAndReturn(bool fullConfirm);
static void SetStatusMessage(PGM_P statusMessage);
};
@@ -1,106 +0,0 @@
#include "../../../../inc/MarlinConfigPre.h"
#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#include "../DGUSDisplayDef.h"
#include "../DGUSDisplay.h"
#include "../DGUSScreenHandler.h"
#include "FilamentLoadUnloadHandler.h"
#include "../../ui_api.h"
#include "../../../marlinui.h"
#include "../../../../module/temperature.h"
#include "../../../../module/settings.h"
#include "../../../../module/planner.h"
#include "../../../../gcode/gcode.h"
celsius_t FilamentLoadUnloadHandler::nozzle_temperature = 0;
float FilamentLoadUnloadHandler::length = 0;
void FilamentLoadUnloadHandler::Init() {
nozzle_temperature = ui.material_preset[0].hotend_temp;
length = 150;
if (ExtUI::isPrinting()) {
nozzle_temperature = ExtUI::getTargetTemp_celsius(ExtUI::extruder_t::E0);
}
}
void FilamentLoadUnloadHandler::HandleTemperature(DGUS_VP_Variable &var, void *val_ptr) {
ScreenHandler.DGUSLCD_SetValueDirectly<uint16_t>(var, val_ptr);
ValidateTemperatures();
}
void FilamentLoadUnloadHandler::HandleLoadUnloadButton(DGUS_VP_Variable &var, void *val_ptr) {
// Common for load/unload -> determine minimum temperature
if (length < 0.1) {
SetStatusMessage("Invalid feed length");
return;
}
if (ExtUI::isPrinting() && !ExtUI::isPrintingPaused()) {
SetStatusMessage(PSTR("Finish Printing First"));
return;
}
DGUSSynchronousOperation syncOperation;
uint16_t button_value = uInt16Value(val_ptr);
switch (button_value) {
case FILCHANGE_ACTION_LOAD_BUTTON:
syncOperation.start();
ChangeFilamentWithTemperature(PSTR("M701 L%f P0"));
syncOperation.done();
break;
case FILCHANGE_ACTION_UNLOAD_BUTTON:
syncOperation.start();
ChangeFilamentWithTemperature(PSTR("M702 U%f"));
syncOperation.done();
break;
}
}
void FilamentLoadUnloadHandler::ValidateTemperatures() {
LIMIT(nozzle_temperature, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - HOTEND_OVERSHOOT);
}
void FilamentLoadUnloadHandler::ChangeFilamentWithTemperature(PGM_P command) {
// Heat if necessary
if (ExtUI::getActualTemp_celsius(ExtUI::E0) < nozzle_temperature && abs(ExtUI::getActualTemp_celsius(ExtUI::E0) - nozzle_temperature) > THERMAL_PROTECTION_HYSTERESIS) {
SetStatusMessage(PSTR("Heating up..."));
uint16_t target_celsius = nozzle_temperature;
NOMORE(target_celsius, thermalManager.hotend_max_target(0));
thermalManager.setTargetHotend(target_celsius, ExtUI::H0);
thermalManager.wait_for_hotend(ExtUI::H0, false);
}
// Inject load filament command
SetStatusMessage(PSTR("Filament load/unload..."));
char cmd[64];
sprintf_P(cmd, command, length);
// Handle commands
SERIAL_ECHOPGM("Injecting command: ", cmd);
GcodeSuite::process_subcommands_now(cmd);
SERIAL_ECHOPGM_P("- done");
if (ScreenHandler.Settings.display_sound) ScreenHandler.Buzzer(500, 100);
SetStatusMessage(PSTR("Filament load/unload complete"));
}
void FilamentLoadUnloadHandler::SetStatusMessage(PGM_P statusMessage) {
ScreenHandler.setstatusmessagePGM(statusMessage);
}
#endif
@@ -1,22 +0,0 @@
#pragma once
#include <cstdint>
class FilamentLoadUnloadHandler {
public:
static void Init();
static void HandleTemperature(DGUS_VP_Variable &var, void *val_ptr);
static void HandleLoadUnloadButton(DGUS_VP_Variable &var, void *val_ptr);
public:
static celsius_t nozzle_temperature;
static float length;
private:
static void ValidateTemperatures();
static void ChangeFilamentWithTemperature(PGM_P command);
static void SetStatusMessage(PGM_P statusMessage);
};
@@ -1,150 +0,0 @@
#include "../../../../inc/MarlinConfigPre.h"
#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH) && HAS_MESH
#include "../DGUSDisplayDef.h"
#include "../DGUSDisplay.h"
#include "../DGUSScreenHandler.h"
#include "MeshValidationHandler.h"
#include "../../ui_api.h"
#include "../../../marlinui.h"
#include "../../../../module/temperature.h"
#include "../../../../module/settings.h"
#include "../../../../module/planner.h"
#include "../../../../gcode/gcode.h"
celsius_t MeshValidationHandler::nozzle_temperature;
celsius_t MeshValidationHandler::bed_temperature;
bool MeshValidationHandler::is_running;
bool MeshValidationHandler::started_from_screen;
bool MeshValidationHandler::is_cancelling;
feedRate_t MeshValidationHandler::prev_feedrate;
void MeshValidationHandler::Init() {
// Set to PLA pre-heat temps by default
nozzle_temperature = ui.material_preset[0].hotend_temp;
bed_temperature = ui.material_preset[0].bed_temp;
ValidateTemperatures();
}
void MeshValidationHandler::HandleTemperature(DGUS_VP_Variable &var, void *val_ptr) {
ScreenHandler.DGUSLCD_SetValueDirectly<uint16_t>(var, val_ptr);
ValidateTemperatures();
}
void MeshValidationHandler::HandleStartOrCancelButton(DGUS_VP_Variable &var, void *val_ptr) {
if (!is_running) {
Start();
} else {
Cancel();
}
}
void MeshValidationHandler::Start() {
if (is_running) return;
// Validate
if (!ExtUI::getMeshValid()) {
SetStatusMessage("Please level bed first");
return;
}
// Block
ScreenHandler.SetSynchronousOperationStart();
is_running = true;
started_from_screen = true;
// Home if necessary - do this synchronously
if (!all_axes_trusted()) {
queue.inject_P("G28 U0");
queue.advance();
}
// Home X and Y so we droop at the side of the bed.
// G26 with temperature and set for full bed, full pattern, retract 4mm, prime 5mm
char gcodeBuffer[128] = {0};
sprintf_P(gcodeBuffer, PSTR("G90\nG0 X0\nG26 B%d H%d R Q4 P2 X0 Y0"), bed_temperature, nozzle_temperature);
queue.inject(gcodeBuffer);
queue.advance();
// Set feedrate
prev_feedrate = ExtUI::getFeedrate_mm_s();
ExtUI::setFeedrate_mm_s(MESH_VALIDATION_PATTERN_FEEDRATE);
SetStatusMessage("Starting...");
}
void MeshValidationHandler::Cancel() {
if (is_cancelling) return;
is_cancelling = true;
ExtUI::simulateUserClick();
SetStatusMessage("Cancelling...");
}
void MeshValidationHandler::OnMeshValidationStart() {
// Note: can also be called when manually invoking G26
if (ScreenHandler.getCurrentScreen() != DGUSLCD_SCREEN_MESH_VALIDATION) {
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MESH_VALIDATION);
}
// Set state
ScreenHandler.SetSynchronousOperationStart();
is_running = true;
}
void MeshValidationHandler::OnMeshValidationFinish() {
// If invoked externally, pop back
if (!started_from_screen) {
ScreenHandler.PopToOldScreen();
}
if (started_from_screen) {
ExtUI::setFeedrate_mm_s(prev_feedrate);
char gcodeBuffer[128] = {0};
if (!is_cancelling) {
// Present
// - Set absolute mode
// - Present bed, high Z
// - Disable stepper
strcpy_P(gcodeBuffer, PSTR("M84"));
SetStatusMessage("Mesh validation pattern printed");
} else {
// Park and disable steppers
strcpy_P(gcodeBuffer, PSTR("G0 X5 F2000\nG27\nM84"));
SetStatusMessage("Canceled mesh validation pattern");
}
// Enqueue
gcode.process_subcommands_now(gcodeBuffer);
}
// Reset state
is_running = false;
started_from_screen = false;
is_cancelling = false;
ScreenHandler.SetSynchronousOperationFinish();
ExtUI::simulateUserClick();
}
void MeshValidationHandler::ValidateTemperatures() {
LIMIT(nozzle_temperature, EXTRUDE_MINTEMP, HEATER_0_MAXTEMP - HOTEND_OVERSHOOT);
LIMIT(bed_temperature, 40 /*Hardcoded minimum for G26, apparently*/, BED_MAXTEMP - BED_OVERSHOOT);
}
void MeshValidationHandler::SetStatusMessage(PGM_P statusMessage) {
ScreenHandler.setstatusmessagePGM(statusMessage);
}
#endif
@@ -1,33 +0,0 @@
#include <cstdint>
#if HAS_MESH
class MeshValidationHandler {
public:
static void Init();
static void HandleTemperature(DGUS_VP_Variable &var, void *val_ptr);
static void HandleStartOrCancelButton(DGUS_VP_Variable &var, void *val_ptr);
static void OnMeshValidationStart();
static void OnMeshValidationFinish();
public:
static celsius_t nozzle_temperature;
static celsius_t bed_temperature;
static feedRate_t prev_feedrate;
static bool is_cancelling;
static bool is_running;
static bool started_from_screen;
private:
static void Start();
static void Cancel();
static void ValidateTemperatures();
static void SetStatusMessage(PGM_P statusMessage);
};
constexpr feedRate_t MESH_VALIDATION_PATTERN_FEEDRATE = G26_XY_FEEDRATE;
#endif
@@ -1,91 +0,0 @@
#include "../../../../inc/MarlinConfigPre.h"
#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#include "../DGUSDisplayDef.h"
#include "../DGUSDisplay.h"
#include "../DGUSScreenHandler.h"
#include "PIDHandler.h"
#include "../../ui_api.h"
#include "../../../marlinui.h"
#include "../../../../module/temperature.h"
#include "../../../../module/settings.h"
#include "../../../../module/planner.h"
#include "../../../../gcode/gcode.h"
// Storage init
uint16_t PIDHandler::cycles = 0;
celsius_t PIDHandler::calibration_temperature = 0;
bool PIDHandler::fan_on = false;
PGM_P PIDHandler::result_message = nullptr;
void PIDHandler::Init() {
// Reset
cycles = 3;
fan_on = ExtUI::getTargetFan_percent(ExtUI::fan_t::FAN0) > 10;
// Use configured PLA temps + 10 degrees
calibration_temperature = ui.material_preset[0].hotend_temp + 15;
// Welcome message
SetStatusMessage(PSTR("Ready"));
}
void PIDHandler::HandleStartButton(DGUS_VP_Variable &var, void *val_ptr) {
//static_assert(ADVANCED_PAUSE_PURGE_LENGTH == 0, "Assuming PURGE_LENGTH is 0 so we can use M701");
// Validate
if (calibration_temperature < EXTRUDE_MINTEMP) {
SetStatusMessage(PSTR("Invalid temperature set"));
return;
}
if (calibration_temperature > HEATER_0_MAXTEMP) {
SetStatusMessage(PSTR("Invalid temperature set"));
return;
}
if (cycles < 1) {
SetStatusMessage(PSTR("Invalid number of cycles"));
return;
}
// Synchronous operation - disable back button
DGUSSynchronousOperation syncOperation;
syncOperation.start();
// Fan
const auto prev_fan_percentage = ExtUI::getActualFan_percent(ExtUI::fan_t::FAN0);
const uint8_t fan_speed = fan_on ? 255 : 0;
// Set-up command
SetStatusMessage(PSTR("PID tuning. Please wait..."));
char cmd[64]; // Add a G4 to allow the fan speed to take effect
sprintf_P(cmd, PSTR("M106 S%d\nG4 S2\nM303 S%d C%d U1"), fan_speed, calibration_temperature, cycles);
SERIAL_ECHOLNPGM("Executing: ", cmd);
ExtUI::injectCommands(cmd);
while (queue.has_commands_queued()) queue.advance();
// Done
ExtUI::setTargetFan_percent(prev_fan_percentage, ExtUI::fan_t::FAN0);
ScreenHandler.Buzzer(0, 250);
settings.save();
syncOperation.done();
SetStatusMessage(result_message);
}
void PIDHandler::SetStatusMessage(PGM_P statusMessage) {
ScreenHandler.setstatusmessagePGM(statusMessage);
}
#endif
@@ -1,21 +0,0 @@
#pragma once
#include <cstdint>
class PIDHandler {
public:
static void Init();
static void HandleStartButton(DGUS_VP_Variable &var, void *val_ptr);
public:
static uint16_t cycles;
static celsius_t calibration_temperature;
static bool fan_on;
static PGM_P result_message;
private:
static void SetStatusMessage(PGM_P statusMessage);
};
@@ -1,470 +0,0 @@
#include "../../../../inc/MarlinConfigPre.h"
#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#include "../DGUSDisplayDef.h"
#include "../DGUSDisplay.h"
#include "../DGUSScreenHandler.h"
#include "../../../../module/temperature.h"
#include "../../../../module/motion.h"
#include "../../../../module/planner.h"
#include "../../../../feature/pause.h"
#include "../../../../gcode/gcode.h"
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
#include "../../../../feature/runout.h"
#endif
#include "../../../../module/settings.h"
#include "../../ui_api.h"
#include "../../../marlinui.h"
#include "PageHandlers.h"
// Definitions of page handlers
void MainMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_MAINENTERKEY:
switch (buttonValue) {
case 1:
// Try to mount an unmounted card (BTT SKR board has especially some trouble sometimes)
card.mount();
ScreenHandler.SDCardInserted();
break;
case 2:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PREPARE);
break;
case 3:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_SETUP);
break;
case 4:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_CALIBRATE);
break;
}
break;
}
}
void SetupMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_PREPAREENTERKEY:
switch(buttonValue) {
case 5: // About
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_INFO);
break;
case 7: // Reset to factory settings
settings.reset();
settings.save();
ExtUI::injectCommands_P(PSTR("M300"));
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MAIN, false);
ScreenHandler.setstatusmessagePGM(PSTR("Restored default settings. Please turn your printer off and then on to complete the reset"));
break;
}
break;
case VP_BUTTON_TEMPCONTROL:
if (buttonValue == 2) ScreenHandler.GotoScreen(DGUSLCD_SCREEN_TEMP);
break;
case VP_BUTTON_ADJUSTENTERKEY:
ScreenHandler.HandleLEDToggle();
break;
}
}
#if HAS_MESH
void LevelingModeHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_BEDLEVELKEY:
switch (buttonValue) {
case 1:
queue.enqueue_one("G28 U0");
queue.enqueue_one("G0 Z0");
break;
case 2:
// Increase Z-offset
ExtUI::smartAdjustAxis_steps(ExtUI::mmToWholeSteps(0.01, ExtUI::axis_t::Z), ExtUI::axis_t::Z, true);;
ScreenHandler.ForceCompleteUpdate();
ScreenHandler.RequestSaveSettings();
break;
case 3:
// Decrease Z-offset
ExtUI::smartAdjustAxis_steps(ExtUI::mmToWholeSteps(-0.01, ExtUI::axis_t::Z), ExtUI::axis_t::Z, true);;
ScreenHandler.ForceCompleteUpdate();
ScreenHandler.RequestSaveSettings();
break;
}
break;
case VP_BUTTON_PREPAREENTERKEY:
if (buttonValue == 9) {
#if DISABLED(HOTEND_IDLE_TIMEOUT)
thermalManager.disable_all_heaters();
#endif
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MAIN, false);
}
if (buttonValue == 1) {
// TODO: set state for "view leveling mesh"
ScreenHandler.SetViewMeshLevelState();
ScreenHandler.InitMeshValues();
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_LEVELING);
}
break;
case VP_BUTTON_MAINENTERKEY:
// Go to leveling screen
ExtUI::injectCommands_P("G28 U0\nG29 U0");
ScreenHandler.ResetMeshValues();
dgusdisplay.WriteVariable(VP_MESH_SCREEN_MESSAGE_ICON, static_cast<uint16_t>(MESH_SCREEN_MESSAGE_ICON_LEVELING));
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_LEVELING);
break;
}
}
void LevelingHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_BEDLEVELKEY:
const bool busy = TERN0(HOST_KEEPALIVE_FEATURE, ((ExtUI::getHostKeepaliveState() == GcodeSuite::MarlinBusyState::IN_PROCESS) || (ExtUI::getHostKeepaliveState() == GcodeSuite::MarlinBusyState::IN_HANDLER)));
if (!busy) {
ScreenHandler.PopToOldScreen();
} else {
ScreenHandler.setstatusmessagePGM("Wait for leveling completion...");
}
break;
}
}
#endif
void TempMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_ADJUSTENTERKEY:
switch (buttonValue) {
case 3:
ScreenHandler.HandleFanToggle();
break;
}
break;
case VP_BUTTON_TEMPCONTROL:
switch (buttonValue){
case 3:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_TEMP_PLA);
break;
case 4:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_TEMP_ABS);
break;
}
break;
}
}
void PrepareMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_PREPAREENTERKEY:
switch (buttonValue){
case 3:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MOVE10MM);
break;
case 6:
// Disable steppers
ScreenHandler.HandleMotorLockUnlock(var, &buttonValue);
break;
}
break;
case VP_BUTTON_HEATLOADSTARTKEY:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_FEED);
break;
case VP_BUTTON_COOLDOWN:
ScreenHandler.HandleAllHeatersOff(var, &buttonValue);
break;
case VP_BUTTON_TEMPCONTROL:
switch (buttonValue) {
case 5:
thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0);
thermalManager.setTargetBed(ui.material_preset[0].bed_temp);
break;
case 6:
thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0);
thermalManager.setTargetBed(ui.material_preset[1].bed_temp);
break;
}
break;
}
ScreenHandler.ForceCompleteUpdate();
}
void TuneMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_BEDLEVELKEY:
switch (buttonValue) {
case 2:
// Increase Z-offset
ExtUI::smartAdjustAxis_steps(ExtUI::mmToWholeSteps(0.01, ExtUI::axis_t::Z), ExtUI::axis_t::Z, true);;
ScreenHandler.ForceCompleteUpdate();
ScreenHandler.RequestSaveSettings();
break;
case 3:
// Decrease Z-offset
ExtUI::smartAdjustAxis_steps(ExtUI::mmToWholeSteps(-0.01, ExtUI::axis_t::Z), ExtUI::axis_t::Z, true);;
ScreenHandler.ForceCompleteUpdate();
ScreenHandler.RequestSaveSettings();
break;
}
break;
case VP_BUTTON_ADJUSTENTERKEY:
switch (buttonValue) {
case 2:
ScreenHandler.GotoScreen(ExtUI::isPrintingPaused() ? DGUSLCD_SCREEN_PRINT_PAUSED : DGUSLCD_SCREEN_PRINT_RUNNING, false);
break;
case 3:
ScreenHandler.HandleFanToggle();
break;
case 4:
ScreenHandler.HandleLEDToggle();
break;
}
}
}
void PrintRunningMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_ADJUSTENTERKEY:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_TUNING);
break;
case VP_BUTTON_PAUSEPRINTKEY:
if (!ScreenHandler.HandlePendingUserConfirmation() && ExtUI::isPrintingPaused()) {
ExtUI::resumePrint();
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PRINT_RUNNING);
} else
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_DIALOG_PAUSE);
break;
case VP_BUTTON_STOPPRINTKEY:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_DIALOG_STOP);
break;
}
}
void PrintPausedMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP) {
case VP_BUTTON_RESUMEPRINTKEY:
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
runout.reset();
#endif
if (!ScreenHandler.HandlePendingUserConfirmation()) {
ExtUI::resumePrint();
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PRINT_RUNNING);
}
break;
case VP_BUTTON_ADJUSTENTERKEY:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_TUNING);
break;
case VP_BUTTON_STOPPRINTKEY:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_DIALOG_STOP);
break;
}
}
void PrintPauseDialogHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP){
case VP_BUTTON_PAUSEPRINTKEY:
switch (buttonValue) {
case 2:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PRINT_RUNNING);
ScreenHandler.setstatusmessagePGM(PSTR("Pausing print - please wait..."));
ExtUI::pausePrint();
break;
case 3:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PRINT_RUNNING);
break;
}
break;
}
}
void PrintFinishMenuHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP){
case VP_BUTTON_MAINENTERKEY:
switch (buttonValue) {
case 5:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MAIN);
break;
}
break;
}
}
void FilamentRunoutHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP){
case VP_BUTTON_RESUMEPRINTKEY:
ExtUI::resumePrint();
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PRINT_RUNNING);
break;
case VP_BUTTON_STOPPRINTKEY:
ExtUI::stopPrint();
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MAIN);
break;
}
}
void StopConfirmScreenHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP){
case VP_BUTTON_STOPPRINTKEY:
switch (buttonValue) {
case 2:
ExtUI::stopPrint();
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MAIN);
break;
case 3:
ScreenHandler.GotoScreen(ExtUI::isPrintingPaused() ? DGUSLCD_SCREEN_PRINT_PAUSED : DGUSLCD_SCREEN_PRINT_RUNNING);
break;
}
break;
}
}
void PreheatSettingsScreenHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
switch (var.VP){
case VP_BUTTON_PREPAREENTERKEY:
// Save button, save settings and go back
ScreenHandler.RequestSaveSettings();
ScreenHandler.PopToOldScreen();
break;
case VP_BUTTON_COOLDOWN: // You can't make this up
// Back button, discard settings
settings.load();
ScreenHandler.PopToOldScreen();
break;
}
}
void MoveHandler(DGUS_VP_Variable &var, unsigned short buttonValue) {
if (var.VP == VP_BUTTON_MOVEKEY) {
switch (buttonValue) {
case 1:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MOVE10MM, false);
break;
case 2:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MOVE1MM, false);
break;
case 3:
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_MOVE01MM, false);
break;
case 4:
// Temporary copy probe settings so we home without preheating, then restore setings afterward
//This machine should never home Z cold...
//auto prev_probe_settings = probe.settings;
//probe.settings.preheat_bed_temp = 0;
//probe.settings.preheat_hotend_temp = 0;
//probe.settings.stabilize_temperatures_after_probing = false;
ExtUI::injectCommands_P("G28");
while (queue.has_commands_queued()) queue.advance();
// ... Restore settings
//probe.settings = prev_probe_settings;
break;
}
}
}
// Register the page handlers
#define PAGE_HANDLER(SCRID, HDLRPTR) { .ScreenID=SCRID, .Handler=HDLRPTR },
const struct PageHandler PageHandlers[] PROGMEM = {
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_MAIN, MainMenuHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_SETUP, SetupMenuHandler)
#if HAS_MESH
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_ZOFFSET_LEVEL, LevelingModeHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_LEVELING, LevelingHandler)
#endif
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_TEMP, TempMenuHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_TEMP_PLA, PreheatSettingsScreenHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_TEMP_ABS, PreheatSettingsScreenHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_TUNING, TuneMenuHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_MOVE01MM, MoveHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_MOVE1MM, MoveHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_MOVE10MM, MoveHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_FILAMENTRUNOUT1, FilamentRunoutHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_FILAMENTRUNOUT2, FilamentRunoutHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_DIALOG_STOP, StopConfirmScreenHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_PRINT_RUNNING, PrintRunningMenuHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_PRINT_PAUSED, PrintPausedMenuHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_PRINT_FINISH, PrintFinishMenuHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_DIALOG_PAUSE, PrintPauseDialogHandler)
PAGE_HANDLER(DGUSLCD_Screens::DGUSLCD_SCREEN_PREPARE, PrepareMenuHandler)
// Terminating
PAGE_HANDLER(static_cast<DGUSLCD_Screens>(0) ,0)
};
void DGUSCrealityDisplay_HandleReturnKeyEvent(DGUS_VP_Variable &var, void *val_ptr) {
const struct PageHandler *map = PageHandlers;
const uint16_t *ret;
const DGUSLCD_Screens current_screen = DGUSScreenHandler::getCurrentScreen();
while ((ret = (uint16_t*) pgm_read_ptr(&(map->Handler)))) {
if ((map->ScreenID) == current_screen) {
uint16_t button_value = uInt16Value(val_ptr);
SERIAL_ECHOLNPGM("Invoking handler for screen ", current_screen);
SERIAL_ECHOLNPGM("with VP=", var.VP, " value=", button_value);
map->Handler(var, button_value);
return;
}
map++;
}
}
#endif
@@ -1,11 +0,0 @@
#pragma once
// Mapping of handlers per page. This construction is necessary because the CR-6 touch screen re-uses the same button IDs all over the place.
typedef void (*DGUS_CREALITY_SCREEN_BUTTON_HANDLER)(DGUS_VP_Variable &var, unsigned short buttonValue);
struct PageHandler {
DGUSLCD_Screens ScreenID;
DGUS_CREALITY_SCREEN_BUTTON_HANDLER Handler;
};
void DGUSCrealityDisplay_HandleReturnKeyEvent(DGUS_VP_Variable &var, void *val_ptr);
-267
View File
@@ -1,267 +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 <https://www.gnu.org/licenses/>.
*
*/
/**
* dgus_creality_lcd.cpp
*
* DGUS implementation written by coldtobi in 2019 for Marlin
*/
#include "../../inc/MarlinConfigPre.h"
#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
#include "ui_api.h"
#include "../marlinui.h"
#include "./dgus_creality/DGUSDisplay.h"
#include "./dgus_creality/DGUSDisplayDef.h"
#include "./dgus_creality/DGUSScreenHandler.h"
#include "./dgus_creality/creality_touch/PIDHandler.h"
#include "./dgus_creality/creality_touch/MeshValidationHandler.h"
#if ENABLED(POWER_LOSS_RECOVERY)
#include "../../feature/powerloss.h"
#endif
extern const char NUL_STR[];
namespace ExtUI {
void onStartup() {
ScreenHandler.Init();
ScreenHandler.UpdateScreenVPData();
}
void onIdle() { ScreenHandler.loop(); }
void onPrinterKilled(FSTR_P const error, FSTR_P const component) {
ScreenHandler.sendinfoscreen(GET_TEXT_F(MSG_HALTED), error, GET_TEXT_F(MSG_PLEASE_RESET), GET_TEXT_F(MSG_PLEASE_RESET), true, true, true, true);
if (error == GET_TEXT_F(MSG_ERR_MAXTEMP) || error == GET_TEXT_F(MSG_THERMAL_RUNAWAY)) {
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_THERMAL_RUNAWAY);
} else if ( error == GET_TEXT_F(MSG_HEATING_FAILED_LCD)) {
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_HEATING_FAILED);
}else if (error == GET_TEXT_F(MSG_ERR_MINTEMP)) {
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_THERMISTOR_ERROR);
} else {
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_KILL);
}
ScreenHandler.KillScreenCalled();
while (!ScreenHandler.loop()); // Wait while anything is left to be sent
}
void onMediaInserted() { TERN_(SDSUPPORT, ScreenHandler.SDCardInserted()); }
void onMediaError() { TERN_(SDSUPPORT, ScreenHandler.SDCardError()); }
void onMediaRemoved() { TERN_(SDSUPPORT, ScreenHandler.SDCardRemoved()); }
void onPlayTone(const uint16_t frequency, const uint16_t duration) {
if (ScreenHandler.getCurrentScreen() == DGUSLCD_SCREEN_FEED) {
// We're in the feed (load filament) workflow - no beep - there is no confirmation
return;
}
ScreenHandler.Buzzer(frequency, duration);
}
bool hasPrintTimer = false;
void onPrintTimerStarted() {
hasPrintTimer = true;
if (!IS_SD_FILE_OPEN() && !(PrintJobRecovery::valid() && PrintJobRecovery::exists())) {
ScreenHandler.SetPrintingFromHost();
}
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
ui.progress_reset();
#endif
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PRINT_RUNNING);
}
void onPrintTimerPaused() {
// Handle M28 Pause SD print - But only if we're not waiting on a user
if (ExtUI::isPrintingFromMediaPaused() && ScreenHandler.getCurrentScreen() == DGUSLCD_SCREEN_PRINT_RUNNING && !ExtUI::awaitingUserConfirm()) {
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PRINT_PAUSED);
}
}
void onPrintTimerStopped() {
hasPrintTimer = false;
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PRINT_FINISH);
}
void onFilamentRunout(const extruder_t extruder) {
// Only navigate to filament runout screen when we don't use M600 for changing the filament - otherwise it gets confusing for the user
#ifndef FILAMENT_RUNOUT_SCRIPT
#define FILAMENT_RUNOUT_SCRIPT "M25"
#endif
if (strcmp_P(FILAMENT_RUNOUT_SCRIPT, PSTR("M600")) != 0) {
ScreenHandler.FilamentRunout();
}
}
void onUserConfirmed() {
SERIAL_ECHOLN("User confirmation invoked");
setPauseMenuResponse(PAUSE_RESPONSE_RESUME_PRINT);
ExtUI::setUserConfirmed();
}
void onUserConfirmRequired(const char * const msg) {
//if (msg) {
SERIAL_ECHOLNPGM("User confirmation requested: ", msg);
if (ScreenHandler.getCurrentScreen() == DGUSLCD_SCREEN_FEED) {
// We're in the feed (load filament) workflow - immediately assume confirmed
onUserConfirmed();
return;
}
ScreenHandler.setstatusmessagePGM(msg);
ScreenHandler.sendinfoscreen("Confirmation required", msg, NUL_STR, "Ok", true, true, false, true);
if (ExtUI::isPrinting()) {
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_PRINT_PAUSED);
} else {
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POPUP);
}
//}
//else if (ScreenHandler.getCurrentScreen() == DGUSLCD_SCREEN_POPUP) {
// DEBUG_ECHOLNPAIR("User confirmation canceled");
// ScreenHandler.setstatusmessagePGM(nullptr);
// ScreenHandler.PopToOldScreen();
//}
}
void onStatusChanged(const char * const msg) { ScreenHandler.setstatusmessage(msg); }
void onFactoryReset() {
ScreenHandler.OnFactoryReset();
}
void onHomingStart() {
ScreenHandler.OnHomingStart();
}
void onHomingDone() {
ScreenHandler.OnHomingComplete();
}
void onPrintDone() {
ScreenHandler.OnPrintFinished();
}
void onStoreSettings(char *buff) {
ScreenHandler.StoreSettings(buff);
}
void onLoadSettings(const char *buff) {
ScreenHandler.LoadSettings(buff);
}
void onPostprocessSettings() {
// Called after loading or resetting stored settings
}
void onSettingsStored(bool success) {
// Called after the entire EEPROM has been written,
// whether successful or not.
}
void onSettingsLoaded(bool success) {
// Called after the entire EEPROM has been read,
// whether successful or not.
}
#if HAS_MESH
void onLevelingStart() {
#if HAS_BED_PROBE
ScreenHandler.OnMeshLevelingStart();
#endif
}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const float zval) {
ScreenHandler.OnMeshLevelingUpdate(xpos, ypos, zval);
}
void onMeshUpdate(const int8_t xpos, const int8_t ypos, const ExtUI::probe_state_t state) {
ScreenHandler.OnMeshLevelingUpdate(xpos, ypos, 0);
}
void onLevelingDone() {
}
#endif
#if ENABLED(POWER_LOSS_RECOVERY)
void onPowerLossResume() {
// Called on resume from power-loss
ScreenHandler.OnPowerlossResume();
}
#endif
#if HAS_PID_HEATING
void onPidTuning(const result_t rst) {
// Called for temperature PID tuning result
switch (rst) {
case PID_BAD_HEATER_ID:
PIDHandler::result_message = GET_TEXT(MSG_PID_BAD_HEATER_ID);
ScreenHandler.setstatusmessagePGM(PIDHandler::result_message);
break;
case PID_TEMP_TOO_HIGH:
PIDHandler::result_message = GET_TEXT(MSG_PID_TEMP_TOO_HIGH);
ScreenHandler.setstatusmessagePGM(PIDHandler::result_message);
break;
case PID_TUNING_TIMEOUT:
PIDHandler::result_message = GET_TEXT(MSG_PID_TIMEOUT);
ScreenHandler.setstatusmessagePGM(PIDHandler::result_message);
break;
case PID_DONE:
PIDHandler::result_message = GET_TEXT(MSG_PID_AUTOTUNE_DONE);
ScreenHandler.setstatusmessagePGM(PIDHandler::result_message);
break;
default:
break;
}
}
#endif
void onSteppersDisabled() {
}
void onSteppersEnabled() {
}
#if HAS_MESH
void onMeshValidationStarting() {
MeshValidationHandler::OnMeshValidationStart();
}
void onMeshValidationFinished() {
MeshValidationHandler::OnMeshValidationFinish();
}
#endif
}
#endif // HAS_DGUS_LCD
@@ -395,12 +395,7 @@ void DGUSReturnKeyCodeHandler::Command_SettingsMenu(DGUS_VP &vp, void *data) {
}
static void _gotoTrammingPoint(unsigned char point) {
#if ENABLED(BED_TRAMMING_USE_PROBE)
float lfrb[4] = {X_MIN_BED + probe.min_x(), Y_MIN_BED + probe.min_y(),
X_MAX_BED - probe.max_x(), Y_MAX_BED - probe.max_y() };
#else
constexpr float lfrb[4] = BED_TRAMMING_INSET_LFRB;
#endif
constexpr float lfrb[4] = BED_TRAMMING_INSET_LFRB;
float x, y;
switch (point) {
@@ -38,9 +38,6 @@
#if ENABLED(ADVANCED_PAUSE_FEATURE)
#include "../../../feature/pause.h"
#endif
#if ENABLED(BED_TRAMMING_USE_PROBE)
#include "../../../module/probe.h"
#endif
#if ENABLED(POWER_LOSS_RECOVERY)
#include "../../../feature/powerloss.h"
#endif
@@ -467,14 +464,7 @@ void DGUSRxHandler::moveToPoint(DGUS_VP &vp, void *data_ptr) {
}
const uint8_t point = ((uint8_t*)data_ptr)[1];
#if ENABLED(BED_TRAMMING_USE_PROBE)
float lfrb[4] = {X_MIN_BED + probe.min_x(), Y_MIN_BED + probe.min_y(),
X_MAX_BED - probe.max_x(), Y_MAX_BED - probe.max_y() };
#else
constexpr float lfrb[4] = BED_TRAMMING_INSET_LFRB;
#endif
constexpr float lfrb[4] = BED_TRAMMING_INSET_LFRB;
float x, y;
switch (point) {
@@ -34,13 +34,14 @@ void FilamentRunoutScreen::onRedraw(draw_mode_t what) {
w.heading( GET_TEXT_F(MSG_FILAMENT));
w.toggle( 2, GET_TEXT_F(MSG_RUNOUT_SENSOR), getFilamentRunoutEnabled());
w.heading(GET_TEXT_F(MSG_RUNOUT_DISTANCE_MM));
w.units(GET_TEXT_F(MSG_UNITS_MM));
w.precision(0);
w.color(e_axis);
w.adjuster( 10, FPSTR(NUL_STR), getFilamentRunoutDistance_mm(), getFilamentRunoutEnabled());
w.increments();
#if HAS_FILAMENT_RUNOUT_DISTANCE
w.heading(GET_TEXT_F(MSG_RUNOUT_DISTANCE_MM));
w.units(GET_TEXT_F(MSG_UNITS_MM));
w.precision(0);
w.color(e_axis);
w.adjuster( 10, FPSTR(NUL_STR), getFilamentRunoutDistance_mm(), getFilamentRunoutEnabled());
w.increments();
#endif
}
bool FilamentRunoutScreen::onTouchHeld(uint8_t tag) {
@@ -50,8 +51,10 @@ bool FilamentRunoutScreen::onTouchHeld(uint8_t tag) {
#endif
switch (tag) {
case 2: setFilamentRunoutEnabled(!getFilamentRunoutEnabled()); break;
case 10: UI_DECREMENT(FilamentRunoutDistance_mm); break;
case 11: UI_INCREMENT(FilamentRunoutDistance_mm); break;
#if HAS_FILAMENT_RUNOUT_DISTANCE
case 10: UI_DECREMENT(FilamentRunoutDistance_mm); break;
case 11: UI_INCREMENT(FilamentRunoutDistance_mm); break;
#endif
default:
return false;
}
File diff suppressed because it is too large Load Diff
@@ -1,304 +0,0 @@
/**
* 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 <https://www.gnu.org/licenses/>.
*
*/
/* ****************************************
* lcd/extui/lib/Creality/Creality_DWIN.h
* ****************************************
* Extensible_UI implementation for Creality DWIN
* 10SPro, Max, CRX, and others
* Based original Creality release, ported to ExtUI for Marlin 2.0
* Written by Insanity Automation, sponsored by Tiny Machines 3D
*
* ***************************************/
#pragma once
#include "string.h"
#include <Arduino.h>
#include "../ui_api.h"
#if ENABLED(EXTENSIBLE_UI)
namespace ExtUI {
/*********************************/
#define FHONE (0x5A)
#define FHTWO (0xA5)
#define FHLENG (0x06)
#define TEXTBYTELEN 18
#define MaxFileNumber 20// 16
#define CEIconGrap 12
#define FileNum MaxFileNumber
#define FileNameLen TEXTBYTELEN
#define SizeofDatabuf 46
/*************Register and Variable addr*****************/
#define RegAddr_W 0x80
#define RegAddr_R 0x81
#define VarAddr_W 0x82
#define VarAddr_R 0x83
#define ExchangePageBase (unsigned long)0x5A010000 //the first page ID. other page = first page ID + relevant num;
#define StartSoundSet ((unsigned long)0x060480A0) // 06,start-music; 04, 4 musics; 80, the volume value; 04, return value about music number.
#define FONT_EEPROM 90
#define AutoLeve_EEPROM 100
#define FanOn 255
#define FanOff 0
/*variable addr*/
#define ExchangepageAddr 0x0084
#define SoundAddr 0x00A0
#define StartIcon 0x1000
#define FeedrateDisplay 0x1006 // Speed
#define Stopprint 0x1008
#define Pauseprint 0x100A
#define Resumeprint 0x100C
#define PrintscheduleIcon 0x100E
#define Timehour 0x1010
#define Timemin 0x1012
#define IconPrintstatus 0x1014
#define Percentage 0x1016
#define FanKeyIcon 0x101E
#define Flowrate 0x1300
#define RunoutToggle 0x1018
#define PowerLossToggle 0x101A
#define LedToggle 0x101C
#define StepMM_X 0x1242
#define StepMM_Y 0x1246
#define StepMM_Z 0x124A
#define StepMM_E 0x124E
#define ProbeOffset_X 0x1236
#define ProbeOffset_Y 0x123A
#define ProbeOffset_Z 0x1026
#define T2Offset_X 0x1090
#define T2Offset_Y 0x1094
#define T2Offset_Z 0x1098
#define T2StepMM_E 0x109C
#define ActiveToolVP 0x1014
#define HotendPID_AutoTmp 0x1252
#define BedPID_AutoTmp 0x1254
#define HotendPID_P 0x1256
#define HotendPID_I 0x125A
#define HotendPID_D 0x125E
#define BedPID_P 0x1262
#define BedPID_I 0x1266
#define BedPID_D 0x126A
#define Jerk_X 0x1270
#define Jerk_Y 0x1272
#define Jerk_Z 0x1274
#define Jerk_E 0x1276
#define Feed_X 0x1278
#define Feed_Y 0x127A
#define Feed_Z 0x127C
#define Feed_E 0x127E
#define Accel_X 0x1280
#define Accel_Y 0x1282
#define Accel_Z 0x1284
#define Accel_E 0x1286
#define ShapingZetaX 0x10A0
#define ShapingZetaY 0x10A2
#define ShapingFreqX 0x10A4
#define ShapingFreqY 0x10A8
#define LinAdvKFactor 0x10AA
#define RunoutMode 0x10AC
#define BabystepIncrement 0x10AE
#define HeatPercentIcon 0x1024
#define NzBdSet 0x1032 // cooldown Hotend and Bed
#define NozzlePreheat 0x1034 // setpoint
#define NozzleTemp 0x1036 // Actual
#define BedPreheat 0x103A // Setpoint
#define Bedtemp 0x103C // Actual
#define e2Temp 0x1050
#define e2Preheat 0x104E
#define AutoZeroIcon 0x1042
#define AutoLevelIcon 0x1045
#define AutoZero 0x1046
#define DisplayXaxis 0x1048
#define DisplayYaxis 0x104A
#define DisplayZaxis 0x104C
#define FilementUnit1 0x1054
#define Exchfilement 0x1056
#define FilementUnit2 0x1058
#define MacVersion 0x1060
#define SoftVersion 0x106A
#define PrinterSize 0x1074
#define CorpWebsite 0x107E
#define VolumeIcon 0x108A
#define SoundIcon 0x108C
#define AutolevelIcon 0x108D
#define ExchFlmntIcon 0x108E
#define AutolevelVal 0x1100
#define FilenameIcon 0x1200
#define FilenameIcon1 0x1220
#define Printfilename 0x2000
#define FilesCurentPage 0x1310
#define FilesMaxPage 0x1312
#define SDFILE_ADDR 0x200A
#define FilenamePlay 0x20D2
#define FilenameChs 0x20D3
#define Choosefilename 0x20D4
#define FilenameCount 0x20DE
#define FilenameNature 0x6003
#define VolumeDisplay 0x1140
#define DisplayBrightness 0x1142
#define DisplayStandbyBrightness 0x1144
#define DisplayStandbyEnableIndicator 0x1146
#define DisplayStandbySeconds 0x1148
#define StatusMessageString 0x2064
#if defined(TARGET_STM32F4)
#define DWIN_SERIAL Serial1
#else
#define DWIN_SERIAL LCD_SERIAL
#endif
/************struct**************/
typedef enum : uint8_t {
DGUS_IDLE, //< waiting for DGUS_HEADER1.
DGUS_HEADER1_SEEN, //< DGUS_HEADER1 received
DGUS_HEADER2_SEEN, //< DGUS_HEADER2 received
DGUS_WAIT_TELEGRAM, //< LEN received, Waiting for to receive all bytes.
} rx_datagram_state_t;
typedef struct DataBuf
{
unsigned char len;
unsigned char head[2];
unsigned char command;
unsigned long addr;
unsigned long bytelen;
unsigned short data[32];
unsigned char reserv[4];
} DB;
struct creality_dwin_settings_t {
size_t settings_size;
uint8_t settings_version;
bool display_standby;
bool display_sound;
int8_t screen_rotation;
int16_t display_volume;
uint8_t standby_screen_brightness;
uint8_t screen_brightness;
int16_t standby_time_seconds;
};
void SetTouchScreenConfiguration();
class RTSSHOW {
public:
RTSSHOW();
int RTS_RecData();
void RTS_SDCardInit(void);
void RTS_SDCardUpate(bool, bool);
int RTS_CheckFilement(int);
void RTS_SndData(void);
void RTS_SndData(const String &, unsigned long, unsigned char = VarAddr_W);
void RTS_SndData(const char[], unsigned long, unsigned char = VarAddr_W);
void RTS_SndData(char, unsigned long, unsigned char = VarAddr_W);
void RTS_SndData(unsigned char*, unsigned long, unsigned char = VarAddr_W);
void RTS_SndData(int, unsigned long, unsigned char = VarAddr_W);
void RTS_SndData(float, unsigned long, unsigned char = VarAddr_W);
void RTS_SndData(unsigned int,unsigned long, unsigned char = VarAddr_W);
void RTS_SndData(long,unsigned long, unsigned char = VarAddr_W);
void RTS_SndData(unsigned long,unsigned long, unsigned char = VarAddr_W);
void WriteVariable(uint16_t adr, const void* values, uint8_t valueslen, bool isstr=false, char fillChar = ' ');
void WriteVariable(uint16_t adr, long);
void RTS_SDcard_Stop();
void RTS_HandleData();
void RTS_Init();
DB recdat;
DB snddat;
unsigned char databuf[SizeofDatabuf];
static rx_datagram_state_t rx_datagram_state;
static uint8_t rx_datagram_len;
static bool Initialized;
};
static RTSSHOW rtscheck;
#define Addvalue 3
#define PrintChoice_Value (0+Addvalue)
#define Zoffset_Value (3+Addvalue)
#define Setting_Value (8+Addvalue)
#define XYZEaxis_Value (12+Addvalue)
#define Filement_Value (15+Addvalue)
#define Language_Value (18+Addvalue)
#define Filename_Value (22+Addvalue)
#define Idex_Settings_Value (26+Addvalue)
enum PROC_COM {Printfile=0,Ajust,Feedrate,PrintChoice=PrintChoice_Value,Zoffset=Zoffset_Value,TempControl,ManualSetTemp,Setting=Setting_Value,
ReturnBack,Bedlevel,Autohome,XYZEaxis=XYZEaxis_Value,Filement=Filement_Value,LanguageChoice=Language_Value,No_Filement,PwrOffNoF,Volume,Filename=Filename_Value,Idex_Settings=Idex_Settings_Value};
const unsigned long Addrbuf[] = {0x1002, 0x1004, 0x1006, 0x1008, 0x100A, 0x100C, 0x1026, 0x1030, 0x1032, 0x1034, 0x103A,
0x103E, 0x1040, 0x1044, 0x1046, 0x1048, 0x104A, 0x104C, 0x1054, 0x1056, 0x1058,
0x105C, 0x105E, 0x105F, 0x1088, 0};
void RTSUpdate();
void RTSInit();
}
#ifndef MAIN_MENU_ITEM_1_GCODE
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
#define MEASURING_GCODE "M190S55\nG28O\nG34\nG29\nM400\nM104S215\nG28\nM109S215\nM420S1\nG1X100Y100F5000\nG1Z0\nM500\nM117 Set Z Offset"
#elif ENABLED(AUTO_BED_LEVELING_UBL)
#define MEASURING_GCODE "M190S55\nG28O\nG34\nG29P1\nG29P3\nG29S1\nG29S0\nG29F0.0\nG29A\nM104S215\nG28\nM109S215\nG1X150Y150F5000\nG1Z0\nM500\nM400\nM117 Set Z Offset"
#else
#define MEASURING_GCODE "G28"
#endif
#else
#define MEASURING_GCODE MAIN_MENU_ITEM_1_GCODE
#endif
#endif
@@ -1,189 +0,0 @@
/**
* 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 <https://www.gnu.org/licenses/>.
*
*/
/* ****************************************
* lcd/extui/lib/Creality/FileNavigator.cpp
* ****************************************
* Extensible_UI implementation for Creality DWIN
* 10SPro, Max, CR10V2
* Based on implementations for Anycubic Chiron and Nextion by Nick Wells and Skorpi08
* Written by Insanity Automation
* ***************************************/
#include "../../../inc/MarlinConfigPre.h"
#if ENABLED(EXTENSIBLE_UI)
#include "FileNavigator.h"
using namespace ExtUI;
#define DEBUG_OUT NEXDEBUGLEVEL
#include "../../../core/debug_out.h"
FileList FileNavigator::filelist; // Instance of the Marlin file API
char FileNavigator::currentfoldername[MAX_PATH_LEN]; // Current folder path
uint16_t FileNavigator::lastindex;
uint8_t FileNavigator::folderdepth;
uint16_t FileNavigator::currentindex; // override the panel request
FileNavigator filenavigator;
FileNavigator::FileNavigator() { reset(); }
void FileNavigator::reset() {
currentfoldername[0] = '\0';
folderdepth = 0;
currentindex = 0;
lastindex = 0;
// Start at root folder
while (!filelist.isAtRootDir()) filelist.upDir();
refresh();
}
void FileNavigator::refresh() { filelist.refresh(); }
bool FileNavigator::getIndexisDir(uint16_t index){
filelist.seek(index);
return filelist.isDir();
}
const char *FileNavigator::getIndexName(uint16_t index){
filelist.seek(index);
return filelist.shortFilename();
}
uint16_t FileNavigator::maxFiles() {
return filelist.count();
}
void FileNavigator::getFiles(uint16_t index) {
uint16_t files = DISPLAY_FILES, fcnt = 0;
if (index == 0)
currentindex = 0;
else {
// Each time we change folder we reset the file index to 0 and keep track
// of the current position as the TFT panel isn't aware of folder trees.
--currentindex; // go back a file to take account of the .. added to the root.
if (index > lastindex)
currentindex += files + 1;
else if (currentindex >= files)
currentindex -= files - 1;
else
currentindex = 0;
}
lastindex = index;
// Clear currently drawn screen
for (int i = 0; i < DISPLAY_FILES; i++)
{
for (int j = 0; j < 20; j++)
rtscheck.RTS_SndData(0, SDFILE_ADDR + (i * 20) + j);
}
for (int j = 0; j < 10; j++)
{
rtscheck.RTS_SndData(0, Printfilename + j); //clean screen.
rtscheck.RTS_SndData(0, Choosefilename + j); //clean filename
}
for (int j = 0; j < 8; j++)
rtscheck.RTS_SndData(0, FilenameCount + j);
for (int j = 1; j <= DISPLAY_FILES; j++)
{
rtscheck.RTS_SndData(10, FilenameIcon + j);
rtscheck.RTS_SndData(10, FilenameIcon1 + j);
}
DEBUG_ECHOLNPGM("index=", index, " currentindex=", currentindex, "folderdepth=", folderdepth);
if (currentindex == 0 && folderdepth > 0) { // Add a link to go up a folder
files--;
rtscheck.RTS_SndData("Up Directory", SDFILE_ADDR);
fcnt++;
}
else if(currentindex == DISPLAY_FILES && folderdepth > 0)
currentindex--;
for (uint16_t seek = currentindex; seek < currentindex + files; seek++) {
if (filelist.seek(seek)) {
const int filelen = strlen(filelist.filename());
if(filelen > 20)
{
char *buf = (char *)filelist.filename();
//char buf[filelen];
//strcpy(&buf[filelen], filelist.filename());
buf[18] = '\0'; // cutoff at screen edge
rtscheck.RTS_SndData(buf, (SDFILE_ADDR + (fcnt * 20)));
}
else
rtscheck.RTS_SndData(filelist.filename(), (SDFILE_ADDR + (fcnt * 20)));
if (filelist.isDir())
{
rtscheck.RTS_SndData((uint8_t)4, FilenameIcon + (fcnt+1));
rtscheck.RTS_SndData((unsigned long)0x041F, (FilenameNature + ((1+fcnt) * 16))); // Change BG of selected line to Blue
}
else
{
rtscheck.RTS_SndData((uint8_t)0, FilenameIcon + (fcnt+1));
rtscheck.RTS_SndData((unsigned long)0xFFFF, (FilenameNature + ((1+fcnt) * 16))); // white
}
SERIAL_ECHOLNPGM("-", seek, " '", filelist.filename(), "' '", currentfoldername, "", filelist.shortFilename(), "'\n");
fcnt++;
}
}
}
void FileNavigator::changeDIR(char *folder) {
DEBUG_ECHOLNPGM("currentfolder: ", currentfoldername, " New: ", folder);
if (folderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth
strcat(currentfoldername, folder);
strcat(currentfoldername, "/");
filelist.changeDir(folder);
refresh();
folderdepth++;
currentindex = 0;
}
void FileNavigator::upDIR() {
filelist.upDir();
refresh();
folderdepth--;
currentindex = 0;
// Remove the last child folder from the stored path
if (folderdepth == 0) {
currentfoldername[0] = '\0';
reset();
}
else {
char *pos = nullptr;
for (uint8_t f = 0; f < folderdepth; f++)
pos = strchr(currentfoldername, '/');
pos[1] = '\0';
}
DEBUG_ECHOLNPGM("depth: ", folderdepth, " currentfoldername: ", currentfoldername);
}
char* FileNavigator::getCurrentFolderName() { return currentfoldername; }
#endif
@@ -1,63 +0,0 @@
/**
* 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 <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/* ****************************************
* lcd/extui/lib/Creality/FileNavigator.h
* ****************************************
* Extensible_UI implementation for Creality DWIN
* 10SPro, Max, CRX and others
* Based on implementations for Anycubic Chiron and Nextion by Nick Wells and Skorpi08
* Written by Insanity Automation
* ***************************************/
#include "../ui_api.h"
#include "Creality_DWIN.h"
#define MAX_FOLDER_DEPTH 4 // Limit folder depth TFT has a limit for the file path
#define MAX_CMND_LEN 16 * MAX_FOLDER_DEPTH // Maximum Length for a Panel command
#define MAX_PATH_LEN 16 * MAX_FOLDER_DEPTH // Maximum number of characters in a SD file path
#define DISPLAY_FILES 4
using namespace ExtUI;
class FileNavigator {
public:
FileNavigator();
static void reset();
static void getFiles(uint16_t);
static void upDIR();
static void changeDIR(char *);
static void refresh();
static char* getCurrentFolderName();
static uint8_t folderdepth;
static uint16_t currentindex;
static bool getIndexisDir(uint16_t);
const char *getIndexName(uint16_t);
static uint16_t maxFiles();
private:
static FileList filelist;
static char currentfoldername[MAX_PATH_LEN];
static uint16_t lastindex;
};
extern FileNavigator filenavigator;
+7 -36
View File
@@ -722,23 +722,15 @@ namespace ExtUI {
}
#if HAS_FILAMENT_SENSOR
bool getFilamentRunoutEnabled(const extruder_t extruder/*=E0*/) { return (runout.enabled[extruder] && (runout.mode[extruder]!=0)); }
void setFilamentRunoutEnabled(const bool value, const extruder_t extruder/*=E0*/) { runout.enabled[extruder] = value; }
bool getFilamentRunoutEnabled() { return runout.enabled; }
void setFilamentRunoutEnabled(const bool value) { runout.enabled = value; }
bool getFilamentRunoutState() { return runout.filament_ran_out; }
void setFilamentRunoutState(const bool value) { runout.filament_ran_out = value; }
float getFilamentRunoutDistance_mm() { return runout.runout_distance(); }
void setFilamentRunoutDistance_mm(const_float_t value) { runout.set_runout_distance(constrain(value, 0, 999)); }
int getRunoutMode(const extruder_t extruder/*=E0*/){
return (int)runout.mode[extruder];
}
void setRunoutMode(const int mode, const extruder_t extruder/*=E0*/){
if((mode >= 0 && mode <=2) || mode==7) {
runout.mode[extruder] = (RunoutMode)mode;
runout.setup();
}
}
#if HAS_FILAMENT_RUNOUT_DISTANCE
float getFilamentRunoutDistance_mm() { return runout.runout_distance(); }
void setFilamentRunoutDistance_mm(const_float_t value) { runout.set_runout_distance(constrain(value, 0, 999)); }
#endif
#endif
#if ENABLED(CASE_LIGHT_ENABLE)
@@ -773,26 +765,6 @@ namespace ExtUI {
}
#endif
#if HAS_SHAPING
float getShapingZeta(const axis_t axis) {
return stepper.get_shaping_damping_ratio(AxisEnum(axis));
}
void setShapingZeta(const float zeta, const axis_t axis) {
if (WITHIN(zeta, 0, 1)) {
stepper.set_shaping_damping_ratio(AxisEnum(axis), zeta);
}
}
float getShapingFrequency(const axis_t axis) {
return stepper.get_shaping_frequency(AxisEnum(axis));
}
void setShapingFrequency(const float freq, const axis_t axis) {
constexpr float min_freq = float(uint32_t(STEPPER_TIMER_RATE) / 2) / shaping_time_t(-2);
if (freq == 0.0f || freq > min_freq) {
stepper.set_shaping_frequency(AxisEnum(axis), freq);
}
}
#endif
#if HAS_JUNCTION_DEVIATION
float getJunctionDeviation_mm() { return planner.junction_deviation_mm; }
@@ -961,7 +933,6 @@ namespace ExtUI {
#if HAS_BED_PROBE
float getProbeOffset_mm(const axis_t axis) { return probe.offset.pos[axis]; }
void setProbeOffset_mm(const_float_t val, const axis_t axis) { probe.offset.pos[axis] = val; }
probe_limits getBedProbeLimits() {return (probe_limits){probe.min_x(), probe.min_y(), probe.max_x(), probe.max_y()};}
#endif
#if ENABLED(BACKLASH_GCODE)
@@ -1198,7 +1169,7 @@ namespace ExtUI {
return isPrinting() && (isPrintingFromMediaPaused() || print_job_timer.isPaused());
}
bool isMediaInserted() { return TERN0(HAS_MEDIA, IS_SD_INSERTED() || card.isMounted()); }
bool isMediaInserted() { return TERN0(HAS_MEDIA, IS_SD_INSERTED()); }
// Pause/Resume/Stop are implemented in MarlinUI
void pausePrint() { ui.pause_print(); }
+7 -15
View File
@@ -68,7 +68,6 @@ namespace ExtUI {
enum extruder_t : uint8_t { E0, E1, E2, E3, E4, E5, E6, E7 };
enum heater_t : uint8_t { H0, H1, H2, H3, H4, H5, BED, CHAMBER, COOLER };
enum fan_t : uint8_t { FAN0, FAN1, FAN2, FAN3, FAN4, FAN5, FAN6, FAN7 };
struct probe_limits { float pos[4];};
#if HAS_PID_HEATING
enum pidresult_t : uint8_t { PID_STARTED, PID_BED_STARTED, PID_CHAMBER_STARTED, PID_BAD_HEATER_ID, PID_TEMP_TOO_HIGH, PID_TUNING_TIMEOUT, PID_DONE };
#endif
@@ -328,13 +327,6 @@ namespace ExtUI {
void setLinearAdvance_mm_mm_s(const_float_t, const extruder_t);
#endif
#if HAS_SHAPING
float getShapingZeta(const axis_t);
void setShapingZeta(const float, const axis_t);
float getShapingFrequency(const axis_t);
void setShapingFrequency(const float, const axis_t);
#endif
// JD or Jerk Control
#if HAS_JUNCTION_DEVIATION
float getJunctionDeviation_mm();
@@ -375,7 +367,6 @@ namespace ExtUI {
#if HAS_BED_PROBE
float getProbeOffset_mm(const axis_t);
void setProbeOffset_mm(const_float_t, const axis_t);
probe_limits getBedProbeLimits();
#endif
// Backlash Control
@@ -394,14 +385,15 @@ namespace ExtUI {
// Filament Runout Sensor
#if HAS_FILAMENT_SENSOR
bool getFilamentRunoutEnabled(const extruder_t extruder=E0);
void setFilamentRunoutEnabled(const bool, const extruder_t extruder=E0);
bool getFilamentRunoutEnabled();
void setFilamentRunoutEnabled(const bool);
bool getFilamentRunoutState();
void setFilamentRunoutState(const bool);
float getFilamentRunoutDistance_mm();
void setFilamentRunoutDistance_mm(const_float_t);
int getRunoutMode(const extruder_t extruder=E0);
void setRunoutMode(const int, const extruder_t extruder=E0);
#if HAS_FILAMENT_RUNOUT_DISTANCE
float getFilamentRunoutDistance_mm();
void setFilamentRunoutDistance_mm(const_float_t);
#endif
#endif
// Case Light Control
-5
View File
@@ -719,11 +719,6 @@ namespace LanguageNarrow_en {
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_MODE = _UxGT("Runout Mode");
LSTR MSG_RUNOUT_MODE_HIGH = _UxGT("Sensor High");
LSTR MSG_RUNOUT_MODE_LOW = _UxGT("Sensor Low");
LSTR MSG_RUNOUT_MODE_MOTION = _UxGT("Motion Encoder");
LSTR MSG_RUNOUT_MODE_NONE = _UxGT("No Sensor");
LSTR MSG_RUNOUT_ENABLE = _UxGT("Enable Runout");
LSTR MSG_RUNOUT_ACTIVE = _UxGT("Runout Active");
LSTR MSG_INVERT_EXTRUDER = _UxGT("Invert Extruder");
+1 -1
View File
@@ -1668,7 +1668,7 @@ void MarlinUI::host_notify(const char * const cstr) {
card.abortFilePrintSoon();
else if (card.isMounted())
card.closefile();
#endif
#endif
#ifdef ACTION_ON_CANCEL
hostui.cancel();
#endif
+6 -51
View File
@@ -45,7 +45,7 @@
#include "../../module/temperature.h"
#endif
#if HAS_FILAMENT_SENSOR
#if HAS_FILAMENT_RUNOUT_DISTANCE
#include "../../feature/runout.h"
#endif
@@ -99,54 +99,6 @@ void menu_backlash();
#endif
#if HAS_FILAMENT_SENSOR
void set_runout_mode_none(const uint8_t e) { runout.mode[e] = RM_NONE; runout.setup(); }
void set_runout_mode_high(const uint8_t e) { runout.mode[e] = RM_OUT_ON_HIGH; runout.setup(); }
void set_runout_mode_low(const uint8_t e) { runout.mode[e] = RM_OUT_ON_LOW; runout.setup(); }
void set_runout_mode_motion(const uint8_t e) { runout.mode[e] = RM_MOTION_SENSOR; runout.setup(); }
#define RUNOUT_EDIT_ITEMS(F) do{ \
EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled[F]); \
ACTION_ITEM(MSG_RUNOUT_MODE_NONE, []{ set_runout_mode_none(F); }); \
ACTION_ITEM(MSG_RUNOUT_MODE_HIGH, []{ set_runout_mode_high(F); }); \
ACTION_ITEM(MSG_RUNOUT_MODE_LOW, []{ set_runout_mode_low(F); }); \
ACTION_ITEM(MSG_RUNOUT_MODE_MOTION, []{ set_runout_mode_motion(F); }); \
editable.decimal = runout.runout_distance(F); \
EDIT_ITEM_FAST(float3, MSG_RUNOUT_DISTANCE_MM, &editable.decimal, 1, 999, \
[]{ runout.set_runout_distance(editable.decimal, F); }, true \
); \
}while(0)
void menu_runout_config() {
START_MENU();
BACK_ITEM(MSG_CONFIGURATION);
RUNOUT_EDIT_ITEMS(0);
#if NUM_RUNOUT_SENSORS > 1
RUNOUT_EDIT_ITEMS(1);
#endif
#if NUM_RUNOUT_SENSORS > 2
RUNOUT_EDIT_ITEMS(2);
#endif
#if NUM_RUNOUT_SENSORS > 3
RUNOUT_EDIT_ITEMS(3);
#endif
#if NUM_RUNOUT_SENSORS > 4
RUNOUT_EDIT_ITEMS(4);
#endif
#if NUM_RUNOUT_SENSORS > 5
RUNOUT_EDIT_ITEMS(5);
#endif
#if NUM_RUNOUT_SENSORS > 6
RUNOUT_EDIT_ITEMS(6);
#endif
#if NUM_RUNOUT_SENSORS > 7
RUNOUT_EDIT_ITEMS(7);
#endif
END_MENU();
}
#endif
#if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE)
//
// Advanced Settings > Filament
@@ -200,8 +152,11 @@ void menu_backlash();
#endif
#endif
#if HAS_FILAMENT_SENSOR
SUBMENU(MSG_RUNOUT_MODE, menu_runout_config);
#if HAS_FILAMENT_RUNOUT_DISTANCE
editable.decimal = runout.runout_distance();
EDIT_ITEM_FAST(float3, MSG_RUNOUT_DISTANCE_MM, &editable.decimal, 1, 999,
[]{ runout.set_runout_distance(editable.decimal); }, true
);
#endif
END_MENU();
+8 -9
View File
@@ -94,22 +94,16 @@ static_assert(COUNT(lco) == 4 || lcodiff == 1 || lcodiff == 3, "The first two BE
constexpr int nr_edge_points = tramming_3_points ? 3 : 4;
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);
#if DISABLED(BED_TRAMMING_USE_PROBE)
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] },
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] };
#endif
static int8_t bed_corner;
/**
* Move to the next corner coordinates
*/
static void _lcd_goto_next_corner() {
#if ENABLED(BED_TRAMMING_USE_PROBE)
xy_pos_t lf = {X_MIN_BED + probe.min_x() + 0.01f, Y_MIN_BED + probe.min_y() + 0.01f },
rb = {X_MAX_BED - probe.max_x() - 0.01f, Y_MAX_BED - probe.max_y() - 0.01f };
#endif
xy_pos_t corner_point = lf; // Left front
if (tramming_3_points) {
@@ -171,6 +165,11 @@ static void _lcd_goto_next_corner() {
#if ENABLED(BED_TRAMMING_USE_PROBE)
#define VALIDATE_POINT(X, Y, STR) static_assert(Probe::build_time::can_reach((X), (Y)), \
"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");
#ifndef PAGE_CONTAINS
#define PAGE_CONTAINS(...) true
#endif
+1 -1
View File
@@ -634,7 +634,7 @@ void menu_configuration() {
#endif
#if HAS_FILAMENT_SENSOR
EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled[active_extruder], runout.reset);
EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled, runout.reset);
#endif
#if HAS_FANCHECK
+1 -1
View File
@@ -264,7 +264,7 @@ void menu_pause_option() {
#if HAS_FILAMENT_SENSOR
if (still_out)
EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled[active_extruder], runout.reset);
EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled, runout.reset);
#endif
if (!still_out)
+1 -1
View File
@@ -30,7 +30,7 @@
#define COLOR(color) RGB(((color >> 16) & 0xFF), ((color >> 8) & 0xFF), (color & 0xFF))
#define HALF(color) RGB(RED(color) >> 1, GREEN(color) >> 1, BLUE(color) >> 1)
// RGB565 color picker: https://rgbcolorpicker.com/565
// RGB565 color picker: https://embeddednotepad.com/page/rgb565-color-picker
// Hex code to color name: https://www.color-name.com/
#define COLOR_BLACK 0x0000 // #000000
+9 -26
View File
@@ -50,10 +50,6 @@
#include "../feature/joystick.h"
#endif
#if HAS_FILAMENT_SENSOR
#include "../feature/runout.h"
#endif
#if HAS_BED_PROBE
#include "probe.h"
#endif
@@ -485,35 +481,22 @@ void __O2 Endstops::report_states() {
#if USE_Z_MIN_PROBE
print_es_state(PROBE_TRIGGERED(), F(STR_Z_PROBE));
#endif
#if HAS_FILAMENT_SENSOR
#if MULTI_FILAMENT_SENSOR
#define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; state = FIL_RUNOUT##N##_STATE; break;
for (uint8_t i = 1; i <= NUM_RUNOUT_SENSORS; ++i) {
pin_t pin;
uint8_t state;
switch (i) {
default: continue;
#define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break;
REPEAT_1(NUM_RUNOUT_SENSORS, _CASE_RUNOUT)
#undef _CASE_RUNOUT
}
const RunoutMode rm = runout.mode[i - 1];
const uint8_t outval = runout.out_state(i - 1);
#if DISABLED(SLIM_LCD_MENUS)
SERIAL_ECHOPGM(STR_FILAMENT);
if (i > 1) SERIAL_CHAR(' ', '0' + i);
SERIAL_ECHOPGM(": ");
if (rm == RM_NONE)
SERIAL_ECHOLNPGM(STR_OFF);
else if (rm == RM_MOTION_SENSOR) {
SERIAL_ECHOPGM("MOTION : ");
print_es_state(extDigitalRead(pin) == outval);
}
else
SERIAL_ECHOLNPGM_P(extDigitalRead(pin) == outval ? PSTR("OUT") : PSTR("PRESENT"));
#else
print_es_state(extDigitalRead(pin) == outval, F(STR_FILAMENT));
#endif
SERIAL_ECHOPGM(STR_FILAMENT);
if (i > 1) SERIAL_CHAR(' ', '0' + i);
print_es_state(extDigitalRead(pin) != state);
}
#undef _CASE_RUNOUT
#elif HAS_FILAMENT_SENSOR
print_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE, F(STR_FILAMENT));
#endif
TERN_(BLTOUCH, bltouch._reset_SW_mode());
+36 -39
View File
@@ -41,8 +41,8 @@
// Check the integrity of data offsets.
// Can be disabled for production build.
#define DEBUG_EEPROM_READWRITE
#define DEBUG_EEPROM_OBSERVE
//#define DEBUG_EEPROM_READWRITE
//#define DEBUG_EEPROM_OBSERVE
#include "settings.h"
@@ -116,6 +116,9 @@
#if HAS_FILAMENT_SENSOR
#include "../feature/runout.h"
#ifndef FIL_RUNOUT_ENABLED_DEFAULT
#define FIL_RUNOUT_ENABLED_DEFAULT true
#endif
#endif
#if ENABLED(ADVANCE_K_EXTRA)
@@ -246,11 +249,8 @@ typedef struct SettingsDataStruct {
//
// FILAMENT_RUNOUT_SENSOR
//
#if HAS_FILAMENT_SENSOR
bool runout_enabled[NUM_RUNOUT_SENSORS]; // M591 S
float runout_distance_mm[NUM_RUNOUT_SENSORS]; // M591 D
uint8_t runout_mode[NUM_RUNOUT_SENSORS]; // M591 P
#endif
bool runout_sensor_enabled; // M412 S
float runout_distance_mm; // M412 D
//
// ENABLE_LEVELING_FADE_HEIGHT
@@ -904,14 +904,22 @@ void MarlinSettings::postprocess() {
//
// Filament Runout Sensor
//
#if HAS_FILAMENT_SENSOR
{
_FIELD_TEST(runout_enabled);
for(uint8_t e=0; e<NUM_RUNOUT_SENSORS; ++e) EEPROM_WRITE(runout.enabled[e]);
for(uint8_t e=0; e<NUM_RUNOUT_SENSORS; ++e) EEPROM_WRITE(runout.runout_distance(e));
for(uint8_t e=0; e<NUM_RUNOUT_SENSORS; ++e) EEPROM_WRITE(runout.mode[e]);
#if HAS_FILAMENT_SENSOR
const bool &runout_sensor_enabled = runout.enabled;
#else
constexpr int8_t runout_sensor_enabled = -1;
#endif
_FIELD_TEST(runout_sensor_enabled);
EEPROM_WRITE(runout_sensor_enabled);
#if HAS_FILAMENT_RUNOUT_DISTANCE
const float &runout_distance_mm = runout.runout_distance();
#else
constexpr float runout_distance_mm = 0;
#endif
EEPROM_WRITE(runout_distance_mm);
}
#endif
//
// Global Leveling
@@ -1927,26 +1935,22 @@ void MarlinSettings::postprocess() {
//
// Filament Runout Sensor
//
#if HAS_FILAMENT_SENSOR
{
bool runout_enabled[NUM_RUNOUT_SENSORS];
float runout_distance_mm[NUM_RUNOUT_SENSORS];
RunoutMode runout_mode[NUM_RUNOUT_SENSORS];
int8_t runout_sensor_enabled;
_FIELD_TEST(runout_sensor_enabled);
EEPROM_READ(runout_sensor_enabled);
#if HAS_FILAMENT_SENSOR
if (!validating) runout.enabled = runout_sensor_enabled < 0 ? FIL_RUNOUT_ENABLED_DEFAULT : runout_sensor_enabled;
#endif
EEPROM_READ(runout_enabled);
TERN_(HAS_FILAMENT_SENSOR, if (runout.enabled) runout.reset());
float runout_distance_mm;
EEPROM_READ(runout_distance_mm);
EEPROM_READ(runout_mode);
if (!validating) {
for(uint8_t e=0; e < NUM_RUNOUT_SENSORS; ++e) {
runout.enabled[e] = runout_enabled[e];
runout.set_runout_distance(runout_distance_mm[e], e);
runout.mode[e] = runout_mode[e];
}
runout.reset();
}
#if HAS_FILAMENT_RUNOUT_DISTANCE
if (!validating) runout.set_runout_distance(runout_distance_mm);
#endif
}
#endif
//
// Global Leveling
@@ -3162,16 +3166,9 @@ void MarlinSettings::reset() {
//
#if HAS_FILAMENT_SENSOR
constexpr bool fred[] = FIL_RUNOUT_ENABLED;
constexpr uint8_t frm[] = FIL_RUNOUT_MODE;
constexpr float frd[] = FIL_RUNOUT_DISTANCE_MM;
static_assert(COUNT(fred) == NUM_RUNOUT_SENSORS, "FIL_RUNOUT_ENABLED must have NUM_RUNOUT_SENSORS values.");
static_assert(COUNT(frm) == NUM_RUNOUT_SENSORS, "FIL_RUNOUT_MODE must have NUM_RUNOUT_SENSORS values.");
static_assert(COUNT(frd) == NUM_RUNOUT_SENSORS, "FIL_RUNOUT_DISTANCE_MM must have NUM_RUNOUT_SENSORS values.");
COPY(runout.enabled, fred);
COPY(runout.mode, frm);
for(uint8_t e = 0; e < NUM_RUNOUT_SENSORS; ++e) runout.set_runout_distance(frd[e], e);
runout.enabled = FIL_RUNOUT_ENABLED_DEFAULT;
runout.reset();
TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, runout.set_runout_distance(FILAMENT_RUNOUT_DISTANCE_MM));
#endif
//
@@ -3972,7 +3969,7 @@ void MarlinSettings::reset() {
//
// Filament Runout Sensor
//
TERN_(HAS_FILAMENT_SENSOR, gcode.M591_report(forReplay));
TERN_(HAS_FILAMENT_SENSOR, gcode.M412_report(forReplay));
#if HAS_ETHERNET
CONFIG_ECHO_HEADING("Ethernet");
+2 -2
View File
@@ -122,7 +122,7 @@ Stepper stepper; // Singleton
#include "../feature/mixing.h"
#endif
#if HAS_FILAMENT_SENSOR
#if HAS_FILAMENT_RUNOUT_DISTANCE
#include "../feature/runout.h"
#endif
@@ -2292,7 +2292,7 @@ hal_timer_t Stepper::block_phase_isr() {
PAGE_SEGMENT_UPDATE_POS(E);
}
#endif
TERN_(HAS_FILAMENT_SENSOR, runout.block_completed(current_block));
TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, runout.block_completed(current_block));
discard_current_block();
}
else {
+1
View File
@@ -4419,6 +4419,7 @@ void Temperature::isr() {
#if ENABLED(AUTO_REPORT_TEMPERATURES)
AutoReporter<Temperature::AutoReportTemp> Temperature::auto_reporter;
void Temperature::AutoReportTemp::report() {
if (wait_for_heatup) return;
print_heater_states(active_extruder OPTARG(HAS_TEMP_REDUNDANT, ENABLED(AUTO_REPORT_REDUNDANT)));
SERIAL_EOL();
}
-2
View File
@@ -224,8 +224,6 @@
#include "ramps/pins_RAMPS_CREALITY.h" // ATmega2560 env:mega2560
#elif MB(DAGOMA_F5)
#include "ramps/pins_DAGOMA_F5.h" // ATmega2560 env:mega2560
#elif MB(DAGOMA_D6)
#include "ramps/pins_DAGOMA_D6.h" // ATmega2560 env:mega2560ext
#elif MB(FYSETC_F6_13)
#include "ramps/pins_FYSETC_F6_13.h" // ATmega2560 env:FYSETC_F6
#elif MB(FYSETC_F6_14)
-119
View File
@@ -1,119 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2024 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 <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#if HOTENDS > 2 || E_STEPPERS > 2
#error "Dagoma3D D6 supports up to 2 hotends / E-steppers."
#endif
#define BOARD_INFO_NAME "Dagoma3D D6"
//
// Trinamic Stallguard pins
//
#define X_DIAG_PIN 43
#define Y_DIAG_PIN 41
#define Z_DIAG_PIN 47
#define E0_DIAG_PIN 21
#define E1_DIAG_PIN 20
//
// Endstops
//
#define X_STOP_PIN 2
#define Y_STOP_PIN 3
#define Z_STOP_PIN 15
//
// Filament Runout Sensor
//
#ifndef FIL_RUNOUT_PIN
#define FIL_RUNOUT_PIN 39
#endif
#if EXTRUDERS > 1 && !defined(FIL_RUNOUT2_PIN)
#define FIL_RUNOUT2_PIN 14
#endif
// Alter timing for graphical display
#if IS_U8GLIB_ST7920
#ifndef BOARD_ST7920_DELAY_1
#define BOARD_ST7920_DELAY_1 0
#endif
#ifndef BOARD_ST7920_DELAY_2
#define BOARD_ST7920_DELAY_2 250
#endif
#ifndef BOARD_ST7920_DELAY_3
#define BOARD_ST7920_DELAY_3 250
#endif
#endif
#define KILL_PIN -1 // NC
#define LCD_CONTRAST_DEFAULT 255
//
// Sensorless homing DIAG pin is not directly connected to the MCU. Close
// the jumper next to the limit switch socket when using sensorless homing.
//
#if HAS_TMC_UART
/**
* TMC2208/TMC2209 stepper drivers
*/
#define X_SERIAL_RX_PIN 73
#define X_SERIAL_TX_PIN 73
#define Y_SERIAL_RX_PIN 73
#define Y_SERIAL_TX_PIN 73
#define Z_SERIAL_RX_PIN 73
#define Z_SERIAL_TX_PIN 73
#define E0_SERIAL_RX_PIN 73
#define E0_SERIAL_TX_PIN 73
#define E1_SERIAL_RX_PIN 12
#define E1_SERIAL_TX_PIN 12
// 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
#ifndef E1_SLAVE_ADDRESS
#define E1_SLAVE_ADDRESS 3
#endif
static_assert(X_SLAVE_ADDRESS == 0, "X_SLAVE_ADDRESS must be 0 for BOARD_DAGOMA_D6.");
static_assert(Y_SLAVE_ADDRESS == 1, "Y_SLAVE_ADDRESS must be 1 for BOARD_DAGOMA_D6.");
static_assert(Z_SLAVE_ADDRESS == 2, "Z_SLAVE_ADDRESS must be 2 for BOARD_DAGOMA_D6.");
static_assert(E0_SLAVE_ADDRESS == 3, "E0_SLAVE_ADDRESS must be 3 for BOARD_DAGOMA_D6.");
static_assert(E1_SLAVE_ADDRESS == 3, "E1_SLAVE_ADDRESS must be 3 for BOARD_DAGOMA_D6.");
#endif
//
// Import default RAMPS 1.4 pins
//
#include "pins_RAMPS.h"
+26 -24
View File
@@ -36,6 +36,14 @@
#define BOARD_INFO_NAME "Tenlog D3 Hero"
#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME
//
// Servos
//
#define SERVO0_PIN 11
#define SERVO1_PIN 6
#define SERVO2_PIN -1 // Original pin 5 used for hotend fans
#define SERVO3_PIN 4
//
// Limit Switches
//
@@ -44,12 +52,14 @@
#define Y_MIN_PIN 14
//#define Y_MAX_PIN 15 // Connected to "DJ" plug on extruder heads
#define Z_MIN_PIN 18
#if ENABLED(BLTOUCH)
#define SERVO0_PIN 19
#else
#define Z_MAX_PIN 19
#endif
#define Z_MAX_PIN 19
//
// Z Probe (when not Z_MIN_PIN)
//
#ifndef Z_MIN_PROBE_PIN
#define Z_MIN_PROBE_PIN 15 // Ramps is normally 32
#endif
//
// Steppers
@@ -89,17 +99,16 @@
//#define Z2_CS_PIN 40
//#endif
#define E0_STEP_PIN 57
#define E0_DIR_PIN 58
#define E0_ENABLE_PIN 59
#define E0_STEP_PIN 26
#define E0_DIR_PIN 28
#define E0_ENABLE_PIN 24
//#ifndef E0_CS_PIN
//define E0_CS_PIN 42
//#endif
#define E1_STEP_PIN 26
#define E1_DIR_PIN 28
#define E1_ENABLE_PIN 24
#define E1_STEP_PIN 57
#define E1_DIR_PIN 58
#define E1_ENABLE_PIN 59
//#ifndef E1_CS_PIN
//define E1_CS_PIN 44
//#endif
@@ -111,8 +120,8 @@
//
// Temperature Sensors
//
#define TEMP_0_PIN 15 // Analog Input
#define TEMP_1_PIN 13 // Analog Input
#define TEMP_0_PIN 13 // Analog Input
#define TEMP_1_PIN 15 // Analog Input
#define TEMP_BED_PIN 14 // Analog Input
// SPI for MAX Thermocouple
@@ -125,8 +134,8 @@
//
// Heaters / Fans
//
#define HEATER_0_PIN 11
#define HEATER_1_PIN 10
#define HEATER_0_PIN 10
#define HEATER_1_PIN 11
#define HEATER_BED_PIN 8
#define FAN0_PIN 9
@@ -134,16 +143,9 @@
// XXX Runout support unknown?
//#define NUM_RUNOUT_SENSORS 0
#define FIL_RUNOUT_PIN 15
//#define FIL_RUNOUT_PIN 22
//#define FIL_RUNOUT2_PIN 21
//
// PSU and Powerloss Recovery
//
#ifdef PSU_CONTROL
#define PS_ON_PIN 40
#endif
//
// Misc. Functions
//
@@ -105,11 +105,6 @@
#define BEEPER_PIN -1
#endif
#if ENABLED(MINIPANEL)
#undef DOGLCD_CS
#define DOGLCD_CS 28
#endif
/**
PIN: 0 Port: B0 E0_DIR_PIN protected
PIN: 1 Port: B1 E0_STEP_PIN protected

Some files were not shown because too many files have changed in this diff Show More