Merge branch 'bugfix-2.0.x' into CrealityDwin2.0_Bleeding

This commit is contained in:
InsanityAutomation
2021-02-10 07:09:49 -05:00
334 changed files with 6050 additions and 3045 deletions
+7 -1
View File
@@ -2638,7 +2638,9 @@
// @section temperature
// Preheat Constants
//
// Preheat Constants - Up to 5 are supported without changes
//
#define PREHEAT_1_LABEL "PLA"
#define PREHEAT_1_TEMP_HOTEND 180
#define PREHEAT_1_TEMP_BED 70
@@ -3548,6 +3550,10 @@
//#define TOUCH_OFFSET_Y 257
//#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
#if BOTH(TOUCH_SCREEN_CALIBRATION, EEPROM_SETTINGS)
#define TOUCH_CALIBRATION_AUTO_SAVE // Auto save successful calibration values to EEPROM
#endif
#if ENABLED(TFT_COLOR_UI)
//#define SINGLE_TOUCH_NAVIGATION
#endif
+10 -3
View File
@@ -113,6 +113,12 @@
#define CHAMBER_BETA 3950 // Beta value
#endif
#if TEMP_SENSOR_PROBE == 1000
#define PROBE_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define PROBE_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
#define PROBE_BETA 3950 // Beta value
#endif
//
// Hephestos 2 24V heated bed upgrade kit.
// https://store.bq.com/en/heated-bed-kit-hephestos2
@@ -354,7 +360,7 @@
* High Temperature Thermistor Support
*
* Thermistors able to support high temperature tend to have a hard time getting
* good readings at room and lower temperatures. This means HEATER_X_RAW_LO_TEMP
* good readings at room and lower temperatures. This means TEMP_SENSOR_X_RAW_LO_TEMP
* will probably be caught when the heating element first turns on during the
* preheating process, which will trigger a min_temp_error as a safety measure
* and force stop everything.
@@ -1612,7 +1618,7 @@
//
// Specify additional languages for the UI. Default specified by LCD_LANGUAGE.
//
#if EITHER(DOGLCD, TOUCH_UI_FTDI_EVE)
#if ANY(DOGLCD, TFT_COLOR_UI, TOUCH_UI_FTDI_EVE)
//#define LCD_LANGUAGE_2 fr
//#define LCD_LANGUAGE_3 de
//#define LCD_LANGUAGE_4 es
@@ -3497,7 +3503,8 @@
#endif
/**
* User-defined menu items that execute custom GCode
* User-defined menu items to run custom G-code.
* Up to 25 may be defined, but the actual number is LCD-dependent.
*/
#if ANY(ABL_UBL, ABL_BI)
#define CUSTOM_USER_MENUS
+2 -2
View File
@@ -82,14 +82,14 @@ typedef int8_t pin_t;
// Serial ports
#ifdef USBCON
#include "../../core/serial_hook.h"
#include "../../core/serial_hook.h"
typedef ForwardSerial0Type< decltype(Serial) > DefaultSerial;
extern DefaultSerial MSerial;
#ifdef BLUETOOTH
typedef ForwardSerial0Type< decltype(bluetoothSerial) > BTSerial;
extern BTSerial btSerial;
#endif
#define MYSERIAL0 TERN(BLUETOOTH, btSerial, MSerial)
#else
#if !WITHIN(SERIAL_PORT, -1, 3)
+2 -2
View File
@@ -595,7 +595,7 @@ MSerialT customizedSerial1(MSerialT::HasEmergencyParser);
MarlinSerial<MMU2SerialCfg<MMU2_SERIAL_PORT>>::_tx_udr_empty_irq();
}
template class MarlinSerial< MarlinSerialCfg<MMU2_SERIAL_PORT> >;
template class MarlinSerial< MMU2SerialCfg<MMU2_SERIAL_PORT> >;
MSerialT3 mmuSerial(MSerialT3::HasEmergencyParser);
#endif
@@ -611,7 +611,7 @@ MSerialT customizedSerial1(MSerialT::HasEmergencyParser);
template class MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> >;
MSerialT4 lcdSerial(MSerialT4::HasEmergencyParser);
#if HAS_DGUS_LCD
template<typename Cfg>
typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::get_tx_buffer_free() {
+5 -5
View File
@@ -238,11 +238,11 @@
static constexpr bool MAX_RX_QUEUED = ENABLED(SERIAL_STATS_MAX_RX_QUEUED);
};
typedef Serial0Type< MarlinSerial< MarlinSerialCfg<SERIAL_PORT> > > MSerialT;
typedef Serial0Type< MarlinSerial< MarlinSerialCfg<SERIAL_PORT> > > MSerialT;
extern MSerialT customizedSerial1;
#ifdef SERIAL_PORT_2
typedef Serial0Type< MarlinSerial< MarlinSerialCfg<SERIAL_PORT_2> > > MSerialT2;
typedef Serial0Type< MarlinSerial< MarlinSerialCfg<SERIAL_PORT_2> > > MSerialT2;
extern MSerialT2 customizedSerial2;
#endif
@@ -262,8 +262,8 @@
static constexpr bool RX_OVERRUNS = false;
};
typedef Serial0Type< MarlinSerial< MMU2SerialCfg<MMU2_SERIAL_PORT> > > MSerialT3;
extern MSerial3 mmuSerial;
typedef Serial0Type< MarlinSerial< MMU2SerialCfg<MMU2_SERIAL_PORT> > > MSerialT3;
extern MSerialT3 mmuSerial;
#endif
#ifdef LCD_SERIAL_PORT
@@ -292,7 +292,7 @@
};
typedef Serial0Type< MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> > > MSerialT4;
typedef Serial0Type< MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> > > MSerialT4;
extern MSerialT4 lcdSerial;
#endif
+7 -15
View File
@@ -235,8 +235,8 @@ static void print_is_also_tied() { SERIAL_ECHOPGM(" is also tied to this pin");
inline void com_print(const uint8_t N, const uint8_t Z) {
const uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
SERIAL_ECHOPGM(" COM");
SERIAL_CHAR('0' + N, Z);
SERIAL_ECHOPAIR(" COM", AS_CHAR('0' + N));
SERIAL_CHAR(Z);
SERIAL_ECHOPAIR(": ", int((*TCCRA >> (6 - Z * 2)) & 0x03));
}
@@ -247,8 +247,8 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
uint8_t WGM = (((*TCCRB & _BV(WGM_2)) >> 1) | (*TCCRA & (_BV(WGM_0) | _BV(WGM_1))));
if (N == 4) WGM |= ((*TCCRB & _BV(WGM_3)) >> 1);
SERIAL_ECHOPGM(" TIMER");
SERIAL_CHAR(T + '0', L);
SERIAL_ECHOPAIR(" TIMER", AS_CHAR(T + '0'));
SERIAL_CHAR(L);
SERIAL_ECHO_SP(3);
if (N == 3) {
@@ -262,19 +262,11 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
SERIAL_ECHOPAIR(" WGM: ", WGM);
com_print(T,L);
SERIAL_ECHOPAIR(" CS: ", (*TCCRB & (_BV(CS_0) | _BV(CS_1) | _BV(CS_2)) ));
SERIAL_ECHOPGM(" TCCR");
SERIAL_CHAR(T + '0');
SERIAL_ECHOPAIR("A: ", *TCCRA);
SERIAL_ECHOPGM(" TCCR");
SERIAL_CHAR(T + '0');
SERIAL_ECHOPAIR("B: ", *TCCRB);
SERIAL_ECHOPAIR(" TCCR", AS_CHAR(T + '0'), "A: ", *TCCRA);
SERIAL_ECHOPAIR(" TCCR", AS_CHAR(T + '0'), "B: ", *TCCRB);
const uint8_t *TMSK = (uint8_t*)TIMSK(T);
SERIAL_ECHOPGM(" TIMSK");
SERIAL_CHAR(T + '0');
SERIAL_ECHOPAIR(": ", *TMSK);
SERIAL_ECHOPAIR(" TIMSK", AS_CHAR(T + '0'), ": ", *TMSK);
const uint8_t OCIE = L - 'A' + 1;
if (N == 3) { if (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6) err_is_counter(); }
+4 -4
View File
@@ -240,7 +240,7 @@
}
// all the others
static uint32_t spiDelayCyclesX4 = (F_CPU) / 1000000; // 4µs => 125khz
static uint32_t spiDelayCyclesX4 = 4 * (F_CPU) / 1000000; // 4µs => 125khz
static uint8_t spiTransferX(uint8_t b) { // using Mode 0
int bits = 8;
@@ -249,12 +249,12 @@
b <<= 1; // little setup time
WRITE(SD_SCK_PIN, HIGH);
__delay_4cycles(spiDelayCyclesX4);
DELAY_CYCLES(spiDelayCyclesX4);
b |= (READ(SD_MISO_PIN) != 0);
WRITE(SD_SCK_PIN, LOW);
__delay_4cycles(spiDelayCyclesX4);
DELAY_CYCLES(spiDelayCyclesX4);
} while (--bits);
return b;
}
@@ -510,7 +510,7 @@
spiRxBlock = (pfnSpiRxBlock)spiRxBlockX;
break;
default:
spiDelayCyclesX4 = ((F_CPU) / 1000000) >> (6 - spiRate);
spiDelayCyclesX4 = ((F_CPU) / 1000000) >> (6 - spiRate) << 2; // spiRate of 2 gives the maximum error with current CPU
spiTransferTx = (pfnSpiTransfer)spiTransferX;
spiTransferRx = (pfnSpiTransfer)spiTransferX;
spiTxBlock = (pfnSpiTxBlock)spiTxBlockX;
+2 -7
View File
@@ -33,10 +33,6 @@
#include "MarlinSerialUSB.h"
#if ENABLED(EMERGENCY_PARSER)
#include "../../feature/e_parser.h"
#endif
// Imports from Atmel USB Stack/CDC implementation
extern "C" {
bool usb_task_cdc_isenabled();
@@ -69,7 +65,7 @@ int MarlinSerialUSB::peek() {
pending_char = udi_cdc_getc();
TERN_(EMERGENCY_PARSER, emergency_parser.update(emergency_state, (char)pending_char));
TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast<MSerialT*>(this)->emergency_state, (char)pending_char));
return pending_char;
}
@@ -91,7 +87,7 @@ int MarlinSerialUSB::read() {
int c = udi_cdc_getc();
TERN_(EMERGENCY_PARSER, emergency_parser.update(emergency_state, (char)c));
TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast<MSerialT*>(this)->emergency_state, (char)c));
return c;
}
@@ -105,7 +101,6 @@ bool MarlinSerialUSB::available() {
}
void MarlinSerialUSB::flush() { }
void MarlinSerialUSB::flushTX() { }
size_t MarlinSerialUSB::write(const uint8_t c) {
+9 -10
View File
@@ -34,21 +34,20 @@
struct MarlinSerialUSB {
static void begin(const long);
static void end();
static int peek();
static int read();
static void flush();
static void flushTX();
static bool available();
static size_t write(const uint8_t c);
void begin(const long);
void end();
int peek();
int read();
void flush();
bool available();
size_t write(const uint8_t c);
#if ENABLED(SERIAL_STATS_DROPPED_RX)
FORCE_INLINE static uint32_t dropped() { return 0; }
FORCE_INLINE uint32_t dropped() { return 0; }
#endif
#if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
FORCE_INLINE static int rxMaxEnqueued() { return 0; }
FORCE_INLINE int rxMaxEnqueued() { return 0; }
#endif
};
typedef Serial0Type<MarlinSerialUSB> MSerialT;
@@ -59,6 +59,7 @@
#if ENABLED(U8GLIB_ST7920)
#include "../../../inc/MarlinConfig.h"
#include "../../shared/Delay.h"
#include <U8glib.h>
@@ -59,6 +59,7 @@
#if HAS_MARLINUI_U8GLIB
#include "../../../inc/MarlinConfig.h"
#include "../../shared/Delay.h"
#include <U8glib.h>
+4 -2
View File
@@ -90,8 +90,6 @@ volatile int numPWMUsed = 0,
#endif
void HAL_init() { TERN_(I2S_STEPPER_STREAM, i2s_init()); }
void HAL_init_board() {
#if ENABLED(ESP3D_WIFISUPPORT)
@@ -126,6 +124,10 @@ void HAL_init_board() {
#endif
#endif
// Initialize the i2s peripheral only if the I2S stepper stream is enabled.
// The following initialization is performed after Serial1 and Serial2 are defined as
// their native pins might conflict with the i2s stream even when they are remapped.
TERN_(I2S_STEPPER_STREAM, i2s_init());
}
void HAL_idletask() {
+1 -1
View File
@@ -139,7 +139,7 @@ void HAL_adc_start_conversion(const uint8_t adc_pin);
#define HAL_IDLETASK 1
#define BOARD_INIT() HAL_init_board();
void HAL_idletask();
void HAL_init();
inline void HAL_init() {}
void HAL_init_board();
//
+6 -1
View File
@@ -63,7 +63,12 @@ int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) {
return ind > -1 ? ind : dval;
}
void flashFirmware(const int16_t) { NVIC_SystemReset(); }
void flashFirmware(const int16_t) {
delay(500); // Give OS time to disconnect
USB_Connect(false); // USB clear connection
delay(1000); // Give OS time to notice
NVIC_SystemReset();
}
void HAL_clear_reset_source(void) {
TERN_(USE_WATCHDOG, watchdog_clear_timeout_flag());
+4 -4
View File
@@ -24,19 +24,19 @@
#include "../../inc/MarlinConfigPre.h"
#include "MarlinSerial.h"
#if USING_SERIAL_0
#if ANY_SERIAL_IS(0)
MSerialT MSerial(true, LPC_UART0);
extern "C" void UART0_IRQHandler() { MSerial.IRQHandler(); }
#endif
#if USING_SERIAL_1
#if ANY_SERIAL_IS(1)
MSerialT MSerial1(true, (LPC_UART_TypeDef *) LPC_UART1);
extern "C" void UART1_IRQHandler() { MSerial1.IRQHandler(); }
#endif
#if USING_SERIAL_2
#if ANY_SERIAL_IS(2)
MSerialT MSerial2(true, LPC_UART2);
extern "C" void UART2_IRQHandler() { MSerial2.IRQHandler(); }
#endif
#if USING_SERIAL_3
#if ANY_SERIAL_IS(3)
MSerialT MSerial3(true, LPC_UART3);
extern "C" void UART3_IRQHandler() { MSerial3.IRQHandler(); }
#endif
+3 -3
View File
@@ -84,16 +84,16 @@ static void debug_rw(const bool write, int &pos, const uint8_t *value, const siz
PGM_P const rw_str = write ? PSTR("write") : PSTR("read");
SERIAL_CHAR(' ');
serialprintPGM(rw_str);
SERIAL_ECHOLNPAIR("_data(", pos, ",", int(value), ",", int(size), ", ...)");
SERIAL_ECHOLNPAIR("_data(", pos, ",", value, ",", size, ", ...)");
if (total) {
SERIAL_ECHOPGM(" f_");
serialprintPGM(rw_str);
SERIAL_ECHOPAIR("()=", int(s), "\n size=", int(size), "\n bytes_");
SERIAL_ECHOPAIR("()=", s, "\n size=", size, "\n bytes_");
serialprintPGM(write ? PSTR("written=") : PSTR("read="));
SERIAL_ECHOLN(total);
}
else
SERIAL_ECHOLNPAIR(" f_lseek()=", int(s));
SERIAL_ECHOLNPAIR(" f_lseek()=", s);
}
// File function return codes for type FRESULT. This goes away soon, but
+5 -5
View File
@@ -31,7 +31,7 @@
/**
* Detect an old pins file by checking for old ADC pins values.
*/
#define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && _CAT(P,_PIN) != 2 && _CAT(P,_PIN) != 3
#define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && !WITHIN(_CAT(P,_PIN), TERN(LPC1768_IS_SKRV1_3, 0, 2), 3) // Include P0_00 and P0_01 for SKR V1.3 board
#if _OLD_TEMP_PIN(TEMP_BED)
#error "TEMP_BED_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
#elif _OLD_TEMP_PIN(TEMP_0)
@@ -92,7 +92,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#define ANY_TX(N,V...) DO(IS_TX##N,||,V)
#define ANY_RX(N,V...) DO(IS_RX##N,||,V)
#if USING_SERIAL_0
#if ANY_SERIAL_IS(0)
#define IS_TX0(P) (P == P0_02)
#define IS_RX0(P) (P == P0_03)
#if IS_TX0(TMC_SW_MISO) || IS_RX0(TMC_SW_MOSI)
@@ -106,7 +106,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#undef IS_RX0
#endif
#if USING_SERIAL_1
#if ANY_SERIAL_IS(1)
#define IS_TX1(P) (P == P0_15)
#define IS_RX1(P) (P == P0_16)
#define _IS_TX1_1 IS_TX1
@@ -127,7 +127,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#undef _IS_RX1_1
#endif
#if USING_SERIAL_2
#if ANY_SERIAL_IS(2)
#define IS_TX2(P) (P == P0_10)
#define IS_RX2(P) (P == P0_11)
#define _IS_TX2_1 IS_TX2
@@ -161,7 +161,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#undef _IS_RX2_1
#endif
#if USING_SERIAL_3
#if ANY_SERIAL_IS(3)
#define PIN_IS_TX3(P) (PIN_EXISTS(P) && P##_PIN == P0_00)
#define PIN_IS_RX3(P) (P##_PIN == P0_01)
#if PIN_IS_TX3(X_MIN) || PIN_IS_RX3(X_MAX)
+2 -2
View File
@@ -119,9 +119,9 @@ void HAL_init() {
#endif
USB_Init(); // USB Initialization
USB_Connect(FALSE); // USB clear connection
USB_Connect(false); // USB clear connection
delay(1000); // Give OS time to notice
USB_Connect(TRUE);
USB_Connect(true);
#if HAS_SD_HOST_DRIVE
MSC_SD_Init(0); // Enable USB SD card access
+3 -3
View File
@@ -27,7 +27,7 @@
#include "../../inc/MarlinConfig.h"
#if USING_SERIAL_1
#if ANY_SERIAL_IS(1)
UartT Serial2(false, &sercom4, PIN_SERIAL2_RX, PIN_SERIAL2_TX, PAD_SERIAL2_RX, PAD_SERIAL2_TX);
void SERCOM4_0_Handler() { Serial2.IrqHandler(); }
void SERCOM4_1_Handler() { Serial2.IrqHandler(); }
@@ -35,7 +35,7 @@
void SERCOM4_3_Handler() { Serial2.IrqHandler(); }
#endif
#if USING_SERIAL_2
#if ANY_SERIAL_IS(2)
UartT Serial3(false, &sercom1, PIN_SERIAL3_RX, PIN_SERIAL3_TX, PAD_SERIAL3_RX, PAD_SERIAL3_TX);
void SERCOM1_0_Handler() { Serial3.IrqHandler(); }
void SERCOM1_1_Handler() { Serial3.IrqHandler(); }
@@ -43,7 +43,7 @@
void SERCOM1_3_Handler() { Serial3.IrqHandler(); }
#endif
#if USING_SERIAL_3
#if ANY_SERIAL_IS(3)
UartT Serial4(false, &sercom5, PIN_SERIAL4_RX, PIN_SERIAL4_TX, PAD_SERIAL4_RX, PAD_SERIAL4_TX);
void SERCOM5_0_Handler() { Serial4.IrqHandler(); }
void SERCOM5_1_Handler() { Serial4.IrqHandler(); }
+18 -11
View File
@@ -42,6 +42,11 @@
#endif
#endif
#if HAS_SD_HOST_DRIVE
#include "msc_sd.h"
#include "usbd_cdc_if.h"
#endif
// ------------------------
// Public Variables
// ------------------------
@@ -52,17 +57,6 @@ uint16_t HAL_adc_result;
// Public functions
// ------------------------
// Needed for DELAY_NS() / DELAY_US() on CORTEX-M7
#if (defined(__arm__) || defined(__thumb__)) && __CORTEX_M == 7
// HAL pre-initialization task
// Force the preinit function to run between the premain() and main() function
// of the STM32 arduino core
__attribute__((constructor (102)))
void HAL_preinit() {
enableCycleCounter();
}
#endif
// HAL initialization task
void HAL_init() {
FastIO_init();
@@ -88,6 +82,19 @@ void HAL_init() {
#if ENABLED(EMERGENCY_PARSER) && USBD_USE_CDC
USB_Hook_init();
#endif
#if HAS_SD_HOST_DRIVE
MSC_SD_init(); // Enable USB SD card access
#endif
}
// HAL idle task
void HAL_idletask() {
#if HAS_SHARED_MEDIA
// Stm32duino currently doesn't have a "loop/idle" method
CDC_resume_receive();
CDC_continue_transmit();
#endif
}
void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); }
+4 -1
View File
@@ -39,7 +39,7 @@
#ifdef USBCON
#include <USBSerial.h>
#include "../../core/serial_hook.h"
#include "../../core/serial_hook.h"
typedef ForwardSerial0Type< decltype(SerialUSB) > DefaultSerial;
extern DefaultSerial MSerial;
#endif
@@ -135,6 +135,8 @@ extern uint16_t HAL_adc_result;
// Enable hooks into setup for HAL
void HAL_init();
#define HAL_IDLETASK 1
void HAL_idletask();
// Clear reset reason
void HAL_clear_reset_source();
@@ -192,6 +194,7 @@ void flashFirmware(const int16_t);
typedef void (*systickCallback_t)(void);
void systick_attach_callback(systickCallback_t cb);
void HAL_SYSTICK_Callback();
extern volatile uint32_t systick_uptime_millis;
#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
+20 -10
View File
@@ -51,18 +51,28 @@ static SPISettings spiConfig;
OUT_WRITE(SD_MOSI_PIN, HIGH);
}
static uint16_t delay_STM32_soft_spi;
// Use function with compile-time value so we can actually reach the desired frequency
// Need to adjust this a little bit: on a 72MHz clock, we have 14ns/clock
// and we'll use ~3 cycles to jump to the method and going back, so it'll take ~40ns from the given clock here
#define CALLING_COST_NS (3U * 1000000000U) / (F_CPU)
void (*delaySPIFunc)();
void delaySPI_125() { DELAY_NS(125 - CALLING_COST_NS); }
void delaySPI_250() { DELAY_NS(250 - CALLING_COST_NS); }
void delaySPI_500() { DELAY_NS(500 - CALLING_COST_NS); }
void delaySPI_1000() { DELAY_NS(1000 - CALLING_COST_NS); }
void delaySPI_2000() { DELAY_NS(2000 - CALLING_COST_NS); }
void delaySPI_4000() { DELAY_NS(4000 - CALLING_COST_NS); }
void spiInit(uint8_t spiRate) {
// Use datarates Marlin uses
switch (spiRate) {
case SPI_FULL_SPEED: delay_STM32_soft_spi = 125; break; // desired: 8,000,000 actual: ~1.1M
case SPI_HALF_SPEED: delay_STM32_soft_spi = 125; break; // desired: 4,000,000 actual: ~1.1M
case SPI_QUARTER_SPEED:delay_STM32_soft_spi = 250; break; // desired: 2,000,000 actual: ~890K
case SPI_EIGHTH_SPEED: delay_STM32_soft_spi = 500; break; // desired: 1,000,000 actual: ~590K
case SPI_SPEED_5: delay_STM32_soft_spi = 1000; break; // desired: 500,000 actual: ~360K
case SPI_SPEED_6: delay_STM32_soft_spi = 2000; break; // desired: 250,000 actual: ~210K
default: delay_STM32_soft_spi = 4000; break; // desired: 125,000 actual: ~123K
case SPI_FULL_SPEED: delaySPIFunc = &delaySPI_125; break; // desired: 8,000,000 actual: ~1.1M
case SPI_HALF_SPEED: delaySPIFunc = &delaySPI_125; break; // desired: 4,000,000 actual: ~1.1M
case SPI_QUARTER_SPEED:delaySPIFunc = &delaySPI_250; break; // desired: 2,000,000 actual: ~890K
case SPI_EIGHTH_SPEED: delaySPIFunc = &delaySPI_500; break; // desired: 1,000,000 actual: ~590K
case SPI_SPEED_5: delaySPIFunc = &delaySPI_1000; break; // desired: 500,000 actual: ~360K
case SPI_SPEED_6: delaySPIFunc = &delaySPI_2000; break; // desired: 250,000 actual: ~210K
default: delaySPIFunc = &delaySPI_4000; break; // desired: 125,000 actual: ~123K
}
SPI.begin();
}
@@ -75,9 +85,9 @@ static SPISettings spiConfig;
WRITE(SD_SCK_PIN, LOW);
WRITE(SD_MOSI_PIN, b & 0x80);
DELAY_NS(delay_STM32_soft_spi);
delaySPIFunc();
WRITE(SD_SCK_PIN, HIGH);
DELAY_NS(delay_STM32_soft_spi);
delaySPIFunc();
b <<= 1; // little setup time
b |= (READ(SD_MISO_PIN) != 0);
+1 -1
View File
@@ -81,7 +81,7 @@ void MarlinSerial::_rx_complete_irq(serial_t *obj) {
}
#if ENABLED(EMERGENCY_PARSER)
emergency_parser.update(emergency_state, c);
emergency_parser.update(static_cast<MSerialT*>(this)->emergency_state, c);
#endif
}
}
@@ -163,7 +163,6 @@
GPIO_InitStruct.Pin = GPIO_PIN_2;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
#if DISABLED(STM32F1xx)
// TODO: use __HAL_RCC_SDIO_RELEASE_RESET() and __HAL_RCC_SDIO_CLK_ENABLE();
RCC->APB2RSTR &= ~RCC_APB2RSTR_SDIORST_Msk; // take SDIO out of reset
+1 -1
View File
@@ -21,6 +21,6 @@
*/
#pragma once
#if defined(USBD_USE_CDC_COMPOSITE) && DISABLED(NO_SD_HOST_DRIVE)
#if defined(USBD_USE_CDC_MSC) && DISABLED(NO_SD_HOST_DRIVE)
#define HAS_SD_HOST_DRIVE 1
#endif
+112
View File
@@ -0,0 +1,112 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2019 BigTreeTech [https://github.com/bigtreetech]
*
* 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.
*
* 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/MarlinConfigPre.h"
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && HAS_SD_HOST_DRIVE
#include "msc_sd.h"
#include "../shared/Marduino.h"
#include "usbd_core.h"
#include <USB.h>
#include <USBMscHandler.h>
#define BLOCK_SIZE 512
#define PRODUCT_ID 0x29
#include "../../sd/cardreader.h"
class Sd2CardUSBMscHandler : public USBMscHandler {
public:
bool GetCapacity(uint32_t *pBlockNum, uint16_t *pBlockSize) {
*pBlockNum = card.getSd2Card().cardSize();
*pBlockSize = BLOCK_SIZE;
return true;
}
bool Write(uint8_t *pBuf, uint32_t blkAddr, uint16_t blkLen) {
auto sd2card = card.getSd2Card();
// single block
if (blkLen == 1) {
watchdog_refresh();
sd2card.writeBlock(blkAddr, pBuf);
return true;
}
// multi block optmization
sd2card.writeStart(blkAddr, blkLen);
while (blkLen--) {
watchdog_refresh();
sd2card.writeData(pBuf);
pBuf += BLOCK_SIZE;
}
sd2card.writeStop();
return true;
}
bool Read(uint8_t *pBuf, uint32_t blkAddr, uint16_t blkLen) {
auto sd2card = card.getSd2Card();
// single block
if (blkLen == 1) {
watchdog_refresh();
sd2card.readBlock(blkAddr, pBuf);
return true;
}
// multi block optmization
sd2card.readStart(blkAddr);
while (blkLen--) {
watchdog_refresh();
sd2card.readData(pBuf);
pBuf += BLOCK_SIZE;
}
sd2card.readStop();
return true;
}
bool IsReady() {
return card.isMounted();
}
};
Sd2CardUSBMscHandler usbMscHandler;
/* USB Mass storage Standard Inquiry Data */
uint8_t Marlin_STORAGE_Inquirydata[] = { /* 36 */
/* LUN 0 */
0x00,
0x80,
0x02,
0x02,
(STANDARD_INQUIRY_DATA_LEN - 5),
0x00,
0x00,
0x00,
'M', 'A', 'R', 'L', 'I', 'N', ' ', ' ', /* Manufacturer : 8 bytes */
'P', 'r', 'o', 'd', 'u', 'c', 't', ' ', /* Product : 16 Bytes */
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
'0', '.', '0', '1', /* Version : 4 Bytes */
};
USBMscHandler *pSingleMscHandler = &usbMscHandler;
void MSC_SD_init() {
USBDevice.end();
delay(200);
USBDevice.begin();
USBDevice.registerMscHandlers(1, &pSingleMscHandler, Marlin_STORAGE_Inquirydata);
}
#endif // __STM32F1__ && HAS_SD_HOST_DRIVE
+18
View File
@@ -0,0 +1,18 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2019 BigTreeTech [https://github.com/bigtreetech]
*
* 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.
*
* 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
void MSC_SD_init();
+28 -1
View File
@@ -84,7 +84,32 @@
#if defined(SERIAL_USB) && !HAS_SD_HOST_DRIVE
USBSerial SerialUSB;
DefaultSerial MSerial(false, SerialUSB);
DefaultSerial MSerial(true, SerialUSB);
#if ENABLED(EMERGENCY_PARSER)
#include "../libmaple/usb/stm32f1/usb_reg_map.h"
#include "libmaple/usb_cdcacm.h"
// The original callback is not called (no way to retrieve address).
// That callback detects a special STM32 reset sequence: this functionality is not essential
// as M997 achieves the same.
void my_rx_callback(unsigned int, void*) {
// max length of 16 is enough to contain all emergency commands
uint8 buf[16];
//rx is usbSerialPart.endpoints[2]
uint16 len = usb_get_ep_rx_count(USB_CDCACM_RX_ENDP);
uint32 total = usb_cdcacm_data_available();
if (len == 0 || total == 0 || !WITHIN(total, len, COUNT(buf)))
return;
// cannot get character by character due to bug in composite_cdcacm_peek_ex
len = usb_cdcacm_peek(buf, total);
for (uint32 i = 0; i < len; i++)
emergency_parser.update(MSerial.emergency_state, buf[i + total - len]);
}
#endif
#endif
uint16_t HAL_adc_result;
@@ -254,6 +279,8 @@ void HAL_init() {
#endif
#if HAS_SD_HOST_DRIVE
MSC_SD_init();
#elif BOTH(SERIAL_USB, EMERGENCY_PARSER)
usb_cdcacm_set_hooks(USB_CDCACM_HOOK_RX, my_rx_callback);
#endif
#if PIN_EXISTS(USB_CONNECT)
OUT_WRITE(USB_CONNECT_PIN, !USB_CONNECT_INVERTING); // USB clear connection
+22 -10
View File
@@ -19,6 +19,7 @@
#include "msc_sd.h"
#include "SPI.h"
#include "usb_reg_map.h"
#define PRODUCT_ID 0x29
@@ -41,14 +42,27 @@ Serial0Type<USBCompositeSerial> MarlinCompositeSerial(true);
#endif
#if ENABLED(EMERGENCY_PARSER)
void (*real_rx_callback)(void);
void my_rx_callback(void) {
real_rx_callback();
int len = MarlinCompositeSerial.available();
while (len-- > 0) // >0 because available() may return a negative value
emergency_parser.update(MarlinCompositeSerial.emergency_state, MarlinCompositeSerial.peek());
}
// The original callback is not called (no way to retrieve address).
// That callback detects a special STM32 reset sequence: this functionality is not essential
// as M997 achieves the same.
void my_rx_callback(unsigned int, void*) {
// max length of 16 is enough to contain all emergency commands
uint8 buf[16];
//rx is usbSerialPart.endpoints[2]
uint16 len = usb_get_ep_rx_count(usbSerialPart.endpoints[2].address);
uint32 total = composite_cdcacm_data_available();
if (len == 0 || total == 0 || !WITHIN(total, len, COUNT(buf)))
return;
// cannot get character by character due to bug in composite_cdcacm_peek_ex
len = composite_cdcacm_peek(buf, total);
for (uint32 i = 0; i < len; i++)
emergency_parser.update(MarlinCompositeSerial.emergency_state, buf[i+total-len]);
}
#endif
void MSC_SD_init() {
@@ -73,9 +87,7 @@ void MSC_SD_init() {
MarlinCompositeSerial.registerComponent();
USBComposite.begin();
#if ENABLED(EMERGENCY_PARSER)
//rx is usbSerialPart.endpoints[2]
real_rx_callback = usbSerialPart.endpoints[2].callback;
usbSerialPart.endpoints[2].callback = my_rx_callback;
composite_cdcacm_set_hooks(USBHID_CDCACM_HOOK_RX, my_rx_callback);
#endif
}
+176
View File
@@ -0,0 +1,176 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "Delay.h"
#include "../../inc/MarlinConfig.h"
#if defined(__arm__) || defined(__thumb__)
static uint32_t ASM_CYCLES_PER_ITERATION = 4; // Initial bet which will be adjusted in calibrate_delay_loop
// Simple assembler loop counting down
void delay_asm(uint32_t cy) {
cy = _MAX(cy / ASM_CYCLES_PER_ITERATION, 1U); // Zero is forbidden here
__asm__ __volatile__(
A(".syntax unified") // is to prevent CM0,CM1 non-unified syntax
L("1")
A("subs %[cnt],#1")
A("bne 1b")
: [cnt]"+r"(cy) // output: +r means input+output
: // input:
: "cc" // clobbers:
);
}
// We can't use CMSIS since it's not available on all platform, so fallback to hardcoded register values
#define HW_REG(X) *(volatile uint32_t *)(X)
#define _DWT_CTRL 0xE0001000
#define _DWT_CYCCNT 0xE0001004 // CYCCNT is 32bits, takes 37s or so to wrap.
#define _DEM_CR 0xE000EDFC
#define _LAR 0xE0001FB0
// Use hardware cycle counter instead, it's much safer
void delay_dwt(uint32_t count) {
// Reuse the ASM_CYCLES_PER_ITERATION variable to avoid wasting another useless variable
register uint32_t start = HW_REG(_DWT_CYCCNT) - ASM_CYCLES_PER_ITERATION, elapsed;
do {
elapsed = HW_REG(_DWT_CYCCNT) - start;
} while (elapsed < count);
}
// Pointer to asm function, calling the functions has a ~20 cycles overhead
DelayImpl DelayCycleFnc = delay_asm;
void calibrate_delay_loop() {
// Check if we have a working DWT implementation in the CPU (see https://developer.arm.com/documentation/ddi0439/b/Data-Watchpoint-and-Trace-Unit/DWT-Programmers-Model)
if (!HW_REG(_DWT_CTRL)) {
// No DWT present, so fallback to plain old ASM nop counting
// Unfortunately, we don't exactly know how many iteration it'll take to decrement a counter in a loop
// It depends on the CPU architecture, the code current position (flash vs SRAM)
// So, instead of wild guessing and making mistake, instead
// compute it once for all
ASM_CYCLES_PER_ITERATION = 1;
// We need to fetch some reference clock before waiting
cli();
uint32_t start = micros();
delay_asm(1000); // On a typical CPU running in MHz, waiting 1000 "unknown cycles" means it'll take between 1ms to 6ms, that's perfectly acceptable
uint32_t end = micros();
sei();
uint32_t expectedCycles = (end - start) * ((F_CPU) / 1000000UL); // Convert microseconds to cycles
// Finally compute the right scale
ASM_CYCLES_PER_ITERATION = (uint32_t)(expectedCycles / 1000);
// No DWT present, likely a Cortex M0 so NOP counting is our best bet here
DelayCycleFnc = delay_asm;
}
else {
// Enable DWT counter
// From https://stackoverflow.com/a/41188674/1469714
HW_REG(_DEM_CR) = HW_REG(_DEM_CR) | 0x01000000; // Enable trace
#if __CORTEX_M == 7
HW_REG(_LAR) = 0xC5ACCE55; // Unlock access to DWT registers, see https://developer.arm.com/documentation/ihi0029/e/ section B2.3.10
#endif
HW_REG(_DWT_CYCCNT) = 0; // Clear DWT cycle counter
HW_REG(_DWT_CTRL) = HW_REG(_DWT_CTRL) | 1; // Enable DWT cycle counter
// Then calibrate the constant offset from the counter
ASM_CYCLES_PER_ITERATION = 0;
uint32_t s = HW_REG(_DWT_CYCCNT);
uint32_t e = HW_REG(_DWT_CYCCNT); // (e - s) contains the number of cycle required to read the cycle counter
delay_dwt(0);
uint32_t f = HW_REG(_DWT_CYCCNT); // (f - e) contains the delay to call the delay function + the time to read the cycle counter
ASM_CYCLES_PER_ITERATION = (f - e) - (e - s);
// Use safer DWT function
DelayCycleFnc = delay_dwt;
}
}
#if ENABLED(MARLIN_DEV_MODE)
void dump_delay_accuracy_check()
{
auto report_call_time = [](PGM_P const name, const uint32_t cycles, const uint32_t total, const bool do_flush=true) {
SERIAL_ECHOPGM("Calling ");
serialprintPGM(name);
SERIAL_ECHOLNPAIR(" for ", cycles, "cycles took: ", total, "cycles");
if (do_flush) SERIAL_FLUSH();
};
uint32_t s, e;
SERIAL_ECHOLNPAIR("Computed delay calibration value: ", ASM_CYCLES_PER_ITERATION);
SERIAL_FLUSH();
// Display the results of the calibration above
constexpr uint32_t testValues[] = { 1, 5, 10, 20, 50, 100, 150, 200, 350, 500, 750, 1000 };
for (auto i : testValues) {
s = micros(); DELAY_US(i); e = micros();
report_call_time(PSTR("delay"), i, e - s);
}
if (HW_REG(_DWT_CTRL)) {
for (auto i : testValues) {
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(i); e = HW_REG(_DWT_CYCCNT);
report_call_time(PSTR("delay"), i, e - s);
}
// Measure the delay to call a real function compared to a function pointer
s = HW_REG(_DWT_CYCCNT); delay_dwt(1); e = HW_REG(_DWT_CYCCNT);
report_call_time(PSTR("delay_dwt"), 1, e - s);
static PGMSTR(dcd, "DELAY_CYCLES directly ");
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES( 1); e = HW_REG(_DWT_CYCCNT);
report_call_time(dcd, 1, e - s, false);
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES( 5); e = HW_REG(_DWT_CYCCNT);
report_call_time(dcd, 5, e - s, false);
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(10); e = HW_REG(_DWT_CYCCNT);
report_call_time(dcd, 10, e - s, false);
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(20); e = HW_REG(_DWT_CYCCNT);
report_call_time(dcd, 20, e - s, false);
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(50); e = HW_REG(_DWT_CYCCNT);
report_call_time(dcd, 50, e - s, false);
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(100); e = HW_REG(_DWT_CYCCNT);
report_call_time(dcd, 100, e - s, false);
s = HW_REG(_DWT_CYCCNT); DELAY_CYCLES(200); e = HW_REG(_DWT_CYCCNT);
report_call_time(dcd, 200, e - s, false);
}
}
#endif // MARLIN_DEV_MODE
#else
void calibrate_delay_loop() {}
#if ENABLED(MARLIN_DEV_MODE)
void dump_delay_accuracy_check() {
static PGMSTR(none, "N/A on this platform");
serialprintPGM(none);
}
#endif
#endif
+64 -68
View File
@@ -21,6 +21,8 @@
*/
#pragma once
#include "../../inc/MarlinConfigPre.h"
/**
* Busy wait delay cycles routines:
*
@@ -31,79 +33,68 @@
#include "../../core/macros.h"
void calibrate_delay_loop();
#if defined(__arm__) || defined(__thumb__)
#if __CORTEX_M == 7
// We want to have delay_cycle function with the lowest possible overhead, so we adjust at the function at runtime based on the current CPU best feature
typedef void (*DelayImpl)(uint32_t);
extern DelayImpl DelayCycleFnc;
// Cortex-M3 through M7 can use the cycle counter of the DWT unit
// https://www.anthonyvh.com/2017/05/18/cortex_m-cycle_counter/
// I've measured 36 cycles on my system to call the cycle waiting method, but it shouldn't change much to have a bit more margin, it only consume a bit more flash
#define TRIP_POINT_FOR_CALLING_FUNCTION 40
FORCE_INLINE static void enableCycleCounter() {
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
#if __CORTEX_M == 7
DWT->LAR = 0xC5ACCE55; // Unlock DWT on the M7
#endif
DWT->CYCCNT = 0;
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
// A simple recursive template class that output exactly one 'nop' of code per recursion
template <int N> struct NopWriter {
FORCE_INLINE static void build() {
__asm__ __volatile__("nop");
NopWriter<N-1>::build();
}
};
// End the loop
template <> struct NopWriter<0> { FORCE_INLINE static void build() {} };
FORCE_INLINE volatile uint32_t getCycleCount() { return DWT->CYCCNT; }
FORCE_INLINE static void DELAY_CYCLES(const uint32_t x) {
const uint32_t endCycles = getCycleCount() + x;
while (PENDING(getCycleCount(), endCycles)) {}
}
#else
// https://blueprints.launchpad.net/gcc-arm-embedded/+spec/delay-cycles
#define nop() __asm__ __volatile__("nop;\n\t":::)
FORCE_INLINE static void __delay_4cycles(uint32_t cy) { // +1 cycle
#if ARCH_PIPELINE_RELOAD_CYCLES < 2
#define EXTRA_NOP_CYCLES A("nop")
#else
#define EXTRA_NOP_CYCLES ""
#endif
__asm__ __volatile__(
A(".syntax unified") // is to prevent CM0,CM1 non-unified syntax
L("1")
A("subs %[cnt],#1")
EXTRA_NOP_CYCLES
A("bne 1b")
: [cnt]"+r"(cy) // output: +r means input+output
: // input:
: "cc" // clobbers:
);
}
// Delay in cycles
FORCE_INLINE static void DELAY_CYCLES(uint32_t x) {
if (__builtin_constant_p(x)) {
#define MAXNOPS 4
if (x <= (MAXNOPS)) {
switch (x) { case 4: nop(); case 3: nop(); case 2: nop(); case 1: nop(); }
}
else { // because of +1 cycle inside delay_4cycles
const uint32_t rem = (x - 1) % (MAXNOPS);
switch (rem) { case 3: nop(); case 2: nop(); case 1: nop(); }
if ((x = (x - 1) / (MAXNOPS)))
__delay_4cycles(x); // if need more then 4 nop loop is more optimal
}
#undef MAXNOPS
namespace Private {
// Split recursing template in 2 different class so we don't reach the maximum template instantiation depth limit
template <bool belowTP, int N> struct Helper {
FORCE_INLINE static void build() {
DelayCycleFnc(N - 2); // Approximative cost of calling the function (might be off by one or 2 cycles)
}
else if ((x >>= 2))
__delay_4cycles(x);
}
#undef nop
};
#endif
template <int N> struct Helper<true, N> {
FORCE_INLINE static void build() {
NopWriter<N - 1>::build();
}
};
template <> struct Helper<true, 0> {
FORCE_INLINE static void build() {}
};
}
// Select a behavior based on the constexpr'ness of the parameter
// If called with a compile-time parameter, then write as many NOP as required to reach the asked cycle count
// (there is some tripping point here to start looping when it's more profitable than gruntly executing NOPs)
// If not called from a compile-time parameter, fallback to a runtime loop counting version instead
template <bool compileTime, int Cycles>
struct SmartDelay {
FORCE_INLINE SmartDelay(int) {
if (Cycles == 0) return;
Private::Helper<Cycles < TRIP_POINT_FOR_CALLING_FUNCTION, Cycles>::build();
}
};
// Runtime version below. There is no way this would run under less than ~TRIP_POINT_FOR_CALLING_FUNCTION cycles
template <int T>
struct SmartDelay<false, T> {
FORCE_INLINE SmartDelay(int v) { DelayCycleFnc(v); }
};
#define DELAY_CYCLES(X) do { SmartDelay<IS_CONSTEXPR(X), IS_CONSTEXPR(X) ? X : 0> _smrtdly_X(X); } while(0)
// For delay in microseconds, no smart delay selection is required, directly call the delay function
// Teensy compiler is too old and does not accept smart delay compile-time / run-time selection correctly
#define DELAY_US(x) DelayCycleFnc((x) * ((F_CPU) / 1000000UL))
#elif defined(__AVR__)
@@ -144,10 +135,15 @@
}
#undef nop
// Delay in microseconds
#define DELAY_US(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL))
#elif defined(__PLAT_LINUX__) || defined(ESP32)
// specified inside platform
// DELAY_CYCLES specified inside platform
// Delay in microseconds
#define DELAY_US(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL))
#else
#error "Unsupported MCU architecture"
@@ -157,5 +153,5 @@
// Delay in nanoseconds
#define DELAY_NS(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL) / 1000UL)
// Delay in microseconds
#define DELAY_US(x) DELAY_CYCLES((x) * ((F_CPU) / 1000000UL))
@@ -34,10 +34,10 @@ static bool UnwReportOut(void* ctx, const UnwReport* bte) {
(*p)++;
SERIAL_CHAR('#'); SERIAL_PRINT(*p, DEC); SERIAL_ECHOPGM(" : ");
SERIAL_ECHOPGM(bte->name ? bte->name : "unknown"); SERIAL_ECHOPGM("@0x"); SERIAL_PRINT(bte->function, HEX);
SERIAL_CHAR('+'); SERIAL_PRINT(bte->address - bte->function,DEC);
SERIAL_ECHOPGM(" PC:"); SERIAL_PRINT(bte->address,HEX); SERIAL_CHAR('\n');
SERIAL_CHAR('#'); SERIAL_ECHO(*p); SERIAL_ECHOPGM(" : ");
SERIAL_ECHOPGM(bte->name ? bte->name : "unknown"); SERIAL_ECHOPGM("@0x"); SERIAL_PRINT(bte->function, PrintBase::Hex);
SERIAL_CHAR('+'); SERIAL_ECHO(bte->address - bte->function);
SERIAL_ECHOPGM(" PC:"); SERIAL_PRINT(bte->address, PrintBase::Hex); SERIAL_CHAR('\n');
return true;
}
+21 -19
View File
@@ -419,8 +419,7 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
if (parked_or_ignoring) gcode.reset_stepper_timeout(ms);
if (gcode.stepper_max_timed_out(ms)) {
SERIAL_ERROR_START();
SERIAL_ECHOLNPAIR(STR_KILL_INACTIVE_TIME, parser.command_ptr);
SERIAL_ERROR_MSG(STR_KILL_INACTIVE_TIME, parser.command_ptr);
kill();
}
@@ -614,8 +613,8 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
*/
void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
#if ENABLED(MARLIN_DEV_MODE)
static uint8_t idle_depth = 0;
if (++idle_depth > 5) SERIAL_ECHOLNPAIR("idle() call depth: ", int(idle_depth));
static uint16_t idle_depth = 0;
if (++idle_depth > 5) SERIAL_ECHOLNPAIR("idle() call depth: ", idle_depth);
#endif
// Core Marlin activities
@@ -886,6 +885,17 @@ void setup() {
#endif
#define SETUP_RUN(C) do{ SETUP_LOG(STRINGIFY(C)); C; }while(0)
MYSERIAL0.begin(BAUDRATE);
millis_t serial_connect_timeout = millis() + 1000UL;
while (!MYSERIAL0.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
#if HAS_MULTI_SERIAL && !HAS_ETHERNET
MYSERIAL1.begin(BAUDRATE);
serial_connect_timeout = millis() + 1000UL;
while (!MYSERIAL1.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
#endif
SERIAL_ECHOLNPGM("start");
// Set up these pins early to prevent suicide
#if HAS_KILL
SETUP_LOG("KILL_PIN");
@@ -918,17 +928,6 @@ void setup() {
#endif
#endif
MYSERIAL0.begin(BAUDRATE);
millis_t serial_connect_timeout = millis() + 1000UL;
while (!MYSERIAL0.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
#if HAS_MULTI_SERIAL && !HAS_ETHERNET
MYSERIAL1.begin(BAUDRATE);
serial_connect_timeout = millis() + 1000UL;
while (!MYSERIAL1.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
#endif
SERIAL_ECHOLNPGM("start");
#if BOTH(HAS_TFT_LVGL_UI, MKS_WIFI_MODULE)
mks_esp_wifi_init();
WIFISERIAL.begin(WIFI_BAUDRATE);
@@ -938,11 +937,11 @@ void setup() {
SETUP_RUN(HAL_init());
// Init and disable SPI thermocouples
#if HEATER_0_USES_MAX6675
// Init and disable SPI thermocouples; this is still needed
#if TEMP_SENSOR_0_IS_MAX_TC
OUT_WRITE(MAX6675_SS_PIN, HIGH); // Disable
#endif
#if HEATER_1_USES_MAX6675
#if TEMP_SENSOR_1_IS_MAX_TC
OUT_WRITE(MAX6675_SS2_PIN, HIGH); // Disable
#endif
@@ -1004,7 +1003,10 @@ void setup() {
);
#endif
SERIAL_ECHO_MSG("Compiled: " __DATE__);
SERIAL_ECHO_MSG(STR_FREE_MEMORY, freeMemory(), STR_PLANNER_BUFFER_BYTES, (int)sizeof(block_t) * (BLOCK_BUFFER_SIZE));
SERIAL_ECHO_MSG(STR_FREE_MEMORY, freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE));
// Some HAL need precise delay adjustment
calibrate_delay_loop();
// Init buzzer pin(s)
#if USE_BEEPER
-2
View File
@@ -415,5 +415,3 @@
#define _MB_1(B) (defined(BOARD_##B) && MOTHERBOARD==BOARD_##B)
#define MB(V...) DO(MB,||,V)
#define IS_MELZI MB(MELZI, MELZI_CREALITY, MELZI_MAKR3D, MELZI_MALYAN, MELZI_TRONXY, MELZI_V2)
+14 -6
View File
@@ -61,6 +61,8 @@
#define _O2 __attribute__((optimize("O2")))
#define _O3 __attribute__((optimize("O3")))
#define IS_CONSTEXPR(...) __builtin_constant_p(__VA_ARGS__) // Only valid solution with C++14. Should use std::is_constant_evaluated() in C++20 instead
#ifndef UNUSED
#define UNUSED(x) ((void)(x))
#endif
@@ -128,20 +130,20 @@
#define NOLESS(v, n) \
do{ \
__typeof__(n) _n = (n); \
__typeof__(v) _n = (n); \
if (_n > v) v = _n; \
}while(0)
#define NOMORE(v, n) \
do{ \
__typeof__(n) _n = (n); \
__typeof__(v) _n = (n); \
if (_n < v) v = _n; \
}while(0)
#define LIMIT(v, n1, n2) \
do{ \
__typeof__(n1) _n1 = (n1); \
__typeof__(n2) _n2 = (n2); \
__typeof__(v) _n1 = (n1); \
__typeof__(v) _n2 = (n2); \
if (_n1 > v) v = _n1; \
else if (_n2 < v) v = _n2; \
}while(0)
@@ -319,9 +321,15 @@
namespace Private {
template<bool, typename _Tp = void> struct enable_if { };
template<typename _Tp> struct enable_if<true, _Tp> { typedef _Tp type; };
template<typename T, typename U> struct is_same { enum { value = false }; };
template<typename T> struct is_same<T, T> { enum { value = true }; };
template <typename T, typename ... Args> struct first_type_of { typedef T type; };
template <typename T> struct first_type_of<T> { typedef T type; };
}
// C++11 solution using SFINAE to detect the existance of a member in a class at compile time.
// It creates a HasMember<Type> structure containing 'value' set to true if the member exists
// C++11 solution using SFINAE to detect the existance of a member in a class at compile time.
// It creates a HasMember<Type> structure containing 'value' set to true if the member exists
#define HAS_MEMBER_IMPL(Member) \
namespace Private { \
template <typename Type, typename Yes=char, typename No=long> struct HasMember_ ## Member { \
+3 -1
View File
@@ -59,12 +59,14 @@ void serialprintPGM(PGM_P str) {
void serial_echo_start() { static PGMSTR(echomagic, "echo:"); serialprintPGM(echomagic); }
void serial_error_start() { static PGMSTR(errormagic, "Error:"); serialprintPGM(errormagic); }
void serial_echopair_PGM(PGM_P const s_P, serial_char_t v) { serialprintPGM(s_P); SERIAL_CHAR(v.c); }
void serial_echopair_PGM(PGM_P const s_P, const char *v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
void serial_echopair_PGM(PGM_P const s_P, char v) { serialprintPGM(s_P); SERIAL_CHAR(v); }
void serial_echopair_PGM(PGM_P const s_P, char v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
void serial_echopair_PGM(PGM_P const s_P, int v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
void serial_echopair_PGM(PGM_P const s_P, long v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
void serial_echopair_PGM(PGM_P const s_P, float v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); }
void serial_echopair_PGM(PGM_P const s_P, double v) { serialprintPGM(s_P); SERIAL_DECIMAL(v); }
void serial_echopair_PGM(PGM_P const s_P, unsigned char v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
void serial_echopair_PGM(PGM_P const s_P, unsigned int v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
void serial_echopair_PGM(PGM_P const s_P, unsigned long v) { serialprintPGM(s_P); SERIAL_ECHO(v); }
+76 -56
View File
@@ -81,37 +81,49 @@ typedef int8_t serial_index_t;
#define PORT_REDIRECT(p) _PORT_REDIRECT(1,p)
#define SERIAL_PORTMASK(P) _BV(P)
#define SERIAL_ECHO(x) SERIAL_OUT(print, x)
#define SERIAL_ECHO_F(V...) SERIAL_OUT(print, V)
#define SERIAL_ECHOLN(x) SERIAL_OUT(println, x)
#define SERIAL_PRINT(x,b) SERIAL_OUT(print, x, b)
#define SERIAL_PRINTLN(x,b) SERIAL_OUT(println, x, b)
#define SERIAL_FLUSH() SERIAL_OUT(flush)
//
// SERIAL_CHAR - Print one or more individual chars
//
inline void SERIAL_CHAR(char a) { SERIAL_IMPL.write(a); }
template <typename ... Args>
void SERIAL_CHAR(char a, Args ... args) { SERIAL_IMPL.write(a); SERIAL_CHAR(args ...); }
#ifdef ARDUINO_ARCH_STM32
#define SERIAL_FLUSHTX() SERIAL_OUT(flush)
#elif TX_BUFFER_SIZE > 0
#define SERIAL_FLUSHTX() SERIAL_OUT(flushTX)
#else
#define SERIAL_FLUSHTX()
#endif
/**
* SERIAL_ECHO - Print a single string or value.
* Any numeric parameter (including char) is printed as a base-10 number.
* A string pointer or literal will be output as a string.
*
* NOTE: Use SERIAL_CHAR to print char as a single character.
*/
template <typename T>
void SERIAL_ECHO(T x) { SERIAL_IMPL.print(x); }
// Print up to 10 chars from a list
#define __CHAR_N(N,V...) _CHAR_##N(V)
#define _CHAR_N(N,V...) __CHAR_N(N,V)
#define _CHAR_1(c) SERIAL_OUT(write, c)
#define _CHAR_2(a,b) do{ _CHAR_1(a); _CHAR_1(b); }while(0)
#define _CHAR_3(a,V...) do{ _CHAR_1(a); _CHAR_2(V); }while(0)
#define _CHAR_4(a,V...) do{ _CHAR_1(a); _CHAR_3(V); }while(0)
#define _CHAR_5(a,V...) do{ _CHAR_1(a); _CHAR_4(V); }while(0)
#define _CHAR_6(a,V...) do{ _CHAR_1(a); _CHAR_5(V); }while(0)
#define _CHAR_7(a,V...) do{ _CHAR_1(a); _CHAR_6(V); }while(0)
#define _CHAR_8(a,V...) do{ _CHAR_1(a); _CHAR_7(V); }while(0)
#define _CHAR_9(a,V...) do{ _CHAR_1(a); _CHAR_8(V); }while(0)
#define _CHAR_10(a,V...) do{ _CHAR_1(a); _CHAR_9(V); }while(0)
// Wrapper for ECHO commands to interpret a char
typedef struct SerialChar { char c; SerialChar(char n) : c(n) { } } serial_char_t;
inline void SERIAL_ECHO(serial_char_t x) { SERIAL_IMPL.write(x.c); }
#define AS_CHAR(C) serial_char_t(C)
#define SERIAL_CHAR(V...) _CHAR_N(NUM_ARGS(V),V)
// SERIAL_ECHO_F prints a floating point value with optional precision
inline void SERIAL_ECHO_F(EnsureDouble x, int digit = 2) { SERIAL_IMPL.print(x, digit); }
template <typename T>
void SERIAL_ECHOLN(T x) { SERIAL_IMPL.println(x); }
// SERIAL_PRINT works like SERIAL_ECHO but allow to specify the encoding base of the number printed
template <typename T, typename U>
void SERIAL_PRINT(T x, U y) { SERIAL_IMPL.print(x, y); }
template <typename T, typename U>
void SERIAL_PRINTLN(T x, U y) { SERIAL_IMPL.println(x, y); }
// Flush the serial port
inline void SERIAL_FLUSH() { SERIAL_IMPL.flush(); }
inline void SERIAL_FLUSHTX() { SERIAL_IMPL.flushTX(); }
// Print a single PROGMEM string to serial
void serialprintPGM(PGM_P str);
// SERIAL_ECHOPAIR / SERIAL_ECHOPAIR_P is used to output a key value pair. The key must be a string and the value can be anything
// Print up to 12 pairs of values. Odd elements auto-wrapped in PSTR().
#define __SEP_N(N,V...) _SEP_##N(V)
#define _SEP_N(N,V...) __SEP_N(N,V)
@@ -170,6 +182,7 @@ typedef int8_t serial_index_t;
#define _SEP_23_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_21_P(V); }while(0)
#define _SEP_24_P(a,b,V...) do{ _SEP_2_P(a,b); _SEP_22_P(V); }while(0)
// SERIAL_ECHOPAIR_P is used to output a key value pair. Unlike SERIAL_ECHOPAIR, the key must be a PGM string already and the value can be anything
#define SERIAL_ECHOPAIR_P(V...) _SEP_N_P(NUM_ARGS(V),V)
// Print up to 12 pairs of values followed by newline
@@ -244,32 +257,39 @@ typedef int8_t serial_index_t;
#define SERIAL_ECHOLNPAIR_P(V...) _SELP_N_P(NUM_ARGS(V),V)
// Print up to 20 comma-separated pairs of values
#define __SLST_N(N,V...) _SLST_##N(V)
#define _SLST_N(N,V...) __SLST_N(N,V)
#define _SLST_1(a) SERIAL_ECHO(a)
#define _SLST_2(a,b) do{ SERIAL_ECHO(a); SERIAL_ECHOPAIR(", ",b); }while(0)
#define _SLST_3(a,b,c) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_1(c); }while(0)
#define _SLST_4(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_2(V); }while(0)
#define _SLST_5(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_3(V); }while(0)
#define _SLST_6(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_4(V); }while(0)
#define _SLST_7(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_5(V); }while(0)
#define _SLST_8(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_6(V); }while(0)
#define _SLST_9(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_7(V); }while(0)
#define _SLST_10(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_8(V); }while(0)
#define _SLST_11(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_9(V); }while(0)
#define _SLST_12(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_10(V); }while(0)
#define _SLST_13(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_11(V); }while(0)
#define _SLST_14(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_12(V); }while(0)
#define _SLST_15(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_13(V); }while(0)
#define _SLST_16(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_14(V); }while(0)
#define _SLST_17(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_15(V); }while(0)
#define _SLST_18(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_16(V); }while(0)
#define _SLST_19(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_17(V); }while(0)
#define _SLST_20(a,b,V...) do{ SERIAL_ECHO(a); _SEP_2(", ",b); _SLST_18(V); }while(0) // Eat two args, pass the rest up
#ifdef AllowDifferentTypeInList
#define SERIAL_ECHOLIST(pre,V...) do{ SERIAL_ECHOPGM(pre); _SLST_N(NUM_ARGS(V),V); }while(0)
#define SERIAL_ECHOLIST_N(N,V...) _SLST_N(N,LIST_N(N,V))
inline void SERIAL_ECHOLIST_IMPL() {}
template <typename T>
void SERIAL_ECHOLIST_IMPL(T && t) { SERIAL_IMPL.print(t); }
template <typename T, typename ... Args>
void SERIAL_ECHOLIST_IMPL(T && t, Args && ... args) {
SERIAL_IMPL.print(t);
serialprintPGM(PSTR(", "));
SERIAL_ECHOLIST_IMPL(args...);
}
template <typename ... Args>
void SERIAL_ECHOLIST(PGM_P const str, Args && ... args) {
SERIAL_IMPL.print(str);
SERIAL_ECHOLIST_IMPL(args...);
}
#else // Optimization if the listed type are all the same (seems to be the case in the codebase so use that instead)
template <typename ... Args>
void SERIAL_ECHOLIST(PGM_P const str, Args && ... args) {
serialprintPGM(str);
typename Private::first_type_of<Args...>::type values[] = { args... };
constexpr size_t argsSize = sizeof...(args);
for (size_t i = 0; i < argsSize; i++) {
if (i) serialprintPGM(PSTR(", "));
SERIAL_IMPL.print(values[i]);
}
}
#endif
#define SERIAL_ECHOPGM_P(P) (serialprintPGM(P))
#define SERIAL_ECHOLNPGM_P(P) (serialprintPGM(P "\n"))
@@ -303,19 +323,19 @@ typedef int8_t serial_index_t;
//
// Functions for serial printing from PROGMEM. (Saves loads of SRAM.)
//
void serial_echopair_PGM(PGM_P const s_P, serial_char_t v);
void serial_echopair_PGM(PGM_P const s_P, const char *v);
void serial_echopair_PGM(PGM_P const s_P, char v);
void serial_echopair_PGM(PGM_P const s_P, int v);
void serial_echopair_PGM(PGM_P const s_P, unsigned int v);
void serial_echopair_PGM(PGM_P const s_P, long v);
void serial_echopair_PGM(PGM_P const s_P, unsigned long v);
void serial_echopair_PGM(PGM_P const s_P, float v);
void serial_echopair_PGM(PGM_P const s_P, double v);
inline void serial_echopair_PGM(PGM_P const s_P, uint8_t v) { serial_echopair_PGM(s_P, (int)v); }
void serial_echopair_PGM(PGM_P const s_P, unsigned char v);
void serial_echopair_PGM(PGM_P const s_P, unsigned int v);
void serial_echopair_PGM(PGM_P const s_P, unsigned long v);
inline void serial_echopair_PGM(PGM_P const s_P, bool v) { serial_echopair_PGM(s_P, (int)v); }
inline void serial_echopair_PGM(PGM_P const s_P, void *v) { serial_echopair_PGM(s_P, (uintptr_t)v); }
void serialprintPGM(PGM_P str);
void serial_echo_start();
void serial_error_start();
void serial_ternary(const bool onoff, PGM_P const pre, PGM_P const on, PGM_P const off, PGM_P const post=nullptr);
+77 -30
View File
@@ -22,25 +22,41 @@
#pragma once
#include "../inc/MarlinConfigPre.h"
#include "macros.h"
#if ENABLED(EMERGENCY_PARSER)
#include "../feature/e_parser.h"
#endif
#ifndef DEC
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
#endif
// flushTX is not implemented in all HAL, so use SFINAE to call the method where it is.
CALL_IF_EXISTS_IMPL(void, flushTX );
CALL_IF_EXISTS_IMPL(bool, connected, true);
// In order to catch usage errors in code, we make the base to encode number explicit
// If given a number (and not this enum), the compiler will reject the overload, falling back to the (double, digit) version
// We don't want hidden conversion of the first parameter to double, so it has to be as hard to do for the compiler as creating this enum
enum class PrintBase {
Dec = 10,
Hex = 16,
Oct = 8,
Bin = 2
};
// A simple forward struct that prevent the compiler to select print(double, int) as a default overload for any type different than
// double or float. For double or float, a conversion exists so the call will be transparent
struct EnsureDouble {
double a;
FORCE_INLINE operator double() { return a; }
// If the compiler breaks on ambiguity here, it's likely because you're calling print(X, base) with X not a double or a float, and a
// base that's not one of PrintBase's value. This exact code is made to detect such error, you NEED to set a base explicitely like this:
// SERIAL_PRINT(v, PrintBase::Hex)
FORCE_INLINE EnsureDouble(double a) : a(a) {}
FORCE_INLINE EnsureDouble(float a) : a(a) {}
};
// Using Curiously Recurring Template Pattern here to avoid virtual table cost when compiling.
// Since the real serial class is known at compile time, this results in compiler writing a completely
// efficient code
// Since the real serial class is known at compile time, this results in the compiler writing
// a completely efficient code.
template <class Child>
struct SerialBase {
#if ENABLED(EMERGENCY_PARSER)
@@ -78,26 +94,47 @@ struct SerialBase {
FORCE_INLINE void write(const char* str) { while (*str) write(*str++); }
FORCE_INLINE void write(const uint8_t* buffer, size_t size) { while (size--) write(*buffer++); }
FORCE_INLINE void print(const char* str) { write(str); }
NO_INLINE void print(char c, int base = 0) { print((long)c, base); }
NO_INLINE void print(unsigned char c, int base = 0) { print((unsigned long)c, base); }
NO_INLINE void print(int c, int base = DEC) { print((long)c, base); }
NO_INLINE void print(unsigned int c, int base = DEC) { print((unsigned long)c, base); }
void print(long c, int base = DEC) { if (!base) write(c); write((const uint8_t*)"-", c < 0); printNumber(c < 0 ? -c : c, base); }
void print(unsigned long c, int base = DEC) { printNumber(c, base); }
void print(double c, int digits = 2) { printFloat(c, digits); }
// No default argument to avoid ambiguity
NO_INLINE void print(char c, PrintBase base) { printNumber((signed long)c, (uint8_t)base); }
NO_INLINE void print(unsigned char c, PrintBase base) { printNumber((unsigned long)c, (uint8_t)base); }
NO_INLINE void print(int c, PrintBase base) { printNumber((signed long)c, (uint8_t)base); }
NO_INLINE void print(unsigned int c, PrintBase base) { printNumber((unsigned long)c, (uint8_t)base); }
void print(unsigned long c, PrintBase base) { printNumber((unsigned long)c, (uint8_t)base); }
void print(long c, PrintBase base) { printNumber((signed long)c, (uint8_t)base); }
void print(EnsureDouble c, int digits) { printFloat(c, digits); }
NO_INLINE void println(const char s[]) { print(s); println(); }
NO_INLINE void println(char c, int base = 0) { print(c, base); println(); }
NO_INLINE void println(unsigned char c, int base = 0) { print(c, base); println(); }
NO_INLINE void println(int c, int base = DEC) { print(c, base); println(); }
NO_INLINE void println(unsigned int c, int base = DEC) { print(c, base); println(); }
NO_INLINE void println(long c, int base = DEC) { print(c, base); println(); }
NO_INLINE void println(unsigned long c, int base = DEC) { print(c, base); println(); }
NO_INLINE void println(double c, int digits = 2) { print(c, digits); println(); }
NO_INLINE void println() { write('\r'); write('\n'); }
// Forward the call to the former's method
FORCE_INLINE void print(char c) { print(c, PrintBase::Dec); }
FORCE_INLINE void print(unsigned char c) { print(c, PrintBase::Dec); }
FORCE_INLINE void print(int c) { print(c, PrintBase::Dec); }
FORCE_INLINE void print(unsigned int c) { print(c, PrintBase::Dec); }
FORCE_INLINE void print(unsigned long c) { print(c, PrintBase::Dec); }
FORCE_INLINE void print(long c) { print(c, PrintBase::Dec); }
FORCE_INLINE void print(double c) { print(c, 2); }
FORCE_INLINE void println(const char s[]) { print(s); println(); }
FORCE_INLINE void println(char c, PrintBase base) { print(c, base); println(); }
FORCE_INLINE void println(unsigned char c, PrintBase base) { print(c, base); println(); }
FORCE_INLINE void println(int c, PrintBase base) { print(c, base); println(); }
FORCE_INLINE void println(unsigned int c, PrintBase base) { print(c, base); println(); }
FORCE_INLINE void println(long c, PrintBase base) { print(c, base); println(); }
FORCE_INLINE void println(unsigned long c, PrintBase base) { print(c, base); println(); }
FORCE_INLINE void println(double c, int digits) { print(c, digits); println(); }
FORCE_INLINE void println() { write('\r'); write('\n'); }
// Forward the call to the former's method
FORCE_INLINE void println(char c) { println(c, PrintBase::Dec); }
FORCE_INLINE void println(unsigned char c) { println(c, PrintBase::Dec); }
FORCE_INLINE void println(int c) { println(c, PrintBase::Dec); }
FORCE_INLINE void println(unsigned int c) { println(c, PrintBase::Dec); }
FORCE_INLINE void println(unsigned long c) { println(c, PrintBase::Dec); }
FORCE_INLINE void println(long c) { println(c, PrintBase::Dec); }
FORCE_INLINE void println(double c) { println(c, 2); }
// Print a number with the given base
void printNumber(unsigned long n, const uint8_t base) {
NO_INLINE void printNumber(unsigned long n, const uint8_t base) {
if (!base) return; // Hopefully, this should raise visible bug immediately
if (n) {
unsigned char buf[8 * sizeof(long)]; // Enough space for base 2
int8_t i = 0;
@@ -109,9 +146,19 @@ struct SerialBase {
}
else write('0');
}
void printNumber(signed long n, const uint8_t base) {
if (base == 10 && n < 0) {
n = -n; // This works because all platforms Marlin's builds on are using 2-complement encoding for negative number
// On such CPU, changing the sign of a number is done by inverting the bits and adding one, so if n = 0x80000000 = -2147483648 then
// -n = 0x7FFFFFFF + 1 => 0x80000000 = 2147483648 (if interpreted as unsigned) or -2147483648 if interpreted as signed.
// On non 2-complement CPU, there would be no possible representation for 2147483648.
write('-');
}
printNumber((unsigned long)n , base);
}
// Print a decimal number
void printFloat(double number, uint8_t digits) {
NO_INLINE void printFloat(double number, uint8_t digits) {
// Handle negative numbers
if (number < 0.0) {
write('-');
@@ -134,7 +181,7 @@ struct SerialBase {
// Extract digits from the remainder one at a time
while (digits--) {
remainder *= 10.0;
int toPrint = int(remainder);
unsigned long toPrint = (unsigned long)remainder;
printNumber(toPrint, 10);
remainder -= toPrint;
}
@@ -142,5 +189,5 @@ struct SerialBase {
}
};
// All serial instances will be built by chaining the features required for the function in a form of a template
// type definition
// All serial instances will be built by chaining the features required
// for the function in the form of a template type definition.
+9 -3
View File
@@ -21,6 +21,7 @@
*/
#pragma once
#include "macros.h"
#include "serial_base.h"
// The most basic serial class: it dispatch to the base serial class with no hook whatsoever. This will compile to nothing but the base serial class
@@ -37,6 +38,8 @@ struct BaseSerial : public SerialBase< BaseSerial<SerialT> >, public SerialT {
bool available(uint8_t index) { return index == 0 && SerialT::available(); }
int read(uint8_t index) { return index == 0 ? SerialT::read() : -1; }
bool connected() { return CALL_IF_EXISTS(bool, static_cast<SerialT*>(this), connected);; }
void flushTX() { CALL_IF_EXISTS(void, static_cast<SerialT*>(this), flushTX); }
// We have 2 implementation of the same method in both base class, let's say which one we want
using SerialT::available;
using SerialT::read;
@@ -68,6 +71,7 @@ struct ConditionalSerial : public SerialBase< ConditionalSerial<SerialT> > {
void msgDone() {}
bool connected() { return CALL_IF_EXISTS(bool, &out, connected); }
void flushTX() { CALL_IF_EXISTS(void, &out, flushTX); }
bool available(uint8_t index) { return index == 0 && out.available(); }
int read(uint8_t index) { return index == 0 ? out.read() : -1; }
@@ -91,6 +95,7 @@ struct ForwardSerial : public SerialBase< ForwardSerial<SerialT> > {
void msgDone() {}
// Existing instances implement Arduino's operator bool, so use that if it's available
bool connected() { return Private::HasMember_connected<SerialT>::value ? CALL_IF_EXISTS(bool, &out, connected) : (bool)out; }
void flushTX() { CALL_IF_EXISTS(void, &out, flushTX); }
bool available(uint8_t index) { return index == 0 && out.available(); }
int read(uint8_t index) { return index == 0 ? out.read() : -1; }
@@ -132,9 +137,10 @@ struct RuntimeSerial : public SerialBase< RuntimeSerial<SerialT> >, public Seria
using BaseClassT::println;
// Underlying implementation might use Arduino's bool operator
bool connected() {
return Private::HasMember_connected<SerialT>::value ? CALL_IF_EXISTS(bool, static_cast<SerialT*>(this), connected) : static_cast<SerialT*>(this)->operator bool();
}
bool connected() {
return Private::HasMember_connected<SerialT>::value ? CALL_IF_EXISTS(bool, static_cast<SerialT*>(this), connected) : static_cast<SerialT*>(this)->operator bool();
}
void flushTX() { CALL_IF_EXISTS(void, static_cast<SerialT*>(this), flushTX); }
void setHook(WriteHook writeHook = 0, EndOfMessageHook eofHook = 0, void * userPointer = 0) {
// Order is important here as serial code can be called inside interrupts
+2 -2
View File
@@ -47,11 +47,11 @@ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOPGM("Extrapolate [");
if (x < 10) DEBUG_CHAR(' ');
DEBUG_ECHO((int)x);
DEBUG_ECHO(x);
DEBUG_CHAR(xdir ? (xdir > 0 ? '+' : '-') : ' ');
DEBUG_CHAR(' ');
if (y < 10) DEBUG_CHAR(' ');
DEBUG_ECHO((int)y);
DEBUG_ECHO(y);
DEBUG_CHAR(ydir ? (ydir > 0 ? '+' : '-') : ' ');
DEBUG_ECHOLNPGM("]");
}
+3 -3
View File
@@ -160,7 +160,7 @@ void reset_bed_level() {
#ifndef SCAD_MESH_OUTPUT
LOOP_L_N(x, sx) {
serial_spaces(precision + (x < 10 ? 3 : 2));
SERIAL_ECHO(int(x));
SERIAL_ECHO(x);
}
SERIAL_EOL();
#endif
@@ -172,7 +172,7 @@ void reset_bed_level() {
SERIAL_ECHOPGM(" ["); // open sub-array
#else
if (y < 10) SERIAL_CHAR(' ');
SERIAL_ECHO(int(y));
SERIAL_ECHO(y);
#endif
LOOP_L_N(x, sx) {
SERIAL_CHAR(' ');
@@ -196,7 +196,7 @@ void reset_bed_level() {
#endif
}
#ifdef SCAD_MESH_OUTPUT
SERIAL_CHAR(' ', ']'); // close sub-array
SERIAL_ECHOPGM(" ]"); // close sub-array
if (y < sy - 1) SERIAL_CHAR(',');
#endif
SERIAL_EOL();
+2 -2
View File
@@ -50,7 +50,7 @@
GRID_LOOP(x, y)
if (!isnan(z_values[x][y])) {
SERIAL_ECHO_START();
SERIAL_ECHOPAIR(" M421 I", int(x), " J", int(y));
SERIAL_ECHOPAIR(" M421 I", x, " J", y);
SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, z_values[x][y], 4);
serial_delay(75); // Prevent Printrun from exploding
}
@@ -214,7 +214,7 @@
else if (isnan(f))
serialprintPGM(human ? PSTR(" . ") : PSTR("NAN"));
else if (human || csv) {
if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Space for positive ('-' for negative)
if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Display sign also for positive numbers (' ' for 0)
SERIAL_ECHO_F(f, 3); // Positive: 5 digits, Negative: 6 digits
}
if (csv && i < GRID_MAX_POINTS_X - 1) SERIAL_CHAR('\t');
+4 -4
View File
@@ -742,7 +742,7 @@
if (do_ubl_mesh_map) display_map(g29_map_type);
const int point_num = (GRID_MAX_POINTS) - count + 1;
SERIAL_ECHOLNPAIR("\nProbing mesh point ", point_num, "/", int(GRID_MAX_POINTS), ".\n");
SERIAL_ECHOLNPAIR("Probing mesh point ", point_num, "/", GRID_MAX_POINTS, ".");
TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), point_num, int(GRID_MAX_POINTS)));
#if HAS_LCD_MENU
@@ -1694,7 +1694,7 @@
SERIAL_EOL();
#if HAS_KILL
SERIAL_ECHOLNPAIR("Kill pin on :", int(KILL_PIN), " state:", int(kill_state()));
SERIAL_ECHOLNPAIR("Kill pin on :", KILL_PIN, " state:", kill_state());
#endif
SERIAL_EOL();
@@ -1707,8 +1707,8 @@
SERIAL_ECHOLNPAIR("Meshes go from ", hex_address((void*)settings.meshes_start_index()), " to ", hex_address((void*)settings.meshes_end_index()));
serial_delay(50);
SERIAL_ECHOLNPAIR("sizeof(ubl) : ", (int)sizeof(ubl)); SERIAL_EOL();
SERIAL_ECHOLNPAIR("z_value[][] size: ", (int)sizeof(z_values)); SERIAL_EOL();
SERIAL_ECHOLNPAIR("sizeof(ubl) : ", sizeof(ubl)); SERIAL_EOL();
SERIAL_ECHOLNPAIR("z_value[][] size: ", sizeof(z_values)); SERIAL_EOL();
serial_delay(25);
SERIAL_ECHOLNPAIR("EEPROM free for UBL: ", hex_address((void*)(settings.meshes_end_index() - settings.meshes_start_index())));
+3 -6
View File
@@ -352,8 +352,7 @@ public:
}
}
else {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("Packet header(", packet.header.sync, "?) corrupt");
SERIAL_ECHO_MSG("Packet header(", packet.header.sync, "?) corrupt");
stream_state = StreamState::PACKET_RESEND;
}
}
@@ -387,8 +386,7 @@ public:
stream_state = StreamState::PACKET_PROCESS;
}
else {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("Packet(", packet.header.sync, ") payload corrupt");
SERIAL_ECHO_MSG("Packet(", packet.header.sync, ") payload corrupt");
stream_state = StreamState::PACKET_RESEND;
}
}
@@ -406,8 +404,7 @@ public:
if (packet_retries < MAX_RETRIES || MAX_RETRIES == 0) {
packet_retries++;
stream_state = StreamState::PACKET_RESET;
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("Resend request ", int(packet_retries));
SERIAL_ECHO_MSG("Resend request ", packet_retries);
SERIAL_ECHOLNPAIR("rs", sync);
}
else
+3 -3
View File
@@ -64,7 +64,7 @@ void BLTouch::init(const bool set_voltage/*=false*/) {
#else
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPAIR("last_written_mode - ", (int)last_written_mode);
DEBUG_ECHOLNPAIR("last_written_mode - ", last_written_mode);
DEBUG_ECHOLNPGM("config mode - "
#if ENABLED(BLTOUCH_SET_5V_MODE)
"BLTOUCH_SET_5V_MODE"
@@ -175,7 +175,7 @@ bool BLTouch::status_proc() {
_set_SW_mode(); // Incidentally, _set_SW_mode() will also RESET any active alarm
const bool tr = triggered(); // If triggered in SW mode, the pin is up, it is STOWED
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("BLTouch is ", (int)tr);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("BLTouch is ", tr);
if (tr) _stow(); else _deploy(); // Turn off SW mode, reset any trigger, honor pin state
return !tr;
@@ -187,7 +187,7 @@ void BLTouch::mode_conv_proc(const bool M5V) {
* BLTOUCH V3.0: This will set the mode (twice) and sadly, a STOW is needed at the end, because of the deploy
* BLTOUCH V3.1: This will set the mode and store it in the eeprom. The STOW is not needed but does not hurt
*/
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("BLTouch Set Mode - ", (int)M5V);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("BLTouch Set Mode - ", M5V);
_deploy();
if (M5V) _set_5V_mode(); else _set_OD_mode();
_mode_store();
+2 -4
View File
@@ -66,10 +66,8 @@ void CancelObject::uncancel_object(const int8_t obj) {
}
void CancelObject::report() {
if (active_object >= 0) {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("Active Object: ", int(active_object));
}
if (active_object >= 0)
SERIAL_ECHO_MSG("Active Object: ", active_object);
if (canceled) {
SERIAL_ECHO_START();
+3 -3
View File
@@ -180,7 +180,7 @@ namespace DirectStepping {
if (!page_states_dirty) return;
page_states_dirty = false;
SERIAL_ECHO(Cfg::CONTROL_CHAR);
SERIAL_CHAR(Cfg::CONTROL_CHAR);
constexpr int state_bits = 2;
constexpr int n_bytes = Cfg::NUM_PAGES >> state_bits;
volatile uint8_t bits_b[n_bytes] = { 0 };
@@ -192,10 +192,10 @@ namespace DirectStepping {
uint8_t crc = 0;
for (uint8_t i = 0 ; i < n_bytes ; i++) {
crc ^= bits_b[i];
SERIAL_ECHO(bits_b[i]);
SERIAL_CHAR(bits_b[i]);
}
SERIAL_ECHO(crc);
SERIAL_CHAR(crc);
SERIAL_EOL();
}
+15 -16
View File
@@ -49,7 +49,7 @@ void I2CPositionEncoder::init(const uint8_t address, const AxisEnum axis) {
initialized++;
SERIAL_ECHOLNPAIR("Setting up encoder on ", axis_codes[encoderAxis], " axis, addr = ", address);
SERIAL_ECHOLNPAIR("Setting up encoder on ", AS_CHAR(axis_codes[encoderAxis]), " axis, addr = ", address);
position = get_position();
}
@@ -67,7 +67,7 @@ void I2CPositionEncoder::update() {
/*
if (trusted) { //commented out as part of the note below
trusted = false;
SERIAL_ECHOLMPAIR("Fault detected on ", axis_codes[encoderAxis], " axis encoder. Disengaging error correction until module is trusted again.");
SERIAL_ECHOLNPAIR("Fault detected on ", AS_CHAR(axis_codes[encoderAxis]), " axis encoder. Disengaging error correction until module is trusted again.");
}
*/
return;
@@ -92,7 +92,7 @@ void I2CPositionEncoder::update() {
if (millis() - lastErrorTime > I2CPE_TIME_TRUSTED) {
trusted = true;
SERIAL_ECHOLNPAIR("Untrusted encoder module on ", axis_codes[encoderAxis], " axis has been fault-free for set duration, reinstating error correction.");
SERIAL_ECHOLNPAIR("Untrusted encoder module on ", AS_CHAR(axis_codes[encoderAxis]), " axis has been fault-free for set duration, reinstating error correction.");
//the encoder likely lost its place when the error occured, so we'll reset and use the printer's
//idea of where it the axis is to re-initialize
@@ -172,7 +172,7 @@ void I2CPositionEncoder::update() {
float sumP = 0;
LOOP_L_N(i, I2CPE_ERR_PRST_ARRAY_SIZE) sumP += errPrst[i];
const int32_t errorP = int32_t(sumP * RECIPROCAL(I2CPE_ERR_PRST_ARRAY_SIZE));
SERIAL_ECHO(axis_codes[encoderAxis]);
SERIAL_CHAR(axis_codes[encoderAxis]);
SERIAL_ECHOLNPAIR(" : CORRECT ERR ", errorP * planner.steps_to_mm[encoderAxis], "mm");
babystep.add_steps(encoderAxis, -LROUND(errorP));
errPrstIdx = 0;
@@ -192,8 +192,8 @@ void I2CPositionEncoder::update() {
if (ABS(error) > I2CPE_ERR_CNT_THRESH * planner.settings.axis_steps_per_mm[encoderAxis]) {
const millis_t ms = millis();
if (ELAPSED(ms, nextErrorCountTime)) {
SERIAL_ECHO(axis_codes[encoderAxis]);
SERIAL_ECHOLNPAIR(" : LARGE ERR ", int(error), "; diffSum=", diffSum);
SERIAL_CHAR(axis_codes[encoderAxis]);
SERIAL_ECHOLNPAIR(" : LARGE ERR ", error, "; diffSum=", diffSum);
errorCount++;
nextErrorCountTime = ms + I2CPE_ERR_CNT_DEBOUNCE_MS;
}
@@ -213,7 +213,7 @@ void I2CPositionEncoder::set_homed() {
trusted++;
#ifdef I2CPE_DEBUG
SERIAL_ECHO(axis_codes[encoderAxis]);
SERIAL_CHAR(axis_codes[encoderAxis]);
SERIAL_ECHOLNPAIR(" axis encoder homed, offset of ", zeroOffset, " ticks.");
#endif
}
@@ -224,7 +224,7 @@ void I2CPositionEncoder::set_unhomed() {
homed = trusted = false;
#ifdef I2CPE_DEBUG
SERIAL_ECHO(axis_codes[encoderAxis]);
SERIAL_CHAR(axis_codes[encoderAxis]);
SERIAL_ECHOLNPGM(" axis encoder unhomed.");
#endif
}
@@ -232,7 +232,7 @@ void I2CPositionEncoder::set_unhomed() {
bool I2CPositionEncoder::passes_test(const bool report) {
if (report) {
if (H != I2CPE_MAG_SIG_GOOD) SERIAL_ECHOPGM("Warning. ");
SERIAL_ECHO(axis_codes[encoderAxis]);
SERIAL_CHAR(axis_codes[encoderAxis]);
serial_ternary(H == I2CPE_MAG_SIG_BAD, PSTR(" axis "), PSTR("magnetic strip "), PSTR("encoder "));
switch (H) {
case I2CPE_MAG_SIG_GOOD:
@@ -253,7 +253,7 @@ float I2CPositionEncoder::get_axis_error_mm(const bool report) {
error = ABS(diff) > 10000 ? 0 : diff; // Huge error is a bad reading
if (report) {
SERIAL_ECHO(axis_codes[encoderAxis]);
SERIAL_CHAR(axis_codes[encoderAxis]);
SERIAL_ECHOLNPAIR(" axis target=", target, "mm; actual=", actual, "mm; err=", error, "mm");
}
@@ -263,7 +263,7 @@ float I2CPositionEncoder::get_axis_error_mm(const bool report) {
int32_t I2CPositionEncoder::get_axis_error_steps(const bool report) {
if (!active) {
if (report) {
SERIAL_ECHO(axis_codes[encoderAxis]);
SERIAL_CHAR(axis_codes[encoderAxis]);
SERIAL_ECHOLNPGM(" axis encoder not active!");
}
return 0;
@@ -288,7 +288,7 @@ int32_t I2CPositionEncoder::get_axis_error_steps(const bool report) {
errorPrev = error;
if (report) {
SERIAL_ECHO(axis_codes[encoderAxis]);
SERIAL_CHAR(axis_codes[encoderAxis]);
SERIAL_ECHOLNPAIR(" axis target=", target, "; actual=", encoderCountInStepperTicksScaled, "; err=", error);
}
@@ -667,8 +667,7 @@ void I2CPositionEncodersMgr::report_position(const int8_t idx, const bool units,
else {
if (noOffset) {
const int32_t raw_count = encoders[idx].get_raw_count();
SERIAL_ECHO(axis_codes[encoders[idx].get_axis()]);
SERIAL_CHAR(' ');
SERIAL_CHAR(axis_codes[encoders[idx].get_axis()], ' ');
for (uint8_t j = 31; j > 0; j--)
SERIAL_ECHO((bool)(0x00000001 & (raw_count >> j)));
@@ -723,7 +722,7 @@ void I2CPositionEncodersMgr::change_module_address(const uint8_t oldaddr, const
// and enable it (it will likely have failed initialization on power-up, before the address change).
const int8_t idx = idx_from_addr(newaddr);
if (idx >= 0 && !encoders[idx].get_active()) {
SERIAL_ECHO(axis_codes[encoders[idx].get_axis()]);
SERIAL_CHAR(axis_codes[encoders[idx].get_axis()]);
SERIAL_ECHOLNPGM(" axis encoder was not detected on printer startup. Trying again.");
encoders[idx].set_active(encoders[idx].passes_test(true));
}
@@ -748,7 +747,7 @@ void I2CPositionEncodersMgr::report_module_firmware(const uint8_t address) {
if (Wire.requestFrom(I2C_ADDRESS(address), uint8_t(32))) {
char c;
while (Wire.available() > 0 && (c = (char)Wire.read()) > 0)
SERIAL_ECHO(c);
SERIAL_CHAR(c);
SERIAL_EOL();
}
+5 -5
View File
@@ -261,32 +261,32 @@ class I2CPositionEncodersMgr {
static void report_error_count(const int8_t idx, const AxisEnum axis) {
CHECK_IDX();
SERIAL_ECHOLNPAIR("Error count on ", axis_codes[axis], " axis is ", encoders[idx].get_error_count());
SERIAL_ECHOLNPAIR("Error count on ", AS_CHAR(axis_codes[axis]), " axis is ", encoders[idx].get_error_count());
}
static void reset_error_count(const int8_t idx, const AxisEnum axis) {
CHECK_IDX();
encoders[idx].set_error_count(0);
SERIAL_ECHOLNPAIR("Error count on ", axis_codes[axis], " axis has been reset.");
SERIAL_ECHOLNPAIR("Error count on ", AS_CHAR(axis_codes[axis]), " axis has been reset.");
}
static void enable_ec(const int8_t idx, const bool enabled, const AxisEnum axis) {
CHECK_IDX();
encoders[idx].set_ec_enabled(enabled);
SERIAL_ECHOPAIR("Error correction on ", axis_codes[axis]);
SERIAL_ECHOPAIR("Error correction on ", AS_CHAR(axis_codes[axis]));
SERIAL_ECHO_TERNARY(encoders[idx].get_ec_enabled(), " axis is ", "en", "dis", "abled.\n");
}
static void set_ec_threshold(const int8_t idx, const float newThreshold, const AxisEnum axis) {
CHECK_IDX();
encoders[idx].set_ec_threshold(newThreshold);
SERIAL_ECHOLNPAIR("Error correct threshold for ", axis_codes[axis], " axis set to ", newThreshold, "mm.");
SERIAL_ECHOLNPAIR("Error correct threshold for ", AS_CHAR(axis_codes[axis]), " axis set to ", newThreshold, "mm.");
}
static void get_ec_threshold(const int8_t idx, const AxisEnum axis) {
CHECK_IDX();
const float threshold = encoders[idx].get_ec_threshold();
SERIAL_ECHOLNPAIR("Error correct threshold for ", axis_codes[axis], " axis is ", threshold, "mm.");
SERIAL_ECHOLNPAIR("Error correct threshold for ", AS_CHAR(axis_codes[axis]), " axis is ", threshold, "mm.");
}
static int8_t idx_from_axis(const AxisEnum axis) {
+1 -1
View File
@@ -182,7 +182,7 @@ void host_action(PGM_P const pstr, const bool eol) {
break;
case PROMPT_PAUSE_RESUME:
msg = PSTR("LCD_PAUSE_RESUME");
#if ENABLED(ADVANCED_PAUSE_FEATURE)
#if BOTH(ADVANCED_PAUSE_FEATURE, SDSUPPORT)
extern const char M24_STR[];
queue.inject_P(M24_STR);
#endif
+7 -5
View File
@@ -147,11 +147,13 @@ void LEDLights::set_color(const LEDColor &incol
millis_t LEDLights::led_off_time; // = 0
void LEDLights::update_timeout(const bool power_on) {
const millis_t ms = millis();
if (power_on)
reset_timeout(ms);
else if (ELAPSED(ms, led_off_time))
set_off();
if (lights_on) {
const millis_t ms = millis();
if (power_on)
reset_timeout(ms);
else if (ELAPSED(ms, led_off_time))
set_off();
}
}
#endif
+1 -1
View File
@@ -203,7 +203,7 @@ public:
public:
static inline void reset_timeout(const millis_t &ms) {
led_off_time = ms + LED_BACKLIGHT_TIMEOUT;
if (!lights_on) set_default();
if (!lights_on) update();
}
static void update_timeout(const bool power_on);
#endif
+2 -2
View File
@@ -135,11 +135,11 @@ void Mixer::refresh_collector(const float proportion/*=1.0*/, const uint8_t t/*=
cmax = _MAX(cmax, v);
csum += v;
}
//SERIAL_ECHOPAIR("Mixer::refresh_collector(", proportion, ", ", int(t), ") cmax=", cmax, " csum=", csum, " color");
//SERIAL_ECHOPAIR("Mixer::refresh_collector(", proportion, ", ", t, ") cmax=", cmax, " csum=", csum, " color");
const float inv_prop = proportion / csum;
MIXER_STEPPER_LOOP(i) {
c[i] = color[t][i] * inv_prop;
//SERIAL_ECHOPAIR(" [", int(t), "][", int(i), "] = ", int(color[t][i]), " (", c[i], ") ");
//SERIAL_ECHOPAIR(" [", t, "][", i, "] = ", color[t][i], " (", c[i], ") ");
}
//SERIAL_EOL();
}
+7 -7
View File
@@ -139,9 +139,9 @@ class Mixer {
#ifdef MIXER_NORMALIZER_DEBUG
SERIAL_ECHOPGM("Mix [ ");
SERIAL_ECHOLIST_N(MIXING_STEPPERS, int(mix[0]), int(mix[1]), int(mix[2]), int(mix[3]), int(mix[4]), int(mix[5]));
SERIAL_ECHOLIST_N(MIXING_STEPPERS, mix[0], mix[1], mix[2], mix[3], mix[4], mix[5]);
SERIAL_ECHOPGM(" ] to Color [ ");
SERIAL_ECHOLIST_N(MIXING_STEPPERS, int(tcolor[0]), int(tcolor[1]), int(tcolor[2]), int(tcolor[3]), int(tcolor[4]), int(tcolor[5]));
SERIAL_ECHOLIST_N(MIXING_STEPPERS, tcolor[0], tcolor[1], tcolor[2], tcolor[3], tcolor[4], tcolor[5]);
SERIAL_ECHOLNPGM(" ]");
#endif
}
@@ -153,10 +153,10 @@ class Mixer {
MIXER_STEPPER_LOOP(i) mix[i] = mixer_perc_t(100.0f * color[j][i] / ctot);
#ifdef MIXER_NORMALIZER_DEBUG
SERIAL_ECHOPAIR("V-tool ", int(j), " [ ");
SERIAL_ECHOLIST_N(MIXING_STEPPERS, int(color[j][0]), int(color[j][1]), int(color[j][2]), int(color[j][3]), int(color[j][4]), int(color[j][5]));
SERIAL_ECHOPAIR("V-tool ", j, " [ ");
SERIAL_ECHOLIST_N(MIXING_STEPPERS, color[j][0], color[j][1], color[j][2], color[j][3], color[j][4], color[j][5]);
SERIAL_ECHOPGM(" ] to Mix [ ");
SERIAL_ECHOLIST_N(MIXING_STEPPERS, int(mix[0]), int(mix[1]), int(mix[2]), int(mix[3]), int(mix[4]), int(mix[5]));
SERIAL_ECHOLIST_N(MIXING_STEPPERS, mix[0], mix[1], mix[2], mix[3], mix[4], mix[5]);
SERIAL_ECHOLNPGM(" ]");
#endif
}
@@ -199,9 +199,9 @@ class Mixer {
#ifdef MIXER_NORMALIZER_DEBUG
SERIAL_ECHOPGM("Gradient [ ");
SERIAL_ECHOLIST_N(MIXING_STEPPERS, int(gradient.color[0]), int(gradient.color[1]), int(gradient.color[2]), int(gradient.color[3]), int(gradient.color[4]), int(gradient.color[5]));
SERIAL_ECHOLIST_N(MIXING_STEPPERS, gradient.color[0], gradient.color[1], gradient.color[2], gradient.color[3], gradient.color[4], gradient.color[5]);
SERIAL_ECHOPGM(" ] to Mix [ ");
SERIAL_ECHOLIST_N(MIXING_STEPPERS, int(mix[0]), int(mix[1]), int(mix[2]), int(mix[3]), int(mix[4]), int(mix[5]));
SERIAL_ECHOLIST_N(MIXING_STEPPERS, mix[0], mix[1], mix[2], mix[3], mix[4], mix[5]);
SERIAL_ECHOLNPGM(" ]");
#endif
}
+3 -6
View File
@@ -514,8 +514,7 @@ static void mmu2_not_responding() {
extruder = index; // filament change is finished
active_extruder = 0;
ENABLE_AXIS_E0();
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(extruder));
SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, extruder);
}
ui.reset_status();
}
@@ -602,8 +601,7 @@ static void mmu2_not_responding() {
active_extruder = 0;
ENABLE_AXIS_E0();
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(extruder));
SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, extruder);
ui.reset_status();
}
@@ -698,8 +696,7 @@ static void mmu2_not_responding() {
extruder = index; //filament change is finished
active_extruder = 0;
ENABLE_AXIS_E0();
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(extruder));
SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, extruder);
ui.reset_status();
}
+7 -7
View File
@@ -130,7 +130,7 @@ fil_change_settings_t fc_settings[EXTRUDERS];
*/
static bool ensure_safe_temperature(const bool wait=true, const PauseMode mode=PAUSE_MODE_SAME) {
DEBUG_SECTION(est, "ensure_safe_temperature", true);
DEBUG_ECHOLNPAIR("... wait:", int(wait), " mode:", int(mode));
DEBUG_ECHOLNPAIR("... wait:", wait, " mode:", mode);
#if ENABLED(PREVENT_COLD_EXTRUSION)
if (!DEBUGGING(DRYRUN) && thermalManager.targetTooColdToExtrude(active_extruder))
@@ -176,7 +176,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
DXC_ARGS
) {
DEBUG_SECTION(lf, "load_filament", true);
DEBUG_ECHOLNPAIR("... slowlen:", slow_load_length, " fastlen:", fast_load_length, " purgelen:", purge_length, " maxbeep:", int(max_beep_count), " showlcd:", int(show_lcd), " pauseforuser:", int(pause_for_user), " pausemode:", int(mode) DXC_SAY);
DEBUG_ECHOLNPAIR("... slowlen:", slow_load_length, " fastlen:", fast_load_length, " purgelen:", purge_length, " maxbeep:", max_beep_count, " showlcd:", show_lcd, " pauseforuser:", pause_for_user, " pausemode:", mode DXC_SAY);
if (!ensure_safe_temperature(false, mode)) {
if (show_lcd) ui.pause_show_message(PAUSE_MESSAGE_STATUS, mode);
@@ -309,7 +309,7 @@ bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/,
#endif
) {
DEBUG_SECTION(uf, "unload_filament", true);
DEBUG_ECHOLNPAIR("... unloadlen:", unload_length, " showlcd:", int(show_lcd), " mode:", int(mode)
DEBUG_ECHOLNPAIR("... unloadlen:", unload_length, " showlcd:", show_lcd, " mode:", mode
#if BOTH(FILAMENT_UNLOAD_ALL_EXTRUDERS, MIXING_EXTRUDER)
, " mixmult:", mix_multiplier
#endif
@@ -373,7 +373,7 @@ uint8_t did_pause_print = 0;
bool pause_print(const float &retract, const xyz_pos_t &park_point, const float &unload_length/*=0*/, const bool show_lcd/*=false*/ DXC_ARGS) {
DEBUG_SECTION(pp, "pause_print", true);
DEBUG_ECHOLNPAIR("... park.x:", park_point.x, " y:", park_point.y, " z:", park_point.z, " unloadlen:", unload_length, " showlcd:", int(show_lcd) DXC_SAY);
DEBUG_ECHOLNPAIR("... park.x:", park_point.x, " y:", park_point.y, " z:", park_point.z, " unloadlen:", unload_length, " showlcd:", show_lcd DXC_SAY);
UNUSED(show_lcd);
@@ -456,7 +456,7 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float
void show_continue_prompt(const bool is_reload) {
DEBUG_SECTION(scp, "pause_print", true);
DEBUG_ECHOLNPAIR("... is_reload:", int(is_reload));
DEBUG_ECHOLNPAIR("... is_reload:", is_reload);
ui.pause_show_message(is_reload ? PAUSE_MESSAGE_INSERT : PAUSE_MESSAGE_WAITING);
SERIAL_ECHO_START();
@@ -465,7 +465,7 @@ void show_continue_prompt(const bool is_reload) {
void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep_count/*=0*/ DXC_ARGS) {
DEBUG_SECTION(wfc, "wait_for_confirmation", true);
DEBUG_ECHOLNPAIR("... is_reload:", is_reload, " maxbeep:", int(max_beep_count) DXC_SAY);
DEBUG_ECHOLNPAIR("... is_reload:", is_reload, " maxbeep:", max_beep_count DXC_SAY);
bool nozzle_timed_out = false;
@@ -561,7 +561,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
*/
void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_length/*=0*/, const float &purge_length/*=ADVANCED_PAUSE_PURGE_LENGTH*/, const int8_t max_beep_count/*=0*/, int16_t targetTemp/*=0*/ DXC_ARGS) {
DEBUG_SECTION(rp, "resume_print", true);
DEBUG_ECHOLNPAIR("... slowlen:", slow_load_length, " fastlen:", fast_load_length, " purgelen:", purge_length, " maxbeep:", int(max_beep_count), " targetTemp:", targetTemp DXC_SAY);
DEBUG_ECHOLNPAIR("... slowlen:", slow_load_length, " fastlen:", fast_load_length, " purgelen:", purge_length, " maxbeep:", max_beep_count, " targetTemp:", targetTemp DXC_SAY);
/*
SERIAL_ECHOLNPAIR(
+6 -6
View File
@@ -532,7 +532,7 @@ void PrintJobRecovery::resume() {
void PrintJobRecovery::debug(PGM_P const prefix) {
DEBUG_PRINT_P(prefix);
DEBUG_ECHOLNPAIR(" Job Recovery Info...\nvalid_head:", int(info.valid_head), " valid_foot:", int(info.valid_foot));
DEBUG_ECHOLNPAIR(" Job Recovery Info...\nvalid_head:", info.valid_head, " valid_foot:", info.valid_foot);
if (info.valid_head) {
if (info.valid_head == info.valid_foot) {
DEBUG_ECHOPGM("current_position: ");
@@ -565,7 +565,7 @@ void PrintJobRecovery::resume() {
DEBUG_ECHOLNPAIR("feedrate: ", info.feedrate);
#if HAS_MULTI_EXTRUDER
DEBUG_ECHOLNPAIR("active_extruder: ", int(info.active_extruder));
DEBUG_ECHOLNPAIR("active_extruder: ", info.active_extruder);
#endif
#if HAS_HOTEND
@@ -584,14 +584,14 @@ void PrintJobRecovery::resume() {
#if HAS_FAN
DEBUG_ECHOPGM("fan_speed: ");
FANS_LOOP(i) {
DEBUG_ECHO(int(info.fan_speed[i]));
DEBUG_ECHO(info.fan_speed[i]);
if (i < FAN_COUNT - 1) DEBUG_CHAR(',');
}
DEBUG_EOL();
#endif
#if HAS_LEVELING
DEBUG_ECHOLNPAIR("leveling: ", int(info.flag.leveling), " fade: ", info.fade);
DEBUG_ECHOLNPAIR("leveling: ", info.flag.leveling, " fade: ", info.fade);
#endif
#if ENABLED(FWRETRACT)
DEBUG_ECHOPGM("retract: ");
@@ -605,8 +605,8 @@ void PrintJobRecovery::resume() {
DEBUG_ECHOLNPAIR("sd_filename: ", info.sd_filename);
DEBUG_ECHOLNPAIR("sdpos: ", info.sdpos);
DEBUG_ECHOLNPAIR("print_job_elapsed: ", info.print_job_elapsed);
DEBUG_ECHOLNPAIR("dryrun: ", int(info.flag.dryrun));
DEBUG_ECHOLNPAIR("allow_cold_extrusion: ", int(info.flag.allow_cold_extrusion));
DEBUG_ECHOLNPAIR("dryrun: ", info.flag.dryrun);
DEBUG_ECHOLNPAIR("allow_cold_extrusion: ", info.flag.allow_cold_extrusion);
}
else
DEBUG_ECHOLNPGM("INVALID DATA");
+3 -3
View File
@@ -43,7 +43,7 @@ void Repeat::add_marker(const uint32_t sdpos, const uint16_t count) {
marker[index].sdpos = sdpos;
marker[index].counter = count ?: -1;
index++;
DEBUG_ECHOLNPAIR("Add Marker ", int(index), " at ", sdpos, " (", count, ")");
DEBUG_ECHOLNPAIR("Add Marker ", index, " at ", sdpos, " (", count, ")");
}
}
@@ -53,14 +53,14 @@ void Repeat::loop() {
else {
const uint8_t ind = index - 1; // Active marker's index
if (!marker[ind].counter) { // Did its counter run out?
DEBUG_ECHOLNPAIR("Pass Marker ", int(index));
DEBUG_ECHOLNPAIR("Pass Marker ", index);
index--; // Carry on. Previous marker on the next 'M808'.
}
else {
card.setIndex(marker[ind].sdpos); // Loop back to the marker.
if (marker[ind].counter > 0) // Ignore a negative (or zero) counter.
--marker[ind].counter; // Decrement the counter. If zero this 'M808' will be skipped next time.
DEBUG_ECHOLNPAIR("Goto Marker ", int(index), " at ", marker[ind].sdpos, " (", marker[ind].counter, ")");
DEBUG_ECHOLNPAIR("Goto Marker ", index, " at ", marker[ind].sdpos, " (", marker[ind].counter, ")");
}
}
}
+32 -32
View File
@@ -233,10 +233,10 @@
void report_polled_driver_data(TMC &st, const TMC_driver_data &data) {
const uint32_t pwm_scale = get_pwm_scale(st);
st.printLabel();
SERIAL_CHAR(':'); SERIAL_PRINT(pwm_scale, DEC);
SERIAL_CHAR(':'); SERIAL_ECHO(pwm_scale);
#if ENABLED(TMC_DEBUG)
#if HAS_TMCX1X0 || HAS_TMC220x
SERIAL_CHAR('/'); SERIAL_PRINT(data.cs_actual, DEC);
SERIAL_CHAR('/'); SERIAL_ECHO(data.cs_actual);
#endif
#if HAS_STALLGUARD
SERIAL_CHAR('/');
@@ -257,7 +257,7 @@
#endif
if (st.flag_otpw) SERIAL_CHAR('F'); // otpw Flag
SERIAL_CHAR('|');
if (st.otpw_count > 0) SERIAL_PRINT(st.otpw_count, DEC);
if (st.otpw_count > 0) SERIAL_ECHO(st.otpw_count);
SERIAL_CHAR('\t');
}
@@ -551,8 +551,8 @@
#if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC5130)
static void _tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) {
switch (i) {
case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break;
case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break;
case TMC_PWM_SCALE: SERIAL_ECHO(st.PWM_SCALE()); break;
case TMC_SGT: SERIAL_ECHO(st.sgt()); break;
case TMC_STEALTHCHOP: serialprint_truefalse(st.en_pwm_mode()); break;
case TMC_INTERPOLATE: serialprint_truefalse(st.intpol()); break;
default: break;
@@ -563,9 +563,9 @@
static void _tmc_parse_drv_status(TMC2130Stepper &st, const TMC_drv_status_enum i) {
switch (i) {
case TMC_STALLGUARD: if (st.stallguard()) SERIAL_CHAR('*'); break;
case TMC_SG_RESULT: SERIAL_PRINT(st.sg_result(), DEC); break;
case TMC_SG_RESULT: SERIAL_ECHO(st.sg_result()); break;
case TMC_FSACTIVE: if (st.fsactive()) SERIAL_CHAR('*'); break;
case TMC_DRV_CS_ACTUAL: SERIAL_PRINT(st.cs_actual(), DEC); break;
case TMC_DRV_CS_ACTUAL: SERIAL_ECHO(st.cs_actual()); break;
default: break;
}
}
@@ -580,13 +580,13 @@
static void _tmc_status(TMC2160Stepper &st, const TMC_debug_enum i) {
switch (i) {
case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break;
case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break;
case TMC_PWM_SCALE: SERIAL_ECHO(st.PWM_SCALE()); break;
case TMC_SGT: SERIAL_ECHO(st.sgt()); break;
case TMC_STEALTHCHOP: serialprint_truefalse(st.en_pwm_mode()); break;
case TMC_GLOBAL_SCALER:
{
uint16_t value = st.GLOBAL_SCALER();
SERIAL_PRINT(value ?: 256, DEC);
SERIAL_ECHO(value ? value : 256);
SERIAL_ECHOPGM("/256");
}
break;
@@ -599,10 +599,10 @@
#if HAS_TMC220x
static void _tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) {
switch (i) {
case TMC_PWM_SCALE_SUM: SERIAL_PRINT(st.pwm_scale_sum(), DEC); break;
case TMC_PWM_SCALE_AUTO: SERIAL_PRINT(st.pwm_scale_auto(), DEC); break;
case TMC_PWM_OFS_AUTO: SERIAL_PRINT(st.pwm_ofs_auto(), DEC); break;
case TMC_PWM_GRAD_AUTO: SERIAL_PRINT(st.pwm_grad_auto(), DEC); break;
case TMC_PWM_SCALE_SUM: SERIAL_ECHO(st.pwm_scale_sum()); break;
case TMC_PWM_SCALE_AUTO: SERIAL_ECHO(st.pwm_scale_auto()); break;
case TMC_PWM_OFS_AUTO: SERIAL_ECHO(st.pwm_ofs_auto()); break;
case TMC_PWM_GRAD_AUTO: SERIAL_ECHO(st.pwm_grad_auto()); break;
case TMC_STEALTHCHOP: serialprint_truefalse(st.stealth()); break;
case TMC_INTERPOLATE: serialprint_truefalse(st.intpol()); break;
default: break;
@@ -613,8 +613,8 @@
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
static void _tmc_status(TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const TMC_debug_enum i) {
switch (i) {
case TMC_SGT: SERIAL_PRINT(st.SGTHRS(), DEC); break;
case TMC_UART_ADDR: SERIAL_PRINT(st.get_address(), DEC); break;
case TMC_SGT: SERIAL_ECHO(st.SGTHRS()); break;
case TMC_UART_ADDR: SERIAL_ECHO(st.get_address()); break;
default:
TMC2208Stepper *parent = &st;
_tmc_status(*parent, i);
@@ -631,7 +631,7 @@
case TMC_T120: if (st.t120()) SERIAL_CHAR('*'); break;
case TMC_S2VSA: if (st.s2vsa()) SERIAL_CHAR('*'); break;
case TMC_S2VSB: if (st.s2vsb()) SERIAL_CHAR('*'); break;
case TMC_DRV_CS_ACTUAL: SERIAL_PRINT(st.cs_actual(), DEC); break;
case TMC_DRV_CS_ACTUAL: SERIAL_ECHO(st.cs_actual()); break;
default: break;
}
}
@@ -639,7 +639,7 @@
#if HAS_DRIVER(TMC2209)
static void _tmc_parse_drv_status(TMC2209Stepper &st, const TMC_drv_status_enum i) {
switch (i) {
case TMC_SG_RESULT: SERIAL_PRINT(st.SG_RESULT(), DEC); break;
case TMC_SG_RESULT: SERIAL_ECHO(st.SG_RESULT()); break;
default: _tmc_parse_drv_status(static_cast<TMC2208Stepper &>(st), i); break;
}
}
@@ -666,15 +666,15 @@
case TMC_RMS_CURRENT: SERIAL_ECHO(st.rms_current()); break;
case TMC_MAX_CURRENT: SERIAL_PRINT((float)st.rms_current() * 1.41, 0); break;
case TMC_IRUN:
SERIAL_PRINT(st.irun(), DEC);
SERIAL_ECHO(st.irun());
SERIAL_ECHOPGM("/31");
break;
case TMC_IHOLD:
SERIAL_PRINT(st.ihold(), DEC);
SERIAL_ECHO(st.ihold());
SERIAL_ECHOPGM("/31");
break;
case TMC_CS_ACTUAL:
SERIAL_PRINT(st.cs_actual(), DEC);
SERIAL_ECHO(st.cs_actual());
SERIAL_ECHOPGM("/31");
break;
case TMC_VSENSE: print_vsense(st); break;
@@ -694,11 +694,11 @@
#if ENABLED(MONITOR_DRIVER_STATUS)
case TMC_OTPW_TRIGGERED: serialprint_truefalse(st.getOTPW()); break;
#endif
case TMC_TOFF: SERIAL_PRINT(st.toff(), DEC); break;
case TMC_TBL: SERIAL_PRINT(st.blank_time(), DEC); break;
case TMC_HEND: SERIAL_PRINT(st.hysteresis_end(), DEC); break;
case TMC_HSTRT: SERIAL_PRINT(st.hysteresis_start(), DEC); break;
case TMC_MSCNT: SERIAL_PRINT(st.get_microstep_counter(), DEC); break;
case TMC_TOFF: SERIAL_ECHO(st.toff()); break;
case TMC_TBL: SERIAL_ECHO(st.blank_time()); break;
case TMC_HEND: SERIAL_ECHO(st.hysteresis_end()); break;
case TMC_HSTRT: SERIAL_ECHO(st.hysteresis_start()); break;
case TMC_MSCNT: SERIAL_ECHO(st.get_microstep_counter()); break;
default: _tmc_status(st, i); break;
}
}
@@ -714,18 +714,18 @@
case TMC_RMS_CURRENT: SERIAL_ECHO(st.rms_current()); break;
case TMC_MAX_CURRENT: SERIAL_PRINT((float)st.rms_current() * 1.41, 0); break;
case TMC_IRUN:
SERIAL_PRINT(st.cs(), DEC);
SERIAL_ECHO(st.cs());
SERIAL_ECHOPGM("/31");
break;
case TMC_VSENSE: serialprintPGM(st.vsense() ? PSTR("1=.165") : PSTR("0=.310")); break;
case TMC_MICROSTEPS: SERIAL_ECHO(st.microsteps()); break;
//case TMC_OTPW: serialprint_truefalse(st.otpw()); break;
//case TMC_OTPW_TRIGGERED: serialprint_truefalse(st.getOTPW()); break;
case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break;
case TMC_TOFF: SERIAL_PRINT(st.toff(), DEC); break;
case TMC_TBL: SERIAL_PRINT(st.blank_time(), DEC); break;
case TMC_HEND: SERIAL_PRINT(st.hysteresis_end(), DEC); break;
case TMC_HSTRT: SERIAL_PRINT(st.hysteresis_start(), DEC); break;
case TMC_SGT: SERIAL_ECHO(st.sgt()); break;
case TMC_TOFF: SERIAL_ECHO(st.toff()); break;
case TMC_TBL: SERIAL_ECHO(st.blank_time()); break;
case TMC_HEND: SERIAL_ECHO(st.hysteresis_end()); break;
case TMC_HSTRT: SERIAL_ECHO(st.hysteresis_start()); break;
default: break;
}
}
+1 -1
View File
@@ -537,7 +537,7 @@ void GcodeSuite::G26() {
if (bedtemp) {
if (!WITHIN(bedtemp, 40, BED_MAX_TARGET)) {
SERIAL_ECHOLNPAIR("?Specified bed temperature not plausible (40-", int(BED_MAX_TARGET), "C).");
SERIAL_ECHOLNPAIR("?Specified bed temperature not plausible (40-", BED_MAX_TARGET, "C).");
return;
}
g26_bed_temp = bedtemp;
+2 -2
View File
@@ -104,7 +104,7 @@ void GcodeSuite::G35() {
const float z_probed_height = probe.probe_at_point(screws_tilt_adjust_pos[i], PROBE_PT_RAISE, 0, true);
if (isnan(z_probed_height)) {
SERIAL_ECHOPAIR("G35 failed at point ", int(i), " (");
SERIAL_ECHOPAIR("G35 failed at point ", i, " (");
SERIAL_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i]));
SERIAL_CHAR(')');
SERIAL_ECHOLNPAIR_P(SP_X_STR, screws_tilt_adjust_pos[i].x, SP_Y_STR, screws_tilt_adjust_pos[i].y);
@@ -113,7 +113,7 @@ void GcodeSuite::G35() {
}
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOPAIR("Probing point ", int(i), " (");
DEBUG_ECHOPAIR("Probing point ", i, " (");
DEBUG_PRINT_P((char *)pgm_read_ptr(&tramming_point_name[i]));
DEBUG_CHAR(')');
DEBUG_ECHOLNPAIR_P(SP_X_STR, screws_tilt_adjust_pos[i].x, SP_Y_STR, screws_tilt_adjust_pos[i].y, SP_Z_STR, z_probed_height);
+2 -2
View File
@@ -637,7 +637,7 @@ G29_TYPE GcodeSuite::G29() {
// Avoid probing outside the round or hexagonal area
if (TERN0(IS_KINEMATIC, !probe.can_reach(probePos))) continue;
if (verbose_level) SERIAL_ECHOLNPAIR("Probing mesh point ", int(pt_index), "/", abl_points, ".");
if (verbose_level) SERIAL_ECHOLNPAIR("Probing mesh point ", pt_index, "/", abl_points, ".");
TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), int(pt_index), int(abl_points)));
measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(probePos, raise_after, verbose_level);
@@ -682,7 +682,7 @@ G29_TYPE GcodeSuite::G29() {
// Probe at 3 arbitrary points
LOOP_L_N(i, 3) {
if (verbose_level) SERIAL_ECHOLNPAIR("Probing point ", int(i + 1), "/3.");
if (verbose_level) SERIAL_ECHOLNPAIR("Probing point ", i + 1, "/3.");
TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/3"), GET_TEXT(MSG_PROBING_MESH), int(i + 1)));
// Retain the last probe position
+4 -8
View File
@@ -142,8 +142,7 @@ void GcodeSuite::G29() {
if (parser.seenval('I')) {
ix = parser.value_int();
if (!WITHIN(ix, 0, GRID_MAX_POINTS_X - 1)) {
SERIAL_ECHOPAIR("I out of range (0-", int(GRID_MAX_POINTS_X - 1));
SERIAL_ECHOLNPGM(")");
SERIAL_ECHOLNPAIR("I out of range (0-", GRID_MAX_POINTS_X - 1, ")");
return;
}
}
@@ -153,8 +152,7 @@ void GcodeSuite::G29() {
if (parser.seenval('J')) {
iy = parser.value_int();
if (!WITHIN(iy, 0, GRID_MAX_POINTS_Y - 1)) {
SERIAL_ECHOPAIR("J out of range (0-", int(GRID_MAX_POINTS_Y - 1));
SERIAL_ECHOLNPGM(")");
SERIAL_ECHOLNPAIR("J out of range (0-", GRID_MAX_POINTS_Y - 1, ")");
return;
}
}
@@ -182,10 +180,8 @@ void GcodeSuite::G29() {
} // switch(state)
if (state == MeshNext) {
SERIAL_ECHOPAIR("MBL G29 point ", _MIN(mbl_probe_index, GRID_MAX_POINTS));
SERIAL_ECHOLNPAIR(" of ", int(GRID_MAX_POINTS));
}
if (state == MeshNext)
SERIAL_ECHOLNPAIR("MBL G29 point ", _MIN(mbl_probe_index, GRID_MAX_POINTS), " of ", GRID_MAX_POINTS);
report_current_position();
}
+9 -9
View File
@@ -238,7 +238,7 @@ void GcodeSuite::G34() {
// the next iteration of probing. This allows adjustments to be made away from the bed.
z_measured[iprobe] = z_probed_height + Z_CLEARANCE_BETWEEN_PROBES;
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(iprobe + 1), " measured position is ", z_measured[iprobe]);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", iprobe + 1, " measured position is ", z_measured[iprobe]);
// Remember the minimum measurement to calculate the correction later on
z_measured_min = _MIN(z_measured_min, z_measured[iprobe]);
@@ -267,7 +267,7 @@ void GcodeSuite::G34() {
linear_fit_data lfd;
incremental_LSF_reset(&lfd);
LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS) {
SERIAL_ECHOLNPAIR("PROBEPT_", int(i), ": ", z_measured[i]);
SERIAL_ECHOLNPAIR("PROBEPT_", i, ": ", z_measured[i]);
incremental_LSF(&lfd, z_stepper_align.xy[i], z_measured[i]);
}
finish_incremental_LSF(&lfd);
@@ -357,8 +357,8 @@ void GcodeSuite::G34() {
// Check for less accuracy compared to last move
if (decreasing_accuracy(last_z_align_move[zstepper], z_align_abs)) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " last_z_align_move = ", last_z_align_move[zstepper]);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " z_align_abs = ", z_align_abs);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", zstepper + 1, " last_z_align_move = ", last_z_align_move[zstepper]);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", zstepper + 1, " z_align_abs = ", z_align_abs);
adjustment_reverse = !adjustment_reverse;
}
@@ -370,7 +370,7 @@ void GcodeSuite::G34() {
// Stop early if all measured points achieve accuracy target
if (z_align_abs > z_auto_align_accuracy) success_break = false;
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " corrected by ", z_align_move);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", zstepper + 1, " corrected by ", z_align_move);
// Lock all steppers except one
stepper.set_all_z_lock(true, zstepper);
@@ -380,7 +380,7 @@ void GcodeSuite::G34() {
// Will match reversed Z steppers on dual steppers. Triple will need more work to map.
if (adjustment_reverse) {
z_align_move = -z_align_move;
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " correction reversed to ", z_align_move);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", zstepper + 1, " correction reversed to ", z_align_move);
}
#endif
@@ -406,7 +406,7 @@ void GcodeSuite::G34() {
if (err_break)
SERIAL_ECHOLNPGM("G34 aborted.");
else {
SERIAL_ECHOLNPAIR("Did ", int(iteration + (iteration != z_auto_align_iterations)), " of ", int(z_auto_align_iterations));
SERIAL_ECHOLNPAIR("Did ", iteration + (iteration != z_auto_align_iterations), " of ", z_auto_align_iterations);
SERIAL_ECHOLNPAIR_F("Accuracy: ", z_maxdiff);
}
@@ -467,10 +467,10 @@ void GcodeSuite::M422() {
if (!parser.seen_any()) {
LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS)
SERIAL_ECHOLNPAIR_P(PSTR("M422 S"), int(i + 1), SP_X_STR, z_stepper_align.xy[i].x, SP_Y_STR, z_stepper_align.xy[i].y);
SERIAL_ECHOLNPAIR_P(PSTR("M422 S"), i + 1, SP_X_STR, z_stepper_align.xy[i].x, SP_Y_STR, z_stepper_align.xy[i].y);
#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
LOOP_L_N(i, NUM_Z_STEPPER_DRIVERS)
SERIAL_ECHOLNPAIR_P(PSTR("M422 W"), int(i + 1), SP_X_STR, z_stepper_align.stepper_xy[i].x, SP_Y_STR, z_stepper_align.stepper_xy[i].y);
SERIAL_ECHOLNPAIR_P(PSTR("M422 W"), i + 1, SP_X_STR, z_stepper_align.stepper_xy[i].x, SP_Y_STR, z_stepper_align.stepper_xy[i].y);
#endif
return;
}
+2 -2
View File
@@ -375,7 +375,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) {
inline void report_measured_positional_error(const measurements_t &m) {
SERIAL_CHAR('T');
SERIAL_ECHO(int(active_extruder));
SERIAL_ECHO(active_extruder);
SERIAL_ECHOLNPGM(" Positional Error:");
#if HAS_X_CENTER
SERIAL_ECHOLNPAIR_P(SP_X_STR, m.pos_error.x);
@@ -408,7 +408,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) {
//
inline void report_hotend_offsets() {
LOOP_S_L_N(e, 1, HOTENDS)
SERIAL_ECHOLNPAIR_P(PSTR("T"), int(e), PSTR(" Hotend Offset X"), hotend_offset[e].x, SP_Y_STR, hotend_offset[e].y, SP_Z_STR, hotend_offset[e].z);
SERIAL_ECHOLNPAIR_P(PSTR("T"), e, PSTR(" Hotend Offset X"), hotend_offset[e].x, SP_Y_STR, hotend_offset[e].y, SP_Z_STR, hotend_offset[e].z);
}
#endif
+1 -1
View File
@@ -241,7 +241,7 @@ void GcodeSuite::M48() {
if (verbose_level > 1) {
SERIAL_ECHO(n + 1);
SERIAL_ECHOPAIR(" of ", int(n_samples));
SERIAL_ECHOPAIR(" of ", n_samples);
SERIAL_ECHOPAIR_F(": z: ", pz, 3);
SERIAL_CHAR(' ');
dev_report(verbose_level > 2, mean, sigma, min, max);
+1 -1
View File
@@ -47,7 +47,7 @@ void M217_report(const bool eeprom=false) {
" G", toolchange_settings.fan_time);
#if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
SERIAL_ECHOPAIR(" A", int(migration.automode));
SERIAL_ECHOPAIR(" A", migration.automode);
SERIAL_ECHOPAIR(" L", LINEAR_UNIT(migration.last));
#endif
+8 -8
View File
@@ -34,7 +34,9 @@
* U<angle> - Stowed Angle
*/
void GcodeSuite::M281() {
if (!parser.seenval('P')) return;
const int servo_index = parser.value_int();
if (WITHIN(servo_index, 0, NUM_SERVOS - 1)) {
#if ENABLED(BLTOUCH)
@@ -53,16 +55,14 @@ void GcodeSuite::M281() {
angle_change = true;
}
if (!angle_change) {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(" Servo ", servo_index,
" L", servo_angles[servo_index][0],
" U", servo_angles[servo_index][1]);
SERIAL_ECHO_MSG(" Servo ", servo_index,
" L", servo_angles[servo_index][0],
" U", servo_angles[servo_index][1]);
}
}
else {
SERIAL_ERROR_START();
SERIAL_ECHOLNPAIR("Servo ", servo_index, " out of range");
}
else
SERIAL_ERROR_MSG("Servo ", servo_index, " out of range");
}
#endif // EDITABLE_SERVO_ANGLES
+5 -4
View File
@@ -35,14 +35,15 @@
* D<dval> - Set the D value
*/
void GcodeSuite::M304() {
if (parser.seen('P')) thermalManager.temp_bed.pid.Kp = parser.value_float();
if (parser.seen('I')) thermalManager.temp_bed.pid.Ki = scalePID_i(parser.value_float());
if (parser.seen('D')) thermalManager.temp_bed.pid.Kd = scalePID_d(parser.value_float());
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(" p:", thermalManager.temp_bed.pid.Kp,
" i:", unscalePID_i(thermalManager.temp_bed.pid.Ki),
" d:", unscalePID_d(thermalManager.temp_bed.pid.Kd));
SERIAL_ECHO_MSG(" p:", thermalManager.temp_bed.pid.Kp,
" i:", unscalePID_i(thermalManager.temp_bed.pid.Ki),
" d:", unscalePID_d(thermalManager.temp_bed.pid.Kd));
}
#endif // PIDTEMPBED
+2 -4
View File
@@ -49,10 +49,8 @@ void GcodeSuite::M305() {
const bool do_set = parser.seen("BCRT");
// A valid P index is required
if (t_index >= (USER_THERMISTORS) || (do_set && t_index < 0)) {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("!Invalid index. (0 <= P <= ", int(USER_THERMISTORS - 1), ")");
}
if (t_index >= (USER_THERMISTORS) || (do_set && t_index < 0))
SERIAL_ECHO_MSG("!Invalid index. (0 <= P <= ", USER_THERMISTORS - 1, ")");
else if (do_set) {
if (parser.seen('R')) // Pullup resistor value
if (!thermalManager.set_pull_up_res(t_index, parser.value_float()))
+3 -3
View File
@@ -131,7 +131,7 @@ inline void servo_probe_test() {
const uint8_t probe_index = parser.byteval('P', Z_PROBE_SERVO_NR);
SERIAL_ECHOLNPAIR("Servo probe test\n"
". using index: ", int(probe_index),
". using index: ", probe_index,
", deploy angle: ", servo_angles[probe_index][0],
", stow angle: ", servo_angles[probe_index][1]
);
@@ -143,7 +143,7 @@ inline void servo_probe_test() {
#define PROBE_TEST_PIN Z_MIN_PIN
constexpr bool probe_inverting = Z_MIN_ENDSTOP_INVERTING;
SERIAL_ECHOLNPAIR(". Probe Z_MIN_PIN: ", int(PROBE_TEST_PIN));
SERIAL_ECHOLNPAIR(". Probe Z_MIN_PIN: ", PROBE_TEST_PIN);
SERIAL_ECHOPGM(". Z_MIN_ENDSTOP_INVERTING: ");
#else
@@ -151,7 +151,7 @@ inline void servo_probe_test() {
#define PROBE_TEST_PIN Z_MIN_PROBE_PIN
constexpr bool probe_inverting = Z_MIN_PROBE_ENDSTOP_INVERTING;
SERIAL_ECHOLNPAIR(". Probe Z_MIN_PROBE_PIN: ", int(PROBE_TEST_PIN));
SERIAL_ECHOLNPAIR(". Probe Z_MIN_PROBE_PIN: ", PROBE_TEST_PIN);
SERIAL_ECHOPGM( ". Z_MIN_PROBE_ENDSTOP_INVERTING: ");
#endif
+1 -1
View File
@@ -37,7 +37,7 @@ void report_M92(const bool echo=true, const int8_t e=-1) {
LOOP_L_N(i, E_STEPPERS) {
if (e >= 0 && i != e) continue;
if (echo) SERIAL_ECHO_START(); else SERIAL_CHAR(' ');
SERIAL_ECHOLNPAIR_P(PSTR(" M92 T"), (int)i,
SERIAL_ECHOLNPAIR_P(PSTR(" M92 T"), i,
SP_E_STR, VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS_N(i)]));
}
#endif
+7 -8
View File
@@ -31,7 +31,9 @@
* M280: Get or set servo position. P<index> [S<angle>]
*/
void GcodeSuite::M280() {
if (!parser.seen('P')) return;
const int servo_index = parser.value_int();
if (WITHIN(servo_index, 0, NUM_SERVOS - 1)) {
if (parser.seen('S')) {
@@ -41,15 +43,12 @@ void GcodeSuite::M280() {
else
MOVE_SERVO(servo_index, a);
}
else {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(" Servo ", servo_index, ": ", servo[servo_index].read());
}
}
else {
SERIAL_ERROR_START();
SERIAL_ECHOLNPAIR("Servo ", servo_index, " out of range");
else
SERIAL_ECHO_MSG(" Servo ", servo_index, ": ", servo[servo_index].read());
}
else
SERIAL_ERROR_MSG("Servo ", servo_index, " out of range");
}
#endif // HAS_SERVOS
+8 -8
View File
@@ -122,26 +122,26 @@
case DXC_DUPLICATION_MODE: DEBUG_ECHOPGM("DUPLICATION"); break;
case DXC_MIRRORED_MODE: DEBUG_ECHOPGM("MIRRORED"); break;
}
DEBUG_ECHOPAIR("\nActive Ext: ", int(active_extruder));
DEBUG_ECHOPAIR("\nActive Ext: ", active_extruder);
if (!active_extruder_parked) DEBUG_ECHOPGM(" NOT ");
DEBUG_ECHOPGM(" parked.");
DEBUG_ECHOPAIR("\nactive_extruder_x_pos: ", current_position.x);
DEBUG_ECHOPAIR("\ninactive_extruder_x: ", inactive_extruder_x);
DEBUG_ECHOPAIR("\nextruder_duplication_enabled: ", int(extruder_duplication_enabled));
DEBUG_ECHOPAIR("\nextruder_duplication_enabled: ", extruder_duplication_enabled);
DEBUG_ECHOPAIR("\nduplicate_extruder_x_offset: ", duplicate_extruder_x_offset);
DEBUG_ECHOPAIR("\nduplicate_extruder_temp_offset: ", duplicate_extruder_temp_offset);
DEBUG_ECHOPAIR("\ndelayed_move_time: ", delayed_move_time);
DEBUG_ECHOPAIR("\nX1 Home X: ", x_home_pos(0), "\nX1_MIN_POS=", int(X1_MIN_POS), "\nX1_MAX_POS=", int(X1_MAX_POS));
DEBUG_ECHOPAIR("\nX2 Home X: ", x_home_pos(1), "\nX2_MIN_POS=", int(X2_MIN_POS), "\nX2_MAX_POS=", int(X2_MAX_POS));
DEBUG_ECHOPAIR("\nX2_HOME_DIR=", int(X2_HOME_DIR), "\nX2_HOME_POS=", int(X2_HOME_POS));
DEBUG_ECHOPAIR("\nX1 Home X: ", x_home_pos(0), "\nX1_MIN_POS=", X1_MIN_POS, "\nX1_MAX_POS=", X1_MAX_POS);
DEBUG_ECHOPAIR("\nX2 Home X: ", x_home_pos(1), "\nX2_MIN_POS=", X2_MIN_POS, "\nX2_MAX_POS=", X2_MAX_POS);
DEBUG_ECHOPAIR("\nX2_HOME_DIR=", X2_HOME_DIR, "\nX2_HOME_POS=", X2_HOME_POS);
DEBUG_ECHOPAIR("\nDEFAULT_DUAL_X_CARRIAGE_MODE=", STRINGIFY(DEFAULT_DUAL_X_CARRIAGE_MODE));
DEBUG_ECHOPAIR("\toolchange_settings.z_raise=", toolchange_settings.z_raise);
DEBUG_ECHOPAIR("\nDEFAULT_DUPLICATION_X_OFFSET=", int(DEFAULT_DUPLICATION_X_OFFSET));
DEBUG_ECHOPAIR("\nDEFAULT_DUPLICATION_X_OFFSET=", DEFAULT_DUPLICATION_X_OFFSET);
DEBUG_EOL();
HOTEND_LOOP() {
DEBUG_ECHOPAIR_P(SP_T_STR, int(e));
LOOP_XYZ(a) DEBUG_ECHOPAIR(" hotend_offset[", int(e), "].", XYZ_CHAR(a) | 0x20, "=", hotend_offset[e][a]);
DEBUG_ECHOPAIR_P(SP_T_STR, e);
LOOP_XYZ(a) DEBUG_ECHOPAIR(" hotend_offset[", e, "].", XYZ_CHAR(a) | 0x20, "=", hotend_offset[e][a]);
DEBUG_EOL();
}
DEBUG_EOL();
+2 -2
View File
@@ -75,7 +75,7 @@ void GcodeSuite::M502() {
if (dowrite) {
val = parser.byteval('V');
persistentStore.write_data(addr, &val);
SERIAL_ECHOLNPAIR("Wrote address ", addr, " with ", int(val));
SERIAL_ECHOLNPAIR("Wrote address ", addr, " with ", val);
}
else {
if (parser.seenval('T')) {
@@ -90,7 +90,7 @@ void GcodeSuite::M502() {
}
else {
persistentStore.read_data(addr, &val);
SERIAL_ECHOLNPAIR("Read address ", addr, " and got ", int(val));
SERIAL_ECHOLNPAIR("Read address ", addr, " and got ", val);
}
}
return;
+4 -4
View File
@@ -43,7 +43,7 @@
void GcodeSuite::M900() {
auto echo_value_oor = [](const char ltr, const bool ten=true) {
SERIAL_CHAR('?'); SERIAL_CHAR(ltr);
SERIAL_CHAR('?', ltr);
SERIAL_ECHOPGM(" value out of range");
if (ten) SERIAL_ECHOPGM(" (0-10)");
SERIAL_ECHOLNPGM(".");
@@ -115,12 +115,12 @@ void GcodeSuite::M900() {
#if ENABLED(EXTRA_LIN_ADVANCE_K)
#if EXTRUDERS < 2
SERIAL_ECHOLNPAIR("Advance S", int(new_slot), " K", kref, "(S", int(!new_slot), " K", lref, ")");
SERIAL_ECHOLNPAIR("Advance S", new_slot, " K", kref, "(S", !new_slot, " K", lref, ")");
#else
LOOP_L_N(i, EXTRUDERS) {
const bool slot = TEST(lin_adv_slot, i);
SERIAL_ECHOLNPAIR("Advance T", int(i), " S", int(slot), " K", planner.extruder_advance_K[i],
"(S", int(!slot), " K", other_extruder_advance_K[i], ")");
SERIAL_ECHOLNPAIR("Advance T", i, " S", slot, " K", planner.extruder_advance_K[i],
"(S", !slot, " K", other_extruder_advance_K[i], ")");
SERIAL_EOL();
}
#endif
+1 -1
View File
@@ -82,7 +82,7 @@ void GcodeSuite::M7219() {
LOOP_L_N(r, MAX7219_LINES) {
SERIAL_ECHOPGM("led_line[");
if (r < 10) SERIAL_CHAR(' ');
SERIAL_ECHO(int(r));
SERIAL_ECHO(r);
SERIAL_ECHOPGM("]=");
for (uint8_t b = 8; b--;) SERIAL_CHAR('0' + TEST(max7219.led_line[r], b));
SERIAL_EOL();
+2 -2
View File
@@ -30,7 +30,7 @@
#include "../../../feature/mixing.h"
inline void echo_mix() {
SERIAL_ECHOPAIR(" (", int(mixer.mix[0]), "%|", int(mixer.mix[1]), "%)");
SERIAL_ECHOPAIR(" (", mixer.mix[0], "%|", mixer.mix[1], "%)");
}
inline void echo_zt(const int t, const float &z) {
@@ -74,7 +74,7 @@ void GcodeSuite::M166() {
#if ENABLED(GRADIENT_VTOOL)
if (mixer.gradient.vtool_index >= 0) {
SERIAL_ECHOPAIR(" (T", int(mixer.gradient.vtool_index));
SERIAL_ECHOPAIR(" (T", mixer.gradient.vtool_index);
SERIAL_CHAR(')');
}
#endif
@@ -48,7 +48,7 @@ void MAC_report() {
SERIAL_ECHOPGM(" MAC: ");
LOOP_L_N(i, 6) {
if (mac[i] < 16) SERIAL_CHAR('0');
SERIAL_PRINT(mac[i], HEX);
SERIAL_PRINT(mac[i], PrintBase::Hex);
if (i < 5) SERIAL_CHAR(':');
}
}
+1 -1
View File
@@ -49,7 +49,7 @@ void GcodeSuite::G61(void) {
// No saved position? No axes being restored?
if (!TEST(saved_slots[slot >> 3], slot & 0x07) || !parser.seen("XYZ")) return;
SERIAL_ECHOPAIR(STR_RESTORING_POS " S", int(slot));
SERIAL_ECHOPAIR(STR_RESTORING_POS " S", slot);
LOOP_XYZ(i) {
destination[i] = parser.seen(XYZ_CHAR(i))
? stored_position[slot][i] + parser.value_axis_units((AxisEnum)i)
+2 -2
View File
@@ -105,7 +105,7 @@ int8_t GcodeSuite::get_target_extruder_from_command() {
if (e < EXTRUDERS) return e;
SERIAL_ECHO_START();
SERIAL_CHAR('M'); SERIAL_ECHO(parser.codenum);
SERIAL_ECHOLNPAIR(" " STR_INVALID_EXTRUDER " ", int(e));
SERIAL_ECHOLNPAIR(" " STR_INVALID_EXTRUDER " ", e);
return -1;
}
return active_extruder;
@@ -124,7 +124,7 @@ int8_t GcodeSuite::get_target_e_stepper_from_command() {
if (e == -1)
SERIAL_ECHOLNPGM(" " STR_E_STEPPER_NOT_SPECIFIED);
else
SERIAL_ECHOLNPAIR(" " STR_INVALID_E_STEPPER " ", int(e));
SERIAL_ECHOLNPAIR(" " STR_INVALID_E_STEPPER " ", e);
return -1;
}
+7 -1
View File
@@ -30,6 +30,8 @@
#include "../HAL/shared/eeprom_if.h"
#include "../HAL/shared/Delay.h"
extern void dump_delay_accuracy_check();
/**
* Dn: G-code for development and testing
*
@@ -141,7 +143,7 @@
}
} break;
case 5: { // D4 Read / Write onboard Flash
case 5: { // D5 Read / Write onboard Flash
#define FLASH_SIZE 1024
uint8_t *pointer = parser.hex_adr_val('A');
uint16_t len = parser.ushortval('C', 1);
@@ -162,6 +164,10 @@
}
} break;
case 6: // D6 Check delay loop accuracy
dump_delay_accuracy_check();
break;
case 100: { // D100 Disable heaters and attempt a hard hang (Watchdog Test)
SERIAL_ECHOLNPGM("Disabling heaters and attempting to trigger Watchdog");
SERIAL_ECHOLNPGM("(USE_WATCHDOG " TERN(USE_WATCHDOG, "ENABLED", "DISABLED") ")");
+4 -4
View File
@@ -32,14 +32,14 @@
* S<seconds> Optional. Set the keepalive interval.
*/
void GcodeSuite::M113() {
if (parser.seenval('S')) {
host_keepalive_interval = parser.value_byte();
NOMORE(host_keepalive_interval, 60);
}
else {
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("M113 S", (unsigned long)host_keepalive_interval);
}
else
SERIAL_ECHO_MSG("M113 S", host_keepalive_interval);
}
#endif // HOST_KEEPALIVE_FEATURE
+2 -2
View File
@@ -35,8 +35,8 @@
static void cap_line(PGM_P const name, bool ena=false) {
SERIAL_ECHOPGM("Cap:");
serialprintPGM(name);
SERIAL_CHAR(':');
SERIAL_ECHOLN(int(ena ? 1 : 0));
SERIAL_CHAR(':', ena ? '1' : '0');
SERIAL_EOL();
}
#endif
+1 -1
View File
@@ -35,7 +35,7 @@
static void config_prefix(PGM_P const name, PGM_P const pref=nullptr, const int8_t ind=-1) {
SERIAL_ECHOPGM("Config:");
if (pref) serialprintPGM(pref);
if (ind >= 0) { SERIAL_ECHO(int(ind)); SERIAL_CHAR(':'); }
if (ind >= 0) { SERIAL_ECHO(ind); SERIAL_CHAR(':'); }
serialprintPGM(name);
SERIAL_CHAR(':');
}
+3 -5
View File
@@ -42,14 +42,12 @@
FORCE_INLINE void mod_probe_offset(const float &offs) {
if (TERN1(BABYSTEP_HOTEND_Z_OFFSET, active_extruder == 0)) {
probe.offset.z += offs;
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(STR_PROBE_OFFSET " " STR_Z, probe.offset.z);
SERIAL_ECHO_MSG(STR_PROBE_OFFSET " " STR_Z, probe.offset.z);
}
else {
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
hotend_offset[active_extruder].z -= offs;
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(STR_PROBE_OFFSET STR_Z ": ", hotend_offset[active_extruder].z);
SERIAL_ECHO_MSG(STR_PROBE_OFFSET STR_Z ": ", hotend_offset[active_extruder].z);
#endif
}
}
@@ -99,7 +97,7 @@ void GcodeSuite::M290() {
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
{
SERIAL_ECHOLNPAIR_P(
PSTR("Hotend "), int(active_extruder)
PSTR("Hotend "), active_extruder
#if ENABLED(BABYSTEP_XY)
, PSTR("Offset X"), hotend_offset[active_extruder].x
, SP_Y_STR, hotend_offset[active_extruder].y
+3 -3
View File
@@ -307,7 +307,7 @@ void GCodeParser::parse(char *p) {
#if ENABLED(DEBUG_GCODE_PARSER)
if (debug) {
SERIAL_ECHOPAIR("Got param ", param, " at index ", (int)(p - command_ptr - 1));
SERIAL_ECHOPAIR("Got param ", param, " at index ", p - command_ptr - 1);
if (has_val) SERIAL_ECHOPGM(" (has_val)");
}
#endif
@@ -391,8 +391,8 @@ void GCodeParser::unknown_command_warning() {
"\n sec-ms: ", value_millis_from_seconds(),
"\n int: ", value_int(),
"\n ushort: ", value_ushort(),
"\n byte: ", (int)value_byte(),
"\n bool: ", (int)value_bool(),
"\n byte: ", value_byte(),
"\n bool: ", value_bool(),
"\n linear: ", value_linear_units(),
"\n celsius: ", value_celsius()
);
+2 -2
View File
@@ -133,9 +133,9 @@ public:
param[ind] = ptr ? ptr - command_ptr : 0; // parameter offset or 0
#if ENABLED(DEBUG_GCODE_PARSER)
if (codenum == 800) {
SERIAL_ECHOPAIR("Set bit ", (int)ind, " of codebits (", hex_address((void*)(codebits >> 16)));
SERIAL_ECHOPAIR("Set bit ", ind, " of codebits (", hex_address((void*)(codebits >> 16)));
print_hex_word((uint16_t)(codebits & 0xFFFF));
SERIAL_ECHOLNPAIR(") | param = ", (int)param[ind]);
SERIAL_ECHOLNPAIR(") | param = ", param[ind]);
}
#endif
}
+3 -3
View File
@@ -58,7 +58,7 @@ void GcodeSuite::M851() {
if (WITHIN(x, -(X_BED_SIZE), X_BED_SIZE))
offs.x = x;
else {
SERIAL_ECHOLNPAIR("?X out of range (-", int(X_BED_SIZE), " to ", int(X_BED_SIZE), ")");
SERIAL_ECHOLNPAIR("?X out of range (-", X_BED_SIZE, " to ", X_BED_SIZE, ")");
ok = false;
}
#else
@@ -72,7 +72,7 @@ void GcodeSuite::M851() {
if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE))
offs.y = y;
else {
SERIAL_ECHOLNPAIR("?Y out of range (-", int(Y_BED_SIZE), " to ", int(Y_BED_SIZE), ")");
SERIAL_ECHOLNPAIR("?Y out of range (-", Y_BED_SIZE, " to ", Y_BED_SIZE, ")");
ok = false;
}
#else
@@ -85,7 +85,7 @@ void GcodeSuite::M851() {
if (WITHIN(z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX))
offs.z = z;
else {
SERIAL_ECHOLNPAIR("?Z out of range (", int(Z_PROBE_OFFSET_RANGE_MIN), " to ", int(Z_PROBE_OFFSET_RANGE_MAX), ")");
SERIAL_ECHOLNPAIR("?Z out of range (", Z_PROBE_OFFSET_RANGE_MIN, " to ", Z_PROBE_OFFSET_RANGE_MAX, ")");
ok = false;
}
}
+5 -6
View File
@@ -298,13 +298,12 @@ void GCodeQueue::ok_to_send() {
#if ENABLED(ADVANCED_OK)
char* p = command_buffer[index_r];
if (*p == 'N') {
SERIAL_ECHO(' ');
SERIAL_ECHO(*p++);
SERIAL_CHAR(' ', *p++);
while (NUMERIC_SIGNED(*p))
SERIAL_ECHO(*p++);
SERIAL_CHAR(*p++);
}
SERIAL_ECHOPAIR_P(SP_P_STR, int(planner.moves_free()),
SP_B_STR, int(BUFSIZE - length));
SERIAL_ECHOPAIR_P(SP_P_STR, planner.moves_free(),
SP_B_STR, BUFSIZE - length);
#endif
SERIAL_EOL();
}
@@ -611,7 +610,7 @@ void GCodeQueue::get_serial_commands() {
if (!is_eol && sd_count) ++sd_count; // End of file with no newline
if (!process_line_done(sd_input_state, command_buffer[index_w], sd_count)) {
// M808 S saves the sdpos of the next line. M808 loops to a new sdpos.
// M808 L saves the sdpos of the next line. M808 loops to a new sdpos.
TERN_(GCODE_REPEAT_MARKERS, repeat.early_parse_M808(command_buffer[index_w]));
// Put the new command into the buffer (no "ok" sent)
+2 -2
View File
@@ -26,6 +26,7 @@
#include "../gcode.h"
#include "../../sd/cardreader.h"
#include "../../lcd/marlinui.h"
/**
* M21: Init SD Card
@@ -36,9 +37,8 @@ void GcodeSuite::M21() { card.mount(); }
* M22: Release SD Card
*/
void GcodeSuite::M22() {
if (!IS_SD_PRINTING()) card.release();
IF_ENABLED(TFT_COLOR_UI, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT));
}
#endif // SDSUPPORT
+1 -2
View File
@@ -35,6 +35,5 @@ void GcodeSuite::M31() {
ui.set_status(buffer);
SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR("Print time: ", buffer);
SERIAL_ECHO_MSG("Print time: ", buffer);
}
+6 -30
View File
@@ -516,34 +516,10 @@
(defined(SERIAL_PORT_2) && SERIAL_PORT_2 == (N)) || \
(defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == (N)) || \
(defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == (N))
#if ANY_SERIAL_IS(-1)
#define USING_SERIAL_DEFAULT
#if ENABLED(CUSTOM_USER_MENUS)
#define _HAS_1(N) (defined(USER_DESC_##N) && defined(USER_GCODE_##N))
#define HAS_USER_ITEM(V...) DO(HAS,||,V)
#else
#define HAS_USER_ITEM(N) 0
#endif
#if ANY_SERIAL_IS(0)
#define USING_SERIAL_0 1
#endif
#if ANY_SERIAL_IS(1)
#define USING_SERIAL_1 1
#endif
#if ANY_SERIAL_IS(2)
#define USING_SERIAL_2 1
#endif
#if ANY_SERIAL_IS(3)
#define USING_SERIAL_3 1
#endif
#if ANY_SERIAL_IS(4)
#define USING_SERIAL_4 1
#endif
#if ANY_SERIAL_IS(5)
#define USING_SERIAL_5 1
#endif
#if ANY_SERIAL_IS(6)
#define USING_SERIAL_6 1
#endif
#if ANY_SERIAL_IS(7)
#define USING_SERIAL_7 1
#endif
#if ANY_SERIAL_IS(8)
#define USING_SERIAL_8 1
#endif
#undef ANY_SERIAL_IS
+182 -82
View File
@@ -404,30 +404,33 @@
#endif
#if TEMP_SENSOR_0 == -5 || TEMP_SENSOR_0 == -3 || TEMP_SENSOR_0 == -2
#define HEATER_0_USES_MAX6675 1
#define TEMP_SENSOR_0_IS_MAX_TC 1
#define HAS_MAX_TC 1
#if TEMP_SENSOR_0 == -3
#define HEATER_0_MAX6675_TMIN -270
#define HEATER_0_MAX6675_TMAX 1800
#define TEMP_SENSOR_0_MAX_TC_TMIN -270
#define TEMP_SENSOR_0_MAX_TC_TMAX 1800
#else
#define HEATER_0_MAX6675_TMIN 0
#define HEATER_0_MAX6675_TMAX 1024
#define TEMP_SENSOR_0_MAX_TC_TMIN 0
#define TEMP_SENSOR_0_MAX_TC_TMAX 1024
#endif
#if TEMP_SENSOR_0 == -5
#define MAX6675_0_IS_MAX31865 1
#define TEMP_SENSOR_0_IS_MAX31865 1
#elif TEMP_SENSOR_0 == -3
#define MAX6675_0_IS_MAX31855 1
#define TEMP_SENSOR_0_IS_MAX31855 1
#elif TEMP_SENSOR_0 == -2
#define TEMP_SENSOR_0_IS_MAX6675 1
#endif
#elif TEMP_SENSOR_0 == -4
#define HEATER_0_USES_AD8495 1
#define TEMP_SENSOR_0_IS_AD8495 1
#elif TEMP_SENSOR_0 == -1
#define HEATER_0_USES_AD595 1
#define TEMP_SENSOR_0_IS_AD595 1
#elif TEMP_SENSOR_0 > 0
#define THERMISTOR_HEATER_0 TEMP_SENSOR_0
#define HEATER_0_USES_THERMISTOR 1
#define TEMP_SENSOR_0_THERMISTOR_ID TEMP_SENSOR_0
#define TEMP_SENSOR_0_IS_THERMISTOR 1
#if TEMP_SENSOR_0 == 1000
#define HEATER_0_USER_THERMISTOR 1
#define TEMP_SENSOR_0_IS_CUSTOM 1
#elif TEMP_SENSOR_0 == 998 || TEMP_SENSOR_0 == 999
#define HEATER_0_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_0_IS_DUMMY 1
#endif
#else
#undef HEATER_0_MINTEMP
@@ -435,18 +438,21 @@
#endif
#if TEMP_SENSOR_1 == -5 || TEMP_SENSOR_1 == -3 || TEMP_SENSOR_1 == -2
#define HEATER_1_USES_MAX6675 1
#define TEMP_SENSOR_1_IS_MAX_TC 1
#define HAS_MAX_TC 1
#if TEMP_SENSOR_1 == -3
#define HEATER_1_MAX6675_TMIN -270
#define HEATER_1_MAX6675_TMAX 1800
#define TEMP_SENSOR_1_MAX_TC_TMIN -270
#define TEMP_SENSOR_1_MAX_TC_TMAX 1800
#else
#define HEATER_1_MAX6675_TMIN 0
#define HEATER_1_MAX6675_TMAX 1024
#define TEMP_SENSOR_1_MAX_TC_TMIN 0
#define TEMP_SENSOR_1_MAX_TC_TMAX 1024
#endif
#if TEMP_SENSOR_1 == -5
#define MAX6675_1_IS_MAX31865 1
#define TEMP_SENSOR_1_IS_MAX31865 1
#elif TEMP_SENSOR_1 == -3
#define MAX6675_1_IS_MAX31855 1
#define TEMP_SENSOR_1_IS_MAX31855 1
#elif TEMP_SENSOR_1 == -2
#define TEMP_SENSOR_1_IS_MAX6675 1
#endif
#if TEMP_SENSOR_1 != TEMP_SENSOR_0
#if TEMP_SENSOR_1 == -5
@@ -458,37 +464,131 @@
#endif
#endif
#elif TEMP_SENSOR_1 == -4
#define HEATER_1_USES_AD8495 1
#define TEMP_SENSOR_1_IS_AD8495 1
#elif TEMP_SENSOR_1 == -1
#define HEATER_1_USES_AD595 1
#define TEMP_SENSOR_1_IS_AD595 1
#elif TEMP_SENSOR_1 > 0
#define THERMISTOR_HEATER_1 TEMP_SENSOR_1
#define HEATER_1_USES_THERMISTOR 1
#define TEMP_SENSOR_1_THERMISTOR_ID TEMP_SENSOR_1
#define TEMP_SENSOR_1_IS_THERMISTOR 1
#if TEMP_SENSOR_1 == 1000
#define HEATER_1_USER_THERMISTOR 1
#define TEMP_SENSOR_1_IS_CUSTOM 1
#elif TEMP_SENSOR_1 == 998 || TEMP_SENSOR_1 == 999
#define HEATER_1_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_1_IS_DUMMY 1
#endif
#else
#undef HEATER_1_MINTEMP
#undef HEATER_1_MAXTEMP
#endif
#if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855
#define HAS_MAX31855 1
#endif
#if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865
#define HAS_MAX31865 1
#endif
#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675
#define HAS_MAX6675 1
#endif
//
// Compatibility layer for MAX (SPI) temp boards
//
#if PIN_EXISTS(MAX6675_SS)
#if TEMP_SENSOR_0_IS_MAX31855
#define MAX31855_CS_PIN MAX6675_SS_PIN
#elif TEMP_SENSOR_0_IS_MAX31865
#define MAX31865_CS_PIN MAX6675_SS_PIN
#elif TEMP_SENSOR_0_IS_MAX6675
#define MAX6675_CS_PIN MAX6675_SS_PIN
#endif
#endif
#if PIN_EXISTS(MAX6675_SS2)
#if TEMP_SENSOR_1_IS_MAX31855
#define MAX31855_CS2_PIN MAX6675_SS2_PIN
#elif TEMP_SENSOR_1_IS_MAX31865
#define MAX31865_CS2_PIN MAX6675_SS2_PIN
#elif TEMP_SENSOR_1_IS_MAX6675
#define MAX6675_CS2_PIN MAX6675_SS2_PIN
#endif
#endif
#if PIN_EXISTS(MAX6675_DO)
#if HAS_MAX31855
#define MAX31855_MISO_PIN MAX6675_DO_PIN
#elif HAS_MAX31865
#define MAX31865_MISO_PIN MAX6675_DO_PIN
#elif HAS_MAX6675
#define MAX6675_MISO_PIN MAX6675_DO_PIN
#endif
#endif
#if PIN_EXISTS(MAX6675_SCK)
#if HAS_MAX31855
#define MAX31855_SCK_PIN MAX6675_SCK_PIN
#elif HAS_MAX31865
#define MAX31865_SCK_PIN MAX6675_SCK_PIN
#endif
#endif
// Compatibility Layer for use when HAL manipulates PINS for MAX31855 and MAX6675
#if PIN_EXISTS(MAX31855_CS) && !PIN_EXISTS(MAX6675_SS)
#define MAX6675_SS_PIN MAX31855_CS_PIN
#endif
#if PIN_EXISTS(MAX31855_CS2) && !PIN_EXISTS(MAX6675_SS2)
#define MAX6675_SS2_PIN MAX31855_CS2_PIN
#endif
#if PIN_EXISTS(MAX6675_CS) && !PIN_EXISTS(MAX6675_SS)
#define MAX6675_SS_PIN MAX6675_CS_PIN
#endif
#if PIN_EXISTS(MAX6675_CS2) && !PIN_EXISTS(MAX6675_SS2)
#define MAX6675_SS2_PIN MAX6675_CS2_PIN
#endif
#if PIN_EXISTS(MAX31855_MISO) && !PIN_EXISTS(MAX6675_DO)
#define MAX6675_DO_PIN MAX31855_MISO_PIN
#endif
#if PIN_EXISTS(MAX6675_MISO) && !PIN_EXISTS(MAX6675_DO)
#define MAX6675_DO_PIN MAX6675_MISO_PIN
#endif
#if PIN_EXISTS(MAX31855_SCK) && !PIN_EXISTS(MAX6675_SCK)
#define MAX6675_SCK_PIN MAX31855_SCK_PIN
#endif
//
// User-defined thermocouple libraries
//
// Add LIB_MAX6675 / LIB_MAX31855 / LIB_MAX31865 to the build_flags
// to select a USER library for MAX6675, MAX31855, MAX31865
//
#if BOTH(HAS_MAX6675, LIB_MAX6675)
#define LIB_USR_MAX6675 1
#endif
#if BOTH(HAS_MAX31855, LIB_MAX31855)
#define LIB_USR_MAX31855 1
#endif
#if HAS_MAX31865
#if ENABLED(LIB_MAX31865)
#define LIB_USR_MAX31865 1
#else
#define LIB_ADAFRUIT_MAX31865 1
#endif
#endif
#if TEMP_SENSOR_2 == -4
#define HEATER_2_USES_AD8495 1
#define TEMP_SENSOR_2_IS_AD8495 1
#elif TEMP_SENSOR_2 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_2."
#elif TEMP_SENSOR_2 == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_2."
#elif TEMP_SENSOR_2 == -1
#define HEATER_2_USES_AD595 1
#define TEMP_SENSOR_2_IS_AD595 1
#elif TEMP_SENSOR_2 > 0
#define THERMISTOR_HEATER_2 TEMP_SENSOR_2
#define HEATER_2_USES_THERMISTOR 1
#define TEMP_SENSOR_2_THERMISTOR_ID TEMP_SENSOR_2
#define TEMP_SENSOR_2_IS_THERMISTOR 1
#if TEMP_SENSOR_2 == 1000
#define HEATER_2_USER_THERMISTOR 1
#define TEMP_SENSOR_2_IS_CUSTOM 1
#elif TEMP_SENSOR_2 == 998 || TEMP_SENSOR_2 == 999
#define HEATER_2_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_2_IS_DUMMY 1
#endif
#else
#undef HEATER_2_MINTEMP
@@ -496,20 +596,20 @@
#endif
#if TEMP_SENSOR_3 == -4
#define HEATER_3_USES_AD8495 1
#define TEMP_SENSOR_3_IS_AD8495 1
#elif TEMP_SENSOR_3 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_3."
#elif TEMP_SENSOR_3 == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_3."
#elif TEMP_SENSOR_3 == -1
#define HEATER_3_USES_AD595 1
#define TEMP_SENSOR_3_IS_AD595 1
#elif TEMP_SENSOR_3 > 0
#define THERMISTOR_HEATER_3 TEMP_SENSOR_3
#define HEATER_3_USES_THERMISTOR 1
#define TEMP_SENSOR_3_THERMISTOR_ID TEMP_SENSOR_3
#define TEMP_SENSOR_3_IS_THERMISTOR 1
#if TEMP_SENSOR_3 == 1000
#define HEATER_3_USER_THERMISTOR 1
#define TEMP_SENSOR_3_IS_CUSTOM 1
#elif TEMP_SENSOR_3 == 998 || TEMP_SENSOR_3 == 999
#define HEATER_3_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_3_IS_DUMMY 1
#endif
#else
#undef HEATER_3_MINTEMP
@@ -517,20 +617,20 @@
#endif
#if TEMP_SENSOR_4 == -4
#define HEATER_4_USES_AD8495 1
#define TEMP_SENSOR_4_IS_AD8495 1
#elif TEMP_SENSOR_4 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_4."
#elif TEMP_SENSOR_4 == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_4."
#elif TEMP_SENSOR_4 == -1
#define HEATER_4_USES_AD595 1
#define TEMP_SENSOR_4_IS_AD595 1
#elif TEMP_SENSOR_4 > 0
#define THERMISTOR_HEATER_4 TEMP_SENSOR_4
#define HEATER_4_USES_THERMISTOR 1
#define TEMP_SENSOR_4_THERMISTOR_ID TEMP_SENSOR_4
#define TEMP_SENSOR_4_IS_THERMISTOR 1
#if TEMP_SENSOR_4 == 1000
#define HEATER_4_USER_THERMISTOR 1
#define TEMP_SENSOR_4_IS_CUSTOM 1
#elif TEMP_SENSOR_4 == 998 || TEMP_SENSOR_4 == 999
#define HEATER_4_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_4_IS_DUMMY 1
#endif
#else
#undef HEATER_4_MINTEMP
@@ -538,20 +638,20 @@
#endif
#if TEMP_SENSOR_5 == -4
#define HEATER_5_USES_AD8495 1
#define TEMP_SENSOR_5_IS_AD8495 1
#elif TEMP_SENSOR_5 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_5."
#elif TEMP_SENSOR_5 == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_5."
#elif TEMP_SENSOR_5 == -1
#define HEATER_5_USES_AD595 1
#define TEMP_SENSOR_5_IS_AD595 1
#elif TEMP_SENSOR_5 > 0
#define THERMISTOR_HEATER_5 TEMP_SENSOR_5
#define HEATER_5_USES_THERMISTOR 1
#define TEMP_SENSOR_5_THERMISTOR_ID TEMP_SENSOR_5
#define TEMP_SENSOR_5_IS_THERMISTOR 1
#if TEMP_SENSOR_5 == 1000
#define HEATER_5_USER_THERMISTOR 1
#define TEMP_SENSOR_5_IS_CUSTOM 1
#elif TEMP_SENSOR_5 == 998 || TEMP_SENSOR_5 == 999
#define HEATER_5_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_5_IS_DUMMY 1
#endif
#else
#undef HEATER_5_MINTEMP
@@ -559,20 +659,20 @@
#endif
#if TEMP_SENSOR_6 == -4
#define HEATER_6_USES_AD8495 1
#define TEMP_SENSOR_6_IS_AD8495 1
#elif TEMP_SENSOR_6 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_6."
#elif TEMP_SENSOR_6 == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_6."
#elif TEMP_SENSOR_6 == -1
#define HEATER_6_USES_AD595 1
#define TEMP_SENSOR_6_IS_AD595 1
#elif TEMP_SENSOR_6 > 0
#define THERMISTOR_HEATER_6 TEMP_SENSOR_6
#define HEATER_6_USES_THERMISTOR 1
#define TEMP_SENSOR_6_THERMISTOR_ID TEMP_SENSOR_6
#define TEMP_SENSOR_6_IS_THERMISTOR 1
#if TEMP_SENSOR_6 == 1000
#define HEATER_6_USER_THERMISTOR 1
#define TEMP_SENSOR_6_IS_CUSTOM 1
#elif TEMP_SENSOR_6 == 998 || TEMP_SENSOR_6 == 999
#define HEATER_6_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_6_IS_DUMMY 1
#endif
#else
#undef HEATER_6_MINTEMP
@@ -580,20 +680,20 @@
#endif
#if TEMP_SENSOR_7 == -4
#define HEATER_7_USES_AD8495 1
#define TEMP_SENSOR_7_IS_AD8495 1
#elif TEMP_SENSOR_7 == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_7."
#elif TEMP_SENSOR_7 == -2
#error "MAX7775 Thermocouples (-2) not supported for TEMP_SENSOR_7."
#elif TEMP_SENSOR_7 == -1
#define HEATER_7_USES_AD595 1
#define TEMP_SENSOR_7_IS_AD595 1
#elif TEMP_SENSOR_7 > 0
#define THERMISTOR_HEATER_7 TEMP_SENSOR_7
#define HEATER_7_USES_THERMISTOR 1
#define TEMP_SENSOR_7_THERMISTOR_ID TEMP_SENSOR_7
#define TEMP_SENSOR_7_IS_THERMISTOR 1
#if TEMP_SENSOR_7 == 1000
#define HEATER_7_USER_THERMISTOR 1
#define TEMP_SENSOR_7_IS_CUSTOM 1
#elif TEMP_SENSOR_7 == 998 || TEMP_SENSOR_7 == 999
#define HEATER_7_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_7_IS_DUMMY 1
#endif
#else
#undef HEATER_7_MINTEMP
@@ -601,20 +701,20 @@
#endif
#if TEMP_SENSOR_BED == -4
#define HEATER_BED_USES_AD8495 1
#define TEMP_SENSOR_BED_IS_AD8495 1
#elif TEMP_SENSOR_BED == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_BED."
#elif TEMP_SENSOR_BED == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_BED."
#elif TEMP_SENSOR_BED == -1
#define HEATER_BED_USES_AD595 1
#define TEMP_SENSOR_BED_IS_AD595 1
#elif TEMP_SENSOR_BED > 0
#define THERMISTORBED TEMP_SENSOR_BED
#define HEATER_BED_USES_THERMISTOR 1
#define TEMP_SENSOR_BED_THERMISTOR_ID TEMP_SENSOR_BED
#define TEMP_SENSOR_BED_IS_THERMISTOR 1
#if TEMP_SENSOR_BED == 1000
#define HEATER_BED_USER_THERMISTOR 1
#define TEMP_SENSOR_BED_IS_CUSTOM 1
#elif TEMP_SENSOR_BED == 998 || TEMP_SENSOR_BED == 999
#define HEATER_BED_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_BED_IS_DUMMY 1
#endif
#else
#undef BED_MINTEMP
@@ -622,20 +722,20 @@
#endif
#if TEMP_SENSOR_CHAMBER == -4
#define HEATER_CHAMBER_USES_AD8495 1
#define TEMP_SENSOR_CHAMBER_IS_AD8495 1
#elif TEMP_SENSOR_CHAMBER == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_CHAMBER."
#elif TEMP_SENSOR_CHAMBER == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_CHAMBER."
#elif TEMP_SENSOR_CHAMBER == -1
#define HEATER_CHAMBER_USES_AD595 1
#define TEMP_SENSOR_CHAMBER_IS_AD595 1
#elif TEMP_SENSOR_CHAMBER > 0
#define THERMISTORCHAMBER TEMP_SENSOR_CHAMBER
#define HEATER_CHAMBER_USES_THERMISTOR 1
#define TEMP_SENSOR_CHAMBER_THERMISTOR_ID TEMP_SENSOR_CHAMBER
#define TEMP_SENSOR_CHAMBER_IS_THERMISTOR 1
#if TEMP_SENSOR_CHAMBER == 1000
#define HEATER_CHAMBER_USER_THERMISTOR 1
#define TEMP_SENSOR_CHAMBER_IS_CUSTOM 1
#elif TEMP_SENSOR_CHAMBER == 998 || TEMP_SENSOR_CHAMBER == 999
#define HEATER_CHAMBER_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_CHAMBER_IS_DUMMY 1
#endif
#else
#undef CHAMBER_MINTEMP
@@ -643,20 +743,20 @@
#endif
#if TEMP_SENSOR_PROBE == -4
#define HEATER_PROBE_USES_AD8495 1
#define TEMP_SENSOR_PROBE_IS_AD8495 1
#elif TEMP_SENSOR_PROBE == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_PROBE."
#elif TEMP_SENSOR_PROBE == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_PROBE."
#elif TEMP_SENSOR_PROBE == -1
#define HEATER_PROBE_USES_AD595 1
#define TEMP_SENSOR_PROBE_IS_AD595 1
#elif TEMP_SENSOR_PROBE > 0
#define THERMISTORPROBE TEMP_SENSOR_PROBE
#define HEATER_PROBE_USES_THERMISTOR 1
#define TEMP_SENSOR_PROBE_THERMISTOR_ID TEMP_SENSOR_PROBE
#define TEMP_SENSOR_PROBE_IS_THERMISTOR 1
#if TEMP_SENSOR_PROBE == 1000
#define HEATER_PROBE_USER_THERMISTOR 1
#define TEMP_SENSOR_PROBE_IS_CUSTOM 1
#elif TEMP_SENSOR_PROBE == 998 || TEMP_SENSOR_PROBE == 999
#define HEATER_PROBE_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_PROBE_IS_DUMMY 1
#endif
#endif
@@ -1792,7 +1892,7 @@
//
// ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface)
//
#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && NONE(HEATER_##P##_USES_MAX6675, HEATER_##P##_DUMMY_THERMISTOR))
#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)
#define HAS_TEMP_ADC_0 1
#endif
@@ -1827,7 +1927,7 @@
#define HAS_TEMP_ADC_CHAMBER 1
#endif
#define HAS_TEMP(N) ANY(HAS_TEMP_ADC_##N, HEATER_##N##_USES_MAX6675, HEATER_##N##_DUMMY_THERMISTOR)
#define HAS_TEMP(N) ANY(HAS_TEMP_ADC_##N, TEMP_SENSOR_##N##_IS_MAX_TC, TEMP_SENSOR_##N##_IS_DUMMY)
#if HAS_HOTEND && HAS_TEMP(0)
#define HAS_TEMP_HOTEND 1
#endif
+28 -26
View File
@@ -1698,46 +1698,48 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
/**
* Required custom thermistor settings
*/
#if HEATER_0_USER_THERMISTOR && !(defined(HOTEND0_PULLUP_RESISTOR_OHMS) && defined(HOTEND0_RESISTANCE_25C_OHMS) && defined(HOTEND0_BETA))
#if TEMP_SENSOR_0_IS_CUSTOM && !(defined(HOTEND0_PULLUP_RESISTOR_OHMS) && defined(HOTEND0_RESISTANCE_25C_OHMS) && defined(HOTEND0_BETA))
#error "TEMP_SENSOR_0 1000 requires HOTEND0_PULLUP_RESISTOR_OHMS, HOTEND0_RESISTANCE_25C_OHMS and HOTEND0_BETA in Configuration_adv.h."
#elif HEATER_1_USER_THERMISTOR && !(defined(HOTEND1_PULLUP_RESISTOR_OHMS) && defined(HOTEND1_RESISTANCE_25C_OHMS) && defined(HOTEND1_BETA))
#elif TEMP_SENSOR_1_IS_CUSTOM && !(defined(HOTEND1_PULLUP_RESISTOR_OHMS) && defined(HOTEND1_RESISTANCE_25C_OHMS) && defined(HOTEND1_BETA))
#error "TEMP_SENSOR_1 1000 requires HOTEND1_PULLUP_RESISTOR_OHMS, HOTEND1_RESISTANCE_25C_OHMS and HOTEND1_BETA in Configuration_adv.h."
#elif HEATER_2_USER_THERMISTOR && !(defined(HOTEND2_PULLUP_RESISTOR_OHMS) && defined(HOTEND2_RESISTANCE_25C_OHMS) && defined(HOTEND2_BETA))
#elif TEMP_SENSOR_2_IS_CUSTOM && !(defined(HOTEND2_PULLUP_RESISTOR_OHMS) && defined(HOTEND2_RESISTANCE_25C_OHMS) && defined(HOTEND2_BETA))
#error "TEMP_SENSOR_2 1000 requires HOTEND2_PULLUP_RESISTOR_OHMS, HOTEND2_RESISTANCE_25C_OHMS and HOTEND2_BETA in Configuration_adv.h."
#elif HEATER_3_USER_THERMISTOR && !(defined(HOTEND3_PULLUP_RESISTOR_OHMS) && defined(HOTEND3_RESISTANCE_25C_OHMS) && defined(HOTEND3_BETA))
#elif TEMP_SENSOR_3_IS_CUSTOM && !(defined(HOTEND3_PULLUP_RESISTOR_OHMS) && defined(HOTEND3_RESISTANCE_25C_OHMS) && defined(HOTEND3_BETA))
#error "TEMP_SENSOR_3 1000 requires HOTEND3_PULLUP_RESISTOR_OHMS, HOTEND3_RESISTANCE_25C_OHMS and HOTEND3_BETA in Configuration_adv.h."
#elif HEATER_4_USER_THERMISTOR && !(defined(HOTEND4_PULLUP_RESISTOR_OHMS) && defined(HOTEND4_RESISTANCE_25C_OHMS) && defined(HOTEND4_BETA))
#elif TEMP_SENSOR_4_IS_CUSTOM && !(defined(HOTEND4_PULLUP_RESISTOR_OHMS) && defined(HOTEND4_RESISTANCE_25C_OHMS) && defined(HOTEND4_BETA))
#error "TEMP_SENSOR_4 1000 requires HOTEND4_PULLUP_RESISTOR_OHMS, HOTEND4_RESISTANCE_25C_OHMS and HOTEND4_BETA in Configuration_adv.h."
#elif HEATER_5_USER_THERMISTOR && !(defined(HOTEND5_PULLUP_RESISTOR_OHMS) && defined(HOTEND5_RESISTANCE_25C_OHMS) && defined(HOTEND5_BETA))
#elif TEMP_SENSOR_5_IS_CUSTOM && !(defined(HOTEND5_PULLUP_RESISTOR_OHMS) && defined(HOTEND5_RESISTANCE_25C_OHMS) && defined(HOTEND5_BETA))
#error "TEMP_SENSOR_5 1000 requires HOTEND5_PULLUP_RESISTOR_OHMS, HOTEND5_RESISTANCE_25C_OHMS and HOTEND5_BETA in Configuration_adv.h."
#elif HEATER_6_USER_THERMISTOR && !(defined(HOTEND6_PULLUP_RESISTOR_OHMS) && defined(HOTEND6_RESISTANCE_25C_OHMS) && defined(HOTEND6_BETA))
#elif TEMP_SENSOR_6_IS_CUSTOM && !(defined(HOTEND6_PULLUP_RESISTOR_OHMS) && defined(HOTEND6_RESISTANCE_25C_OHMS) && defined(HOTEND6_BETA))
#error "TEMP_SENSOR_6 1000 requires HOTEND6_PULLUP_RESISTOR_OHMS, HOTEND6_RESISTANCE_25C_OHMS and HOTEND6_BETA in Configuration_adv.h."
#elif HEATER_7_USER_THERMISTOR && !(defined(HOTEND7_PULLUP_RESISTOR_OHMS) && defined(HOTEND7_RESISTANCE_25C_OHMS) && defined(HOTEND7_BETA))
#elif TEMP_SENSOR_7_IS_CUSTOM && !(defined(HOTEND7_PULLUP_RESISTOR_OHMS) && defined(HOTEND7_RESISTANCE_25C_OHMS) && defined(HOTEND7_BETA))
#error "TEMP_SENSOR_7 1000 requires HOTEND7_PULLUP_RESISTOR_OHMS, HOTEND7_RESISTANCE_25C_OHMS and HOTEND7_BETA in Configuration_adv.h."
#elif HEATER_BED_USER_THERMISTOR && !(defined(BED_PULLUP_RESISTOR_OHMS) && defined(BED_RESISTANCE_25C_OHMS) && defined(BED_BETA))
#elif TEMP_SENSOR_BED_IS_CUSTOM && !(defined(BED_PULLUP_RESISTOR_OHMS) && defined(BED_RESISTANCE_25C_OHMS) && defined(BED_BETA))
#error "TEMP_SENSOR_BED 1000 requires BED_PULLUP_RESISTOR_OHMS, BED_RESISTANCE_25C_OHMS and BED_BETA in Configuration_adv.h."
#elif HEATER_CHAMBER_USER_THERMISTOR && !(defined(CHAMBER_PULLUP_RESISTOR_OHMS) && defined(CHAMBER_RESISTANCE_25C_OHMS) && defined(CHAMBER_BETA))
#elif TEMP_SENSOR_CHAMBER_IS_CUSTOM && !(defined(CHAMBER_PULLUP_RESISTOR_OHMS) && defined(CHAMBER_RESISTANCE_25C_OHMS) && defined(CHAMBER_BETA))
#error "TEMP_SENSOR_CHAMBER 1000 requires CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS and CHAMBER_BETA in Configuration_adv.h."
#elif TEMP_SENSOR_PROBE_IS_CUSTOM && !(defined(PROBE_PULLUP_RESISTOR_OHMS) && defined(PROBE_RESISTANCE_25C_OHMS) && defined(PROBE_BETA))
#error "TEMP_SENSOR_PROBE 1000 requires PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS and PROBE_BETA in Configuration_adv.h."
#endif
/**
* Pins and Sensor IDs must be set for each heater
*/
#if HEATER_0_USES_MAX6675 && !PIN_EXISTS(MAX6675_SS)
#error "MAX6675_SS_PIN (required for TEMP_SENSOR_0) not defined for this board."
#elif HAS_HOTEND && !HAS_TEMP_HOTEND && !HEATER_0_DUMMY_THERMISTOR
#if TEMP_SENSOR_0_IS_MAX6675 && !ANY_PIN(MAX6675_SS, MAX31855_CS, MAX31865_CS, MAX6675_CS)
#error "TEMP_SENSOR_0 requires a MAX6675_SS_PIN, MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN."
#elif HAS_HOTEND && !HAS_TEMP_HOTEND && !TEMP_SENSOR_0_IS_DUMMY
#error "TEMP_0_PIN (required for TEMP_SENSOR_0) not defined for this board."
#elif EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL) && !HAS_HEATER_1
#error "HEATER_1_PIN is not defined. TEMP_SENSOR_1 might not be set, or the board (not EEB / EEF?) doesn't define a pin."
#endif
#if HAS_MULTI_HOTEND
#if HEATER_1_USES_MAX6675 && !PIN_EXISTS(MAX6675_SS2)
#error "MAX6675_SS2_PIN (required for TEMP_SENSOR_1) not defined for this board."
#if TEMP_SENSOR_1_IS_MAX6675 && !ANY_PIN(MAX6675_SS2, MAX31855_CS2, MAX31865_CS2, MAX6675_CS2)
#error "TEMP_SENSOR_1 requires a MAX6675_SS2_PIN, MAX6675_CS2_PIN, MAX31855_CS2_PIN, or MAX31865_CS2_PIN."
#elif TEMP_SENSOR_1 == 0
#error "TEMP_SENSOR_1 is required with 2 or more HOTENDS."
#elif !ANY_PIN(TEMP_1, MAX6675_SS2) && !HEATER_1_DUMMY_THERMISTOR
#error "TEMP_1_PIN not defined for this board."
#elif !ANY_PIN(TEMP_1, MAX6675_SS2) && !TEMP_SENSOR_1_IS_DUMMY
#error "TEMP_1_PIN or MAX6675_SS2_PIN not defined for this board."
#elif ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
#error "HOTENDS must be 1 with TEMP_SENSOR_1_AS_REDUNDANT."
#endif
@@ -1746,7 +1748,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#error "TEMP_SENSOR_2 is required with 3 or more HOTENDS."
#elif !HAS_HEATER_2
#error "HEATER_2_PIN not defined for this board."
#elif !PIN_EXISTS(TEMP_2) && !HEATER_2_DUMMY_THERMISTOR
#elif !PIN_EXISTS(TEMP_2) && !TEMP_SENSOR_2_IS_DUMMY
#error "TEMP_2_PIN not defined for this board."
#endif
#if HOTENDS > 3
@@ -1754,7 +1756,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#error "TEMP_SENSOR_3 is required with 4 or more HOTENDS."
#elif !HAS_HEATER_3
#error "HEATER_3_PIN not defined for this board."
#elif !PIN_EXISTS(TEMP_3) && !HEATER_3_DUMMY_THERMISTOR
#elif !PIN_EXISTS(TEMP_3) && !TEMP_SENSOR_3_IS_DUMMY
#error "TEMP_3_PIN not defined for this board."
#endif
#if HOTENDS > 4
@@ -1762,7 +1764,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#error "TEMP_SENSOR_4 is required with 5 or more HOTENDS."
#elif !HAS_HEATER_4
#error "HEATER_4_PIN not defined for this board."
#elif !PIN_EXISTS(TEMP_4) && !HEATER_4_DUMMY_THERMISTOR
#elif !PIN_EXISTS(TEMP_4) && !TEMP_SENSOR_4_IS_DUMMY
#error "TEMP_4_PIN not defined for this board."
#endif
#if HOTENDS > 5
@@ -1770,7 +1772,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#error "TEMP_SENSOR_5 is required with 6 HOTENDS."
#elif !HAS_HEATER_5
#error "HEATER_5_PIN not defined for this board."
#elif !PIN_EXISTS(TEMP_5) && !HEATER_5_DUMMY_THERMISTOR
#elif !PIN_EXISTS(TEMP_5) && !TEMP_SENSOR_5_IS_DUMMY
#error "TEMP_5_PIN not defined for this board."
#endif
#if HOTENDS > 6
@@ -1778,7 +1780,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#error "TEMP_SENSOR_6 is required with 6 HOTENDS."
#elif !HAS_HEATER_6
#error "HEATER_6_PIN not defined for this board."
#elif !PIN_EXISTS(TEMP_6) && !HEATER_6_DUMMY_THERMISTOR
#elif !PIN_EXISTS(TEMP_6) && !TEMP_SENSOR_6_IS_DUMMY
#error "TEMP_6_PIN not defined for this board."
#endif
#if HOTENDS > 7
@@ -1786,7 +1788,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#error "TEMP_SENSOR_7 is required with 7 HOTENDS."
#elif !HAS_HEATER_7
#error "HEATER_7_PIN not defined for this board."
#elif !PIN_EXISTS(TEMP_7) && !HEATER_7_DUMMY_THERMISTOR
#elif !PIN_EXISTS(TEMP_7) && !TEMP_SENSOR_7_IS_DUMMY
#error "TEMP_7_PIN not defined for this board."
#endif
#elif TEMP_SENSOR_7 != 0
@@ -1895,9 +1897,9 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#error "TEMP_SENSOR_1 is required with TEMP_SENSOR_1_AS_REDUNDANT."
#endif
#if MAX6675_0_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_0) && defined(MAX31865_CALIBRATION_OHMS_0))
#if TEMP_SENSOR_0_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_0) && defined(MAX31865_CALIBRATION_OHMS_0))
#error "MAX31865_SENSOR_OHMS_0 and MAX31865_CALIBRATION_OHMS_0 must be set if TEMP_SENSOR_0 is MAX31865."
#elif MAX6675_1_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_1) && defined(MAX31865_CALIBRATION_OHMS_1))
#elif TEMP_SENSOR_1_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_1) && defined(MAX31865_CALIBRATION_OHMS_1))
#error "MAX31865_SENSOR_OHMS_1 and MAX31865_CALIBRATION_OHMS_1 must be set if TEMP_SENSOR_1 is MAX31865."
#endif
@@ -1907,7 +1909,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
#if !HAS_HEATER_0 && EXTRUDERS
#error "HEATER_0_PIN not defined for this board."
#elif !ANY_PIN(TEMP_0, MAX6675_SS)
#error "TEMP_0_PIN not defined for this board."
#error "TEMP_0_PIN or MAX6675_SS not defined for this board."
#elif ((defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && !PINS_EXIST(E0_STEP, E0_DIR))
#error "E0_STEP_PIN or E0_DIR_PIN not defined for this board."
#elif ( !(defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)) && (!PINS_EXIST(E0_STEP, E0_DIR) || !HAS_E0_ENABLE))
+1 -1
View File
@@ -42,7 +42,7 @@
* version was tagged.
*/
#ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "2021-01-31"
#define STRING_DISTRIBUTION_DATE "2021-02-10"
#endif
/**
+4
View File
@@ -39,6 +39,10 @@
#include "../../../_Bootscreen.h"
#if ENABLED(CUSTOM_BOOTSCREEN_ANIMATED) && DISABLED(CUSTOM_BOOTSCREEN_ANIMATED_FRAME_TIME) && !defined(CUSTOM_BOOTSCREEN_FRAME_TIME)
#define CUSTOM_BOOTSCREEN_FRAME_TIME 500 // (ms)
#endif
#ifndef CUSTOM_BOOTSCREEN_BMPWIDTH
#define CUSTOM_BOOTSCREEN_BMPWIDTH 128
#endif
+6 -9
View File
@@ -118,12 +118,10 @@ bool MarlinUI::detected() { return true; }
#endif
#if ENABLED(CUSTOM_BOOTSCREEN_ANIMATED)
const void * const frame_ptr = pgm_read_ptr(&custom_bootscreen_animation[frame]);
#if ENABLED(CUSTOM_BOOTSCREEN_TIME_PER_FRAME)
const boot_frame_t * const frame_info = (boot_frame_t*)frame_ptr;
const u8g_pgm_uint8_t * const bmp = (u8g_pgm_uint8_t*)pgm_read_ptr(&frame_info->bitmap);
#if ENABLED(CUSTOM_BOOTSCREEN_ANIMATED_FRAME_TIME)
const u8g_pgm_uint8_t * const bmp = (u8g_pgm_uint8_t*)pgm_read_ptr(&custom_bootscreen_animation[frame].bitmap);
#else
const u8g_pgm_uint8_t * const bmp = (u8g_pgm_uint8_t*)frame_ptr;
const u8g_pgm_uint8_t * const bmp = (u8g_pgm_uint8_t*)pgm_read_ptr(&custom_bootscreen_animation[frame]);
#endif
#else
const u8g_pgm_uint8_t * const bmp = custom_start_bmp;
@@ -150,16 +148,15 @@ bool MarlinUI::detected() { return true; }
constexpr millis_t frame_time = 0;
constexpr uint8_t f = 0;
#else
#if DISABLED(CUSTOM_BOOTSCREEN_TIME_PER_FRAME)
#if DISABLED(CUSTOM_BOOTSCREEN_ANIMATED_FRAME_TIME)
constexpr millis_t frame_time = CUSTOM_BOOTSCREEN_FRAME_TIME;
#endif
LOOP_L_N(f, COUNT(custom_bootscreen_animation))
#endif
{
#if ENABLED(CUSTOM_BOOTSCREEN_TIME_PER_FRAME)
#if ENABLED(CUSTOM_BOOTSCREEN_ANIMATED_FRAME_TIME)
const uint8_t fr = _MIN(f, COUNT(custom_bootscreen_animation) - 1);
const boot_frame_t * const frame_info = (boot_frame_t*)pgm_read_ptr(&custom_bootscreen_animation[fr]);
const millis_t frame_time = pgm_read_word(&frame_info->duration);
const millis_t frame_time = pgm_read_word(&custom_bootscreen_animation[fr].duration);
#endif
u8g.firstPage();
do { draw_custom_bootscreen(f); } while (u8g.nextPage());
+85 -99
View File
@@ -191,16 +191,12 @@ constexpr float default_max_acceleration[] = DEFAULT_MAX_ACCELERATION;
constexpr float default_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK };
#endif
uint8_t Percentrecord = 0;
uint16_t remain_time = 0;
static uint8_t _card_percent = 0;
static uint16_t _remain_time = 0;
#if ENABLED(PAUSE_HEAT)
#if HAS_HOTEND
uint16_t temphot = 0;
#endif
#if HAS_HEATED_BED
uint16_t tempbed = 0;
#endif
TERN_(HAS_HOTEND, uint16_t resume_hotend_temp = 0);
TERN_(HAS_HEATED_BED, uint16_t resume_bed_temp = 0);
#endif
#if HAS_ZOFFSET_ITEM
@@ -1081,8 +1077,8 @@ void Draw_Printing_Screen() {
void Draw_Print_ProgressBar() {
DWIN_ICON_Show(ICON, ICON_Bar, 15, 93);
DWIN_Draw_Rectangle(1, BarFill_Color, 16 + Percentrecord * 240 / 100, 93, 256, 113);
DWIN_Draw_IntValue(true, true, 0, font8x16, Percent_Color, Color_Bg_Black, 2, 117, 133, Percentrecord);
DWIN_Draw_Rectangle(1, BarFill_Color, 16 + _card_percent * 240 / 100, 93, 256, 113);
DWIN_Draw_IntValue(true, true, 0, font8x16, Percent_Color, Color_Bg_Black, 2, 117, 133, _card_percent);
DWIN_Draw_String(false, false, font8x16, Percent_Color, Color_Bg_Black, 133, 133, F("%"));
}
@@ -1094,9 +1090,9 @@ void Draw_Print_ProgressElapsed() {
}
void Draw_Print_ProgressRemain() {
DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 176, 212, remain_time / 3600);
DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 176, 212, _remain_time / 3600);
DWIN_Draw_String(false, false, font8x16, Color_White, Color_Bg_Black, 192, 212, F(":"));
DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 200, 212, (remain_time % 3600) / 60);
DWIN_Draw_IntValue(true, true, 1, font8x16, Color_White, Color_Bg_Black, 2, 200, 212, (_remain_time % 3600) / 60);
}
void Goto_PrintProcess() {
@@ -1165,10 +1161,9 @@ void HMI_Move_X(void) {
HMI_ValueStruct.Move_X_scale -= EncoderRate.encoderMoveValue;
}
NOLESS(HMI_ValueStruct.Move_X_scale, (X_MIN_POS) * MINUNITMULT);
NOMORE(HMI_ValueStruct.Move_X_scale, (X_MAX_POS) * MINUNITMULT);
current_position[X_AXIS] = HMI_ValueStruct.Move_X_scale / 10;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale);
LIMIT(HMI_ValueStruct.Move_X_scaled, (X_MIN_POS) * MINUNITMULT, (X_MAX_POS) * MINUNITMULT);
current_position.x = HMI_ValueStruct.Move_X_scaled / MINUNITMULT;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 216, MBASE(1), HMI_ValueStruct.Move_X_scaled);
DWIN_UpdateLCD();
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale);
@@ -1200,10 +1195,9 @@ void HMI_Move_Y(void) {
HMI_ValueStruct.Move_Y_scale -= EncoderRate.encoderMoveValue;
}
NOLESS(HMI_ValueStruct.Move_Y_scale, (Y_MIN_POS) * MINUNITMULT);
NOMORE(HMI_ValueStruct.Move_Y_scale, (Y_MAX_POS) * MINUNITMULT);
current_position[Y_AXIS] = HMI_ValueStruct.Move_Y_scale / 10;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale);
LIMIT(HMI_ValueStruct.Move_Y_scaled, (Y_MIN_POS) * MINUNITMULT, (Y_MAX_POS) * MINUNITMULT);
current_position.y = HMI_ValueStruct.Move_Y_scaled / MINUNITMULT;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 216, MBASE(2), HMI_ValueStruct.Move_Y_scaled);
DWIN_UpdateLCD();
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale);
@@ -1235,10 +1229,9 @@ void HMI_Move_Z(void) {
HMI_ValueStruct.Move_Z_scale -= EncoderRate.encoderMoveValue;
}
NOLESS(HMI_ValueStruct.Move_Z_scale, Z_MIN_POS * MINUNITMULT);
NOMORE(HMI_ValueStruct.Move_Z_scale, Z_MAX_POS * MINUNITMULT);
current_position[Z_AXIS] = HMI_ValueStruct.Move_Z_scale / 10;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale);
LIMIT(HMI_ValueStruct.Move_Z_scaled, Z_MIN_POS * MINUNITMULT, Z_MAX_POS * MINUNITMULT);
current_position.z = HMI_ValueStruct.Move_Z_scaled / MINUNITMULT;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 216, MBASE(3), HMI_ValueStruct.Move_Z_scaled);
DWIN_UpdateLCD();
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale);
@@ -1323,8 +1316,7 @@ void HMI_Move_Z(void) {
DWIN_UpdateLCD();
return;
}
NOLESS(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MIN) * 100);
NOMORE(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MAX) * 100);
LIMIT(HMI_ValueStruct.offset_value, (Z_PROBE_OFFSET_RANGE_MIN) * 100, (Z_PROBE_OFFSET_RANGE_MAX) * 100);
last_zoffset = dwin_zoffset;
dwin_zoffset = HMI_ValueStruct.offset_value / 100.0f;
#if EITHER(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP)
@@ -1372,8 +1364,7 @@ void HMI_Move_Z(void) {
return;
}
// E_Temp limit
NOMORE(HMI_ValueStruct.E_Temp, MAX_E_TEMP);
NOLESS(HMI_ValueStruct.E_Temp, MIN_E_TEMP);
LIMIT(HMI_ValueStruct.E_Temp, MIN_E_TEMP, MAX_E_TEMP);
// E_Temp value
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(temp_line), HMI_ValueStruct.E_Temp);
}
@@ -1416,8 +1407,7 @@ void HMI_Move_Z(void) {
return;
}
// Bed_Temp limit
NOMORE(HMI_ValueStruct.Bed_Temp, BED_MAX_TARGET);
NOLESS(HMI_ValueStruct.Bed_Temp, MIN_BED_TEMP);
LIMIT(HMI_ValueStruct.Bed_Temp, MIN_BED_TEMP, BED_MAX_TARGET);
// Bed_Temp value
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp);
}
@@ -1461,8 +1451,7 @@ void HMI_Move_Z(void) {
return;
}
// Fan_speed limit
NOMORE(HMI_ValueStruct.Fan_speed, FANON);
NOLESS(HMI_ValueStruct.Fan_speed, FANOFF);
LIMIT(HMI_ValueStruct.Fan_speed, FANOFF, FANON);
// Fan_speed value
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed);
}
@@ -1481,8 +1470,7 @@ void HMI_PrintSpeed() {
return;
}
// print_speed limit
NOMORE(HMI_ValueStruct.print_speed, MAX_PRINT_SPEED);
NOLESS(HMI_ValueStruct.print_speed, MIN_PRINT_SPEED);
LIMIT(HMI_ValueStruct.print_speed, MIN_PRINT_SPEED, MAX_PRINT_SPEED);
// print_speed value
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(select_tune.now + MROWS - index_tune), HMI_ValueStruct.print_speed);
}
@@ -1537,20 +1525,20 @@ void HMI_MaxAccelerationXYZE() {
void HMI_MaxJerkXYZE() {
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
if (encoder_diffState != ENCODER_DIFF_NO) {
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Jerk)) {
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Jerk_scaled)) {
checkkey = MaxJerk;
EncoderRate.enabled = false;
if (WITHIN(HMI_flag.jerk_axis, X_AXIS, E_AXIS))
planner.set_max_jerk(HMI_flag.jerk_axis, HMI_ValueStruct.Max_Jerk / 10);
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk);
planner.set_max_jerk(HMI_flag.jerk_axis, HMI_ValueStruct.Max_Jerk_scaled / 10);
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk_scaled);
return;
}
// MaxJerk limit
if (WITHIN(HMI_flag.jerk_axis, X_AXIS, E_AXIS))
NOMORE(HMI_ValueStruct.Max_Jerk, default_max_jerk[HMI_flag.jerk_axis] * 2 * MINUNITMULT);
NOLESS(HMI_ValueStruct.Max_Jerk, (MIN_MAXJERK) * MINUNITMULT);
NOMORE(HMI_ValueStruct.Max_Jerk_scaled, default_max_jerk[HMI_flag.jerk_axis] * 2 * MINUNITMULT);
NOLESS(HMI_ValueStruct.Max_Jerk_scaled, (MIN_MAXJERK) * MINUNITMULT);
// MaxJerk value
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk);
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk_scaled);
}
}
@@ -1559,43 +1547,41 @@ void HMI_MaxAccelerationXYZE() {
void HMI_StepXYZE() {
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
if (encoder_diffState != ENCODER_DIFF_NO) {
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Step)) {
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Step_scaled)) {
checkkey = Step;
EncoderRate.enabled = false;
if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS))
planner.settings.axis_steps_per_mm[HMI_flag.step_axis] = HMI_ValueStruct.Max_Step / 10;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step);
planner.settings.axis_steps_per_mm[HMI_flag.step_axis] = HMI_ValueStruct.Max_Step_scaled / 10;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step_scaled);
return;
}
// Step limit
if (WITHIN(HMI_flag.step_axis, X_AXIS, E_AXIS))
NOMORE(HMI_ValueStruct.Max_Step, 999.9 * MINUNITMULT);
NOLESS(HMI_ValueStruct.Max_Step, MIN_STEP);
NOMORE(HMI_ValueStruct.Max_Step_scaled, 999.9 * MINUNITMULT);
NOLESS(HMI_ValueStruct.Max_Step_scaled, MIN_STEP);
// Step value
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step);
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step_scaled);
}
}
void update_variable() {
#if HAS_HOTEND
static float last_temp_hotend_target = 0, last_temp_hotend_current = 0;
#endif
#if HAS_HEATED_BED
static float last_temp_bed_target = 0, last_temp_bed_current = 0;
#endif
#if HAS_FAN
static uint8_t last_fan_speed = 0;
#endif
TERN_(HAS_HOTEND, static float last_temp_hotend_target = 0);
TERN_(HAS_HEATED_BED, static float last_temp_bed_target = 0);
TERN_(HAS_FAN, static uint8_t last_fan_speed = 0);
/* Tune page temperature update */
if (checkkey == Tune) {
#if HAS_HOTEND
if (last_temp_hotend_target != thermalManager.temp_hotend[0].target)
if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) {
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), thermalManager.temp_hotend[0].target);
last_temp_hotend_target = thermalManager.temp_hotend[0].target;
}
#endif
#if HAS_HEATED_BED
if (last_temp_bed_target != thermalManager.temp_bed.target)
if (last_temp_bed_target != thermalManager.temp_bed.target) {
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), thermalManager.temp_bed.target);
last_temp_bed_target = thermalManager.temp_bed.target;
}
#endif
#if HAS_FAN
if (last_fan_speed != thermalManager.fan_speed[0]) {
@@ -1608,12 +1594,16 @@ void update_variable() {
/* Temperature page temperature update */
if (checkkey == TemperatureID) {
#if HAS_HOTEND
if (last_temp_hotend_target != thermalManager.temp_hotend[0].target)
if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) {
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_TEMP), thermalManager.temp_hotend[0].target);
last_temp_hotend_target = thermalManager.temp_hotend[0].target;
}
#endif
#if HAS_HEATED_BED
if (last_temp_bed_target != thermalManager.temp_bed.target)
if (last_temp_bed_target != thermalManager.temp_bed.target) {
DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TEMP_CASE_BED), thermalManager.temp_bed.target);
last_temp_bed_target = thermalManager.temp_bed.target;
}
#endif
#if HAS_FAN
if (last_fan_speed != thermalManager.fan_speed[0]) {
@@ -1625,9 +1615,10 @@ void update_variable() {
/* Bottom temperature update */
#if HAS_HOTEND
if (last_temp_hotend_current != thermalManager.temp_hotend[0].celsius) {
static float _hotendtemp = 0;
if (_hotendtemp != thermalManager.temp_hotend[0].celsius) {
DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33, 382, thermalManager.temp_hotend[0].celsius);
last_temp_hotend_current = thermalManager.temp_hotend[0].celsius;
_hotendtemp = thermalManager.temp_hotend[0].celsius;
}
if (last_temp_hotend_target != thermalManager.temp_hotend[0].target) {
DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 33 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_hotend[0].target);
@@ -1635,9 +1626,10 @@ void update_variable() {
}
#endif
#if HAS_HEATED_BED
if (last_temp_bed_current != thermalManager.temp_bed.celsius) {
static float _bedtemp = 0;
if (_bedtemp != thermalManager.temp_bed.celsius) {
DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178, 382, thermalManager.temp_bed.celsius);
last_temp_bed_current = thermalManager.temp_bed.celsius;
_bedtemp = thermalManager.temp_bed.celsius;
}
if (last_temp_bed_target != thermalManager.temp_bed.target) {
DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 178 + 4 * STAT_CHR_W + 6, 382, thermalManager.temp_bed.target);
@@ -1818,7 +1810,7 @@ void HMI_SDCardUpdate() {
if (HMI_flag.home_flag) return;
if (DWIN_lcd_sd_status != card.isMounted()) {
DWIN_lcd_sd_status = card.isMounted();
// SERIAL_ECHOLNPAIR("HMI_SDCardUpdate: ", int(DWIN_lcd_sd_status));
// SERIAL_ECHOLNPAIR("HMI_SDCardUpdate: ", DWIN_lcd_sd_status);
if (DWIN_lcd_sd_status) {
if (checkkey == SelectFile)
Redraw_SD_List();
@@ -2181,13 +2173,11 @@ void HMI_Printing() {
char cmd[40];
cmd[0] = '\0';
#if ENABLED(PAUSE_HEAT)
#if HAS_HEATED_BED
if (tempbed) sprintf_P(cmd, PSTR("M190 S%i\n"), tempbed);
#endif
#if HAS_HOTEND
if (temphot) sprintf_P(&cmd[strlen(cmd)], PSTR("M109 S%i\n"), temphot);
#endif
#if BOTH(HAS_HEATED_BED, PAUSE_HEAT)
if (resume_bed_temp) sprintf_P(cmd, PSTR("M190 S%i\n"), resume_bed_temp);
#endif
#if BOTH(HAS_HOTEND, PAUSE_HEAT)
if (resume_hotend_temp) sprintf_P(&cmd[strlen(cmd)], PSTR("M109 S%i\n"), resume_hotend_temp);
#endif
strcat_P(cmd, M24_STR);
@@ -2368,8 +2358,8 @@ void HMI_Prepare() {
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(2), current_position.y * MINUNITMULT);
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, UNITFDIGITS, 216, MBASE(3), current_position.z * MINUNITMULT);
#if HAS_HOTEND
HMI_ValueStruct.Move_E_scale = current_position.e * MINUNITMULT;
DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale);
HMI_ValueStruct.Move_E_scaled = current_position.e * MINUNITMULT;
DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scaled);
#endif
break;
case PREPARE_CASE_DISA: // Disable steppers
@@ -2619,11 +2609,11 @@ void HMI_AxisMove() {
if (HMI_flag.ETempTooLow_flag) {
if (encoder_diffState == ENCODER_DIFF_ENTER) {
HMI_flag.ETempTooLow_flag = false;
HMI_ValueStruct.Move_E_scale = current_position.e * MINUNITMULT;
HMI_ValueStruct.Move_E_scaled = current_position.e * MINUNITMULT;
Draw_Move_Menu();
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale);
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale);
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale);
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scaled);
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scaled);
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scaled);
DWIN_Draw_Signed_Float(font8x16, Color_Bg_Black, 3, 1, 216, MBASE(4), 0);
DWIN_UpdateLCD();
}
@@ -2648,20 +2638,20 @@ void HMI_AxisMove() {
break;
case 1: // X axis move
checkkey = Move_X;
HMI_ValueStruct.Move_X_scale = current_position.x * MINUNITMULT;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scale);
HMI_ValueStruct.Move_X_scaled = current_position.x * MINUNITMULT;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(1), HMI_ValueStruct.Move_X_scaled);
EncoderRate.enabled = true;
break;
case 2: // Y axis move
checkkey = Move_Y;
HMI_ValueStruct.Move_Y_scale = current_position.y * MINUNITMULT;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scale);
HMI_ValueStruct.Move_Y_scaled = current_position.y * MINUNITMULT;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(2), HMI_ValueStruct.Move_Y_scaled);
EncoderRate.enabled = true;
break;
case 3: // Z axis move
checkkey = Move_Z;
HMI_ValueStruct.Move_Z_scale = current_position.z * MINUNITMULT;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scale);
HMI_ValueStruct.Move_Z_scaled = current_position.z * MINUNITMULT;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 1, 216, MBASE(3), HMI_ValueStruct.Move_Z_scaled);
EncoderRate.enabled = true;
break;
#if HAS_HOTEND
@@ -2676,8 +2666,8 @@ void HMI_AxisMove() {
}
#endif
checkkey = Extruder;
HMI_ValueStruct.Move_E_scale = current_position.e * MINUNITMULT;
DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scale);
HMI_ValueStruct.Move_E_scaled = current_position.e * MINUNITMULT;
DWIN_Draw_Signed_Float(font8x16, Select_Color, 3, 1, 216, MBASE(4), HMI_ValueStruct.Move_E_scaled);
EncoderRate.enabled = true;
break;
#endif
@@ -3463,8 +3453,8 @@ void HMI_MaxAcceleration() {
if (WITHIN(select_jerk.now, 1, 4)) {
checkkey = MaxJerk_value;
HMI_flag.jerk_axis = AxisEnum(select_jerk.now - 1);
HMI_ValueStruct.Max_Jerk = planner.max_jerk[HMI_flag.jerk_axis] * MINUNITMULT;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk);
HMI_ValueStruct.Max_Jerk_scaled = planner.max_jerk[HMI_flag.jerk_axis] * MINUNITMULT;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 210, MBASE(select_jerk.now), HMI_ValueStruct.Max_Jerk_scaled);
EncoderRate.enabled = true;
}
else { // Back
@@ -3493,8 +3483,8 @@ void HMI_Step() {
if (WITHIN(select_step.now, 1, 4)) {
checkkey = Step_value;
HMI_flag.step_axis = AxisEnum(select_step.now - 1);
HMI_ValueStruct.Max_Step = planner.settings.axis_steps_per_mm[HMI_flag.step_axis] * MINUNITMULT;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step);
HMI_ValueStruct.Max_Step_scaled = planner.settings.axis_steps_per_mm[HMI_flag.step_axis] * MINUNITMULT;
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, Select_Color, 3, UNITFDIGITS, 210, MBASE(select_step.now), HMI_ValueStruct.Max_Step_scaled);
EncoderRate.enabled = true;
}
else { // Back
@@ -3545,7 +3535,7 @@ void EachMomentUpdate() {
planner.finish_and_disable();
// show percent bar and value
Percentrecord = 0;
_card_percent = 0;
Draw_Print_ProgressBar();
// show print done confirm
@@ -3563,12 +3553,8 @@ void EachMomentUpdate() {
if (HMI_flag.pause_action && printingIsPaused() && !planner.has_blocks_queued()) {
HMI_flag.pause_action = false;
#if ENABLED(PAUSE_HEAT)
#if HAS_HEATED_BED
tempbed = thermalManager.temp_bed.target;
#endif
#if HAS_HOTEND
temphot = thermalManager.temp_hotend[0].target;
#endif
TERN_(HAS_HOTEND, resume_hotend_temp = thermalManager.temp_hotend[0].target);
TERN_(HAS_HEATED_BED, resume_bed_temp = thermalManager.temp_bed.target);
thermalManager.disable_all_heaters();
#endif
queue.inject_P(PSTR("G1 F1200 X0 Y0"));
@@ -3580,7 +3566,7 @@ void EachMomentUpdate() {
if (last_cardpercentValue != card_pct) { // print percent
last_cardpercentValue = card_pct;
if (card_pct) {
Percentrecord = card_pct;
_card_percent = card_pct;
Draw_Print_ProgressBar();
}
}
@@ -3597,8 +3583,8 @@ void EachMomentUpdate() {
// Estimate remaining time every 20 seconds
static millis_t next_remain_time_update = 0;
if (Percentrecord > 1 && ELAPSED(ms, next_remain_time_update) && !HMI_flag.heat_flag) {
remain_time = (elapsed.value - dwin_heat_time) / (Percentrecord * 0.01f) - (elapsed.value - dwin_heat_time);
if (_card_percent > 1 && ELAPSED(ms, next_remain_time_update) && !HMI_flag.heat_flag) {
_remain_time = (elapsed.value - dwin_heat_time) / (_card_percent * 0.01f) - (elapsed.value - dwin_heat_time);
next_remain_time_update += SEC_TO_MS(20);
Draw_Print_ProgressRemain();
}
+6 -6
View File
@@ -240,13 +240,13 @@ typedef struct {
int16_t print_speed = 100;
float Max_Feedspeed = 0;
float Max_Acceleration = 0;
float Max_Jerk = 0;
float Max_Step = 0;
float Move_X_scale = 0;
float Move_Y_scale = 0;
float Move_Z_scale = 0;
float Max_Jerk_scaled = 0;
float Max_Step_scaled = 0;
float Move_X_scaled = 0;
float Move_Y_scaled = 0;
float Move_Z_scaled = 0;
#if HAS_HOTEND
float Move_E_scale = 0;
float Move_E_scaled = 0;
#endif
float offset_value = 0;
int8_t show_mode = 0; // -1: Temperature control 0: Printing temperature

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