Browse Source

Merge branch '2.0.x' into vanilla_fb_2.0.x

vanilla_fb_2.0.x
Sergey 3 years ago
parent
commit
96c1807b76
  1. 8
      .gitignore
  2. 8
      .vscode/extensions.json
  3. 3
      Marlin/Configuration_adv.h
  4. 2
      Marlin/src/HAL/AVR/MarlinSerial.h
  5. 2
      Marlin/src/HAL/DUE/MarlinSerial.h
  6. 2
      Marlin/src/HAL/DUE/MarlinSerialUSB.cpp
  7. 2
      Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp
  8. 2
      Marlin/src/HAL/LPC1768/include/SPI.h
  9. 4
      Marlin/src/HAL/LPC1768/tft/xpt2046.h
  10. 4
      Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h
  11. 10
      Marlin/src/HAL/STM32/sdio.cpp
  12. 29
      Marlin/src/HAL/STM32/sdio.h
  13. 4
      Marlin/src/HAL/STM32/tft/xpt2046.h
  14. 2
      Marlin/src/HAL/STM32F1/SPI.h
  15. 14
      Marlin/src/HAL/STM32F1/pinsDebug.h
  16. 4
      Marlin/src/HAL/STM32F1/tft/xpt2046.h
  17. 6
      Marlin/src/HAL/shared/eeprom_api.h
  18. 6
      Marlin/src/core/language.h
  19. 16
      Marlin/src/core/macros.h
  20. 2
      Marlin/src/core/serial_hook.h
  21. 18
      Marlin/src/core/types.h
  22. 6
      Marlin/src/feature/babystep.h
  23. 10
      Marlin/src/feature/backlash.h
  24. 10
      Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h
  25. 22
      Marlin/src/feature/bedlevel/ubl/ubl.h
  26. 2
      Marlin/src/feature/bltouch.h
  27. 8
      Marlin/src/feature/cancel_object.h
  28. 4
      Marlin/src/feature/caselight.h
  29. 6
      Marlin/src/feature/controllerfan.h
  30. 8
      Marlin/src/feature/encoder_i2c.cpp
  31. 8
      Marlin/src/feature/fancheck.h
  32. 16
      Marlin/src/feature/filwidth.h
  33. 4
      Marlin/src/feature/host_actions.h
  34. 52
      Marlin/src/feature/leds/leds.h
  35. 28
      Marlin/src/feature/leds/neopixel.h
  36. 16
      Marlin/src/feature/leds/printer_event_leds.h
  37. 6
      Marlin/src/feature/max7219.h
  38. 10
      Marlin/src/feature/mixing.h
  39. 12
      Marlin/src/feature/mmu/mmu2.h
  40. 2
      Marlin/src/feature/power.h
  41. 22
      Marlin/src/feature/powerloss.h
  42. 6
      Marlin/src/feature/probe_temp_comp.h
  43. 4
      Marlin/src/feature/repeat.h
  44. 54
      Marlin/src/feature/runout.h
  45. 42
      Marlin/src/feature/spindle_laser.h
  46. 8
      Marlin/src/feature/tmc_util.cpp
  47. 157
      Marlin/src/feature/tmc_util.h
  48. 8
      Marlin/src/feature/twibus.h
  49. 12
      Marlin/src/gcode/calibrate/G28.cpp
  50. 8
      Marlin/src/gcode/calibrate/G34.cpp
  51. 30
      Marlin/src/gcode/calibrate/G425.cpp
  52. 2
      Marlin/src/gcode/config/M200-M205.cpp
  53. 68
      Marlin/src/gcode/feature/L6470/M906.cpp
  54. 0
      Marlin/src/gcode/feature/L6470/M916-M918.cpp
  55. 6
      Marlin/src/gcode/feature/pause/M600.cpp
  56. 12
      Marlin/src/gcode/feature/pause/M701_M702.cpp
  57. 4
      Marlin/src/gcode/feature/power_monitor/M430.cpp
  58. 51
      Marlin/src/gcode/feature/trinamic/M569.cpp
  59. 57
      Marlin/src/gcode/feature/trinamic/M906.cpp
  60. 105
      Marlin/src/gcode/feature/trinamic/M911-M914.cpp
  61. 266
      Marlin/src/gcode/feature/trinamic/M919.cpp
  62. 4
      Marlin/src/gcode/gcode.cpp
  63. 22
      Marlin/src/gcode/gcode.h
  64. 1
      Marlin/src/gcode/lcd/M0_M1.cpp
  65. 4
      Marlin/src/gcode/motion/G5.cpp
  66. 118
      Marlin/src/gcode/parser.h
  67. 14
      Marlin/src/gcode/queue.h
  68. 11
      Marlin/src/gcode/temp/M303.cpp
  69. 24
      Marlin/src/inc/Conditionals_LCD.h
  70. 2
      Marlin/src/inc/Conditionals_adv.h
  71. 66
      Marlin/src/inc/Conditionals_post.h
  72. 98
      Marlin/src/inc/SanityCheck.h
  73. 2
      Marlin/src/inc/Version.h
  74. 62
      Marlin/src/lcd/buttons.h
  75. 10
      Marlin/src/lcd/e3v2/creality/dwin.cpp
  76. 1071
      Marlin/src/lcd/e3v2/enhanced/dwin.cpp
  77. 93
      Marlin/src/lcd/e3v2/enhanced/dwin.h
  78. 92
      Marlin/src/lcd/e3v2/enhanced/dwin_defines.h
  79. 2
      Marlin/src/lcd/e3v2/enhanced/dwin_lcd.cpp
  80. 2
      Marlin/src/lcd/e3v2/enhanced/dwin_lcd.h
  81. 55
      Marlin/src/lcd/e3v2/enhanced/dwin_popup.cpp
  82. 62
      Marlin/src/lcd/e3v2/enhanced/dwin_popup.h
  83. 3
      Marlin/src/lcd/e3v2/enhanced/dwinui.cpp
  84. 58
      Marlin/src/lcd/e3v2/enhanced/dwinui.h
  85. 109
      Marlin/src/lcd/e3v2/enhanced/endstop_diag.cpp
  86. 37
      Marlin/src/lcd/e3v2/enhanced/endstop_diag.h
  87. 7
      Marlin/src/lcd/e3v2/enhanced/lockscreen.cpp
  88. 9
      Marlin/src/lcd/e3v2/enhanced/lockscreen.h
  89. 22
      Marlin/src/lcd/e3v2/enhanced/meshviewer.cpp
  90. 22
      Marlin/src/lcd/e3v2/enhanced/meshviewer.h
  91. 76
      Marlin/src/lcd/e3v2/enhanced/printstats.cpp
  92. 37
      Marlin/src/lcd/e3v2/enhanced/printstats.h
  93. 16
      Marlin/src/lcd/e3v2/marlinui/dwin_string.h
  94. 4
      Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp
  95. 4
      Marlin/src/lcd/extui/dgus/DGUSDisplay.h
  96. 8
      Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp
  97. 2
      Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp
  98. 14
      Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h
  99. 2
      Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp
  100. 14
      Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h

8
.gitignore

@ -41,7 +41,6 @@ applet/
*.rej *.rej
*.bak *.bak
*.idea *.idea
*.s
*.i *.i
*.ii *.ii
*.swp *.swp
@ -141,11 +140,8 @@ __vm/
vc-fileutils.settings vc-fileutils.settings
# Visual Studio Code # Visual Studio Code
.vscode .vscode/*
.vscode/.browse.c_cpp.db* !.vscode/extensions.json
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/*.db
#Simulation #Simulation
imgui.ini imgui.ini

8
.vscode/extensions.json

@ -0,0 +1,8 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"marlinfirmware.auto-build",
"platformio.platformio-ide"
]
}

3
Marlin/Configuration_adv.h

@ -2975,6 +2975,9 @@
//#define CHOPPER_TIMING_Z2 CHOPPER_TIMING_Z //#define CHOPPER_TIMING_Z2 CHOPPER_TIMING_Z
//#define CHOPPER_TIMING_Z3 CHOPPER_TIMING_Z //#define CHOPPER_TIMING_Z3 CHOPPER_TIMING_Z
//#define CHOPPER_TIMING_Z4 CHOPPER_TIMING_Z //#define CHOPPER_TIMING_Z4 CHOPPER_TIMING_Z
//#define CHOPPER_TIMING_I CHOPPER_TIMING
//#define CHOPPER_TIMING_J CHOPPER_TIMING
//#define CHOPPER_TIMING_K CHOPPER_TIMING
//#define CHOPPER_TIMING_E CHOPPER_TIMING // For Extruders (override below) //#define CHOPPER_TIMING_E CHOPPER_TIMING // For Extruders (override below)
//#define CHOPPER_TIMING_E1 CHOPPER_TIMING_E //#define CHOPPER_TIMING_E1 CHOPPER_TIMING_E
//#define CHOPPER_TIMING_E2 CHOPPER_TIMING_E //#define CHOPPER_TIMING_E2 CHOPPER_TIMING_E

2
Marlin/src/HAL/AVR/MarlinSerial.h

@ -217,7 +217,7 @@
#endif #endif
enum { HasEmergencyParser = Cfg::EMERGENCYPARSER }; enum { HasEmergencyParser = Cfg::EMERGENCYPARSER };
static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; } static bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; }
FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; } FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; }
FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; } FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; }

2
Marlin/src/HAL/DUE/MarlinSerial.h

@ -118,7 +118,7 @@ public:
static size_t write(const uint8_t c); static size_t write(const uint8_t c);
static void flushTX(); static void flushTX();
static inline bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; } static bool emergency_parser_enabled() { return Cfg::EMERGENCYPARSER; }
FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; } FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; }
FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; } FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; }

2
Marlin/src/HAL/DUE/MarlinSerialUSB.cpp

@ -41,7 +41,7 @@ extern "C" {
int udi_cdc_getc(); int udi_cdc_getc();
bool udi_cdc_is_tx_ready(); bool udi_cdc_is_tx_ready();
int udi_cdc_putc(int value); int udi_cdc_putc(int value);
}; }
// Pending character // Pending character
static int pending_char = -1; static int pending_char = -1;

2
Marlin/src/HAL/DUE/usb/sd_mmc_spi_mem.cpp

@ -10,7 +10,7 @@
#include "../../../sd/cardreader.h" #include "../../../sd/cardreader.h"
extern "C" { extern "C" {
#include "sd_mmc_spi_mem.h" #include "sd_mmc_spi_mem.h"
} }
#define SD_MMC_BLOCK_SIZE 512 #define SD_MMC_BLOCK_SIZE 512

2
Marlin/src/HAL/LPC1768/include/SPI.h

@ -77,7 +77,7 @@ public:
//uint32_t spiRate() const { return spi_speed; } //uint32_t spiRate() const { return spi_speed; }
static inline uint32_t spiRate2Clock(uint32_t spiRate) { static uint32_t spiRate2Clock(uint32_t spiRate) {
uint32_t Marlin_speed[7]; // CPSR is always 2 uint32_t Marlin_speed[7]; // CPSR is always 2
Marlin_speed[0] = 8333333; //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED Marlin_speed[0] = 8333333; //(SCR: 2) desired: 8,000,000 actual: 8,333,333 +4.2% SPI_FULL_SPEED
Marlin_speed[1] = 4166667; //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED Marlin_speed[1] = 4166667; //(SCR: 5) desired: 4,000,000 actual: 4,166,667 +4.2% SPI_HALF_SPEED

4
Marlin/src/HAL/LPC1768/tft/xpt2046.h

@ -65,8 +65,8 @@ private:
static uint16_t getRawData(const XPTCoordinate coordinate); static uint16_t getRawData(const XPTCoordinate coordinate);
static bool isTouched(); static bool isTouched();
static inline void DataTransferBegin() { WRITE(TOUCH_CS_PIN, LOW); }; static void DataTransferBegin() { WRITE(TOUCH_CS_PIN, LOW); };
static inline void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); }; static void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); };
#if ENABLED(TOUCH_BUTTONS_HW_SPI) #if ENABLED(TOUCH_BUTTONS_HW_SPI)
static uint16_t HardwareIO(uint16_t data); static uint16_t HardwareIO(uint16_t data);
#endif #endif

4
Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h

@ -62,8 +62,8 @@ private:
static uint16_t getRawData(const XPTCoordinate coordinate); static uint16_t getRawData(const XPTCoordinate coordinate);
static bool isTouched(); static bool isTouched();
static inline void DataTransferBegin(); static void DataTransferBegin();
static inline void DataTransferEnd(); static void DataTransferEnd();
#if ENABLED(TOUCH_BUTTONS_HW_SPI) #if ENABLED(TOUCH_BUTTONS_HW_SPI)
static uint16_t HardwareIO(uint16_t data); static uint16_t HardwareIO(uint16_t data);
#endif #endif

10
Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp → Marlin/src/HAL/STM32/sdio.cpp

@ -28,6 +28,8 @@
#if ENABLED(SDIO_SUPPORT) #if ENABLED(SDIO_SUPPORT)
#include "sdio.h"
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
@ -49,14 +51,6 @@
#error "SDIO only supported with STM32F103xE, STM32F103xG, STM32F4xx, or STM32F7xx." #error "SDIO only supported with STM32F103xE, STM32F103xG, STM32F4xx, or STM32F7xx."
#endif #endif
// Fixed
#define SDIO_D0_PIN PC8
#define SDIO_D1_PIN PC9
#define SDIO_D2_PIN PC10
#define SDIO_D3_PIN PC11
#define SDIO_CK_PIN PC12
#define SDIO_CMD_PIN PD2
SD_HandleTypeDef hsd; // create SDIO structure SD_HandleTypeDef hsd; // create SDIO structure
// F4 supports one DMA for RX and another for TX, but Marlin will never // F4 supports one DMA for RX and another for TX, but Marlin will never
// do read and write at same time, so we use the same DMA for both. // do read and write at same time, so we use the same DMA for both.

29
Marlin/src/HAL/STM32/sdio.h

@ -0,0 +1,29 @@
/**
* 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
#define SDIO_D0_PIN PC8
#define SDIO_D1_PIN PC9
#define SDIO_D2_PIN PC10
#define SDIO_D3_PIN PC11
#define SDIO_CK_PIN PC12
#define SDIO_CMD_PIN PD2

4
Marlin/src/HAL/STM32/tft/xpt2046.h

@ -69,8 +69,8 @@ private:
static uint16_t getRawData(const XPTCoordinate coordinate); static uint16_t getRawData(const XPTCoordinate coordinate);
static bool isTouched(); static bool isTouched();
static inline void DataTransferBegin() { if (SPIx.Instance) { HAL_SPI_Init(&SPIx); } WRITE(TOUCH_CS_PIN, LOW); }; static void DataTransferBegin() { if (SPIx.Instance) { HAL_SPI_Init(&SPIx); } WRITE(TOUCH_CS_PIN, LOW); };
static inline void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); }; static void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); };
static uint16_t HardwareIO(uint16_t data); static uint16_t HardwareIO(uint16_t data);
static uint16_t SoftwareIO(uint16_t data); static uint16_t SoftwareIO(uint16_t data);
static uint16_t IO(uint16_t data = 0) { return SPIx.Instance ? HardwareIO(data) : SoftwareIO(data); } static uint16_t IO(uint16_t data = 0) { return SPIx.Instance ? HardwareIO(data) : SoftwareIO(data); }

2
Marlin/src/HAL/STM32F1/SPI.h

@ -417,7 +417,7 @@ private:
/** /**
* @brief Wait until TXE (tx empty) flag is set and BSY (busy) flag unset. * @brief Wait until TXE (tx empty) flag is set and BSY (busy) flag unset.
*/ */
static inline void waitSpiTxEnd(spi_dev *spi_d) { static void waitSpiTxEnd(spi_dev *spi_d) {
while (spi_is_tx_empty(spi_d) == 0) { /* nada */ } // wait until TXE=1 while (spi_is_tx_empty(spi_d) == 0) { /* nada */ } // wait until TXE=1
while (spi_is_busy(spi_d) != 0) { /* nada */ } // wait until BSY=0 while (spi_is_busy(spi_d) != 0) { /* nada */ } // wait until BSY=0
} }

14
Marlin/src/HAL/STM32F1/pinsDebug.h

@ -54,11 +54,11 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS];
#define M43_NEVER_TOUCH(Q) (Q >= 9 && Q <= 12) // SERIAL/USB pins PA9(TX) PA10(RX) #define M43_NEVER_TOUCH(Q) (Q >= 9 && Q <= 12) // SERIAL/USB pins PA9(TX) PA10(RX)
#endif #endif
static inline int8_t get_pin_mode(pin_t pin) { static int8_t get_pin_mode(pin_t pin) {
return VALID_PIN(pin) ? _GET_MODE(pin) : -1; return VALID_PIN(pin) ? _GET_MODE(pin) : -1;
} }
static inline pin_t DIGITAL_PIN_TO_ANALOG_PIN(pin_t pin) { static pin_t DIGITAL_PIN_TO_ANALOG_PIN(pin_t pin) {
if (!VALID_PIN(pin)) return -1; if (!VALID_PIN(pin)) return -1;
int8_t adc_channel = int8_t(PIN_MAP[pin].adc_channel); int8_t adc_channel = int8_t(PIN_MAP[pin].adc_channel);
#ifdef NUM_ANALOG_INPUTS #ifdef NUM_ANALOG_INPUTS
@ -67,7 +67,7 @@ static inline pin_t DIGITAL_PIN_TO_ANALOG_PIN(pin_t pin) {
return pin_t(adc_channel); return pin_t(adc_channel);
} }
static inline bool IS_ANALOG(pin_t pin) { static bool IS_ANALOG(pin_t pin) {
if (!VALID_PIN(pin)) return false; if (!VALID_PIN(pin)) return false;
if (PIN_MAP[pin].adc_channel != ADCx) { if (PIN_MAP[pin].adc_channel != ADCx) {
#ifdef NUM_ANALOG_INPUTS #ifdef NUM_ANALOG_INPUTS
@ -78,11 +78,11 @@ static inline bool IS_ANALOG(pin_t pin) {
return false; return false;
} }
static inline bool GET_PINMODE(const pin_t pin) { static bool GET_PINMODE(const pin_t pin) {
return VALID_PIN(pin) && !IS_INPUT(pin); return VALID_PIN(pin) && !IS_INPUT(pin);
} }
static inline bool GET_ARRAY_IS_DIGITAL(const int16_t array_pin) { static bool GET_ARRAY_IS_DIGITAL(const int16_t array_pin) {
const pin_t pin = GET_ARRAY_PIN(array_pin); const pin_t pin = GET_ARRAY_PIN(array_pin);
return (!IS_ANALOG(pin) return (!IS_ANALOG(pin)
#ifdef NUM_ANALOG_INPUTS #ifdef NUM_ANALOG_INPUTS
@ -93,7 +93,7 @@ static inline bool GET_ARRAY_IS_DIGITAL(const int16_t array_pin) {
#include "../../inc/MarlinConfig.h" // Allow pins/pins.h to set density #include "../../inc/MarlinConfig.h" // Allow pins/pins.h to set density
static inline void pwm_details(const pin_t pin) { static void pwm_details(const pin_t pin) {
if (PWM_PIN(pin)) { if (PWM_PIN(pin)) {
timer_dev * const tdev = PIN_MAP[pin].timer_device; timer_dev * const tdev = PIN_MAP[pin].timer_device;
const uint8_t channel = PIN_MAP[pin].timer_channel; const uint8_t channel = PIN_MAP[pin].timer_channel;
@ -113,7 +113,7 @@ static inline void pwm_details(const pin_t pin) {
} }
} }
static inline void print_port(pin_t pin) { static void print_port(pin_t pin) {
const char port = 'A' + char(pin >> 4); // pin div 16 const char port = 'A' + char(pin >> 4); // pin div 16
const int16_t gbit = PIN_MAP[pin].gpio_bit; const int16_t gbit = PIN_MAP[pin].gpio_bit;
char buffer[8]; char buffer[8];

4
Marlin/src/HAL/STM32F1/tft/xpt2046.h

@ -65,8 +65,8 @@ private:
static uint16_t getRawData(const XPTCoordinate coordinate); static uint16_t getRawData(const XPTCoordinate coordinate);
static bool isTouched(); static bool isTouched();
static inline void DataTransferBegin() { WRITE(TOUCH_CS_PIN, LOW); }; static void DataTransferBegin() { WRITE(TOUCH_CS_PIN, LOW); };
static inline void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); }; static void DataTransferEnd() { WRITE(TOUCH_CS_PIN, HIGH); };
#if ENABLED(TOUCH_BUTTONS_HW_SPI) #if ENABLED(TOUCH_BUTTONS_HW_SPI)
static uint16_t HardwareIO(uint16_t data); static uint16_t HardwareIO(uint16_t data);
#endif #endif

6
Marlin/src/HAL/shared/eeprom_api.h

@ -49,7 +49,7 @@ public:
// Write one or more bytes of data // Write one or more bytes of data
// Return 'true' on write error // Return 'true' on write error
static inline bool write_data(const int pos, const uint8_t *value, const size_t size=sizeof(uint8_t)) { static bool write_data(const int pos, const uint8_t *value, const size_t size=sizeof(uint8_t)) {
int data_pos = pos; int data_pos = pos;
uint16_t crc = 0; uint16_t crc = 0;
return write_data(data_pos, value, size, &crc); return write_data(data_pos, value, size, &crc);
@ -57,11 +57,11 @@ public:
// Write a single byte of data // Write a single byte of data
// Return 'true' on write error // Return 'true' on write error
static inline bool write_data(const int pos, const uint8_t value) { return write_data(pos, &value); } static bool write_data(const int pos, const uint8_t value) { return write_data(pos, &value); }
// Read one or more bytes of data // Read one or more bytes of data
// Return 'true' on read error // Return 'true' on read error
static inline bool read_data(const int pos, uint8_t *value, const size_t size=1) { static bool read_data(const int pos, uint8_t *value, const size_t size=1) {
int data_pos = pos; int data_pos = pos;
uint16_t crc = 0; uint16_t crc = 0;
return read_data(data_pos, value, size, &crc); return read_data(data_pos, value, size, &crc);

6
Marlin/src/core/language.h

@ -368,7 +368,7 @@
#define LCD_STR_E STR_E #define LCD_STR_E STR_E
// Extra Axis and Endstop Names // Extra Axis and Endstop Names
#if LINEAR_AXES >= 4 #if HAS_I_AXIS
#if AXIS4_NAME == 'A' #if AXIS4_NAME == 'A'
#define AXIS4_STR "A" #define AXIS4_STR "A"
#define STR_I_MIN "a_min" #define STR_I_MIN "a_min"
@ -402,7 +402,7 @@
#define AXIS4_STR "" #define AXIS4_STR ""
#endif #endif
#if LINEAR_AXES >= 5 #if HAS_J_AXIS
#if AXIS5_NAME == 'A' #if AXIS5_NAME == 'A'
#define AXIS5_STR "A" #define AXIS5_STR "A"
#define STR_J_MIN "a_min" #define STR_J_MIN "a_min"
@ -436,7 +436,7 @@
#define AXIS5_STR "" #define AXIS5_STR ""
#endif #endif
#if LINEAR_AXES >= 6 #if HAS_K_AXIS
#if AXIS6_NAME == 'A' #if AXIS6_NAME == 'A'
#define AXIS6_STR "A" #define AXIS6_STR "A"
#define STR_K_MIN "a_min" #define STR_K_MIN "a_min"

16
Marlin/src/core/macros.h

@ -131,13 +131,13 @@
#ifdef __cplusplus #ifdef __cplusplus
// C++11 solution that is standards compliant. // C++11 solution that is standards compliant.
template <class V, class N> static inline constexpr void NOLESS(V& v, const N n) { template <class V, class N> static constexpr void NOLESS(V& v, const N n) {
if (n > v) v = n; if (n > v) v = n;
} }
template <class V, class N> static inline constexpr void NOMORE(V& v, const N n) { template <class V, class N> static constexpr void NOMORE(V& v, const N n) {
if (n < v) v = n; if (n < v) v = n;
} }
template <class V, class N1, class N2> static inline constexpr void LIMIT(V& v, const N1 n1, const N2 n2) { template <class V, class N1, class N2> static constexpr void LIMIT(V& v, const N1 n1, const N2 n2) {
if (n1 > v) v = n1; if (n1 > v) v = n1;
else if (n2 < v) v = n2; else if (n2 < v) v = n2;
} }
@ -366,7 +366,7 @@
#undef ABS #undef ABS
#ifdef __cplusplus #ifdef __cplusplus
template <class T> static inline constexpr const T ABS(const T v) { return v >= 0 ? v : -v; } template <class T> static constexpr const T ABS(const T v) { return v >= 0 ? v : -v; }
#else #else
#define ABS(a) ({__typeof__(a) _a = (a); _a >= 0 ? _a : -_a;}) #define ABS(a) ({__typeof__(a) _a = (a); _a >= 0 ? _a : -_a;})
#endif #endif
@ -409,14 +409,14 @@
extern "C++" { extern "C++" {
// C++11 solution that is standards compliant. Return type is deduced automatically // C++11 solution that is standards compliant. Return type is deduced automatically
template <class L, class R> static inline constexpr auto _MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) { template <class L, class R> static constexpr auto _MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) {
return lhs < rhs ? lhs : rhs; return lhs < rhs ? lhs : rhs;
} }
template <class L, class R> static inline constexpr auto _MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) { template <class L, class R> static constexpr auto _MAX(const L lhs, const R rhs) -> decltype(lhs + rhs) {
return lhs > rhs ? lhs : rhs; return lhs > rhs ? lhs : rhs;
} }
template<class T, class ... Ts> static inline constexpr const T _MIN(T V, Ts... Vs) { return _MIN(V, _MIN(Vs...)); } template<class T, class ... Ts> static constexpr const T _MIN(T V, Ts... Vs) { return _MIN(V, _MIN(Vs...)); }
template<class T, class ... Ts> static inline constexpr const T _MAX(T V, Ts... Vs) { return _MAX(V, _MAX(Vs...)); } template<class T, class ... Ts> static constexpr const T _MAX(T V, Ts... Vs) { return _MAX(V, _MAX(Vs...)); }
} }

2
Marlin/src/core/serial_hook.h

@ -37,7 +37,7 @@ public:
inline constexpr bool enabled(const SerialMask PortMask) const { return mask & PortMask.mask; } inline constexpr bool enabled(const SerialMask PortMask) const { return mask & PortMask.mask; }
inline constexpr SerialMask combine(const SerialMask other) const { return SerialMask(mask | other.mask); } inline constexpr SerialMask combine(const SerialMask other) const { return SerialMask(mask | other.mask); }
inline constexpr SerialMask operator<< (const int offset) const { return SerialMask(mask << offset); } inline constexpr SerialMask operator<< (const int offset) const { return SerialMask(mask << offset); }
static inline SerialMask from(const serial_index_t index) { static SerialMask from(const serial_index_t index) {
if (index.valid()) return SerialMask(_BV(index.index)); if (index.valid()) return SerialMask(_BV(index.index));
return SerialMask(0); // A invalid index mean no output return SerialMask(0); // A invalid index mean no output
} }

18
Marlin/src/core/types.h

@ -64,6 +64,8 @@ struct IF<true, L, R> { typedef L type; };
#define GANG_ITEM_E(N) #define GANG_ITEM_E(N)
#endif #endif
#define AXIS_COLLISION(L) (AXIS4_NAME == L || AXIS5_NAME == L || AXIS6_NAME == L)
// //
// Enumerated axis indices // Enumerated axis indices
// //
@ -96,10 +98,10 @@ enum AxisEnum : uint8_t {
// A, B, and C are for DELTA, SCARA, etc. // A, B, and C are for DELTA, SCARA, etc.
, A_AXIS = X_AXIS , A_AXIS = X_AXIS
#if LINEAR_AXES >= 2 #if HAS_Y_AXIS
, B_AXIS = Y_AXIS , B_AXIS = Y_AXIS
#endif #endif
#if LINEAR_AXES >= 3 #if HAS_Z_AXIS
, C_AXIS = Z_AXIS , C_AXIS = Z_AXIS
#endif #endif
@ -406,13 +408,13 @@ struct XYZval {
FI void set(const T (&arr)[DISTINCT_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5]); } 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
#endif #endif
#if LINEAR_AXES >= 4 #if HAS_I_AXIS
FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; }
#endif #endif
#if LINEAR_AXES >= 5 #if HAS_J_AXIS
FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; } FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; }
#endif #endif
#if LINEAR_AXES >= 6 #if HAS_K_AXIS
FI void set(const T px, const T py, const T pz, const T pi, const T pj) { x = px; y = py; z = pz; i = pi; j = pj; } 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 #endif
@ -547,13 +549,13 @@ struct XYZEval {
FI void set(const XYZval<T> pxyz, const T pe) { set(pxyz); 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); } 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 #endif
#if LINEAR_AXES >= 4 #if HAS_I_AXIS
FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; } FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; }
#endif #endif
#if LINEAR_AXES >= 5 #if HAS_J_AXIS
FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; } FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; }
#endif #endif
#if LINEAR_AXES >= 6 #if HAS_K_AXIS
FI void set(const T px, const T py, const T pz, const T pi, const T pj) { x = px; y = py; z = pz; i = pi; j = pj; } 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 #endif

6
Marlin/src/feature/babystep.h

@ -54,7 +54,7 @@ public:
#if ENABLED(BABYSTEP_DISPLAY_TOTAL) #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
static int16_t axis_total[BS_TOTAL_IND(Z_AXIS) + 1]; // Total babysteps since G28 static int16_t axis_total[BS_TOTAL_IND(Z_AXIS) + 1]; // Total babysteps since G28
static inline void reset_total(const AxisEnum axis) { static void reset_total(const AxisEnum axis) {
if (TERN1(BABYSTEP_XY, axis == Z_AXIS)) if (TERN1(BABYSTEP_XY, axis == Z_AXIS))
axis_total[BS_TOTAL_IND(axis)] = 0; axis_total[BS_TOTAL_IND(axis)] = 0;
} }
@ -63,7 +63,7 @@ public:
static void add_steps(const AxisEnum axis, const int16_t distance); static void add_steps(const AxisEnum axis, const int16_t distance);
static void add_mm(const AxisEnum axis, const_float_t mm); static void add_mm(const AxisEnum axis, const_float_t mm);
static inline bool has_steps() { static bool has_steps() {
return steps[BS_AXIS_IND(X_AXIS)] || steps[BS_AXIS_IND(Y_AXIS)] || steps[BS_AXIS_IND(Z_AXIS)]; return steps[BS_AXIS_IND(X_AXIS)] || steps[BS_AXIS_IND(Y_AXIS)] || steps[BS_AXIS_IND(Z_AXIS)];
} }
@ -71,7 +71,7 @@ public:
// Called by the Temperature or Stepper ISR to // Called by the Temperature or Stepper ISR to
// apply accumulated babysteps to the axes. // apply accumulated babysteps to the axes.
// //
static inline void task() { static void task() {
LOOP_LE_N(i, BS_AXIS_IND(Z_AXIS)) step_axis(BS_AXIS(i)); LOOP_LE_N(i, BS_AXIS_IND(Z_AXIS)) step_axis(BS_AXIS(i));
} }

10
Marlin/src/feature/backlash.h

@ -35,8 +35,8 @@ public:
static float smoothing_mm; static float smoothing_mm;
#endif #endif
static inline void set_correction(const_float_t v) { correction = _MAX(0, _MIN(1.0, v)) * all_on; } static void set_correction(const_float_t v) { correction = _MAX(0, _MIN(1.0, v)) * all_on; }
static inline float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; } static float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; }
#else #else
static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF; static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF;
static const xyz_float_t distance_mm; static const xyz_float_t distance_mm;
@ -53,7 +53,7 @@ public:
static void measure_with_probe(); static void measure_with_probe();
#endif #endif
static inline float get_measurement(const AxisEnum a) { static float get_measurement(const AxisEnum a) {
UNUSED(a); UNUSED(a);
// Return the measurement averaged over all readings // Return the measurement averaged over all readings
return TERN(MEASURE_BACKLASH_WHEN_PROBING return TERN(MEASURE_BACKLASH_WHEN_PROBING
@ -62,12 +62,12 @@ public:
); );
} }
static inline bool has_measurement(const AxisEnum a) { static bool has_measurement(const AxisEnum a) {
UNUSED(a); UNUSED(a);
return TERN0(MEASURE_BACKLASH_WHEN_PROBING, measured_count[a] > 0); return TERN0(MEASURE_BACKLASH_WHEN_PROBING, measured_count[a] > 0);
} }
static inline bool has_any_measurement() { static bool has_any_measurement() {
return has_measurement(X_AXIS) || has_measurement(Y_AXIS) || has_measurement(Z_AXIS); return has_measurement(X_AXIS) || has_measurement(Y_AXIS) || has_measurement(Z_AXIS);
} }

10
Marlin/src/feature/bedlevel/mbl/mesh_bed_leveling.h

@ -58,7 +58,7 @@ public:
static void set_z(const int8_t px, const int8_t py, const_float_t z) { z_values[px][py] = z; } static void set_z(const int8_t px, const int8_t py, const_float_t z) { z_values[px][py] = z; }
static inline void zigzag(const int8_t index, int8_t &px, int8_t &py) { static void zigzag(const int8_t index, int8_t &px, int8_t &py) {
px = index % (GRID_MAX_POINTS_X); px = index % (GRID_MAX_POINTS_X);
py = index / (GRID_MAX_POINTS_X); py = index / (GRID_MAX_POINTS_X);
if (py & 1) px = (GRID_MAX_POINTS_X) - 1 - px; // Zig zag if (py & 1) px = (GRID_MAX_POINTS_X) - 1 - px; // Zig zag
@ -78,10 +78,10 @@ public:
int8_t cy = (y - (MESH_MIN_Y)) * RECIPROCAL(MESH_Y_DIST); int8_t cy = (y - (MESH_MIN_Y)) * RECIPROCAL(MESH_Y_DIST);
return constrain(cy, 0, GRID_MAX_CELLS_Y - 1); return constrain(cy, 0, GRID_MAX_CELLS_Y - 1);
} }
static inline xy_int8_t cell_indexes(const_float_t x, const_float_t y) { static xy_int8_t cell_indexes(const_float_t x, const_float_t y) {
return { cell_index_x(x), cell_index_y(y) }; return { cell_index_x(x), cell_index_y(y) };
} }
static inline xy_int8_t cell_indexes(const xy_pos_t &xy) { return cell_indexes(xy.x, xy.y); } static xy_int8_t cell_indexes(const xy_pos_t &xy) { return cell_indexes(xy.x, xy.y); }
static int8_t probe_index_x(const_float_t x) { static int8_t probe_index_x(const_float_t x) {
int8_t px = (x - (MESH_MIN_X) + 0.5f * (MESH_X_DIST)) * RECIPROCAL(MESH_X_DIST); int8_t px = (x - (MESH_MIN_X) + 0.5f * (MESH_X_DIST)) * RECIPROCAL(MESH_X_DIST);
@ -91,10 +91,10 @@ public:
int8_t py = (y - (MESH_MIN_Y) + 0.5f * (MESH_Y_DIST)) * RECIPROCAL(MESH_Y_DIST); int8_t py = (y - (MESH_MIN_Y) + 0.5f * (MESH_Y_DIST)) * RECIPROCAL(MESH_Y_DIST);
return WITHIN(py, 0, (GRID_MAX_POINTS_Y) - 1) ? py : -1; return WITHIN(py, 0, (GRID_MAX_POINTS_Y) - 1) ? py : -1;
} }
static inline xy_int8_t probe_indexes(const_float_t x, const_float_t y) { static xy_int8_t probe_indexes(const_float_t x, const_float_t y) {
return { probe_index_x(x), probe_index_y(y) }; return { probe_index_x(x), probe_index_y(y) };
} }
static inline xy_int8_t probe_indexes(const xy_pos_t &xy) { return probe_indexes(xy.x, xy.y); } static xy_int8_t probe_indexes(const xy_pos_t &xy) { return probe_indexes(xy.x, xy.y); }
static float calc_z0(const_float_t a0, const_float_t a1, const_float_t z1, const_float_t a2, const_float_t z2) { static float calc_z0(const_float_t a0, const_float_t a1, const_float_t z1, const_float_t a2, const_float_t z2) {
const float delta_z = (z2 - z1) / (a2 - a1), const float delta_z = (z2 - z1) / (a2 - a1),

22
Marlin/src/feature/bedlevel/ubl/ubl.h

@ -80,7 +80,7 @@ private:
static void tilt_mesh_based_on_3pts(const_float_t z1, const_float_t z2, const_float_t z3); static void tilt_mesh_based_on_3pts(const_float_t z1, const_float_t z2, const_float_t z3);
static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map); static void tilt_mesh_based_on_probed_grid(const bool do_ubl_mesh_map);
static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir); static bool smart_fill_one(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir);
static inline bool smart_fill_one(const xy_uint8_t &pos, const xy_uint8_t &dir) { static bool smart_fill_one(const xy_uint8_t &pos, const xy_uint8_t &dir) {
return smart_fill_one(pos.x, pos.y, dir.x, dir.y); return smart_fill_one(pos.x, pos.y, dir.x, dir.y);
} }
static void smart_fill_mesh(); static void smart_fill_mesh();
@ -124,7 +124,7 @@ public:
static bool lcd_map_control; static bool lcd_map_control;
static void steppers_were_disabled(); static void steppers_were_disabled();
#else #else
static inline void steppers_were_disabled() {} static void steppers_were_disabled() {}
#endif #endif
static volatile int16_t encoder_diff; // Volatile because buttons may change it at interrupt time static volatile int16_t encoder_diff; // Volatile because buttons may change it at interrupt time
@ -157,10 +157,10 @@ public:
return constrain(cell_index_y_raw(y), 0, GRID_MAX_CELLS_Y - 1); return constrain(cell_index_y_raw(y), 0, GRID_MAX_CELLS_Y - 1);
} }
static inline xy_int8_t cell_indexes(const_float_t x, const_float_t y) { static xy_int8_t cell_indexes(const_float_t x, const_float_t y) {
return { cell_index_x(x), cell_index_y(y) }; return { cell_index_x(x), cell_index_y(y) };
} }
static inline xy_int8_t cell_indexes(const xy_pos_t &xy) { return cell_indexes(xy.x, xy.y); } static xy_int8_t cell_indexes(const xy_pos_t &xy) { return cell_indexes(xy.x, xy.y); }
static int8_t closest_x_index(const_float_t x) { static int8_t closest_x_index(const_float_t x) {
const int8_t px = (x - (MESH_MIN_X) + (MESH_X_DIST) * 0.5) * RECIPROCAL(MESH_X_DIST); const int8_t px = (x - (MESH_MIN_X) + (MESH_X_DIST) * 0.5) * RECIPROCAL(MESH_X_DIST);
@ -170,7 +170,7 @@ public:
const int8_t py = (y - (MESH_MIN_Y) + (MESH_Y_DIST) * 0.5) * RECIPROCAL(MESH_Y_DIST); const int8_t py = (y - (MESH_MIN_Y) + (MESH_Y_DIST) * 0.5) * RECIPROCAL(MESH_Y_DIST);
return WITHIN(py, 0, (GRID_MAX_POINTS_Y) - 1) ? py : -1; return WITHIN(py, 0, (GRID_MAX_POINTS_Y) - 1) ? py : -1;
} }
static inline xy_int8_t closest_indexes(const xy_pos_t &xy) { static xy_int8_t closest_indexes(const xy_pos_t &xy) {
return { closest_x_index(xy.x), closest_y_index(xy.y) }; return { closest_x_index(xy.x), closest_y_index(xy.y) };
} }
@ -203,7 +203,7 @@ public:
* z_correction_for_x_on_horizontal_mesh_line is an optimization for * z_correction_for_x_on_horizontal_mesh_line is an optimization for
* the case where the printer is making a vertical line that only crosses horizontal mesh lines. * the case where the printer is making a vertical line that only crosses horizontal mesh lines.
*/ */
static inline float z_correction_for_x_on_horizontal_mesh_line(const_float_t rx0, const int x1_i, const int yi) { static float z_correction_for_x_on_horizontal_mesh_line(const_float_t rx0, const int x1_i, const int yi) {
if (!WITHIN(x1_i, 0, (GRID_MAX_POINTS_X) - 1) || !WITHIN(yi, 0, (GRID_MAX_POINTS_Y) - 1)) { if (!WITHIN(x1_i, 0, (GRID_MAX_POINTS_X) - 1) || !WITHIN(yi, 0, (GRID_MAX_POINTS_Y) - 1)) {
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
@ -226,7 +226,7 @@ public:
// //
// See comments above for z_correction_for_x_on_horizontal_mesh_line // See comments above for z_correction_for_x_on_horizontal_mesh_line
// //
static inline float z_correction_for_y_on_vertical_mesh_line(const_float_t ry0, const int xi, const int y1_i) { static float z_correction_for_y_on_vertical_mesh_line(const_float_t ry0, const int xi, const int y1_i) {
if (!WITHIN(xi, 0, (GRID_MAX_POINTS_X) - 1) || !WITHIN(y1_i, 0, (GRID_MAX_POINTS_Y) - 1)) { if (!WITHIN(xi, 0, (GRID_MAX_POINTS_X) - 1) || !WITHIN(y1_i, 0, (GRID_MAX_POINTS_Y) - 1)) {
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
@ -285,12 +285,12 @@ public:
return z0; return z0;
} }
static inline float get_z_correction(const xy_pos_t &pos) { return get_z_correction(pos.x, pos.y); } static float get_z_correction(const xy_pos_t &pos) { return get_z_correction(pos.x, pos.y); }
static inline float mesh_index_to_xpos(const uint8_t i) { static float mesh_index_to_xpos(const uint8_t i) {
return i < (GRID_MAX_POINTS_X) ? pgm_read_float(&_mesh_index_to_xpos[i]) : MESH_MIN_X + i * (MESH_X_DIST); return i < (GRID_MAX_POINTS_X) ? pgm_read_float(&_mesh_index_to_xpos[i]) : MESH_MIN_X + i * (MESH_X_DIST);
} }
static inline float mesh_index_to_ypos(const uint8_t i) { static float mesh_index_to_ypos(const uint8_t i) {
return i < (GRID_MAX_POINTS_Y) ? pgm_read_float(&_mesh_index_to_ypos[i]) : MESH_MIN_Y + i * (MESH_Y_DIST); return i < (GRID_MAX_POINTS_Y) ? pgm_read_float(&_mesh_index_to_ypos[i]) : MESH_MIN_Y + i * (MESH_Y_DIST);
} }
@ -300,7 +300,7 @@ public:
static void line_to_destination_cartesian(const_feedRate_t scaled_fr_mm_s, const uint8_t e); static void line_to_destination_cartesian(const_feedRate_t scaled_fr_mm_s, const uint8_t e);
#endif #endif
static inline bool mesh_is_valid() { static bool mesh_is_valid() {
GRID_LOOP(x, y) if (isnan(z_values[x][y])) return false; GRID_LOOP(x, y) if (isnan(z_values[x][y])) return false;
return true; return true;
} }

2
Marlin/src/feature/bltouch.h

@ -76,7 +76,7 @@ public:
static constexpr bool high_speed_mode = false; static constexpr bool high_speed_mode = false;
#endif #endif
static inline float z_extra_clearance() { return high_speed_mode ? 7 : 0; } static float z_extra_clearance() { return high_speed_mode ? 7 : 0; }
// DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing // DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing
static bool deploy() { return deploy_proc(); } static bool deploy() { return deploy_proc(); }

8
Marlin/src/feature/cancel_object.h

@ -32,10 +32,10 @@ public:
static void cancel_object(const int8_t obj); static void cancel_object(const int8_t obj);
static void uncancel_object(const int8_t obj); static void uncancel_object(const int8_t obj);
static void report(); static void report();
static inline bool is_canceled(const int8_t obj) { return TEST(canceled, obj); } static bool is_canceled(const int8_t obj) { return TEST(canceled, obj); }
static inline void clear_active_object() { set_active_object(-1); } static void clear_active_object() { set_active_object(-1); }
static inline void cancel_active_object() { cancel_object(active_object); } static void cancel_active_object() { cancel_object(active_object); }
static inline void reset() { canceled = 0x0000; object_count = 0; clear_active_object(); } static void reset() { canceled = 0x0000; object_count = 0; clear_active_object(); }
}; };
extern CancelObject cancelable; extern CancelObject cancelable;

4
Marlin/src/feature/caselight.h

@ -49,8 +49,8 @@ public:
} }
static void update(const bool sflag); static void update(const bool sflag);
static inline void update_brightness() { update(false); } static void update_brightness() { update(false); }
static inline void update_enabled() { update(true); } static void update_enabled() { update(true); }
#if ENABLED(CASE_LIGHT_IS_COLOR_LED) #if ENABLED(CASE_LIGHT_IS_COLOR_LED)
private: private:

6
Marlin/src/feature/controllerfan.h

@ -60,9 +60,9 @@ class ControllerFan {
#else #else
static const controllerFan_settings_t &settings; static const controllerFan_settings_t &settings;
#endif #endif
static inline bool state() { return speed > 0; } static bool state() { return speed > 0; }
static inline void init() { reset(); } static void init() { reset(); }
static inline void reset() { TERN_(CONTROLLER_FAN_EDITABLE, settings = controllerFan_defaults); } static void reset() { TERN_(CONTROLLER_FAN_EDITABLE, settings = controllerFan_defaults); }
static void setup(); static void setup();
static void update(); static void update();
}; };

8
Marlin/src/feature/encoder_i2c.cpp

@ -756,7 +756,7 @@ int8_t I2CPositionEncodersMgr::parse() {
if (!parser.has_value()) { if (!parser.has_value()) {
SERIAL_ECHOLNPGM("?A seen, but no address specified! [30-200]"); SERIAL_ECHOLNPGM("?A seen, but no address specified! [30-200]");
return I2CPE_PARSE_ERR; return I2CPE_PARSE_ERR;
}; }
I2CPE_addr = parser.value_byte(); I2CPE_addr = parser.value_byte();
if (!WITHIN(I2CPE_addr, 30, 200)) { // reserve the first 30 and last 55 if (!WITHIN(I2CPE_addr, 30, 200)) { // reserve the first 30 and last 55
@ -775,7 +775,7 @@ int8_t I2CPositionEncodersMgr::parse() {
if (!parser.has_value()) { if (!parser.has_value()) {
SERIAL_ECHOLNPGM("?I seen, but no index specified! [0-", I2CPE_ENCODER_CNT - 1, "]"); SERIAL_ECHOLNPGM("?I seen, but no index specified! [0-", I2CPE_ENCODER_CNT - 1, "]");
return I2CPE_PARSE_ERR; return I2CPE_PARSE_ERR;
}; }
I2CPE_idx = parser.value_byte(); I2CPE_idx = parser.value_byte();
if (I2CPE_idx >= I2CPE_ENCODER_CNT) { if (I2CPE_idx >= I2CPE_ENCODER_CNT) {
@ -791,7 +791,7 @@ int8_t I2CPositionEncodersMgr::parse() {
I2CPE_anyaxis = parser.seen_axis(); I2CPE_anyaxis = parser.seen_axis();
return I2CPE_PARSE_OK; return I2CPE_PARSE_OK;
}; }
/** /**
* M860: Report the position(s) of position encoder module(s). * M860: Report the position(s) of position encoder module(s).
@ -934,7 +934,7 @@ void I2CPositionEncodersMgr::M864() {
if (!parser.has_value()) { if (!parser.has_value()) {
SERIAL_ECHOLNPGM("?S seen, but no address specified! [30-200]"); SERIAL_ECHOLNPGM("?S seen, but no address specified! [30-200]");
return; return;
}; }
newAddress = parser.value_byte(); newAddress = parser.value_byte();
if (!WITHIN(newAddress, 30, 200)) { if (!WITHIN(newAddress, 30, 200)) {

8
Marlin/src/feature/fancheck.h

@ -56,7 +56,7 @@ class FanCheck {
static uint8_t rps[TACHO_COUNT]; static uint8_t rps[TACHO_COUNT];
static TachoError error; static TachoError error;
static inline void report_speed_error(uint8_t fan); static void report_speed_error(uint8_t fan);
public: public:
@ -67,11 +67,11 @@ class FanCheck {
static void compute_speed(uint16_t elapsedTime); static void compute_speed(uint16_t elapsedTime);
static void print_fan_states(); static void print_fan_states();
#if HAS_PWMFANCHECK #if HAS_PWMFANCHECK
static inline void toggle_measuring() { measuring = !measuring; } static void toggle_measuring() { measuring = !measuring; }
static inline bool is_measuring() { return measuring; } static bool is_measuring() { return measuring; }
#endif #endif
static inline void check_deferred_error() { static void check_deferred_error() {
if (error == TachoError::DETECTED) { if (error == TachoError::DETECTED) {
error = TachoError::REPORTED; error = TachoError::REPORTED;
TERN(PARK_HEAD_ON_PAUSE, queue.inject(F("M125")), kill(GET_TEXT_F(MSG_FAN_SPEED_FAULT))); TERN(PARK_HEAD_ON_PAUSE, queue.inject(F("M125")), kill(GET_TEXT_F(MSG_FAN_SPEED_FAULT)));

16
Marlin/src/feature/filwidth.h

@ -41,9 +41,9 @@ public:
FilamentWidthSensor() { init(); } FilamentWidthSensor() { init(); }
static void init(); static void init();
static inline void enable(const bool ena) { enabled = ena; } static void enable(const bool ena) { enabled = ena; }
static inline void set_delay_cm(const uint8_t cm) { static void set_delay_cm(const uint8_t cm) {
meas_delay_cm = _MIN(cm, MAX_MEASUREMENT_DELAY); meas_delay_cm = _MIN(cm, MAX_MEASUREMENT_DELAY);
} }
@ -67,18 +67,18 @@ public:
} }
// Convert raw measurement to mm // Convert raw measurement to mm
static inline float raw_to_mm(const uint16_t v) { return v * 5.0f * RECIPROCAL(float(MAX_RAW_THERMISTOR_VALUE)); } static float raw_to_mm(const uint16_t v) { return v * 5.0f * RECIPROCAL(float(MAX_RAW_THERMISTOR_VALUE)); }
static inline float raw_to_mm() { return raw_to_mm(raw); } static float raw_to_mm() { return raw_to_mm(raw); }
// A scaled reading is ready // A scaled reading is ready
// Divide to get to 0-16384 range since we used 1/128 IIR filter approach // Divide to get to 0-16384 range since we used 1/128 IIR filter approach
static inline void reading_ready() { raw = accum >> 10; } static void reading_ready() { raw = accum >> 10; }
// Update mm from the raw measurement // Update mm from the raw measurement
static inline void update_measured_mm() { measured_mm = raw_to_mm(); } static void update_measured_mm() { measured_mm = raw_to_mm(); }
// Update ring buffer used to delay filament measurements // Update ring buffer used to delay filament measurements
static inline void advance_e(const_float_t e_move) { static void advance_e(const_float_t e_move) {
// Increment counters with the E distance // Increment counters with the E distance
e_count += e_move; e_count += e_move;
@ -106,7 +106,7 @@ public:
} }
// Dynamically set the volumetric multiplier based on the delayed width measurement. // Dynamically set the volumetric multiplier based on the delayed width measurement.
static inline void update_volumetric() { static void update_volumetric() {
if (enabled) { if (enabled) {
int8_t read_index = index_r - meas_delay_cm; int8_t read_index = index_r - meas_delay_cm;
if (read_index < 0) read_index += MMD_CM; // Loop around buffer if needed if (read_index < 0) read_index += MMD_CM; // Loop around buffer if needed

4
Marlin/src/feature/host_actions.h

@ -97,7 +97,7 @@ class HostUI {
static void handle_response(const uint8_t response); static void handle_response(const uint8_t response);
static void notify_P(PGM_P const message); static void notify_P(PGM_P const message);
static inline void notify(FSTR_P const fmsg) { notify_P(FTOP(fmsg)); } static void notify(FSTR_P const fmsg) { notify_P(FTOP(fmsg)); }
static void notify(const char * const message); static void notify(const char * const message);
static void prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char='\0'); static void prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char='\0');
@ -105,7 +105,7 @@ class HostUI {
static void prompt_end(); static void prompt_end();
static void prompt_do(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr); static void prompt_do(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr);
static void prompt_do(const PromptReason reason, FSTR_P const pstr, const char extra_char, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr); static void prompt_do(const PromptReason reason, FSTR_P const pstr, const char extra_char, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr);
static inline void prompt_open(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr) { static void prompt_open(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr) {
if (host_prompt_reason == PROMPT_NOT_DEFINED) prompt_do(reason, pstr, btn1, btn2); if (host_prompt_reason == PROMPT_NOT_DEFINED) prompt_do(reason, pstr, btn1, btn2);
} }

52
Marlin/src/feature/leds/leds.h

@ -118,7 +118,7 @@ public:
OPTARG(NEOPIXEL_IS_SEQUENTIAL, bool isSequence=false) OPTARG(NEOPIXEL_IS_SEQUENTIAL, bool isSequence=false)
); );
static inline void set_color(uint8_t r, uint8_t g, uint8_t b static void set_color(uint8_t r, uint8_t g, uint8_t b
OPTARG(HAS_WHITE_LED, uint8_t w=0) OPTARG(HAS_WHITE_LED, uint8_t w=0)
OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS) OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS)
OPTARG(NEOPIXEL_IS_SEQUENTIAL, bool isSequence=false) OPTARG(NEOPIXEL_IS_SEQUENTIAL, bool isSequence=false)
@ -126,23 +126,23 @@ public:
set_color(LEDColor(r, g, b OPTARG(HAS_WHITE_LED, w) OPTARG(NEOPIXEL_LED, i)) OPTARG(NEOPIXEL_IS_SEQUENTIAL, isSequence)); set_color(LEDColor(r, g, b OPTARG(HAS_WHITE_LED, w) OPTARG(NEOPIXEL_LED, i)) OPTARG(NEOPIXEL_IS_SEQUENTIAL, isSequence));
} }
static inline void set_off() { set_color(LEDColorOff()); } static void set_off() { set_color(LEDColorOff()); }
static inline void set_green() { set_color(LEDColorGreen()); } static void set_green() { set_color(LEDColorGreen()); }
static inline void set_white() { set_color(LEDColorWhite()); } static void set_white() { set_color(LEDColorWhite()); }
#if ENABLED(LED_COLOR_PRESETS) #if ENABLED(LED_COLOR_PRESETS)
static const LEDColor defaultLEDColor; static const LEDColor defaultLEDColor;
static inline void set_default() { set_color(defaultLEDColor); } static void set_default() { set_color(defaultLEDColor); }
static inline void set_red() { set_color(LEDColorRed()); } static void set_red() { set_color(LEDColorRed()); }
static inline void set_orange() { set_color(LEDColorOrange()); } static void set_orange() { set_color(LEDColorOrange()); }
static inline void set_yellow() { set_color(LEDColorYellow()); } static void set_yellow() { set_color(LEDColorYellow()); }
static inline void set_blue() { set_color(LEDColorBlue()); } static void set_blue() { set_color(LEDColorBlue()); }
static inline void set_indigo() { set_color(LEDColorIndigo()); } static void set_indigo() { set_color(LEDColorIndigo()); }
static inline void set_violet() { set_color(LEDColorViolet()); } static void set_violet() { set_color(LEDColorViolet()); }
#endif #endif
#if ENABLED(PRINTER_EVENT_LEDS) #if ENABLED(PRINTER_EVENT_LEDS)
static inline LEDColor get_color() { return lights_on ? color : LEDColorOff(); } static LEDColor get_color() { return lights_on ? color : LEDColorOff(); }
#endif #endif
#if ANY(LED_CONTROL_MENU, PRINTER_EVENT_LEDS, CASE_LIGHT_IS_COLOR_LED) #if ANY(LED_CONTROL_MENU, PRINTER_EVENT_LEDS, CASE_LIGHT_IS_COLOR_LED)
@ -154,14 +154,14 @@ public:
static void toggle(); // swap "off" with color static void toggle(); // swap "off" with color
#endif #endif
#if EITHER(LED_CONTROL_MENU, CASE_LIGHT_USE_RGB_LED) #if EITHER(LED_CONTROL_MENU, CASE_LIGHT_USE_RGB_LED)
static inline void update() { set_color(color); } static void update() { set_color(color); }
#endif #endif
#ifdef LED_BACKLIGHT_TIMEOUT #ifdef LED_BACKLIGHT_TIMEOUT
private: private:
static millis_t led_off_time; static millis_t led_off_time;
public: public:
static inline void reset_timeout(const millis_t &ms) { static void reset_timeout(const millis_t &ms) {
led_off_time = ms + LED_BACKLIGHT_TIMEOUT; led_off_time = ms + LED_BACKLIGHT_TIMEOUT;
if (!lights_on) update(); if (!lights_on) update();
} }
@ -181,7 +181,7 @@ extern LEDLights leds;
static void set_color(const LEDColor &color); static void set_color(const LEDColor &color);
static inline void set_color(uint8_t r, uint8_t g, uint8_t b static void set_color(uint8_t r, uint8_t g, uint8_t b
OPTARG(HAS_WHITE_LED, uint8_t w=0) OPTARG(HAS_WHITE_LED, uint8_t w=0)
OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS) OPTARG(NEOPIXEL_LED, uint8_t i=NEOPIXEL_BRIGHTNESS)
) { ) {
@ -191,26 +191,26 @@ extern LEDLights leds;
)); ));
} }
static inline void set_off() { set_color(LEDColorOff()); } static void set_off() { set_color(LEDColorOff()); }
static inline void set_green() { set_color(LEDColorGreen()); } static void set_green() { set_color(LEDColorGreen()); }
static inline void set_white() { set_color(LEDColorWhite()); } static void set_white() { set_color(LEDColorWhite()); }
#if ENABLED(NEO2_COLOR_PRESETS) #if ENABLED(NEO2_COLOR_PRESETS)
static const LEDColor defaultLEDColor; static const LEDColor defaultLEDColor;
static inline void set_default() { set_color(defaultLEDColor); } static void set_default() { set_color(defaultLEDColor); }
static inline void set_red() { set_color(LEDColorRed()); } static void set_red() { set_color(LEDColorRed()); }
static inline void set_orange() { set_color(LEDColorOrange()); } static void set_orange() { set_color(LEDColorOrange()); }
static inline void set_yellow() { set_color(LEDColorYellow()); } static void set_yellow() { set_color(LEDColorYellow()); }
static inline void set_blue() { set_color(LEDColorBlue()); } static void set_blue() { set_color(LEDColorBlue()); }
static inline void set_indigo() { set_color(LEDColorIndigo()); } static void set_indigo() { set_color(LEDColorIndigo()); }
static inline void set_violet() { set_color(LEDColorViolet()); } static void set_violet() { set_color(LEDColorViolet()); }
#endif #endif
#if ENABLED(NEOPIXEL2_SEPARATE) #if ENABLED(NEOPIXEL2_SEPARATE)
static LEDColor color; // last non-off color static LEDColor color; // last non-off color
static bool lights_on; // the last set color was "on" static bool lights_on; // the last set color was "on"
static void toggle(); // swap "off" with color static void toggle(); // swap "off" with color
static inline void update() { set_color(color); } static void update() { set_color(color); }
#endif #endif
}; };

28
Marlin/src/feature/leds/neopixel.h

@ -94,12 +94,12 @@ public:
static void reset_background_color(); static void reset_background_color();
#endif #endif
static inline void begin() { static void begin() {
adaneo1.begin(); adaneo1.begin();
TERN_(CONJOINED_NEOPIXEL, adaneo2.begin()); TERN_(CONJOINED_NEOPIXEL, adaneo2.begin());
} }
static inline void set_pixel_color(const uint16_t n, const uint32_t c) { static void set_pixel_color(const uint16_t n, const uint32_t c) {
#if ENABLED(NEOPIXEL2_INSERIES) #if ENABLED(NEOPIXEL2_INSERIES)
if (n >= NEOPIXEL_PIXELS) adaneo2.setPixelColor(n - (NEOPIXEL_PIXELS), c); if (n >= NEOPIXEL_PIXELS) adaneo2.setPixelColor(n - (NEOPIXEL_PIXELS), c);
else adaneo1.setPixelColor(n, c); else adaneo1.setPixelColor(n, c);
@ -109,12 +109,12 @@ public:
#endif #endif
} }
static inline void set_brightness(const uint8_t b) { static void set_brightness(const uint8_t b) {
adaneo1.setBrightness(b); adaneo1.setBrightness(b);
TERN_(CONJOINED_NEOPIXEL, adaneo2.setBrightness(b)); TERN_(CONJOINED_NEOPIXEL, adaneo2.setBrightness(b));
} }
static inline void show() { static void show() {
// Some platforms cannot maintain PWM output when NeoPixel disables interrupts for long durations. // Some platforms cannot maintain PWM output when NeoPixel disables interrupts for long durations.
TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT()); TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT());
adaneo1.show(); adaneo1.show();
@ -130,11 +130,11 @@ public:
} }
// Accessors // Accessors
static inline uint16_t pixels() { return adaneo1.numPixels() * TERN1(NEOPIXEL2_INSERIES, 2); } static uint16_t pixels() { return adaneo1.numPixels() * TERN1(NEOPIXEL2_INSERIES, 2); }
static inline uint8_t brightness() { return adaneo1.getBrightness(); } static uint8_t brightness() { return adaneo1.getBrightness(); }
static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w)) { static uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED, uint8_t w)) {
return adaneo1.Color(r, g, b OPTARG(HAS_WHITE_LED, w)); return adaneo1.Color(r, g, b OPTARG(HAS_WHITE_LED, w));
} }
}; };
@ -165,18 +165,18 @@ extern Marlin_NeoPixel neo;
static void set_color(const uint32_t c); static void set_color(const uint32_t c);
static inline void begin() { adaneo.begin(); } static void begin() { adaneo.begin(); }
static inline void set_pixel_color(const uint16_t n, const uint32_t c) { adaneo.setPixelColor(n, c); } static void set_pixel_color(const uint16_t n, const uint32_t c) { adaneo.setPixelColor(n, c); }
static inline void set_brightness(const uint8_t b) { adaneo.setBrightness(b); } static void set_brightness(const uint8_t b) { adaneo.setBrightness(b); }
static inline void show() { static void show() {
adaneo.show(); adaneo.show();
adaneo.setPin(NEOPIXEL2_PIN); adaneo.setPin(NEOPIXEL2_PIN);
} }
// Accessors // Accessors
static inline uint16_t pixels() { return adaneo.numPixels();} static uint16_t pixels() { return adaneo.numPixels();}
static inline uint8_t brightness() { return adaneo.getBrightness(); } static uint8_t brightness() { return adaneo.getBrightness(); }
static inline uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED2, uint8_t w)) { static uint32_t Color(uint8_t r, uint8_t g, uint8_t b OPTARG(HAS_WHITE_LED2, uint8_t w)) {
return adaneo.Color(r, g, b OPTARG(HAS_WHITE_LED2, w)); return adaneo.Color(r, g, b OPTARG(HAS_WHITE_LED2, w));
} }
}; };

16
Marlin/src/feature/leds/printer_event_leds.h

@ -36,32 +36,32 @@ private:
static bool leds_off_after_print; static bool leds_off_after_print;
#endif #endif
static inline void set_done() { TERN(LED_COLOR_PRESETS, leds.set_default(), leds.set_off()); } static void set_done() { TERN(LED_COLOR_PRESETS, leds.set_default(), leds.set_off()); }
public: public:
#if HAS_TEMP_HOTEND #if HAS_TEMP_HOTEND
static inline LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); } static LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); }
static void onHotendHeating(const celsius_t start, const celsius_t current, const celsius_t target); static void onHotendHeating(const celsius_t start, const celsius_t current, const celsius_t target);
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
static inline LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); } static LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); }
static void onBedHeating(const celsius_t start, const celsius_t current, const celsius_t target); static void onBedHeating(const celsius_t start, const celsius_t current, const celsius_t target);
#endif #endif
#if HAS_HEATED_CHAMBER #if HAS_HEATED_CHAMBER
static inline LEDColor onChamberHeatingStart() { old_intensity = 127; return leds.get_color(); } static LEDColor onChamberHeatingStart() { old_intensity = 127; return leds.get_color(); }
static void onChamberHeating(const celsius_t start, const celsius_t current, const celsius_t target); static void onChamberHeating(const celsius_t start, const celsius_t current, const celsius_t target);
#endif #endif
#if HAS_TEMP_HOTEND || HAS_HEATED_BED || HAS_HEATED_CHAMBER #if HAS_TEMP_HOTEND || HAS_HEATED_BED || HAS_HEATED_CHAMBER
static inline void onHeatingDone() { leds.set_white(); } static void onHeatingDone() { leds.set_white(); }
static inline void onPidTuningDone(LEDColor c) { leds.set_color(c); } static void onPidTuningDone(LEDColor c) { leds.set_color(c); }
#endif #endif
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
static inline void onPrintCompleted() { static void onPrintCompleted() {
leds.set_green(); leds.set_green();
#if HAS_LEDS_OFF_FLAG #if HAS_LEDS_OFF_FLAG
leds_off_after_print = true; leds_off_after_print = true;
@ -71,7 +71,7 @@ public:
#endif #endif
} }
static inline void onResumeAfterWait() { static void onResumeAfterWait() {
#if HAS_LEDS_OFF_FLAG #if HAS_LEDS_OFF_FLAG
if (leds_off_after_print) { if (leds_off_after_print) {
set_done(); set_done();

6
Marlin/src/feature/max7219.h

@ -88,13 +88,13 @@ public:
static void send(const uint8_t reg, const uint8_t data); static void send(const uint8_t reg, const uint8_t data);
// Refresh all units // Refresh all units
static inline void refresh() { for (uint8_t i = 0; i < 8; i++) refresh_line(i); } static void refresh() { for (uint8_t i = 0; i < 8; i++) refresh_line(i); }
// Suspend / resume updates to the LED unit // Suspend / resume updates to the LED unit
// Use these methods to speed up multiple changes // Use these methods to speed up multiple changes
// or to apply updates from interrupt context. // or to apply updates from interrupt context.
static inline void suspend() { suspended++; } static void suspend() { suspended++; }
static inline void resume() { suspended--; suspended |= 0x80; } static void resume() { suspended--; suspended |= 0x80; }
// Update a single native line on all units // Update a single native line on all units
static void refresh_line(const uint8_t line); static void refresh_line(const uint8_t line);

10
Marlin/src/feature/mixing.h

@ -126,7 +126,7 @@ class Mixer {
static mixer_perc_t mix[MIXING_STEPPERS]; // Scratch array for the Mix in proportion to 100 static mixer_perc_t mix[MIXING_STEPPERS]; // Scratch array for the Mix in proportion to 100
static inline void copy_mix_to_color(mixer_comp_t (&tcolor)[MIXING_STEPPERS]) { static void copy_mix_to_color(mixer_comp_t (&tcolor)[MIXING_STEPPERS]) {
// Scale each component to the largest one in terms of COLOR_A_MASK // Scale each component to the largest one in terms of COLOR_A_MASK
// So the largest component will be COLOR_A_MASK and the other will be in proportion to it // So the largest component will be COLOR_A_MASK and the other will be in proportion to it
const float scale = (COLOR_A_MASK) * RECIPROCAL(_MAX( const float scale = (COLOR_A_MASK) * RECIPROCAL(_MAX(
@ -145,7 +145,7 @@ class Mixer {
#endif #endif
} }
static inline void update_mix_from_vtool(const uint8_t j=selected_vtool) { static void update_mix_from_vtool(const uint8_t j=selected_vtool) {
float ctot = 0; float ctot = 0;
MIXER_STEPPER_LOOP(i) ctot += color[j][i]; MIXER_STEPPER_LOOP(i) ctot += color[j][i];
//MIXER_STEPPER_LOOP(i) mix[i] = 100.0f * color[j][i] / ctot; //MIXER_STEPPER_LOOP(i) mix[i] = 100.0f * color[j][i] / ctot;
@ -165,7 +165,7 @@ class Mixer {
#if HAS_DUAL_MIXING #if HAS_DUAL_MIXING
// Update the virtual tool from an edited mix // Update the virtual tool from an edited mix
static inline void update_vtool_from_mix() { static void update_vtool_from_mix() {
copy_mix_to_color(color[selected_vtool]); copy_mix_to_color(color[selected_vtool]);
TERN_(GRADIENT_MIX, refresh_gradient()); TERN_(GRADIENT_MIX, refresh_gradient());
// MIXER_STEPPER_LOOP(i) collector[i] = mix[i]; // MIXER_STEPPER_LOOP(i) collector[i] = mix[i];
@ -182,7 +182,7 @@ class Mixer {
// Update the current mix from the gradient for a given Z // Update the current mix from the gradient for a given Z
static void update_gradient_for_z(const_float_t z); static void update_gradient_for_z(const_float_t z);
static void update_gradient_for_planner_z(); static void update_gradient_for_planner_z();
static inline void gradient_control(const_float_t z) { static void gradient_control(const_float_t z) {
if (gradient.enabled) { if (gradient.enabled) {
if (z >= gradient.end_z) if (z >= gradient.end_z)
T(gradient.end_vtool); T(gradient.end_vtool);
@ -191,7 +191,7 @@ class Mixer {
} }
} }
static inline void update_mix_from_gradient() { static void update_mix_from_gradient() {
float ctot = 0; float ctot = 0;
MIXER_STEPPER_LOOP(i) ctot += gradient.color[i]; MIXER_STEPPER_LOOP(i) ctot += gradient.color[i];
MIXER_STEPPER_LOOP(i) mix[i] = (mixer_perc_t)CEIL(100.0f * gradient.color[i] / ctot); MIXER_STEPPER_LOOP(i) mix[i] = (mixer_perc_t)CEIL(100.0f * gradient.color[i] / ctot);

12
Marlin/src/feature/mmu/mmu2.h

@ -43,7 +43,7 @@ public:
static void init(); static void init();
static void reset(); static void reset();
static inline bool enabled() { return _enabled; } static bool enabled() { return _enabled; }
static void mmu_loop(); static void mmu_loop();
static void tool_change(const uint8_t index); static void tool_change(const uint8_t index);
static void tool_change(const char *special); static void tool_change(const char *special);
@ -57,10 +57,10 @@ public:
static bool eject_filament(const uint8_t index, const bool recover); static bool eject_filament(const uint8_t index, const bool recover);
private: private:
static inline bool rx_str(FSTR_P fstr); static bool rx_str(FSTR_P fstr);
static inline void tx_str(FSTR_P fstr); static void tx_str(FSTR_P fstr);
static inline void tx_printf(FSTR_P ffmt, const int argument); static void tx_printf(FSTR_P ffmt, const int argument);
static inline void tx_printf(FSTR_P ffmt, const int argument1, const int argument2); static void tx_printf(FSTR_P ffmt, const int argument1, const int argument2);
static void clear_rx_buffer(); static void clear_rx_buffer();
static bool rx_ok(); static bool rx_ok();
@ -99,7 +99,7 @@ private:
static millis_t prev_request, prev_P0_request; static millis_t prev_request, prev_P0_request;
static char rx_buffer[MMU_RX_SIZE], tx_buffer[MMU_TX_SIZE]; static char rx_buffer[MMU_RX_SIZE], tx_buffer[MMU_TX_SIZE];
static inline void set_runout_valid(const bool valid) { static void set_runout_valid(const bool valid) {
finda_runout_valid = valid; finda_runout_valid = valid;
#if HAS_FILAMENT_SENSOR #if HAS_FILAMENT_SENSOR
if (valid) runout.reset(); if (valid) runout.reset();

2
Marlin/src/feature/power.h

@ -40,7 +40,7 @@ class Power {
#if ENABLED(AUTO_POWER_CONTROL) && POWER_OFF_DELAY > 0 #if ENABLED(AUTO_POWER_CONTROL) && POWER_OFF_DELAY > 0
static void power_off_soon(); static void power_off_soon();
#else #else
static inline void power_off_soon() { power_off(); } static void power_off_soon() { power_off(); }
#endif #endif
#if ENABLED(AUTO_POWER_CONTROL) #if ENABLED(AUTO_POWER_CONTROL)

22
Marlin/src/feature/powerloss.h

@ -152,7 +152,7 @@ class PrintJobRecovery {
static void init(); static void init();
static void prepare(); static void prepare();
static inline void setup() { static void setup() {
#if PIN_EXISTS(POWER_LOSS) #if PIN_EXISTS(POWER_LOSS)
#if ENABLED(POWER_LOSS_PULLUP) #if ENABLED(POWER_LOSS_PULLUP)
SET_INPUT_PULLUP(POWER_LOSS_PIN); SET_INPUT_PULLUP(POWER_LOSS_PIN);
@ -165,28 +165,28 @@ class PrintJobRecovery {
} }
// Track each command's file offsets // Track each command's file offsets
static inline uint32_t command_sdpos() { return sdpos[queue_index_r]; } static uint32_t command_sdpos() { return sdpos[queue_index_r]; }
static inline void commit_sdpos(const uint8_t index_w) { sdpos[index_w] = cmd_sdpos; } static void commit_sdpos(const uint8_t index_w) { sdpos[index_w] = cmd_sdpos; }
static bool enabled; static bool enabled;
static void enable(const bool onoff); static void enable(const bool onoff);
static void changed(); static void changed();
static inline bool exists() { return card.jobRecoverFileExists(); } static bool exists() { return card.jobRecoverFileExists(); }
static inline void open(const bool read) { card.openJobRecoveryFile(read); } static void open(const bool read) { card.openJobRecoveryFile(read); }
static inline void close() { file.close(); } static void close() { file.close(); }
static void check(); static void check();
static void resume(); static void resume();
static void purge(); static void purge();
static inline void cancel() { purge(); IF_DISABLED(NO_SD_AUTOSTART, card.autofile_begin()); } static void cancel() { purge(); IF_DISABLED(NO_SD_AUTOSTART, card.autofile_begin()); }
static void load(); static void load();
static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE), const float zraise=POWER_LOSS_ZRAISE, const bool raised=false); static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE), const float zraise=POWER_LOSS_ZRAISE, const bool raised=false);
#if PIN_EXISTS(POWER_LOSS) #if PIN_EXISTS(POWER_LOSS)
static inline void outage() { static void outage() {
static constexpr uint8_t OUTAGE_THRESHOLD = 3; static constexpr uint8_t OUTAGE_THRESHOLD = 3;
static uint8_t outage_counter = 0; static uint8_t outage_counter = 0;
if (enabled && READ(POWER_LOSS_PIN) == POWER_LOSS_STATE) { if (enabled && READ(POWER_LOSS_PIN) == POWER_LOSS_STATE) {
@ -199,14 +199,14 @@ class PrintJobRecovery {
#endif #endif
// The referenced file exists // The referenced file exists
static inline bool interrupted_file_exists() { return card.fileExists(info.sd_filename); } static bool interrupted_file_exists() { return card.fileExists(info.sd_filename); }
static inline bool valid() { return info.valid() && interrupted_file_exists(); } static bool valid() { return info.valid() && interrupted_file_exists(); }
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY) #if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
static void debug(FSTR_P const prefix); static void debug(FSTR_P const prefix);
#else #else
static inline void debug(FSTR_P const) {} static void debug(FSTR_P const) {}
#endif #endif
private: private:

6
Marlin/src/feature/probe_temp_comp.h

@ -74,11 +74,11 @@ class ProbeTempComp {
static int16_t z_offsets_hotend[PTC_HOTEND_COUNT]; // (µm) static int16_t z_offsets_hotend[PTC_HOTEND_COUNT]; // (µm)
#endif #endif
static inline void reset_index() { calib_idx = 0; }; static void reset_index() { calib_idx = 0; };
static inline uint8_t get_index() { return calib_idx; } static uint8_t get_index() { return calib_idx; }
static void reset(); static void reset();
static void clear_offsets(const TempSensorID tsi); static void clear_offsets(const TempSensorID tsi);
static inline void clear_all_offsets() { static void clear_all_offsets() {
TERN_(PTC_PROBE, clear_offsets(TSI_PROBE)); TERN_(PTC_PROBE, clear_offsets(TSI_PROBE));
TERN_(PTC_BED, clear_offsets(TSI_BED)); TERN_(PTC_BED, clear_offsets(TSI_BED));
TERN_(PTC_HOTEND, clear_offsets(TSI_EXT)); TERN_(PTC_HOTEND, clear_offsets(TSI_EXT));

4
Marlin/src/feature/repeat.h

@ -38,8 +38,8 @@ private:
static repeat_marker_t marker[MAX_REPEAT_NESTING]; static repeat_marker_t marker[MAX_REPEAT_NESTING];
static uint8_t index; static uint8_t index;
public: public:
static inline void reset() { index = 0; } static void reset() { index = 0; }
static inline bool is_active() { static bool is_active() {
LOOP_L_N(i, index) if (marker[i].counter) return true; LOOP_L_N(i, index) if (marker[i].counter) return true;
return false; return false;
} }

54
Marlin/src/feature/runout.h

@ -83,30 +83,30 @@ class TFilamentMonitor : public FilamentMonitorBase {
static sensor_t sensor; static sensor_t sensor;
public: public:
static inline void setup() { static void setup() {
sensor.setup(); sensor.setup();
reset(); reset();
} }
static inline void reset() { static void reset() {
filament_ran_out = false; filament_ran_out = false;
response.reset(); response.reset();
} }
// Call this method when filament is present, // Call this method when filament is present,
// so the response can reset its counter. // so the response can reset its counter.
static inline void filament_present(const uint8_t extruder) { static void filament_present(const uint8_t extruder) {
response.filament_present(extruder); response.filament_present(extruder);
} }
#if HAS_FILAMENT_RUNOUT_DISTANCE #if HAS_FILAMENT_RUNOUT_DISTANCE
static inline float& runout_distance() { return response.runout_distance_mm; } static float& runout_distance() { return response.runout_distance_mm; }
static inline void set_runout_distance(const_float_t mm) { response.runout_distance_mm = mm; } static void set_runout_distance(const_float_t mm) { response.runout_distance_mm = mm; }
#endif #endif
// Handle a block completion. RunoutResponseDelayed uses this to // Handle a block completion. RunoutResponseDelayed uses this to
// add up the length of filament moved while the filament is out. // add up the length of filament moved while the filament is out.
static inline void block_completed(const block_t * const b) { static void block_completed(const block_t * const b) {
if (enabled) { if (enabled) {
response.block_completed(b); response.block_completed(b);
sensor.block_completed(b); sensor.block_completed(b);
@ -114,7 +114,7 @@ class TFilamentMonitor : public FilamentMonitorBase {
} }
// Give the response a chance to update its counter. // Give the response a chance to update its counter.
static inline void run() { static void run() {
if (enabled && !filament_ran_out && (printingIsActive() || did_pause_print)) { if (enabled && !filament_ran_out && (printingIsActive() || did_pause_print)) {
TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, cli()); // Prevent RunoutResponseDelayed::block_completed from accumulating here TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, cli()); // Prevent RunoutResponseDelayed::block_completed from accumulating here
response.run(); response.run();
@ -168,12 +168,12 @@ class FilamentSensorBase {
* Called by FilamentSensorSwitch::run when filament is detected. * Called by FilamentSensorSwitch::run when filament is detected.
* Called by FilamentSensorEncoder::block_completed when motion is detected. * Called by FilamentSensorEncoder::block_completed when motion is detected.
*/ */
static inline void filament_present(const uint8_t extruder) { static void filament_present(const uint8_t extruder) {
runout.filament_present(extruder); // ...which calls response.filament_present(extruder) runout.filament_present(extruder); // ...which calls response.filament_present(extruder)
} }
public: public:
static inline void setup() { static void setup() {
#define _INIT_RUNOUT_PIN(P,S,U,D) do{ if (ENABLED(U)) SET_INPUT_PULLUP(P); else if (ENABLED(D)) SET_INPUT_PULLDOWN(P); else SET_INPUT(P); }while(0) #define _INIT_RUNOUT_PIN(P,S,U,D) do{ if (ENABLED(U)) SET_INPUT_PULLUP(P); else if (ENABLED(D)) SET_INPUT_PULLDOWN(P); else SET_INPUT(P); }while(0)
#define INIT_RUNOUT_PIN(N) _INIT_RUNOUT_PIN(FIL_RUNOUT##N##_PIN, FIL_RUNOUT##N##_STATE, FIL_RUNOUT##N##_PULLUP, FIL_RUNOUT##N##_PULLDOWN) #define INIT_RUNOUT_PIN(N) _INIT_RUNOUT_PIN(FIL_RUNOUT##N##_PIN, FIL_RUNOUT##N##_STATE, FIL_RUNOUT##N##_PULLUP, FIL_RUNOUT##N##_PULLDOWN)
#if NUM_RUNOUT_SENSORS >= 1 #if NUM_RUNOUT_SENSORS >= 1
@ -205,14 +205,14 @@ class FilamentSensorBase {
} }
// Return a bitmask of runout pin states // Return a bitmask of runout pin states
static inline uint8_t poll_runout_pins() { static uint8_t poll_runout_pins() {
#define _OR_RUNOUT(N) | (READ(FIL_RUNOUT##N##_PIN) ? _BV((N) - 1) : 0) #define _OR_RUNOUT(N) | (READ(FIL_RUNOUT##N##_PIN) ? _BV((N) - 1) : 0)
return (0 REPEAT_1(NUM_RUNOUT_SENSORS, _OR_RUNOUT)); return (0 REPEAT_1(NUM_RUNOUT_SENSORS, _OR_RUNOUT));
#undef _OR_RUNOUT #undef _OR_RUNOUT
} }
// Return a bitmask of runout flag states (1 bits always indicates runout) // Return a bitmask of runout flag states (1 bits always indicates runout)
static inline uint8_t poll_runout_states() { static uint8_t poll_runout_states() {
return poll_runout_pins() ^ uint8_t(0 return poll_runout_pins() ^ uint8_t(0
#if NUM_RUNOUT_SENSORS >= 1 #if NUM_RUNOUT_SENSORS >= 1
| (FIL_RUNOUT1_STATE ? 0 : _BV(1 - 1)) | (FIL_RUNOUT1_STATE ? 0 : _BV(1 - 1))
@ -254,7 +254,7 @@ class FilamentSensorBase {
private: private:
static uint8_t motion_detected; static uint8_t motion_detected;
static inline void poll_motion_sensor() { static void poll_motion_sensor() {
static uint8_t old_state; static uint8_t old_state;
const uint8_t new_state = poll_runout_pins(), const uint8_t new_state = poll_runout_pins(),
change = old_state ^ new_state; change = old_state ^ new_state;
@ -273,7 +273,7 @@ class FilamentSensorBase {
} }
public: public:
static inline void block_completed(const block_t * const b) { static void block_completed(const block_t * const b) {
// If the sensor wheel has moved since the last call to // If the sensor wheel has moved since the last call to
// this method reset the runout counter for the extruder. // this method reset the runout counter for the extruder.
if (TEST(motion_detected, b->extruder)) if (TEST(motion_detected, b->extruder))
@ -283,7 +283,7 @@ class FilamentSensorBase {
motion_detected = 0; motion_detected = 0;
} }
static inline void run() { poll_motion_sensor(); } static void run() { poll_motion_sensor(); }
}; };
#else #else
@ -294,7 +294,7 @@ class FilamentSensorBase {
*/ */
class FilamentSensorSwitch : public FilamentSensorBase { class FilamentSensorSwitch : public FilamentSensorBase {
private: private:
static inline bool poll_runout_state(const uint8_t extruder) { static bool poll_runout_state(const uint8_t extruder) {
const uint8_t runout_states = poll_runout_states(); const uint8_t runout_states = poll_runout_states();
#if MULTI_FILAMENT_SENSOR #if MULTI_FILAMENT_SENSOR
if ( !TERN0(DUAL_X_CARRIAGE, idex_is_duplicating()) if ( !TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())
@ -307,9 +307,9 @@ class FilamentSensorBase {
} }
public: public:
static inline void block_completed(const block_t * const) {} static void block_completed(const block_t * const) {}
static inline void run() { static void run() {
LOOP_L_N(s, NUM_RUNOUT_SENSORS) { LOOP_L_N(s, NUM_RUNOUT_SENSORS) {
const bool out = poll_runout_state(s); const bool out = poll_runout_state(s);
if (!out) filament_present(s); if (!out) filament_present(s);
@ -341,11 +341,11 @@ class FilamentSensorBase {
public: public:
static float runout_distance_mm; static float runout_distance_mm;
static inline void reset() { static void reset() {
LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i); LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i);
} }
static inline void run() { static void run() {
#if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG) #if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG)
static millis_t t = 0; static millis_t t = 0;
const millis_t ms = millis(); const millis_t ms = millis();
@ -358,17 +358,17 @@ class FilamentSensorBase {
#endif #endif
} }
static inline uint8_t has_run_out() { static uint8_t has_run_out() {
uint8_t runout_flags = 0; uint8_t runout_flags = 0;
LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_mm_countdown[i] < 0) SBI(runout_flags, i); LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_mm_countdown[i] < 0) SBI(runout_flags, i);
return runout_flags; return runout_flags;
} }
static inline void filament_present(const uint8_t extruder) { static void filament_present(const uint8_t extruder) {
runout_mm_countdown[extruder] = runout_distance_mm; runout_mm_countdown[extruder] = runout_distance_mm;
} }
static inline void block_completed(const block_t * const b) { static void block_completed(const block_t * const b) {
if (b->steps.x || b->steps.y || b->steps.z || did_pause_print) { // Allow pause purge move to re-trigger runout state if (b->steps.x || b->steps.y || b->steps.z || did_pause_print) { // Allow pause purge move to re-trigger runout state
// Only trigger on extrusion with XYZ movement to allow filament change and retract/recover. // Only trigger on extrusion with XYZ movement to allow filament change and retract/recover.
const uint8_t e = b->extruder; const uint8_t e = b->extruder;
@ -389,23 +389,23 @@ class FilamentSensorBase {
static int8_t runout_count[NUM_RUNOUT_SENSORS]; static int8_t runout_count[NUM_RUNOUT_SENSORS];
public: public:
static inline void reset() { static void reset() {
LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i); LOOP_L_N(i, NUM_RUNOUT_SENSORS) filament_present(i);
} }
static inline void run() { static void run() {
LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_count[i] >= 0) runout_count[i]--; LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_count[i] >= 0) runout_count[i]--;
} }
static inline uint8_t has_run_out() { static uint8_t has_run_out() {
uint8_t runout_flags = 0; uint8_t runout_flags = 0;
LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_count[i] < 0) SBI(runout_flags, i); LOOP_L_N(i, NUM_RUNOUT_SENSORS) if (runout_count[i] < 0) SBI(runout_flags, i);
return runout_flags; return runout_flags;
} }
static inline void block_completed(const block_t * const) { } static void block_completed(const block_t * const) { }
static inline void filament_present(const uint8_t extruder) { static void filament_present(const uint8_t extruder) {
runout_count[extruder] = runout_threshold; runout_count[extruder] = runout_threshold;
} }
}; };

42
Marlin/src/feature/spindle_laser.h

@ -103,12 +103,12 @@ public:
static void init(); static void init();
#if ENABLED(MARLIN_DEV_MODE) #if ENABLED(MARLIN_DEV_MODE)
static inline void refresh_frequency() { set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency); } static void refresh_frequency() { set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), frequency); }
#endif #endif
// Modifying this function should update everywhere // Modifying this function should update everywhere
static inline bool enabled(const cutter_power_t opwr) { return opwr > 0; } static bool enabled(const cutter_power_t opwr) { return opwr > 0; }
static inline bool enabled() { return enabled(power); } static bool enabled() { return enabled(power); }
static void apply_power(const uint8_t inpow); static void apply_power(const uint8_t inpow);
@ -124,13 +124,13 @@ public:
public: public:
static void set_ocr(const uint8_t ocr); static void set_ocr(const uint8_t ocr);
static inline void ocr_set_power(const uint8_t ocr) { power = ocr; set_ocr(ocr); } static void ocr_set_power(const uint8_t ocr) { power = ocr; set_ocr(ocr); }
static void ocr_off(); static void ocr_off();
/** /**
* Update output for power->OCR translation * Update output for power->OCR translation
*/ */
static inline uint8_t upower_to_ocr(const cutter_power_t upwr) { static uint8_t upower_to_ocr(const cutter_power_t upwr) {
return uint8_t( return uint8_t(
#if CUTTER_UNIT_IS(PWM255) #if CUTTER_UNIT_IS(PWM255)
upwr upwr
@ -145,11 +145,11 @@ public:
/** /**
* Correct power to configured range * Correct power to configured range
*/ */
static inline cutter_power_t power_to_range(const cutter_power_t pwr) { static cutter_power_t power_to_range(const cutter_power_t pwr) {
return power_to_range(pwr, _CUTTER_POWER(CUTTER_POWER_UNIT)); return power_to_range(pwr, _CUTTER_POWER(CUTTER_POWER_UNIT));
} }
static inline cutter_power_t power_to_range(const cutter_power_t pwr, const uint8_t pwrUnit) { static cutter_power_t power_to_range(const cutter_power_t pwr, const uint8_t pwrUnit) {
static constexpr float static constexpr float
min_pct = TERN(CUTTER_POWER_RELATIVE, 0, TERN(SPINDLE_FEATURE, round(100.0f * (SPEED_POWER_MIN) / (SPEED_POWER_MAX)), SPEED_POWER_MIN)), min_pct = TERN(CUTTER_POWER_RELATIVE, 0, TERN(SPINDLE_FEATURE, round(100.0f * (SPEED_POWER_MIN) / (SPEED_POWER_MAX)), SPEED_POWER_MIN)),
max_pct = TERN(SPINDLE_FEATURE, 100, SPEED_POWER_MAX); max_pct = TERN(SPINDLE_FEATURE, 100, SPEED_POWER_MAX);
@ -188,7 +188,7 @@ public:
* Enable/Disable spindle/laser * Enable/Disable spindle/laser
* @param enable true = enable; false = disable * @param enable true = enable; false = disable
*/ */
static inline void set_enabled(const bool enable) { static void set_enabled(const bool enable) {
uint8_t value = 0; uint8_t value = 0;
if (enable) { if (enable) {
#if ENABLED(SPINDLE_LASER_USE_PWM) #if ENABLED(SPINDLE_LASER_USE_PWM)
@ -203,14 +203,14 @@ public:
set_power(value); set_power(value);
} }
static inline void disable() { isReady = false; set_enabled(false); } static void disable() { isReady = false; set_enabled(false); }
/** /**
* Wait for spindle to spin up or spin down * Wait for spindle to spin up or spin down
* *
* @param on true = state to on; false = state to off. * @param on true = state to on; false = state to off.
*/ */
static inline void power_delay(const bool on) { static void power_delay(const bool on) {
#if DISABLED(LASER_POWER_INLINE) #if DISABLED(LASER_POWER_INLINE)
safe_delay(on ? SPINDLE_LASER_POWERUP_DELAY : SPINDLE_LASER_POWERDOWN_DELAY); safe_delay(on ? SPINDLE_LASER_POWERUP_DELAY : SPINDLE_LASER_POWERDOWN_DELAY);
#endif #endif
@ -220,7 +220,7 @@ public:
static void set_reverse(const bool reverse); static void set_reverse(const bool reverse);
static bool is_reverse() { return READ(SPINDLE_DIR_PIN) == SPINDLE_INVERT_DIR; } static bool is_reverse() { return READ(SPINDLE_DIR_PIN) == SPINDLE_INVERT_DIR; }
#else #else
static inline void set_reverse(const bool) {} static void set_reverse(const bool) {}
static bool is_reverse() { return false; } static bool is_reverse() { return false; }
#endif #endif
@ -228,7 +228,7 @@ public:
static void air_evac_enable(); // Turn On Cutter Vacuum or Laser Blower motor static void air_evac_enable(); // Turn On Cutter Vacuum or Laser Blower motor
static void air_evac_disable(); // Turn Off Cutter Vacuum or Laser Blower motor static void air_evac_disable(); // Turn Off Cutter Vacuum or Laser Blower motor
static void air_evac_toggle(); // Toggle Cutter Vacuum or Laser Blower motor static void air_evac_toggle(); // Toggle Cutter Vacuum or Laser Blower motor
static inline bool air_evac_state() { // Get current state static bool air_evac_state() { // Get current state
return (READ(AIR_EVACUATION_PIN) == AIR_EVACUATION_ACTIVE); return (READ(AIR_EVACUATION_PIN) == AIR_EVACUATION_ACTIVE);
} }
#endif #endif
@ -237,13 +237,13 @@ public:
static void air_assist_enable(); // Turn on air assist static void air_assist_enable(); // Turn on air assist
static void air_assist_disable(); // Turn off air assist static void air_assist_disable(); // Turn off air assist
static void air_assist_toggle(); // Toggle air assist static void air_assist_toggle(); // Toggle air assist
static inline bool air_assist_state() { // Get current state static bool air_assist_state() { // Get current state
return (READ(AIR_ASSIST_PIN) == AIR_ASSIST_ACTIVE); return (READ(AIR_ASSIST_PIN) == AIR_ASSIST_ACTIVE);
} }
#endif #endif
#if HAS_LCD_MENU #if HAS_LCD_MENU
static inline void enable_with_dir(const bool reverse) { static void enable_with_dir(const bool reverse) {
isReady = true; isReady = true;
const uint8_t ocr = TERN(SPINDLE_LASER_USE_PWM, upower_to_ocr(menuPower), 255); const uint8_t ocr = TERN(SPINDLE_LASER_USE_PWM, upower_to_ocr(menuPower), 255);
if (menuPower) if (menuPower)
@ -259,7 +259,7 @@ public:
FORCE_INLINE static void enable_same_dir() { enable_with_dir(is_reverse()); } FORCE_INLINE static void enable_same_dir() { enable_with_dir(is_reverse()); }
#if ENABLED(SPINDLE_LASER_USE_PWM) #if ENABLED(SPINDLE_LASER_USE_PWM)
static inline void update_from_mpower() { static void update_from_mpower() {
if (isReady) power = upower_to_ocr(menuPower); if (isReady) power = upower_to_ocr(menuPower);
unitPower = menuPower; unitPower = menuPower;
} }
@ -271,7 +271,7 @@ public:
* Also fires with any PWM power that was previous set * Also fires with any PWM power that was previous set
* If not set defaults to 80% power * If not set defaults to 80% power
*/ */
static inline void test_fire_pulse() { static void test_fire_pulse() {
TERN_(USE_BEEPER, buzzer.tone(30, 3000)); TERN_(USE_BEEPER, buzzer.tone(30, 3000));
enable_forward(); // Turn Laser on (Spindle speak but same funct) enable_forward(); // Turn Laser on (Spindle speak but same funct)
delay(testPulse); // Delay for time set by user in pulse ms menu screen. delay(testPulse); // Delay for time set by user in pulse ms menu screen.
@ -288,7 +288,7 @@ public:
*/ */
// Force disengage planner power control // Force disengage planner power control
static inline void inline_disable() { static void inline_disable() {
isReady = false; isReady = false;
unitPower = 0; unitPower = 0;
planner.laser_inline.status.isPlanned = false; planner.laser_inline.status.isPlanned = false;
@ -297,7 +297,7 @@ public:
} }
// Inline modes of all other functions; all enable planner inline power control // Inline modes of all other functions; all enable planner inline power control
static inline void set_inline_enabled(const bool enable) { static void set_inline_enabled(const bool enable) {
if (enable) if (enable)
inline_power(255); inline_power(255);
else { else {
@ -326,10 +326,10 @@ public:
#endif #endif
} }
static inline void inline_direction(const bool) { /* never */ } static void inline_direction(const bool) { /* never */ }
#if ENABLED(SPINDLE_LASER_USE_PWM) #if ENABLED(SPINDLE_LASER_USE_PWM)
static inline void inline_ocr_power(const uint8_t ocrpwr) { static void inline_ocr_power(const uint8_t ocrpwr) {
isReady = ocrpwr > 0; isReady = ocrpwr > 0;
planner.laser_inline.status.isEnabled = ocrpwr > 0; planner.laser_inline.status.isEnabled = ocrpwr > 0;
planner.laser_inline.power = ocrpwr; planner.laser_inline.power = ocrpwr;
@ -337,7 +337,7 @@ public:
#endif #endif
#endif // LASER_POWER_INLINE #endif // LASER_POWER_INLINE
static inline void kill() { static void kill() {
TERN_(LASER_POWER_INLINE, inline_disable()); TERN_(LASER_POWER_INLINE, inline_disable());
disable(); disable();
} }

8
Marlin/src/feature/tmc_util.cpp

@ -472,12 +472,8 @@
void tmc_set_report_interval(const uint16_t update_interval) { void tmc_set_report_interval(const uint16_t update_interval) {
if ((report_tmc_status_interval = update_interval)) if ((report_tmc_status_interval = update_interval))
SERIAL_ECHOLNPGM("axis:pwm_scale" SERIAL_ECHOLNPGM("axis:pwm_scale"
#if HAS_STEALTHCHOP TERN_(HAS_STEALTHCHOP, "/curr_scale")
"/curr_scale" TERN_(HAS_STALLGUARD, "/mech_load")
#endif
#if HAS_STALLGUARD
"/mech_load"
#endif
"|flags|warncount" "|flags|warncount"
); );
} }

157
Marlin/src/feature/tmc_util.h

@ -45,6 +45,12 @@ constexpr uint16_t _tmc_thrs(const uint16_t msteps, const uint32_t thrs, const u
return 12650000UL * msteps / (256 * thrs * spmm); return 12650000UL * msteps / (256 * thrs * spmm);
} }
typedef struct {
uint8_t toff;
int8_t hend;
uint8_t hstrt;
} chopper_timing_t;
template<char AXIS_LETTER, char DRIVER_ID> template<char AXIS_LETTER, char DRIVER_ID>
class TMCStorage { class TMCStorage {
protected: protected:
@ -58,13 +64,13 @@ class TMCStorage {
uint8_t otpw_count = 0, uint8_t otpw_count = 0,
error_count = 0; error_count = 0;
bool flag_otpw = false; bool flag_otpw = false;
inline bool getOTPW() { return flag_otpw; } bool getOTPW() { return flag_otpw; }
inline void clear_otpw() { flag_otpw = 0; } void clear_otpw() { flag_otpw = 0; }
#endif #endif
inline uint16_t getMilliamps() { return val_mA; } uint16_t getMilliamps() { return val_mA; }
inline void printLabel() { void printLabel() {
SERIAL_CHAR(AXIS_LETTER); SERIAL_CHAR(AXIS_LETTER);
if (DRIVER_ID > '0') SERIAL_CHAR(DRIVER_ID); if (DRIVER_ID > '0') SERIAL_CHAR(DRIVER_ID);
} }
@ -91,25 +97,31 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
TMCMarlin(const uint16_t CS, const float RS, const uint16_t pinMOSI, const uint16_t pinMISO, const uint16_t pinSCK, const uint8_t axis_chain_index) : TMCMarlin(const uint16_t CS, const float RS, const uint16_t pinMOSI, const uint16_t pinMISO, const uint16_t pinSCK, const uint8_t axis_chain_index) :
TMC(CS, RS, pinMOSI, pinMISO, pinSCK, axis_chain_index) TMC(CS, RS, pinMOSI, pinMISO, pinSCK, axis_chain_index)
{} {}
inline uint16_t rms_current() { return TMC::rms_current(); } uint16_t rms_current() { return TMC::rms_current(); }
inline void rms_current(uint16_t mA) { void rms_current(uint16_t mA) {
this->val_mA = mA; this->val_mA = mA;
TMC::rms_current(mA); TMC::rms_current(mA);
} }
inline void rms_current(const uint16_t mA, const float mult) { void rms_current(const uint16_t mA, const float mult) {
this->val_mA = mA; this->val_mA = mA;
TMC::rms_current(mA, mult); TMC::rms_current(mA, mult);
} }
inline uint16_t get_microstep_counter() { return TMC::MSCNT(); } uint16_t get_microstep_counter() { return TMC::MSCNT(); }
#if HAS_STEALTHCHOP #if HAS_STEALTHCHOP
inline bool get_stealthChop() { return this->en_pwm_mode(); } bool get_stealthChop() { return this->en_pwm_mode(); }
inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; }
inline void refresh_stepping_mode() { this->en_pwm_mode(this->stored.stealthChop_enabled); } void refresh_stepping_mode() { this->en_pwm_mode(this->stored.stealthChop_enabled); }
inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); } void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); }
inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); } bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
#endif #endif
void set_chopper_times(const chopper_timing_t &ct) {
TMC::toff(ct.toff);
TMC::hysteresis_end(ct.hend);
TMC::hysteresis_start(ct.hstrt);
}
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
uint32_t get_pwm_thrs() { uint32_t get_pwm_thrs() {
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
@ -121,7 +133,7 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
#endif #endif
#if USE_SENSORLESS #if USE_SENSORLESS
inline int16_t homing_threshold() { return TMC::sgt(); } int16_t homing_threshold() { return TMC::sgt(); }
void homing_threshold(int16_t sgt_val) { void homing_threshold(int16_t sgt_val) {
sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max); sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max);
TMC::sgt(sgt_val); TMC::sgt(sgt_val);
@ -133,13 +145,13 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
#endif #endif
#if HAS_LCD_MENU #if HAS_LCD_MENU
inline void refresh_stepper_current() { rms_current(this->val_mA); } void refresh_stepper_current() { rms_current(this->val_mA); }
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); }
#endif #endif
#if USE_SENSORLESS #if USE_SENSORLESS
inline void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); } void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); }
#endif #endif
#endif #endif
@ -161,24 +173,30 @@ class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
{} {}
uint16_t rms_current() { return TMC2208Stepper::rms_current(); } uint16_t rms_current() { return TMC2208Stepper::rms_current(); }
inline void rms_current(const uint16_t mA) { void rms_current(const uint16_t mA) {
this->val_mA = mA; this->val_mA = mA;
TMC2208Stepper::rms_current(mA); TMC2208Stepper::rms_current(mA);
} }
inline void rms_current(const uint16_t mA, const float mult) { void rms_current(const uint16_t mA, const float mult) {
this->val_mA = mA; this->val_mA = mA;
TMC2208Stepper::rms_current(mA, mult); TMC2208Stepper::rms_current(mA, mult);
} }
inline uint16_t get_microstep_counter() { return TMC2208Stepper::MSCNT(); } uint16_t get_microstep_counter() { return TMC2208Stepper::MSCNT(); }
#if HAS_STEALTHCHOP #if HAS_STEALTHCHOP
inline bool get_stealthChop() { return !this->en_spreadCycle(); } bool get_stealthChop() { return !this->en_spreadCycle(); }
inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; }
inline void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); } void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); }
inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); } void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); }
inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); } bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
#endif #endif
void set_chopper_times(const chopper_timing_t &ct) {
TMC2208Stepper::toff(ct.toff);
TMC2208Stepper::hysteresis_end(ct.hend);
TMC2208Stepper::hysteresis_start(ct.hstrt);
}
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
uint32_t get_pwm_thrs() { uint32_t get_pwm_thrs() {
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
@ -190,10 +208,10 @@ class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
#endif #endif
#if HAS_LCD_MENU #if HAS_LCD_MENU
inline void refresh_stepper_current() { rms_current(this->val_mA); } void refresh_stepper_current() { rms_current(this->val_mA); }
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); }
#endif #endif
#endif #endif
}; };
@ -209,24 +227,30 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
{} {}
uint8_t get_address() { return slave_address; } uint8_t get_address() { return slave_address; }
uint16_t rms_current() { return TMC2209Stepper::rms_current(); } uint16_t rms_current() { return TMC2209Stepper::rms_current(); }
inline void rms_current(const uint16_t mA) { void rms_current(const uint16_t mA) {
this->val_mA = mA; this->val_mA = mA;
TMC2209Stepper::rms_current(mA); TMC2209Stepper::rms_current(mA);
} }
inline void rms_current(const uint16_t mA, const float mult) { void rms_current(const uint16_t mA, const float mult) {
this->val_mA = mA; this->val_mA = mA;
TMC2209Stepper::rms_current(mA, mult); TMC2209Stepper::rms_current(mA, mult);
} }
inline uint16_t get_microstep_counter() { return TMC2209Stepper::MSCNT(); } uint16_t get_microstep_counter() { return TMC2209Stepper::MSCNT(); }
#if HAS_STEALTHCHOP #if HAS_STEALTHCHOP
inline bool get_stealthChop() { return !this->en_spreadCycle(); } bool get_stealthChop() { return !this->en_spreadCycle(); }
inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; } bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; }
inline void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); } void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); }
inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); } void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); }
inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); } bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
#endif #endif
void set_chopper_times(const chopper_timing_t &ct) {
TMC2209Stepper::toff(ct.toff);
TMC2209Stepper::hysteresis_end(ct.hend);
TMC2209Stepper::hysteresis_start(ct.hstrt);
}
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
uint32_t get_pwm_thrs() { uint32_t get_pwm_thrs() {
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
@ -237,7 +261,7 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
} }
#endif #endif
#if USE_SENSORLESS #if USE_SENSORLESS
inline int16_t homing_threshold() { return TMC2209Stepper::SGTHRS(); } int16_t homing_threshold() { return TMC2209Stepper::SGTHRS(); }
void homing_threshold(int16_t sgt_val) { void homing_threshold(int16_t sgt_val) {
sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max); sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max);
TMC2209Stepper::SGTHRS(sgt_val); TMC2209Stepper::SGTHRS(sgt_val);
@ -246,13 +270,13 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
#endif #endif
#if HAS_LCD_MENU #if HAS_LCD_MENU
inline void refresh_stepper_current() { rms_current(this->val_mA); } void refresh_stepper_current() { rms_current(this->val_mA); }
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); }
#endif #endif
#if USE_SENSORLESS #if USE_SENSORLESS
inline void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); } void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); }
#endif #endif
#endif #endif
@ -269,15 +293,21 @@ class TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC266
TMCMarlin(const uint16_t CS, const float RS, const uint16_t pinMOSI, const uint16_t pinMISO, const uint16_t pinSCK, const uint8_t) : TMCMarlin(const uint16_t CS, const float RS, const uint16_t pinMOSI, const uint16_t pinMISO, const uint16_t pinSCK, const uint8_t) :
TMC2660Stepper(CS, RS, pinMOSI, pinMISO, pinSCK) TMC2660Stepper(CS, RS, pinMOSI, pinMISO, pinSCK)
{} {}
inline uint16_t rms_current() { return TMC2660Stepper::rms_current(); } uint16_t rms_current() { return TMC2660Stepper::rms_current(); }
inline void rms_current(const uint16_t mA) { void rms_current(const uint16_t mA) {
this->val_mA = mA; this->val_mA = mA;
TMC2660Stepper::rms_current(mA); TMC2660Stepper::rms_current(mA);
} }
inline uint16_t get_microstep_counter() { return TMC2660Stepper::mstep(); } uint16_t get_microstep_counter() { return TMC2660Stepper::mstep(); }
void set_chopper_times(const chopper_timing_t &ct) {
TMC2660Stepper::toff(ct.toff);
TMC2660Stepper::hysteresis_end(ct.hend);
TMC2660Stepper::hysteresis_start(ct.hstrt);
}
#if USE_SENSORLESS #if USE_SENSORLESS
inline int16_t homing_threshold() { return TMC2660Stepper::sgt(); } int16_t homing_threshold() { return TMC2660Stepper::sgt(); }
void homing_threshold(int16_t sgt_val) { void homing_threshold(int16_t sgt_val) {
sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max); sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max);
TMC2660Stepper::sgt(sgt_val); TMC2660Stepper::sgt(sgt_val);
@ -286,10 +316,10 @@ class TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC266
#endif #endif
#if HAS_LCD_MENU #if HAS_LCD_MENU
inline void refresh_stepper_current() { rms_current(this->val_mA); } void refresh_stepper_current() { rms_current(this->val_mA); }
#if USE_SENSORLESS #if USE_SENSORLESS
inline void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); } void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); }
#endif #endif
#endif #endif
@ -297,43 +327,6 @@ class TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC266
sgt_max = 63; sgt_max = 63;
}; };
template<typename TMC>
void tmc_print_current(TMC &st) {
st.printLabel();
SERIAL_ECHOLNPGM(" driver current: ", st.getMilliamps());
}
#if ENABLED(MONITOR_DRIVER_STATUS)
template<typename TMC>
void tmc_report_otpw(TMC &st) {
st.printLabel();
SERIAL_ECHOPGM(" temperature prewarn triggered: ");
serialprint_truefalse(st.getOTPW());
SERIAL_EOL();
}
template<typename TMC>
void tmc_clear_otpw(TMC &st) {
st.clear_otpw();
st.printLabel();
SERIAL_ECHOLNPGM(" prewarn flag cleared");
}
#endif
#if ENABLED(HYBRID_THRESHOLD)
template<typename TMC>
void tmc_print_pwmthrs(TMC &st) {
st.printLabel();
SERIAL_ECHOLNPGM(" stealthChop max speed: ", st.get_pwm_thrs());
}
#endif
#if USE_SENSORLESS
template<typename TMC>
void tmc_print_sgt(TMC &st) {
st.printLabel();
SERIAL_ECHOPGM(" homing sensitivity: ");
SERIAL_PRINTLN(st.homing_threshold(), PrintBase::Dec);
}
#endif
void monitor_tmc_drivers(); void monitor_tmc_drivers();
void test_tmc_connection(LOGICAL_AXIS_DECL(const bool, true)); void test_tmc_connection(LOGICAL_AXIS_DECL(const bool, true));

8
Marlin/src/feature/twibus.h

@ -244,11 +244,11 @@ class TWIBus {
static void debug(FSTR_P const func, char c); static void debug(FSTR_P const func, char c);
static void debug(FSTR_P const func, char adr[]); static void debug(FSTR_P const func, char adr[]);
#else #else
static inline void debug(FSTR_P const, uint32_t) {} static void debug(FSTR_P const, uint32_t) {}
static inline void debug(FSTR_P const, char) {} static void debug(FSTR_P const, char) {}
static inline void debug(FSTR_P const, char[]) {} static void debug(FSTR_P const, char[]) {}
#endif #endif
static inline void debug(FSTR_P const func, uint8_t v) { debug(func, (uint32_t)v); } static void debug(FSTR_P const func, uint8_t v) { debug(func, (uint32_t)v); }
}; };
extern TWIBus i2c; extern TWIBus i2c;

12
Marlin/src/gcode/calibrate/G28.cpp

@ -441,15 +441,9 @@ void GcodeSuite::G28() {
} }
#endif #endif
#if LINEAR_AXES >= 4 TERN_(HAS_I_AXIS, if (doI) homeaxis(I_AXIS));
if (doI) homeaxis(I_AXIS); TERN_(HAS_J_AXIS, if (doJ) homeaxis(J_AXIS));
#endif TERN_(HAS_K_AXIS, if (doK) homeaxis(K_AXIS));
#if LINEAR_AXES >= 5
if (doJ) homeaxis(J_AXIS);
#endif
#if LINEAR_AXES >= 6
if (doK) homeaxis(K_AXIS);
#endif
sync_plan_position(); sync_plan_position();

8
Marlin/src/gcode/calibrate/G34.cpp

@ -114,10 +114,6 @@ void GcodeSuite::G34() {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Final Z Move"); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Final Z Move");
do_blocking_move_to_z(zgrind, MMM_TO_MMS(GANTRY_CALIBRATION_FEEDRATE)); do_blocking_move_to_z(zgrind, MMM_TO_MMS(GANTRY_CALIBRATION_FEEDRATE));
// Back off end plate, back to normal motion range
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Backoff");
do_blocking_move_to_z(zpounce, MMM_TO_MMS(GANTRY_CALIBRATION_FEEDRATE));
#if _REDUCE_CURRENT #if _REDUCE_CURRENT
// Reset current to original values // Reset current to original values
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Restore Current"); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Restore Current");
@ -146,6 +142,10 @@ void GcodeSuite::G34() {
#endif #endif
#endif #endif
// Back off end plate, back to normal motion range
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z Backoff");
do_blocking_move_to_z(zpounce, MMM_TO_MMS(GANTRY_CALIBRATION_FEEDRATE));
#ifdef GANTRY_CALIBRATION_COMMANDS_POST #ifdef GANTRY_CALIBRATION_COMMANDS_POST
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Running Post Commands"); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Running Post Commands");
process_subcommands_now(F(GANTRY_CALIBRATION_COMMANDS_POST)); process_subcommands_now(F(GANTRY_CALIBRATION_COMMANDS_POST));

30
Marlin/src/gcode/calibrate/G425.cpp

@ -73,16 +73,16 @@
#if BOTH(CALIBRATION_MEASURE_LEFT, CALIBRATION_MEASURE_RIGHT) #if BOTH(CALIBRATION_MEASURE_LEFT, CALIBRATION_MEASURE_RIGHT)
#define HAS_X_CENTER 1 #define HAS_X_CENTER 1
#endif #endif
#if HAS_Y_AXIS && BOTH(CALIBRATION_MEASURE_FRONT, CALIBRATION_MEASURE_BACK) #if ALL(HAS_Y_AXIS, CALIBRATION_MEASURE_FRONT, CALIBRATION_MEASURE_BACK)
#define HAS_Y_CENTER 1 #define HAS_Y_CENTER 1
#endif #endif
#if LINEAR_AXES >= 4 && BOTH(CALIBRATION_MEASURE_IMIN, CALIBRATION_MEASURE_IMAX) #if ALL(HAS_I_AXIS, CALIBRATION_MEASURE_IMIN, CALIBRATION_MEASURE_IMAX)
#define HAS_I_CENTER 1 #define HAS_I_CENTER 1
#endif #endif
#if LINEAR_AXES >= 5 && BOTH(CALIBRATION_MEASURE_JMIN, CALIBRATION_MEASURE_JMAX) #if ALL(HAS_J_AXIS, CALIBRATION_MEASURE_JMIN, CALIBRATION_MEASURE_JMAX)
#define HAS_J_CENTER 1 #define HAS_J_CENTER 1
#endif #endif
#if LINEAR_AXES >= 6 && BOTH(CALIBRATION_MEASURE_KMIN, CALIBRATION_MEASURE_KMAX) #if ALL(HAS_K_AXIS, CALIBRATION_MEASURE_KMIN, CALIBRATION_MEASURE_KMAX)
#define HAS_K_CENTER 1 #define HAS_K_CENTER 1
#endif #endif
@ -246,7 +246,7 @@ inline void probe_side(measurements_t &m, const float uncertainty, const side_t
case RIGHT: dir = -1; case RIGHT: dir = -1;
case LEFT: axis = X_AXIS; break; case LEFT: axis = X_AXIS; break;
#endif #endif
#if LINEAR_AXES >= 2 && AXIS_CAN_CALIBRATE(Y) #if HAS_Y_AXIS && AXIS_CAN_CALIBRATE(Y)
case BACK: dir = -1; case BACK: dir = -1;
case FRONT: axis = Y_AXIS; break; case FRONT: axis = Y_AXIS; break;
#endif #endif
@ -258,15 +258,15 @@ inline void probe_side(measurements_t &m, const float uncertainty, const side_t
return; return;
} }
#endif #endif
#if LINEAR_AXES >= 4 && AXIS_CAN_CALIBRATE(I) #if HAS_I_AXIS && AXIS_CAN_CALIBRATE(I)
case IMINIMUM: dir = -1; case IMINIMUM: dir = -1;
case IMAXIMUM: axis = I_AXIS; break; case IMAXIMUM: axis = I_AXIS; break;
#endif #endif
#if LINEAR_AXES >= 5 && AXIS_CAN_CALIBRATE(J) #if HAS_J_AXIS && AXIS_CAN_CALIBRATE(J)
case JMINIMUM: dir = -1; case JMINIMUM: dir = -1;
case JMAXIMUM: axis = J_AXIS; break; case JMAXIMUM: axis = J_AXIS; break;
#endif #endif
#if LINEAR_AXES >= 6 && AXIS_CAN_CALIBRATE(K) #if HAS_K_AXIS && AXIS_CAN_CALIBRATE(K)
case KMINIMUM: dir = -1; case KMINIMUM: dir = -1;
case KMAXIMUM: axis = K_AXIS; break; case KMAXIMUM: axis = K_AXIS; break;
#endif #endif
@ -370,7 +370,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) {
SERIAL_ECHOLNPGM(" Back: ", m.obj_side[BACK]); SERIAL_ECHOLNPGM(" Back: ", m.obj_side[BACK]);
#endif #endif
#endif #endif
#if LINEAR_AXES >= 4 #if HAS_I_AXIS
#if ENABLED(CALIBRATION_MEASURE_IMIN) #if ENABLED(CALIBRATION_MEASURE_IMIN)
SERIAL_ECHOLNPGM(" " STR_I_MIN ": ", m.obj_side[IMINIMUM]); SERIAL_ECHOLNPGM(" " STR_I_MIN ": ", m.obj_side[IMINIMUM]);
#endif #endif
@ -378,7 +378,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) {
SERIAL_ECHOLNPGM(" " STR_I_MAX ": ", m.obj_side[IMAXIMUM]); SERIAL_ECHOLNPGM(" " STR_I_MAX ": ", m.obj_side[IMAXIMUM]);
#endif #endif
#endif #endif
#if LINEAR_AXES >= 5 #if HAS_J_AXIS
#if ENABLED(CALIBRATION_MEASURE_JMIN) #if ENABLED(CALIBRATION_MEASURE_JMIN)
SERIAL_ECHOLNPGM(" " STR_J_MIN ": ", m.obj_side[JMINIMUM]); SERIAL_ECHOLNPGM(" " STR_J_MIN ": ", m.obj_side[JMINIMUM]);
#endif #endif
@ -386,7 +386,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) {
SERIAL_ECHOLNPGM(" " STR_J_MAX ": ", m.obj_side[JMAXIMUM]); SERIAL_ECHOLNPGM(" " STR_J_MAX ": ", m.obj_side[JMAXIMUM]);
#endif #endif
#endif #endif
#if LINEAR_AXES >= 6 #if HAS_K_AXIS
#if ENABLED(CALIBRATION_MEASURE_KMIN) #if ENABLED(CALIBRATION_MEASURE_KMIN)
SERIAL_ECHOLNPGM(" " STR_K_MIN ": ", m.obj_side[KMINIMUM]); SERIAL_ECHOLNPGM(" " STR_K_MIN ": ", m.obj_side[KMINIMUM]);
#endif #endif
@ -439,7 +439,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) {
#if HAS_Z_AXIS && AXIS_CAN_CALIBRATE(Z) #if HAS_Z_AXIS && AXIS_CAN_CALIBRATE(Z)
SERIAL_ECHOLNPGM(" Top: ", m.backlash[TOP]); SERIAL_ECHOLNPGM(" Top: ", m.backlash[TOP]);
#endif #endif
#if LINEAR_AXES >= 4 && AXIS_CAN_CALIBRATE(I) #if HAS_I_AXIS && AXIS_CAN_CALIBRATE(I)
#if ENABLED(CALIBRATION_MEASURE_IMIN) #if ENABLED(CALIBRATION_MEASURE_IMIN)
SERIAL_ECHOLNPGM(" " STR_I_MIN ": ", m.backlash[IMINIMUM]); SERIAL_ECHOLNPGM(" " STR_I_MIN ": ", m.backlash[IMINIMUM]);
#endif #endif
@ -447,7 +447,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) {
SERIAL_ECHOLNPGM(" " STR_I_MAX ": ", m.backlash[IMAXIMUM]); SERIAL_ECHOLNPGM(" " STR_I_MAX ": ", m.backlash[IMAXIMUM]);
#endif #endif
#endif #endif
#if LINEAR_AXES >= 5 && AXIS_CAN_CALIBRATE(J) #if HAS_J_AXIS && AXIS_CAN_CALIBRATE(J)
#if ENABLED(CALIBRATION_MEASURE_JMIN) #if ENABLED(CALIBRATION_MEASURE_JMIN)
SERIAL_ECHOLNPGM(" " STR_J_MIN ": ", m.backlash[JMINIMUM]); SERIAL_ECHOLNPGM(" " STR_J_MIN ": ", m.backlash[JMINIMUM]);
#endif #endif
@ -455,7 +455,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) {
SERIAL_ECHOLNPGM(" " STR_J_MAX ": ", m.backlash[JMAXIMUM]); SERIAL_ECHOLNPGM(" " STR_J_MAX ": ", m.backlash[JMAXIMUM]);
#endif #endif
#endif #endif
#if LINEAR_AXES >= 6 && AXIS_CAN_CALIBRATE(K) #if HAS_K_AXIS && AXIS_CAN_CALIBRATE(K)
#if ENABLED(CALIBRATION_MEASURE_KMIN) #if ENABLED(CALIBRATION_MEASURE_KMIN)
SERIAL_ECHOLNPGM(" " STR_K_MIN ": ", m.backlash[KMINIMUM]); SERIAL_ECHOLNPGM(" " STR_K_MIN ": ", m.backlash[KMINIMUM]);
#endif #endif
@ -666,7 +666,7 @@ inline void calibrate_all_toolheads(measurements_t &m, const float uncertainty)
* 1) For each nozzle, touch top and sides of object to determine object position and * 1) For each nozzle, touch top and sides of object to determine object position and
* nozzle offsets. Do a fast but rough search over a wider area. * nozzle offsets. Do a fast but rough search over a wider area.
* 2) With the first nozzle, touch top and sides of object to determine backlash values * 2) With the first nozzle, touch top and sides of object to determine backlash values
* for all axis (if BACKLASH_GCODE is enabled) * for all axes (if BACKLASH_GCODE is enabled)
* 3) For each nozzle, touch top and sides of object slowly to determine precise * 3) For each nozzle, touch top and sides of object slowly to determine precise
* position of object. Adjust coordinate system and nozzle offsets so probed object * position of object. Adjust coordinate system and nozzle offsets so probed object
* location corresponds to known object location with a high degree of precision. * location corresponds to known object location with a high degree of precision.

2
Marlin/src/gcode/config/M200-M205.cpp

@ -253,7 +253,7 @@ void GcodeSuite::M205() {
if (parser.seenval('S')) planner.settings.min_feedrate_mm_s = parser.value_linear_units(); if (parser.seenval('S')) planner.settings.min_feedrate_mm_s = parser.value_linear_units();
if (parser.seenval('T')) planner.settings.min_travel_feedrate_mm_s = parser.value_linear_units(); if (parser.seenval('T')) planner.settings.min_travel_feedrate_mm_s = parser.value_linear_units();
#if HAS_JUNCTION_DEVIATION #if HAS_JUNCTION_DEVIATION
#if HAS_CLASSIC_JERK && (AXIS4_NAME == 'J' || AXIS5_NAME == 'J' || AXIS6_NAME == 'J') #if HAS_CLASSIC_JERK && AXIS_COLLISION('J')
#error "Can't set_max_jerk for 'J' axis because 'J' is used for Junction Deviation." #error "Can't set_max_jerk for 'J' axis because 'J' is used for Junction Deviation."
#endif #endif
if (parser.seenval('J')) { if (parser.seenval('J')) {

68
Marlin/src/gcode/feature/L6470/M906.cpp

@ -24,6 +24,10 @@
#if HAS_L64XX #if HAS_L64XX
#if AXIS_COLLISION('I')
#error "M906 parameter collision with axis name."
#endif
#include "../../gcode.h" #include "../../gcode.h"
#include "../../../libs/L64XX/L64XX_Marlin.h" #include "../../../libs/L64XX/L64XX_Marlin.h"
#include "../../../module/stepper/indirection.h" #include "../../../module/stepper/indirection.h"
@ -202,12 +206,11 @@ void L64XX_report_current(L64XX &motor, const L64XX_axis_t axis) {
* On L6474 this sets the TVAL register (same address). * On L6474 this sets the TVAL register (same address).
* *
* I - select which driver(s) to change on multi-driver axis * I - select which driver(s) to change on multi-driver axis
* 0 - (default) all drivers on the axis or E0 * (default) all drivers on the axis
* 1 - monitor only X, Y, Z or E1 * 0 - monitor only the first XYZ... driver
* 2 - monitor only X2, Y2, Z2 or E2 * 1 - monitor only X2, Y2, Z2
* 3 - monitor only Z3 or E3 * 2 - monitor only Z3
* 4 - monitor only Z4 or E4 * 3 - monitor only Z4
* 5 - monitor only E5
* Xxxx, Yxxx, Zxxx, Exxx - axis to change (optional) * Xxxx, Yxxx, Zxxx, Exxx - axis to change (optional)
* L6474 - current in mA (4A max) * L6474 - current in mA (4A max)
* All others - 0-255 * All others - 0-255
@ -227,8 +230,10 @@ void GcodeSuite::M906() {
uint8_t report_current = true; uint8_t report_current = true;
#if HAS_L64XX #if AXIS_IS_L64XX(X2) || AXIS_IS_L64XX(Y2) || AXIS_IS_L64XX(Z2) || AXIS_IS_L64XX(Z3) || AXIS_IS_L64XX(Z4)
const uint8_t index = parser.byteval('I'); const int8_t index = parser.byteval('I', -1);
#else
constexpr int8_t index = -1;
#endif #endif
LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(axis_codes[i])) { LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(axis_codes[i])) {
@ -241,73 +246,72 @@ void GcodeSuite::M906() {
} }
switch (i) { switch (i) {
#if AXIS_IS_L64XX(X) || AXIS_IS_L64XX(X2)
case X_AXIS: case X_AXIS:
#if AXIS_IS_L64XX(X) #if AXIS_IS_L64XX(X)
if (index == 0) L6470_SET_KVAL_HOLD(X); if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(X);
#endif #endif
#if AXIS_IS_L64XX(X2) #if AXIS_IS_L64XX(X2)
if (index == 1) L6470_SET_KVAL_HOLD(X2); if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(X2);
#endif #endif
break; break;
#endif
#if HAS_Y_AXIS #if AXIS_IS_L64XX(Y) || AXIS_IS_L64XX(Y2)
case Y_AXIS: case Y_AXIS:
#if AXIS_IS_L64XX(Y) #if AXIS_IS_L64XX(Y)
if (index == 0) L6470_SET_KVAL_HOLD(Y); if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(Y);
#endif #endif
#if AXIS_IS_L64XX(Y2) #if AXIS_IS_L64XX(Y2)
if (index == 1) L6470_SET_KVAL_HOLD(Y2); if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(Y2);
#endif #endif
break; break;
#endif #endif
#if HAS_Z_AXIS #if AXIS_IS_L64XX(Z) || AXIS_IS_L64XX(Z2) || AXIS_IS_L64XX(Z3) || AXIS_IS_L64XX(Z4)
case Z_AXIS: case Z_AXIS:
#if AXIS_IS_L64XX(Z) #if AXIS_IS_L64XX(Z)
if (index == 0) L6470_SET_KVAL_HOLD(Z); if (index < 0 || index == 0) L6470_SET_KVAL_HOLD(Z);
#endif #endif
#if AXIS_IS_L64XX(Z2) #if AXIS_IS_L64XX(Z2)
if (index == 1) L6470_SET_KVAL_HOLD(Z2); if (index < 0 || index == 1) L6470_SET_KVAL_HOLD(Z2);
#endif #endif
#if AXIS_IS_L64XX(Z3) #if AXIS_IS_L64XX(Z3)
if (index == 2) L6470_SET_KVAL_HOLD(Z3); if (index < 0 || index == 2) L6470_SET_KVAL_HOLD(Z3);
#endif #endif
#if AXIS_DRIVER_TYPE_Z4(L6470) #if AXIS_IS_L64XX(Z4)
if (index == 3) L6470_SET_KVAL_HOLD(Z4); if (index < 0 || index == 3) L6470_SET_KVAL_HOLD(Z4);
#endif #endif
break; break;
#endif #endif
#if E_STEPPERS #if AXIS_IS_L64XX(E0) || AXIS_IS_L64XX(E1) || AXIS_IS_L64XX(E2) || AXIS_IS_L64XX(E3) || AXIS_IS_L64XX(E4) || AXIS_IS_L64XX(E5) || AXIS_IS_L64XX(E6) || AXIS_IS_L64XX(E7)
case E_AXIS: { case E_AXIS: {
const int8_t target_e_stepper = get_target_e_stepper_from_command(0); const int8_t eindex = get_target_e_stepper_from_command(-2);
if (target_e_stepper < 0) return;
switch (target_e_stepper) {
#if AXIS_IS_L64XX(E0) #if AXIS_IS_L64XX(E0)
case 0: L6470_SET_KVAL_HOLD(E0); break; if (eindex < 0 || eindex == 0) L6470_SET_KVAL_HOLD(E0);
#endif #endif
#if AXIS_IS_L64XX(E1) #if AXIS_IS_L64XX(E1)
case 1: L6470_SET_KVAL_HOLD(E1); break; if (eindex < 0 || eindex == 1) L6470_SET_KVAL_HOLD(E1);
#endif #endif
#if AXIS_IS_L64XX(E2) #if AXIS_IS_L64XX(E2)
case 2: L6470_SET_KVAL_HOLD(E2); break; if (eindex < 0 || eindex == 2) L6470_SET_KVAL_HOLD(E2);
#endif #endif
#if AXIS_IS_L64XX(E3) #if AXIS_IS_L64XX(E3)
case 3: L6470_SET_KVAL_HOLD(E3); break; if (eindex < 0 || eindex == 3) L6470_SET_KVAL_HOLD(E3);
#endif #endif
#if AXIS_IS_L64XX(E4) #if AXIS_IS_L64XX(E4)
case 4: L6470_SET_KVAL_HOLD(E4); break; if (eindex < 0 || eindex == 4) L6470_SET_KVAL_HOLD(E4);
#endif #endif
#if AXIS_IS_L64XX(E5) #if AXIS_IS_L64XX(E5)
case 5: L6470_SET_KVAL_HOLD(E5); break; if (eindex < 0 || eindex == 5) L6470_SET_KVAL_HOLD(E5);
#endif #endif
#if AXIS_IS_L64XX(E6) #if AXIS_IS_L64XX(E6)
case 6: L6470_SET_KVAL_HOLD(E6); break; if (eindex < 0 || eindex == 6) L6470_SET_KVAL_HOLD(E6);
#endif #endif
#if AXIS_IS_L64XX(E7) #if AXIS_IS_L64XX(E7)
case 7: L6470_SET_KVAL_HOLD(E7); break; if (eindex < 0 || eindex == 7) L6470_SET_KVAL_HOLD(E7);
#endif #endif
}
} break; } break;
#endif #endif
} }

0
Marlin/src/gcode/feature/L6470/M916-918.cpp → Marlin/src/gcode/feature/L6470/M916-M918.cpp

6
Marlin/src/gcode/feature/pause/M600.cpp

@ -67,13 +67,13 @@
void GcodeSuite::M600() { void GcodeSuite::M600() {
#if ENABLED(MIXING_EXTRUDER) #if ENABLED(MIXING_EXTRUDER)
const int8_t target_e_stepper = get_target_e_stepper_from_command(); const int8_t eindex = get_target_e_stepper_from_command();
if (target_e_stepper < 0) return; if (eindex < 0) return;
const uint8_t old_mixing_tool = mixer.get_current_vtool(); const uint8_t old_mixing_tool = mixer.get_current_vtool();
mixer.T(MIXER_DIRECT_SET_TOOL); mixer.T(MIXER_DIRECT_SET_TOOL);
MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(target_e_stepper) ? 1.0 : 0.0); MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(eindex) ? 1.0 : 0.0);
mixer.normalize(); mixer.normalize();
const int8_t target_extruder = active_extruder; const int8_t target_extruder = active_extruder;

12
Marlin/src/gcode/feature/pause/M701_M702.cpp

@ -60,13 +60,13 @@ void GcodeSuite::M701() {
if (TERN0(NO_MOTION_BEFORE_HOMING, axes_should_home())) park_point.z = 0; if (TERN0(NO_MOTION_BEFORE_HOMING, axes_should_home())) park_point.z = 0;
#if ENABLED(MIXING_EXTRUDER) #if ENABLED(MIXING_EXTRUDER)
const int8_t target_e_stepper = get_target_e_stepper_from_command(); const int8_t eindex = get_target_e_stepper_from_command();
if (target_e_stepper < 0) return; if (eindex < 0) return;
const uint8_t old_mixing_tool = mixer.get_current_vtool(); const uint8_t old_mixing_tool = mixer.get_current_vtool();
mixer.T(MIXER_DIRECT_SET_TOOL); mixer.T(MIXER_DIRECT_SET_TOOL);
MIXER_STEPPER_LOOP(i) mixer.set_collector(i, (i == (uint8_t)target_e_stepper) ? 1.0 : 0.0); MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(eindex) ? 1.0 : 0.0);
mixer.normalize(); mixer.normalize();
const int8_t target_extruder = active_extruder; const int8_t target_extruder = active_extruder;
@ -165,10 +165,10 @@ void GcodeSuite::M702() {
#endif #endif
if (seenT) { if (seenT) {
const int8_t target_e_stepper = get_target_e_stepper_from_command(); const int8_t eindex = get_target_e_stepper_from_command();
if (target_e_stepper < 0) return; if (eindex < 0) return;
mixer.T(MIXER_DIRECT_SET_TOOL); mixer.T(MIXER_DIRECT_SET_TOOL);
MIXER_STEPPER_LOOP(i) mixer.set_collector(i, (i == (uint8_t)target_e_stepper) ? 1.0 : 0.0); MIXER_STEPPER_LOOP(i) mixer.set_collector(i, i == uint8_t(eindex) ? 1.0 : 0.0);
mixer.normalize(); mixer.normalize();
} }

4
Marlin/src/gcode/feature/power_monitor/M430.cpp

@ -53,9 +53,7 @@ void GcodeSuite::M430() {
SERIAL_ECHOLNPGM( SERIAL_ECHOLNPGM(
#if ENABLED(POWER_MONITOR_CURRENT) #if ENABLED(POWER_MONITOR_CURRENT)
"Current: ", power_monitor.getAmps(), "A" "Current: ", power_monitor.getAmps(), "A"
#if ENABLED(POWER_MONITOR_VOLTAGE) TERN_(POWER_MONITOR_VOLTAGE, " ")
" "
#endif
#endif #endif
#if ENABLED(POWER_MONITOR_VOLTAGE) #if ENABLED(POWER_MONITOR_VOLTAGE)
"Voltage: ", power_monitor.getVolts(), "V" "Voltage: ", power_monitor.getVolts(), "V"

51
Marlin/src/gcode/feature/trinamic/M569.cpp

@ -24,6 +24,10 @@
#if HAS_STEALTHCHOP #if HAS_STEALTHCHOP
#if AXIS_COLLISION('I')
#error "M569 parameter collision with axis name."
#endif
#include "../../gcode.h" #include "../../gcode.h"
#include "../../../feature/tmc_util.h" #include "../../../feature/tmc_util.h"
#include "../../../module/stepper/indirection.h" #include "../../../module/stepper/indirection.h"
@ -40,35 +44,35 @@ void tmc_set_stealthChop(TMC &st, const bool enable) {
st.refresh_stepping_mode(); st.refresh_stepping_mode();
} }
static void set_stealth_status(const bool enable, const int8_t target_e_stepper) { static void set_stealth_status(const bool enable, const int8_t eindex) {
#define TMC_SET_STEALTH(Q) tmc_set_stealthChop(stepper##Q, enable) #define TMC_SET_STEALTH(Q) tmc_set_stealthChop(stepper##Q, enable)
#if X_HAS_STEALTHCHOP || Y_HAS_STEALTHCHOP || Z_HAS_STEALTHCHOP \ #if X2_HAS_STEALTHCHOP || Y2_HAS_STEALTHCHOP || Z2_HAS_STEALTHCHOP || Z3_HAS_STEALTHCHOP || Z4_HAS_STEALTHCHOP
|| I_HAS_STEALTHCHOP || J_HAS_STEALTHCHOP || K_HAS_STEALTHCHOP \ const int8_t index = parser.byteval('I', -1);
|| X2_HAS_STEALTHCHOP || Y2_HAS_STEALTHCHOP || Z2_HAS_STEALTHCHOP || Z3_HAS_STEALTHCHOP || Z4_HAS_STEALTHCHOP #else
const uint8_t index = parser.byteval('I'); constexpr int8_t index = -1;
#endif #endif
LOOP_LOGICAL_AXES(i) if (parser.seen(axis_codes[i])) { LOOP_LOGICAL_AXES(i) if (parser.seen(axis_codes[i])) {
switch (i) { switch (i) {
case X_AXIS: case X_AXIS:
TERN_(X_HAS_STEALTHCHOP, if (index == 0) TMC_SET_STEALTH(X)); TERN_(X_HAS_STEALTHCHOP, if (index < 0 || index == 0) TMC_SET_STEALTH(X));
TERN_(X2_HAS_STEALTHCHOP, if (index == 1) TMC_SET_STEALTH(X2)); TERN_(X2_HAS_STEALTHCHOP, if (index < 0 || index == 1) TMC_SET_STEALTH(X2));
break; break;
#if HAS_Y_AXIS #if HAS_Y_AXIS
case Y_AXIS: case Y_AXIS:
TERN_(Y_HAS_STEALTHCHOP, if (index == 0) TMC_SET_STEALTH(Y)); TERN_(Y_HAS_STEALTHCHOP, if (index < 0 || index == 0) TMC_SET_STEALTH(Y));
TERN_(Y2_HAS_STEALTHCHOP, if (index == 1) TMC_SET_STEALTH(Y2)); TERN_(Y2_HAS_STEALTHCHOP, if (index < 0 || index == 1) TMC_SET_STEALTH(Y2));
break; break;
#endif #endif
#if HAS_Z_AXIS #if HAS_Z_AXIS
case Z_AXIS: case Z_AXIS:
TERN_(Z_HAS_STEALTHCHOP, if (index == 0) TMC_SET_STEALTH(Z)); TERN_(Z_HAS_STEALTHCHOP, if (index < 0 || index == 0) TMC_SET_STEALTH(Z));
TERN_(Z2_HAS_STEALTHCHOP, if (index == 1) TMC_SET_STEALTH(Z2)); TERN_(Z2_HAS_STEALTHCHOP, if (index < 0 || index == 1) TMC_SET_STEALTH(Z2));
TERN_(Z3_HAS_STEALTHCHOP, if (index == 2) TMC_SET_STEALTH(Z3)); TERN_(Z3_HAS_STEALTHCHOP, if (index < 0 || index == 2) TMC_SET_STEALTH(Z3));
TERN_(Z4_HAS_STEALTHCHOP, if (index == 3) TMC_SET_STEALTH(Z4)); TERN_(Z4_HAS_STEALTHCHOP, if (index < 0 || index == 3) TMC_SET_STEALTH(Z4));
break; break;
#endif #endif
@ -84,17 +88,14 @@ static void set_stealth_status(const bool enable, const int8_t target_e_stepper)
#if E_STEPPERS #if E_STEPPERS
case E_AXIS: { case E_AXIS: {
if (target_e_stepper < 0) return; TERN_(E0_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 0) TMC_SET_STEALTH(E0));
switch (target_e_stepper) { TERN_(E1_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 1) TMC_SET_STEALTH(E1));
TERN_(E0_HAS_STEALTHCHOP, case 0: TMC_SET_STEALTH(E0); break;) TERN_(E2_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 2) TMC_SET_STEALTH(E2));
TERN_(E1_HAS_STEALTHCHOP, case 1: TMC_SET_STEALTH(E1); break;) TERN_(E3_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 3) TMC_SET_STEALTH(E3));
TERN_(E2_HAS_STEALTHCHOP, case 2: TMC_SET_STEALTH(E2); break;) TERN_(E4_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 4) TMC_SET_STEALTH(E4));
TERN_(E3_HAS_STEALTHCHOP, case 3: TMC_SET_STEALTH(E3); break;) TERN_(E5_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 5) TMC_SET_STEALTH(E5));
TERN_(E4_HAS_STEALTHCHOP, case 4: TMC_SET_STEALTH(E4); break;) TERN_(E6_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 6) TMC_SET_STEALTH(E6));
TERN_(E5_HAS_STEALTHCHOP, case 5: TMC_SET_STEALTH(E5); break;) TERN_(E7_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 7) TMC_SET_STEALTH(E7));
TERN_(E6_HAS_STEALTHCHOP, case 6: TMC_SET_STEALTH(E6); break;)
TERN_(E7_HAS_STEALTHCHOP, case 7: TMC_SET_STEALTH(E7); break;)
}
} break; } break;
#endif #endif
} }
@ -133,7 +134,7 @@ static void say_stealth_status() {
*/ */
void GcodeSuite::M569() { void GcodeSuite::M569() {
if (parser.seen('S')) if (parser.seen('S'))
set_stealth_status(parser.value_bool(), get_target_e_stepper_from_command(0)); set_stealth_status(parser.value_bool(), get_target_e_stepper_from_command(-2));
else else
say_stealth_status(); say_stealth_status();
} }

57
Marlin/src/gcode/feature/trinamic/M906.cpp

@ -28,6 +28,12 @@
#include "../../../feature/tmc_util.h" #include "../../../feature/tmc_util.h"
#include "../../../module/stepper/indirection.h" #include "../../../module/stepper/indirection.h"
template<typename TMC>
static void tmc_print_current(TMC &st) {
st.printLabel();
SERIAL_ECHOLNPGM(" driver current: ", st.getMilliamps());
}
/** /**
* M906: Set motor current in milliamps. * M906: Set motor current in milliamps.
* *
@ -48,46 +54,50 @@ void GcodeSuite::M906() {
bool report = true; bool report = true;
#if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) || AXIS_IS_TMC(I) || AXIS_IS_TMC(J) || AXIS_IS_TMC(K) #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4)
const uint8_t index = parser.byteval('I'); const int8_t index = parser.byteval('I', -1);
#else
constexpr int8_t index = -1;
#endif #endif
LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(axis_codes[i])) { LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(axis_codes[i])) {
report = false; report = false;
switch (i) { switch (i) {
#if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2)
case X_AXIS: case X_AXIS:
#if AXIS_IS_TMC(X) #if AXIS_IS_TMC(X)
if (index == 0) TMC_SET_CURRENT(X); if (index < 0 || index == 0) TMC_SET_CURRENT(X);
#endif #endif
#if AXIS_IS_TMC(X2) #if AXIS_IS_TMC(X2)
if (index == 1) TMC_SET_CURRENT(X2); if (index < 0 || index == 1) TMC_SET_CURRENT(X2);
#endif #endif
break; break;
#endif
#if HAS_Y_AXIS #if AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2)
case Y_AXIS: case Y_AXIS:
#if AXIS_IS_TMC(Y) #if AXIS_IS_TMC(Y)
if (index == 0) TMC_SET_CURRENT(Y); if (index < 0 || index == 0) TMC_SET_CURRENT(Y);
#endif #endif
#if AXIS_IS_TMC(Y2) #if AXIS_IS_TMC(Y2)
if (index == 1) TMC_SET_CURRENT(Y2); if (index < 0 || index == 1) TMC_SET_CURRENT(Y2);
#endif #endif
break; break;
#endif #endif
#if HAS_Z_AXIS #if AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4)
case Z_AXIS: case Z_AXIS:
#if AXIS_IS_TMC(Z) #if AXIS_IS_TMC(Z)
if (index == 0) TMC_SET_CURRENT(Z); if (index < 0 || index == 0) TMC_SET_CURRENT(Z);
#endif #endif
#if AXIS_IS_TMC(Z2) #if AXIS_IS_TMC(Z2)
if (index == 1) TMC_SET_CURRENT(Z2); if (index < 0 || index == 1) TMC_SET_CURRENT(Z2);
#endif #endif
#if AXIS_IS_TMC(Z3) #if AXIS_IS_TMC(Z3)
if (index == 2) TMC_SET_CURRENT(Z3); if (index < 0 || index == 2) TMC_SET_CURRENT(Z3);
#endif #endif
#if AXIS_IS_TMC(Z4) #if AXIS_IS_TMC(Z4)
if (index == 3) TMC_SET_CURRENT(Z4); if (index < 0 || index == 3) TMC_SET_CURRENT(Z4);
#endif #endif
break; break;
#endif #endif
@ -102,36 +112,33 @@ void GcodeSuite::M906() {
case K_AXIS: TMC_SET_CURRENT(K); break; case K_AXIS: TMC_SET_CURRENT(K); break;
#endif #endif
#if E_STEPPERS #if AXIS_IS_TMC(E0) || AXIS_IS_TMC(E1) || AXIS_IS_TMC(E2) || AXIS_IS_TMC(E3) || AXIS_IS_TMC(E4) || AXIS_IS_TMC(E5) || AXIS_IS_TMC(E6) || AXIS_IS_TMC(E7)
case E_AXIS: { case E_AXIS: {
const int8_t target_e_stepper = get_target_e_stepper_from_command(0); const int8_t eindex = get_target_e_stepper_from_command(-2);
if (target_e_stepper < 0) return;
switch (target_e_stepper) {
#if AXIS_IS_TMC(E0) #if AXIS_IS_TMC(E0)
case 0: TMC_SET_CURRENT(E0); break; if (eindex < 0 || eindex == 0) TMC_SET_CURRENT(E0);
#endif #endif
#if AXIS_IS_TMC(E1) #if AXIS_IS_TMC(E1)
case 1: TMC_SET_CURRENT(E1); break; if (eindex < 0 || eindex == 1) TMC_SET_CURRENT(E1);
#endif #endif
#if AXIS_IS_TMC(E2) #if AXIS_IS_TMC(E2)
case 2: TMC_SET_CURRENT(E2); break; if (eindex < 0 || eindex == 2) TMC_SET_CURRENT(E2);
#endif #endif
#if AXIS_IS_TMC(E3) #if AXIS_IS_TMC(E3)
case 3: TMC_SET_CURRENT(E3); break; if (eindex < 0 || eindex == 3) TMC_SET_CURRENT(E3);
#endif #endif
#if AXIS_IS_TMC(E4) #if AXIS_IS_TMC(E4)
case 4: TMC_SET_CURRENT(E4); break; if (eindex < 0 || eindex == 4) TMC_SET_CURRENT(E4);
#endif #endif
#if AXIS_IS_TMC(E5) #if AXIS_IS_TMC(E5)
case 5: TMC_SET_CURRENT(E5); break; if (eindex < 0 || eindex == 5) TMC_SET_CURRENT(E5);
#endif #endif
#if AXIS_IS_TMC(E6) #if AXIS_IS_TMC(E6)
case 6: TMC_SET_CURRENT(E6); break; if (eindex < 0 || eindex == 6) TMC_SET_CURRENT(E6);
#endif #endif
#if AXIS_IS_TMC(E7) #if AXIS_IS_TMC(E7)
case 7: TMC_SET_CURRENT(E7); break; if (eindex < 0 || eindex == 7) TMC_SET_CURRENT(E7);
#endif #endif
}
} break; } break;
#endif #endif
} }

105
Marlin/src/gcode/feature/trinamic/M911-M914.cpp

@ -38,19 +38,19 @@
#if M91x_USE(X) || M91x_USE(X2) #if M91x_USE(X) || M91x_USE(X2)
#define M91x_SOME_X 1 #define M91x_SOME_X 1
#endif #endif
#if LINEAR_AXES >= 2 && (M91x_USE(Y) || M91x_USE(Y2)) #if HAS_Y_AXIS && (M91x_USE(Y) || M91x_USE(Y2))
#define M91x_SOME_Y 1 #define M91x_SOME_Y 1
#endif #endif
#if HAS_Z_AXIS && (M91x_USE(Z) || M91x_USE(Z2) || M91x_USE(Z3) || M91x_USE(Z4)) #if HAS_Z_AXIS && (M91x_USE(Z) || M91x_USE(Z2) || M91x_USE(Z3) || M91x_USE(Z4))
#define M91x_SOME_Z 1 #define M91x_SOME_Z 1
#endif #endif
#if LINEAR_AXES >= 4 && M91x_USE(I) #if HAS_I_AXIS && M91x_USE(I)
#define M91x_USE_I 1 #define M91x_USE_I 1
#endif #endif
#if LINEAR_AXES >= 5 && M91x_USE(J) #if HAS_J_AXIS && M91x_USE(J)
#define M91x_USE_J 1 #define M91x_USE_J 1
#endif #endif
#if LINEAR_AXES >= 6 && M91x_USE(K) #if HAS_K_AXIS && M91x_USE(K)
#define M91x_USE_K 1 #define M91x_USE_K 1
#endif #endif
@ -62,6 +62,21 @@
#error "MONITOR_DRIVER_STATUS requires at least one TMC2130, 2160, 2208, 2209, 2660, 5130, or 5160." #error "MONITOR_DRIVER_STATUS requires at least one TMC2130, 2160, 2208, 2209, 2660, 5130, or 5160."
#endif #endif
template<typename TMC>
static void tmc_report_otpw(TMC &st) {
st.printLabel();
SERIAL_ECHOPGM(" temperature prewarn triggered: ");
serialprint_truefalse(st.getOTPW());
SERIAL_EOL();
}
template<typename TMC>
static void tmc_clear_otpw(TMC &st) {
st.clear_otpw();
st.printLabel();
SERIAL_ECHOLNPGM(" prewarn flag cleared");
}
/** /**
* M911: Report TMC stepper driver overtemperature pre-warn flag * M911: Report TMC stepper driver overtemperature pre-warn flag
* This flag is held by the library, persisting until cleared by M912 * This flag is held by the library, persisting until cleared by M912
@ -223,11 +238,17 @@
#endif // MONITOR_DRIVER_STATUS #endif // MONITOR_DRIVER_STATUS
/**
* M913: Set HYBRID_THRESHOLD speed.
*/
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
template<typename TMC>
static void tmc_print_pwmthrs(TMC &st) {
st.printLabel();
SERIAL_ECHOLNPGM(" stealthChop max speed: ", st.get_pwm_thrs());
}
/**
* M913: Set HYBRID_THRESHOLD speed.
*/
void GcodeSuite::M913() { void GcodeSuite::M913() {
#define TMC_SAY_PWMTHRS(A,Q) tmc_print_pwmthrs(stepper##Q) #define TMC_SAY_PWMTHRS(A,Q) tmc_print_pwmthrs(stepper##Q)
#define TMC_SET_PWMTHRS(A,Q) stepper##Q.set_pwm_thrs(value) #define TMC_SET_PWMTHRS(A,Q) stepper##Q.set_pwm_thrs(value)
@ -235,20 +256,36 @@
#define TMC_SET_PWMTHRS_E(E) stepperE##E.set_pwm_thrs(value) #define TMC_SET_PWMTHRS_E(E) stepperE##E.set_pwm_thrs(value)
bool report = true; bool report = true;
#if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4) || AXIS_IS_TMC(I) || AXIS_IS_TMC(J) || AXIS_IS_TMC(K) #if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4)
const uint8_t index = parser.byteval('I'); const int8_t index = parser.byteval('I', -1);
#else
constexpr int8_t index = -1;
#endif #endif
LOOP_LOGICAL_AXES(i) if (int32_t value = parser.longval(axis_codes[i])) { LOOP_LOGICAL_AXES(i) if (int32_t value = parser.longval(axis_codes[i])) {
report = false; report = false;
switch (i) { switch (i) {
#if X_HAS_STEALTHCHOP || X2_HAS_STEALTHCHOP
case X_AXIS: case X_AXIS:
TERN_(X_HAS_STEALTHCHOP, if (index < 2) TMC_SET_PWMTHRS(X,X)); TERN_(X_HAS_STEALTHCHOP, if (index < 0 || index == 0) TMC_SET_PWMTHRS(X,X));
TERN_(X2_HAS_STEALTHCHOP, if (!(index & 1)) TMC_SET_PWMTHRS(X,X2)); TERN_(X2_HAS_STEALTHCHOP, if (index < 0 || index == 1) TMC_SET_PWMTHRS(X,X2));
break; break;
#endif
#if Y_HAS_STEALTHCHOP || Y2_HAS_STEALTHCHOP
case Y_AXIS: case Y_AXIS:
TERN_(Y_HAS_STEALTHCHOP, if (index < 2) TMC_SET_PWMTHRS(Y,Y)); TERN_(Y_HAS_STEALTHCHOP, if (index < 0 || index == 0) TMC_SET_PWMTHRS(Y,Y));
TERN_(Y2_HAS_STEALTHCHOP, if (!(index & 1)) TMC_SET_PWMTHRS(Y,Y2)); TERN_(Y2_HAS_STEALTHCHOP, if (index < 0 || index == 1) TMC_SET_PWMTHRS(Y,Y2));
break; break;
#endif
#if Z_HAS_STEALTHCHOP || Z2_HAS_STEALTHCHOP || Z3_HAS_STEALTHCHOP || Z4_HAS_STEALTHCHOP
case Z_AXIS:
TERN_(Z_HAS_STEALTHCHOP, if (index < 0 || index == 0) TMC_SET_PWMTHRS(Z,Z));
TERN_(Z2_HAS_STEALTHCHOP, if (index < 0 || index == 1) TMC_SET_PWMTHRS(Z,Z2));
TERN_(Z3_HAS_STEALTHCHOP, if (index < 0 || index == 2) TMC_SET_PWMTHRS(Z,Z3));
TERN_(Z4_HAS_STEALTHCHOP, if (index < 0 || index == 3) TMC_SET_PWMTHRS(Z,Z4));
break;
#endif
#if I_HAS_STEALTHCHOP #if I_HAS_STEALTHCHOP
case I_AXIS: TMC_SET_PWMTHRS(I,I); break; case I_AXIS: TMC_SET_PWMTHRS(I,I); break;
@ -260,26 +297,17 @@
case K_AXIS: TMC_SET_PWMTHRS(K,K); break; case K_AXIS: TMC_SET_PWMTHRS(K,K); break;
#endif #endif
case Z_AXIS: #if E0_HAS_STEALTHCHOP || E1_HAS_STEALTHCHOP || E2_HAS_STEALTHCHOP || E3_HAS_STEALTHCHOP || E4_HAS_STEALTHCHOP || E5_HAS_STEALTHCHOP || E6_HAS_STEALTHCHOP || E7_HAS_STEALTHCHOP
TERN_(Z_HAS_STEALTHCHOP, if (index < 2) TMC_SET_PWMTHRS(Z,Z));
TERN_(Z2_HAS_STEALTHCHOP, if (index == 0 || index == 2) TMC_SET_PWMTHRS(Z,Z2));
TERN_(Z3_HAS_STEALTHCHOP, if (index == 0 || index == 3) TMC_SET_PWMTHRS(Z,Z3));
TERN_(Z4_HAS_STEALTHCHOP, if (index == 0 || index == 4) TMC_SET_PWMTHRS(Z,Z4));
break;
#if E_STEPPERS
case E_AXIS: { case E_AXIS: {
const int8_t target_e_stepper = get_target_e_stepper_from_command(0); const int8_t eindex = get_target_e_stepper_from_command(-2);
if (target_e_stepper < 0) return; TERN_(E0_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 0) TMC_SET_PWMTHRS_E(0));
switch (target_e_stepper) { TERN_(E1_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 1) TMC_SET_PWMTHRS_E(1));
TERN_(E0_HAS_STEALTHCHOP, case 0: TMC_SET_PWMTHRS_E(0); break;) TERN_(E2_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 2) TMC_SET_PWMTHRS_E(2));
TERN_(E1_HAS_STEALTHCHOP, case 1: TMC_SET_PWMTHRS_E(1); break;) TERN_(E3_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 3) TMC_SET_PWMTHRS_E(3));
TERN_(E2_HAS_STEALTHCHOP, case 2: TMC_SET_PWMTHRS_E(2); break;) TERN_(E4_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 4) TMC_SET_PWMTHRS_E(4));
TERN_(E3_HAS_STEALTHCHOP, case 3: TMC_SET_PWMTHRS_E(3); break;) TERN_(E5_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 5) TMC_SET_PWMTHRS_E(5));
TERN_(E4_HAS_STEALTHCHOP, case 4: TMC_SET_PWMTHRS_E(4); break;) TERN_(E6_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 6) TMC_SET_PWMTHRS_E(6));
TERN_(E5_HAS_STEALTHCHOP, case 5: TMC_SET_PWMTHRS_E(5); break;) TERN_(E7_HAS_STEALTHCHOP, if (eindex < 0 || eindex == 7) TMC_SET_PWMTHRS_E(7));
TERN_(E6_HAS_STEALTHCHOP, case 6: TMC_SET_PWMTHRS_E(6); break;)
TERN_(E7_HAS_STEALTHCHOP, case 7: TMC_SET_PWMTHRS_E(7); break;)
}
} break; } break;
#endif // E_STEPPERS #endif // E_STEPPERS
} }
@ -407,11 +435,18 @@
#endif // HYBRID_THRESHOLD #endif // HYBRID_THRESHOLD
/**
* M914: Set StallGuard sensitivity.
*/
#if USE_SENSORLESS #if USE_SENSORLESS
template<typename TMC>
static void tmc_print_sgt(TMC &st) {
st.printLabel();
SERIAL_ECHOPGM(" homing sensitivity: ");
SERIAL_PRINTLN(st.homing_threshold(), PrintBase::Dec);
}
/**
* M914: Set StallGuard sensitivity.
*/
void GcodeSuite::M914() { void GcodeSuite::M914() {
bool report = true; bool report = true;

266
Marlin/src/gcode/feature/trinamic/M919.cpp

@ -0,0 +1,266 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../../inc/MarlinConfig.h"
#if HAS_TRINAMIC_CONFIG
#if AXIS_COLLISION('I')
#error "M919 parameter collision with axis name."
#endif
#include "../../gcode.h"
#include "../../../feature/tmc_util.h"
#include "../../../module/stepper/indirection.h"
#define DEBUG_OUT ENABLED(MARLIN_DEV_MODE)
#include "../../../core/debug_out.h"
template<typename TMC>
static void tmc_print_chopper_time(TMC &st) {
st.printLabel();
SERIAL_ECHOLNPGM(" chopper .toff: ", st.toff(),
" .hend: ", st.hysteresis_end(),
" .hstrt: ", st.hysteresis_start());
}
/**
* M919: Set TMC stepper driver chopper times
*
* Parameters:
* XYZ...E - Selected axes
* I[index] - Axis sub-index (Omit for all XYZ steppers, 1 for X2, Y2, Z2; 2 for Z3; 3 for Z4)
* T[index] - Extruder index (Zero-based. Omit for all extruders.)
* O - time-off [ 1..15]
* P - hysteresis_end [-3..12]
* S - hysteresis_start [ 1...8]
*
* With no parameters report chopper times for all axes
*/
void GcodeSuite::M919() {
bool err = false;
int8_t toff = int8_t(parser.intval('O', -127));
if (toff != -127) {
if (WITHIN(toff, 1, 15))
DEBUG_ECHOLNPGM(".toff: ", toff);
else {
SERIAL_ECHOLNPGM("?O out of range (1..15)");
err = true;
}
}
int8_t hend = int8_t(parser.intval('P', -127));
if (hend != -127) {
if (WITHIN(hend, -3, 12))
DEBUG_ECHOLNPGM(".hend: ", hend);
else {
SERIAL_ECHOLNPGM("?P out of range (-3..12)");
err = true;
}
}
int8_t hstrt = int8_t(parser.intval('S', -127));
if (hstrt != -127) {
if (WITHIN(hstrt, 1, 8))
DEBUG_ECHOLNPGM(".hstrt: ", hstrt);
else {
SERIAL_ECHOLNPGM("?S out of range (1..8)");
err = true;
}
}
if (err) return;
#if AXIS_IS_TMC(X2) || AXIS_IS_TMC(Y2) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4)
const int8_t index = parser.byteval('I');
#else
constexpr int8_t index = -1;
#endif
auto make_chopper_timing = [](chopper_timing_t bct, const int8_t toff, const int8_t hend, const int8_t hstrt) {
chopper_timing_t uct = bct;
if (toff != -127) uct.toff = toff;
if (hend != -127) uct.hend = hend;
if (hstrt != -127) uct.hstrt = hstrt;
return uct;
};
#define TMC_SET_CHOPPER_TIME(Q) stepper##Q.set_chopper_times(make_chopper_timing(CHOPPER_TIMING_##Q, toff, hend, hstrt))
#if AXIS_IS_TMC(E0) || AXIS_IS_TMC(E1) || AXIS_IS_TMC(E2) || AXIS_IS_TMC(E3) || AXIS_IS_TMC(E4) || AXIS_IS_TMC(E5) || AXIS_IS_TMC(E6) || AXIS_IS_TMC(E7)
#define HAS_E_CHOPPER 1
int8_t eindex = -1;
#endif
bool report = true;
LOOP_LOGICAL_AXES(i) if (parser.seen_test(axis_codes[i])) {
report = false;
// Get the chopper timing for the specified axis and index
switch (i) {
default: // A specified axis isn't Trinamic
SERIAL_ECHOLNPGM("?Axis ", AS_CHAR(axis_codes[i]), " has no TMC drivers.");
break;
#if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2)
case X_AXIS:
#if AXIS_IS_TMC(X)
if (index <= 0) TMC_SET_CHOPPER_TIME(X);
#endif
#if AXIS_IS_TMC(X2)
if (index < 0 || index == 1) TMC_SET_CHOPPER_TIME(X2);
#endif
break;
#endif
#if AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2)
case Y_AXIS:
#if AXIS_IS_TMC(Y)
if (index <= 0) TMC_SET_CHOPPER_TIME(Y);
#endif
#if AXIS_IS_TMC(Y2)
if (index < 0 || index == 1) TMC_SET_CHOPPER_TIME(Y2);
#endif
break;
#endif
#if AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3) || AXIS_IS_TMC(Z4)
case Z_AXIS:
#if AXIS_IS_TMC(Z)
if (index <= 0) TMC_SET_CHOPPER_TIME(Z);
#endif
#if AXIS_IS_TMC(Z2)
if (index < 0 || index == 1) TMC_SET_CHOPPER_TIME(Z2);
#endif
#if AXIS_IS_TMC(Z3)
if (index < 0 || index == 2) TMC_SET_CHOPPER_TIME(Z3);
#endif
#if AXIS_IS_TMC(Z4)
if (index < 0 || index == 3) TMC_SET_CHOPPER_TIME(Z4);
#endif
break;
#endif
#if AXIS_IS_TMC(I)
case I_AXIS: TMC_SET_CHOPPER_TIME(I); break;
#endif
#if AXIS_IS_TMC(J)
case J_AXIS: TMC_SET_CHOPPER_TIME(J); break;
#endif
#if AXIS_IS_TMC(K)
case K_AXIS: TMC_SET_CHOPPER_TIME(K); break;
#endif
#if HAS_E_CHOPPER
case E_AXIS: {
#if AXIS_IS_TMC(E0)
if (eindex <= 0) TMC_SET_CHOPPER_TIME(E0);
#endif
#if AXIS_IS_TMC(E1)
if (eindex < 0 || eindex == 1) TMC_SET_CHOPPER_TIME(E1);
#endif
#if AXIS_IS_TMC(E2)
if (eindex < 0 || eindex == 2) TMC_SET_CHOPPER_TIME(E2);
#endif
#if AXIS_IS_TMC(E3)
if (eindex < 0 || eindex == 3) TMC_SET_CHOPPER_TIME(E3);
#endif
#if AXIS_IS_TMC(E4)
if (eindex < 0 || eindex == 4) TMC_SET_CHOPPER_TIME(E4);
#endif
#if AXIS_IS_TMC(E5)
if (eindex < 0 || eindex == 5) TMC_SET_CHOPPER_TIME(E5);
#endif
#if AXIS_IS_TMC(E6)
if (eindex < 0 || eindex == 6) TMC_SET_CHOPPER_TIME(E6);
#endif
#if AXIS_IS_TMC(E7)
if (eindex < 0 || eindex == 7) TMC_SET_CHOPPER_TIME(E7);
#endif
} break;
#endif
}
}
if (report) {
#define TMC_SAY_CHOPPER_TIME(Q) tmc_print_chopper_time(stepper##Q)
#if AXIS_IS_TMC(X)
TMC_SAY_CHOPPER_TIME(X);
#endif
#if AXIS_IS_TMC(X2)
TMC_SAY_CHOPPER_TIME(X2);
#endif
#if AXIS_IS_TMC(Y)
TMC_SAY_CHOPPER_TIME(Y);
#endif
#if AXIS_IS_TMC(Y2)
TMC_SAY_CHOPPER_TIME(Y2);
#endif
#if AXIS_IS_TMC(Z)
TMC_SAY_CHOPPER_TIME(Z);
#endif
#if AXIS_IS_TMC(Z2)
TMC_SAY_CHOPPER_TIME(Z2);
#endif
#if AXIS_IS_TMC(Z3)
TMC_SAY_CHOPPER_TIME(Z3);
#endif
#if AXIS_IS_TMC(Z4)
TMC_SAY_CHOPPER_TIME(Z4);
#endif
#if AXIS_IS_TMC(I)
TMC_SAY_CHOPPER_TIME(I);
#endif
#if AXIS_IS_TMC(J)
TMC_SAY_CHOPPER_TIME(J);
#endif
#if AXIS_IS_TMC(K)
TMC_SAY_CHOPPER_TIME(K);
#endif
#if AXIS_IS_TMC(E0)
TMC_SAY_CHOPPER_TIME(E0);
#endif
#if AXIS_IS_TMC(E1)
TMC_SAY_CHOPPER_TIME(E1);
#endif
#if AXIS_IS_TMC(E2)
TMC_SAY_CHOPPER_TIME(E2);
#endif
#if AXIS_IS_TMC(E3)
TMC_SAY_CHOPPER_TIME(E3);
#endif
#if AXIS_IS_TMC(E4)
TMC_SAY_CHOPPER_TIME(E4);
#endif
#if AXIS_IS_TMC(E5)
TMC_SAY_CHOPPER_TIME(E5);
#endif
#if AXIS_IS_TMC(E6)
TMC_SAY_CHOPPER_TIME(E6);
#endif
#if AXIS_IS_TMC(E7)
TMC_SAY_CHOPPER_TIME(E7);
#endif
}
}
#endif // HAS_TRINAMIC_CONFIG

4
Marlin/src/gcode/gcode.cpp

@ -148,6 +148,7 @@ int8_t GcodeSuite::get_target_extruder_from_command() {
int8_t GcodeSuite::get_target_e_stepper_from_command(const int8_t dval/*=-1*/) { int8_t GcodeSuite::get_target_e_stepper_from_command(const int8_t dval/*=-1*/) {
const int8_t e = parser.intval('T', dval); const int8_t e = parser.intval('T', dval);
if (WITHIN(e, 0, E_STEPPERS - 1)) return e; if (WITHIN(e, 0, E_STEPPERS - 1)) return e;
if (dval == -2) return dval;
SERIAL_ECHO_START(); SERIAL_ECHO_START();
SERIAL_CHAR('M'); SERIAL_ECHO(parser.codenum); SERIAL_CHAR('M'); SERIAL_ECHO(parser.codenum);
@ -159,7 +160,7 @@ int8_t GcodeSuite::get_target_e_stepper_from_command(const int8_t dval/*=-1*/) {
} }
/** /**
* Set XYZIJKE destination and feedrate from the current GCode command * Set XYZ...E destination and feedrate from the current GCode command
* *
* - Set destination from included axis codes * - Set destination from included axis codes
* - Set to current for missing axis codes * - Set to current for missing axis codes
@ -970,6 +971,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
#if USE_SENSORLESS #if USE_SENSORLESS
case 914: M914(); break; // M914: Set StallGuard sensitivity. case 914: M914(); break; // M914: Set StallGuard sensitivity.
#endif #endif
case 919: M919(); break; // M919: Set stepper Chopper Times
#endif #endif
#if HAS_L64XX #if HAS_L64XX

22
Marlin/src/gcode/gcode.h

@ -284,7 +284,7 @@
* M871 - Print/reset/clear first layer temperature offset values. (Requires PTC_PROBE, PTC_BED, or PTC_HOTEND) * M871 - Print/reset/clear first layer temperature offset values. (Requires PTC_PROBE, PTC_BED, or PTC_HOTEND)
* M876 - Handle Prompt Response. (Requires HOST_PROMPT_SUPPORT and not EMERGENCY_PARSER) * M876 - Handle Prompt Response. (Requires HOST_PROMPT_SUPPORT and not EMERGENCY_PARSER)
* M900 - Get or Set Linear Advance K-factor. (Requires LIN_ADVANCE) * M900 - Get or Set Linear Advance K-factor. (Requires LIN_ADVANCE)
* M906 - Set or get motor current in milliamps using axis codes X, Y, Z, E. Report values if no axis codes given. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660 or L6470) * M906 - Set or get motor current in milliamps using axis codes XYZE, etc. Report values if no axis codes given. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660 or L6470)
* M907 - Set digital trimpot motor current using axis codes. (Requires a board with digital trimpots) * M907 - Set digital trimpot motor current using axis codes. (Requires a board with digital trimpots)
* M908 - Control digital trimpot directly. (Requires HAS_MOTOR_CURRENT_DAC or DIGIPOTSS_PIN) * M908 - Control digital trimpot directly. (Requires HAS_MOTOR_CURRENT_DAC or DIGIPOTSS_PIN)
* M909 - Print digipot/DAC current value. (Requires HAS_MOTOR_CURRENT_DAC) * M909 - Print digipot/DAC current value. (Requires HAS_MOTOR_CURRENT_DAC)
@ -296,6 +296,7 @@
* M916 - L6470 tuning: Increase KVAL_HOLD until thermal warning. (Requires at least one _DRIVER_TYPE L6470) * M916 - L6470 tuning: Increase KVAL_HOLD until thermal warning. (Requires at least one _DRIVER_TYPE L6470)
* M917 - L6470 tuning: Find minimum current thresholds. (Requires at least one _DRIVER_TYPE L6470) * M917 - L6470 tuning: Find minimum current thresholds. (Requires at least one _DRIVER_TYPE L6470)
* M918 - L6470 tuning: Increase speed until max or error. (Requires at least one _DRIVER_TYPE L6470) * M918 - L6470 tuning: Increase speed until max or error. (Requires at least one _DRIVER_TYPE L6470)
* M919 - Get or Set motor Chopper Times (time_off, hysteresis_end, hysteresis_start) using axis codes XYZE, etc. If no parameters are given, report. (Requires at least one _DRIVER_TYPE defined as TMC2130/2160/5130/5160/2208/2209/2660)
* M951 - Set Magnetic Parking Extruder parameters. (Requires MAGNETIC_PARKING_EXTRUDER) * M951 - Set Magnetic Parking Extruder parameters. (Requires MAGNETIC_PARKING_EXTRUDER)
* M3426 - Read MCP3426 ADC over I2C. (Requires HAS_MCP3426_ADC) * M3426 - Read MCP3426 ADC over I2C. (Requires HAS_MCP3426_ADC)
* M7219 - Control Max7219 Matrix LEDs. (Requires MAX7219_GCODE) * M7219 - Control Max7219 Matrix LEDs. (Requires MAX7219_GCODE)
@ -349,7 +350,7 @@ public:
static axis_bits_t axis_relative; static axis_bits_t axis_relative;
static inline bool axis_is_relative(const AxisEnum a) { static bool axis_is_relative(const AxisEnum a) {
#if HAS_EXTRUDERS #if HAS_EXTRUDERS
if (a == E_AXIS) { if (a == E_AXIS) {
if (TEST(axis_relative, E_MODE_REL)) return true; if (TEST(axis_relative, E_MODE_REL)) return true;
@ -358,7 +359,7 @@ public:
#endif #endif
return TEST(axis_relative, a); return TEST(axis_relative, a);
} }
static inline void set_relative_mode(const bool rel) { static void set_relative_mode(const bool rel) {
axis_relative = rel ? (0 LOGICAL_AXIS_GANG( axis_relative = rel ? (0 LOGICAL_AXIS_GANG(
| _BV(REL_E), | _BV(REL_E),
| _BV(REL_X), | _BV(REL_Y), | _BV(REL_Z), | _BV(REL_X), | _BV(REL_Y), | _BV(REL_Z),
@ -366,11 +367,11 @@ public:
)) : 0; )) : 0;
} }
#if HAS_EXTRUDERS #if HAS_EXTRUDERS
static inline void set_e_relative() { static void set_e_relative() {
CBI(axis_relative, E_MODE_ABS); CBI(axis_relative, E_MODE_ABS);
SBI(axis_relative, E_MODE_REL); SBI(axis_relative, E_MODE_REL);
} }
static inline void set_e_absolute() { static void set_e_absolute() {
CBI(axis_relative, E_MODE_REL); CBI(axis_relative, E_MODE_REL);
SBI(axis_relative, E_MODE_ABS); SBI(axis_relative, E_MODE_ABS);
} }
@ -403,7 +404,7 @@ public:
static void report_echo_start(const bool forReplay); static void report_echo_start(const bool forReplay);
static void report_heading(const bool forReplay, FSTR_P const fstr, const bool eol=true); static void report_heading(const bool forReplay, FSTR_P const fstr, const bool eol=true);
static inline void report_heading_etc(const bool forReplay, FSTR_P const fstr, const bool eol=true) { static void report_heading_etc(const bool forReplay, FSTR_P const fstr, const bool eol=true) {
report_heading(forReplay, fstr, eol); report_heading(forReplay, fstr, eol);
report_echo_start(forReplay); report_echo_start(forReplay);
} }
@ -420,20 +421,20 @@ public:
static void process_subcommands_now(FSTR_P fgcode); static void process_subcommands_now(FSTR_P fgcode);
static void process_subcommands_now(char * gcode); static void process_subcommands_now(char * gcode);
static inline void home_all_axes(const bool keep_leveling=false) { static void home_all_axes(const bool keep_leveling=false) {
process_subcommands_now(keep_leveling ? FPSTR(G28_STR) : TERN(CAN_SET_LEVELING_AFTER_G28, F("G28L0"), FPSTR(G28_STR))); process_subcommands_now(keep_leveling ? FPSTR(G28_STR) : TERN(CAN_SET_LEVELING_AFTER_G28, F("G28L0"), FPSTR(G28_STR)));
} }
#if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE) #if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE)
static bool autoreport_paused; static bool autoreport_paused;
static inline bool set_autoreport_paused(const bool p) { static bool set_autoreport_paused(const bool p) {
const bool was = autoreport_paused; const bool was = autoreport_paused;
autoreport_paused = p; autoreport_paused = p;
return was; return was;
} }
#else #else
static constexpr bool autoreport_paused = false; static constexpr bool autoreport_paused = false;
static inline bool set_autoreport_paused(const bool) { return false; } static bool set_autoreport_paused(const bool) { return false; }
#endif #endif
#if ENABLED(HOST_KEEPALIVE_FEATURE) #if ENABLED(HOST_KEEPALIVE_FEATURE)
@ -453,7 +454,7 @@ public:
static uint8_t host_keepalive_interval; static uint8_t host_keepalive_interval;
static void host_keepalive(); static void host_keepalive();
static inline bool host_keepalive_is_paused() { return busy_state >= PAUSED_FOR_USER; } static bool host_keepalive_is_paused() { return busy_state >= PAUSED_FOR_USER; }
#define KEEPALIVE_STATE(N) REMEMBER(_KA_, gcode.busy_state, gcode.N) #define KEEPALIVE_STATE(N) REMEMBER(_KA_, gcode.busy_state, gcode.N)
#else #else
@ -1140,6 +1141,7 @@ private:
static void M914(); static void M914();
static void M914_report(const bool forReplay=true); static void M914_report(const bool forReplay=true);
#endif #endif
static void M919();
#endif #endif
#if HAS_L64XX #if HAS_L64XX

1
Marlin/src/gcode/lcd/M0_M1.cpp

@ -36,6 +36,7 @@
#elif ENABLED(EXTENSIBLE_UI) #elif ENABLED(EXTENSIBLE_UI)
#include "../../lcd/extui/ui_api.h" #include "../../lcd/extui/ui_api.h"
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED) #elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
#include "../../lcd/e3v2/enhanced/dwin_popup.h"
#include "../../lcd/e3v2/enhanced/dwin.h" #include "../../lcd/e3v2/enhanced/dwin.h"
#endif #endif

4
Marlin/src/gcode/motion/G5.cpp

@ -24,6 +24,10 @@
#if ENABLED(BEZIER_CURVE_SUPPORT) #if ENABLED(BEZIER_CURVE_SUPPORT)
#if AXIS_COLLISION('I') || AXIS_COLLISION('J')
#error "G5 parameter collision with axis name."
#endif
#include "../../module/motion.h" #include "../../module/motion.h"
#include "../../module/planner_bezier.h" #include "../../module/planner_bezier.h"

118
Marlin/src/gcode/parser.h

@ -126,7 +126,7 @@ public:
} }
// Set the flag and pointer for a parameter // Set the flag and pointer for a parameter
static inline void set(const char c, char * const ptr) { static void set(const char c, char * const ptr) {
const uint8_t ind = LETTER_BIT(c); const uint8_t ind = LETTER_BIT(c);
if (ind >= COUNT(param)) return; // Only A-Z if (ind >= COUNT(param)) return; // Only A-Z
SBI32(codebits, ind); // parameter exists SBI32(codebits, ind); // parameter exists
@ -142,7 +142,7 @@ public:
// Code seen bit was set. If not found, value_ptr is unchanged. // Code seen bit was set. If not found, value_ptr is unchanged.
// This allows "if (seen('A')||seen('B'))" to use the last-found value. // This allows "if (seen('A')||seen('B'))" to use the last-found value.
static inline bool seen(const char c) { static bool seen(const char c) {
const uint8_t ind = LETTER_BIT(c); const uint8_t ind = LETTER_BIT(c);
if (ind >= COUNT(param)) return false; // Only A-Z if (ind >= COUNT(param)) return false; // Only A-Z
const bool b = TEST32(codebits, ind); const bool b = TEST32(codebits, ind);
@ -183,7 +183,7 @@ public:
} }
#endif #endif
static inline bool seen_any() { return !!codebits; } static bool seen_any() { return !!codebits; }
FORCE_INLINE static bool seen_test(const char c) { return TEST32(codebits, LETTER_BIT(c)); } FORCE_INLINE static bool seen_test(const char c) { return TEST32(codebits, LETTER_BIT(c)); }
@ -204,19 +204,19 @@ public:
// Code is found in the string. If not found, value_ptr is unchanged. // Code is found in the string. If not found, value_ptr is unchanged.
// This allows "if (seen('A')||seen('B'))" to use the last-found value. // This allows "if (seen('A')||seen('B'))" to use the last-found value.
static inline bool seen(const char c) { static bool seen(const char c) {
char *p = strgchr(command_args, c); char *p = strgchr(command_args, c);
const bool b = !!p; const bool b = !!p;
if (b) value_ptr = valid_number(&p[1]) ? &p[1] : nullptr; if (b) value_ptr = valid_number(&p[1]) ? &p[1] : nullptr;
return b; return b;
} }
static inline bool seen_any() { return *command_args == '\0'; } static bool seen_any() { return *command_args == '\0'; }
FORCE_INLINE static bool seen_test(const char c) { return (bool)strgchr(command_args, c); } FORCE_INLINE static bool seen_test(const char c) { return (bool)strgchr(command_args, c); }
// At least one of a list of code letters was seen // At least one of a list of code letters was seen
static inline bool seen(const char * const str) { static bool seen(const char * const str) {
for (uint8_t i = 0; const char c = str[i]; i++) for (uint8_t i = 0; const char c = str[i]; i++)
if (seen_test(c)) return true; if (seen_test(c)) return true;
return false; return false;
@ -225,7 +225,7 @@ public:
#endif // !FASTER_GCODE_PARSER #endif // !FASTER_GCODE_PARSER
// Seen any axis parameter // Seen any axis parameter
static inline bool seen_axis() { return seen(LOGICAL_AXES_STRING); } static bool seen_axis() { return seen(LOGICAL_AXES_STRING); }
#if ENABLED(GCODE_QUOTED_STRINGS) #if ENABLED(GCODE_QUOTED_STRINGS)
static char* unescape_string(char* &src); static char* unescape_string(char* &src);
@ -243,19 +243,19 @@ public:
#endif #endif
// Test whether the parsed command matches the input // Test whether the parsed command matches the input
static inline bool is_command(const char ltr, const uint16_t num) { return command_letter == ltr && codenum == num; } static bool is_command(const char ltr, const uint16_t num) { return command_letter == ltr && codenum == num; }
// The code value pointer was set // The code value pointer was set
FORCE_INLINE static bool has_value() { return !!value_ptr; } FORCE_INLINE static bool has_value() { return !!value_ptr; }
// Seen a parameter with a value // Seen a parameter with a value
static inline bool seenval(const char c) { return seen(c) && has_value(); } static bool seenval(const char c) { return seen(c) && has_value(); }
// The value as a string // The value as a string
static inline char* value_string() { return value_ptr; } static char* value_string() { return value_ptr; }
// Float removes 'E' to prevent scientific notation interpretation // Float removes 'E' to prevent scientific notation interpretation
static inline float value_float() { static float value_float() {
if (value_ptr) { if (value_ptr) {
char *e = value_ptr; char *e = value_ptr;
for (;;) { for (;;) {
@ -275,31 +275,31 @@ public:
} }
// Code value as a long or ulong // Code value as a long or ulong
static inline int32_t value_long() { return value_ptr ? strtol(value_ptr, nullptr, 10) : 0L; } static int32_t value_long() { return value_ptr ? strtol(value_ptr, nullptr, 10) : 0L; }
static inline uint32_t value_ulong() { return value_ptr ? strtoul(value_ptr, nullptr, 10) : 0UL; } static uint32_t value_ulong() { return value_ptr ? strtoul(value_ptr, nullptr, 10) : 0UL; }
// Code value for use as time // Code value for use as time
static inline millis_t value_millis() { return value_ulong(); } static millis_t value_millis() { return value_ulong(); }
static inline millis_t value_millis_from_seconds() { return (millis_t)SEC_TO_MS(value_float()); } static millis_t value_millis_from_seconds() { return (millis_t)SEC_TO_MS(value_float()); }
// Reduce to fewer bits // Reduce to fewer bits
static inline int16_t value_int() { return (int16_t)value_long(); } static int16_t value_int() { return (int16_t)value_long(); }
static inline uint16_t value_ushort() { return (uint16_t)value_long(); } static uint16_t value_ushort() { return (uint16_t)value_long(); }
static inline uint8_t value_byte() { return (uint8_t)constrain(value_long(), 0, 255); } static uint8_t value_byte() { return (uint8_t)constrain(value_long(), 0, 255); }
// Bool is true with no value or non-zero // Bool is true with no value or non-zero
static inline bool value_bool() { return !has_value() || !!value_byte(); } static bool value_bool() { return !has_value() || !!value_byte(); }
// Units modes: Inches, Fahrenheit, Kelvin // Units modes: Inches, Fahrenheit, Kelvin
#if ENABLED(INCH_MODE_SUPPORT) #if ENABLED(INCH_MODE_SUPPORT)
static inline float mm_to_linear_unit(const_float_t mm) { return mm / linear_unit_factor; } static float mm_to_linear_unit(const_float_t mm) { return mm / linear_unit_factor; }
static inline float mm_to_volumetric_unit(const_float_t mm) { return mm / (volumetric_enabled ? volumetric_unit_factor : linear_unit_factor); } static float mm_to_volumetric_unit(const_float_t mm) { return mm / (volumetric_enabled ? volumetric_unit_factor : linear_unit_factor); }
// Init linear units by constructor // Init linear units by constructor
GCodeParser() { set_input_linear_units(LINEARUNIT_MM); } GCodeParser() { set_input_linear_units(LINEARUNIT_MM); }
static inline void set_input_linear_units(const LinearUnit units) { static void set_input_linear_units(const LinearUnit units) {
switch (units) { switch (units) {
default: default:
case LINEARUNIT_MM: linear_unit_factor = 1.0f; break; case LINEARUNIT_MM: linear_unit_factor = 1.0f; break;
@ -308,7 +308,7 @@ public:
volumetric_unit_factor = POW(linear_unit_factor, 3); volumetric_unit_factor = POW(linear_unit_factor, 3);
} }
static inline float axis_unit_factor(const AxisEnum axis) { static float axis_unit_factor(const AxisEnum axis) {
return ( return (
#if HAS_EXTRUDERS #if HAS_EXTRUDERS
axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor axis >= E_AXIS && volumetric_enabled ? volumetric_unit_factor : linear_unit_factor
@ -318,46 +318,46 @@ public:
); );
} }
static inline float linear_value_to_mm(const_float_t v) { return v * linear_unit_factor; } static float linear_value_to_mm(const_float_t v) { return v * linear_unit_factor; }
static inline float axis_value_to_mm(const AxisEnum axis, const float v) { return v * axis_unit_factor(axis); } static float axis_value_to_mm(const AxisEnum axis, const float v) { return v * axis_unit_factor(axis); }
static inline float per_axis_value(const AxisEnum axis, const float v) { return v / axis_unit_factor(axis); } static float per_axis_value(const AxisEnum axis, const float v) { return v / axis_unit_factor(axis); }
#else #else
static inline float mm_to_linear_unit(const_float_t mm) { return mm; } static float mm_to_linear_unit(const_float_t mm) { return mm; }
static inline float mm_to_volumetric_unit(const_float_t mm) { return mm; } static float mm_to_volumetric_unit(const_float_t mm) { return mm; }
static inline float linear_value_to_mm(const_float_t v) { return v; } static float linear_value_to_mm(const_float_t v) { return v; }
static inline float axis_value_to_mm(const AxisEnum, const float v) { return v; } static float axis_value_to_mm(const AxisEnum, const float v) { return v; }
static inline float per_axis_value(const AxisEnum, const float v) { return v; } static float per_axis_value(const AxisEnum, const float v) { return v; }
#endif #endif
static inline bool using_inch_units() { return mm_to_linear_unit(1.0f) != 1.0f; } static bool using_inch_units() { return mm_to_linear_unit(1.0f) != 1.0f; }
#define IN_TO_MM(I) ((I) * 25.4f) #define IN_TO_MM(I) ((I) * 25.4f)
#define MM_TO_IN(M) ((M) / 25.4f) #define MM_TO_IN(M) ((M) / 25.4f)
#define LINEAR_UNIT(V) parser.mm_to_linear_unit(V) #define LINEAR_UNIT(V) parser.mm_to_linear_unit(V)
#define VOLUMETRIC_UNIT(V) parser.mm_to_volumetric_unit(V) #define VOLUMETRIC_UNIT(V) parser.mm_to_volumetric_unit(V)
static inline float value_linear_units() { return linear_value_to_mm(value_float()); } static float value_linear_units() { return linear_value_to_mm(value_float()); }
static inline float value_axis_units(const AxisEnum axis) { return axis_value_to_mm(axis, value_float()); } static float value_axis_units(const AxisEnum axis) { return axis_value_to_mm(axis, value_float()); }
static inline float value_per_axis_units(const AxisEnum axis) { return per_axis_value(axis, value_float()); } static float value_per_axis_units(const AxisEnum axis) { return per_axis_value(axis, value_float()); }
#if ENABLED(TEMPERATURE_UNITS_SUPPORT) #if ENABLED(TEMPERATURE_UNITS_SUPPORT)
static inline void set_input_temp_units(const TempUnit units) { input_temp_units = units; } static void set_input_temp_units(const TempUnit units) { input_temp_units = units; }
static inline char temp_units_code() { static char temp_units_code() {
return input_temp_units == TEMPUNIT_K ? 'K' : input_temp_units == TEMPUNIT_F ? 'F' : 'C'; return input_temp_units == TEMPUNIT_K ? 'K' : input_temp_units == TEMPUNIT_F ? 'F' : 'C';
} }
static inline FSTR_P temp_units_name() { static FSTR_P temp_units_name() {
return input_temp_units == TEMPUNIT_K ? F("Kelvin") : input_temp_units == TEMPUNIT_F ? F("Fahrenheit") : F("Celsius"); return input_temp_units == TEMPUNIT_K ? F("Kelvin") : input_temp_units == TEMPUNIT_F ? F("Fahrenheit") : F("Celsius");
} }
#if HAS_LCD_MENU && DISABLED(DISABLE_M503) #if HAS_LCD_MENU && DISABLED(DISABLE_M503)
static inline float to_temp_units(celsius_t c) { static float to_temp_units(celsius_t c) {
switch (input_temp_units) { switch (input_temp_units) {
default: default:
case TEMPUNIT_C: return c; case TEMPUNIT_C: return c;
@ -368,7 +368,7 @@ public:
#endif // HAS_LCD_MENU && !DISABLE_M503 #endif // HAS_LCD_MENU && !DISABLE_M503
static inline celsius_t value_celsius() { static celsius_t value_celsius() {
float f = value_float(); float f = value_float();
switch (input_temp_units) { switch (input_temp_units) {
default: default:
@ -379,7 +379,7 @@ public:
return LROUND(f); return LROUND(f);
} }
static inline celsius_t value_celsius_diff() { static celsius_t value_celsius_diff() {
float f = value_float(); float f = value_float();
switch (input_temp_units) { switch (input_temp_units) {
default: default:
@ -392,35 +392,35 @@ public:
#else // !TEMPERATURE_UNITS_SUPPORT #else // !TEMPERATURE_UNITS_SUPPORT
static inline float to_temp_units(int16_t c) { return (float)c; } static float to_temp_units(int16_t c) { return (float)c; }
static inline celsius_t value_celsius() { return value_int(); } static celsius_t value_celsius() { return value_int(); }
static inline celsius_t value_celsius_diff() { return value_int(); } static celsius_t value_celsius_diff() { return value_int(); }
#endif // !TEMPERATURE_UNITS_SUPPORT #endif // !TEMPERATURE_UNITS_SUPPORT
static inline feedRate_t value_feedrate() { return MMM_TO_MMS(value_linear_units()); } static feedRate_t value_feedrate() { return MMM_TO_MMS(value_linear_units()); }
void unknown_command_warning(); void unknown_command_warning();
// Provide simple value accessors with default option // Provide simple value accessors with default option
static inline char* stringval(const char c, char * const dval=nullptr) { return seenval(c) ? value_string() : dval; } static char* stringval(const char c, char * const dval=nullptr) { return seenval(c) ? value_string() : dval; }
static inline float floatval(const char c, const float dval=0.0) { return seenval(c) ? value_float() : dval; } static float floatval(const char c, const float dval=0.0) { return seenval(c) ? value_float() : dval; }
static inline bool boolval(const char c, const bool dval=false) { return seenval(c) ? value_bool() : (seen(c) ? true : dval); } static bool boolval(const char c, const bool dval=false) { return seenval(c) ? value_bool() : (seen(c) ? true : dval); }
static inline uint8_t byteval(const char c, const uint8_t dval=0) { return seenval(c) ? value_byte() : dval; } static uint8_t byteval(const char c, const uint8_t dval=0) { return seenval(c) ? value_byte() : dval; }
static inline int16_t intval(const char c, const int16_t dval=0) { return seenval(c) ? value_int() : dval; } static int16_t intval(const char c, const int16_t dval=0) { return seenval(c) ? value_int() : dval; }
static inline uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort() : dval; } static uint16_t ushortval(const char c, const uint16_t dval=0) { return seenval(c) ? value_ushort() : dval; }
static inline int32_t longval(const char c, const int32_t dval=0) { return seenval(c) ? value_long() : dval; } static int32_t longval(const char c, const int32_t dval=0) { return seenval(c) ? value_long() : dval; }
static inline uint32_t ulongval(const char c, const uint32_t dval=0) { return seenval(c) ? value_ulong() : dval; } static uint32_t ulongval(const char c, const uint32_t dval=0) { return seenval(c) ? value_ulong() : dval; }
static inline float linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; } static float linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; }
static inline float axisunitsval(const char c, const AxisEnum a, const float dval=0) static float axisunitsval(const char c, const AxisEnum a, const float dval=0)
{ return seenval(c) ? value_axis_units(a) : dval; } { return seenval(c) ? value_axis_units(a) : dval; }
static inline celsius_t celsiusval(const char c, const celsius_t dval=0) { return seenval(c) ? value_celsius() : dval; } static celsius_t celsiusval(const char c, const celsius_t dval=0) { return seenval(c) ? value_celsius() : dval; }
static inline feedRate_t feedrateval(const char c, const feedRate_t dval=0) { return seenval(c) ? value_feedrate() : dval; } static feedRate_t feedrateval(const char c, const feedRate_t dval=0) { return seenval(c) ? value_feedrate() : dval; }
#if ENABLED(MARLIN_DEV_MODE) #if ENABLED(MARLIN_DEV_MODE)
static inline uint8_t* hex_adr_val(const char c, uint8_t * const dval=nullptr) { static uint8_t* hex_adr_val(const char c, uint8_t * const dval=nullptr) {
if (!seen(c) || *value_ptr != 'x') return dval; if (!seen(c) || *value_ptr != 'x') return dval;
uint8_t *out = nullptr; uint8_t *out = nullptr;
for (char *vp = value_ptr + 1; HEXCHR(*vp) >= 0; vp++) for (char *vp = value_ptr + 1; HEXCHR(*vp) >= 0; vp++)
@ -428,7 +428,7 @@ public:
return out; return out;
} }
static inline uint16_t hex_val(const char c, uint16_t const dval=0) { static uint16_t hex_val(const char c, uint16_t const dval=0) {
if (!seen(c) || *value_ptr != 'x') return dval; if (!seen(c) || *value_ptr != 'x') return dval;
uint16_t out = 0; uint16_t out = 0;
for (char *vp = value_ptr + 1; HEXCHR(*vp) >= 0; vp++) for (char *vp = value_ptr + 1; HEXCHR(*vp) >= 0; vp++)

14
Marlin/src/gcode/queue.h

@ -126,14 +126,14 @@ public:
* Don't inject comments or use leading spaces! * Don't inject comments or use leading spaces!
* Aborts the current PROGMEM queue so only use for one or two commands. * Aborts the current PROGMEM queue so only use for one or two commands.
*/ */
static inline void inject_P(PGM_P const pgcode) { injected_commands_P = pgcode; } static void inject_P(PGM_P const pgcode) { injected_commands_P = pgcode; }
static inline void inject(FSTR_P const fgcode) { inject_P(FTOP(fgcode)); } static void inject(FSTR_P const fgcode) { inject_P(FTOP(fgcode)); }
/** /**
* Enqueue command(s) to run from SRAM. Drained by process_injected_command(). * Enqueue command(s) to run from SRAM. Drained by process_injected_command().
* Aborts the current SRAM queue so only use for one or two commands. * Aborts the current SRAM queue so only use for one or two commands.
*/ */
static inline void inject(const char * const gcode) { static void inject(const char * const gcode) {
strncpy(injected_commands, gcode, sizeof(injected_commands) - 1); strncpy(injected_commands, gcode, sizeof(injected_commands) - 1);
} }
@ -158,7 +158,7 @@ public:
* Enqueue from program memory and return only when commands are actually enqueued * Enqueue from program memory and return only when commands are actually enqueued
*/ */
static void enqueue_now_P(PGM_P const pcmd); static void enqueue_now_P(PGM_P const pcmd);
static inline void enqueue_now(FSTR_P const fcmd) { enqueue_now_P(FTOP(fcmd)); } static void enqueue_now(FSTR_P const fcmd) { enqueue_now_P(FTOP(fcmd)); }
/** /**
* Check whether there are any commands yet to be executed * Check whether there are any commands yet to be executed
@ -192,7 +192,7 @@ public:
* P<int> Planner space remaining * P<int> Planner space remaining
* B<int> Block queue space remaining * B<int> Block queue space remaining
*/ */
static inline void ok_to_send() { ring_buffer.ok_to_send(); } static void ok_to_send() { ring_buffer.ok_to_send(); }
/** /**
* Clear the serial line and request a resend of * Clear the serial line and request a resend of
@ -203,7 +203,7 @@ public:
/** /**
* (Re)Set the current line number for the last received command * (Re)Set the current line number for the last received command
*/ */
static inline void set_current_line_number(long n) { serial_state[ring_buffer.command_port().index].last_N = n; } static void set_current_line_number(long n) { serial_state[ring_buffer.command_port().index].last_N = n; }
#if ENABLED(BUFFER_MONITORING) #if ENABLED(BUFFER_MONITORING)
@ -237,7 +237,7 @@ public:
static void auto_report_buffer_statistics(); static void auto_report_buffer_statistics();
static inline void set_auto_report_interval(uint8_t v) { static void set_auto_report_interval(uint8_t v) {
NOMORE(v, 60); NOMORE(v, 60);
auto_buffer_report_interval = v; auto_buffer_report_interval = v;
next_buffer_report_ms = millis() + 1000UL * v; next_buffer_report_ms = millis() + 1000UL * v;

11
Marlin/src/gcode/temp/M303.cpp

@ -77,10 +77,17 @@ void GcodeSuite::M303() {
return; return;
} }
const celsius_t temp = parser.celsiusval('S', default_temp); const bool seenC = parser.seenval('C');
const int c = parser.intval('C', 5); const int c = seenC ? parser.value_int() : 5;
const bool seenS = parser.seenval('S');
const celsius_t temp = seenS ? parser.value_celsius() : default_temp;
const bool u = parser.boolval('U'); const bool u = parser.boolval('U');
#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
if (seenC) HMI_data.PidCycles = c;
if (seenS) { if (hid == H_BED) HMI_data.BedPidT = temp; else HMI_data.HotendPidT = temp; }
#endif
#if DISABLED(BUSY_WHILE_HEATING) #if DISABLED(BUSY_WHILE_HEATING)
KEEPALIVE_STATE(NOT_BUSY); KEEPALIVE_STATE(NOT_BUSY);
#endif #endif

24
Marlin/src/inc/Conditionals_LCD.h

@ -207,8 +207,11 @@
#define IS_ULTIPANEL 1 #define IS_ULTIPANEL 1
#define U8GLIB_SSD1309 #define U8GLIB_SSD1309
#define LCD_RESET_PIN LCD_PINS_D6 // This controller need a reset pin #define LCD_RESET_PIN LCD_PINS_D6 // This controller need a reset pin
#define ENCODER_PULSES_PER_STEP 2 #define ENCODER_PULSES_PER_STEP 4
#define ENCODER_STEPS_PER_MENU_ITEM 2 #define ENCODER_STEPS_PER_MENU_ITEM 1
#ifndef PCA9632
#define PCA9632
#endif
#elif ENABLED(MAKEBOARD_MINI_2_LINE_DISPLAY_1602) #elif ENABLED(MAKEBOARD_MINI_2_LINE_DISPLAY_1602)
@ -693,6 +696,15 @@
#define HAS_Y_AXIS 1 #define HAS_Y_AXIS 1
#if LINEAR_AXES >= XYZ #if LINEAR_AXES >= XYZ
#define HAS_Z_AXIS 1 #define HAS_Z_AXIS 1
#if LINEAR_AXES >= 4
#define HAS_I_AXIS 1
#if LINEAR_AXES >= 5
#define HAS_J_AXIS 1
#if LINEAR_AXES >= 6
#define HAS_K_AXIS 1
#endif
#endif
#endif
#endif #endif
#endif #endif
@ -1215,13 +1227,13 @@
#if HAS_Z_AXIS && !defined(INVERT_Z_DIR) #if HAS_Z_AXIS && !defined(INVERT_Z_DIR)
#define INVERT_Z_DIR false #define INVERT_Z_DIR false
#endif #endif
#if LINEAR_AXES >= 4 && !defined(INVERT_I_DIR) #if HAS_I_AXIS && !defined(INVERT_I_DIR)
#define INVERT_I_DIR false #define INVERT_I_DIR false
#endif #endif
#if LINEAR_AXES >= 5 && !defined(INVERT_J_DIR) #if HAS_J_AXIS && !defined(INVERT_J_DIR)
#define INVERT_J_DIR false #define INVERT_J_DIR false
#endif #endif
#if LINEAR_AXES >= 6 && !defined(INVERT_K_DIR) #if HAS_K_AXIS && !defined(INVERT_K_DIR)
#define INVERT_K_DIR false #define INVERT_K_DIR false
#endif #endif
#if HAS_EXTRUDERS && !defined(INVERT_E_DIR) #if HAS_EXTRUDERS && !defined(INVERT_E_DIR)
@ -1411,7 +1423,7 @@
#endif #endif
#endif #endif
#if ANY(USE_XMIN_PLUG, USE_YMIN_PLUG, USE_ZMIN_PLUG, USE_XMAX_PLUG, USE_YMAX_PLUG, USE_ZMAX_PLUG) #if X_HOME_DIR || (HAS_Y_AXIS && Y_HOME_DIR) || (HAS_Z_AXIS && Z_HOME_DIR) || (HAS_I_AXIS && I_HOME_DIR) || (HAS_J_AXIS && J_HOME_DIR) || (HAS_K_AXIS && K_HOME_DIR)
#define HAS_ENDSTOPS 1 #define HAS_ENDSTOPS 1
#define COORDINATE_OKAY(N,L,H) WITHIN(N,L,H) #define COORDINATE_OKAY(N,L,H) WITHIN(N,L,H)
#else #else

2
Marlin/src/inc/Conditionals_adv.h

@ -1006,7 +1006,7 @@
#endif #endif
// AVR are (usually) too limited in resources to store the configuration into the binary // AVR are (usually) too limited in resources to store the configuration into the binary
#if !defined(FORCE_CONFIG_EMBED) && (defined(__AVR__) || DISABLED(SDSUPPORT) || EITHER(SDCARD_READONLY, DISABLE_M503)) #if ENABLED(CONFIGURATION_EMBEDDING) && !defined(FORCE_CONFIG_EMBED) && (defined(__AVR__) || DISABLED(SDSUPPORT) || EITHER(SDCARD_READONLY, DISABLE_M503))
#undef CONFIGURATION_EMBEDDING #undef CONFIGURATION_EMBEDDING
#define CANNOT_EMBED_CONFIGURATION defined(__AVR__) #define CANNOT_EMBED_CONFIGURATION defined(__AVR__)
#endif #endif

66
Marlin/src/inc/Conditionals_post.h

@ -97,13 +97,13 @@
#else #else
#undef CONTROLLER_FAN_USE_Z_ONLY #undef CONTROLLER_FAN_USE_Z_ONLY
#endif #endif
#if LINEAR_AXES >= 4 #if HAS_I_AXIS
#define I_MAX_LENGTH (I_MAX_POS - (I_MIN_POS)) #define I_MAX_LENGTH (I_MAX_POS - (I_MIN_POS))
#endif #endif
#if LINEAR_AXES >= 5 #if HAS_J_AXIS
#define J_MAX_LENGTH (J_MAX_POS - (J_MIN_POS)) #define J_MAX_LENGTH (J_MAX_POS - (J_MIN_POS))
#endif #endif
#if LINEAR_AXES >= 6 #if HAS_K_AXIS
#define K_MAX_LENGTH (K_MAX_POS - (K_MIN_POS)) #define K_MAX_LENGTH (K_MAX_POS - (K_MIN_POS))
#endif #endif
@ -114,13 +114,13 @@
#if HAS_Y_AXIS && !defined(Y_BED_SIZE) #if HAS_Y_AXIS && !defined(Y_BED_SIZE)
#define Y_BED_SIZE Y_MAX_LENGTH #define Y_BED_SIZE Y_MAX_LENGTH
#endif #endif
#if LINEAR_AXES >= 4 && !defined(I_BED_SIZE) #if HAS_I_AXIS && !defined(I_BED_SIZE)
#define I_BED_SIZE I_MAX_LENGTH #define I_BED_SIZE I_MAX_LENGTH
#endif #endif
#if LINEAR_AXES >= 5 && !defined(J_BED_SIZE) #if HAS_J_AXIS && !defined(J_BED_SIZE)
#define J_BED_SIZE J_MAX_LENGTH #define J_BED_SIZE J_MAX_LENGTH
#endif #endif
#if LINEAR_AXES >= 6 && !defined(K_BED_SIZE) #if HAS_K_AXIS && !defined(K_BED_SIZE)
#define K_BED_SIZE K_MAX_LENGTH #define K_BED_SIZE K_MAX_LENGTH
#endif #endif
@ -134,13 +134,13 @@
#if HAS_Y_AXIS #if HAS_Y_AXIS
#define _Y_HALF_BED ((Y_BED_SIZE) / 2) #define _Y_HALF_BED ((Y_BED_SIZE) / 2)
#endif #endif
#if LINEAR_AXES >= 4 #if HAS_I_AXIS
#define _I_HALF_IMAX ((I_BED_SIZE) / 2) #define _I_HALF_IMAX ((I_BED_SIZE) / 2)
#endif #endif
#if LINEAR_AXES >= 5 #if HAS_J_AXIS
#define _J_HALF_JMAX ((J_BED_SIZE) / 2) #define _J_HALF_JMAX ((J_BED_SIZE) / 2)
#endif #endif
#if LINEAR_AXES >= 6 #if HAS_K_AXIS
#define _K_HALF_KMAX ((K_BED_SIZE) / 2) #define _K_HALF_KMAX ((K_BED_SIZE) / 2)
#endif #endif
@ -149,13 +149,13 @@
#define Y_CENTER TERN(BED_CENTER_AT_0_0, 0, _Y_HALF_BED) #define Y_CENTER TERN(BED_CENTER_AT_0_0, 0, _Y_HALF_BED)
#define XY_CENTER { X_CENTER, Y_CENTER } #define XY_CENTER { X_CENTER, Y_CENTER }
#endif #endif
#if LINEAR_AXES >= 4 #if HAS_I_AXIS
#define I_CENTER TERN(BED_CENTER_AT_0_0, 0, _I_HALF_BED) #define I_CENTER TERN(BED_CENTER_AT_0_0, 0, _I_HALF_BED)
#endif #endif
#if LINEAR_AXES >= 5 #if HAS_J_AXIS
#define J_CENTER TERN(BED_CENTER_AT_0_0, 0, _J_HALF_BED) #define J_CENTER TERN(BED_CENTER_AT_0_0, 0, _J_HALF_BED)
#endif #endif
#if LINEAR_AXES >= 6 #if HAS_K_AXIS
#define K_CENTER TERN(BED_CENTER_AT_0_0, 0, _K_HALF_BED) #define K_CENTER TERN(BED_CENTER_AT_0_0, 0, _K_HALF_BED)
#endif #endif
@ -166,15 +166,15 @@
#define Y_MIN_BED (Y_CENTER - _Y_HALF_BED) #define Y_MIN_BED (Y_CENTER - _Y_HALF_BED)
#define Y_MAX_BED (Y_MIN_BED + Y_BED_SIZE) #define Y_MAX_BED (Y_MIN_BED + Y_BED_SIZE)
#endif #endif
#if LINEAR_AXES >= 4 #if HAS_I_AXIS
#define I_MINIM (I_CENTER - _I_HALF_BED_SIZE) #define I_MINIM (I_CENTER - _I_HALF_BED_SIZE)
#define I_MAXIM (I_MINIM + I_BED_SIZE) #define I_MAXIM (I_MINIM + I_BED_SIZE)
#endif #endif
#if LINEAR_AXES >= 5 #if HAS_J_AXIS
#define J_MINIM (J_CENTER - _J_HALF_BED_SIZE) #define J_MINIM (J_CENTER - _J_HALF_BED_SIZE)
#define J_MAXIM (J_MINIM + J_BED_SIZE) #define J_MAXIM (J_MINIM + J_BED_SIZE)
#endif #endif
#if LINEAR_AXES >= 6 #if HAS_K_AXIS
#define K_MINIM (K_CENTER - _K_HALF_BED_SIZE) #define K_MINIM (K_CENTER - _K_HALF_BED_SIZE)
#define K_MAXIM (K_MINIM + K_BED_SIZE) #define K_MAXIM (K_MINIM + K_BED_SIZE)
#endif #endif
@ -253,21 +253,21 @@
#define Z_HOME_POS TERN(Z_HOME_TO_MIN, Z_MIN_POS, Z_MAX_POS) #define Z_HOME_POS TERN(Z_HOME_TO_MIN, Z_MIN_POS, Z_MAX_POS)
#endif #endif
#if LINEAR_AXES >= 4 #if HAS_I_AXIS
#ifdef MANUAL_I_HOME_POS #ifdef MANUAL_I_HOME_POS
#define I_HOME_POS MANUAL_I_HOME_POS #define I_HOME_POS MANUAL_I_HOME_POS
#else #else
#define I_HOME_POS TERN(I_HOME_TO_MIN, I_MIN_POS, I_MAX_POS) #define I_HOME_POS TERN(I_HOME_TO_MIN, I_MIN_POS, I_MAX_POS)
#endif #endif
#endif #endif
#if LINEAR_AXES >= 5 #if HAS_J_AXIS
#ifdef MANUAL_J_HOME_POS #ifdef MANUAL_J_HOME_POS
#define J_HOME_POS MANUAL_J_HOME_POS #define J_HOME_POS MANUAL_J_HOME_POS
#else #else
#define J_HOME_POS TERN(J_HOME_TO_MIN, J_MIN_POS, J_MAX_POS) #define J_HOME_POS TERN(J_HOME_TO_MIN, J_MIN_POS, J_MAX_POS)
#endif #endif
#endif #endif
#if LINEAR_AXES >= 6 #if HAS_K_AXIS
#ifdef MANUAL_K_HOME_POS #ifdef MANUAL_K_HOME_POS
#define K_HOME_POS MANUAL_K_HOME_POS #define K_HOME_POS MANUAL_K_HOME_POS
#else #else
@ -745,7 +745,7 @@
#define LIB_INTERNAL_MAX31865 1 #define LIB_INTERNAL_MAX31865 1
#endif #endif
#endif //HAS_MAX_TC #endif // HAS_MAX_TC
/** /**
* X_DUAL_ENDSTOPS endstop reassignment * X_DUAL_ENDSTOPS endstop reassignment
@ -1620,7 +1620,7 @@
#endif #endif
#endif #endif
#if LINEAR_AXES >= 4 #if HAS_I_AXIS
#if PIN_EXISTS(I_ENABLE) || AXIS_IS_L64XX(I) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(I)) #if PIN_EXISTS(I_ENABLE) || AXIS_IS_L64XX(I) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(I))
#define HAS_I_ENABLE 1 #define HAS_I_ENABLE 1
#endif #endif
@ -1640,7 +1640,7 @@
#undef DISABLE_INACTIVE_I #undef DISABLE_INACTIVE_I
#endif #endif
#if LINEAR_AXES >= 5 #if HAS_J_AXIS
#if PIN_EXISTS(J_ENABLE) || AXIS_IS_L64XX(J) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(J)) #if PIN_EXISTS(J_ENABLE) || AXIS_IS_L64XX(J) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(J))
#define HAS_J_ENABLE 1 #define HAS_J_ENABLE 1
#endif #endif
@ -1660,7 +1660,7 @@
#undef DISABLE_INACTIVE_J #undef DISABLE_INACTIVE_J
#endif #endif
#if LINEAR_AXES >= 6 #if HAS_K_AXIS
#if PIN_EXISTS(K_ENABLE) || AXIS_IS_L64XX(K) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(K)) #if PIN_EXISTS(K_ENABLE) || AXIS_IS_L64XX(K) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(K))
#define HAS_K_ENABLE 1 #define HAS_K_ENABLE 1
#endif #endif
@ -2395,28 +2395,28 @@
// ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface) // ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface)
// //
#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && NONE(TEMP_SENSOR_##P##_IS_MAX_TC, TEMP_SENSOR_##P##_IS_DUMMY)) #define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && NONE(TEMP_SENSOR_##P##_IS_MAX_TC, TEMP_SENSOR_##P##_IS_DUMMY))
#if HAS_ADC_TEST(0) #if HOTENDS > 0 && HAS_ADC_TEST(0)
#define HAS_TEMP_ADC_0 1 #define HAS_TEMP_ADC_0 1
#endif #endif
#if HAS_ADC_TEST(1) #if HOTENDS > 1 && HAS_ADC_TEST(1)
#define HAS_TEMP_ADC_1 1 #define HAS_TEMP_ADC_1 1
#endif #endif
#if HAS_ADC_TEST(2) #if HOTENDS > 2 && HAS_ADC_TEST(2)
#define HAS_TEMP_ADC_2 1 #define HAS_TEMP_ADC_2 1
#endif #endif
#if HAS_ADC_TEST(3) #if HOTENDS > 3 && HAS_ADC_TEST(3)
#define HAS_TEMP_ADC_3 1 #define HAS_TEMP_ADC_3 1
#endif #endif
#if HAS_ADC_TEST(4) #if HOTENDS > 4 && HAS_ADC_TEST(4)
#define HAS_TEMP_ADC_4 1 #define HAS_TEMP_ADC_4 1
#endif #endif
#if HAS_ADC_TEST(5) #if HOTENDS > 5 && HAS_ADC_TEST(5)
#define HAS_TEMP_ADC_5 1 #define HAS_TEMP_ADC_5 1
#endif #endif
#if HAS_ADC_TEST(6) #if HOTENDS > 6 && HAS_ADC_TEST(6)
#define HAS_TEMP_ADC_6 1 #define HAS_TEMP_ADC_6 1
#endif #endif
#if HAS_ADC_TEST(7) #if HOTENDS > 7 && HAS_ADC_TEST(7)
#define HAS_TEMP_ADC_7 1 #define HAS_TEMP_ADC_7 1
#endif #endif
#if HAS_ADC_TEST(BED) #if HAS_ADC_TEST(BED)
@ -2549,13 +2549,13 @@
#endif #endif
// Thermal protection // Thermal protection
#if BOTH(HAS_HEATED_BED, THERMAL_PROTECTION_BED) #if !HAS_HEATED_BED
#define HAS_THERMALLY_PROTECTED_BED 1 #undef THERMAL_PROTECTION_BED
#endif #endif
#if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0 #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
#define WATCH_HOTENDS 1 #define WATCH_HOTENDS 1
#endif #endif
#if HAS_THERMALLY_PROTECTED_BED && WATCH_BED_TEMP_PERIOD > 0 #if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0
#define WATCH_BED 1 #define WATCH_BED 1
#endif #endif
#if BOTH(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER) && WATCH_CHAMBER_TEMP_PERIOD > 0 #if BOTH(HAS_HEATED_CHAMBER, THERMAL_PROTECTION_CHAMBER) && WATCH_CHAMBER_TEMP_PERIOD > 0

98
Marlin/src/inc/SanityCheck.h

@ -824,7 +824,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "LCD_PROGRESS_BAR requires SDSUPPORT or LCD_SET_PROGRESS_MANUALLY." #error "LCD_PROGRESS_BAR requires SDSUPPORT or LCD_SET_PROGRESS_MANUALLY."
#elif NONE(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL) #elif NONE(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
#error "LCD_PROGRESS_BAR only applies to HD44780 character LCD and TFTGLCD_PANEL_(SPI|I2C)." #error "LCD_PROGRESS_BAR only applies to HD44780 character LCD and TFTGLCD_PANEL_(SPI|I2C)."
#elif HAS_MARLINUI_U8GLIB #elif HAS_MARLINUI_U8GLIB || IS_DWIN_MARLINUI
#error "LCD_PROGRESS_BAR does not apply to graphical displays." #error "LCD_PROGRESS_BAR does not apply to graphical displays."
#elif ENABLED(FILAMENT_LCD_DISPLAY) #elif ENABLED(FILAMENT_LCD_DISPLAY)
#error "LCD_PROGRESS_BAR and FILAMENT_LCD_DISPLAY are not fully compatible. Comment out this line to use both." #error "LCD_PROGRESS_BAR and FILAMENT_LCD_DISPLAY are not fully compatible. Comment out this line to use both."
@ -1416,7 +1416,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
/** /**
* Allow only extra axis codes that do not conflict with G-code parameter names * Allow only extra axis codes that do not conflict with G-code parameter names
*/ */
#if LINEAR_AXES >= 4 #if HAS_I_AXIS
#if AXIS4_NAME != 'A' && AXIS4_NAME != 'B' && AXIS4_NAME != 'C' && AXIS4_NAME != 'U' && AXIS4_NAME != 'V' && AXIS4_NAME != 'W' #if AXIS4_NAME != 'A' && AXIS4_NAME != 'B' && AXIS4_NAME != 'C' && AXIS4_NAME != 'U' && AXIS4_NAME != 'V' && AXIS4_NAME != 'W'
#error "AXIS4_NAME can only be one of 'A', 'B', 'C', 'U', 'V', or 'W'." #error "AXIS4_NAME can only be one of 'A', 'B', 'C', 'U', 'V', or 'W'."
#elif !defined(I_MIN_POS) || !defined(I_MAX_POS) #elif !defined(I_MIN_POS) || !defined(I_MAX_POS)
@ -1427,7 +1427,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "I_ENABLE_ON is required for your I driver with LINEAR_AXES >= 4." #error "I_ENABLE_ON is required for your I driver with LINEAR_AXES >= 4."
#endif #endif
#endif #endif
#if LINEAR_AXES >= 5 #if HAS_J_AXIS
#if AXIS5_NAME == AXIS4_NAME #if AXIS5_NAME == AXIS4_NAME
#error "AXIS5_NAME must be unique." #error "AXIS5_NAME must be unique."
#elif AXIS5_NAME != 'A' && AXIS5_NAME != 'B' && AXIS5_NAME != 'C' && AXIS5_NAME != 'U' && AXIS5_NAME != 'V' && AXIS5_NAME != 'W' #elif AXIS5_NAME != 'A' && AXIS5_NAME != 'B' && AXIS5_NAME != 'C' && AXIS5_NAME != 'U' && AXIS5_NAME != 'V' && AXIS5_NAME != 'W'
@ -1440,7 +1440,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "J_ENABLE_ON is required for your J driver with LINEAR_AXES >= 5." #error "J_ENABLE_ON is required for your J driver with LINEAR_AXES >= 5."
#endif #endif
#endif #endif
#if LINEAR_AXES >= 6 #if HAS_K_AXIS
#if AXIS6_NAME == AXIS5_NAME || AXIS6_NAME == AXIS4_NAME #if AXIS6_NAME == AXIS5_NAME || AXIS6_NAME == AXIS4_NAME
#error "AXIS6_NAME must be unique." #error "AXIS6_NAME must be unique."
#elif AXIS6_NAME != 'A' && AXIS6_NAME != 'B' && AXIS6_NAME != 'C' && AXIS6_NAME != 'U' && AXIS6_NAME != 'V' && AXIS6_NAME != 'W' #elif AXIS6_NAME != 'A' && AXIS6_NAME != 'B' && AXIS6_NAME != 'C' && AXIS6_NAME != 'U' && AXIS6_NAME != 'V' && AXIS6_NAME != 'W'
@ -1995,8 +1995,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#endif #endif
#endif #endif
#if HAS_FAN0 && CONTROLLER_FAN_PIN == FAN_PIN #if HAS_FAN0
#if CONTROLLER_FAN_PIN == FAN_PIN
#error "You cannot set CONTROLLER_FAN_PIN equal to FAN_PIN." #error "You cannot set CONTROLLER_FAN_PIN equal to FAN_PIN."
#elif ENABLED(FAN_SOFT_PWM_REQUIRED) && DISABLED(FAN_SOFT_PWM)
#error "FAN_SOFT_PWM is required. Enable it to continue."
#endif
#endif #endif
#if ENABLED(USE_CONTROLLER_FAN) #if ENABLED(USE_CONTROLLER_FAN)
@ -2395,13 +2399,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#if _AXIS_PLUG_UNUSED_TEST(Z) #if _AXIS_PLUG_UNUSED_TEST(Z)
#error "You must enable USE_ZMIN_PLUG or USE_ZMAX_PLUG." #error "You must enable USE_ZMIN_PLUG or USE_ZMAX_PLUG."
#endif #endif
#if LINEAR_AXES >= 4 && _AXIS_PLUG_UNUSED_TEST(I) #if HAS_I_AXIS && _AXIS_PLUG_UNUSED_TEST(I)
#error "You must enable USE_IMIN_PLUG or USE_IMAX_PLUG." #error "You must enable USE_IMIN_PLUG or USE_IMAX_PLUG."
#endif #endif
#if LINEAR_AXES >= 5 && _AXIS_PLUG_UNUSED_TEST(J) #if HAS_J_AXIS && _AXIS_PLUG_UNUSED_TEST(J)
#error "You must enable USE_JMIN_PLUG or USE_JMAX_PLUG." #error "You must enable USE_JMIN_PLUG or USE_JMAX_PLUG."
#endif #endif
#if LINEAR_AXES >= 6 && _AXIS_PLUG_UNUSED_TEST(K) #if HAS_K_AXIS && _AXIS_PLUG_UNUSED_TEST(K)
#error "You must enable USE_KMIN_PLUG or USE_KMAX_PLUG." #error "You must enable USE_KMIN_PLUG or USE_KMAX_PLUG."
#endif #endif
@ -2415,17 +2419,17 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "Enable USE_YMIN_PLUG when homing Y to MIN." #error "Enable USE_YMIN_PLUG when homing Y to MIN."
#elif Y_HOME_TO_MAX && DISABLED(USE_YMAX_PLUG) #elif Y_HOME_TO_MAX && DISABLED(USE_YMAX_PLUG)
#error "Enable USE_YMAX_PLUG when homing Y to MAX." #error "Enable USE_YMAX_PLUG when homing Y to MAX."
#elif LINEAR_AXES >= 4 && I_HOME_TO_MIN && DISABLED(USE_IMIN_PLUG) #elif HAS_I_AXIS && I_HOME_TO_MIN && DISABLED(USE_IMIN_PLUG)
#error "Enable USE_IMIN_PLUG when homing I to MIN." #error "Enable USE_IMIN_PLUG when homing I to MIN."
#elif LINEAR_AXES >= 4 && I_HOME_TO_MAX && DISABLED(USE_IMAX_PLUG) #elif HAS_I_AXIS && I_HOME_TO_MAX && DISABLED(USE_IMAX_PLUG)
#error "Enable USE_IMAX_PLUG when homing I to MAX." #error "Enable USE_IMAX_PLUG when homing I to MAX."
#elif LINEAR_AXES >= 5 && J_HOME_TO_MIN && DISABLED(USE_JMIN_PLUG) #elif HAS_J_AXIS && J_HOME_TO_MIN && DISABLED(USE_JMIN_PLUG)
#error "Enable USE_JMIN_PLUG when homing J to MIN." #error "Enable USE_JMIN_PLUG when homing J to MIN."
#elif LINEAR_AXES >= 5 && J_HOME_TO_MAX && DISABLED(USE_JMAX_PLUG) #elif HAS_J_AXIS && J_HOME_TO_MAX && DISABLED(USE_JMAX_PLUG)
#error "Enable USE_JMAX_PLUG when homing J to MAX." #error "Enable USE_JMAX_PLUG when homing J to MAX."
#elif LINEAR_AXES >= 6 && K_HOME_TO_MIN && DISABLED(USE_KMIN_PLUG) #elif HAS_K_AXIS && K_HOME_TO_MIN && DISABLED(USE_KMIN_PLUG)
#error "Enable USE_KMIN_PLUG when homing K to MIN." #error "Enable USE_KMIN_PLUG when homing K to MIN."
#elif LINEAR_AXES >= 6 && K_HOME_TO_MAX && DISABLED(USE_KMAX_PLUG) #elif HAS_K_AXIS && K_HOME_TO_MAX && DISABLED(USE_KMAX_PLUG)
#error "Enable USE_KMAX_PLUG when homing K to MAX." #error "Enable USE_KMAX_PLUG when homing K to MAX."
#endif #endif
#endif #endif
@ -2765,6 +2769,20 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "Please select only one of CHIRON_TFT_STANDARD or CHIRON_TFT_NEW." #error "Please select only one of CHIRON_TFT_STANDARD or CHIRON_TFT_NEW."
#endif #endif
#if ENABLED(ANYCUBIC_LCD_CHIRON)
#if !defined(BEEPER_PIN)
#error "ANYCUBIC_LCD_CHIRON requires BEEPER_PIN"
#elif DISABLED(SDSUPPORT)
#error "ANYCUBIC_LCD_CHIRON requires SDSUPPORT"
#elif TEMP_SENSOR_BED == 0
#error "ANYCUBIC_LCD_CHIRON requires heatbed (TEMP_SENSOR_BED)"
#elif NONE(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING)
#error "ANYCUBIC_LCD_CHIRON requires one of: AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL or MESH_BED_LEVELING"
#elif DISABLED(BABYSTEPPING)
#error "ANYCUBIC_LCD_CHIRON requires BABYSTEPPING"
#endif
#endif
#if EITHER(MKS_TS35_V2_0, BTT_TFT35_SPI_V1_0) && SD_CONNECTION_IS(LCD) #if EITHER(MKS_TS35_V2_0, BTT_TFT35_SPI_V1_0) && SD_CONNECTION_IS(LCD)
#error "SDCARD_CONNECTION cannot be set to LCD for the enabled TFT. No available SD card reader." #error "SDCARD_CONNECTION cannot be set to LCD for the enabled TFT. No available SD card reader."
#endif #endif
@ -2936,11 +2954,11 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "TMC2208 or TMC2209 on E6 requires E6_HARDWARE_SERIAL or E6_SERIAL_(RX|TX)_PIN." #error "TMC2208 or TMC2209 on E6 requires E6_HARDWARE_SERIAL or E6_SERIAL_(RX|TX)_PIN."
#elif INVALID_TMC_UART(E7) #elif INVALID_TMC_UART(E7)
#error "TMC2208 or TMC2209 on E7 requires E7_HARDWARE_SERIAL or E7_SERIAL_(RX|TX)_PIN." #error "TMC2208 or TMC2209 on E7 requires E7_HARDWARE_SERIAL or E7_SERIAL_(RX|TX)_PIN."
#elif LINEAR_AXES >= 4 && INVALID_TMC_UART(I) #elif HAS_I_AXIS && INVALID_TMC_UART(I)
#error "TMC2208 or TMC2209 on I requires I_HARDWARE_SERIAL or I_SERIAL_(RX|TX)_PIN." #error "TMC2208 or TMC2209 on I requires I_HARDWARE_SERIAL or I_SERIAL_(RX|TX)_PIN."
#elif LINEAR_AXES >= 5 && INVALID_TMC_UART(J) #elif HAS_J_AXIS && INVALID_TMC_UART(J)
#error "TMC2208 or TMC2209 on J requires J_HARDWARE_SERIAL or J_SERIAL_(RX|TX)_PIN." #error "TMC2208 or TMC2209 on J requires J_HARDWARE_SERIAL or J_SERIAL_(RX|TX)_PIN."
#elif LINEAR_AXES >= 6 && INVALID_TMC_UART(K) #elif HAS_K_AXIS && INVALID_TMC_UART(K)
#error "TMC2208 or TMC2209 on K requires K_HARDWARE_SERIAL or K_SERIAL_(RX|TX)_PIN." #error "TMC2208 or TMC2209 on K requires K_HARDWARE_SERIAL or K_SERIAL_(RX|TX)_PIN."
#endif #endif
#undef INVALID_TMC_UART #undef INVALID_TMC_UART
@ -3026,11 +3044,11 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
INVALID_TMC_MS(E6) INVALID_TMC_MS(E6)
#elif !TMC_MICROSTEP_IS_VALID(E7) #elif !TMC_MICROSTEP_IS_VALID(E7)
INVALID_TMC_MS(E7) INVALID_TMC_MS(E7)
#elif LINEAR_AXES >= 4 && !TMC_MICROSTEP_IS_VALID(I) #elif HAS_I_AXIS && !TMC_MICROSTEP_IS_VALID(I)
INVALID_TMC_MS(I) INVALID_TMC_MS(I)
#elif LINEAR_AXES >= 5 && !TMC_MICROSTEP_IS_VALID(J) #elif HAS_J_AXIS && !TMC_MICROSTEP_IS_VALID(J)
INVALID_TMC_MS(J) INVALID_TMC_MS(J)
#elif LINEAR_AXES >= 6 && !TMC_MICROSTEP_IS_VALID(K) #elif HAS_K_AXIS && !TMC_MICROSTEP_IS_VALID(K)
INVALID_TMC_MS(K) INVALID_TMC_MS(K)
#endif #endif
#undef INVALID_TMC_MS #undef INVALID_TMC_MS
@ -3052,13 +3070,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#define X_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(X,TMC2209) #define X_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(X,TMC2209)
#define Y_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(Y,TMC2209) #define Y_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(Y,TMC2209)
#define Z_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(Z,TMC2209) #define Z_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(Z,TMC2209)
#if LINEAR_AXES >= 4 #if HAS_I_AXIS
#define I_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(I,TMC2209) #define I_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(I,TMC2209)
#endif #endif
#if LINEAR_AXES >= 5 #if HAS_J_AXIS
#define J_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(J,TMC2209) #define J_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(J,TMC2209)
#endif #endif
#if LINEAR_AXES >= 6 #if HAS_K_AXIS
#define K_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(K,TMC2209) #define K_ENDSTOP_INVERTING !AXIS_DRIVER_TYPE(K,TMC2209)
#endif #endif
@ -3075,17 +3093,17 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_ZMIN (or ENDSTOPPULLUPS) when homing to Z_MIN." #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_ZMIN (or ENDSTOPPULLUPS) when homing to Z_MIN."
#elif Z_SENSORLESS && Z_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_ZMAX) #elif Z_SENSORLESS && Z_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_ZMAX)
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_ZMAX (or ENDSTOPPULLUPS) when homing to Z_MAX." #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_ZMAX (or ENDSTOPPULLUPS) when homing to Z_MAX."
#elif LINEAR_AXES >= 4 && I_SENSORLESS && I_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_IMIN) #elif ALL(HAS_I_AXIS, I_SENSORLESS, I_HOME_TO_MIN) && DISABLED(ENDSTOPPULLUP_IMIN)
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_IMIN (or ENDSTOPPULLUPS) when homing to I_MIN." #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_IMIN (or ENDSTOPPULLUPS) when homing to I_MIN."
#elif LINEAR_AXES >= 4 && I_SENSORLESS && I_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_IMAX) #elif ALL(HAS_I_AXIS, I_SENSORLESS, I_HOME_TO_MAX) && DISABLED(ENDSTOPPULLUP_IMAX)
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_IMAX (or ENDSTOPPULLUPS) when homing to I_MAX." #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_IMAX (or ENDSTOPPULLUPS) when homing to I_MAX."
#elif LINEAR_AXES >= 5 && J_SENSORLESS && J_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_JMIN) #elif ALL(HAS_J_AXIS, J_SENSORLESS, J_HOME_TO_MIN) && DISABLED(ENDSTOPPULLUP_JMIN)
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_JMIN (or ENDSTOPPULLUPS) when homing to J_MIN." #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_JMIN (or ENDSTOPPULLUPS) when homing to J_MIN."
#elif LINEAR_AXES >= 5 && J_SENSORLESS && J_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_JMAX) #elif ALL(HAS_J_AXIS, J_SENSORLESS, J_HOME_TO_MAX) && DISABLED(ENDSTOPPULLUP_JMAX)
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_JMAX (or ENDSTOPPULLUPS) when homing to J_MAX." #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_JMAX (or ENDSTOPPULLUPS) when homing to J_MAX."
#elif LINEAR_AXES >= 6 && K_SENSORLESS && K_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_KMIN) #elif ALL(HAS_K_AXIS, K_SENSORLESS, K_HOME_TO_MIN) && DISABLED(ENDSTOPPULLUP_KMIN)
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_KMIN (or ENDSTOPPULLUPS) when homing to K_MIN." #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_KMIN (or ENDSTOPPULLUPS) when homing to K_MIN."
#elif LINEAR_AXES >= 6 && K_SENSORLESS && K_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_KMAX) #elif ALL(HAS_K_AXIS, K_SENSORLESS, K_HOME_TO_MAX) && DISABLED(ENDSTOPPULLUP_KMAX)
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_KMAX (or ENDSTOPPULLUPS) when homing to K_MAX." #error "SENSORLESS_HOMING requires ENDSTOPPULLUP_KMAX (or ENDSTOPPULLUPS) when homing to K_MAX."
#endif #endif
#endif #endif
@ -3131,37 +3149,37 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#else #else
#error "SENSORLESS_HOMING requires Z_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to Z_MAX." #error "SENSORLESS_HOMING requires Z_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to Z_MAX."
#endif #endif
#elif LINEAR_AXES >= 4 && I_SENSORLESS && I_HOME_TO_MIN && I_MIN_ENDSTOP_INVERTING != I_ENDSTOP_INVERTING #elif ALL(HAS_I_AXIS, I_SENSORLESS, I_HOME_TO_MIN) && I_MIN_ENDSTOP_INVERTING != I_ENDSTOP_INVERTING
#if I_ENDSTOP_INVERTING #if I_ENDSTOP_INVERTING
#error "SENSORLESS_HOMING requires I_MIN_ENDSTOP_INVERTING = true when homing to I_MIN." #error "SENSORLESS_HOMING requires I_MIN_ENDSTOP_INVERTING = true when homing to I_MIN."
#else #else
#error "SENSORLESS_HOMING requires I_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to I_MIN." #error "SENSORLESS_HOMING requires I_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to I_MIN."
#endif #endif
#elif LINEAR_AXES >= 4 && I_SENSORLESS && I_HOME_TO_MAX && I_MAX_ENDSTOP_INVERTING != I_ENDSTOP_INVERTING #elif ALL(HAS_I_AXIS, I_SENSORLESS, I_HOME_TO_MAX) && I_MAX_ENDSTOP_INVERTING != I_ENDSTOP_INVERTING
#if I_ENDSTOP_INVERTING #if I_ENDSTOP_INVERTING
#error "SENSORLESS_HOMING requires I_MAX_ENDSTOP_INVERTING = true when homing to I_MAX." #error "SENSORLESS_HOMING requires I_MAX_ENDSTOP_INVERTING = true when homing to I_MAX."
#else #else
#error "SENSORLESS_HOMING requires I_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to I_MAX." #error "SENSORLESS_HOMING requires I_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to I_MAX."
#endif #endif
#elif LINEAR_AXES >= 5 && J_SENSORLESS && J_HOME_TO_MIN && J_MIN_ENDSTOP_INVERTING != J_ENDSTOP_INVERTING #elif ALL(HAS_J_AXIS, J_SENSORLESS, J_HOME_TO_MIN) && J_MIN_ENDSTOP_INVERTING != J_ENDSTOP_INVERTING
#if J_ENDSTOP_INVERTING #if J_ENDSTOP_INVERTING
#error "SENSORLESS_HOMING requires J_MIN_ENDSTOP_INVERTING = true when homing to J_MIN." #error "SENSORLESS_HOMING requires J_MIN_ENDSTOP_INVERTING = true when homing to J_MIN."
#else #else
#error "SENSORLESS_HOMING requires J_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to J_MIN." #error "SENSORLESS_HOMING requires J_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to J_MIN."
#endif #endif
#elif LINEAR_AXES >= 5 && J_SENSORLESS && J_HOME_TO_MAX && J_MAX_ENDSTOP_INVERTING != J_ENDSTOP_INVERTING #elif ALL(HAS_J_AXIS, J_SENSORLESS, J_HOME_TO_MAX) && J_MAX_ENDSTOP_INVERTING != J_ENDSTOP_INVERTING
#if J_ENDSTOP_INVERTING #if J_ENDSTOP_INVERTING
#error "SENSORLESS_HOMING requires J_MAX_ENDSTOP_INVERTING = true when homing to J_MAX." #error "SENSORLESS_HOMING requires J_MAX_ENDSTOP_INVERTING = true when homing to J_MAX."
#else #else
#error "SENSORLESS_HOMING requires J_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to J_MAX." #error "SENSORLESS_HOMING requires J_MAX_ENDSTOP_INVERTING = false when homing TMC2209 to J_MAX."
#endif #endif
#elif LINEAR_AXES >= 6 && K_SENSORLESS && K_HOME_TO_MIN && K_MIN_ENDSTOP_INVERTING != K_ENDSTOP_INVERTING #elif ALL(HAS_K_AXIS, K_SENSORLESS, K_HOME_TO_MIN) && K_MIN_ENDSTOP_INVERTING != K_ENDSTOP_INVERTING
#if K_ENDSTOP_INVERTING #if K_ENDSTOP_INVERTING
#error "SENSORLESS_HOMING requires K_MIN_ENDSTOP_INVERTING = true when homing to K_MIN." #error "SENSORLESS_HOMING requires K_MIN_ENDSTOP_INVERTING = true when homing to K_MIN."
#else #else
#error "SENSORLESS_HOMING requires K_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to K_MIN." #error "SENSORLESS_HOMING requires K_MIN_ENDSTOP_INVERTING = false when homing TMC2209 to K_MIN."
#endif #endif
#elif LINEAR_AXES >= 6 && K_SENSORLESS && K_HOME_TO_MAX && K_MAX_ENDSTOP_INVERTING != K_ENDSTOP_INVERTING #elif ALL(HAS_K_AXIS, K_SENSORLESS, K_HOME_TO_MAX) && K_MAX_ENDSTOP_INVERTING != K_ENDSTOP_INVERTING
#if K_ENDSTOP_INVERTING #if K_ENDSTOP_INVERTING
#error "SENSORLESS_HOMING requires K_MAX_ENDSTOP_INVERTING = true when homing to K_MAX." #error "SENSORLESS_HOMING requires K_MAX_ENDSTOP_INVERTING = true when homing to K_MAX."
#else #else
@ -3285,7 +3303,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
/** /**
* L64XX requirement * L64XX requirement
*/ */
#if HAS_L64XX && LINEAR_AXES >= 4 #if HAS_L64XX && HAS_I_AXIS
#error "L64XX requires LINEAR_AXES 3. Homing with L64XX is not yet implemented for LINEAR_AXES > 3." #error "L64XX requires LINEAR_AXES 3. Homing with L64XX is not yet implemented for LINEAR_AXES > 3."
#endif #endif
@ -3664,7 +3682,7 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive.");
#error "COOLANT_FLOOD requires COOLANT_FLOOD_PIN to be defined." #error "COOLANT_FLOOD requires COOLANT_FLOOD_PIN to be defined."
#endif #endif
#if NONE(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI) && ENABLED(PRINT_PROGRESS_SHOW_DECIMALS) #if NONE(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI, IS_DWIN_MARLINUI) && ENABLED(PRINT_PROGRESS_SHOW_DECIMALS)
#error "PRINT_PROGRESS_SHOW_DECIMALS currently requires a Graphical LCD." #error "PRINT_PROGRESS_SHOW_DECIMALS currently requires a Graphical LCD."
#endif #endif
@ -3760,17 +3778,17 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive.");
#if _BAD_DRIVER(Z) #if _BAD_DRIVER(Z)
#error "Z_DRIVER_TYPE is not recognized." #error "Z_DRIVER_TYPE is not recognized."
#endif #endif
#if LINEAR_AXES >= 4 #if HAS_I_AXIS
#if _BAD_DRIVER(I) #if _BAD_DRIVER(I)
#error "I_DRIVER_TYPE is not recognized." #error "I_DRIVER_TYPE is not recognized."
#endif #endif
#endif #endif
#if LINEAR_AXES >= 5 #if HAS_J_AXIS
#if _BAD_DRIVER(J) #if _BAD_DRIVER(J)
#error "J_DRIVER_TYPE is not recognized." #error "J_DRIVER_TYPE is not recognized."
#endif #endif
#endif #endif
#if LINEAR_AXES >= 6 #if HAS_K_AXIS
#if _BAD_DRIVER(K) #if _BAD_DRIVER(K)
#error "K_DRIVER_TYPE is not recognized." #error "K_DRIVER_TYPE is not recognized."
#endif #endif

2
Marlin/src/inc/Version.h

@ -42,7 +42,7 @@
* version was tagged. * version was tagged.
*/ */
#ifndef STRING_DISTRIBUTION_DATE #ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "2021-09-03" #define STRING_DISTRIBUTION_DATE "2021-12-25"
#endif #endif
/** /**

62
Marlin/src/lcd/buttons.h

@ -45,36 +45,6 @@
#define ENCODER_PHASE_3 1 #define ENCODER_PHASE_3 1
#endif #endif
#if IS_RRW_KEYPAD
#define BTN_OFFSET 0 // Bit offset into buttons for shift register values
#define BLEN_KEYPAD_F3 0
#define BLEN_KEYPAD_F2 1
#define BLEN_KEYPAD_F1 2
#define BLEN_KEYPAD_DOWN 3
#define BLEN_KEYPAD_RIGHT 4
#define BLEN_KEYPAD_MIDDLE 5
#define BLEN_KEYPAD_UP 6
#define BLEN_KEYPAD_LEFT 7
#define EN_KEYPAD_F1 _BV(BTN_OFFSET + BLEN_KEYPAD_F1)
#define EN_KEYPAD_F2 _BV(BTN_OFFSET + BLEN_KEYPAD_F2)
#define EN_KEYPAD_F3 _BV(BTN_OFFSET + BLEN_KEYPAD_F3)
#define EN_KEYPAD_DOWN _BV(BTN_OFFSET + BLEN_KEYPAD_DOWN)
#define EN_KEYPAD_RIGHT _BV(BTN_OFFSET + BLEN_KEYPAD_RIGHT)
#define EN_KEYPAD_MIDDLE _BV(BTN_OFFSET + BLEN_KEYPAD_MIDDLE)
#define EN_KEYPAD_UP _BV(BTN_OFFSET + BLEN_KEYPAD_UP)
#define EN_KEYPAD_LEFT _BV(BTN_OFFSET + BLEN_KEYPAD_LEFT)
#define RRK(B) (keypad_buttons & (B))
#ifdef EN_C
#define BUTTON_CLICK() ((buttons & EN_C) || RRK(EN_KEYPAD_MIDDLE))
#else
#define BUTTON_CLICK() RRK(EN_KEYPAD_MIDDLE)
#endif
#endif
#if EITHER(HAS_DIGITAL_BUTTONS, HAS_DWIN_E3V2) #if EITHER(HAS_DIGITAL_BUTTONS, HAS_DWIN_E3V2)
// Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes) // Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes)
#define BLEN_A 0 #define BLEN_A 0
@ -141,8 +111,40 @@
#define B_ST _BV(BL_ST) #define B_ST _BV(BL_ST)
#ifndef BUTTON_CLICK #ifndef BUTTON_CLICK
#if EN_C
#define BUTTON_CLICK() (buttons & (B_MI|B_ST)) #define BUTTON_CLICK() (buttons & (B_MI|B_ST))
#endif #endif
#endif
#endif
#if IS_RRW_KEYPAD
#define BTN_OFFSET 0 // Bit offset into buttons for shift register values
#define BLEN_KEYPAD_F3 0
#define BLEN_KEYPAD_F2 1
#define BLEN_KEYPAD_F1 2
#define BLEN_KEYPAD_DOWN 3
#define BLEN_KEYPAD_RIGHT 4
#define BLEN_KEYPAD_MIDDLE 5
#define BLEN_KEYPAD_UP 6
#define BLEN_KEYPAD_LEFT 7
#define EN_KEYPAD_F1 _BV(BTN_OFFSET + BLEN_KEYPAD_F1)
#define EN_KEYPAD_F2 _BV(BTN_OFFSET + BLEN_KEYPAD_F2)
#define EN_KEYPAD_F3 _BV(BTN_OFFSET + BLEN_KEYPAD_F3)
#define EN_KEYPAD_DOWN _BV(BTN_OFFSET + BLEN_KEYPAD_DOWN)
#define EN_KEYPAD_RIGHT _BV(BTN_OFFSET + BLEN_KEYPAD_RIGHT)
#define EN_KEYPAD_MIDDLE _BV(BTN_OFFSET + BLEN_KEYPAD_MIDDLE)
#define EN_KEYPAD_UP _BV(BTN_OFFSET + BLEN_KEYPAD_UP)
#define EN_KEYPAD_LEFT _BV(BTN_OFFSET + BLEN_KEYPAD_LEFT)
#define RRK(B) (keypad_buttons & (B))
#ifdef EN_C
#define BUTTON_CLICK() ((buttons & EN_C) || RRK(EN_KEYPAD_MIDDLE))
#else
#define BUTTON_CLICK() RRK(EN_KEYPAD_MIDDLE)
#endif
#endif #endif
#ifndef EN_A #ifndef EN_A

10
Marlin/src/lcd/e3v2/creality/dwin.cpp

@ -1754,7 +1754,7 @@ void update_variable() {
if (_new_hotend_target) if (_new_hotend_target)
Draw_Stat_Int(25 + 4 * STAT_CHR_W + 6, 384, _hotendtarget); Draw_Stat_Int(25 + 4 * STAT_CHR_W + 6, 384, _hotendtarget);
static int16_t _flow = planner.flow_percentage[0]; static int16_t _flow = 0;
if (_flow != planner.flow_percentage[0]) { if (_flow != planner.flow_percentage[0]) {
_flow = planner.flow_percentage[0]; _flow = planner.flow_percentage[0];
Draw_Stat_Int(116 + 2 * STAT_CHR_W, 417, _flow); Draw_Stat_Int(116 + 2 * STAT_CHR_W, 417, _flow);
@ -1768,7 +1768,7 @@ void update_variable() {
Draw_Stat_Int(25 + 4 * STAT_CHR_W + 6, 417, _bedtarget); Draw_Stat_Int(25 + 4 * STAT_CHR_W + 6, 417, _bedtarget);
#endif #endif
static int16_t _feedrate = 100; static int16_t _feedrate = 0;
if (_feedrate != feedrate_percentage) { if (_feedrate != feedrate_percentage) {
_feedrate = feedrate_percentage; _feedrate = feedrate_percentage;
Draw_Stat_Int(116 + 2 * STAT_CHR_W, 384, _feedrate); Draw_Stat_Int(116 + 2 * STAT_CHR_W, 384, _feedrate);
@ -2269,6 +2269,8 @@ void HMI_SelectFile() {
// thermalManager.fan_speed[i] = 255; // thermalManager.fan_speed[i] = 255;
#endif #endif
_card_percent = 0;
_remain_time = 0;
Goto_PrintProcess(); Goto_PrintProcess();
} }
} }
@ -4173,10 +4175,7 @@ void EachMomentUpdate() {
} }
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off else if (DWIN_lcd_sd_status && recovery.dwin_flag) { // resume print before power off
static bool recovery_flag = false;
recovery.dwin_flag = false; recovery.dwin_flag = false;
recovery_flag = true;
auto update_selection = [&](const bool sel) { auto update_selection = [&](const bool sel) {
HMI_flag.select_flag = sel; HMI_flag.select_flag = sel;
@ -4196,6 +4195,7 @@ void EachMomentUpdate() {
DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, npos, 252, name); DWIN_Draw_String(true, font8x16, Popup_Text_Color, Color_Bg_Window, npos, 252, name);
DWIN_UpdateLCD(); DWIN_UpdateLCD();
bool recovery_flag = true;
while (recovery_flag) { while (recovery_flag) {
EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
if (encoder_diffState != ENCODER_DIFF_NO) { if (encoder_diffState != ENCODER_DIFF_NO) {

1071
Marlin/src/lcd/e3v2/enhanced/dwin.cpp

File diff suppressed because it is too large

93
Marlin/src/lcd/e3v2/enhanced/dwin.h

@ -24,8 +24,8 @@
/** /**
* DWIN UI Enhanced implementation * DWIN UI Enhanced implementation
* Author: Miguel A. Risco-Castillo * Author: Miguel A. Risco-Castillo
* Version: 3.7.1 * Version: 3.9.1
* Date: 2021/11/09 * Date: 2021/11/21
*/ */
#include "../../../inc/MarlinConfigPre.h" #include "../../../inc/MarlinConfigPre.h"
@ -45,7 +45,7 @@
#define HAS_ZOFFSET_ITEM 1 #define HAS_ZOFFSET_ITEM 1
#endif #endif
static constexpr size_t eeprom_data_size = 64; #include "dwin_defines.h"
enum processID : uint8_t { enum processID : uint8_t {
// Process ID // Process ID
@ -59,11 +59,16 @@ enum processID : uint8_t {
SelectFile, SelectFile,
PrintProcess, PrintProcess,
PrintDone, PrintDone,
PwrlossRec,
Reboot,
Info, Info,
// Popup Windows // Popup Windows
Homing, Homing,
Leveling, Leveling,
PidProcess,
ESDiagProcess,
PrintStatsProcess,
PauseOrStop, PauseOrStop,
FilamentPurge, FilamentPurge,
WaitResponse, WaitResponse,
@ -97,39 +102,6 @@ typedef struct {
void (*LiveUpdate)() = nullptr; // Auxiliar live update function void (*LiveUpdate)() = nullptr; // Auxiliar live update function
} HMI_value_t; } HMI_value_t;
typedef struct {
uint16_t Background_Color = Def_Background_Color;
uint16_t Cursor_color = Def_Cursor_color;
uint16_t TitleBg_color = Def_TitleBg_color;
uint16_t TitleTxt_color = Def_TitleTxt_color;
uint16_t Text_Color = Def_Text_Color;
uint16_t Selected_Color = Def_Selected_Color;
uint16_t SplitLine_Color = Def_SplitLine_Color;
uint16_t Highlight_Color = Def_Highlight_Color;
uint16_t StatusBg_Color = Def_StatusBg_Color;
uint16_t StatusTxt_Color = Def_StatusTxt_Color;
uint16_t PopupBg_color = Def_PopupBg_color;
uint16_t PopupTxt_Color = Def_PopupTxt_Color;
uint16_t AlertBg_Color = Def_AlertBg_Color;
uint16_t AlertTxt_Color = Def_AlertTxt_Color;
uint16_t PercentTxt_Color = Def_PercentTxt_Color;
uint16_t Barfill_Color = Def_Barfill_Color;
uint16_t Indicator_Color = Def_Indicator_Color;
uint16_t Coordinate_Color = Def_Coordinate_Color;
#if HAS_PREHEAT
#ifdef PREHEAT_1_TEMP_HOTEND
int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND;
int16_t PidCycles = 10;
#endif
#ifdef PREHEAT_1_TEMP_BED
int16_t BedPidT = PREHEAT_1_TEMP_BED;
#endif
#endif
#if ENABLED(PREVENT_COLD_EXTRUSION)
int16_t ExtMinT = EXTRUDE_MINTEMP;
#endif
} HMI_data_t;
typedef struct { typedef struct {
uint8_t language; uint8_t language;
bool pause_flag:1; // printing is paused bool pause_flag:1; // printing is paused
@ -138,15 +110,24 @@ typedef struct {
bool select_flag:1; // Popup button selected bool select_flag:1; // Popup button selected
bool home_flag:1; // homing in course bool home_flag:1; // homing in course
bool heat_flag:1; // 0: heating done 1: during heating bool heat_flag:1; // 0: heating done 1: during heating
bool lock_flag:1; // 0: lock called from AdvSet 1: lock called from Tune
} HMI_flag_t; } HMI_flag_t;
extern HMI_value_t HMI_value; extern HMI_value_t HMI_value;
extern HMI_flag_t HMI_flag; extern HMI_flag_t HMI_flag;
extern HMI_data_t HMI_data;
extern uint8_t checkkey; extern uint8_t checkkey;
extern millis_t dwin_heat_time; extern millis_t dwin_heat_time;
// Popups
#if HAS_HOTEND || HAS_HEATED_BED
void DWIN_Popup_Temperature(const bool toohigh);
#endif
#if HAS_HOTEND
void Popup_Window_ETempTooLow();
#endif
#if ENABLED(POWER_LOSS_RECOVERY)
void Popup_PowerLossRecovery();
#endif
// SD Card // SD Card
void HMI_SDCardInit(); void HMI_SDCardInit();
void HMI_SDCardUpdate(); void HMI_SDCardUpdate();
@ -154,8 +135,8 @@ void HMI_SDCardUpdate();
// Other // Other
void Goto_PrintProcess(); void Goto_PrintProcess();
void Goto_Main_Menu(); void Goto_Main_Menu();
void Goto_InfoMenu(); void Goto_Info_Menu();
void Draw_Select_Highlight(const bool sel); void Goto_PowerLossRecovery();
void Draw_Status_Area(const bool with_update); // Status Area void Draw_Status_Area(const bool with_update); // Status Area
void Draw_Main_Area(); // Redraw main area; void Draw_Main_Area(); // Redraw main area;
void DWIN_Redraw_screen(); // Redraw all screen elements void DWIN_Redraw_screen(); // Redraw all screen elements
@ -204,11 +185,18 @@ void DWIN_RebootScreen();
#endif #endif
// Utility and extensions // Utility and extensions
void DWIN_LockScreen();
void DWIN_UnLockScreen();
void HMI_LockScreen(); void HMI_LockScreen();
void DWIN_LockScreen(const bool flag = true);
#if HAS_MESH #if HAS_MESH
void DWIN_MeshViewer(); void DWIN_MeshViewer();
#endif #endif
#if HAS_ESDIAG
void Draw_EndStopDiag();
#endif
#if ENABLED(PRINTCOUNTER)
void Draw_PrintStats();
#endif
// HMI user control functions // HMI user control functions
void HMI_Menu(); void HMI_Menu();
@ -223,7 +211,7 @@ void Draw_Control_Menu();
void Draw_AdvancedSettings_Menu(); void Draw_AdvancedSettings_Menu();
void Draw_Prepare_Menu(); void Draw_Prepare_Menu();
void Draw_Move_Menu(); void Draw_Move_Menu();
void Draw_LevBedCorners_Menu(); void Draw_Tramming_Menu();
#if HAS_HOME_OFFSET #if HAS_HOME_OFFSET
void Draw_HomeOffset_Menu(); void Draw_HomeOffset_Menu();
#endif #endif
@ -262,23 +250,6 @@ void Draw_Steps_Menu();
#if EITHER(HAS_BED_PROBE, BABYSTEPPING) #if EITHER(HAS_BED_PROBE, BABYSTEPPING)
void Draw_ZOffsetWiz_Menu(); void Draw_ZOffsetWiz_Menu();
#endif #endif
#if ENABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU)
// Popup windows void Draw_Homing_Menu();
void DWIN_Draw_Popup(const uint8_t icon, const char * const cmsg1, FSTR_P const fmsg2, uint8_t button=0);
void DWIN_Draw_Popup(const uint8_t icon, FSTR_P const fmsg1=nullptr, FSTR_P const fmsg2=nullptr, uint8_t button=0);
template<typename T, typename U>
void DWIN_Popup_Confirm(const uint8_t icon, T amsg1, U amsg2) {
HMI_SaveProcessID(WaitResponse);
DWIN_Draw_Popup(icon, amsg1, amsg2, ICON_Confirm_E); // Button Confirm
DWIN_UpdateLCD();
}
#if HAS_HOTEND || HAS_HEATED_BED
void DWIN_Popup_Temperature(const bool toohigh);
#endif
#if HAS_HOTEND
void Popup_Window_ETempTooLow();
#endif #endif
void Popup_Window_Resume();

92
Marlin/src/lcd/e3v2/enhanced/dwin_defines.h

@ -0,0 +1,92 @@
/**
* 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
/**
* DWIN general defines and data structs
* Author: Miguel A. Risco-Castillo
* Version: 3.9.1
* Date: 2021/11/21
*/
#include "../../../core/types.h"
#include "../common/dwin_color.h"
#define Def_Background_Color RGB( 1, 12, 8)
#define Def_Cursor_color RGB(20, 49, 31)
#define Def_TitleBg_color RGB( 0, 23, 16)
#define Def_TitleTxt_color Color_White
#define Def_Text_Color Color_White
#define Def_Selected_Color Select_Color
#define Def_SplitLine_Color RGB( 0, 23, 16)
#define Def_Highlight_Color Color_White
#define Def_StatusBg_Color RGB( 0, 23, 16)
#define Def_StatusTxt_Color Color_Yellow
#define Def_PopupBg_color Color_Bg_Window
#define Def_PopupTxt_Color Popup_Text_Color
#define Def_AlertBg_Color Color_Bg_Red
#define Def_AlertTxt_Color Color_Yellow
#define Def_PercentTxt_Color Percent_Color
#define Def_Barfill_Color BarFill_Color
#define Def_Indicator_Color Color_White
#define Def_Coordinate_Color Color_White
#define HAS_ESDIAG 1
#define DEFAULT_LCD_BRIGHTNESS 127
typedef struct {
// Color settings
uint16_t Background_Color = Def_Background_Color;
uint16_t Cursor_color = Def_Cursor_color;
uint16_t TitleBg_color = Def_TitleBg_color;
uint16_t TitleTxt_color = Def_TitleTxt_color;
uint16_t Text_Color = Def_Text_Color;
uint16_t Selected_Color = Def_Selected_Color;
uint16_t SplitLine_Color = Def_SplitLine_Color;
uint16_t Highlight_Color = Def_Highlight_Color;
uint16_t StatusBg_Color = Def_StatusBg_Color;
uint16_t StatusTxt_Color = Def_StatusTxt_Color;
uint16_t PopupBg_color = Def_PopupBg_color;
uint16_t PopupTxt_Color = Def_PopupTxt_Color;
uint16_t AlertBg_Color = Def_AlertBg_Color;
uint16_t AlertTxt_Color = Def_AlertTxt_Color;
uint16_t PercentTxt_Color = Def_PercentTxt_Color;
uint16_t Barfill_Color = Def_Barfill_Color;
uint16_t Indicator_Color = Def_Indicator_Color;
uint16_t Coordinate_Color = Def_Coordinate_Color;
//
#if defined(PREHEAT_1_TEMP_HOTEND) && HAS_HOTEND
int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND;
#endif
#if defined(PREHEAT_1_TEMP_BED) && HAS_HEATED_BED
int16_t BedPidT = PREHEAT_1_TEMP_BED;
#endif
#if ANY(HAS_HOTEND, HAS_HEATED_BED)
int16_t PidCycles = 10;
#endif
#if ENABLED(PREVENT_COLD_EXTRUSION)
int16_t ExtMinT = EXTRUDE_MINTEMP;
#endif
} HMI_data_t;
static constexpr size_t eeprom_data_size = 64;
extern HMI_data_t HMI_data;

2
Marlin/src/lcd/e3v2/enhanced/dwin_lcd.cpp

@ -23,7 +23,7 @@
/** /**
* DWIN UI Enhanced implementation * DWIN UI Enhanced implementation
* Author: Miguel A. Risco-Castillo * Author: Miguel A. Risco-Castillo
* Version: 3.7.1 * Version: 3.8.1
* Date: 2021/11/09 * Date: 2021/11/09
*/ */

2
Marlin/src/lcd/e3v2/enhanced/dwin_lcd.h

@ -24,7 +24,7 @@
/** /**
* DWIN UI Enhanced implementation * DWIN UI Enhanced implementation
* Author: Miguel A. Risco-Castillo * Author: Miguel A. Risco-Castillo
* Version: 3.7.1 * Version: 3.8.1
* Date: 2021/11/09 * Date: 2021/11/09
*/ */

55
Marlin/src/lcd/e3v2/enhanced/dwin_popup.cpp

@ -0,0 +1,55 @@
/**
* 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/>.
*
*/
/**
* DWIN UI Enhanced implementation
* Author: Miguel A. Risco-Castillo
* Version: 3.8.1
* Date: 2021/11/06
*/
#include "dwin.h"
#include "dwin_popup.h"
void Draw_Select_Highlight(const bool sel) {
HMI_flag.select_flag = sel;
const uint16_t c1 = sel ? HMI_data.Highlight_Color : HMI_data.PopupBg_color,
c2 = sel ? HMI_data.PopupBg_color : HMI_data.Highlight_Color;
DWIN_Draw_Rectangle(0, c1, 25, 279, 126, 318);
DWIN_Draw_Rectangle(0, c1, 24, 278, 127, 319);
DWIN_Draw_Rectangle(0, c2, 145, 279, 246, 318);
DWIN_Draw_Rectangle(0, c2, 144, 278, 247, 319);
}
void DWIN_Popup_Continue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2) {
HMI_SaveProcessID(WaitResponse);
DWIN_Draw_Popup(icon, fmsg1, fmsg2, ICON_Continue_E); // Button Continue
DWIN_UpdateLCD();
}
void DWIN_Popup_ConfirmCancel(const uint8_t icon, FSTR_P const fmsg2) {
DWIN_Draw_Popup(ICON_BLTouch, F("Please confirm"), fmsg2);
DWINUI::Draw_Icon(ICON_Confirm_E, 26, 280);
DWINUI::Draw_Icon(ICON_Cancel_E, 146, 280);
Draw_Select_Highlight(true);
DWIN_UpdateLCD();
}

62
Marlin/src/lcd/e3v2/enhanced/dwin_popup.h

@ -0,0 +1,62 @@
/**
* 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
/**
* DWIN UI Enhanced implementation
* Author: Miguel A. Risco-Castillo
* Version: 3.8.1
* Date: 2021/11/06
*/
#include "dwinui.h"
#include "dwin.h"
// Popup windows
void Draw_Select_Highlight(const bool sel);
inline void Draw_Popup_Bkgd() {
DWIN_Draw_Rectangle(1, HMI_data.PopupBg_color, 14, 60, 258, 330);
DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, 14, 60, 258, 330);
}
template<typename T, typename U>
void DWIN_Draw_Popup(const uint8_t icon, T amsg1=nullptr, U amsg2=nullptr, uint8_t button=0) {
DWINUI::ClearMenuArea();
Draw_Popup_Bkgd();
if (icon) DWINUI::Draw_Icon(icon, 101, 105);
if (amsg1) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 210, amsg1);
if (amsg2) DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 240, amsg2);
if (button) DWINUI::Draw_Icon(button, 86, 280);
}
template<typename T, typename U>
void DWIN_Popup_Confirm(const uint8_t icon, T amsg1, U amsg2) {
HMI_SaveProcessID(WaitResponse);
DWIN_Draw_Popup(icon, amsg1, amsg2, ICON_Confirm_E); // Button Confirm
DWIN_UpdateLCD();
}
void DWIN_Popup_Continue(const uint8_t icon, FSTR_P const fmsg1, FSTR_P const fmsg2);
void DWIN_Popup_ConfirmCancel(const uint8_t icon, FSTR_P const fmsg2);

3
Marlin/src/lcd/e3v2/enhanced/dwinui.cpp

@ -23,7 +23,7 @@
/** /**
* DWIN UI Enhanced implementation * DWIN UI Enhanced implementation
* Author: Miguel A. Risco-Castillo * Author: Miguel A. Risco-Castillo
* Version: 3.7.1 * Version: 3.8.1
* Date: 2021/11/09 * Date: 2021/11/09
*/ */
@ -34,6 +34,7 @@
#include "../../../inc/MarlinConfig.h" #include "../../../inc/MarlinConfig.h"
#include "dwin_lcd.h" #include "dwin_lcd.h"
#include "dwinui.h" #include "dwinui.h"
#include "dwin_defines.h"
//#define DEBUG_OUT 1 //#define DEBUG_OUT 1
#include "../../../core/debug_out.h" #include "../../../core/debug_out.h"

58
Marlin/src/lcd/e3v2/enhanced/dwinui.h

@ -24,8 +24,8 @@
/** /**
* DWIN UI Enhanced implementation * DWIN UI Enhanced implementation
* Author: Miguel A. Risco-Castillo * Author: Miguel A. Risco-Castillo
* Version: 3.7.1 * Version: 3.9.1
* Date: 2021/11/09 * Date: 2021/11/21
*/ */
#include "dwin_lcd.h" #include "dwin_lcd.h"
@ -38,13 +38,22 @@
#define ICON_Cancel ICON_StockConfiguration #define ICON_Cancel ICON_StockConfiguration
#define ICON_CustomPreheat ICON_SetEndTemp #define ICON_CustomPreheat ICON_SetEndTemp
#define ICON_Error ICON_TempTooHigh #define ICON_Error ICON_TempTooHigh
#define ICON_ESDiag ICON_Info
#define ICON_ExtrudeMinT ICON_HotendTemp #define ICON_ExtrudeMinT ICON_HotendTemp
#define ICON_FilLoad ICON_WriteEEPROM #define ICON_FilLoad ICON_WriteEEPROM
#define ICON_FilMan ICON_ResumeEEPROM #define ICON_FilMan ICON_ResumeEEPROM
#define ICON_FilSet ICON_ResumeEEPROM #define ICON_FilSet ICON_ResumeEEPROM
#define ICON_FilUnload ICON_ReadEEPROM #define ICON_FilUnload ICON_ReadEEPROM
#define ICON_Flow ICON_StepE #define ICON_Flow ICON_StepE
#define ICON_LevBed ICON_SetEndTemp #define ICON_FWRetLength ICON_StepE
#define ICON_FWRetSpeed ICON_Setspeed
#define ICON_FWRetZRaise ICON_MoveZ
#define ICON_FWRecSpeed ICON_Setspeed
#define ICON_HomeX ICON_MoveX
#define ICON_HomeY ICON_MoveY
#define ICON_HomeZ ICON_MoveZ
#define ICON_HSMode ICON_StockConfiguration
#define ICON_Tram ICON_SetEndTemp
#define ICON_Lock ICON_Cool #define ICON_Lock ICON_Cool
#define ICON_ManualMesh ICON_HotendTemp #define ICON_ManualMesh ICON_HotendTemp
#define ICON_MeshNext ICON_Axis #define ICON_MeshNext ICON_Axis
@ -52,9 +61,14 @@
#define ICON_MeshViewer ICON_HotendTemp #define ICON_MeshViewer ICON_HotendTemp
#define ICON_MoveZ0 ICON_HotendTemp #define ICON_MoveZ0 ICON_HotendTemp
#define ICON_Park ICON_Motion #define ICON_Park ICON_Motion
#define ICON_PIDbed ICON_SetBedTemp
#define ICON_PIDcycles ICON_ResumeEEPROM #define ICON_PIDcycles ICON_ResumeEEPROM
#define ICON_PIDValue ICON_Contact #define ICON_PIDValue ICON_Contact
#define ICON_PrintStats ICON_PrintTime
#define ICON_PrintStatsReset ICON_RemainTime
#define ICON_ProbeDeploy ICON_SetEndTemp
#define ICON_ProbeSet ICON_SetEndTemp #define ICON_ProbeSet ICON_SetEndTemp
#define ICON_ProbeStow ICON_SetEndTemp
#define ICON_ProbeTest ICON_SetEndTemp #define ICON_ProbeTest ICON_SetEndTemp
#define ICON_Pwrlossr ICON_Motion #define ICON_Pwrlossr ICON_Motion
#define ICON_Reboot ICON_ResumeEEPROM #define ICON_Reboot ICON_ResumeEEPROM
@ -63,25 +77,11 @@
#define ICON_SetCustomPreheat ICON_SetEndTemp #define ICON_SetCustomPreheat ICON_SetEndTemp
#define ICON_Sound ICON_Cool #define ICON_Sound ICON_Cool
// Default UI Colors // Extended and default UI Colors
#define Def_Background_Color Color_Bg_Black #define Color_Black 0
#define Def_Cursor_color Rectangle_Color #define Color_Green RGB(0,63,0)
#define Def_TitleBg_color Color_Bg_Blue #define Color_Aqua RGB(0,63,31)
#define Def_TitleTxt_color Color_White #define Color_Blue RGB(0,0,31)
#define Def_Text_Color Color_White
#define Def_Selected_Color Select_Color
#define Def_SplitLine_Color Line_Color
#define Def_Highlight_Color Color_White
#define Def_StatusBg_Color RGB(0,20,20)
#define Def_StatusTxt_Color Color_Yellow
#define Def_PopupBg_color Color_Bg_Window
#define Def_PopupTxt_Color Popup_Text_Color
#define Def_AlertBg_Color Color_Bg_Red
#define Def_AlertTxt_Color Color_Yellow
#define Def_PercentTxt_Color Percent_Color
#define Def_Barfill_Color BarFill_Color
#define Def_Indicator_Color Color_White
#define Def_Coordinate_Color Color_White
// UI element defines and constants // UI element defines and constants
#define DWIN_FONT_MENU font8x16 #define DWIN_FONT_MENU font8x16
@ -111,8 +111,8 @@ constexpr uint16_t TITLE_HEIGHT = 30, // Title bar heig
#define MBASE(L) (MYPOS(L) + CAPOFF) #define MBASE(L) (MYPOS(L) + CAPOFF)
// Create and add a MenuItem object to the menu array // Create and add a MenuItem object to the menu array
#define ADDMENUITEM(V...) DWINUI::MenuItemsAdd(new MenuItemClass(V)) #define MENU_ITEM(V...) DWINUI::MenuItemsAdd(new MenuItemClass(V))
#define ADDMENUITEM_P(V...) DWINUI::MenuItemsAdd(new MenuItemPtrClass(V)) #define EDIT_ITEM(V...) DWINUI::MenuItemsAdd(new MenuItemPtrClass(V))
typedef struct { uint16_t left, top, right, bottom; } rect_t; typedef struct { uint16_t left, top, right, bottom; } rect_t;
typedef struct { uint16_t x, y, w, h; } frame_rect_t; typedef struct { uint16_t x, y, w, h; } frame_rect_t;
@ -197,9 +197,11 @@ namespace DWINUI {
// Get font character width // Get font character width
uint8_t fontWidth(uint8_t cfont); uint8_t fontWidth(uint8_t cfont);
inline uint8_t fontWidth() { return fontWidth(font); };
// Get font character height // Get font character height
uint8_t fontHeight(uint8_t cfont); uint8_t fontHeight(uint8_t cfont);
inline uint8_t fontHeight() { return fontHeight(font); };
// Get screen x coordinates from text column // Get screen x coordinates from text column
uint16_t ColToX(uint8_t col); uint16_t ColToX(uint8_t col);
@ -412,6 +414,14 @@ namespace DWINUI {
Draw_CenteredString(false, font, textcolor, backcolor, y, title); Draw_CenteredString(false, font, textcolor, backcolor, y, title);
} }
// Draw a box
// mode: 0=frame, 1=fill, 2=XOR fill
// color: Rectangle color
// frame: Box coordinates and size
inline void Draw_Box(uint8_t mode, uint16_t color, frame_rect_t frame) {
DWIN_Draw_Box(mode, color, frame.x, frame.y, frame.w, frame.h);
}
// Draw a circle // Draw a circle
// Color: circle color // Color: circle color
// x: abscissa of the center of the circle // x: abscissa of the center of the circle

109
Marlin/src/lcd/e3v2/enhanced/endstop_diag.cpp

@ -0,0 +1,109 @@
/**
* 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/>.
*
*/
/**
* DWIN End Stops diagnostic page
* Author: Miguel A. Risco-Castillo
* Version: 1.0
* Date: 2021/11/06
*/
#include "../../../inc/MarlinConfigPre.h"
#include "dwin_defines.h"
#if BOTH(DWIN_CREALITY_LCD_ENHANCED, HAS_ESDIAG)
#include "endstop_diag.h"
#include "../../../core/types.h"
#include "../../marlinui.h"
#include "dwin_lcd.h"
#include "dwinui.h"
#include "dwin_popup.h"
#include "dwin.h"
#if HAS_FILAMENT_SENSOR
#include "../../../feature/runout.h"
#endif
#if HAS_BED_PROBE
#include "../../../module/probe.h"
#endif
ESDiagClass ESDiag;
void draw_es_label(FSTR_P const flabel=nullptr) {
DWINUI::cursor.x = 40;
if (flabel) DWINUI::Draw_String(F(flabel));
DWINUI::Draw_String(F(": "));
DWINUI::MoveBy(0, 25);
}
void draw_es_state(const bool is_hit) {
const uint8_t LM = 130;
DWINUI::cursor.x = LM;
DWIN_Draw_Rectangle(1, HMI_data.PopupBg_color, LM, DWINUI::cursor.y, LM + 100, DWINUI::cursor.y + 20);
is_hit ? DWINUI::Draw_String(RGB(31,31,16), F(STR_ENDSTOP_HIT)) : DWINUI::Draw_String(RGB(16,63,16), F(STR_ENDSTOP_OPEN));
DWINUI::MoveBy(0, 25);
}
void ESDiagClass::Draw() {
Title.ShowCaption(F("End-stops Diagnostic"));
DWINUI::ClearMenuArea();
Draw_Popup_Bkgd();
DWINUI::Draw_Icon(ICON_Continue_E, 86, 250);
DWINUI::cursor.y = 80;
#define ES_LABEL(S) draw_es_label(F(STR_##S))
#if HAS_X_MIN
ES_LABEL(X_MIN);
#endif
#if HAS_Y_MIN
ES_LABEL(Y_MIN);
#endif
#if HAS_Z_MIN
ES_LABEL(Z_MIN);
#endif
#if HAS_FILAMENT_SENSOR
draw_es_label(F(STR_FILAMENT));
#endif
Update();
}
void ESDiagClass::Update() {
DWINUI::cursor.y = 80;
#define ES_REPORT(S) draw_es_state(READ(S##_PIN) != S##_ENDSTOP_INVERTING)
#if HAS_X_MIN
ES_REPORT(X_MIN);
#endif
#if HAS_Y_MIN
ES_REPORT(Y_MIN);
#endif
#if HAS_Z_MIN
ES_REPORT(Z_MIN);
#endif
#if HAS_FILAMENT_SENSOR
draw_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE);
#endif
DWIN_UpdateLCD();
}
#endif // DWIN_CREALITY_LCD_ENHANCED && HAS_MESH

37
Marlin/src/lcd/e3v2/enhanced/endstop_diag.h

@ -0,0 +1,37 @@
/**
* 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
/**
* DWIN End Stops diagnostic page
* Author: Miguel A. Risco-Castillo
* Version: 1.0
* Date: 2021/11/06
*/
class ESDiagClass {
public:
void Draw();
void Update();
};
extern ESDiagClass ESDiag;

7
Marlin/src/lcd/e3v2/enhanced/lockscreen.cpp

@ -21,10 +21,10 @@
*/ */
/** /**
* DWIN UI Enhanced implementation * Lock screen implementation for DWIN UI Enhanced implementation
* Author: Miguel A. Risco-Castillo * Author: Miguel A. Risco-Castillo
* Version: 3.6.3 * Version: 2.1
* Date: 2021/09/08 * Date: 2021/11/09
*/ */
#include "../../../inc/MarlinConfigPre.h" #include "../../../inc/MarlinConfigPre.h"
@ -41,6 +41,7 @@ LockScreenClass lockScreen;
uint8_t LockScreenClass::lock_pos = 0; uint8_t LockScreenClass::lock_pos = 0;
bool LockScreenClass::unlocked = false; bool LockScreenClass::unlocked = false;
uint8_t LockScreenClass::rprocess = 0;
void LockScreenClass::init() { void LockScreenClass::init() {
lock_pos = 0; lock_pos = 0;

9
Marlin/src/lcd/e3v2/enhanced/lockscreen.h

@ -22,10 +22,10 @@
#pragma once #pragma once
/** /**
* DWIN UI Enhanced implementation * Lock screen implementation for DWIN UI Enhanced implementation
* Author: Miguel A. Risco-Castillo * Author: Miguel A. Risco-Castillo
* Version: 3.6.3 * Version: 2.1
* Date: 2021/09/08 * Date: 2021/11/09
*/ */
#include "../common/encoder.h" #include "../common/encoder.h"
@ -36,10 +36,11 @@ private:
static bool unlocked; static bool unlocked;
static uint8_t lock_pos; static uint8_t lock_pos;
public: public:
static uint8_t rprocess;
static void init(); static void init();
static void onEncoder(EncoderState encoder_diffState); static void onEncoder(EncoderState encoder_diffState);
static void draw(); static void draw();
static inline bool isUnlocked() { return unlocked; } static bool isUnlocked() { return unlocked; }
}; };
extern LockScreenClass lockScreen; extern LockScreenClass lockScreen;

22
Marlin/src/lcd/e3v2/enhanced/meshviewer.cpp

@ -1,12 +1,13 @@
/** /**
* DWIN Mesh Viewer * Marlin 3D Printer Firmware
* Author: Miguel A. Risco-Castillo * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* version: 3.8.1 *
* Date: 2021/11/06 * 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 * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as * it under the terms of the GNU General Public License as published by
* published by the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
@ -14,11 +15,18 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
* *
*/ */
/**
* DWIN Mesh Viewer
* Author: Miguel A. Risco-Castillo
* Version: 3.8.1
* Date: 2021/11/06
*/
#include "../../../inc/MarlinConfigPre.h" #include "../../../inc/MarlinConfigPre.h"
#if BOTH(DWIN_CREALITY_LCD_ENHANCED, HAS_MESH) #if BOTH(DWIN_CREALITY_LCD_ENHANCED, HAS_MESH)

22
Marlin/src/lcd/e3v2/enhanced/meshviewer.h

@ -1,12 +1,13 @@
/** /**
* DWIN Mesh Viewer * Marlin 3D Printer Firmware
* Author: Miguel A. Risco-Castillo * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Version: 3.8.1 *
* Date: 2021/11/06 * 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 * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as * it under the terms of the GNU General Public License as published by
* published by the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
@ -14,12 +15,19 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
* *
*/ */
#pragma once #pragma once
/**
* DWIN Mesh Viewer
* Author: Miguel A. Risco-Castillo
* Version: 3.8.1
* Date: 2021/11/06
*/
class MeshViewerClass { class MeshViewerClass {
public: public:
void Draw(); void Draw();

76
Marlin/src/lcd/e3v2/enhanced/printstats.cpp

@ -0,0 +1,76 @@
/**
* 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/>.
*
*/
/**
* DWIN Print Stats page
* Author: Miguel A. Risco-Castillo
* Version: 1.0
* Date: 2021/11/21
*/
#include "../../../inc/MarlinConfigPre.h"
#if BOTH(DWIN_CREALITY_LCD_ENHANCED, PRINTCOUNTER)
#include "printstats.h"
#include "../../../core/types.h"
#include "../../marlinui.h"
#include "../../../module/printcounter.h"
#include "dwin_lcd.h"
#include "dwinui.h"
#include "dwin_popup.h"
#include "dwin.h"
PrintStatsClass PrintStats;
void PrintStatsClass::Draw() {
char buf[50] = "";
char str[30] = "";
constexpr int8_t MRG = 30;
Title.ShowCaption(GET_TEXT_F(MSG_INFO_STATS_MENU));
DWINUI::ClearMenuArea();
Draw_Popup_Bkgd();
DWINUI::Draw_Icon(ICON_Continue_E, 86, 250);
printStatistics ps = print_job_timer.getStats();
sprintf_P(buf, PSTR(S_FMT ": %i"), GET_TEXT(MSG_INFO_PRINT_COUNT), ps.totalPrints);
DWINUI::Draw_String(MRG, 80, buf);
sprintf_P(buf, PSTR(S_FMT ": %i"), GET_TEXT(MSG_INFO_COMPLETED_PRINTS), ps.finishedPrints);
DWINUI::Draw_String(MRG, 100, buf);
duration_t(print_job_timer.getStats().printTime).toDigital(str, true);
sprintf_P(buf, PSTR(S_FMT ": %s"), GET_TEXT(MSG_INFO_PRINT_TIME), str);
DWINUI::Draw_String(MRG, 120, buf);
duration_t(print_job_timer.getStats().longestPrint).toDigital(str, true);
sprintf_P(buf, PSTR(S_FMT ": %s"), GET_TEXT(MSG_INFO_PRINT_LONGEST), str);
DWINUI::Draw_String(MRG, 140, buf);
sprintf_P(buf, PSTR(S_FMT ": %s m"), GET_TEXT(MSG_INFO_PRINT_FILAMENT), dtostrf(ps.filamentUsed / 1000, 1, 2, str));
DWINUI::Draw_String(MRG, 160, buf);
}
void PrintStatsClass::Reset() {
print_job_timer.initStats();
HMI_AudioFeedback();
}
#endif // DWIN_CREALITY_LCD_ENHANCED && PRINTCOUNTER

37
Marlin/src/lcd/e3v2/enhanced/printstats.h

@ -0,0 +1,37 @@
/**
* 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
/**
* DWIN Print Stats page
* Author: Miguel A. Risco-Castillo
* Version: 1.0
* Date: 2021/11/21
*/
class PrintStatsClass {
public:
void Draw();
static void Reset();
};
extern PrintStatsClass PrintStats;

16
Marlin/src/lcd/e3v2/marlinui/dwin_string.h

@ -55,7 +55,7 @@ class DWIN_String {
//static font_t *font() { return font_header; }; //static font_t *font() { return font_header; };
//static uint16_t font_height() { return font_header->FontAscent - font_header->FontDescent; } //static uint16_t font_height() { return font_header->FontAscent - font_header->FontDescent; }
//static glyph_t *glyph(uint8_t character) { return glyphs[character] ?: glyphs[0x3F]; } /* Use '?' for unknown glyphs */ //static glyph_t *glyph(uint8_t character) { return glyphs[character] ?: glyphs[0x3F]; } /* Use '?' for unknown glyphs */
//static inline glyph_t *glyph(uint8_t *character) { return glyph(*character); } //static glyph_t *glyph(uint8_t *character) { return glyph(*character); }
static void set(); static void set();
//static void add(uint8_t character) { add_character(character); eol(); } //static void add(uint8_t character) { add_character(character); eol(); }
@ -65,10 +65,10 @@ class DWIN_String {
static void set(uint8_t *string) { set(); add(string); } static void set(uint8_t *string) { set(); add(string); }
static void set(wchar_t character) { set(); add(character); } static void set(wchar_t character) { set(); add(character); }
static void set(uint8_t *string, int8_t index, const char *itemString=nullptr) { set(); add(string, index, (uint8_t *)itemString); } static void set(uint8_t *string, int8_t index, const char *itemString=nullptr) { set(); add(string, index, (uint8_t *)itemString); }
static inline void set(FSTR_P fstring) { set((uint8_t *)fstring); } static void set(FSTR_P fstring) { set((uint8_t *)fstring); }
static inline void set(const char *string) { set((uint8_t *)string); } static void set(const char *string) { set((uint8_t *)string); }
static inline void set(const char *string, int8_t index, const char *itemString=nullptr) { set((uint8_t *)string, index, itemString); } static void set(const char *string, int8_t index, const char *itemString=nullptr) { set((uint8_t *)string, index, itemString); }
static inline void add(const char *string) { add((uint8_t *)string); } static void add(const char *string) { add((uint8_t *)string); }
static void trim(const uint8_t character=0x20); static void trim(const uint8_t character=0x20);
static void rtrim(const uint8_t character=0x20); static void rtrim(const uint8_t character=0x20);
@ -76,9 +76,9 @@ class DWIN_String {
static void truncate(uint8_t maxlen) { if (len > maxlen) { len = maxlen; eol(); } } static void truncate(uint8_t maxlen) { if (len > maxlen) { len = maxlen; eol(); } }
static inline uint8_t length() { return len; } static uint8_t length() { return len; }
static inline uint16_t width() { return span; } static uint16_t width() { return span; }
static inline uint8_t *string() { return data; } static uint8_t *string() { return data; }
static uint16_t center(uint16_t width) { return span > width ? 0 : (width - span) / 2; } static uint16_t center(uint16_t width) { return span > width ? 0 : (width - span) / 2; }
}; };

4
Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp

@ -243,7 +243,7 @@ void ChironTFT::StatusChange(const char * const msg) {
case AC_printer_probing: { case AC_printer_probing: {
// If probing completes ok save the mesh and park // If probing completes ok save the mesh and park
// Ignore the custom machine name // Ignore the custom machine name
if (strcmp_P(msg + strlen(CUSTOM_MACHINE_NAME), MARLIN_msg_ready) == 0) { if (strcmp_P(msg + strlen(MACHINE_NAME), MARLIN_msg_ready) == 0) {
injectCommands(F("M500\nG27")); injectCommands(F("M500\nG27"));
SendtoTFTLN(AC_msg_probing_complete); SendtoTFTLN(AC_msg_probing_complete);
printer_state = AC_printer_idle; printer_state = AC_printer_idle;
@ -366,7 +366,7 @@ int8_t ChironTFT::FindToken(char c) {
#endif #endif
return pos; return pos;
} }
} while(++pos < command_len); } while (++pos < command_len);
#if ACDEBUG(AC_INFO) #if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Not found: ", c); SERIAL_ECHOLNPGM("Not found: ", c);
#endif #endif

4
Marlin/src/lcd/extui/dgus/DGUSDisplay.h

@ -95,14 +95,14 @@ public:
// Checks two things: Can we confirm the presence of the display and has we initialized it. // Checks two things: Can we confirm the presence of the display and has we initialized it.
// (both boils down that the display answered to our chatting) // (both boils down that the display answered to our chatting)
static inline bool isInitialized() { return Initialized; } static bool isInitialized() { return Initialized; }
private: private:
static void WriteHeader(uint16_t adr, uint8_t cmd, uint8_t payloadlen); static void WriteHeader(uint16_t adr, uint8_t cmd, uint8_t payloadlen);
static void WritePGM(const char str[], uint8_t len); static void WritePGM(const char str[], uint8_t len);
static void ProcessRx(); static void ProcessRx();
static inline uint16_t swap16(const uint16_t value) { return (value & 0xFFU) << 8U | (value >> 8U); } static uint16_t swap16(const uint16_t value) { return (value & 0xFFU) << 8U | (value >> 8U); }
static rx_datagram_state_t rx_datagram_state; static rx_datagram_state_t rx_datagram_state;
static uint8_t rx_datagram_len; static uint8_t rx_datagram_len;
static bool Initialized, no_reentrance; static bool Initialized, no_reentrance;

8
Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp

@ -508,9 +508,9 @@ void DGUSScreenHandler::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_
case VP_Z_STEP_PER_MM: axis = ExtUI::axis_t::Z; break; case VP_Z_STEP_PER_MM: axis = ExtUI::axis_t::Z; break;
default: return; default: return;
} }
DEBUG_ECHOLNPAIR_F("value:", value); DEBUG_ECHOLNPGM("value:", value);
ExtUI::setAxisSteps_per_mm(value, axis); ExtUI::setAxisSteps_per_mm(value, axis);
DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(axis)); DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisSteps_per_mm(axis));
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
return; return;
} }
@ -531,9 +531,9 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, vo
#endif #endif
#endif #endif
} }
DEBUG_ECHOLNPAIR_F("value:", value); DEBUG_ECHOLNPGM("value:", value);
ExtUI::setAxisSteps_per_mm(value, extruder); ExtUI::setAxisSteps_per_mm(value, extruder);
DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(extruder)); DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisSteps_per_mm(extruder));
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
} }

2
Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.cpp

@ -268,7 +268,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
#endif #endif
} }
DEBUG_ECHOLNPAIR_F("V3:", newvalue); DEBUG_ECHOLNPGM("V3:", newvalue);
*(float *)var.memadr = newvalue; *(float *)var.memadr = newvalue;
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel

14
Marlin/src/lcd/extui/dgus/fysetc/DGUSScreenHandler.h

@ -38,10 +38,10 @@ public:
// Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
// The bools specifying whether the strings are in RAM or FLASH. // The bools specifying whether the strings are in RAM or FLASH.
static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash);
} }
static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash);
} }
@ -206,20 +206,20 @@ public:
static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) { static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) {
if (var.memadr) { if (var.memadr) {
float f = *(float *)var.memadr; float f = *(float *)var.memadr;
DEBUG_ECHOLNPAIR_F(" >> ", f, 6); DEBUG_ECHOLNPGM(" >> ", f, 6);
f *= cpow(10, decimals); f *= cpow(10, decimals);
dgusdisplay.WriteVariable(var.VP, (int16_t)f); dgusdisplay.WriteVariable(var.VP, (int16_t)f);
} }
} }
// Force an update of all VP on the current screen. // Force an update of all VP on the current screen.
static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } static void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; }
// Has all VPs sent to the screen // Has all VPs sent to the screen
static inline bool IsScreenComplete() { return ScreenComplete; } static bool IsScreenComplete() { return ScreenComplete; }
static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; } static DGUSLCD_Screens getCurrentScreen() { return current_screen; }
static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } static void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; }
private: private:
static DGUSLCD_Screens current_screen; //< currently on screen static DGUSLCD_Screens current_screen; //< currently on screen

2
Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.cpp

@ -268,7 +268,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
#endif #endif
} }
DEBUG_ECHOLNPAIR_F("V3:", newvalue); DEBUG_ECHOLNPGM("V3:", newvalue);
*(float *)var.memadr = newvalue; *(float *)var.memadr = newvalue;
skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel

14
Marlin/src/lcd/extui/dgus/hiprecy/DGUSScreenHandler.h

@ -38,10 +38,10 @@ public:
// Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen // Send all 4 strings that are displayed on the infoscreen, confirmation screen and kill screen
// The bools specifying whether the strings are in RAM or FLASH. // The bools specifying whether the strings are in RAM or FLASH.
static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash); static void sendinfoscreen(const char *line1, const char *line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash);
static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, const char *line3, const char *line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash); sendinfoscreen(FTOP(line1), FTOP(line2), line3, line4, l1inflash, l2inflash, l3inflash, liinflash);
} }
static inline void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) { static void sendinfoscreen(FSTR_P const line1, FSTR_P const line2, FSTR_P const line3, FSTR_P const line4, bool l1inflash, bool l2inflash, bool l3inflash, bool liinflash) {
sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash); sendinfoscreen(FTOP(line1), FTOP(line2), FTOP(line3), FTOP(line4), l1inflash, l2inflash, l3inflash, liinflash);
} }
@ -206,20 +206,20 @@ public:
static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) { static void DGUSLCD_SendFloatAsIntValueToDisplay(DGUS_VP_Variable &var) {
if (var.memadr) { if (var.memadr) {
float f = *(float *)var.memadr; float f = *(float *)var.memadr;
DEBUG_ECHOLNPAIR_F(" >> ", f, 6); DEBUG_ECHOLNPGM(" >> ", f, 6);
f *= cpow(10, decimals); f *= cpow(10, decimals);
dgusdisplay.WriteVariable(var.VP, (int16_t)f); dgusdisplay.WriteVariable(var.VP, (int16_t)f);
} }
} }
// Force an update of all VP on the current screen. // Force an update of all VP on the current screen.
static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; } static void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; }
// Has all VPs sent to the screen // Has all VPs sent to the screen
static inline bool IsScreenComplete() { return ScreenComplete; } static bool IsScreenComplete() { return ScreenComplete; }
static inline DGUSLCD_Screens getCurrentScreen() { return current_screen; } static DGUSLCD_Screens getCurrentScreen() { return current_screen; }
static inline void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; } static void SetupConfirmAction( void (*f)()) { confirm_action_cb = f; }
private: private:
static DGUSLCD_Screens current_screen; //< currently on screen static DGUSLCD_Screens current_screen; //< currently on screen

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

Loading…
Cancel
Save