Compare commits
258 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b878127ea0 | ||
|
6ea6556d09 | ||
|
2b37a71eba | ||
|
e3ae76d76d | ||
|
b24508907e | ||
|
ec3daadf43 | ||
|
ae76011e75 | ||
|
34066c1717 | ||
|
19fe3d5e79 | ||
|
ec518e6e7b | ||
|
003ce25acf | ||
|
3e5d867276 | ||
|
b1bcb387fa | ||
|
0fbd8c52bb | ||
|
08895e6cb0 | ||
|
38e775496a | ||
|
47631167f9 | ||
|
185e0dc7b7 | ||
|
bcf6ca59df | ||
|
1ba694cebb | ||
|
906fa05bd6 | ||
|
651f15f833 | ||
|
ef41c1f452 | ||
|
8050813d32 | ||
|
25e7e2fce0 | ||
|
a0f7f0e9e2 | ||
|
f3e0bc7a4b | ||
|
49ff1e837a | ||
|
4f8191b481 | ||
|
927a1a1738 | ||
|
f2f23e8097 | ||
|
cce585f6ca | ||
|
5bfb465ab4 | ||
|
ce7bbafb8f | ||
|
5ffc4bfe3a | ||
|
3ecc99e95d | ||
|
f22c5d3cc6 | ||
|
d8df8e0eed | ||
|
e38958f256 | ||
|
d7c77403fd | ||
|
c8898b5ca0 | ||
|
781257bc64 | ||
|
dec083dcc1 | ||
|
cdd9507493 | ||
|
dba877311e | ||
|
31fd3be6eb | ||
|
2b4284df81 | ||
|
d84e2d6e29 | ||
|
56355159c6 | ||
|
a7135d429b | ||
|
3b0a40cd5d | ||
|
83c74802f8 | ||
|
adc17933cd | ||
|
68c52673d6 | ||
|
2aa35577f2 | ||
|
14ffc66c45 | ||
|
2ea0832e0f | ||
|
ab050878e9 | ||
|
707a04022e | ||
|
d12c357793 | ||
|
ddf8668e16 | ||
|
3491e49c5f | ||
|
d322e495b2 | ||
|
5d80f7006a | ||
|
3e7a9e5d20 | ||
|
33e8769226 | ||
|
59842edbcb | ||
|
507e1e436e | ||
|
b27447ef48 | ||
|
c9a3ba99be | ||
|
967942460e | ||
|
bfa257902e | ||
|
3f103c91f0 | ||
|
2fd9971f41 | ||
|
a3063a9392 | ||
|
d8a02bbbdb | ||
|
76d4a395d1 | ||
|
c515bfb5fb | ||
|
83430be580 | ||
|
9bd9f91722 | ||
|
e6ef43e51a | ||
|
16bca67f2d | ||
|
d65eea550c | ||
|
46080b367a | ||
|
317afae37c | ||
|
930a608236 | ||
|
6e3c45580c | ||
|
e3df7d7bc8 | ||
|
c1fca91103 | ||
|
d3c56a76e7 | ||
|
4194cdda5b | ||
|
f5f999d7bf | ||
|
b4b607681c | ||
|
1e75eba27b | ||
|
f3f3d202ac | ||
|
c90fa530db | ||
|
aeb8097cbc | ||
|
04bea72787 | ||
|
ce95f56ac8 | ||
|
aff45fd455 | ||
|
c8f28d9d09 | ||
|
f3697e5e02 | ||
|
557ba20ff4 | ||
|
dd0e5c26d1 | ||
|
c9a3f41152 | ||
|
d13ffa0aba | ||
|
fb0be29604 | ||
|
7ca1550775 | ||
|
665a71b471 | ||
|
9268a4b28c | ||
|
529bbfad10 | ||
|
e7945c2277 | ||
|
5ee91c73ed | ||
|
2116e4202b | ||
|
19521d16cd | ||
|
057302b936 | ||
|
d62619c9c8 | ||
|
9c80a89597 | ||
|
00834ef03d | ||
|
5b7b065b96 | ||
|
a739af823f | ||
|
493eb446b7 | ||
|
1b45b3802a | ||
|
7898307d78 | ||
|
8da8aa140f | ||
|
4572af2bce | ||
|
6dc17f0e6e | ||
|
3fcf3f69ca | ||
|
a9fd2769f3 | ||
|
9adaf92674 | ||
|
e75c3b6c54 | ||
|
61f2bb1228 | ||
|
d1502f74ea | ||
|
83f9413196 | ||
|
cdc3e18d99 | ||
|
55a6315862 | ||
|
cf447a5442 | ||
|
7597b4fb40 | ||
|
7cd0f2a32a | ||
|
4dae5890e9 | ||
|
738ae4be33 | ||
|
e573611021 | ||
|
f60965a107 | ||
|
3995e8373c | ||
|
ddc82b84e2 | ||
|
87a943756a | ||
|
8e28731f96 | ||
|
cdbd438a04 | ||
|
3220c49f1b | ||
|
94e67a036a | ||
|
c977e82074 | ||
|
9878a5ab58 | ||
|
2de914c38c | ||
|
49b05ba989 | ||
|
85fa8c55c9 | ||
|
57eef65d9c | ||
|
894c954e8f | ||
|
046bac6769 | ||
|
765720e98b | ||
|
26a244325b | ||
|
f7d28ce1d6 | ||
|
c85633b47f | ||
|
6861b1ec82 | ||
|
003cb20b9f | ||
|
f1f622de01 | ||
|
dbb8f3db09 | ||
|
5d7c72db5a | ||
|
755adb8973 | ||
|
0977429138 | ||
|
1dfa6cbc80 | ||
|
e3998dc3df | ||
|
b6e1838fa6 | ||
|
908caba735 | ||
|
121f3b1096 | ||
|
9e373617dc | ||
|
5298fa357c | ||
|
2c15bc5d39 | ||
|
159f9c85a6 | ||
|
1d1f318752 | ||
|
40a9d82ae9 | ||
|
72c28d3462 | ||
|
ed224ca7d8 | ||
|
02e131b5fd | ||
|
5afb5e03b0 | ||
|
52a23b969b | ||
|
afcc7ea22b | ||
|
c463b81819 | ||
|
f688c7d20d | ||
|
0167bba371 | ||
|
7004fb702d | ||
|
2f2dd3322d | ||
|
31d3a781a8 | ||
|
a7fd6b68be | ||
|
6a1e78e614 | ||
|
770edea577 | ||
|
08a51b2820 | ||
|
ac11c689f7 | ||
|
f3e199fcd2 | ||
|
ffcbe68570 | ||
|
06e965e29c | ||
|
e865cc0249 | ||
|
5d8d03da03 | ||
|
0b3da61ac7 | ||
|
a24eb691fb | ||
|
c5c8ef436c | ||
|
83309c1ac8 | ||
|
ec2f4f512e | ||
|
ad991734c4 | ||
|
03184e1c31 | ||
|
cca5844ba9 | ||
|
45d3866f97 | ||
|
94edfc0a8f | ||
|
9fa9eebe51 | ||
|
4518506559 | ||
|
c1fb84e1a6 | ||
|
ea34aa2d3e | ||
|
d6cb657c85 | ||
|
0df9f30f14 | ||
|
d3e902af76 | ||
|
0b3420a012 | ||
|
5cf0975913 | ||
|
db90a180c2 | ||
|
d174d610bd | ||
|
e69e56ea52 | ||
|
0c66c713b6 | ||
|
95230c9792 | ||
|
7eea0ac6de | ||
|
b19a1f602a | ||
|
789235b925 | ||
|
00722c3294 | ||
|
cb4e3889ec | ||
|
76ec7040f1 | ||
|
b41365b495 | ||
|
6e18af6f81 | ||
|
12bc28bc8c | ||
|
3fa3be1f31 | ||
|
a468701511 | ||
|
f67cd07328 | ||
|
5cbdf51b4a | ||
|
7378afc6d8 | ||
|
7957408497 | ||
|
53fc13ba7f | ||
|
a0ea7cbf26 | ||
|
6310e023a7 | ||
|
5f594ce5d3 | ||
|
64a7dfbe7d | ||
|
5d0e94c11c | ||
|
0ca1170b6d | ||
|
addc91a409 | ||
|
450f329f05 | ||
|
1f72b4f65b | ||
|
50195ec990 | ||
|
2d9557cf40 | ||
|
5625ceec7d | ||
|
888e9cb60b | ||
|
d00f6cbe12 | ||
|
8abef30a75 | ||
|
158b26b875 |
3
.github/workflows/check-pr.yml
vendored
3
.github/workflows/check-pr.yml
vendored
@@ -20,9 +20,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: peter-evans/close-pull@v1
|
||||
- uses: superbrothers/close-pull-request@v3
|
||||
with:
|
||||
delete-branch: false
|
||||
comment: >
|
||||
Thanks for your contribution! Unfortunately we can't accept PRs directed at release branches. We make patches to the bugfix branches and only later do we push them out as releases.
|
||||
|
||||
|
69
.github/workflows/test-builds.yml
vendored
69
.github/workflows/test-builds.yml
vendored
@@ -36,9 +36,11 @@ jobs:
|
||||
# Base Environments
|
||||
|
||||
- DUE
|
||||
- DUE_archim
|
||||
- esp32
|
||||
- linux_native
|
||||
- mega2560
|
||||
- at90usb1286_dfu
|
||||
- teensy31
|
||||
- teensy35
|
||||
- teensy41
|
||||
@@ -46,62 +48,86 @@ jobs:
|
||||
|
||||
# Extended AVR Environments
|
||||
|
||||
- FYSETC_F6_13
|
||||
- FYSETC_F6
|
||||
- mega1280
|
||||
- rambo
|
||||
- sanguino1284p
|
||||
- sanguino644p
|
||||
|
||||
# Extended STM32 Environments
|
||||
# STM32F1 (Maple) Environments
|
||||
|
||||
- STM32F103RC_btt
|
||||
- STM32F103RC_btt_USB
|
||||
- STM32F103RE_btt
|
||||
- STM32F103RE_btt_USB
|
||||
#- STM32F103RC_btt_maple
|
||||
- STM32F103RC_btt_USB_maple
|
||||
- STM32F103RC_fysetc
|
||||
- STM32F103RC_meeb
|
||||
- jgaurora_a5s_a1
|
||||
- STM32F103VE_longer
|
||||
#- mks_robin_maple
|
||||
- mks_robin_lite
|
||||
- mks_robin_pro
|
||||
#- mks_robin_nano35_maple
|
||||
#- STM32F103RET6_creality_maple
|
||||
|
||||
# STM32 (ST) Environments
|
||||
|
||||
- STM32F103RC_btt
|
||||
#- STM32F103RC_btt_USB
|
||||
- STM32F103RE_btt
|
||||
- STM32F103RE_btt_USB
|
||||
- STM32F103RET6_creality
|
||||
- STM32F407VE_black
|
||||
- STM32F401VE_STEVAL
|
||||
- BIGTREE_BTT002
|
||||
- BIGTREE_SKR_PRO
|
||||
- BIGTREE_GTR_V1_0
|
||||
- mks_robin
|
||||
- mks_robin_stm32
|
||||
- ARMED
|
||||
- FYSETC_S6
|
||||
- STM32F070CB_malyan
|
||||
- STM32F070RB_malyan
|
||||
- malyan_M300
|
||||
- mks_robin_lite
|
||||
- FLYF407ZG
|
||||
- rumba32
|
||||
- mks_robin_pro
|
||||
- STM32F103RET6_creality
|
||||
- LERDGEX
|
||||
- LERDGEK
|
||||
- mks_robin_nano35
|
||||
- NUCLEO_F767ZI
|
||||
- REMRAM_V1
|
||||
- BTT_SKR_SE_BX
|
||||
- chitu_f103
|
||||
|
||||
# Put lengthy tests last
|
||||
|
||||
- LPC1768
|
||||
- LPC1769
|
||||
|
||||
# STM32 with non-STM framework. both broken for now. they should use HAL_STM32 which is working.
|
||||
|
||||
#- STM32F4
|
||||
#- STM32F7
|
||||
|
||||
# Non-working environment tests
|
||||
#- at90usb1286_cdc
|
||||
#- at90usb1286_dfu
|
||||
#- STM32F103CB_malyan
|
||||
#- STM32F103RE
|
||||
#- mks_robin_mini
|
||||
|
||||
steps:
|
||||
|
||||
- name: Check out the PR
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Cache pip
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
|
||||
- name: Cache PlatformIO
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.platformio
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
|
||||
- name: Select Python 3.7
|
||||
uses: actions/setup-python@v1
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.7' # Version range or exact version of a Python version to use, using semvers version range syntax.
|
||||
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
|
||||
@@ -111,13 +137,6 @@ jobs:
|
||||
pip install -U https://github.com/platformio/platformio-core/archive/develop.zip
|
||||
platformio update
|
||||
|
||||
- name: Check out the PR
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Run ${{ matrix.test-platform }} Tests
|
||||
run: |
|
||||
# Inline tests script
|
||||
chmod +x buildroot/bin/*
|
||||
chmod +x buildroot/tests/*
|
||||
export PATH=./buildroot/bin/:./buildroot/tests/:${PATH}
|
||||
run_tests . ${{ matrix.test-platform }}
|
||||
make tests-single-ci TEST_TARGET=${{ matrix.test-platform }}
|
||||
|
@@ -35,7 +35,7 @@
|
||||
*
|
||||
* Advanced settings can be found in Configuration_adv.h
|
||||
*/
|
||||
#define CONFIGURATION_H_VERSION 020008
|
||||
#define CONFIGURATION_H_VERSION 02000901
|
||||
|
||||
//===========================================================================
|
||||
//============================= Getting Started =============================
|
||||
@@ -105,14 +105,9 @@
|
||||
#define SERIAL_PORT 0
|
||||
|
||||
/**
|
||||
* Select a secondary serial port on the board to use for communication with the host.
|
||||
* Currently Ethernet (-2) is only supported on Teensy 4.1 boards.
|
||||
* :[-2, -1, 0, 1, 2, 3, 4, 5, 6, 7]
|
||||
*/
|
||||
//#define SERIAL_PORT_2 -1
|
||||
|
||||
/**
|
||||
* This setting determines the communication speed of the printer.
|
||||
* Serial Port Baud Rate
|
||||
* This is the default communication speed for all serial ports.
|
||||
* Set the baud rate defaults for additional serial ports below.
|
||||
*
|
||||
* 250000 works in most cases, but you might try a lower speed if
|
||||
* you commonly experience drop-outs during host printing.
|
||||
@@ -121,6 +116,23 @@
|
||||
* :[2400, 9600, 19200, 38400, 57600, 115200, 250000, 500000, 1000000]
|
||||
*/
|
||||
#define BAUDRATE 250000
|
||||
//#define BAUD_RATE_GCODE // Enable G-code M575 to set the baud rate
|
||||
|
||||
/**
|
||||
* Select a secondary serial port on the board to use for communication with the host.
|
||||
* Currently Ethernet (-2) is only supported on Teensy 4.1 boards.
|
||||
* :[-2, -1, 0, 1, 2, 3, 4, 5, 6, 7]
|
||||
*/
|
||||
//#define SERIAL_PORT_2 -1
|
||||
//#define BAUDRATE_2 250000 // Enable to override BAUDRATE
|
||||
|
||||
/**
|
||||
* Select a third serial port on the board to use for communication with the host.
|
||||
* Currently only supported for AVR, DUE, LPC1768/9 and STM32/STM32F1
|
||||
* :[-1, 0, 1, 2, 3, 4, 5, 6, 7]
|
||||
*/
|
||||
//#define SERIAL_PORT_3 1
|
||||
//#define BAUDRATE_3 250000 // Enable to override BAUDRATE
|
||||
|
||||
// Enable the Bluetooth serial interface on AT90USB devices
|
||||
//#define BLUETOOTH
|
||||
@@ -137,6 +149,45 @@
|
||||
// Choose your own or use a service like https://www.uuidgenerator.net/version4
|
||||
//#define MACHINE_UUID "00000000-0000-0000-0000-000000000000"
|
||||
|
||||
/**
|
||||
* Define the number of coordinated linear axes.
|
||||
* See https://github.com/DerAndere1/Marlin/wiki
|
||||
* Each linear axis gets its own stepper control and endstop:
|
||||
*
|
||||
* Steppers: *_STEP_PIN, *_ENABLE_PIN, *_DIR_PIN, *_ENABLE_ON
|
||||
* Endstops: *_STOP_PIN, USE_*MIN_PLUG, USE_*MAX_PLUG
|
||||
* Axes: *_MIN_POS, *_MAX_POS, INVERT_*_DIR
|
||||
* Planner: DEFAULT_AXIS_STEPS_PER_UNIT, DEFAULT_MAX_FEEDRATE
|
||||
* DEFAULT_MAX_ACCELERATION, AXIS_RELATIVE_MODES,
|
||||
* MICROSTEP_MODES, MANUAL_FEEDRATE
|
||||
*
|
||||
* :[3, 4, 5, 6]
|
||||
*/
|
||||
//#define LINEAR_AXES 3
|
||||
|
||||
/**
|
||||
* Axis codes for additional axes:
|
||||
* This defines the axis code that is used in G-code commands to
|
||||
* reference a specific axis.
|
||||
* 'A' for rotational axis parallel to X
|
||||
* 'B' for rotational axis parallel to Y
|
||||
* 'C' for rotational axis parallel to Z
|
||||
* 'U' for secondary linear axis parallel to X
|
||||
* 'V' for secondary linear axis parallel to Y
|
||||
* 'W' for secondary linear axis parallel to Z
|
||||
* Regardless of the settings, firmware-internal axis IDs are
|
||||
* I (AXIS4), J (AXIS5), K (AXIS6).
|
||||
*/
|
||||
#if LINEAR_AXES >= 4
|
||||
#define AXIS4_NAME 'A' // :['A', 'B', 'C', 'U', 'V', 'W']
|
||||
#endif
|
||||
#if LINEAR_AXES >= 5
|
||||
#define AXIS5_NAME 'B' // :['A', 'B', 'C', 'U', 'V', 'W']
|
||||
#endif
|
||||
#if LINEAR_AXES >= 6
|
||||
#define AXIS6_NAME 'C' // :['A', 'B', 'C', 'U', 'V', 'W']
|
||||
#endif
|
||||
|
||||
// @section extruder
|
||||
|
||||
// This defines the number of extruders
|
||||
@@ -421,6 +472,7 @@
|
||||
#define TEMP_SENSOR_PROBE 0
|
||||
#define TEMP_SENSOR_CHAMBER 0
|
||||
#define TEMP_SENSOR_COOLER 0
|
||||
#define TEMP_SENSOR_REDUNDANT 0
|
||||
|
||||
// Dummy thermistor constant temperature readings, for use with 998 and 999
|
||||
#define DUMMY_THERMISTOR_998_VALUE 25
|
||||
@@ -432,11 +484,6 @@
|
||||
//#define MAX31865_SENSOR_OHMS_1 100
|
||||
//#define MAX31865_CALIBRATION_OHMS_1 430
|
||||
|
||||
// Use temp sensor 1 as a redundant sensor with sensor 0. If the readings
|
||||
// from the two sensors differ too much the print will be aborted.
|
||||
//#define TEMP_SENSOR_1_AS_REDUNDANT
|
||||
#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
|
||||
|
||||
#define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109
|
||||
#define TEMP_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer
|
||||
#define TEMP_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target
|
||||
@@ -449,6 +496,28 @@
|
||||
#define TEMP_CHAMBER_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer
|
||||
#define TEMP_CHAMBER_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target
|
||||
|
||||
/**
|
||||
* Redundant Temperature Sensor (TEMP_SENSOR_REDUNDANT)
|
||||
*
|
||||
* Use a temp sensor as a redundant sensor for another reading. Select an unused temperature sensor, and another
|
||||
* sensor you'd like it to be redundant for. If the two thermistors differ by TEMP_SENSOR_REDUNDANT_MAX_DIFF (°C),
|
||||
* the print will be aborted. Whichever sensor is selected will have its normal functions disabled; i.e. selecting
|
||||
* the Bed sensor (-1) will disable bed heating/monitoring.
|
||||
*
|
||||
* Use the following to select temp sensors:
|
||||
* -5 : Cooler
|
||||
* -4 : Probe
|
||||
* -3 : not used
|
||||
* -2 : Chamber
|
||||
* -1 : Bed
|
||||
* 0-7 : E0 through E7
|
||||
*/
|
||||
#if TEMP_SENSOR_REDUNDANT
|
||||
#define TEMP_SENSOR_REDUNDANT_SOURCE 1 // The sensor that will provide the redundant reading.
|
||||
#define TEMP_SENSOR_REDUNDANT_TARGET 0 // The sensor that we are providing a redundant reading for.
|
||||
#define TEMP_SENSOR_REDUNDANT_MAX_DIFF 10 // (°C) Temperature difference that will trigger a print abort.
|
||||
#endif
|
||||
|
||||
// Below this temperature the heater will be switched off
|
||||
// because it probably indicates a broken thermistor wire.
|
||||
#define HEATER_0_MINTEMP 5
|
||||
@@ -679,9 +748,15 @@
|
||||
#define USE_XMIN_PLUG
|
||||
#define USE_YMIN_PLUG
|
||||
#define USE_ZMIN_PLUG
|
||||
//#define USE_IMIN_PLUG
|
||||
//#define USE_JMIN_PLUG
|
||||
//#define USE_KMIN_PLUG
|
||||
//#define USE_XMAX_PLUG
|
||||
//#define USE_YMAX_PLUG
|
||||
//#define USE_ZMAX_PLUG
|
||||
//#define USE_IMAX_PLUG
|
||||
//#define USE_JMAX_PLUG
|
||||
//#define USE_KMAX_PLUG
|
||||
|
||||
// Enable pullup for all endstops to prevent a floating state
|
||||
#define ENDSTOPPULLUPS
|
||||
@@ -690,9 +765,15 @@
|
||||
//#define ENDSTOPPULLUP_XMAX
|
||||
//#define ENDSTOPPULLUP_YMAX
|
||||
//#define ENDSTOPPULLUP_ZMAX
|
||||
//#define ENDSTOPPULLUP_IMAX
|
||||
//#define ENDSTOPPULLUP_JMAX
|
||||
//#define ENDSTOPPULLUP_KMAX
|
||||
//#define ENDSTOPPULLUP_XMIN
|
||||
//#define ENDSTOPPULLUP_YMIN
|
||||
//#define ENDSTOPPULLUP_ZMIN
|
||||
//#define ENDSTOPPULLUP_IMIN
|
||||
//#define ENDSTOPPULLUP_JMIN
|
||||
//#define ENDSTOPPULLUP_KMIN
|
||||
//#define ENDSTOPPULLUP_ZMIN_PROBE
|
||||
#endif
|
||||
|
||||
@@ -703,9 +784,15 @@
|
||||
//#define ENDSTOPPULLDOWN_XMAX
|
||||
//#define ENDSTOPPULLDOWN_YMAX
|
||||
//#define ENDSTOPPULLDOWN_ZMAX
|
||||
//#define ENDSTOPPULLDOWN_IMAX
|
||||
//#define ENDSTOPPULLDOWN_JMAX
|
||||
//#define ENDSTOPPULLDOWN_KMAX
|
||||
//#define ENDSTOPPULLDOWN_XMIN
|
||||
//#define ENDSTOPPULLDOWN_YMIN
|
||||
//#define ENDSTOPPULLDOWN_ZMIN
|
||||
//#define ENDSTOPPULLDOWN_IMIN
|
||||
//#define ENDSTOPPULLDOWN_JMIN
|
||||
//#define ENDSTOPPULLDOWN_KMIN
|
||||
//#define ENDSTOPPULLDOWN_ZMIN_PROBE
|
||||
#endif
|
||||
|
||||
@@ -713,9 +800,15 @@
|
||||
#define X_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define Y_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define Z_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define I_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define J_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define K_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define X_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define Y_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define Z_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define I_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define J_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define K_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define Z_MIN_PROBE_ENDSTOP_INVERTING false // Set to true to invert the logic of the probe.
|
||||
|
||||
/**
|
||||
@@ -744,6 +837,9 @@
|
||||
//#define Z2_DRIVER_TYPE A4988
|
||||
//#define Z3_DRIVER_TYPE A4988
|
||||
//#define Z4_DRIVER_TYPE A4988
|
||||
//#define I_DRIVER_TYPE A4988
|
||||
//#define J_DRIVER_TYPE A4988
|
||||
//#define K_DRIVER_TYPE A4988
|
||||
#define E0_DRIVER_TYPE A4988
|
||||
//#define E1_DRIVER_TYPE A4988
|
||||
//#define E2_DRIVER_TYPE A4988
|
||||
@@ -797,14 +893,14 @@
|
||||
/**
|
||||
* Default Axis Steps Per Unit (steps/mm)
|
||||
* Override with M92
|
||||
* X, Y, Z, E0 [, E1[, E2...]]
|
||||
* X, Y, Z [, I [, J [, K]]], E0 [, E1[, E2...]]
|
||||
*/
|
||||
#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, 500 }
|
||||
|
||||
/**
|
||||
* Default Max Feed Rate (mm/s)
|
||||
* Override with M203
|
||||
* X, Y, Z, E0 [, E1[, E2...]]
|
||||
* X, Y, Z [, I [, J [, K]]], E0 [, E1[, E2...]]
|
||||
*/
|
||||
#define DEFAULT_MAX_FEEDRATE { 300, 300, 5, 25 }
|
||||
|
||||
@@ -817,7 +913,7 @@
|
||||
* Default Max Acceleration (change/s) change = mm/s
|
||||
* (Maximum start speed for accelerated moves)
|
||||
* Override with M201
|
||||
* X, Y, Z, E0 [, E1[, E2...]]
|
||||
* X, Y, Z [, I [, J [, K]]], E0 [, E1[, E2...]]
|
||||
*/
|
||||
#define DEFAULT_MAX_ACCELERATION { 3000, 3000, 100, 10000 }
|
||||
|
||||
@@ -851,6 +947,9 @@
|
||||
#define DEFAULT_XJERK 10.0
|
||||
#define DEFAULT_YJERK 10.0
|
||||
#define DEFAULT_ZJERK 0.3
|
||||
//#define DEFAULT_IJERK 0.3
|
||||
//#define DEFAULT_JJERK 0.3
|
||||
//#define DEFAULT_KJERK 0.3
|
||||
|
||||
//#define TRAVEL_EXTRA_XYJERK 0.0 // Additional jerk allowance for all travel moves
|
||||
|
||||
@@ -1149,7 +1248,8 @@
|
||||
//#define WAIT_FOR_HOTEND // Wait for hotend to heat back up between probes (to improve accuracy & prevent cold extrude)
|
||||
#endif
|
||||
//#define PROBING_FANS_OFF // Turn fans off when probing
|
||||
//#define PROBING_STEPPERS_OFF // Turn steppers off (unless needed to hold position) when probing
|
||||
//#define PROBING_ESTEPPERS_OFF // Turn all extruder steppers off when probing
|
||||
//#define PROBING_STEPPERS_OFF // Turn all steppers off (unless needed to hold position) when probing (including extruders)
|
||||
//#define DELAY_BEFORE_PROBING 200 // (ms) To prevent vibrations from triggering piezo sensors
|
||||
|
||||
// Require minimum nozzle and/or bed temperature for probing
|
||||
@@ -1165,12 +1265,18 @@
|
||||
#define Y_ENABLE_ON 0
|
||||
#define Z_ENABLE_ON 0
|
||||
#define E_ENABLE_ON 0 // For all extruders
|
||||
//#define I_ENABLE_ON 0
|
||||
//#define J_ENABLE_ON 0
|
||||
//#define K_ENABLE_ON 0
|
||||
|
||||
// Disable axis steppers immediately when they're not being stepped.
|
||||
// WARNING: When motors turn off there is a chance of losing position accuracy!
|
||||
#define DISABLE_X false
|
||||
#define DISABLE_Y false
|
||||
#define DISABLE_Z false
|
||||
//#define DISABLE_I false
|
||||
//#define DISABLE_J false
|
||||
//#define DISABLE_K false
|
||||
|
||||
// Turn off the display blinking that warns about possible accuracy reduction
|
||||
//#define DISABLE_REDUCED_ACCURACY_WARNING
|
||||
@@ -1186,6 +1292,9 @@
|
||||
#define INVERT_X_DIR false
|
||||
#define INVERT_Y_DIR true
|
||||
#define INVERT_Z_DIR false
|
||||
//#define INVERT_I_DIR false
|
||||
//#define INVERT_J_DIR false
|
||||
//#define INVERT_K_DIR false
|
||||
|
||||
// @section extruder
|
||||
|
||||
@@ -1221,6 +1330,9 @@
|
||||
#define X_HOME_DIR -1
|
||||
#define Y_HOME_DIR -1
|
||||
#define Z_HOME_DIR -1
|
||||
//#define I_HOME_DIR -1
|
||||
//#define J_HOME_DIR -1
|
||||
//#define K_HOME_DIR -1
|
||||
|
||||
// @section machine
|
||||
|
||||
@@ -1235,6 +1347,12 @@
|
||||
#define X_MAX_POS X_BED_SIZE
|
||||
#define Y_MAX_POS Y_BED_SIZE
|
||||
#define Z_MAX_POS 200
|
||||
//#define I_MIN_POS 0
|
||||
//#define I_MAX_POS 50
|
||||
//#define J_MIN_POS 0
|
||||
//#define J_MAX_POS 50
|
||||
//#define K_MIN_POS 0
|
||||
//#define K_MAX_POS 50
|
||||
|
||||
/**
|
||||
* Software Endstops
|
||||
@@ -1251,6 +1369,9 @@
|
||||
#define MIN_SOFTWARE_ENDSTOP_X
|
||||
#define MIN_SOFTWARE_ENDSTOP_Y
|
||||
#define MIN_SOFTWARE_ENDSTOP_Z
|
||||
#define MIN_SOFTWARE_ENDSTOP_I
|
||||
#define MIN_SOFTWARE_ENDSTOP_J
|
||||
#define MIN_SOFTWARE_ENDSTOP_K
|
||||
#endif
|
||||
|
||||
// Max software endstops constrain movement within maximum coordinate bounds
|
||||
@@ -1259,6 +1380,9 @@
|
||||
#define MAX_SOFTWARE_ENDSTOP_X
|
||||
#define MAX_SOFTWARE_ENDSTOP_Y
|
||||
#define MAX_SOFTWARE_ENDSTOP_Z
|
||||
#define MAX_SOFTWARE_ENDSTOP_I
|
||||
#define MAX_SOFTWARE_ENDSTOP_J
|
||||
#define MAX_SOFTWARE_ENDSTOP_K
|
||||
#endif
|
||||
|
||||
#if EITHER(MIN_SOFTWARE_ENDSTOPS, MAX_SOFTWARE_ENDSTOPS)
|
||||
@@ -1491,6 +1615,8 @@
|
||||
//#define UBL_Z_RAISE_WHEN_OFF_MESH 2.5 // When the nozzle is off the mesh, this value is used
|
||||
// as the Z-Height correction value.
|
||||
|
||||
//#define UBL_MESH_WIZARD // Run several commands in a row to get a complete mesh
|
||||
|
||||
#elif ENABLED(MESH_BED_LEVELING)
|
||||
|
||||
//===========================================================================
|
||||
@@ -1568,6 +1694,9 @@
|
||||
//#define MANUAL_X_HOME_POS 0
|
||||
//#define MANUAL_Y_HOME_POS 0
|
||||
//#define MANUAL_Z_HOME_POS 0
|
||||
//#define MANUAL_I_HOME_POS 0
|
||||
//#define MANUAL_J_HOME_POS 0
|
||||
//#define MANUAL_K_HOME_POS 0
|
||||
|
||||
// Use "Z Safe Homing" to avoid homing with a Z probe outside the bed area.
|
||||
//
|
||||
@@ -1810,11 +1939,20 @@
|
||||
/**
|
||||
* Print Job Timer
|
||||
*
|
||||
* Automatically start and stop the print job timer on M104/M109/M190.
|
||||
* Automatically start and stop the print job timer on M104/M109/M140/M190/M141/M191.
|
||||
* The print job timer will only be stopped if the bed/chamber target temp is
|
||||
* below BED_MINTEMP/CHAMBER_MINTEMP.
|
||||
*
|
||||
* M104 (hotend, no wait) - high temp = none, low temp = stop timer
|
||||
* M109 (hotend, wait) - high temp = start timer, low temp = stop timer
|
||||
* M190 (bed, wait) - high temp = start timer, low temp = none
|
||||
* M104 (hotend, no wait) - high temp = none, low temp = stop timer
|
||||
* M109 (hotend, wait) - high temp = start timer, low temp = stop timer
|
||||
* M140 (bed, no wait) - high temp = none, low temp = stop timer
|
||||
* M190 (bed, wait) - high temp = start timer, low temp = none
|
||||
* M141 (chamber, no wait) - high temp = none, low temp = stop timer
|
||||
* M191 (chamber, wait) - high temp = start timer, low temp = none
|
||||
*
|
||||
* For M104/M109, high temp is anything over EXTRUDE_MINTEMP / 2.
|
||||
* For M140/M190, high temp is anything over BED_MINTEMP.
|
||||
* For M141/M191, high temp is anything over CHAMBER_MINTEMP.
|
||||
*
|
||||
* The timer can also be controlled with the following commands:
|
||||
*
|
||||
@@ -2258,7 +2396,8 @@
|
||||
// MKS LCD12864A/B with graphic controller and SD support. Follows MKS_MINI_12864 pinout.
|
||||
// https://www.aliexpress.com/item/33018110072.html
|
||||
//
|
||||
//#define MKS_LCD12864
|
||||
//#define MKS_LCD12864A
|
||||
//#define MKS_LCD12864B
|
||||
|
||||
//
|
||||
// FYSETC variant of the MINI12864 graphic controller with SD support
|
||||
@@ -2561,7 +2700,7 @@
|
||||
//#define DWIN_CREALITY_LCD
|
||||
|
||||
//
|
||||
// ADS7843/XPT2046 ADC Touchscreen such as ILI9341 2.8
|
||||
// Touch Screen Settings
|
||||
//
|
||||
//#define TOUCH_SCREEN
|
||||
#if ENABLED(TOUCH_SCREEN)
|
||||
@@ -2675,7 +2814,7 @@
|
||||
//#define NEOPIXEL_LED
|
||||
#if ENABLED(NEOPIXEL_LED)
|
||||
#define NEOPIXEL_TYPE NEO_GRBW // NEO_GRBW / NEO_GRB - four/three channel driver type (defined in Adafruit_NeoPixel.h)
|
||||
#define NEOPIXEL_PIN 4 // LED driving pin
|
||||
//#define NEOPIXEL_PIN 4 // LED driving pin
|
||||
//#define NEOPIXEL2_TYPE NEOPIXEL_TYPE
|
||||
//#define NEOPIXEL2_PIN 5
|
||||
#define NEOPIXEL_PIXELS 30 // Number of LEDs in the strip. (Longest strip when NEOPIXEL2_SEPARATE is disabled.)
|
||||
@@ -2693,10 +2832,11 @@
|
||||
//#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel
|
||||
#endif
|
||||
|
||||
// Use a single NeoPixel LED for static (background) lighting
|
||||
//#define NEOPIXEL_BKGD_LED_INDEX 0 // Index of the LED to use
|
||||
//#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 } // R, G, B, W
|
||||
//#define NEOPIXEL_BKGD_ALWAYS_ON // Keep the backlight on when other NeoPixels are off
|
||||
// Use some of the NeoPixel LEDs for static (background) lighting
|
||||
//#define NEOPIXEL_BKGD_INDEX_FIRST 0 // Index of the first background LED
|
||||
//#define NEOPIXEL_BKGD_INDEX_LAST 5 // Index of the last background LED
|
||||
//#define NEOPIXEL_BKGD_COLOR { 255, 255, 255, 0 } // R, G, B, W
|
||||
//#define NEOPIXEL_BKGD_ALWAYS_ON // Keep the backlight on when other NeoPixels are off
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@@ -30,7 +30,7 @@
|
||||
*
|
||||
* Basic settings can be found in Configuration.h
|
||||
*/
|
||||
#define CONFIGURATION_ADV_H_VERSION 020008
|
||||
#define CONFIGURATION_ADV_H_VERSION 02000901
|
||||
|
||||
//===========================================================================
|
||||
//============================= Thermal Settings ============================
|
||||
@@ -125,6 +125,12 @@
|
||||
#define PROBE_BETA 3950 // Beta value
|
||||
#endif
|
||||
|
||||
#if TEMP_SENSOR_REDUNDANT == 1000
|
||||
#define REDUNDANT_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
|
||||
#define REDUNDANT_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
|
||||
#define REDUNDANT_BETA 3950 // Beta value
|
||||
#endif
|
||||
|
||||
//
|
||||
// Hephestos 2 24V heated bed upgrade kit.
|
||||
// https://store.bq.com/en/heated-bed-kit-hephestos2
|
||||
@@ -196,7 +202,7 @@
|
||||
#define COOLER_MAXTEMP 26 // (°C)
|
||||
#define COOLER_DEFAULT_TEMP 16 // (°C)
|
||||
#define TEMP_COOLER_HYSTERESIS 1 // (°C) Temperature proximity considered "close enough" to the target
|
||||
#define COOLER_PIN 8 // Laser cooler on/off pin used to control power to the cooling element e.g. TEC, External chiller via relay
|
||||
#define COOLER_PIN 8 // Laser cooler on/off pin used to control power to the cooling element (e.g., TEC, External chiller via relay)
|
||||
#define COOLER_INVERTING false
|
||||
#define TEMP_COOLER_PIN 15 // Laser/Cooler temperature sensor pin. ADC is required.
|
||||
#define COOLER_FAN // Enable a fan on the cooler, Fan# 0,1,2,3 etc.
|
||||
@@ -526,6 +532,11 @@
|
||||
//#define USE_OCR2A_AS_TOP
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Use one of the PWM fans as a redundant part-cooling fan
|
||||
*/
|
||||
//#define REDUNDANT_PART_COOLING_FAN 2 // Index of the fan to sync with FAN 0.
|
||||
|
||||
// @section extruder
|
||||
|
||||
/**
|
||||
@@ -671,6 +682,12 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Drive the E axis with two synchronized steppers
|
||||
//#define E_DUAL_STEPPER_DRIVERS
|
||||
#if ENABLED(E_DUAL_STEPPER_DRIVERS)
|
||||
//#define INVERT_E1_VS_E0_DIR // Enable if the E motors need opposite DIR states
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Dual X Carriage
|
||||
*
|
||||
@@ -734,7 +751,7 @@
|
||||
* the position of the toolhead relative to the workspace.
|
||||
*/
|
||||
|
||||
//#define SENSORLESS_BACKOFF_MM { 2, 2 } // (mm) Backoff from endstops before sensorless homing
|
||||
//#define SENSORLESS_BACKOFF_MM { 2, 2, 0 } // (mm) Backoff from endstops before sensorless homing
|
||||
|
||||
#define HOMING_BUMP_MM { 5, 5, 2 } // (mm) Backoff from endstops after first bump
|
||||
#define HOMING_BUMP_DIVISOR { 2, 2, 4 } // Re-Bump Speed Divisor (Divides the Homing Feedrate)
|
||||
@@ -918,6 +935,9 @@
|
||||
#define INVERT_X_STEP_PIN false
|
||||
#define INVERT_Y_STEP_PIN false
|
||||
#define INVERT_Z_STEP_PIN false
|
||||
#define INVERT_I_STEP_PIN false
|
||||
#define INVERT_J_STEP_PIN false
|
||||
#define INVERT_K_STEP_PIN false
|
||||
#define INVERT_E_STEP_PIN false
|
||||
|
||||
/**
|
||||
@@ -929,6 +949,9 @@
|
||||
#define DISABLE_INACTIVE_X true
|
||||
#define DISABLE_INACTIVE_Y true
|
||||
#define DISABLE_INACTIVE_Z true // Set 'false' if the nozzle could fall onto your printed part!
|
||||
#define DISABLE_INACTIVE_I true
|
||||
#define DISABLE_INACTIVE_J true
|
||||
#define DISABLE_INACTIVE_K true
|
||||
#define DISABLE_INACTIVE_E true
|
||||
|
||||
// Default Minimum Feedrates for printing and travel moves
|
||||
@@ -969,7 +992,7 @@
|
||||
#if ENABLED(BACKLASH_COMPENSATION)
|
||||
// Define values for backlash distance and correction.
|
||||
// If BACKLASH_GCODE is enabled these values are the defaults.
|
||||
#define BACKLASH_DISTANCE_MM { 0, 0, 0 } // (mm)
|
||||
#define BACKLASH_DISTANCE_MM { 0, 0, 0 } // (mm) One value for each linear axis
|
||||
#define BACKLASH_CORRECTION 0.0 // 0.0 = no correction; 1.0 = full correction
|
||||
|
||||
// Add steps for motor direction changes on CORE kinematics
|
||||
@@ -1040,6 +1063,13 @@
|
||||
#define CALIBRATION_MEASURE_LEFT
|
||||
#define CALIBRATION_MEASURE_BACK
|
||||
|
||||
//#define CALIBRATION_MEASURE_IMIN
|
||||
//#define CALIBRATION_MEASURE_IMAX
|
||||
//#define CALIBRATION_MEASURE_JMIN
|
||||
//#define CALIBRATION_MEASURE_JMAX
|
||||
//#define CALIBRATION_MEASURE_KMIN
|
||||
//#define CALIBRATION_MEASURE_KMAX
|
||||
|
||||
// Probing at the exact top center only works if the center is flat. If
|
||||
// probing on a screwhead or hollow washer, probe near the edges.
|
||||
//#define CALIBRATION_MEASURE_AT_TOP_EDGES
|
||||
@@ -1301,6 +1331,8 @@
|
||||
|
||||
//#define BROWSE_MEDIA_ON_INSERT // Open the file browser when media is inserted
|
||||
|
||||
//#define MEDIA_MENU_AT_TOP // Force the media menu to be listed on the top of the main menu
|
||||
|
||||
#define EVENT_GCODE_SD_ABORT "G28XY" // G-code to run on SD Abort Print (e.g., "G28XY" or "G27")
|
||||
|
||||
#if ENABLED(PRINTER_EVENT_LEDS)
|
||||
@@ -1486,8 +1518,8 @@
|
||||
#if ENABLED(MULTI_VOLUME)
|
||||
#define VOLUME_SD_ONBOARD
|
||||
#define VOLUME_USB_FLASH_DRIVE
|
||||
#define DEFAULT_VOLUME SD_ONBOARD
|
||||
#define DEFAULT_SHARED_VOLUME USB_FLASH_DRIVE
|
||||
#define DEFAULT_VOLUME SV_SD_ONBOARD
|
||||
#define DEFAULT_SHARED_VOLUME SV_USB_FLASH_DRIVE
|
||||
#endif
|
||||
|
||||
#endif // SDSUPPORT
|
||||
@@ -1562,7 +1594,7 @@
|
||||
*/
|
||||
//#define STATUS_COMBINE_HEATERS // Use combined heater images instead of separate ones
|
||||
//#define STATUS_HOTEND_NUMBERLESS // Use plain hotend icons instead of numbered ones (with 2+ hotends)
|
||||
#define STATUS_HOTEND_INVERTED // Show solid nozzle bitmaps when heating (Requires STATUS_HOTEND_ANIM)
|
||||
#define STATUS_HOTEND_INVERTED // Show solid nozzle bitmaps when heating (Requires STATUS_HOTEND_ANIM for numbered hotends)
|
||||
#define STATUS_HOTEND_ANIM // Use a second bitmap to indicate hotend heating
|
||||
#define STATUS_BED_ANIM // Use a second bitmap to indicate bed heating
|
||||
#define STATUS_CHAMBER_ANIM // Use a second bitmap to indicate chamber heating
|
||||
@@ -1940,30 +1972,30 @@
|
||||
//#define USE_TEMP_EXT_COMPENSATION
|
||||
|
||||
// Probe temperature calibration generates a table of values starting at PTC_SAMPLE_START
|
||||
// (e.g. 30), in steps of PTC_SAMPLE_RES (e.g. 5) with PTC_SAMPLE_COUNT (e.g. 10) samples.
|
||||
// (e.g., 30), in steps of PTC_SAMPLE_RES (e.g., 5) with PTC_SAMPLE_COUNT (e.g., 10) samples.
|
||||
|
||||
//#define PTC_SAMPLE_START 30.0f
|
||||
//#define PTC_SAMPLE_RES 5.0f
|
||||
//#define PTC_SAMPLE_COUNT 10U
|
||||
//#define PTC_SAMPLE_START 30 // (°C)
|
||||
//#define PTC_SAMPLE_RES 5 // (°C)
|
||||
//#define PTC_SAMPLE_COUNT 10
|
||||
|
||||
// Bed temperature calibration builds a similar table.
|
||||
|
||||
//#define BTC_SAMPLE_START 60.0f
|
||||
//#define BTC_SAMPLE_RES 5.0f
|
||||
//#define BTC_SAMPLE_COUNT 10U
|
||||
//#define BTC_SAMPLE_START 60 // (°C)
|
||||
//#define BTC_SAMPLE_RES 5 // (°C)
|
||||
//#define BTC_SAMPLE_COUNT 10
|
||||
|
||||
// The temperature the probe should be at while taking measurements during bed temperature
|
||||
// calibration.
|
||||
//#define BTC_PROBE_TEMP 30.0f
|
||||
//#define BTC_PROBE_TEMP 30 // (°C)
|
||||
|
||||
// Height above Z=0.0f to raise the nozzle. Lowering this can help the probe to heat faster.
|
||||
// Note: the Z=0.0f offset is determined by the probe offset which can be set using M851.
|
||||
//#define PTC_PROBE_HEATING_OFFSET 0.5f
|
||||
// Height above Z=0.0 to raise the nozzle. Lowering this can help the probe to heat faster.
|
||||
// Note: the Z=0.0 offset is determined by the probe offset which can be set using M851.
|
||||
//#define PTC_PROBE_HEATING_OFFSET 0.5
|
||||
|
||||
// Height to raise the Z-probe between heating and taking the next measurement. Some probes
|
||||
// may fail to untrigger if they have been triggered for a long time, which can be solved by
|
||||
// increasing the height the probe is raised to.
|
||||
//#define PTC_PROBE_RAISE 15U
|
||||
//#define PTC_PROBE_RAISE 15
|
||||
|
||||
// If the probe is outside of the defined range, use linear extrapolation using the closest
|
||||
// point and the PTC_LINEAR_EXTRAPOLATION'th next point. E.g. if set to 4 it will use data[0]
|
||||
@@ -2078,7 +2110,7 @@
|
||||
// @section motion
|
||||
|
||||
// The number of linear moves that can be in the planner at once.
|
||||
// The value of BLOCK_BUFFER_SIZE must be a power of 2 (e.g. 8, 16, 32)
|
||||
// The value of BLOCK_BUFFER_SIZE must be a power of 2 (e.g., 8, 16, 32)
|
||||
#if BOTH(SDSUPPORT, DIRECT_STEPPING)
|
||||
#define BLOCK_BUFFER_SIZE 8
|
||||
#elif ENABLED(SDSUPPORT)
|
||||
@@ -2114,9 +2146,6 @@
|
||||
//#define SERIAL_XON_XOFF
|
||||
#endif
|
||||
|
||||
// Add M575 G-code to change the baud rate
|
||||
//#define BAUD_RATE_GCODE
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
// Enable this option to collect and display the maximum
|
||||
// RX queue usage after transferring a file to SD.
|
||||
@@ -2237,6 +2266,13 @@
|
||||
//#define EVENT_GCODE_AFTER_TOOLCHANGE "G12X" // Extra G-code to run after tool-change
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Extra G-code to run while executing tool-change commands. Can be used to use an additional
|
||||
* stepper motor (I axis, see option LINEAR_AXES in Configuration.h) to drive the tool-changer.
|
||||
*/
|
||||
//#define EVENT_GCODE_TOOLCHANGE_T0 "G28 A\nG1 A0" // Extra G-code to run while executing tool-change command T0
|
||||
//#define EVENT_GCODE_TOOLCHANGE_T1 "G1 A10" // Extra G-code to run while executing tool-change command T1
|
||||
|
||||
/**
|
||||
* Tool Sensors detect when tools have been picked up or dropped.
|
||||
* Requires the pins TOOL_SENSOR1_PIN, TOOL_SENSOR2_PIN, etc.
|
||||
@@ -2301,14 +2337,15 @@
|
||||
#endif // HAS_MULTI_EXTRUDER
|
||||
|
||||
/**
|
||||
* Advanced Pause
|
||||
* Experimental feature for filament change support and for parking the nozzle when paused.
|
||||
* Adds the GCode M600 for initiating filament change.
|
||||
* If PARK_HEAD_ON_PAUSE enabled, adds the GCode M125 to pause printing and park the nozzle.
|
||||
* Advanced Pause for Filament Change
|
||||
* - Adds the G-code M600 Filament Change to initiate a filament change.
|
||||
* - This feature is required for the default FILAMENT_RUNOUT_SCRIPT.
|
||||
*
|
||||
* Requires an LCD display.
|
||||
* Requires NOZZLE_PARK_FEATURE.
|
||||
* This feature is required for the default FILAMENT_RUNOUT_SCRIPT.
|
||||
* Requirements:
|
||||
* - For Filament Change parking enable and configure NOZZLE_PARK_FEATURE.
|
||||
* - For user interaction enable an LCD display, HOST_PROMPT_SUPPORT, or EMERGENCY_PARSER.
|
||||
*
|
||||
* Enable PARK_HEAD_ON_PAUSE to add the G-code M125 Pause and Park.
|
||||
*/
|
||||
//#define ADVANCED_PAUSE_FEATURE
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
@@ -2413,6 +2450,24 @@
|
||||
#define Z4_MICROSTEPS Z_MICROSTEPS
|
||||
#endif
|
||||
|
||||
#if AXIS_DRIVER_TYPE_I(TMC26X)
|
||||
#define I_MAX_CURRENT 1000
|
||||
#define I_SENSE_RESISTOR 91
|
||||
#define I_MICROSTEPS 16
|
||||
#endif
|
||||
|
||||
#if AXIS_DRIVER_TYPE_J(TMC26X)
|
||||
#define J_MAX_CURRENT 1000
|
||||
#define J_SENSE_RESISTOR 91
|
||||
#define J_MICROSTEPS 16
|
||||
#endif
|
||||
|
||||
#if AXIS_DRIVER_TYPE_K(TMC26X)
|
||||
#define K_MAX_CURRENT 1000
|
||||
#define K_SENSE_RESISTOR 91
|
||||
#define K_MICROSTEPS 16
|
||||
#endif
|
||||
|
||||
#if AXIS_DRIVER_TYPE_E0(TMC26X)
|
||||
#define E0_MAX_CURRENT 1000
|
||||
#define E0_SENSE_RESISTOR 91
|
||||
@@ -2563,6 +2618,33 @@
|
||||
//#define Z4_INTERPOLATE true
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(I)
|
||||
#define I_CURRENT 800
|
||||
#define I_CURRENT_HOME I_CURRENT
|
||||
#define I_MICROSTEPS 16
|
||||
#define I_RSENSE 0.11
|
||||
#define I_CHAIN_POS -1
|
||||
//#define I_INTERPOLATE true
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(J)
|
||||
#define J_CURRENT 800
|
||||
#define J_CURRENT_HOME J_CURRENT
|
||||
#define J_MICROSTEPS 16
|
||||
#define J_RSENSE 0.11
|
||||
#define J_CHAIN_POS -1
|
||||
//#define J_INTERPOLATE true
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(K)
|
||||
#define K_CURRENT 800
|
||||
#define K_CURRENT_HOME K_CURRENT
|
||||
#define K_MICROSTEPS 16
|
||||
#define K_RSENSE 0.11
|
||||
#define K_CHAIN_POS -1
|
||||
//#define K_INTERPOLATE true
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(E0)
|
||||
#define E0_CURRENT 800
|
||||
#define E0_MICROSTEPS 16
|
||||
@@ -2638,6 +2720,10 @@
|
||||
//#define Y2_CS_PIN -1
|
||||
//#define Z2_CS_PIN -1
|
||||
//#define Z3_CS_PIN -1
|
||||
//#define Z4_CS_PIN -1
|
||||
//#define I_CS_PIN -1
|
||||
//#define J_CS_PIN -1
|
||||
//#define K_CS_PIN -1
|
||||
//#define E0_CS_PIN -1
|
||||
//#define E1_CS_PIN -1
|
||||
//#define E2_CS_PIN -1
|
||||
@@ -2677,6 +2763,9 @@
|
||||
//#define Z2_SLAVE_ADDRESS 0
|
||||
//#define Z3_SLAVE_ADDRESS 0
|
||||
//#define Z4_SLAVE_ADDRESS 0
|
||||
//#define I_SLAVE_ADDRESS 0
|
||||
//#define J_SLAVE_ADDRESS 0
|
||||
//#define K_SLAVE_ADDRESS 0
|
||||
//#define E0_SLAVE_ADDRESS 0
|
||||
//#define E1_SLAVE_ADDRESS 0
|
||||
//#define E2_SLAVE_ADDRESS 0
|
||||
@@ -2701,6 +2790,9 @@
|
||||
*/
|
||||
#define STEALTHCHOP_XY
|
||||
#define STEALTHCHOP_Z
|
||||
#define STEALTHCHOP_I
|
||||
#define STEALTHCHOP_J
|
||||
#define STEALTHCHOP_K
|
||||
#define STEALTHCHOP_E
|
||||
|
||||
/**
|
||||
@@ -2772,6 +2864,9 @@
|
||||
#define Z2_HYBRID_THRESHOLD 3
|
||||
#define Z3_HYBRID_THRESHOLD 3
|
||||
#define Z4_HYBRID_THRESHOLD 3
|
||||
#define I_HYBRID_THRESHOLD 3
|
||||
#define J_HYBRID_THRESHOLD 3
|
||||
#define K_HYBRID_THRESHOLD 3
|
||||
#define E0_HYBRID_THRESHOLD 30
|
||||
#define E1_HYBRID_THRESHOLD 30
|
||||
#define E2_HYBRID_THRESHOLD 30
|
||||
@@ -2797,7 +2892,7 @@
|
||||
*
|
||||
* It is recommended to set HOMING_BUMP_MM to { 0, 0, 0 }.
|
||||
*
|
||||
* SPI_ENDSTOPS *** Beta feature! *** TMC2130 Only ***
|
||||
* SPI_ENDSTOPS *** Beta feature! *** TMC2130/TMC5160 Only ***
|
||||
* Poll the driver through SPI to determine load when homing.
|
||||
* Removes the need for a wire from DIAG1 to an endstop pin.
|
||||
*
|
||||
@@ -2818,6 +2913,9 @@
|
||||
//#define Z2_STALL_SENSITIVITY Z_STALL_SENSITIVITY
|
||||
//#define Z3_STALL_SENSITIVITY Z_STALL_SENSITIVITY
|
||||
//#define Z4_STALL_SENSITIVITY Z_STALL_SENSITIVITY
|
||||
//#define I_STALL_SENSITIVITY 8
|
||||
//#define J_STALL_SENSITIVITY 8
|
||||
//#define K_STALL_SENSITIVITY 8
|
||||
//#define SPI_ENDSTOPS // TMC2130 only
|
||||
//#define IMPROVE_HOMING_RELIABILITY
|
||||
#endif
|
||||
@@ -2958,6 +3056,33 @@
|
||||
#define Z4_SLEW_RATE 1
|
||||
#endif
|
||||
|
||||
#if AXIS_DRIVER_TYPE_I(L6470)
|
||||
#define I_MICROSTEPS 128
|
||||
#define I_OVERCURRENT 2000
|
||||
#define I_STALLCURRENT 1500
|
||||
#define I_MAX_VOLTAGE 127
|
||||
#define I_CHAIN_POS -1
|
||||
#define I_SLEW_RATE 1
|
||||
#endif
|
||||
|
||||
#if AXIS_DRIVER_TYPE_J(L6470)
|
||||
#define J_MICROSTEPS 128
|
||||
#define J_OVERCURRENT 2000
|
||||
#define J_STALLCURRENT 1500
|
||||
#define J_MAX_VOLTAGE 127
|
||||
#define J_CHAIN_POS -1
|
||||
#define J_SLEW_RATE 1
|
||||
#endif
|
||||
|
||||
#if AXIS_DRIVER_TYPE_K(L6470)
|
||||
#define K_MICROSTEPS 128
|
||||
#define K_OVERCURRENT 2000
|
||||
#define K_STALLCURRENT 1500
|
||||
#define K_MAX_VOLTAGE 127
|
||||
#define K_CHAIN_POS -1
|
||||
#define K_SLEW_RATE 1
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_L64XX(E0)
|
||||
#define E0_MICROSTEPS 128
|
||||
#define E0_OVERCURRENT 2000
|
||||
@@ -3166,13 +3291,19 @@
|
||||
//#define AIR_EVACUATION // Cutter Vacuum / Laser Blower motor control with G-codes M10-M11
|
||||
#if ENABLED(AIR_EVACUATION)
|
||||
#define AIR_EVACUATION_ACTIVE LOW // Set to "HIGH" if the on/off function is active HIGH
|
||||
#define AIR_EVACUATION_PIN 42 // Override the default Cutter Vacuum or Laser Blower pin
|
||||
//#define AIR_EVACUATION_PIN 42 // Override the default Cutter Vacuum or Laser Blower pin
|
||||
#endif
|
||||
|
||||
//#define SPINDLE_SERVO // A servo converting an angle to spindle power
|
||||
//#define AIR_ASSIST // Air Assist control with G-codes M8-M9
|
||||
#if ENABLED(AIR_ASSIST)
|
||||
#define AIR_ASSIST_ACTIVE LOW // Active state on air assist pin
|
||||
//#define AIR_ASSIST_PIN 44 // Override the default Air Assist pin
|
||||
#endif
|
||||
|
||||
//#define SPINDLE_SERVO // A servo converting an angle to spindle power
|
||||
#ifdef SPINDLE_SERVO
|
||||
#define SPINDLE_SERVO_NR 0 // Index of servo used for spindle control
|
||||
#define SPINDLE_SERVO_MIN 10 // Minimum angle for servo spindle
|
||||
#define SPINDLE_SERVO_NR 0 // Index of servo used for spindle control
|
||||
#define SPINDLE_SERVO_MIN 10 // Minimum angle for servo spindle
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -3301,8 +3432,18 @@
|
||||
#define SPINDLE_LASER_POWERDOWN_DELAY 50 // (ms) Delay to allow the spindle to stop
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// Laser I2C Ammeter (High precision INA226 low/high side module)
|
||||
//
|
||||
//#define I2C_AMMETER
|
||||
#if ENABLED(I2C_AMMETER)
|
||||
#define I2C_AMMETER_IMAX 0.1 // (Amps) Calibration value for the expected current range
|
||||
#define I2C_AMMETER_SHUNT_RESISTOR 0.1 // (Ohms) Calibration shunt resistor value
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif // SPINDLE_FEATURE || LASER_FEATURE
|
||||
|
||||
/**
|
||||
* Synchronous Laser Control with M106/M107
|
||||
@@ -3409,6 +3550,11 @@
|
||||
*/
|
||||
#define AUTO_REPORT_TEMPERATURES
|
||||
|
||||
/**
|
||||
* Auto-report position with M154 S<seconds>
|
||||
*/
|
||||
//#define AUTO_REPORT_POSITION
|
||||
|
||||
/**
|
||||
* Include capabilities in M115 output
|
||||
*/
|
||||
@@ -3478,7 +3624,7 @@
|
||||
#define PROPORTIONAL_FONT_RATIO 1.0
|
||||
|
||||
/**
|
||||
* Spend 28 bytes of SRAM to optimize the GCode parser
|
||||
* Spend 28 bytes of SRAM to optimize the G-code parser
|
||||
*/
|
||||
#define FASTER_GCODE_PARSER
|
||||
|
||||
@@ -3774,6 +3920,16 @@
|
||||
#define GANTRY_CALIBRATION_COMMANDS_POST "G28" // G28 highly recommended to ensure an accurate position
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Instant freeze / unfreeze functionality
|
||||
* Specified pin has pullup and connecting to ground will instantly pause motion.
|
||||
* Potentially useful for emergency stop that allows being resumed.
|
||||
*/
|
||||
//#define FREEZE_FEATURE
|
||||
#if ENABLED(FREEZE_FEATURE)
|
||||
//#define FREEZE_PIN 41 // Override the default (KILL) pin here
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MAX7219 Debug Matrix
|
||||
*
|
||||
|
@@ -28,7 +28,7 @@
|
||||
/**
|
||||
* Marlin release version identifier
|
||||
*/
|
||||
//#define SHORT_BUILD_VERSION "2.0.8"
|
||||
//#define SHORT_BUILD_VERSION "2.0.9.1"
|
||||
|
||||
/**
|
||||
* Verbose version identifier which should contain a reference to the location
|
||||
@@ -41,7 +41,7 @@
|
||||
* here we define this default string as the date where the latest release
|
||||
* version was tagged.
|
||||
*/
|
||||
//#define STRING_DISTRIBUTION_DATE "2021-04-30"
|
||||
//#define STRING_DISTRIBUTION_DATE "2021-06-27"
|
||||
|
||||
/**
|
||||
* Defines a generic printer name to be output to the LCD after booting Marlin.
|
||||
|
@@ -93,28 +93,35 @@ typedef int8_t pin_t;
|
||||
#define MYSERIAL1 TERN(BLUETOOTH, btSerial, MSerial0)
|
||||
#else
|
||||
#if !WITHIN(SERIAL_PORT, -1, 3)
|
||||
#error "SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#error "SERIAL_PORT must be from 0 to 3, or -1 for USB Serial."
|
||||
#endif
|
||||
#define MYSERIAL1 customizedSerial1
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
#if !WITHIN(SERIAL_PORT_2, -1, 3)
|
||||
#error "SERIAL_PORT_2 must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#error "SERIAL_PORT_2 must be from 0 to 3, or -1 for USB Serial."
|
||||
#endif
|
||||
#define MYSERIAL2 customizedSerial2
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_3
|
||||
#if !WITHIN(SERIAL_PORT_3, -1, 3)
|
||||
#error "SERIAL_PORT_3 must be from 0 to 3, or -1 for USB Serial."
|
||||
#endif
|
||||
#define MYSERIAL3 customizedSerial3
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MMU2_SERIAL_PORT
|
||||
#if !WITHIN(MMU2_SERIAL_PORT, -1, 3)
|
||||
#error "MMU2_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#error "MMU2_SERIAL_PORT must be from 0 to 3, or -1 for USB Serial."
|
||||
#endif
|
||||
#define MMU2_SERIAL mmuSerial
|
||||
#endif
|
||||
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if !WITHIN(LCD_SERIAL_PORT, -1, 3)
|
||||
#error "LCD_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#error "LCD_SERIAL_PORT must be from 0 to 3, or -1 for USB Serial."
|
||||
#endif
|
||||
#define LCD_SERIAL lcdSerial
|
||||
#if HAS_DGUS_LCD
|
||||
@@ -179,7 +186,7 @@ inline void HAL_adc_init() {
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
|
||||
#define HAL_SENSITIVE_PINS 0, 1
|
||||
#define HAL_SENSITIVE_PINS 0, 1,
|
||||
|
||||
#ifdef __AVR_AT90USB1286__
|
||||
#define JTAG_DISABLE() do{ MCUCR = 0x80; MCUCR = 0x80; }while(0)
|
||||
|
@@ -567,7 +567,7 @@ ISR(SERIAL_REGNAME(USART, SERIAL_PORT, _UDRE_vect)) {
|
||||
|
||||
// Because of the template definition above, it's required to instantiate the template to have all methods generated
|
||||
template class MarlinSerial< MarlinSerialCfg<SERIAL_PORT> >;
|
||||
MSerialT customizedSerial1(MSerialT::HasEmergencyParser);
|
||||
MSerialT1 customizedSerial1(MSerialT1::HasEmergencyParser);
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
|
||||
@@ -582,7 +582,24 @@ MSerialT customizedSerial1(MSerialT::HasEmergencyParser);
|
||||
|
||||
template class MarlinSerial< MarlinSerialCfg<SERIAL_PORT_2> >;
|
||||
MSerialT2 customizedSerial2(MSerialT2::HasEmergencyParser);
|
||||
#endif
|
||||
|
||||
#endif // SERIAL_PORT_2
|
||||
|
||||
#ifdef SERIAL_PORT_3
|
||||
|
||||
// Hookup ISR handlers
|
||||
ISR(SERIAL_REGNAME(USART, SERIAL_PORT_3, _RX_vect)) {
|
||||
MarlinSerial<MarlinSerialCfg<SERIAL_PORT_3>>::store_rxd_char();
|
||||
}
|
||||
|
||||
ISR(SERIAL_REGNAME(USART, SERIAL_PORT_3, _UDRE_vect)) {
|
||||
MarlinSerial<MarlinSerialCfg<SERIAL_PORT_3>>::_tx_udr_empty_irq();
|
||||
}
|
||||
|
||||
template class MarlinSerial< MarlinSerialCfg<SERIAL_PORT_3> >;
|
||||
MSerialT3 customizedSerial3(MSerialT3::HasEmergencyParser);
|
||||
|
||||
#endif // SERIAL_PORT_3
|
||||
|
||||
#ifdef MMU2_SERIAL_PORT
|
||||
|
||||
@@ -595,8 +612,9 @@ MSerialT customizedSerial1(MSerialT::HasEmergencyParser);
|
||||
}
|
||||
|
||||
template class MarlinSerial< MMU2SerialCfg<MMU2_SERIAL_PORT> >;
|
||||
MSerialT3 mmuSerial(MSerialT3::HasEmergencyParser);
|
||||
#endif
|
||||
MSerialMMU2 mmuSerial(MSerialMMU2::HasEmergencyParser);
|
||||
|
||||
#endif // MMU2_SERIAL_PORT
|
||||
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
|
||||
@@ -609,7 +627,7 @@ MSerialT customizedSerial1(MSerialT::HasEmergencyParser);
|
||||
}
|
||||
|
||||
template class MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> >;
|
||||
MSerialT4 lcdSerial(MSerialT4::HasEmergencyParser);
|
||||
MSerialLCD lcdSerial(MSerialLCD::HasEmergencyParser);
|
||||
|
||||
#if HAS_DGUS_LCD
|
||||
template<typename Cfg>
|
||||
@@ -622,13 +640,13 @@ MSerialT customizedSerial1(MSerialT::HasEmergencyParser);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif // LCD_SERIAL_PORT
|
||||
|
||||
#endif // !USBCON && (UBRRH || UBRR0H || UBRR1H || UBRR2H || UBRR3H)
|
||||
|
||||
// For AT90USB targets use the UART for BT interfacing
|
||||
#if defined(USBCON) && ENABLED(BLUETOOTH)
|
||||
MSerialT5 bluetoothSerial(false);
|
||||
MSerialBT bluetoothSerial(false);
|
||||
#endif
|
||||
|
||||
#endif // __AVR__
|
||||
|
@@ -238,14 +238,19 @@
|
||||
static constexpr bool MAX_RX_QUEUED = ENABLED(SERIAL_STATS_MAX_RX_QUEUED);
|
||||
};
|
||||
|
||||
typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT> > > MSerialT;
|
||||
extern MSerialT customizedSerial1;
|
||||
typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT> > > MSerialT1;
|
||||
extern MSerialT1 customizedSerial1;
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT_2> > > MSerialT2;
|
||||
extern MSerialT2 customizedSerial2;
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_3
|
||||
typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT_3> > > MSerialT3;
|
||||
extern MSerialT3 customizedSerial3;
|
||||
#endif
|
||||
|
||||
#endif // !USBCON
|
||||
|
||||
#ifdef MMU2_SERIAL_PORT
|
||||
@@ -262,8 +267,8 @@
|
||||
static constexpr bool RX_OVERRUNS = false;
|
||||
};
|
||||
|
||||
typedef Serial1Class< MarlinSerial< MMU2SerialCfg<MMU2_SERIAL_PORT> > > MSerialT3;
|
||||
extern MSerialT3 mmuSerial;
|
||||
typedef Serial1Class< MarlinSerial< MMU2SerialCfg<MMU2_SERIAL_PORT> > > MSerialMMU2;
|
||||
extern MSerialMMU2 mmuSerial;
|
||||
#endif
|
||||
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
@@ -281,12 +286,12 @@
|
||||
static constexpr bool RX_OVERRUNS = BOTH(HAS_DGUS_LCD, SERIAL_STATS_RX_BUFFER_OVERRUNS);
|
||||
};
|
||||
|
||||
typedef Serial1Class< MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> > > MSerialT4;
|
||||
extern MSerialT4 lcdSerial;
|
||||
typedef Serial1Class< MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> > > MSerialLCD;
|
||||
extern MSerialLCD lcdSerial;
|
||||
#endif
|
||||
|
||||
// Use the UART for Bluetooth in AT90USB configurations
|
||||
#if defined(USBCON) && ENABLED(BLUETOOTH)
|
||||
typedef Serial1Class<HardwareSerial> MSerialT5;
|
||||
extern MSerialT5 bluetoothSerial;
|
||||
typedef Serial1Class<HardwareSerial> MSerialBT;
|
||||
extern MSerialBT bluetoothSerial;
|
||||
#endif
|
||||
|
@@ -168,6 +168,51 @@ void setup_endstop_interrupts() {
|
||||
pciSetup(Z_MIN_PIN);
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_I_MAX
|
||||
#if (digitalPinToInterrupt(I_MAX_PIN) != NOT_AN_INTERRUPT)
|
||||
_ATTACH(I_MAX_PIN);
|
||||
#else
|
||||
static_assert(digitalPinHasPCICR(I_MAX_PIN), "I_MAX_PIN is not interrupt-capable");
|
||||
pciSetup(I_MAX_PIN);
|
||||
#endif
|
||||
#elif HAS_I_MIN
|
||||
#if (digitalPinToInterrupt(I_MIN_PIN) != NOT_AN_INTERRUPT)
|
||||
_ATTACH(I_MIN_PIN);
|
||||
#else
|
||||
static_assert(digitalPinHasPCICR(I_MIN_PIN), "I_MIN_PIN is not interrupt-capable");
|
||||
pciSetup(I_MIN_PIN);
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_J_MAX
|
||||
#if (digitalPinToInterrupt(J_MAX_PIN) != NOT_AN_INTERRUPT)
|
||||
_ATTACH(J_MAX_PIN);
|
||||
#else
|
||||
static_assert(digitalPinHasPCICR(J_MAX_PIN), "J_MAX_PIN is not interrupt-capable");
|
||||
pciSetup(J_MAX_PIN);
|
||||
#endif
|
||||
#elif HAS_J_MIN
|
||||
#if (digitalPinToInterrupt(J_MIN_PIN) != NOT_AN_INTERRUPT)
|
||||
_ATTACH(J_MIN_PIN);
|
||||
#else
|
||||
static_assert(digitalPinHasPCICR(J_MIN_PIN), "J_MIN_PIN is not interrupt-capable");
|
||||
pciSetup(J_MIN_PIN);
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_K_MAX
|
||||
#if (digitalPinToInterrupt(K_MAX_PIN) != NOT_AN_INTERRUPT)
|
||||
_ATTACH(K_MAX_PIN);
|
||||
#else
|
||||
static_assert(digitalPinHasPCICR(K_MAX_PIN), "K_MAX_PIN is not interrupt-capable");
|
||||
pciSetup(K_MAX_PIN);
|
||||
#endif
|
||||
#elif HAS_K_MIN
|
||||
#if (digitalPinToInterrupt(K_MIN_PIN) != NOT_AN_INTERRUPT)
|
||||
_ATTACH(K_MIN_PIN);
|
||||
#else
|
||||
static_assert(digitalPinHasPCICR(K_MIN_PIN), "K_MIN_PIN is not interrupt-capable");
|
||||
pciSetup(K_MIN_PIN);
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_X2_MAX
|
||||
#if (digitalPinToInterrupt(X2_MAX_PIN) != NOT_AN_INTERRUPT)
|
||||
_ATTACH(X2_MAX_PIN);
|
||||
@@ -256,6 +301,5 @@ void setup_endstop_interrupts() {
|
||||
pciSetup(Z_MIN_PROBE_PIN);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// If we arrive here without raising an assertion, each pin has either an EXT-interrupt or a PCI.
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@
|
||||
// portModeRegister takes a different argument
|
||||
#define digitalPinToTimer_DEBUG(p) digitalPinToTimer(p)
|
||||
#define digitalPinToBitMask_DEBUG(p) digitalPinToBitMask(p)
|
||||
#define digitalPinToPort_DEBUG(p) digitalPinToPort_Teensy(p)
|
||||
#define digitalPinToPort_DEBUG(p) digitalPinToPort(p)
|
||||
#define GET_PINMODE(pin) (*portModeRegister(pin) & digitalPinToBitMask_DEBUG(pin))
|
||||
|
||||
#elif AVR_ATmega2560_FAMILY_PLUS_70 // So we can access/display all the pins on boards using more than 70
|
||||
|
@@ -50,13 +50,12 @@ extern DefaultSerial4 MSerial3;
|
||||
#define _MSERIAL(X) MSerial##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
|
||||
// Define MYSERIAL1/2 before MarlinSerial includes!
|
||||
#if SERIAL_PORT == -1 || ENABLED(EMERGENCY_PARSER)
|
||||
#define MYSERIAL1 customizedSerial1
|
||||
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
#else
|
||||
#error "The required SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#error "The required SERIAL_PORT must be from 0 to 3, or -1 for USB Serial."
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
@@ -65,7 +64,17 @@ extern DefaultSerial4 MSerial3;
|
||||
#elif WITHIN(SERIAL_PORT_2, 0, 3)
|
||||
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
|
||||
#else
|
||||
#error "SERIAL_PORT_2 must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#error "SERIAL_PORT_2 must be from 0 to 3, or -1 for USB Serial."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_3
|
||||
#if SERIAL_PORT_3 == -1 || ENABLED(EMERGENCY_PARSER)
|
||||
#define MYSERIAL3 customizedSerial3
|
||||
#elif WITHIN(SERIAL_PORT_3, 0, 3)
|
||||
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
|
||||
#else
|
||||
#error "SERIAL_PORT_3 must be from 0 to 3, or -1 for USB Serial."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -78,12 +87,10 @@ extern DefaultSerial4 MSerial3;
|
||||
#endif
|
||||
|
||||
#ifdef LCD_SERIAL_PORT
|
||||
#if LCD_SERIAL_PORT == -1
|
||||
#define LCD_SERIAL lcdSerial
|
||||
#elif WITHIN(LCD_SERIAL_PORT, 0, 3)
|
||||
#if WITHIN(LCD_SERIAL_PORT, 0, 3)
|
||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||
#else
|
||||
#error "LCD_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#error "LCD_SERIAL_PORT must be from 0 to 3."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@@ -478,7 +478,7 @@ void MarlinSerial<Cfg>::flushTX() {
|
||||
// If not using the USB port as serial port
|
||||
#if defined(SERIAL_PORT) && SERIAL_PORT >= 0
|
||||
template class MarlinSerial< MarlinSerialCfg<SERIAL_PORT> >;
|
||||
MSerialT customizedSerial1(MarlinSerialCfg<SERIAL_PORT>::EMERGENCYPARSER);
|
||||
MSerialT1 customizedSerial1(MarlinSerialCfg<SERIAL_PORT>::EMERGENCYPARSER);
|
||||
#endif
|
||||
|
||||
#if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0
|
||||
@@ -486,4 +486,9 @@ void MarlinSerial<Cfg>::flushTX() {
|
||||
MSerialT2 customizedSerial2(MarlinSerialCfg<SERIAL_PORT_2>::EMERGENCYPARSER);
|
||||
#endif
|
||||
|
||||
#if defined(SERIAL_PORT_3) && SERIAL_PORT_3 >= 0
|
||||
template class MarlinSerial< MarlinSerialCfg<SERIAL_PORT_3> >;
|
||||
MSerialT3 customizedSerial3(MarlinSerialCfg<SERIAL_PORT_3>::EMERGENCYPARSER);
|
||||
#endif
|
||||
|
||||
#endif // ARDUINO_ARCH_SAM
|
||||
|
@@ -141,11 +141,16 @@ struct MarlinSerialCfg {
|
||||
};
|
||||
|
||||
#if defined(SERIAL_PORT) && SERIAL_PORT >= 0
|
||||
typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT> > > MSerialT;
|
||||
extern MSerialT customizedSerial1;
|
||||
typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT> > > MSerialT1;
|
||||
extern MSerialT1 customizedSerial1;
|
||||
#endif
|
||||
|
||||
#if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0
|
||||
typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT_2> > > MSerialT2;
|
||||
extern MSerialT2 customizedSerial2;
|
||||
#endif
|
||||
|
||||
#if defined(SERIAL_PORT_3) && SERIAL_PORT_3 >= 0
|
||||
typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT_3> > > MSerialT3;
|
||||
extern MSerialT3 customizedSerial3;
|
||||
#endif
|
||||
|
@@ -19,13 +19,13 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifdef ARDUINO_ARCH_SAM
|
||||
|
||||
/**
|
||||
* MarlinSerial_Due.cpp - Hardware serial library for Arduino DUE
|
||||
* Copyright (c) 2017 Eduardo José Tagle. All right reserved
|
||||
* Based on MarlinSerial for AVR, copyright (c) 2006 Nicholas Zambetti. All right reserved.
|
||||
*/
|
||||
#ifdef ARDUINO_ARCH_SAM
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
@@ -65,7 +65,7 @@ int MarlinSerialUSB::peek() {
|
||||
|
||||
pending_char = udi_cdc_getc();
|
||||
|
||||
TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast<MSerialT*>(this)->emergency_state, (char)pending_char));
|
||||
TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast<MSerialT1*>(this)->emergency_state, (char)pending_char));
|
||||
|
||||
return pending_char;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ int MarlinSerialUSB::read() {
|
||||
|
||||
int c = udi_cdc_getc();
|
||||
|
||||
TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast<MSerialT*>(this)->emergency_state, (char)c));
|
||||
TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast<MSerialT1*>(this)->emergency_state, (char)c));
|
||||
|
||||
return c;
|
||||
}
|
||||
@@ -129,10 +129,13 @@ size_t MarlinSerialUSB::write(const uint8_t c) {
|
||||
|
||||
// Preinstantiate
|
||||
#if SERIAL_PORT == -1
|
||||
MSerialT customizedSerial1(TERN0(EMERGENCY_PARSER, true));
|
||||
MSerialT1 customizedSerial1(TERN0(EMERGENCY_PARSER, true));
|
||||
#endif
|
||||
#if SERIAL_PORT_2 == -1
|
||||
MSerialT customizedSerial2(TERN0(EMERGENCY_PARSER, true));
|
||||
MSerialT2 customizedSerial2(TERN0(EMERGENCY_PARSER, true));
|
||||
#endif
|
||||
#if SERIAL_PORT_3 == -1
|
||||
MSerialT3 customizedSerial3(TERN0(EMERGENCY_PARSER, true));
|
||||
#endif
|
||||
|
||||
#endif // HAS_USB_SERIAL
|
||||
|
@@ -27,11 +27,9 @@
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#if HAS_USB_SERIAL
|
||||
|
||||
#include <WString.h>
|
||||
#include "../../core/serial_hook.h"
|
||||
|
||||
#include <WString.h>
|
||||
|
||||
struct MarlinSerialUSB {
|
||||
void begin(const long);
|
||||
@@ -50,14 +48,18 @@ struct MarlinSerialUSB {
|
||||
FORCE_INLINE int rxMaxEnqueued() { return 0; }
|
||||
#endif
|
||||
};
|
||||
typedef Serial1Class<MarlinSerialUSB> MSerialT;
|
||||
|
||||
#if SERIAL_PORT == -1
|
||||
extern MSerialT customizedSerial1;
|
||||
typedef Serial1Class<MarlinSerialUSB> MSerialT1;
|
||||
extern MSerialT1 customizedSerial1;
|
||||
#endif
|
||||
|
||||
#if SERIAL_PORT_2 == -1
|
||||
extern MSerialT customizedSerial2;
|
||||
typedef Serial1Class<MarlinSerialUSB> MSerialT2;
|
||||
extern MSerialT2 customizedSerial2;
|
||||
#endif
|
||||
|
||||
#endif // HAS_USB_SERIAL
|
||||
#if SERIAL_PORT_3 == -1
|
||||
typedef Serial1Class<MarlinSerialUSB> MSerialT3;
|
||||
extern MSerialT3 customizedSerial3;
|
||||
#endif
|
||||
|
@@ -64,4 +64,10 @@ void setup_endstop_interrupts() {
|
||||
TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
|
||||
TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
|
||||
TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
|
||||
TERN_(HAS_I_MAX, _ATTACH(I_MAX_PIN));
|
||||
TERN_(HAS_I_MIN, _ATTACH(I_MIN_PIN));
|
||||
TERN_(HAS_J_MAX, _ATTACH(J_MAX_PIN));
|
||||
TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN));
|
||||
TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN));
|
||||
TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN));
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@
|
||||
* For ARDUINO_ARCH_SAM
|
||||
* Note the code here was specifically crafted by disassembling what GCC produces
|
||||
* out of it, so GCC is able to optimize it out as much as possible to the least
|
||||
* amount of instructions. Be very carefull if you modify them, as "clean code"
|
||||
* amount of instructions. Be very careful if you modify them, as "clean code"
|
||||
* leads to less efficient compiled code!!
|
||||
*/
|
||||
|
||||
|
@@ -29,7 +29,7 @@
|
||||
#include "wifi.h"
|
||||
#include <ESPAsyncWebServer.h>
|
||||
|
||||
MSerialT webSocketSerial(false);
|
||||
MSerialWebSocketT webSocketSerial(false);
|
||||
AsyncWebSocket ws("/ws"); // TODO Move inside the class.
|
||||
|
||||
// RingBuffer impl
|
||||
|
@@ -81,5 +81,5 @@ public:
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef Serial1Class<WebSocketSerial> MSerialT;
|
||||
extern MSerialT webSocketSerial;
|
||||
typedef Serial1Class<WebSocketSerial> MSerialWebSocketT;
|
||||
extern MSerialWebSocketT webSocketSerial;
|
||||
|
@@ -59,4 +59,10 @@ void setup_endstop_interrupts() {
|
||||
TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
|
||||
TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
|
||||
TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
|
||||
TERN_(HAS_I_MAX, _ATTACH(I_MAX_PIN));
|
||||
TERN_(HAS_I_MIN, _ATTACH(I_MIN_PIN));
|
||||
TERN_(HAS_J_MAX, _ATTACH(J_MAX_PIN));
|
||||
TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN));
|
||||
TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN));
|
||||
TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN));
|
||||
}
|
||||
|
@@ -25,43 +25,6 @@
|
||||
|
||||
#include "../../../gcode/parser.h"
|
||||
|
||||
uint8_t analog_offset = NUM_DIGITAL_PINS - NUM_ANALOG_INPUTS;
|
||||
|
||||
// Get the digital pin for an analog index
|
||||
pin_t analogInputToDigitalPin(const int8_t p) {
|
||||
return (WITHIN(p, 0, NUM_ANALOG_INPUTS) ? analog_offset + p : P_NC);
|
||||
}
|
||||
|
||||
// Return the index of a pin number
|
||||
int16_t GET_PIN_MAP_INDEX(const pin_t pin) {
|
||||
return pin;
|
||||
}
|
||||
|
||||
// Test whether the pin is valid
|
||||
bool VALID_PIN(const pin_t p) {
|
||||
return WITHIN(p, 0, NUM_DIGITAL_PINS);
|
||||
}
|
||||
|
||||
// Get the analog index for a digital pin
|
||||
int8_t DIGITAL_PIN_TO_ANALOG_PIN(const pin_t p) {
|
||||
return (WITHIN(p, analog_offset, NUM_DIGITAL_PINS) ? p - analog_offset : P_NC);
|
||||
}
|
||||
|
||||
// Test whether the pin is PWM
|
||||
bool PWM_PIN(const pin_t p) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Test whether the pin is interruptable
|
||||
bool INTERRUPT_PIN(const pin_t p) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the pin number at the given index
|
||||
pin_t GET_PIN_MAP_PIN(const int16_t ind) {
|
||||
return ind;
|
||||
}
|
||||
|
||||
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) {
|
||||
return parser.intval(code, dval);
|
||||
}
|
||||
|
@@ -34,26 +34,32 @@ constexpr uint8_t NUM_ANALOG_INPUTS = 16;
|
||||
|
||||
#define HAL_SENSITIVE_PINS
|
||||
|
||||
constexpr uint8_t analog_offset = NUM_DIGITAL_PINS - NUM_ANALOG_INPUTS;
|
||||
|
||||
// Get the digital pin for an analog index
|
||||
pin_t analogInputToDigitalPin(const int8_t p);
|
||||
|
||||
// Return the index of a pin number
|
||||
int16_t GET_PIN_MAP_INDEX(const pin_t pin);
|
||||
|
||||
// Test whether the pin is valid
|
||||
bool VALID_PIN(const pin_t p);
|
||||
constexpr pin_t analogInputToDigitalPin(const int8_t p) {
|
||||
return (WITHIN(p, 0, NUM_ANALOG_INPUTS) ? analog_offset + p : P_NC);
|
||||
}
|
||||
|
||||
// Get the analog index for a digital pin
|
||||
int8_t DIGITAL_PIN_TO_ANALOG_PIN(const pin_t p);
|
||||
constexpr int8_t DIGITAL_PIN_TO_ANALOG_PIN(const pin_t p) {
|
||||
return (WITHIN(p, analog_offset, NUM_DIGITAL_PINS) ? p - analog_offset : P_NC);
|
||||
}
|
||||
|
||||
// Return the index of a pin number
|
||||
constexpr int16_t GET_PIN_MAP_INDEX(const pin_t pin) { return pin; }
|
||||
|
||||
// Test whether the pin is valid
|
||||
constexpr bool VALID_PIN(const pin_t p) { return WITHIN(p, 0, NUM_DIGITAL_PINS); }
|
||||
|
||||
// Test whether the pin is PWM
|
||||
bool PWM_PIN(const pin_t p);
|
||||
constexpr bool PWM_PIN(const pin_t p) { return false; }
|
||||
|
||||
// Test whether the pin is interruptable
|
||||
bool INTERRUPT_PIN(const pin_t p);
|
||||
constexpr bool INTERRUPT_PIN(const pin_t p) { return false; }
|
||||
|
||||
// Get the pin number at the given index
|
||||
pin_t GET_PIN_MAP_PIN(const int16_t ind);
|
||||
constexpr pin_t GET_PIN_MAP_PIN(const int16_t ind) { return ind; }
|
||||
|
||||
// Parse a G-code word into a pin index
|
||||
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval);
|
||||
|
@@ -84,6 +84,16 @@ extern DefaultSerial1 USBSerial;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_3
|
||||
#if SERIAL_PORT_3 == -1
|
||||
#define MYSERIAL3 USBSerial
|
||||
#elif WITHIN(SERIAL_PORT_3, 0, 3)
|
||||
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
|
||||
#else
|
||||
#error "SERIAL_PORT_3 must be from 0 to 3. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MMU2_SERIAL_PORT
|
||||
#if MMU2_SERIAL_PORT == -1
|
||||
#define MMU2_SERIAL USBSerial
|
||||
@@ -188,7 +198,7 @@ constexpr pin_t GET_PIN_MAP_PIN(const int16_t index) {
|
||||
// Parse a G-code word into a pin index
|
||||
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval);
|
||||
// P0.6 thru P0.9 are for the onboard SD card
|
||||
#define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09
|
||||
#define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09,
|
||||
|
||||
#define HAL_IDLETASK 1
|
||||
void HAL_idletask();
|
||||
|
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
#ifdef TARGET_LPC1768
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "HAL.h"
|
||||
|
||||
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||
|
@@ -66,11 +66,7 @@
|
||||
|
||||
#include <SoftwareSPI.h>
|
||||
|
||||
#ifndef HAL_SPI_SPEED
|
||||
#define HAL_SPI_SPEED SPI_FULL_SPEED
|
||||
#endif
|
||||
|
||||
static uint8_t SPI_speed = HAL_SPI_SPEED;
|
||||
static uint8_t SPI_speed = SPI_FULL_SPEED;
|
||||
|
||||
static uint8_t spiTransfer(uint8_t b) {
|
||||
return swSpiTransfer(b, SPI_speed, SD_SCK_PIN, SD_MISO_PIN, SD_MOSI_PIN);
|
||||
@@ -106,15 +102,13 @@
|
||||
|
||||
#else
|
||||
|
||||
#ifndef HAL_SPI_SPEED
|
||||
#ifdef SD_SPI_SPEED
|
||||
#define HAL_SPI_SPEED SD_SPI_SPEED
|
||||
#else
|
||||
#define HAL_SPI_SPEED SPI_FULL_SPEED
|
||||
#endif
|
||||
#ifdef SD_SPI_SPEED
|
||||
#define INIT_SPI_SPEED SD_SPI_SPEED
|
||||
#else
|
||||
#define INIT_SPI_SPEED SPI_FULL_SPEED
|
||||
#endif
|
||||
|
||||
void spiBegin() { spiInit(HAL_SPI_SPEED); } // Set up SCK, MOSI & MISO pins for SSP0
|
||||
void spiBegin() { spiInit(INIT_SPI_SPEED); } // Set up SCK, MOSI & MISO pins for SSP0
|
||||
|
||||
void spiInit(uint8_t spiRate) {
|
||||
#if SD_MISO_PIN == BOARD_SPI1_MISO_PIN
|
||||
|
@@ -26,9 +26,9 @@
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if USING_HW_SERIAL0
|
||||
MarlinSerial _MSerial(LPC_UART0);
|
||||
MSerialT MSerial0(true, _MSerial);
|
||||
extern "C" void UART0_IRQHandler() { _MSerial.IRQHandler(); }
|
||||
MarlinSerial _MSerial0(LPC_UART0);
|
||||
MSerialT MSerial0(true, _MSerial0);
|
||||
extern "C" void UART0_IRQHandler() { _MSerial0.IRQHandler(); }
|
||||
#endif
|
||||
#if USING_HW_SERIAL1
|
||||
MarlinSerial _MSerial1((LPC_UART_TypeDef *) LPC_UART1);
|
||||
@@ -52,7 +52,7 @@
|
||||
// Need to figure out which serial port we are and react in consequence (Marlin does not have CONTAINER_OF macro)
|
||||
if (false) {}
|
||||
#if USING_HW_SERIAL0
|
||||
else if (this == &_MSerial) emergency_parser.update(MSerial0.emergency_state, c);
|
||||
else if (this == &_MSerial0) emergency_parser.update(MSerial0.emergency_state, c);
|
||||
#endif
|
||||
#if USING_HW_SERIAL1
|
||||
else if (this == &_MSerial1) emergency_parser.update(MSerial1.emergency_state, c);
|
||||
|
@@ -60,8 +60,8 @@ extern MSerialT MSerial1;
|
||||
extern MSerialT MSerial2;
|
||||
extern MSerialT MSerial3;
|
||||
|
||||
// Consequently, we can't use a RuntimeSerial either. The workaround would be to use a RuntimeSerial<ForwardSerial<MarlinSerial>> type here
|
||||
// Right now, let's ignore this until it's actually required.
|
||||
// Consequently, we can't use a RuntimeSerial either. The workaround would be to use
|
||||
// a RuntimeSerial<ForwardSerial<MarlinSerial>> type here. Ignore for now until it's actually required.
|
||||
#if ENABLED(SERIAL_RUNTIME_HOOK)
|
||||
#error "SERIAL_RUNTIME_HOOK is not yet supported for LPC176x."
|
||||
#endif
|
||||
|
@@ -122,4 +122,37 @@ void setup_endstop_interrupts() {
|
||||
#endif
|
||||
_ATTACH(Z_MIN_PROBE_PIN);
|
||||
#endif
|
||||
#if HAS_I_MAX
|
||||
#if !LPC1768_PIN_INTERRUPT_M(I_MAX_PIN)
|
||||
#error "I_MAX_PIN is not INTERRUPT-capable."
|
||||
#endif
|
||||
_ATTACH(I_MAX_PIN);
|
||||
#elif HAS_I_MIN
|
||||
#if !LPC1768_PIN_INTERRUPT_M(I_MIN_PIN)
|
||||
#error "I_MIN_PIN is not INTERRUPT-capable."
|
||||
#endif
|
||||
_ATTACH(I_MIN_PIN);
|
||||
#endif
|
||||
#if HAS_J_MAX
|
||||
#if !LPC1768_PIN_INTERRUPT_M(J_MAX_PIN)
|
||||
#error "J_MAX_PIN is not INTERRUPT-capable."
|
||||
#endif
|
||||
_ATTACH(J_MAX_PIN);
|
||||
#elif HAS_J_MIN
|
||||
#if !LPC1768_PIN_INTERRUPT_M(J_MIN_PIN)
|
||||
#error "J_MIN_PIN is not INTERRUPT-capable."
|
||||
#endif
|
||||
_ATTACH(J_MIN_PIN);
|
||||
#endif
|
||||
#if HAS_K_MAX
|
||||
#if !LPC1768_PIN_INTERRUPT_M(K_MAX_PIN)
|
||||
#error "K_MAX_PIN is not INTERRUPT-capable."
|
||||
#endif
|
||||
_ATTACH(K_MAX_PIN);
|
||||
#elif HAS_K_MIN
|
||||
#if !LPC1768_PIN_INTERRUPT_M(K_MIN_PIN)
|
||||
#error "K_MIN_PIN is not INTERRUPT-capable."
|
||||
#endif
|
||||
_ATTACH(K_MIN_PIN);
|
||||
#endif
|
||||
}
|
||||
|
@@ -144,7 +144,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
|
||||
#error "Serial port pins (2) conflict with Z4 pins!"
|
||||
#elif ANY_RX(2, X_DIR_PIN, Y_DIR_PIN)
|
||||
#error "Serial port pins (2) conflict with other pins!"
|
||||
#elif Y_HOME_DIR < 0 && IS_TX2(Y_STOP_PIN)
|
||||
#elif Y_HOME_TO_MIN && IS_TX2(Y_STOP_PIN)
|
||||
#error "Serial port pins (2) conflict with Y endstop pin!"
|
||||
#elif HAS_CUSTOM_PROBE_PIN && IS_TX2(Z_MIN_PROBE_PIN)
|
||||
#error "Serial port pins (2) conflict with probe pin!"
|
||||
|
@@ -117,7 +117,7 @@ void HAL_init() {
|
||||
PinCfg.Pinmode = 2; // no pull-up/pull-down
|
||||
PINSEL_ConfigPin(&PinCfg);
|
||||
// now set CLKOUT_EN bit
|
||||
LPC_SC->CLKOUTCFG |= (1<<8);
|
||||
SBI(LPC_SC->CLKOUTCFG, 8);
|
||||
#endif
|
||||
|
||||
USB_Init(); // USB Initialization
|
||||
|
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_TFT_XPT2046 || HAS_TOUCH_BUTTONS
|
||||
#if HAS_TFT_XPT2046 || HAS_RES_TOUCH_BUTTONS
|
||||
|
||||
#include "xpt2046.h"
|
||||
#include <SPI.h>
|
||||
|
@@ -54,7 +54,7 @@ enum XPTCoordinate : uint8_t {
|
||||
XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE,
|
||||
};
|
||||
|
||||
#if !defined(XPT2046_Z1_THRESHOLD)
|
||||
#ifndef XPT2046_Z1_THRESHOLD
|
||||
#define XPT2046_Z1_THRESHOLD 10
|
||||
#endif
|
||||
|
||||
|
@@ -20,101 +20,104 @@ def print_error(e):
|
||||
'or copy the firmware (.pio/build/%s/firmware.bin) manually to the appropriate disk\n' \
|
||||
%(e, env.get('PIOENV')))
|
||||
|
||||
try:
|
||||
#
|
||||
# Find a disk for upload
|
||||
#
|
||||
upload_disk = 'Disk not found'
|
||||
target_file_found = False
|
||||
target_drive_found = False
|
||||
if current_OS == 'Windows':
|
||||
def before_upload(source, target, env):
|
||||
try:
|
||||
#
|
||||
# platformio.ini will accept this for a Windows upload port designation: 'upload_port = L:'
|
||||
# Windows - doesn't care about the disk's name, only cares about the drive letter
|
||||
import subprocess,string
|
||||
from ctypes import windll
|
||||
# Find a disk for upload
|
||||
#
|
||||
upload_disk = 'Disk not found'
|
||||
target_file_found = False
|
||||
target_drive_found = False
|
||||
if current_OS == 'Windows':
|
||||
#
|
||||
# platformio.ini will accept this for a Windows upload port designation: 'upload_port = L:'
|
||||
# Windows - doesn't care about the disk's name, only cares about the drive letter
|
||||
import subprocess,string
|
||||
from ctypes import windll
|
||||
|
||||
# getting list of drives
|
||||
# https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python
|
||||
drives = []
|
||||
bitmask = windll.kernel32.GetLogicalDrives()
|
||||
for letter in string.ascii_uppercase:
|
||||
if bitmask & 1:
|
||||
drives.append(letter)
|
||||
bitmask >>= 1
|
||||
# getting list of drives
|
||||
# https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python
|
||||
drives = []
|
||||
bitmask = windll.kernel32.GetLogicalDrives()
|
||||
for letter in string.ascii_uppercase:
|
||||
if bitmask & 1:
|
||||
drives.append(letter)
|
||||
bitmask >>= 1
|
||||
|
||||
for drive in drives:
|
||||
final_drive_name = drive + ':\\'
|
||||
# print ('disc check: {}'.format(final_drive_name))
|
||||
try:
|
||||
volume_info = str(subprocess.check_output('cmd /C dir ' + final_drive_name, stderr=subprocess.STDOUT))
|
||||
except Exception as e:
|
||||
print ('error:{}'.format(e))
|
||||
continue
|
||||
else:
|
||||
if target_drive in volume_info and not target_file_found: # set upload if not found target file yet
|
||||
target_drive_found = True
|
||||
upload_disk = final_drive_name
|
||||
if target_filename in volume_info:
|
||||
if not target_file_found:
|
||||
for drive in drives:
|
||||
final_drive_name = drive + ':\\'
|
||||
# print ('disc check: {}'.format(final_drive_name))
|
||||
try:
|
||||
volume_info = str(subprocess.check_output('cmd /C dir ' + final_drive_name, stderr=subprocess.STDOUT))
|
||||
except Exception as e:
|
||||
print ('error:{}'.format(e))
|
||||
continue
|
||||
else:
|
||||
if target_drive in volume_info and not target_file_found: # set upload if not found target file yet
|
||||
target_drive_found = True
|
||||
upload_disk = final_drive_name
|
||||
target_file_found = True
|
||||
if target_filename in volume_info:
|
||||
if not target_file_found:
|
||||
upload_disk = final_drive_name
|
||||
target_file_found = True
|
||||
|
||||
elif current_OS == 'Linux':
|
||||
#
|
||||
# platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive'
|
||||
#
|
||||
drives = os.listdir(os.path.join(os.sep, 'media', getpass.getuser()))
|
||||
if target_drive in drives: # If target drive is found, use it.
|
||||
target_drive_found = True
|
||||
upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), target_drive) + os.sep
|
||||
else:
|
||||
elif current_OS == 'Linux':
|
||||
#
|
||||
# platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive'
|
||||
#
|
||||
drives = os.listdir(os.path.join(os.sep, 'media', getpass.getuser()))
|
||||
if target_drive in drives: # If target drive is found, use it.
|
||||
target_drive_found = True
|
||||
upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), target_drive) + os.sep
|
||||
else:
|
||||
for drive in drives:
|
||||
try:
|
||||
files = os.listdir(os.path.join(os.sep, 'media', getpass.getuser(), drive))
|
||||
except:
|
||||
continue
|
||||
else:
|
||||
if target_filename in files:
|
||||
upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), drive) + os.sep
|
||||
target_file_found = True
|
||||
break
|
||||
#
|
||||
# set upload_port to drive if found
|
||||
#
|
||||
|
||||
if target_file_found or target_drive_found:
|
||||
env.Replace(
|
||||
UPLOAD_FLAGS="-P$UPLOAD_PORT"
|
||||
)
|
||||
|
||||
elif current_OS == 'Darwin': # MAC
|
||||
#
|
||||
# platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive'
|
||||
#
|
||||
drives = os.listdir('/Volumes') # human readable names
|
||||
if target_drive in drives and not target_file_found: # set upload if not found target file yet
|
||||
target_drive_found = True
|
||||
upload_disk = '/Volumes/' + target_drive + '/'
|
||||
for drive in drives:
|
||||
try:
|
||||
files = os.listdir(os.path.join(os.sep, 'media', getpass.getuser(), drive))
|
||||
filenames = os.listdir('/Volumes/' + drive + '/') # will get an error if the drive is protected
|
||||
except:
|
||||
continue
|
||||
else:
|
||||
if target_filename in files:
|
||||
upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), drive) + os.sep
|
||||
if target_filename in filenames:
|
||||
if not target_file_found:
|
||||
upload_disk = '/Volumes/' + drive + '/'
|
||||
target_file_found = True
|
||||
break
|
||||
#
|
||||
# set upload_port to drive if found
|
||||
#
|
||||
|
||||
#
|
||||
# Set upload_port to drive if found
|
||||
#
|
||||
if target_file_found or target_drive_found:
|
||||
env.Replace(
|
||||
UPLOAD_FLAGS="-P$UPLOAD_PORT"
|
||||
)
|
||||
env.Replace(UPLOAD_PORT=upload_disk)
|
||||
print('\nUpload disk: ', upload_disk, '\n')
|
||||
else:
|
||||
print_error('Autodetect Error')
|
||||
|
||||
elif current_OS == 'Darwin': # MAC
|
||||
#
|
||||
# platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive'
|
||||
#
|
||||
drives = os.listdir('/Volumes') # human readable names
|
||||
if target_drive in drives and not target_file_found: # set upload if not found target file yet
|
||||
target_drive_found = True
|
||||
upload_disk = '/Volumes/' + target_drive + '/'
|
||||
for drive in drives:
|
||||
try:
|
||||
filenames = os.listdir('/Volumes/' + drive + '/') # will get an error if the drive is protected
|
||||
except:
|
||||
continue
|
||||
else:
|
||||
if target_filename in filenames:
|
||||
if not target_file_found:
|
||||
upload_disk = '/Volumes/' + drive + '/'
|
||||
target_file_found = True
|
||||
except Exception as e:
|
||||
print_error(str(e))
|
||||
|
||||
#
|
||||
# Set upload_port to drive if found
|
||||
#
|
||||
if target_file_found or target_drive_found:
|
||||
env.Replace(UPLOAD_PORT=upload_disk)
|
||||
print('\nUpload disk: ', upload_disk, '\n')
|
||||
else:
|
||||
print_error('Autodetect Error')
|
||||
|
||||
except Exception as e:
|
||||
print_error(str(e))
|
||||
env.AddPreAction("upload", before_upload)
|
||||
|
@@ -43,8 +43,6 @@
|
||||
extern DefaultSerial4 MSerial3;
|
||||
extern DefaultSerial5 MSerial4;
|
||||
|
||||
// MYSERIAL1 required before MarlinSerial includes!
|
||||
|
||||
#define __MSERIAL(X) MSerial##X
|
||||
#define _MSERIAL(X) __MSERIAL(X)
|
||||
#define MSERIAL(X) _MSERIAL(INCREMENT(X))
|
||||
|
@@ -47,80 +47,38 @@
|
||||
|
||||
#include "../../module/endstops.h"
|
||||
|
||||
#define MATCH_EILINE(P1,P2) (P1 != P2 && PIN_TO_EILINE(P1) == PIN_TO_EILINE(P2))
|
||||
#if HAS_X_MAX
|
||||
#define MATCH_X_MAX_EILINE(P) MATCH_EILINE(P, X_MAX_PIN)
|
||||
#else
|
||||
#define MATCH_X_MAX_EILINE(P) false
|
||||
#endif
|
||||
#if HAS_X_MIN
|
||||
#define MATCH_X_MIN_EILINE(P) MATCH_EILINE(P, X_MIN_PIN)
|
||||
#else
|
||||
#define MATCH_X_MIN_EILINE(P) false
|
||||
#endif
|
||||
#if HAS_Y_MAX
|
||||
#define MATCH_Y_MAX_EILINE(P) MATCH_EILINE(P, Y_MAX_PIN)
|
||||
#else
|
||||
#define MATCH_Y_MAX_EILINE(P) false
|
||||
#endif
|
||||
#if HAS_Y_MIN
|
||||
#define MATCH_Y_MIN_EILINE(P) MATCH_EILINE(P, Y_MIN_PIN)
|
||||
#else
|
||||
#define MATCH_Y_MIN_EILINE(P) false
|
||||
#endif
|
||||
#if HAS_Z_MAX
|
||||
#define MATCH_Z_MAX_EILINE(P) MATCH_EILINE(P, Z_MAX_PIN)
|
||||
#else
|
||||
#define MATCH_Z_MAX_EILINE(P) false
|
||||
#endif
|
||||
#if HAS_Z_MIN
|
||||
#define MATCH_Z_MIN_EILINE(P) MATCH_EILINE(P, Z_MIN_PIN)
|
||||
#else
|
||||
#define MATCH_Z_MIN_EILINE(P) false
|
||||
#endif
|
||||
#if HAS_Z2_MAX
|
||||
#define MATCH_Z2_MAX_EILINE(P) MATCH_EILINE(P, Z2_MAX_PIN)
|
||||
#else
|
||||
#define MATCH_Z2_MAX_EILINE(P) false
|
||||
#endif
|
||||
#if HAS_Z2_MIN
|
||||
#define MATCH_Z2_MIN_EILINE(P) MATCH_EILINE(P, Z2_MIN_PIN)
|
||||
#else
|
||||
#define MATCH_Z2_MIN_EILINE(P) false
|
||||
#endif
|
||||
#if HAS_Z3_MAX
|
||||
#define MATCH_Z3_MAX_EILINE(P) MATCH_EILINE(P, Z3_MAX_PIN)
|
||||
#else
|
||||
#define MATCH_Z3_MAX_EILINE(P) false
|
||||
#endif
|
||||
#if HAS_Z3_MIN
|
||||
#define MATCH_Z3_MIN_EILINE(P) MATCH_EILINE(P, Z3_MIN_PIN)
|
||||
#else
|
||||
#define MATCH_Z3_MIN_EILINE(P) false
|
||||
#endif
|
||||
#if HAS_Z4_MAX
|
||||
#define MATCH_Z4_MAX_EILINE(P) MATCH_EILINE(P, Z4_MAX_PIN)
|
||||
#else
|
||||
#define MATCH_Z4_MAX_EILINE(P) false
|
||||
#endif
|
||||
#if HAS_Z4_MIN
|
||||
#define MATCH_Z4_MIN_EILINE(P) MATCH_EILINE(P, Z4_MIN_PIN)
|
||||
#else
|
||||
#define MATCH_Z4_MIN_EILINE(P) false
|
||||
#endif
|
||||
#if HAS_Z_MIN_PROBE_PIN
|
||||
#define MATCH_Z_MIN_PROBE_EILINE(P) MATCH_EILINE(P, Z_MIN_PROBE_PIN)
|
||||
#else
|
||||
#define MATCH_Z_MIN_PROBE_EILINE(P) false
|
||||
#endif
|
||||
#define AVAILABLE_EILINE(P) (PIN_TO_EILINE(P) != -1 \
|
||||
&& !MATCH_X_MAX_EILINE(P) && !MATCH_X_MIN_EILINE(P) \
|
||||
&& !MATCH_Y_MAX_EILINE(P) && !MATCH_Y_MIN_EILINE(P) \
|
||||
&& !MATCH_Z_MAX_EILINE(P) && !MATCH_Z_MIN_EILINE(P) \
|
||||
&& !MATCH_Z2_MAX_EILINE(P) && !MATCH_Z2_MIN_EILINE(P) \
|
||||
&& !MATCH_Z3_MAX_EILINE(P) && !MATCH_Z3_MIN_EILINE(P) \
|
||||
&& !MATCH_Z4_MAX_EILINE(P) && !MATCH_Z4_MIN_EILINE(P) \
|
||||
&& !MATCH_Z_MIN_PROBE_EILINE(P))
|
||||
#define MATCH_EILINE(P1,P2) (P1 != P2 && PIN_TO_EILINE(P1) == PIN_TO_EILINE(P2))
|
||||
#define MATCH_X_MAX_EILINE(P) TERN0(HAS_X_MAX, DEFER4(MATCH_EILINE)(P, X_MAX_PIN))
|
||||
#define MATCH_X_MIN_EILINE(P) TERN0(HAS_X_MIN, DEFER4(MATCH_EILINE)(P, X_MIN_PIN))
|
||||
#define MATCH_Y_MAX_EILINE(P) TERN0(HAS_Y_MAX, DEFER4(MATCH_EILINE)(P, Y_MAX_PIN))
|
||||
#define MATCH_Y_MIN_EILINE(P) TERN0(HAS_Y_MIN, DEFER4(MATCH_EILINE)(P, Y_MIN_PIN))
|
||||
#define MATCH_Z_MAX_EILINE(P) TERN0(HAS_Z_MAX, DEFER4(MATCH_EILINE)(P, Z_MAX_PIN))
|
||||
#define MATCH_Z_MIN_EILINE(P) TERN0(HAS_Z_MIN, DEFER4(MATCH_EILINE)(P, Z_MIN_PIN))
|
||||
#define MATCH_I_MAX_EILINE(P) TERN0(HAS_I_MAX, DEFER4(MATCH_EILINE)(P, I_MAX_PIN))
|
||||
#define MATCH_I_MIN_EILINE(P) TERN0(HAS_I_MIN, DEFER4(MATCH_EILINE)(P, I_MIN_PIN))
|
||||
#define MATCH_J_MAX_EILINE(P) TERN0(HAS_J_MAX, DEFER4(MATCH_EILINE)(P, J_MAX_PIN))
|
||||
#define MATCH_J_MIN_EILINE(P) TERN0(HAS_J_MIN, DEFER4(MATCH_EILINE)(P, J_MIN_PIN))
|
||||
#define MATCH_K_MAX_EILINE(P) TERN0(HAS_K_MAX, DEFER4(MATCH_EILINE)(P, K_MAX_PIN))
|
||||
#define MATCH_K_MIN_EILINE(P) TERN0(HAS_K_MIN, DEFER4(MATCH_EILINE)(P, K_MIN_PIN))
|
||||
#define MATCH_Z2_MAX_EILINE(P) TERN0(HAS_Z2_MAX, DEFER4(MATCH_EILINE)(P, Z2_MAX_PIN))
|
||||
#define MATCH_Z2_MIN_EILINE(P) TERN0(HAS_Z2_MIN, DEFER4(MATCH_EILINE)(P, Z2_MIN_PIN))
|
||||
#define MATCH_Z3_MAX_EILINE(P) TERN0(HAS_Z3_MAX, DEFER4(MATCH_EILINE)(P, Z3_MAX_PIN))
|
||||
#define MATCH_Z3_MIN_EILINE(P) TERN0(HAS_Z3_MIN, DEFER4(MATCH_EILINE)(P, Z3_MIN_PIN))
|
||||
#define MATCH_Z4_MAX_EILINE(P) TERN0(HAS_Z4_MAX, DEFER4(MATCH_EILINE)(P, Z4_MAX_PIN))
|
||||
#define MATCH_Z4_MIN_EILINE(P) TERN0(HAS_Z4_MIN, DEFER4(MATCH_EILINE)(P, Z4_MIN_PIN))
|
||||
#define MATCH_Z_MIN_PROBE_EILINE(P) TERN0(HAS_Z_MIN_PROBE_PIN, DEFER4(MATCH_EILINE)(P, Z_MIN_PROBE_PIN))
|
||||
|
||||
#define AVAILABLE_EILINE(P) ( PIN_TO_EILINE(P) != -1 \
|
||||
&& !MATCH_X_MAX_EILINE(P) && !MATCH_X_MIN_EILINE(P) \
|
||||
&& !MATCH_Y_MAX_EILINE(P) && !MATCH_Y_MIN_EILINE(P) \
|
||||
&& !MATCH_Z_MAX_EILINE(P) && !MATCH_Z_MIN_EILINE(P) \
|
||||
&& !MATCH_I_MAX_EILINE(P) && !MATCH_I_MIN_EILINE(P) \
|
||||
&& !MATCH_J_MAX_EILINE(P) && !MATCH_J_MIN_EILINE(P) \
|
||||
&& !MATCH_K_MAX_EILINE(P) && !MATCH_K_MIN_EILINE(P) \
|
||||
&& !MATCH_Z2_MAX_EILINE(P) && !MATCH_Z2_MIN_EILINE(P) \
|
||||
&& !MATCH_Z3_MAX_EILINE(P) && !MATCH_Z3_MIN_EILINE(P) \
|
||||
&& !MATCH_Z4_MAX_EILINE(P) && !MATCH_Z4_MIN_EILINE(P) \
|
||||
&& !MATCH_Z_MIN_PROBE_EILINE(P) )
|
||||
|
||||
// One ISR for all EXT-Interrupts
|
||||
void endstop_ISR() { endstops.update(); }
|
||||
@@ -204,5 +162,37 @@ void setup_endstop_interrupts() {
|
||||
#error "Z_MIN_PROBE_PIN has no EXTINT line available."
|
||||
#endif
|
||||
_ATTACH(Z_MIN_PROBE_PIN);
|
||||
#elif HAS_I_MAX
|
||||
#if !AVAILABLE_EILINE(I_MAX_PIN)
|
||||
#error "I_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(I_MAX_PIN, endstop_ISR, CHANGE);
|
||||
#elif HAS_I_MIN
|
||||
#if !AVAILABLE_EILINE(I_MIN_PIN)
|
||||
#error "I_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(I_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_J_MAX
|
||||
#if !AVAILABLE_EILINE(J_MAX_PIN)
|
||||
#error "J_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(J_MAX_PIN, endstop_ISR, CHANGE);
|
||||
#elif HAS_J_MIN
|
||||
#if !AVAILABLE_EILINE(J_MIN_PIN)
|
||||
#error "J_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(J_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_K_MAX
|
||||
#if !AVAILABLE_EILINE(K_MAX_PIN)
|
||||
#error "K_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(K_MAX_PIN, endstop_ISR, CHANGE);
|
||||
#elif HAS_K_MIN
|
||||
#if !AVAILABLE_EILINE(K_MIN_PIN)
|
||||
#error "K_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(K_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
@@ -96,6 +96,12 @@ void HAL_init() {
|
||||
#if HAS_SD_HOST_DRIVE
|
||||
MSC_SD_init(); // Enable USB SD card access
|
||||
#endif
|
||||
|
||||
#if PIN_EXISTS(USB_CONNECT)
|
||||
OUT_WRITE(USB_CONNECT_PIN, !USB_CONNECT_INVERTING); // USB clear connection
|
||||
delay(1000); // Give OS time to notice
|
||||
WRITE(USB_CONNECT_PIN, USB_CONNECT_INVERTING);
|
||||
#endif
|
||||
}
|
||||
|
||||
// HAL idle task
|
||||
|
@@ -37,6 +37,9 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//
|
||||
// Serial Ports
|
||||
//
|
||||
#ifdef USBCON
|
||||
#include <USBSerial.h>
|
||||
#include "../../core/serial_hook.h"
|
||||
@@ -44,9 +47,6 @@
|
||||
extern DefaultSerial1 MSerial0;
|
||||
#endif
|
||||
|
||||
// ------------------------
|
||||
// Defines
|
||||
// ------------------------
|
||||
#define _MSERIAL(X) MSerial##X
|
||||
#define MSERIAL(X) _MSERIAL(X)
|
||||
|
||||
@@ -68,6 +68,16 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_3
|
||||
#if SERIAL_PORT_3 == -1
|
||||
#define MYSERIAL3 MSerial0
|
||||
#elif WITHIN(SERIAL_PORT_3, 1, 6)
|
||||
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
|
||||
#else
|
||||
#error "SERIAL_PORT_3 must be from 1 to 6. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MMU2_SERIAL_PORT
|
||||
#if MMU2_SERIAL_PORT == -1
|
||||
#define MMU2_SERIAL MSerial0
|
||||
@@ -185,6 +195,7 @@ uint16_t HAL_adc_get_result();
|
||||
#ifdef STM32F1xx
|
||||
#define JTAG_DISABLE() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_JTAGDISABLE)
|
||||
#define JTAGSWD_DISABLE() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_DISABLE)
|
||||
#define JTAGSWD_RESET() AFIO_DBGAFR_CONFIG(AFIO_MAPR_SWJ_CFG_RESET); // Reset: FULL SWD+JTAG
|
||||
#endif
|
||||
|
||||
#define PLATFORM_M997_SUPPORT
|
||||
|
@@ -71,8 +71,8 @@ static void TXBegin() {
|
||||
volatile uint32_t ICER[32];
|
||||
};
|
||||
|
||||
NVICMin * nvicBase = (NVICMin*)0xE000E100;
|
||||
nvicBase->ICER[nvicIndex / 32] |= _BV32(nvicIndex % 32);
|
||||
NVICMin *nvicBase = (NVICMin*)0xE000E100;
|
||||
SBI32(nvicBase->ICER[nvicIndex >> 5], nvicIndex & 0x1F);
|
||||
|
||||
// We NEED memory barriers to ensure Interrupts are actually disabled!
|
||||
// ( https://dzone.com/articles/nvic-disabling-interrupts-on-arm-cortex-m-and-the )
|
||||
|
@@ -163,11 +163,9 @@ static SPISettings spiConfig;
|
||||
}
|
||||
spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0);
|
||||
|
||||
#if ENABLED(CUSTOM_SPI_PINS)
|
||||
SPI.setMISO(SD_MISO_PIN);
|
||||
SPI.setMOSI(SD_MOSI_PIN);
|
||||
SPI.setSCLK(SD_SCK_PIN);
|
||||
#endif
|
||||
SPI.setMISO(SD_MISO_PIN);
|
||||
SPI.setMOSI(SD_MOSI_PIN);
|
||||
SPI.setSCLK(SD_SCK_PIN);
|
||||
|
||||
SPI.begin();
|
||||
}
|
||||
|
82
Marlin/src/HAL/STM32/eeprom_bl24cxx.cpp
Normal file
82
Marlin/src/HAL/STM32/eeprom_bl24cxx.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
#ifdef STM32F1
|
||||
|
||||
/**
|
||||
* PersistentStore for Arduino-style EEPROM interface
|
||||
* with simple implementations supplied by Marlin.
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(IIC_BL24CXX_EEPROM)
|
||||
|
||||
#include "../shared/eeprom_if.h"
|
||||
#include "../shared/eeprom_api.h"
|
||||
|
||||
//
|
||||
// PersistentStore
|
||||
//
|
||||
|
||||
#ifndef MARLIN_EEPROM_SIZE
|
||||
#error "MARLIN_EEPROM_SIZE is required for IIC_BL24CXX_EEPROM."
|
||||
#endif
|
||||
|
||||
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }
|
||||
|
||||
bool PersistentStore::access_start() { eeprom_init(); return true; }
|
||||
bool PersistentStore::access_finish() { return true; }
|
||||
|
||||
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
|
||||
uint16_t written = 0;
|
||||
while (size--) {
|
||||
uint8_t v = *value;
|
||||
uint8_t * const p = (uint8_t * const)pos;
|
||||
if (v != eeprom_read_byte(p)) { // EEPROM has only ~100,000 write cycles, so only write bytes that have changed!
|
||||
eeprom_write_byte(p, v);
|
||||
if (++written & 0x7F) delay(2); else safe_delay(2); // Avoid triggering watchdog during long EEPROM writes
|
||||
if (eeprom_read_byte(p) != v) {
|
||||
SERIAL_ECHO_MSG(STR_ERR_EEPROM_WRITE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
crc16(crc, &v, 1);
|
||||
pos++;
|
||||
value++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
||||
do {
|
||||
uint8_t * const p = (uint8_t * const)pos;
|
||||
uint8_t c = eeprom_read_byte(p);
|
||||
if (writing) *value = c;
|
||||
crc16(crc, &c, 1);
|
||||
pos++;
|
||||
value++;
|
||||
} while (--size);
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // IIC_BL24CXX_EEPROM
|
||||
#endif // STM32F1
|
@@ -28,6 +28,10 @@
|
||||
|
||||
#include "../shared/eeprom_api.h"
|
||||
|
||||
// Better: "utility/stm32_eeprom.h", but only after updating stm32duino to 2.0.0
|
||||
// Use EEPROM.h for compatibility, for now.
|
||||
#include <EEPROM.h>
|
||||
|
||||
/**
|
||||
* The STM32 HAL supports chips that deal with "pages" and some with "sectors" and some that
|
||||
* even have multiple "banks" of flash.
|
||||
|
54
Marlin/src/HAL/STM32/eeprom_if_iic.cpp
Normal file
54
Marlin/src/HAL/STM32/eeprom_if_iic.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Platform-independent Arduino functions for I2C EEPROM.
|
||||
* Enable USE_SHARED_EEPROM if not supplied by the framework.
|
||||
*/
|
||||
|
||||
#ifdef STM32F1
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(IIC_BL24CXX_EEPROM)
|
||||
|
||||
#include "../../libs/BL24CXX.h"
|
||||
#include "../shared/eeprom_if.h"
|
||||
|
||||
void eeprom_init() { BL24CXX::init(); }
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// ------------------------
|
||||
|
||||
void eeprom_write_byte(uint8_t *pos, uint8_t value) {
|
||||
const unsigned eeprom_address = (unsigned)pos;
|
||||
return BL24CXX::writeOneByte(eeprom_address, value);
|
||||
}
|
||||
|
||||
uint8_t eeprom_read_byte(uint8_t *pos) {
|
||||
const unsigned eeprom_address = (unsigned)pos;
|
||||
return BL24CXX::readOneByte(eeprom_address);
|
||||
}
|
||||
|
||||
#endif // IIC_BL24CXX_EEPROM
|
||||
#endif // STM32F1
|
@@ -46,4 +46,10 @@ void setup_endstop_interrupts() {
|
||||
TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
|
||||
TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
|
||||
TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
|
||||
TERN_(HAS_I_MAX, _ATTACH(I_MAX_PIN));
|
||||
TERN_(HAS_I_MIN, _ATTACH(I_MIN_PIN));
|
||||
TERN_(HAS_J_MAX, _ATTACH(J_MAX_PIN));
|
||||
TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN));
|
||||
TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN));
|
||||
TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN));
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if defined(USBD_USE_CDC_MSC) && DISABLED(NO_SD_HOST_DRIVE)
|
||||
#if BOTH(SDSUPPORT, USBD_USE_CDC_MSC) && DISABLED(NO_SD_HOST_DRIVE)
|
||||
#define HAS_SD_HOST_DRIVE 1
|
||||
#endif
|
||||
|
||||
@@ -30,3 +30,6 @@
|
||||
#undef F_CPU
|
||||
#define F_CPU BOARD_F_CPU
|
||||
#endif
|
||||
|
||||
// The Sensitive Pins array is not optimizable
|
||||
#define RUNTIME_ONLY_ANALOG_TO_DIGITAL
|
||||
|
@@ -33,12 +33,12 @@ public:
|
||||
DiskIODriver* diskIODriver() {
|
||||
#if ENABLED(MULTI_VOLUME)
|
||||
#if SHARED_VOLUME_IS(SD_ONBOARD)
|
||||
return &card.media_sd_spi;
|
||||
return &card.media_driver_sdcard;
|
||||
#elif SHARED_VOLUME_IS(USB_FLASH_DRIVE)
|
||||
return &card.media_usbFlashDrive;
|
||||
return &card.media_driver_usbFlash;
|
||||
#endif
|
||||
#else
|
||||
return diskIODriver();
|
||||
return card.diskIODriver();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
202
Marlin/src/HAL/STM32/tft/gt911.cpp
Normal file
202
Marlin/src/HAL/STM32/tft/gt911.cpp
Normal file
@@ -0,0 +1,202 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(TFT_TOUCH_DEVICE_GT911)
|
||||
|
||||
#include "gt911.h"
|
||||
#include "pinconfig.h"
|
||||
|
||||
SW_IIC::SW_IIC(uint16_t sda, uint16_t scl) {
|
||||
scl_pin = scl;
|
||||
sda_pin = sda;
|
||||
}
|
||||
|
||||
// Software I2C hardware io init
|
||||
void SW_IIC::init() {
|
||||
OUT_WRITE(scl_pin, HIGH);
|
||||
OUT_WRITE(sda_pin, HIGH);
|
||||
}
|
||||
|
||||
// Software I2C start signal
|
||||
void SW_IIC::start() {
|
||||
write_sda(HIGH); // SDA = 1
|
||||
write_scl(HIGH); // SCL = 1
|
||||
iic_delay(2);
|
||||
write_sda(LOW); // SDA = 0
|
||||
iic_delay(1);
|
||||
write_scl(LOW); // SCL = 0 // keep SCL low, avoid false stop caused by level jump caused by SDA switching IN/OUT
|
||||
}
|
||||
|
||||
// Software I2C stop signal
|
||||
void SW_IIC::stop() {
|
||||
write_scl(LOW); // SCL = 0
|
||||
iic_delay(2);
|
||||
write_sda(LOW); // SDA = 0
|
||||
iic_delay(2);
|
||||
write_scl(HIGH); // SCL = 1
|
||||
iic_delay(2);
|
||||
write_sda(HIGH); // SDA = 1
|
||||
}
|
||||
|
||||
// Software I2C sends ACK or NACK signal
|
||||
void SW_IIC::send_ack(bool ack) {
|
||||
write_sda(ack ? LOW : HIGH); // SDA = !ack
|
||||
iic_delay(2);
|
||||
write_scl(HIGH); // SCL = 1
|
||||
iic_delay(2);
|
||||
write_scl(LOW); // SCL = 0
|
||||
}
|
||||
|
||||
// Software I2C read ACK or NACK signal
|
||||
bool SW_IIC::read_ack() {
|
||||
bool error = 0;
|
||||
set_sda_in();
|
||||
|
||||
iic_delay(2);
|
||||
|
||||
write_scl(HIGH); // SCL = 1
|
||||
error = read_sda();
|
||||
|
||||
iic_delay(2);
|
||||
|
||||
write_scl(LOW); // SCL = 0
|
||||
|
||||
set_sda_out();
|
||||
return error;
|
||||
}
|
||||
|
||||
void SW_IIC::send_byte(uint8_t txd) {
|
||||
LOOP_L_N(i, 8) {
|
||||
write_sda(txd & 0x80); // write data bit
|
||||
txd <<= 1;
|
||||
iic_delay(1);
|
||||
write_scl(HIGH); // SCL = 1
|
||||
iic_delay(2);
|
||||
write_scl(LOW); // SCL = 0
|
||||
iic_delay(1);
|
||||
}
|
||||
|
||||
read_ack(); // wait ack
|
||||
}
|
||||
|
||||
uint8_t SW_IIC::read_byte(bool ack) {
|
||||
uint8_t data = 0;
|
||||
|
||||
set_sda_in();
|
||||
LOOP_L_N(i, 8) {
|
||||
write_scl(HIGH); // SCL = 1
|
||||
iic_delay(1);
|
||||
data <<= 1;
|
||||
if (read_sda()) data++;
|
||||
write_scl(LOW); // SCL = 0
|
||||
iic_delay(2);
|
||||
}
|
||||
set_sda_out();
|
||||
|
||||
send_ack(ack);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
GT911_REG_MAP GT911::reg;
|
||||
SW_IIC GT911::sw_iic = SW_IIC(GT911_SW_I2C_SDA_PIN, GT911_SW_I2C_SCL_PIN);
|
||||
|
||||
void GT911::write_reg(uint16_t reg, uint8_t reg_len, uint8_t* w_data, uint8_t w_len) {
|
||||
sw_iic.start();
|
||||
sw_iic.send_byte(gt911_slave_address); // Set IIC Slave address
|
||||
LOOP_L_N(i, reg_len) { // Set reg address
|
||||
uint8_t r = (reg >> (8 * (reg_len - 1 - i))) & 0xFF;
|
||||
sw_iic.send_byte(r);
|
||||
}
|
||||
|
||||
LOOP_L_N(i, w_len) { // Write data to reg
|
||||
sw_iic.send_byte(w_data[i]);
|
||||
}
|
||||
sw_iic.stop();
|
||||
}
|
||||
|
||||
void GT911::read_reg(uint16_t reg, uint8_t reg_len, uint8_t* r_data, uint8_t r_len) {
|
||||
sw_iic.start();
|
||||
sw_iic.send_byte(gt911_slave_address); // Set IIC Slave address
|
||||
LOOP_L_N(i, reg_len) { // Set reg address
|
||||
uint8_t r = (reg >> (8 * (reg_len - 1 - i))) & 0xFF;
|
||||
sw_iic.send_byte(r);
|
||||
}
|
||||
|
||||
sw_iic.start();
|
||||
sw_iic.send_byte(gt911_slave_address + 1); // Set read mode
|
||||
|
||||
LOOP_L_N(i, r_len) {
|
||||
r_data[i] = sw_iic.read_byte(1); // Read data from reg
|
||||
}
|
||||
sw_iic.stop();
|
||||
}
|
||||
|
||||
void GT911::Init() {
|
||||
OUT_WRITE(GT911_RST_PIN, LOW);
|
||||
OUT_WRITE(GT911_INT_PIN, LOW);
|
||||
delay(20);
|
||||
WRITE(GT911_RST_PIN, HIGH);
|
||||
SET_INPUT(GT911_INT_PIN);
|
||||
|
||||
sw_iic.init();
|
||||
|
||||
uint8_t clear_reg = 0x0000;
|
||||
write_reg(0x814E, 2, &clear_reg, 2); // Reset to 0 for start
|
||||
}
|
||||
|
||||
bool GT911::getFirstTouchPoint(int16_t *x, int16_t *y) {
|
||||
read_reg(0x814E, 2, ®.REG.status, 1);
|
||||
|
||||
if (reg.REG.status & 0x80) {
|
||||
uint8_t clear_reg = 0x00;
|
||||
write_reg(0x814E, 2, &clear_reg, 1); // Reset to 0 for start
|
||||
read_reg(0x8150, 2, reg.map + 2, 8 * (reg.REG.status & 0x0F));
|
||||
|
||||
// First touch point
|
||||
*x = ((reg.REG.point[0].xh & 0x0F) << 8) | reg.REG.point[0].xl;
|
||||
*y = ((reg.REG.point[0].yh & 0x0F) << 8) | reg.REG.point[0].yl;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GT911::getPoint(int16_t *x, int16_t *y) {
|
||||
static bool touched = 0;
|
||||
static int16_t read_x = 0, read_y = 0;
|
||||
static millis_t next_time = 0;
|
||||
|
||||
if (ELAPSED(millis(), next_time)) {
|
||||
touched = getFirstTouchPoint(&read_x, &read_y);
|
||||
next_time = millis() + 20;
|
||||
}
|
||||
|
||||
*x = read_x;
|
||||
*y = read_y;
|
||||
return touched;
|
||||
}
|
||||
|
||||
#endif // TFT_TOUCH_DEVICE_GT911
|
||||
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
|
120
Marlin/src/HAL/STM32/tft/gt911.h
Normal file
120
Marlin/src/HAL/STM32/tft/gt911.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* 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
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#define GT911_SLAVE_ADDRESS 0xBA
|
||||
|
||||
#if !PIN_EXISTS(GT911_RST)
|
||||
#error "GT911_RST_PIN is not defined."
|
||||
#elif !PIN_EXISTS(GT911_INT)
|
||||
#error "GT911_INT_PIN is not defined."
|
||||
#elif !PIN_EXISTS(GT911_SW_I2C_SCL)
|
||||
#error "GT911_SW_I2C_SCL_PIN is not defined."
|
||||
#elif !PIN_EXISTS(GT911_SW_I2C_SDA)
|
||||
#error "GT911_SW_I2C_SDA_PIN is not defined."
|
||||
#endif
|
||||
|
||||
class SW_IIC {
|
||||
private:
|
||||
uint16_t scl_pin;
|
||||
uint16_t sda_pin;
|
||||
void write_scl(bool level)
|
||||
{
|
||||
WRITE(scl_pin, level);
|
||||
}
|
||||
void write_sda(bool level)
|
||||
{
|
||||
WRITE(sda_pin, level);
|
||||
}
|
||||
bool read_sda()
|
||||
{
|
||||
return READ(sda_pin);
|
||||
}
|
||||
void set_sda_out()
|
||||
{
|
||||
SET_OUTPUT(sda_pin);
|
||||
}
|
||||
void set_sda_in()
|
||||
{
|
||||
SET_INPUT_PULLUP(sda_pin);
|
||||
}
|
||||
static void iic_delay(uint8_t t)
|
||||
{
|
||||
delayMicroseconds(t);
|
||||
}
|
||||
|
||||
public:
|
||||
SW_IIC(uint16_t sda, uint16_t scl);
|
||||
// setSCL/SDA have to be called before begin()
|
||||
void setSCL(uint16_t scl)
|
||||
{
|
||||
scl_pin = scl;
|
||||
};
|
||||
void setSDA(uint16_t sda)
|
||||
{
|
||||
sda_pin = sda;
|
||||
};
|
||||
void init(); // Initialize the IO port of IIC
|
||||
void start(); // Send IIC start signal
|
||||
void stop(); // Send IIC stop signal
|
||||
void send_byte(uint8_t txd); // IIC sends a byte
|
||||
uint8_t read_byte(bool ack); // IIC reads a byte
|
||||
void send_ack(bool ack); // IIC sends ACK or NACK signal
|
||||
bool read_ack();
|
||||
};
|
||||
|
||||
typedef struct __attribute__((__packed__)) {
|
||||
uint8_t xl;
|
||||
uint8_t xh;
|
||||
uint8_t yl;
|
||||
uint8_t yh;
|
||||
uint8_t sizel;
|
||||
uint8_t sizeh;
|
||||
uint8_t reserved;
|
||||
uint8_t track_id;
|
||||
} GT911_POINT;
|
||||
|
||||
typedef union __attribute__((__packed__)) {
|
||||
uint8_t map[42];
|
||||
struct {
|
||||
uint8_t status; // 0x814E
|
||||
uint8_t track_id; // 0x814F
|
||||
|
||||
GT911_POINT point[5]; // [0]:0x8150 - 0x8157 / [1]:0x8158 - 0x815F / [2]:0x8160 - 0x8167 / [3]:0x8168 - 0x816F / [4]:0x8170 - 0x8177
|
||||
} REG;
|
||||
} GT911_REG_MAP;
|
||||
|
||||
class GT911 {
|
||||
private:
|
||||
static const uint8_t gt911_slave_address = GT911_SLAVE_ADDRESS;
|
||||
static GT911_REG_MAP reg;
|
||||
static SW_IIC sw_iic;
|
||||
static void write_reg(uint16_t reg, uint8_t reg_len, uint8_t* w_data, uint8_t w_len);
|
||||
static void read_reg(uint16_t reg, uint8_t reg_len, uint8_t* r_data, uint8_t r_len);
|
||||
|
||||
public:
|
||||
static void Init();
|
||||
static bool getFirstTouchPoint(int16_t *x, int16_t *y);
|
||||
static bool getPoint(int16_t *x, int16_t *y);
|
||||
};
|
@@ -45,7 +45,6 @@
|
||||
#define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000)
|
||||
#define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE ((uint16_t)0x0200)
|
||||
|
||||
|
||||
void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command) {
|
||||
|
||||
__IO uint32_t tmpmrd =0;
|
||||
@@ -192,7 +191,7 @@ void LTDC_Config() {
|
||||
|
||||
hltdc_F.Instance = LTDC;
|
||||
|
||||
/* Layer0 Configuration ------------------------------------------------------*/
|
||||
/* Layer0 Configuration ------------------------------------------------------*/
|
||||
|
||||
/* Windowing configuration */
|
||||
pLayerCfg.WindowX0 = 0;
|
||||
@@ -289,22 +288,21 @@ void TFT_LTDC::DrawRect(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint
|
||||
uint16_t offline = TFT_WIDTH - (ex - sx);
|
||||
uint32_t addr = (uint32_t)&framebuffer[(TFT_WIDTH * sy) + sx];
|
||||
|
||||
DMA2D->CR &= ~(1 << 0);
|
||||
CBI(DMA2D->CR, 0);
|
||||
DMA2D->CR = 3 << 16;
|
||||
DMA2D->OPFCCR = 0X02;
|
||||
DMA2D->OOR = offline;
|
||||
DMA2D->OMAR = addr;
|
||||
DMA2D->NLR = (ey - sy) | ((ex - sx) << 16);
|
||||
DMA2D->OCOLR = color;
|
||||
DMA2D->CR |= 1<<0;
|
||||
SBI(DMA2D->CR, 0);
|
||||
|
||||
uint32_t timeout = 0;
|
||||
while((DMA2D->ISR & (1<<1)) == 0)
|
||||
{
|
||||
while (!TEST(DMA2D->ISR, 1)) {
|
||||
timeout++;
|
||||
if(timeout>0X1FFFFF)break;
|
||||
if (timeout > 0x1FFFFF) break;
|
||||
}
|
||||
DMA2D->IFCR |= 1<<1;
|
||||
SBI(DMA2D->IFCR, 1);
|
||||
}
|
||||
|
||||
void TFT_LTDC::DrawImage(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uint16_t *colors) {
|
||||
@@ -314,7 +312,7 @@ void TFT_LTDC::DrawImage(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uin
|
||||
uint16_t offline = TFT_WIDTH - (ex - sx);
|
||||
uint32_t addr = (uint32_t)&framebuffer[(TFT_WIDTH * sy) + sx];
|
||||
|
||||
DMA2D->CR &= ~(1 << 0);
|
||||
CBI(DMA2D->CR, 0);
|
||||
DMA2D->CR = 0 << 16;
|
||||
DMA2D->FGPFCCR = 0X02;
|
||||
DMA2D->FGOR = 0;
|
||||
@@ -322,15 +320,14 @@ void TFT_LTDC::DrawImage(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, uin
|
||||
DMA2D->FGMAR = (uint32_t)colors;
|
||||
DMA2D->OMAR = addr;
|
||||
DMA2D->NLR = (ey - sy) | ((ex - sx) << 16);
|
||||
DMA2D->CR |= 1<<0;
|
||||
SBI(DMA2D->CR, 0);
|
||||
|
||||
uint32_t timeout = 0;
|
||||
while((DMA2D->ISR & (1<<1)) == 0)
|
||||
{
|
||||
while (!TEST(DMA2D->ISR, 1)) {
|
||||
timeout++;
|
||||
if(timeout>0X1FFFFF)break;
|
||||
if (timeout > 0x1FFFFF) break;
|
||||
}
|
||||
DMA2D->IFCR |= 1<<1;
|
||||
SBI(DMA2D->IFCR, 1);
|
||||
}
|
||||
|
||||
void TFT_LTDC::WriteData(uint16_t data) {
|
||||
|
@@ -125,12 +125,20 @@ void TFT_SPI::DataTransferBegin(uint16_t DataSize) {
|
||||
WRITE(TFT_CS_PIN, LOW);
|
||||
}
|
||||
|
||||
#ifdef TFT_DEFAULT_DRIVER
|
||||
#include "../../../lcd/tft_io/tft_ids.h"
|
||||
#endif
|
||||
|
||||
uint32_t TFT_SPI::GetID() {
|
||||
uint32_t id;
|
||||
id = ReadID(LCD_READ_ID);
|
||||
|
||||
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF)
|
||||
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF) {
|
||||
id = ReadID(LCD_READ_ID4);
|
||||
#ifdef TFT_DEFAULT_DRIVER
|
||||
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF)
|
||||
id = TFT_DEFAULT_DRIVER;
|
||||
#endif
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_TFT_XPT2046 || HAS_TOUCH_BUTTONS
|
||||
#if HAS_TFT_XPT2046 || HAS_RES_TOUCH_BUTTONS
|
||||
|
||||
#include "xpt2046.h"
|
||||
#include "pinconfig.h"
|
||||
|
@@ -56,7 +56,7 @@ enum XPTCoordinate : uint8_t {
|
||||
XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE,
|
||||
};
|
||||
|
||||
#if !defined(XPT2046_Z1_THRESHOLD)
|
||||
#ifndef XPT2046_Z1_THRESHOLD
|
||||
#define XPT2046_Z1_THRESHOLD 10
|
||||
#endif
|
||||
|
||||
|
@@ -21,15 +21,12 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
// ------------------------
|
||||
// Defines
|
||||
// ------------------------
|
||||
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
|
||||
// STM32 timers may be 16 or 32 bit. Limiting HAL_TIMER_TYPE_MAX to 16 bits
|
||||
// avoids issues with STM32F0 MCUs, which seem to pause timers if UINT32_MAX
|
||||
// is written to the register. STM32F4 timers do not manifest this issue,
|
||||
|
@@ -293,7 +293,7 @@ void HAL_init() {
|
||||
#if PIN_EXISTS(USB_CONNECT)
|
||||
OUT_WRITE(USB_CONNECT_PIN, !USB_CONNECT_INVERTING); // USB clear connection
|
||||
delay(1000); // Give OS time to notice
|
||||
OUT_WRITE(USB_CONNECT_PIN, USB_CONNECT_INVERTING);
|
||||
WRITE(USB_CONNECT_PIN, USB_CONNECT_INVERTING);
|
||||
#endif
|
||||
TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the minimal serial handler
|
||||
}
|
||||
|
@@ -36,7 +36,6 @@
|
||||
#include "fastio.h"
|
||||
#include "watchdog.h"
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <util/atomic.h>
|
||||
|
||||
@@ -63,11 +62,10 @@
|
||||
#ifdef SERIAL_USB
|
||||
typedef ForwardSerial1Class< USBSerial > DefaultSerial1;
|
||||
extern DefaultSerial1 MSerial0;
|
||||
|
||||
#if !HAS_SD_HOST_DRIVE
|
||||
#define UsbSerial MSerial0
|
||||
#else
|
||||
#if HAS_SD_HOST_DRIVE
|
||||
#define UsbSerial MarlinCompositeSerial
|
||||
#else
|
||||
#define UsbSerial MSerial0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -86,11 +84,7 @@
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
#else
|
||||
#define MYSERIAL1 MSERIAL(1) // dummy port
|
||||
#if NUM_UARTS == 5
|
||||
#error "SERIAL_PORT must be from 1 to 5. You can also use -1 if the board supports Native USB."
|
||||
#else
|
||||
#error "SERIAL_PORT must be from 1 to 3. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
static_assert(false, "SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.")
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
@@ -100,11 +94,18 @@
|
||||
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
|
||||
#else
|
||||
#define MYSERIAL2 MSERIAL(1) // dummy port
|
||||
#if NUM_UARTS == 5
|
||||
#error "SERIAL_PORT_2 must be from 1 to 5. You can also use -1 if the board supports Native USB."
|
||||
#else
|
||||
#error "SERIAL_PORT_2 must be from 1 to 3. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
static_assert(false, "SERIAL_PORT_2 must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_PORT_3
|
||||
#if SERIAL_PORT_3 == -1
|
||||
#define MYSERIAL3 UsbSerial
|
||||
#elif WITHIN(SERIAL_PORT_3, 1, NUM_UARTS)
|
||||
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
|
||||
#else
|
||||
#define MYSERIAL3 MSERIAL(1) // dummy port
|
||||
static_assert(false, "SERIAL_PORT_3 must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -115,11 +116,7 @@
|
||||
#define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
|
||||
#else
|
||||
#define MMU2_SERIAL MSERIAL(1) // dummy port
|
||||
#if NUM_UARTS == 5
|
||||
#error "MMU2_SERIAL_PORT must be from 1 to 5. You can also use -1 if the board supports Native USB."
|
||||
#else
|
||||
#error "MMU2_SERIAL_PORT must be from 1 to 3. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
static_assert(false, "MMU2_SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -130,11 +127,7 @@
|
||||
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
|
||||
#else
|
||||
#define LCD_SERIAL MSERIAL(1) // dummy port
|
||||
#if NUM_UARTS == 5
|
||||
#error "LCD_SERIAL_PORT must be from 1 to 5. You can also use -1 if the board supports Native USB."
|
||||
#else
|
||||
#error "LCD_SERIAL_PORT must be from 1 to 3. You can also use -1 if the board supports Native USB."
|
||||
#endif
|
||||
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
|
||||
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
|
||||
|
@@ -55,7 +55,7 @@ static void TXBegin() {
|
||||
nvic_irq_disable(dev->irq_num);
|
||||
|
||||
// Use this if removing libmaple
|
||||
//NVIC_BASE->ICER[1] |= _BV(irq - 32);
|
||||
//SBI(NVIC_BASE->ICER[1], irq - 32);
|
||||
|
||||
// We NEED memory barriers to ensure Interrupts are actually disabled!
|
||||
// ( https://dzone.com/articles/nvic-disabling-interrupts-on-arm-cortex-m-and-the )
|
||||
|
@@ -167,6 +167,15 @@ constexpr bool IsSerialClassAllowed(const HardwareSerial&) { return false; }
|
||||
#if AXIS_HAS_HW_SERIAL(Z4)
|
||||
CHECK_AXIS_SERIAL(Z4);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(I)
|
||||
CHECK_AXIS_SERIAL(I);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(J)
|
||||
CHECK_AXIS_SERIAL(J);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(K)
|
||||
CHECK_AXIS_SERIAL(K);
|
||||
#endif
|
||||
#if AXIS_HAS_HW_SERIAL(E0)
|
||||
CHECK_AXIS_SERIAL(E0);
|
||||
#endif
|
||||
|
@@ -11,6 +11,7 @@ if __name__ == "__main__":
|
||||
"-fsigned-char",
|
||||
"-fno-move-loop-invariants",
|
||||
"-fno-strict-aliasing",
|
||||
"-fsingle-precision-constant",
|
||||
|
||||
"--specs=nano.specs",
|
||||
"--specs=nosys.specs",
|
||||
|
@@ -71,4 +71,10 @@ void setup_endstop_interrupts() {
|
||||
TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
|
||||
TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
|
||||
TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
|
||||
TERN_(HAS_I_MAX, _ATTACH(I_MAX_PIN));
|
||||
TERN_(HAS_I_MIN, _ATTACH(I_MIN_PIN));
|
||||
TERN_(HAS_J_MAX, _ATTACH(J_MAX_PIN));
|
||||
TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN));
|
||||
TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN));
|
||||
TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN));
|
||||
}
|
||||
|
@@ -38,8 +38,8 @@
|
||||
#define SPI_CLOCK_MAX SPI_BAUD_PCLK_DIV_2
|
||||
#endif
|
||||
|
||||
#define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) /* Set OnboardSPI cs low */
|
||||
#define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) /* Set OnboardSPI cs high */
|
||||
#define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) // Set OnboardSPI cs low
|
||||
#define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) // Set OnboardSPI cs high
|
||||
|
||||
#define FCLK_FAST() ONBOARD_SD_SPI.setClockDivider(SPI_CLOCK_MAX)
|
||||
#define FCLK_SLOW() ONBOARD_SD_SPI.setClockDivider(SPI_BAUD_PCLK_DIV_256)
|
||||
@@ -49,32 +49,32 @@
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
/* MMC/SD command */
|
||||
#define CMD0 (0) /* GO_IDLE_STATE */
|
||||
#define CMD1 (1) /* SEND_OP_COND (MMC) */
|
||||
#define ACMD41 (0x80+41) /* SEND_OP_COND (SDC) */
|
||||
#define CMD8 (8) /* SEND_IF_COND */
|
||||
#define CMD9 (9) /* SEND_CSD */
|
||||
#define CMD10 (10) /* SEND_CID */
|
||||
#define CMD12 (12) /* STOP_TRANSMISSION */
|
||||
#define ACMD13 (0x80+13) /* SD_STATUS (SDC) */
|
||||
#define CMD16 (16) /* SET_BLOCKLEN */
|
||||
#define CMD17 (17) /* READ_SINGLE_BLOCK */
|
||||
#define CMD18 (18) /* READ_MULTIPLE_BLOCK */
|
||||
#define CMD23 (23) /* SET_BLOCK_COUNT (MMC) */
|
||||
#define ACMD23 (0x80+23) /* SET_WR_BLK_ERASE_COUNT (SDC) */
|
||||
#define CMD24 (24) /* WRITE_BLOCK */
|
||||
#define CMD25 (25) /* WRITE_MULTIPLE_BLOCK */
|
||||
#define CMD32 (32) /* ERASE_ER_BLK_START */
|
||||
#define CMD33 (33) /* ERASE_ER_BLK_END */
|
||||
#define CMD38 (38) /* ERASE */
|
||||
#define CMD48 (48) /* READ_EXTR_SINGLE */
|
||||
#define CMD49 (49) /* WRITE_EXTR_SINGLE */
|
||||
#define CMD55 (55) /* APP_CMD */
|
||||
#define CMD58 (58) /* READ_OCR */
|
||||
#define CMD0 (0) // GO_IDLE_STATE
|
||||
#define CMD1 (1) // SEND_OP_COND (MMC)
|
||||
#define ACMD41 (0x80+41) // SEND_OP_COND (SDC)
|
||||
#define CMD8 (8) // SEND_IF_COND
|
||||
#define CMD9 (9) // SEND_CSD
|
||||
#define CMD10 (10) // SEND_CID
|
||||
#define CMD12 (12) // STOP_TRANSMISSION
|
||||
#define ACMD13 (0x80+13) // SD_STATUS (SDC)
|
||||
#define CMD16 (16) // SET_BLOCKLEN
|
||||
#define CMD17 (17) // READ_SINGLE_BLOCK
|
||||
#define CMD18 (18) // READ_MULTIPLE_BLOCK
|
||||
#define CMD23 (23) // SET_BLOCK_COUNT (MMC)
|
||||
#define ACMD23 (0x80+23) // SET_WR_BLK_ERASE_COUNT (SDC)
|
||||
#define CMD24 (24) // WRITE_BLOCK
|
||||
#define CMD25 (25) // WRITE_MULTIPLE_BLOCK
|
||||
#define CMD32 (32) // ERASE_ER_BLK_START
|
||||
#define CMD33 (33) // ERASE_ER_BLK_END
|
||||
#define CMD38 (38) // ERASE
|
||||
#define CMD48 (48) // READ_EXTR_SINGLE
|
||||
#define CMD49 (49) // WRITE_EXTR_SINGLE
|
||||
#define CMD55 (55) // APP_CMD
|
||||
#define CMD58 (58) // READ_OCR
|
||||
|
||||
static volatile DSTATUS Stat = STA_NOINIT; /* Physical drive status */
|
||||
static volatile DSTATUS Stat = STA_NOINIT; // Physical drive status
|
||||
static volatile UINT timeout;
|
||||
static BYTE CardType; /* Card type flags */
|
||||
static BYTE CardType; // Card type flags
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Send/Receive data to the MMC (Platform dependent) */
|
||||
@@ -82,7 +82,7 @@ static BYTE CardType; /* Card type flags */
|
||||
|
||||
/* Exchange a byte */
|
||||
static BYTE xchg_spi (
|
||||
BYTE dat /* Data to send */
|
||||
BYTE dat // Data to send
|
||||
) {
|
||||
BYTE returnByte = ONBOARD_SD_SPI.transfer(dat);
|
||||
return returnByte;
|
||||
@@ -90,18 +90,18 @@ static BYTE xchg_spi (
|
||||
|
||||
/* Receive multiple byte */
|
||||
static void rcvr_spi_multi (
|
||||
BYTE *buff, /* Pointer to data buffer */
|
||||
UINT btr /* Number of bytes to receive (16, 64 or 512) */
|
||||
BYTE *buff, // Pointer to data buffer
|
||||
UINT btr // Number of bytes to receive (16, 64 or 512)
|
||||
) {
|
||||
ONBOARD_SD_SPI.dmaTransfer(0, const_cast<uint8_t*>(buff), btr);
|
||||
}
|
||||
|
||||
#if _DISKIO_WRITE
|
||||
|
||||
/* Send multiple bytes */
|
||||
// Send multiple bytes
|
||||
static void xmit_spi_multi (
|
||||
const BYTE *buff, /* Pointer to the data */
|
||||
UINT btx /* Number of bytes to send (multiple of 16) */
|
||||
const BYTE *buff, // Pointer to the data
|
||||
UINT btx // Number of bytes to send (multiple of 16)
|
||||
) {
|
||||
ONBOARD_SD_SPI.dmaSend(const_cast<uint8_t*>(buff), btx);
|
||||
}
|
||||
@@ -112,16 +112,15 @@ static void rcvr_spi_multi (
|
||||
/* Wait for card ready */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
static int wait_ready ( /* 1:Ready, 0:Timeout */
|
||||
UINT wt /* Timeout [ms] */
|
||||
static int wait_ready ( // 1:Ready, 0:Timeout
|
||||
UINT wt // Timeout [ms]
|
||||
) {
|
||||
BYTE d;
|
||||
|
||||
timeout = millis() + wt;
|
||||
do {
|
||||
d = xchg_spi(0xFF);
|
||||
/* This loop takes a while. Insert rot_rdq() here for multitask environment. */
|
||||
} while (d != 0xFF && (timeout > millis())); /* Wait for card goes ready or timeout */
|
||||
// This loop takes a while. Insert rot_rdq() here for multitask environment.
|
||||
} while (d != 0xFF && (timeout > millis())); // Wait for card goes ready or timeout
|
||||
|
||||
return (d == 0xFF) ? 1 : 0;
|
||||
}
|
||||
@@ -131,21 +130,21 @@ static int wait_ready ( /* 1:Ready, 0:Timeout */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
static void deselect() {
|
||||
CS_HIGH(); /* CS = H */
|
||||
xchg_spi(0xFF); /* Dummy clock (force DO hi-z for multiple slave SPI) */
|
||||
CS_HIGH(); // CS = H
|
||||
xchg_spi(0xFF); // Dummy clock (force DO hi-z for multiple slave SPI)
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Select card and wait for ready */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
static int select() { /* 1:OK, 0:Timeout */
|
||||
CS_LOW(); /* CS = L */
|
||||
xchg_spi(0xFF); /* Dummy clock (force DO enabled) */
|
||||
static int select() { // 1:OK, 0:Timeout
|
||||
CS_LOW(); // CS = L
|
||||
xchg_spi(0xFF); // Dummy clock (force DO enabled)
|
||||
|
||||
if (wait_ready(500)) return 1; /* Leading busy check: Wait for card ready */
|
||||
if (wait_ready(500)) return 1; // Leading busy check: Wait for card ready
|
||||
|
||||
deselect(); /* Timeout */
|
||||
deselect(); // Timeout
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -153,16 +152,18 @@ static int select() { /* 1:OK, 0:Timeout */
|
||||
/* Control SPI module (Platform dependent) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
static void power_on() { /* Enable SSP module and attach it to I/O pads */
|
||||
// Enable SSP module and attach it to I/O pads
|
||||
static void sd_power_on() {
|
||||
ONBOARD_SD_SPI.setModule(ONBOARD_SPI_DEVICE);
|
||||
ONBOARD_SD_SPI.begin();
|
||||
ONBOARD_SD_SPI.setBitOrder(MSBFIRST);
|
||||
ONBOARD_SD_SPI.setDataMode(SPI_MODE0);
|
||||
OUT_WRITE(ONBOARD_SD_CS_PIN, HIGH); /* Set CS# high */
|
||||
OUT_WRITE(ONBOARD_SD_CS_PIN, HIGH); // Set CS# high
|
||||
}
|
||||
|
||||
static void power_off() { /* Disable SPI function */
|
||||
select(); /* Wait for card ready */
|
||||
// Disable SPI function
|
||||
static void sd_power_off() {
|
||||
select(); // Wait for card ready
|
||||
deselect();
|
||||
}
|
||||
|
||||
@@ -170,23 +171,23 @@ static void power_off() { /* Disable SPI function */
|
||||
/* Receive a data packet from the MMC */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
static int rcvr_datablock ( /* 1:OK, 0:Error */
|
||||
BYTE *buff, /* Data buffer */
|
||||
UINT btr /* Data block length (byte) */
|
||||
static int rcvr_datablock ( // 1:OK, 0:Error
|
||||
BYTE *buff, // Data buffer
|
||||
UINT btr // Data block length (byte)
|
||||
) {
|
||||
BYTE token;
|
||||
|
||||
timeout = millis() + 200;
|
||||
do { /* Wait for DataStart token in timeout of 200ms */
|
||||
do { // Wait for DataStart token in timeout of 200ms
|
||||
token = xchg_spi(0xFF);
|
||||
/* This loop will take a while. Insert rot_rdq() here for multitask environment. */
|
||||
// This loop will take a while. Insert rot_rdq() here for multitask environment.
|
||||
} while ((token == 0xFF) && (timeout > millis()));
|
||||
if (token != 0xFE) return 0; /* Function fails if invalid DataStart token or timeout */
|
||||
if (token != 0xFE) return 0; // Function fails if invalid DataStart token or timeout
|
||||
|
||||
rcvr_spi_multi(buff, btr); /* Store trailing data to the buffer */
|
||||
xchg_spi(0xFF); xchg_spi(0xFF); /* Discard CRC */
|
||||
rcvr_spi_multi(buff, btr); // Store trailing data to the buffer
|
||||
xchg_spi(0xFF); xchg_spi(0xFF); // Discard CRC
|
||||
|
||||
return 1; /* Function succeeded */
|
||||
return 1; // Function succeeded
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
@@ -195,25 +196,25 @@ static int rcvr_datablock ( /* 1:OK, 0:Error */
|
||||
|
||||
#if _DISKIO_WRITE
|
||||
|
||||
static int xmit_datablock ( /* 1:OK, 0:Failed */
|
||||
const BYTE *buff, /* Ponter to 512 byte data to be sent */
|
||||
BYTE token /* Token */
|
||||
static int xmit_datablock( // 1:OK, 0:Failed
|
||||
const BYTE *buff, // Pointer to 512 byte data to be sent
|
||||
BYTE token // Token
|
||||
) {
|
||||
BYTE resp;
|
||||
|
||||
if (!wait_ready(500)) return 0; /* Leading busy check: Wait for card ready to accept data block */
|
||||
if (!wait_ready(500)) return 0; // Leading busy check: Wait for card ready to accept data block
|
||||
|
||||
xchg_spi(token); /* Send token */
|
||||
if (token == 0xFD) return 1; /* Do not send data if token is StopTran */
|
||||
xchg_spi(token); // Send token
|
||||
if (token == 0xFD) return 1; // Do not send data if token is StopTran
|
||||
|
||||
xmit_spi_multi(buff, 512); /* Data */
|
||||
xchg_spi(0xFF); xchg_spi(0xFF); /* Dummy CRC */
|
||||
xmit_spi_multi(buff, 512); // Data
|
||||
xchg_spi(0xFF); xchg_spi(0xFF); // Dummy CRC
|
||||
|
||||
resp = xchg_spi(0xFF); /* Receive data resp */
|
||||
resp = xchg_spi(0xFF); // Receive data resp
|
||||
|
||||
return (resp & 0x1F) == 0x05 ? 1 : 0; /* Data was accepted or not */
|
||||
return (resp & 0x1F) == 0x05 ? 1 : 0; // Data was accepted or not
|
||||
|
||||
/* Busy check is done at next transmission */
|
||||
// Busy check is done at next transmission
|
||||
}
|
||||
|
||||
#endif // _DISKIO_WRITE
|
||||
@@ -222,43 +223,43 @@ static int rcvr_datablock ( /* 1:OK, 0:Error */
|
||||
/* Send a command packet to the MMC */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
static BYTE send_cmd ( /* Return value: R1 resp (bit7==1:Failed to send) */
|
||||
BYTE cmd, /* Command index */
|
||||
DWORD arg /* Argument */
|
||||
static BYTE send_cmd( // Return value: R1 resp (bit7==1:Failed to send)
|
||||
BYTE cmd, // Command index
|
||||
DWORD arg // Argument
|
||||
) {
|
||||
BYTE n, res;
|
||||
|
||||
if (cmd & 0x80) { /* Send a CMD55 prior to ACMD<n> */
|
||||
if (cmd & 0x80) { // Send a CMD55 prior to ACMD<n>
|
||||
cmd &= 0x7F;
|
||||
res = send_cmd(CMD55, 0);
|
||||
if (res > 1) return res;
|
||||
}
|
||||
|
||||
/* Select the card and wait for ready except to stop multiple block read */
|
||||
// Select the card and wait for ready except to stop multiple block read
|
||||
if (cmd != CMD12) {
|
||||
deselect();
|
||||
if (!select()) return 0xFF;
|
||||
}
|
||||
|
||||
/* Send command packet */
|
||||
xchg_spi(0x40 | cmd); /* Start + command index */
|
||||
xchg_spi((BYTE)(arg >> 24)); /* Argument[31..24] */
|
||||
xchg_spi((BYTE)(arg >> 16)); /* Argument[23..16] */
|
||||
xchg_spi((BYTE)(arg >> 8)); /* Argument[15..8] */
|
||||
xchg_spi((BYTE)arg); /* Argument[7..0] */
|
||||
n = 0x01; /* Dummy CRC + Stop */
|
||||
if (cmd == CMD0) n = 0x95; /* Valid CRC for CMD0(0) */
|
||||
if (cmd == CMD8) n = 0x87; /* Valid CRC for CMD8(0x1AA) */
|
||||
// Send command packet
|
||||
xchg_spi(0x40 | cmd); // Start + command index
|
||||
xchg_spi((BYTE)(arg >> 24)); // Argument[31..24]
|
||||
xchg_spi((BYTE)(arg >> 16)); // Argument[23..16]
|
||||
xchg_spi((BYTE)(arg >> 8)); // Argument[15..8]
|
||||
xchg_spi((BYTE)arg); // Argument[7..0]
|
||||
n = 0x01; // Dummy CRC + Stop
|
||||
if (cmd == CMD0) n = 0x95; // Valid CRC for CMD0(0)
|
||||
if (cmd == CMD8) n = 0x87; // Valid CRC for CMD8(0x1AA)
|
||||
xchg_spi(n);
|
||||
|
||||
/* Receive command resp */
|
||||
if (cmd == CMD12) xchg_spi(0xFF); /* Diacard following one byte when CMD12 */
|
||||
n = 10; /* Wait for response (10 bytes max) */
|
||||
// Receive command response
|
||||
if (cmd == CMD12) xchg_spi(0xFF); // Discard the following byte when CMD12
|
||||
n = 10; // Wait for response (10 bytes max)
|
||||
do
|
||||
res = xchg_spi(0xFF);
|
||||
while ((res & 0x80) && --n);
|
||||
|
||||
return res; /* Return received response */
|
||||
return res; // Return received response
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
@@ -270,49 +271,52 @@ static BYTE send_cmd ( /* Return value: R1 resp (bit7==1:Failed to send) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DSTATUS disk_initialize (
|
||||
BYTE drv /* Physical drive number (0) */
|
||||
BYTE drv // Physical drive number (0)
|
||||
) {
|
||||
BYTE n, cmd, ty, ocr[4];
|
||||
|
||||
if (drv) return STA_NOINIT; /* Supports only drive 0 */
|
||||
power_on(); /* Initialize SPI */
|
||||
if (drv) return STA_NOINIT; // Supports only drive 0
|
||||
sd_power_on(); // Initialize SPI
|
||||
|
||||
if (Stat & STA_NODISK) return Stat; /* Is a card existing in the soket? */
|
||||
if (Stat & STA_NODISK) return Stat; // Is a card existing in the soket?
|
||||
|
||||
FCLK_SLOW();
|
||||
for (n = 10; n; n--) xchg_spi(0xFF); /* Send 80 dummy clocks */
|
||||
for (n = 10; n; n--) xchg_spi(0xFF); // Send 80 dummy clocks
|
||||
|
||||
ty = 0;
|
||||
if (send_cmd(CMD0, 0) == 1) { /* Put the card SPI state */
|
||||
timeout = millis() + 1000; /* Initialization timeout = 1 sec */
|
||||
if (send_cmd(CMD8, 0x1AA) == 1) { /* Is the catd SDv2? */
|
||||
for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); /* Get 32 bit return value of R7 resp */
|
||||
if (ocr[2] == 0x01 && ocr[3] == 0xAA) { /* Does the card support 2.7-3.6V? */
|
||||
while ((timeout > millis()) && send_cmd(ACMD41, 1UL << 30)) ; /* Wait for end of initialization with ACMD41(HCS) */
|
||||
if ((timeout > millis()) && send_cmd(CMD58, 0) == 0) { /* Check CCS bit in the OCR */
|
||||
if (send_cmd(CMD0, 0) == 1) { // Put the card SPI state
|
||||
timeout = millis() + 1000; // Initialization timeout = 1 sec
|
||||
if (send_cmd(CMD8, 0x1AA) == 1) { // Is the catd SDv2?
|
||||
for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF); // Get 32 bit return value of R7 resp
|
||||
if (ocr[2] == 0x01 && ocr[3] == 0xAA) { // Does the card support 2.7-3.6V?
|
||||
while ((timeout > millis()) && send_cmd(ACMD41, 1UL << 30)); // Wait for end of initialization with ACMD41(HCS)
|
||||
if ((timeout > millis()) && send_cmd(CMD58, 0) == 0) { // Check CCS bit in the OCR
|
||||
for (n = 0; n < 4; n++) ocr[n] = xchg_spi(0xFF);
|
||||
ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; /* Check if the card is SDv2 */
|
||||
ty = (ocr[0] & 0x40) ? CT_SD2 | CT_BLOCK : CT_SD2; // Check if the card is SDv2
|
||||
}
|
||||
}
|
||||
} else { /* Not an SDv2 card */
|
||||
if (send_cmd(ACMD41, 0) <= 1) { /* SDv1 or MMCv3? */
|
||||
ty = CT_SD1; cmd = ACMD41; /* SDv1 (ACMD41(0)) */
|
||||
} else {
|
||||
ty = CT_MMC; cmd = CMD1; /* MMCv3 (CMD1(0)) */
|
||||
}
|
||||
else { // Not an SDv2 card
|
||||
if (send_cmd(ACMD41, 0) <= 1) { // SDv1 or MMCv3?
|
||||
ty = CT_SD1; cmd = ACMD41; // SDv1 (ACMD41(0))
|
||||
}
|
||||
while ((timeout > millis()) && send_cmd(cmd, 0)) ; /* Wait for the card leaves idle state */
|
||||
if (!(timeout > millis()) || send_cmd(CMD16, 512) != 0) /* Set block length: 512 */
|
||||
else {
|
||||
ty = CT_MMC; cmd = CMD1; // MMCv3 (CMD1(0))
|
||||
}
|
||||
while ((timeout > millis()) && send_cmd(cmd, 0)); // Wait for the card leaves idle state
|
||||
if (!(timeout > millis()) || send_cmd(CMD16, 512) != 0) // Set block length: 512
|
||||
ty = 0;
|
||||
}
|
||||
}
|
||||
CardType = ty; /* Card type */
|
||||
CardType = ty; // Card type
|
||||
deselect();
|
||||
|
||||
if (ty) { /* OK */
|
||||
FCLK_FAST(); /* Set fast clock */
|
||||
Stat &= ~STA_NOINIT; /* Clear STA_NOINIT flag */
|
||||
} else { /* Failed */
|
||||
power_off();
|
||||
if (ty) { // OK
|
||||
FCLK_FAST(); // Set fast clock
|
||||
Stat &= ~STA_NOINIT; // Clear STA_NOINIT flag
|
||||
}
|
||||
else { // Failed
|
||||
sd_power_off();
|
||||
Stat = STA_NOINIT;
|
||||
}
|
||||
|
||||
@@ -324,10 +328,10 @@ DSTATUS disk_initialize (
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DSTATUS disk_status (
|
||||
BYTE drv /* Physical drive number (0) */
|
||||
BYTE drv // Physical drive number (0)
|
||||
) {
|
||||
if (drv) return STA_NOINIT; /* Supports only drive 0 */
|
||||
return Stat; /* Return disk status */
|
||||
if (drv) return STA_NOINIT; // Supports only drive 0
|
||||
return Stat; // Return disk status
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
@@ -335,28 +339,28 @@ DSTATUS disk_status (
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DRESULT disk_read (
|
||||
BYTE drv, /* Physical drive number (0) */
|
||||
BYTE *buff, /* Pointer to the data buffer to store read data */
|
||||
DWORD sector, /* Start sector number (LBA) */
|
||||
UINT count /* Number of sectors to read (1..128) */
|
||||
BYTE drv, // Physical drive number (0)
|
||||
BYTE *buff, // Pointer to the data buffer to store read data
|
||||
DWORD sector, // Start sector number (LBA)
|
||||
UINT count // Number of sectors to read (1..128)
|
||||
) {
|
||||
BYTE cmd;
|
||||
|
||||
if (drv || !count) return RES_PARERR; /* Check parameter */
|
||||
if (Stat & STA_NOINIT) return RES_NOTRDY; /* Check if drive is ready */
|
||||
if (!(CardType & CT_BLOCK)) sector *= 512; /* LBA ot BA conversion (byte addressing cards) */
|
||||
if (drv || !count) return RES_PARERR; // Check parameter
|
||||
if (Stat & STA_NOINIT) return RES_NOTRDY; // Check if drive is ready
|
||||
if (!(CardType & CT_BLOCK)) sector *= 512; // LBA ot BA conversion (byte addressing cards)
|
||||
FCLK_FAST();
|
||||
cmd = count > 1 ? CMD18 : CMD17; /* READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK */
|
||||
cmd = count > 1 ? CMD18 : CMD17; // READ_MULTIPLE_BLOCK : READ_SINGLE_BLOCK
|
||||
if (send_cmd(cmd, sector) == 0) {
|
||||
do {
|
||||
if (!rcvr_datablock(buff, 512)) break;
|
||||
buff += 512;
|
||||
} while (--count);
|
||||
if (cmd == CMD18) send_cmd(CMD12, 0); /* STOP_TRANSMISSION */
|
||||
if (cmd == CMD18) send_cmd(CMD12, 0); // STOP_TRANSMISSION
|
||||
}
|
||||
deselect();
|
||||
|
||||
return count ? RES_ERROR : RES_OK; /* Return result */
|
||||
return count ? RES_ERROR : RES_OK; // Return result
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
@@ -366,36 +370,36 @@ DRESULT disk_read (
|
||||
#if _DISKIO_WRITE
|
||||
|
||||
DRESULT disk_write(
|
||||
BYTE drv, /* Physical drive number (0) */
|
||||
const BYTE *buff, /* Ponter to the data to write */
|
||||
DWORD sector, /* Start sector number (LBA) */
|
||||
UINT count /* Number of sectors to write (1..128) */
|
||||
BYTE drv, // Physical drive number (0)
|
||||
const BYTE *buff, // Pointer to the data to write
|
||||
DWORD sector, // Start sector number (LBA)
|
||||
UINT count // Number of sectors to write (1..128)
|
||||
) {
|
||||
if (drv || !count) return RES_PARERR; /* Check parameter */
|
||||
if (Stat & STA_NOINIT) return RES_NOTRDY; /* Check drive status */
|
||||
if (Stat & STA_PROTECT) return RES_WRPRT; /* Check write protect */
|
||||
if (drv || !count) return RES_PARERR; // Check parameter
|
||||
if (Stat & STA_NOINIT) return RES_NOTRDY; // Check drive status
|
||||
if (Stat & STA_PROTECT) return RES_WRPRT; // Check write protect
|
||||
FCLK_FAST();
|
||||
if (!(CardType & CT_BLOCK)) sector *= 512; /* LBA ==> BA conversion (byte addressing cards) */
|
||||
if (!(CardType & CT_BLOCK)) sector *= 512; // LBA ==> BA conversion (byte addressing cards)
|
||||
|
||||
if (count == 1) { /* Single sector write */
|
||||
if ((send_cmd(CMD24, sector) == 0) /* WRITE_BLOCK */
|
||||
if (count == 1) { // Single sector write
|
||||
if ((send_cmd(CMD24, sector) == 0) // WRITE_BLOCK
|
||||
&& xmit_datablock(buff, 0xFE)) {
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
else { /* Multiple sector write */
|
||||
if (CardType & CT_SDC) send_cmd(ACMD23, count); /* Predefine number of sectors */
|
||||
if (send_cmd(CMD25, sector) == 0) { /* WRITE_MULTIPLE_BLOCK */
|
||||
else { // Multiple sector write
|
||||
if (CardType & CT_SDC) send_cmd(ACMD23, count); // Predefine number of sectors
|
||||
if (send_cmd(CMD25, sector) == 0) { // WRITE_MULTIPLE_BLOCK
|
||||
do {
|
||||
if (!xmit_datablock(buff, 0xFC)) break;
|
||||
buff += 512;
|
||||
} while (--count);
|
||||
if (!xmit_datablock(0, 0xFD)) count = 1; /* STOP_TRAN token */
|
||||
if (!xmit_datablock(0, 0xFD)) count = 1; // STOP_TRAN token
|
||||
}
|
||||
}
|
||||
deselect();
|
||||
|
||||
return count ? RES_ERROR : RES_OK; /* Return result */
|
||||
return count ? RES_ERROR : RES_OK; // Return result
|
||||
}
|
||||
|
||||
#endif // _DISKIO_WRITE
|
||||
@@ -407,9 +411,9 @@ DRESULT disk_read (
|
||||
#if _DISKIO_IOCTL
|
||||
|
||||
DRESULT disk_ioctl (
|
||||
BYTE drv, /* Physical drive number (0) */
|
||||
BYTE cmd, /* Control command code */
|
||||
void *buff /* Pointer to the conrtol data */
|
||||
BYTE drv, // Physical drive number (0)
|
||||
BYTE cmd, // Control command code
|
||||
void *buff // Pointer to the conrtol data
|
||||
) {
|
||||
DRESULT res;
|
||||
BYTE n, csd[16], *ptr = (BYTE *)buff;
|
||||
@@ -420,22 +424,23 @@ DRESULT disk_read (
|
||||
UINT dc;
|
||||
#endif
|
||||
|
||||
if (drv) return RES_PARERR; /* Check parameter */
|
||||
if (Stat & STA_NOINIT) return RES_NOTRDY; /* Check if drive is ready */
|
||||
if (drv) return RES_PARERR; // Check parameter
|
||||
if (Stat & STA_NOINIT) return RES_NOTRDY; // Check if drive is ready
|
||||
|
||||
res = RES_ERROR;
|
||||
FCLK_FAST();
|
||||
switch (cmd) {
|
||||
case CTRL_SYNC: /* Wait for end of internal write process of the drive */
|
||||
case CTRL_SYNC: // Wait for end of internal write process of the drive
|
||||
if (select()) res = RES_OK;
|
||||
break;
|
||||
|
||||
case GET_SECTOR_COUNT: /* Get drive capacity in unit of sector (DWORD) */
|
||||
case GET_SECTOR_COUNT: // Get drive capacity in unit of sector (DWORD)
|
||||
if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) {
|
||||
if ((csd[0] >> 6) == 1) { /* SDC ver 2.00 */
|
||||
if ((csd[0] >> 6) == 1) { // SDC ver 2.00
|
||||
csize = csd[9] + ((WORD)csd[8] << 8) + ((DWORD)(csd[7] & 63) << 16) + 1;
|
||||
*(DWORD*)buff = csize << 10;
|
||||
} else { /* SDC ver 1.XX or MMC ver 3 */
|
||||
}
|
||||
else { // SDC ver 1.XX or MMC ver 3
|
||||
n = (csd[5] & 15) + ((csd[10] & 128) >> 7) + ((csd[9] & 3) << 1) + 2;
|
||||
csize = (csd[8] >> 6) + ((WORD)csd[7] << 2) + ((WORD)(csd[6] & 3) << 10) + 1;
|
||||
*(DWORD*)buff = csize << (n - 9);
|
||||
@@ -444,21 +449,23 @@ DRESULT disk_read (
|
||||
}
|
||||
break;
|
||||
|
||||
case GET_BLOCK_SIZE: /* Get erase block size in unit of sector (DWORD) */
|
||||
if (CardType & CT_SD2) { /* SDC ver 2.00 */
|
||||
if (send_cmd(ACMD13, 0) == 0) { /* Read SD status */
|
||||
case GET_BLOCK_SIZE: // Get erase block size in unit of sector (DWORD)
|
||||
if (CardType & CT_SD2) { // SDC ver 2.00
|
||||
if (send_cmd(ACMD13, 0) == 0) { // Read SD status
|
||||
xchg_spi(0xFF);
|
||||
if (rcvr_datablock(csd, 16)) { /* Read partial block */
|
||||
for (n = 64 - 16; n; n--) xchg_spi(0xFF); /* Purge trailing data */
|
||||
if (rcvr_datablock(csd, 16)) { // Read partial block
|
||||
for (n = 64 - 16; n; n--) xchg_spi(0xFF); // Purge trailing data
|
||||
*(DWORD*)buff = 16UL << (csd[10] >> 4);
|
||||
res = RES_OK;
|
||||
}
|
||||
}
|
||||
} else { /* SDC ver 1.XX or MMC */
|
||||
if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { /* Read CSD */
|
||||
if (CardType & CT_SD1) { /* SDC ver 1.XX */
|
||||
}
|
||||
else { // SDC ver 1.XX or MMC
|
||||
if ((send_cmd(CMD9, 0) == 0) && rcvr_datablock(csd, 16)) { // Read CSD
|
||||
if (CardType & CT_SD1) { // SDC ver 1.XX
|
||||
*(DWORD*)buff = (((csd[10] & 63) << 1) + ((WORD)(csd[11] & 128) >> 7) + 1) << ((csd[13] >> 6) - 1);
|
||||
} else { /* MMC */
|
||||
}
|
||||
else { // MMC
|
||||
*(DWORD*)buff = ((WORD)((csd[10] & 124) >> 2) + 1) * (((csd[11] & 3) << 3) + ((csd[11] & 224) >> 5) + 1);
|
||||
}
|
||||
res = RES_OK;
|
||||
@@ -466,47 +473,47 @@ DRESULT disk_read (
|
||||
}
|
||||
break;
|
||||
|
||||
case CTRL_TRIM: /* Erase a block of sectors (used when _USE_TRIM in ffconf.h is 1) */
|
||||
if (!(CardType & CT_SDC)) break; /* Check if the card is SDC */
|
||||
if (disk_ioctl(drv, MMC_GET_CSD, csd)) break; /* Get CSD */
|
||||
if (!(csd[0] >> 6) && !(csd[10] & 0x40)) break; /* Check if sector erase can be applied to the card */
|
||||
dp = (DWORD *)buff; st = dp[0]; ed = dp[1]; /* Load sector block */
|
||||
case CTRL_TRIM: // Erase a block of sectors (used when _USE_TRIM in ffconf.h is 1)
|
||||
if (!(CardType & CT_SDC)) break; // Check if the card is SDC
|
||||
if (disk_ioctl(drv, MMC_GET_CSD, csd)) break; // Get CSD
|
||||
if (!(csd[0] >> 6) && !(csd[10] & 0x40)) break; // Check if sector erase can be applied to the card
|
||||
dp = (DWORD *)buff; st = dp[0]; ed = dp[1]; // Load sector block
|
||||
if (!(CardType & CT_BLOCK)) {
|
||||
st *= 512; ed *= 512;
|
||||
}
|
||||
if (send_cmd(CMD32, st) == 0 && send_cmd(CMD33, ed) == 0 && send_cmd(CMD38, 0) == 0 && wait_ready(30000)) { /* Erase sector block */
|
||||
res = RES_OK; /* FatFs does not check result of this command */
|
||||
if (send_cmd(CMD32, st) == 0 && send_cmd(CMD33, ed) == 0 && send_cmd(CMD38, 0) == 0 && wait_ready(30000)) { // Erase sector block
|
||||
res = RES_OK; // FatFs does not check result of this command
|
||||
}
|
||||
break;
|
||||
|
||||
/* Following commands are never used by FatFs module */
|
||||
// The following commands are never used by FatFs module
|
||||
|
||||
case MMC_GET_TYPE: /* Get MMC/SDC type (BYTE) */
|
||||
case MMC_GET_TYPE: // Get MMC/SDC type (BYTE)
|
||||
*ptr = CardType;
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
case MMC_GET_CSD: /* Read CSD (16 bytes) */
|
||||
if (send_cmd(CMD9, 0) == 0 && rcvr_datablock(ptr, 16)) { /* READ_CSD */
|
||||
case MMC_GET_CSD: // Read CSD (16 bytes)
|
||||
if (send_cmd(CMD9, 0) == 0 && rcvr_datablock(ptr, 16)) {
|
||||
res = RES_OK;
|
||||
}
|
||||
break;
|
||||
|
||||
case MMC_GET_CID: /* Read CID (16 bytes) */
|
||||
if (send_cmd(CMD10, 0) == 0 && rcvr_datablock(ptr, 16)) { /* READ_CID */
|
||||
case MMC_GET_CID: // Read CID (16 bytes)
|
||||
if (send_cmd(CMD10, 0) == 0 && rcvr_datablock(ptr, 16)) {
|
||||
res = RES_OK;
|
||||
}
|
||||
break;
|
||||
|
||||
case MMC_GET_OCR: /* Read OCR (4 bytes) */
|
||||
if (send_cmd(CMD58, 0) == 0) { /* READ_OCR */
|
||||
case MMC_GET_OCR: // Read OCR (4 bytes)
|
||||
if (send_cmd(CMD58, 0) == 0) {
|
||||
for (n = 4; n; n--) *ptr++ = xchg_spi(0xFF);
|
||||
res = RES_OK;
|
||||
}
|
||||
break;
|
||||
|
||||
case MMC_GET_SDSTAT: /* Read SD status (64 bytes) */
|
||||
if (send_cmd(ACMD13, 0) == 0) { /* SD_STATUS */
|
||||
case MMC_GET_SDSTAT: // Read SD status (64 bytes)
|
||||
if (send_cmd(ACMD13, 0) == 0) {
|
||||
xchg_spi(0xFF);
|
||||
if (rcvr_datablock(ptr, 64)) res = RES_OK;
|
||||
}
|
||||
|
@@ -90,12 +90,20 @@ void TFT_SPI::DataTransferBegin(uint16_t DataSize) {
|
||||
TFT_CS_L;
|
||||
}
|
||||
|
||||
#ifdef TFT_DEFAULT_DRIVER
|
||||
#include "../../../lcd/tft_io/tft_ids.h"
|
||||
#endif
|
||||
|
||||
uint32_t TFT_SPI::GetID() {
|
||||
uint32_t id;
|
||||
id = ReadID(LCD_READ_ID);
|
||||
|
||||
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF)
|
||||
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF) {
|
||||
id = ReadID(LCD_READ_ID4);
|
||||
#ifdef TFT_DEFAULT_DRIVER
|
||||
if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF)
|
||||
id = TFT_DEFAULT_DRIVER;
|
||||
#endif
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_TFT_XPT2046 || HAS_TOUCH_BUTTONS
|
||||
#if HAS_TFT_XPT2046 || HAS_RES_TOUCH_BUTTONS
|
||||
|
||||
#include "xpt2046.h"
|
||||
#include <SPI.h>
|
||||
|
@@ -54,7 +54,7 @@ enum XPTCoordinate : uint8_t {
|
||||
XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE,
|
||||
};
|
||||
|
||||
#if !defined(XPT2046_Z1_THRESHOLD)
|
||||
#ifndef XPT2046_Z1_THRESHOLD
|
||||
#define XPT2046_Z1_THRESHOLD 10
|
||||
#endif
|
||||
|
||||
|
@@ -25,9 +25,10 @@
|
||||
* HAL for stm32duino.com based on Libmaple and compatible (STM32F1)
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "HAL.h"
|
||||
|
||||
#include <libmaple/timer.h>
|
||||
#include "../../core/boards.h"
|
||||
|
||||
// ------------------------
|
||||
// Defines
|
||||
@@ -37,7 +38,6 @@
|
||||
* TODO: Check and confirm what timer we will use for each Temps and stepper driving.
|
||||
* We should probable drive temps with PWM.
|
||||
*/
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
|
||||
typedef uint16_t hal_timer_t;
|
||||
#define HAL_TIMER_TYPE_MAX 0xFFFF
|
||||
@@ -80,7 +80,7 @@ typedef uint16_t hal_timer_t;
|
||||
//#define TEMP_TIMER_NUM 4 // 2->4, Timer 2 for Stepper Current PWM
|
||||
#endif
|
||||
|
||||
#if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_E3_DIP, BTT_SKR_MINI_E3_V1_2, MKS_ROBIN_LITE)
|
||||
#if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_E3_DIP, BTT_SKR_MINI_E3_V1_2, MKS_ROBIN_LITE, MKS_ROBIN_E3D, MKS_ROBIN_E3)
|
||||
// SKR Mini E3 boards use PA8 as FAN_PIN, so TIMER 1 is used for Fan PWM.
|
||||
#ifdef STM32_HIGH_DENSITY
|
||||
#define SERVO0_TIMER_NUM 8 // tone.cpp uses Timer 4
|
||||
|
@@ -68,6 +68,8 @@ extern USBSerialType USBSerial;
|
||||
#elif WITHIN(SERIAL_PORT, 0, 3)
|
||||
DECLARE_SERIAL(SERIAL_PORT);
|
||||
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
|
||||
#else
|
||||
#error "The required SERIAL_PORT must be from 0 to 3, or -1 for Native USB."
|
||||
#endif
|
||||
|
||||
#define HAL_SERVO_LIB libServo
|
||||
|
@@ -21,11 +21,12 @@
|
||||
*/
|
||||
#ifdef __MK20DX256__
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "HAL.h"
|
||||
|
||||
#include <SPI.h>
|
||||
#include <pins_arduino.h>
|
||||
#include "spi_pins.h"
|
||||
#include "../../core/macros.h"
|
||||
|
||||
static SPISettings spiConfig;
|
||||
|
||||
|
@@ -64,4 +64,10 @@ void setup_endstop_interrupts() {
|
||||
TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
|
||||
TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
|
||||
TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
|
||||
TERN_(HAS_I_MAX, _ATTACH(I_MAX_PIN));
|
||||
TERN_(HAS_I_MIN, _ATTACH(I_MIN_PIN));
|
||||
TERN_(HAS_J_MAX, _ATTACH(J_MAX_PIN));
|
||||
TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN));
|
||||
TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN));
|
||||
TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN));
|
||||
}
|
||||
|
@@ -26,11 +26,12 @@
|
||||
|
||||
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "HAL.h"
|
||||
|
||||
#include <SPI.h>
|
||||
#include <pins_arduino.h>
|
||||
#include "spi_pins.h"
|
||||
#include "../../core/macros.h"
|
||||
|
||||
static SPISettings spiConfig;
|
||||
|
||||
|
@@ -63,4 +63,10 @@ void setup_endstop_interrupts() {
|
||||
TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
|
||||
TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
|
||||
TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
|
||||
TERN_(HAS_I_MAX, _ATTACH(I_MAX_PIN));
|
||||
TERN_(HAS_I_MIN, _ATTACH(I_MIN_PIN));
|
||||
TERN_(HAS_J_MAX, _ATTACH(J_MAX_PIN));
|
||||
TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN));
|
||||
TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN));
|
||||
TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN));
|
||||
}
|
||||
|
@@ -26,10 +26,11 @@
|
||||
|
||||
#ifdef __IMXRT1062__
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "HAL.h"
|
||||
|
||||
#include "../shared/Delay.h"
|
||||
#include "timers.h"
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X)
|
||||
|
@@ -26,11 +26,12 @@
|
||||
|
||||
#ifdef __IMXRT1062__
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "HAL.h"
|
||||
|
||||
#include <SPI.h>
|
||||
#include <pins_arduino.h>
|
||||
#include "spi_pins.h"
|
||||
#include "../../core/macros.h"
|
||||
|
||||
static SPISettings spiConfig;
|
||||
|
||||
|
@@ -63,4 +63,10 @@ void setup_endstop_interrupts() {
|
||||
TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
|
||||
TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
|
||||
TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
|
||||
TERN_(HAS_I_MAX, _ATTACH(I_MAX_PIN));
|
||||
TERN_(HAS_I_MIN, _ATTACH(I_MIN_PIN));
|
||||
TERN_(HAS_J_MAX, _ATTACH(J_MAX_PIN));
|
||||
TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN));
|
||||
TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN));
|
||||
TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN));
|
||||
}
|
||||
|
@@ -82,4 +82,8 @@
|
||||
#define UNUSED(x) ((void)(x))
|
||||
#endif
|
||||
|
||||
#ifndef FORCE_INLINE
|
||||
#define FORCE_INLINE inline __attribute__((always_inline))
|
||||
#endif
|
||||
|
||||
#include "progmem.h"
|
||||
|
@@ -30,11 +30,17 @@
|
||||
#if ENABLED(I2C_EEPROM)
|
||||
|
||||
#include "eeprom_if.h"
|
||||
#include <Wire.h>
|
||||
|
||||
#if ENABLED(SOFT_I2C_EEPROM)
|
||||
#include <SlowSoftWire.h>
|
||||
SlowSoftWire Wire = SlowSoftWire(I2C_SDA_PIN, I2C_SCL_PIN, true);
|
||||
#else
|
||||
#include <Wire.h>
|
||||
#endif
|
||||
|
||||
void eeprom_init() {
|
||||
Wire.begin(
|
||||
#if PINS_EXIST(I2C_SCL, I2C_SDA)
|
||||
#if PINS_EXIST(I2C_SCL, I2C_SDA) && DISABLED(SOFT_I2C_EEPROM)
|
||||
uint8_t(I2C_SDA_PIN), uint8_t(I2C_SCL_PIN)
|
||||
#endif
|
||||
);
|
||||
@@ -55,11 +61,24 @@ static constexpr uint8_t eeprom_device_address = I2C_ADDRESS(EEPROM_DEVICE_ADDRE
|
||||
// Public functions
|
||||
// ------------------------
|
||||
|
||||
#define SMALL_EEPROM (MARLIN_EEPROM_SIZE <= 2048)
|
||||
|
||||
// Combine Address high bits into the device address on <=16Kbit (2K) and >512Kbit (64K) EEPROMs.
|
||||
// Note: MARLIN_EEPROM_SIZE is specified in bytes, whereas EEPROM model numbers refer to bits.
|
||||
// e.g., The "16" in BL24C16 indicates a 16Kbit (2KB) size.
|
||||
static uint8_t _eeprom_calc_device_address(uint8_t * const pos) {
|
||||
const unsigned eeprom_address = (unsigned)pos;
|
||||
return (SMALL_EEPROM || MARLIN_EEPROM_SIZE > 65536)
|
||||
? uint8_t(eeprom_device_address | ((eeprom_address >> (SMALL_EEPROM ? 8 : 16)) & 0x07))
|
||||
: eeprom_device_address;
|
||||
}
|
||||
|
||||
static void _eeprom_begin(uint8_t * const pos) {
|
||||
const unsigned eeprom_address = (unsigned)pos;
|
||||
Wire.beginTransmission(eeprom_device_address);
|
||||
Wire.write(int(eeprom_address >> 8)); // Address High
|
||||
Wire.write(int(eeprom_address & 0xFF)); // Address Low
|
||||
Wire.beginTransmission(_eeprom_calc_device_address(pos));
|
||||
if (!SMALL_EEPROM)
|
||||
Wire.write(uint8_t((eeprom_address >> 8) & 0xFF)); // Address High, if needed
|
||||
Wire.write(uint8_t(eeprom_address & 0xFF)); // Address Low
|
||||
}
|
||||
|
||||
void eeprom_write_byte(uint8_t *pos, uint8_t value) {
|
||||
@@ -75,7 +94,7 @@ void eeprom_write_byte(uint8_t *pos, uint8_t value) {
|
||||
uint8_t eeprom_read_byte(uint8_t *pos) {
|
||||
_eeprom_begin(pos);
|
||||
Wire.endTransmission();
|
||||
Wire.requestFrom(eeprom_device_address, (byte)1);
|
||||
Wire.requestFrom(_eeprom_calc_device_address(pos), (byte)1);
|
||||
return Wire.available() ? Wire.read() : 0xFF;
|
||||
}
|
||||
|
||||
|
@@ -68,9 +68,9 @@
|
||||
#endif
|
||||
|
||||
#if HAS_TFT_LVGL_UI
|
||||
#include "lcd/extui/lib/mks_ui/tft_lvgl_configuration.h"
|
||||
#include "lcd/extui/lib/mks_ui/draw_ui.h"
|
||||
#include "lcd/extui/lib/mks_ui/mks_hardware_test.h"
|
||||
#include "lcd/extui/mks_ui/tft_lvgl_configuration.h"
|
||||
#include "lcd/extui/mks_ui/draw_ui.h"
|
||||
#include "lcd/extui/mks_ui/mks_hardware_test.h"
|
||||
#include <lvgl.h>
|
||||
#endif
|
||||
|
||||
@@ -229,7 +229,7 @@
|
||||
#endif
|
||||
|
||||
#if ENABLED(DGUS_LCD_UI_MKS)
|
||||
#include "lcd/extui/lib/dgus/DGUSScreenHandler.h"
|
||||
#include "lcd/extui/dgus/DGUSScreenHandler.h"
|
||||
#endif
|
||||
|
||||
#if HAS_DRIVER_SAFE_POWER_PROTECT
|
||||
@@ -282,12 +282,22 @@ bool wait_for_heatup = true;
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wnarrowing"
|
||||
|
||||
#ifndef RUNTIME_ONLY_ANALOG_TO_DIGITAL
|
||||
template <pin_t ...D>
|
||||
constexpr pin_t OnlyPins<_SP_END, D...>::table[sizeof...(D)];
|
||||
#endif
|
||||
|
||||
bool pin_is_protected(const pin_t pin) {
|
||||
static const pin_t sensitive_pins[] PROGMEM = SENSITIVE_PINS;
|
||||
LOOP_L_N(i, COUNT(sensitive_pins)) {
|
||||
pin_t sensitive_pin;
|
||||
memcpy_P(&sensitive_pin, &sensitive_pins[i], sizeof(pin_t));
|
||||
if (pin == sensitive_pin) return true;
|
||||
#ifdef RUNTIME_ONLY_ANALOG_TO_DIGITAL
|
||||
static const pin_t sensitive_pins[] PROGMEM = { SENSITIVE_PINS };
|
||||
const size_t pincount = COUNT(sensitive_pins);
|
||||
#else
|
||||
static constexpr size_t pincount = OnlyPins<SENSITIVE_PINS>::size;
|
||||
static const pin_t (&sensitive_pins)[pincount] PROGMEM = OnlyPins<SENSITIVE_PINS>::table;
|
||||
#endif
|
||||
LOOP_L_N(i, pincount) {
|
||||
const pin_t * const pptr = &sensitive_pins[i];
|
||||
if (pin == (sizeof(pin_t) == 2 ? (pin_t)pgm_read_word(pptr) : (pin_t)pgm_read_byte(pptr))) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -304,6 +314,9 @@ void enable_all_steppers() {
|
||||
ENABLE_AXIS_X();
|
||||
ENABLE_AXIS_Y();
|
||||
ENABLE_AXIS_Z();
|
||||
ENABLE_AXIS_I(); // Marlin 6-axis support by DerAndere (https://github.com/DerAndere1/Marlin/wiki)
|
||||
ENABLE_AXIS_J();
|
||||
ENABLE_AXIS_K();
|
||||
enable_e_steppers();
|
||||
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onSteppersEnabled());
|
||||
@@ -317,7 +330,7 @@ void disable_e_steppers() {
|
||||
void disable_e_stepper(const uint8_t e) {
|
||||
#define _CASE_DIS_E(N) case N: DISABLE_AXIS_E##N(); break;
|
||||
switch (e) {
|
||||
REPEAT(EXTRUDERS, _CASE_DIS_E)
|
||||
REPEAT(E_STEPPERS, _CASE_DIS_E)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,24 +338,23 @@ void disable_all_steppers() {
|
||||
DISABLE_AXIS_X();
|
||||
DISABLE_AXIS_Y();
|
||||
DISABLE_AXIS_Z();
|
||||
DISABLE_AXIS_I();
|
||||
DISABLE_AXIS_J();
|
||||
DISABLE_AXIS_K();
|
||||
disable_e_steppers();
|
||||
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onSteppersDisabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* A Print Job exists when the timer is running or SD printing
|
||||
* A Print Job exists when the timer is running or SD is printing
|
||||
*/
|
||||
bool printJobOngoing() {
|
||||
return print_job_timer.isRunning() || IS_SD_PRINTING();
|
||||
}
|
||||
bool printJobOngoing() { return print_job_timer.isRunning() || IS_SD_PRINTING(); }
|
||||
|
||||
/**
|
||||
* Printing is active when the print job timer is running
|
||||
* Printing is active when a job is underway but not paused
|
||||
*/
|
||||
bool printingIsActive() {
|
||||
return !did_pause_print && (print_job_timer.isRunning() || IS_SD_PRINTING());
|
||||
}
|
||||
bool printingIsActive() { return !did_pause_print && printJobOngoing(); }
|
||||
|
||||
/**
|
||||
* Printing is paused according to SD or host indicators
|
||||
@@ -367,7 +379,7 @@ void startOrResumeJob() {
|
||||
|
||||
inline void abortSDPrinting() {
|
||||
IF_DISABLED(NO_SD_AUTOSTART, card.autofile_cancel());
|
||||
card.endFilePrint(TERN_(SD_RESORT, true));
|
||||
card.abortFilePrintNow(TERN_(SD_RESORT, true));
|
||||
|
||||
queue.clear();
|
||||
quickstop_stepper();
|
||||
@@ -390,8 +402,8 @@ void startOrResumeJob() {
|
||||
}
|
||||
|
||||
inline void finishSDPrinting() {
|
||||
if (queue.enqueue_one_P(PSTR("M1001"))) {
|
||||
marlin_state = MF_RUNNING;
|
||||
if (queue.enqueue_one_P(PSTR("M1001"))) { // Keep trying until it gets queued
|
||||
marlin_state = MF_RUNNING; // Signal to stop trying
|
||||
TERN_(PASSWORD_AFTER_SD_PRINT_END, password.lock_machine());
|
||||
TERN_(DGUS_LCD_UI_MKS, ScreenHandler.SDPrintingFinished());
|
||||
}
|
||||
@@ -412,19 +424,18 @@ void startOrResumeJob() {
|
||||
* - Check if an idle but hot extruder needs filament extruded (EXTRUDER_RUNOUT_PREVENT)
|
||||
* - Pulse FET_SAFETY_PIN if it exists
|
||||
*/
|
||||
inline void manage_inactivity(const bool ignore_stepper_queue=false) {
|
||||
inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
|
||||
queue.get_available_commands();
|
||||
|
||||
const millis_t ms = millis();
|
||||
|
||||
// Prevent steppers timing-out in the middle of M600
|
||||
// unless PAUSE_PARK_NO_STEPPER_TIMEOUT is disabled
|
||||
const bool parked_or_ignoring = ignore_stepper_queue
|
||||
// Prevent steppers timing-out
|
||||
const bool do_reset_timeout = no_stepper_sleep
|
||||
|| TERN0(PAUSE_PARK_NO_STEPPER_TIMEOUT, did_pause_print);
|
||||
|
||||
// Reset both the M18/M84 activity timeout and the M85 max 'kill' timeout
|
||||
if (parked_or_ignoring) gcode.reset_stepper_timeout(ms);
|
||||
if (do_reset_timeout) gcode.reset_stepper_timeout(ms);
|
||||
|
||||
if (gcode.stepper_max_timed_out(ms)) {
|
||||
SERIAL_ERROR_MSG(STR_KILL_INACTIVE_TIME, parser.command_ptr);
|
||||
@@ -440,7 +451,7 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
|
||||
// activity timeout and the M85 max 'kill' timeout
|
||||
if (planner.has_blocks_queued())
|
||||
gcode.reset_stepper_timeout(ms);
|
||||
else if (!parked_or_ignoring && gcode.stepper_inactive_timeout()) {
|
||||
else if (!do_reset_timeout && gcode.stepper_inactive_timeout()) {
|
||||
if (!already_shutdown_steppers) {
|
||||
already_shutdown_steppers = true; // L6470 SPI will consume 99% of free time without this
|
||||
|
||||
@@ -448,6 +459,9 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
|
||||
if (ENABLED(DISABLE_INACTIVE_X)) DISABLE_AXIS_X();
|
||||
if (ENABLED(DISABLE_INACTIVE_Y)) DISABLE_AXIS_Y();
|
||||
if (ENABLED(DISABLE_INACTIVE_Z)) DISABLE_AXIS_Z();
|
||||
if (ENABLED(DISABLE_INACTIVE_I)) DISABLE_AXIS_I();
|
||||
if (ENABLED(DISABLE_INACTIVE_J)) DISABLE_AXIS_J();
|
||||
if (ENABLED(DISABLE_INACTIVE_K)) DISABLE_AXIS_K();
|
||||
if (ENABLED(DISABLE_INACTIVE_E)) disable_e_steppers();
|
||||
|
||||
TERN_(AUTO_BED_LEVELING_UBL, ubl.steppers_were_disabled());
|
||||
@@ -487,6 +501,10 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAS_FREEZE_PIN
|
||||
Stepper::frozen = !READ(FREEZE_PIN);
|
||||
#endif
|
||||
|
||||
#if HAS_HOME
|
||||
// Handle a standalone HOME button
|
||||
constexpr millis_t HOME_DEBOUNCE_DELAY = 1000UL;
|
||||
@@ -716,14 +734,14 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
|
||||
* - Update the Průša MMU2
|
||||
* - Handle Joystick jogging
|
||||
*/
|
||||
void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
|
||||
void idle(bool no_stepper_sleep/*=false*/) {
|
||||
#if ENABLED(MARLIN_DEV_MODE)
|
||||
static uint16_t idle_depth = 0;
|
||||
if (++idle_depth > 5) SERIAL_ECHOLNPAIR("idle() call depth: ", idle_depth);
|
||||
#endif
|
||||
|
||||
// Core Marlin activities
|
||||
manage_inactivity(TERN_(ADVANCED_PAUSE_FEATURE, no_stepper_sleep));
|
||||
manage_inactivity(no_stepper_sleep);
|
||||
|
||||
// Manage Heaters (and Watchdog)
|
||||
thermalManager.manage_heater();
|
||||
@@ -748,7 +766,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
|
||||
|
||||
// Handle Power-Loss Recovery
|
||||
#if ENABLED(POWER_LOSS_RECOVERY) && PIN_EXISTS(POWER_LOSS)
|
||||
if (printJobOngoing()) recovery.outage();
|
||||
if (IS_SD_PRINTING()) recovery.outage();
|
||||
#endif
|
||||
|
||||
// Run StallGuard endstop checks
|
||||
@@ -796,6 +814,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
|
||||
if (!gcode.autoreport_paused) {
|
||||
TERN_(AUTO_REPORT_TEMPERATURES, thermalManager.auto_reporter.tick());
|
||||
TERN_(AUTO_REPORT_SD_STATUS, card.auto_reporter.tick());
|
||||
TERN_(AUTO_REPORT_POSITION, position_auto_reporter.tick());
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -825,18 +844,19 @@ void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr
|
||||
|
||||
TERN_(HAS_CUTTER, cutter.kill()); // Full cutter shutdown including ISR control
|
||||
|
||||
SERIAL_ERROR_MSG(STR_ERR_KILLED);
|
||||
// Echo the LCD message to serial for extra context
|
||||
if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNPGM_P(lcd_error); }
|
||||
|
||||
#if HAS_DISPLAY
|
||||
ui.kill_screen(lcd_error ?: GET_TEXT(MSG_KILLED), lcd_component ?: NUL_STR);
|
||||
#else
|
||||
UNUSED(lcd_error);
|
||||
UNUSED(lcd_component);
|
||||
UNUSED(lcd_error); UNUSED(lcd_component);
|
||||
#endif
|
||||
|
||||
#if HAS_TFT_LVGL_UI
|
||||
lv_draw_error_message(lcd_error);
|
||||
#endif
|
||||
TERN_(HAS_TFT_LVGL_UI, lv_draw_error_message(lcd_error));
|
||||
|
||||
// "Error:Printer halted. kill() called!"
|
||||
SERIAL_ERROR_MSG(STR_ERR_KILLED);
|
||||
|
||||
#ifdef ACTION_ON_KILL
|
||||
host_action_kill();
|
||||
@@ -900,7 +920,7 @@ void stop() {
|
||||
thermalManager.set_fans_paused(false); // Un-pause fans for safety
|
||||
#endif
|
||||
|
||||
if (IsRunning()) {
|
||||
if (!IsStopped()) {
|
||||
SERIAL_ERROR_MSG(STR_ERR_STOPPED);
|
||||
LCD_MESSAGEPGM(MSG_STOPPED);
|
||||
safe_delay(350); // allow enough time for messages to get out before stopping
|
||||
@@ -933,6 +953,15 @@ inline void tmc_standby_setup() {
|
||||
#if PIN_EXISTS(Z4_STDBY)
|
||||
SET_INPUT_PULLDOWN(Z4_STDBY_PIN);
|
||||
#endif
|
||||
#if PIN_EXISTS(I_STDBY)
|
||||
SET_INPUT_PULLDOWN(I_STDBY_PIN);
|
||||
#endif
|
||||
#if PIN_EXISTS(J_STDBY)
|
||||
SET_INPUT_PULLDOWN(J_STDBY_PIN);
|
||||
#endif
|
||||
#if PIN_EXISTS(K_STDBY)
|
||||
SET_INPUT_PULLDOWN(K_STDBY_PIN);
|
||||
#endif
|
||||
#if PIN_EXISTS(E0_STDBY)
|
||||
SET_INPUT_PULLDOWN(E0_STDBY_PIN);
|
||||
#endif
|
||||
@@ -1071,9 +1100,20 @@ void setup() {
|
||||
while (!MYSERIAL1.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
||||
|
||||
#if HAS_MULTI_SERIAL && !HAS_ETHERNET
|
||||
MYSERIAL2.begin(BAUDRATE);
|
||||
#ifndef BAUDRATE_2
|
||||
#define BAUDRATE_2 BAUDRATE
|
||||
#endif
|
||||
MYSERIAL2.begin(BAUDRATE_2);
|
||||
serial_connect_timeout = millis() + 1000UL;
|
||||
while (!MYSERIAL2.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
||||
#ifdef SERIAL_PORT_3
|
||||
#ifndef BAUDRATE_3
|
||||
#define BAUDRATE_3 BAUDRATE
|
||||
#endif
|
||||
MYSERIAL3.begin(BAUDRATE_3);
|
||||
serial_connect_timeout = millis() + 1000UL;
|
||||
while (!MYSERIAL3.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
||||
#endif
|
||||
#endif
|
||||
SERIAL_ECHOLNPGM("start");
|
||||
|
||||
@@ -1087,16 +1127,29 @@ void setup() {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_FREEZE_PIN
|
||||
SETUP_LOG("FREEZE_PIN");
|
||||
SET_INPUT_PULLUP(FREEZE_PIN);
|
||||
#endif
|
||||
|
||||
#if HAS_SUICIDE
|
||||
SETUP_LOG("SUICIDE_PIN");
|
||||
OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_INVERTING);
|
||||
#endif
|
||||
|
||||
#ifdef JTAGSWD_RESET
|
||||
SETUP_LOG("JTAGSWD_RESET");
|
||||
JTAGSWD_RESET();
|
||||
#endif
|
||||
|
||||
#if EITHER(DISABLE_DEBUG, DISABLE_JTAG)
|
||||
delay(10);
|
||||
// Disable any hardware debug to free up pins for IO
|
||||
#if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE)
|
||||
SETUP_LOG("JTAGSWD_DISABLE");
|
||||
JTAGSWD_DISABLE();
|
||||
#elif defined(JTAG_DISABLE)
|
||||
SETUP_LOG("JTAG_DISABLE");
|
||||
JTAG_DISABLE();
|
||||
#else
|
||||
#error "DISABLE_(DEBUG|JTAG) is not supported for the selected MCU/Board."
|
||||
@@ -1115,10 +1168,10 @@ void setup() {
|
||||
SETUP_RUN(HAL_init());
|
||||
|
||||
// Init and disable SPI thermocouples; this is still needed
|
||||
#if TEMP_SENSOR_0_IS_MAX_TC
|
||||
#if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 0)
|
||||
OUT_WRITE(MAX6675_SS_PIN, HIGH); // Disable
|
||||
#endif
|
||||
#if TEMP_SENSOR_1_IS_MAX_TC
|
||||
#if TEMP_SENSOR_1_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 1)
|
||||
OUT_WRITE(MAX6675_SS2_PIN, HIGH); // Disable
|
||||
#endif
|
||||
|
||||
@@ -1406,10 +1459,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if HAS_PRUSA_MMU1
|
||||
SETUP_LOG("Prusa MMU1");
|
||||
SET_OUTPUT(E_MUX0_PIN);
|
||||
SET_OUTPUT(E_MUX1_PIN);
|
||||
SET_OUTPUT(E_MUX2_PIN);
|
||||
SETUP_RUN(mmu_init());
|
||||
#endif
|
||||
|
||||
#if HAS_FANMUX
|
||||
@@ -1477,7 +1527,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF)
|
||||
SETUP_RUN(test_tmc_connection(true, true, true, true));
|
||||
SETUP_RUN(test_tmc_connection());
|
||||
#endif
|
||||
|
||||
#if HAS_DRIVER_SAFE_POWER_PROTECT
|
||||
|
@@ -34,8 +34,8 @@
|
||||
void stop();
|
||||
|
||||
// Pass true to keep steppers from timing out
|
||||
void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep=false));
|
||||
inline void idle_no_sleep() { idle(TERN_(ADVANCED_PAUSE_FEATURE, true)); }
|
||||
void idle(bool no_stepper_sleep=false);
|
||||
inline void idle_no_sleep() { idle(true); }
|
||||
|
||||
#if ENABLED(G38_PROBE_TARGET)
|
||||
extern uint8_t G38_move; // Flag to tell the ISR that G38 is in progress, and the type
|
||||
@@ -56,20 +56,21 @@ void minkill(const bool steppers_off=false);
|
||||
|
||||
// Global State of the firmware
|
||||
enum MarlinState : uint8_t {
|
||||
MF_INITIALIZING = 0,
|
||||
MF_RUNNING = _BV(0),
|
||||
MF_PAUSED = _BV(1),
|
||||
MF_WAITING = _BV(2),
|
||||
MF_STOPPED = _BV(3),
|
||||
MF_SD_COMPLETE = _BV(4),
|
||||
MF_KILLED = _BV(7)
|
||||
MF_INITIALIZING = 0,
|
||||
MF_STOPPED,
|
||||
MF_KILLED,
|
||||
MF_RUNNING,
|
||||
MF_SD_COMPLETE,
|
||||
MF_PAUSED,
|
||||
MF_WAITING,
|
||||
};
|
||||
|
||||
extern MarlinState marlin_state;
|
||||
inline bool IsRunning() { return marlin_state == MF_RUNNING; }
|
||||
inline bool IsStopped() { return marlin_state != MF_RUNNING; }
|
||||
inline bool IsRunning() { return marlin_state >= MF_RUNNING; }
|
||||
inline bool IsStopped() { return marlin_state == MF_STOPPED; }
|
||||
|
||||
bool printingIsActive();
|
||||
bool printJobOngoing();
|
||||
bool printingIsPaused();
|
||||
void startOrResumeJob();
|
||||
|
||||
|
@@ -159,6 +159,7 @@
|
||||
#define BOARD_PICA_REVB 1324 // PICA Shield (original version)
|
||||
#define BOARD_PICA 1325 // PICA Shield (rev C or later)
|
||||
#define BOARD_INTAMSYS40 1326 // Intamsys 4.0 (Funmat HT)
|
||||
#define BOARD_MALYAN_M180 1327 // Malyan M180 Mainboard Version 2 (no display function, direct gcode only)
|
||||
|
||||
//
|
||||
// ATmega1281, ATmega2561
|
||||
@@ -320,7 +321,7 @@
|
||||
#define BOARD_BTT_SKR_MINI_V1_1 4023 // BigTreeTech SKR Mini v1.1 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_MINI_E3_V1_0 4024 // BigTreeTech SKR Mini E3 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_MINI_E3_V1_2 4025 // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_MINI_E3_V2_0 4026 // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_MINI_E3_V2_0 4026 // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_BTT_SKR_MINI_MZ_V1_0 4027 // BigTreeTech SKR Mini MZ V1.0 (STM32F103RC)
|
||||
#define BOARD_BTT_SKR_E3_DIP 4028 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE)
|
||||
#define BOARD_BTT_SKR_CR6 4029 // BigTreeTech SKR CR6 v1.0 (STM32F103RE)
|
||||
@@ -367,22 +368,26 @@
|
||||
#define BOARD_BTT_SKR_PRO_V1_2 4208 // BigTreeTech SKR Pro v1.2 (STM32F407ZGT6)
|
||||
#define BOARD_BTT_BTT002_V1_0 4209 // BigTreeTech BTT002 v1.0 (STM32F407VGT6)
|
||||
#define BOARD_BTT_E3_RRF 4210 // BigTreeTech E3 RRF (STM32F407VGT6)
|
||||
#define BOARD_BTT_SKR_V2_0 4211 // BigTreeTech SKR v2.0 (STM32F407VGT6)
|
||||
#define BOARD_BTT_GTR_V1_0 4212 // BigTreeTech GTR v1.0 (STM32F407IGT)
|
||||
#define BOARD_LERDGE_K 4213 // Lerdge K (STM32F407ZG)
|
||||
#define BOARD_LERDGE_S 4214 // Lerdge S (STM32F407VE)
|
||||
#define BOARD_LERDGE_X 4215 // Lerdge X (STM32F407VE)
|
||||
#define BOARD_VAKE403D 4216 // VAkE 403D (STM32F446VET6)
|
||||
#define BOARD_FYSETC_S6 4217 // FYSETC S6 (STM32F446VET6)
|
||||
#define BOARD_FYSETC_S6_V2_0 4218 // FYSETC S6 v2.0 (STM32F446VET6)
|
||||
#define BOARD_FYSETC_SPIDER 4219 // FYSETC Spider (STM32F446VET6)
|
||||
#define BOARD_FLYF407ZG 4220 // FLYF407ZG (STM32F407ZG)
|
||||
#define BOARD_MKS_ROBIN2 4221 // MKS_ROBIN2 (STM32F407ZE)
|
||||
#define BOARD_MKS_ROBIN_PRO_V2 4222 // MKS Robin Pro V2 (STM32F407VE)
|
||||
#define BOARD_MKS_ROBIN_NANO_V3 4223 // MKS Robin Nano V3 (STM32F407VG)
|
||||
#define BOARD_ANET_ET4 4224 // ANET ET4 V1.x (STM32F407VGT6)
|
||||
#define BOARD_ANET_ET4P 4225 // ANET ET4P V1.x (STM32F407VGT6)
|
||||
#define BOARD_FYSETC_CHEETAH_V20 4226 // FYSETC Cheetah V2.0
|
||||
#define BOARD_BTT_SKR_V2_0_REV_A 4211 // BigTreeTech SKR v2.0 Rev A (STM32F407VGT6)
|
||||
#define BOARD_BTT_SKR_V2_0_REV_B 4212 // BigTreeTech SKR v2.0 Rev B (STM32F407VGT6)
|
||||
#define BOARD_BTT_GTR_V1_0 4213 // BigTreeTech GTR v1.0 (STM32F407IGT)
|
||||
#define BOARD_BTT_OCTOPUS_V1_0 4214 // BigTreeTech Octopus v1.0 (STM32F446ZET6)
|
||||
#define BOARD_BTT_OCTOPUS_V1_1 4215 // BigTreeTech Octopus v1.1 (STM32F446ZET6)
|
||||
#define BOARD_LERDGE_K 4216 // Lerdge K (STM32F407ZG)
|
||||
#define BOARD_LERDGE_S 4217 // Lerdge S (STM32F407VE)
|
||||
#define BOARD_LERDGE_X 4218 // Lerdge X (STM32F407VE)
|
||||
#define BOARD_VAKE403D 4219 // VAkE 403D (STM32F446VET6)
|
||||
#define BOARD_FYSETC_S6 4220 // FYSETC S6 (STM32F446VET6)
|
||||
#define BOARD_FYSETC_S6_V2_0 4221 // FYSETC S6 v2.0 (STM32F446VET6)
|
||||
#define BOARD_FYSETC_SPIDER 4222 // FYSETC Spider (STM32F446VET6)
|
||||
#define BOARD_FLYF407ZG 4223 // FLYF407ZG (STM32F407ZG)
|
||||
#define BOARD_MKS_ROBIN2 4224 // MKS_ROBIN2 (STM32F407ZE)
|
||||
#define BOARD_MKS_ROBIN_PRO_V2 4225 // MKS Robin Pro V2 (STM32F407VE)
|
||||
#define BOARD_MKS_ROBIN_NANO_V3 4226 // MKS Robin Nano V3 (STM32F407VG)
|
||||
#define BOARD_ANET_ET4 4227 // ANET ET4 V1.x (STM32F407VGT6)
|
||||
#define BOARD_ANET_ET4P 4228 // ANET ET4P V1.x (STM32F407VGT6)
|
||||
#define BOARD_FYSETC_CHEETAH_V20 4229 // FYSETC Cheetah V2.0
|
||||
|
||||
|
||||
//
|
||||
// ARM Cortex M7
|
||||
|
@@ -44,6 +44,6 @@ private:
|
||||
SERIAL_ECHOPGM_P(the_msg);
|
||||
}
|
||||
SERIAL_CHAR(' ');
|
||||
print_xyz(current_position);
|
||||
print_pos(current_position);
|
||||
}
|
||||
};
|
||||
|
@@ -60,6 +60,9 @@
|
||||
#define AXIS_DRIVER_TYPE_X(T) _AXIS_DRIVER_TYPE(X,T)
|
||||
#define AXIS_DRIVER_TYPE_Y(T) _AXIS_DRIVER_TYPE(Y,T)
|
||||
#define AXIS_DRIVER_TYPE_Z(T) _AXIS_DRIVER_TYPE(Z,T)
|
||||
#define AXIS_DRIVER_TYPE_I(T) _AXIS_DRIVER_TYPE(I,T)
|
||||
#define AXIS_DRIVER_TYPE_J(T) _AXIS_DRIVER_TYPE(J,T)
|
||||
#define AXIS_DRIVER_TYPE_K(T) _AXIS_DRIVER_TYPE(K,T)
|
||||
|
||||
#define AXIS_DRIVER_TYPE_X2(T) (EITHER(X_DUAL_STEPPER_DRIVERS, DUAL_X_CARRIAGE) && _AXIS_DRIVER_TYPE(X2,T))
|
||||
#define AXIS_DRIVER_TYPE_Y2(T) (ENABLED(Y_DUAL_STEPPER_DRIVERS) && _AXIS_DRIVER_TYPE(Y2,T))
|
||||
@@ -83,6 +86,7 @@
|
||||
#define HAS_E_DRIVER(T) (0 RREPEAT2(E_STEPPERS, _OR_ADTE, T))
|
||||
|
||||
#define HAS_DRIVER(T) ( AXIS_DRIVER_TYPE_X(T) || AXIS_DRIVER_TYPE_Y(T) || AXIS_DRIVER_TYPE_Z(T) \
|
||||
|| AXIS_DRIVER_TYPE_I(T) || AXIS_DRIVER_TYPE_J(T) || AXIS_DRIVER_TYPE_K(T) \
|
||||
|| AXIS_DRIVER_TYPE_X2(T) || AXIS_DRIVER_TYPE_Y2(T) || AXIS_DRIVER_TYPE_Z2(T) \
|
||||
|| AXIS_DRIVER_TYPE_Z3(T) || AXIS_DRIVER_TYPE_Z4(T) || HAS_E_DRIVER(T) )
|
||||
|
||||
@@ -153,9 +157,11 @@
|
||||
#define _OR_EAH(N,T) || AXIS_HAS_##T(E##N)
|
||||
#define E_AXIS_HAS(T) (0 _OR_EAH(0,T) _OR_EAH(1,T) _OR_EAH(2,T) _OR_EAH(3,T) _OR_EAH(4,T) _OR_EAH(5,T) _OR_EAH(6,T) _OR_EAH(7,T))
|
||||
|
||||
#define ANY_AXIS_HAS(T) ( AXIS_HAS_##T(X) || AXIS_HAS_##T(Y) || AXIS_HAS_##T(Z) \
|
||||
|| AXIS_HAS_##T(X2) || AXIS_HAS_##T(Y2) || AXIS_HAS_##T(Z2) \
|
||||
|| AXIS_HAS_##T(Z3) || AXIS_HAS_##T(Z4) || E_AXIS_HAS(T) )
|
||||
#define ANY_AXIS_HAS(T) ( AXIS_HAS_##T(X) || AXIS_HAS_##T(X2) \
|
||||
|| AXIS_HAS_##T(Y) || AXIS_HAS_##T(Y2) \
|
||||
|| AXIS_HAS_##T(Z) || AXIS_HAS_##T(Z2) || AXIS_HAS_##T(Z3) || AXIS_HAS_##T(Z4) \
|
||||
|| AXIS_HAS_##T(I) || AXIS_HAS_##T(J) || AXIS_HAS_##T(K) \
|
||||
|| E_AXIS_HAS(T) )
|
||||
|
||||
#if ANY_AXIS_HAS(STEALTHCHOP)
|
||||
#define HAS_STEALTHCHOP 1
|
||||
|
@@ -140,25 +140,7 @@
|
||||
#define STR_RESEND "Resend: "
|
||||
#define STR_UNKNOWN_COMMAND "Unknown command: \""
|
||||
#define STR_ACTIVE_EXTRUDER "Active Extruder: "
|
||||
#define STR_X_MIN "x_min"
|
||||
#define STR_X_MAX "x_max"
|
||||
#define STR_X2_MIN "x2_min"
|
||||
#define STR_X2_MAX "x2_max"
|
||||
#define STR_Y_MIN "y_min"
|
||||
#define STR_Y_MAX "y_max"
|
||||
#define STR_Y2_MIN "y2_min"
|
||||
#define STR_Y2_MAX "y2_max"
|
||||
#define STR_Z_MIN "z_min"
|
||||
#define STR_Z_MAX "z_max"
|
||||
#define STR_Z2_MIN "z2_min"
|
||||
#define STR_Z2_MAX "z2_max"
|
||||
#define STR_Z3_MIN "z3_min"
|
||||
#define STR_Z3_MAX "z3_max"
|
||||
#define STR_Z4_MIN "z4_min"
|
||||
#define STR_Z4_MAX "z4_max"
|
||||
#define STR_Z_PROBE "z_probe"
|
||||
#define STR_PROBE_EN "probe_en"
|
||||
#define STR_FILAMENT_RUNOUT_SENSOR "filament"
|
||||
|
||||
#define STR_PROBE_OFFSET "Probe Offset"
|
||||
#define STR_SKEW_MIN "min_skew_factor: "
|
||||
#define STR_SKEW_MAX "max_skew_factor: "
|
||||
@@ -277,17 +259,43 @@
|
||||
#define STR_REMINDER_SAVE_SETTINGS "Remember to save!"
|
||||
#define STR_PASSWORD_SET "Password is "
|
||||
|
||||
// LCD Menu Messages
|
||||
//
|
||||
// Endstop Names used by Endstops::report_states
|
||||
//
|
||||
#define STR_X_MIN "x_min"
|
||||
#define STR_X_MAX "x_max"
|
||||
#define STR_X2_MIN "x2_min"
|
||||
#define STR_X2_MAX "x2_max"
|
||||
|
||||
#define LANGUAGE_DATA_INCL_(M) STRINGIFY_(fontdata/langdata_##M.h)
|
||||
#define LANGUAGE_DATA_INCL(M) LANGUAGE_DATA_INCL_(M)
|
||||
#if HAS_Y_AXIS
|
||||
#define STR_Y_MIN "y_min"
|
||||
#define STR_Y_MAX "y_max"
|
||||
#define STR_Y2_MIN "y2_min"
|
||||
#define STR_Y2_MAX "y2_max"
|
||||
#endif
|
||||
|
||||
#define LANGUAGE_INCL_(M) STRINGIFY_(../lcd/language/language_##M.h)
|
||||
#define LANGUAGE_INCL(M) LANGUAGE_INCL_(M)
|
||||
#if HAS_Z_AXIS
|
||||
#define STR_Z_MIN "z_min"
|
||||
#define STR_Z_MAX "z_max"
|
||||
#define STR_Z2_MIN "z2_min"
|
||||
#define STR_Z2_MAX "z2_max"
|
||||
#define STR_Z3_MIN "z3_min"
|
||||
#define STR_Z3_MAX "z3_max"
|
||||
#define STR_Z4_MIN "z4_min"
|
||||
#define STR_Z4_MAX "z4_max"
|
||||
#endif
|
||||
|
||||
#define STR_Z_PROBE "z_probe"
|
||||
#define STR_PROBE_EN "probe_en"
|
||||
#define STR_FILAMENT_RUNOUT_SENSOR "filament"
|
||||
|
||||
// General axis names
|
||||
#define STR_X "X"
|
||||
#define STR_Y "Y"
|
||||
#define STR_Z "Z"
|
||||
#define STR_I AXIS4_STR
|
||||
#define STR_J AXIS5_STR
|
||||
#define STR_K AXIS6_STR
|
||||
#define STR_E "E"
|
||||
#if IS_KINEMATIC
|
||||
#define STR_A "A"
|
||||
@@ -307,8 +315,114 @@
|
||||
#define LCD_STR_A STR_A
|
||||
#define LCD_STR_B STR_B
|
||||
#define LCD_STR_C STR_C
|
||||
#define LCD_STR_I STR_I
|
||||
#define LCD_STR_J STR_J
|
||||
#define LCD_STR_K STR_K
|
||||
#define LCD_STR_E STR_E
|
||||
|
||||
// Extra Axis and Endstop Names
|
||||
#if LINEAR_AXES >= 4
|
||||
#if AXIS4_NAME == 'A'
|
||||
#define AXIS4_STR "A"
|
||||
#define STR_I_MIN "a_min"
|
||||
#define STR_I_MAX "a_max"
|
||||
#elif AXIS4_NAME == 'B'
|
||||
#define AXIS4_STR "B"
|
||||
#define STR_I_MIN "b_min"
|
||||
#define STR_I_MAX "b_max"
|
||||
#elif AXIS4_NAME == 'C'
|
||||
#define AXIS4_STR "C"
|
||||
#define STR_I_MIN "c_min"
|
||||
#define STR_I_MAX "c_max"
|
||||
#elif AXIS4_NAME == 'U'
|
||||
#define AXIS4_STR "U"
|
||||
#define STR_I_MIN "u_min"
|
||||
#define STR_I_MAX "u_max"
|
||||
#elif AXIS4_NAME == 'V'
|
||||
#define AXIS4_STR "V"
|
||||
#define STR_I_MIN "v_min"
|
||||
#define STR_I_MAX "v_max"
|
||||
#elif AXIS4_NAME == 'W'
|
||||
#define AXIS4_STR "W"
|
||||
#define STR_I_MIN "w_min"
|
||||
#define STR_I_MAX "w_max"
|
||||
#else
|
||||
#define AXIS4_STR "A"
|
||||
#define STR_I_MIN "a_min"
|
||||
#define STR_I_MAX "a_max"
|
||||
#endif
|
||||
#else
|
||||
#define AXIS4_STR ""
|
||||
#endif
|
||||
|
||||
#if LINEAR_AXES >= 5
|
||||
#if AXIS5_NAME == 'A'
|
||||
#define AXIS5_STR "A"
|
||||
#define STR_J_MIN "a_min"
|
||||
#define STR_J_MAX "a_max"
|
||||
#elif AXIS5_NAME == 'B'
|
||||
#define AXIS5_STR "B"
|
||||
#define STR_J_MIN "b_min"
|
||||
#define STR_J_MAX "b_max"
|
||||
#elif AXIS5_NAME == 'C'
|
||||
#define AXIS5_STR "C"
|
||||
#define STR_J_MIN "c_min"
|
||||
#define STR_J_MAX "c_max"
|
||||
#elif AXIS5_NAME == 'U'
|
||||
#define AXIS5_STR "U"
|
||||
#define STR_J_MIN "u_min"
|
||||
#define STR_J_MAX "u_max"
|
||||
#elif AXIS5_NAME == 'V'
|
||||
#define AXIS5_STR "V"
|
||||
#define STR_J_MIN "v_min"
|
||||
#define STR_J_MAX "v_max"
|
||||
#elif AXIS5_NAME == 'W'
|
||||
#define AXIS5_STR "W"
|
||||
#define STR_J_MIN "w_min"
|
||||
#define STR_J_MAX "w_max"
|
||||
#else
|
||||
#define AXIS5_STR "B"
|
||||
#define STR_J_MIN "b_min"
|
||||
#define STR_J_MAX "b_max"
|
||||
#endif
|
||||
#else
|
||||
#define AXIS5_STR ""
|
||||
#endif
|
||||
|
||||
#if LINEAR_AXES >= 6
|
||||
#if AXIS6_NAME == 'A'
|
||||
#define AXIS6_STR "A"
|
||||
#define STR_K_MIN "a_min"
|
||||
#define STR_K_MAX "a_max"
|
||||
#elif AXIS6_NAME == 'B'
|
||||
#define AXIS6_STR "B"
|
||||
#define STR_K_MIN "b_min"
|
||||
#define STR_K_MAX "b_max"
|
||||
#elif AXIS6_NAME == 'C'
|
||||
#define AXIS6_STR "C"
|
||||
#define STR_K_MIN "c_min"
|
||||
#define STR_K_MAX "c_max"
|
||||
#elif AXIS6_NAME == 'U'
|
||||
#define AXIS6_STR "U"
|
||||
#define STR_K_MIN "u_min"
|
||||
#define STR_K_MAX "u_max"
|
||||
#elif AXIS6_NAME == 'V'
|
||||
#define AXIS6_STR "V"
|
||||
#define STR_K_MIN "v_min"
|
||||
#define STR_K_MAX "v_max"
|
||||
#elif AXIS6_NAME == 'W'
|
||||
#define AXIS6_STR "W"
|
||||
#define STR_K_MIN "w_min"
|
||||
#define STR_K_MAX "w_max"
|
||||
#else
|
||||
#define AXIS6_STR "C"
|
||||
#define STR_K_MIN "c_min"
|
||||
#define STR_K_MAX "c_max"
|
||||
#endif
|
||||
#else
|
||||
#define AXIS6_STR ""
|
||||
#endif
|
||||
|
||||
#if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
|
||||
|
||||
// Custom characters defined in the first 8 characters of the LCD
|
||||
@@ -386,6 +500,14 @@
|
||||
#define LCD_STR_E6 "E" LCD_STR_N6
|
||||
#define LCD_STR_E7 "E" LCD_STR_N7
|
||||
|
||||
// Include localized LCD Menu Messages
|
||||
|
||||
#define LANGUAGE_DATA_INCL_(M) STRINGIFY_(fontdata/langdata_##M.h)
|
||||
#define LANGUAGE_DATA_INCL(M) LANGUAGE_DATA_INCL_(M)
|
||||
|
||||
#define LANGUAGE_INCL_(M) STRINGIFY_(../lcd/language/language_##M.h)
|
||||
#define LANGUAGE_INCL(M) LANGUAGE_INCL_(M)
|
||||
|
||||
// Use superscripts, if possible. Evaluated at point of use.
|
||||
#define SUPERSCRIPT_TWO TERN(NOT_EXTENDED_ISO10646_1_5X7, "^2", "²")
|
||||
#define SUPERSCRIPT_THREE TERN(NOT_EXTENDED_ISO10646_1_5X7, "^3", "³")
|
||||
|
@@ -36,12 +36,21 @@
|
||||
#define _XMIN_ 100
|
||||
#define _YMIN_ 200
|
||||
#define _ZMIN_ 300
|
||||
#define _IMIN_ 500
|
||||
#define _JMIN_ 600
|
||||
#define _KMIN_ 700
|
||||
#define _XMAX_ 101
|
||||
#define _YMAX_ 201
|
||||
#define _ZMAX_ 301
|
||||
#define _IMAX_ 501
|
||||
#define _JMAX_ 601
|
||||
#define _KMAX_ 701
|
||||
#define _XDIAG_ 102
|
||||
#define _YDIAG_ 202
|
||||
#define _ZDIAG_ 302
|
||||
#define _IDIAG_ 502
|
||||
#define _JDIAG_ 602
|
||||
#define _KDIAG_ 702
|
||||
#define _E0DIAG_ 400
|
||||
#define _E1DIAG_ 401
|
||||
#define _E2DIAG_ 402
|
||||
@@ -195,6 +204,11 @@
|
||||
#define __TERN(T,V...) ___TERN(_CAT(_NO,T),V) // Prepend '_NO' to get '_NOT_0' or '_NOT_1'
|
||||
#define ___TERN(P,V...) THIRD(P,V) // If first argument has a comma, A. Else B.
|
||||
|
||||
#define _OPTARG(A) , A
|
||||
#define OPTARG(O,A) TERN_(O,DEFER4(_OPTARG)(A))
|
||||
#define _OPTCODE(A) A;
|
||||
#define OPTCODE(O,A) TERN_(O,DEFER4(_OPTCODE)(A))
|
||||
|
||||
// Macros to avoid 'f + 0.0' which is not always optimized away. Minus included for symmetry.
|
||||
// Compiler flags -fno-signed-zeros -ffinite-math-only also cover 'f * 1.0', 'f - f', etc.
|
||||
#define PLUS_TERN0(O,A) _TERN(_ENA_1(O),,+ (A)) // OPTION ? '+ (A)' : '<nul>'
|
||||
@@ -237,6 +251,38 @@
|
||||
memcpy(&a[0],&b[0],_MIN(sizeof(a),sizeof(b))); \
|
||||
}while(0)
|
||||
|
||||
#define CODE_9( A,B,C,D,E,F,G,H,I,...) A; B; C; D; E; F; G; H; I
|
||||
#define CODE_8( A,B,C,D,E,F,G,H,...) A; B; C; D; E; F; G; H
|
||||
#define CODE_7( A,B,C,D,E,F,G,...) A; B; C; D; E; F; G
|
||||
#define CODE_6( A,B,C,D,E,F,...) A; B; C; D; E; F
|
||||
#define CODE_5( A,B,C,D,E,...) A; B; C; D; E
|
||||
#define CODE_4( A,B,C,D,...) A; B; C; D
|
||||
#define CODE_3( A,B,C,...) A; B; C
|
||||
#define CODE_2( A,B,...) A; B
|
||||
#define CODE_1( A,...) A
|
||||
#define _CODE_N(N,V...) CODE_##N(V)
|
||||
#define CODE_N(N,V...) _CODE_N(N,V)
|
||||
|
||||
#define GANG_16(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,...) A B C D E F G H I J K L M N O P
|
||||
#define GANG_15(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,...) A B C D E F G H I J K L M N O
|
||||
#define GANG_14(A,B,C,D,E,F,G,H,I,J,K,L,M,N,...) A B C D E F G H I J K L M N
|
||||
#define GANG_13(A,B,C,D,E,F,G,H,I,J,K,L,M...) A B C D E F G H I J K L M
|
||||
#define GANG_12(A,B,C,D,E,F,G,H,I,J,K,L...) A B C D E F G H I J K L
|
||||
#define GANG_11(A,B,C,D,E,F,G,H,I,J,K,...) A B C D E F G H I J K
|
||||
#define GANG_10(A,B,C,D,E,F,G,H,I,J,...) A B C D E F G H I J
|
||||
#define GANG_9( A,B,C,D,E,F,G,H,I,...) A B C D E F G H I
|
||||
#define GANG_8( A,B,C,D,E,F,G,H,...) A B C D E F G H
|
||||
#define GANG_7( A,B,C,D,E,F,G,...) A B C D E F G
|
||||
#define GANG_6( A,B,C,D,E,F,...) A B C D E F
|
||||
#define GANG_5( A,B,C,D,E,...) A B C D E
|
||||
#define GANG_4( A,B,C,D,...) A B C D
|
||||
#define GANG_3( A,B,C,...) A B C
|
||||
#define GANG_2( A,B,...) A B
|
||||
#define GANG_1( A,...) A
|
||||
#define _GANG_N(N,V...) GANG_##N(V)
|
||||
#define GANG_N(N,V...) _GANG_N(N,V)
|
||||
#define GANG_N_1(N,K) _GANG_N(N,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K)
|
||||
|
||||
// Macros for initializing arrays
|
||||
#define LIST_16(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P
|
||||
#define LIST_15(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O
|
||||
@@ -254,10 +300,13 @@
|
||||
#define LIST_3( A,B,C,...) A,B,C
|
||||
#define LIST_2( A,B,...) A,B
|
||||
#define LIST_1( A,...) A
|
||||
#define LIST_0(...)
|
||||
|
||||
#define _LIST_N(N,V...) LIST_##N(V)
|
||||
#define LIST_N(N,V...) _LIST_N(N,V)
|
||||
#define LIST_N_1(N,K) _LIST_N(N,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K)
|
||||
#define ARRAY_N(N,V...) { _LIST_N(N,V) }
|
||||
#define ARRAY_N_1(N,K) { LIST_N_1(N,K) }
|
||||
|
||||
#define _JOIN_1(O) (O)
|
||||
#define JOIN_N(N,C,V...) (DO(JOIN,C,LIST_N(N,V)))
|
||||
@@ -301,8 +350,12 @@
|
||||
#define HYPOT(x,y) SQRT(HYPOT2(x,y))
|
||||
|
||||
// Use NUM_ARGS(__VA_ARGS__) to get the number of variadic arguments
|
||||
#define _NUM_ARGS(_,Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C,B,A,OUT,...) OUT
|
||||
#define NUM_ARGS(V...) _NUM_ARGS(0,V,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
|
||||
#define _NUM_ARGS(_,n,m,l,k,j,i,h,g,f,e,d,c,b,a,Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C,B,A,OUT,...) OUT
|
||||
#define NUM_ARGS(V...) _NUM_ARGS(0,V,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
|
||||
|
||||
// Use TWO_ARGS(__VA_ARGS__) to get whether there are 1, 2, or >2 arguments
|
||||
#define _TWO_ARGS(_,n,m,l,k,j,i,h,g,f,e,d,c,b,a,Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C,B,A,OUT,...) OUT
|
||||
#define TWO_ARGS(V...) _TWO_ARGS(0,V,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,1,0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -414,31 +467,19 @@
|
||||
|
||||
#else
|
||||
|
||||
#define MIN_2(a,b) ((a)<(b)?(a):(b))
|
||||
#define MIN_3(a,V...) MIN_2(a,MIN_2(V))
|
||||
#define MIN_4(a,V...) MIN_2(a,MIN_3(V))
|
||||
#define MIN_5(a,V...) MIN_2(a,MIN_4(V))
|
||||
#define MIN_6(a,V...) MIN_2(a,MIN_5(V))
|
||||
#define MIN_7(a,V...) MIN_2(a,MIN_6(V))
|
||||
#define MIN_8(a,V...) MIN_2(a,MIN_7(V))
|
||||
#define MIN_9(a,V...) MIN_2(a,MIN_8(V))
|
||||
#define MIN_10(a,V...) MIN_2(a,MIN_9(V))
|
||||
#define __MIN_N(N,V...) MIN_##N(V)
|
||||
#define _MIN_N(N,V...) __MIN_N(N,V)
|
||||
#define _MIN(V...) _MIN_N(NUM_ARGS(V), V)
|
||||
#define _MIN_N_REF() _MIN_N
|
||||
#define _MIN(V...) EVAL(_MIN_N(TWO_ARGS(V),V))
|
||||
#define MIN_2(a,b) ((a)<(b)?(a):(b))
|
||||
#define MIN_3(a,V...) MIN_2(a,DEFER2(_MIN_N_REF)()(TWO_ARGS(V),V))
|
||||
|
||||
#define MAX_2(a,b) ((a)>(b)?(a):(b))
|
||||
#define MAX_3(a,V...) MAX_2(a,MAX_2(V))
|
||||
#define MAX_4(a,V...) MAX_2(a,MAX_3(V))
|
||||
#define MAX_5(a,V...) MAX_2(a,MAX_4(V))
|
||||
#define MAX_6(a,V...) MAX_2(a,MAX_5(V))
|
||||
#define MAX_7(a,V...) MAX_2(a,MAX_6(V))
|
||||
#define MAX_8(a,V...) MAX_2(a,MAX_7(V))
|
||||
#define MAX_9(a,V...) MAX_2(a,MAX_8(V))
|
||||
#define MAX_10(a,V...) MAX_2(a,MAX_9(V))
|
||||
#define __MAX_N(N,V...) MAX_##N(V)
|
||||
#define _MAX_N(N,V...) __MAX_N(N,V)
|
||||
#define _MAX(V...) _MAX_N(NUM_ARGS(V), V)
|
||||
#define _MAX_N_REF() _MAX_N
|
||||
#define _MAX(V...) EVAL(_MAX_N(TWO_ARGS(V),V))
|
||||
#define MAX_2(a,b) ((a)>(b)?(a):(b))
|
||||
#define MAX_3(a,V...) MAX_2(a,DEFER2(_MAX_N_REF)()(TWO_ARGS(V),V))
|
||||
|
||||
#endif
|
||||
|
||||
@@ -473,6 +514,9 @@
|
||||
#define ADD8(N) ADD4(ADD4(N))
|
||||
#define ADD9(N) ADD4(ADD5(N))
|
||||
#define ADD10(N) ADD5(ADD5(N))
|
||||
#define SUM(A,B) _CAT(ADD,A)(B)
|
||||
#define DOUBLE_(n) ADD##n(n)
|
||||
#define DOUBLE(n) DOUBLE_(n)
|
||||
|
||||
// Macros for subtracting
|
||||
#define DEC_0 0
|
||||
@@ -581,6 +625,7 @@
|
||||
// Repeat a macro passing S...N-1.
|
||||
#define REPEAT_S(S,N,OP) EVAL(_REPEAT(S,SUB##S(N),OP))
|
||||
#define REPEAT(N,OP) REPEAT_S(0,N,OP)
|
||||
#define REPEAT_1(N,OP) REPEAT_S(1,INCREMENT(N),OP)
|
||||
|
||||
// Repeat a macro passing 0...N-1 plus additional arguments.
|
||||
#define REPEAT2_S(S,N,OP,V...) EVAL(_REPEAT2(S,SUB##S(N),OP,V))
|
||||
|
@@ -36,6 +36,10 @@ PGMSTR(X_LBL, "X:"); PGMSTR(Y_LBL, "Y:"); PGMSTR(Z_LBL, "Z:"); PGMST
|
||||
PGMSTR(SP_A_STR, " A"); PGMSTR(SP_B_STR, " B"); PGMSTR(SP_C_STR, " C");
|
||||
PGMSTR(SP_X_STR, " X"); PGMSTR(SP_Y_STR, " Y"); PGMSTR(SP_Z_STR, " Z"); PGMSTR(SP_E_STR, " E");
|
||||
PGMSTR(SP_X_LBL, " X:"); PGMSTR(SP_Y_LBL, " Y:"); PGMSTR(SP_Z_LBL, " Z:"); PGMSTR(SP_E_LBL, " E:");
|
||||
PGMSTR(I_STR, AXIS4_STR); PGMSTR(J_STR, AXIS5_STR); PGMSTR(K_STR, AXIS6_STR);
|
||||
PGMSTR(I_LBL, AXIS4_STR ":"); PGMSTR(J_LBL, AXIS5_STR ":"); PGMSTR(K_LBL, AXIS6_STR ":");
|
||||
PGMSTR(SP_I_STR, " " AXIS4_STR); PGMSTR(SP_J_STR, " " AXIS5_STR); PGMSTR(SP_K_STR, " " AXIS6_STR);
|
||||
PGMSTR(SP_I_LBL, " " AXIS4_STR ":"); PGMSTR(SP_J_LBL, " " AXIS5_STR ":"); PGMSTR(SP_K_LBL, " " AXIS6_STR ":");
|
||||
|
||||
// Hook Meatpack if it's enabled on the first leaf
|
||||
#if ENABLED(MEATPACK_ON_SERIAL_PORT_1)
|
||||
@@ -44,6 +48,9 @@ PGMSTR(SP_X_LBL, " X:"); PGMSTR(SP_Y_LBL, " Y:"); PGMSTR(SP_Z_LBL, " Z:"); PGMST
|
||||
#if ENABLED(MEATPACK_ON_SERIAL_PORT_2)
|
||||
SerialLeafT2 mpSerial2(false, _SERIAL_LEAF_2);
|
||||
#endif
|
||||
#if ENABLED(MEATPACK_ON_SERIAL_PORT_3)
|
||||
SerialLeafT3 mpSerial3(false, _SERIAL_LEAF_3);
|
||||
#endif
|
||||
|
||||
// Step 2: For multiserial, handle the second serial port as well
|
||||
#if HAS_MULTI_SERIAL
|
||||
@@ -52,7 +59,14 @@ PGMSTR(SP_X_LBL, " X:"); PGMSTR(SP_Y_LBL, " Y:"); PGMSTR(SP_Z_LBL, " Z:"); PGMST
|
||||
SerialLeafT2 msSerial2(ethernet.have_telnet_client, MYSERIAL2, false);
|
||||
#endif
|
||||
|
||||
SerialOutputT multiSerial(SERIAL_LEAF_1, SERIAL_LEAF_2);
|
||||
#define __S_LEAF(N) ,SERIAL_LEAF_##N
|
||||
#define _S_LEAF(N) __S_LEAF(N)
|
||||
|
||||
SerialOutputT multiSerial( SERIAL_LEAF_1 REPEAT_S(2, INCREMENT(NUM_SERIAL), _S_LEAF) );
|
||||
|
||||
#undef __S_LEAF
|
||||
#undef _S_LEAF
|
||||
|
||||
#endif
|
||||
|
||||
void serialprintPGM(PGM_P str) {
|
||||
@@ -91,8 +105,10 @@ void print_bin(uint16_t val) {
|
||||
}
|
||||
}
|
||||
|
||||
void print_xyz(const_float_t x, const_float_t y, const_float_t z, PGM_P const prefix/*=nullptr*/, PGM_P const suffix/*=nullptr*/) {
|
||||
void print_pos(LINEAR_AXIS_ARGS(const_float_t), PGM_P const prefix/*=nullptr*/, PGM_P const suffix/*=nullptr*/) {
|
||||
if (prefix) serialprintPGM(prefix);
|
||||
SERIAL_ECHOPAIR_P(SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z);
|
||||
SERIAL_ECHOPAIR_P(
|
||||
LIST_N(DOUBLE(LINEAR_AXES), SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z, SP_I_STR, i, SP_J_STR, j, SP_K_STR, k)
|
||||
);
|
||||
if (suffix) serialprintPGM(suffix); else SERIAL_EOL();
|
||||
}
|
||||
|
@@ -29,12 +29,16 @@
|
||||
#endif
|
||||
|
||||
// Commonly-used strings in serial output
|
||||
extern const char NUL_STR[], SP_P_STR[], SP_T_STR[],
|
||||
extern const char NUL_STR[],
|
||||
SP_X_STR[], SP_Y_STR[], SP_Z_STR[],
|
||||
SP_A_STR[], SP_B_STR[], SP_C_STR[], SP_E_STR[],
|
||||
SP_X_LBL[], SP_Y_LBL[], SP_Z_LBL[], SP_E_LBL[],
|
||||
SP_I_STR[], SP_J_STR[], SP_K_STR[],
|
||||
SP_I_LBL[], SP_J_LBL[], SP_K_LBL[],
|
||||
SP_P_STR[], SP_T_STR[],
|
||||
X_STR[], Y_STR[], Z_STR[], E_STR[],
|
||||
X_LBL[], Y_LBL[], Z_LBL[], E_LBL[],
|
||||
SP_A_STR[], SP_B_STR[], SP_C_STR[],
|
||||
SP_X_STR[], SP_Y_STR[], SP_Z_STR[], SP_E_STR[],
|
||||
SP_X_LBL[], SP_Y_LBL[], SP_Z_LBL[], SP_E_LBL[];
|
||||
I_LBL[], J_LBL[], K_LBL[];
|
||||
|
||||
//
|
||||
// Debugging flags for use by M111
|
||||
@@ -62,11 +66,11 @@ extern uint8_t marlin_debug_flags;
|
||||
//
|
||||
// Serial redirection
|
||||
//
|
||||
// Step 1: Find what's the first serial leaf
|
||||
// Step 1: Find out what the first serial leaf is
|
||||
#if BOTH(HAS_MULTI_SERIAL, SERIAL_CATCHALL)
|
||||
#define _SERIAL_LEAF_1 MYSERIAL
|
||||
#define _SERIAL_LEAF_1 MYSERIAL
|
||||
#else
|
||||
#define _SERIAL_LEAF_1 MYSERIAL1
|
||||
#define _SERIAL_LEAF_1 MYSERIAL1
|
||||
#endif
|
||||
|
||||
// Hook Meatpack if it's enabled on the first leaf
|
||||
@@ -78,7 +82,8 @@ extern uint8_t marlin_debug_flags;
|
||||
#define SERIAL_LEAF_1 _SERIAL_LEAF_1
|
||||
#endif
|
||||
|
||||
// Step 2: For multiserial, handle the second serial port as well
|
||||
// Step 2: For multiserial wrap all serial ports in a single
|
||||
// interface with the ability to output to multiple serial ports.
|
||||
#if HAS_MULTI_SERIAL
|
||||
#define _PORT_REDIRECT(n,p) REMEMBER(n,multiSerial.portMask,p)
|
||||
#define _PORT_RESTORE(n,p) RESTORE(n)
|
||||
@@ -86,18 +91,17 @@ extern uint8_t marlin_debug_flags;
|
||||
// If we have a catchall, use that directly
|
||||
#ifdef SERIAL_CATCHALL
|
||||
#define _SERIAL_LEAF_2 SERIAL_CATCHALL
|
||||
#elif HAS_ETHERNET
|
||||
typedef ConditionalSerial<decltype(MYSERIAL2)> SerialLeafT2; // We need to create an instance here
|
||||
extern SerialLeafT2 msSerial2;
|
||||
#define _SERIAL_LEAF_2 msSerial2
|
||||
#else
|
||||
#if HAS_ETHERNET
|
||||
// We need to create an instance here
|
||||
typedef ConditionalSerial<decltype(MYSERIAL2)> SerialLeafT2;
|
||||
extern SerialLeafT2 msSerial2;
|
||||
#define _SERIAL_LEAF_2 msSerial2
|
||||
#else
|
||||
// Don't create a useless instance here, directly use the existing instance
|
||||
#define _SERIAL_LEAF_2 MYSERIAL2
|
||||
#endif
|
||||
#define _SERIAL_LEAF_2 MYSERIAL2 // Don't create a useless instance here, directly use the existing instance
|
||||
#endif
|
||||
|
||||
// Nothing complicated here
|
||||
#define _SERIAL_LEAF_3 MYSERIAL3
|
||||
|
||||
// Hook Meatpack if it's enabled on the second leaf
|
||||
#if ENABLED(MEATPACK_ON_SERIAL_PORT_2)
|
||||
typedef MeatpackSerial<decltype(_SERIAL_LEAF_2)> SerialLeafT2;
|
||||
@@ -107,7 +111,23 @@ extern uint8_t marlin_debug_flags;
|
||||
#define SERIAL_LEAF_2 _SERIAL_LEAF_2
|
||||
#endif
|
||||
|
||||
typedef MultiSerial<decltype(SERIAL_LEAF_1), decltype(SERIAL_LEAF_2), 0> SerialOutputT;
|
||||
// Hook Meatpack if it's enabled on the third leaf
|
||||
#if ENABLED(MEATPACK_ON_SERIAL_PORT_3)
|
||||
typedef MeatpackSerial<decltype(_SERIAL_LEAF_3)> SerialLeafT3;
|
||||
extern SerialLeafT3 mpSerial3;
|
||||
#define SERIAL_LEAF_3 mpSerial3
|
||||
#else
|
||||
#define SERIAL_LEAF_3 _SERIAL_LEAF_3
|
||||
#endif
|
||||
|
||||
#define __S_MULTI(N) decltype(SERIAL_LEAF_##N),
|
||||
#define _S_MULTI(N) __S_MULTI(N)
|
||||
|
||||
typedef MultiSerial< REPEAT_1(NUM_SERIAL, _S_MULTI) 0> SerialOutputT;
|
||||
|
||||
#undef __S_MULTI
|
||||
#undef _S_MULTI
|
||||
|
||||
extern SerialOutputT multiSerial;
|
||||
#define SERIAL_IMPL multiSerial
|
||||
#else
|
||||
@@ -166,139 +186,45 @@ inline void SERIAL_FLUSHTX() { SERIAL_IMPL.flushTX(); }
|
||||
// Print a single PROGMEM string to serial
|
||||
void serialprintPGM(PGM_P str);
|
||||
|
||||
// SERIAL_ECHOPAIR / SERIAL_ECHOPAIR_P is used to output a key value pair. The key must be a string and the value can be anything
|
||||
// Print up to 12 pairs of values. Odd elements auto-wrapped in PSTR().
|
||||
#define __SEP_N(N,V...) _SEP_##N(V)
|
||||
#define _SEP_N(N,V...) __SEP_N(N,V)
|
||||
#define _SEP_1(PRE) SERIAL_ECHOPGM(PRE)
|
||||
#define _SEP_2(PRE,V) serial_echopair_PGM(PSTR(PRE),V)
|
||||
#define _SEP_3(a,b,c) do{ _SEP_2(a,b); SERIAL_ECHOPGM(c); }while(0)
|
||||
#define _SEP_4(a,b,V...) do{ _SEP_2(a,b); _SEP_2(V); }while(0)
|
||||
#define _SEP_5(a,b,V...) do{ _SEP_2(a,b); _SEP_3(V); }while(0)
|
||||
#define _SEP_6(a,b,V...) do{ _SEP_2(a,b); _SEP_4(V); }while(0)
|
||||
#define _SEP_7(a,b,V...) do{ _SEP_2(a,b); _SEP_5(V); }while(0)
|
||||
#define _SEP_8(a,b,V...) do{ _SEP_2(a,b); _SEP_6(V); }while(0)
|
||||
#define _SEP_9(a,b,V...) do{ _SEP_2(a,b); _SEP_7(V); }while(0)
|
||||
#define _SEP_10(a,b,V...) do{ _SEP_2(a,b); _SEP_8(V); }while(0)
|
||||
#define _SEP_11(a,b,V...) do{ _SEP_2(a,b); _SEP_9(V); }while(0)
|
||||
#define _SEP_12(a,b,V...) do{ _SEP_2(a,b); _SEP_10(V); }while(0)
|
||||
#define _SEP_13(a,b,V...) do{ _SEP_2(a,b); _SEP_11(V); }while(0)
|
||||
#define _SEP_14(a,b,V...) do{ _SEP_2(a,b); _SEP_12(V); }while(0)
|
||||
#define _SEP_15(a,b,V...) do{ _SEP_2(a,b); _SEP_13(V); }while(0)
|
||||
#define _SEP_16(a,b,V...) do{ _SEP_2(a,b); _SEP_14(V); }while(0)
|
||||
#define _SEP_17(a,b,V...) do{ _SEP_2(a,b); _SEP_15(V); }while(0)
|
||||
#define _SEP_18(a,b,V...) do{ _SEP_2(a,b); _SEP_16(V); }while(0)
|
||||
#define _SEP_19(a,b,V...) do{ _SEP_2(a,b); _SEP_17(V); }while(0)
|
||||
#define _SEP_20(a,b,V...) do{ _SEP_2(a,b); _SEP_18(V); }while(0)
|
||||
#define _SEP_21(a,b,V...) do{ _SEP_2(a,b); _SEP_19(V); }while(0)
|
||||
#define _SEP_22(a,b,V...) do{ _SEP_2(a,b); _SEP_20(V); }while(0)
|
||||
#define _SEP_23(a,b,V...) do{ _SEP_2(a,b); _SEP_21(V); }while(0)
|
||||
#define _SEP_24(a,b,V...) do{ _SEP_2(a,b); _SEP_22(V); }while(0)
|
||||
//
|
||||
// SERIAL_ECHOPAIR... macros are used to output string-value pairs.
|
||||
//
|
||||
|
||||
#define SERIAL_ECHOPAIR(V...) _SEP_N(NUM_ARGS(V),V)
|
||||
// Print up to 20 pairs of values. Odd elements must be literal strings.
|
||||
#define __SEP_N(N,V...) _SEP_##N(V)
|
||||
#define _SEP_N(N,V...) __SEP_N(N,V)
|
||||
#define _SEP_N_REF() _SEP_N
|
||||
#define _SEP_1(s) SERIAL_ECHOPGM(s);
|
||||
#define _SEP_2(s,v) serial_echopair_PGM(PSTR(s),v);
|
||||
#define _SEP_3(s,v,V...) _SEP_2(s,v); DEFER2(_SEP_N_REF)()(TWO_ARGS(V),V);
|
||||
#define SERIAL_ECHOPAIR(V...) do{ EVAL(_SEP_N(TWO_ARGS(V),V)); }while(0)
|
||||
|
||||
// Print up to 12 pairs of values. Odd elements must be PSTR pointers.
|
||||
#define __SEP_N_P(N,V...) _SEP_##N##_P(V)
|
||||
#define _SEP_N_P(N,V...) __SEP_N_P(N,V)
|
||||
#define _SEP_1_P(PRE) serialprintPGM(PRE)
|
||||
#define _SEP_2_P(PRE,V) serial_echopair_PGM(PRE,V)
|
||||
#define _SEP_3_P(a,b,c) do{ _SEP_2_P(a,b); serialprintPGM(c); }while(0)
|
||||
#define _SEP_4_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_2_P(V); }while(0)
|
||||
#define _SEP_5_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_3_P(V); }while(0)
|
||||
#define _SEP_6_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_4_P(V); }while(0)
|
||||
#define _SEP_7_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_5_P(V); }while(0)
|
||||
#define _SEP_8_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_6_P(V); }while(0)
|
||||
#define _SEP_9_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_7_P(V); }while(0)
|
||||
#define _SEP_10_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_8_P(V); }while(0)
|
||||
#define _SEP_11_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_9_P(V); }while(0)
|
||||
#define _SEP_12_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_10_P(V); }while(0)
|
||||
#define _SEP_13_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_11_P(V); }while(0)
|
||||
#define _SEP_14_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_12_P(V); }while(0)
|
||||
#define _SEP_15_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_13_P(V); }while(0)
|
||||
#define _SEP_16_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_14_P(V); }while(0)
|
||||
#define _SEP_17_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_15_P(V); }while(0)
|
||||
#define _SEP_18_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_16_P(V); }while(0)
|
||||
#define _SEP_19_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_17_P(V); }while(0)
|
||||
#define _SEP_20_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_18_P(V); }while(0)
|
||||
#define _SEP_21_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_19_P(V); }while(0)
|
||||
#define _SEP_22_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_20_P(V); }while(0)
|
||||
#define _SEP_23_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_21_P(V); }while(0)
|
||||
#define _SEP_24_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_22_P(V); }while(0)
|
||||
// Print up to 20 pairs of values followed by newline. Odd elements must be literal strings.
|
||||
#define __SELP_N(N,V...) _SELP_##N(V)
|
||||
#define _SELP_N(N,V...) __SELP_N(N,V)
|
||||
#define _SELP_N_REF() _SELP_N
|
||||
#define _SELP_1(s) SERIAL_ECHOLNPGM(s);
|
||||
#define _SELP_2(s,v) serial_echopair_PGM(PSTR(s),v); SERIAL_EOL();
|
||||
#define _SELP_3(s,v,V...) _SEP_2(s,v); DEFER2(_SELP_N_REF)()(TWO_ARGS(V),V);
|
||||
#define SERIAL_ECHOLNPAIR(V...) do{ EVAL(_SELP_N(TWO_ARGS(V),V)); }while(0)
|
||||
|
||||
// SERIAL_ECHOPAIR_P is used to output a key value pair. Unlike SERIAL_ECHOPAIR, the key must be a PGM string already and the value can be anything
|
||||
#define SERIAL_ECHOPAIR_P(V...) _SEP_N_P(NUM_ARGS(V),V)
|
||||
// Print up to 20 pairs of values. Odd elements must be PSTR pointers.
|
||||
#define __SEP_N_P(N,V...) _SEP_##N##_P(V)
|
||||
#define _SEP_N_P(N,V...) __SEP_N_P(N,V)
|
||||
#define _SEP_N_P_REF() _SEP_N_P
|
||||
#define _SEP_1_P(s) serialprintPGM(s);
|
||||
#define _SEP_2_P(s,v) serial_echopair_PGM(s,v);
|
||||
#define _SEP_3_P(s,v,V...) _SEP_2_P(s,v); DEFER2(_SEP_N_P_REF)()(TWO_ARGS(V),V);
|
||||
#define SERIAL_ECHOPAIR_P(V...) do{ EVAL(_SEP_N_P(TWO_ARGS(V),V)); }while(0)
|
||||
|
||||
// Print up to 12 pairs of values followed by newline
|
||||
#define __SELP_N(N,V...) _SELP_##N(V)
|
||||
#define _SELP_N(N,V...) __SELP_N(N,V)
|
||||
#define _SELP_1(PRE) SERIAL_ECHOLNPGM(PRE)
|
||||
#define _SELP_2(PRE,V) do{ serial_echopair_PGM(PSTR(PRE),V); SERIAL_EOL(); }while(0)
|
||||
#define _SELP_3(a,b,c) do{ _SEP_2(a,b); SERIAL_ECHOLNPGM(c); }while(0)
|
||||
#define _SELP_4(a,b,V...) do{ _SEP_2(a,b); _SELP_2(V); }while(0)
|
||||
#define _SELP_5(a,b,V...) do{ _SEP_2(a,b); _SELP_3(V); }while(0)
|
||||
#define _SELP_6(a,b,V...) do{ _SEP_2(a,b); _SELP_4(V); }while(0)
|
||||
#define _SELP_7(a,b,V...) do{ _SEP_2(a,b); _SELP_5(V); }while(0)
|
||||
#define _SELP_8(a,b,V...) do{ _SEP_2(a,b); _SELP_6(V); }while(0)
|
||||
#define _SELP_9(a,b,V...) do{ _SEP_2(a,b); _SELP_7(V); }while(0)
|
||||
#define _SELP_10(a,b,V...) do{ _SEP_2(a,b); _SELP_8(V); }while(0)
|
||||
#define _SELP_11(a,b,V...) do{ _SEP_2(a,b); _SELP_9(V); }while(0)
|
||||
#define _SELP_12(a,b,V...) do{ _SEP_2(a,b); _SELP_10(V); }while(0)
|
||||
#define _SELP_13(a,b,V...) do{ _SEP_2(a,b); _SELP_11(V); }while(0)
|
||||
#define _SELP_14(a,b,V...) do{ _SEP_2(a,b); _SELP_12(V); }while(0)
|
||||
#define _SELP_15(a,b,V...) do{ _SEP_2(a,b); _SELP_13(V); }while(0)
|
||||
#define _SELP_16(a,b,V...) do{ _SEP_2(a,b); _SELP_14(V); }while(0)
|
||||
#define _SELP_17(a,b,V...) do{ _SEP_2(a,b); _SELP_15(V); }while(0)
|
||||
#define _SELP_18(a,b,V...) do{ _SEP_2(a,b); _SELP_16(V); }while(0)
|
||||
#define _SELP_19(a,b,V...) do{ _SEP_2(a,b); _SELP_17(V); }while(0)
|
||||
#define _SELP_20(a,b,V...) do{ _SEP_2(a,b); _SELP_18(V); }while(0)
|
||||
#define _SELP_21(a,b,V...) do{ _SEP_2(a,b); _SELP_19(V); }while(0)
|
||||
#define _SELP_22(a,b,V...) do{ _SEP_2(a,b); _SELP_20(V); }while(0)
|
||||
#define _SELP_23(a,b,V...) do{ _SEP_2(a,b); _SELP_21(V); }while(0)
|
||||
#define _SELP_24(a,b,V...) do{ _SEP_2(a,b); _SELP_22(V); }while(0)
|
||||
#define _SELP_25(a,b,V...) do{ _SEP_2(a,b); _SELP_23(V); }while(0)
|
||||
#define _SELP_26(a,b,V...) do{ _SEP_2(a,b); _SELP_24(V); }while(0)
|
||||
#define _SELP_27(a,b,V...) do{ _SEP_2(a,b); _SELP_25(V); }while(0)
|
||||
#define _SELP_28(a,b,V...) do{ _SEP_2(a,b); _SELP_26(V); }while(0)
|
||||
#define _SELP_29(a,b,V...) do{ _SEP_2(a,b); _SELP_27(V); }while(0)
|
||||
#define _SELP_30(a,b,V...) do{ _SEP_2(a,b); _SELP_28(V); }while(0) // Eat two args, pass the rest up
|
||||
|
||||
#define SERIAL_ECHOLNPAIR(V...) _SELP_N(NUM_ARGS(V),V)
|
||||
|
||||
// Print up to 12 pairs of values followed by newline
|
||||
#define __SELP_N_P(N,V...) _SELP_##N##_P(V)
|
||||
#define _SELP_N_P(N,V...) __SELP_N_P(N,V)
|
||||
#define _SELP_1_P(PRE) serialprintPGM(PRE)
|
||||
#define _SELP_2_P(PRE,V) do{ serial_echopair_PGM(PRE,V); SERIAL_EOL(); }while(0)
|
||||
#define _SELP_3_P(a,b,c) do{ _SEP_2_P(a,b); serialprintPGM(c); }while(0)
|
||||
#define _SELP_4_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_2_P(V); }while(0)
|
||||
#define _SELP_5_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_3_P(V); }while(0)
|
||||
#define _SELP_6_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_4_P(V); }while(0)
|
||||
#define _SELP_7_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_5_P(V); }while(0)
|
||||
#define _SELP_8_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_6_P(V); }while(0)
|
||||
#define _SELP_9_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_7_P(V); }while(0)
|
||||
#define _SELP_10_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_8_P(V); }while(0)
|
||||
#define _SELP_11_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_9_P(V); }while(0)
|
||||
#define _SELP_12_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_10_P(V); }while(0)
|
||||
#define _SELP_13_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_11_P(V); }while(0)
|
||||
#define _SELP_14_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_12_P(V); }while(0)
|
||||
#define _SELP_15_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_13_P(V); }while(0)
|
||||
#define _SELP_16_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_14_P(V); }while(0)
|
||||
#define _SELP_17_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_15_P(V); }while(0)
|
||||
#define _SELP_18_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_16_P(V); }while(0)
|
||||
#define _SELP_19_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_17_P(V); }while(0)
|
||||
#define _SELP_20_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_18_P(V); }while(0)
|
||||
#define _SELP_21_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_19_P(V); }while(0)
|
||||
#define _SELP_22_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_20_P(V); }while(0)
|
||||
#define _SELP_23_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_21_P(V); }while(0)
|
||||
#define _SELP_24_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_22_P(V); }while(0)
|
||||
#define _SELP_25_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_23_P(V); }while(0)
|
||||
#define _SELP_26_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_24_P(V); }while(0)
|
||||
#define _SELP_27_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_25_P(V); }while(0)
|
||||
#define _SELP_28_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_26_P(V); }while(0)
|
||||
#define _SELP_29_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_27_P(V); }while(0)
|
||||
#define _SELP_30_P(a,b,V...) do{ _SEP_2_P(a,b); _SELP_28_P(V); }while(0) // Eat two args, pass the rest up
|
||||
|
||||
#define SERIAL_ECHOLNPAIR_P(V...) _SELP_N_P(NUM_ARGS(V),V)
|
||||
// Print up to 20 pairs of values followed by newline. Odd elements must be PSTR pointers.
|
||||
#define __SELP_N_P(N,V...) _SELP_##N##_P(V)
|
||||
#define _SELP_N_P(N,V...) __SELP_N_P(N,V)
|
||||
#define _SELP_N_P_REF() _SELP_N_P
|
||||
#define _SELP_1_P(s) { serialprintPGM(s); SERIAL_EOL(); }
|
||||
#define _SELP_2_P(s,v) { serial_echopair_PGM(s,v); SERIAL_EOL(); }
|
||||
#define _SELP_3_P(s,v,V...) { _SEP_2_P(s,v); DEFER2(_SELP_N_P_REF)()(TWO_ARGS(V),V); }
|
||||
#define SERIAL_ECHOLNPAIR_P(V...) do{ EVAL(_SELP_N_P(TWO_ARGS(V),V)); }while(0)
|
||||
|
||||
#ifdef AllowDifferentTypeInList
|
||||
|
||||
@@ -388,11 +314,11 @@ void serialprint_truefalse(const bool tf);
|
||||
void serial_spaces(uint8_t count);
|
||||
|
||||
void print_bin(const uint16_t val);
|
||||
void print_xyz(const_float_t x, const_float_t y, const_float_t z, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr);
|
||||
void print_pos(LINEAR_AXIS_ARGS(const_float_t), PGM_P const prefix=nullptr, PGM_P const suffix=nullptr);
|
||||
|
||||
inline void print_xyz(const xyz_pos_t &xyz, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr) {
|
||||
print_xyz(xyz.x, xyz.y, xyz.z, prefix, suffix);
|
||||
inline void print_pos(const xyz_pos_t &xyz, PGM_P const prefix=nullptr, PGM_P const suffix=nullptr) {
|
||||
print_pos(LINEAR_AXIS_ELEM(xyz), prefix, suffix);
|
||||
}
|
||||
|
||||
#define SERIAL_POS(SUFFIX,VAR) do { print_xyz(VAR, PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n")); }while(0)
|
||||
#define SERIAL_XYZ(PREFIX,V...) do { print_xyz(V, PSTR(PREFIX), nullptr); }while(0)
|
||||
#define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n")); }while(0)
|
||||
#define SERIAL_XYZ(PREFIX,V...) do { print_pos(V, PSTR(PREFIX), nullptr); }while(0)
|
||||
|
@@ -67,7 +67,7 @@ struct BaseSerial : public SerialBase< BaseSerial<SerialT> >, public SerialT {
|
||||
|
||||
SerialFeature features(serial_index_t index) const { return CALL_IF_EXISTS(SerialFeature, static_cast<const SerialT*>(this), features, index); }
|
||||
|
||||
// We have 2 implementation of the same method in both base class, let's say which one we want
|
||||
// Two implementations of the same method exist in both base classes so indicate the right one
|
||||
using SerialT::available;
|
||||
using SerialT::read;
|
||||
using SerialT::begin;
|
||||
@@ -134,7 +134,7 @@ struct ForwardSerial : public SerialBase< ForwardSerial<SerialT> > {
|
||||
ForwardSerial(const bool e, SerialT & out) : BaseClassT(e), out(out) {}
|
||||
};
|
||||
|
||||
// A class that's can be hooked and unhooked at runtime, useful to capturing the output of the serial interface
|
||||
// A class that can be hooked and unhooked at runtime, useful to capture the output of the serial interface
|
||||
template <class SerialT>
|
||||
struct RuntimeSerial : public SerialBase< RuntimeSerial<SerialT> >, public SerialT {
|
||||
typedef SerialBase< RuntimeSerial<SerialT> > BaseClassT;
|
||||
@@ -195,54 +195,71 @@ struct RuntimeSerial : public SerialBase< RuntimeSerial<SerialT> >, public Seria
|
||||
RuntimeSerial(const bool e, Args... args) : BaseClassT(e), SerialT(args...), writeHook(0), eofHook(0), userPointer(0) {}
|
||||
};
|
||||
|
||||
// A class that duplicates its output conditionally to 2 serial interfaces
|
||||
template <class Serial0T, class Serial1T, const uint8_t offset = 0, const uint8_t step = 1>
|
||||
struct MultiSerial : public SerialBase< MultiSerial<Serial0T, Serial1T, offset, step> > {
|
||||
typedef SerialBase< MultiSerial<Serial0T, Serial1T, offset, step> > BaseClassT;
|
||||
#define _S_CLASS(N) class Serial##N##T,
|
||||
#define _S_NAME(N) Serial##N##T,
|
||||
|
||||
template < REPEAT(NUM_SERIAL, _S_CLASS) const uint8_t offset=0, const uint8_t step=1 >
|
||||
struct MultiSerial : public SerialBase< MultiSerial< REPEAT(NUM_SERIAL, _S_NAME) offset, step > > {
|
||||
typedef SerialBase< MultiSerial< REPEAT(NUM_SERIAL, _S_NAME) offset, step > > BaseClassT;
|
||||
|
||||
#undef _S_CLASS
|
||||
#undef _S_NAME
|
||||
|
||||
SerialMask portMask;
|
||||
Serial0T & serial0;
|
||||
Serial1T & serial1;
|
||||
|
||||
static constexpr uint8_t Usage = ((1 << step) - 1); // A bit mask containing as many bits as step
|
||||
static constexpr uint8_t FirstOutput = (Usage << offset);
|
||||
static constexpr uint8_t SecondOutput = (Usage << (offset + step));
|
||||
static constexpr uint8_t Both = FirstOutput | SecondOutput;
|
||||
#define _S_DECLARE(N) Serial##N##T & serial##N;
|
||||
REPEAT(NUM_SERIAL, _S_DECLARE);
|
||||
#undef _S_DECLARE
|
||||
|
||||
static constexpr uint8_t Usage = _BV(step) - 1; // A bit mask containing 'step' bits
|
||||
|
||||
#define _OUT_PORT(N) (Usage << (offset + (step * N))),
|
||||
static constexpr uint8_t output[] = { REPEAT(NUM_SERIAL, _OUT_PORT) };
|
||||
#undef _OUT_PORT
|
||||
|
||||
#define _OUT_MASK(N) | output[N]
|
||||
static constexpr uint8_t ALL = 0 REPEAT(NUM_SERIAL, _OUT_MASK);
|
||||
#undef _OUT_MASK
|
||||
|
||||
NO_INLINE void write(uint8_t c) {
|
||||
if (portMask.enabled(FirstOutput)) serial0.write(c);
|
||||
if (portMask.enabled(SecondOutput)) serial1.write(c);
|
||||
#define _S_WRITE(N) if (portMask.enabled(output[N])) serial##N.write(c);
|
||||
REPEAT(NUM_SERIAL, _S_WRITE);
|
||||
#undef _S_WRITE
|
||||
}
|
||||
NO_INLINE void msgDone() {
|
||||
if (portMask.enabled(FirstOutput)) serial0.msgDone();
|
||||
if (portMask.enabled(SecondOutput)) serial1.msgDone();
|
||||
#define _S_DONE(N) if (portMask.enabled(output[N])) serial##N.msgDone();
|
||||
REPEAT(NUM_SERIAL, _S_DONE);
|
||||
#undef _S_DONE
|
||||
}
|
||||
int available(serial_index_t index) {
|
||||
if (index.within(0 + offset, step + offset - 1))
|
||||
return serial0.available(index);
|
||||
else if (index.within(step + offset, 2 * step + offset - 1))
|
||||
return serial1.available(index);
|
||||
uint8_t pos = offset;
|
||||
#define _S_AVAILABLE(N) if (index.within(pos, pos + step - 1)) return serial##N.available(index); else pos += step;
|
||||
REPEAT(NUM_SERIAL, _S_AVAILABLE);
|
||||
#undef _S_AVAILABLE
|
||||
return false;
|
||||
}
|
||||
int read(serial_index_t index) {
|
||||
if (index.within(0 + offset, step + offset - 1))
|
||||
return serial0.read(index);
|
||||
else if (index.within(step + offset, 2 * step + offset - 1))
|
||||
return serial1.read(index);
|
||||
uint8_t pos = offset;
|
||||
#define _S_READ(N) if (index.within(pos, pos + step - 1)) return serial##N.read(index); else pos += step;
|
||||
REPEAT(NUM_SERIAL, _S_READ);
|
||||
#undef _S_READ
|
||||
return -1;
|
||||
}
|
||||
void begin(const long br) {
|
||||
if (portMask.enabled(FirstOutput)) serial0.begin(br);
|
||||
if (portMask.enabled(SecondOutput)) serial1.begin(br);
|
||||
#define _S_BEGIN(N) if (portMask.enabled(output[N])) serial##N.begin(br);
|
||||
REPEAT(NUM_SERIAL, _S_BEGIN);
|
||||
#undef _S_BEGIN
|
||||
}
|
||||
void end() {
|
||||
if (portMask.enabled(FirstOutput)) serial0.end();
|
||||
if (portMask.enabled(SecondOutput)) serial1.end();
|
||||
#define _S_END(N) if (portMask.enabled(output[N])) serial##N.end();
|
||||
REPEAT(NUM_SERIAL, _S_END);
|
||||
#undef _S_END
|
||||
}
|
||||
bool connected() {
|
||||
bool ret = true;
|
||||
if (portMask.enabled(FirstOutput)) ret = CALL_IF_EXISTS(bool, &serial0, connected);
|
||||
if (portMask.enabled(SecondOutput)) ret = ret && CALL_IF_EXISTS(bool, &serial1, connected);
|
||||
#define _S_CONNECTED(N) if (portMask.enabled(output[N]) && !CALL_IF_EXISTS(bool, &serial##N, connected)) ret = false;
|
||||
REPEAT(NUM_SERIAL, _S_CONNECTED);
|
||||
#undef _S_CONNECTED
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -250,27 +267,32 @@ struct MultiSerial : public SerialBase< MultiSerial<Serial0T, Serial1T, offset,
|
||||
using BaseClassT::read;
|
||||
|
||||
// Redirect flush
|
||||
NO_INLINE void flush() {
|
||||
if (portMask.enabled(FirstOutput)) serial0.flush();
|
||||
if (portMask.enabled(SecondOutput)) serial1.flush();
|
||||
NO_INLINE void flush() {
|
||||
#define _S_FLUSH(N) if (portMask.enabled(output[N])) serial##N.flush();
|
||||
REPEAT(NUM_SERIAL, _S_FLUSH);
|
||||
#undef _S_FLUSH
|
||||
}
|
||||
NO_INLINE void flushTX() {
|
||||
if (portMask.enabled(FirstOutput)) CALL_IF_EXISTS(void, &serial0, flushTX);
|
||||
if (portMask.enabled(SecondOutput)) CALL_IF_EXISTS(void, &serial1, flushTX);
|
||||
NO_INLINE void flushTX() {
|
||||
#define _S_FLUSHTX(N) if (portMask.enabled(output[N])) CALL_IF_EXISTS(void, &serial0, flushTX);
|
||||
REPEAT(NUM_SERIAL, _S_FLUSHTX);
|
||||
#undef _S_FLUSHTX
|
||||
}
|
||||
|
||||
// Forward feature queries
|
||||
SerialFeature features(serial_index_t index) const {
|
||||
if (index.within(0 + offset, step + offset - 1))
|
||||
return serial0.features(index);
|
||||
else if (index.within(step + offset, 2 * step + offset - 1))
|
||||
return serial1.features(index);
|
||||
SerialFeature features(serial_index_t index) const {
|
||||
uint8_t pos = offset;
|
||||
#define _S_FEATURES(N) if (index.within(pos, pos + step - 1)) return serial##N.features(index); else pos += step;
|
||||
REPEAT(NUM_SERIAL, _S_FEATURES);
|
||||
#undef _S_FEATURES
|
||||
return SerialFeature::None;
|
||||
}
|
||||
|
||||
MultiSerial(Serial0T & serial0, Serial1T & serial1, const SerialMask mask = Both, const bool e = false) :
|
||||
BaseClassT(e),
|
||||
portMask(mask), serial0(serial0), serial1(serial1) {}
|
||||
#define _S_REFS(N) Serial##N##T & serial##N,
|
||||
#define _S_INIT(N) ,serial##N (serial##N)
|
||||
|
||||
MultiSerial(REPEAT(NUM_SERIAL, _S_REFS) const SerialMask mask = ALL, const bool e = false)
|
||||
: BaseClassT(e), portMask(mask) REPEAT(NUM_SERIAL, _S_INIT) {}
|
||||
|
||||
};
|
||||
|
||||
// Build the actual serial object depending on current configuration
|
||||
@@ -278,4 +300,7 @@ struct MultiSerial : public SerialBase< MultiSerial<Serial0T, Serial1T, offset,
|
||||
#define ForwardSerial1Class TERN(SERIAL_RUNTIME_HOOK, RuntimeSerial, ForwardSerial)
|
||||
#ifdef HAS_MULTI_SERIAL
|
||||
#define Serial2Class ConditionalSerial
|
||||
#if NUM_SERIAL >= 3
|
||||
#define Serial3Class ConditionalSerial
|
||||
#endif
|
||||
#endif
|
||||
|
@@ -29,34 +29,6 @@
|
||||
class __FlashStringHelper;
|
||||
typedef const __FlashStringHelper *progmem_str;
|
||||
|
||||
//
|
||||
// Enumerated axis indices
|
||||
//
|
||||
// - X_AXIS, Y_AXIS, and Z_AXIS should be used for axes in Cartesian space
|
||||
// - A_AXIS, B_AXIS, and C_AXIS should be used for Steppers, corresponding to XYZ on Cartesians
|
||||
// - X_HEAD, Y_HEAD, and Z_HEAD should be used for Steppers on Core kinematics
|
||||
//
|
||||
enum AxisEnum : uint8_t {
|
||||
X_AXIS = 0, A_AXIS = 0,
|
||||
Y_AXIS = 1, B_AXIS = 1,
|
||||
Z_AXIS = 2, C_AXIS = 2,
|
||||
E_AXIS = 3,
|
||||
X_HEAD = 4, Y_HEAD = 5, Z_HEAD = 6,
|
||||
E0_AXIS = 3,
|
||||
E1_AXIS, E2_AXIS, E3_AXIS, E4_AXIS, E5_AXIS, E6_AXIS, E7_AXIS,
|
||||
ALL_AXES = 0xFE, NO_AXIS = 0xFF
|
||||
};
|
||||
|
||||
//
|
||||
// Loop over XYZE axes
|
||||
//
|
||||
#define LOOP_XYZ(VAR) LOOP_S_LE_N(VAR, X_AXIS, Z_AXIS)
|
||||
#define LOOP_XYZE(VAR) LOOP_S_LE_N(VAR, X_AXIS, E_AXIS)
|
||||
#define LOOP_XYZE_N(VAR) LOOP_S_L_N(VAR, X_AXIS, XYZE_N)
|
||||
#define LOOP_ABC(VAR) LOOP_S_LE_N(VAR, A_AXIS, C_AXIS)
|
||||
#define LOOP_ABCE(VAR) LOOP_S_LE_N(VAR, A_AXIS, E_AXIS)
|
||||
#define LOOP_ABCE_N(VAR) LOOP_S_L_N(VAR, A_AXIS, XYZE_N)
|
||||
|
||||
//
|
||||
// Conditional type assignment magic. For example...
|
||||
//
|
||||
@@ -67,6 +39,85 @@ struct IF { typedef R type; };
|
||||
template <class L, class R>
|
||||
struct IF<true, L, R> { typedef L type; };
|
||||
|
||||
#define LINEAR_AXIS_GANG(V...) GANG_N(LINEAR_AXES, V)
|
||||
#define LINEAR_AXIS_CODE(V...) CODE_N(LINEAR_AXES, V)
|
||||
#define LINEAR_AXIS_LIST(V...) LIST_N(LINEAR_AXES, V)
|
||||
#define LINEAR_AXIS_ARRAY(V...) { LINEAR_AXIS_LIST(V) }
|
||||
#define LINEAR_AXIS_ARGS(T...) LINEAR_AXIS_LIST(T x, T y, T z, T i, T j, T k)
|
||||
#define LINEAR_AXIS_ELEM(O) LINEAR_AXIS_LIST(O.x, O.y, O.z, O.i, O.j, O.k)
|
||||
#define LINEAR_AXIS_DEFS(T,V) LINEAR_AXIS_LIST(T x=V, T y=V, T z=V, T i=V, T j=V, T k=V)
|
||||
|
||||
#define LOGICAL_AXIS_GANG(E,V...) LINEAR_AXIS_GANG(V) GANG_ITEM_E(E)
|
||||
#define LOGICAL_AXIS_CODE(E,V...) LINEAR_AXIS_CODE(V) CODE_ITEM_E(E)
|
||||
#define LOGICAL_AXIS_LIST(E,V...) LINEAR_AXIS_LIST(V) LIST_ITEM_E(E)
|
||||
#define LOGICAL_AXIS_ARRAY(E,V...) { LOGICAL_AXIS_LIST(E,V) }
|
||||
#define LOGICAL_AXIS_ARGS(T...) LOGICAL_AXIS_LIST(T e, T x, T y, T z, T i, T j, T k)
|
||||
#define LOGICAL_AXIS_ELEM(O) LOGICAL_AXIS_LIST(O.e, O.x, O.y, O.z, O.i, O.j, O.k)
|
||||
#define LOGICAL_AXIS_DECL(T,V) LOGICAL_AXIS_LIST(T e=V, T x=V, T y=V, T z=V, T i=V, T j=V, T k=V)
|
||||
|
||||
#if HAS_EXTRUDERS
|
||||
#define LIST_ITEM_E(N) , N
|
||||
#define CODE_ITEM_E(N) ; N
|
||||
#define GANG_ITEM_E(N) N
|
||||
#else
|
||||
#define LIST_ITEM_E(N)
|
||||
#define CODE_ITEM_E(N)
|
||||
#define GANG_ITEM_E(N)
|
||||
#endif
|
||||
|
||||
//
|
||||
// Enumerated axis indices
|
||||
//
|
||||
// - X_AXIS, Y_AXIS, and Z_AXIS should be used for axes in Cartesian space
|
||||
// - A_AXIS, B_AXIS, and C_AXIS should be used for Steppers, corresponding to XYZ on Cartesians
|
||||
// - X_HEAD, Y_HEAD, and Z_HEAD should be used for Steppers on Core kinematics
|
||||
//
|
||||
enum AxisEnum : uint8_t {
|
||||
|
||||
// Linear axes may be controlled directly or indirectly
|
||||
LINEAR_AXIS_LIST(X_AXIS, Y_AXIS, Z_AXIS, I_AXIS, J_AXIS, K_AXIS)
|
||||
|
||||
// Extruder axes may be considered distinctly
|
||||
#define _EN_ITEM(N) , E##N##_AXIS
|
||||
REPEAT(EXTRUDERS, _EN_ITEM)
|
||||
#undef _EN_ITEM
|
||||
|
||||
// Core also keeps toolhead directions
|
||||
#if EITHER(IS_CORE, MARKFORGED_XY)
|
||||
, X_HEAD, Y_HEAD, Z_HEAD
|
||||
#endif
|
||||
|
||||
// Distinct axes, including all E and Core
|
||||
, NUM_AXIS_ENUMS
|
||||
|
||||
// Most of the time we refer only to the single E_AXIS
|
||||
#if HAS_EXTRUDERS
|
||||
, E_AXIS = E0_AXIS
|
||||
#endif
|
||||
|
||||
// A, B, and C are for DELTA, SCARA, etc.
|
||||
, A_AXIS = X_AXIS
|
||||
#if LINEAR_AXES >= 2
|
||||
, B_AXIS = Y_AXIS
|
||||
#endif
|
||||
#if LINEAR_AXES >= 3
|
||||
, C_AXIS = Z_AXIS
|
||||
#endif
|
||||
|
||||
// To refer to all or none
|
||||
, ALL_AXES_ENUM = 0xFE, NO_AXIS_ENUM = 0xFF
|
||||
};
|
||||
|
||||
typedef IF<(NUM_AXIS_ENUMS > 8), uint16_t, uint8_t>::type axis_bits_t;
|
||||
|
||||
//
|
||||
// Loop over axes
|
||||
//
|
||||
#define LOOP_ABC(VAR) LOOP_S_LE_N(VAR, A_AXIS, C_AXIS)
|
||||
#define LOOP_LINEAR_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, LINEAR_AXES)
|
||||
#define LOOP_LOGICAL_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, LOGICAL_AXES)
|
||||
#define LOOP_DISTINCT_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, DISTINCT_AXES)
|
||||
|
||||
//
|
||||
// feedRate_t is just a humble float
|
||||
//
|
||||
@@ -187,7 +238,7 @@ void toNative(xyz_pos_t &raw);
|
||||
void toNative(xyze_pos_t &raw);
|
||||
|
||||
//
|
||||
// XY coordinates, counters, etc.
|
||||
// Paired XY coordinates, counters, flags, etc.
|
||||
//
|
||||
template<typename T>
|
||||
struct XYval {
|
||||
@@ -196,18 +247,34 @@ struct XYval {
|
||||
struct { T a, b; };
|
||||
T pos[2];
|
||||
};
|
||||
FI void set(const T px) { x = px; }
|
||||
FI void set(const T px, const T py) { x = px; y = py; }
|
||||
FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; }
|
||||
FI void set(const T (&arr)[XYZ]) { x = arr[0]; y = arr[1]; }
|
||||
FI void set(const T (&arr)[XYZE]) { x = arr[0]; y = arr[1]; }
|
||||
#if XYZE_N > XYZE
|
||||
FI void set(const T (&arr)[XYZE_N]) { x = arr[0]; y = arr[1]; }
|
||||
#endif
|
||||
|
||||
// Set all to 0
|
||||
FI void reset() { x = y = 0; }
|
||||
|
||||
// Setters taking struct types and arrays
|
||||
FI void set(const T px) { x = px; }
|
||||
#if HAS_Y_AXIS
|
||||
FI void set(const T px, const T py) { x = px; y = py; }
|
||||
FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; }
|
||||
#endif
|
||||
#if LINEAR_AXES > XY
|
||||
FI void set(const T (&arr)[LINEAR_AXES]) { x = arr[0]; y = arr[1]; }
|
||||
#endif
|
||||
#if LOGICAL_AXES > LINEAR_AXES
|
||||
FI void set(const T (&arr)[LOGICAL_AXES]) { x = arr[0]; y = arr[1]; }
|
||||
#if DISTINCT_AXES > LOGICAL_AXES
|
||||
FI void set(const T (&arr)[DISTINCT_AXES]) { x = arr[0]; y = arr[1]; }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Length reduced to one dimension
|
||||
FI T magnitude() const { return (T)sqrtf(x*x + y*y); }
|
||||
// Pointer to the data as a simple array
|
||||
FI operator T* () { return pos; }
|
||||
// If any element is true then it's true
|
||||
FI operator bool() { return x || y; }
|
||||
|
||||
// Explicit copy and copies with conversion
|
||||
FI XYval<T> copy() const { return *this; }
|
||||
FI XYval<T> ABS() const { return { T(_ABS(x)), T(_ABS(y)) }; }
|
||||
FI XYval<int16_t> asInt() { return { int16_t(x), int16_t(y) }; }
|
||||
@@ -219,17 +286,27 @@ struct XYval {
|
||||
FI XYval<float> asFloat() { return { static_cast<float>(x), static_cast<float>(y) }; }
|
||||
FI XYval<float> asFloat() const { return { static_cast<float>(x), static_cast<float>(y) }; }
|
||||
FI XYval<float> reciprocal() const { return { _RECIP(x), _RECIP(y) }; }
|
||||
|
||||
// Marlin workspace shifting is done with G92 and M206
|
||||
FI XYval<float> asLogical() const { XYval<float> o = asFloat(); toLogical(o); return o; }
|
||||
FI XYval<float> asNative() const { XYval<float> o = asFloat(); toNative(o); return o; }
|
||||
|
||||
// Cast to a type with more fields by making a new object
|
||||
FI operator XYZval<T>() { return { x, y }; }
|
||||
FI operator XYZval<T>() const { return { x, y }; }
|
||||
FI operator XYZEval<T>() { return { x, y }; }
|
||||
FI operator XYZEval<T>() const { return { x, y }; }
|
||||
FI T& operator[](const int i) { return pos[i]; }
|
||||
FI const T& operator[](const int i) const { return pos[i]; }
|
||||
|
||||
// Accessor via an AxisEnum (or any integer) [index]
|
||||
FI T& operator[](const int n) { return pos[n]; }
|
||||
FI const T& operator[](const int n) const { return pos[n]; }
|
||||
|
||||
// Assignment operator overrides do the expected thing
|
||||
FI XYval<T>& operator= (const T v) { set(v, v ); return *this; }
|
||||
FI XYval<T>& operator= (const XYZval<T> &rs) { set(rs.x, rs.y); return *this; }
|
||||
FI XYval<T>& operator= (const XYZEval<T> &rs) { set(rs.x, rs.y); return *this; }
|
||||
|
||||
// Override other operators to get intuitive behaviors
|
||||
FI XYval<T> operator+ (const XYval<T> &rs) const { XYval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
|
||||
FI XYval<T> operator+ (const XYval<T> &rs) { XYval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
|
||||
FI XYval<T> operator- (const XYval<T> &rs) const { XYval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; }
|
||||
@@ -266,6 +343,10 @@ struct XYval {
|
||||
FI XYval<T> operator>>(const int &v) { XYval<T> ls = *this; _RS(ls.x); _RS(ls.y); return ls; }
|
||||
FI XYval<T> operator<<(const int &v) const { XYval<T> ls = *this; _LS(ls.x); _LS(ls.y); return ls; }
|
||||
FI XYval<T> operator<<(const int &v) { XYval<T> ls = *this; _LS(ls.x); _LS(ls.y); return ls; }
|
||||
FI const XYval<T> operator-() const { XYval<T> o = *this; o.x = -x; o.y = -y; return o; }
|
||||
FI XYval<T> operator-() { XYval<T> o = *this; o.x = -x; o.y = -y; return o; }
|
||||
|
||||
// Modifier operators
|
||||
FI XYval<T>& operator+=(const XYval<T> &rs) { x += rs.x; y += rs.y; return *this; }
|
||||
FI XYval<T>& operator-=(const XYval<T> &rs) { x -= rs.x; y -= rs.y; return *this; }
|
||||
FI XYval<T>& operator*=(const XYval<T> &rs) { x *= rs.x; y *= rs.y; return *this; }
|
||||
@@ -279,6 +360,8 @@ struct XYval {
|
||||
FI XYval<T>& operator*=(const int &v) { x *= v; y *= v; return *this; }
|
||||
FI XYval<T>& operator>>=(const int &v) { _RS(x); _RS(y); return *this; }
|
||||
FI XYval<T>& operator<<=(const int &v) { _LS(x); _LS(y); return *this; }
|
||||
|
||||
// Exact comparisons. For floats a "NEAR" operation may be better.
|
||||
FI bool operator==(const XYval<T> &rs) { return x == rs.x && y == rs.y; }
|
||||
FI bool operator==(const XYZval<T> &rs) { return x == rs.x && y == rs.y; }
|
||||
FI bool operator==(const XYZEval<T> &rs) { return x == rs.x && y == rs.y; }
|
||||
@@ -291,224 +374,291 @@ struct XYval {
|
||||
FI bool operator!=(const XYval<T> &rs) const { return !operator==(rs); }
|
||||
FI bool operator!=(const XYZval<T> &rs) const { return !operator==(rs); }
|
||||
FI bool operator!=(const XYZEval<T> &rs) const { return !operator==(rs); }
|
||||
FI XYval<T> operator-() { XYval<T> o = *this; o.x = -x; o.y = -y; return o; }
|
||||
FI const XYval<T> operator-() const { XYval<T> o = *this; o.x = -x; o.y = -y; return o; }
|
||||
};
|
||||
|
||||
//
|
||||
// XYZ coordinates, counters, etc.
|
||||
// Linear Axes coordinates, counters, flags, etc.
|
||||
//
|
||||
template<typename T>
|
||||
struct XYZval {
|
||||
union {
|
||||
struct { T x, y, z; };
|
||||
struct { T a, b, c; };
|
||||
T pos[3];
|
||||
struct { T LINEAR_AXIS_ARGS(); };
|
||||
struct { T LINEAR_AXIS_LIST(a, b, c, u, v, w); };
|
||||
T pos[LINEAR_AXES];
|
||||
};
|
||||
|
||||
// Set all to 0
|
||||
FI void reset() { LINEAR_AXIS_GANG(x =, y =, z =, i =, j =, k =) 0; }
|
||||
|
||||
// Setters taking struct types and arrays
|
||||
FI void set(const T px) { x = px; }
|
||||
FI void set(const T px, const T py) { x = px; y = py; }
|
||||
FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; }
|
||||
FI void set(const XYval<T> pxy, const T pz) { x = pxy.x; y = pxy.y; z = pz; }
|
||||
FI void set(const XYval<T> pxy) { x = pxy.x; y = pxy.y; }
|
||||
FI void set(const XYval<T> pxy, const T pz) { LINEAR_AXIS_CODE(x = pxy.x, y = pxy.y, z = pz, NOOP, NOOP, NOOP); }
|
||||
FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; }
|
||||
FI void set(const T (&arr)[XYZ]) { x = arr[0]; y = arr[1]; z = arr[2]; }
|
||||
FI void set(const T (&arr)[XYZE]) { x = arr[0]; y = arr[1]; z = arr[2]; }
|
||||
#if XYZE_N > XYZE
|
||||
FI void set(const T (&arr)[XYZE_N]) { x = arr[0]; y = arr[1]; z = arr[2]; }
|
||||
#if HAS_Z_AXIS
|
||||
FI void set(const T (&arr)[LINEAR_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5]); }
|
||||
FI void set(LINEAR_AXIS_ARGS(const T)) { LINEAR_AXIS_CODE(a = x, b = y, c = z, u = i, v = j, w = k ); }
|
||||
#endif
|
||||
FI void reset() { x = y = z = 0; }
|
||||
FI T magnitude() const { return (T)sqrtf(x*x + y*y + z*z); }
|
||||
#if LOGICAL_AXES > LINEAR_AXES
|
||||
FI void set(const T (&arr)[LOGICAL_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5]); }
|
||||
FI void set(LOGICAL_AXIS_ARGS(const T)) { LINEAR_AXIS_CODE(a = x, b = y, c = z, u = i, v = j, w = k ); }
|
||||
#if DISTINCT_AXES > LOGICAL_AXES
|
||||
FI void set(const T (&arr)[DISTINCT_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5]); }
|
||||
#endif
|
||||
#endif
|
||||
#if LINEAR_AXES >= 4
|
||||
FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; }
|
||||
#endif
|
||||
#if LINEAR_AXES >= 5
|
||||
FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; }
|
||||
#endif
|
||||
#if LINEAR_AXES >= 6
|
||||
FI void set(const T px, const T py, const T pz, const T pi, const T pj) { x = px; y = py; z = pz; i = pi; j = pj; }
|
||||
#endif
|
||||
|
||||
// Length reduced to one dimension
|
||||
FI T magnitude() const { return (T)sqrtf(LINEAR_AXIS_GANG(x*x, + y*y, + z*z, + i*i, + j*j, + k*k)); }
|
||||
// Pointer to the data as a simple array
|
||||
FI operator T* () { return pos; }
|
||||
FI operator bool() { return z || x || y; }
|
||||
// If any element is true then it's true
|
||||
FI operator bool() { return LINEAR_AXIS_GANG(x, || y, || z, || i, || j, || k); }
|
||||
|
||||
// Explicit copy and copies with conversion
|
||||
FI XYZval<T> copy() const { XYZval<T> o = *this; return o; }
|
||||
FI XYZval<T> ABS() const { return { T(_ABS(x)), T(_ABS(y)), T(_ABS(z)) }; }
|
||||
FI XYZval<int16_t> asInt() { return { int16_t(x), int16_t(y), int16_t(z) }; }
|
||||
FI XYZval<int16_t> asInt() const { return { int16_t(x), int16_t(y), int16_t(z) }; }
|
||||
FI XYZval<int32_t> asLong() { return { int32_t(x), int32_t(y), int32_t(z) }; }
|
||||
FI XYZval<int32_t> asLong() const { return { int32_t(x), int32_t(y), int32_t(z) }; }
|
||||
FI XYZval<int32_t> ROUNDL() { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)) }; }
|
||||
FI XYZval<int32_t> ROUNDL() const { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)) }; }
|
||||
FI XYZval<float> asFloat() { return { static_cast<float>(x), static_cast<float>(y), static_cast<float>(z) }; }
|
||||
FI XYZval<float> asFloat() const { return { static_cast<float>(x), static_cast<float>(y), static_cast<float>(z) }; }
|
||||
FI XYZval<float> reciprocal() const { return { _RECIP(x), _RECIP(y), _RECIP(z) }; }
|
||||
FI XYZval<T> ABS() const { return LINEAR_AXIS_ARRAY(T(_ABS(x)), T(_ABS(y)), T(_ABS(z)), T(_ABS(i)), T(_ABS(j)), T(_ABS(k))); }
|
||||
FI XYZval<int16_t> asInt() { return LINEAR_AXIS_ARRAY(int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k)); }
|
||||
FI XYZval<int16_t> asInt() const { return LINEAR_AXIS_ARRAY(int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k)); }
|
||||
FI XYZval<int32_t> asLong() { return LINEAR_AXIS_ARRAY(int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k)); }
|
||||
FI XYZval<int32_t> asLong() const { return LINEAR_AXIS_ARRAY(int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k)); }
|
||||
FI XYZval<int32_t> ROUNDL() { return LINEAR_AXIS_ARRAY(int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k))); }
|
||||
FI XYZval<int32_t> ROUNDL() const { return LINEAR_AXIS_ARRAY(int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k))); }
|
||||
FI XYZval<float> asFloat() { return LINEAR_AXIS_ARRAY(static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(i), static_cast<float>(j), static_cast<float>(k)); }
|
||||
FI XYZval<float> asFloat() const { return LINEAR_AXIS_ARRAY(static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(i), static_cast<float>(j), static_cast<float>(k)); }
|
||||
FI XYZval<float> reciprocal() const { return LINEAR_AXIS_ARRAY(_RECIP(x), _RECIP(y), _RECIP(z), _RECIP(i), _RECIP(j), _RECIP(k)); }
|
||||
|
||||
// Marlin workspace shifting is done with G92 and M206
|
||||
FI XYZval<float> asLogical() const { XYZval<float> o = asFloat(); toLogical(o); return o; }
|
||||
FI XYZval<float> asNative() const { XYZval<float> o = asFloat(); toNative(o); return o; }
|
||||
|
||||
// In-place cast to types having fewer fields
|
||||
FI operator XYval<T>&() { return *(XYval<T>*)this; }
|
||||
FI operator const XYval<T>&() const { return *(const XYval<T>*)this; }
|
||||
FI operator XYZEval<T>() const { return { x, y, z }; }
|
||||
FI T& operator[](const int i) { return pos[i]; }
|
||||
FI const T& operator[](const int i) const { return pos[i]; }
|
||||
FI XYZval<T>& operator= (const T v) { set(v, v, v ); return *this; }
|
||||
|
||||
// Cast to a type with more fields by making a new object
|
||||
FI operator XYZEval<T>() const { return LINEAR_AXIS_ARRAY(x, y, z, i, j, k); }
|
||||
|
||||
// Accessor via an AxisEnum (or any integer) [index]
|
||||
FI T& operator[](const int n) { return pos[n]; }
|
||||
FI const T& operator[](const int n) const { return pos[n]; }
|
||||
|
||||
// Assignment operator overrides do the expected thing
|
||||
FI XYZval<T>& operator= (const T v) { set(ARRAY_N_1(LINEAR_AXES, v)); return *this; }
|
||||
FI XYZval<T>& operator= (const XYval<T> &rs) { set(rs.x, rs.y ); return *this; }
|
||||
FI XYZval<T>& operator= (const XYZEval<T> &rs) { set(rs.x, rs.y, rs.z); return *this; }
|
||||
FI XYZval<T> operator+ (const XYval<T> &rs) const { XYZval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
|
||||
FI XYZval<T> operator+ (const XYval<T> &rs) { XYZval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
|
||||
FI XYZval<T> operator- (const XYval<T> &rs) const { XYZval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; }
|
||||
FI XYZval<T> operator- (const XYval<T> &rs) { XYZval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; }
|
||||
FI XYZval<T> operator* (const XYval<T> &rs) const { XYZval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; }
|
||||
FI XYZval<T> operator* (const XYval<T> &rs) { XYZval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; }
|
||||
FI XYZval<T> operator/ (const XYval<T> &rs) const { XYZval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
|
||||
FI XYZval<T> operator/ (const XYval<T> &rs) { XYZval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
|
||||
FI XYZval<T> operator+ (const XYZval<T> &rs) const { XYZval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; }
|
||||
FI XYZval<T> operator+ (const XYZval<T> &rs) { XYZval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; }
|
||||
FI XYZval<T> operator- (const XYZval<T> &rs) const { XYZval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; }
|
||||
FI XYZval<T> operator- (const XYZval<T> &rs) { XYZval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; }
|
||||
FI XYZval<T> operator* (const XYZval<T> &rs) const { XYZval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; }
|
||||
FI XYZval<T> operator* (const XYZval<T> &rs) { XYZval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; }
|
||||
FI XYZval<T> operator/ (const XYZval<T> &rs) const { XYZval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; }
|
||||
FI XYZval<T> operator/ (const XYZval<T> &rs) { XYZval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; }
|
||||
FI XYZval<T> operator+ (const XYZEval<T> &rs) const { XYZval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; }
|
||||
FI XYZval<T> operator+ (const XYZEval<T> &rs) { XYZval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; }
|
||||
FI XYZval<T> operator- (const XYZEval<T> &rs) const { XYZval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; }
|
||||
FI XYZval<T> operator- (const XYZEval<T> &rs) { XYZval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; }
|
||||
FI XYZval<T> operator* (const XYZEval<T> &rs) const { XYZval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; }
|
||||
FI XYZval<T> operator* (const XYZEval<T> &rs) { XYZval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; }
|
||||
FI XYZval<T> operator/ (const XYZEval<T> &rs) const { XYZval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; }
|
||||
FI XYZval<T> operator/ (const XYZEval<T> &rs) { XYZval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; }
|
||||
FI XYZval<T> operator* (const float &v) const { XYZval<T> ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; return ls; }
|
||||
FI XYZval<T> operator* (const float &v) { XYZval<T> ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; return ls; }
|
||||
FI XYZval<T> operator* (const int &v) const { XYZval<T> ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; return ls; }
|
||||
FI XYZval<T> operator* (const int &v) { XYZval<T> ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; return ls; }
|
||||
FI XYZval<T> operator/ (const float &v) const { XYZval<T> ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; return ls; }
|
||||
FI XYZval<T> operator/ (const float &v) { XYZval<T> ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; return ls; }
|
||||
FI XYZval<T> operator/ (const int &v) const { XYZval<T> ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; return ls; }
|
||||
FI XYZval<T> operator/ (const int &v) { XYZval<T> ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; return ls; }
|
||||
FI XYZval<T> operator>>(const int &v) const { XYZval<T> ls = *this; _RS(ls.x); _RS(ls.y); _RS(ls.z); return ls; }
|
||||
FI XYZval<T> operator>>(const int &v) { XYZval<T> ls = *this; _RS(ls.x); _RS(ls.y); _RS(ls.z); return ls; }
|
||||
FI XYZval<T> operator<<(const int &v) const { XYZval<T> ls = *this; _LS(ls.x); _LS(ls.y); _LS(ls.z); return ls; }
|
||||
FI XYZval<T> operator<<(const int &v) { XYZval<T> ls = *this; _LS(ls.x); _LS(ls.y); _LS(ls.z); return ls; }
|
||||
FI XYZval<T>& operator+=(const XYval<T> &rs) { x += rs.x; y += rs.y; return *this; }
|
||||
FI XYZval<T>& operator-=(const XYval<T> &rs) { x -= rs.x; y -= rs.y; return *this; }
|
||||
FI XYZval<T>& operator*=(const XYval<T> &rs) { x *= rs.x; y *= rs.y; return *this; }
|
||||
FI XYZval<T>& operator/=(const XYval<T> &rs) { x /= rs.x; y /= rs.y; return *this; }
|
||||
FI XYZval<T>& operator+=(const XYZval<T> &rs) { x += rs.x; y += rs.y; z += rs.z; return *this; }
|
||||
FI XYZval<T>& operator-=(const XYZval<T> &rs) { x -= rs.x; y -= rs.y; z -= rs.z; return *this; }
|
||||
FI XYZval<T>& operator*=(const XYZval<T> &rs) { x *= rs.x; y *= rs.y; z *= rs.z; return *this; }
|
||||
FI XYZval<T>& operator/=(const XYZval<T> &rs) { x /= rs.x; y /= rs.y; z /= rs.z; return *this; }
|
||||
FI XYZval<T>& operator+=(const XYZEval<T> &rs) { x += rs.x; y += rs.y; z += rs.z; return *this; }
|
||||
FI XYZval<T>& operator-=(const XYZEval<T> &rs) { x -= rs.x; y -= rs.y; z -= rs.z; return *this; }
|
||||
FI XYZval<T>& operator*=(const XYZEval<T> &rs) { x *= rs.x; y *= rs.y; z *= rs.z; return *this; }
|
||||
FI XYZval<T>& operator/=(const XYZEval<T> &rs) { x /= rs.x; y /= rs.y; z /= rs.z; return *this; }
|
||||
FI XYZval<T>& operator*=(const float &v) { x *= v; y *= v; z *= v; return *this; }
|
||||
FI XYZval<T>& operator*=(const int &v) { x *= v; y *= v; z *= v; return *this; }
|
||||
FI XYZval<T>& operator>>=(const int &v) { _RS(x); _RS(y); _RS(z); return *this; }
|
||||
FI XYZval<T>& operator<<=(const int &v) { _LS(x); _LS(y); _LS(z); return *this; }
|
||||
FI bool operator==(const XYZEval<T> &rs) { return x == rs.x && y == rs.y && z == rs.z; }
|
||||
FI XYZval<T>& operator= (const XYZEval<T> &rs) { set(LINEAR_AXIS_ELEM(rs)); return *this; }
|
||||
|
||||
// Override other operators to get intuitive behaviors
|
||||
FI XYZval<T> operator+ (const XYval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator+ (const XYval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator- (const XYval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator- (const XYval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator* (const XYval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator* (const XYval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator/ (const XYval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator/ (const XYval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator+ (const XYZval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; }
|
||||
FI XYZval<T> operator+ (const XYZval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; }
|
||||
FI XYZval<T> operator- (const XYZval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; }
|
||||
FI XYZval<T> operator- (const XYZval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; }
|
||||
FI XYZval<T> operator* (const XYZval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; }
|
||||
FI XYZval<T> operator* (const XYZval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; }
|
||||
FI XYZval<T> operator/ (const XYZval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; }
|
||||
FI XYZval<T> operator/ (const XYZval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; }
|
||||
FI XYZval<T> operator+ (const XYZEval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; }
|
||||
FI XYZval<T> operator+ (const XYZEval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; }
|
||||
FI XYZval<T> operator- (const XYZEval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; }
|
||||
FI XYZval<T> operator- (const XYZEval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; }
|
||||
FI XYZval<T> operator* (const XYZEval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; }
|
||||
FI XYZval<T> operator* (const XYZEval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; }
|
||||
FI XYZval<T> operator/ (const XYZEval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; }
|
||||
FI XYZval<T> operator/ (const XYZEval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; }
|
||||
FI XYZval<T> operator* (const float &v) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; }
|
||||
FI XYZval<T> operator* (const float &v) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; }
|
||||
FI XYZval<T> operator* (const int &v) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; }
|
||||
FI XYZval<T> operator* (const int &v) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; }
|
||||
FI XYZval<T> operator/ (const float &v) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; }
|
||||
FI XYZval<T> operator/ (const float &v) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; }
|
||||
FI XYZval<T> operator/ (const int &v) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; }
|
||||
FI XYZval<T> operator/ (const int &v) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; }
|
||||
FI XYZval<T> operator>>(const int &v) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k) ); return ls; }
|
||||
FI XYZval<T> operator>>(const int &v) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k) ); return ls; }
|
||||
FI XYZval<T> operator<<(const int &v) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k) ); return ls; }
|
||||
FI XYZval<T> operator<<(const int &v) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k) ); return ls; }
|
||||
FI const XYZval<T> operator-() const { XYZval<T> o = *this; LINEAR_AXIS_CODE(o.x = -x, o.y = -y, o.z = -z, o.i = -i, o.j = -j, o.k = -k); return o; }
|
||||
FI XYZval<T> operator-() { XYZval<T> o = *this; LINEAR_AXIS_CODE(o.x = -x, o.y = -y, o.z = -z, o.i = -i, o.j = -j, o.k = -k); return o; }
|
||||
|
||||
// Modifier operators
|
||||
FI XYZval<T>& operator+=(const XYval<T> &rs) { LINEAR_AXIS_CODE(x += rs.x, y += rs.y, NOOP, NOOP, NOOP, NOOP ); return *this; }
|
||||
FI XYZval<T>& operator-=(const XYval<T> &rs) { LINEAR_AXIS_CODE(x -= rs.x, y -= rs.y, NOOP, NOOP, NOOP, NOOP ); return *this; }
|
||||
FI XYZval<T>& operator*=(const XYval<T> &rs) { LINEAR_AXIS_CODE(x *= rs.x, y *= rs.y, NOOP, NOOP, NOOP, NOOP ); return *this; }
|
||||
FI XYZval<T>& operator/=(const XYval<T> &rs) { LINEAR_AXIS_CODE(x /= rs.x, y /= rs.y, NOOP, NOOP, NOOP, NOOP ); return *this; }
|
||||
FI XYZval<T>& operator+=(const XYZval<T> &rs) { LINEAR_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k); return *this; }
|
||||
FI XYZval<T>& operator-=(const XYZval<T> &rs) { LINEAR_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k); return *this; }
|
||||
FI XYZval<T>& operator*=(const XYZval<T> &rs) { LINEAR_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k); return *this; }
|
||||
FI XYZval<T>& operator/=(const XYZval<T> &rs) { LINEAR_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k); return *this; }
|
||||
FI XYZval<T>& operator+=(const XYZEval<T> &rs) { LINEAR_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k); return *this; }
|
||||
FI XYZval<T>& operator-=(const XYZEval<T> &rs) { LINEAR_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k); return *this; }
|
||||
FI XYZval<T>& operator*=(const XYZEval<T> &rs) { LINEAR_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k); return *this; }
|
||||
FI XYZval<T>& operator/=(const XYZEval<T> &rs) { LINEAR_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k); return *this; }
|
||||
FI XYZval<T>& operator*=(const float &v) { LINEAR_AXIS_CODE(x *= v, y *= v, z *= v, i *= v, j *= v, k *= v); return *this; }
|
||||
FI XYZval<T>& operator*=(const int &v) { LINEAR_AXIS_CODE(x *= v, y *= v, z *= v, i *= v, j *= v, k *= v); return *this; }
|
||||
FI XYZval<T>& operator>>=(const int &v) { LINEAR_AXIS_CODE(_RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k)); return *this; }
|
||||
FI XYZval<T>& operator<<=(const int &v) { LINEAR_AXIS_CODE(_LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k)); return *this; }
|
||||
|
||||
// Exact comparisons. For floats a "NEAR" operation may be better.
|
||||
FI bool operator==(const XYZEval<T> &rs) { return true LINEAR_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k); }
|
||||
FI bool operator==(const XYZEval<T> &rs) const { return true LINEAR_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k); }
|
||||
FI bool operator!=(const XYZEval<T> &rs) { return !operator==(rs); }
|
||||
FI bool operator==(const XYZEval<T> &rs) const { return x == rs.x && y == rs.y && z == rs.z; }
|
||||
FI bool operator!=(const XYZEval<T> &rs) const { return !operator==(rs); }
|
||||
FI XYZval<T> operator-() { XYZval<T> o = *this; o.x = -x; o.y = -y; o.z = -z; return o; }
|
||||
FI const XYZval<T> operator-() const { XYZval<T> o = *this; o.x = -x; o.y = -y; o.z = -z; return o; }
|
||||
};
|
||||
|
||||
//
|
||||
// XYZE coordinates, counters, etc.
|
||||
// Logical Axes coordinates, counters, etc.
|
||||
//
|
||||
template<typename T>
|
||||
struct XYZEval {
|
||||
union {
|
||||
struct{ T x, y, z, e; };
|
||||
struct{ T a, b, c; };
|
||||
T pos[4];
|
||||
struct { T LOGICAL_AXIS_ARGS(); };
|
||||
struct { T LOGICAL_AXIS_LIST(_e, a, b, c, u, v, w); };
|
||||
T pos[LOGICAL_AXES];
|
||||
};
|
||||
FI void reset() { x = y = z = e = 0; }
|
||||
FI T magnitude() const { return (T)sqrtf(x*x + y*y + z*z + e*e); }
|
||||
FI operator T* () { return pos; }
|
||||
FI operator bool() { return e || z || x || y; }
|
||||
FI void set(const T px) { x = px; }
|
||||
FI void set(const T px, const T py) { x = px; y = py; }
|
||||
FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; }
|
||||
FI void set(const T px, const T py, const T pz, const T pe) { x = px; y = py; z = pz; e = pe; }
|
||||
FI void set(const XYval<T> pxy) { x = pxy.x; y = pxy.y; }
|
||||
FI void set(const XYval<T> pxy, const T pz) { x = pxy.x; y = pxy.y; z = pz; }
|
||||
FI void set(const XYZval<T> pxyz) { x = pxyz.x; y = pxyz.y; z = pxyz.z; }
|
||||
FI void set(const XYval<T> pxy, const T pz, const T pe) { x = pxy.x; y = pxy.y; z = pz; e = pe; }
|
||||
FI void set(const XYval<T> pxy, const XYval<T> pze) { x = pxy.x; y = pxy.y; z = pze.z; e = pze.e; }
|
||||
FI void set(const XYZval<T> pxyz, const T pe) { x = pxyz.x; y = pxyz.y; z = pxyz.z; e = pe; }
|
||||
FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; }
|
||||
FI void set(const T (&arr)[XYZ]) { x = arr[0]; y = arr[1]; z = arr[2]; }
|
||||
FI void set(const T (&arr)[XYZE]) { x = arr[0]; y = arr[1]; z = arr[2]; e = arr[3]; }
|
||||
#if XYZE_N > XYZE
|
||||
FI void set(const T (&arr)[XYZE_N]) { x = arr[0]; y = arr[1]; z = arr[2]; e = arr[3]; }
|
||||
// Reset all to 0
|
||||
FI void reset() { LOGICAL_AXIS_GANG(e =, x =, y =, z =, i =, j =, k =) 0; }
|
||||
|
||||
// Setters taking struct types and arrays
|
||||
FI void set(const T px) { x = px; }
|
||||
FI void set(const T px, const T py) { x = px; y = py; }
|
||||
FI void set(const XYval<T> pxy) { x = pxy.x; y = pxy.y; }
|
||||
FI void set(const XYZval<T> pxyz) { set(LINEAR_AXIS_ELEM(pxyz)); }
|
||||
#if HAS_Z_AXIS
|
||||
FI void set(LINEAR_AXIS_ARGS(const T)) { LINEAR_AXIS_CODE(a = x, b = y, c = z, u = i, v = j, w = k); }
|
||||
#endif
|
||||
FI XYZEval<T> copy() const { return *this; }
|
||||
FI XYZEval<T> ABS() const { return { T(_ABS(x)), T(_ABS(y)), T(_ABS(z)), T(_ABS(e)) }; }
|
||||
FI XYZEval<int16_t> asInt() { return { int16_t(x), int16_t(y), int16_t(z), int16_t(e) }; }
|
||||
FI XYZEval<int16_t> asInt() const { return { int16_t(x), int16_t(y), int16_t(z), int16_t(e) }; }
|
||||
FI XYZEval<int32_t> asLong() { return { int32_t(x), int32_t(y), int32_t(z), int32_t(e) }; }
|
||||
FI XYZEval<int32_t> asLong() const { return { int32_t(x), int32_t(y), int32_t(z), int32_t(e) }; }
|
||||
FI XYZEval<int32_t> ROUNDL() { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(e)) }; }
|
||||
FI XYZEval<int32_t> ROUNDL() const { return { int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(e)) }; }
|
||||
FI XYZEval<float> asFloat() { return { static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(e) }; }
|
||||
FI XYZEval<float> asFloat() const { return { static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(e) }; }
|
||||
FI XYZEval<float> reciprocal() const { return { _RECIP(x), _RECIP(y), _RECIP(z), _RECIP(e) }; }
|
||||
FI XYZEval<float> asLogical() const { XYZEval<float> o = asFloat(); toLogical(o); return o; }
|
||||
FI XYZEval<float> asNative() const { XYZEval<float> o = asFloat(); toNative(o); return o; }
|
||||
FI operator XYval<T>&() { return *(XYval<T>*)this; }
|
||||
FI operator const XYval<T>&() const { return *(const XYval<T>*)this; }
|
||||
FI operator XYZval<T>&() { return *(XYZval<T>*)this; }
|
||||
FI operator const XYZval<T>&() const { return *(const XYZval<T>*)this; }
|
||||
FI T& operator[](const int i) { return pos[i]; }
|
||||
FI const T& operator[](const int i) const { return pos[i]; }
|
||||
FI XYZEval<T>& operator= (const T v) { set(v, v, v, v); return *this; }
|
||||
FI XYZEval<T>& operator= (const XYval<T> &rs) { set(rs.x, rs.y); return *this; }
|
||||
FI XYZEval<T>& operator= (const XYZval<T> &rs) { set(rs.x, rs.y, rs.z); return *this; }
|
||||
FI XYZEval<T> operator+ (const XYval<T> &rs) const { XYZEval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
|
||||
FI XYZEval<T> operator+ (const XYval<T> &rs) { XYZEval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
|
||||
FI XYZEval<T> operator- (const XYval<T> &rs) const { XYZEval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; }
|
||||
FI XYZEval<T> operator- (const XYval<T> &rs) { XYZEval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; }
|
||||
FI XYZEval<T> operator* (const XYval<T> &rs) const { XYZEval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; }
|
||||
FI XYZEval<T> operator* (const XYval<T> &rs) { XYZEval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; }
|
||||
FI XYZEval<T> operator/ (const XYval<T> &rs) const { XYZEval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
|
||||
FI XYZEval<T> operator/ (const XYval<T> &rs) { XYZEval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
|
||||
FI XYZEval<T> operator+ (const XYZval<T> &rs) const { XYZEval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; }
|
||||
FI XYZEval<T> operator+ (const XYZval<T> &rs) { XYZEval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; return ls; }
|
||||
FI XYZEval<T> operator- (const XYZval<T> &rs) const { XYZEval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; }
|
||||
FI XYZEval<T> operator- (const XYZval<T> &rs) { XYZEval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; return ls; }
|
||||
FI XYZEval<T> operator* (const XYZval<T> &rs) const { XYZEval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; }
|
||||
FI XYZEval<T> operator* (const XYZval<T> &rs) { XYZEval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; return ls; }
|
||||
FI XYZEval<T> operator/ (const XYZval<T> &rs) const { XYZEval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; }
|
||||
FI XYZEval<T> operator/ (const XYZval<T> &rs) { XYZEval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; return ls; }
|
||||
FI XYZEval<T> operator+ (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; ls.e += rs.e; return ls; }
|
||||
FI XYZEval<T> operator+ (const XYZEval<T> &rs) { XYZEval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; ls.z += rs.z; ls.e += rs.e; return ls; }
|
||||
FI XYZEval<T> operator- (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; ls.e -= rs.e; return ls; }
|
||||
FI XYZEval<T> operator- (const XYZEval<T> &rs) { XYZEval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; ls.z -= rs.z; ls.e -= rs.e; return ls; }
|
||||
FI XYZEval<T> operator* (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; ls.e *= rs.e; return ls; }
|
||||
FI XYZEval<T> operator* (const XYZEval<T> &rs) { XYZEval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; ls.z *= rs.z; ls.e *= rs.e; return ls; }
|
||||
FI XYZEval<T> operator/ (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; ls.e /= rs.e; return ls; }
|
||||
FI XYZEval<T> operator/ (const XYZEval<T> &rs) { XYZEval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; ls.z /= rs.z; ls.e /= rs.e; return ls; }
|
||||
FI XYZEval<T> operator* (const float &v) const { XYZEval<T> ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; ls.e *= v; return ls; }
|
||||
FI XYZEval<T> operator* (const float &v) { XYZEval<T> ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; ls.e *= v; return ls; }
|
||||
FI XYZEval<T> operator* (const int &v) const { XYZEval<T> ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; ls.e *= v; return ls; }
|
||||
FI XYZEval<T> operator* (const int &v) { XYZEval<T> ls = *this; ls.x *= v; ls.y *= v; ls.z *= v; ls.e *= v; return ls; }
|
||||
FI XYZEval<T> operator/ (const float &v) const { XYZEval<T> ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; ls.e /= v; return ls; }
|
||||
FI XYZEval<T> operator/ (const float &v) { XYZEval<T> ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; ls.e /= v; return ls; }
|
||||
FI XYZEval<T> operator/ (const int &v) const { XYZEval<T> ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; ls.e /= v; return ls; }
|
||||
FI XYZEval<T> operator/ (const int &v) { XYZEval<T> ls = *this; ls.x /= v; ls.y /= v; ls.z /= v; ls.e /= v; return ls; }
|
||||
FI XYZEval<T> operator>>(const int &v) const { XYZEval<T> ls = *this; _RS(ls.x); _RS(ls.y); _RS(ls.z); _RS(ls.e); return ls; }
|
||||
FI XYZEval<T> operator>>(const int &v) { XYZEval<T> ls = *this; _RS(ls.x); _RS(ls.y); _RS(ls.z); _RS(ls.e); return ls; }
|
||||
FI XYZEval<T> operator<<(const int &v) const { XYZEval<T> ls = *this; _LS(ls.x); _LS(ls.y); _LS(ls.z); _LS(ls.e); return ls; }
|
||||
FI XYZEval<T> operator<<(const int &v) { XYZEval<T> ls = *this; _LS(ls.x); _LS(ls.y); _LS(ls.z); _LS(ls.e); return ls; }
|
||||
FI XYZEval<T>& operator+=(const XYval<T> &rs) { x += rs.x; y += rs.y; return *this; }
|
||||
FI XYZEval<T>& operator-=(const XYval<T> &rs) { x -= rs.x; y -= rs.y; return *this; }
|
||||
FI XYZEval<T>& operator*=(const XYval<T> &rs) { x *= rs.x; y *= rs.y; return *this; }
|
||||
FI XYZEval<T>& operator/=(const XYval<T> &rs) { x /= rs.x; y /= rs.y; return *this; }
|
||||
FI XYZEval<T>& operator+=(const XYZval<T> &rs) { x += rs.x; y += rs.y; z += rs.z; return *this; }
|
||||
FI XYZEval<T>& operator-=(const XYZval<T> &rs) { x -= rs.x; y -= rs.y; z -= rs.z; return *this; }
|
||||
FI XYZEval<T>& operator*=(const XYZval<T> &rs) { x *= rs.x; y *= rs.y; z *= rs.z; return *this; }
|
||||
FI XYZEval<T>& operator/=(const XYZval<T> &rs) { x /= rs.x; y /= rs.y; z /= rs.z; return *this; }
|
||||
FI XYZEval<T>& operator+=(const XYZEval<T> &rs) { x += rs.x; y += rs.y; z += rs.z; e += rs.e; return *this; }
|
||||
FI XYZEval<T>& operator-=(const XYZEval<T> &rs) { x -= rs.x; y -= rs.y; z -= rs.z; e -= rs.e; return *this; }
|
||||
FI XYZEval<T>& operator*=(const XYZEval<T> &rs) { x *= rs.x; y *= rs.y; z *= rs.z; e *= rs.e; return *this; }
|
||||
FI XYZEval<T>& operator/=(const XYZEval<T> &rs) { x /= rs.x; y /= rs.y; z /= rs.z; e /= rs.e; return *this; }
|
||||
FI XYZEval<T>& operator*=(const T &v) { x *= v; y *= v; z *= v; e *= v; return *this; }
|
||||
FI XYZEval<T>& operator>>=(const int &v) { _RS(x); _RS(y); _RS(z); _RS(e); return *this; }
|
||||
FI XYZEval<T>& operator<<=(const int &v) { _LS(x); _LS(y); _LS(z); _LS(e); return *this; }
|
||||
FI bool operator==(const XYZval<T> &rs) { return x == rs.x && y == rs.y && z == rs.z; }
|
||||
FI bool operator!=(const XYZval<T> &rs) { return !operator==(rs); }
|
||||
FI bool operator==(const XYZval<T> &rs) const { return x == rs.x && y == rs.y && z == rs.z; }
|
||||
FI bool operator!=(const XYZval<T> &rs) const { return !operator==(rs); }
|
||||
FI XYZEval<T> operator-() { return { -x, -y, -z, -e }; }
|
||||
FI const XYZEval<T> operator-() const { return { -x, -y, -z, -e }; }
|
||||
#if LOGICAL_AXES > LINEAR_AXES
|
||||
FI void set(const XYval<T> pxy, const T pe) { set(pxy); e = pe; }
|
||||
FI void set(const XYZval<T> pxyz, const T pe) { set(pxyz); e = pe; }
|
||||
FI void set(LOGICAL_AXIS_ARGS(const T)) { LOGICAL_AXIS_CODE(_e = e, a = x, b = y, c = z, u = i, v = j, w = k); }
|
||||
#endif
|
||||
#if LINEAR_AXES >= 4
|
||||
FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; }
|
||||
#endif
|
||||
#if LINEAR_AXES >= 5
|
||||
FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; }
|
||||
#endif
|
||||
#if LINEAR_AXES >= 6
|
||||
FI void set(const T px, const T py, const T pz, const T pi, const T pj) { x = px; y = py; z = pz; i = pi; j = pj; }
|
||||
#endif
|
||||
|
||||
// Length reduced to one dimension
|
||||
FI T magnitude() const { return (T)sqrtf(LOGICAL_AXIS_GANG(+ e*e, + x*x, + y*y, + z*z, + i*i, + j*j, + k*k)); }
|
||||
// Pointer to the data as a simple array
|
||||
FI operator T* () { return pos; }
|
||||
// If any element is true then it's true
|
||||
FI operator bool() { return 0 LOGICAL_AXIS_GANG(|| e, || x, || y, || z, || i, || j, || k); }
|
||||
|
||||
// Explicit copy and copies with conversion
|
||||
FI XYZEval<T> copy() const { XYZEval<T> o = *this; return o; }
|
||||
FI XYZEval<T> ABS() const { return LOGICAL_AXIS_ARRAY(T(_ABS(e)), T(_ABS(x)), T(_ABS(y)), T(_ABS(z)), T(_ABS(i)), T(_ABS(j)), T(_ABS(k))); }
|
||||
FI XYZEval<int16_t> asInt() { return LOGICAL_AXIS_ARRAY(int16_t(e), int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k)); }
|
||||
FI XYZEval<int16_t> asInt() const { return LOGICAL_AXIS_ARRAY(int16_t(e), int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k)); }
|
||||
FI XYZEval<int32_t> asLong() { return LOGICAL_AXIS_ARRAY(int32_t(e), int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k)); }
|
||||
FI XYZEval<int32_t> asLong() const { return LOGICAL_AXIS_ARRAY(int32_t(e), int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k)); }
|
||||
FI XYZEval<int32_t> ROUNDL() { return LOGICAL_AXIS_ARRAY(int32_t(LROUND(e)), int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k))); }
|
||||
FI XYZEval<int32_t> ROUNDL() const { return LOGICAL_AXIS_ARRAY(int32_t(LROUND(e)), int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k))); }
|
||||
FI XYZEval<float> asFloat() { return LOGICAL_AXIS_ARRAY(static_cast<float>(e), static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(i), static_cast<float>(j), static_cast<float>(k)); }
|
||||
FI XYZEval<float> asFloat() const { return LOGICAL_AXIS_ARRAY(static_cast<float>(e), static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(i), static_cast<float>(j), static_cast<float>(k)); }
|
||||
FI XYZEval<float> reciprocal() const { return LOGICAL_AXIS_ARRAY(_RECIP(e), _RECIP(x), _RECIP(y), _RECIP(z), _RECIP(i), _RECIP(j), _RECIP(k)); }
|
||||
|
||||
// Marlin workspace shifting is done with G92 and M206
|
||||
FI XYZEval<float> asLogical() const { XYZEval<float> o = asFloat(); toLogical(o); return o; }
|
||||
FI XYZEval<float> asNative() const { XYZEval<float> o = asFloat(); toNative(o); return o; }
|
||||
|
||||
// In-place cast to types having fewer fields
|
||||
FI operator XYval<T>&() { return *(XYval<T>*)this; }
|
||||
FI operator const XYval<T>&() const { return *(const XYval<T>*)this; }
|
||||
FI operator XYZval<T>&() { return *(XYZval<T>*)this; }
|
||||
FI operator const XYZval<T>&() const { return *(const XYZval<T>*)this; }
|
||||
|
||||
// Accessor via an AxisEnum (or any integer) [index]
|
||||
FI T& operator[](const int n) { return pos[n]; }
|
||||
FI const T& operator[](const int n) const { return pos[n]; }
|
||||
|
||||
// Assignment operator overrides do the expected thing
|
||||
FI XYZEval<T>& operator= (const T v) { set(LIST_N_1(LINEAR_AXES, v)); return *this; }
|
||||
FI XYZEval<T>& operator= (const XYval<T> &rs) { set(rs.x, rs.y); return *this; }
|
||||
FI XYZEval<T>& operator= (const XYZval<T> &rs) { set(LINEAR_AXIS_ELEM(rs)); return *this; }
|
||||
|
||||
// Override other operators to get intuitive behaviors
|
||||
FI XYZEval<T> operator+ (const XYval<T> &rs) const { XYZEval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
|
||||
FI XYZEval<T> operator+ (const XYval<T> &rs) { XYZEval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
|
||||
FI XYZEval<T> operator- (const XYval<T> &rs) const { XYZEval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; }
|
||||
FI XYZEval<T> operator- (const XYval<T> &rs) { XYZEval<T> ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; }
|
||||
FI XYZEval<T> operator* (const XYval<T> &rs) const { XYZEval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; }
|
||||
FI XYZEval<T> operator* (const XYval<T> &rs) { XYZEval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; }
|
||||
FI XYZEval<T> operator/ (const XYval<T> &rs) const { XYZEval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
|
||||
FI XYZEval<T> operator/ (const XYval<T> &rs) { XYZEval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
|
||||
FI XYZEval<T> operator+ (const XYZval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; }
|
||||
FI XYZEval<T> operator+ (const XYZval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; }
|
||||
FI XYZEval<T> operator- (const XYZval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; }
|
||||
FI XYZEval<T> operator- (const XYZval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; }
|
||||
FI XYZEval<T> operator* (const XYZval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; }
|
||||
FI XYZEval<T> operator* (const XYZval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; }
|
||||
FI XYZEval<T> operator/ (const XYZval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; }
|
||||
FI XYZEval<T> operator/ (const XYZval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; }
|
||||
FI XYZEval<T> operator+ (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; }
|
||||
FI XYZEval<T> operator+ (const XYZEval<T> &rs) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; }
|
||||
FI XYZEval<T> operator- (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; }
|
||||
FI XYZEval<T> operator- (const XYZEval<T> &rs) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; }
|
||||
FI XYZEval<T> operator* (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; }
|
||||
FI XYZEval<T> operator* (const XYZEval<T> &rs) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; }
|
||||
FI XYZEval<T> operator/ (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; }
|
||||
FI XYZEval<T> operator/ (const XYZEval<T> &rs) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; }
|
||||
FI XYZEval<T> operator* (const float &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; }
|
||||
FI XYZEval<T> operator* (const float &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; }
|
||||
FI XYZEval<T> operator* (const int &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; }
|
||||
FI XYZEval<T> operator* (const int &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; }
|
||||
FI XYZEval<T> operator/ (const float &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; }
|
||||
FI XYZEval<T> operator/ (const float &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; }
|
||||
FI XYZEval<T> operator/ (const int &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; }
|
||||
FI XYZEval<T> operator/ (const int &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; }
|
||||
FI XYZEval<T> operator>>(const int &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k) ); return ls; }
|
||||
FI XYZEval<T> operator>>(const int &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k) ); return ls; }
|
||||
FI XYZEval<T> operator<<(const int &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k) ); return ls; }
|
||||
FI XYZEval<T> operator<<(const int &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k) ); return ls; }
|
||||
FI const XYZEval<T> operator-() const { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k); }
|
||||
FI XYZEval<T> operator-() { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k); }
|
||||
|
||||
// Modifier operators
|
||||
FI XYZEval<T>& operator+=(const XYval<T> &rs) { x += rs.x; y += rs.y; return *this; }
|
||||
FI XYZEval<T>& operator-=(const XYval<T> &rs) { x -= rs.x; y -= rs.y; return *this; }
|
||||
FI XYZEval<T>& operator*=(const XYval<T> &rs) { x *= rs.x; y *= rs.y; return *this; }
|
||||
FI XYZEval<T>& operator/=(const XYval<T> &rs) { x /= rs.x; y /= rs.y; return *this; }
|
||||
FI XYZEval<T>& operator+=(const XYZval<T> &rs) { LINEAR_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k); return *this; }
|
||||
FI XYZEval<T>& operator-=(const XYZval<T> &rs) { LINEAR_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k); return *this; }
|
||||
FI XYZEval<T>& operator*=(const XYZval<T> &rs) { LINEAR_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k); return *this; }
|
||||
FI XYZEval<T>& operator/=(const XYZval<T> &rs) { LINEAR_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k); return *this; }
|
||||
FI XYZEval<T>& operator+=(const XYZEval<T> &rs) { LOGICAL_AXIS_CODE(e += rs.e, x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k); return *this; }
|
||||
FI XYZEval<T>& operator-=(const XYZEval<T> &rs) { LOGICAL_AXIS_CODE(e -= rs.e, x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k); return *this; }
|
||||
FI XYZEval<T>& operator*=(const XYZEval<T> &rs) { LOGICAL_AXIS_CODE(e *= rs.e, x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k); return *this; }
|
||||
FI XYZEval<T>& operator/=(const XYZEval<T> &rs) { LOGICAL_AXIS_CODE(e /= rs.e, x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k); return *this; }
|
||||
FI XYZEval<T>& operator*=(const T &v) { LOGICAL_AXIS_CODE(e *= v, x *= v, y *= v, z *= v, i *= v, j *= v, k *= v); return *this; }
|
||||
FI XYZEval<T>& operator>>=(const int &v) { LOGICAL_AXIS_CODE(_RS(e), _RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k)); return *this; }
|
||||
FI XYZEval<T>& operator<<=(const int &v) { LOGICAL_AXIS_CODE(_LS(e), _LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k)); return *this; }
|
||||
|
||||
// Exact comparisons. For floats a "NEAR" operation may be better.
|
||||
FI bool operator==(const XYZval<T> &rs) { return true LINEAR_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k); }
|
||||
FI bool operator==(const XYZval<T> &rs) const { return true LINEAR_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k); }
|
||||
FI bool operator!=(const XYZval<T> &rs) { return !operator==(rs); }
|
||||
FI bool operator!=(const XYZval<T> &rs) const { return !operator==(rs); }
|
||||
};
|
||||
|
||||
#undef _RECIP
|
||||
@@ -516,6 +666,3 @@ struct XYZEval {
|
||||
#undef _LS
|
||||
#undef _RS
|
||||
#undef FI
|
||||
|
||||
const xyze_char_t axis_codes { 'X', 'Y', 'Z', 'E' };
|
||||
#define XYZ_CHAR(A) ((char)('X' + A))
|
||||
|
@@ -35,18 +35,6 @@ void safe_delay(millis_t ms) {
|
||||
thermalManager.manage_heater(); // This keeps us safe if too many small safe_delay() calls are made
|
||||
}
|
||||
|
||||
#if ENABLED(MARLIN_DEV_MODE)
|
||||
void early_safe_delay(millis_t ms) {
|
||||
while (ms > 50) {
|
||||
ms -= 50;
|
||||
delay(50);
|
||||
watchdog_refresh();
|
||||
}
|
||||
delay(ms);
|
||||
watchdog_refresh();
|
||||
}
|
||||
#endif
|
||||
|
||||
// A delay to provide brittle hosts time to receive bytes
|
||||
#if ENABLED(SERIAL_OVERRUN_PROTECTION)
|
||||
|
||||
@@ -134,10 +122,10 @@ void safe_delay(millis_t ms) {
|
||||
SERIAL_ECHOLNPAIR("Z Fade: ", planner.z_fade_height);
|
||||
#endif
|
||||
#if ABL_PLANAR
|
||||
SERIAL_ECHOPGM("ABL Adjustment X");
|
||||
LOOP_XYZ(a) {
|
||||
SERIAL_ECHOPGM("ABL Adjustment");
|
||||
LOOP_LINEAR_AXES(a) {
|
||||
const float v = planner.get_axis_position_mm(AxisEnum(a)) - current_position[a];
|
||||
SERIAL_CHAR(' ', XYZ_CHAR(a));
|
||||
SERIAL_CHAR(' ', AXIS_CHAR(a));
|
||||
if (v > 0) SERIAL_CHAR('+');
|
||||
SERIAL_DECIMAL(v);
|
||||
}
|
||||
|
@@ -26,11 +26,6 @@
|
||||
#include "../core/millis_t.h"
|
||||
|
||||
void safe_delay(millis_t ms); // Delay ensuring that temperatures are updated and the watchdog is kept alive.
|
||||
#if ENABLED(MARLIN_DEV_MODE)
|
||||
void early_safe_delay(millis_t ms); // Delay ensuring that the watchdog is kept alive. Can be used before the Temperature ISR starts.
|
||||
#else
|
||||
inline void early_safe_delay(millis_t ms) { safe_delay(ms); }
|
||||
#endif
|
||||
|
||||
#if ENABLED(SERIAL_OVERRUN_PROTECTION)
|
||||
void serial_delay(const millis_t ms);
|
||||
@@ -81,3 +76,11 @@ public:
|
||||
// Converts from an uint8_t in the range of 0-255 to an uint8_t
|
||||
// in the range 0-100 while avoiding rounding artifacts
|
||||
constexpr uint8_t ui8_to_percent(const uint8_t i) { return (int(i) * 100 + 127) / 255; }
|
||||
|
||||
const xyze_char_t axis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', AXIS4_NAME, AXIS5_NAME, AXIS6_NAME);
|
||||
|
||||
#if LINEAR_AXES <= XYZ
|
||||
#define AXIS_CHAR(A) ((char)('X' + A))
|
||||
#else
|
||||
#define AXIS_CHAR(A) axis_codes[A]
|
||||
#endif
|
||||
|
54
Marlin/src/feature/ammeter.cpp
Normal file
54
Marlin/src/feature/ammeter.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(I2C_AMMETER)
|
||||
|
||||
#include "ammeter.h"
|
||||
|
||||
#ifndef I2C_AMMETER_IMAX
|
||||
#define I2C_AMMETER_IMAX 0.500 // Calibration range 500 Milliamps
|
||||
#endif
|
||||
|
||||
INA226 ina;
|
||||
|
||||
Ammeter ammeter;
|
||||
|
||||
float Ammeter::scale;
|
||||
float Ammeter::current;
|
||||
|
||||
void Ammeter::init() {
|
||||
ina.begin();
|
||||
ina.configure(INA226_AVERAGES_16, INA226_BUS_CONV_TIME_1100US, INA226_SHUNT_CONV_TIME_1100US, INA226_MODE_SHUNT_BUS_CONT);
|
||||
ina.calibrate(I2C_AMMETER_SHUNT_RESISTOR, I2C_AMMETER_IMAX);
|
||||
}
|
||||
|
||||
float Ammeter::read() {
|
||||
scale = 1;
|
||||
current = ina.readShuntCurrent();
|
||||
if (current <= 0.0001f) current = 0; // Clean up least-significant-bit amplification errors
|
||||
if (current < 0.1f) scale = 1000;
|
||||
return current * scale;
|
||||
}
|
||||
|
||||
#endif // I2C_AMMETER
|
39
Marlin/src/feature/ammeter.h
Normal file
39
Marlin/src/feature/ammeter.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../inc/MarlinConfigPre.h"
|
||||
|
||||
#include <Wire.h>
|
||||
#include <INA226.h>
|
||||
|
||||
class Ammeter {
|
||||
private:
|
||||
static float scale;
|
||||
|
||||
public:
|
||||
static float current;
|
||||
static void init();
|
||||
static float read();
|
||||
};
|
||||
|
||||
extern Ammeter ammeter;
|
@@ -104,7 +104,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
|
||||
|
||||
const float f_corr = float(correction) / 255.0f;
|
||||
|
||||
LOOP_XYZ(axis) {
|
||||
LOOP_LINEAR_AXES(axis) {
|
||||
if (distance_mm[axis]) {
|
||||
const bool reversing = TEST(dm,axis);
|
||||
|
||||
|
@@ -24,7 +24,7 @@
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if EITHER(RESTORE_LEVELING_AFTER_G28, ENABLE_LEVELING_AFTER_G28)
|
||||
#define G28_L0_ENSURES_LEVELING_OFF 1
|
||||
#define CAN_SET_LEVELING_AFTER_G28 1
|
||||
#endif
|
||||
|
||||
#if ENABLED(PROBE_MANUALLY)
|
||||
|
@@ -103,9 +103,7 @@ public:
|
||||
}
|
||||
|
||||
static float get_z(const xy_pos_t &pos
|
||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
, const_float_t factor=1.0f
|
||||
#endif
|
||||
OPTARG(ENABLE_LEVELING_FADE_HEIGHT, const_float_t factor=1.0f)
|
||||
) {
|
||||
#if DISABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
constexpr float factor = 1.0f;
|
||||
|
@@ -35,6 +35,7 @@ unified_bed_leveling ubl;
|
||||
#include "../../../module/planner.h"
|
||||
#include "../../../module/motion.h"
|
||||
#include "../../../module/probe.h"
|
||||
#include "../../../module/temperature.h"
|
||||
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
#include "../../../lcd/extui/ui_api.h"
|
||||
@@ -163,7 +164,7 @@ static void serial_echo_column_labels(const uint8_t sp) {
|
||||
* 2: TODO: Display on Graphical LCD
|
||||
* 4: Compact Human-Readable
|
||||
*/
|
||||
void unified_bed_leveling::display_map(const int map_type) {
|
||||
void unified_bed_leveling::display_map(const uint8_t map_type) {
|
||||
const bool was = gcode.set_autoreport_paused(true);
|
||||
|
||||
constexpr uint8_t eachsp = 1 + 6 + 1, // [-3.567]
|
||||
@@ -254,4 +255,48 @@ bool unified_bed_leveling::sanity_check() {
|
||||
return !!error_flag;
|
||||
}
|
||||
|
||||
#if ENABLED(UBL_MESH_WIZARD)
|
||||
|
||||
/**
|
||||
* M1004: UBL Mesh Wizard - One-click mesh creation with or without a probe
|
||||
*/
|
||||
void GcodeSuite::M1004() {
|
||||
|
||||
#define ALIGN_GCODE TERN(Z_STEPPER_AUTO_ALIGN, "G34", "")
|
||||
#define PROBE_GCODE TERN(HAS_BED_PROBE, "G29P1\nG29P3", "G29P4R")
|
||||
|
||||
#if HAS_HOTEND
|
||||
if (parser.seenval('H')) { // Handle H# parameter to set Hotend temp
|
||||
const celsius_t hotend_temp = parser.value_int(); // Marlin never sends itself F or K, always C
|
||||
thermalManager.setTargetHotend(hotend_temp, 0);
|
||||
thermalManager.wait_for_hotend(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
if (parser.seenval('B')) { // Handle B# parameter to set Bed temp
|
||||
const celsius_t bed_temp = parser.value_int(); // Marlin never sends itself F or K, always C
|
||||
thermalManager.setTargetBed(bed_temp);
|
||||
thermalManager.wait_for_bed(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
process_subcommands_now_P(G28_STR); // Home
|
||||
process_subcommands_now_P(PSTR(ALIGN_GCODE "\n" // Align multi z axis if available
|
||||
PROBE_GCODE "\n" // Build mesh with available hardware
|
||||
"G29P3\nG29P3")); // Ensure mesh is complete by running smart fill twice
|
||||
|
||||
if (parser.seenval('S')) {
|
||||
char umw_gcode[32];
|
||||
sprintf_P(umw_gcode, PSTR("G29S%i"), parser.value_int());
|
||||
queue.inject(umw_gcode);
|
||||
}
|
||||
|
||||
process_subcommands_now_P(PSTR("G29A\nG29F10\n" // Set UBL Active & Fade 10
|
||||
"M140S0\nM104S0\n" // Turn off heaters
|
||||
"M500")); // Store settings
|
||||
}
|
||||
|
||||
#endif // UBL_MESH_WIZARD
|
||||
|
||||
#endif // AUTO_BED_LEVELING_UBL
|
||||
|
@@ -32,7 +32,7 @@
|
||||
#define UBL_OK false
|
||||
#define UBL_ERR true
|
||||
|
||||
enum MeshPointType : char { INVALID, REAL, SET_IN_BITMAP };
|
||||
enum MeshPointType : char { INVALID, REAL, SET_IN_BITMAP, CLOSEST };
|
||||
|
||||
// External references
|
||||
|
||||
@@ -47,10 +47,10 @@ struct mesh_index_pair;
|
||||
|
||||
typedef struct {
|
||||
bool C_seen;
|
||||
int8_t V_verbosity,
|
||||
int8_t KLS_storage_slot;
|
||||
uint8_t R_repetition,
|
||||
V_verbosity,
|
||||
P_phase,
|
||||
R_repetition,
|
||||
KLS_storage_slot,
|
||||
T_map_type;
|
||||
float B_shim_thickness,
|
||||
C_constant;
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
static void report_state();
|
||||
static void save_ubl_active_state_and_disable();
|
||||
static void restore_ubl_active_state_and_leave();
|
||||
static void display_map(const int) _O0;
|
||||
static void display_map(const uint8_t) _O0;
|
||||
static mesh_index_pair find_closest_mesh_point_of_type(const MeshPointType, const xy_pos_t&, const bool=false, MeshFlags *done_flags=nullptr) _O0;
|
||||
static mesh_index_pair find_furthest_invalid_mesh_point() _O0;
|
||||
static void reset();
|
||||
|
@@ -305,8 +305,8 @@ void unified_bed_leveling::G29() {
|
||||
bool probe_deployed = false;
|
||||
if (G29_parse_parameters()) return; // Abort on parameter error
|
||||
|
||||
const int8_t p_val = parser.intval('P', -1);
|
||||
const bool may_move = p_val == 1 || p_val == 2 || p_val == 4 || parser.seen('J');
|
||||
const uint8_t p_val = parser.byteval('P');
|
||||
const bool may_move = p_val == 1 || p_val == 2 || p_val == 4 || parser.seen_test('J');
|
||||
#if ENABLED(HAS_MULTI_HOTEND)
|
||||
const uint8_t old_tool_index = active_extruder;
|
||||
#endif
|
||||
@@ -315,13 +315,13 @@ void unified_bed_leveling::G29() {
|
||||
if (may_move) {
|
||||
planner.synchronize();
|
||||
// Send 'N' to force homing before G29 (internal only)
|
||||
if (axes_should_home() || parser.seen('N')) gcode.home_all_axes();
|
||||
if (axes_should_home() || parser.seen_test('N')) gcode.home_all_axes();
|
||||
TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0));
|
||||
}
|
||||
|
||||
// Invalidate one or more nearby mesh points, possibly all.
|
||||
if (parser.seen('I')) {
|
||||
int16_t count = parser.has_value() ? parser.value_int() : 1;
|
||||
uint8_t count = parser.has_value() ? parser.value_byte() : 1;
|
||||
bool invalidate_all = count >= GRID_MAX_POINTS;
|
||||
if (!invalidate_all) {
|
||||
while (count--) {
|
||||
@@ -345,7 +345,7 @@ void unified_bed_leveling::G29() {
|
||||
}
|
||||
|
||||
if (parser.seen('Q')) {
|
||||
const int test_pattern = parser.has_value() ? parser.value_int() : -99;
|
||||
const int16_t test_pattern = parser.has_value() ? parser.value_int() : -99;
|
||||
if (!WITHIN(test_pattern, -1, 2)) {
|
||||
SERIAL_ECHOLNPGM("Invalid test_pattern value. (-1 to 2)\n");
|
||||
return;
|
||||
@@ -380,7 +380,7 @@ void unified_bed_leveling::G29() {
|
||||
// Allow the user to specify the height because 10mm is a little extreme in some cases.
|
||||
for (uint8_t x = (GRID_MAX_POINTS_X) / 3; x < 2 * (GRID_MAX_POINTS_X) / 3; x++) // Create a rectangular raised area in
|
||||
for (uint8_t y = (GRID_MAX_POINTS_Y) / 3; y < 2 * (GRID_MAX_POINTS_Y) / 3; y++) { // the center of the bed
|
||||
z_values[x][y] += parser.seen('C') ? param.C_constant : 9.99f;
|
||||
z_values[x][y] += parser.seen_test('C') ? param.C_constant : 9.99f;
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
|
||||
}
|
||||
break;
|
||||
@@ -389,7 +389,7 @@ void unified_bed_leveling::G29() {
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
|
||||
if (parser.seen('J')) {
|
||||
if (parser.seen_test('J')) {
|
||||
save_ubl_active_state_and_disable();
|
||||
tilt_mesh_based_on_probed_grid(param.J_grid_size == 0); // Zero size does 3-Point
|
||||
restore_ubl_active_state_and_leave();
|
||||
@@ -402,7 +402,7 @@ void unified_bed_leveling::G29() {
|
||||
|
||||
#endif // HAS_BED_PROBE
|
||||
|
||||
if (parser.seen('P')) {
|
||||
if (parser.seen_test('P')) {
|
||||
if (WITHIN(param.P_phase, 0, 1) && storage_slot == -1) {
|
||||
storage_slot = 0;
|
||||
SERIAL_ECHOLNPGM("Default storage slot 0 selected.");
|
||||
@@ -423,7 +423,7 @@ void unified_bed_leveling::G29() {
|
||||
//
|
||||
// Invalidate Entire Mesh and Automatically Probe Mesh in areas that can be reached by the probe
|
||||
//
|
||||
if (!parser.seen('C')) {
|
||||
if (!parser.seen_test('C')) {
|
||||
invalidate();
|
||||
SERIAL_ECHOLNPGM("Mesh invalidated. Probing mesh.");
|
||||
}
|
||||
@@ -433,7 +433,7 @@ void unified_bed_leveling::G29() {
|
||||
SERIAL_DECIMAL(param.XY_pos.y);
|
||||
SERIAL_ECHOLNPGM(").\n");
|
||||
}
|
||||
probe_entire_mesh(param.XY_pos, parser.seen('T'), parser.seen('E'), parser.seen('U'));
|
||||
probe_entire_mesh(param.XY_pos, parser.seen_test('T'), parser.seen_test('E'), parser.seen_test('U'));
|
||||
|
||||
report_current_position();
|
||||
probe_deployed = true;
|
||||
@@ -449,7 +449,7 @@ void unified_bed_leveling::G29() {
|
||||
SERIAL_ECHOLNPGM("Manually probing unreachable points.");
|
||||
do_z_clearance(Z_CLEARANCE_BETWEEN_PROBES);
|
||||
|
||||
if (parser.seen('C') && !param.XY_seen) {
|
||||
if (parser.seen_test('C') && !param.XY_seen) {
|
||||
|
||||
/**
|
||||
* Use a good default location for the path.
|
||||
@@ -483,7 +483,7 @@ void unified_bed_leveling::G29() {
|
||||
}
|
||||
|
||||
const float height = parser.floatval('H', Z_CLEARANCE_BETWEEN_PROBES);
|
||||
manually_probe_remaining_mesh(param.XY_pos, height, param.B_shim_thickness, parser.seen('T'));
|
||||
manually_probe_remaining_mesh(param.XY_pos, height, param.B_shim_thickness, parser.seen_test('T'));
|
||||
|
||||
SERIAL_ECHOLNPGM("G29 P2 finished.");
|
||||
|
||||
@@ -555,7 +555,7 @@ void unified_bed_leveling::G29() {
|
||||
|
||||
case 4: // Fine Tune (i.e., Edit) the Mesh
|
||||
#if HAS_LCD_MENU
|
||||
fine_tune_mesh(param.XY_pos, parser.seen('T'));
|
||||
fine_tune_mesh(param.XY_pos, parser.seen_test('T'));
|
||||
#else
|
||||
SERIAL_ECHOLNPGM("?P4 is only available when an LCD is present.");
|
||||
return;
|
||||
@@ -574,7 +574,7 @@ void unified_bed_leveling::G29() {
|
||||
// Much of the 'What?' command can be eliminated. But until we are fully debugged, it is
|
||||
// good to have the extra information. Soon... we prune this to just a few items
|
||||
//
|
||||
if (parser.seen('W')) g29_what_command();
|
||||
if (parser.seen_test('W')) g29_what_command();
|
||||
|
||||
//
|
||||
// When we are fully debugged, this may go away. But there are some valid
|
||||
@@ -592,7 +592,7 @@ void unified_bed_leveling::G29() {
|
||||
//
|
||||
|
||||
if (parser.seen('L')) { // Load Current Mesh Data
|
||||
param.KLS_storage_slot = parser.has_value() ? parser.value_int() : storage_slot;
|
||||
param.KLS_storage_slot = parser.has_value() ? (int8_t)parser.value_int() : storage_slot;
|
||||
|
||||
int16_t a = settings.calc_num_meshes();
|
||||
|
||||
@@ -617,10 +617,10 @@ void unified_bed_leveling::G29() {
|
||||
//
|
||||
|
||||
if (parser.seen('S')) { // Store (or Save) Current Mesh Data
|
||||
param.KLS_storage_slot = parser.has_value() ? parser.value_int() : storage_slot;
|
||||
param.KLS_storage_slot = parser.has_value() ? (int8_t)parser.value_int() : storage_slot;
|
||||
|
||||
if (param.KLS_storage_slot == -1) // Special case, the user wants to 'Export' the mesh to the
|
||||
return report_current_mesh(); // host program to be saved on the user's computer
|
||||
if (param.KLS_storage_slot == -1) // Special case: 'Export' the mesh to the
|
||||
return report_current_mesh(); // host so it can be saved in a file.
|
||||
|
||||
int16_t a = settings.calc_num_meshes();
|
||||
|
||||
@@ -640,7 +640,7 @@ void unified_bed_leveling::G29() {
|
||||
SERIAL_ECHOLNPGM("Done.");
|
||||
}
|
||||
|
||||
if (parser.seen('T'))
|
||||
if (parser.seen_test('T'))
|
||||
display_map(param.T_map_type);
|
||||
|
||||
LEAVE:
|
||||
@@ -673,7 +673,7 @@ void unified_bed_leveling::G29() {
|
||||
*/
|
||||
void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const_float_t offset) {
|
||||
float sum = 0;
|
||||
int n = 0;
|
||||
uint8_t n = 0;
|
||||
GRID_LOOP(x, y)
|
||||
if (!isnan(z_values[x][y])) {
|
||||
sum += z_values[x][y];
|
||||
@@ -734,7 +734,7 @@ void unified_bed_leveling::shift_mesh_height() {
|
||||
do {
|
||||
if (do_ubl_mesh_map) display_map(param.T_map_type);
|
||||
|
||||
const int point_num = (GRID_MAX_POINTS) - count + 1;
|
||||
const uint8_t point_num = (GRID_MAX_POINTS - count) + 1;
|
||||
SERIAL_ECHOLNPAIR("Probing mesh point ", point_num, "/", GRID_MAX_POINTS, ".");
|
||||
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), point_num, int(GRID_MAX_POINTS)));
|
||||
|
||||
@@ -915,7 +915,7 @@ void set_message_with_feedback(PGM_P const msg_P) {
|
||||
|
||||
if (do_ubl_mesh_map) display_map(param.T_map_type); // Show user where we're probing
|
||||
|
||||
if (parser.seen('B')) {
|
||||
if (parser.seen_test('B')) {
|
||||
SERIAL_ECHOPGM_P(GET_TEXT(MSG_UBL_BC_INSERT));
|
||||
LCD_MESSAGEPGM(MSG_UBL_BC_INSERT);
|
||||
}
|
||||
@@ -954,7 +954,7 @@ void set_message_with_feedback(PGM_P const msg_P) {
|
||||
* NOTE: Blocks the G-code queue and captures Marlin UI during use.
|
||||
*/
|
||||
void unified_bed_leveling::fine_tune_mesh(const xy_pos_t &pos, const bool do_ubl_mesh_map) {
|
||||
if (!parser.seen('R')) // fine_tune_mesh() is special. If no repetition count flag is specified
|
||||
if (!parser.seen_test('R')) // fine_tune_mesh() is special. If no repetition count flag is specified
|
||||
param.R_repetition = 1; // do exactly one mesh location. Otherwise use what the parser decided.
|
||||
|
||||
#if ENABLED(UBL_MESH_EDIT_MOVES_Z)
|
||||
@@ -1025,7 +1025,7 @@ void set_message_with_feedback(PGM_P const msg_P) {
|
||||
SET_SOFT_ENDSTOP_LOOSE(true);
|
||||
|
||||
do {
|
||||
idle();
|
||||
idle_no_sleep();
|
||||
new_z = ui.ubl_mesh_value();
|
||||
TERN_(UBL_MESH_EDIT_MOVES_Z, do_blocking_move_to_z(h_offset + new_z)); // Move the nozzle as the point is edited
|
||||
SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
|
||||
@@ -1083,7 +1083,7 @@ bool unified_bed_leveling::G29_parse_parameters() {
|
||||
param.R_repetition = 0;
|
||||
|
||||
if (parser.seen('R')) {
|
||||
param.R_repetition = parser.has_value() ? parser.value_int() : GRID_MAX_POINTS;
|
||||
param.R_repetition = parser.has_value() ? parser.value_byte() : GRID_MAX_POINTS;
|
||||
NOMORE(param.R_repetition, GRID_MAX_POINTS);
|
||||
if (param.R_repetition < 1) {
|
||||
SERIAL_ECHOLNPGM("?(R)epetition count invalid (1+).\n");
|
||||
@@ -1091,14 +1091,14 @@ bool unified_bed_leveling::G29_parse_parameters() {
|
||||
}
|
||||
}
|
||||
|
||||
param.V_verbosity = parser.seen('V') ? parser.value_int() : 0;
|
||||
param.V_verbosity = parser.byteval('V');
|
||||
if (!WITHIN(param.V_verbosity, 0, 4)) {
|
||||
SERIAL_ECHOLNPGM("?(V)erbose level implausible (0-4).\n");
|
||||
err_flag = true;
|
||||
}
|
||||
|
||||
if (parser.seen('P')) {
|
||||
const int pv = parser.value_int();
|
||||
const uint8_t pv = parser.value_byte();
|
||||
#if !HAS_BED_PROBE
|
||||
if (pv == 1) {
|
||||
SERIAL_ECHOLNPGM("G29 P1 requires a probe.\n");
|
||||
@@ -1153,15 +1153,15 @@ bool unified_bed_leveling::G29_parse_parameters() {
|
||||
* Leveling is being enabled here with old data, possibly
|
||||
* none. Error handling should disable for safety...
|
||||
*/
|
||||
if (parser.seen('A')) {
|
||||
if (parser.seen('D')) {
|
||||
if (parser.seen_test('A')) {
|
||||
if (parser.seen_test('D')) {
|
||||
SERIAL_ECHOLNPGM("?Can't activate and deactivate at the same time.\n");
|
||||
return UBL_ERR;
|
||||
}
|
||||
set_bed_leveling_enabled(true);
|
||||
report_state();
|
||||
}
|
||||
else if (parser.seen('D')) {
|
||||
else if (parser.seen_test('D')) {
|
||||
set_bed_leveling_enabled(false);
|
||||
report_state();
|
||||
}
|
||||
@@ -1181,7 +1181,7 @@ bool unified_bed_leveling::G29_parse_parameters() {
|
||||
}
|
||||
#endif
|
||||
|
||||
param.T_map_type = parser.intval('T');
|
||||
param.T_map_type = parser.byteval('T');
|
||||
if (!WITHIN(param.T_map_type, 0, 2)) {
|
||||
SERIAL_ECHOLNPGM("Invalid map type.\n");
|
||||
return UBL_ERR;
|
||||
@@ -1282,7 +1282,7 @@ mesh_index_pair unified_bed_leveling::find_furthest_invalid_mesh_point() {
|
||||
|
||||
static bool test_func(uint8_t i, uint8_t j, void *data) {
|
||||
find_closest_t *d = (find_closest_t*)data;
|
||||
if ( (d->type == (isnan(ubl.z_values[i][j]) ? INVALID : REAL))
|
||||
if ( d->type == CLOSEST || d->type == (isnan(ubl.z_values[i][j]) ? INVALID : REAL)
|
||||
|| (d->type == SET_IN_BITMAP && !d->done_flags->marked(i, j))
|
||||
) {
|
||||
// Found a Mesh Point of the specified type!
|
||||
@@ -1326,7 +1326,7 @@ mesh_index_pair unified_bed_leveling::find_closest_mesh_point_of_type(const Mesh
|
||||
float best_so_far = 99999.99f;
|
||||
|
||||
GRID_LOOP(i, j) {
|
||||
if ( (type == (isnan(z_values[i][j]) ? INVALID : REAL))
|
||||
if ( type == CLOSEST || type == (isnan(z_values[i][j]) ? INVALID : REAL)
|
||||
|| (type == SET_IN_BITMAP && !done_flags->marked(i, j))
|
||||
) {
|
||||
// Found a Mesh Point of the specified type!
|
||||
@@ -1520,7 +1520,7 @@ void unified_bed_leveling::smart_fill_mesh() {
|
||||
SERIAL_ECHOLNPAIR("Tilting mesh point ", point_num, "/", total_points, "\n");
|
||||
TERN_(HAS_STATUS_MESSAGE, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points));
|
||||
|
||||
measured_z = probe.probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity); // TODO: Needs error handling
|
||||
measured_z = probe.probe_at_point(rpos, parser.seen_test('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity); // TODO: Needs error handling
|
||||
|
||||
abort_flag = isnan(measured_z);
|
||||
|
||||
@@ -1833,7 +1833,7 @@ void unified_bed_leveling::smart_fill_mesh() {
|
||||
return;
|
||||
}
|
||||
|
||||
param.KLS_storage_slot = parser.value_int();
|
||||
param.KLS_storage_slot = (int8_t)parser.value_int();
|
||||
|
||||
float tmp_z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
|
||||
settings.load_mesh(param.KLS_storage_slot, &tmp_z_values);
|
||||
|
@@ -113,20 +113,22 @@
|
||||
const xy_float_t ad = sign * dist;
|
||||
const bool use_x_dist = ad.x > ad.y;
|
||||
|
||||
float on_axis_distance = use_x_dist ? dist.x : dist.y,
|
||||
e_position = end.e - start.e,
|
||||
z_position = end.z - start.z;
|
||||
float on_axis_distance = use_x_dist ? dist.x : dist.y;
|
||||
|
||||
const float e_normalized_dist = e_position / on_axis_distance, // Allow divide by zero
|
||||
z_normalized_dist = z_position / on_axis_distance;
|
||||
const float z_normalized_dist = (end.z - start.z) / on_axis_distance; // Allow divide by zero
|
||||
#if HAS_EXTRUDERS
|
||||
const float e_normalized_dist = (end.e - start.e) / on_axis_distance;
|
||||
const bool inf_normalized_flag = isinf(e_normalized_dist);
|
||||
#endif
|
||||
|
||||
xy_int8_t icell = istart;
|
||||
|
||||
const float ratio = dist.y / dist.x, // Allow divide by zero
|
||||
c = start.y - ratio * start.x;
|
||||
|
||||
const bool inf_normalized_flag = isinf(e_normalized_dist),
|
||||
inf_ratio_flag = isinf(ratio);
|
||||
const bool inf_ratio_flag = isinf(ratio);
|
||||
|
||||
xyze_pos_t dest; // Stores XYZE for segmented moves
|
||||
|
||||
/**
|
||||
* Handle vertical lines that stay within one column.
|
||||
@@ -143,34 +145,36 @@
|
||||
* For others the next X is the same so this can continue.
|
||||
* Calculate X at the next Y mesh line.
|
||||
*/
|
||||
const float rx = inf_ratio_flag ? start.x : (next_mesh_line_y - c) / ratio;
|
||||
dest.x = inf_ratio_flag ? start.x : (next_mesh_line_y - c) / ratio;
|
||||
|
||||
float z0 = z_correction_for_x_on_horizontal_mesh_line(rx, icell.x, icell.y)
|
||||
float z0 = z_correction_for_x_on_horizontal_mesh_line(dest.x, icell.x, icell.y)
|
||||
* planner.fade_scaling_factor_for_z(end.z);
|
||||
|
||||
// Undefined parts of the Mesh in z_values[][] are NAN.
|
||||
// Replace NAN corrections with 0.0 to prevent NAN propagation.
|
||||
if (isnan(z0)) z0 = 0.0;
|
||||
|
||||
const float ry = mesh_index_to_ypos(icell.y);
|
||||
dest.y = mesh_index_to_ypos(icell.y);
|
||||
|
||||
/**
|
||||
* Without this check, it's possible to generate a zero length move, as in the case where
|
||||
* the line is heading down, starting exactly on a mesh line boundary. Since this is rare
|
||||
* it might be fine to remove this check and let planner.buffer_segment() filter it out.
|
||||
*/
|
||||
if (ry != start.y) {
|
||||
if (dest.y != start.y) {
|
||||
if (!inf_normalized_flag) { // fall-through faster than branch
|
||||
on_axis_distance = use_x_dist ? rx - start.x : ry - start.y;
|
||||
e_position = start.e + on_axis_distance * e_normalized_dist;
|
||||
z_position = start.z + on_axis_distance * z_normalized_dist;
|
||||
on_axis_distance = use_x_dist ? dest.x - start.x : dest.y - start.y;
|
||||
TERN_(HAS_EXTRUDERS, dest.e = start.e + on_axis_distance * e_normalized_dist);
|
||||
dest.z = start.z + on_axis_distance * z_normalized_dist;
|
||||
}
|
||||
else {
|
||||
e_position = end.e;
|
||||
z_position = end.z;
|
||||
TERN_(HAS_EXTRUDERS, dest.e = end.e);
|
||||
dest.z = end.z;
|
||||
}
|
||||
|
||||
planner.buffer_segment(rx, ry, z_position + z0, e_position, scaled_fr_mm_s, extruder);
|
||||
dest.z += z0;
|
||||
planner.buffer_segment(dest, scaled_fr_mm_s, extruder);
|
||||
|
||||
} //else printf("FIRST MOVE PRUNED ");
|
||||
}
|
||||
|
||||
@@ -188,12 +192,13 @@
|
||||
*/
|
||||
if (iadd.y == 0) { // Horizontal line?
|
||||
icell.x += ineg.x; // Heading left? Just go to the left edge of the cell for the first move.
|
||||
|
||||
while (icell.x != iend.x + ineg.x) {
|
||||
icell.x += iadd.x;
|
||||
const float rx = mesh_index_to_xpos(icell.x);
|
||||
const float ry = ratio * rx + c; // Calculate Y at the next X mesh line
|
||||
dest.x = mesh_index_to_xpos(icell.x);
|
||||
dest.y = ratio * dest.x + c; // Calculate Y at the next X mesh line
|
||||
|
||||
float z0 = z_correction_for_y_on_vertical_mesh_line(ry, icell.x, icell.y)
|
||||
float z0 = z_correction_for_y_on_vertical_mesh_line(dest.y, icell.x, icell.y)
|
||||
* planner.fade_scaling_factor_for_z(end.z);
|
||||
|
||||
// Undefined parts of the Mesh in z_values[][] are NAN.
|
||||
@@ -205,19 +210,20 @@
|
||||
* the line is heading left, starting exactly on a mesh line boundary. Since this is rare
|
||||
* it might be fine to remove this check and let planner.buffer_segment() filter it out.
|
||||
*/
|
||||
if (rx != start.x) {
|
||||
if (dest.x != start.x) {
|
||||
if (!inf_normalized_flag) {
|
||||
on_axis_distance = use_x_dist ? rx - start.x : ry - start.y;
|
||||
e_position = start.e + on_axis_distance * e_normalized_dist; // is based on X or Y because this is a horizontal move
|
||||
z_position = start.z + on_axis_distance * z_normalized_dist;
|
||||
on_axis_distance = use_x_dist ? dest.x - start.x : dest.y - start.y;
|
||||
TERN_(HAS_EXTRUDERS, dest.e = start.e + on_axis_distance * e_normalized_dist); // Based on X or Y because the move is horizontal
|
||||
dest.z = start.z + on_axis_distance * z_normalized_dist;
|
||||
}
|
||||
else {
|
||||
e_position = end.e;
|
||||
z_position = end.z;
|
||||
TERN_(HAS_EXTRUDERS, dest.e = end.e);
|
||||
dest.z = end.z;
|
||||
}
|
||||
|
||||
if (!planner.buffer_segment(rx, ry, z_position + z0, e_position, scaled_fr_mm_s, extruder))
|
||||
break;
|
||||
dest.z += z0;
|
||||
if (!planner.buffer_segment(dest, scaled_fr_mm_s, extruder)) break;
|
||||
|
||||
} //else printf("FIRST MOVE PRUNED ");
|
||||
}
|
||||
|
||||
@@ -239,57 +245,65 @@
|
||||
while (cnt) {
|
||||
|
||||
const float next_mesh_line_x = mesh_index_to_xpos(icell.x + iadd.x),
|
||||
next_mesh_line_y = mesh_index_to_ypos(icell.y + iadd.y),
|
||||
ry = ratio * next_mesh_line_x + c, // Calculate Y at the next X mesh line
|
||||
rx = (next_mesh_line_y - c) / ratio; // Calculate X at the next Y mesh line
|
||||
// (No need to worry about ratio == 0.
|
||||
// In that case, it was already detected
|
||||
// as a vertical line move above.)
|
||||
next_mesh_line_y = mesh_index_to_ypos(icell.y + iadd.y);
|
||||
|
||||
if (neg.x == (rx > next_mesh_line_x)) { // Check if we hit the Y line first
|
||||
dest.y = ratio * next_mesh_line_x + c; // Calculate Y at the next X mesh line
|
||||
dest.x = (next_mesh_line_y - c) / ratio; // Calculate X at the next Y mesh line
|
||||
// (No need to worry about ratio == 0.
|
||||
// In that case, it was already detected
|
||||
// as a vertical line move above.)
|
||||
|
||||
if (neg.x == (dest.x > next_mesh_line_x)) { // Check if we hit the Y line first
|
||||
// Yes! Crossing a Y Mesh Line next
|
||||
float z0 = z_correction_for_x_on_horizontal_mesh_line(rx, icell.x - ineg.x, icell.y + iadd.y)
|
||||
float z0 = z_correction_for_x_on_horizontal_mesh_line(dest.x, icell.x - ineg.x, icell.y + iadd.y)
|
||||
* planner.fade_scaling_factor_for_z(end.z);
|
||||
|
||||
// Undefined parts of the Mesh in z_values[][] are NAN.
|
||||
// Replace NAN corrections with 0.0 to prevent NAN propagation.
|
||||
if (isnan(z0)) z0 = 0.0;
|
||||
|
||||
dest.y = next_mesh_line_y;
|
||||
|
||||
if (!inf_normalized_flag) {
|
||||
on_axis_distance = use_x_dist ? rx - start.x : next_mesh_line_y - start.y;
|
||||
e_position = start.e + on_axis_distance * e_normalized_dist;
|
||||
z_position = start.z + on_axis_distance * z_normalized_dist;
|
||||
on_axis_distance = use_x_dist ? dest.x - start.x : dest.y - start.y;
|
||||
TERN_(HAS_EXTRUDERS, dest.e = start.e + on_axis_distance * e_normalized_dist);
|
||||
dest.z = start.z + on_axis_distance * z_normalized_dist;
|
||||
}
|
||||
else {
|
||||
e_position = end.e;
|
||||
z_position = end.z;
|
||||
TERN_(HAS_EXTRUDERS, dest.e = end.e);
|
||||
dest.z = end.z;
|
||||
}
|
||||
if (!planner.buffer_segment(rx, next_mesh_line_y, z_position + z0, e_position, scaled_fr_mm_s, extruder))
|
||||
break;
|
||||
|
||||
dest.z += z0;
|
||||
if (!planner.buffer_segment(dest, scaled_fr_mm_s, extruder)) break;
|
||||
|
||||
icell.y += iadd.y;
|
||||
cnt.y--;
|
||||
}
|
||||
else {
|
||||
// Yes! Crossing a X Mesh Line next
|
||||
float z0 = z_correction_for_y_on_vertical_mesh_line(ry, icell.x + iadd.x, icell.y - ineg.y)
|
||||
float z0 = z_correction_for_y_on_vertical_mesh_line(dest.y, icell.x + iadd.x, icell.y - ineg.y)
|
||||
* planner.fade_scaling_factor_for_z(end.z);
|
||||
|
||||
// Undefined parts of the Mesh in z_values[][] are NAN.
|
||||
// Replace NAN corrections with 0.0 to prevent NAN propagation.
|
||||
if (isnan(z0)) z0 = 0.0;
|
||||
|
||||
dest.x = next_mesh_line_x;
|
||||
|
||||
if (!inf_normalized_flag) {
|
||||
on_axis_distance = use_x_dist ? next_mesh_line_x - start.x : ry - start.y;
|
||||
e_position = start.e + on_axis_distance * e_normalized_dist;
|
||||
z_position = start.z + on_axis_distance * z_normalized_dist;
|
||||
on_axis_distance = use_x_dist ? dest.x - start.x : dest.y - start.y;
|
||||
TERN_(HAS_EXTRUDERS, dest.e = start.e + on_axis_distance * e_normalized_dist);
|
||||
dest.z = start.z + on_axis_distance * z_normalized_dist;
|
||||
}
|
||||
else {
|
||||
e_position = end.e;
|
||||
z_position = end.z;
|
||||
TERN_(HAS_EXTRUDERS, dest.e = end.e);
|
||||
dest.z = end.z;
|
||||
}
|
||||
|
||||
if (!planner.buffer_segment(next_mesh_line_x, ry, z_position + z0, e_position, scaled_fr_mm_s, extruder))
|
||||
break;
|
||||
dest.z += z0;
|
||||
if (!planner.buffer_segment(dest, scaled_fr_mm_s, extruder)) break;
|
||||
|
||||
icell.x += iadd.x;
|
||||
cnt.x--;
|
||||
}
|
||||
@@ -362,15 +376,11 @@
|
||||
while (--segments) {
|
||||
raw += diff;
|
||||
planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, segment_xyz_mm
|
||||
#if ENABLED(SCARA_FEEDRATE_SCALING)
|
||||
, inv_duration
|
||||
#endif
|
||||
OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
|
||||
);
|
||||
}
|
||||
planner.buffer_line(destination, scaled_fr_mm_s, active_extruder, segment_xyz_mm
|
||||
#if ENABLED(SCARA_FEEDRATE_SCALING)
|
||||
, inv_duration
|
||||
#endif
|
||||
OPTARG(SCARA_FEEDRATE_SCALING, inv_duration)
|
||||
);
|
||||
return false; // Did not set current from destination
|
||||
}
|
||||
@@ -442,11 +452,9 @@
|
||||
#endif
|
||||
;
|
||||
|
||||
planner.buffer_line(raw.x, raw.y, raw.z + z_cxcy, raw.e, scaled_fr_mm_s, active_extruder, segment_xyz_mm
|
||||
#if ENABLED(SCARA_FEEDRATE_SCALING)
|
||||
, inv_duration
|
||||
#endif
|
||||
);
|
||||
const float oldz = raw.z; raw.z += z_cxcy;
|
||||
planner.buffer_line(raw, scaled_fr_mm_s, active_extruder, segment_xyz_mm OPTARG(SCARA_FEEDRATE_SCALING, inv_duration) );
|
||||
raw.z = oldz;
|
||||
|
||||
if (segments == 0) // done with last segment
|
||||
return false; // didn't set current from destination
|
||||
|
@@ -24,9 +24,11 @@
|
||||
#include "../inc/MarlinConfig.h"
|
||||
|
||||
#define BINARY_STREAM_COMPRESSION
|
||||
|
||||
#if ENABLED(BINARY_STREAM_COMPRESSION)
|
||||
#include "../libs/heatshrink/heatshrink_decoder.h"
|
||||
// STM32 (and others?) require a word-aligned buffer for SD card transfers via DMA
|
||||
static __attribute__((aligned(sizeof(size_t)))) uint8_t decode_buffer[512] = {};
|
||||
static heatshrink_decoder hsd;
|
||||
#endif
|
||||
|
||||
inline bool bs_serial_data_available(const serial_index_t index) {
|
||||
@@ -37,16 +39,6 @@ inline int bs_read_serial(const serial_index_t index) {
|
||||
return SERIAL_IMPL.read(index);
|
||||
}
|
||||
|
||||
#if ENABLED(BINARY_STREAM_COMPRESSION)
|
||||
static heatshrink_decoder hsd;
|
||||
#if BOTH(ARDUINO_ARCH_STM32F1, SDIO_SUPPORT)
|
||||
// STM32 requires a word-aligned buffer for SD card transfers via DMA
|
||||
static __attribute__((aligned(sizeof(size_t)))) uint8_t decode_buffer[512] = {};
|
||||
#else
|
||||
static uint8_t decode_buffer[512] = {};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class SDFileTransferProtocol {
|
||||
private:
|
||||
struct Packet {
|
||||
|
@@ -28,10 +28,6 @@
|
||||
|
||||
CaseLight caselight;
|
||||
|
||||
#if CASE_LIGHT_IS_COLOR_LED
|
||||
#include "leds/leds.h"
|
||||
#endif
|
||||
|
||||
#if CASELIGHT_USES_BRIGHTNESS && !defined(CASE_LIGHT_DEFAULT_BRIGHTNESS)
|
||||
#define CASE_LIGHT_DEFAULT_BRIGHTNESS 0 // For use on PWM pin as non-PWM just sets a default
|
||||
#endif
|
||||
@@ -43,17 +39,9 @@ CaseLight caselight;
|
||||
bool CaseLight::on = CASE_LIGHT_DEFAULT_ON;
|
||||
|
||||
#if CASE_LIGHT_IS_COLOR_LED
|
||||
LEDColor CaseLight::color =
|
||||
#ifdef CASE_LIGHT_DEFAULT_COLOR
|
||||
CASE_LIGHT_DEFAULT_COLOR
|
||||
#else
|
||||
{ 255, 255, 255, 255 }
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
|
||||
#ifndef INVERT_CASE_LIGHT
|
||||
#define INVERT_CASE_LIGHT false
|
||||
#include "leds/leds.h"
|
||||
constexpr uint8_t init_case_light[] = CASE_LIGHT_DEFAULT_COLOR;
|
||||
LEDColor CaseLight::color = { init_case_light[0], init_case_light[1], init_case_light[2] OPTARG(HAS_WHITE_LED, init_case_light[3]) };
|
||||
#endif
|
||||
|
||||
void CaseLight::update(const bool sflag) {
|
||||
@@ -72,16 +60,12 @@ void CaseLight::update(const bool sflag) {
|
||||
if (sflag && on)
|
||||
brightness = brightness_sav; // Restore last brightness for M355 S1
|
||||
|
||||
const uint8_t i = on ? brightness : 0, n10ct = INVERT_CASE_LIGHT ? 255 - i : i;
|
||||
const uint8_t i = on ? brightness : 0, n10ct = ENABLED(INVERT_CASE_LIGHT) ? 255 - i : i;
|
||||
UNUSED(n10ct);
|
||||
#endif
|
||||
|
||||
#if CASE_LIGHT_IS_COLOR_LED
|
||||
|
||||
leds.set_color(
|
||||
MakeLEDColor(color.r, color.g, color.b, color.w, n10ct),
|
||||
false
|
||||
);
|
||||
|
||||
leds.set_color(LEDColor(color.r, color.g, color.b OPTARG(HAS_WHITE_LED, color.w), n10ct));
|
||||
#else // !CASE_LIGHT_IS_COLOR_LED
|
||||
|
||||
#if CASELIGHT_USES_BRIGHTNESS
|
||||
@@ -96,7 +80,7 @@ void CaseLight::update(const bool sflag) {
|
||||
else
|
||||
#endif
|
||||
{
|
||||
const bool s = on ? !INVERT_CASE_LIGHT : INVERT_CASE_LIGHT;
|
||||
const bool s = on ? TERN(INVERT_CASE_LIGHT, LOW, HIGH) : TERN(INVERT_CASE_LIGHT, HIGH, LOW);
|
||||
WRITE(CASE_LIGHT_PIN, s ? HIGH : LOW);
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@
|
||||
#include "leds/leds.h" // for LEDColor
|
||||
#endif
|
||||
|
||||
#if DISABLED(CASE_LIGHT_NO_BRIGHTNESS) || ENABLED(CASE_LIGHT_USE_NEOPIXEL)
|
||||
#if NONE(CASE_LIGHT_NO_BRIGHTNESS, CASE_LIGHT_IS_COLOR_LED) || ENABLED(CASE_LIGHT_USE_NEOPIXEL)
|
||||
#define CASELIGHT_USES_BRIGHTNESS 1
|
||||
#endif
|
||||
|
||||
|
@@ -78,10 +78,8 @@ public:
|
||||
|
||||
// Get the total flow (in liters per minute) since the last reading
|
||||
static void calc_flowrate() {
|
||||
//flowmeter_interrupt_disable();
|
||||
// const uint16_t pulses = flowpulses;
|
||||
//flowmeter_interrupt_enable();
|
||||
flowrate = flowpulses * 60.0f * (1000.0f / (FLOWMETER_INTERVAL)) * (1000.0f / (FLOWMETER_PPL));
|
||||
// flowrate = (litres) * (seconds) = litres per minute
|
||||
flowrate = (flowpulses / (float)FLOWMETER_PPL) * ((1000.0f / (float)FLOWMETER_INTERVAL) * 60.0f);
|
||||
flowpulses = 0;
|
||||
}
|
||||
|
||||
|
@@ -66,14 +66,14 @@ uint8_t MCP4728::analogWrite(const uint8_t channel, const uint16_t value) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Write all input resistor values to EEPROM using SequencialWrite method.
|
||||
* Write all input resistor values to EEPROM using SequentialWrite method.
|
||||
* This will update both input register and EEPROM value
|
||||
* This will also write current Vref, PowerDown, Gain settings to EEPROM
|
||||
*/
|
||||
uint8_t MCP4728::eepromWrite() {
|
||||
Wire.beginTransmission(I2C_ADDRESS(DAC_DEV_ADDRESS));
|
||||
Wire.write(SEQWRITE);
|
||||
LOOP_XYZE(i) {
|
||||
LOOP_LOGICAL_AXES(i) {
|
||||
Wire.write(DAC_STEPPER_VREF << 7 | DAC_STEPPER_GAIN << 4 | highByte(dac_values[i]));
|
||||
Wire.write(lowByte(dac_values[i]));
|
||||
}
|
||||
@@ -135,7 +135,7 @@ void MCP4728::setDrvPct(xyze_uint_t &pct) {
|
||||
*/
|
||||
uint8_t MCP4728::fastWrite() {
|
||||
Wire.beginTransmission(I2C_ADDRESS(DAC_DEV_ADDRESS));
|
||||
LOOP_XYZE(i) {
|
||||
LOOP_LOGICAL_AXES(i) {
|
||||
Wire.write(highByte(dac_values[i]));
|
||||
Wire.write(lowByte(dac_values[i]));
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user